summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.travis.yml6
-rw-r--r--AUTHORS.md4
-rw-r--r--CONTRIBUTING.md10
-rw-r--r--DONORS.md34
-rw-r--r--README.md4
-rw-r--r--SConstruct27
-rw-r--r--core/bind/core_bind.cpp3
-rw-r--r--core/bind/core_bind.h1
-rw-r--r--core/cowdata.h5
-rw-r--r--core/dictionary.cpp5
-rw-r--r--core/dictionary.h1
-rw-r--r--core/dvector.h4
-rw-r--r--core/hash_map.h4
-rw-r--r--core/image.cpp17
-rw-r--r--core/io/image_loader.cpp1
-rw-r--r--core/io/logger.cpp4
-rw-r--r--core/io/marshalls.cpp5
-rw-r--r--core/io/multiplayer_api.cpp4
-rw-r--r--core/io/resource_format_binary.cpp2
-rw-r--r--core/io/resource_loader.cpp2
-rw-r--r--core/io/resource_loader.h4
-rw-r--r--core/math/face3.cpp9
-rw-r--r--core/math/math_funcs.h2
-rw-r--r--core/math/matrix3.cpp20
-rw-r--r--core/math/quat.cpp18
-rw-r--r--core/math/quat.h2
-rw-r--r--core/math/vector2.cpp4
-rw-r--r--core/math/vector2.h2
-rw-r--r--core/math/vector3.h6
-rw-r--r--core/oa_hash_map.h4
-rw-r--r--core/os/input.cpp2
-rw-r--r--core/os/memory.cpp2
-rw-r--r--core/os/rw_lock.h4
-rw-r--r--core/rid.h1
-rw-r--r--core/script_debugger_remote.cpp25
-rw-r--r--core/ustring.cpp19
-rw-r--r--core/variant.cpp2
-rw-r--r--core/variant_call.cpp2
-rw-r--r--core/variant_op.cpp12
-rw-r--r--doc/classes/ArrayMesh.xml2
-rw-r--r--doc/classes/AudioEffectBandLimitFilter.xml2
-rw-r--r--doc/classes/AudioEffectBandPassFilter.xml2
-rw-r--r--doc/classes/AudioEffectHighPassFilter.xml2
-rw-r--r--doc/classes/AudioEffectLowPassFilter.xml2
-rw-r--r--doc/classes/AudioEffectNotchFilter.xml2
-rw-r--r--doc/classes/BaseButton.xml2
-rw-r--r--doc/classes/CheckBox.xml4
-rw-r--r--doc/classes/CheckButton.xml4
-rw-r--r--doc/classes/CollisionShape.xml2
-rw-r--r--doc/classes/CollisionShape2D.xml2
-rw-r--r--doc/classes/Control.xml2
-rw-r--r--doc/classes/FileDialog.xml10
-rw-r--r--doc/classes/Input.xml1
-rw-r--r--doc/classes/KinematicBody.xml2
-rw-r--r--doc/classes/KinematicBody2D.xml2
-rw-r--r--doc/classes/LineEdit.xml2
-rw-r--r--doc/classes/MeshDataTool.xml57
-rw-r--r--doc/classes/NavigationPolygon.xml33
-rw-r--r--doc/classes/Node.xml2
-rw-r--r--doc/classes/PackedScene.xml2
-rw-r--r--doc/classes/ProjectSettings.xml22
-rw-r--r--doc/classes/RichTextLabel.xml18
-rw-r--r--doc/classes/SceneTree.xml4
-rw-r--r--doc/classes/ScriptCreateDialog.xml2
-rw-r--r--doc/classes/SpatialMaterial.xml70
-rw-r--r--doc/classes/SpinBox.xml2
-rw-r--r--doc/classes/StreamPeerSSL.xml2
-rw-r--r--doc/classes/StreamPeerTCP.xml3
-rw-r--r--doc/classes/String.xml1
-rw-r--r--doc/classes/SurfaceTool.xml11
-rw-r--r--doc/classes/TabContainer.xml6
-rw-r--r--doc/classes/Tabs.xml20
-rw-r--r--doc/classes/TextureProgress.xml10
-rw-r--r--doc/classes/TileSet.xml2
-rw-r--r--doc/classes/Tree.xml2
-rw-r--r--doc/classes/TreeItem.xml9
-rw-r--r--doc/classes/Vector2.xml9
-rw-r--r--doc/classes/Vector3.xml11
-rw-r--r--doc/classes/VisualServer.xml2
-rw-r--r--doc/classes/YSort.xml1
-rw-r--r--drivers/coreaudio/audio_driver_coreaudio.cpp213
-rw-r--r--drivers/coreaudio/audio_driver_coreaudio.h4
-rw-r--r--drivers/coremidi/core_midi.cpp6
-rw-r--r--drivers/gles2/rasterizer_gles2.cpp7
-rw-r--r--drivers/gles2/rasterizer_scene_gles2.cpp11
-rw-r--r--drivers/gles2/rasterizer_storage_gles2.h1
-rw-r--r--drivers/gles2/shaders/copy.glsl22
-rw-r--r--drivers/gles2/shaders/scene.glsl111
-rw-r--r--drivers/gles3/rasterizer_gles3.cpp4
-rw-r--r--drivers/gles3/rasterizer_scene_gles3.cpp19
-rw-r--r--drivers/gles3/rasterizer_scene_gles3.h2
-rw-r--r--drivers/gles3/rasterizer_storage_gles3.cpp68
-rw-r--r--drivers/gles3/shader_compiler_gles3.cpp1
-rw-r--r--drivers/gles3/shader_gles3.h12
-rw-r--r--drivers/gles3/shaders/scene.glsl6
-rw-r--r--drivers/pulseaudio/audio_driver_pulseaudio.cpp18
-rw-r--r--drivers/pulseaudio/audio_driver_pulseaudio.h1
-rw-r--r--drivers/rtaudio/audio_driver_rtaudio.cpp2
-rw-r--r--drivers/unix/dir_access_unix.cpp6
-rw-r--r--drivers/unix/net_socket_posix.cpp4
-rw-r--r--drivers/unix/os_unix.cpp6
-rw-r--r--drivers/unix/thread_posix.cpp3
-rw-r--r--drivers/wasapi/audio_driver_wasapi.cpp18
-rw-r--r--drivers/windows/file_access_windows.cpp4
-rw-r--r--editor/animation_track_editor.cpp2
-rw-r--r--editor/audio_stream_preview.cpp4
-rw-r--r--editor/code_editor.cpp2
-rw-r--r--editor/create_dialog.cpp2
-rw-r--r--editor/editor_autoload_settings.cpp2
-rw-r--r--editor/editor_file_dialog.cpp27
-rw-r--r--editor/editor_file_system.cpp12
-rw-r--r--editor/editor_file_system.h2
-rw-r--r--editor/editor_inspector.cpp7
-rw-r--r--editor/editor_node.cpp12
-rw-r--r--editor/editor_profiler.cpp2
-rw-r--r--editor/editor_properties.cpp46
-rw-r--r--editor/editor_properties.h2
-rw-r--r--editor/editor_themes.cpp11
-rw-r--r--editor/filesystem_dock.cpp24
-rw-r--r--editor/find_in_files.cpp25
-rw-r--r--editor/icons/icon_GUI_viewport_hdiagsplitter.svg67
-rw-r--r--editor/icons/icon_GUI_viewport_vdiagsplitter.svg73
-rw-r--r--editor/icons/icon_GUI_viewport_vhsplitter.svg66
-rw-r--r--editor/icons/icon_noise_texture.svg3
-rw-r--r--editor/icons/icon_script_extend.svg8
-rw-r--r--editor/import/editor_import_collada.cpp2
-rw-r--r--editor/import/editor_scene_importer_gltf.cpp12
-rw-r--r--editor/import/resource_importer_scene.cpp34
-rw-r--r--editor/import/resource_importer_scene.h2
-rw-r--r--editor/inspector_dock.cpp15
-rw-r--r--editor/inspector_dock.h1
-rw-r--r--editor/plugin_config_dialog.cpp2
-rw-r--r--editor/plugins/abstract_polygon_2d_editor.cpp24
-rw-r--r--editor/plugins/animation_blend_space_2d_editor.cpp4
-rw-r--r--editor/plugins/asset_library_editor_plugin.cpp3
-rw-r--r--editor/plugins/camera_editor_plugin.cpp12
-rw-r--r--editor/plugins/camera_editor_plugin.h1
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp33
-rw-r--r--editor/plugins/canvas_item_editor_plugin.h6
-rw-r--r--editor/plugins/collision_shape_2d_editor_plugin.cpp53
-rw-r--r--editor/plugins/light_occluder_2d_editor_plugin.cpp30
-rw-r--r--editor/plugins/path_2d_editor_plugin.cpp38
-rw-r--r--editor/plugins/resource_preloader_editor_plugin.cpp71
-rw-r--r--editor/plugins/resource_preloader_editor_plugin.h8
-rw-r--r--editor/plugins/script_editor_plugin.cpp14
-rw-r--r--editor/plugins/script_text_editor.cpp32
-rw-r--r--editor/plugins/spatial_editor_plugin.cpp88
-rw-r--r--editor/plugins/spatial_editor_plugin.h3
-rw-r--r--editor/plugins/tile_map_editor_plugin.cpp93
-rw-r--r--editor/plugins/tile_map_editor_plugin.h2
-rw-r--r--editor/plugins/tile_set_editor_plugin.cpp14
-rw-r--r--editor/project_export.cpp6
-rw-r--r--editor/property_editor.cpp14
-rw-r--r--editor/scene_tree_dock.cpp20
-rw-r--r--editor/scene_tree_editor.cpp2
-rw-r--r--editor/script_editor_debugger.cpp32
-rw-r--r--editor/spatial_editor_gizmos.cpp28
-rw-r--r--main/input_default.cpp35
-rw-r--r--main/input_default.h1
-rw-r--r--main/main.cpp4
-rw-r--r--main/tests/test_oa_hash_map.cpp31
-rw-r--r--main/tests/test_string.cpp173
-rw-r--r--methods.py4
-rw-r--r--modules/bullet/area_bullet.cpp10
-rw-r--r--modules/bullet/area_bullet.h3
-rw-r--r--modules/bullet/bullet_physics_server.cpp22
-rw-r--r--modules/bullet/bullet_physics_server.h7
-rw-r--r--modules/bullet/bullet_utilities.h7
-rw-r--r--modules/bullet/collision_object_bullet.cpp163
-rw-r--r--modules/bullet/collision_object_bullet.h40
-rw-r--r--modules/bullet/godot_motion_state.h2
-rw-r--r--modules/bullet/rigid_body_bullet.cpp42
-rw-r--r--modules/bullet/rigid_body_bullet.h11
-rw-r--r--modules/bullet/shape_bullet.cpp17
-rw-r--r--modules/bullet/shape_owner_bullet.h9
-rw-r--r--modules/bullet/soft_body_bullet.cpp6
-rw-r--r--modules/bullet/soft_body_bullet.h7
-rw-r--r--modules/bullet/space_bullet.cpp29
-rw-r--r--modules/csg/csg.cpp4
-rw-r--r--modules/csg/csg_shape.cpp7
-rw-r--r--modules/enet/doc_classes/NetworkedMultiplayerENet.xml2
-rw-r--r--modules/gdnative/nativescript/api_generator.cpp1
-rw-r--r--modules/gdnative/nativescript/nativescript.cpp13
-rw-r--r--modules/gdnative/nativescript/nativescript.h23
-rw-r--r--modules/gdscript/editor/gdscript_highlighter.cpp18
-rw-r--r--modules/gdscript/gdscript_compiler.cpp20
-rw-r--r--modules/gdscript/gdscript_compiler.h10
-rw-r--r--modules/gdscript/gdscript_function.cpp72
-rw-r--r--modules/gdscript/gdscript_function.h10
-rw-r--r--modules/gdscript/gdscript_parser.cpp10
-rw-r--r--modules/gdscript/gdscript_tokenizer.cpp2
-rw-r--r--modules/mono/SCsub26
-rw-r--r--modules/mono/config.py180
-rw-r--r--modules/mono/csharp_script.cpp6
-rw-r--r--modules/mono/doc_classes/GodotSharp.xml34
-rw-r--r--modules/mono/editor/GodotSharpTools/Editor/GodotSharpExport.cs74
-rw-r--r--modules/mono/editor/GodotSharpTools/GodotSharpTools.csproj1
-rw-r--r--modules/mono/editor/bindings_generator.cpp235
-rw-r--r--modules/mono/editor/bindings_generator.h29
-rw-r--r--modules/mono/editor/csharp_project.cpp8
-rw-r--r--modules/mono/editor/godotsharp_builds.cpp53
-rw-r--r--modules/mono/editor/godotsharp_editor.cpp34
-rw-r--r--modules/mono/editor/godotsharp_editor.h2
-rw-r--r--modules/mono/editor/godotsharp_export.cpp146
-rw-r--r--modules/mono/editor/godotsharp_export.h4
-rw-r--r--modules/mono/editor/mono_bottom_panel.cpp2
-rw-r--r--modules/mono/glue/Managed/Files/Extensions/NodeExtensions.cs24
-rw-r--r--modules/mono/glue/Managed/Files/Extensions/ResourceLoaderExtensions.cs4
-rw-r--r--modules/mono/glue/Managed/Files/GD.cs4
-rw-r--r--modules/mono/glue/nodepath_glue.cpp2
-rw-r--r--modules/mono/glue/rid_glue.cpp2
-rw-r--r--modules/mono/godotsharp_dirs.cpp89
-rw-r--r--modules/mono/godotsharp_dirs.h11
-rw-r--r--modules/mono/mono_gd/gd_mono.cpp184
-rw-r--r--modules/mono/mono_gd/gd_mono.h46
-rw-r--r--modules/mono/mono_gd/gd_mono_assembly.cpp148
-rw-r--r--modules/mono/mono_gd/gd_mono_assembly.h3
-rw-r--r--modules/mono/mono_gd/gd_mono_field.cpp316
-rw-r--r--modules/mono/mono_gd/gd_mono_header.h10
-rw-r--r--modules/mono/mono_gd/gd_mono_marshal.cpp317
-rw-r--r--modules/mono/mono_gd/gd_mono_marshal.h285
-rw-r--r--modules/mono/utils/macros.h9
-rw-r--r--modules/opensimplex/doc_classes/NoiseTexture.xml18
-rw-r--r--modules/thekla_unwrap/config.py3
-rw-r--r--modules/theora/video_stream_theora.cpp1
-rw-r--r--modules/visual_script/visual_script.cpp20
-rw-r--r--modules/visual_script/visual_script.h1
-rw-r--r--modules/visual_script/visual_script_editor.cpp10
-rw-r--r--modules/visual_script/visual_script_editor.h2
-rw-r--r--modules/visual_script/visual_script_nodes.cpp18
-rw-r--r--modules/visual_script/visual_script_property_selector.cpp62
-rw-r--r--modules/webm/video_stream_webm.cpp1
-rw-r--r--modules/websocket/emws_server.cpp3
-rw-r--r--modules/websocket/lws_client.cpp21
-rw-r--r--modules/websocket/websocket_multiplayer.cpp2
-rw-r--r--modules/xatlas_unwrap/config.py4
-rw-r--r--modules/xatlas_unwrap/register_types.cpp18
-rw-r--r--platform/android/build.gradle.template11
-rw-r--r--platform/android/godot_android.cpp2
-rw-r--r--platform/android/java/gradle/wrapper/gradle-wrapper.properties2
-rw-r--r--platform/android/java_glue.cpp4
-rw-r--r--platform/haiku/haiku_direct_window.cpp2
-rw-r--r--platform/iphone/gl_view.mm12
-rw-r--r--platform/javascript/engine.js3
-rw-r--r--platform/javascript/pre.js3
-rw-r--r--platform/osx/os_osx.mm58
-rw-r--r--platform/server/os_server.cpp2
-rw-r--r--platform/uwp/os_uwp.cpp2
-rw-r--r--platform/windows/context_gl_win.cpp24
-rw-r--r--platform/windows/joypad.cpp2
-rw-r--r--platform/windows/os_windows.cpp25
-rw-r--r--platform/x11/godot_x11.cpp5
-rw-r--r--platform/x11/os_x11.cpp6
-rw-r--r--scene/2d/animated_sprite.cpp10
-rw-r--r--scene/2d/animated_sprite.h1
-rw-r--r--scene/2d/audio_stream_player_2d.cpp2
-rw-r--r--scene/2d/camera_2d.cpp8
-rw-r--r--scene/2d/collision_polygon_2d.cpp2
-rw-r--r--scene/2d/cpu_particles_2d.cpp2
-rw-r--r--scene/2d/node_2d.cpp6
-rw-r--r--scene/2d/node_2d.h2
-rw-r--r--scene/2d/tile_map.cpp4
-rw-r--r--scene/3d/audio_stream_player_3d.cpp6
-rw-r--r--scene/3d/baked_lightmap.cpp69
-rw-r--r--scene/3d/cpu_particles.cpp23
-rw-r--r--scene/3d/cpu_particles.h2
-rw-r--r--scene/3d/light.cpp9
-rw-r--r--scene/3d/mesh_instance.cpp6
-rw-r--r--scene/3d/mesh_instance.h1
-rw-r--r--scene/3d/voxel_light_baker.cpp14
-rw-r--r--scene/animation/animation_blend_space_2d.cpp2
-rw-r--r--scene/gui/base_button.cpp2
-rw-r--r--scene/gui/color_picker.cpp3
-rw-r--r--scene/gui/control.cpp18
-rw-r--r--scene/gui/gradient_edit.cpp14
-rw-r--r--scene/gui/graph_edit.cpp12
-rw-r--r--scene/gui/graph_edit.h2
-rw-r--r--scene/gui/grid_container.cpp17
-rw-r--r--scene/gui/grid_container.h1
-rw-r--r--scene/gui/label.cpp4
-rw-r--r--scene/gui/line_edit.cpp4
-rw-r--r--scene/gui/nine_patch_rect.cpp4
-rw-r--r--scene/gui/tabs.cpp81
-rw-r--r--scene/gui/tabs.h2
-rw-r--r--scene/gui/text_edit.cpp13
-rw-r--r--scene/gui/texture_progress.cpp10
-rw-r--r--scene/gui/tree.cpp7
-rw-r--r--scene/main/node.cpp2
-rw-r--r--scene/resources/animation.cpp2
-rw-r--r--scene/resources/convex_polygon_shape.cpp3
-rw-r--r--scene/resources/dynamic_font.cpp4
-rw-r--r--scene/resources/particles_material.cpp2
-rw-r--r--scene/resources/shape.cpp2
-rw-r--r--scene/resources/style_box.cpp34
-rw-r--r--servers/audio/audio_stream.cpp16
-rw-r--r--servers/audio/audio_stream.h2
-rw-r--r--servers/audio/effects/reverb.cpp24
-rw-r--r--servers/audio_server.cpp9
-rw-r--r--servers/audio_server.h1
-rw-r--r--servers/physics/collision_solver_sat.cpp1
-rw-r--r--servers/physics/collision_solver_sw.cpp1
-rw-r--r--servers/physics/joints/generic_6dof_joint_sw.cpp2
-rw-r--r--servers/physics/joints/generic_6dof_joint_sw.h6
-rw-r--r--servers/physics/shape_sw.cpp2
-rw-r--r--servers/physics_2d/body_pair_2d_sw.cpp2
-rw-r--r--servers/physics_2d/step_2d_sw.cpp2
-rw-r--r--servers/visual/shader_language.cpp1
-rw-r--r--servers/visual/shader_types.cpp1
-rw-r--r--servers/visual/visual_server_canvas.cpp2
-rw-r--r--servers/visual/visual_server_scene.cpp10
-rw-r--r--servers/visual/visual_server_scene.h5
311 files changed, 3866 insertions, 2359 deletions
diff --git a/.travis.yml b/.travis.yml
index 7161a3e029..a5217c1d9c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -29,7 +29,7 @@ matrix:
- clang-format-6.0
- libstdc++6 # >= 4.9 needed for clang-format-6.0
- - env: PLATFORM=x11 TOOLS=yes TARGET=debug CACHE_NAME=${PLATFORM}-tools-mono-gcc EXTRA_ARGS="module_mono_enabled=yes mono_glue=no"
+ - env: PLATFORM=x11 TOOLS=yes TARGET=debug CACHE_NAME=${PLATFORM}-tools-mono-gcc EXTRA_ARGS="module_mono_enabled=yes mono_glue=no werror=yes"
os: linux
compiler: gcc
addons:
@@ -49,7 +49,7 @@ matrix:
build_command: "scons p=x11 -j2 $OPTIONS"
branch_pattern: coverity_scan
- - env: PLATFORM=x11 TOOLS=no TARGET=release CACHE_NAME=${PLATFORM}-clang
+ - env: PLATFORM=x11 TOOLS=no TARGET=release CACHE_NAME=${PLATFORM}-clang EXTRA_ARGS="werror=yes"
os: linux
compiler: clang
addons:
@@ -57,7 +57,7 @@ matrix:
packages:
- *linux_deps
- - env: PLATFORM=android TOOLS=no TARGET=release_debug CACHE_NAME=${PLATFORM}-clang
+ - env: PLATFORM=android TOOLS=no TARGET=release_debug CACHE_NAME=${PLATFORM}-clang EXTRA_ARGS="werror=yes"
os: linux
compiler: clang
diff --git a/AUTHORS.md b/AUTHORS.md
index 9666145582..13a67ce3f5 100644
--- a/AUTHORS.md
+++ b/AUTHORS.md
@@ -45,9 +45,11 @@ name is available.
Bojidar Marinov (bojidar-bg)
bruvzg
Carl Olsson (not-surt)
+ Chris Bradfield (cbscribe)
Dana Olson (adolson)
Daniel J. Ramirez (djrm)
Dmitry Koteroff (Krakean)
+ DualMatrix
Emmanuel Leblond (touilleMan)
Eric Lasota (elasota)
est31
@@ -111,9 +113,9 @@ name is available.
Ramesh Ravone (RameshRavone)
Ray Koopa (RayKoopa)
Rémi Verschelde (akien-mga)
+ Rhody Lugo (rraallvv)
Roberto F. Arroyo (robfram)
romulox-x
- rraallvv
Ruslan Mustakov (endragor)
Saniko (sanikoyes)
SaracenOne
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 68ec20a525..2ea2ed6bba 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -70,11 +70,15 @@ Similar rules can be applied when contributing bug fixes - it's always best to
discuss the implementation in the bug report first if you are not 100% about
what would be the best fix.
+In addition to the following tips, also take a look at the
+[Engine development guide](http://docs.godotengine.org/en/latest/development/cpp/)
+for an introduction to developing on Godot.
+
#### Be nice to the git history
-Try to make simple PRs with that handle one specific topic. Just like for
-reporting issues, it's better to open 3 different PRs that each address a
-different issue than one big PR with three commits.
+Try to make simple PRs that handle one specific topic. Just like for reporting
+issues, it's better to open 3 different PRs that each address a different issue
+than one big PR with three commits.
When updating your fork with upstream changes, please use ``git pull --rebase``
to avoid creating "merge commits". Those commits unnecessarily pollute the git
diff --git a/DONORS.md b/DONORS.md
index 41d24c5fbb..6fdb02e3fa 100644
--- a/DONORS.md
+++ b/DONORS.md
@@ -21,40 +21,43 @@ generous deed immortalized in the next stable release of Godot Engine.
## Mini sponsors
+ Andrew Dunai
Brandon Lamb
Christian Uldall Pedersen
Christopher Igoe
Christoph Woinke
GameDev.net
Hein-Pieter van Braam
+ iDev.Network Studios
Jamal Alyafei
Jay Sistar
+ Leona Eden
Matthieu Huvé
Mike King
Nathan Warden
Neal Gompa (Conan Kudo)
Pascal Julien
Patrick Aarstad
- rottis
Ruslan Mustakov
Slobodan Milnovic
Stephan Lanfermann
Stoney Meyerhoeffer
+ thechris
Thomas Mathews
VilliHaukka
## Gold donors
- 3Dexplorer
Asdf
cheese65536
K9Kraken
- Kris Michael
Manuele Finocchiaro
Nathanael Beisiegel
Officine Pixel S.n.c.
+ Retro Village
Zaven Muradyan
+ 13MHz
Allen Schade
Andreas Schüle
Austen McRae
@@ -62,12 +65,14 @@ generous deed immortalized in the next stable release of Godot Engine.
David Gehrig
Florian Breisch
Gary Oberbrunner
+ Jay Horton
Johannes Wuensch
Josep G. Camarasa
Joshua Lesperance
Krzysztof Dluzniewski
Kyle Szklenski
Mohammad Taleb
+ Moonwards
Paul LaMotte
Ranoller
Sergey
@@ -91,7 +96,6 @@ generous deed immortalized in the next stable release of Godot Engine.
Rami
Robert Willes
Robin Arys
- Rodrigo Loli
Ronnie Ashlock
ScottMakesGames
Thomas Bjarnelöf
@@ -102,8 +106,8 @@ generous deed immortalized in the next stable release of Godot Engine.
Alessandra Pereyra
Alexey Dyadchenko
Amanda Haldy
- Anthony Ryan
Branwen Danielle Zakariasen
+ Chau Siu Hung
Chris Brown
Chris Petrich
Cody Parker
@@ -112,15 +116,16 @@ generous deed immortalized in the next stable release of Godot Engine.
E.G.
Eric
Eric Monson
+ Ethan Bennis
Fidget Sinner
flesk
G Barnes
+ Gero
GGGames.org
Giovanni Solimeno
Guilherme Felipe de C. G. da Silva
Hasen Judy
Heath Hayes
- Jay Horton
Jeppe Zapp
joe513
Juraj Móza
@@ -130,10 +135,8 @@ generous deed immortalized in the next stable release of Godot Engine.
Markus Wiesner
Marvin
Nahuel Sacchetti
- Neal Barry
Nick Nikitin
Pablo Cholaky
- Patrick Schnorbus
Pete Goodwin
ray-tracer
Ruben Soares Luis
@@ -141,10 +144,9 @@ generous deed immortalized in the next stable release of Godot Engine.
Sindre Sømme
Sofox
Stoned Xander
- Tim Dalporto
Trent McPheron
- Wilfrid ARNOLD
WytRabbit
+ Zachariah Gibbons
## Silver donors
@@ -177,7 +179,6 @@ generous deed immortalized in the next stable release of Godot Engine.
Christian Baune
Christian Winter
Christopher Schmitt
- Chris Wilson
Collin Shooltz
Daniel Johnson
Daniel Kaplan
@@ -187,16 +188,14 @@ generous deed immortalized in the next stable release of Godot Engine.
David May
Disktra
Dominik Wetzel
- dRez Games
Duy Kevin Nguyen
Edward Herbert
Elias Nykrem
Eric Martini
Eugenio Hugo Salgüero Jáñez
- Extarys
Fabian Becker
fengjiongmax
- Francesco Lisi
+ Foomf
G3Dev sàrl
Gerrit Großkopf
Gilberto K. Otubo
@@ -207,7 +206,6 @@ generous deed immortalized in the next stable release of Godot Engine.
ialex32x
Jahn Johansen
Jaime Ruiz-Borau Vizárraga
- Jed
Jeff Hungerford
Joel Fivat
Johan Lindberg
@@ -237,7 +235,6 @@ generous deed immortalized in the next stable release of Godot Engine.
magodev
Manolis Makris
Martin Eigel
- Martins Odabi
Max R.R. Collada
Maxwell
Mertcan Mermerkaya
@@ -256,14 +253,15 @@ generous deed immortalized in the next stable release of Godot Engine.
Nicolas SAN AGUSTIN
Niko Leopold
Noi Sek
- Pablo Seibelt
Pan Ip
Pascal Grüter
Pat LaBine
Patrick Nafarrete
Paul E Hansen
+ Paul Gieske
Paul Mason
Paweł Kowal
+ Phillip Ryals
Pierre-Igor Berthet
Pietro Vertechi
Piotr Kaczmarski
@@ -287,9 +285,11 @@ generous deed immortalized in the next stable release of Godot Engine.
Tim
Tom Larrow
Tristan Crawford
+ Tryggve Sollid
Trym Nilsen
Tyler Stafos
UltyX
+ Vaiktorg
Victor
Viktor Ferenczi
waka nya
diff --git a/README.md b/README.md
index 8ad738c23d..b34b9e8702 100644
--- a/README.md
+++ b/README.md
@@ -40,7 +40,7 @@ Official binaries for the Godot editor and the export templates can be found
[See the official docs](http://docs.godotengine.org/en/latest/development/compiling/)
for compilation instructions for every supported platform.
-### Community
+### Community and contributing
Godot is not only an engine but an ever-growing community of users and engine
developers. The main community channels are listed [on the homepage](https://godotengine.org/community).
@@ -49,6 +49,8 @@ To get in touch with the developers, the best way is to join the
[#godotengine IRC channel](https://webchat.freenode.net/?channels=godotengine)
on Freenode.
+To get started contributing to the project, see the [contributing guide](CONTRIBUTING.md).
+
### Documentation and demos
The official documentation is hosted on [ReadTheDocs](http://docs.godotengine.org).
diff --git a/SConstruct b/SConstruct
index f1587e0280..f8c1c82961 100644
--- a/SConstruct
+++ b/SConstruct
@@ -159,15 +159,16 @@ opts.Add(BoolVariable('minizip', "Enable ZIP archive support using minizip", Tru
opts.Add(BoolVariable('xaudio2', "Enable the XAudio2 audio driver", False))
# Advanced options
-opts.Add(BoolVariable('disable_3d', "Disable 3D nodes for a smaller executable", False))
-opts.Add(BoolVariable('disable_advanced_gui', "Disable advanced 3D GUI nodes and behaviors", False))
-opts.Add('extra_suffix', "Custom extra suffix added to the base filename of all generated binary files", '')
opts.Add(BoolVariable('verbose', "Enable verbose output for the compilation", False))
-opts.Add(BoolVariable('vsproj', "Generate a Visual Studio solution", False))
-opts.Add(EnumVariable('warnings', "Set the level of warnings emitted during compilation", 'no', ('extra', 'all', 'moderate', 'no')))
opts.Add(BoolVariable('progress', "Show a progress indicator during compilation", True))
+opts.Add(EnumVariable('warnings', "Set the level of warnings emitted during compilation", 'all', ('extra', 'all', 'moderate', 'no')))
+opts.Add(BoolVariable('werror', "Treat compiler warnings as errors. Depends on the level of warnings set with 'warnings'", False))
opts.Add(BoolVariable('dev', "If yes, alias for verbose=yes warnings=all", False))
+opts.Add('extra_suffix', "Custom extra suffix added to the base filename of all generated binary files", '')
+opts.Add(BoolVariable('vsproj', "Generate a Visual Studio solution", False))
opts.Add(EnumVariable('macports_clang', "Build using Clang from MacPorts", 'no', ('no', '5.0', 'devel')))
+opts.Add(BoolVariable('disable_3d', "Disable 3D nodes for a smaller executable", False))
+opts.Add(BoolVariable('disable_advanced_gui', "Disable advanced 3D GUI nodes and behaviors", False))
opts.Add(BoolVariable('no_editor_splash', "Don't use the custom splash screen for the editor", False))
opts.Add('system_certs_path', "Use this path as SSL certificates default for editor (for package maintainers)", '')
@@ -235,7 +236,6 @@ env_base.platform_apis = platform_apis
if (env_base['target'] == 'debug'):
env_base.Append(CPPDEFINES=['DEBUG_MEMORY_ALLOC','DISABLE_FORCED_INLINE'])
-
if (env_base['no_editor_splash']):
env_base.Append(CPPDEFINES=['NO_EDITOR_SPLASH'])
@@ -318,15 +318,13 @@ if selected_platform in platform_list:
# must happen after the flags, so when flags are used by configure, stuff happens (ie, ssl on x11)
detect.configure(env)
- if (env["warnings"] == 'yes'):
- print("WARNING: warnings=yes is deprecated; assuming warnings=all")
-
+ # Configure compiler warnings
if env.msvc:
# Truncations, narrowing conversions, signed/unsigned comparisons...
disable_nonessential_warnings = ['/wd4267', '/wd4244', '/wd4305', '/wd4018', '/wd4800']
if (env["warnings"] == 'extra'):
env.Append(CCFLAGS=['/Wall']) # Implies /W4
- elif (env["warnings"] == 'all' or env["warnings"] == 'yes'):
+ elif (env["warnings"] == 'all'):
env.Append(CCFLAGS=['/W3'] + disable_nonessential_warnings)
elif (env["warnings"] == 'moderate'):
env.Append(CCFLAGS=['/W2'] + disable_nonessential_warnings)
@@ -334,17 +332,22 @@ if selected_platform in platform_list:
env.Append(CCFLAGS=['/w'])
# Set exception handling model to avoid warnings caused by Windows system headers.
env.Append(CCFLAGS=['/EHsc'])
+ if (env["werror"]):
+ env.Append(CCFLAGS=['/WX'])
else: # Rest of the world
disable_nonessential_warnings = ['-Wno-sign-compare']
if (env["warnings"] == 'extra'):
env.Append(CCFLAGS=['-Wall', '-Wextra'])
- elif (env["warnings"] == 'all' or env["warnings"] == 'yes'):
+ elif (env["warnings"] == 'all'):
env.Append(CCFLAGS=['-Wall'] + disable_nonessential_warnings)
elif (env["warnings"] == 'moderate'):
env.Append(CCFLAGS=['-Wall', '-Wno-unused'] + disable_nonessential_warnings)
else: # 'no'
env.Append(CCFLAGS=['-w'])
- env.Append(CCFLAGS=['-Werror=return-type'])
+ if (env["werror"]):
+ env.Append(CCFLAGS=['-Werror'])
+ else: # always enable those errors
+ env.Append(CCFLAGS=['-Werror=return-type'])
suffix = "." + selected_platform
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp
index 57654e96dc..a3ff4bf13e 100644
--- a/core/bind/core_bind.cpp
+++ b/core/bind/core_bind.cpp
@@ -180,6 +180,7 @@ void _ResourceSaver::_bind_methods() {
BIND_ENUM_CONSTANT(FLAG_OMIT_EDITOR_PROPERTIES);
BIND_ENUM_CONSTANT(FLAG_SAVE_BIG_ENDIAN);
BIND_ENUM_CONSTANT(FLAG_COMPRESS);
+ BIND_ENUM_CONSTANT(FLAG_REPLACE_SUBRESOURCE_PATHS);
}
_ResourceSaver::_ResourceSaver() {
@@ -2487,7 +2488,7 @@ _Thread::~_Thread() {
if (active) {
ERR_EXPLAIN("Reference to a Thread object object was lost while the thread is still running...");
}
- ERR_FAIL_COND(active == true);
+ ERR_FAIL_COND(active);
}
/////////////////////////////////////
diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h
index 3a913e01ed..79403879ac 100644
--- a/core/bind/core_bind.h
+++ b/core/bind/core_bind.h
@@ -80,6 +80,7 @@ public:
FLAG_OMIT_EDITOR_PROPERTIES = 8,
FLAG_SAVE_BIG_ENDIAN = 16,
FLAG_COMPRESS = 32,
+ FLAG_REPLACE_SUBRESOURCE_PATHS = 64,
};
static _ResourceSaver *get_singleton() { return singleton; }
diff --git a/core/cowdata.h b/core/cowdata.h
index 9e75d4ed55..54ece4c856 100644
--- a/core/cowdata.h
+++ b/core/cowdata.h
@@ -87,7 +87,10 @@ private:
#if defined(_add_overflow) && defined(_mul_overflow)
size_t o;
size_t p;
- if (_mul_overflow(p_elements, sizeof(T), &o)) return false;
+ if (_mul_overflow(p_elements, sizeof(T), &o)) {
+ *out = 0;
+ return false;
+ }
*out = next_power_of_2(o);
if (_add_overflow(o, static_cast<size_t>(32), &p)) return false; //no longer allocated here
return true;
diff --git a/core/dictionary.cpp b/core/dictionary.cpp
index ba32606819..ccbdff3816 100644
--- a/core/dictionary.cpp
+++ b/core/dictionary.cpp
@@ -145,6 +145,11 @@ 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)
diff --git a/core/dictionary.h b/core/dictionary.h
index 9950fb6361..d3b98c2f63 100644
--- a/core/dictionary.h
+++ b/core/dictionary.h
@@ -69,6 +69,7 @@ public:
bool erase(const Variant &p_key);
bool operator==(const Dictionary &p_dictionary) const;
+ bool operator!=(const Dictionary &p_dictionary) const;
uint32_t hash() const;
void operator=(const Dictionary &p_dictionary);
diff --git a/core/dvector.h b/core/dvector.h
index 0d0848a19a..2830c57ec0 100644
--- a/core/dvector.h
+++ b/core/dvector.h
@@ -149,7 +149,7 @@ class PoolVector {
}
}
- if (old_alloc->refcount.unref() == true) {
+ if (old_alloc->refcount.unref()) {
//this should never happen but..
#ifdef DEBUG_ENABLED
@@ -209,7 +209,7 @@ class PoolVector {
if (!alloc)
return;
- if (alloc->refcount.unref() == false) {
+ if (!alloc->refcount.unref()) {
alloc = NULL;
return;
}
diff --git a/core/hash_map.h b/core/hash_map.h
index 8620edba73..3869cd3c36 100644
--- a/core/hash_map.h
+++ b/core/hash_map.h
@@ -150,7 +150,7 @@ private:
if (new_hash_table_power == -1)
return;
- Element **new_hash_table = memnew_arr(Element *, (1 << new_hash_table_power));
+ Element **new_hash_table = memnew_arr(Element *, ((uint64_t)1 << new_hash_table_power));
if (!new_hash_table) {
ERR_PRINT("Out of Memory");
@@ -230,7 +230,7 @@ private:
if (!p_t.hash_table || p_t.hash_table_power == 0)
return; /* not copying from empty table */
- hash_table = memnew_arr(Element *, 1 << p_t.hash_table_power);
+ 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;
diff --git a/core/image.cpp b/core/image.cpp
index e90ed96499..172f5e517a 100644
--- a/core/image.cpp
+++ b/core/image.cpp
@@ -780,9 +780,9 @@ void Image::resize(int p_width, int p_height, Interpolation p_interpolation) {
// Setup mipmap-aware scaling
Image dst2;
- int mip1;
- int mip2;
- float mip1_weight;
+ int mip1 = 0;
+ int mip2 = 0;
+ float mip1_weight = 0;
if (mipmap_aware) {
float avg_scale = ((float)p_width / width + (float)p_height / height) * 0.5f;
if (avg_scale >= 1.0f) {
@@ -1198,7 +1198,9 @@ void Image::expand_x2_hq2x() {
if (current != FORMAT_RGBA8)
convert(current);
- if (used_mipmaps) {
+ // 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();
}
}
@@ -1471,7 +1473,8 @@ 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, size_height;
+ int size_width = 0;
+ int size_height = 0;
int pixelchars = 0;
mipmaps = false;
bool has_alpha = false;
@@ -1487,8 +1490,8 @@ void Image::create(const char **p_xpm) {
int line = 0;
HashMap<String, Color> colormap;
- int colormap_size;
- uint32_t pixel_size;
+ int colormap_size = 0;
+ uint32_t pixel_size = 0;
PoolVector<uint8_t>::Write w;
while (status != DONE) {
diff --git a/core/io/image_loader.cpp b/core/io/image_loader.cpp
index f202320043..3ae9ff676c 100644
--- a/core/io/image_loader.cpp
+++ b/core/io/image_loader.cpp
@@ -118,7 +118,6 @@ RES ResourceFormatLoaderImage::load(const String &p_path, const String &p_origin
if (r_error) {
*r_error = ERR_CANT_OPEN;
}
- memdelete(f);
return RES();
}
diff --git a/core/io/logger.cpp b/core/io/logger.cpp
index 051c02ab32..01755c8ee9 100644
--- a/core/io/logger.cpp
+++ b/core/io/logger.cpp
@@ -45,6 +45,10 @@
#endif
#endif
+#if defined(MINGW_ENABLED) || defined(_MSC_VER)
+#define sprintf sprintf_s
+#endif
+
bool Logger::should_log(bool p_err) {
return (!p_err || _print_error_enabled) && (p_err || _print_line_enabled);
}
diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp
index ec430d41a9..6338cee39d 100644
--- a/core/io/marshalls.cpp
+++ b/core/io/marshalls.cpp
@@ -850,17 +850,16 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
} break;
case Variant::INT: {
- int64_t val = p_variant;
if (flags & ENCODE_FLAG_64) {
//64 bits
if (buf) {
- encode_uint64(val, buf);
+ encode_uint64(p_variant.operator int64_t(), buf);
}
r_len += 8;
} else {
if (buf) {
- encode_uint32(int32_t(val), buf);
+ encode_uint32(p_variant.operator int32_t(), buf);
}
r_len += 4;
diff --git a/core/io/multiplayer_api.cpp b/core/io/multiplayer_api.cpp
index 17b77bc535..b3f0a76a80 100644
--- a/core/io/multiplayer_api.cpp
+++ b/core/io/multiplayer_api.cpp
@@ -416,7 +416,7 @@ bool MultiplayerAPI::_send_confirm_path(NodePath p_path, PathSentCache *psc, int
Map<int, bool>::Element *F = psc->confirmed_peers.find(E->get());
- if (!F || F->get() == false) {
+ if (!F || !F->get()) {
// Path was not cached, or was cached but is unconfirmed.
if (!F) {
// Not cached at all, take note.
@@ -578,7 +578,7 @@ void MultiplayerAPI::_send_rpc(Node *p_from, int p_to, bool p_unreliable, bool p
network_peer->set_target_peer(E->get()); // To this one specifically.
- if (F->get() == true) {
+ if (F->get()) {
// This one confirmed path, so use id.
encode_uint32(psc->id, &(packet_cache.write[1]));
network_peer->put_packet(packet_cache.ptr(), ofs);
diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp
index e5741014a4..aa73d7bc5c 100644
--- a/core/io/resource_format_binary.cpp
+++ b/core/io/resource_format_binary.cpp
@@ -1309,7 +1309,7 @@ void ResourceFormatSaverBinaryInstance::write_variant(FileAccess *f, const Varia
case Variant::INT: {
int64_t val = p_property;
- if (val > 0x7FFFFFFF || val < -0x80000000) {
+ if (val > 0x7FFFFFFF || val < -(int64_t)0x80000000) {
f->store_32(VARIANT_INT64);
f->store_64(val);
diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp
index 8c56d55e85..d156a9f4bd 100644
--- a/core/io/resource_loader.cpp
+++ b/core/io/resource_loader.cpp
@@ -647,3 +647,5 @@ bool ResourceLoader::timestamp_on_load = false;
SelfList<Resource>::List ResourceLoader::remapped_list;
HashMap<String, Vector<String> > ResourceLoader::translation_remaps;
HashMap<String, String> ResourceLoader::path_remaps;
+
+ResourceLoaderImport ResourceLoader::import = NULL;
diff --git a/core/io/resource_loader.h b/core/io/resource_loader.h
index de0981350d..96bc6fa8dd 100644
--- a/core/io/resource_loader.h
+++ b/core/io/resource_loader.h
@@ -77,6 +77,8 @@ public:
typedef void (*ResourceLoadErrorNotify)(void *p_ud, const String &p_text);
typedef void (*DependencyErrorNotify)(void *p_ud, const String &p_loading, const String &p_which, const String &p_type);
+typedef Error (*ResourceLoaderImport)(const String &p_path);
+
class ResourceLoader {
enum {
@@ -147,6 +149,8 @@ public:
static void reload_translation_remaps();
static void load_translation_remaps();
static void clear_translation_remaps();
+
+ static ResourceLoaderImport import;
};
#endif
diff --git a/core/math/face3.cpp b/core/math/face3.cpp
index aa46fde7f7..8366137131 100644
--- a/core/math/face3.cpp
+++ b/core/math/face3.cpp
@@ -202,11 +202,12 @@ bool Face3::intersects_aabb(const AABB &p_aabb) const {
{ \
real_t aabb_min = p_aabb.position.m_ax; \
real_t aabb_max = p_aabb.position.m_ax + p_aabb.size.m_ax; \
- real_t tri_min, tri_max; \
- for (int i = 0; i < 3; i++) { \
- if (i == 0 || vertex[i].m_ax > tri_max) \
+ real_t tri_min = vertex[0].m_ax; \
+ real_t tri_max = vertex[0].m_ax; \
+ for (int i = 1; i < 3; i++) { \
+ if (vertex[i].m_ax > tri_max) \
tri_max = vertex[i].m_ax; \
- if (i == 0 || vertex[i].m_ax < tri_min) \
+ if (vertex[i].m_ax < tri_min) \
tri_min = vertex[i].m_ax; \
} \
\
diff --git a/core/math/math_funcs.h b/core/math/math_funcs.h
index 472baf0484..9a486a49d0 100644
--- a/core/math/math_funcs.h
+++ b/core/math/math_funcs.h
@@ -46,7 +46,7 @@ class Math {
public:
Math() {} // useless to instance
- static const uint64_t RANDOM_MAX = 4294967295;
+ static const uint64_t RANDOM_MAX = 0xFFFFFFFF;
static _ALWAYS_INLINE_ double sin(double p_x) { return ::sin(p_x); }
static _ALWAYS_INLINE_ float sin(float p_x) { return ::sinf(p_x); }
diff --git a/core/math/matrix3.cpp b/core/math/matrix3.cpp
index fca54b1556..925a7b3f1e 100644
--- a/core/math/matrix3.cpp
+++ b/core/math/matrix3.cpp
@@ -299,14 +299,14 @@ Vector3 Basis::rotref_posscale_decomposition(Basis &rotref) const {
ERR_FAIL_COND_V(determinant() == 0, Vector3());
Basis m = transposed() * (*this);
- ERR_FAIL_COND_V(m.is_diagonal() == false, Vector3());
+ ERR_FAIL_COND_V(!m.is_diagonal(), Vector3());
#endif
Vector3 scale = get_scale();
Basis inv_scale = Basis().scaled(scale.inverse()); // this will also absorb the sign of scale
rotref = (*this) * inv_scale;
#ifdef MATH_CHECKS
- ERR_FAIL_COND_V(rotref.is_orthogonal() == false, Vector3());
+ ERR_FAIL_COND_V(!rotref.is_orthogonal(), Vector3());
#endif
return scale.abs();
}
@@ -430,7 +430,7 @@ Vector3 Basis::get_euler_xyz() const {
Vector3 euler;
#ifdef MATH_CHECKS
- ERR_FAIL_COND_V(is_rotation() == false, euler);
+ ERR_FAIL_COND_V(!is_rotation(), euler);
#endif
real_t sy = elements[0][2];
if (sy < 1.0) {
@@ -497,7 +497,7 @@ Vector3 Basis::get_euler_yxz() const {
Vector3 euler;
#ifdef MATH_CHECKS
- ERR_FAIL_COND_V(is_rotation() == false, euler);
+ ERR_FAIL_COND_V(!is_rotation(), euler);
#endif
real_t m12 = elements[1][2];
@@ -556,7 +556,7 @@ bool Basis::is_equal_approx(const Basis &a, const Basis &b) const {
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
- if (Math::is_equal_approx(a.elements[i][j], b.elements[i][j]) == false)
+ if (!Math::is_equal_approx(a.elements[i][j], b.elements[i][j]))
return false;
}
}
@@ -600,7 +600,7 @@ Basis::operator String() const {
Quat Basis::get_quat() const {
#ifdef MATH_CHECKS
- ERR_FAIL_COND_V(is_rotation() == false, Quat());
+ ERR_FAIL_COND_V(!is_rotation(), Quat());
#endif
real_t trace = elements[0][0] + elements[1][1] + elements[2][2];
real_t temp[4];
@@ -697,7 +697,7 @@ void Basis::set_orthogonal_index(int p_index) {
void Basis::get_axis_angle(Vector3 &r_axis, real_t &r_angle) const {
#ifdef MATH_CHECKS
- ERR_FAIL_COND(is_rotation() == false);
+ ERR_FAIL_COND(!is_rotation());
#endif
real_t angle, x, y, z; // variables for result
real_t epsilon = 0.01; // margin to allow for rounding errors
@@ -785,7 +785,7 @@ void Basis::set_quat(const Quat &p_quat) {
void Basis::set_axis_angle(const Vector3 &p_axis, real_t p_phi) {
// Rotation matrix from axis and angle, see https://en.wikipedia.org/wiki/Rotation_matrix#Rotation_matrix_from_axis_angle
#ifdef MATH_CHECKS
- ERR_FAIL_COND(p_axis.is_normalized() == false);
+ ERR_FAIL_COND(!p_axis.is_normalized());
#endif
Vector3 axis_sq(p_axis.x * p_axis.x, p_axis.y * p_axis.y, p_axis.z * p_axis.z);
@@ -837,8 +837,8 @@ void Basis::set_diagonal(const Vector3 p_diag) {
Basis Basis::slerp(const Basis &target, const real_t &t) const {
// TODO: implement this directly without using quaternions to make it more efficient
#ifdef MATH_CHECKS
- ERR_FAIL_COND_V(is_rotation() == false, Basis());
- ERR_FAIL_COND_V(target.is_rotation() == false, Basis());
+ ERR_FAIL_COND_V(!is_rotation(), Basis());
+ ERR_FAIL_COND_V(!target.is_rotation(), Basis());
#endif
Quat from(*this);
diff --git a/core/math/quat.cpp b/core/math/quat.cpp
index d660ce4553..791e84f089 100644
--- a/core/math/quat.cpp
+++ b/core/math/quat.cpp
@@ -100,7 +100,7 @@ void Quat::set_euler_yxz(const Vector3 &p_euler) {
// This implementation uses YXZ convention (Z is the first rotation).
Vector3 Quat::get_euler_yxz() const {
#ifdef MATH_CHECKS
- ERR_FAIL_COND_V(is_normalized() == false, Vector3(0, 0, 0));
+ ERR_FAIL_COND_V(!is_normalized(), Vector3(0, 0, 0));
#endif
Basis m(*this);
return m.get_euler_yxz();
@@ -140,15 +140,15 @@ bool Quat::is_normalized() const {
Quat Quat::inverse() const {
#ifdef MATH_CHECKS
- ERR_FAIL_COND_V(is_normalized() == false, Quat());
+ ERR_FAIL_COND_V(!is_normalized(), Quat());
#endif
return Quat(-x, -y, -z, w);
}
Quat Quat::slerp(const Quat &q, const real_t &t) const {
#ifdef MATH_CHECKS
- ERR_FAIL_COND_V(is_normalized() == false, Quat());
- ERR_FAIL_COND_V(q.is_normalized() == false, Quat());
+ ERR_FAIL_COND_V(!is_normalized(), Quat());
+ ERR_FAIL_COND_V(!q.is_normalized(), Quat());
#endif
Quat to1;
real_t omega, cosom, sinom, scale0, scale1;
@@ -194,8 +194,8 @@ Quat Quat::slerp(const Quat &q, const real_t &t) const {
Quat Quat::slerpni(const Quat &q, const real_t &t) const {
#ifdef MATH_CHECKS
- ERR_FAIL_COND_V(is_normalized() == false, Quat());
- ERR_FAIL_COND_V(q.is_normalized() == false, Quat());
+ ERR_FAIL_COND_V(!is_normalized(), Quat());
+ ERR_FAIL_COND_V(!q.is_normalized(), Quat());
#endif
const Quat &from = *this;
@@ -216,8 +216,8 @@ Quat Quat::slerpni(const Quat &q, const real_t &t) const {
Quat Quat::cubic_slerp(const Quat &q, const Quat &prep, const Quat &postq, const real_t &t) const {
#ifdef MATH_CHECKS
- ERR_FAIL_COND_V(is_normalized() == false, Quat());
- ERR_FAIL_COND_V(q.is_normalized() == false, Quat());
+ ERR_FAIL_COND_V(!is_normalized(), Quat());
+ ERR_FAIL_COND_V(!q.is_normalized(), Quat());
#endif
//the only way to do slerp :|
real_t t2 = (1.0 - t) * t * 2;
@@ -233,7 +233,7 @@ Quat::operator String() const {
void Quat::set_axis_angle(const Vector3 &axis, const real_t &angle) {
#ifdef MATH_CHECKS
- ERR_FAIL_COND(axis.is_normalized() == false);
+ ERR_FAIL_COND(!axis.is_normalized());
#endif
real_t d = axis.length();
if (d == 0)
diff --git a/core/math/quat.h b/core/math/quat.h
index 10d3846c87..c4f9b3a732 100644
--- a/core/math/quat.h
+++ b/core/math/quat.h
@@ -87,7 +87,7 @@ public:
_FORCE_INLINE_ Vector3 xform(const Vector3 &v) const {
#ifdef MATH_CHECKS
- ERR_FAIL_COND_V(is_normalized() == false, v);
+ ERR_FAIL_COND_V(!is_normalized(), v);
#endif
Vector3 u(x, y, z);
Vector3 uv = u.cross(v);
diff --git a/core/math/vector2.cpp b/core/math/vector2.cpp
index 84c9f0fca6..7c6f056f09 100644
--- a/core/math/vector2.cpp
+++ b/core/math/vector2.cpp
@@ -167,7 +167,7 @@ Vector2 Vector2::cubic_interpolate(const Vector2 &p_b, const Vector2 &p_pre_a, c
// slide returns the component of the vector along the given plane, specified by its normal vector.
Vector2 Vector2::slide(const Vector2 &p_normal) const {
#ifdef MATH_CHECKS
- ERR_FAIL_COND_V(p_normal.is_normalized() == false, Vector2());
+ ERR_FAIL_COND_V(!p_normal.is_normalized(), Vector2());
#endif
return *this - p_normal * this->dot(p_normal);
}
@@ -178,7 +178,7 @@ Vector2 Vector2::bounce(const Vector2 &p_normal) const {
Vector2 Vector2::reflect(const Vector2 &p_normal) const {
#ifdef MATH_CHECKS
- ERR_FAIL_COND_V(p_normal.is_normalized() == false, Vector2());
+ ERR_FAIL_COND_V(!p_normal.is_normalized(), Vector2());
#endif
return 2.0 * p_normal * this->dot(p_normal) - *this;
}
diff --git a/core/math/vector2.h b/core/math/vector2.h
index df49484aaf..e5e555597d 100644
--- a/core/math/vector2.h
+++ b/core/math/vector2.h
@@ -230,7 +230,7 @@ Vector2 Vector2::linear_interpolate(const Vector2 &p_b, real_t p_t) const {
Vector2 Vector2::slerp(const Vector2 &p_b, real_t p_t) const {
#ifdef MATH_CHECKS
- ERR_FAIL_COND_V(is_normalized() == false, Vector2());
+ ERR_FAIL_COND_V(!is_normalized(), Vector2());
#endif
real_t theta = angle_to(p_b);
return rotated(theta * p_t);
diff --git a/core/math/vector3.h b/core/math/vector3.h
index 5302832eeb..16feba6a0c 100644
--- a/core/math/vector3.h
+++ b/core/math/vector3.h
@@ -218,7 +218,7 @@ Vector3 Vector3::linear_interpolate(const Vector3 &p_b, real_t p_t) const {
Vector3 Vector3::slerp(const Vector3 &p_b, real_t p_t) const {
#ifdef MATH_CHECKS
- ERR_FAIL_COND_V(is_normalized() == false, Vector3());
+ ERR_FAIL_COND_V(!is_normalized(), Vector3());
#endif
real_t theta = angle_to(p_b);
@@ -430,7 +430,7 @@ void Vector3::zero() {
// slide returns the component of the vector along the given plane, specified by its normal vector.
Vector3 Vector3::slide(const Vector3 &p_normal) const {
#ifdef MATH_CHECKS
- ERR_FAIL_COND_V(p_normal.is_normalized() == false, Vector3());
+ ERR_FAIL_COND_V(!p_normal.is_normalized(), Vector3());
#endif
return *this - p_normal * this->dot(p_normal);
}
@@ -441,7 +441,7 @@ Vector3 Vector3::bounce(const Vector3 &p_normal) const {
Vector3 Vector3::reflect(const Vector3 &p_normal) const {
#ifdef MATH_CHECKS
- ERR_FAIL_COND_V(p_normal.is_normalized() == false, Vector3());
+ ERR_FAIL_COND_V(!p_normal.is_normalized(), Vector3());
#endif
return 2.0 * p_normal * this->dot(p_normal) - *this;
}
diff --git a/core/oa_hash_map.h b/core/oa_hash_map.h
index 3705762d6c..9840442519 100644
--- a/core/oa_hash_map.h
+++ b/core/oa_hash_map.h
@@ -125,7 +125,7 @@ private:
while (42) {
if (hashes[pos] == EMPTY_HASH) {
- _construct(pos, hash, p_key, p_value);
+ _construct(pos, hash, key, value);
return;
}
@@ -136,7 +136,7 @@ private:
if (hashes[pos] & DELETED_HASH_BIT) {
// we found a place where we can fit in!
- _construct(pos, hash, p_key, p_value);
+ _construct(pos, hash, key, value);
return;
}
diff --git a/core/os/input.cpp b/core/os/input.cpp
index 6830df7e81..4cd1f0b24a 100644
--- a/core/os/input.cpp
+++ b/core/os/input.cpp
@@ -42,7 +42,7 @@ Input *Input::get_singleton() {
}
void Input::set_mouse_mode(MouseMode p_mode) {
- ERR_FAIL_INDEX(p_mode, 4);
+ ERR_FAIL_INDEX((int)p_mode, 4);
OS::get_singleton()->set_mouse_mode((OS::MouseMode)p_mode);
}
diff --git a/core/os/memory.cpp b/core/os/memory.cpp
index 041371a6e2..f25e40ef78 100644
--- a/core/os/memory.cpp
+++ b/core/os/memory.cpp
@@ -172,9 +172,9 @@ void Memory::free_static(void *p_ptr, bool p_pad_align) {
if (prepad) {
mem -= PAD_ALIGN;
- uint64_t *s = (uint64_t *)mem;
#ifdef DEBUG_ENABLED
+ uint64_t *s = (uint64_t *)mem;
atomic_sub(&mem_usage, *s);
#endif
diff --git a/core/os/rw_lock.h b/core/os/rw_lock.h
index 8d1029723b..4333d9a016 100644
--- a/core/os/rw_lock.h
+++ b/core/os/rw_lock.h
@@ -57,9 +57,7 @@ class RWLockRead {
public:
RWLockRead(const RWLock *p_lock) {
- if (p_lock) {
- lock = const_cast<RWLock *>(p_lock);
- }
+ lock = const_cast<RWLock *>(p_lock);
if (lock) lock->read_lock();
}
~RWLockRead() {
diff --git a/core/rid.h b/core/rid.h
index fbb3e443fc..81d5b45d21 100644
--- a/core/rid.h
+++ b/core/rid.h
@@ -118,7 +118,6 @@ protected:
p_rid._data->_owner = NULL;
}
-#
#endif
public:
diff --git a/core/script_debugger_remote.cpp b/core/script_debugger_remote.cpp
index 388e3b77a3..3e984fae32 100644
--- a/core/script_debugger_remote.cpp
+++ b/core/script_debugger_remote.cpp
@@ -578,8 +578,14 @@ void ScriptDebuggerRemote::_send_object_id(ObjectID p_id) {
for (ScriptConstantsMap::Element *sc = constants.front(); sc; sc = sc->next()) {
for (Map<StringName, Variant>::Element *E = sc->get().front(); E; E = E->next()) {
String script_path = sc->key() == si->get_script().ptr() ? "" : sc->key()->get_path().get_file() + "/";
- PropertyInfo pi(E->value().get_type(), "Constants/" + script_path + E->key());
- properties.push_back(PropertyDesc(pi, E->value()));
+ if (E->value().get_type() == Variant::OBJECT) {
+ Variant id = ((Object *)E->value())->get_instance_id();
+ PropertyInfo pi(id.get_type(), "Constants/" + E->key(), PROPERTY_HINT_OBJECT_ID, "Object");
+ properties.push_back(PropertyDesc(pi, id));
+ } else {
+ PropertyInfo pi(E->value().get_type(), "Constants/" + script_path + E->key());
+ properties.push_back(PropertyDesc(pi, E->value()));
+ }
}
}
}
@@ -592,8 +598,14 @@ void ScriptDebuggerRemote::_send_object_id(ObjectID p_id) {
Map<StringName, Variant> constants;
s->get_constants(&constants);
for (Map<StringName, Variant>::Element *E = constants.front(); E; E = E->next()) {
- PropertyInfo pi(E->value().get_type(), String("Constants/") + E->key());
- properties.push_front(PropertyDesc(pi, E->value()));
+ if (E->value().get_type() == Variant::OBJECT) {
+ Variant id = ((Object *)E->value())->get_instance_id();
+ PropertyInfo pi(id.get_type(), "Constants/" + E->key(), PROPERTY_HINT_OBJECT_ID, "Object");
+ properties.push_front(PropertyDesc(pi, E->value()));
+ } else {
+ PropertyInfo pi(E->value().get_type(), String("Constants/") + E->key());
+ properties.push_front(PropertyDesc(pi, E->value()));
+ }
}
}
}
@@ -634,10 +646,9 @@ void ScriptDebuggerRemote::_send_object_id(ObjectID p_id) {
prop.push_back(pi.hint);
prop.push_back(pi.hint_string);
prop.push_back(pi.usage);
+
if (!res.is_null()) {
- var = String("PATH") + res->get_path();
- } else if (var.get_type() == Variant::STRING) {
- var = String("DATA") + var;
+ var = res->get_path();
}
prop.push_back(var);
diff --git a/core/ustring.cpp b/core/ustring.cpp
index 3f073b181f..1195cd0719 100644
--- a/core/ustring.cpp
+++ b/core/ustring.cpp
@@ -49,7 +49,7 @@
#endif
#if defined(MINGW_ENABLED) || defined(_MSC_VER)
-#define snprintf _snprintf
+#define snprintf _snprintf_s
#endif
#define MAX_DIGITS 6
@@ -586,6 +586,8 @@ String String::camelcase_to_underscore(bool lowercase) const {
bool is_upper = cstr[i] >= A && cstr[i] <= Z;
bool is_number = cstr[i] >= '0' && cstr[i] <= '9';
bool are_next_2_lower = false;
+ bool is_next_lower = false;
+ bool is_next_number = false;
bool was_precedent_upper = cstr[i - 1] >= A && cstr[i - 1] <= Z;
bool was_precedent_number = cstr[i - 1] >= '0' && cstr[i - 1] <= '9';
@@ -593,7 +595,18 @@ String String::camelcase_to_underscore(bool lowercase) const {
are_next_2_lower = cstr[i + 1] >= a && cstr[i + 1] <= z && cstr[i + 2] >= a && cstr[i + 2] <= z;
}
- bool should_split = ((is_upper && !was_precedent_upper && !was_precedent_number) || (was_precedent_upper && is_upper && are_next_2_lower) || (is_number && !was_precedent_number));
+ if (i + 1 < this->size()) {
+ is_next_lower = cstr[i + 1] >= a && cstr[i + 1] <= z;
+ is_next_number = cstr[i + 1] >= '0' && cstr[i + 1] <= '9';
+ }
+
+ const bool a = is_upper && !was_precedent_upper && !was_precedent_number;
+ const bool b = was_precedent_upper && is_upper && are_next_2_lower;
+ const bool c = is_number && !was_precedent_number;
+ const bool can_break_number_letter = is_number && !was_precedent_number && is_next_lower;
+ const bool can_break_letter_number = !is_number && was_precedent_number && (is_next_lower || is_next_number);
+
+ bool should_split = a || b || c || can_break_number_letter || can_break_letter_number;
if (should_split) {
new_string += this->substr(start_index, i - start_index) + "_";
start_index = i;
@@ -3092,7 +3105,7 @@ String String::simplify_path() const {
} else if (s.begins_with("user://")) {
drive = "user://";
- s = s.substr(6, s.length());
+ s = s.substr(7, s.length());
} else if (s.begins_with("/") || s.begins_with("\\")) {
drive = s.substr(0, 1);
diff --git a/core/variant.cpp b/core/variant.cpp
index 7d75c2243b..edbe66ba31 100644
--- a/core/variant.cpp
+++ b/core/variant.cpp
@@ -858,7 +858,7 @@ bool Variant::is_one() const {
// atomic types
case BOOL: {
- return _data._bool == true;
+ return _data._bool;
} break;
case INT: {
diff --git a/core/variant_call.cpp b/core/variant_call.cpp
index f7fa2ebc70..8693a584f2 100644
--- a/core/variant_call.cpp
+++ b/core/variant_call.cpp
@@ -1895,6 +1895,7 @@ void register_variant_methods() {
_VariantCall::add_constant(Variant::VECTOR3, "AXIS_Z", Vector3::AXIS_Z);
_VariantCall::add_variant_constant(Variant::VECTOR3, "ZERO", Vector3(0, 0, 0));
+ _VariantCall::add_variant_constant(Variant::VECTOR3, "ONE", Vector3(1, 1, 1));
_VariantCall::add_variant_constant(Variant::VECTOR3, "INF", Vector3(Math_INF, Math_INF, Math_INF));
_VariantCall::add_variant_constant(Variant::VECTOR3, "LEFT", Vector3(-1, 0, 0));
_VariantCall::add_variant_constant(Variant::VECTOR3, "RIGHT", Vector3(1, 0, 0));
@@ -1904,6 +1905,7 @@ void register_variant_methods() {
_VariantCall::add_variant_constant(Variant::VECTOR3, "BACK", Vector3(0, 0, 1));
_VariantCall::add_variant_constant(Variant::VECTOR2, "ZERO", Vector2(0, 0));
+ _VariantCall::add_variant_constant(Variant::VECTOR2, "ONE", Vector2(1, 1));
_VariantCall::add_variant_constant(Variant::VECTOR2, "INF", Vector2(Math_INF, Math_INF));
_VariantCall::add_variant_constant(Variant::VECTOR2, "LEFT", Vector2(-1, 0));
_VariantCall::add_variant_constant(Variant::VECTOR2, "RIGHT", Vector2(1, 0));
diff --git a/core/variant_op.cpp b/core/variant_op.cpp
index 9afc31a772..d193858966 100644
--- a/core/variant_op.cpp
+++ b/core/variant_op.cpp
@@ -521,7 +521,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
const Dictionary *arr_a = reinterpret_cast<const Dictionary *>(p_a._data._mem);
const Dictionary *arr_b = reinterpret_cast<const Dictionary *>(p_b._data._mem);
- _RETURN((*arr_a == *arr_b) == false);
+ _RETURN(*arr_a != *arr_b);
}
CASE_TYPE(math, OP_NOT_EQUAL, ARRAY) {
@@ -3521,7 +3521,7 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant &
//not as efficient but..
real_t va = a;
real_t vb = b;
- r_dst = (1.0 - c) * va + vb * c;
+ r_dst = va + (vb - va) * c;
} else {
r_dst = a;
@@ -3542,13 +3542,13 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant &
case INT: {
int64_t va = a._data._int;
int64_t vb = b._data._int;
- r_dst = int((1.0 - c) * va + vb * c);
+ r_dst = int(va + (vb - va) * c);
}
return;
case REAL: {
real_t va = a._data._real;
real_t vb = b._data._real;
- r_dst = (1.0 - c) * va + vb * c;
+ r_dst = va + (vb - va) * c;
}
return;
case STRING: {
@@ -3556,7 +3556,9 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant &
String sa = *reinterpret_cast<const String *>(a._data._mem);
String sb = *reinterpret_cast<const String *>(b._data._mem);
String dst;
- int csize = sb.length() * c + sa.length() * (1.0 - c);
+ int sa_len = sa.length();
+ int sb_len = sb.length();
+ int csize = sa_len + (sb_len - sa_len) * c;
if (csize == 0) {
r_dst = "";
return;
diff --git a/doc/classes/ArrayMesh.xml b/doc/classes/ArrayMesh.xml
index ed3d2d2205..7806cf4ce4 100644
--- a/doc/classes/ArrayMesh.xml
+++ b/doc/classes/ArrayMesh.xml
@@ -47,7 +47,7 @@
</argument>
<description>
Creates a new surface.
- Surfaces are created to be rendered using a "primitive", which may be PRIMITIVE_POINTS, PRIMITIVE_LINES, PRIMITIVE_LINE_STRIP, PRIMITIVE_LINE_LOOP, PRIMITIVE_TRIANGLES, PRIMITIVE_TRIANGLE_STRIP, PRIMITIVE_TRIANGLE_FAN. See [Mesh] for details. (As a note, when using indices, it is recommended to only use points, lines or triangles). [method get_surface_count] will become the surf_idx for this new surface.
+ Surfaces are created to be rendered using a "primitive", which may be PRIMITIVE_POINTS, PRIMITIVE_LINES, PRIMITIVE_LINE_STRIP, PRIMITIVE_LINE_LOOP, PRIMITIVE_TRIANGLES, PRIMITIVE_TRIANGLE_STRIP, PRIMITIVE_TRIANGLE_FAN. See [Mesh] for details. (As a note, when using indices, it is recommended to only use points, lines or triangles). [method Mesh.get_surface_count] will become the [code]surf_idx[/code] for this new surface.
The [code]arrays[/code] argument is an array of arrays. See [enum ArrayType] for the values used in this array. For example, [code]arrays[0][/code] is the array of vertices. That first vertex sub-array is always required; the others are optional. Adding an index array puts this function into "index mode" where the vertex and other arrays become the sources of data and the index array defines the vertex order. All sub-arrays must have the same length as the vertex array or be empty, except for [code]ARRAY_INDEX[/code] if it is used.
Adding an index array puts this function into "index mode" where the vertex and other arrays become the sources of data, and the index array defines the order of the vertices.
Godot uses clockwise winding order for front faces of triangle primitive modes.
diff --git a/doc/classes/AudioEffectBandLimitFilter.xml b/doc/classes/AudioEffectBandLimitFilter.xml
index 9eba806ad5..c9ddbd5b9a 100644
--- a/doc/classes/AudioEffectBandLimitFilter.xml
+++ b/doc/classes/AudioEffectBandLimitFilter.xml
@@ -4,7 +4,7 @@
Adds a band limit filter to the Audio Bus.
</brief_description>
<description>
- Limits the frequencies in a range around the [member cutoff_hz] and allows frequencies outside of this range to pass.
+ Limits the frequencies in a range around the [member AudioEffectFilter.cutoff_hz] and allows frequencies outside of this range to pass.
</description>
<tutorials>
</tutorials>
diff --git a/doc/classes/AudioEffectBandPassFilter.xml b/doc/classes/AudioEffectBandPassFilter.xml
index 11aab3e86d..7f4c9f4632 100644
--- a/doc/classes/AudioEffectBandPassFilter.xml
+++ b/doc/classes/AudioEffectBandPassFilter.xml
@@ -4,7 +4,7 @@
Adds a band pass filter to the Audio Bus.
</brief_description>
<description>
- Attenuates the frequencies inside of a range around the [member cutoff_hz] and cuts frequencies outside of this band.
+ Attenuates the frequencies inside of a range around the [member AudioEffectFilter.cutoff_hz] and cuts frequencies outside of this band.
</description>
<tutorials>
</tutorials>
diff --git a/doc/classes/AudioEffectHighPassFilter.xml b/doc/classes/AudioEffectHighPassFilter.xml
index 3d487fc783..6c97199cb9 100644
--- a/doc/classes/AudioEffectHighPassFilter.xml
+++ b/doc/classes/AudioEffectHighPassFilter.xml
@@ -4,7 +4,7 @@
Adds a high pass filter to the Audio Bus.
</brief_description>
<description>
- Cuts frequencies lower than the [member cutoff_hz] and allows higher frequencies to pass.
+ Cuts frequencies lower than the [member AudioEffectFilter.cutoff_hz] and allows higher frequencies to pass.
</description>
<tutorials>
</tutorials>
diff --git a/doc/classes/AudioEffectLowPassFilter.xml b/doc/classes/AudioEffectLowPassFilter.xml
index 3facd8b665..7048a56e6c 100644
--- a/doc/classes/AudioEffectLowPassFilter.xml
+++ b/doc/classes/AudioEffectLowPassFilter.xml
@@ -4,7 +4,7 @@
Adds a low pass filter to the Audio Bus.
</brief_description>
<description>
- Cuts frequencies higher than the [member cutoff_hz] and allows lower frequencies to pass.
+ Cuts frequencies higher than the [member AudioEffectFilter.cutoff_hz] and allows lower frequencies to pass.
</description>
<tutorials>
</tutorials>
diff --git a/doc/classes/AudioEffectNotchFilter.xml b/doc/classes/AudioEffectNotchFilter.xml
index 741931f262..0378934890 100644
--- a/doc/classes/AudioEffectNotchFilter.xml
+++ b/doc/classes/AudioEffectNotchFilter.xml
@@ -4,7 +4,7 @@
Adds a notch filter to the Audio Bus.
</brief_description>
<description>
- Attenuates frequencies in a narrow band around the [member cutoff_hz] and cuts frequencies outside of this range.
+ Attenuates frequencies in a narrow band around the [member AudioEffectFilter.cutoff_hz] and cuts frequencies outside of this range.
</description>
<tutorials>
</tutorials>
diff --git a/doc/classes/BaseButton.xml b/doc/classes/BaseButton.xml
index 3ff8634010..3364770280 100644
--- a/doc/classes/BaseButton.xml
+++ b/doc/classes/BaseButton.xml
@@ -106,6 +106,8 @@
<constant name="DRAW_DISABLED" value="3" enum="DrawMode">
The state of buttons are disabled.
</constant>
+ <constant name="DRAW_HOVER_PRESSED" value="4" enum="DrawMode">
+ </constant>
<constant name="ACTION_MODE_BUTTON_PRESS" value="0" enum="ActionMode">
Require just a press to consider the button clicked.
</constant>
diff --git a/doc/classes/CheckBox.xml b/doc/classes/CheckBox.xml
index fb2cf64d98..a2a7cf85e8 100644
--- a/doc/classes/CheckBox.xml
+++ b/doc/classes/CheckBox.xml
@@ -31,10 +31,14 @@
</theme_item>
<theme_item name="font_color_hover" type="Color">
</theme_item>
+ <theme_item name="font_color_hover_pressed" type="Color">
+ </theme_item>
<theme_item name="font_color_pressed" type="Color">
</theme_item>
<theme_item name="hover" type="StyleBox">
</theme_item>
+ <theme_item name="hover_pressed" type="StyleBox">
+ </theme_item>
<theme_item name="hseparation" type="int">
</theme_item>
<theme_item name="normal" type="StyleBox">
diff --git a/doc/classes/CheckButton.xml b/doc/classes/CheckButton.xml
index deba9a17b6..24875017fe 100644
--- a/doc/classes/CheckButton.xml
+++ b/doc/classes/CheckButton.xml
@@ -29,10 +29,14 @@
</theme_item>
<theme_item name="font_color_hover" type="Color">
</theme_item>
+ <theme_item name="font_color_hover_pressed" type="Color">
+ </theme_item>
<theme_item name="font_color_pressed" type="Color">
</theme_item>
<theme_item name="hover" type="StyleBox">
</theme_item>
+ <theme_item name="hover_pressed" type="StyleBox">
+ </theme_item>
<theme_item name="hseparation" type="int">
</theme_item>
<theme_item name="normal" type="StyleBox">
diff --git a/doc/classes/CollisionShape.xml b/doc/classes/CollisionShape.xml
index 682c9340df..5639c14192 100644
--- a/doc/classes/CollisionShape.xml
+++ b/doc/classes/CollisionShape.xml
@@ -4,7 +4,7 @@
Node that represents collision shape data in 3D space.
</brief_description>
<description>
- Editor facility for creating and editing collision shapes in 3D space. You can use this node to represent all sorts of collision shapes, for example, add this to an [Area] to give it a detection shape, or add it to a [PhysicsBody] to create a solid object. [b]IMPORTANT[/b]: this is an Editor-only helper to create shapes, use [method get_shape] to get the actual shape.
+ Editor facility for creating and editing collision shapes in 3D space. You can use this node to represent all sorts of collision shapes, for example, add this to an [Area] to give it a detection shape, or add it to a [PhysicsBody] to create a solid object. [b]IMPORTANT[/b]: this is an Editor-only helper to create shapes, use [method CollisionObject.shape_owner_get_shape] to get the actual shape.
</description>
<tutorials>
<link>http://docs.godotengine.org/en/3.0/tutorials/physics/physics_introduction.html</link>
diff --git a/doc/classes/CollisionShape2D.xml b/doc/classes/CollisionShape2D.xml
index 3312fad99c..713cb8d098 100644
--- a/doc/classes/CollisionShape2D.xml
+++ b/doc/classes/CollisionShape2D.xml
@@ -4,7 +4,7 @@
Node that represents collision shape data in 2D space.
</brief_description>
<description>
- Editor facility for creating and editing collision shapes in 2D space. You can use this node to represent all sorts of collision shapes, for example, add this to an [Area2D] to give it a detection shape, or add it to a [PhysicsBody2D] to create a solid object. [b]IMPORTANT[/b]: this is an Editor-only helper to create shapes, use [method get_shape] to get the actual shape.
+ Editor facility for creating and editing collision shapes in 2D space. You can use this node to represent all sorts of collision shapes, for example, add this to an [Area2D] to give it a detection shape, or add it to a [PhysicsBody2D] to create a solid object. [b]IMPORTANT[/b]: this is an Editor-only helper to create shapes, use [method CollisionObject2D.shape_owner_get_shape] to get the actual shape.
</description>
<tutorials>
<link>http://docs.godotengine.org/en/3.0/tutorials/physics/physics_introduction.html</link>
diff --git a/doc/classes/Control.xml b/doc/classes/Control.xml
index 1a27aea23f..ee82afd592 100644
--- a/doc/classes/Control.xml
+++ b/doc/classes/Control.xml
@@ -76,7 +76,7 @@
<argument index="1" name="constant" type="int">
</argument>
<description>
- Overrides an integer constant in the [member theme] resource the node uses. If the [code]constant[/code] is invalid, Godot clears the override. See [member Theme.INVALID_CONSTANT] for more information.
+ Overrides an integer constant in the [member theme] resource the node uses. If the [code]constant[/code] is invalid, Godot clears the override.
</description>
</method>
<method name="add_font_override">
diff --git a/doc/classes/FileDialog.xml b/doc/classes/FileDialog.xml
index 247228d265..29aa26b67f 100644
--- a/doc/classes/FileDialog.xml
+++ b/doc/classes/FileDialog.xml
@@ -17,7 +17,7 @@
<argument index="0" name="filter" type="String">
</argument>
<description>
- Add a custom filter. Filter format is: "mask ; description", example (C++): dialog-&gt;add_filter("*.png ; PNG Images");
+ Add a custom filter. Example: [code]add_filter("*.png ; PNG Images")[/code]
</description>
</method>
<method name="clear_filters">
@@ -31,12 +31,14 @@
<return type="void">
</return>
<description>
+ Clear currently selected items in the dialog.
</description>
</method>
<method name="get_line_edit">
<return type="LineEdit">
</return>
<description>
+ Returns the LineEdit for the selected file.
</description>
</method>
<method name="get_vbox">
@@ -56,6 +58,7 @@
</methods>
<members>
<member name="access" type="int" setter="set_access" getter="get_access" enum="FileDialog.Access">
+ The file system access scope. See enum [code]Access[/code] constants.
</member>
<member name="current_dir" type="String" setter="set_current_dir" getter="get_current_dir">
The current working directory of the file dialog.
@@ -67,13 +70,16 @@
The currently selected file path of the file dialog.
</member>
<member name="filters" type="PoolStringArray" setter="set_filters" getter="get_filters">
+ Set file type filters. This example shows only .png and .gd files [code]set_filters(PoolStringArray(["*.png ; PNG Images","*.gd ; GD Script"]))[/code].
</member>
<member name="mode" type="int" setter="set_mode" getter="get_mode" enum="FileDialog.Mode">
+ Set dialog to open or save mode, changes selection behavior. See enum [code]Mode[/code] constants.
</member>
<member name="mode_overrides_title" type="bool" setter="set_mode_overrides_title" getter="is_mode_overriding_title">
- If [code]true[/code], changing the [code]mode[/code] property will set the window title accordingly (e. g. setting mode to [code]MODE_OPEN_FILE[/code] will change the window title to "Open a File").
+ If [code]true[/code], changing the [code]Mode[/code] property will set the window title accordingly (e. g. setting mode to [code]MODE_OPEN_FILE[/code] will change the window title to "Open a File").
</member>
<member name="show_hidden_files" type="bool" setter="set_show_hidden_files" getter="is_showing_hidden_files">
+ If [code]true[/code], the dialog will show hidden files.
</member>
</members>
<signals>
diff --git a/doc/classes/Input.xml b/doc/classes/Input.xml
index 338d01ae5f..10ec15b99d 100644
--- a/doc/classes/Input.xml
+++ b/doc/classes/Input.xml
@@ -55,6 +55,7 @@
<argument index="0" name="action" type="String">
</argument>
<description>
+ Returns a value between 0 and 1 representing the intensity of the given action. In a joypad, for example, the further away the axis (analog sticks or L2, R2 triggers) is from the dead zone, the closer the value will be to 1. If the action is mapped to a control that has no axis as the keyboard, the value returned will be 0 or 1.
</description>
</method>
<method name="get_connected_joypads">
diff --git a/doc/classes/KinematicBody.xml b/doc/classes/KinematicBody.xml
index 17310ab4dc..82638fc57a 100644
--- a/doc/classes/KinematicBody.xml
+++ b/doc/classes/KinematicBody.xml
@@ -69,7 +69,7 @@
</argument>
<description>
Moves the body along the vector [code]rel_vec[/code]. The body will stop if it collides. Returns a [KinematicCollision], which contains information about the collision.
- If [code]test_only[/code] is [code]true[/true], the body does not move but the would-be collision information is given.
+ If [code]test_only[/code] is [code]true[/code], the body does not move but the would-be collision information is given.
</description>
</method>
<method name="move_and_slide">
diff --git a/doc/classes/KinematicBody2D.xml b/doc/classes/KinematicBody2D.xml
index e48660a889..6511b2f182 100644
--- a/doc/classes/KinematicBody2D.xml
+++ b/doc/classes/KinematicBody2D.xml
@@ -116,7 +116,7 @@
</argument>
<description>
Moves the body while keeping it attached to slopes. Similar to [method move_and_slide].
- As long as the [code]snap[/code] vector is in contact with the ground, the body will remain attached to the surface. This means you must disable snap in order to jump, for example. You can do this by setting[code]snap[/code] to[code](0, 0)[/code] or by using [method move_and_slide] instead.
+ As long as the [code]snap[/code] vector is in contact with the ground, the body will remain attached to the surface. This means you must disable snap in order to jump, for example. You can do this by setting [code]snap[/code] to [code](0, 0)[/code] or by using [method move_and_slide] instead.
</description>
</method>
<method name="test_move">
diff --git a/doc/classes/LineEdit.xml b/doc/classes/LineEdit.xml
index c244b8b7a7..f842dd8311 100644
--- a/doc/classes/LineEdit.xml
+++ b/doc/classes/LineEdit.xml
@@ -89,6 +89,7 @@
The cursor's position inside the [code]LineEdit[/code]. When set, the text may scroll to accommodate it.
</member>
<member name="clear_button_enabled" type="bool" setter="set_clear_button_enabled" getter="is_clear_button_enabled">
+ If [code]true[/code] the [code]LineEdit[/code] will show a clear button if [code]text[/code] is not empty.
</member>
<member name="context_menu_enabled" type="bool" setter="set_context_menu_enabled" getter="is_context_menu_enabled">
If [code]true[/code] the context menu will appear when right clicked.
@@ -169,6 +170,7 @@
Undoes the previous action.
</constant>
<constant name="MENU_REDO" value="6" enum="MenuItems">
+ Reverse the last undo action.
</constant>
<constant name="MENU_MAX" value="7" enum="MenuItems">
</constant>
diff --git a/doc/classes/MeshDataTool.xml b/doc/classes/MeshDataTool.xml
index 43d94004a8..5c3af3e2e1 100644
--- a/doc/classes/MeshDataTool.xml
+++ b/doc/classes/MeshDataTool.xml
@@ -1,8 +1,22 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="MeshDataTool" inherits="Reference" category="Core" version="3.1">
<brief_description>
+ Helper tool to access and edit [Mesh] data.
</brief_description>
<description>
+ The MeshDataTool provides access to individual vertices in a [Mesh]. It allows users to read and edit vertex data of meshes. It also creates an array of faces and edges.
+ To use the MeshDataTool, load a mesh with [method create_from_surface]. When you are finished editing the data commit the data to a mesh with [method commit_to_surface].
+ Below is an example of how the MeshDataTool may be used.
+ [codeblock]
+ var mdt = MeshDataTool.new()
+ mdt.create_from_surface(mesh, 0)
+ for i in range(mdt.get_vertex_count()):
+ var vertex = mdt.get_vertex(i)
+ ...
+ mdt.set_vertex(i, vertex)
+ mesh.surface_remove(0)
+ mdt.commit_to_surface(mesh)
+ [/codeblock]
</description>
<tutorials>
</tutorials>
@@ -13,6 +27,7 @@
<return type="void">
</return>
<description>
+ Clears all data currently in MeshDataTool.
</description>
</method>
<method name="commit_to_surface">
@@ -21,6 +36,7 @@
<argument index="0" name="mesh" type="ArrayMesh">
</argument>
<description>
+ Adds a new surface to specified [Mesh] with edited data.
</description>
</method>
<method name="create_from_surface">
@@ -31,12 +47,15 @@
<argument index="1" name="surface" type="int">
</argument>
<description>
+ Uses specified surface of given [Mesh] to populate data for MeshDataTool.
+ Requires [Mesh] with primitive type [code]PRIMITIVE_TRIANGLES[/code].
</description>
</method>
<method name="get_edge_count" qualifiers="const">
<return type="int">
</return>
<description>
+ Returns the number of edges in this [Mesh].
</description>
</method>
<method name="get_edge_faces" qualifiers="const">
@@ -45,6 +64,7 @@
<argument index="0" name="idx" type="int">
</argument>
<description>
+ Returns array of faces that touch given edge.
</description>
</method>
<method name="get_edge_meta" qualifiers="const">
@@ -53,6 +73,7 @@
<argument index="0" name="idx" type="int">
</argument>
<description>
+ Returns meta information assigned to given edge.
</description>
</method>
<method name="get_edge_vertex" qualifiers="const">
@@ -63,12 +84,15 @@
<argument index="1" name="vertex" type="int">
</argument>
<description>
+ Returns index of specified vertex connected to given edge.
+ Vertex argument can only be 0 or 1 because edges are comprised of two vertices.
</description>
</method>
<method name="get_face_count" qualifiers="const">
<return type="int">
</return>
<description>
+ Returns the number of faces in this [Mesh].
</description>
</method>
<method name="get_face_edge" qualifiers="const">
@@ -79,6 +103,8 @@
<argument index="1" name="edge" type="int">
</argument>
<description>
+ Returns specified edge associated with given face.
+ Edge argument must 2 or less becuase a face only has three edges.
</description>
</method>
<method name="get_face_meta" qualifiers="const">
@@ -87,6 +113,7 @@
<argument index="0" name="idx" type="int">
</argument>
<description>
+ Returns meta data associated with given face.
</description>
</method>
<method name="get_face_normal" qualifiers="const">
@@ -95,6 +122,7 @@
<argument index="0" name="idx" type="int">
</argument>
<description>
+ Calculates and returns face normal of given face.
</description>
</method>
<method name="get_face_vertex" qualifiers="const">
@@ -105,18 +133,23 @@
<argument index="1" name="vertex" type="int">
</argument>
<description>
+ Returns specified vertex of given face.
+ Vertex argument must be 2 or less becuase faces contain three vertices.
</description>
</method>
<method name="get_format" qualifiers="const">
<return type="int">
</return>
<description>
+ Returns format of [Mesh]. Format is an integer made up of [Mesh] format flags combined together. For example, a mesh containing both vertices and normals would return a format of [code]3[/code] becuase [code]ARRAY_FORMAT_VERTEX[/code] is [code]1[/code] and [code]ARRAY_FORMAT_NORMAL[/code] is [code]2[/code].
+ For list of format flags see [ArrayMesh].
</description>
</method>
<method name="get_material" qualifiers="const">
<return type="Material">
</return>
<description>
+ Returns material assigned to the [Mesh].
</description>
</method>
<method name="get_vertex" qualifiers="const">
@@ -125,6 +158,7 @@
<argument index="0" name="idx" type="int">
</argument>
<description>
+ Returns the vertex at given index.
</description>
</method>
<method name="get_vertex_bones" qualifiers="const">
@@ -133,6 +167,7 @@
<argument index="0" name="idx" type="int">
</argument>
<description>
+ Returns the bones of the given vertex.
</description>
</method>
<method name="get_vertex_color" qualifiers="const">
@@ -141,12 +176,14 @@
<argument index="0" name="idx" type="int">
</argument>
<description>
+ Returns the color of the given vertex.
</description>
</method>
<method name="get_vertex_count" qualifiers="const">
<return type="int">
</return>
<description>
+ Returns the total number of vertices in [Mesh].
</description>
</method>
<method name="get_vertex_edges" qualifiers="const">
@@ -155,6 +192,7 @@
<argument index="0" name="idx" type="int">
</argument>
<description>
+ Returns array of edges that share given vertex.
</description>
</method>
<method name="get_vertex_faces" qualifiers="const">
@@ -163,6 +201,7 @@
<argument index="0" name="idx" type="int">
</argument>
<description>
+ Returns array of faces that share given vertex.
</description>
</method>
<method name="get_vertex_meta" qualifiers="const">
@@ -171,6 +210,7 @@
<argument index="0" name="idx" type="int">
</argument>
<description>
+ Returns meta data associated with given vertex.
</description>
</method>
<method name="get_vertex_normal" qualifiers="const">
@@ -179,6 +219,7 @@
<argument index="0" name="idx" type="int">
</argument>
<description>
+ Returns normal of given vertex.
</description>
</method>
<method name="get_vertex_tangent" qualifiers="const">
@@ -187,6 +228,7 @@
<argument index="0" name="idx" type="int">
</argument>
<description>
+ Returns tangent of given vertex.
</description>
</method>
<method name="get_vertex_uv" qualifiers="const">
@@ -195,6 +237,7 @@
<argument index="0" name="idx" type="int">
</argument>
<description>
+ Returns UV of given vertex.
</description>
</method>
<method name="get_vertex_uv2" qualifiers="const">
@@ -203,6 +246,7 @@
<argument index="0" name="idx" type="int">
</argument>
<description>
+ Returns UV2 of given vertex.
</description>
</method>
<method name="get_vertex_weights" qualifiers="const">
@@ -211,6 +255,7 @@
<argument index="0" name="idx" type="int">
</argument>
<description>
+ Returns bone weights of given vertex.
</description>
</method>
<method name="set_edge_meta">
@@ -221,6 +266,7 @@
<argument index="1" name="meta" type="Variant">
</argument>
<description>
+ Sets the meta data of given edge.
</description>
</method>
<method name="set_face_meta">
@@ -231,6 +277,7 @@
<argument index="1" name="meta" type="Variant">
</argument>
<description>
+ Sets the meta data of given face.
</description>
</method>
<method name="set_material">
@@ -239,6 +286,7 @@
<argument index="0" name="material" type="Material">
</argument>
<description>
+ Sets the material to be used by newly constructed [Mesh].
</description>
</method>
<method name="set_vertex">
@@ -249,6 +297,7 @@
<argument index="1" name="vertex" type="Vector3">
</argument>
<description>
+ Sets the position of given vertex.
</description>
</method>
<method name="set_vertex_bones">
@@ -259,6 +308,7 @@
<argument index="1" name="bones" type="PoolIntArray">
</argument>
<description>
+ Sets the bones of given vertex.
</description>
</method>
<method name="set_vertex_color">
@@ -269,6 +319,7 @@
<argument index="1" name="color" type="Color">
</argument>
<description>
+ Sets the color of given vertex.
</description>
</method>
<method name="set_vertex_meta">
@@ -279,6 +330,7 @@
<argument index="1" name="meta" type="Variant">
</argument>
<description>
+ Sets the meta data associated with given vertex.
</description>
</method>
<method name="set_vertex_normal">
@@ -289,6 +341,7 @@
<argument index="1" name="normal" type="Vector3">
</argument>
<description>
+ Sets the normal of given vertex.
</description>
</method>
<method name="set_vertex_tangent">
@@ -299,6 +352,7 @@
<argument index="1" name="tangent" type="Plane">
</argument>
<description>
+ Sets the tangent of given vertex.
</description>
</method>
<method name="set_vertex_uv">
@@ -309,6 +363,7 @@
<argument index="1" name="uv" type="Vector2">
</argument>
<description>
+ Sets the UV of given vertex.
</description>
</method>
<method name="set_vertex_uv2">
@@ -319,6 +374,7 @@
<argument index="1" name="uv2" type="Vector2">
</argument>
<description>
+ Sets the UV2 of given vertex.
</description>
</method>
<method name="set_vertex_weights">
@@ -329,6 +385,7 @@
<argument index="1" name="weights" type="PoolRealArray">
</argument>
<description>
+ Sets the bone weights of given vertex.
</description>
</method>
</methods>
diff --git a/doc/classes/NavigationPolygon.xml b/doc/classes/NavigationPolygon.xml
index b29e19e5d8..4ede80b98c 100644
--- a/doc/classes/NavigationPolygon.xml
+++ b/doc/classes/NavigationPolygon.xml
@@ -1,8 +1,27 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="NavigationPolygon" inherits="Resource" category="Core" version="3.1">
<brief_description>
+ A node that has methods to draw outlines or use indices of vertices to create navigation polygons.
</brief_description>
<description>
+ There are two ways to create polygons. Either by using the [method add_outline] method or using the [method add_polygon] method.
+ Using [method add_outline]:
+ [code]
+ var polygon = NavigationPolygon.new()
+ var outline = PoolVector2Array([Vector2(0, 0), Vector2(0, 50), Vector2(50, 50), Vector2(50, 0)])
+ polygon.add_outline(outline)
+ polygon.make_polygons_from_outlines()
+ $NavigationPolygonInstance.navpoly = polygon
+ [/code]
+ Using [method add_polygon] and indices of the vertices array.
+ [code]
+ var polygon = NavigationPolygon.new()
+ var vertices = PoolVector2Array([Vector2(0, 0), Vector2(0, 50), Vector2(50, 50), Vector2(50, 0)])
+ polygon.set_vertices(vertices)
+ var indices = PoolIntArray(0, 3, 1)
+ polygon.add_polygon(indices)
+ $NavigationPolygonInstance.navpoly = polygon
+ [/code]
</description>
<tutorials>
</tutorials>
@@ -15,6 +34,7 @@
<argument index="0" name="outline" type="PoolVector2Array">
</argument>
<description>
+ Appends a [PoolVector2Array] that contains the vertices of an outline to the internal array that contains all the outlines. You have to call [method make_polygons_from_outlines] in order for this array to be converted to polygons that the engine will use.
</description>
</method>
<method name="add_outline_at_index">
@@ -25,6 +45,7 @@
<argument index="1" name="index" type="int">
</argument>
<description>
+ Adds a [PoolVector2Array] that contains the vertices of an outline to the internal array that contains all the outlines at a fixed position. You have to call [method make_polygons_from_outlines] in order for this array to be converted to polygons that the engine will use.
</description>
</method>
<method name="add_polygon">
@@ -33,18 +54,21 @@
<argument index="0" name="polygon" type="PoolIntArray">
</argument>
<description>
+ Adds a polygon using the indices of the vertices you get when calling [method get_vertices].
</description>
</method>
<method name="clear_outlines">
<return type="void">
</return>
<description>
+ Clears the array of the outlines, but it doesn't clear the vertices and the polygons that were created by them.
</description>
</method>
<method name="clear_polygons">
<return type="void">
</return>
<description>
+ Clears the array of polygons, but it doesn't clear the array of outlines and vertices.
</description>
</method>
<method name="get_outline" qualifiers="const">
@@ -53,12 +77,14 @@
<argument index="0" name="idx" type="int">
</argument>
<description>
+ Returns a [PoolVector2Array] containing the vertices of an outline that was created in the editor or by script.
</description>
</method>
<method name="get_outline_count" qualifiers="const">
<return type="int">
</return>
<description>
+ Returns the number of outlines that were created in the editor or by script.
</description>
</method>
<method name="get_polygon">
@@ -67,24 +93,28 @@
<argument index="0" name="idx" type="int">
</argument>
<description>
+ Returns a [PoolIntArray] containing the indices of the vertices of a created polygon.
</description>
</method>
<method name="get_polygon_count" qualifiers="const">
<return type="int">
</return>
<description>
+ Returns the count of all polygons.
</description>
</method>
<method name="get_vertices" qualifiers="const">
<return type="PoolVector2Array">
</return>
<description>
+ Returns a [PoolVector2Array] containing all the vertices being used to create the polygons.
</description>
</method>
<method name="make_polygons_from_outlines">
<return type="void">
</return>
<description>
+ Creates polygons from the outlines added in the editor or by script.
</description>
</method>
<method name="remove_outline">
@@ -93,6 +123,7 @@
<argument index="0" name="idx" type="int">
</argument>
<description>
+ Removes an outline created in the editor or by script. You have to call [method make_polygons_from_outlines] for the polygons to update.
</description>
</method>
<method name="set_outline">
@@ -103,6 +134,7 @@
<argument index="1" name="outline" type="PoolVector2Array">
</argument>
<description>
+ Changes an outline created in the editor or by script. You have to call [method make_polygons_from_outlines] for the polygons to update.
</description>
</method>
<method name="set_vertices">
@@ -111,6 +143,7 @@
<argument index="0" name="vertices" type="PoolVector2Array">
</argument>
<description>
+ Sets the vertices that can be then indexed to create polygons with the [method add_polygon] method.
</description>
</method>
</methods>
diff --git a/doc/classes/Node.xml b/doc/classes/Node.xml
index dc754b4628..a33ee5c363 100644
--- a/doc/classes/Node.xml
+++ b/doc/classes/Node.xml
@@ -12,7 +12,7 @@
[b]Processing:[/b] Nodes can override the "process" state, so that they receive a callback on each frame requesting them to process (do something). Normal processing (callback [method _process], toggled with [method set_process]) happens as fast as possible and is dependent on the frame rate, so the processing time [i]delta[/i] is passed as an argument. Physics processing (callback [method _physics_process], toggled with [method set_physics_process]) happens a fixed number of times per second (60 by default) and is useful for code related to the physics engine.
Nodes can also process input events. When present, the [method _input] function will be called for each input that the program receives. In many cases, this can be overkill (unless used for simple projects), and the [method _unhandled_input] function might be preferred; it is called when the input event was not handled by anyone else (typically, GUI [Control] nodes), ensuring that the node only receives the events that were meant for it.
To keep track of the scene hierarchy (especially when instancing scenes into other scenes), an "owner" can be set for the node with [method set_owner]. This keeps track of who instanced what. This is mostly useful when writing editors and tools, though.
- Finally, when a node is freed with [method free] or [method queue_free], it will also free all its children.
+ Finally, when a node is freed with [method Object.free] or [method queue_free], it will also free all its children.
[b]Groups:[/b] Nodes can be added to as many groups as you want to be easy to manage, you could create groups like "enemies" or "collectables" for example, depending on your game. See [method add_to_group], [method is_in_group] and [method remove_from_group]. You can then retrieve all nodes in these groups, iterate them and even call methods on groups via the methods on [SceneTree].
[b]Networking with nodes:[/b] After connecting to a server (or making one, see [NetworkedMultiplayerENet]) it is possible to use the built-in RPC (remote procedure call) system to communicate over the network. By calling [method rpc] with a method name, it will be called locally and in all connected peers (peers = clients and the server that accepts connections). To identify which node receives the RPC call Godot will use its [NodePath] (make sure node names are the same on all peers). Also take a look at the high-level networking tutorial and corresponding demos.
</description>
diff --git a/doc/classes/PackedScene.xml b/doc/classes/PackedScene.xml
index 0d58e61c3a..08df3f0ad6 100644
--- a/doc/classes/PackedScene.xml
+++ b/doc/classes/PackedScene.xml
@@ -39,7 +39,7 @@
<argument index="0" name="edit_state" type="int" enum="PackedScene.GenEditState" default="0">
</argument>
<description>
- Instantiates the scene's node hierarchy. Triggers child scene instantiation(s). Triggers the [enum Object.NOTIFICATION_INSTANCED] notification on the root node.
+ Instantiates the scene's node hierarchy. Triggers child scene instantiation(s). Triggers the [enum Node.NOTIFICATION_INSTANCED] notification on the root node.
</description>
</method>
<method name="pack">
diff --git a/doc/classes/ProjectSettings.xml b/doc/classes/ProjectSettings.xml
index 0b7c0a63ad..9efc05dfd5 100644
--- a/doc/classes/ProjectSettings.xml
+++ b/doc/classes/ProjectSettings.xml
@@ -102,7 +102,7 @@
<argument index="0" name="name" type="String">
</argument>
<description>
- Returns true if the specified property exists and its initial value differs from the current value.
+ Returns true if the specified property exists and its initial value differs from the current value.
</description>
</method>
<method name="property_get_revert">
@@ -111,14 +111,14 @@
<argument index="0" name="name" type="String">
</argument>
<description>
- Returns the initial value of the specified property. Returns null if the property does not exist.
+ Returns the initial value of the specified property. Returns null if the property does not exist.
</description>
</method>
<method name="save">
<return type="int" enum="Error">
</return>
<description>
- Saves the configuration to the project.godot file.
+ Saves the configuration to the project.godot file.
</description>
</method>
<method name="save_custom">
@@ -127,7 +127,7 @@
<argument index="0" name="file" type="String">
</argument>
<description>
- Saves the configuration to a custom file.
+ Saves the configuration to a custom file.
</description>
</method>
<method name="set_initial_value">
@@ -213,8 +213,6 @@
<member name="audio/mix_rate" type="int" setter="" getter="">
Mix rate used for audio. In general, it's better to not touch this and leave it to the host operating system.
</member>
- <member name="audio/output_latency" type="int" setter="" getter="">
- </member>
<member name="audio/video_delay_compensation_ms" type="int" setter="" getter="">
Setting to hardcode audio delay when playing video. Best to leave this untouched unless you know what you are doing.
</member>
@@ -693,12 +691,20 @@
<member name="rendering/quality/reflections/high_quality_ggx.mobile" type="bool" setter="" getter="">
</member>
<member name="rendering/quality/reflections/texture_array_reflections" type="bool" setter="" getter="">
- For reflection probes and panorama backgrounds (sky), use a texure array instead of mipmaps. This reduces jitter noise on reflections, but costs more performance and memory.
+ For reflection probes and panorama backgrounds (sky), use a texture array instead of mipmaps. This reduces jitter noise on reflections, but costs more performance and memory.
</member>
<member name="rendering/quality/reflections/texture_array_reflections.mobile" type="bool" setter="" getter="">
</member>
+ <member name="rendering/quality/shading/force_blinn_over_ggx" type="bool" setter="" getter="">
+ </member>
+ <member name="rendering/quality/shading/force_blinn_over_ggx.mobile" type="bool" setter="" getter="">
+ </member>
+ <member name="rendering/quality/shading/force_lambert_over_burley" type="bool" setter="" getter="">
+ </member>
+ <member name="rendering/quality/shading/force_lambert_over_burley.mobile" type="bool" setter="" getter="">
+ </member>
<member name="rendering/quality/shading/force_vertex_shading" type="bool" setter="" getter="">
- Force vertex shading for all rendering. This can increase performance a lot, but also reduces quality inmensely. Can work to optimize on very low end mobile.
+ Force vertex shading for all rendering. This can increase performance a lot, but also reduces quality immensely. Can work to optimize on very low end mobile.
</member>
<member name="rendering/quality/shading/force_vertex_shading.mobile" type="bool" setter="" getter="">
</member>
diff --git a/doc/classes/RichTextLabel.xml b/doc/classes/RichTextLabel.xml
index 618f2f42b2..357d2e7a15 100644
--- a/doc/classes/RichTextLabel.xml
+++ b/doc/classes/RichTextLabel.xml
@@ -166,6 +166,12 @@
Adds a meta tag to the tag stack. Similar to the bbcode [code][url=something]{text}[/url][/code], but supports non-[String] metadata types.
</description>
</method>
+ <method name="push_strikethrough">
+ <return type="void">
+ </return>
+ <description>
+ </description>
+ </method>
<method name="push_table">
<return type="void">
</return>
@@ -304,15 +310,17 @@
</constant>
<constant name="ITEM_UNDERLINE" value="6" enum="ItemType">
</constant>
- <constant name="ITEM_ALIGN" value="7" enum="ItemType">
+ <constant name="ITEM_STRIKETHROUGH" value="7" enum="ItemType">
+ </constant>
+ <constant name="ITEM_ALIGN" value="8" enum="ItemType">
</constant>
- <constant name="ITEM_INDENT" value="8" enum="ItemType">
+ <constant name="ITEM_INDENT" value="9" enum="ItemType">
</constant>
- <constant name="ITEM_LIST" value="9" enum="ItemType">
+ <constant name="ITEM_LIST" value="10" enum="ItemType">
</constant>
- <constant name="ITEM_TABLE" value="10" enum="ItemType">
+ <constant name="ITEM_TABLE" value="11" enum="ItemType">
</constant>
- <constant name="ITEM_META" value="11" enum="ItemType">
+ <constant name="ITEM_META" value="12" enum="ItemType">
</constant>
</constants>
<theme_items>
diff --git a/doc/classes/SceneTree.xml b/doc/classes/SceneTree.xml
index 1985845552..b89ecd1de9 100644
--- a/doc/classes/SceneTree.xml
+++ b/doc/classes/SceneTree.xml
@@ -278,6 +278,10 @@
</member>
<member name="paused" type="bool" setter="set_pause" getter="is_paused">
If [code]true[/code] the SceneTree is paused.
+ Doing so will have the following behavior:
+ * 2D and 3D physics will be stopped.
+ * _process and _physics_process will not be called anymore in nodes.
+ * _input and _input_event will not be called anymore either.
</member>
<member name="refuse_new_network_connections" type="bool" setter="set_refuse_new_network_connections" getter="is_refusing_new_network_connections">
If [code]true[/code] the SceneTree's [member network_peer] refuses new incoming connections.
diff --git a/doc/classes/ScriptCreateDialog.xml b/doc/classes/ScriptCreateDialog.xml
index 3de068dbcb..67ce9a8e87 100644
--- a/doc/classes/ScriptCreateDialog.xml
+++ b/doc/classes/ScriptCreateDialog.xml
@@ -24,6 +24,8 @@
</argument>
<argument index="1" name="path" type="String">
</argument>
+ <argument index="2" name="built_in_enabled" type="bool" default="true">
+ </argument>
<description>
Prefills required fields to configure the ScriptCreateDialog for use.
</description>
diff --git a/doc/classes/SpatialMaterial.xml b/doc/classes/SpatialMaterial.xml
index 354c6686bb..57fb267e91 100644
--- a/doc/classes/SpatialMaterial.xml
+++ b/doc/classes/SpatialMaterial.xml
@@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="SpatialMaterial" inherits="Material" category="Core" version="3.1">
<brief_description>
+ Default 3D rendering material.
</brief_description>
<description>
+ This provides a default material with a wide variety of rendering features and properties without the need to write shader code. See the tutorial below for details.
</description>
<tutorials>
<link>http://docs.godotengine.org/en/3.0/tutorials/3d/spatial_material.html</link>
@@ -13,16 +15,20 @@
</methods>
<members>
<member name="albedo_color" type="Color" setter="set_albedo" getter="get_albedo">
+ The material's base color.
</member>
<member name="albedo_texture" type="Texture" setter="set_texture" getter="get_texture">
</member>
<member name="anisotropy" type="float" setter="set_anisotropy" getter="get_anisotropy">
+ The strength of the anisotropy effect.
</member>
<member name="anisotropy_enabled" type="bool" setter="set_feature" getter="get_feature">
+ If [code]true[/code] anisotropy is enabled. Changes the shape of the specular blob and aligns it to tangent space. Default value: [code]false[/code].
</member>
<member name="anisotropy_flowmap" type="Texture" setter="set_texture" getter="get_texture">
</member>
<member name="ao_enabled" type="bool" setter="set_feature" getter="get_feature">
+ If [code]true[/code] ambient occlusion is enabled.
</member>
<member name="ao_light_affect" type="float" setter="set_ao_light_affect" getter="get_ao_light_affect">
</member>
@@ -35,6 +41,7 @@
<member name="clearcoat" type="float" setter="set_clearcoat" getter="get_clearcoat">
</member>
<member name="clearcoat_enabled" type="bool" setter="set_feature" getter="get_feature">
+ If [code]true[/code] clearcoat rendering is enabled. Adds a secondary transparent pass to the material. Default value: [code]false[/code].
</member>
<member name="clearcoat_gloss" type="float" setter="set_clearcoat_gloss" getter="get_clearcoat_gloss">
</member>
@@ -43,6 +50,7 @@
<member name="depth_deep_parallax" type="bool" setter="set_depth_deep_parallax" getter="is_depth_deep_parallax_enabled">
</member>
<member name="depth_enabled" type="bool" setter="set_feature" getter="get_feature">
+ If [code]true[/code] Depth mapping is enabled. See also [member normal_enabled].
</member>
<member name="depth_max_layers" type="int" setter="set_depth_deep_parallax_max_layers" getter="get_depth_deep_parallax_max_layers">
</member>
@@ -71,10 +79,13 @@
<member name="distance_fade_mode" type="int" setter="set_distance_fade" getter="get_distance_fade" enum="SpatialMaterial.DistanceFadeMode">
</member>
<member name="emission" type="Color" setter="set_emission" getter="get_emission">
+ The emitted light's color. See [member emission_enabled].
</member>
<member name="emission_enabled" type="bool" setter="set_feature" getter="get_feature">
+ If [code]true[/code] the body emits light.
</member>
<member name="emission_energy" type="float" setter="set_emission_energy" getter="get_emission_energy">
+ The emitted light's strength. See [member emission_enabled].
</member>
<member name="emission_on_uv2" type="bool" setter="set_flag" getter="get_flag">
</member>
@@ -85,36 +96,49 @@
<member name="flags_albedo_tex_force_srgb" type="bool" setter="set_flag" getter="get_flag">
</member>
<member name="flags_disable_ambient_light" type="bool" setter="set_flag" getter="get_flag">
+ If [code]true[/code] the object receives no ambient light. Default value: [code]false[/code].
</member>
<member name="flags_do_not_receive_shadows" type="bool" setter="set_flag" getter="get_flag">
+ If [code]true[/code] the object receives no shadow that would otherwise be cast onto it. Default value: [code]false[/code].
</member>
<member name="flags_ensure_correct_normals" type="bool" setter="set_flag" getter="get_flag">
</member>
<member name="flags_fixed_size" type="bool" setter="set_flag" getter="get_flag">
+ If [code]true[/code] the object is rendered at the same size regardless of distance. Default value: [code]false[/code].
</member>
<member name="flags_no_depth_test" type="bool" setter="set_flag" getter="get_flag">
+ If [code]true[/code] depth testing is disabled and the object will be drawn in render order.
</member>
<member name="flags_transparent" type="bool" setter="set_feature" getter="get_feature">
+ If [code]true[/code] transparency is enabled on the body. Default value: [code]false[/code]. See also [member params_blend_mode].
</member>
<member name="flags_unshaded" type="bool" setter="set_flag" getter="get_flag">
+ If [code]true[/code] the object is unaffected by lighting. Default value: [code]false[/code].
</member>
<member name="flags_use_point_size" type="bool" setter="set_flag" getter="get_flag">
+ If [code]true[/code] render point size can be changed. Note: this is only effective for objects whose geometry is point-based rather than triangle-based. See also [member params_point_size].
</member>
<member name="flags_vertex_lighting" type="bool" setter="set_flag" getter="get_flag">
+ If [code]true[/code] lighting is calculated per vertex rather than per pixel. This may increase performance on low-end devices. Default value: [code]false[/code].
</member>
<member name="flags_world_triplanar" type="bool" setter="set_flag" getter="get_flag">
+ If [code]true[/code] triplanar mapping is calculated in world space rather than object local space. See also [member uv1_triplanar]. Default value: [code]false[/code].
</member>
<member name="metallic" type="float" setter="set_metallic" getter="get_metallic">
+ The reflectivity of the object's surface. The higher the value the more light is reflected.
</member>
<member name="metallic_specular" type="float" setter="set_specular" getter="get_specular">
+ General reflectivity amount. Note: unlike [member metallic], this is not energy-conserving, so it should be left at [code]0.5[/code] in most cases. See also [member roughness].
</member>
<member name="metallic_texture" type="Texture" setter="set_texture" getter="get_texture">
</member>
<member name="metallic_texture_channel" type="int" setter="set_metallic_texture_channel" getter="get_metallic_texture_channel" enum="SpatialMaterial.TextureChannel">
</member>
<member name="normal_enabled" type="bool" setter="set_feature" getter="get_feature">
+ If [code]true[/code] normal mapping is enabled.
</member>
<member name="normal_scale" type="float" setter="set_normal_scale" getter="get_normal_scale">
+ The strength of the normal map's effect.
</member>
<member name="normal_texture" type="Texture" setter="set_texture" getter="get_texture">
</member>
@@ -123,40 +147,55 @@
<member name="params_billboard_keep_scale" type="bool" setter="set_flag" getter="get_flag">
</member>
<member name="params_billboard_mode" type="int" setter="set_billboard_mode" getter="get_billboard_mode" enum="SpatialMaterial.BillboardMode">
+ Controls how the object faces the camera. See [enum BillboardMode].
</member>
<member name="params_blend_mode" type="int" setter="set_blend_mode" getter="get_blend_mode" enum="SpatialMaterial.BlendMode">
+ The material's blend mode. Note that values other than [code]Mix[/code] force the object into the transparent pipeline. See [enum BlendMode].
</member>
<member name="params_cull_mode" type="int" setter="set_cull_mode" getter="get_cull_mode" enum="SpatialMaterial.CullMode">
+ Which side of the object is not drawn when backfaces are rendered. See [enum CullMode].
</member>
<member name="params_depth_draw_mode" type="int" setter="set_depth_draw_mode" getter="get_depth_draw_mode" enum="SpatialMaterial.DepthDrawMode">
+ Determines when depth rendering takes place. See [enum DepthDrawMode]. See also [member flags_transparent].
</member>
<member name="params_diffuse_mode" type="int" setter="set_diffuse_mode" getter="get_diffuse_mode" enum="SpatialMaterial.DiffuseMode">
+ The algorithm used for diffuse light scattering. See [enum DiffuseMode].
</member>
<member name="params_grow" type="bool" setter="set_grow_enabled" getter="is_grow_enabled">
+ If [code]true[/code] enables the vertex grow setting. See [member params_grow_amount].
</member>
<member name="params_grow_amount" type="float" setter="set_grow" getter="get_grow">
+ Grows object vertices in the direction of their normals.
</member>
<member name="params_line_width" type="float" setter="set_line_width" getter="get_line_width">
</member>
<member name="params_point_size" type="float" setter="set_point_size" getter="get_point_size">
+ The point size in pixels. See [member flags_use_point_size].
</member>
<member name="params_specular_mode" type="int" setter="set_specular_mode" getter="get_specular_mode" enum="SpatialMaterial.SpecularMode">
+ The method for rendering the specular blob. See [enum SpecularMode].
</member>
<member name="params_use_alpha_scissor" type="bool" setter="set_flag" getter="get_flag">
</member>
<member name="particles_anim_h_frames" type="int" setter="set_particles_anim_h_frames" getter="get_particles_anim_h_frames">
+ The number of horizontal frames in the particle spritesheet. Only enabled when using [code]BillboardMode.BILLBOARD_PARTICLES[/code]. See [member params_billboard_mode].
</member>
<member name="particles_anim_loop" type="int" setter="set_particles_anim_loop" getter="get_particles_anim_loop">
+ If [code]true[/code] particle animations are looped. Only enabled when using [code]BillboardMode.BILLBOARD_PARTICLES[/code]. See [member params_billboard_mode].
</member>
<member name="particles_anim_v_frames" type="int" setter="set_particles_anim_v_frames" getter="get_particles_anim_v_frames">
+ The number of vertical frames in the particle spritesheet. Only enabled when using [code]BillboardMode.BILLBOARD_PARTICLES[/code]. See [member params_billboard_mode].
</member>
<member name="proximity_fade_distance" type="float" setter="set_proximity_fade_distance" getter="get_proximity_fade_distance">
</member>
<member name="proximity_fade_enable" type="bool" setter="set_proximity_fade" getter="is_proximity_fade_enabled">
+ If [code]true[/code] the proximity and distance fade effect is enabled. Default value: [code]false[/code].
</member>
<member name="refraction_enabled" type="bool" setter="set_feature" getter="get_feature">
+ If [code]true[/code] the refraction effect is enabled. Distorts transparency based on light from behind the object. Default value: [code]false[/code].
</member>
<member name="refraction_scale" type="float" setter="set_refraction" getter="get_refraction">
+ The strength of the refraction effect.
</member>
<member name="refraction_texture" type="Texture" setter="set_texture" getter="get_texture">
</member>
@@ -165,26 +204,33 @@
<member name="rim" type="float" setter="set_rim" getter="get_rim">
</member>
<member name="rim_enabled" type="bool" setter="set_feature" getter="get_feature">
+ If [code]true[/code] rim effect is enabled. Default value: [code]false[/code].
</member>
<member name="rim_texture" type="Texture" setter="set_texture" getter="get_texture">
</member>
<member name="rim_tint" type="float" setter="set_rim_tint" getter="get_rim_tint">
+ The amount of to blend light and albedo color when rendering rim effect. If [code]0[/code] the light color is used, while [code]1[/code] means albedo color is used. An intermediate value generally works best.
</member>
<member name="roughness" type="float" setter="set_roughness" getter="get_roughness">
+ Surface reflection. A value of [code]0[/code] represents a perfect mirror while a value of [code]1[/code] completely blurs the reflection. See also [member metallic].
</member>
<member name="roughness_texture" type="Texture" setter="set_texture" getter="get_texture">
</member>
<member name="roughness_texture_channel" type="int" setter="set_roughness_texture_channel" getter="get_roughness_texture_channel" enum="SpatialMaterial.TextureChannel">
</member>
<member name="subsurf_scatter_enabled" type="bool" setter="set_feature" getter="get_feature">
+ If [code]true[/code] subsurface scattering is enabled. Emulates light that penetrates an object's surface, is scattered, and then emerges.
</member>
<member name="subsurf_scatter_strength" type="float" setter="set_subsurface_scattering_strength" getter="get_subsurface_scattering_strength">
+ The strength of the subsurface scattering effect.
</member>
<member name="subsurf_scatter_texture" type="Texture" setter="set_texture" getter="get_texture">
</member>
<member name="transmission" type="Color" setter="set_transmission" getter="get_transmission">
+ The color used by the transmission effect. Represents the light passing through an object.
</member>
<member name="transmission_enabled" type="bool" setter="set_feature" getter="get_feature">
+ If [code]true[/code] the transmission effect is enabled. Default value: [code]false[/code].
</member>
<member name="transmission_texture" type="Texture" setter="set_texture" getter="get_texture">
</member>
@@ -205,8 +251,10 @@
<member name="uv2_triplanar_sharpness" type="float" setter="set_uv2_triplanar_blend_sharpness" getter="get_uv2_triplanar_blend_sharpness">
</member>
<member name="vertex_color_is_srgb" type="bool" setter="set_flag" getter="get_flag">
+ If [code]true[/code] the model's vertex colors are processed as sRGB mode. Default value: [code]false[/code].
</member>
<member name="vertex_color_use_as_albedo" type="bool" setter="set_flag" getter="get_flag">
+ If [code]true[/code] the vertex color is used as albedo color. Default value: [code]false[/code].
</member>
</members>
<constants>
@@ -275,6 +323,7 @@
<constant name="FEATURE_MAX" value="12" enum="Feature">
</constant>
<constant name="BLEND_MODE_MIX" value="0" enum="BlendMode">
+ Default blend mode.
</constant>
<constant name="BLEND_MODE_ADD" value="1" enum="BlendMode">
</constant>
@@ -283,18 +332,25 @@
<constant name="BLEND_MODE_MUL" value="3" enum="BlendMode">
</constant>
<constant name="DEPTH_DRAW_OPAQUE_ONLY" value="0" enum="DepthDrawMode">
+ Default depth draw mode. Depth is drawn only for opaque objects.
</constant>
<constant name="DEPTH_DRAW_ALWAYS" value="1" enum="DepthDrawMode">
+ Depth draw is calculated for both opaque and transparent objects.
</constant>
<constant name="DEPTH_DRAW_DISABLED" value="2" enum="DepthDrawMode">
+ No depth draw.
</constant>
<constant name="DEPTH_DRAW_ALPHA_OPAQUE_PREPASS" value="3" enum="DepthDrawMode">
+ For transparent objects, an opaque pass is made first with the opaque parts, then transparency is drawn.
</constant>
<constant name="CULL_BACK" value="0" enum="CullMode">
+ Default cull mode. The back of the object is culled when not visible.
</constant>
<constant name="CULL_FRONT" value="1" enum="CullMode">
+ The front of the object is culled when not visible.
</constant>
<constant name="CULL_DISABLED" value="2" enum="CullMode">
+ No culling is performed.
</constant>
<constant name="FLAG_UNSHADED" value="0" enum="Flags">
</constant>
@@ -335,32 +391,46 @@
<constant name="FLAG_MAX" value="18" enum="Flags">
</constant>
<constant name="DIFFUSE_BURLEY" value="0" enum="DiffuseMode">
+ Default diffuse scattering algorithm.
</constant>
<constant name="DIFFUSE_LAMBERT" value="1" enum="DiffuseMode">
+ Diffuse scattering ignores roughness.
</constant>
<constant name="DIFFUSE_LAMBERT_WRAP" value="2" enum="DiffuseMode">
+ Extends Lambert to cover more than 90 degrees when roughness increases.
</constant>
<constant name="DIFFUSE_OREN_NAYAR" value="3" enum="DiffuseMode">
+ Attempts to use roughness to emulate microsurfacing.
</constant>
<constant name="DIFFUSE_TOON" value="4" enum="DiffuseMode">
+ Uses a hard cut for lighting, with smoothing affected by roughness.
</constant>
<constant name="SPECULAR_SCHLICK_GGX" value="0" enum="SpecularMode">
+ Default specular blob.
</constant>
<constant name="SPECULAR_BLINN" value="1" enum="SpecularMode">
+ Older specular algorithm, included for compatibility.
</constant>
<constant name="SPECULAR_PHONG" value="2" enum="SpecularMode">
+ Older specular algorithm, included for compatibility.
</constant>
<constant name="SPECULAR_TOON" value="3" enum="SpecularMode">
+ Toon blob which changes size based on roughness.
</constant>
<constant name="SPECULAR_DISABLED" value="4" enum="SpecularMode">
+ No specular blob.
</constant>
<constant name="BILLBOARD_DISABLED" value="0" enum="BillboardMode">
+ Default value.
</constant>
<constant name="BILLBOARD_ENABLED" value="1" enum="BillboardMode">
+ The object's z-axis will always face the camera.
</constant>
<constant name="BILLBOARD_FIXED_Y" value="2" enum="BillboardMode">
+ The object's x-axis will always face the camera.
</constant>
<constant name="BILLBOARD_PARTICLES" value="3" enum="BillboardMode">
+ Used for particle systems. Enables particle animation options.
</constant>
<constant name="TEXTURE_CHANNEL_RED" value="0" enum="TextureChannel">
</constant>
diff --git a/doc/classes/SpinBox.xml b/doc/classes/SpinBox.xml
index 0fcd5bbaf5..5087cf355a 100644
--- a/doc/classes/SpinBox.xml
+++ b/doc/classes/SpinBox.xml
@@ -19,6 +19,8 @@
</method>
</methods>
<members>
+ <member name="align" type="int" setter="set_align" getter="get_align" enum="LineEdit.Align">
+ </member>
<member name="editable" type="bool" setter="set_editable" getter="is_editable">
</member>
<member name="prefix" type="String" setter="set_prefix" getter="get_prefix">
diff --git a/doc/classes/StreamPeerSSL.xml b/doc/classes/StreamPeerSSL.xml
index cf8769d22b..33948df509 100644
--- a/doc/classes/StreamPeerSSL.xml
+++ b/doc/classes/StreamPeerSSL.xml
@@ -63,6 +63,8 @@
<constant name="STATUS_DISCONNECTED" value="0" enum="Status">
A status representing a [code]StreamPeerSSL[/code] that is disconnected.
</constant>
+ <constant name="STATUS_HANDSHAKING" value="1" enum="Status">
+ </constant>
<constant name="STATUS_CONNECTED" value="2" enum="Status">
A status representing a [code]StreamPeerSSL[/code] that is connected to a host.
</constant>
diff --git a/doc/classes/StreamPeerTCP.xml b/doc/classes/StreamPeerTCP.xml
index 664ffc60c3..9a0fceddab 100644
--- a/doc/classes/StreamPeerTCP.xml
+++ b/doc/classes/StreamPeerTCP.xml
@@ -4,7 +4,7 @@
TCP Stream peer.
</brief_description>
<description>
- TCP Stream peer. This object can be used to connect to TCP servers, or also is returned by a tcp server.
+ TCP Stream peer. This object can be used to connect to TCP servers, or also is returned by a TCP server.
</description>
<tutorials>
</tutorials>
@@ -54,6 +54,7 @@
<return type="bool">
</return>
<description>
+ Returns [code]true[/code] if this peer is currently connected to a host, [code]false[code] otherwise.
</description>
</method>
<method name="set_no_delay">
diff --git a/doc/classes/String.xml b/doc/classes/String.xml
index d404c32b38..536165487d 100644
--- a/doc/classes/String.xml
+++ b/doc/classes/String.xml
@@ -671,6 +671,7 @@
<return type="PoolByteArray">
</return>
<description>
+ Returns the SHA-256 hash of the string as an array of bytes.
</description>
</method>
<method name="sha256_text">
diff --git a/doc/classes/SurfaceTool.xml b/doc/classes/SurfaceTool.xml
index deda7bc292..4f9ac68e47 100644
--- a/doc/classes/SurfaceTool.xml
+++ b/doc/classes/SurfaceTool.xml
@@ -14,6 +14,7 @@
[/codeblock]
The [code]SurfaceTool[/code] now contains one vertex of a triangle which has a UV coordinate and a specified [Color]. If another vertex were added without calls to [method add_uv] or [method add_color] then the last values would be used.
It is very important that vertex attributes are passed [b]before[/b] the call to [method add_vertex], failure to do this will result in an error when committing the vertex information to a mesh.
+ Additionally, the attributes used before the first vertex is added determine the format of the mesh. For example if you only add UVs to the first vertex, you cannot add color to any of the subsequent vertices.
</description>
<tutorials>
</tutorials>
@@ -26,7 +27,7 @@
<argument index="0" name="bones" type="PoolIntArray">
</argument>
<description>
- Add an array of bones for the next Vertex to use.
+ Add an array of bones for the next Vertex to use. Array must contain 4 integers.
</description>
</method>
<method name="add_color">
@@ -99,6 +100,7 @@
</argument>
<description>
Insert a triangle fan made of array data into [Mesh] being constructed.
+ Requires primitive type be set to [code]PRIMITIVE_TRIANGLES[/code].
</description>
</method>
<method name="add_uv">
@@ -134,7 +136,7 @@
<argument index="0" name="weights" type="PoolRealArray">
</argument>
<description>
- Specify weight value for next Vertex to use.
+ Specify weight values for next Vertex to use. Array must contain 4 values.
</description>
</method>
<method name="append_from">
@@ -147,6 +149,7 @@
<argument index="2" name="transform" type="Transform">
</argument>
<description>
+ Append vertices from a given [Mesh] surface onto the current vertex array with specified [Transform].
</description>
</method>
<method name="begin">
@@ -184,6 +187,7 @@
<argument index="1" name="surface" type="int">
</argument>
<description>
+ Creates a vertex array from an existing [Mesh].
</description>
</method>
<method name="deindex">
@@ -201,12 +205,15 @@
<description>
Generates normals from Vertices so you do not have to do it manually.
Setting "flip" [code]true[/code] inverts resulting normals.
+ Requires primitive type to be set to [code]PRIMITIVE_TRIANGLES[/code].
</description>
</method>
<method name="generate_tangents">
<return type="void">
</return>
<description>
+ Generates a tangent vector for each vertex.
+ Requires that each vertex have UVs and normals set already.
</description>
</method>
<method name="index">
diff --git a/doc/classes/TabContainer.xml b/doc/classes/TabContainer.xml
index 5acfd6194e..f17c10b31e 100644
--- a/doc/classes/TabContainer.xml
+++ b/doc/classes/TabContainer.xml
@@ -82,6 +82,7 @@
<return type="int">
</return>
<description>
+ Returns the [code]TabContainer[/code] rearrange group id.
</description>
</method>
<method name="set_popup">
@@ -132,6 +133,7 @@
<argument index="0" name="group_id" type="int">
</argument>
<description>
+ Defines rearrange group id, choose for each [code]TabContainer[/code] the same value to enable tab drag between [code]TabContainer[/code]. Enable drag with [code]set_drag_to_rearrange_enabled(true)[/code].
</description>
</method>
</methods>
@@ -140,6 +142,7 @@
The current tab index. When set, this index's [Control] node's [code]visible[/code] property is set to [code]true[/code] and all others are set to [code]false[/code].
</member>
<member name="drag_to_rearrange_enabled" type="bool" setter="set_drag_to_rearrange_enabled" getter="get_drag_to_rearrange_enabled">
+ If [code]true[/code], tabs can be rearranged with mouse drag.
</member>
<member name="tab_align" type="int" setter="set_tab_align" getter="get_tab_align" enum="TabContainer.TabAlign">
The alignment of all tabs in the tab container. See the [code]ALIGN_*[/code] constants for details.
@@ -171,10 +174,13 @@
</signals>
<constants>
<constant name="ALIGN_LEFT" value="0" enum="TabAlign">
+ Align the tabs to the left.
</constant>
<constant name="ALIGN_CENTER" value="1" enum="TabAlign">
+ Align the tabs to the center.
</constant>
<constant name="ALIGN_RIGHT" value="2" enum="TabAlign">
+ Align the tabs to the right.
</constant>
</constants>
<theme_items>
diff --git a/doc/classes/Tabs.xml b/doc/classes/Tabs.xml
index fc1d0476ed..350b49513d 100644
--- a/doc/classes/Tabs.xml
+++ b/doc/classes/Tabs.xml
@@ -19,6 +19,7 @@
<argument index="1" name="icon" type="Texture" default="null">
</argument>
<description>
+ Adds a new tab.
</description>
</method>
<method name="ensure_tab_visible">
@@ -27,6 +28,7 @@
<argument index="0" name="idx" type="int">
</argument>
<description>
+ Moves the Scroll view to make the tab visible.
</description>
</method>
<method name="get_offset_buttons_visible" qualifiers="const">
@@ -39,12 +41,14 @@
<return type="bool">
</return>
<description>
+ Returns [code]true[/code] if select with right mouse button is enabled.
</description>
</method>
<method name="get_tab_count" qualifiers="const">
<return type="int">
</return>
<description>
+ Returns the number of tabs.
</description>
</method>
<method name="get_tab_disabled" qualifiers="const">
@@ -53,6 +57,7 @@
<argument index="0" name="tab_idx" type="int">
</argument>
<description>
+ Returns [code]true[/code] if the tab at index [code]tab_idx[/code] is disabled.
</description>
</method>
<method name="get_tab_icon" qualifiers="const">
@@ -61,6 +66,7 @@
<argument index="0" name="tab_idx" type="int">
</argument>
<description>
+ Returns the [Texture] for the tab at index [code]tab_idx[/code] or null if the tab has no [Texture].
</description>
</method>
<method name="get_tab_offset" qualifiers="const">
@@ -84,12 +90,14 @@
<argument index="0" name="tab_idx" type="int">
</argument>
<description>
+ Returns the title of the tab at index [code]tab_idx[/code]. Tab titles default to the name of the indexed child node, but this can be overridden with [method set_tab_title].
</description>
</method>
<method name="get_tabs_rearrange_group" qualifiers="const">
<return type="int">
</return>
<description>
+ Returns the [code]Tabs[/code] rearrange group id.
</description>
</method>
<method name="move_tab">
@@ -109,6 +117,7 @@
<argument index="0" name="tab_idx" type="int">
</argument>
<description>
+ Removes tab at index [code]tab_idx[/code]
</description>
</method>
<method name="set_select_with_rmb">
@@ -117,6 +126,7 @@
<argument index="0" name="enabled" type="bool">
</argument>
<description>
+ If [code]true[/code] enables selecting a tab with right mouse button.
</description>
</method>
<method name="set_tab_disabled">
@@ -127,6 +137,7 @@
<argument index="1" name="disabled" type="bool">
</argument>
<description>
+ If [code]disabled[/code] is false, hides the tab at index [code]tab_idx[/code]. Note that its title text will remain, unless also removed with [method set_tab_title].
</description>
</method>
<method name="set_tab_icon">
@@ -137,6 +148,7 @@
<argument index="1" name="icon" type="Texture">
</argument>
<description>
+ Sets an icon for the tab at index [code]tab_idx[/code].
</description>
</method>
<method name="set_tab_title">
@@ -147,6 +159,7 @@
<argument index="1" name="title" type="String">
</argument>
<description>
+ Sets a title for the tab at index [code]tab_idx[/code].
</description>
</method>
<method name="set_tabs_rearrange_group">
@@ -155,17 +168,21 @@
<argument index="0" name="group_id" type="int">
</argument>
<description>
+ Defines rearrange group id, choose for each [code]Tabs[/code] the same value to enable tab drag between [code]Tabs[/code]. Enable drag with [code]set_drag_to_rearrange_enabled(true)[/code].
</description>
</method>
</methods>
<members>
<member name="current_tab" type="int" setter="set_current_tab" getter="get_current_tab">
+ Select tab at index [code]tab_idx[/code].
</member>
<member name="drag_to_rearrange_enabled" type="bool" setter="set_drag_to_rearrange_enabled" getter="get_drag_to_rearrange_enabled">
+ If [code]true[/code], tabs can be rearranged with mouse drag.
</member>
<member name="scrolling_enabled" type="bool" setter="set_scrolling_enabled" getter="get_scrolling_enabled">
</member>
<member name="tab_align" type="int" setter="set_tab_align" getter="get_tab_align" enum="Tabs.TabAlign">
+ The alignment of all tabs. See enum [code]TabAlign[/code] constants for details.
</member>
<member name="tab_close_display_policy" type="int" setter="set_tab_close_display_policy" getter="get_tab_close_display_policy" enum="Tabs.CloseButtonDisplayPolicy">
</member>
@@ -210,10 +227,13 @@
</signals>
<constants>
<constant name="ALIGN_LEFT" value="0" enum="TabAlign">
+ Align the tabs to the left.
</constant>
<constant name="ALIGN_CENTER" value="1" enum="TabAlign">
+ Align the tabs to the center.
</constant>
<constant name="ALIGN_RIGHT" value="2" enum="TabAlign">
+ Align the tabs to the right.
</constant>
<constant name="ALIGN_MAX" value="3" enum="TabAlign">
</constant>
diff --git a/doc/classes/TextureProgress.xml b/doc/classes/TextureProgress.xml
index f74420e8b1..3cbaf0429c 100644
--- a/doc/classes/TextureProgress.xml
+++ b/doc/classes/TextureProgress.xml
@@ -52,10 +52,13 @@
[Texture] that draws under the progress bar. The bar's background.
</member>
<member name="tint_over" type="Color" setter="set_tint_over" getter="get_tint_over">
+ Multiplies the color of the bar's [code]texture_over[/code] texture. The effect is similar to [member CanvasItem.modulate], except it only affects this specific texture instead of the entire node.
</member>
<member name="tint_progress" type="Color" setter="set_tint_progress" getter="get_tint_progress">
+ Multiplies the color of the bar's [code]texture_progress[/code] texture.
</member>
<member name="tint_under" type="Color" setter="set_tint_under" getter="get_tint_under">
+ Multiplies the color of the bar's [code]texture_under[/code] texture.
</member>
</members>
<constants>
@@ -72,16 +75,19 @@
The [member texture_progress] fills from bottom to top.
</constant>
<constant name="FILL_CLOCKWISE" value="4" enum="FillMode">
- Turns the node into a radial bar. The [member texture_progress] fills clockwise. See [member radial_center_offset], [member radial_initial_angle] and [member radial_fill_degrees] to refine its behavior.
+ Turns the node into a radial bar. The [member texture_progress] fills clockwise. See [member radial_center_offset], [member radial_initial_angle] and [member radial_fill_degrees] to control the way the bar fills up.
</constant>
<constant name="FILL_COUNTER_CLOCKWISE" value="5" enum="FillMode">
- Turns the node into a radial bar. The [member texture_progress] fills counter-clockwise. See [member radial_center_offset], [member radial_initial_angle] and [member radial_fill_degrees] to refine its behavior.
+ Turns the node into a radial bar. The [member texture_progress] fills counter-clockwise. See [member radial_center_offset], [member radial_initial_angle] and [member radial_fill_degrees] to control the way the bar fills up.
</constant>
<constant name="FILL_BILINEAR_LEFT_AND_RIGHT" value="6" enum="FillMode">
+ The [member texture_progress] fills from the center, expanding both towards the left and the right.
</constant>
<constant name="FILL_BILINEAR_TOP_AND_BOTTOM" value="7" enum="FillMode">
+ The [member texture_progress] fills from the center, expanding both towards the top and the bottom.
</constant>
<constant name="FILL_CLOCKWISE_AND_COUNTER_CLOCKWISE" value="8" enum="FillMode">
+ Turns the node into a radial bar. The [member texture_progress] fills radially from the center, expanding both clockwise and counter-clockwise. See [member radial_center_offset], [member radial_initial_angle] and [member radial_fill_degrees] to control the way the bar fills up.
</constant>
</constants>
</class>
diff --git a/doc/classes/TileSet.xml b/doc/classes/TileSet.xml
index 3f0d6317a6..ffd15e8d8b 100644
--- a/doc/classes/TileSet.xml
+++ b/doc/classes/TileSet.xml
@@ -268,7 +268,7 @@
<argument index="1" name="shape_id" type="int">
</argument>
<description>
- Returns the [Transform2D] of a tile's sahpe.
+ Returns the [Transform2D] of a tile's shape.
</description>
</method>
<method name="tile_get_shapes" qualifiers="const">
diff --git a/doc/classes/Tree.xml b/doc/classes/Tree.xml
index 0431718066..8051062fc4 100644
--- a/doc/classes/Tree.xml
+++ b/doc/classes/Tree.xml
@@ -230,7 +230,7 @@
The amount of columns.
</member>
<member name="drop_mode_flags" type="int" setter="set_drop_mode_flags" getter="get_drop_mode_flags">
- The drop mode as an OR combination of flags. See [code]DROP_MODE_*[/code] constants. Once dropping is done, reverts to [code]DROP_MODE_DISABLED[/code]. Setting this during [method can_drop_data] is recommended.
+ The drop mode as an OR combination of flags. See [code]DROP_MODE_*[/code] constants. Once dropping is done, reverts to [code]DROP_MODE_DISABLED[/code]. Setting this during [method Control.can_drop_data] is recommended.
</member>
<member name="hide_folding" type="bool" setter="set_hide_folding" getter="is_folding_hidden">
If [code]true[/code] the folding arrow is hidden.
diff --git a/doc/classes/TreeItem.xml b/doc/classes/TreeItem.xml
index c5a63b1acb..b4227b34be 100644
--- a/doc/classes/TreeItem.xml
+++ b/doc/classes/TreeItem.xml
@@ -25,7 +25,7 @@
<argument index="4" name="tooltip" type="String" default="&quot;&quot;">
</argument>
<description>
- Adds a button with [Texture] [code]button[/code] at column [code]column[/code]. The [code]button_idx[/code] index is used to identify the button when calling other methods. If not specified, the next available index is used, which may be retrieved by calling [code]get_buton_count()[/code] immediately after this method. Optionally, the button can be [code]disabled[/code] and have a [code]tooltip[/code].
+ Adds a button with [Texture] [code]button[/code] at column [code]column[/code]. The [code]button_idx[/code] index is used to identify the button when calling other methods. If not specified, the next available index is used, which may be retrieved by calling [method get_button_count] immediately after this method. Optionally, the button can be [code]disabled[/code] and have a [code]tooltip[/code].
</description>
</method>
<method name="clear_custom_bg_color">
@@ -559,13 +559,10 @@
<constant name="CELL_MODE_RANGE" value="2" enum="TreeCellMode">
Cell contains a range.
</constant>
- <constant name="CELL_MODE_RANGE_EXPRESSION" value="3" enum="TreeCellMode">
- Cell contains a range expression.
- </constant>
- <constant name="CELL_MODE_ICON" value="4" enum="TreeCellMode">
+ <constant name="CELL_MODE_ICON" value="3" enum="TreeCellMode">
Cell contains an icon.
</constant>
- <constant name="CELL_MODE_CUSTOM" value="5" enum="TreeCellMode">
+ <constant name="CELL_MODE_CUSTOM" value="4" enum="TreeCellMode">
</constant>
<constant name="ALIGN_LEFT" value="0" enum="TextAlign">
Align text to the left. See [code]set_text_align()[/code].
diff --git a/doc/classes/Vector2.xml b/doc/classes/Vector2.xml
index 7e03e7f0fe..1f8eb47044 100644
--- a/doc/classes/Vector2.xml
+++ b/doc/classes/Vector2.xml
@@ -259,15 +259,18 @@
</methods>
<members>
<member name="x" type="float" setter="" getter="">
- The vector's x component.
+ The vector's x component. Also accessible by using the index position [code][0][/code].
</member>
<member name="y" type="float" setter="" getter="">
- The vector's y component.
+ The vector's y component. Also accessible by using the index position [code][1][/code].
</member>
</members>
<constants>
<constant name="ZERO" value="Vector2( 0, 0 )">
- Null vector.
+ Zero vector.
+ </constant>
+ <constant name="ONE" value="Vector2( 1, 1 )">
+ One vector.
</constant>
<constant name="INF" value="Vector2( inf, inf )">
Infinite vector.
diff --git a/doc/classes/Vector3.xml b/doc/classes/Vector3.xml
index 4211c34d8e..2499ba75ff 100644
--- a/doc/classes/Vector3.xml
+++ b/doc/classes/Vector3.xml
@@ -260,13 +260,13 @@
</methods>
<members>
<member name="x" type="float" setter="" getter="">
- The vector's x component.
+ The vector's x component. Also accessible by using the index position [code][0][/code].
</member>
<member name="y" type="float" setter="" getter="">
- The vector's y component.
+ The vector's y component. Also accessible by using the index position [code][1][/code].
</member>
<member name="z" type="float" setter="" getter="">
- The vector's z component.
+ The vector's z component. Also accessible by using the index position [code][2][/code].
</member>
</members>
<constants>
@@ -280,7 +280,10 @@
Enumerated value for the Z axis.
</constant>
<constant name="ZERO" value="Vector3( 0, 0, 0 )">
- Null vector.
+ Zero vector.
+ </constant>
+ <constant name="ONE" value="Vector3( 1, 1, 1 )">
+ One vector.
</constant>
<constant name="INF" value="Vector3( inf, inf, inf )">
Infinite vector.
diff --git a/doc/classes/VisualServer.xml b/doc/classes/VisualServer.xml
index 58b3d33cdb..225a1f2bba 100644
--- a/doc/classes/VisualServer.xml
+++ b/doc/classes/VisualServer.xml
@@ -4380,7 +4380,7 @@
</constant>
<constant name="ENV_TONE_MAPPER_LINEAR" value="0" enum="EnvironmentToneMapper">
</constant>
- <constant name="ENV_TONE_MAPPER_REINHARDT" value="1" enum="EnvironmentToneMapper">
+ <constant name="ENV_TONE_MAPPER_REINHARD" value="1" enum="EnvironmentToneMapper">
</constant>
<constant name="ENV_TONE_MAPPER_FILMIC" value="2" enum="EnvironmentToneMapper">
</constant>
diff --git a/doc/classes/YSort.xml b/doc/classes/YSort.xml
index 12b9cb623f..45ae8645b1 100644
--- a/doc/classes/YSort.xml
+++ b/doc/classes/YSort.xml
@@ -14,6 +14,7 @@
</methods>
<members>
<member name="sort_enabled" type="bool" setter="set_sort_enabled" getter="is_sort_enabled">
+ If [code]true[/code] child nodes are sorted, otherwise sorting is disabled. Default: [code]true[/code].
</member>
</members>
<constants>
diff --git a/drivers/coreaudio/audio_driver_coreaudio.cpp b/drivers/coreaudio/audio_driver_coreaudio.cpp
index 09e50e4aaa..850b90d59b 100644
--- a/drivers/coreaudio/audio_driver_coreaudio.cpp
+++ b/drivers/coreaudio/audio_driver_coreaudio.cpp
@@ -95,11 +95,6 @@ Error AudioDriverCoreAudio::init() {
result = AudioObjectAddPropertyListener(kAudioObjectSystemObject, &prop, &output_device_address_cb, this);
ERR_FAIL_COND_V(result != noErr, FAILED);
-
- prop.mSelector = kAudioHardwarePropertyDefaultInputDevice;
-
- result = AudioObjectAddPropertyListener(kAudioObjectSystemObject, &prop, &input_device_address_cb, this);
- ERR_FAIL_COND_V(result != noErr, FAILED);
#endif
AudioStreamBasicDescription strdesc;
@@ -123,26 +118,6 @@ Error AudioDriverCoreAudio::init() {
break;
}
- zeromem(&strdesc, sizeof(strdesc));
- size = sizeof(strdesc);
- result = AudioUnitGetProperty(audio_unit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output, kInputBus, &strdesc, &size);
- ERR_FAIL_COND_V(result != noErr, FAILED);
-
- switch (strdesc.mChannelsPerFrame) {
- case 1: // Mono
- capture_channels = 1;
- break;
-
- case 2: // Stereo
- capture_channels = 2;
- break;
-
- default:
- // Unknown number of channels, default to stereo
- capture_channels = 2;
- break;
- }
-
mix_rate = GLOBAL_DEF_RST("audio/mix_rate", DEFAULT_MIX_RATE);
zeromem(&strdesc, sizeof(strdesc));
@@ -158,11 +133,6 @@ Error AudioDriverCoreAudio::init() {
result = AudioUnitSetProperty(audio_unit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, kOutputBus, &strdesc, sizeof(strdesc));
ERR_FAIL_COND_V(result != noErr, FAILED);
- strdesc.mChannelsPerFrame = capture_channels;
-
- result = AudioUnitSetProperty(audio_unit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output, kInputBus, &strdesc, sizeof(strdesc));
- ERR_FAIL_COND_V(result != noErr, FAILED);
-
int latency = GLOBAL_DEF_RST("audio/output_latency", DEFAULT_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);
@@ -175,9 +145,6 @@ Error AudioDriverCoreAudio::init() {
unsigned int buffer_size = buffer_frames * channels;
samples_in.resize(buffer_size);
input_buf.resize(buffer_size);
- input_buffer.resize(buffer_size * 8);
- input_position = 0;
- input_size = 0;
print_verbose("CoreAudio: detected " + itos(channels) + " channels");
print_verbose("CoreAudio: audio buffer frames: " + itos(buffer_frames) + " calculated latency: " + itos(buffer_frames * 1000 / mix_rate) + "ms");
@@ -189,16 +156,10 @@ Error AudioDriverCoreAudio::init() {
result = AudioUnitSetProperty(audio_unit, kAudioUnitProperty_SetRenderCallback, kAudioUnitScope_Input, kOutputBus, &callback, sizeof(callback));
ERR_FAIL_COND_V(result != noErr, FAILED);
- zeromem(&callback, sizeof(AURenderCallbackStruct));
- callback.inputProc = &AudioDriverCoreAudio::input_callback;
- callback.inputProcRefCon = this;
- result = AudioUnitSetProperty(audio_unit, kAudioOutputUnitProperty_SetInputCallback, kAudioUnitScope_Global, 0, &callback, sizeof(callback));
- ERR_FAIL_COND_V(result != noErr, FAILED);
-
result = AudioUnitInitialize(audio_unit);
ERR_FAIL_COND_V(result != noErr, FAILED);
- return OK;
+ return capture_init();
}
OSStatus AudioDriverCoreAudio::output_callback(void *inRefCon,
@@ -265,7 +226,7 @@ OSStatus AudioDriverCoreAudio::input_callback(void *inRefCon,
bufferList.mBuffers[0].mNumberChannels = ad->capture_channels;
bufferList.mBuffers[0].mDataByteSize = ad->input_buf.size() * sizeof(int16_t);
- OSStatus result = AudioUnitRender(ad->audio_unit, ioActionFlags, inTimeStamp, inBusNumber, inNumberFrames, &bufferList);
+ OSStatus result = AudioUnitRender(ad->input_unit, ioActionFlags, inTimeStamp, inBusNumber, inNumberFrames, &bufferList);
if (result == noErr) {
for (int i = 0; i < inNumberFrames * ad->capture_channels; i++) {
int32_t sample = ad->input_buf[i] << 16;
@@ -277,7 +238,7 @@ OSStatus AudioDriverCoreAudio::input_callback(void *inRefCon,
}
}
} else {
- ERR_PRINT(("AudioUnitRender failed, code: " + itos(result)).utf8().get_data());
+ ERR_PRINTS("AudioUnitRender failed, code: " + itos(result));
}
ad->unlock();
@@ -289,7 +250,7 @@ void AudioDriverCoreAudio::start() {
if (!active) {
OSStatus result = AudioOutputUnitStart(audio_unit);
if (result != noErr) {
- ERR_PRINT(("AudioOutputUnitStart failed, code: " + itos(result)).utf8().get_data());
+ ERR_PRINTS("AudioOutputUnitStart failed, code: " + itos(result));
} else {
active = true;
}
@@ -300,7 +261,7 @@ void AudioDriverCoreAudio::stop() {
if (active) {
OSStatus result = AudioOutputUnitStop(audio_unit);
if (result != noErr) {
- ERR_PRINT(("AudioOutputUnitStop failed, code: " + itos(result)).utf8().get_data());
+ ERR_PRINTS("AudioOutputUnitStop failed, code: " + itos(result));
} else {
active = false;
}
@@ -332,6 +293,8 @@ bool AudioDriverCoreAudio::try_lock() {
}
void AudioDriverCoreAudio::finish() {
+ capture_finish();
+
if (audio_unit) {
OSStatus result;
@@ -375,6 +338,7 @@ void AudioDriverCoreAudio::finish() {
ERR_PRINT("AudioComponentInstanceDispose failed");
}
+ audio_unit = NULL;
unlock();
}
@@ -384,20 +348,160 @@ void AudioDriverCoreAudio::finish() {
}
}
-Error AudioDriverCoreAudio::capture_start() {
+Error AudioDriverCoreAudio::capture_init() {
+ AudioComponentDescription desc;
+ zeromem(&desc, sizeof(desc));
+ desc.componentType = kAudioUnitType_Output;
+#ifdef OSX_ENABLED
+ desc.componentSubType = kAudioUnitSubType_HALOutput;
+#else
+ desc.componentSubType = kAudioUnitSubType_RemoteIO;
+#endif
+ desc.componentManufacturer = kAudioUnitManufacturer_Apple;
+
+ AudioComponent comp = AudioComponentFindNext(NULL, &desc);
+ ERR_FAIL_COND_V(comp == NULL, FAILED);
+
+ OSStatus result = AudioComponentInstanceNew(comp, &input_unit);
+ ERR_FAIL_COND_V(result != noErr, FAILED);
+
+#ifdef OSX_ENABLED
+ AudioObjectPropertyAddress prop;
+ prop.mSelector = kAudioHardwarePropertyDefaultInputDevice;
+ prop.mScope = kAudioObjectPropertyScopeGlobal;
+ prop.mElement = kAudioObjectPropertyElementMaster;
+
+ result = AudioObjectAddPropertyListener(kAudioObjectSystemObject, &prop, &input_device_address_cb, this);
+ ERR_FAIL_COND_V(result != noErr, FAILED);
+#endif
UInt32 flag = 1;
- OSStatus result = AudioUnitSetProperty(audio_unit, kAudioOutputUnitProperty_EnableIO, kAudioUnitScope_Input, kInputBus, &flag, sizeof(flag));
+ result = AudioUnitSetProperty(input_unit, kAudioOutputUnitProperty_EnableIO, kAudioUnitScope_Input, kInputBus, &flag, sizeof(flag));
+ ERR_FAIL_COND_V(result != noErr, FAILED);
+ flag = 0;
+ result = AudioUnitSetProperty(input_unit, kAudioOutputUnitProperty_EnableIO, kAudioUnitScope_Output, kOutputBus, &flag, sizeof(flag));
+ ERR_FAIL_COND_V(result != noErr, FAILED);
+
+ UInt32 size;
+#ifdef OSX_ENABLED
+ AudioDeviceID deviceId;
+ size = sizeof(AudioDeviceID);
+ AudioObjectPropertyAddress property = { kAudioHardwarePropertyDefaultInputDevice, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster };
+
+ result = AudioObjectGetPropertyData(kAudioObjectSystemObject, &property, 0, NULL, &size, &deviceId);
+ ERR_FAIL_COND_V(result != noErr, FAILED);
+
+ result = AudioUnitSetProperty(input_unit, kAudioOutputUnitProperty_CurrentDevice, kAudioUnitScope_Global, 0, &deviceId, sizeof(AudioDeviceID));
+ ERR_FAIL_COND_V(result != noErr, FAILED);
+#endif
+
+ AudioStreamBasicDescription strdesc;
+ zeromem(&strdesc, sizeof(strdesc));
+ size = sizeof(strdesc);
+ result = AudioUnitGetProperty(input_unit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output, kInputBus, &strdesc, &size);
+ ERR_FAIL_COND_V(result != noErr, FAILED);
+
+ switch (strdesc.mChannelsPerFrame) {
+ case 1: // Mono
+ capture_channels = 1;
+ break;
+
+ case 2: // Stereo
+ capture_channels = 2;
+ break;
+
+ default:
+ // Unknown number of channels, default to stereo
+ capture_channels = 2;
+ break;
+ }
+
+ mix_rate = GLOBAL_DEF_RST("audio/mix_rate", DEFAULT_MIX_RATE);
+
+ zeromem(&strdesc, sizeof(strdesc));
+ strdesc.mFormatID = kAudioFormatLinearPCM;
+ strdesc.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger | kLinearPCMFormatFlagIsPacked;
+ strdesc.mChannelsPerFrame = capture_channels;
+ strdesc.mSampleRate = mix_rate;
+ strdesc.mFramesPerPacket = 1;
+ strdesc.mBitsPerChannel = 16;
+ strdesc.mBytesPerFrame = strdesc.mBitsPerChannel * strdesc.mChannelsPerFrame / 8;
+ strdesc.mBytesPerPacket = strdesc.mBytesPerFrame * strdesc.mFramesPerPacket;
+
+ result = AudioUnitSetProperty(input_unit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output, kInputBus, &strdesc, sizeof(strdesc));
+ ERR_FAIL_COND_V(result != noErr, FAILED);
+
+ AURenderCallbackStruct callback;
+ zeromem(&callback, sizeof(AURenderCallbackStruct));
+ callback.inputProc = &AudioDriverCoreAudio::input_callback;
+ callback.inputProcRefCon = this;
+ result = AudioUnitSetProperty(input_unit, kAudioOutputUnitProperty_SetInputCallback, kAudioUnitScope_Global, kInputBus, &callback, sizeof(callback));
+ ERR_FAIL_COND_V(result != noErr, FAILED);
+
+ result = AudioUnitInitialize(input_unit);
ERR_FAIL_COND_V(result != noErr, FAILED);
return OK;
}
+void AudioDriverCoreAudio::capture_finish() {
+ if (input_unit) {
+ lock();
+
+ AURenderCallbackStruct callback;
+ zeromem(&callback, sizeof(AURenderCallbackStruct));
+ OSStatus result = AudioUnitSetProperty(input_unit, kAudioOutputUnitProperty_SetInputCallback, kAudioUnitScope_Global, 0, &callback, sizeof(callback));
+ if (result != noErr) {
+ ERR_PRINT("AudioUnitSetProperty failed");
+ }
+
+ result = AudioUnitUninitialize(input_unit);
+ if (result != noErr) {
+ ERR_PRINT("AudioUnitUninitialize failed");
+ }
+
+#ifdef OSX_ENABLED
+ AudioObjectPropertyAddress prop;
+ prop.mSelector = kAudioHardwarePropertyDefaultInputDevice;
+ prop.mScope = kAudioObjectPropertyScopeGlobal;
+ prop.mElement = kAudioObjectPropertyElementMaster;
+
+ result = AudioObjectRemovePropertyListener(kAudioObjectSystemObject, &prop, &input_device_address_cb, this);
+ if (result != noErr) {
+ ERR_PRINT("AudioObjectRemovePropertyListener failed");
+ }
+#endif
+
+ result = AudioComponentInstanceDispose(input_unit);
+ if (result != noErr) {
+ ERR_PRINT("AudioComponentInstanceDispose failed");
+ }
+
+ input_unit = NULL;
+ unlock();
+ }
+}
+
+Error AudioDriverCoreAudio::capture_start() {
+
+ input_buffer_init(buffer_frames);
+
+ OSStatus result = AudioOutputUnitStart(input_unit);
+ if (result != noErr) {
+ ERR_PRINTS("AudioOutputUnitStart failed, code: " + itos(result));
+ }
+
+ return OK;
+}
+
Error AudioDriverCoreAudio::capture_stop() {
- UInt32 flag = 0;
- OSStatus result = AudioUnitSetProperty(audio_unit, kAudioOutputUnitProperty_EnableIO, kAudioUnitScope_Input, kInputBus, &flag, sizeof(flag));
- ERR_FAIL_COND_V(result != noErr, FAILED);
+ if (input_unit) {
+ OSStatus result = AudioOutputUnitStop(input_unit);
+ if (result != noErr) {
+ ERR_PRINTS("AudioOutputUnitStop failed, code: " + itos(result));
+ }
+ }
return OK;
}
@@ -531,12 +635,14 @@ void AudioDriverCoreAudio::_set_device(const String &device, bool capture) {
}
if (found) {
- OSStatus result = AudioUnitSetProperty(audio_unit, kAudioOutputUnitProperty_CurrentDevice, kAudioUnitScope_Global, capture ? kInputBus : kOutputBus, &deviceId, sizeof(AudioDeviceID));
+ OSStatus result = AudioUnitSetProperty(capture ? input_unit : audio_unit, kAudioOutputUnitProperty_CurrentDevice, kAudioUnitScope_Global, 0, &deviceId, sizeof(AudioDeviceID));
ERR_FAIL_COND(result != noErr);
- // Reset audio input to keep synchronisation.
- input_position = 0;
- input_size = 0;
+ if (capture) {
+ // Reset audio input to keep synchronisation.
+ input_position = 0;
+ input_size = 0;
+ }
}
}
@@ -580,6 +686,7 @@ String AudioDriverCoreAudio::capture_get_device() {
AudioDriverCoreAudio::AudioDriverCoreAudio() {
audio_unit = NULL;
+ input_unit = NULL;
active = false;
mutex = NULL;
diff --git a/drivers/coreaudio/audio_driver_coreaudio.h b/drivers/coreaudio/audio_driver_coreaudio.h
index d3f7c8d596..474a9e43ae 100644
--- a/drivers/coreaudio/audio_driver_coreaudio.h
+++ b/drivers/coreaudio/audio_driver_coreaudio.h
@@ -43,6 +43,7 @@
class AudioDriverCoreAudio : public AudioDriver {
AudioComponentInstance audio_unit;
+ AudioComponentInstance input_unit;
bool active;
Mutex *mutex;
@@ -83,6 +84,9 @@ class AudioDriverCoreAudio : public AudioDriver {
UInt32 inBusNumber, UInt32 inNumberFrames,
AudioBufferList *ioData);
+ Error capture_init();
+ void capture_finish();
+
public:
const char *get_name() const {
return "CoreAudio";
diff --git a/drivers/coremidi/core_midi.cpp b/drivers/coremidi/core_midi.cpp
index e8106c4543..2ebbabaa38 100644
--- a/drivers/coremidi/core_midi.cpp
+++ b/drivers/coremidi/core_midi.cpp
@@ -51,13 +51,13 @@ Error MIDIDriverCoreMidi::open() {
OSStatus result = MIDIClientCreate(name, NULL, NULL, &client);
CFRelease(name);
if (result != noErr) {
- ERR_PRINTS("MIDIClientCreate failed: " + String(GetMacOSStatusErrorString(result)));
+ ERR_PRINTS("MIDIClientCreate failed, code: " + itos(result));
return ERR_CANT_OPEN;
}
result = MIDIInputPortCreate(client, CFSTR("Godot Input"), MIDIDriverCoreMidi::read, (void *)this, &port_in);
if (result != noErr) {
- ERR_PRINTS("MIDIInputPortCreate failed: " + String(GetMacOSStatusErrorString(result)));
+ ERR_PRINTS("MIDIInputPortCreate failed, code: " + itos(result));
return ERR_CANT_OPEN;
}
@@ -65,7 +65,7 @@ Error MIDIDriverCoreMidi::open() {
for (int i = 0; i < sources; i++) {
MIDIEndpointRef source = MIDIGetSource(i);
- if (source != NULL) {
+ if (source) {
MIDIPortConnectSource(port_in, source, (void *)this);
connected_sources.insert(i, source);
}
diff --git a/drivers/gles2/rasterizer_gles2.cpp b/drivers/gles2/rasterizer_gles2.cpp
index 5f4b5428e8..175587b1bb 100644
--- a/drivers/gles2/rasterizer_gles2.cpp
+++ b/drivers/gles2/rasterizer_gles2.cpp
@@ -74,6 +74,11 @@
#include <EGL/eglext.h>
#endif
+#if defined(MINGW_ENABLED) || defined(_MSC_VER)
+#define strcpy strcpy_s
+#endif
+
+#ifndef IPHONE_ENABLED
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)
@@ -83,6 +88,7 @@ static void GLAPIENTRY _gl_debug_print(GLenum source, GLenum type, GLuint id, GL
return; //these are ultimately annoying, so removing for now
char debSource[256], debType[256], debSev[256];
+
if (source == _EXT_DEBUG_SOURCE_API_ARB)
strcpy(debSource, "OpenGL");
else if (source == _EXT_DEBUG_SOURCE_WINDOW_SYSTEM_ARB)
@@ -120,6 +126,7 @@ static void GLAPIENTRY _gl_debug_print(GLenum source, GLenum type, GLuint id, GL
ERR_PRINTS(output);
}
+#endif // IPHONE_ENABLED
typedef void (*DEBUGPROCARB)(GLenum source,
GLenum type,
diff --git a/drivers/gles2/rasterizer_scene_gles2.cpp b/drivers/gles2/rasterizer_scene_gles2.cpp
index fbcbebc88c..7e6d969ccb 100644
--- a/drivers/gles2/rasterizer_scene_gles2.cpp
+++ b/drivers/gles2/rasterizer_scene_gles2.cpp
@@ -2455,13 +2455,20 @@ void RasterizerSceneGLES2::_draw_sky(RasterizerStorageGLES2::Sky *p_sky, const C
glEnableVertexAttribArray(VS::ARRAY_VERTEX);
glEnableVertexAttribArray(VS::ARRAY_TEX_UV);
+ storage->shaders.copy.set_conditional(CopyShaderGLES2::USE_ASYM_PANO, asymmetrical);
+ storage->shaders.copy.set_conditional(CopyShaderGLES2::USE_PANORAMA, !asymmetrical);
storage->shaders.copy.set_conditional(CopyShaderGLES2::USE_MULTIPLIER, true);
storage->shaders.copy.set_conditional(CopyShaderGLES2::USE_CUBEMAP, false);
- storage->shaders.copy.set_conditional(CopyShaderGLES2::USE_PANORAMA, true);
storage->shaders.copy.set_conditional(CopyShaderGLES2::USE_COPY_SECTION, false);
storage->shaders.copy.set_conditional(CopyShaderGLES2::USE_CUSTOM_ALPHA, false);
storage->shaders.copy.bind();
storage->shaders.copy.set_uniform(CopyShaderGLES2::MULTIPLIER, p_energy);
+ if (asymmetrical) {
+ // pack the bits we need from our projection matrix
+ storage->shaders.copy.set_uniform(CopyShaderGLES2::ASYM_PROJ, camera.matrix[2][0], camera.matrix[0][0], camera.matrix[2][1], camera.matrix[1][1]);
+ ///@TODO I couldn't get mat3 + p_transform.basis to work, that would be better here.
+ storage->shaders.copy.set_uniform(CopyShaderGLES2::PANO_TRANSFORM, p_transform);
+ }
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
@@ -2469,6 +2476,8 @@ void RasterizerSceneGLES2::_draw_sky(RasterizerStorageGLES2::Sky *p_sky, const C
glDisableVertexAttribArray(VS::ARRAY_TEX_UV);
glBindBuffer(GL_ARRAY_BUFFER, 0);
+ storage->shaders.copy.set_conditional(CopyShaderGLES2::USE_ASYM_PANO, false);
+ storage->shaders.copy.set_conditional(CopyShaderGLES2::USE_PANORAMA, false);
storage->shaders.copy.set_conditional(CopyShaderGLES2::USE_MULTIPLIER, false);
storage->shaders.copy.set_conditional(CopyShaderGLES2::USE_CUBEMAP, false);
}
diff --git a/drivers/gles2/rasterizer_storage_gles2.h b/drivers/gles2/rasterizer_storage_gles2.h
index b42e2dfb1f..c928f753b1 100644
--- a/drivers/gles2/rasterizer_storage_gles2.h
+++ b/drivers/gles2/rasterizer_storage_gles2.h
@@ -43,7 +43,6 @@
/*
#include "shaders/blend_shape.glsl.gen.h"
#include "shaders/canvas.glsl.gen.h"
-#include "shaders/copy.glsl.gen.h"
#include "shaders/particles.glsl.gen.h"
*/
diff --git a/drivers/gles2/shaders/copy.glsl b/drivers/gles2/shaders/copy.glsl
index 16bbde196d..0b8da4f875 100644
--- a/drivers/gles2/shaders/copy.glsl
+++ b/drivers/gles2/shaders/copy.glsl
@@ -35,6 +35,8 @@ void main() {
#if defined(USE_CUBEMAP) || defined(USE_PANORAMA)
cube_interp = cube_in;
+#elif defined(USE_ASYM_PANO)
+ uv_interp = vertex_attrib.xy;
#else
uv_interp = uv_in;
#endif
@@ -68,6 +70,11 @@ varying vec2 uv_interp;
#endif
/* clang-format on */
+#ifdef USE_ASYM_PANO
+uniform highp mat4 pano_transform;
+uniform highp vec4 asym_proj;
+#endif
+
#ifdef USE_CUBEMAP
uniform samplerCube source_cube; // texunit:0
#else
@@ -108,6 +115,21 @@ void main() {
vec4 color = texturePanorama(source, normalize(cube_interp));
+#elif defined(USE_ASYM_PANO)
+
+ // When an asymmetrical projection matrix is used (applicable for stereoscopic rendering i.e. VR) we need to do this calculation per fragment to get a perspective correct result.
+ // Note that we're ignoring the x-offset for IPD, with Z sufficiently in the distance it becomes neglectible, as a result we could probably just set cube_normal.z to -1.
+ // The Matrix[2][0] (= asym_proj.x) and Matrix[2][1] (= asym_proj.z) values are what provide the right shift in the image.
+
+ vec3 cube_normal;
+ cube_normal.z = -1000000.0;
+ cube_normal.x = (cube_normal.z * (-uv_interp.x - asym_proj.x)) / asym_proj.y;
+ cube_normal.y = (cube_normal.z * (-uv_interp.y - asym_proj.z)) / asym_proj.a;
+ cube_normal = mat3(pano_transform) * cube_normal;
+ cube_normal.z = -cube_normal.z;
+
+ vec4 color = texturePanorama(source, normalize(cube_normal.xyz));
+
#elif defined(USE_CUBEMAP)
vec4 color = textureCube(source_cube, normalize(cube_interp));
#else
diff --git a/drivers/gles2/shaders/scene.glsl b/drivers/gles2/shaders/scene.glsl
index fae010b003..a1f0c2680c 100644
--- a/drivers/gles2/shaders/scene.glsl
+++ b/drivers/gles2/shaders/scene.glsl
@@ -75,12 +75,12 @@ attribute highp vec4 instance_custom_data; // attrib:12
// uniforms
//
-uniform mat4 camera_matrix;
-uniform mat4 camera_inverse_matrix;
-uniform mat4 projection_matrix;
-uniform mat4 projection_inverse_matrix;
+uniform highp mat4 camera_matrix;
+uniform highp mat4 camera_inverse_matrix;
+uniform highp mat4 projection_matrix;
+uniform highp mat4 projection_inverse_matrix;
-uniform mat4 world_transform;
+uniform highp mat4 world_transform;
uniform highp float time;
@@ -156,22 +156,22 @@ varying highp vec3 diffuse_interp;
varying highp vec3 specular_interp;
// general for all lights
-uniform vec4 light_color;
-uniform float light_specular;
+uniform highp vec4 light_color;
+uniform highp float light_specular;
// directional
-uniform vec3 light_direction;
+uniform highp vec3 light_direction;
// omni
-uniform vec3 light_position;
+uniform highp vec3 light_position;
-uniform float light_range;
-uniform float light_attenuation;
+uniform highp float light_range;
+uniform highp float light_attenuation;
// spot
-uniform float light_spot_attenuation;
-uniform float light_spot_range;
-uniform float light_spot_angle;
+uniform highp float light_spot_attenuation;
+uniform highp float light_spot_range;
+uniform highp float light_spot_angle;
void light_compute(
vec3 N,
@@ -262,9 +262,9 @@ void light_compute(
#ifdef USE_REFLECTION_PROBE1
-uniform mat4 refprobe1_local_matrix;
+uniform highp mat4 refprobe1_local_matrix;
varying mediump vec4 refprobe1_reflection_normal_blend;
-uniform vec3 refprobe1_box_extents;
+uniform highp vec3 refprobe1_box_extents;
#ifndef USE_LIGHTMAP
varying mediump vec3 refprobe1_ambient_normal;
@@ -274,9 +274,9 @@ varying mediump vec3 refprobe1_ambient_normal;
#ifdef USE_REFLECTION_PROBE2
-uniform mat4 refprobe2_local_matrix;
+uniform highp mat4 refprobe2_local_matrix;
varying mediump vec4 refprobe2_reflection_normal_blend;
-uniform vec3 refprobe2_box_extents;
+uniform highp vec3 refprobe2_box_extents;
#ifndef USE_LIGHTMAP
varying mediump vec3 refprobe2_ambient_normal;
@@ -310,7 +310,6 @@ uniform highp float fog_height_max;
uniform mediump float fog_height_curve;
#endif
-
#endif //fog
void main() {
@@ -360,7 +359,7 @@ void main() {
normal = normalize((world_matrix * vec4(normal, 0.0)).xyz);
#if defined(ENABLE_TANGENT_INTERP) || defined(ENABLE_NORMALMAP)
- tangent = normalize((world_matrix * vec4(tangent, 0.0)), xyz);
+ tangent = normalize((world_matrix * vec4(tangent, 0.0)).xyz);
binormal = normalize((world_matrix * vec4(binormal, 0.0)).xyz);
#endif
#endif
@@ -625,19 +624,19 @@ VERTEX_SHADER_CODE
{
- float fog_z = smoothstep(fog_depth_begin, fog_max_distance, length(vertex));
+ float fog_z = smoothstep(fog_depth_begin, fog_max_distance, length(vertex));
- fog_amount = pow(fog_z, fog_depth_curve);
+ fog_amount = pow(fog_z, fog_depth_curve);
}
#endif
#ifdef FOG_HEIGHT_ENABLED
{
- float y = (camera_matrix * vec4(vertex_interp, 1.0)).y;
- fog_amount = max(fog_amount, pow(smoothstep(fog_height_min, fog_height_max, y), fog_height_curve));
+ float y = (camera_matrix * vec4(vertex_interp, 1.0)).y;
+ fog_amount = max(fog_amount, pow(smoothstep(fog_height_min, fog_height_max, y), fog_height_curve));
}
#endif
- fog_interp = vec4(fog_color,fog_amount);
+ fog_interp = vec4(fog_color, fog_amount);
#endif //fog
@@ -671,13 +670,13 @@ precision highp int;
// uniforms
//
-uniform mat4 camera_matrix;
+uniform highp mat4 camera_matrix;
/* clang-format on */
-uniform mat4 camera_inverse_matrix;
-uniform mat4 projection_matrix;
-uniform mat4 projection_inverse_matrix;
+uniform highp mat4 camera_inverse_matrix;
+uniform highp mat4 projection_matrix;
+uniform highp mat4 projection_inverse_matrix;
-uniform mat4 world_transform;
+uniform highp mat4 world_transform;
uniform highp float time;
@@ -704,9 +703,9 @@ varying mediump vec3 refprobe1_ambient_normal;
#else
uniform bool refprobe1_use_box_project;
-uniform vec3 refprobe1_box_extents;
+uniform highp vec3 refprobe1_box_extents;
uniform vec3 refprobe1_box_offset;
-uniform mat4 refprobe1_local_matrix;
+uniform highp mat4 refprobe1_local_matrix;
#endif //use vertex lighting
@@ -731,9 +730,9 @@ varying mediump vec3 refprobe2_ambient_normal;
#else
uniform bool refprobe2_use_box_project;
-uniform vec3 refprobe2_box_extents;
+uniform highp vec3 refprobe2_box_extents;
uniform vec3 refprobe2_box_offset;
-uniform mat4 refprobe2_local_matrix;
+uniform highp mat4 refprobe2_local_matrix;
#endif //use vertex lighting
@@ -874,29 +873,29 @@ uniform float ambient_energy;
varying highp vec3 diffuse_interp;
varying highp vec3 specular_interp;
-uniform vec3 light_direction; //may be used by fog, so leave here
+uniform highp vec3 light_direction; //may be used by fog, so leave here
#else
//done in fragment
// general for all lights
-uniform vec4 light_color;
-uniform float light_specular;
+uniform highp vec4 light_color;
+uniform highp float light_specular;
// directional
-uniform vec3 light_direction;
+uniform highp vec3 light_direction;
// omni
-uniform vec3 light_position;
+uniform highp vec3 light_position;
-uniform float light_attenuation;
+uniform highp float light_attenuation;
// spot
-uniform float light_spot_attenuation;
-uniform float light_spot_range;
-uniform float light_spot_angle;
+uniform highp float light_spot_attenuation;
+uniform highp float light_spot_range;
+uniform highp float light_spot_angle;
#endif
//this is needed outside above if because dual paraboloid wants it
-uniform float light_range;
+uniform highp float light_range;
#ifdef USE_SHADOW
@@ -2021,8 +2020,8 @@ FRAGMENT_SHADER_CODE
#if defined(USE_VERTEX_LIGHTING)
- gl_FragColor.rgb = mix(gl_FragColor.rgb,fog_interp.rgb,fog_interp.a);
-#else //pixel based fog
+ gl_FragColor.rgb = mix(gl_FragColor.rgb, fog_interp.rgb, fog_interp.a);
+#else //pixel based fog
float fog_amount = 0.0;
#ifdef LIGHT_MODE_DIRECTIONAL
@@ -2036,26 +2035,26 @@ FRAGMENT_SHADER_CODE
{
- float fog_z = smoothstep(fog_depth_begin, fog_max_distance, length(vertex));
+ float fog_z = smoothstep(fog_depth_begin, fog_max_distance, length(vertex));
- fog_amount = pow(fog_z, fog_depth_curve);
+ fog_amount = pow(fog_z, fog_depth_curve);
- if (fog_transmit_enabled) {
- vec3 total_light = gl_FragColor.rgb;
- float transmit = pow(fog_z, fog_transmit_curve);
- fog_color = mix(max(total_light, fog_color), fog_color, transmit);
- }
+ if (fog_transmit_enabled) {
+ vec3 total_light = gl_FragColor.rgb;
+ float transmit = pow(fog_z, fog_transmit_curve);
+ fog_color = mix(max(total_light, fog_color), fog_color, transmit);
+ }
}
#endif
#ifdef FOG_HEIGHT_ENABLED
{
- float y = (camera_matrix * vec4(vertex, 1.0)).y;
- fog_amount = max(fog_amount, pow(smoothstep(fog_height_min, fog_height_max, y), fog_height_curve));
+ float y = (camera_matrix * vec4(vertex, 1.0)).y;
+ fog_amount = max(fog_amount, pow(smoothstep(fog_height_min, fog_height_max, y), fog_height_curve));
}
#endif
- gl_FragColor.rgb = mix(gl_FragColor.rgb,fog_color,fog_amount);
+ gl_FragColor.rgb = mix(gl_FragColor.rgb, fog_color, fog_amount);
#endif //use vertex lit
diff --git a/drivers/gles3/rasterizer_gles3.cpp b/drivers/gles3/rasterizer_gles3.cpp
index 2b3be9d0bd..d3cd01a903 100644
--- a/drivers/gles3/rasterizer_gles3.cpp
+++ b/drivers/gles3/rasterizer_gles3.cpp
@@ -73,6 +73,10 @@ RasterizerScene *RasterizerGLES3::get_scene() {
#define _EXT_DEBUG_SEVERITY_LOW_ARB 0x9148
#define _EXT_DEBUG_OUTPUT 0x92E0
+#if defined(MINGW_ENABLED) || defined(_MSC_VER)
+#define strcpy strcpy_s
+#endif
+
#ifdef GLAD_ENABLED
// Restricting to GLAD as only used in initialize() with GLAD_GL_ARB_debug_output
#if (defined WINDOWS_ENABLED) && !(defined UWP_ENABLED)
diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp
index 14c436fd00..fcb68f44fe 100644
--- a/drivers/gles3/rasterizer_scene_gles3.cpp
+++ b/drivers/gles3/rasterizer_scene_gles3.cpp
@@ -653,7 +653,7 @@ bool RasterizerSceneGLES3::reflection_probe_instance_begin_render(RID p_instance
int best_free = -1;
int best_used = -1;
- uint64_t best_used_frame;
+ uint64_t best_used_frame = 0;
for (int i = 0; i < reflection_atlas->reflections.size(); i++) {
if (reflection_atlas->reflections[i].owner == RID()) {
@@ -1246,14 +1246,11 @@ bool RasterizerSceneGLES3::_setup_material(RasterizerStorageGLES3::Material *p_m
case ShaderLanguage::TYPE_SAMPLER3D: {
target = GL_TEXTURE_3D;
+ tex = storage->resources.white_tex_3d;
- switch (texture_hints[i]) {
-
- // TODO
- default: {
- tex = storage->resources.white_tex_3d;
- } break;
- }
+ //switch (texture_hints[i]) {
+ // TODO
+ //}
} break;
@@ -2519,7 +2516,7 @@ void RasterizerSceneGLES3::_draw_sky(RasterizerStorageGLES3::Sky *p_sky, const C
storage->shaders.copy.set_conditional(CopyShaderGLES3::USE_PANORAMA, false);
}
-void RasterizerSceneGLES3::_setup_environment(Environment *env, const CameraMatrix &p_cam_projection, const Transform &p_cam_transform) {
+void RasterizerSceneGLES3::_setup_environment(Environment *env, const CameraMatrix &p_cam_projection, const Transform &p_cam_transform, bool p_no_fog) {
//store camera into ubo
store_camera(p_cam_projection, state.ubo_data.projection_matrix);
@@ -2570,7 +2567,7 @@ void RasterizerSceneGLES3::_setup_environment(Environment *env, const CameraMatr
state.ubo_data.fog_color_enabled[0] = linear_fog.r;
state.ubo_data.fog_color_enabled[1] = linear_fog.g;
state.ubo_data.fog_color_enabled[2] = linear_fog.b;
- state.ubo_data.fog_color_enabled[3] = env->fog_enabled ? 1.0 : 0.0;
+ state.ubo_data.fog_color_enabled[3] = (!p_no_fog && env->fog_enabled) ? 1.0 : 0.0;
Color linear_sun = env->fog_sun_color.to_linear();
state.ubo_data.fog_sun_color_amount[0] = linear_sun.r;
@@ -4083,7 +4080,7 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const
state.ubo_data.screen_pixel_size[1] = 1.0 / storage->frame.current_rt->height;
}
- _setup_environment(env, p_cam_projection, p_cam_transform);
+ _setup_environment(env, p_cam_projection, p_cam_transform, p_reflection_probe.is_valid());
bool fb_cleared = false;
diff --git a/drivers/gles3/rasterizer_scene_gles3.h b/drivers/gles3/rasterizer_scene_gles3.h
index b4c4a0558f..4b4a0b9303 100644
--- a/drivers/gles3/rasterizer_scene_gles3.h
+++ b/drivers/gles3/rasterizer_scene_gles3.h
@@ -831,7 +831,7 @@ public:
void _draw_sky(RasterizerStorageGLES3::Sky *p_sky, const CameraMatrix &p_projection, const Transform &p_transform, bool p_vflip, float p_custom_fov, float p_energy);
- void _setup_environment(Environment *env, const CameraMatrix &p_cam_projection, const Transform &p_cam_transform);
+ void _setup_environment(Environment *env, const CameraMatrix &p_cam_projection, const Transform &p_cam_transform, bool p_no_fog = false);
void _setup_directional_light(int p_index, const Transform &p_camera_inverse_transform, bool p_use_shadows);
void _setup_lights(RID *p_light_cull_result, int p_light_cull_count, const Transform &p_camera_inverse_transform, const CameraMatrix &p_camera_projection, RID p_shadow_atlas);
void _setup_reflections(RID *p_reflection_probe_cull_result, int p_reflection_probe_cull_count, const Transform &p_camera_inverse_transform, const CameraMatrix &p_camera_projection, RID p_reflection_atlas, Environment *p_env);
diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp
index 58c0a104c1..a9aa152f10 100644
--- a/drivers/gles3/rasterizer_storage_gles3.cpp
+++ b/drivers/gles3/rasterizer_storage_gles3.cpp
@@ -730,7 +730,7 @@ void RasterizerStorageGLES3::texture_set_data(RID p_texture, const Ref<Image> &p
}
};
- GLenum blit_target;
+ GLenum blit_target = GL_TEXTURE_2D;
switch (texture->type) {
case VS::TEXTURE_TYPE_2D: {
@@ -948,7 +948,7 @@ void RasterizerStorageGLES3::texture_set_data_partial(RID p_texture, const Ref<I
Image::Format real_format;
Ref<Image> img = _get_gl_image_and_format(p_sub_img, p_sub_img->get_format(), texture->flags, real_format, format, internal_format, type, compressed, srgb);
- GLenum blit_target;
+ GLenum blit_target = GL_TEXTURE_2D;
switch (texture->type) {
case VS::TEXTURE_TYPE_2D: {
@@ -4066,35 +4066,37 @@ void RasterizerStorageGLES3::multimesh_allocate(RID p_multimesh, int p_instances
multimesh->data.resize(format_floats * p_instances);
+ float *dataptr = multimesh->data.ptrw();
+
for (int i = 0; i < p_instances * format_floats; i += format_floats) {
int color_from = 0;
int custom_data_from = 0;
if (multimesh->transform_format == VS::MULTIMESH_TRANSFORM_2D) {
- multimesh->data.write[i + 0] = 1.0;
- multimesh->data.write[i + 1] = 0.0;
- multimesh->data.write[i + 2] = 0.0;
- multimesh->data.write[i + 3] = 0.0;
- multimesh->data.write[i + 4] = 0.0;
- multimesh->data.write[i + 5] = 1.0;
- multimesh->data.write[i + 6] = 0.0;
- multimesh->data.write[i + 7] = 0.0;
+ dataptr[i + 0] = 1.0;
+ dataptr[i + 1] = 0.0;
+ dataptr[i + 2] = 0.0;
+ dataptr[i + 3] = 0.0;
+ dataptr[i + 4] = 0.0;
+ dataptr[i + 5] = 1.0;
+ dataptr[i + 6] = 0.0;
+ dataptr[i + 7] = 0.0;
color_from = 8;
custom_data_from = 8;
} else {
- multimesh->data.write[i + 0] = 1.0;
- multimesh->data.write[i + 1] = 0.0;
- multimesh->data.write[i + 2] = 0.0;
- multimesh->data.write[i + 3] = 0.0;
- multimesh->data.write[i + 4] = 0.0;
- multimesh->data.write[i + 5] = 1.0;
- multimesh->data.write[i + 6] = 0.0;
- multimesh->data.write[i + 7] = 0.0;
- multimesh->data.write[i + 8] = 0.0;
- multimesh->data.write[i + 9] = 0.0;
- multimesh->data.write[i + 10] = 1.0;
- multimesh->data.write[i + 11] = 0.0;
+ dataptr[i + 0] = 1.0;
+ dataptr[i + 1] = 0.0;
+ dataptr[i + 2] = 0.0;
+ dataptr[i + 3] = 0.0;
+ dataptr[i + 4] = 0.0;
+ dataptr[i + 5] = 1.0;
+ dataptr[i + 6] = 0.0;
+ dataptr[i + 7] = 0.0;
+ dataptr[i + 8] = 0.0;
+ dataptr[i + 9] = 0.0;
+ dataptr[i + 10] = 1.0;
+ dataptr[i + 11] = 0.0;
color_from = 12;
custom_data_from = 12;
}
@@ -4109,14 +4111,14 @@ void RasterizerStorageGLES3::multimesh_allocate(RID p_multimesh, int p_instances
} cu;
cu.colu = 0xFFFFFFFF;
- multimesh->data.write[i + color_from + 0] = cu.colf;
+ dataptr[i + color_from + 0] = cu.colf;
custom_data_from = color_from + 1;
} else if (multimesh->color_format == VS::MULTIMESH_COLOR_FLOAT) {
- multimesh->data.write[i + color_from + 0] = 1.0;
- multimesh->data.write[i + color_from + 1] = 1.0;
- multimesh->data.write[i + color_from + 2] = 1.0;
- multimesh->data.write[i + color_from + 3] = 1.0;
+ dataptr[i + color_from + 0] = 1.0;
+ dataptr[i + color_from + 1] = 1.0;
+ dataptr[i + color_from + 2] = 1.0;
+ dataptr[i + color_from + 3] = 1.0;
custom_data_from = color_from + 4;
}
@@ -4130,13 +4132,13 @@ void RasterizerStorageGLES3::multimesh_allocate(RID p_multimesh, int p_instances
} cu;
cu.colu = 0;
- multimesh->data.write[i + custom_data_from + 0] = cu.colf;
+ dataptr[i + custom_data_from + 0] = cu.colf;
} else if (multimesh->custom_data_format == VS::MULTIMESH_CUSTOM_DATA_FLOAT) {
- multimesh->data.write[i + custom_data_from + 0] = 0.0;
- multimesh->data.write[i + custom_data_from + 1] = 0.0;
- multimesh->data.write[i + custom_data_from + 2] = 0.0;
- multimesh->data.write[i + custom_data_from + 3] = 0.0;
+ dataptr[i + custom_data_from + 0] = 0.0;
+ dataptr[i + custom_data_from + 1] = 0.0;
+ dataptr[i + custom_data_from + 2] = 0.0;
+ dataptr[i + custom_data_from + 3] = 0.0;
}
}
@@ -6841,7 +6843,7 @@ void RasterizerStorageGLES3::_render_target_allocate(RenderTarget *rt) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, level);
glDisable(GL_SCISSOR_TEST);
glColorMask(1, 1, 1, 1);
- if (rt->buffers.active == false) {
+ if (!rt->buffers.active) {
glDepthMask(GL_TRUE);
}
diff --git a/drivers/gles3/shader_compiler_gles3.cpp b/drivers/gles3/shader_compiler_gles3.cpp
index dbc8507951..be36b41417 100644
--- a/drivers/gles3/shader_compiler_gles3.cpp
+++ b/drivers/gles3/shader_compiler_gles3.cpp
@@ -872,6 +872,7 @@ ShaderCompilerGLES3::ShaderCompilerGLES3() {
actions[VS::SHADER_SPATIAL].renames["SCREEN_UV"] = "screen_uv";
actions[VS::SHADER_SPATIAL].renames["SCREEN_TEXTURE"] = "screen_texture";
actions[VS::SHADER_SPATIAL].renames["DEPTH_TEXTURE"] = "depth_buffer";
+ actions[VS::SHADER_SPATIAL].renames["DEPTH"] = "gl_FragDepth";
actions[VS::SHADER_SPATIAL].renames["ALPHA_SCISSOR"] = "alpha_scissor";
actions[VS::SHADER_SPATIAL].renames["OUTPUT_IS_SRGB"] = "SHADER_IS_SRGB";
diff --git a/drivers/gles3/shader_gles3.h b/drivers/gles3/shader_gles3.h
index 9db4942163..0d360e8453 100644
--- a/drivers/gles3/shader_gles3.h
+++ b/drivers/gles3/shader_gles3.h
@@ -128,11 +128,13 @@ private:
Vector<GLint> texture_uniform_locations;
uint32_t code_version;
bool ok;
- Version() {
- code_version = 0;
- ok = false;
- uniform_location = NULL;
- }
+ Version() :
+ id(0),
+ vert_id(0),
+ frag_id(0),
+ uniform_location(NULL),
+ code_version(0),
+ ok(false) {}
};
Version *version;
diff --git a/drivers/gles3/shaders/scene.glsl b/drivers/gles3/shaders/scene.glsl
index 598bd3465e..91ab34f775 100644
--- a/drivers/gles3/shaders/scene.glsl
+++ b/drivers/gles3/shaders/scene.glsl
@@ -1340,7 +1340,7 @@ void reflection_process(int idx, vec3 vertex, vec3 normal, vec3 binormal, vec3 t
reflection_accum += reflection;
}
-#ifndef USE_LIGHTMAP
+#if !defined(USE_LIGHTMAP) && !defined(USE_LIGHTMAP_CAPTURE)
if (reflections[idx].ambient.a > 0.0) { //compute ambient using skybox
vec3 local_amb_vec = (reflections[idx].local_matrix * vec4(normal, 0.0)).xyz;
@@ -1957,7 +1957,7 @@ FRAGMENT_SHADER_CODE
} else {
specular_light += env_reflection_light;
}
-#ifndef USE_LIGHTMAP
+#if !defined(USE_LIGHTMAP) && !defined(USE_LIGHTMAP_CAPTURE)
if (ambient_accum.a > 0.0) {
ambient_light = ambient_accum.rgb / ambient_accum.a;
}
@@ -2053,7 +2053,7 @@ FRAGMENT_SHADER_CODE
emission = emission * rev_amount + fog_color * fog_amount;
ambient_light *= rev_amount;
- specular_light *rev_amount;
+ specular_light *= rev_amount;
diffuse_light *= rev_amount;
}
diff --git a/drivers/pulseaudio/audio_driver_pulseaudio.cpp b/drivers/pulseaudio/audio_driver_pulseaudio.cpp
index 9c02549e39..d78316945f 100644
--- a/drivers/pulseaudio/audio_driver_pulseaudio.cpp
+++ b/drivers/pulseaudio/audio_driver_pulseaudio.cpp
@@ -613,20 +613,18 @@ Error AudioDriverPulseAudio::capture_init_device() {
break;
}
- print_verbose("PulseAudio: detected " + itos(pa_rec_map.channels) + " input channels");
-
pa_sample_spec spec;
spec.format = PA_SAMPLE_S16LE;
spec.channels = pa_rec_map.channels;
spec.rate = mix_rate;
- int latency = 30;
- input_buffer_frames = closest_power_of_2(latency * mix_rate / 1000);
- int buffer_size = input_buffer_frames * spec.channels;
+ int input_latency = 30;
+ int input_buffer_frames = closest_power_of_2(input_latency * mix_rate / 1000);
+ int input_buffer_size = input_buffer_frames * spec.channels;
pa_buffer_attr attr;
- attr.fragsize = buffer_size * sizeof(int16_t);
+ attr.fragsize = input_buffer_size * sizeof(int16_t);
pa_rec_str = pa_stream_new(pa_ctx, "Record", &spec, &pa_rec_map);
if (pa_rec_str == NULL) {
@@ -642,9 +640,10 @@ Error AudioDriverPulseAudio::capture_init_device() {
ERR_FAIL_V(ERR_CANT_OPEN);
}
- input_buffer.resize(input_buffer_frames * 8);
- input_position = 0;
- input_size = 0;
+ input_buffer_init(input_buffer_frames);
+
+ print_verbose("PulseAudio: detected " + itos(pa_rec_map.channels) + " input channels");
+ print_verbose("PulseAudio: input buffer frames: " + itos(input_buffer_frames) + " calculated latency: " + itos(input_buffer_frames * 1000 / mix_rate) + "ms");
return OK;
}
@@ -760,7 +759,6 @@ AudioDriverPulseAudio::AudioDriverPulseAudio() {
mix_rate = 0;
buffer_frames = 0;
- input_buffer_frames = 0;
pa_buffer_size = 0;
channels = 0;
pa_ready = 0;
diff --git a/drivers/pulseaudio/audio_driver_pulseaudio.h b/drivers/pulseaudio/audio_driver_pulseaudio.h
index f8358a452b..d8bab841ff 100644
--- a/drivers/pulseaudio/audio_driver_pulseaudio.h
+++ b/drivers/pulseaudio/audio_driver_pulseaudio.h
@@ -64,7 +64,6 @@ class AudioDriverPulseAudio : public AudioDriver {
unsigned int mix_rate;
unsigned int buffer_frames;
- unsigned int input_buffer_frames;
unsigned int pa_buffer_size;
int channels;
int pa_ready;
diff --git a/drivers/rtaudio/audio_driver_rtaudio.cpp b/drivers/rtaudio/audio_driver_rtaudio.cpp
index 10ba0663f2..9353128333 100644
--- a/drivers/rtaudio/audio_driver_rtaudio.cpp
+++ b/drivers/rtaudio/audio_driver_rtaudio.cpp
@@ -128,7 +128,7 @@ Error AudioDriverRtAudio::init() {
active = true;
break;
- } catch (RtAudioError &e) {
+ } catch (RtAudioError) {
// try with less channels
ERR_PRINT("Unable to open audio, retrying with fewer channels...");
diff --git a/drivers/unix/dir_access_unix.cpp b/drivers/unix/dir_access_unix.cpp
index 48b4369b7e..929e67faa9 100644
--- a/drivers/unix/dir_access_unix.cpp
+++ b/drivers/unix/dir_access_unix.cpp
@@ -309,7 +309,7 @@ Error DirAccessUnix::change_dir(String p_dir) {
// prev_dir is the directory we are changing out of
String prev_dir;
char real_current_dir_name[2048];
- getcwd(real_current_dir_name, 2048);
+ ERR_FAIL_COND_V(getcwd(real_current_dir_name, 2048) == NULL, ERR_BUG);
if (prev_dir.parse_utf8(real_current_dir_name))
prev_dir = real_current_dir_name; //no utf8, maybe latin?
@@ -330,7 +330,7 @@ Error DirAccessUnix::change_dir(String p_dir) {
// the directory exists, so set current_dir to try_dir
current_dir = try_dir;
- chdir(prev_dir.utf8().get_data());
+ ERR_FAIL_COND_V(chdir(prev_dir.utf8().get_data()) != 0, ERR_BUG);
return OK;
}
@@ -405,7 +405,7 @@ DirAccessUnix::DirAccessUnix() {
// set current directory to an absolute path of the current directory
char real_current_dir_name[2048];
- getcwd(real_current_dir_name, 2048);
+ ERR_FAIL_COND(getcwd(real_current_dir_name, 2048) == NULL);
if (current_dir.parse_utf8(real_current_dir_name))
current_dir = real_current_dir_name;
diff --git a/drivers/unix/net_socket_posix.cpp b/drivers/unix/net_socket_posix.cpp
index 3f03175403..2cc2032cbb 100644
--- a/drivers/unix/net_socket_posix.cpp
+++ b/drivers/unix/net_socket_posix.cpp
@@ -42,12 +42,8 @@
#include <sys/types.h>
#include <unistd.h>
#ifndef NO_FCNTL
-#ifdef __HAIKU__
#include <fcntl.h>
#else
-#include <sys/fcntl.h>
-#endif
-#else
#include <sys/ioctl.h>
#endif
#include <netinet/in.h>
diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp
index 6c70934bc6..7ff27be501 100644
--- a/drivers/unix/os_unix.cpp
+++ b/drivers/unix/os_unix.cpp
@@ -487,9 +487,11 @@ String OS_Unix::get_executable_path() const {
//fix for running from a symlink
char buf[256];
memset(buf, 0, 256);
- readlink("/proc/self/exe", buf, sizeof(buf));
+ ssize_t len = readlink("/proc/self/exe", buf, sizeof(buf));
String b;
- b.parse_utf8(buf);
+ if (len > 0) {
+ b.parse_utf8(buf, len);
+ }
if (b == "") {
WARN_PRINT("Couldn't get executable path from /proc/self/exe, using argv[0]");
return OS::get_executable_path();
diff --git a/drivers/unix/thread_posix.cpp b/drivers/unix/thread_posix.cpp
index fcefe0a3b3..54bbbf2dad 100644
--- a/drivers/unix/thread_posix.cpp
+++ b/drivers/unix/thread_posix.cpp
@@ -103,8 +103,6 @@ void ThreadPosix::wait_to_finish_func_posix(Thread *p_thread) {
Error ThreadPosix::set_name_func_posix(const String &p_name) {
- pthread_t running_thread = pthread_self();
-
#ifdef PTHREAD_NO_RENAME
return ERR_UNAVAILABLE;
@@ -117,6 +115,7 @@ Error ThreadPosix::set_name_func_posix(const String &p_name) {
#else
+ pthread_t running_thread = pthread_self();
#ifdef PTHREAD_BSD_SET_NAME
pthread_set_name_np(running_thread, p_name.utf8().get_data());
int err = 0; // Open/FreeBSD ignore errors in this function
diff --git a/drivers/wasapi/audio_driver_wasapi.cpp b/drivers/wasapi/audio_driver_wasapi.cpp
index 3d4979175b..8665f701b1 100644
--- a/drivers/wasapi/audio_driver_wasapi.cpp
+++ b/drivers/wasapi/audio_driver_wasapi.cpp
@@ -336,10 +336,7 @@ Error AudioDriverWASAPI::init_capture_device(bool reinit) {
HRESULT hr = audio_input.audio_client->GetBufferSize(&max_frames);
ERR_FAIL_COND_V(hr != S_OK, ERR_CANT_OPEN);
- // Set the buffer size
- input_buffer.resize(max_frames * CAPTURE_BUFFER_CHANNELS);
- input_position = 0;
- input_size = 0;
+ input_buffer_init(max_frames);
return OK;
}
@@ -796,19 +793,18 @@ Error AudioDriverWASAPI::capture_start() {
return err;
}
- if (audio_input.active == false) {
- audio_input.audio_client->Start();
- audio_input.active = true;
-
- return OK;
+ if (audio_input.active) {
+ return FAILED;
}
- return FAILED;
+ audio_input.audio_client->Start();
+ audio_input.active = true;
+ return OK;
}
Error AudioDriverWASAPI::capture_stop() {
- if (audio_input.active == true) {
+ if (audio_input.active) {
audio_input.audio_client->Stop();
audio_input.active = false;
diff --git a/drivers/windows/file_access_windows.cpp b/drivers/windows/file_access_windows.cpp
index b4492a2022..2582478259 100644
--- a/drivers/windows/file_access_windows.cpp
+++ b/drivers/windows/file_access_windows.cpp
@@ -114,7 +114,7 @@ Error FileAccessWindows::_open(const String &p_path, int p_mode_flags) {
path = path + ".tmp";
}
- f = _wfopen(path.c_str(), mode_string);
+ _wfopen_s(&f, path.c_str(), mode_string);
if (f == NULL) {
last_error = ERR_FILE_CANT_OPEN;
@@ -278,7 +278,7 @@ 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);
- g = _wfopen(filename.c_str(), L"rb");
+ _wfopen_s(&g, filename.c_str(), L"rb");
if (g == NULL) {
return false;
diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp
index 77be561477..3997469e95 100644
--- a/editor/animation_track_editor.cpp
+++ b/editor/animation_track_editor.cpp
@@ -4086,6 +4086,8 @@ void AnimationTrackEditor::_move_selection_commit() {
for (int i = 0; i < track_edits.size(); i++) {
track_edits[i]->update();
}
+
+ _update_key_edit();
}
void AnimationTrackEditor::_move_selection_cancel() {
diff --git a/editor/audio_stream_preview.cpp b/editor/audio_stream_preview.cpp
index c5759ac076..5a94d41aba 100644
--- a/editor/audio_stream_preview.cpp
+++ b/editor/audio_stream_preview.cpp
@@ -50,7 +50,7 @@ float AudioStreamPreview::get_max(float p_time, float p_time_next) const {
time_to = time_from + 1;
}
- uint8_t vmax;
+ uint8_t vmax = 0;
for (int i = time_from; i < time_to; i++) {
@@ -77,7 +77,7 @@ float AudioStreamPreview::get_min(float p_time, float p_time_next) const {
time_to = time_from + 1;
}
- uint8_t vmin;
+ uint8_t vmin = 0;
for (int i = time_from; i < time_to; i++) {
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp
index 79c22f667a..aeb304d3b9 100644
--- a/editor/code_editor.cpp
+++ b/editor/code_editor.cpp
@@ -1039,6 +1039,8 @@ void CodeTextEditor::delete_lines() {
int to_line = text_editor->get_selection_to_line();
int from_line = text_editor->get_selection_from_line();
int count = Math::abs(to_line - from_line) + 1;
+
+ text_editor->cursor_set_line(to_line, false);
while (count) {
text_editor->set_line(text_editor->cursor_get_line(), "");
text_editor->backspace_at_cursor();
diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp
index eb11aea9cc..c4516c1f17 100644
--- a/editor/create_dialog.cpp
+++ b/editor/create_dialog.cpp
@@ -558,6 +558,7 @@ void CreateDialog::_history_selected() {
return;
search_box->set_text(item->get_text(0).get_slicec(' ', 0));
+ favorites->deselect_all();
_update_search();
}
@@ -568,6 +569,7 @@ void CreateDialog::_favorite_selected() {
return;
search_box->set_text(item->get_text(0).get_slicec(' ', 0));
+ recent->deselect_all();
_update_search();
}
diff --git a/editor/editor_autoload_settings.cpp b/editor/editor_autoload_settings.cpp
index 1374c8c9aa..64742ff74c 100644
--- a/editor/editor_autoload_settings.cpp
+++ b/editor/editor_autoload_settings.cpp
@@ -185,6 +185,7 @@ void EditorAutoloadSettings::_autoload_edited() {
if (path.begins_with("*"))
path = path.substr(1, path.length());
+ // Singleton autoloads are represented with a leading "*" in their path.
if (checked)
path = "*" + path;
@@ -651,6 +652,7 @@ void EditorAutoloadSettings::autoload_add(const String &p_name, const String &p_
UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo();
undo_redo->create_action(TTR("Add AutoLoad"));
+ // Singleton autoloads are represented with a leading "*" in their path.
undo_redo->add_do_property(ProjectSettings::get_singleton(), name, "*" + path);
if (ProjectSettings::get_singleton()->has_setting(name)) {
diff --git a/editor/editor_file_dialog.cpp b/editor/editor_file_dialog.cpp
index 38bdba31ea..438d7ea306 100644
--- a/editor/editor_file_dialog.cpp
+++ b/editor/editor_file_dialog.cpp
@@ -501,7 +501,7 @@ void EditorFileDialog::_items_clear_selection() {
case MODE_OPEN_FILE:
case MODE_OPEN_FILES:
get_ok()->set_text(TTR("Open"));
- get_ok()->set_disabled(item_list->is_anything_selected() == false);
+ get_ok()->set_disabled(!item_list->is_anything_selected());
break;
case MODE_OPEN_DIR:
@@ -1135,14 +1135,10 @@ void EditorFileDialog::_update_drives() {
}
void EditorFileDialog::_favorite_selected(int p_idx) {
-
- Vector<String> favorited = EditorSettings::get_singleton()->get_favorites();
- ERR_FAIL_INDEX(p_idx, favorited.size());
-
- dir_access->change_dir(favorited[p_idx]);
+ dir_access->change_dir(favorites->get_item_metadata(p_idx));
file->set_text("");
- invalidate();
update_dir();
+ invalidate();
_push_history();
}
@@ -1192,7 +1188,7 @@ void EditorFileDialog::_update_favorites() {
bool res = access == ACCESS_RESOURCES;
String current = get_current_dir();
- Ref<Texture> star = get_icon("Favorites", "EditorIcons");
+ Ref<Texture> folder_icon = get_icon("Folder", "EditorIcons");
favorites->clear();
favorite->set_pressed(false);
@@ -1203,16 +1199,23 @@ void EditorFileDialog::_update_favorites() {
if (cres != res)
continue;
String name = favorited[i];
-
- bool setthis = name == current;
+ bool setthis = false;
if (res && name == "res://") {
+ if (name == current)
+ setthis = true;
name = "/";
+ } else if (name.ends_with("/")) {
+ if (name == current)
+ setthis = true;
+ name = name.substr(0, name.length() - 1);
+ name = name.get_file();
+
+ favorites->add_item(name, folder_icon);
} else {
- name = name.get_file() + "/";
+ continue; // We don't handle favorite files here
}
- favorites->add_item(name, star);
favorites->set_item_metadata(favorites->get_item_count() - 1, favorited[i]);
if (setthis) {
diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp
index ee20d95f25..d73bf86f64 100644
--- a/editor/editor_file_system.cpp
+++ b/editor/editor_file_system.cpp
@@ -1705,6 +1705,17 @@ void EditorFileSystem::reimport_files(const Vector<String> &p_files) {
emit_signal("resources_reimported", p_files);
}
+Error EditorFileSystem::_resource_import(const String &p_path) {
+
+ Vector<String> files;
+ files.push_back(p_path);
+
+ singleton->update_file(p_path);
+ singleton->reimport_files(files);
+
+ return OK;
+}
+
void EditorFileSystem::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_filesystem"), &EditorFileSystem::get_filesystem);
@@ -1744,6 +1755,7 @@ void EditorFileSystem::_update_extensions() {
EditorFileSystem::EditorFileSystem() {
+ ResourceLoader::import = _resource_import;
reimport_on_missing_imported_files = GLOBAL_DEF("editor/reimport_missing_imported_files", true);
singleton = this;
diff --git a/editor/editor_file_system.h b/editor/editor_file_system.h
index f2f72eddbd..47077425a1 100644
--- a/editor/editor_file_system.h
+++ b/editor/editor_file_system.h
@@ -230,6 +230,8 @@ class EditorFileSystem : public Node {
String _get_global_script_class(const String &p_type, const String &p_path, String *r_extends, String *r_icon_path) const;
+ static Error _resource_import(const String &p_path);
+
protected:
void _notification(int p_what);
static void _bind_methods();
diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp
index c6258c8493..a90f15004a 100644
--- a/editor/editor_inspector.cpp
+++ b/editor/editor_inspector.cpp
@@ -2139,6 +2139,13 @@ void EditorInspector::_notification(int p_what) {
}
if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
+
+ if (use_sub_inspector_bg) {
+ add_style_override("bg", get_stylebox("sub_inspector_bg", "Editor"));
+ } else if (is_inside_tree()) {
+ add_style_override("bg", get_stylebox("bg", "Tree"));
+ }
+
update_tree();
}
}
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 790e38afca..d01543198a 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -227,12 +227,6 @@ void EditorNode::_unhandled_input(const Ref<InputEvent> &p_event) {
_editor_select_prev();
}
- if (k->get_scancode() == KEY_ESCAPE) {
- for (int i = 0; i < bottom_panel_items.size(); i++) {
- _bottom_panel_switch(false, i);
- }
- }
-
if (old_editor != editor_plugin_screen) {
get_tree()->set_input_as_handled();
}
@@ -3889,7 +3883,7 @@ void EditorNode::_scene_tab_closed(int p_tab) {
}
void EditorNode::_scene_tab_hover(int p_tab) {
- if (bool(EDITOR_GET("interface/scene_tabs/show_thumbnail_on_hover")) == false) {
+ if (!bool(EDITOR_GET("interface/scene_tabs/show_thumbnail_on_hover"))) {
return;
}
int current_tab = scene_tabs->get_current_tab();
@@ -3898,7 +3892,9 @@ void EditorNode::_scene_tab_hover(int p_tab) {
tab_preview_panel->hide();
} else {
String path = editor_data.get_scene_path(p_tab);
- EditorResourcePreview::get_singleton()->queue_resource_preview(path, this, "_thumbnail_done", p_tab);
+ if (path != String()) {
+ EditorResourcePreview::get_singleton()->queue_resource_preview(path, this, "_thumbnail_done", p_tab);
+ }
}
}
diff --git a/editor/editor_profiler.cpp b/editor/editor_profiler.cpp
index b57e3826c6..d3978749c0 100644
--- a/editor/editor_profiler.cpp
+++ b/editor/editor_profiler.cpp
@@ -257,7 +257,7 @@ void EditorProfiler::_update_plot() {
//get
const Metric &m = frame_metrics[idx];
- if (m.valid == false)
+ if (!m.valid)
continue; //skip because invalid
float value = 0;
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp
index c5c78b2590..96d482f47e 100644
--- a/editor/editor_properties.cpp
+++ b/editor/editor_properties.cpp
@@ -477,33 +477,16 @@ EditorPropertyCheck::EditorPropertyCheck() {
void EditorPropertyEnum::_option_selected(int p_which) {
- String text = options->get_item_text(p_which);
- Vector<String> text_split = text.split(":");
- if (text_split.size() == 1) {
- emit_signal("property_changed", get_edited_property(), p_which);
- return;
- }
- String name = text_split[1];
- emit_signal("property_changed", get_edited_property(), name.to_int());
+ int val = options->get_item_metadata(p_which);
+ emit_signal("property_changed", get_edited_property(), val);
}
void EditorPropertyEnum::update_property() {
int which = get_edited_object()->get(get_edited_property());
- if (which == 0) {
- options->select(which);
- return;
- }
for (int i = 0; i < options->get_item_count(); i++) {
- String text = options->get_item_text(i);
- Vector<String> text_split = text.split(":");
- if (text_split.size() == 1) {
- options->select(which);
- return;
- }
- String name = text_split[1];
- if (itos(which) == name) {
+ if (which == (int)options->get_item_metadata(i)) {
options->select(i);
return;
}
@@ -511,8 +494,15 @@ void EditorPropertyEnum::update_property() {
}
void EditorPropertyEnum::setup(const Vector<String> &p_options) {
+
+ int current_val = 0;
for (int i = 0; i < p_options.size(); i++) {
- options->add_item(p_options[i], i);
+ Vector<String> text_split = p_options[i].split(":");
+ if (text_split.size() != 1)
+ current_val = text_split[1].to_int();
+ options->add_item(text_split[0]);
+ options->set_item_metadata(i, current_val);
+ current_val += 1;
}
}
@@ -1779,7 +1769,7 @@ void EditorPropertyColor::_color_changed(const Color &p_color) {
void EditorPropertyColor::_popup_closed() {
- emit_signal("property_changed", get_edited_property(), picker->get_pick_color(), true);
+ emit_signal("property_changed", get_edited_property(), picker->get_pick_color(), false);
}
void EditorPropertyColor::_bind_methods() {
@@ -2102,12 +2092,18 @@ void EditorPropertyResource::_menu_option(int p_which) {
}
}
-void EditorPropertyResource::_resource_preview(const String &p_path, const Ref<Texture> &p_preview, ObjectID p_obj) {
+void EditorPropertyResource::_resource_preview(const String &p_path, const Ref<Texture> &p_preview, const Ref<Texture> &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();
+
+ if (ClassDB::is_parent_class(type, "Script")) {
+ assign->set_text(p->get_path().get_file());
+ return;
+ }
+
if (p_preview.is_valid()) {
- String type = p->get_class_name();
preview->set_margin(MARGIN_LEFT, assign->get_icon()->get_width() + assign->get_stylebox("normal")->get_default_margin(MARGIN_LEFT) + get_constant("hseparation", "Button"));
if (type == "GradientTexture") {
preview->set_stretch_mode(TextureRect::STRETCH_SCALE);
@@ -2374,7 +2370,7 @@ void EditorPropertyResource::update_property() {
if (res->get_name() != String()) {
assign->set_text(res->get_name());
} else if (res->get_path().is_resource_file()) {
- assign->set_text(res->get_name());
+ assign->set_text(res->get_path().get_file());
assign->set_tooltip(res->get_path());
} else {
assign->set_text(res->get_class());
diff --git a/editor/editor_properties.h b/editor/editor_properties.h
index 18e70345aa..35d8f4d306 100644
--- a/editor/editor_properties.h
+++ b/editor/editor_properties.h
@@ -548,7 +548,7 @@ class EditorPropertyResource : public EditorProperty {
void _file_selected(const String &p_path);
void _menu_option(int p_which);
- void _resource_preview(const String &p_path, const Ref<Texture> &p_preview, ObjectID p_obj);
+ void _resource_preview(const String &p_path, const Ref<Texture> &p_preview, const Ref<Texture> &p_small_preview, ObjectID p_obj);
void _resource_selected();
void _viewport_selected(const NodePath &p_path);
diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp
index 3cdbc4f188..36053d7534 100644
--- a/editor/editor_themes.cpp
+++ b/editor/editor_themes.cpp
@@ -251,7 +251,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
Color preset_accent_color;
Color preset_base_color;
- float preset_contrast;
+ float preset_contrast = 0;
// Please, use alphabet order if you've added new theme here(After "Default" and "Custom")
@@ -635,7 +635,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
theme->set_icon("visibility_hidden", "PopupMenu", theme->get_icon("GuiVisibilityHidden", "EditorIcons"));
theme->set_icon("visibility_visible", "PopupMenu", theme->get_icon("GuiVisibilityVisible", "EditorIcons"));
theme->set_icon("visibility_xray", "PopupMenu", theme->get_icon("GuiVisibilityXray", "EditorIcons"));
- theme->set_constant("vseparation", "PopupMenu", (extra_spacing + default_margin_size) * EDSCALE);
+ theme->set_constant("vseparation", "PopupMenu", (extra_spacing + default_margin_size + 1) * EDSCALE);
Ref<StyleBoxFlat> sub_inspector_bg = make_flat_stylebox(dark_color_1, 2, 0, 0, 0);
sub_inspector_bg->set_border_width(MARGIN_LEFT, 2);
@@ -734,10 +734,10 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
theme->set_color("font_color", "ItemList", font_color);
theme->set_color("font_color_selected", "ItemList", mono_color);
theme->set_color("guide_color", "ItemList", guide_color);
- theme->set_constant("vseparation", "ItemList", 2 * EDSCALE);
- theme->set_constant("hseparation", "ItemList", 2 * EDSCALE);
+ theme->set_constant("vseparation", "ItemList", 3 * EDSCALE);
+ theme->set_constant("hseparation", "ItemList", 3 * EDSCALE);
theme->set_constant("icon_margin", "ItemList", default_margin_size * EDSCALE);
- theme->set_constant("line_separation", "ItemList", 2 * EDSCALE);
+ theme->set_constant("line_separation", "ItemList", 3 * EDSCALE);
// Tabs & TabContainer
theme->set_stylebox("tab_fg", "TabContainer", style_tab_selected);
@@ -1016,6 +1016,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
theme->set_constant("port_offset", "GraphNode", 14 * EDSCALE);
theme->set_constant("title_h_offset", "GraphNode", -16 * EDSCALE);
+ theme->set_constant("title_offset", "GraphNode", 20 * EDSCALE);
theme->set_constant("close_h_offset", "GraphNode", 20 * EDSCALE);
theme->set_constant("close_offset", "GraphNode", 20 * EDSCALE);
theme->set_constant("separation", "GraphNode", 1 * EDSCALE);
diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp
index 2c69909f23..26bc43c540 100644
--- a/editor/filesystem_dock.cpp
+++ b/editor/filesystem_dock.cpp
@@ -412,7 +412,7 @@ void FileSystemDock::_tree_multi_selected(Object *p_item, int p_column, bool p_s
return;
TreeItem *favorites_item = tree->get_root()->get_children();
- if (selected->get_parent() == favorites_item) {
+ if (selected->get_parent() == favorites_item && !String(selected->get_metadata(0)).ends_with("/")) {
// Go to the favorites if we click in the favorites and the path has changed
path = "Favorites";
} else {
@@ -1172,6 +1172,23 @@ void FileSystemDock::_update_project_settings_after_move(const Map<String, Strin
}
};
}
+
+ // Also search for the file in autoload, as they are stored differently from normal files.
+ List<PropertyInfo> property_list;
+ ProjectSettings::get_singleton()->get_property_list(&property_list);
+ for (const List<PropertyInfo>::Element *E = property_list.front(); E; E = E->next()) {
+ if (E->get().name.begins_with("autoload/")) {
+ // If the autoload resource paths has a leading "*", it indicates that it is a Singleton,
+ // so we have to handle both cases when updating.
+ String autoload = GLOBAL_GET(E->get().name);
+ String autoload_singleton = autoload.substr(1, autoload.length());
+ if (p_renames.has(autoload)) {
+ ProjectSettings::get_singleton()->set_setting(E->get().name, p_renames[autoload]);
+ } else if (autoload.begins_with("*") && p_renames.has(autoload_singleton)) {
+ ProjectSettings::get_singleton()->set_setting(E->get().name, "*" + p_renames[autoload_singleton]);
+ }
+ }
+ }
ProjectSettings::get_singleton()->save();
}
@@ -1200,7 +1217,8 @@ void FileSystemDock::_make_dir_confirm() {
if (dir_name.length() == 0) {
EditorNode::get_singleton()->show_warning(TTR("No name provided"));
return;
- } else if (dir_name.find("/") != -1 || dir_name.find("\\") != -1 || dir_name.find(":") != -1 || dir_name.ends_with(".") || dir_name.ends_with(" ")) {
+ } else if (dir_name.find("/") != -1 || dir_name.find("\\") != -1 || dir_name.find(":") != -1 || dir_name.find("*") != -1 ||
+ dir_name.find("|") != -1 || dir_name.find(">") != -1 || dir_name.ends_with(".") || dir_name.ends_with(" ")) {
EditorNode::get_singleton()->show_warning(TTR("Provided name contains invalid characters"));
return;
}
@@ -1953,7 +1971,7 @@ void FileSystemDock::_get_drag_target_folder(String &target, bool &target_favori
}
String ltarget = files->get_item_metadata(pos);
- target = ltarget.ends_with("/") ? ltarget : path;
+ target = ltarget.ends_with("/") ? ltarget : path.get_base_dir();
return;
}
diff --git a/editor/find_in_files.cpp b/editor/find_in_files.cpp
index 2af81b8ac7..0ccaa95fb7 100644
--- a/editor/find_in_files.cpp
+++ b/editor/find_in_files.cpp
@@ -31,6 +31,7 @@
#include "find_in_files.h"
#include "core/os/dir_access.h"
#include "core/os/os.h"
+#include "editor_node.h"
#include "editor_scale.h"
#include "scene/gui/box_container.h"
#include "scene/gui/button.h"
@@ -300,7 +301,7 @@ const char *FindInFilesDialog::SIGNAL_REPLACE_REQUESTED = "replace_requested";
FindInFilesDialog::FindInFilesDialog() {
- set_custom_minimum_size(Size2(400, 190));
+ set_custom_minimum_size(Size2(400, 190) * EDSCALE);
set_resizable(true);
set_title(TTR("Find in Files"));
@@ -334,13 +335,11 @@ FindInFilesDialog::FindInFilesDialog() {
HBoxContainer *hbc = memnew(HBoxContainer);
_whole_words_checkbox = memnew(CheckBox);
- _whole_words_checkbox->set_text(TTR("Whole words"));
- _whole_words_checkbox->set_pressed(true);
+ _whole_words_checkbox->set_text(TTR("Whole Words"));
hbc->add_child(_whole_words_checkbox);
_match_case_checkbox = memnew(CheckBox);
- _match_case_checkbox->set_text(TTR("Match case"));
- _match_case_checkbox->set_pressed(true);
+ _match_case_checkbox->set_text(TTR("Match Case"));
hbc->add_child(_match_case_checkbox);
gc->add_child(hbc);
@@ -548,7 +547,7 @@ FindInFilesPanel::FindInFilesPanel() {
hbc->add_child(find_label);
_search_text_label = memnew(Label);
- _search_text_label->add_font_override("font", get_font("source", "EditorFonts"));
+ _search_text_label->add_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_font("source", "EditorFonts"));
hbc->add_child(_search_text_label);
_progress_bar = memnew(ProgressBar);
@@ -562,14 +561,14 @@ FindInFilesPanel::FindInFilesPanel() {
_cancel_button = memnew(Button);
_cancel_button->set_text(TTR("Cancel"));
_cancel_button->connect("pressed", this, "_on_cancel_button_clicked");
- _cancel_button->set_disabled(true);
+ _cancel_button->hide();
hbc->add_child(_cancel_button);
vbc->add_child(hbc);
}
_results_display = memnew(Tree);
- _results_display->add_font_override("font", get_font("source", "EditorFonts"));
+ _results_display->add_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_font("source", "EditorFonts"));
_results_display->set_v_size_flags(SIZE_EXPAND_FILL);
_results_display->connect("item_selected", this, "_on_result_selected");
_results_display->connect("item_edited", this, "_on_item_edited");
@@ -641,7 +640,7 @@ void FindInFilesPanel::start_search() {
_finder->start();
update_replace_buttons();
- _cancel_button->set_disabled(false);
+ _cancel_button->show();
}
void FindInFilesPanel::stop_search() {
@@ -651,7 +650,7 @@ void FindInFilesPanel::stop_search() {
_status_label->set_text("");
update_replace_buttons();
set_progress_visible(false);
- _cancel_button->set_disabled(true);
+ _cancel_button->hide();
}
void FindInFilesPanel::_notification(int p_what) {
@@ -687,7 +686,7 @@ void FindInFilesPanel::_on_result_found(String fpath, int line_number, int begin
// Do this first because it resets properties of the cell...
item->set_cell_mode(text_index, TreeItem::CELL_MODE_CUSTOM);
- String item_text = String::num_int64(line_number) + ": " + text.replace("\t", " ");
+ String item_text = vformat("%3s: %s", line_number, text.replace("\t", " "));
item->set_text(text_index, item_text);
item->set_custom_draw(text_index, this, "_draw_result_text");
@@ -702,7 +701,7 @@ void FindInFilesPanel::_on_result_found(String fpath, int line_number, int begin
r.begin = begin;
r.end = end;
r.draw_begin = (item_text_width - raw_text_width) + font->get_string_size(text.left(r.begin)).x;
- r.draw_width = font->get_string_size(text.substr(r.begin, r.end - r.begin + 1)).x;
+ r.draw_width = font->get_string_size(text.substr(r.begin, r.end - r.begin)).x;
_result_items[item] = r;
if (_with_replace) {
@@ -753,7 +752,7 @@ void FindInFilesPanel::_on_finished() {
_status_label->set_text(TTR("Search complete"));
update_replace_buttons();
set_progress_visible(false);
- _cancel_button->set_disabled(true);
+ _cancel_button->hide();
}
void FindInFilesPanel::_on_cancel_button_clicked() {
diff --git a/editor/icons/icon_GUI_viewport_hdiagsplitter.svg b/editor/icons/icon_GUI_viewport_hdiagsplitter.svg
index 36769768fd..90a0f56c43 100644
--- a/editor/icons/icon_GUI_viewport_hdiagsplitter.svg
+++ b/editor/icons/icon_GUI_viewport_hdiagsplitter.svg
@@ -1,64 +1,5 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<svg
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:cc="http://creativecommons.org/ns#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns="http://www.w3.org/2000/svg"
- xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
- xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
- width="64"
- height="34"
- version="1.1"
- viewBox="0 0 64 34"
- id="svg6"
- sodipodi:docname="icon_GUI_vsplitter1.svg"
- inkscape:version="0.92.2 2405546, 2018-03-11">
- <metadata
- id="metadata12">
- <rdf:RDF>
- <cc:Work
- rdf:about="">
- <dc:format>image/svg+xml</dc:format>
- <dc:type
- rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title></dc:title>
- </cc:Work>
- </rdf:RDF>
- </metadata>
- <defs
- id="defs10" />
- <sodipodi:namedview
- pagecolor="#ffffff"
- bordercolor="#666666"
- borderopacity="1"
- objecttolerance="10"
- gridtolerance="10"
- guidetolerance="10"
- inkscape:pageopacity="0"
- inkscape:pageshadow="2"
- inkscape:window-width="1366"
- inkscape:window-height="714"
- id="namedview8"
- showgrid="false"
- inkscape:zoom="5.6568543"
- inkscape:cx="37.006499"
- inkscape:cy="15.680715"
- inkscape:window-x="0"
- inkscape:window-y="0"
- inkscape:window-maximized="1"
- inkscape:current-layer="svg6" />
- <g
- transform="translate(0,-1018.4)"
- id="g4" />
- <g
- transform="rotate(90,541.2,539.2)"
- id="g4-3">
- <path
- id="path2-6"
- style="fill:none;stroke:#ffffff;stroke-width:2;stroke-linecap:round;stroke-opacity:0.39216003"
- d="M 4.0306826,1048.4 H 34 m -30,30 v -60"
- inkscape:connector-curvature="0"
- sodipodi:nodetypes="cccc" />
- </g>
+<svg width="64" height="34" version="1.1" viewBox="0 0 64 34" xmlns="http://www.w3.org/2000/svg">
+<g transform="rotate(90,541.2,539.2)">
+<path d="m4.0307 1048.4h29.969m-30 30v-60" fill="none" stroke="#fff" stroke-linecap="round" stroke-opacity=".39216" stroke-width="2"/>
+</g>
</svg>
diff --git a/editor/icons/icon_GUI_viewport_vdiagsplitter.svg b/editor/icons/icon_GUI_viewport_vdiagsplitter.svg
index f23b4a0a74..481f895d46 100644
--- a/editor/icons/icon_GUI_viewport_vdiagsplitter.svg
+++ b/editor/icons/icon_GUI_viewport_vdiagsplitter.svg
@@ -1,68 +1,7 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<svg
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:cc="http://creativecommons.org/ns#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns="http://www.w3.org/2000/svg"
- xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
- xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
- width="34"
- height="64"
- version="1.1"
- viewBox="0 0 34 64"
- id="svg6"
- sodipodi:docname="icon_GUI_vsplitter2.svg"
- inkscape:version="0.92.2 2405546, 2018-03-11">
- <metadata
- id="metadata12">
- <rdf:RDF>
- <cc:Work
- rdf:about="">
- <dc:format>image/svg+xml</dc:format>
- <dc:type
- rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title></dc:title>
- </cc:Work>
- </rdf:RDF>
- </metadata>
- <defs
- id="defs10" />
- <sodipodi:namedview
- pagecolor="#ffffff"
- bordercolor="#666666"
- borderopacity="1"
- objecttolerance="10"
- gridtolerance="10"
- guidetolerance="10"
- inkscape:pageopacity="0"
- inkscape:pageshadow="2"
- inkscape:window-width="1366"
- inkscape:window-height="714"
- id="namedview8"
- showgrid="false"
- inkscape:zoom="4"
- inkscape:cx="32.245723"
- inkscape:cy="44.255214"
- inkscape:window-x="0"
- inkscape:window-y="0"
- inkscape:window-maximized="1"
- inkscape:current-layer="svg6" />
- <g
- transform="translate(0,-988.4)"
- id="g4" />
- <g
- id="g839"
- transform="rotate(90,32.003536,32.003535)">
- <g
- id="g4-3"
- transform="rotate(90,526.2,554.2)">
- <path
- sodipodi:nodetypes="cccc"
- inkscape:connector-curvature="0"
- d="M 4.0306826,1048.4 H 34 m -30,30 v -60"
- style="fill:none;stroke:#ffffff;stroke-width:2;stroke-linecap:round;stroke-opacity:0.39216003"
- id="path2-6" />
- </g>
- </g>
+<svg width="34" height="64" version="1.1" viewBox="0 0 34 64" xmlns="http://www.w3.org/2000/svg">
+<g transform="rotate(90 32.004 32.004)">
+<g transform="rotate(90,526.2,554.2)">
+<path d="m4.0307 1048.4h29.969m-30 30v-60" fill="none" stroke="#fff" stroke-linecap="round" stroke-opacity=".39216" stroke-width="2"/>
+</g>
+</g>
</svg>
diff --git a/editor/icons/icon_GUI_viewport_vhsplitter.svg b/editor/icons/icon_GUI_viewport_vhsplitter.svg
index 429cf909ae..52d7d8f0b7 100644
--- a/editor/icons/icon_GUI_viewport_vhsplitter.svg
+++ b/editor/icons/icon_GUI_viewport_vhsplitter.svg
@@ -1,63 +1,5 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<svg
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:cc="http://creativecommons.org/ns#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns="http://www.w3.org/2000/svg"
- xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
- xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
- width="64"
- height="64"
- version="1.1"
- viewBox="0 0 64 64"
- id="svg6"
- sodipodi:docname="icon_GUI_vsplitter.svg"
- inkscape:version="0.92.2 2405546, 2018-03-11">
- <metadata
- id="metadata12">
- <rdf:RDF>
- <cc:Work
- rdf:about="">
- <dc:format>image/svg+xml</dc:format>
- <dc:type
- rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title></dc:title>
- </cc:Work>
- </rdf:RDF>
- </metadata>
- <defs
- id="defs10" />
- <sodipodi:namedview
- pagecolor="#ffffff"
- bordercolor="#666666"
- borderopacity="1"
- objecttolerance="10"
- gridtolerance="10"
- guidetolerance="10"
- inkscape:pageopacity="0"
- inkscape:pageshadow="2"
- inkscape:window-width="1366"
- inkscape:window-height="714"
- id="namedview8"
- showgrid="false"
- inkscape:zoom="4.65625"
- inkscape:cx="9.8488117"
- inkscape:cy="20.04653"
- inkscape:window-x="0"
- inkscape:window-y="0"
- inkscape:window-maximized="1"
- inkscape:current-layer="svg6" />
- <g
- transform="translate(0,-988.4)"
- id="g4" />
- <g
- transform="rotate(90,526.2,554.2)"
- id="g4-3">
- <path
- id="path2-6"
- style="fill:none;stroke:#ffffff;stroke-width:2;stroke-linecap:round;stroke-opacity:0.39216003"
- d="m -26,1048.4 h 60 m -30,30 v -60"
- inkscape:connector-curvature="0" />
- </g>
+<svg width="64" height="64" version="1.1" viewBox="0 0 64 64" xmlns="http://www.w3.org/2000/svg">
+<g transform="rotate(90,526.2,554.2)">
+<path d="m-26 1048.4h60m-30 30v-60" fill="none" stroke="#fff" stroke-linecap="round" stroke-opacity=".39216" stroke-width="2"/>
+</g>
</svg>
diff --git a/editor/icons/icon_noise_texture.svg b/editor/icons/icon_noise_texture.svg
new file mode 100644
index 0000000000..5908c2b2d4
--- /dev/null
+++ b/editor/icons/icon_noise_texture.svg
@@ -0,0 +1,3 @@
+<svg width="16" height="16" version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
+<path d="m2 1c-0.55228 0-1 0.44772-1 1v12c0 0.55228 0.44772 1 1 1h12c0.55228 0 1-0.44772 1-1v-12c0-0.55228-0.44772-1-1-1zm1 2h10v8h-10zm3 1v2h2v-2zm2 2v2h2v2h2v-6h-2v2zm0 2h-2v-2h-2v4h4z" fill="#e0e0e0" fill-opacity=".99608"/>
+</svg>
diff --git a/editor/icons/icon_script_extend.svg b/editor/icons/icon_script_extend.svg
new file mode 100644
index 0000000000..ef3d48af9f
--- /dev/null
+++ b/editor/icons/icon_script_extend.svg
@@ -0,0 +1,8 @@
+<svg width="16" height="16" version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
+<g transform="translate(0 -1036.4)">
+<path transform="translate(0 1036.4)" d="m6 1v1c-0.55228 0-1 0.44772-1 1v10h-1v-2h-2v2c2.826e-4 0.35698 0.19084 0.68674 0.5 0.86523 0.15194 0.088045 0.32439 0.13452 0.5 0.13477v1h7c0.73866 0 1.3763-0.40437 1.7227-1h-3.7227v-4h4v-5h3v-2c0-1.1046-0.89543-2-2-2z" fill="#e0e0e0"/>
+<path transform="translate(0 1036.4)" d="m6 1c-1.1046 0-2 0.89543-2 2v7h-2-1v1 2c0 1.1046 0.89543 2 2 2s2-0.89543 2-2v-10c0-0.55228 0.44772-1 1-1s1 0.44772 1 1v1 1 1h1 4v-1h-4v-1-1c0-1.1046-0.89543-2-2-2zm-4 10h2v2c0 0.55228-0.44772 1-1 1s-1-0.44772-1-1v-2z" fill="#b4b4b4"/>
+<circle cx="3" cy="1048.4" rx="1" ry="1" fill="#e0e0e0"/>
+<path d="m16 1048.4-3-3v2h-4v2h4v2z" fill="#68b6ff" fill-rule="evenodd"/>
+</g>
+</svg>
diff --git a/editor/import/editor_import_collada.cpp b/editor/import/editor_import_collada.cpp
index 60ca66e464..e8bb772a64 100644
--- a/editor/import/editor_import_collada.cpp
+++ b/editor/import/editor_import_collada.cpp
@@ -321,7 +321,7 @@ Error ColladaImport::_create_scene(Collada::Node *p_node, Spatial *p_parent) {
} else {
//mesh since nothing else
node = memnew(MeshInstance);
- Object::cast_to<MeshInstance>(node)->set_flag(GeometryInstance::FLAG_USE_BAKED_LIGHT, true);
+ //Object::cast_to<MeshInstance>(node)->set_flag(GeometryInstance::FLAG_USE_BAKED_LIGHT, true);
}
} break;
case Collada::Node::TYPE_SKELETON: {
diff --git a/editor/import/editor_scene_importer_gltf.cpp b/editor/import/editor_scene_importer_gltf.cpp
index a6b754de3b..cb15be35f2 100644
--- a/editor/import/editor_scene_importer_gltf.cpp
+++ b/editor/import/editor_scene_importer_gltf.cpp
@@ -1793,22 +1793,22 @@ template <>
struct EditorSceneImporterGLTFInterpolate<Quat> {
Quat lerp(const Quat &a, const Quat &b, float c) const {
- ERR_FAIL_COND_V(a.is_normalized() == false, Quat());
- ERR_FAIL_COND_V(b.is_normalized() == false, Quat());
+ ERR_FAIL_COND_V(!a.is_normalized(), Quat());
+ ERR_FAIL_COND_V(!b.is_normalized(), Quat());
return a.slerp(b, c).normalized();
}
Quat catmull_rom(const Quat &p0, const Quat &p1, const Quat &p2, const Quat &p3, float c) {
- ERR_FAIL_COND_V(p1.is_normalized() == false, Quat());
- ERR_FAIL_COND_V(p2.is_normalized() == false, Quat());
+ ERR_FAIL_COND_V(!p1.is_normalized(), Quat());
+ ERR_FAIL_COND_V(!p2.is_normalized(), Quat());
return p1.slerp(p2, c).normalized();
}
Quat bezier(Quat start, Quat control_1, Quat control_2, Quat end, float t) {
- ERR_FAIL_COND_V(start.is_normalized() == false, Quat());
- ERR_FAIL_COND_V(end.is_normalized() == false, Quat());
+ ERR_FAIL_COND_V(!start.is_normalized(), Quat());
+ ERR_FAIL_COND_V(!end.is_normalized(), Quat());
return start.slerp(end, t).normalized();
}
diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp
index 6d72cb4909..c5a5980fc1 100644
--- a/editor/import/resource_importer_scene.cpp
+++ b/editor/import/resource_importer_scene.cpp
@@ -365,29 +365,37 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array
return p_node;
MeshInstance *mi = Object::cast_to<MeshInstance>(p_node);
if (mi) {
- Node *col;
+ Node *col = NULL;
if (_teststr(name, "colonly")) {
col = mi->create_trimesh_collision_node();
- ERR_FAIL_COND_V(!col, NULL);
+ if (col == NULL) {
+ ERR_PRINTS("Error generating collision for mesh: " + name);
+ } else {
- col->set_name(_fixstr(name, "colonly"));
+ col->set_name(_fixstr(name, "colonly"));
+ }
} else {
col = mi->create_convex_collision_node();
- ERR_FAIL_COND_V(!col, NULL);
+ if (col == NULL) {
+ ERR_PRINTS("Error generating collision for mesh: " + name);
+ } else {
- col->set_name(_fixstr(name, "convcolonly"));
+ col->set_name(_fixstr(name, "convcolonly"));
+ }
}
- Object::cast_to<Spatial>(col)->set_transform(mi->get_transform());
- p_node->replace_by(col);
- memdelete(p_node);
- p_node = col;
+ if (col) {
+ Object::cast_to<Spatial>(col)->set_transform(mi->get_transform());
+ p_node->replace_by(col);
+ memdelete(p_node);
+ p_node = col;
- StaticBody *sb = Object::cast_to<StaticBody>(col);
- CollisionShape *colshape = Object::cast_to<CollisionShape>(sb->get_child(0));
- colshape->set_name("shape");
- colshape->set_owner(p_node->get_owner());
+ StaticBody *sb = Object::cast_to<StaticBody>(col);
+ CollisionShape *colshape = Object::cast_to<CollisionShape>(sb->get_child(0));
+ colshape->set_name("shape");
+ colshape->set_owner(p_node->get_owner());
+ }
} else if (p_node->has_meta("empty_draw_type")) {
String empty_draw_type = String(p_node->get_meta("empty_draw_type"));
StaticBody *sb = memnew(StaticBody);
diff --git a/editor/import/resource_importer_scene.h b/editor/import/resource_importer_scene.h
index b046e2e975..b81a52ab70 100644
--- a/editor/import/resource_importer_scene.h
+++ b/editor/import/resource_importer_scene.h
@@ -116,7 +116,7 @@ class ResourceImporterScene : public ResourceImporter {
enum LightBakeMode {
LIGHT_BAKE_DISABLED,
LIGHT_BAKE_ENABLE,
- //LIGHT_BAKE_LIGHTMAPS
+ LIGHT_BAKE_LIGHTMAPS
};
void _replace_owner(Node *p_node, Node *p_scene, Node *p_new_owner);
diff --git a/editor/inspector_dock.cpp b/editor/inspector_dock.cpp
index 4f4980d83c..750fca2852 100644
--- a/editor/inspector_dock.cpp
+++ b/editor/inspector_dock.cpp
@@ -328,6 +328,21 @@ Container *InspectorDock::get_addon_area() {
return this;
}
+void InspectorDock::_notification(int p_what) {
+ switch (p_what) {
+ case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
+ set_theme(editor->get_gui_base()->get_theme());
+ resource_new_button->set_icon(get_icon("New", "EditorIcons"));
+ resource_load_button->set_icon(get_icon("Load", "EditorIcons"));
+ backward_button->set_icon(get_icon("Back", "EditorIcons"));
+ forward_button->set_icon(get_icon("Forward", "EditorIcons"));
+ history_menu->set_icon(get_icon("History", "EditorIcons"));
+ object_menu->set_icon(get_icon("Tools", "EditorIcons"));
+ warning->set_icon(get_icon("NodeWarning", "EditorIcons"));
+ } break;
+ }
+}
+
void InspectorDock::_bind_methods() {
ClassDB::bind_method("_menu_option", &InspectorDock::_menu_option);
diff --git a/editor/inspector_dock.h b/editor/inspector_dock.h
index 97ef6899dc..57d2a03295 100644
--- a/editor/inspector_dock.h
+++ b/editor/inspector_dock.h
@@ -118,6 +118,7 @@ class InspectorDock : public VBoxContainer {
protected:
static void _bind_methods();
+ void _notification(int p_what);
public:
void go_back();
diff --git a/editor/plugin_config_dialog.cpp b/editor/plugin_config_dialog.cpp
index a334f79f5a..8e626e7111 100644
--- a/editor/plugin_config_dialog.cpp
+++ b/editor/plugin_config_dialog.cpp
@@ -180,7 +180,7 @@ PluginConfigDialog::PluginConfigDialog() {
grid->add_child(desc_lb);
desc_edit = memnew(TextEdit);
- desc_edit->set_custom_minimum_size(Size2(400.0f, 50.0f));
+ desc_edit->set_custom_minimum_size(Size2(400, 80) * EDSCALE);
grid->add_child(desc_edit);
Label *author_lb = memnew(Label);
diff --git a/editor/plugins/abstract_polygon_2d_editor.cpp b/editor/plugins/abstract_polygon_2d_editor.cpp
index f7e59e2beb..71a5d73b2f 100644
--- a/editor/plugins/abstract_polygon_2d_editor.cpp
+++ b/editor/plugins/abstract_polygon_2d_editor.cpp
@@ -132,8 +132,8 @@ Vector2 AbstractPolygon2DEditor::_get_offset(int p_idx) const {
void AbstractPolygon2DEditor::_commit_action() {
- undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update");
- undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update");
+ undo_redo->add_do_method(canvas_item_editor, "update_viewport");
+ undo_redo->add_undo_method(canvas_item_editor, "update_viewport");
undo_redo->commit_action();
}
@@ -218,7 +218,7 @@ void AbstractPolygon2DEditor::_node_removed(Node *p_node) {
edit(NULL);
hide();
- canvas_item_editor->get_viewport_control()->update();
+ canvas_item_editor->update_viewport();
}
}
@@ -334,7 +334,7 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event)
edited_point = PosVertex(closest, xform.affine_inverse().xform(closest.pos));
selected_point = closest;
edge_point = PosVertex();
- canvas_item_editor->get_viewport_control()->update();
+ canvas_item_editor->update_viewport();
return true;
} else {
@@ -403,7 +403,7 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event)
wip_active = true;
_wip_changed();
edited_point = PosVertex(-1, 1, cpoint);
- canvas_item_editor->get_viewport_control()->update();
+ canvas_item_editor->update_viewport();
hover_point = Vertex();
selected_point = Vertex(0);
edge_point = PosVertex();
@@ -424,7 +424,7 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event)
_wip_changed();
edited_point = PosVertex(-1, wip.size(), cpoint);
selected_point = Vertex(wip.size() - 1);
- canvas_item_editor->get_viewport_control()->update();
+ canvas_item_editor->update_viewport();
return true;
}
}
@@ -453,7 +453,7 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event)
_set_polygon(edited_point.polygon, vertices);
}
- canvas_item_editor->get_viewport_control()->update();
+ canvas_item_editor->update_viewport();
} else if (mode == MODE_EDIT || (_is_line() && mode == MODE_CREATE)) {
const PosVertex onEdgeVertex = closest_edge_point(gpoint);
@@ -462,20 +462,20 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event)
hover_point = Vertex();
edge_point = onEdgeVertex;
- canvas_item_editor->get_viewport_control()->update();
+ canvas_item_editor->update_viewport();
} else {
if (edge_point.valid()) {
edge_point = PosVertex();
- canvas_item_editor->get_viewport_control()->update();
+ 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->get_viewport_control()->update();
+ canvas_item_editor->update_viewport();
}
}
}
@@ -494,7 +494,7 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event)
wip.remove(selected_point.vertex);
_wip_changed();
selected_point = wip.size() - 1;
- canvas_item_editor->get_viewport_control()->update();
+ canvas_item_editor->update_viewport();
return true;
}
} else {
@@ -627,7 +627,7 @@ void AbstractPolygon2DEditor::edit(Node *p_polygon) {
hover_point = Vertex();
selected_point = Vertex();
- canvas_item_editor->get_viewport_control()->update();
+ canvas_item_editor->update_viewport();
} else {
diff --git a/editor/plugins/animation_blend_space_2d_editor.cpp b/editor/plugins/animation_blend_space_2d_editor.cpp
index c4f8cdc3d7..394b888d0e 100644
--- a/editor/plugins/animation_blend_space_2d_editor.cpp
+++ b/editor/plugins/animation_blend_space_2d_editor.cpp
@@ -434,7 +434,7 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_draw() {
if (blend_space->get_snap().x > 0) {
- int prev_idx;
+ 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;
@@ -450,7 +450,7 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_draw() {
if (blend_space->get_snap().y > 0) {
- int prev_idx;
+ 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;
diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp
index 66770d98e5..138b8a491c 100644
--- a/editor/plugins/asset_library_editor_plugin.cpp
+++ b/editor/plugins/asset_library_editor_plugin.cpp
@@ -962,6 +962,9 @@ HBoxContainer *EditorAssetLibrary::_make_pages(int p_page, int p_page_count, int
HBoxContainer *hbc = memnew(HBoxContainer);
+ if (p_page_count < 2)
+ return hbc;
+
//do the mario
int from = p_page - 5;
if (from < 0)
diff --git a/editor/plugins/camera_editor_plugin.cpp b/editor/plugins/camera_editor_plugin.cpp
index 37fbb54c30..3d8b24ccc7 100644
--- a/editor/plugins/camera_editor_plugin.cpp
+++ b/editor/plugins/camera_editor_plugin.cpp
@@ -32,18 +32,6 @@
#include "spatial_editor_plugin.h"
-void CameraEditor::_notification(int p_what) {
-
- switch (p_what) {
-
- /* case NOTIFICATION_PROCESS: {
-
- if (preview->is_pressed() && node)
- node->call("make_current");
-
- } break;*/
- }
-}
void CameraEditor::_node_removed(Node *p_node) {
if (p_node == node) {
diff --git a/editor/plugins/camera_editor_plugin.h b/editor/plugins/camera_editor_plugin.h
index 275624beeb..0340808c9a 100644
--- a/editor/plugins/camera_editor_plugin.h
+++ b/editor/plugins/camera_editor_plugin.h
@@ -50,7 +50,6 @@ class CameraEditor : public Control {
void _pressed();
protected:
- void _notification(int p_what);
void _node_removed(Node *p_node);
static void _bind_methods();
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index e8f00ce0ba..31dd20e453 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -1025,8 +1025,7 @@ bool CanvasItemEditor::_gui_input_zoom_or_pan(const Ref<InputEvent> &p_event) {
// Scroll or pan down
if (bool(EditorSettings::get_singleton()->get("editors/2d/scroll_to_pan"))) {
view_offset.y += int(EditorSettings::get_singleton()->get("editors/2d/pan_speed")) / zoom * b->get_factor();
- _update_scrollbars();
- viewport->update();
+ update_viewport();
} else {
_zoom_on_position(zoom * (1 - (0.05 * b->get_factor())), b->get_position());
}
@@ -1037,8 +1036,7 @@ bool CanvasItemEditor::_gui_input_zoom_or_pan(const Ref<InputEvent> &p_event) {
// Scroll or pan up
if (bool(EditorSettings::get_singleton()->get("editors/2d/scroll_to_pan"))) {
view_offset.y -= int(EditorSettings::get_singleton()->get("editors/2d/pan_speed")) / zoom * b->get_factor();
- _update_scrollbars();
- viewport->update();
+ update_viewport();
} else {
_zoom_on_position(zoom * ((0.95 + (0.05 * b->get_factor())) / 0.95), b->get_position());
}
@@ -1049,8 +1047,7 @@ bool CanvasItemEditor::_gui_input_zoom_or_pan(const Ref<InputEvent> &p_event) {
// Pan left
if (bool(EditorSettings::get_singleton()->get("editors/2d/scroll_to_pan"))) {
view_offset.x -= int(EditorSettings::get_singleton()->get("editors/2d/pan_speed")) / zoom * b->get_factor();
- _update_scrollbars();
- viewport->update();
+ update_viewport();
return true;
}
}
@@ -1059,8 +1056,7 @@ bool CanvasItemEditor::_gui_input_zoom_or_pan(const Ref<InputEvent> &p_event) {
// Pan right
if (bool(EditorSettings::get_singleton()->get("editors/2d/scroll_to_pan"))) {
view_offset.x += int(EditorSettings::get_singleton()->get("editors/2d/pan_speed")) / zoom * b->get_factor();
- _update_scrollbars();
- viewport->update();
+ update_viewport();
return true;
}
}
@@ -1112,8 +1108,7 @@ bool CanvasItemEditor::_gui_input_zoom_or_pan(const Ref<InputEvent> &p_event) {
}
view_offset.x -= relative.x / zoom;
view_offset.y -= relative.y / zoom;
- _update_scrollbars();
- viewport->update();
+ update_viewport();
return true;
}
}
@@ -1131,8 +1126,7 @@ bool CanvasItemEditor::_gui_input_zoom_or_pan(const Ref<InputEvent> &p_event) {
const Vector2 delta = (int(EditorSettings::get_singleton()->get("editors/2d/pan_speed")) / zoom) * pan_gesture->get_delta();
view_offset.x += delta.x;
view_offset.y += delta.y;
- _update_scrollbars();
- viewport->update();
+ update_viewport();
return true;
}
@@ -3168,6 +3162,11 @@ void CanvasItemEditor::_draw_viewport() {
_draw_hover();
}
+void CanvasItemEditor::update_viewport() {
+ _update_scrollbars();
+ viewport->update();
+}
+
void CanvasItemEditor::_notification(int p_what) {
if (p_what == NOTIFICATION_PHYSICS_PROCESS) {
@@ -3574,8 +3573,7 @@ void CanvasItemEditor::_zoom_on_position(float p_zoom, Point2 p_position) {
view_offset.x = Math::round(view_offset.x + ofs.x);
view_offset.y = Math::round(view_offset.y + ofs.y);
- _update_scrollbars();
- viewport->update();
+ update_viewport();
}
void CanvasItemEditor::_button_zoom_minus() {
@@ -4172,8 +4170,7 @@ void CanvasItemEditor::_focus_selection(int p_op) {
Vector2 offset = viewport->get_size() / 2 - editor->get_scene_root()->get_global_canvas_transform().xform(center);
view_offset.x -= offset.x / zoom;
view_offset.y -= offset.y / zoom;
- _update_scrollbars();
- viewport->update();
+ update_viewport();
} else { // VIEW_FRAME_TO_SELECTION
@@ -4210,6 +4207,7 @@ void CanvasItemEditor::_bind_methods() {
ClassDB::bind_method(D_METHOD("_selection_result_pressed"), &CanvasItemEditor::_selection_result_pressed);
ClassDB::bind_method(D_METHOD("_selection_menu_hide"), &CanvasItemEditor::_selection_menu_hide);
ClassDB::bind_method(D_METHOD("set_state"), &CanvasItemEditor::set_state);
+ ClassDB::bind_method(D_METHOD("update_viewport"), &CanvasItemEditor::update_viewport);
ADD_SIGNAL(MethodInfo("item_lock_status_changed"));
ADD_SIGNAL(MethodInfo("item_group_status_changed"));
@@ -4608,6 +4606,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
skeleton_menu = memnew(MenuButton);
hb->add_child(skeleton_menu);
+ skeleton_menu->set_tooltip(TTR("Skeleton Options"));
p = skeleton_menu->get_popup();
p->set_hide_on_checkable_item_selection(false);
@@ -5113,7 +5112,7 @@ bool CanvasItemEditorViewport::can_drop_data(const Point2 &p_point, const Varian
type == "AtlasTexture" ||
type == "LargeTexture") {
Ref<Texture> texture = Ref<Texture>(Object::cast_to<Texture>(*res));
- if (texture.is_valid() == false) {
+ if (!texture.is_valid()) {
continue;
}
} else {
diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h
index 6a788692d7..dc7b74112f 100644
--- a/editor/plugins/canvas_item_editor_plugin.h
+++ b/editor/plugins/canvas_item_editor_plugin.h
@@ -280,6 +280,10 @@ private:
Transform2D xform;
float length;
uint64_t last_pass;
+
+ BoneList() :
+ length(0.f),
+ last_pass(0) {}
};
uint64_t bone_last_frame;
@@ -543,6 +547,8 @@ public:
Control *get_viewport_control() { return viewport; }
+ void update_viewport();
+
Tool get_current_tool() { return tool; }
void set_undo_redo(UndoRedo *p_undo_redo) { undo_redo = p_undo_redo; }
diff --git a/editor/plugins/collision_shape_2d_editor_plugin.cpp b/editor/plugins/collision_shape_2d_editor_plugin.cpp
index d1a94f5b49..5d85a64b9c 100644
--- a/editor/plugins/collision_shape_2d_editor_plugin.cpp
+++ b/editor/plugins/collision_shape_2d_editor_plugin.cpp
@@ -129,7 +129,7 @@ void CollisionShape2DEditor::set_handle(int idx, Point2 &p_point) {
capsule->set_height(parameter * 2 - capsule->get_radius() * 2);
}
- canvas_item_editor->get_viewport_control()->update();
+ canvas_item_editor->update_viewport();
}
} break;
@@ -138,7 +138,7 @@ void CollisionShape2DEditor::set_handle(int idx, Point2 &p_point) {
Ref<CircleShape2D> circle = node->get_shape();
circle->set_radius(p_point.length());
- canvas_item_editor->get_viewport_control()->update();
+ canvas_item_editor->update_viewport();
} break;
@@ -160,7 +160,7 @@ void CollisionShape2DEditor::set_handle(int idx, Point2 &p_point) {
line->set_normal(p_point.normalized());
}
- canvas_item_editor->get_viewport_control()->update();
+ canvas_item_editor->update_viewport();
}
} break;
@@ -170,7 +170,7 @@ void CollisionShape2DEditor::set_handle(int idx, Point2 &p_point) {
ray->set_length(Math::abs(p_point.y));
- canvas_item_editor->get_viewport_control()->update();
+ canvas_item_editor->update_viewport();
} break;
@@ -183,7 +183,7 @@ void CollisionShape2DEditor::set_handle(int idx, Point2 &p_point) {
rect->set_extents(extents.abs());
- canvas_item_editor->get_viewport_control()->update();
+ canvas_item_editor->update_viewport();
}
} break;
@@ -198,7 +198,7 @@ void CollisionShape2DEditor::set_handle(int idx, Point2 &p_point) {
seg->set_b(p_point);
}
- canvas_item_editor->get_viewport_control()->update();
+ canvas_item_editor->update_viewport();
}
} break;
@@ -207,7 +207,6 @@ void CollisionShape2DEditor::set_handle(int idx, Point2 &p_point) {
void CollisionShape2DEditor::commit_handle(int idx, Variant &p_org) {
- Control *c = canvas_item_editor->get_viewport_control();
undo_redo->create_action(TTR("Set Handle"));
switch (shape_type) {
@@ -216,14 +215,14 @@ void CollisionShape2DEditor::commit_handle(int idx, Variant &p_org) {
if (idx == 0) {
undo_redo->add_do_method(capsule.ptr(), "set_radius", capsule->get_radius());
- undo_redo->add_do_method(c, "update");
+ undo_redo->add_do_method(canvas_item_editor, "update_viewport");
undo_redo->add_undo_method(capsule.ptr(), "set_radius", p_org);
- undo_redo->add_do_method(c, "update");
+ undo_redo->add_do_method(canvas_item_editor, "update_viewport");
} else if (idx == 1) {
undo_redo->add_do_method(capsule.ptr(), "set_height", capsule->get_height());
- undo_redo->add_do_method(c, "update");
+ undo_redo->add_do_method(canvas_item_editor, "update_viewport");
undo_redo->add_undo_method(capsule.ptr(), "set_height", p_org);
- undo_redo->add_undo_method(c, "update");
+ undo_redo->add_undo_method(canvas_item_editor, "update_viewport");
}
} break;
@@ -232,9 +231,9 @@ void CollisionShape2DEditor::commit_handle(int idx, Variant &p_org) {
Ref<CircleShape2D> circle = node->get_shape();
undo_redo->add_do_method(circle.ptr(), "set_radius", circle->get_radius());
- undo_redo->add_do_method(c, "update");
+ undo_redo->add_do_method(canvas_item_editor, "update_viewport");
undo_redo->add_undo_method(circle.ptr(), "set_radius", p_org);
- undo_redo->add_undo_method(c, "update");
+ undo_redo->add_undo_method(canvas_item_editor, "update_viewport");
} break;
@@ -251,14 +250,14 @@ void CollisionShape2DEditor::commit_handle(int idx, Variant &p_org) {
if (idx == 0) {
undo_redo->add_do_method(line.ptr(), "set_d", line->get_d());
- undo_redo->add_do_method(c, "update");
+ undo_redo->add_do_method(canvas_item_editor, "update_viewport");
undo_redo->add_undo_method(line.ptr(), "set_d", p_org);
- undo_redo->add_undo_method(c, "update");
+ undo_redo->add_undo_method(canvas_item_editor, "update_viewport");
} else {
undo_redo->add_do_method(line.ptr(), "set_normal", line->get_normal());
- undo_redo->add_do_method(c, "update");
+ undo_redo->add_do_method(canvas_item_editor, "update_viewport");
undo_redo->add_undo_method(line.ptr(), "set_normal", p_org);
- undo_redo->add_undo_method(c, "update");
+ undo_redo->add_undo_method(canvas_item_editor, "update_viewport");
}
} break;
@@ -267,9 +266,9 @@ void CollisionShape2DEditor::commit_handle(int idx, Variant &p_org) {
Ref<RayShape2D> ray = node->get_shape();
undo_redo->add_do_method(ray.ptr(), "set_length", ray->get_length());
- undo_redo->add_do_method(c, "update");
+ undo_redo->add_do_method(canvas_item_editor, "update_viewport");
undo_redo->add_undo_method(ray.ptr(), "set_length", p_org);
- undo_redo->add_undo_method(c, "update");
+ undo_redo->add_undo_method(canvas_item_editor, "update_viewport");
} break;
@@ -277,9 +276,9 @@ void CollisionShape2DEditor::commit_handle(int idx, Variant &p_org) {
Ref<RectangleShape2D> rect = node->get_shape();
undo_redo->add_do_method(rect.ptr(), "set_extents", rect->get_extents());
- undo_redo->add_do_method(c, "update");
+ undo_redo->add_do_method(canvas_item_editor, "update_viewport");
undo_redo->add_undo_method(rect.ptr(), "set_extents", p_org);
- undo_redo->add_undo_method(c, "update");
+ undo_redo->add_undo_method(canvas_item_editor, "update_viewport");
} break;
@@ -287,14 +286,14 @@ void CollisionShape2DEditor::commit_handle(int idx, Variant &p_org) {
Ref<SegmentShape2D> seg = node->get_shape();
if (idx == 0) {
undo_redo->add_do_method(seg.ptr(), "set_a", seg->get_a());
- undo_redo->add_do_method(c, "update");
+ undo_redo->add_do_method(canvas_item_editor, "update_viewport");
undo_redo->add_undo_method(seg.ptr(), "set_a", p_org);
- undo_redo->add_undo_method(c, "update");
+ undo_redo->add_undo_method(canvas_item_editor, "update_viewport");
} else if (idx == 1) {
undo_redo->add_do_method(seg.ptr(), "set_b", seg->get_b());
- undo_redo->add_do_method(c, "update");
+ undo_redo->add_do_method(canvas_item_editor, "update_viewport");
undo_redo->add_undo_method(seg.ptr(), "set_b", p_org);
- undo_redo->add_undo_method(c, "update");
+ undo_redo->add_undo_method(canvas_item_editor, "update_viewport");
}
} break;
@@ -411,7 +410,7 @@ void CollisionShape2DEditor::_get_current_shape_type() {
shape_type = -1;
}
- canvas_item_editor->get_viewport_control()->update();
+ canvas_item_editor->update_viewport();
}
void CollisionShape2DEditor::forward_canvas_draw_over_viewport(Control *p_overlay) {
@@ -538,7 +537,7 @@ void CollisionShape2DEditor::edit(Node *p_node) {
node = NULL;
}
- canvas_item_editor->get_viewport_control()->update();
+ canvas_item_editor->update_viewport();
}
void CollisionShape2DEditor::_bind_methods() {
diff --git a/editor/plugins/light_occluder_2d_editor_plugin.cpp b/editor/plugins/light_occluder_2d_editor_plugin.cpp
index 2f2e1dae81..6a16cf0989 100644
--- a/editor/plugins/light_occluder_2d_editor_plugin.cpp
+++ b/editor/plugins/light_occluder_2d_editor_plugin.cpp
@@ -57,7 +57,7 @@ void LightOccluder2DEditor::_node_removed(Node *p_node) {
if (p_node == node) {
node = NULL;
hide();
- canvas_item_editor->get_viewport_control()->update();
+ canvas_item_editor->update_viewport();
}
}
@@ -88,8 +88,8 @@ void LightOccluder2DEditor::_wip_close(bool p_closed) {
undo_redo->add_undo_method(node->get_occluder_polygon().ptr(), "set_closed", node->get_occluder_polygon()->is_closed());
undo_redo->add_do_method(node->get_occluder_polygon().ptr(), "set_closed", p_closed);
- undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update");
- undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update");
+ undo_redo->add_do_method(canvas_item_editor, "update_viewport");
+ undo_redo->add_undo_method(canvas_item_editor, "update_viewport");
undo_redo->commit_action();
wip.clear();
wip_active = false;
@@ -139,7 +139,7 @@ bool LightOccluder2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
wip.push_back(cpoint);
wip_active = true;
edited_point_pos = cpoint;
- canvas_item_editor->get_viewport_control()->update();
+ canvas_item_editor->update_viewport();
edited_point = 1;
return true;
} else {
@@ -158,7 +158,7 @@ bool LightOccluder2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
wip.push_back(cpoint);
edited_point = wip.size();
- canvas_item_editor->get_viewport_control()->update();
+ canvas_item_editor->update_viewport();
return true;
//add wip point
@@ -183,8 +183,8 @@ bool LightOccluder2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
undo_redo->add_undo_method(node->get_occluder_polygon().ptr(), "set_polygon", poly);
poly.push_back(cpoint);
undo_redo->add_do_method(node->get_occluder_polygon().ptr(), "set_polygon", poly);
- undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update");
- undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update");
+ undo_redo->add_do_method(canvas_item_editor, "update_viewport");
+ undo_redo->add_undo_method(canvas_item_editor, "update_viewport");
undo_redo->commit_action();
return true;
}
@@ -217,7 +217,7 @@ bool LightOccluder2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
edited_point = closest_idx + 1;
edited_point_pos = xform.affine_inverse().xform(closest_pos);
node->get_occluder_polygon()->set_polygon(Variant(poly));
- canvas_item_editor->get_viewport_control()->update();
+ canvas_item_editor->update_viewport();
return true;
}
} else {
@@ -244,7 +244,7 @@ bool LightOccluder2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
pre_move_edit = poly;
edited_point = closest_idx;
edited_point_pos = xform.affine_inverse().xform(closest_pos);
- canvas_item_editor->get_viewport_control()->update();
+ canvas_item_editor->update_viewport();
return true;
}
}
@@ -259,8 +259,8 @@ bool LightOccluder2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
undo_redo->create_action(TTR("Edit Poly"));
undo_redo->add_do_method(node->get_occluder_polygon().ptr(), "set_polygon", poly);
undo_redo->add_undo_method(node->get_occluder_polygon().ptr(), "set_polygon", pre_move_edit);
- undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update");
- undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update");
+ undo_redo->add_do_method(canvas_item_editor, "update_viewport");
+ undo_redo->add_undo_method(canvas_item_editor, "update_viewport");
undo_redo->commit_action();
edited_point = -1;
@@ -290,8 +290,8 @@ bool LightOccluder2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
undo_redo->add_undo_method(node->get_occluder_polygon().ptr(), "set_polygon", poly);
poly.remove(closest_idx);
undo_redo->add_do_method(node->get_occluder_polygon().ptr(), "set_polygon", poly);
- undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update");
- undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update");
+ undo_redo->add_do_method(canvas_item_editor, "update_viewport");
+ undo_redo->add_undo_method(canvas_item_editor, "update_viewport");
undo_redo->commit_action();
return true;
}
@@ -312,7 +312,7 @@ bool LightOccluder2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
cpoint = canvas_item_editor->snap_point(cpoint);
edited_point_pos = node->get_global_transform().affine_inverse().xform(cpoint);
- canvas_item_editor->get_viewport_control()->update();
+ canvas_item_editor->update_viewport();
}
}
@@ -369,7 +369,7 @@ void LightOccluder2DEditor::edit(Node *p_collision_polygon) {
wip.clear();
wip_active = false;
edited_point = -1;
- canvas_item_editor->get_viewport_control()->update();
+ canvas_item_editor->update_viewport();
} else {
node = NULL;
}
diff --git a/editor/plugins/path_2d_editor_plugin.cpp b/editor/plugins/path_2d_editor_plugin.cpp
index 88b3194490..c67c96798a 100644
--- a/editor/plugins/path_2d_editor_plugin.cpp
+++ b/editor/plugins/path_2d_editor_plugin.cpp
@@ -130,8 +130,8 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
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);
- undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update");
- undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update");
+ undo_redo->add_do_method(canvas_item_editor, "update_viewport");
+ undo_redo->add_undo_method(canvas_item_editor, "update_viewport");
undo_redo->commit_action();
return true;
} else if (dist_to_p_out < grab_threshold) {
@@ -139,8 +139,8 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
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));
- undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update");
- undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update");
+ undo_redo->add_do_method(canvas_item_editor, "update_viewport");
+ undo_redo->add_undo_method(canvas_item_editor, "update_viewport");
undo_redo->commit_action();
return true;
} else if (dist_to_p_in < grab_threshold) {
@@ -148,8 +148,8 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
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));
- undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update");
- undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update");
+ undo_redo->add_do_method(canvas_item_editor, "update_viewport");
+ undo_redo->add_undo_method(canvas_item_editor, "update_viewport");
undo_redo->commit_action();
return true;
}
@@ -165,8 +165,8 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
undo_redo->create_action(TTR("Add Point to Curve"));
undo_redo->add_do_method(curve.ptr(), "add_point", cpoint);
undo_redo->add_undo_method(curve.ptr(), "remove_point", curve->get_point_count());
- undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update");
- undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update");
+ undo_redo->add_do_method(canvas_item_editor, "update_viewport");
+ undo_redo->add_undo_method(canvas_item_editor, "update_viewport");
undo_redo->commit_action();
action = ACTION_MOVING_POINT;
@@ -174,7 +174,7 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
moving_from = curve->get_point_position(action_point);
moving_screen_from = gpoint;
- canvas_item_editor->get_viewport_control()->update();
+ canvas_item_editor->update_viewport();
return true;
}
@@ -196,8 +196,8 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
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);
- undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update");
- undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update");
+ undo_redo->add_do_method(canvas_item_editor, "update_viewport");
+ undo_redo->add_undo_method(canvas_item_editor, "update_viewport");
undo_redo->commit_action();
} break;
@@ -212,8 +212,8 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
undo_redo->add_do_method(curve.ptr(), "set_point_out", action_point, mirror_handle_length ? -new_pos : (-new_pos.normalized() * orig_out_length));
undo_redo->add_undo_method(curve.ptr(), "set_point_out", action_point, mirror_handle_length ? -moving_from : (-moving_from.normalized() * orig_out_length));
}
- undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update");
- undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update");
+ undo_redo->add_do_method(canvas_item_editor, "update_viewport");
+ undo_redo->add_undo_method(canvas_item_editor, "update_viewport");
undo_redo->commit_action();
} break;
@@ -228,8 +228,8 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
undo_redo->add_do_method(curve.ptr(), "set_point_in", action_point, mirror_handle_length ? -new_pos : (-new_pos.normalized() * orig_in_length));
undo_redo->add_undo_method(curve.ptr(), "set_point_in", action_point, mirror_handle_length ? -moving_from : (-moving_from.normalized() * orig_in_length));
}
- undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update");
- undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update");
+ undo_redo->add_do_method(canvas_item_editor, "update_viewport");
+ undo_redo->add_undo_method(canvas_item_editor, "update_viewport");
undo_redo->commit_action();
} break;
@@ -280,7 +280,7 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
} break;
}
- canvas_item_editor->get_viewport_control()->update();
+ canvas_item_editor->update_viewport();
return true;
}
}
@@ -331,7 +331,7 @@ void Path2DEditor::_node_visibility_changed() {
if (!node)
return;
- canvas_item_editor->get_viewport_control()->update();
+ canvas_item_editor->update_viewport();
}
void Path2DEditor::edit(Node *p_path2d) {
@@ -406,8 +406,8 @@ void Path2DEditor::_mode_selected(int p_mode) {
undo_redo->create_action(TTR("Remove Point from Curve"));
undo_redo->add_do_method(node->get_curve().ptr(), "add_point", begin);
undo_redo->add_undo_method(node->get_curve().ptr(), "remove_point", node->get_curve()->get_point_count());
- undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update");
- undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update");
+ undo_redo->add_do_method(canvas_item_editor, "update_viewport");
+ undo_redo->add_undo_method(canvas_item_editor, "update_viewport");
undo_redo->commit_action();
return;
}
diff --git a/editor/plugins/resource_preloader_editor_plugin.cpp b/editor/plugins/resource_preloader_editor_plugin.cpp
index dd327d0a2c..bd4a35c9d8 100644
--- a/editor/plugins/resource_preloader_editor_plugin.cpp
+++ b/editor/plugins/resource_preloader_editor_plugin.cpp
@@ -44,7 +44,6 @@ void ResourcePreloaderEditor::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
load->set_icon(get_icon("Folder", "EditorIcons"));
- _delete->set_icon(get_icon("Remove", "EditorIcons"));
}
if (p_what == NOTIFICATION_READY) {
@@ -138,15 +137,11 @@ void ResourcePreloaderEditor::_item_edited() {
}
}
-void ResourcePreloaderEditor::_delete_confirm_pressed() {
+void ResourcePreloaderEditor::_remove_resource(const String &p_to_remove) {
- if (!tree->get_selected())
- return;
-
- String to_remove = tree->get_selected()->get_text(0);
undo_redo->create_action(TTR("Delete Resource"));
- undo_redo->add_do_method(preloader, "remove_resource", to_remove);
- undo_redo->add_undo_method(preloader, "add_resource", to_remove, preloader->get_resource(to_remove));
+ 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));
undo_redo->add_do_method(this, "_update_library");
undo_redo->add_undo_method(this, "_update_library");
undo_redo->commit_action();
@@ -184,21 +179,6 @@ void ResourcePreloaderEditor::_paste_pressed() {
undo_redo->commit_action();
}
-void ResourcePreloaderEditor::_delete_pressed() {
-
- if (!tree->get_selected())
- return;
-
- _delete_confirm_pressed(); //it has undo.. why bother with a dialog..
- /*
- dialog->set_title("Confirm...");
- dialog->set_text("Remove Resource '"+tree->get_selected()->get_text(0)+"' ?");
- //dialog->get_cancel()->set_text("Cancel");
- //dialog->get_ok()->show();
- dialog->get_ok()->set_text("Remove");
- dialog->popup_centered(Size2(300,60));*/
-}
-
void ResourcePreloaderEditor::_update_library() {
tree->clear();
@@ -228,17 +208,20 @@ void ResourcePreloaderEditor::_update_library() {
ERR_CONTINUE(r.is_null());
- ti->set_tooltip(0, r->get_path());
+ String type = r->get_class();
+ ti->set_icon(0, EditorNode::get_singleton()->get_class_icon(type, "Object"));
+ ti->set_tooltip(0, TTR("Instance:") + " " + r->get_path() + "\n" + TTR("Type:") + " " + type);
+
ti->set_text(1, r->get_path());
- ti->add_button(1, get_icon("InstanceOptions", "EditorIcons"), BUTTON_SUBSCENE, false, TTR("Open in Editor"));
- ti->set_tooltip(1, TTR("Instance:") + " " + r->get_path() + "\n" + TTR("Type:") + " " + r->get_class());
ti->set_editable(1, false);
ti->set_selectable(1, false);
- String type = r->get_class();
- ti->set_text(2, type);
- ti->set_selectable(2, false);
- ti->set_icon(2, EditorNode::get_singleton()->get_class_icon(type, ""));
+ if (type == "PackedScene") {
+ ti->add_button(1, get_icon("InstanceOptions", "EditorIcons"), BUTTON_OPEN_SCENE, false, TTR("Open in Editor"));
+ } else {
+ ti->add_button(1, get_icon("Load", "EditorIcons"), BUTTON_EDIT_RESOURCE, false, TTR("Open in Editor"));
+ }
+ ti->add_button(1, get_icon("Remove", "EditorIcons"), BUTTON_REMOVE, false, TTR("Remove"));
}
//player->add_resource("default",resource);
@@ -249,10 +232,16 @@ void ResourcePreloaderEditor::_cell_button_pressed(Object *p_item, int p_column,
TreeItem *item = Object::cast_to<TreeItem>(p_item);
ERR_FAIL_COND(!item);
- String rpath = item->get_text(p_column);
-
- if (p_id == BUTTON_SUBSCENE) {
+ if (p_id == BUTTON_OPEN_SCENE) {
+ String rpath = item->get_text(p_column);
EditorInterface::get_singleton()->open_scene_from_path(rpath);
+
+ } else if (p_id == BUTTON_EDIT_RESOURCE) {
+ RES r = preloader->get_resource(item->get_text(0));
+ EditorInterface::get_singleton()->edit_resource(r);
+
+ } else if (p_id == BUTTON_REMOVE) {
+ _remove_resource(item->get_text(0));
}
}
@@ -365,12 +354,11 @@ void ResourcePreloaderEditor::_bind_methods() {
ClassDB::bind_method(D_METHOD("_gui_input"), &ResourcePreloaderEditor::_gui_input);
ClassDB::bind_method(D_METHOD("_load_pressed"), &ResourcePreloaderEditor::_load_pressed);
ClassDB::bind_method(D_METHOD("_item_edited"), &ResourcePreloaderEditor::_item_edited);
- ClassDB::bind_method(D_METHOD("_delete_pressed"), &ResourcePreloaderEditor::_delete_pressed);
ClassDB::bind_method(D_METHOD("_paste_pressed"), &ResourcePreloaderEditor::_paste_pressed);
- ClassDB::bind_method(D_METHOD("_delete_confirm_pressed"), &ResourcePreloaderEditor::_delete_confirm_pressed);
ClassDB::bind_method(D_METHOD("_files_load_request"), &ResourcePreloaderEditor::_files_load_request);
ClassDB::bind_method(D_METHOD("_update_library"), &ResourcePreloaderEditor::_update_library);
ClassDB::bind_method(D_METHOD("_cell_button_pressed"), &ResourcePreloaderEditor::_cell_button_pressed);
+ ClassDB::bind_method(D_METHOD("_remove_resource", "to_remove"), &ResourcePreloaderEditor::_remove_resource);
ClassDB::bind_method(D_METHOD("get_drag_data_fw"), &ResourcePreloaderEditor::get_drag_data_fw);
ClassDB::bind_method(D_METHOD("can_drop_data_fw"), &ResourcePreloaderEditor::can_drop_data_fw);
@@ -391,9 +379,6 @@ ResourcePreloaderEditor::ResourcePreloaderEditor() {
load->set_tooltip(TTR("Load Resource"));
hbc->add_child(load);
- _delete = memnew(Button);
- hbc->add_child(_delete);
-
paste = memnew(Button);
paste->set_text(TTR("Paste"));
hbc->add_child(paste);
@@ -403,13 +388,11 @@ ResourcePreloaderEditor::ResourcePreloaderEditor() {
tree = memnew(Tree);
tree->connect("button_pressed", this, "_cell_button_pressed");
- tree->set_columns(3);
- tree->set_column_min_width(0, 3);
- tree->set_column_min_width(1, 1);
- tree->set_column_min_width(2, 1);
+ tree->set_columns(2);
+ tree->set_column_min_width(0, 2);
+ tree->set_column_min_width(1, 3);
tree->set_column_expand(0, true);
tree->set_column_expand(1, true);
- tree->set_column_expand(2, true);
tree->set_v_size_flags(SIZE_EXPAND_FILL);
tree->set_drag_forwarding(this);
@@ -419,10 +402,8 @@ ResourcePreloaderEditor::ResourcePreloaderEditor() {
add_child(dialog);
load->connect("pressed", this, "_load_pressed");
- _delete->connect("pressed", this, "_delete_pressed");
paste->connect("pressed", this, "_paste_pressed");
file->connect("files_selected", this, "_files_load_request");
- //dialog->connect("confirmed", this,"_delete_confirm_pressed");
tree->connect("item_edited", this, "_item_edited");
loading_scene = false;
}
diff --git a/editor/plugins/resource_preloader_editor_plugin.h b/editor/plugins/resource_preloader_editor_plugin.h
index e737157785..0a8238ce18 100644
--- a/editor/plugins/resource_preloader_editor_plugin.h
+++ b/editor/plugins/resource_preloader_editor_plugin.h
@@ -43,11 +43,12 @@ class ResourcePreloaderEditor : public PanelContainer {
GDCLASS(ResourcePreloaderEditor, PanelContainer);
enum {
- BUTTON_SUBSCENE = 0,
+ BUTTON_OPEN_SCENE,
+ BUTTON_EDIT_RESOURCE,
+ BUTTON_REMOVE
};
Button *load;
- Button *_delete;
Button *paste;
Tree *tree;
bool loading_scene;
@@ -62,8 +63,7 @@ class ResourcePreloaderEditor : public PanelContainer {
void _load_scene_pressed();
void _files_load_request(const Vector<String> &p_paths);
void _paste_pressed();
- void _delete_pressed();
- void _delete_confirm_pressed();
+ void _remove_resource(const String &p_to_remove);
void _update_library();
void _cell_button_pressed(Object *p_item, int p_column, int p_id);
void _item_edited();
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index 7cda15bdc6..080d3ff894 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -1960,7 +1960,7 @@ bool ScriptEditor::edit(const RES &p_resource, int p_line, int p_col, bool p_gra
// doesn't have it, make a new one
- ScriptEditorBase *se;
+ ScriptEditorBase *se = NULL;
for (int i = script_editor_func_count - 1; i >= 0; i--) {
se = script_editor_funcs[i](p_resource);
@@ -2912,7 +2912,7 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
script_list = memnew(ItemList);
list_split->add_child(script_list);
- script_list->set_custom_minimum_size(Size2(150 * EDSCALE, 90)); //need to give a bit of limit to avoid it from disappearing
+ script_list->set_custom_minimum_size(Size2(150, 90) * EDSCALE); //need to give a bit of limit to avoid it from disappearing
script_list->set_v_size_flags(SIZE_EXPAND_FILL);
script_split->set_split_offset(140);
_sort_list_on_update = true;
@@ -2951,7 +2951,7 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
overview_vbox->add_child(members_overview);
members_overview->set_allow_reselect(true);
- members_overview->set_custom_minimum_size(Size2(0, 90)); //need to give a bit of limit to avoid it from disappearing
+ members_overview->set_custom_minimum_size(Size2(0, 90) * EDSCALE); //need to give a bit of limit to avoid it from disappearing
members_overview->set_v_size_flags(SIZE_EXPAND_FILL);
members_overview->set_allow_rmb_select(true);
members_overview->set_drag_forwarding(this);
@@ -2959,12 +2959,12 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
help_overview = memnew(ItemList);
overview_vbox->add_child(help_overview);
help_overview->set_allow_reselect(true);
- help_overview->set_custom_minimum_size(Size2(0, 90)); //need to give a bit of limit to avoid it from disappearing
+ help_overview->set_custom_minimum_size(Size2(0, 90) * EDSCALE); //need to give a bit of limit to avoid it from disappearing
help_overview->set_v_size_flags(SIZE_EXPAND_FILL);
tab_container = memnew(TabContainer);
tab_container->set_tabs_visible(false);
- tab_container->set_custom_minimum_size(Size2(200 * EDSCALE, 0));
+ tab_container->set_custom_minimum_size(Size2(200, 0) * EDSCALE);
script_split->add_child(tab_container);
tab_container->set_h_size_flags(SIZE_EXPAND_FILL);
@@ -3173,9 +3173,9 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
find_in_files_dialog->connect(FindInFilesDialog::SIGNAL_REPLACE_REQUESTED, this, "_start_find_in_files", varray(true));
add_child(find_in_files_dialog);
find_in_files = memnew(FindInFilesPanel);
- find_in_files_button = editor->add_bottom_panel_item(TTR("Search results"), find_in_files);
+ find_in_files_button = editor->add_bottom_panel_item(TTR("Search Results"), find_in_files);
find_in_files_button->set_tooltip(TTR("Search in files"));
- find_in_files->set_custom_minimum_size(Size2(0, 200));
+ find_in_files->set_custom_minimum_size(Size2(0, 200) * EDSCALE);
find_in_files->connect(FindInFilesPanel::SIGNAL_RESULT_SELECTED, this, "_on_find_in_files_result_selected");
find_in_files->connect(FindInFilesPanel::SIGNAL_FILES_MODIFIED, this, "_on_find_in_files_modified_files");
find_in_files->hide();
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp
index 9b968c3523..362b8543d4 100644
--- a/editor/plugins/script_text_editor.cpp
+++ b/editor/plugins/script_text_editor.cpp
@@ -817,6 +817,9 @@ void ScriptTextEditor::_edit_option(int p_op) {
if (tx->get_selection_to_column() == 0)
end -= 1;
+ int col_to = tx->get_selection_to_column();
+ int cursor_pos = tx->cursor_get_column();
+
// Check if all lines in the selected block are commented
bool is_commented = true;
for (int i = begin; i <= end; i++) {
@@ -839,19 +842,42 @@ void ScriptTextEditor::_edit_option(int p_op) {
}
tx->set_line(i, line_text);
}
+
+ // Adjust selection & cursor position.
+ int offset = is_commented ? -1 : 1;
+ int col_from = tx->get_selection_from_column() > 0 ? tx->get_selection_from_column() + offset : 0;
+
+ if (is_commented && tx->cursor_get_column() == tx->get_line(tx->cursor_get_line()).length() + 1)
+ cursor_pos += 1;
+
+ if (tx->get_selection_to_column() != 0 && col_to != tx->get_line(tx->get_selection_to_line()).length() + 1)
+ col_to += offset;
+
+ if (tx->cursor_get_column() != 0)
+ cursor_pos += offset;
+
+ tx->select(begin, col_from, tx->get_selection_to_line(), col_to);
+ tx->cursor_set_column(cursor_pos);
+
} else {
int begin = tx->cursor_get_line();
String line_text = tx->get_line(begin);
- if (line_text.begins_with(delimiter))
+ int col = tx->cursor_get_column();
+ if (line_text.begins_with(delimiter)) {
line_text = line_text.substr(delimiter.length(), line_text.length());
- else
+ col -= 1;
+ } else {
line_text = delimiter + line_text;
+ col += 1;
+ }
+
tx->set_line(begin, line_text);
+ tx->cursor_set_column(col);
}
tx->end_complex_operation();
tx->update();
- //tx->deselect();
+
} break;
case EDIT_COMPLETE: {
diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp
index 114610c562..0dda95832c 100644
--- a/editor/plugins/spatial_editor_plugin.cpp
+++ b/editor/plugins/spatial_editor_plugin.cpp
@@ -534,9 +534,9 @@ void SpatialEditorViewport::_update_name() {
String view_mode = orthogonal ? TTR("Orthogonal") : TTR("Perspective");
if (name != "")
- view_menu->set_text("[ " + name + " " + view_mode + " ]");
+ view_menu->set_text(name + " " + view_mode);
else
- view_menu->set_text("[ " + view_mode + " ]");
+ view_menu->set_text(view_mode);
view_menu->set_size(Vector2(0, 0)); // resets the button size
}
@@ -2124,7 +2124,7 @@ void SpatialEditorViewport::_notification(int p_what) {
_update_freelook(delta);
Node *scene_root = editor->get_scene_tree_dock()->get_editor_data()->get_edited_scene_root();
- if (previewing_cinema == true && scene_root != NULL) {
+ if (previewing_cinema && scene_root != NULL) {
Camera *cam = scene_root->get_viewport()->get_camera();
if (cam != NULL && cam != previewing) {
//then switch the viewport's camera to the scene's viewport camera
@@ -2250,6 +2250,11 @@ void SpatialEditorViewport::_notification(int p_what) {
float cinema_half_width = cinema_label->get_size().width / 2.0f;
cinema_label->set_anchor_and_margin(MARGIN_LEFT, 0.5f, -cinema_half_width);
}
+
+ if (lock_rotation) {
+ float locked_half_width = locked_label->get_size().width / 2.0f;
+ locked_label->set_anchor_and_margin(MARGIN_LEFT, 0.5f, -locked_half_width);
+ }
}
if (p_what == NOTIFICATION_ENTER_TREE) {
@@ -2260,21 +2265,36 @@ void SpatialEditorViewport::_notification(int p_what) {
surface->connect("mouse_exited", this, "_surface_mouse_exit");
surface->connect("focus_entered", this, "_surface_focus_enter");
surface->connect("focus_exited", this, "_surface_focus_exit");
- info_label->add_style_override("normal", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles"));
- fps_label->add_style_override("normal", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles"));
- cinema_label->add_style_override("normal", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles"));
- preview_camera->set_icon(get_icon("Camera", "EditorIcons"));
+
_init_gizmo_instance(index);
}
+
if (p_what == NOTIFICATION_EXIT_TREE) {
_finish_gizmo_instances();
}
- if (p_what == NOTIFICATION_MOUSE_ENTER) {
- }
+ if (p_what == NOTIFICATION_THEME_CHANGED) {
+
+ view_menu->set_icon(get_icon("GuiMiniTabMenu", "EditorIcons"));
+ preview_camera->set_icon(get_icon("Camera", "EditorIcons"));
+
+ view_menu->add_style_override("normal", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles"));
+ view_menu->add_style_override("hover", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles"));
+ view_menu->add_style_override("pressed", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles"));
+ view_menu->add_style_override("focus", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles"));
+ view_menu->add_style_override("disabled", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles"));
- if (p_what == NOTIFICATION_DRAW) {
+ preview_camera->add_style_override("normal", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles"));
+ preview_camera->add_style_override("hover", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles"));
+ preview_camera->add_style_override("pressed", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles"));
+ preview_camera->add_style_override("focus", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles"));
+ preview_camera->add_style_override("disabled", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles"));
+
+ info_label->add_style_override("normal", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles"));
+ fps_label->add_style_override("normal", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles"));
+ cinema_label->add_style_override("normal", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles"));
+ locked_label->add_style_override("normal", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles"));
}
}
@@ -2515,8 +2535,14 @@ void SpatialEditorViewport::_menu_option(int p_option) {
if (!se)
continue;
- Transform xform = camera_transform;
- xform.scale_basis(sp->get_scale());
+ Transform xform;
+ if (orthogonal) {
+ xform = sp->get_global_transform();
+ xform.basis.set_euler(camera_transform.basis.get_euler());
+ } else {
+ xform = camera_transform;
+ xform.scale_basis(sp->get_scale());
+ }
undo_redo->add_do_method(sp, "set_global_transform", xform);
undo_redo->add_undo_method(sp, "set_global_transform", sp->get_global_gizmo_transform());
@@ -2564,9 +2590,9 @@ void SpatialEditorViewport::_menu_option(int p_option) {
lock_rotation = !current;
view_menu->get_popup()->set_item_checked(idx, !current);
if (lock_rotation) {
- view_menu->set_icon(get_icon("Lock", "EditorIcons"));
+ locked_label->show();
} else {
- view_menu->set_icon(Ref<Texture>());
+ locked_label->hide();
}
} break;
@@ -2636,11 +2662,6 @@ void SpatialEditorViewport::_menu_option(int p_option) {
bool current = view_menu->get_popup()->is_item_checked(idx);
view_menu->get_popup()->set_item_checked(idx, !current);
- if (current)
- preview_camera->set_anchor_and_margin(MARGIN_TOP, ANCHOR_BEGIN, 10 * EDSCALE);
- else
- preview_camera->set_anchor_and_margin(MARGIN_TOP, ANCHOR_BEGIN, 15 * EDSCALE + fps_label->get_size().height);
-
} break;
case VIEW_DISPLAY_NORMAL: {
@@ -2754,7 +2775,7 @@ void SpatialEditorViewport::_toggle_camera_preview(bool p_activate) {
VS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), camera->get_camera()); //restore
if (!preview)
preview_camera->hide();
- view_menu->show();
+ view_menu->set_disabled(false);
surface->update();
} else {
@@ -2762,7 +2783,7 @@ void SpatialEditorViewport::_toggle_camera_preview(bool p_activate) {
previewing = preview;
previewing->connect("tree_exiting", this, "_preview_exited_scene");
VS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), preview->get_camera()); //replace
- view_menu->hide();
+ view_menu->set_disabled(true);
surface->update();
}
}
@@ -3419,9 +3440,10 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed
surface->set_focus_mode(FOCUS_ALL);
view_menu = memnew(MenuButton);
+ view_menu->set_flat(false);
surface->add_child(view_menu);
- view_menu->set_position(Point2(4, 4) * EDSCALE);
- view_menu->set_self_modulate(Color(1, 1, 1, 0.5));
+ view_menu->set_position(Point2(10, 10) * EDSCALE);
+
view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/top_view"), VIEW_TOP);
view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/bottom_view"), VIEW_BOTTOM);
view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/left_view"), VIEW_LEFT);
@@ -3472,12 +3494,8 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed
ED_SHORTCUT("spatial_editor/freelook_down", TTR("Freelook Down"), KEY_Q);
ED_SHORTCUT("spatial_editor/freelook_speed_modifier", TTR("Freelook Speed Modifier"), KEY_SHIFT);
- preview_camera = memnew(Button);
- preview_camera->set_toggle_mode(true);
- preview_camera->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_END, -90 * EDSCALE);
- preview_camera->set_anchor_and_margin(MARGIN_TOP, ANCHOR_BEGIN, 10 * EDSCALE);
- preview_camera->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, -10 * EDSCALE);
- preview_camera->set_h_grow_direction(GROW_DIRECTION_BEGIN);
+ preview_camera = memnew(CheckBox);
+ preview_camera->set_position(Point2(10 * EDSCALE, 15 * EDSCALE + view_menu->get_size().height));
preview_camera->set_text(TTR("Preview"));
surface->add_child(preview_camera);
preview_camera->hide();
@@ -3497,7 +3515,6 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed
surface->add_child(info_label);
info_label->hide();
- // FPS Counter.
fps_label = memnew(Label);
fps_label->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_END, -90 * EDSCALE);
fps_label->set_anchor_and_margin(MARGIN_TOP, ANCHOR_BEGIN, 10 * EDSCALE);
@@ -3515,6 +3532,16 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed
cinema_label->hide();
previewing_cinema = false;
+ locked_label = memnew(Label);
+ locked_label->set_anchor_and_margin(MARGIN_TOP, ANCHOR_END, -20 * EDSCALE);
+ locked_label->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_END, -10 * EDSCALE);
+ locked_label->set_h_grow_direction(GROW_DIRECTION_END);
+ locked_label->set_v_grow_direction(GROW_DIRECTION_BEGIN);
+ locked_label->set_align(Label::ALIGN_CENTER);
+ surface->add_child(locked_label);
+ locked_label->set_text(TTR("View Rotation Locked"));
+ locked_label->hide();
+
accept = NULL;
freelook_active = false;
@@ -5438,7 +5465,6 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
view_menu = memnew(MenuButton);
view_menu->set_text(TTR("View"));
- view_menu->set_position(Point2(212, 0));
hbc_menu->add_child(view_menu);
p = view_menu->get_popup();
diff --git a/editor/plugins/spatial_editor_plugin.h b/editor/plugins/spatial_editor_plugin.h
index c552f21e39..3cce76cc17 100644
--- a/editor/plugins/spatial_editor_plugin.h
+++ b/editor/plugins/spatial_editor_plugin.h
@@ -192,7 +192,7 @@ private:
EditorSelection *editor_selection;
UndoRedo *undo_redo;
- Button *preview_camera;
+ CheckBox *preview_camera;
ViewportContainer *viewport_container;
MenuButton *view_menu;
@@ -211,6 +211,7 @@ private:
Label *info_label;
Label *fps_label;
Label *cinema_label;
+ Label *locked_label;
struct _RayResult {
diff --git a/editor/plugins/tile_map_editor_plugin.cpp b/editor/plugins/tile_map_editor_plugin.cpp
index aa4338d775..ed1fa9b217 100644
--- a/editor/plugins/tile_map_editor_plugin.cpp
+++ b/editor/plugins/tile_map_editor_plugin.cpp
@@ -43,8 +43,8 @@ void TileMapEditor::_notification(int p_what) {
case NOTIFICATION_PROCESS: {
- if (bucket_queue.size() && canvas_item_editor) {
- canvas_item_editor->update();
+ if (bucket_queue.size()) {
+ CanvasItemEditor::get_singleton()->update_viewport();
}
} break;
@@ -97,27 +97,27 @@ void TileMapEditor::_menu_option(int p_option) {
// immediately without pressing the left mouse button first
tool = TOOL_NONE;
- canvas_item_editor->update();
+ CanvasItemEditor::get_singleton()->update_viewport();
} break;
case OPTION_BUCKET: {
tool = TOOL_BUCKET;
- canvas_item_editor->update();
+ CanvasItemEditor::get_singleton()->update_viewport();
} break;
case OPTION_PICK_TILE: {
tool = TOOL_PICKING;
- canvas_item_editor->update();
+ CanvasItemEditor::get_singleton()->update_viewport();
} break;
case OPTION_SELECT: {
tool = TOOL_SELECTING;
selection_active = false;
- canvas_item_editor->update();
+ CanvasItemEditor::get_singleton()->update_viewport();
} break;
case OPTION_COPY: {
@@ -126,7 +126,7 @@ void TileMapEditor::_menu_option(int p_option) {
if (selection_active) {
tool = TOOL_PASTING;
- canvas_item_editor->update();
+ CanvasItemEditor::get_singleton()->update_viewport();
}
} break;
case OPTION_ERASE_SELECTION: {
@@ -141,7 +141,7 @@ void TileMapEditor::_menu_option(int p_option) {
selection_active = false;
copydata.clear();
- canvas_item_editor->update();
+ CanvasItemEditor::get_singleton()->update_viewport();
} break;
case OPTION_FIX_INVALID: {
@@ -165,7 +165,7 @@ void TileMapEditor::_menu_option(int p_option) {
tool = TOOL_PASTING;
- canvas_item_editor->update();
+ CanvasItemEditor::get_singleton()->update_viewport();
}
} break;
}
@@ -182,13 +182,13 @@ void TileMapEditor::_palette_multi_selected(int index, bool selected) {
void TileMapEditor::_canvas_mouse_enter() {
mouse_over = true;
- canvas_item_editor->update();
+ CanvasItemEditor::get_singleton()->update_viewport();
}
void TileMapEditor::_canvas_mouse_exit() {
mouse_over = false;
- canvas_item_editor->update();
+ CanvasItemEditor::get_singleton()->update_viewport();
}
Vector<int> TileMapEditor::get_selected_tiles() const {
@@ -318,7 +318,7 @@ void TileMapEditor::_manual_toggled(bool p_enabled) {
void TileMapEditor::_text_entered(const String &p_text) {
- canvas_item_editor->grab_focus();
+ canvas_item_editor_viewport->grab_focus();
}
void TileMapEditor::_text_changed(const String &p_text) {
@@ -524,7 +524,7 @@ void TileMapEditor::_pick_tile(const Point2 &p_pos) {
transp->set_pressed(node->is_cell_transposed(p_pos.x, p_pos.y));
_update_transform_buttons();
- canvas_item_editor->update();
+ CanvasItemEditor::get_singleton()->update_viewport();
}
PoolVector<Vector2> TileMapEditor::_bucket_fill(const Point2i &p_start, bool erase, bool preview) {
@@ -671,7 +671,7 @@ void TileMapEditor::_select(const Point2i &p_from, const Point2i &p_to) {
rectangle.position = begin;
rectangle.size = end - begin;
- canvas_item_editor->update();
+ CanvasItemEditor::get_singleton()->update_viewport();
}
void TileMapEditor::_erase_selection() {
@@ -978,7 +978,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
paint_undo.clear();
- canvas_item_editor->update();
+ CanvasItemEditor::get_singleton()->update_viewport();
}
} else if (tool == TOOL_RECTANGLE_PAINT) {
@@ -995,7 +995,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
}
_finish_undo();
- canvas_item_editor->update();
+ CanvasItemEditor::get_singleton()->update_viewport();
}
} else if (tool == TOOL_PASTING) {
@@ -1011,12 +1011,12 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
}
_finish_undo();
- canvas_item_editor->update();
+ CanvasItemEditor::get_singleton()->update_viewport();
return true; // We want to keep the Pasting tool
} else if (tool == TOOL_SELECTING) {
- canvas_item_editor->update();
+ CanvasItemEditor::get_singleton()->update_viewport();
} else if (tool == TOOL_BUCKET) {
@@ -1055,7 +1055,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
tool = TOOL_NONE;
selection_active = false;
- canvas_item_editor->update();
+ CanvasItemEditor::get_singleton()->update_viewport();
return true;
}
@@ -1065,7 +1065,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
tool = TOOL_NONE;
copydata.clear();
- canvas_item_editor->update();
+ CanvasItemEditor::get_singleton()->update_viewport();
return true;
}
@@ -1106,7 +1106,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
_finish_undo();
if (tool == TOOL_RECTANGLE_ERASE || tool == TOOL_LINE_ERASE) {
- canvas_item_editor->update();
+ CanvasItemEditor::get_singleton()->update_viewport();
}
tool = TOOL_NONE;
@@ -1149,7 +1149,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
if (new_over_tile != over_tile) {
over_tile = new_over_tile;
- canvas_item_editor->update();
+ CanvasItemEditor::get_singleton()->update_viewport();
}
if (show_tile_info) {
@@ -1235,7 +1235,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
_set_cell(points[i], invalid_cell);
}
- canvas_item_editor->update();
+ CanvasItemEditor::get_singleton()->update_viewport();
}
return true;
@@ -1294,7 +1294,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
tool = TOOL_NONE;
- canvas_item_editor->update();
+ CanvasItemEditor::get_singleton()->update_viewport();
return true;
}
@@ -1308,13 +1308,13 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
// NOTE: We do not set tool = TOOL_PAINTING as this begins painting
// immediately without pressing the left mouse button first
tool = TOOL_NONE;
- canvas_item_editor->update();
+ CanvasItemEditor::get_singleton()->update_viewport();
return true;
}
if (ED_IS_SHORTCUT("tile_map_editor/bucket_fill", p_event)) {
tool = TOOL_BUCKET;
- canvas_item_editor->update();
+ CanvasItemEditor::get_singleton()->update_viewport();
return true;
}
@@ -1327,7 +1327,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
tool = TOOL_SELECTING;
selection_active = false;
- canvas_item_editor->update();
+ CanvasItemEditor::get_singleton()->update_viewport();
return true;
}
@@ -1337,7 +1337,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
if (selection_active) {
tool = TOOL_PASTING;
- canvas_item_editor->update();
+ CanvasItemEditor::get_singleton()->update_viewport();
return true;
}
@@ -1354,7 +1354,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
tool = TOOL_PASTING;
- canvas_item_editor->update();
+ CanvasItemEditor::get_singleton()->update_viewport();
return true;
}
}
@@ -1368,21 +1368,21 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
flip_h = !flip_h;
mirror_x->set_pressed(flip_h);
_update_transform_buttons();
- canvas_item_editor->update();
+ CanvasItemEditor::get_singleton()->update_viewport();
return true;
}
if (ED_IS_SHORTCUT("tile_map_editor/mirror_y", p_event)) {
flip_v = !flip_v;
mirror_y->set_pressed(flip_v);
_update_transform_buttons();
- canvas_item_editor->update();
+ CanvasItemEditor::get_singleton()->update_viewport();
return true;
}
if (ED_IS_SHORTCUT("tile_map_editor/transpose", p_event)) {
transpose = !transpose;
transp->set_pressed(transpose);
_update_transform_buttons();
- canvas_item_editor->update();
+ CanvasItemEditor::get_singleton()->update_viewport();
return true;
}
}
@@ -1396,8 +1396,7 @@ void TileMapEditor::forward_canvas_draw_over_viewport(Control *p_overlay) {
return;
Transform2D cell_xf = node->get_cell_transform();
-
- Transform2D xform = p_overlay->get_canvas_transform() * node->get_global_transform();
+ Transform2D xform = CanvasItemEditor::get_singleton()->get_canvas_transform() * node->get_global_transform();
Transform2D xform_inv = xform.affine_inverse();
Size2 screen_size = p_overlay->get_size();
@@ -1608,8 +1607,8 @@ void TileMapEditor::edit(Node *p_tile_map) {
search_box->set_text("");
- if (!canvas_item_editor) {
- canvas_item_editor = CanvasItemEditor::get_singleton()->get_viewport_control();
+ if (!canvas_item_editor_viewport) {
+ canvas_item_editor_viewport = CanvasItemEditor::get_singleton()->get_viewport_control();
}
if (node)
@@ -1617,20 +1616,20 @@ void TileMapEditor::edit(Node *p_tile_map) {
if (p_tile_map) {
node = Object::cast_to<TileMap>(p_tile_map);
- if (!canvas_item_editor->is_connected("mouse_entered", this, "_canvas_mouse_enter"))
- canvas_item_editor->connect("mouse_entered", this, "_canvas_mouse_enter");
- if (!canvas_item_editor->is_connected("mouse_exited", this, "_canvas_mouse_exit"))
- canvas_item_editor->connect("mouse_exited", this, "_canvas_mouse_exit");
+ if (!canvas_item_editor_viewport->is_connected("mouse_entered", this, "_canvas_mouse_enter"))
+ canvas_item_editor_viewport->connect("mouse_entered", this, "_canvas_mouse_enter");
+ if (!canvas_item_editor_viewport->is_connected("mouse_exited", this, "_canvas_mouse_exit"))
+ canvas_item_editor_viewport->connect("mouse_exited", this, "_canvas_mouse_exit");
_update_palette();
} else {
node = NULL;
- if (canvas_item_editor->is_connected("mouse_entered", this, "_canvas_mouse_enter"))
- canvas_item_editor->disconnect("mouse_entered", this, "_canvas_mouse_enter");
- if (canvas_item_editor->is_connected("mouse_exited", this, "_canvas_mouse_exit"))
- canvas_item_editor->disconnect("mouse_exited", this, "_canvas_mouse_exit");
+ if (canvas_item_editor_viewport->is_connected("mouse_entered", this, "_canvas_mouse_enter"))
+ canvas_item_editor_viewport->disconnect("mouse_entered", this, "_canvas_mouse_enter");
+ if (canvas_item_editor_viewport->is_connected("mouse_exited", this, "_canvas_mouse_exit"))
+ canvas_item_editor_viewport->disconnect("mouse_exited", this, "_canvas_mouse_exit");
_update_palette();
}
@@ -1644,9 +1643,7 @@ void TileMapEditor::edit(Node *p_tile_map) {
void TileMapEditor::_tileset_settings_changed() {
_update_palette();
-
- if (canvas_item_editor)
- canvas_item_editor->update();
+ CanvasItemEditor::get_singleton()->update_viewport();
}
void TileMapEditor::_icon_size_changed(float p_value) {
@@ -1730,7 +1727,7 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) {
node = NULL;
manual_autotile = false;
manual_position = Vector2(0, 0);
- canvas_item_editor = NULL;
+ canvas_item_editor_viewport = NULL;
editor = p_editor;
undo_redo = editor->get_undo_redo();
diff --git a/editor/plugins/tile_map_editor_plugin.h b/editor/plugins/tile_map_editor_plugin.h
index 74aece6f47..3d44647a1b 100644
--- a/editor/plugins/tile_map_editor_plugin.h
+++ b/editor/plugins/tile_map_editor_plugin.h
@@ -82,7 +82,7 @@ class TileMapEditor : public VBoxContainer {
EditorNode *editor;
UndoRedo *undo_redo;
- Control *canvas_item_editor;
+ Control *canvas_item_editor_viewport;
LineEdit *search_box;
HSlider *size_slider;
diff --git a/editor/plugins/tile_set_editor_plugin.cpp b/editor/plugins/tile_set_editor_plugin.cpp
index 3de2284cea..9988d82fb8 100644
--- a/editor/plugins/tile_set_editor_plugin.cpp
+++ b/editor/plugins/tile_set_editor_plugin.cpp
@@ -569,6 +569,10 @@ void TileSetEditor::_on_textures_added(const PoolStringArray &p_paths) {
int invalid_count = 0;
for (int i = 0; i < p_paths.size(); i++) {
Ref<Texture> t = Ref<Texture>(ResourceLoader::load(p_paths[i]));
+
+ ERR_EXPLAIN("'" + p_paths[i] + "' is not a valid texture.");
+ ERR_CONTINUE(!t.is_valid());
+
if (texture_map.has(t->get_rid())) {
invalid_count++;
} else {
@@ -577,9 +581,13 @@ void TileSetEditor::_on_textures_added(const PoolStringArray &p_paths) {
texture_list->set_item_metadata(texture_list->get_item_count() - 1, t->get_rid());
}
}
- update_texture_list_icon();
- texture_list->select(texture_list->get_item_count() - 1);
- _on_texture_list_selected(texture_list->get_item_count() - 1);
+
+ if (texture_list->get_item_count() > 0) {
+ update_texture_list_icon();
+ texture_list->select(texture_list->get_item_count() - 1);
+ _on_texture_list_selected(texture_list->get_item_count() - 1);
+ }
+
if (invalid_count > 0) {
err_dialog->set_text(vformat(TTR("%s file(s) were not added because was already on the list."), String::num(invalid_count, 0)));
err_dialog->popup_centered(Size2(300, 60));
diff --git a/editor/project_export.cpp b/editor/project_export.cpp
index fa6dce1771..3ec49e187f 100644
--- a/editor/project_export.cpp
+++ b/editor/project_export.cpp
@@ -638,10 +638,10 @@ bool ProjectExportDialog::_fill_tree(EditorFileSystemDirectory *p_dir, TreeItem
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) == false) {
- memdelete(subdir);
- } else {
+ if (_fill_tree(p_dir->get_subdir(i), subdir, current, p_only_scenes)) {
used = true;
+ } else {
+ memdelete(subdir);
}
}
diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp
index c611327a31..9ef6e4332c 100644
--- a/editor/property_editor.cpp
+++ b/editor/property_editor.cpp
@@ -132,7 +132,7 @@ void CustomPropertyEditor::_menu_option(int p_which) {
emit_signal("variant_changed");
} else if (hint == PROPERTY_HINT_ENUM) {
- v = p_which;
+ v = menu->get_item_metadata(p_which);
emit_signal("variant_changed");
}
} break;
@@ -427,12 +427,14 @@ 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++) {
- if (options[i].find(":") != -1) {
- menu->add_item(options[i].get_slicec(':', 0), options[i].get_slicec(':', 1).to_int());
- } else {
- menu->add_item(options[i], i);
- }
+ Vector<String> text_split = options[i].split(":");
+ 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;
}
menu->set_position(get_position());
menu->popup();
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp
index f2c04d7326..45c20121da 100644
--- a/editor/scene_tree_dock.cpp
+++ b/editor/scene_tree_dock.cpp
@@ -574,6 +574,8 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
editor_data->get_undo_redo().add_do_method(editor, "set_edited_scene", node);
editor_data->get_undo_redo().add_do_method(node, "set_filename", root->get_filename());
editor_data->get_undo_redo().add_do_method(root, "set_filename", String());
+ editor_data->get_undo_redo().add_do_method(node, "set_owner", (Object *)NULL);
+ editor_data->get_undo_redo().add_do_method(root, "set_owner", node);
_node_replace_owner(root, root, node, MODE_DO);
editor_data->get_undo_redo().add_undo_method(root, "set_filename", root->get_filename());
@@ -581,6 +583,9 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
editor_data->get_undo_redo().add_undo_method(node, "remove_child", root);
editor_data->get_undo_redo().add_undo_method(editor, "set_edited_scene", root);
editor_data->get_undo_redo().add_undo_method(node->get_parent(), "add_child", node);
+ editor_data->get_undo_redo().add_undo_method(root, "set_owner", (Object *)NULL);
+ editor_data->get_undo_redo().add_undo_method(node, "set_owner", root);
+
_node_replace_owner(root, root, root, MODE_UNDO);
editor_data->get_undo_redo().add_do_method(scene_tree, "update_tree");
@@ -797,7 +802,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
case TOOL_CREATE_USER_INTERFACE:
case TOOL_CREATE_FAVORITE: {
- Node *new_node;
+ Node *new_node = NULL;
if (TOOL_CREATE_FAVORITE == p_tool) {
String name = selected_favorite_root.get_slicec(' ', 0);
@@ -836,6 +841,8 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
editor_data->get_undo_redo().commit_action();
editor->edit_node(new_node);
+ editor_selection->clear();
+ editor_selection->add_node(new_node);
} break;
@@ -980,7 +987,7 @@ 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->get_owner()) {
+ if (p_node->get_owner() == p_base && p_node != p_root) {
UndoRedo *undo_redo = &editor_data->get_undo_redo();
switch (p_mode) {
case MODE_BIDI: {
@@ -1606,6 +1613,14 @@ void SceneTreeDock::_delete_confirm() {
void SceneTreeDock::_update_script_button() {
if (EditorNode::get_singleton()->get_editor_selection()->get_selection().size() == 1) {
button_create_script->show();
+ Node *n = EditorNode::get_singleton()->get_editor_selection()->get_selected_node_list()[0];
+ if (n->get_script().is_null()) {
+ button_create_script->set_icon(get_icon("ScriptCreate", "EditorIcons"));
+ button_create_script->set_tooltip(TTR("Attach a new or existing script for the selected node."));
+ } else {
+ button_create_script->set_icon(get_icon("ScriptExtend", "EditorIcons"));
+ button_create_script->set_tooltip(TTR("Extend the selected node's script with a new or existing script."));
+ }
} else {
button_create_script->hide();
}
@@ -2352,7 +2367,6 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSel
tb = memnew(ToolButton);
tb->connect("pressed", this, "_tool_selected", make_binds(TOOL_ATTACH_SCRIPT, false));
- tb->set_tooltip(TTR("Attach a new or existing script for the selected node."));
tb->set_shortcut(ED_GET_SHORTCUT("scene_tree/attach_script"));
filter_hbc->add_child(tb);
tb->hide();
diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp
index 07670bb420..848e4def6d 100644
--- a/editor/scene_tree_editor.cpp
+++ b/editor/scene_tree_editor.cpp
@@ -73,7 +73,7 @@ void SceneTreeEditor::_cell_button_pressed(Object *p_item, int p_column, int p_i
undo_redo->create_action(TTR("Toggle Visible"));
_toggle_visible(n);
List<Node *> selection = editor_selection->get_selected_node_list();
- if (selection.size() > 1) {
+ if (selection.size() > 1 && selection.find(n) != NULL) {
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
Node *nv = E->get();
ERR_FAIL_COND(!nv);
diff --git a/editor/script_editor_debugger.cpp b/editor/script_editor_debugger.cpp
index eb72d0aa6e..a36a844710 100644
--- a/editor/script_editor_debugger.cpp
+++ b/editor/script_editor_debugger.cpp
@@ -355,7 +355,7 @@ void ScriptEditorDebugger::_video_mem_request() {
Size2 ScriptEditorDebugger::get_minimum_size() const {
Size2 ms = Control::get_minimum_size();
- ms.y = MAX(ms.y, 250);
+ ms.y = MAX(ms.y, 250 * EDSCALE);
return ms;
}
void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_data) {
@@ -493,23 +493,29 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
pinfo.usage = PropertyUsageFlags(int(prop[4]));
Variant var = prop[5];
+ if (pinfo.type == Variant::OBJECT) {
+ if (var.is_zero()) {
+ var = RES();
+ } else if (var.get_type() == Variant::STRING) {
+ var = ResourceLoader::load(var);
+
+ if (pinfo.hint_string == "Script")
+ debugObj->set_script(var);
+ } else if (var.get_type() == Variant::OBJECT) {
+ if (((Object *)var)->is_class("EncodedObjectAsID")) {
+ var = Object::cast_to<EncodedObjectAsID>(var)->get_object_id();
+ pinfo.type = var.get_type();
+ pinfo.hint = PROPERTY_HINT_OBJECT_ID;
+ pinfo.hint_string = "Object";
+ }
+ }
+ }
+
if (is_new_object) {
//don't update.. it's the same, instead refresh
debugObj->prop_list.push_back(pinfo);
}
- if (var.get_type() == Variant::STRING) {
- String str = var;
- var = str.substr(4, str.length());
-
- if (str.begins_with("PATH")) {
- if (String(var).empty())
- var = RES();
- else
- var = ResourceLoader::load(var);
- }
- }
-
debugObj->prop_values[pinfo.name] = var;
}
diff --git a/editor/spatial_editor_gizmos.cpp b/editor/spatial_editor_gizmos.cpp
index 96bca86f83..881f20cecb 100644
--- a/editor/spatial_editor_gizmos.cpp
+++ b/editor/spatial_editor_gizmos.cpp
@@ -3454,10 +3454,9 @@ void CollisionShapeSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
if (points.size() > 3) {
- QuickHull qh;
Vector<Vector3> varr = Variant(points);
Geometry::MeshData md;
- Error err = qh.build(varr, md);
+ Error err = QuickHull::build(varr, md);
if (err == OK) {
Vector<Vector3> points;
points.resize(md.edges.size() * 2);
@@ -4201,21 +4200,16 @@ void JointSpatialGizmoPlugin::CreateGeneric6DOFJointGizmo(
float cs = 0.25;
for (int ax = 0; ax < 3; ax++) {
- /*r_points.push_back(p_offset.translated(Vector3(+cs,0,0)).origin);
- r_points.push_back(p_offset.translated(Vector3(-cs,0,0)).origin);
- r_points.push_back(p_offset.translated(Vector3(0,+cs,0)).origin);
- r_points.push_back(p_offset.translated(Vector3(0,-cs,0)).origin);
- r_points.push_back(p_offset.translated(Vector3(0,0,+cs*2)).origin);
- r_points.push_back(p_offset.translated(Vector3(0,0,-cs*2)).origin); */
-
- float ll;
- float ul;
- float lll;
- float lul;
-
- int a1, a2, a3;
- bool enable_ang;
- bool enable_lin;
+ float ll = 0;
+ float ul = 0;
+ float lll = 0;
+ float lul = 0;
+
+ int a1 = 0;
+ int a2 = 0;
+ int a3 = 0;
+ bool enable_ang = false;
+ bool enable_lin = false;
switch (ax) {
case 0:
diff --git a/main/input_default.cpp b/main/input_default.cpp
index 913c143025..33c422190d 100644
--- a/main/input_default.cpp
+++ b/main/input_default.cpp
@@ -261,6 +261,13 @@ void InputDefault::parse_input_event(const Ref<InputEvent> &p_event) {
void InputDefault::_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
+ // emulated back to touch events in an endless loop.
+ // - Emulated touch events are handed right to the main loop (i.e., the SceneTree) because they don't
+ // require additional handling by this class.
+
_THREAD_SAFE_METHOD_
Ref<InputEventKey> k = p_event;
@@ -316,11 +323,21 @@ void InputDefault::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool
}
}
- if (emulate_mouse_from_touch) {
+ Ref<InputEventScreenTouch> st = p_event;
+
+ if (st.is_valid()) {
+
+ if (st->is_pressed()) {
+ SpeedTrack &track = touch_speed_track[st->get_index()];
+ track.reset();
+ } else {
+ // Since a pointer index may not occur again (OSs may or may not reuse them),
+ // imperatively remove it from the map to keep no fossil entries in it
+ touch_speed_track.erase(st->get_index());
+ }
- Ref<InputEventScreenTouch> st = p_event;
+ if (emulate_mouse_from_touch) {
- if (st.is_valid()) {
bool translate = false;
if (st->is_pressed()) {
if (mouse_from_touch_index == -1) {
@@ -351,10 +368,18 @@ void InputDefault::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool
_parse_input_event_impl(button_event, true);
}
}
+ }
+
+ 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);
- Ref<InputEventScreenDrag> sd = p_event;
+ if (emulate_mouse_from_touch && sd->get_index() == mouse_from_touch_index) {
- if (sd.is_valid() && sd->get_index() == mouse_from_touch_index) {
Ref<InputEventMouseMotion> motion_event;
motion_event.instance();
diff --git a/main/input_default.h b/main/input_default.h
index b420ec124b..4964b9a83c 100644
--- a/main/input_default.h
+++ b/main/input_default.h
@@ -117,6 +117,7 @@ class InputDefault : public Input {
};
SpeedTrack mouse_speed_track;
+ Map<int, SpeedTrack> touch_speed_track;
Map<int, Joypad> joy_names;
int fallback_mapping;
diff --git a/main/main.cpp b/main/main.cpp
index 41ae368087..e9cd183d8a 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -729,7 +729,9 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
#ifdef TOOLS_ENABLED
editor = false;
#else
- OS::get_singleton()->print("Error: Could not load game path '%s'.\n", project_path.ascii().get_data());
+ String error_msg = "Error: Could not load game data at path '" + project_path + "'. Is the .pck file missing?\n";
+ OS::get_singleton()->print(error_msg.ascii().get_data());
+ OS::get_singleton()->alert(error_msg);
goto error;
#endif
diff --git a/main/tests/test_oa_hash_map.cpp b/main/tests/test_oa_hash_map.cpp
index 0e34faace7..deaba285cf 100644
--- a/main/tests/test_oa_hash_map.cpp
+++ b/main/tests/test_oa_hash_map.cpp
@@ -48,7 +48,7 @@ MainLoop *test() {
map.set(1337, 21);
map.set(42, 11880);
- int value;
+ int value = 0;
map.lookup(42, value);
OS::get_singleton()->print("capacity %d\n", map.get_capacity());
@@ -92,6 +92,35 @@ MainLoop *test() {
}
}
+ // stress test / test for issue #22928
+ {
+ OAHashMap<int, int> map;
+ int dummy;
+ const int N = 1000;
+ uint32_t *keys = new uint32_t[N];
+
+ Math::seed(0);
+
+ // insert a couple of random keys (with a dummy value, which is ignored)
+ for (int i = 0; i < N; i++) {
+ keys[i] = Math::rand();
+ map.set(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
+ for (int i = 0; i < N; i++) {
+ if (!map.lookup(keys[i], dummy)) {
+ OS::get_singleton()->print("could not find 0x%X despite it has been inserted previously! (not checking the other keys, breaking...)\n", unsigned(keys[i]));
+ break;
+ }
+ }
+
+ delete[] keys;
+ }
+
return NULL;
}
} // namespace TestOAHashMap
diff --git a/main/tests/test_string.cpp b/main/tests/test_string.cpp
index 74157d63c9..7e19c7bf3e 100644
--- a/main/tests/test_string.cpp
+++ b/main/tests/test_string.cpp
@@ -480,7 +480,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == String("fish % frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
//////// INTS
@@ -491,7 +491,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == String("fish 5 frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
// Int left padded with zeroes.
format = "fish %05d frog";
@@ -500,7 +500,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == String("fish 00005 frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
// Int left padded with spaces.
format = "fish %5d frog";
@@ -509,7 +509,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == String("fish 5 frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
// Int right padded with spaces.
format = "fish %-5d frog";
@@ -518,7 +518,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == String("fish 5 frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
// Int with sign (positive).
format = "fish %+d frog";
@@ -527,7 +527,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == String("fish +5 frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
// Negative int.
format = "fish %d frog";
@@ -536,7 +536,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == String("fish -5 frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
// Hex (lower)
format = "fish %x frog";
@@ -545,7 +545,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == String("fish 2d frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
// Hex (upper)
format = "fish %X frog";
@@ -554,7 +554,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == String("fish 2D frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
// Octal
format = "fish %o frog";
@@ -563,7 +563,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == String("fish 143 frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
////// REALS
@@ -574,7 +574,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == String("fish 99.990000 frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
// Real left-padded
format = "fish %11f frog";
@@ -583,7 +583,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == String("fish 99.990000 frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
// Real right-padded
format = "fish %-11f frog";
@@ -592,7 +592,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == String("fish 99.990000 frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
// Real given int.
format = "fish %f frog";
@@ -601,7 +601,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == String("fish 99.000000 frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
// Real with sign (positive).
format = "fish %+f frog";
@@ -610,7 +610,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == String("fish +99.990000 frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
// Real with 1 decimals.
format = "fish %.1f frog";
@@ -619,7 +619,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == String("fish 100.0 frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
// Real with 12 decimals.
format = "fish %.12f frog";
@@ -628,7 +628,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == String("fish 99.990000000000 frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
// Real with no decimals.
format = "fish %.f frog";
@@ -637,7 +637,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == String("fish 100 frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
/////// Strings.
@@ -648,7 +648,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == String("fish cheese frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
// String left-padded
format = "fish %10s frog";
@@ -657,7 +657,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == String("fish cheese frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
// String right-padded
format = "fish %-10s frog";
@@ -666,7 +666,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == String("fish cheese frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
///// Characters
@@ -677,7 +677,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == String("fish A frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
// Character as int.
format = "fish %c frog";
@@ -686,7 +686,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == String("fish A frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
///// Dynamic width
@@ -698,7 +698,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == String("fish cheese frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
// Int dynamic width
format = "fish %*d frog";
@@ -708,7 +708,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == String("fish 99 frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
// Float dynamic width
format = "fish %*.*f frog";
@@ -719,7 +719,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == String("fish 99.990 frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
///// Errors
@@ -730,7 +730,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == "not enough arguments for format string" && error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
// More arguments than formats.
format = "fish %s frog";
@@ -740,7 +740,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == "not all arguments converted during string formatting" && error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
// Incomplete format.
format = "fish %10";
@@ -749,7 +749,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == "incomplete format" && error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
// Bad character in format string
format = "fish %&f frog";
@@ -758,7 +758,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == "unsupported format character" && error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
// Too many decimals.
format = "fish %2.2.2f frog";
@@ -767,7 +767,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == "too many decimal points in format" && error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
// * not a number
format = "fish %*f frog";
@@ -777,7 +777,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == "* wants number" && error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
// Character too long.
format = "fish %c frog";
@@ -786,7 +786,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == "%c requires number or single-character string" && error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
// Character bad type.
format = "fish %c frog";
@@ -795,7 +795,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == "%c requires number or single-character string" && error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
return state;
}
@@ -819,37 +819,127 @@ bool test_29() {
String ip4 = "192.168.0.1";
bool success = ip4.is_valid_ip_address();
OS::get_singleton()->print("Is valid ipv4: %ls, %s\n", ip4.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
ip4 = "192.368.0.1";
success = (!ip4.is_valid_ip_address());
OS::get_singleton()->print("Is invalid ipv4: %ls, %s\n", ip4.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
String ip6 = "2001:0db8:85a3:0000:0000:8a2e:0370:7334";
success = ip6.is_valid_ip_address();
OS::get_singleton()->print("Is valid ipv6: %ls, %s\n", ip6.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
ip6 = "2001:0db8:85j3:0000:0000:8a2e:0370:7334";
success = (!ip6.is_valid_ip_address());
OS::get_singleton()->print("Is invalid ipv6: %ls, %s\n", ip6.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
ip6 = "2001:0db8:85f345:0000:0000:8a2e:0370:7334";
success = (!ip6.is_valid_ip_address());
OS::get_singleton()->print("Is invalid ipv6: %ls, %s\n", ip6.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
ip6 = "2001:0db8::0:8a2e:370:7334";
success = (ip6.is_valid_ip_address());
OS::get_singleton()->print("Is valid ipv6: %ls, %s\n", ip6.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
ip6 = "::ffff:192.168.0.1";
success = (ip6.is_valid_ip_address());
OS::get_singleton()->print("Is valid ipv6: %ls, %s\n", ip6.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
+
+ return state;
+};
+
+bool test_30() {
+ bool state = true;
+ bool success = true;
+ String input = "bytes2var";
+ String output = "Bytes 2 Var";
+ success = (input.capitalize() == output);
+ state = state && success;
+ OS::get_singleton()->print("Capitalize %ls: %ls, %s\n", input.c_str(), output.c_str(), success ? "OK" : "FAIL");
+
+ input = "linear2db";
+ output = "Linear 2 Db";
+ success = (input.capitalize() == output);
+ state = state && success;
+ OS::get_singleton()->print("Capitalize %ls: %ls, %s\n", input.c_str(), output.c_str(), success ? "OK" : "FAIL");
+
+ input = "vector3";
+ output = "Vector 3";
+ success = (input.capitalize() == output);
+ state = state && success;
+ OS::get_singleton()->print("Capitalize %ls: %ls, %s\n", input.c_str(), output.c_str(), success ? "OK" : "FAIL");
+
+ input = "sha256";
+ output = "Sha 256";
+ success = (input.capitalize() == output);
+ state = state && success;
+ OS::get_singleton()->print("Capitalize %ls: %ls, %s\n", input.c_str(), output.c_str(), success ? "OK" : "FAIL");
+
+ input = "2db";
+ output = "2 Db";
+ success = (input.capitalize() == output);
+ state = state && success;
+ OS::get_singleton()->print("Capitalize %ls: %ls, %s\n", input.c_str(), output.c_str(), success ? "OK" : "FAIL");
+
+ input = "PascalCase";
+ output = "Pascal Case";
+ success = (input.capitalize() == output);
+ state = state && success;
+ OS::get_singleton()->print("Capitalize %ls: %ls, %s\n", input.c_str(), output.c_str(), success ? "OK" : "FAIL");
+
+ input = "PascalPascalCase";
+ output = "Pascal Pascal Case";
+ success = (input.capitalize() == output);
+ state = state && success;
+ OS::get_singleton()->print("Capitalize %ls: %ls, %s\n", input.c_str(), output.c_str(), success ? "OK" : "FAIL");
+
+ input = "snake_case";
+ output = "Snake Case";
+ success = (input.capitalize() == output);
+ state = state && success;
+ OS::get_singleton()->print("Capitalize %ls: %ls, %s\n", input.c_str(), output.c_str(), success ? "OK" : "FAIL");
+
+ input = "snake_snake_case";
+ output = "Snake Snake Case";
+ success = (input.capitalize() == output);
+ state = state && success;
+ OS::get_singleton()->print("Capitalize %ls: %ls, %s\n", input.c_str(), output.c_str(), success ? "OK" : "FAIL");
+
+ input = "sha256sum";
+ output = "Sha 256 Sum";
+ success = (input.capitalize() == output);
+ state = state && success;
+ OS::get_singleton()->print("Capitalize %ls: %ls, %s\n", input.c_str(), output.c_str(), success ? "OK" : "FAIL");
+
+ input = "cat2dog";
+ output = "Cat 2 Dog";
+ success = (input.capitalize() == output);
+ state = state && success;
+ OS::get_singleton()->print("Capitalize %ls: %ls, %s\n", input.c_str(), output.c_str(), success ? "OK" : "FAIL");
+
+ input = "function(name)";
+ output = "Function(name)";
+ success = (input.capitalize() == output);
+ state = state && success;
+ OS::get_singleton()->print("Capitalize %ls (existing incorrect behavior): %ls, %s\n", input.c_str(), output.c_str(), success ? "OK" : "FAIL");
+
+ input = "snake_case_function(snake_case_arg)";
+ output = "Snake Case Function(snake Case Arg)";
+ success = (input.capitalize() == output);
+ state = state && success;
+ OS::get_singleton()->print("Capitalize %ls (existing incorrect behavior): %ls, %s\n", input.c_str(), output.c_str(), success ? "OK" : "FAIL");
+
+ input = "snake_case_function( snake_case_arg )";
+ output = "Snake Case Function( Snake Case Arg )";
+ success = (input.capitalize() == output);
+ state = state && success;
+ OS::get_singleton()->print("Capitalize %ls: %ls, %s\n", input.c_str(), output.c_str(), success ? "OK" : "FAIL");
return state;
};
@@ -887,6 +977,7 @@ TestFunc test_funcs[] = {
test_27,
test_28,
test_29,
+ test_30,
0
};
diff --git a/methods.py b/methods.py
index 3add9b1f18..0cf05751a8 100644
--- a/methods.py
+++ b/methods.py
@@ -22,6 +22,10 @@ def add_source_files(self, sources, filetype, lib_env=None, shared=False):
def disable_warnings(self):
# 'self' is the environment
if self.msvc:
+ # We have to remove existing warning level defines before appending /w,
+ # otherwise we get: "warning D9025 : overriding '/W3' with '/w'"
+ warn_flags = ['/Wall', '/W4', '/W3', '/W2', '/W1', '/WX']
+ self['CCFLAGS'] = [x for x in self['CCFLAGS'] if not x in warn_flags]
self.Append(CCFLAGS=['/w'])
else:
self.Append(CCFLAGS=['-w'])
diff --git a/modules/bullet/area_bullet.cpp b/modules/bullet/area_bullet.cpp
index a3ba3aa0bf..a0486443c2 100644
--- a/modules/bullet/area_bullet.cpp
+++ b/modules/bullet/area_bullet.cpp
@@ -58,7 +58,7 @@ AreaBullet::AreaBullet() :
isScratched(false) {
btGhost = bulletnew(btGhostObject);
- btGhost->setCollisionShape(BulletPhysicsServer::get_empty_shape());
+ reload_shapes();
setupBulletCollisionObject(btGhost);
/// Collision objects with a callback still have collision response with dynamic rigid bodies.
/// In order to use collision objects as trigger, you have to disable the collision response.
@@ -166,11 +166,9 @@ bool AreaBullet::is_monitoring() const {
return get_godot_object_flags() & GOF_IS_MONITORING_AREA;
}
-void AreaBullet::main_shape_resetted() {
- if (get_main_shape())
- btGhost->setCollisionShape(get_main_shape());
- else
- btGhost->setCollisionShape(BulletPhysicsServer::get_empty_shape());
+void AreaBullet::main_shape_changed() {
+ CRASH_COND(!get_main_shape())
+ btGhost->setCollisionShape(get_main_shape());
}
void AreaBullet::reload_body() {
diff --git a/modules/bullet/area_bullet.h b/modules/bullet/area_bullet.h
index a6bf73906c..1c5962cfe3 100644
--- a/modules/bullet/area_bullet.h
+++ b/modules/bullet/area_bullet.h
@@ -142,7 +142,7 @@ public:
_FORCE_INLINE_ void set_spOv_priority(int p_priority) { spOv_priority = p_priority; }
_FORCE_INLINE_ int get_spOv_priority() { return spOv_priority; }
- virtual void main_shape_resetted();
+ virtual void main_shape_changed();
virtual void reload_body();
virtual void set_space(SpaceBullet *p_space);
@@ -157,6 +157,7 @@ public:
virtual void on_collision_filters_change();
virtual void on_collision_checker_start() {}
+ virtual void on_collision_checker_end() { isTransformChanged = false; }
void add_overlap(CollisionObjectBullet *p_otherObject);
void put_overlap_as_exit(int p_index);
diff --git a/modules/bullet/bullet_physics_server.cpp b/modules/bullet/bullet_physics_server.cpp
index 53a38967c3..315afe3d72 100644
--- a/modules/bullet/bullet_physics_server.cpp
+++ b/modules/bullet/bullet_physics_server.cpp
@@ -74,12 +74,6 @@
body->get_space()->add_constraint(joint, joint->is_disabled_collisions_between_bodies());
// <--------------- Joint creation asserts
-btEmptyShape *BulletPhysicsServer::emptyShape(ShapeBullet::create_shape_empty());
-
-btEmptyShape *BulletPhysicsServer::get_empty_shape() {
- return emptyShape;
-}
-
void BulletPhysicsServer::_bind_methods() {
//ClassDB::bind_method(D_METHOD("DoTest"), &BulletPhysicsServer::DoTest);
}
@@ -89,9 +83,7 @@ BulletPhysicsServer::BulletPhysicsServer() :
active(true),
active_spaces_count(0) {}
-BulletPhysicsServer::~BulletPhysicsServer() {
- bulletdelete(emptyShape);
-}
+BulletPhysicsServer::~BulletPhysicsServer() {}
RID BulletPhysicsServer::shape_create(ShapeType p_shape) {
ShapeBullet *shape = NULL;
@@ -338,7 +330,7 @@ Transform BulletPhysicsServer::area_get_shape_transform(RID p_area, int p_shape_
void BulletPhysicsServer::area_remove_shape(RID p_area, int p_shape_idx) {
AreaBullet *area = area_owner.get(p_area);
ERR_FAIL_COND(!area);
- return area->remove_shape(p_shape_idx);
+ return area->remove_shape_full(p_shape_idx);
}
void BulletPhysicsServer::area_clear_shapes(RID p_area) {
@@ -346,7 +338,7 @@ void BulletPhysicsServer::area_clear_shapes(RID p_area) {
ERR_FAIL_COND(!area);
for (int i = area->get_shape_count(); 0 < i; --i)
- area->remove_shape(0);
+ area->remove_shape_full(0);
}
void BulletPhysicsServer::area_set_shape_disabled(RID p_area, int p_shape_idx, bool p_disabled) {
@@ -567,7 +559,7 @@ void BulletPhysicsServer::body_remove_shape(RID p_body, int p_shape_idx) {
RigidBodyBullet *body = rigid_body_owner.get(p_body);
ERR_FAIL_COND(!body);
- body->remove_shape(p_shape_idx);
+ body->remove_shape_full(p_shape_idx);
}
void BulletPhysicsServer::body_clear_shapes(RID p_body) {
@@ -1486,7 +1478,7 @@ void BulletPhysicsServer::free(RID p_rid) {
// Notify the shape is configured
for (Map<ShapeOwnerBullet *, int>::Element *element = shape->get_owners().front(); element; element = element->next()) {
- static_cast<ShapeOwnerBullet *>(element->key())->remove_shape(shape);
+ static_cast<ShapeOwnerBullet *>(element->key())->remove_shape_full(shape);
}
shape_owner.free(p_rid);
@@ -1497,7 +1489,7 @@ void BulletPhysicsServer::free(RID p_rid) {
body->set_space(NULL);
- body->remove_all_shapes(true);
+ body->remove_all_shapes(true, true);
rigid_body_owner.free(p_rid);
bulletdelete(body);
@@ -1517,7 +1509,7 @@ void BulletPhysicsServer::free(RID p_rid) {
area->set_space(NULL);
- area->remove_all_shapes(true);
+ area->remove_all_shapes(true, true);
area_owner.free(p_rid);
bulletdelete(area);
diff --git a/modules/bullet/bullet_physics_server.h b/modules/bullet/bullet_physics_server.h
index 4c52cace67..6b7dcd86e6 100644
--- a/modules/bullet/bullet_physics_server.h
+++ b/modules/bullet/bullet_physics_server.h
@@ -60,13 +60,6 @@ class BulletPhysicsServer : public PhysicsServer {
mutable RID_Owner<SoftBodyBullet> soft_body_owner;
mutable RID_Owner<JointBullet> joint_owner;
-private:
- /// This is used as replacement of collision shape inside a compound or main shape
- static btEmptyShape *emptyShape;
-
-public:
- static btEmptyShape *get_empty_shape();
-
protected:
static void _bind_methods();
diff --git a/modules/bullet/bullet_utilities.h b/modules/bullet/bullet_utilities.h
index 029eb6691a..553c1d0384 100644
--- a/modules/bullet/bullet_utilities.h
+++ b/modules/bullet/bullet_utilities.h
@@ -39,7 +39,8 @@
new cl
#define bulletdelete(cl) \
- delete cl; \
- cl = NULL;
-
+ { \
+ delete cl; \
+ cl = NULL; \
+ }
#endif
diff --git a/modules/bullet/collision_object_bullet.cpp b/modules/bullet/collision_object_bullet.cpp
index 61834b8e3f..402a276f95 100644
--- a/modules/bullet/collision_object_bullet.cpp
+++ b/modules/bullet/collision_object_bullet.cpp
@@ -43,8 +43,7 @@
@author AndreaCatania
*/
-#define enableDynamicAabbTree true
-#define initialChildCapacity 1
+#define enableDynamicAabbTree false
CollisionObjectBullet::ShapeWrapper::~ShapeWrapper() {}
@@ -60,7 +59,10 @@ void CollisionObjectBullet::ShapeWrapper::set_transform(const btTransform &p_tra
void CollisionObjectBullet::ShapeWrapper::claim_bt_shape(const btVector3 &body_scale) {
if (!bt_shape) {
- bt_shape = shape->create_bt_shape(scale * body_scale);
+ if (active)
+ bt_shape = shape->create_bt_shape(scale * body_scale);
+ else
+ bt_shape = ShapeBullet::create_shape_empty();
}
}
@@ -72,7 +74,8 @@ CollisionObjectBullet::CollisionObjectBullet(Type p_type) :
bt_collision_object(NULL),
body_scale(1., 1., 1.),
force_shape_reset(false),
- space(NULL) {}
+ space(NULL),
+ isTransformChanged(false) {}
CollisionObjectBullet::~CollisionObjectBullet() {
// Remove all overlapping, notify is not required since godot take care of it
@@ -90,7 +93,7 @@ bool equal(real_t first, real_t second) {
void CollisionObjectBullet::set_body_scale(const Vector3 &p_new_scale) {
if (!equal(p_new_scale[0], body_scale[0]) || !equal(p_new_scale[1], body_scale[1]) || !equal(p_new_scale[2], body_scale[2])) {
body_scale = p_new_scale;
- on_body_scale_changed();
+ body_scale_changed();
}
}
@@ -100,7 +103,7 @@ btVector3 CollisionObjectBullet::get_bt_body_scale() const {
return s;
}
-void CollisionObjectBullet::on_body_scale_changed() {
+void CollisionObjectBullet::body_scale_changed() {
force_shape_reset = true;
}
@@ -186,49 +189,33 @@ Transform CollisionObjectBullet::get_transform() const {
void CollisionObjectBullet::set_transform__bullet(const btTransform &p_global_transform) {
bt_collision_object->setWorldTransform(p_global_transform);
+ notify_transform_changed();
}
const btTransform &CollisionObjectBullet::get_transform__bullet() const {
return bt_collision_object->getWorldTransform();
}
+void CollisionObjectBullet::notify_transform_changed() {
+ isTransformChanged = true;
+}
+
RigidCollisionObjectBullet::RigidCollisionObjectBullet(Type p_type) :
CollisionObjectBullet(p_type),
mainShape(NULL) {
}
RigidCollisionObjectBullet::~RigidCollisionObjectBullet() {
- remove_all_shapes(true);
+ remove_all_shapes(true, true);
if (mainShape && mainShape->isCompound()) {
bulletdelete(mainShape);
}
}
-/* Not used
-void RigidCollisionObjectBullet::_internal_replaceShape(btCollisionShape *p_old_shape, btCollisionShape *p_new_shape) {
- bool at_least_one_was_changed = false;
- btTransform old_transf;
- // Inverse because I need remove the shapes
- // Fetch all shapes to be sure to remove all shapes
- for (int i = compoundShape->getNumChildShapes() - 1; 0 <= i; --i) {
- if (compoundShape->getChildShape(i) == p_old_shape) {
-
- old_transf = compoundShape->getChildTransform(i);
- compoundShape->removeChildShapeByIndex(i);
- compoundShape->addChildShape(old_transf, p_new_shape);
- at_least_one_was_changed = true;
- }
- }
-
- if (at_least_one_was_changed) {
- on_shapes_changed();
- }
-}*/
-
void RigidCollisionObjectBullet::add_shape(ShapeBullet *p_shape, const Transform &p_transform) {
shapes.push_back(ShapeWrapper(p_shape, p_transform, true));
p_shape->add_owner(this);
- on_shapes_changed();
+ reload_shapes();
}
void RigidCollisionObjectBullet::set_shape(int p_index, ShapeBullet *p_shape) {
@@ -236,17 +223,31 @@ void RigidCollisionObjectBullet::set_shape(int p_index, ShapeBullet *p_shape) {
shp.shape->remove_owner(this);
p_shape->add_owner(this);
shp.shape = p_shape;
- on_shapes_changed();
+ reload_shapes();
}
-void RigidCollisionObjectBullet::set_shape_transform(int p_index, const Transform &p_transform) {
- ERR_FAIL_INDEX(p_index, get_shape_count());
+int RigidCollisionObjectBullet::get_shape_count() const {
+ return shapes.size();
+}
- shapes.write[p_index].set_transform(p_transform);
- on_shape_changed(shapes.write[p_index].shape);
+ShapeBullet *RigidCollisionObjectBullet::get_shape(int p_index) const {
+ return shapes[p_index].shape;
}
-void RigidCollisionObjectBullet::remove_shape(ShapeBullet *p_shape) {
+btCollisionShape *RigidCollisionObjectBullet::get_bt_shape(int p_index) const {
+ return shapes[p_index].bt_shape;
+}
+
+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)
+ return i;
+ }
+ return -1;
+}
+
+void RigidCollisionObjectBullet::remove_shape_full(ShapeBullet *p_shape) {
// Remove the shape, all the times it appears
// Reverse order required for delete.
for (int i = shapes.size() - 1; 0 <= i; --i) {
@@ -255,35 +256,32 @@ void RigidCollisionObjectBullet::remove_shape(ShapeBullet *p_shape) {
shapes.remove(i);
}
}
- on_shapes_changed();
+ reload_shapes();
}
-void RigidCollisionObjectBullet::remove_shape(int p_index) {
+void RigidCollisionObjectBullet::remove_shape_full(int p_index) {
ERR_FAIL_INDEX(p_index, get_shape_count());
internal_shape_destroy(p_index);
shapes.remove(p_index);
- on_shapes_changed();
+ reload_shapes();
}
-void RigidCollisionObjectBullet::remove_all_shapes(bool p_permanentlyFromThisBody) {
+void RigidCollisionObjectBullet::remove_all_shapes(bool p_permanentlyFromThisBody, bool p_force_not_reload) {
// Reverse order required for delete.
for (int i = shapes.size() - 1; 0 <= i; --i) {
internal_shape_destroy(i, p_permanentlyFromThisBody);
}
shapes.clear();
- on_shapes_changed();
-}
-
-int RigidCollisionObjectBullet::get_shape_count() const {
- return shapes.size();
+ if (!p_force_not_reload)
+ reload_shapes();
}
-ShapeBullet *RigidCollisionObjectBullet::get_shape(int p_index) const {
- return shapes[p_index].shape;
-}
+void RigidCollisionObjectBullet::set_shape_transform(int p_index, const Transform &p_transform) {
+ ERR_FAIL_INDEX(p_index, get_shape_count());
-btCollisionShape *RigidCollisionObjectBullet::get_bt_shape(int p_index) const {
- return shapes[p_index].bt_shape;
+ shapes.write[p_index].set_transform(p_transform);
+ // Note, enableDynamicAabbTree is false because on transform change compound is destroyed
+ reload_shapes();
}
const btTransform &RigidCollisionObjectBullet::get_bt_shape_transform(int p_index) const {
@@ -296,21 +294,27 @@ Transform RigidCollisionObjectBullet::get_shape_transform(int p_index) const {
return trs;
}
-void RigidCollisionObjectBullet::on_shape_changed(const ShapeBullet *const p_shape) {
- const int size = shapes.size();
- for (int i = 0; i < size; ++i) {
- if (shapes[i].shape == p_shape) {
- bulletdelete(shapes.write[i].bt_shape);
- }
- }
- on_shapes_changed();
+void RigidCollisionObjectBullet::set_shape_disabled(int p_index, bool p_disabled) {
+ shapes.write[p_index].active = !p_disabled;
+ shape_changed(p_index);
+}
+
+bool RigidCollisionObjectBullet::is_shape_disabled(int p_index) {
+ return !shapes[p_index].active;
}
-void RigidCollisionObjectBullet::on_shapes_changed() {
+void RigidCollisionObjectBullet::shape_changed(int p_shape_index) {
+ bulletdelete(shapes.write[p_shape_index].bt_shape);
+ reload_shapes();
+}
+
+void RigidCollisionObjectBullet::reload_shapes() {
if (mainShape && mainShape->isCompound()) {
+ // Destroy compound
bulletdelete(mainShape);
}
+
mainShape = NULL;
ShapeWrapper *shpWrapper;
@@ -325,55 +329,38 @@ void RigidCollisionObjectBullet::on_shapes_changed() {
force_shape_reset = false;
}
- btVector3 body_scale(get_bt_body_scale());
-
- if (!shape_count)
- return;
+ const btVector3 body_scale(get_bt_body_scale());
// Try to optimize by not using compound
if (1 == shape_count) {
shpWrapper = &shapes.write[0];
- if (shpWrapper->active && shpWrapper->transform.getOrigin().isZero() && shpWrapper->transform.getBasis() == shpWrapper->transform.getBasis().getIdentity()) {
+ if (shpWrapper->transform.getOrigin().isZero() && shpWrapper->transform.getBasis() == shpWrapper->transform.getBasis().getIdentity()) {
shpWrapper->claim_bt_shape(body_scale);
mainShape = shpWrapper->bt_shape;
- main_shape_resetted();
+ main_shape_changed();
return;
}
}
- btCompoundShape *compoundShape = bulletnew(btCompoundShape(enableDynamicAabbTree, initialChildCapacity));
+ // Optimization not possible use a compound shape
+ btCompoundShape *compoundShape = bulletnew(btCompoundShape(enableDynamicAabbTree, shape_count));
- // Insert all shapes into compound
for (int i(0); i < shape_count; ++i) {
shpWrapper = &shapes.write[i];
- if (shpWrapper->active) {
- shpWrapper->claim_bt_shape(body_scale);
-
- btTransform scaled_shape_transform(shpWrapper->transform);
- scaled_shape_transform.getOrigin() *= body_scale;
- compoundShape->addChildShape(scaled_shape_transform, shpWrapper->bt_shape);
- } else {
- compoundShape->addChildShape(btTransform(), BulletPhysicsServer::get_empty_shape());
- }
+ shpWrapper->claim_bt_shape(body_scale);
+ btTransform scaled_shape_transform(shpWrapper->transform);
+ scaled_shape_transform.getOrigin() *= body_scale;
+ compoundShape->addChildShape(scaled_shape_transform, shpWrapper->bt_shape);
}
compoundShape->recalculateLocalAabb();
mainShape = compoundShape;
- main_shape_resetted();
-}
-
-void RigidCollisionObjectBullet::set_shape_disabled(int p_index, bool p_disabled) {
- shapes.write[p_index].active = !p_disabled;
- on_shapes_changed();
-}
-
-bool RigidCollisionObjectBullet::is_shape_disabled(int p_index) {
- return !shapes[p_index].active;
+ main_shape_changed();
}
-void RigidCollisionObjectBullet::on_body_scale_changed() {
- CollisionObjectBullet::on_body_scale_changed();
- on_shapes_changed();
+void RigidCollisionObjectBullet::body_scale_changed() {
+ CollisionObjectBullet::body_scale_changed();
+ reload_shapes();
}
void RigidCollisionObjectBullet::internal_shape_destroy(int p_index, bool p_permanentlyFromThisBody) {
diff --git a/modules/bullet/collision_object_bullet.h b/modules/bullet/collision_object_bullet.h
index ea06cecb17..4a0c805ce5 100644
--- a/modules/bullet/collision_object_bullet.h
+++ b/modules/bullet/collision_object_bullet.h
@@ -132,6 +132,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;
public:
CollisionObjectBullet(Type p_type);
@@ -157,7 +158,7 @@ public:
void set_body_scale(const Vector3 &p_new_scale);
const Vector3 &get_body_scale() const { return body_scale; }
btVector3 get_bt_body_scale() const;
- virtual void on_body_scale_changed();
+ virtual void body_scale_changed();
void add_collision_exception(const CollisionObjectBullet *p_ignoreCollisionObject);
void remove_collision_exception(const CollisionObjectBullet *p_ignoreCollisionObject);
@@ -185,8 +186,9 @@ public:
virtual void reload_body() = 0;
virtual void set_space(SpaceBullet *p_space) = 0;
_FORCE_INLINE_ SpaceBullet *get_space() const { return space; }
- /// This is an event that is called when a collision checker starts
+
virtual void on_collision_checker_start() = 0;
+ virtual void on_collision_checker_end() = 0;
virtual void dispatch_callbacks() = 0;
@@ -197,7 +199,6 @@ public:
virtual void on_enter_area(AreaBullet *p_area) = 0;
virtual void on_exit_area(AreaBullet *p_area);
- /// GodotObjectFlags
void set_godot_object_flags(int flags);
int get_godot_object_flags() const;
@@ -205,11 +206,13 @@ public:
Transform get_transform() const;
virtual void set_transform__bullet(const btTransform &p_global_transform);
virtual const btTransform &get_transform__bullet() const;
+
+ bool is_transform_changed() const { return isTransformChanged; }
+ virtual void notify_transform_changed();
};
class RigidCollisionObjectBullet : public CollisionObjectBullet, public ShapeOwnerBullet {
protected:
- /// This could be a compound shape in case multi please collision are found
btCollisionShape *mainShape;
Vector<ShapeWrapper> shapes;
@@ -219,31 +222,34 @@ public:
_FORCE_INLINE_ const Vector<ShapeWrapper> &get_shapes_wrappers() const { return shapes; }
- /// This is used to set new shape or replace existing
- //virtual void _internal_replaceShape(btCollisionShape *p_old_shape, btCollisionShape *p_new_shape) = 0;
+ _FORCE_INLINE_ btCollisionShape *get_main_shape() const { return mainShape; }
+
void add_shape(ShapeBullet *p_shape, const Transform &p_transform = Transform());
void set_shape(int p_index, ShapeBullet *p_shape);
- void set_shape_transform(int p_index, const Transform &p_transform);
- virtual void remove_shape(ShapeBullet *p_shape);
- void remove_shape(int p_index);
- void remove_all_shapes(bool p_permanentlyFromThisBody = false);
-
- virtual void on_shape_changed(const ShapeBullet *const p_shape);
- virtual void on_shapes_changed();
-
- _FORCE_INLINE_ btCollisionShape *get_main_shape() const { return mainShape; }
int get_shape_count() const;
ShapeBullet *get_shape(int p_index) const;
btCollisionShape *get_bt_shape(int p_index) const;
+
+ int find_shape(ShapeBullet *p_shape) const;
+
+ virtual void remove_shape_full(ShapeBullet *p_shape);
+ void remove_shape_full(int p_index);
+ void remove_all_shapes(bool p_permanentlyFromThisBody = false, bool p_force_not_reload = false);
+
+ void set_shape_transform(int p_index, const Transform &p_transform);
+
const btTransform &get_bt_shape_transform(int p_index) const;
Transform get_shape_transform(int p_index) const;
void set_shape_disabled(int p_index, bool p_disabled);
bool is_shape_disabled(int p_index);
- virtual void main_shape_resetted() = 0;
- virtual void on_body_scale_changed();
+ virtual void shape_changed(int p_shape_index);
+ virtual void reload_shapes();
+
+ virtual void main_shape_changed() = 0;
+ virtual void body_scale_changed();
private:
void internal_shape_destroy(int p_index, bool p_permanentlyFromThisBody = false);
diff --git a/modules/bullet/godot_motion_state.h b/modules/bullet/godot_motion_state.h
index fa58e86589..5844ef8bf3 100644
--- a/modules/bullet/godot_motion_state.h
+++ b/modules/bullet/godot_motion_state.h
@@ -82,7 +82,7 @@ public:
virtual void setWorldTransform(const btTransform &worldTrans) {
bodyCurrentWorldTransform = worldTrans;
- owner->scratch();
+ owner->notify_transform_changed();
}
public:
diff --git a/modules/bullet/rigid_body_bullet.cpp b/modules/bullet/rigid_body_bullet.cpp
index d9a77885b3..37e7718969 100644
--- a/modules/bullet/rigid_body_bullet.cpp
+++ b/modules/bullet/rigid_body_bullet.cpp
@@ -265,13 +265,13 @@ RigidBodyBullet::RigidBodyBullet() :
angularDamp(0),
can_sleep(true),
omit_forces_integration(false),
+ can_integrate_forces(false),
maxCollisionsDetection(0),
collisionsCount(0),
maxAreasWhereIam(10),
areaWhereIamCount(0),
countGravityPointSpaces(0),
isScratchedSpaceOverrideModificator(false),
- isTransformChanged(false),
previousActiveState(true),
force_integration_callback(NULL) {
@@ -279,9 +279,10 @@ RigidBodyBullet::RigidBodyBullet() :
// Initial properties
const btVector3 localInertia(0, 0, 0);
- btRigidBody::btRigidBodyConstructionInfo cInfo(mass, godotMotionState, BulletPhysicsServer::get_empty_shape(), localInertia);
+ btRigidBody::btRigidBodyConstructionInfo cInfo(mass, godotMotionState, NULL, localInertia);
btBody = bulletnew(btRigidBody(cInfo));
+ reload_shapes();
setupBulletCollisionObject(btBody);
set_mode(PhysicsServer::BODY_MODE_RIGID);
@@ -314,11 +315,9 @@ void RigidBodyBullet::destroy_kinematic_utilities() {
}
}
-void RigidBodyBullet::main_shape_resetted() {
- if (get_main_shape())
- btBody->setCollisionShape(get_main_shape());
- else
- btBody->setCollisionShape(BulletPhysicsServer::get_empty_shape());
+void RigidBodyBullet::main_shape_changed() {
+ CRASH_COND(!get_main_shape())
+ btBody->setCollisionShape(get_main_shape());
set_continuous_collision_detection(is_continuous_collision_detection_enabled()); // Reset
}
@@ -333,7 +332,7 @@ void RigidBodyBullet::reload_body() {
void RigidBodyBullet::set_space(SpaceBullet *p_space) {
// Clear the old space if there is one
if (space) {
- isTransformChanged = false;
+ can_integrate_forces = false;
// Remove all eventual constraints
assert_no_constraints();
@@ -350,8 +349,8 @@ void RigidBodyBullet::set_space(SpaceBullet *p_space) {
}
void RigidBodyBullet::dispatch_callbacks() {
- /// The check isTransformChanged 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 && isTransformChanged) {
+ /// The check isFirstTransformChanged is necessary in order to call integrated forces only when the first transform is sent
+ if ((btBody->isKinematicObject() || btBody->isActive() || previousActiveState != btBody->isActive()) && force_integration_callback && can_integrate_forces) {
if (omit_forces_integration)
btBody->clearForces();
@@ -400,10 +399,6 @@ void RigidBodyBullet::set_force_integration_callback(ObjectID p_id, const String
}
}
-void RigidBodyBullet::scratch() {
- isTransformChanged = true;
-}
-
void RigidBodyBullet::scratch_space_override_modificator() {
isScratchedSpaceOverrideModificator = true;
}
@@ -418,6 +413,11 @@ void RigidBodyBullet::on_collision_checker_start() {
collisionsCount = 0;
}
+void RigidBodyBullet::on_collision_checker_end() {
+ // Always true if active and not a static or kinematic body
+ isTransformChanged = btBody->isActive() && !btBody->isStaticOrKinematicObject();
+}
+
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) {
@@ -520,7 +520,7 @@ real_t RigidBodyBullet::get_param(PhysicsServer::BodyParameter p_param) const {
void RigidBodyBullet::set_mode(PhysicsServer::BodyMode p_mode) {
// This is necessary to block force_integration untile next move
- isTransformChanged = false;
+ can_integrate_forces = false;
destroy_kinematic_utilities();
// The mode change is relevant to its mass
switch (p_mode) {
@@ -777,8 +777,7 @@ void RigidBodyBullet::set_transform__bullet(const btTransform &p_global_transfor
// The kinematic use MotionState class
godotMotionState->moveBody(p_global_transform);
}
- btBody->setWorldTransform(p_global_transform);
- scratch();
+ CollisionObjectBullet::set_transform__bullet(p_global_transform);
}
const btTransform &RigidBodyBullet::get_transform__bullet() const {
@@ -791,8 +790,8 @@ const btTransform &RigidBodyBullet::get_transform__bullet() const {
}
}
-void RigidBodyBullet::on_shapes_changed() {
- RigidCollisionObjectBullet::on_shapes_changed();
+void RigidBodyBullet::reload_shapes() {
+ RigidCollisionObjectBullet::reload_shapes();
const btScalar invMass = btBody->getInvMass();
const btScalar mass = invMass == 0 ? 0 : 1 / invMass;
@@ -987,6 +986,11 @@ void RigidBodyBullet::reload_kinematic_shapes() {
kinematic_utilities->copyAllOwnerShapes();
}
+void RigidBodyBullet::notify_transform_changed() {
+ RigidCollisionObjectBullet::notify_transform_changed();
+ can_integrate_forces = true;
+}
+
void RigidBodyBullet::_internal_set_mass(real_t p_mass) {
btVector3 localInertia(0, 0, 0);
diff --git a/modules/bullet/rigid_body_bullet.h b/modules/bullet/rigid_body_bullet.h
index 25dac30951..26e5018c87 100644
--- a/modules/bullet/rigid_body_bullet.h
+++ b/modules/bullet/rigid_body_bullet.h
@@ -202,6 +202,7 @@ private:
real_t angularDamp;
bool can_sleep;
bool omit_forces_integration;
+ bool can_integrate_forces;
Vector<CollisionData> collisions;
// these parameters are used to avoid vector resize
@@ -216,7 +217,6 @@ private:
int countGravityPointSpaces;
bool isScratchedSpaceOverrideModificator;
- bool isTransformChanged;
bool previousActiveState; // Last check state
ForceIntegrationCallback *force_integration_callback;
@@ -231,17 +231,18 @@ public:
_FORCE_INLINE_ btRigidBody *get_bt_rigid_body() { return btBody; }
- virtual void main_shape_resetted();
+ virtual void main_shape_changed();
virtual void reload_body();
virtual void set_space(SpaceBullet *p_space);
virtual void dispatch_callbacks();
void set_force_integration_callback(ObjectID p_id, const StringName &p_method, const Variant &p_udata = Variant());
- void scratch();
void scratch_space_override_modificator();
virtual void on_collision_filters_change();
virtual void on_collision_checker_start();
+ virtual void on_collision_checker_end();
+
void set_max_collisions_detection(int p_maxCollisionsDetection) {
maxCollisionsDetection = p_maxCollisionsDetection;
collisions.resize(p_maxCollisionsDetection);
@@ -302,7 +303,7 @@ public:
virtual void set_transform__bullet(const btTransform &p_global_transform);
virtual const btTransform &get_transform__bullet() const;
- virtual void on_shapes_changed();
+ virtual void reload_shapes();
virtual void on_enter_area(AreaBullet *p_area);
virtual void on_exit_area(AreaBullet *p_area);
@@ -311,6 +312,8 @@ public:
/// Kinematic
void reload_kinematic_shapes();
+ virtual void notify_transform_changed();
+
private:
void _internal_set_mass(real_t p_mass);
};
diff --git a/modules/bullet/shape_bullet.cpp b/modules/bullet/shape_bullet.cpp
index 4a2263407c..8bb621a863 100644
--- a/modules/bullet/shape_bullet.cpp
+++ b/modules/bullet/shape_bullet.cpp
@@ -34,6 +34,7 @@
#include "bullet_physics_server.h"
#include "bullet_types_converter.h"
#include "bullet_utilities.h"
+#include "core/project_settings.h"
#include "shape_owner_bullet.h"
#include <BulletCollision/CollisionDispatch/btInternalEdgeUtility.h>
@@ -64,7 +65,8 @@ btCollisionShape *ShapeBullet::prepare(btCollisionShape *p_btShape) const {
void ShapeBullet::notifyShapeChanged() {
for (Map<ShapeOwnerBullet *, int>::Element *E = owners.front(); E; E = E->next()) {
- static_cast<ShapeOwnerBullet *>(E->key())->on_shape_changed(this);
+ ShapeOwnerBullet *owner = static_cast<ShapeOwnerBullet *>(E->key());
+ owner->shape_changed(owner->find_shape(this));
}
}
@@ -400,18 +402,22 @@ void ConcavePolygonShapeBullet::setup(PoolVector<Vector3> p_faces) {
btVector3 supVec_1;
btVector3 supVec_2;
for (int i = 0; i < src_face_count; ++i) {
- G_TO_B(facesr[i * 3], supVec_0);
+ G_TO_B(facesr[i * 3 + 0], supVec_0);
G_TO_B(facesr[i * 3 + 1], supVec_1);
G_TO_B(facesr[i * 3 + 2], supVec_2);
- shapeInterface->addTriangle(supVec_0, supVec_1, supVec_2);
+ // Inverted from standard godot otherwise btGenerateInternalEdgeInfo generates wrong edge info
+ shapeInterface->addTriangle(supVec_2, supVec_1, supVec_0);
}
const bool useQuantizedAabbCompression = true;
meshShape = bulletnew(btBvhTriangleMeshShape(shapeInterface, useQuantizedAabbCompression));
- btTriangleInfoMap *triangleInfoMap = new btTriangleInfoMap();
- btGenerateInternalEdgeInfo(meshShape, triangleInfoMap);
+
+ if (GLOBAL_DEF("physics/3d/smooth_trimesh_collision", false)) {
+ btTriangleInfoMap *triangleInfoMap = new btTriangleInfoMap();
+ btGenerateInternalEdgeInfo(meshShape, triangleInfoMap);
+ }
} else {
meshShape = NULL;
ERR_PRINT("The faces count are 0, the mesh shape cannot be created");
@@ -426,6 +432,7 @@ btCollisionShape *ConcavePolygonShapeBullet::create_bt_shape(const btVector3 &p_
cs = ShapeBullet::create_shape_empty();
cs->setLocalScaling(p_implicit_scale);
prepare(cs);
+ cs->setMargin(0);
return cs;
}
diff --git a/modules/bullet/shape_owner_bullet.h b/modules/bullet/shape_owner_bullet.h
index 29d42d12f2..72ddbc482c 100644
--- a/modules/bullet/shape_owner_bullet.h
+++ b/modules/bullet/shape_owner_bullet.h
@@ -45,11 +45,10 @@ class CollisionObjectBullet;
/// E.G. BodyShape is a child of this
class ShapeOwnerBullet {
public:
- /// This is used to set new shape or replace existing
- //virtual void _internal_replaceShape(btCollisionShape *p_old_shape, btCollisionShape *p_new_shape) = 0;
- virtual void on_shape_changed(const ShapeBullet *const p_shape) = 0;
- virtual void on_shapes_changed() = 0;
- virtual void remove_shape(class ShapeBullet *p_shape) = 0;
+ virtual int find_shape(ShapeBullet *p_shape) const = 0;
+ virtual void shape_changed(int p_shape_index) = 0;
+ virtual void reload_shapes() = 0;
+ virtual void remove_shape_full(class ShapeBullet *p_shape) = 0;
virtual ~ShapeOwnerBullet() {}
};
#endif
diff --git a/modules/bullet/soft_body_bullet.cpp b/modules/bullet/soft_body_bullet.cpp
index f373ce5db4..94f350210f 100644
--- a/modules/bullet/soft_body_bullet.cpp
+++ b/modules/bullet/soft_body_bullet.cpp
@@ -72,12 +72,6 @@ void SoftBodyBullet::set_space(SpaceBullet *p_space) {
}
}
-void SoftBodyBullet::dispatch_callbacks() {}
-
-void SoftBodyBullet::on_collision_filters_change() {}
-
-void SoftBodyBullet::on_collision_checker_start() {}
-
void SoftBodyBullet::on_enter_area(AreaBullet *p_area) {}
void SoftBodyBullet::on_exit_area(AreaBullet *p_area) {}
diff --git a/modules/bullet/soft_body_bullet.h b/modules/bullet/soft_body_bullet.h
index c775193584..d04bfca046 100644
--- a/modules/bullet/soft_body_bullet.h
+++ b/modules/bullet/soft_body_bullet.h
@@ -91,9 +91,10 @@ public:
virtual void reload_body();
virtual void set_space(SpaceBullet *p_space);
- virtual void dispatch_callbacks();
- virtual void on_collision_filters_change();
- virtual void on_collision_checker_start();
+ virtual void dispatch_callbacks() {}
+ virtual void on_collision_filters_change() {}
+ virtual void on_collision_checker_start() {}
+ virtual void on_collision_checker_end() {}
virtual void on_enter_area(AreaBullet *p_area);
virtual void on_exit_area(AreaBullet *p_area);
diff --git a/modules/bullet/space_bullet.cpp b/modules/bullet/space_bullet.cpp
index ba4c72f4c7..ab2d1781ad 100644
--- a/modules/bullet/space_bullet.cpp
+++ b/modules/bullet/space_bullet.cpp
@@ -175,7 +175,7 @@ bool BulletPhysicsDirectSpaceState::cast_motion(const RID &p_shape, const Transf
btResult.m_collisionFilterGroup = 0;
btResult.m_collisionFilterMask = p_collision_mask;
- space->dynamicsWorld->convexSweepTest(bt_convex_shape, bt_xform_from, bt_xform_to, btResult, 0.002);
+ space->dynamicsWorld->convexSweepTest(bt_convex_shape, bt_xform_from, bt_xform_to, btResult, space->dynamicsWorld->getDispatchInfo().m_allowedCcdPenetration);
r_closest_unsafe = 1.0;
r_closest_safe = 1.0;
@@ -540,17 +540,20 @@ void onBulletPreTickCallback(btDynamicsWorld *p_dynamicsWorld, btScalar timeStep
void onBulletTickCallback(btDynamicsWorld *p_dynamicsWorld, btScalar timeStep) {
- // Notify all Collision objects the collision checker is started
const btCollisionObjectArray &colObjArray = p_dynamicsWorld->getCollisionObjectArray();
+
+ // Notify all Collision objects the collision checker is started
for (int i = colObjArray.size() - 1; 0 <= i; --i) {
- CollisionObjectBullet *colObj = static_cast<CollisionObjectBullet *>(colObjArray[i]->getUserPointer());
- assert(NULL != colObj);
- colObj->on_collision_checker_start();
+ static_cast<CollisionObjectBullet *>(colObjArray[i]->getUserPointer())->on_collision_checker_start();
}
SpaceBullet *sb = static_cast<SpaceBullet *>(p_dynamicsWorld->getWorldUserInfo());
sb->check_ghost_overlaps();
sb->check_body_collision();
+
+ for (int i = colObjArray.size() - 1; 0 <= i; --i) {
+ static_cast<CollisionObjectBullet *>(colObjArray[i]->getUserPointer())->on_collision_checker_end();
+ }
}
BulletPhysicsDirectSpaceState *SpaceBullet::get_direct_state() {
@@ -571,7 +574,6 @@ void SpaceBullet::create_empty_world(bool p_create_soft_world) {
gjk_epa_pen_solver = bulletnew(btGjkEpaPenetrationDepthSolver);
gjk_simplex_solver = bulletnew(btVoronoiSimplexSolver);
- gjk_simplex_solver->setEqualVertexThreshold(0.f);
void *world_mem;
if (p_create_soft_world) {
@@ -650,7 +652,6 @@ void SpaceBullet::check_ghost_overlaps() {
btConvexShape *area_shape;
btGjkPairDetector::ClosestPointInput gjk_input;
AreaBullet *area;
- RigidCollisionObjectBullet *otherObject;
int x(-1), i(-1), y(-1), z(-1), indexOverlap(-1);
/// For each areas
@@ -677,13 +678,17 @@ void SpaceBullet::check_ghost_overlaps() {
// For each overlapping
for (i = ghostOverlaps.size() - 1; 0 <= i; --i) {
- if (ghostOverlaps[i]->getUserIndex() == CollisionObjectBullet::TYPE_AREA) {
- if (!static_cast<AreaBullet *>(ghostOverlaps[i]->getUserPointer())->is_monitorable())
- continue;
- } else if (ghostOverlaps[i]->getUserIndex() != CollisionObjectBullet::TYPE_RIGID_BODY)
+ btCollisionObject *overlapped_bt_co = ghostOverlaps[i];
+ RigidCollisionObjectBullet *otherObject = static_cast<RigidCollisionObjectBullet *>(overlapped_bt_co->getUserPointer());
+
+ if (!area->is_transform_changed() && !otherObject->is_transform_changed())
continue;
- otherObject = static_cast<RigidCollisionObjectBullet *>(ghostOverlaps[i]->getUserPointer());
+ if (overlapped_bt_co->getUserIndex() == CollisionObjectBullet::TYPE_AREA) {
+ if (!static_cast<AreaBullet *>(overlapped_bt_co->getUserPointer())->is_monitorable())
+ continue;
+ } else if (overlapped_bt_co->getUserIndex() != CollisionObjectBullet::TYPE_RIGID_BODY)
+ continue;
bool hasOverlap = false;
diff --git a/modules/csg/csg.cpp b/modules/csg/csg.cpp
index 567485c2c7..88f3c0338a 100644
--- a/modules/csg/csg.cpp
+++ b/modules/csg/csg.cpp
@@ -750,7 +750,7 @@ void CSGBrushOperation::_add_poly_outline(const BuildPoly &p_poly, int p_from_po
t2d.affine_invert();
- float max_angle;
+ float max_angle = 0;
int next_point_angle = -1;
for (int i = 0; i < vertex_process[to_point].size(); i++) {
@@ -805,7 +805,7 @@ void CSGBrushOperation::_merge_poly(MeshMerge &mesh, int p_face_idx, const Build
//process points that were not processed
for (int i = 0; i < edge_process.size(); i++) {
- if (edge_process[i] == true)
+ if (edge_process[i])
continue; //already processed
int intersect_poly = -1;
diff --git a/modules/csg/csg_shape.cpp b/modules/csg/csg_shape.cpp
index 714be16db7..44044d2750 100644
--- a/modules/csg/csg_shape.cpp
+++ b/modules/csg/csg_shape.cpp
@@ -521,6 +521,11 @@ CSGBrush *CSGMesh::_build_brush() {
Array arrays = mesh->surface_get_arrays(i);
+ if (arrays.size() == 0) {
+ _make_dirty();
+ ERR_FAIL_COND_V(arrays.size() == 0, NULL);
+ }
+
PoolVector<Vector3> avertices = arrays[Mesh::ARRAY_VERTEX];
if (avertices.size() == 0)
continue;
@@ -1573,7 +1578,7 @@ CSGBrush *CSGPolygon::_build_brush() {
}
CSGBrush *brush = memnew(CSGBrush);
- int face_count;
+ int face_count = 0;
switch (mode) {
case MODE_DEPTH: face_count = triangles.size() * 2 / 3 + (final_polygon.size()) * 2; break;
diff --git a/modules/enet/doc_classes/NetworkedMultiplayerENet.xml b/modules/enet/doc_classes/NetworkedMultiplayerENet.xml
index 76c551e8d7..6d990f6f6f 100644
--- a/modules/enet/doc_classes/NetworkedMultiplayerENet.xml
+++ b/modules/enet/doc_classes/NetworkedMultiplayerENet.xml
@@ -76,7 +76,7 @@
<return type="int">
</return>
<description>
- Returns the channel of the next packet that will be retrieved via [method PacketPeer.get_packet_peer]
+ Returns the channel of the next packet that will be retrieved via [method PacketPeer.get_packet]
</description>
</method>
<method name="get_peer_address" qualifiers="const">
diff --git a/modules/gdnative/nativescript/api_generator.cpp b/modules/gdnative/nativescript/api_generator.cpp
index 0983c12619..8c6dace847 100644
--- a/modules/gdnative/nativescript/api_generator.cpp
+++ b/modules/gdnative/nativescript/api_generator.cpp
@@ -292,6 +292,7 @@ List<ClassAPI> generate_c_api_classes() {
method_api.has_varargs = method_bind && method_bind->is_vararg();
// Method flags
+ method_api.is_virtual = false;
if (method_info.flags) {
const uint32_t flags = method_info.flags;
method_api.is_editor = flags & METHOD_FLAG_EDITOR;
diff --git a/modules/gdnative/nativescript/nativescript.cpp b/modules/gdnative/nativescript/nativescript.cpp
index 641e4021d8..3e56275396 100644
--- a/modules/gdnative/nativescript/nativescript.cpp
+++ b/modules/gdnative/nativescript/nativescript.cpp
@@ -1016,6 +1016,16 @@ NativeScriptLanguage::NativeScriptLanguage() {
#ifdef DEBUG_ENABLED
profiling = false;
#endif
+
+ _init_call_type = "nativescript_init";
+ _init_call_name = "nativescript_init";
+ _terminate_call_name = "nativescript_terminate";
+ _noarg_call_type = "nativescript_no_arg";
+ _frame_call_name = "nativescript_frame";
+#ifndef NO_THREADS
+ _thread_enter_call_name = "nativescript_thread_enter";
+ _thread_exit_call_name = "nativescript_thread_exit";
+#endif
}
NativeScriptLanguage::~NativeScriptLanguage() {
@@ -1701,8 +1711,7 @@ void NativeReloadNode::_notification(int p_what) {
}
RES ResourceFormatLoaderNativeScript::load(const String &p_path, const String &p_original_path, Error *r_error) {
- ResourceFormatLoaderText rsflt;
- return rsflt.load(p_path, p_original_path, r_error);
+ return ResourceFormatLoaderText::singleton->load(p_path, p_original_path, r_error);
}
void ResourceFormatLoaderNativeScript::get_recognized_extensions(List<String> *p_extensions) const {
diff --git a/modules/gdnative/nativescript/nativescript.h b/modules/gdnative/nativescript/nativescript.h
index ade8ffd280..51370f5fbf 100644
--- a/modules/gdnative/nativescript/nativescript.h
+++ b/modules/gdnative/nativescript/nativescript.h
@@ -277,18 +277,14 @@ public:
Map<String, Set<NativeScript *> > library_script_users;
- const StringName _init_call_type = "nativescript_init";
- const StringName _init_call_name = "nativescript_init";
-
- const StringName _terminate_call_name = "nativescript_terminate";
-
- const StringName _noarg_call_type = "nativescript_no_arg";
-
- const StringName _frame_call_name = "nativescript_frame";
-
+ StringName _init_call_type;
+ StringName _init_call_name;
+ StringName _terminate_call_name;
+ StringName _noarg_call_type;
+ StringName _frame_call_name;
#ifndef NO_THREADS
- const StringName _thread_enter_call_name = "nativescript_thread_enter";
- const StringName _thread_exit_call_name = "nativescript_thread_exit";
+ StringName _thread_enter_call_name;
+ StringName _thread_exit_call_name;
#endif
NativeScriptLanguage();
@@ -372,11 +368,14 @@ inline NativeScriptDesc *NativeScript::get_script_desc() const {
class NativeReloadNode : public Node {
GDCLASS(NativeReloadNode, Node)
- bool unloaded = false;
+ bool unloaded;
public:
static void _bind_methods();
void _notification(int p_what);
+
+ NativeReloadNode() :
+ unloaded(false) {}
};
class ResourceFormatLoaderNativeScript : public ResourceFormatLoader {
diff --git a/modules/gdscript/editor/gdscript_highlighter.cpp b/modules/gdscript/editor/gdscript_highlighter.cpp
index c199667270..e4aee842ba 100644
--- a/modules/gdscript/editor/gdscript_highlighter.cpp
+++ b/modules/gdscript/editor/gdscript_highlighter.cpp
@@ -72,6 +72,7 @@ Map<int, TextEdit::HighlighterInfo> GDScriptSyntaxHighlighter::_get_line_syntax_
bool in_word = false;
bool in_function_name = false;
bool in_variable_declaration = false;
+ bool in_function_args = false;
bool in_member_variable = false;
bool in_node_path = false;
bool is_hex_notation = false;
@@ -220,17 +221,24 @@ Map<int, TextEdit::HighlighterInfo> GDScriptSyntaxHighlighter::_get_line_syntax_
}
if (is_symbol) {
- in_function_name = false;
- in_member_variable = false;
- if (expect_type && str[j] != ' ' && str[j] != '\t' && str[j] != ':') {
+ if (in_function_name) {
+ in_function_args = true;
+ }
+
+ if (in_function_args && str[j] == ')') {
+ in_function_args = false;
+ }
+
+ if (expect_type && prev_is_char) {
expect_type = false;
}
+
if (j > 0 && str[j] == '>' && str[j - 1] == '-') {
expect_type = true;
}
- if (in_variable_declaration || previous_text == "(" || previous_text == ",") {
+ if (in_variable_declaration || in_function_args) {
int k = j;
// Skip space
while (k < str.length() && (str[k] == '\t' || str[k] == ' ')) {
@@ -244,6 +252,8 @@ Map<int, TextEdit::HighlighterInfo> GDScriptSyntaxHighlighter::_get_line_syntax_
}
in_variable_declaration = false;
+ in_function_name = false;
+ in_member_variable = false;
}
if (!in_node_path && in_region == -1 && str[j] == '$') {
diff --git a/modules/gdscript/gdscript_compiler.cpp b/modules/gdscript/gdscript_compiler.cpp
index 310c4e21f2..45319c59e7 100644
--- a/modules/gdscript/gdscript_compiler.cpp
+++ b/modules/gdscript/gdscript_compiler.cpp
@@ -1603,13 +1603,13 @@ Error GDScriptCompiler::_parse_block(CodeGen &codegen, const GDScriptParser::Blo
return OK;
}
-Error GDScriptCompiler::_parse_function(GDScript *p_script, const GDScriptParser::ClassNode *p_class, const GDScriptParser::FunctionNode *p_func, bool p_for_ready) {
+Error GDScriptCompiler::_parse_function(Ref<GDScript> p_script, const GDScriptParser::ClassNode *p_class, const GDScriptParser::FunctionNode *p_func, bool p_for_ready) {
Vector<int> bytecode;
CodeGen codegen;
codegen.class_node = p_class;
- codegen.script = p_script;
+ codegen.script = p_script.ptr();
codegen.function_node = p_func;
codegen.stack_max = 0;
codegen.current_line = 0;
@@ -1853,7 +1853,7 @@ Error GDScriptCompiler::_parse_function(GDScript *p_script, const GDScriptParser
return OK;
}
-Error GDScriptCompiler::_parse_class_level(GDScript *p_script, GDScript *p_owner, const GDScriptParser::ClassNode *p_class, bool p_keep_state) {
+Error GDScriptCompiler::_parse_class_level(Ref<GDScript> p_script, Ref<GDScript> p_owner, const GDScriptParser::ClassNode *p_class, bool p_keep_state) {
if (p_class->owner && p_class->owner->owner) {
// Owner is not root
@@ -1887,7 +1887,7 @@ Error GDScriptCompiler::_parse_class_level(GDScript *p_script, GDScript *p_owner
p_script->initializer = NULL;
p_script->subclasses.clear();
- p_script->_owner = p_owner;
+ p_script->_owner = p_owner.ptr();
p_script->tool = p_class->tool;
p_script->name = p_class->name;
@@ -1994,7 +1994,7 @@ Error GDScriptCompiler::_parse_class_level(GDScript *p_script, GDScript *p_owner
StringName name = p_class->_signals[i].name;
- GDScript *c = p_script;
+ GDScript *c = p_script.ptr();
while (c) {
@@ -2054,7 +2054,7 @@ Error GDScriptCompiler::_parse_class_level(GDScript *p_script, GDScript *p_owner
return OK;
}
-Error GDScriptCompiler::_parse_class_blocks(GDScript *p_script, const GDScriptParser::ClassNode *p_class, bool p_keep_state) {
+Error GDScriptCompiler::_parse_class_blocks(Ref<GDScript> p_script, const GDScriptParser::ClassNode *p_class, bool p_keep_state) {
//parse methods
bool has_initializer = false;
@@ -2159,7 +2159,7 @@ Error GDScriptCompiler::_parse_class_blocks(GDScript *p_script, const GDScriptPa
return OK;
}
-void GDScriptCompiler::_make_scripts(const GDScript *p_script, const GDScriptParser::ClassNode *p_class, bool p_keep_state) {
+void GDScriptCompiler::_make_scripts(const Ref<GDScript> p_script, const GDScriptParser::ClassNode *p_class, bool p_keep_state) {
Map<StringName, Ref<GDScript> > old_subclasses;
@@ -2178,20 +2178,20 @@ void GDScriptCompiler::_make_scripts(const GDScript *p_script, const GDScriptPar
subclass.instance();
}
- subclass->_owner = const_cast<GDScript *>(p_script);
+ subclass->_owner = const_cast<GDScript *>(p_script.ptr());
class_map.insert(name, subclass);
_make_scripts(subclass.ptr(), p_class->subclasses[i], p_keep_state);
}
}
-Error GDScriptCompiler::compile(const GDScriptParser *p_parser, GDScript *p_script, bool p_keep_state) {
+Error GDScriptCompiler::compile(const GDScriptParser *p_parser, Ref<GDScript> p_script, bool p_keep_state) {
err_line = -1;
err_column = -1;
error = "";
parser = p_parser;
- main_script = p_script;
+ main_script = p_script.ptr();
const GDScriptParser::Node *root = parser->get_parse_tree();
ERR_FAIL_COND_V(root->type != GDScriptParser::Node::TYPE_CLASS, ERR_INVALID_DATA);
diff --git a/modules/gdscript/gdscript_compiler.h b/modules/gdscript/gdscript_compiler.h
index 55f5e2b48e..23c6450aa7 100644
--- a/modules/gdscript/gdscript_compiler.h
+++ b/modules/gdscript/gdscript_compiler.h
@@ -148,17 +148,17 @@ class GDScriptCompiler {
int _parse_assign_right_expression(CodeGen &codegen, const GDScriptParser::OperatorNode *p_expression, int p_stack_level);
int _parse_expression(CodeGen &codegen, const GDScriptParser::Node *p_expression, int p_stack_level, bool p_root = false, bool p_initializer = false);
Error _parse_block(CodeGen &codegen, const GDScriptParser::BlockNode *p_block, int p_stack_level = 0, int p_break_addr = -1, int p_continue_addr = -1);
- Error _parse_function(GDScript *p_script, const GDScriptParser::ClassNode *p_class, const GDScriptParser::FunctionNode *p_func, bool p_for_ready = false);
- Error _parse_class_level(GDScript *p_script, GDScript *p_owner, const GDScriptParser::ClassNode *p_class, bool p_keep_state);
- Error _parse_class_blocks(GDScript *p_script, const GDScriptParser::ClassNode *p_class, bool p_keep_state);
- void _make_scripts(const GDScript *p_script, const GDScriptParser::ClassNode *p_class, bool p_keep_state);
+ Error _parse_function(Ref<GDScript> p_script, const GDScriptParser::ClassNode *p_class, const GDScriptParser::FunctionNode *p_func, bool p_for_ready = false);
+ Error _parse_class_level(Ref<GDScript> p_script, Ref<GDScript> p_owner, const GDScriptParser::ClassNode *p_class, bool p_keep_state);
+ Error _parse_class_blocks(Ref<GDScript> p_script, const GDScriptParser::ClassNode *p_class, bool p_keep_state);
+ void _make_scripts(const Ref<GDScript> p_script, const GDScriptParser::ClassNode *p_class, bool p_keep_state);
int err_line;
int err_column;
StringName source;
String error;
public:
- Error compile(const GDScriptParser *p_parser, GDScript *p_script, bool p_keep_state = false);
+ Error compile(const GDScriptParser *p_parser, Ref<GDScript> p_script, bool p_keep_state = false);
String get_error() const;
int get_error_line() const;
diff --git a/modules/gdscript/gdscript_function.cpp b/modules/gdscript/gdscript_function.cpp
index 8088dcf17d..31115a4bd9 100644
--- a/modules/gdscript/gdscript_function.cpp
+++ b/modules/gdscript/gdscript_function.cpp
@@ -275,7 +275,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
#endif
uint32_t alloca_size = 0;
- GDScript *_class;
+ GDScript *script;
int ip = 0;
int line = _initial_line;
@@ -286,7 +286,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
line = p_state->line;
ip = p_state->ip;
alloca_size = p_state->stack.size();
- _class = p_state->_class;
+ script = p_state->script.ptr();
p_instance = p_state->instance;
defarg = p_state->defarg;
self = p_state->self;
@@ -368,9 +368,9 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
} else {
self = p_instance->owner;
}
- _class = p_instance->script.ptr();
+ script = p_instance->script.ptr();
} else {
- _class = _script;
+ script = this->_script.ptr();
}
}
@@ -395,7 +395,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
#define GET_VARIANT_PTR(m_v, m_code_ofs) \
Variant *m_v; \
- m_v = _get_variant(_code_ptr[ip + m_code_ofs], p_instance, _class, self, stack, err_text); \
+ m_v = _get_variant(_code_ptr[ip + m_code_ofs], p_instance, script, self, stack, err_text); \
if (unlikely(!m_v)) \
OPCODE_BREAK;
@@ -404,7 +404,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
#define CHECK_SPACE(m_space)
#define GET_VARIANT_PTR(m_v, m_code_ofs) \
Variant *m_v; \
- m_v = _get_variant(_code_ptr[ip + m_code_ofs], p_instance, _class, self, stack, err_text);
+ m_v = _get_variant(_code_ptr[ip + m_code_ofs], p_instance, script, self, stack, err_text);
#endif
@@ -419,8 +419,8 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
profile.call_count++;
profile.frame_call_count++;
}
-#endif
bool exit_ok = false;
+#endif
#ifdef DEBUG_ENABLED
OPCODE_WHILE(ip < _code_size) {
@@ -673,13 +673,15 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
OPCODE(OPCODE_SET_MEMBER) {
CHECK_SPACE(3);
-#ifdef DEBUG_ENABLED
int indexname = _code_ptr[ip + 1];
GD_ERR_BREAK(indexname < 0 || indexname >= _global_names_count);
const StringName *index = &_global_names_ptr[indexname];
GET_VARIANT_PTR(src, 2);
bool valid;
+#ifndef DEBUG_ENABLED
+ ClassDB::set_property(p_instance->owner, *index, *src, &valid);
+#else
bool ok = ClassDB::set_property(p_instance->owner, *index, *src, &valid);
if (!ok) {
err_text = "Internal error setting property: " + String(*index);
@@ -696,12 +698,14 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
OPCODE(OPCODE_GET_MEMBER) {
CHECK_SPACE(3);
-#ifdef DEBUG_ENABLED
int indexname = _code_ptr[ip + 1];
GD_ERR_BREAK(indexname < 0 || indexname >= _global_names_count);
const StringName *index = &_global_names_ptr[indexname];
GET_VARIANT_PTR(dst, 2);
+#ifndef DEBUG_ENABLED
+ ClassDB::get_property(p_instance->owner, *index, *dst);
+#else
bool ok = ClassDB::get_property(p_instance->owner, *index, *dst);
if (!ok) {
err_text = "Internal error getting property: " + String(*index);
@@ -779,11 +783,11 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
OPCODE(OPCODE_ASSIGN_TYPED_NATIVE) {
CHECK_SPACE(4);
- GET_VARIANT_PTR(type, 1);
GET_VARIANT_PTR(dst, 2);
GET_VARIANT_PTR(src, 3);
#ifdef DEBUG_ENABLED
+ GET_VARIANT_PTR(type, 1);
GDScriptNativeClass *nc = Object::cast_to<GDScriptNativeClass>(type->operator Object *());
GD_ERR_BREAK(!nc);
if (src->get_type() != Variant::OBJECT && src->get_type() != Variant::NIL) {
@@ -808,11 +812,11 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
OPCODE(OPCODE_ASSIGN_TYPED_SCRIPT) {
CHECK_SPACE(4);
- GET_VARIANT_PTR(type, 1);
GET_VARIANT_PTR(dst, 2);
GET_VARIANT_PTR(src, 3);
#ifdef DEBUG_ENABLED
+ GET_VARIANT_PTR(type, 1);
Script *base_type = Object::cast_to<Script>(type->operator Object *());
GD_ERR_BREAK(!base_type);
@@ -1181,7 +1185,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
GET_VARIANT_PTR(dst, argc + 3);
- const GDScript *gds = _script;
+ const GDScript *gds = _script.ptr();
const Map<StringName, GDScriptFunction *>::Element *E = NULL;
while (gds->base.ptr()) {
@@ -1252,11 +1256,10 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
gdfs->state.stack_size = _stack_size;
gdfs->state.self = self;
gdfs->state.alloca_size = alloca_size;
- gdfs->state._class = _class;
+ gdfs->state.script = _script;
gdfs->state.ip = ip + ipofs;
gdfs->state.line = line;
gdfs->state.instance_id = (p_instance && p_instance->get_owner()) ? p_instance->get_owner()->get_instance_id() : 0;
- gdfs->state.script_id = _class->get_instance_id();
//gdfs->state.result_pos=ip+ipofs-1;
gdfs->state.defarg = defarg;
gdfs->state.instance = p_instance;
@@ -1310,7 +1313,9 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
#endif
}
+#ifdef DEBUG_ENABLED
exit_ok = true;
+#endif
OPCODE_BREAK;
}
@@ -1387,7 +1392,9 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
CHECK_SPACE(2);
GET_VARIANT_PTR(r, 1);
retvalue = *r;
+#ifdef DEBUG_ENABLED
exit_ok = true;
+#endif
OPCODE_BREAK;
}
@@ -1459,9 +1466,9 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
OPCODE(OPCODE_ASSERT) {
CHECK_SPACE(2);
- GET_VARIANT_PTR(test, 1);
#ifdef DEBUG_ENABLED
+ GET_VARIANT_PTR(test, 1);
bool result = test->booleanize();
if (!result) {
@@ -1516,8 +1523,9 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
DISPATCH_OPCODE;
OPCODE(OPCODE_END) {
-
+#ifdef DEBUG_ENABLED
exit_ok = true;
+#endif
OPCODE_BREAK;
}
@@ -1540,8 +1548,8 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
String err_file;
if (p_instance)
err_file = p_instance->script->path;
- else if (_class)
- err_file = _class->path;
+ else if (script)
+ err_file = script->path;
if (err_file == "")
err_file = "<built-in>";
String err_func = name;
@@ -1756,15 +1764,20 @@ GDScriptFunction::~GDScriptFunction() {
Variant GDScriptFunctionState::_signal_callback(const Variant **p_args, int p_argcount, Variant::CallError &r_error) {
#ifdef DEBUG_ENABLED
- if (state.instance_id && !ObjectDB::get_instance(state.instance_id)) {
- ERR_EXPLAIN("Resumed after yield, but class instance is gone");
+ // Checking this first since it's faster
+ if (!state.script.is_valid()) {
+ ERR_EXPLAIN("Resumed after yield, but script is gone");
ERR_FAIL_V(Variant());
}
- if (state.script_id && !ObjectDB::get_instance(state.script_id)) {
- ERR_EXPLAIN("Resumed after yield, but script is gone");
+ if (state.instance_id && !ObjectDB::get_instance(state.instance_id)) {
+ ERR_EXPLAIN("Resumed after yield, but class instance is gone");
ERR_FAIL_V(Variant());
}
+#else
+ if (!is_valid()) {
+ return Variant();
+ }
#endif
Variant arg;
@@ -1832,12 +1845,12 @@ bool GDScriptFunctionState::is_valid(bool p_extended_check) const {
return false;
if (p_extended_check) {
+ //script gone? (checking this first since it's faster)
+ if (!state.script.is_valid())
+ return false;
//class instance gone?
if (state.instance_id && !ObjectDB::get_instance(state.instance_id))
return false;
- //script gone?
- if (state.script_id && !ObjectDB::get_instance(state.script_id))
- return false;
}
return true;
@@ -1847,13 +1860,14 @@ Variant GDScriptFunctionState::resume(const Variant &p_arg) {
ERR_FAIL_COND_V(!function, Variant());
#ifdef DEBUG_ENABLED
- if (state.instance_id && !ObjectDB::get_instance(state.instance_id)) {
- ERR_EXPLAIN("Resumed after yield, but class instance is gone");
+ // Checking this first since it's faster
+ if (!state.script.is_valid()) {
+ ERR_EXPLAIN("Resumed after yield, but script is gone");
ERR_FAIL_V(Variant());
}
- if (state.script_id && !ObjectDB::get_instance(state.script_id)) {
- ERR_EXPLAIN("Resumed after yield, but script is gone");
+ if (state.instance_id && !ObjectDB::get_instance(state.instance_id)) {
+ ERR_EXPLAIN("Resumed after yield, but class instance is gone");
ERR_FAIL_V(Variant());
}
#endif
diff --git a/modules/gdscript/gdscript_function.h b/modules/gdscript/gdscript_function.h
index bfb6d673f1..a47070de4f 100644
--- a/modules/gdscript/gdscript_function.h
+++ b/modules/gdscript/gdscript_function.h
@@ -225,7 +225,7 @@ private:
bool _static;
MultiplayerAPI::RPCMode rpc_mode;
- GDScript *_script;
+ Ref<GDScript> _script;
StringName name;
Vector<Variant> constants;
@@ -272,15 +272,13 @@ private:
public:
struct CallState {
- ObjectID instance_id; //by debug only
- ObjectID script_id;
-
+ ObjectID instance_id;
GDScriptInstance *instance;
Vector<uint8_t> stack;
int stack_size;
Variant self;
uint32_t alloca_size;
- GDScript *_class;
+ Ref<GDScript> script;
int ip;
int line;
int defarg;
@@ -299,7 +297,7 @@ public:
int get_default_argument_addr(int p_idx) const;
GDScriptDataType get_return_type() const;
GDScriptDataType get_argument_type(int p_idx) const;
- GDScript *get_script() const { return _script; }
+ GDScript *get_script() const { return const_cast<GDScript *>(_script.ptr()); }
StringName get_source() const { return source; }
void debug_get_stack_member_state(int p_line, List<Pair<StringName, int> > *r_stackvars) const;
diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp
index a79fcccaeb..97ac6f7de6 100644
--- a/modules/gdscript/gdscript_parser.cpp
+++ b/modules/gdscript/gdscript_parser.cpp
@@ -679,7 +679,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
if (tokenizer->get_token() == GDScriptTokenizer::TK_BUILT_IN_TYPE) {
Variant::Type ct = tokenizer->get_token_type();
- if (p_parsing_constant == false) {
+ if (!p_parsing_constant) {
if (ct == Variant::ARRAY) {
if (tokenizer->get_token(2) == GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
ArrayNode *arr = alloc_node<ArrayNode>();
@@ -6709,9 +6709,15 @@ GDScriptParser::DataType GDScriptParser::_reduce_function_call_type(const Operat
}
}
+ bool rets = false;
return_type.has_type = true;
return_type.kind = DataType::BUILTIN;
- return_type.builtin_type = Variant::get_method_return_type(base_type.builtin_type, callee_name);
+ return_type.builtin_type = Variant::get_method_return_type(base_type.builtin_type, callee_name, &rets);
+ // If the method returns, but it might return any type, (Variant::NIL), pretend we don't know the type.
+ // At least make sure we know that it returns
+ if (rets && return_type.builtin_type == Variant::NIL) {
+ return_type.has_type = false;
+ }
break;
}
diff --git a/modules/gdscript/gdscript_tokenizer.cpp b/modules/gdscript/gdscript_tokenizer.cpp
index 77e1b7290e..c37142b3c1 100644
--- a/modules/gdscript/gdscript_tokenizer.cpp
+++ b/modules/gdscript/gdscript_tokenizer.cpp
@@ -128,8 +128,8 @@ const char *GDScriptTokenizer::token_names[TK_MAX] = {
"'.'",
"'?'",
"':'",
- "'->'",
"'$'",
+ "'->'",
"'\\n'",
"PI",
"TAU",
diff --git a/modules/mono/SCsub b/modules/mono/SCsub
index 1d5c145027..9a62b0fdc9 100644
--- a/modules/mono/SCsub
+++ b/modules/mono/SCsub
@@ -88,9 +88,6 @@ vars.Update(env_mono)
if env_mono['mono_glue']:
env_mono.Append(CPPDEFINES=['MONO_GLUE_ENABLED'])
-if ARGUMENTS.get('yolo_copy', False):
- env_mono.Append(CPPDEFINES=['YOLO_COPY'])
-
# Configure TLS checks
import tls_configure
@@ -244,16 +241,13 @@ def mono_build_solution(source, target, env):
copyfile(os.path.join(src_dir, asm_file), os.path.join(dst_dir, asm_file))
-output_dir = Dir('#bin').abspath
-assemblies_output_dir = Dir(env['mono_assemblies_output_dir']).abspath
-
-mono_sln_builder = Builder(action=mono_build_solution)
-env_mono.Append(BUILDERS={'MonoBuildSolution': mono_sln_builder})
-env_mono.MonoBuildSolution(
- os.path.join(assemblies_output_dir, 'GodotSharpTools.dll'),
- 'editor/GodotSharpTools/GodotSharpTools.sln'
-)
-
-if os.path.normpath(output_dir) != os.path.normpath(assemblies_output_dir):
- rel_assemblies_output_dir = os.path.relpath(assemblies_output_dir, output_dir)
- env_mono.Append(CPPDEFINES={'GD_MONO_EDITOR_ASSEMBLIES_DIR': rel_assemblies_output_dir})
+if env['tools']:
+ output_dir = Dir('#bin').abspath
+ editor_tools_dir = os.path.join(output_dir, 'GodotSharp', 'Tools')
+
+ mono_sln_builder = Builder(action=mono_build_solution)
+ env_mono.Append(BUILDERS={'MonoBuildSolution': mono_sln_builder})
+ env_mono.MonoBuildSolution(
+ os.path.join(editor_tools_dir, 'GodotSharpTools.dll'),
+ 'editor/GodotSharpTools/GodotSharpTools.sln'
+ )
diff --git a/modules/mono/config.py b/modules/mono/config.py
index 01649a972e..8427103ee7 100644
--- a/modules/mono/config.py
+++ b/modules/mono/config.py
@@ -5,7 +5,7 @@ import sys
import subprocess
from distutils.version import LooseVersion
-from SCons.Script import BoolVariable, Dir, Environment, File, PathVariable, SCons, Variables
+from SCons.Script import BoolVariable, Dir, Environment, File, SCons, Variables
monoreg = imp.load_source('mono_reg_utils', 'modules/mono/mono_reg_utils.py')
@@ -55,30 +55,20 @@ def copy_file(src_dir, dst_dir, name):
copyfile(src_path, dst_path)
-def custom_path_is_dir_create(key, val, env):
- """Validator to check if Path is a directory, creating it if it does not exist.
- Similar to PathIsDirCreate, except it uses SCons.Script.Dir() and
- SCons.Script.File() in order to support the '#' top level directory token.
- """
- # Dir constructor will throw an error if the path points to a file
- fsDir = Dir(val)
- if not fsDir.exists:
- os.makedirs(fsDir.abspath)
-
-
def configure(env):
env.use_ptrcall = True
env.add_module_version_string('mono')
envvars = Variables()
envvars.Add(BoolVariable('mono_static', 'Statically link mono', False))
- envvars.Add(PathVariable('mono_assemblies_output_dir', 'Path to the assemblies output directory', '#bin', custom_path_is_dir_create))
+ envvars.Add(BoolVariable('copy_mono_root', 'Make a copy of the mono installation directory to bundle with the editor', False))
envvars.Update(env)
bits = env['bits']
+ tools_enabled = env['tools']
mono_static = env['mono_static']
- assemblies_output_dir = Dir(env['mono_assemblies_output_dir']).abspath
+ copy_mono_root = env['copy_mono_root']
mono_lib_names = ['mono-2.0-sgen', 'monosgen-2.0']
@@ -151,8 +141,6 @@ def configure(env):
raise RuntimeError('Could not find mono shared library in: ' + mono_bin_path)
copy_file(mono_bin_path, 'bin', mono_dll_name + '.dll')
-
- copy_file(os.path.join(mono_lib_path, 'mono', '4.5'), assemblies_output_dir, 'mscorlib.dll')
else:
sharedlib_ext = '.dylib' if sys.platform == 'darwin' else '.so'
@@ -204,16 +192,14 @@ def configure(env):
if sys.platform == 'darwin':
env.Append(LINKFLAGS=['-Wl,-force_load,' + mono_lib_file])
- elif sys.platform == 'linux' or sys.platform == 'linux2':
- env.Append(LINKFLAGS=['-Wl,-whole-archive', mono_lib_file, '-Wl,-no-whole-archive'])
else:
- raise RuntimeError('mono-static: Not supported on this platform')
+ env.Append(LINKFLAGS=['-Wl,-whole-archive', mono_lib_file, '-Wl,-no-whole-archive'])
else:
env.Append(LIBS=[mono_lib])
if sys.platform == 'darwin':
env.Append(LIBS=['iconv', 'pthread'])
- elif sys.platform == 'linux' or sys.platform == 'linux2':
+ else:
env.Append(LIBS=['m', 'rt', 'dl', 'pthread'])
if not mono_static:
@@ -223,8 +209,6 @@ def configure(env):
raise RuntimeError('Could not find mono shared library in: ' + mono_lib_path)
copy_file(mono_lib_path, 'bin', 'lib' + mono_so_name + sharedlib_ext)
-
- copy_file(os.path.join(mono_lib_path, 'mono', '4.5'), assemblies_output_dir, 'mscorlib.dll')
else:
assert not mono_static
@@ -238,7 +222,6 @@ def configure(env):
mono_lib_path = ''
mono_so_name = ''
- mono_prefix = subprocess.check_output(['pkg-config', 'mono-2', '--variable=prefix']).decode('utf8').strip()
tmpenv = Environment()
tmpenv.AppendENVPath('PKG_CONFIG_PATH', os.getenv('PKG_CONFIG_PATH'))
@@ -255,16 +238,163 @@ def configure(env):
raise RuntimeError('Could not find mono shared library in: ' + str(tmpenv['LIBPATH']))
copy_file(mono_lib_path, 'bin', 'lib' + mono_so_name + sharedlib_ext)
- copy_file(os.path.join(mono_prefix, 'lib', 'mono', '4.5'), assemblies_output_dir, 'mscorlib.dll')
env.Append(LINKFLAGS='-rdynamic')
+ if not tools_enabled:
+ if not mono_root:
+ mono_root = subprocess.check_output(['pkg-config', 'mono-2', '--variable=prefix']).decode('utf8').strip()
+
+ make_template_dir(env, mono_root)
+
+ if copy_mono_root:
+ if not mono_root:
+ mono_root = subprocess.check_output(['pkg-config', 'mono-2', '--variable=prefix']).decode('utf8').strip()
+
+ if tools_enabled:
+ copy_mono_root_files(env, mono_root)
+ else:
+ print("Ignoring option: 'copy_mono_root'. Only available for builds with 'tools' enabled.")
+
+
+def make_template_dir(env, mono_root):
+ from shutil import rmtree
+
+ platform = env['platform']
+ target = env['target']
+
+ template_dir_name = ''
+
+ if platform == 'windows':
+ template_dir_name = 'data.mono.%s.%s.%s' % (platform, env['bits'], target)
+ elif platform == 'osx':
+ template_dir_name = 'data.mono.%s.%s' % (platform, target)
+ elif platform == 'x11':
+ template_dir_name = 'data.mono.%s.%s.%s' % (platform, env['bits'], target)
+ else:
+ assert False
+
+ output_dir = Dir('#bin').abspath
+ template_dir = os.path.join(output_dir, template_dir_name)
+
+ template_mono_root_dir = os.path.join(template_dir, 'Mono')
+
+ if os.path.isdir(template_mono_root_dir):
+ rmtree(template_mono_root_dir) # Clean first
+
+ # Copy etc/mono/
+
+ template_mono_config_dir = os.path.join(template_mono_root_dir, 'etc', 'mono')
+ copy_mono_etc_dir(mono_root, template_mono_config_dir, env['platform'])
+
+ # Copy the required shared libraries
+
+ copy_mono_shared_libs(mono_root, template_mono_root_dir, env['platform'])
+
+
+def copy_mono_root_files(env, mono_root):
+ from glob import glob
+ from shutil import copy
+ from shutil import rmtree
+
+ if not mono_root:
+ raise RuntimeError('Mono installation directory not found')
+
+ output_dir = Dir('#bin').abspath
+ editor_mono_root_dir = os.path.join(output_dir, 'GodotSharp', 'Mono')
+
+ if os.path.isdir(editor_mono_root_dir):
+ rmtree(editor_mono_root_dir) # Clean first
+
+ # Copy etc/mono/
+
+ editor_mono_config_dir = os.path.join(editor_mono_root_dir, 'etc', 'mono')
+ copy_mono_etc_dir(mono_root, editor_mono_config_dir, env['platform'])
+
+ # Copy the required shared libraries
+
+ copy_mono_shared_libs(mono_root, editor_mono_root_dir, env['platform'])
+
+ # Copy framework assemblies
+
+ mono_framework_dir = os.path.join(mono_root, 'lib', 'mono', '4.5')
+ mono_framework_facades_dir = os.path.join(mono_framework_dir, 'Facades')
+
+ editor_mono_framework_dir = os.path.join(editor_mono_root_dir, 'lib', 'mono', '4.5')
+ editor_mono_framework_facades_dir = os.path.join(editor_mono_framework_dir, 'Facades')
+
+ if not os.path.isdir(editor_mono_framework_dir):
+ os.makedirs(editor_mono_framework_dir)
+ if not os.path.isdir(editor_mono_framework_facades_dir):
+ os.makedirs(editor_mono_framework_facades_dir)
+
+ for assembly in glob(os.path.join(mono_framework_dir, '*.dll')):
+ copy(assembly, editor_mono_framework_dir)
+ for assembly in glob(os.path.join(mono_framework_facades_dir, '*.dll')):
+ copy(assembly, editor_mono_framework_facades_dir)
+
+
+def copy_mono_etc_dir(mono_root, target_mono_config_dir, platform):
+ from distutils.dir_util import copy_tree
+ from glob import glob
+ from shutil import copy
+
+ if not os.path.isdir(target_mono_config_dir):
+ os.makedirs(target_mono_config_dir)
+
+ mono_etc_dir = os.path.join(mono_root, 'etc', 'mono')
+ if not os.path.isdir(mono_etc_dir):
+ mono_etc_dir = ''
+ etc_hint_dirs = []
+ if platform != 'windows':
+ etc_hint_dirs += ['/etc/mono', '/usr/local/etc/mono']
+ if 'MONO_CFG_DIR' in os.environ:
+ etc_hint_dirs += [os.path.join(os.environ['MONO_CFG_DIR'], 'mono')]
+ for etc_hint_dir in etc_hint_dirs:
+ if os.path.isdir(etc_hint_dir):
+ mono_etc_dir = etc_hint_dir
+ break
+ if not mono_etc_dir:
+ raise RuntimeError('Mono installation etc directory not found')
+
+ copy_tree(os.path.join(mono_etc_dir, '2.0'), os.path.join(target_mono_config_dir, '2.0'))
+ copy_tree(os.path.join(mono_etc_dir, '4.0'), os.path.join(target_mono_config_dir, '4.0'))
+ copy_tree(os.path.join(mono_etc_dir, '4.5'), os.path.join(target_mono_config_dir, '4.5'))
+ copy_tree(os.path.join(mono_etc_dir, 'mconfig'), os.path.join(target_mono_config_dir, 'mconfig'))
+
+ for file in glob(os.path.join(mono_etc_dir, '*')):
+ if os.path.isfile(file):
+ copy(file, target_mono_config_dir)
+
+
+def copy_mono_shared_libs(mono_root, target_mono_root_dir, platform):
+ from shutil import copy
+
+ if platform == 'windows':
+ target_mono_bin_dir = os.path.join(target_mono_root_dir, 'bin')
+
+ if not os.path.isdir(target_mono_bin_dir):
+ os.makedirs(target_mono_bin_dir)
+
+ copy(os.path.join(mono_root, 'bin', 'MonoPosixHelper.dll'), os.path.join(target_mono_bin_dir, 'MonoPosixHelper.dll'))
+ else:
+ target_mono_lib_dir = os.path.join(target_mono_root_dir, 'lib')
+
+ if not os.path.isdir(target_mono_lib_dir):
+ os.makedirs(target_mono_lib_dir)
+
+ if platform == 'osx':
+ copy(os.path.join(mono_root, 'lib', 'libMonoPosixHelper.dylib'), os.path.join(target_mono_lib_dir, 'libMonoPosixHelper.dylib'))
+ elif platform == 'x11':
+ copy(os.path.join(mono_root, 'lib', 'libmono-btls-shared.so'), os.path.join(target_mono_lib_dir, 'libmono-btls-shared.so'))
+ copy(os.path.join(mono_root, 'lib', 'libMonoPosixHelper.so'), os.path.join(target_mono_lib_dir, 'libMonoPosixHelper.so'))
+
def configure_for_mono_version(env, mono_version):
if mono_version is None:
raise RuntimeError('Mono JIT compiler version not found')
print('Found Mono JIT compiler version: ' + str(mono_version))
- if mono_version >= LooseVersion("5.12.0"):
+ if mono_version >= LooseVersion('5.12.0'):
env.Append(CPPFLAGS=['-DHAS_PENDING_EXCEPTIONS'])
diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp
index 91fd482235..5160d42367 100644
--- a/modules/mono/csharp_script.cpp
+++ b/modules/mono/csharp_script.cpp
@@ -1194,7 +1194,7 @@ bool CSharpInstance::set(const StringName &p_name, const Variant &p_value) {
MonoObject *ret = method->invoke(mono_object, args);
- if (ret && GDMonoMarshal::unbox<MonoBoolean>(ret) == true)
+ if (ret && GDMonoMarshal::unbox<MonoBoolean>(ret))
return true;
break;
@@ -1459,7 +1459,7 @@ MonoObject *CSharpInstance::_internal_new_managed() {
void CSharpInstance::mono_object_disposed(MonoObject *p_obj) {
#ifdef DEBUG_ENABLED
- CRASH_COND(base_ref == true);
+ CRASH_COND(base_ref);
CRASH_COND(gchandle.is_null());
#endif
CSharpLanguage::get_singleton()->release_script_gchandle(p_obj, gchandle);
@@ -1468,7 +1468,7 @@ void CSharpInstance::mono_object_disposed(MonoObject *p_obj) {
void CSharpInstance::mono_object_disposed_baseref(MonoObject *p_obj, bool p_is_finalizer, bool &r_owner_deleted) {
#ifdef DEBUG_ENABLED
- CRASH_COND(base_ref == false);
+ CRASH_COND(!base_ref);
CRASH_COND(gchandle.is_null());
#endif
if (_unreference_owner_unsafe()) {
diff --git a/modules/mono/doc_classes/GodotSharp.xml b/modules/mono/doc_classes/GodotSharp.xml
index 985c66464b..921c1ca825 100644
--- a/modules/mono/doc_classes/GodotSharp.xml
+++ b/modules/mono/doc_classes/GodotSharp.xml
@@ -23,18 +23,44 @@
Detaches the current thread from the mono runtime.
</description>
</method>
- <method name="is_domain_loaded">
+ <method name="get_domain_id">
+ <return type="int">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="get_scripts_domain_id">
+ <return type="int">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="is_domain_finalizing_for_unload">
+ <return type="bool">
+ </return>
+ <argument index="0" name="domain_id" type="int">
+ </argument>
+ <description>
+ Returns whether the domain is being finalized.
+ </description>
+ </method>
+ <method name="is_runtime_initialized">
+ <return type="bool">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="is_runtime_shutting_down">
<return type="bool">
</return>
<description>
- Returns whether the scripts domain is loaded.
</description>
</method>
- <method name="is_finalizing_domain">
+ <method name="is_scripts_domain_loaded">
<return type="bool">
</return>
<description>
- Returns whether the scripts domain is being finalized.
+ Returns whether the scripts domain is loaded.
</description>
</method>
</methods>
diff --git a/modules/mono/editor/GodotSharpTools/Editor/GodotSharpExport.cs b/modules/mono/editor/GodotSharpTools/Editor/GodotSharpExport.cs
new file mode 100644
index 0000000000..5fd708d539
--- /dev/null
+++ b/modules/mono/editor/GodotSharpTools/Editor/GodotSharpExport.cs
@@ -0,0 +1,74 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Runtime.CompilerServices;
+
+namespace GodotSharpTools.Editor
+{
+ public static class GodotSharpExport
+ {
+ public static void _ExportBegin(string[] features, bool debug, string path, int flags)
+ {
+ var featureSet = new HashSet<string>(features);
+
+ if (PlatformHasTemplateDir(featureSet))
+ {
+ string templateDirName = "data.mono";
+
+ if (featureSet.Contains("Windows"))
+ {
+ templateDirName += ".windows";
+ templateDirName += featureSet.Contains("64") ? ".64" : ".32";
+ }
+ else if (featureSet.Contains("X11"))
+ {
+ templateDirName += ".x11";
+ templateDirName += featureSet.Contains("64") ? ".64" : ".32";
+ }
+ else
+ {
+ throw new NotSupportedException("Target platform not supported");
+ }
+
+ templateDirName += debug ? ".debug" : ".release";
+
+ string templateDirPath = Path.Combine(GetTemplatesDir(), templateDirName);
+
+ if (!Directory.Exists(templateDirPath))
+ throw new FileNotFoundException("Data template directory not found");
+
+ string outputDir = new FileInfo(path).Directory.FullName;
+
+ string outputDataDir = Path.Combine(outputDir, GetDataDirName());
+
+ if (Directory.Exists(outputDataDir))
+ Directory.Delete(outputDataDir, recursive: true); // Clean first
+
+ Directory.CreateDirectory(outputDataDir);
+
+ foreach (string dir in Directory.GetDirectories(templateDirPath, "*", SearchOption.AllDirectories))
+ {
+ Directory.CreateDirectory(Path.Combine(outputDataDir, dir.Substring(templateDirPath.Length + 1)));
+ }
+
+ foreach (string file in Directory.GetFiles(templateDirPath, "*", SearchOption.AllDirectories))
+ {
+ File.Copy(file, Path.Combine(outputDataDir, file.Substring(templateDirPath.Length + 1)));
+ }
+ }
+ }
+
+ public static bool PlatformHasTemplateDir(HashSet<string> featureSet)
+ {
+ // OSX export templates are contained in a zip, so we place
+ // our custom template inside it and let Godot do the rest.
+ return !featureSet.Contains("OSX");
+ }
+
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ extern static string GetTemplatesDir();
+
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ extern static string GetDataDirName();
+ }
+}
diff --git a/modules/mono/editor/GodotSharpTools/GodotSharpTools.csproj b/modules/mono/editor/GodotSharpTools/GodotSharpTools.csproj
index 773e8196f7..fceb732426 100644
--- a/modules/mono/editor/GodotSharpTools/GodotSharpTools.csproj
+++ b/modules/mono/editor/GodotSharpTools/GodotSharpTools.csproj
@@ -41,6 +41,7 @@
<Compile Include="Project\ProjectUtils.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Utils\OS.cs" />
+ <Compile Include="Editor\GodotSharpExport.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project> \ No newline at end of file
diff --git a/modules/mono/editor/bindings_generator.cpp b/modules/mono/editor/bindings_generator.cpp
index 2c3435fc1c..710682d3aa 100644
--- a/modules/mono/editor/bindings_generator.cpp
+++ b/modules/mono/editor/bindings_generator.cpp
@@ -97,7 +97,7 @@
#define C_METHOD_MONOARRAY_TO(m_type) C_NS_MONOMARSHAL "::mono_array_to_" #m_type
#define C_METHOD_MONOARRAY_FROM(m_type) C_NS_MONOMARSHAL "::" #m_type "_to_mono_array"
-#define BINDINGS_GENERATOR_VERSION UINT32_C(3)
+#define BINDINGS_GENERATOR_VERSION UINT32_C(5)
const char *BindingsGenerator::TypeInterface::DEFAULT_VARARG_C_IN = "\t%0 %1_in = %1;\n";
@@ -173,23 +173,74 @@ static String snake_to_camel_case(const String &p_identifier, bool p_input_is_up
return ret;
}
-String BindingsGenerator::_determine_enum_prefix(const EnumInterface &p_ienum) {
+int BindingsGenerator::_determine_enum_prefix(const EnumInterface &p_ienum) {
CRASH_COND(p_ienum.constants.empty());
- const List<ConstantInterface>::Element *front = p_ienum.constants.front();
- int candidate_len = front->get().name.length();
+ 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;
- for (const List<ConstantInterface>::Element *E = front->next(); E; E = E->next()) {
- int j = 0;
- for (j = 0; j < candidate_len && j < E->get().name.length(); j++) {
- if (front->get().name[j] != E->get().name[j])
- break;
+ 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();
+
+ Vector<String> parts = iconstant.name.split("_", /* p_allow_empty: */ true);
+
+ int i;
+ for (i = 0; i < candidate_len && i < parts.size(); i++) {
+ 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)
+ break;
+ }
}
- candidate_len = j;
+ candidate_len = i;
+
+ if (candidate_len == 0)
+ return 0;
}
- return front->get().name.substr(0, candidate_len);
+ 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;
+
+ ConstantInterface &curr_const = E->get();
+
+ String constant_name = curr_const.name;
+
+ Vector<String> parts = constant_name.split("_", /* p_allow_empty: */ true);
+
+ 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')
+ break;
+ }
+ }
+
+ constant_name = "";
+ for (int i = curr_prefix_length; i < parts.size(); i++) {
+ if (i > curr_prefix_length)
+ constant_name += "_";
+ constant_name += parts[i];
+ }
+
+ curr_const.proxy_name = snake_to_pascal_case(constant_name, true);
+ }
+ }
}
void BindingsGenerator::_generate_method_icalls(const TypeInterface &p_itype) {
@@ -272,7 +323,7 @@ void BindingsGenerator::_generate_global_constants(List<String> &p_output) {
}
p_output.push_back(MEMBER_BEGIN "public const int ");
- p_output.push_back(iconstant.name);
+ p_output.push_back(iconstant.proxy_name);
p_output.push_back(" = ");
p_output.push_back(itos(iconstant.value));
p_output.push_back(";");
@@ -334,25 +385,8 @@ void BindingsGenerator::_generate_global_constants(List<String> &p_output) {
p_output.push_back(INDENT2 "/// </summary>\n");
}
- String constant_name = iconstant.name;
-
- if (!ienum.prefix.empty() && constant_name.begins_with(ienum.prefix)) {
- constant_name = constant_name.substr(ienum.prefix.length(), constant_name.length());
- }
-
- if (constant_name[0] >= '0' && constant_name[0] <= '9') {
- // The name of enum constants may begin with a numeric digit when strip from the enum prefix,
- // so we make the prefix one word shorter in those cases.
- int i = 0;
- for (i = ienum.prefix.length() - 1; i >= 0; i--) {
- if (ienum.prefix[i] >= 'A' && ienum.prefix[i] <= 'Z')
- break;
- }
- constant_name = ienum.prefix.substr(i, ienum.prefix.length()) + constant_name;
- }
-
p_output.push_back(INDENT2);
- p_output.push_back(constant_name);
+ p_output.push_back(iconstant.proxy_name);
p_output.push_back(" = ");
p_output.push_back(itos(iconstant.value));
p_output.push_back(E != ienum.constants.back() ? ",\n" : "\n");
@@ -646,8 +680,11 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str
List<String> output;
output.push_back("using System;\n"); // IntPtr
+ output.push_back("using System.Diagnostics;\n"); // DebuggerBrowsable
+
output.push_back("\n#pragma warning disable CS1591 // Disable warning: "
"'Missing XML comment for publicly visible type or member'\n");
+
output.push_back("\nnamespace " BINDINGS_NAMESPACE "\n" OPEN_BLOCK);
const DocData::ClassDoc *class_doc = itype.class_doc;
@@ -717,7 +754,7 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str
}
output.push_back(MEMBER_BEGIN "public const int ");
- output.push_back(iconstant.name);
+ output.push_back(iconstant.proxy_name);
output.push_back(" = ");
output.push_back(itos(iconstant.value));
output.push_back(";");
@@ -757,25 +794,8 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str
output.push_back(INDENT3 "/// </summary>\n");
}
- String constant_name = iconstant.name;
-
- if (!ienum.prefix.empty() && constant_name.begins_with(ienum.prefix)) {
- constant_name = constant_name.substr(ienum.prefix.length(), constant_name.length());
- }
-
- if (constant_name[0] >= '0' && constant_name[0] <= '9') {
- // The name of enum constants may begin with a numeric digit when strip from the enum prefix,
- // so we make the prefix one word shorter in those cases.
- int i = 0;
- for (i = ienum.prefix.length() - 1; i >= 0; i--) {
- if (ienum.prefix[i] >= 'A' && ienum.prefix[i] <= 'Z')
- break;
- }
- constant_name = ienum.prefix.substr(i, ienum.prefix.length()) + constant_name;
- }
-
output.push_back(INDENT3);
- output.push_back(constant_name);
+ output.push_back(iconstant.proxy_name);
output.push_back(" = ");
output.push_back(itos(iconstant.value));
output.push_back(E != ienum.constants.back() ? ",\n" : "\n");
@@ -1086,7 +1106,7 @@ Error BindingsGenerator::_generate_cs_method(const BindingsGenerator::TypeInterf
// Generate method
{
if (!p_imethod.is_virtual && !p_imethod.requires_object_call) {
- p_output.push_back(MEMBER_BEGIN "private static IntPtr ");
+ p_output.push_back(MEMBER_BEGIN "[DebuggerBrowsable(DebuggerBrowsableState.Never)]" MEMBER_BEGIN "private static IntPtr ");
p_output.push_back(method_bind_field + " = Object." ICALL_GET_METHODBIND "(" BINDINGS_NATIVE_NAME_FIELD ", \"");
p_output.push_back(p_imethod.name);
p_output.push_back("\");\n");
@@ -1269,12 +1289,12 @@ Error BindingsGenerator::generate_glue(const String &p_output_dir) {
output.push_back("namespace GodotSharpBindings\n" OPEN_BLOCK "\n");
output.push_back("uint64_t get_core_api_hash() { return ");
- output.push_back(String::num_uint64(GDMono::get_singleton()->get_api_core_hash()) + "; }\n");
+ output.push_back(String::num_uint64(GDMono::get_singleton()->get_api_core_hash()) + "U; }\n");
output.push_back("#ifdef TOOLS_ENABLED\n"
"uint64_t get_editor_api_hash() { return ");
- output.push_back(String::num_uint64(GDMono::get_singleton()->get_api_editor_hash()) +
- "; }\n#endif // TOOLS_ENABLED\n");
+ output.push_back(String::num_uint64(GDMono::get_singleton()->get_api_editor_hash()) + "U; }\n");
+ output.push_back("#endif // TOOLS_ENABLED\n");
output.push_back("uint32_t get_bindings_version() { return ");
output.push_back(String::num_uint64(BINDINGS_GENERATOR_VERSION) + "; }\n");
@@ -1843,11 +1863,13 @@ void BindingsGenerator::_populate_object_type_interfaces() {
EnumInterface ienum(enum_proxy_cname);
const List<StringName> &constants = enum_map.get(*k);
for (const List<StringName>::Element *E = constants.front(); E; E = E->next()) {
- int *value = class_info->constant_map.getptr(E->get());
+ const StringName &constant_cname = E->get();
+ String constant_name = constant_cname.operator String();
+ int *value = class_info->constant_map.getptr(constant_cname);
ERR_FAIL_NULL(value);
- constant_list.erase(E->get().operator String());
+ constant_list.erase(constant_name);
- ConstantInterface iconstant(snake_to_pascal_case(E->get(), true), *value);
+ ConstantInterface iconstant(constant_name, snake_to_pascal_case(constant_name, true), *value);
iconstant.const_doc = NULL;
for (int i = 0; i < itype.class_doc->constants.size(); i++) {
@@ -1862,7 +1884,9 @@ void BindingsGenerator::_populate_object_type_interfaces() {
ienum.constants.push_back(iconstant);
}
- ienum.prefix = _determine_enum_prefix(ienum);
+ int prefix_length = _determine_enum_prefix(ienum);
+
+ _apply_prefix_to_enum_constants(ienum, prefix_length);
itype.enums.push_back(ienum);
@@ -1876,10 +1900,11 @@ void BindingsGenerator::_populate_object_type_interfaces() {
}
for (const List<String>::Element *E = constant_list.front(); E; E = E->next()) {
- int *value = class_info->constant_map.getptr(E->get());
+ const String &constant_name = E->get();
+ int *value = class_info->constant_map.getptr(StringName(E->get()));
ERR_FAIL_NULL(value);
- ConstantInterface iconstant(snake_to_pascal_case(E->get(), true), *value);
+ ConstantInterface iconstant(constant_name, snake_to_pascal_case(constant_name, true), *value);
iconstant.const_doc = NULL;
for (int i = 0; i < itype.class_doc->constants.size(); i++) {
@@ -1990,18 +2015,18 @@ void BindingsGenerator::_populate_builtin_type_interfaces() {
TypeInterface itype;
-#define INSERT_STRUCT_TYPE(m_type, m_type_in) \
- { \
- itype = TypeInterface::create_value_type(String(#m_type)); \
- itype.c_in = "\tMARSHALLED_IN(" #m_type ", %1, %1_in);\n"; \
- itype.c_out = "\tMARSHALLED_OUT(" #m_type ", %1, ret_out)\n" \
- "\treturn mono_value_box(mono_domain_get(), CACHED_CLASS_RAW(%2), ret_out);\n"; \
- itype.c_arg_in = "&%s_in"; \
- itype.c_type_in = m_type_in; \
- itype.cs_in = "ref %s"; \
- itype.cs_out = "return (%1)%0;"; \
- itype.im_type_out = "object"; \
- builtin_types.insert(itype.cname, itype); \
+#define INSERT_STRUCT_TYPE(m_type, m_type_in) \
+ { \
+ itype = TypeInterface::create_value_type(String(#m_type)); \
+ itype.c_in = "\t%0 %1_in = MARSHALLED_IN(" #m_type ", %1);\n"; \
+ itype.c_out = "\treturn MARSHALLED_OUT(" #m_type ", %1);\n"; \
+ itype.c_arg_in = "&%s_in"; \
+ itype.c_type_in = "GDMonoMarshal::M_" #m_type "*"; \
+ itype.c_type_out = "GDMonoMarshal::M_" #m_type; \
+ itype.cs_in = "ref %s"; \
+ itype.cs_out = "return (%1)%0;"; \
+ itype.im_type_out = itype.cs_type; \
+ builtin_types.insert(itype.cname, itype); \
}
INSERT_STRUCT_TYPE(Vector2, "real_t*")
@@ -2019,26 +2044,31 @@ void BindingsGenerator::_populate_builtin_type_interfaces() {
// bool
itype = TypeInterface::create_value_type(String("bool"));
- itype.c_arg_in = "&%s";
- // /* MonoBoolean <---> bool
- itype.c_in = "\t%0 %1_in = (%0)%1;\n";
- itype.c_out = "\treturn (%0)%1;\n";
- itype.c_type = "bool";
- // */
- itype.c_type_in = "MonoBoolean";
- itype.c_type_out = itype.c_type_in;
+
+ {
+ // MonoBoolean <---> bool
+ itype.c_in = "\t%0 %1_in = (%0)%1;\n";
+ itype.c_out = "\treturn (%0)%1;\n";
+ itype.c_type = "bool";
+ itype.c_type_in = "MonoBoolean";
+ itype.c_type_out = itype.c_type_in;
+ itype.c_arg_in = "&%s_in";
+ }
itype.im_type_in = itype.name;
itype.im_type_out = itype.name;
builtin_types.insert(itype.cname, itype);
// int
+ // C interface is the same as that of enums. Remember to apply any
+ // changes done here to TypeInterface::postsetup_enum_type as well
itype = TypeInterface::create_value_type(String("int"));
itype.c_arg_in = "&%s_in";
- // /* ptrcall only supports int64_t and uint64_t
- itype.c_in = "\t%0 %1_in = (%0)%1;\n";
- itype.c_out = "\treturn (%0)%1;\n";
- itype.c_type = "int64_t";
- // */
+ {
+ // The expected types for parameters and return value in ptrcall are 'int64_t' or 'uint64_t'.
+ itype.c_in = "\t%0 %1_in = (%0)%1;\n";
+ itype.c_out = "\treturn (%0)%1;\n";
+ itype.c_type = "int64_t";
+ }
itype.c_type_in = "int32_t";
itype.c_type_out = itype.c_type_in;
itype.im_type_in = itype.name;
@@ -2047,21 +2077,22 @@ void BindingsGenerator::_populate_builtin_type_interfaces() {
// real_t
itype = TypeInterface();
+ itype.name = "float"; // The name is always "float" in Variant, even with REAL_T_IS_DOUBLE.
+ itype.cname = itype.name;
#ifdef REAL_T_IS_DOUBLE
- itype.name = "double";
+ itype.proxy_name = "double";
#else
- itype.name = "float";
+ itype.proxy_name = "float";
#endif
- itype.cname = itype.name;
- itype.proxy_name = itype.name;
- itype.c_arg_in = "&%s_in";
- //* ptrcall only supports double
- itype.c_in = "\t%0 %1_in = (%0)%1;\n";
- itype.c_out = "\treturn (%0)%1;\n";
- itype.c_type = "double";
- //*/
- itype.c_type_in = "real_t";
- itype.c_type_out = "real_t";
+ {
+ // The expected type for parameters and return value in ptrcall is 'double'.
+ itype.c_in = "\t%0 %1_in = (%0)%1;\n";
+ itype.c_out = "\treturn (%0)%1;\n";
+ itype.c_type = "double";
+ itype.c_type_in = "real_t";
+ itype.c_type_out = "real_t";
+ itype.c_arg_in = "&%s_in";
+ }
itype.cs_type = itype.proxy_name;
itype.im_type_in = itype.proxy_name;
itype.im_type_out = itype.proxy_name;
@@ -2256,7 +2287,7 @@ void BindingsGenerator::_populate_global_constants() {
int constant_value = GlobalConstants::get_global_constant_value(i);
StringName enum_name = GlobalConstants::get_global_constant_enum(i);
- ConstantInterface iconstant(snake_to_pascal_case(constant_name, true), constant_value);
+ ConstantInterface iconstant(constant_name, snake_to_pascal_case(constant_name, true), constant_value);
iconstant.const_doc = const_doc;
if (enum_name != StringName()) {
@@ -2284,16 +2315,18 @@ void BindingsGenerator::_populate_global_constants() {
TypeInterface::postsetup_enum_type(enum_itype);
enum_types.insert(enum_itype.cname, enum_itype);
- ienum.prefix = _determine_enum_prefix(ienum);
+ int prefix_length = _determine_enum_prefix(ienum);
- // HARDCODED
+ // HARDCODED: The Error enum have the prefix 'ERR_' for everything except 'OK' and 'FAILED'.
if (ienum.cname == name_cache.enum_Error) {
- if (!ienum.prefix.empty()) { // Just in case it ever changes
+ if (prefix_length > 0) { // Just in case it ever changes
ERR_PRINTS("Prefix for enum 'Error' is not empty");
}
- ienum.prefix = "Err";
+ prefix_length = 1; // 'ERR_'
}
+
+ _apply_prefix_to_enum_constants(ienum, prefix_length);
}
}
diff --git a/modules/mono/editor/bindings_generator.h b/modules/mono/editor/bindings_generator.h
index ad89255ba5..38cf99c294 100644
--- a/modules/mono/editor/bindings_generator.h
+++ b/modules/mono/editor/bindings_generator.h
@@ -43,20 +43,21 @@ class BindingsGenerator {
struct ConstantInterface {
String name;
+ String proxy_name;
int value;
const DocData::ConstantDoc *const_doc;
ConstantInterface() {}
- ConstantInterface(const String &p_name, int p_value) {
+ ConstantInterface(const String &p_name, const String &p_proxy_name, int p_value) {
name = p_name;
+ proxy_name = p_proxy_name;
value = p_value;
}
};
struct EnumInterface {
StringName cname;
- String prefix;
List<ConstantInterface> constants;
_FORCE_INLINE_ bool operator==(const EnumInterface &p_ienum) const {
@@ -223,7 +224,7 @@ class BindingsGenerator {
String c_in;
/**
- * Determines the name of the variable that will be passed as argument to a ptrcall.
+ * Determines the expression that will be passed as argument to ptrcall.
* By default the value equals the name of the parameter,
* this varies for types that require special manipulation via [c_in].
* Formatting elements:
@@ -333,8 +334,6 @@ class BindingsGenerator {
itype.proxy_name = itype.name;
itype.c_type = itype.name;
- itype.c_type_in = "void*";
- itype.c_type_out = "MonoObject*";
itype.cs_type = itype.proxy_name;
itype.im_type_in = "ref " + itype.proxy_name;
itype.im_type_out = itype.proxy_name;
@@ -385,10 +384,19 @@ class BindingsGenerator {
}
static void postsetup_enum_type(TypeInterface &r_enum_itype) {
- r_enum_itype.c_arg_in = "&%s";
- r_enum_itype.c_type = "int";
- r_enum_itype.c_type_in = "int";
- r_enum_itype.c_type_out = "int";
+ // C interface is the same as that of 'int'. Remember to apply any
+ // changes done here to the 'int' type interface as well
+
+ r_enum_itype.c_arg_in = "&%s_in";
+ {
+ // The expected types for parameters and return value in ptrcall are 'int64_t' or 'uint64_t'.
+ r_enum_itype.c_in = "\t%0 %1_in = (%0)%1;\n";
+ r_enum_itype.c_out = "\treturn (%0)%1;\n";
+ r_enum_itype.c_type = "int64_t";
+ }
+ r_enum_itype.c_type_in = "int32_t";
+ r_enum_itype.c_type_out = r_enum_itype.c_type_in;
+
r_enum_itype.cs_type = r_enum_itype.proxy_name;
r_enum_itype.cs_in = "(int)%s";
r_enum_itype.cs_out = "return (%1)%0;";
@@ -513,7 +521,8 @@ class BindingsGenerator {
return p_type.name;
}
- String _determine_enum_prefix(const EnumInterface &p_ienum);
+ int _determine_enum_prefix(const EnumInterface &p_ienum);
+ void _apply_prefix_to_enum_constants(EnumInterface &p_ienum, int p_prefix_length);
void _generate_method_icalls(const TypeInterface &p_itype);
diff --git a/modules/mono/editor/csharp_project.cpp b/modules/mono/editor/csharp_project.cpp
index 4764cbe941..6f223b75a3 100644
--- a/modules/mono/editor/csharp_project.cpp
+++ b/modules/mono/editor/csharp_project.cpp
@@ -51,7 +51,7 @@ String generate_core_api_project(const String &p_dir, const Vector<String> &p_fi
MonoObject *ret = klass->get_method("GenCoreApiProject", 2)->invoke(NULL, args, &exc);
if (exc) {
- GDMonoUtils::debug_unhandled_exception(exc);
+ GDMonoUtils::debug_print_unhandled_exception(exc);
ERR_FAIL_V(String());
}
@@ -72,7 +72,7 @@ String generate_editor_api_project(const String &p_dir, const String &p_core_dll
MonoObject *ret = klass->get_method("GenEditorApiProject", 3)->invoke(NULL, args, &exc);
if (exc) {
- GDMonoUtils::debug_unhandled_exception(exc);
+ GDMonoUtils::debug_print_unhandled_exception(exc);
ERR_FAIL_V(String());
}
@@ -93,7 +93,7 @@ String generate_game_project(const String &p_dir, const String &p_name, const Ve
MonoObject *ret = klass->get_method("GenGameProject", 3)->invoke(NULL, args, &exc);
if (exc) {
- GDMonoUtils::debug_unhandled_exception(exc);
+ GDMonoUtils::debug_print_unhandled_exception(exc);
ERR_FAIL_V(String());
}
@@ -114,7 +114,7 @@ void add_item(const String &p_project_path, const String &p_item_type, const Str
klass->get_method("AddItemToProjectChecked", 3)->invoke(NULL, args, &exc);
if (exc) {
- GDMonoUtils::debug_unhandled_exception(exc);
+ GDMonoUtils::debug_print_unhandled_exception(exc);
ERR_FAIL();
}
}
diff --git a/modules/mono/editor/godotsharp_builds.cpp b/modules/mono/editor/godotsharp_builds.cpp
index d397814fa7..b504cfe712 100644
--- a/modules/mono/editor/godotsharp_builds.cpp
+++ b/modules/mono/editor/godotsharp_builds.cpp
@@ -249,6 +249,18 @@ bool GodotSharpBuilds::build_api_sln(const String &p_name, const String &p_api_s
bool GodotSharpBuilds::copy_api_assembly(const String &p_src_dir, const String &p_dst_dir, const String &p_assembly_name, APIAssembly::Type p_api_type) {
+ // Create destination directory if needed
+ if (!DirAccess::exists(p_dst_dir)) {
+ DirAccess *da = DirAccess::create_for_path(p_dst_dir);
+ Error err = da->make_dir_recursive(p_dst_dir);
+ memdelete(da);
+
+ if (err != OK) {
+ show_build_error_dialog("Failed to create destination directory for the API assemblies. Error: " + itos(err));
+ return false;
+ }
+ }
+
String assembly_file = p_assembly_name + ".dll";
String assembly_src = p_src_dir.plus_file(assembly_file);
String assembly_dst = p_dst_dir.plus_file(assembly_file);
@@ -294,11 +306,21 @@ String GodotSharpBuilds::_api_folder_name(APIAssembly::Type p_api_type) {
bool GodotSharpBuilds::make_api_sln(APIAssembly::Type p_api_type) {
String api_name = p_api_type == APIAssembly::API_CORE ? API_ASSEMBLY_NAME : EDITOR_API_ASSEMBLY_NAME;
+
+ String editor_prebuilt_api_dir = GodotSharpDirs::get_data_editor_prebuilt_api_dir();
+ String res_assemblies_dir = GodotSharpDirs::get_res_assemblies_dir();
+
+ if (FileAccess::exists(editor_prebuilt_api_dir.plus_file(api_name + ".dll"))) {
+ EditorProgress pr("mono_copy_prebuilt_api_assembly", "Copying prebuilt " + api_name + " assembly...", 1);
+ pr.step("Copying " + api_name + " assembly", 0);
+ return GodotSharpBuilds::copy_api_assembly(editor_prebuilt_api_dir, res_assemblies_dir, api_name, p_api_type);
+ }
+
String api_build_config = "Release";
- EditorProgress pr("mono_build_release_" + api_name, "Building " + api_name + " solution...", 4);
+ EditorProgress pr("mono_build_release_" + api_name, "Building " + api_name + " solution...", 3);
- pr.step("Generating " + api_name + " solution");
+ pr.step("Generating " + api_name + " solution", 0);
String core_api_sln_dir = GodotSharpDirs::get_mono_solutions_dir()
.plus_file(_api_folder_name(APIAssembly::API_CORE))
@@ -336,34 +358,18 @@ bool GodotSharpBuilds::make_api_sln(APIAssembly::Type p_api_type) {
}
}
- pr.step("Building " + api_name + " solution");
+ pr.step("Building " + api_name + " solution", 1);
if (!GodotSharpBuilds::build_api_sln(api_name, api_sln_dir, api_build_config))
return false;
- pr.step("Copying " + api_name + " assembly");
-
- String res_assemblies_dir = GodotSharpDirs::get_res_assemblies_dir();
-
- // Create assemblies directory if needed
- if (!DirAccess::exists(res_assemblies_dir)) {
- DirAccess *da = DirAccess::create_for_path(res_assemblies_dir);
- Error err = da->make_dir_recursive(res_assemblies_dir);
- memdelete(da);
-
- if (err != OK) {
- show_build_error_dialog("Failed to create assemblies directory. Error: " + itos(err));
- return false;
- }
- }
+ pr.step("Copying " + api_name + " assembly", 2);
// Copy the built assembly to the assemblies directory
String api_assembly_dir = api_sln_dir.plus_file("bin").plus_file(api_build_config);
if (!GodotSharpBuilds::copy_api_assembly(api_assembly_dir, res_assemblies_dir, api_name, p_api_type))
return false;
- pr.step("Done");
-
return true;
}
@@ -378,9 +384,8 @@ bool GodotSharpBuilds::build_project_blocking(const String &p_config) {
if (!GodotSharpBuilds::make_api_sln(APIAssembly::API_EDITOR))
return false;
- EditorProgress pr("mono_project_debug_build", "Building project solution...", 2);
-
- pr.step("Building project solution");
+ EditorProgress pr("mono_project_debug_build", "Building project solution...", 1);
+ pr.step("Building project solution", 0);
MonoBuildInfo build_info(GodotSharpDirs::get_project_sln_path(), p_config);
if (!GodotSharpBuilds::get_singleton()->build(build_info)) {
@@ -388,8 +393,6 @@ bool GodotSharpBuilds::build_project_blocking(const String &p_config) {
return false;
}
- pr.step("Done");
-
return true;
}
diff --git a/modules/mono/editor/godotsharp_editor.cpp b/modules/mono/editor/godotsharp_editor.cpp
index 3ee38515bf..9df4e10266 100644
--- a/modules/mono/editor/godotsharp_editor.cpp
+++ b/modules/mono/editor/godotsharp_editor.cpp
@@ -108,6 +108,33 @@ bool GodotSharpEditor::_create_project_solution() {
return true;
}
+void GodotSharpEditor::_make_api_solutions_if_needed() {
+ // I'm sick entirely of ProgressDialog
+ static bool recursion_guard = false;
+ if (!recursion_guard) {
+ recursion_guard = true;
+ _make_api_solutions_if_needed_impl();
+ recursion_guard = false;
+ }
+}
+
+void GodotSharpEditor::_make_api_solutions_if_needed_impl() {
+ // If the project has a solution and C# project make sure the API assemblies are present and up to date
+ String res_assemblies_dir = GodotSharpDirs::get_res_assemblies_dir();
+
+ if (!FileAccess::exists(res_assemblies_dir.plus_file(API_ASSEMBLY_NAME ".dll")) ||
+ GDMono::get_singleton()->metadata_is_api_assembly_invalidated(APIAssembly::API_CORE)) {
+ if (!GodotSharpBuilds::make_api_sln(APIAssembly::API_CORE))
+ return;
+ }
+
+ if (!FileAccess::exists(res_assemblies_dir.plus_file(EDITOR_API_ASSEMBLY_NAME ".dll")) ||
+ GDMono::get_singleton()->metadata_is_api_assembly_invalidated(APIAssembly::API_EDITOR)) {
+ if (!GodotSharpBuilds::make_api_sln(APIAssembly::API_EDITOR))
+ return; // Redundant? I don't think so
+ }
+}
+
void GodotSharpEditor::_remove_create_sln_menu_option() {
menu_popup->remove_item(menu_popup->get_item_index(MENU_CREATE_SLN));
@@ -169,6 +196,7 @@ void GodotSharpEditor::_notification(int p_notification) {
void GodotSharpEditor::_bind_methods() {
ClassDB::bind_method(D_METHOD("_create_project_solution"), &GodotSharpEditor::_create_project_solution);
+ ClassDB::bind_method(D_METHOD("_make_api_solutions_if_needed"), &GodotSharpEditor::_make_api_solutions_if_needed);
ClassDB::bind_method(D_METHOD("_remove_create_sln_menu_option"), &GodotSharpEditor::_remove_create_sln_menu_option);
ClassDB::bind_method(D_METHOD("_toggle_about_dialog_on_start"), &GodotSharpEditor::_toggle_about_dialog_on_start);
ClassDB::bind_method(D_METHOD("_menu_option_pressed", "id"), &GodotSharpEditor::_menu_option_pressed);
@@ -197,6 +225,7 @@ void GodotSharpEditor::register_internal_calls() {
mono_add_internal_call("GodotSharpTools.Utils.OS::GetPlatformName", (void *)godot_icall_Utils_OS_GetPlatformName);
GodotSharpBuilds::register_internal_calls();
+ GodotSharpExport::register_internal_calls();
}
void GodotSharpEditor::show_error_dialog(const String &p_message, const String &p_title) {
@@ -389,7 +418,10 @@ GodotSharpEditor::GodotSharpEditor(EditorNode *p_editor) {
String sln_path = GodotSharpDirs::get_project_sln_path();
String csproj_path = GodotSharpDirs::get_project_csproj_path();
- if (!FileAccess::exists(sln_path) || !FileAccess::exists(csproj_path)) {
+ if (FileAccess::exists(sln_path) && FileAccess::exists(csproj_path)) {
+ // We can't use EditorProgress here. It calls Main::iterarion() and the main loop is not initialized yet.
+ call_deferred("_make_api_solutions_if_needed");
+ } else {
bottom_panel_btn->hide();
menu_popup->add_item(TTR("Create C# solution"), MENU_CREATE_SLN);
}
diff --git a/modules/mono/editor/godotsharp_editor.h b/modules/mono/editor/godotsharp_editor.h
index 46b6bd5ebf..9fb0e40132 100644
--- a/modules/mono/editor/godotsharp_editor.h
+++ b/modules/mono/editor/godotsharp_editor.h
@@ -56,6 +56,8 @@ class GodotSharpEditor : public Node {
#endif
bool _create_project_solution();
+ void _make_api_solutions_if_needed();
+ void _make_api_solutions_if_needed_impl();
void _remove_create_sln_menu_option();
void _show_about_dialog();
diff --git a/modules/mono/editor/godotsharp_export.cpp b/modules/mono/editor/godotsharp_export.cpp
index cd09e6516a..933ede93dc 100644
--- a/modules/mono/editor/godotsharp_export.cpp
+++ b/modules/mono/editor/godotsharp_export.cpp
@@ -30,12 +30,37 @@
#include "godotsharp_export.h"
+#include "core/version.h"
+
#include "../csharp_script.h"
#include "../godotsharp_defs.h"
#include "../godotsharp_dirs.h"
+#include "../mono_gd/gd_mono_class.h"
+#include "../mono_gd/gd_mono_marshal.h"
#include "godotsharp_builds.h"
-void GodotSharpExport::_export_file(const String &p_path, const String &p_type, const Set<String> &p_features) {
+static MonoString *godot_icall_GodotSharpExport_GetTemplatesDir() {
+ String current_version = VERSION_FULL_CONFIG;
+ String templates_dir = EditorSettings::get_singleton()->get_templates_dir().plus_file(current_version);
+ return GDMonoMarshal::mono_string_from_godot(ProjectSettings::get_singleton()->globalize_path(templates_dir));
+}
+
+static MonoString *godot_icall_GodotSharpExport_GetDataDirName() {
+ String appname = ProjectSettings::get_singleton()->get("application/config/name");
+ String appname_safe = OS::get_singleton()->get_safe_dir_name(appname);
+ return GDMonoMarshal::mono_string_from_godot("data_" + appname_safe);
+}
+
+void GodotSharpExport::register_internal_calls() {
+ static bool registered = false;
+ ERR_FAIL_COND(registered);
+ registered = true;
+
+ mono_add_internal_call("GodotSharpTools.Editor.GodotSharpExport::GetTemplatesDir", (void *)godot_icall_GodotSharpExport_GetTemplatesDir);
+ mono_add_internal_call("GodotSharpTools.Editor.GodotSharpExport::GetDataDirName", (void *)godot_icall_GodotSharpExport_GetDataDirName);
+}
+
+void GodotSharpExport::_export_file(const String &p_path, const String &p_type, const Set<String> &) {
if (p_type != CSharpLanguage::get_singleton()->get_type())
return;
@@ -56,59 +81,78 @@ void GodotSharpExport::_export_begin(const Set<String> &p_features, bool p_debug
// TODO right now there is no way to stop the export process with an error
ERR_FAIL_COND(!GDMono::get_singleton()->is_runtime_initialized());
- ERR_FAIL_NULL(GDMono::get_singleton()->get_tools_domain());
+ ERR_FAIL_NULL(TOOLS_DOMAIN);
+ ERR_FAIL_NULL(GDMono::get_singleton()->get_editor_tools_assembly());
String build_config = p_debug ? "Debug" : "Release";
ERR_FAIL_COND(!GodotSharpBuilds::build_project_blocking(build_config));
- // Add API assemblies
-
- String core_api_dll_path = GodotSharpDirs::get_res_assemblies_dir().plus_file(API_ASSEMBLY_NAME ".dll");
- ERR_FAIL_COND(!_add_assembly(core_api_dll_path, core_api_dll_path));
-
- String editor_api_dll_path = GodotSharpDirs::get_res_assemblies_dir().plus_file(EDITOR_API_ASSEMBLY_NAME ".dll");
- ERR_FAIL_COND(!_add_assembly(editor_api_dll_path, editor_api_dll_path));
+ // Add dependency assemblies
- // Add project assembly
+ Map<String, String> dependencies;
String project_dll_name = ProjectSettings::get_singleton()->get("application/config/name");
if (project_dll_name.empty()) {
project_dll_name = "UnnamedProject";
}
- String project_dll_src_path = GodotSharpDirs::get_res_temp_assemblies_base_dir().plus_file(build_config).plus_file(project_dll_name + ".dll");
- String project_dll_dst_path = GodotSharpDirs::get_res_assemblies_dir().plus_file(project_dll_name + ".dll");
- ERR_FAIL_COND(!_add_assembly(project_dll_src_path, project_dll_dst_path));
-
- // Add dependencies
-
- MonoDomain *prev_domain = mono_domain_get();
- MonoDomain *export_domain = GDMonoUtils::create_domain("GodotEngine.ProjectExportDomain");
+ String project_dll_src_dir = GodotSharpDirs::get_res_temp_assemblies_base_dir().plus_file(build_config);
+ String project_dll_src_path = project_dll_src_dir.plus_file(project_dll_name + ".dll");
+ dependencies.insert(project_dll_name, project_dll_src_path);
- ERR_FAIL_COND(!export_domain);
- ERR_FAIL_COND(!mono_domain_set(export_domain, false));
+ {
+ MonoDomain *export_domain = GDMonoUtils::create_domain("GodotEngine.ProjectExportDomain");
+ ERR_FAIL_NULL(export_domain);
+ _GDMONO_SCOPE_EXIT_DOMAIN_UNLOAD_(export_domain);
- Map<String, String> dependencies;
- dependencies.insert("mscorlib", GDMono::get_singleton()->get_corlib_assembly()->get_path());
-
- GDMonoAssembly *scripts_assembly = GDMonoAssembly::load_from(project_dll_name, project_dll_src_path, /* refonly: */ true);
+ _GDMONO_SCOPE_DOMAIN_(export_domain);
- ERR_EXPLAIN("Cannot load refonly assembly: " + project_dll_name);
- ERR_FAIL_COND(!scripts_assembly);
+ GDMonoAssembly *scripts_assembly = NULL;
+ bool load_success = GDMono::get_singleton()->load_assembly_from(project_dll_name,
+ project_dll_src_dir, &scripts_assembly, /* refonly: */ true);
- Error depend_error = _get_assembly_dependencies(scripts_assembly, dependencies);
+ ERR_EXPLAIN("Cannot load refonly assembly: " + project_dll_name);
+ ERR_FAIL_COND(!load_success);
- GDMono::get_singleton()->finalize_and_unload_domain(export_domain);
- mono_domain_set(prev_domain, false);
-
- ERR_FAIL_COND(depend_error != OK);
+ Vector<String> search_dirs;
+ GDMonoAssembly::fill_search_dirs(search_dirs);
+ Error depend_error = _get_assembly_dependencies(scripts_assembly, search_dirs, dependencies);
+ ERR_FAIL_COND(depend_error != OK);
+ }
for (Map<String, String>::Element *E = dependencies.front(); E; E = E->next()) {
String depend_src_path = E->value();
String depend_dst_path = GodotSharpDirs::get_res_assemblies_dir().plus_file(depend_src_path.get_file());
ERR_FAIL_COND(!_add_assembly(depend_src_path, depend_dst_path));
}
+
+ // Mono specific export template extras (data dir)
+
+ GDMonoClass *export_class = GDMono::get_singleton()->get_editor_tools_assembly()->get_class("GodotSharpTools.Editor", "GodotSharpExport");
+ ERR_FAIL_NULL(export_class);
+ GDMonoMethod *export_begin_method = export_class->get_method("_ExportBegin", 4);
+ ERR_FAIL_NULL(export_begin_method);
+
+ MonoArray *features = mono_array_new(mono_domain_get(), CACHED_CLASS_RAW(String), p_features.size());
+ int i = 0;
+ for (const Set<String>::Element *E = p_features.front(); E; E = E->next()) {
+ MonoString *boxed = GDMonoMarshal::mono_string_from_godot(E->get());
+ mono_array_set(features, MonoString *, i, boxed);
+ i++;
+ }
+
+ MonoBoolean debug = p_debug;
+ MonoString *path = GDMonoMarshal::mono_string_from_godot(p_path);
+ uint32_t flags = p_flags;
+ void *args[4] = { features, &debug, path, &flags };
+ MonoException *exc = NULL;
+ export_begin_method->invoke_raw(NULL, args, &exc);
+
+ if (exc) {
+ GDMonoUtils::debug_print_unhandled_exception(exc);
+ ERR_FAIL();
+ }
}
bool GodotSharpExport::_add_assembly(const String &p_src_path, const String &p_dst_path) {
@@ -125,7 +169,7 @@ bool GodotSharpExport::_add_assembly(const String &p_src_path, const String &p_d
return true;
}
-Error GodotSharpExport::_get_assembly_dependencies(GDMonoAssembly *p_assembly, Map<String, String> &r_dependencies) {
+Error GodotSharpExport::_get_assembly_dependencies(GDMonoAssembly *p_assembly, const Vector<String> &p_search_dirs, Map<String, String> &r_dependencies) {
MonoImage *image = p_assembly->get_image();
@@ -134,18 +178,48 @@ Error GodotSharpExport::_get_assembly_dependencies(GDMonoAssembly *p_assembly, M
mono_assembly_get_assemblyref(image, i, ref_aname);
String ref_name = mono_assembly_name_get_name(ref_aname);
- if (ref_name == "mscorlib" || r_dependencies.find(ref_name))
+ if (r_dependencies.find(ref_name))
continue;
GDMonoAssembly *ref_assembly = NULL;
- if (!GDMono::get_singleton()->load_assembly(ref_name, ref_aname, &ref_assembly, /* refonly: */ true)) {
- ERR_EXPLAIN("Cannot load refonly assembly: " + ref_name);
+ String path;
+ bool has_extension = ref_name.ends_with(".dll") || ref_name.ends_with(".exe");
+
+ for (int i = 0; i < p_search_dirs.size(); i++) {
+ const String &search_dir = p_search_dirs[i];
+
+ if (has_extension) {
+ path = search_dir.plus_file(ref_name);
+ if (FileAccess::exists(path)) {
+ GDMono::get_singleton()->load_assembly_from(ref_name.get_basename(), search_dir, ref_aname, &ref_assembly, true);
+ if (ref_assembly != NULL)
+ break;
+ }
+ } else {
+ path = search_dir.plus_file(ref_name + ".dll");
+ if (FileAccess::exists(path)) {
+ GDMono::get_singleton()->load_assembly_from(ref_name, search_dir, ref_aname, &ref_assembly, true);
+ if (ref_assembly != NULL)
+ break;
+ }
+
+ path = search_dir.plus_file(ref_name + ".exe");
+ if (FileAccess::exists(path)) {
+ GDMono::get_singleton()->load_assembly_from(ref_name, search_dir, ref_aname, &ref_assembly, true);
+ if (ref_assembly != NULL)
+ break;
+ }
+ }
+ }
+
+ if (!ref_assembly) {
+ ERR_EXPLAIN("Cannot load assembly (refonly): " + ref_name);
ERR_FAIL_V(ERR_CANT_RESOLVE);
}
r_dependencies.insert(ref_name, ref_assembly->get_path());
- Error err = _get_assembly_dependencies(ref_assembly, r_dependencies);
+ Error err = _get_assembly_dependencies(ref_assembly, p_search_dirs, r_dependencies);
if (err != OK)
return err;
}
diff --git a/modules/mono/editor/godotsharp_export.h b/modules/mono/editor/godotsharp_export.h
index b38db9660c..f007016578 100644
--- a/modules/mono/editor/godotsharp_export.h
+++ b/modules/mono/editor/godotsharp_export.h
@@ -43,13 +43,15 @@ class GodotSharpExport : public EditorExportPlugin {
bool _add_assembly(const String &p_src_path, const String &p_dst_path);
- Error _get_assembly_dependencies(GDMonoAssembly *p_assembly, Map<String, String> &r_dependencies);
+ Error _get_assembly_dependencies(GDMonoAssembly *p_assembly, const Vector<String> &p_search_dirs, Map<String, String> &r_dependencies);
protected:
virtual void _export_file(const String &p_path, const String &p_type, const Set<String> &p_features);
virtual void _export_begin(const Set<String> &p_features, bool p_debug, const String &p_path, int p_flags);
public:
+ static void register_internal_calls();
+
GodotSharpExport();
~GodotSharpExport();
};
diff --git a/modules/mono/editor/mono_bottom_panel.cpp b/modules/mono/editor/mono_bottom_panel.cpp
index 8d9b345a92..0ac59a1be8 100644
--- a/modules/mono/editor/mono_bottom_panel.cpp
+++ b/modules/mono/editor/mono_bottom_panel.cpp
@@ -63,7 +63,7 @@ void MonoBottomPanel::_update_build_tabs_list() {
item_tooltip += "Running";
}
- if (!tab->build_exited || !tab->build_result == MonoBuildTab::RESULT_SUCCESS) {
+ if (!tab->build_exited || tab->build_result == MonoBuildTab::RESULT_ERROR) {
item_tooltip += "\nErrors: " + itos(tab->error_count);
}
diff --git a/modules/mono/glue/Managed/Files/Extensions/NodeExtensions.cs b/modules/mono/glue/Managed/Files/Extensions/NodeExtensions.cs
index 71534d7782..366d89b1c2 100644
--- a/modules/mono/glue/Managed/Files/Extensions/NodeExtensions.cs
+++ b/modules/mono/glue/Managed/Files/Extensions/NodeExtensions.cs
@@ -2,42 +2,42 @@ namespace Godot
{
public partial class Node
{
- public T GetNode<T>(NodePath path) where T : Godot.Node
+ public T GetNode<T>(NodePath path) where T : class
{
- return (T)GetNode(path);
+ return (T)(object)GetNode(path);
}
- public T GetNodeOrNull<T>(NodePath path) where T : Godot.Node
+ public T GetNodeOrNull<T>(NodePath path) where T : class
{
return GetNode(path) as T;
}
- public T GetChild<T>(int idx) where T : Godot.Node
+ public T GetChild<T>(int idx) where T : class
{
- return (T)GetChild(idx);
+ return (T)(object)GetChild(idx);
}
- public T GetChildOrNull<T>(int idx) where T : Godot.Node
+ public T GetChildOrNull<T>(int idx) where T : class
{
return GetChild(idx) as T;
}
- public T GetOwner<T>() where T : Godot.Node
+ public T GetOwner<T>() where T : class
{
- return (T)GetOwner();
+ return (T)(object)GetOwner();
}
- public T GetOwnerOrNull<T>() where T : Godot.Node
+ public T GetOwnerOrNull<T>() where T : class
{
return GetOwner() as T;
}
- public T GetParent<T>() where T : Godot.Node
+ public T GetParent<T>() where T : class
{
- return (T)GetParent();
+ return (T)(object)GetParent();
}
- public T GetParentOrNull<T>() where T : Godot.Node
+ public T GetParentOrNull<T>() where T : class
{
return GetParent() as T;
}
diff --git a/modules/mono/glue/Managed/Files/Extensions/ResourceLoaderExtensions.cs b/modules/mono/glue/Managed/Files/Extensions/ResourceLoaderExtensions.cs
index ceecc589e6..684d160b57 100644
--- a/modules/mono/glue/Managed/Files/Extensions/ResourceLoaderExtensions.cs
+++ b/modules/mono/glue/Managed/Files/Extensions/ResourceLoaderExtensions.cs
@@ -2,9 +2,9 @@ namespace Godot
{
public static partial class ResourceLoader
{
- public static T Load<T>(string path) where T : Godot.Resource
+ public static T Load<T>(string path) where T : class
{
- return (T) Load(path);
+ return (T)(object)Load(path);
}
}
}
diff --git a/modules/mono/glue/Managed/Files/GD.cs b/modules/mono/glue/Managed/Files/GD.cs
index 264be23588..e4818e186c 100644
--- a/modules/mono/glue/Managed/Files/GD.cs
+++ b/modules/mono/glue/Managed/Files/GD.cs
@@ -65,9 +65,9 @@ namespace Godot
return ResourceLoader.Load(path);
}
- public static T Load<T>(string path) where T : Godot.Resource
+ public static T Load<T>(string path) where T : class
{
- return (T) ResourceLoader.Load(path);
+ return ResourceLoader.Load<T>(path);
}
public static void Print(params object[] what)
diff --git a/modules/mono/glue/nodepath_glue.cpp b/modules/mono/glue/nodepath_glue.cpp
index 4b7648a4f9..422d73104d 100644
--- a/modules/mono/glue/nodepath_glue.cpp
+++ b/modules/mono/glue/nodepath_glue.cpp
@@ -40,7 +40,7 @@ NodePath *godot_icall_NodePath_Ctor(MonoString *p_path) {
void godot_icall_NodePath_Dtor(NodePath *p_ptr) {
ERR_FAIL_NULL(p_ptr);
- _GodotSharp::get_singleton()->queue_dispose(p_ptr);
+ memdelete(p_ptr);
}
MonoString *godot_icall_NodePath_operator_String(NodePath *p_np) {
diff --git a/modules/mono/glue/rid_glue.cpp b/modules/mono/glue/rid_glue.cpp
index 5d66b8aa6f..6c002b5b9d 100644
--- a/modules/mono/glue/rid_glue.cpp
+++ b/modules/mono/glue/rid_glue.cpp
@@ -45,7 +45,7 @@ RID *godot_icall_RID_Ctor(Object *p_from) {
void godot_icall_RID_Dtor(RID *p_ptr) {
ERR_FAIL_NULL(p_ptr);
- _GodotSharp::get_singleton()->queue_dispose(p_ptr);
+ memdelete(p_ptr);
}
uint32_t godot_icall_RID_get_id(RID *p_ptr) {
diff --git a/modules/mono/godotsharp_dirs.cpp b/modules/mono/godotsharp_dirs.cpp
index 2570e68f13..d3fb2cb640 100644
--- a/modules/mono/godotsharp_dirs.cpp
+++ b/modules/mono/godotsharp_dirs.cpp
@@ -30,11 +30,11 @@
#include "godotsharp_dirs.h"
+#include "core/os/dir_access.h"
#include "core/os/os.h"
+#include "core/project_settings.h"
#ifdef TOOLS_ENABLED
-#include "core/os/dir_access.h"
-#include "core/project_settings.h"
#include "core/version.h"
#include "editor/editor_settings.h"
#endif
@@ -95,10 +95,18 @@ public:
#ifdef TOOLS_ENABLED
String mono_solutions_dir;
String build_logs_dir;
+
String sln_filepath;
String csproj_filepath;
+
+ String data_mono_bin_dir;
+ String data_editor_tools_dir;
+ String data_editor_prebuilt_api_dir;
#endif
+ String data_mono_etc_dir;
+ String data_mono_lib_dir;
+
private:
_GodotSharpDirs() {
res_data_dir = "res://.mono";
@@ -123,10 +131,60 @@ private:
name = "UnnamedProject";
}
- String base_path = String("res://") + name;
+ String base_path = ProjectSettings::get_singleton()->globalize_path("res://");
+
+ sln_filepath = base_path.plus_file(name + ".sln");
+ csproj_filepath = base_path.plus_file(name + ".csproj");
+#endif
+
+ String exe_dir = OS::get_singleton()->get_executable_path().get_base_dir();
+
+#ifdef TOOLS_ENABLED
+
+ String data_dir_root = exe_dir.plus_file("GodotSharp");
+ data_editor_tools_dir = data_dir_root.plus_file("Tools");
+ data_editor_prebuilt_api_dir = data_dir_root.plus_file("Api");
+
+ String data_mono_root_dir = data_dir_root.plus_file("Mono");
+ data_mono_bin_dir = data_mono_root_dir.plus_file("bin");
+ data_mono_etc_dir = data_mono_root_dir.plus_file("etc");
+ data_mono_lib_dir = data_mono_root_dir.plus_file("lib");
+
+#ifdef OSX_ENABLED
+ if (!DirAccess::exists(data_editor_tools_dir)) {
+ data_editor_tools_dir = exe_dir.plus_file("../Frameworks/GodotSharp/Tools");
+ }
+
+ if (!DirAccess::exists(data_editor_prebuilt_api_dir)) {
+ data_editor_prebuilt_api_dir = exe_dir.plus_file("../Frameworks/GodotSharp/Api");
+ }
+
+ if (!DirAccess::exists(data_mono_root_dir)) {
+ data_mono_bin_dir = exe_dir.plus_file("../Frameworks/GodotSharp/Mono/bin");
+ data_mono_etc_dir = exe_dir.plus_file("../Resources/GodotSharp/Mono/etc");
+ data_mono_lib_dir = exe_dir.plus_file("../Frameworks/GodotSharp/Mono/lib");
+ }
+#endif
+
+#else
+
+ String appname = OS::get_singleton()->get_safe_dir_name(ProjectSettings::get_singleton()->get("application/config/name"));
+ String data_dir_root = exe_dir.plus_file("data_" + appname);
+ if (!DirAccess::exists(data_dir_root)) {
+ data_dir_root = exe_dir.plus_file("data_Godot");
+ }
+
+ String data_mono_root_dir = data_dir_root.plus_file("Mono");
+ data_mono_etc_dir = data_mono_root_dir.plus_file("etc");
+ data_mono_lib_dir = data_mono_root_dir.plus_file("lib");
+
+#ifdef OSX_ENABLED
+ if (!DirAccess::exists(data_mono_root_dir)) {
+ data_mono_etc_dir = exe_dir.plus_file("../Resources/GodotSharp/Mono/etc");
+ data_mono_lib_dir = exe_dir.plus_file("../Frameworks/GodotSharp/Mono/lib");
+ }
+#endif
- sln_filepath = ProjectSettings::get_singleton()->globalize_path(base_path + ".sln");
- csproj_filepath = ProjectSettings::get_singleton()->globalize_path(base_path + ".csproj");
#endif
}
@@ -192,5 +250,26 @@ String get_project_sln_path() {
String get_project_csproj_path() {
return _GodotSharpDirs::get_singleton().csproj_filepath;
}
+
+String get_data_mono_bin_dir() {
+ return _GodotSharpDirs::get_singleton().data_mono_bin_dir;
+}
+
+String get_data_editor_tools_dir() {
+ return _GodotSharpDirs::get_singleton().data_editor_tools_dir;
+}
+
+String get_data_editor_prebuilt_api_dir() {
+ return _GodotSharpDirs::get_singleton().data_editor_prebuilt_api_dir;
+}
#endif
+
+String get_data_mono_etc_dir() {
+ return _GodotSharpDirs::get_singleton().data_mono_etc_dir;
+}
+
+String get_data_mono_lib_dir() {
+ return _GodotSharpDirs::get_singleton().data_mono_lib_dir;
+}
+
} // namespace GodotSharpDirs
diff --git a/modules/mono/godotsharp_dirs.h b/modules/mono/godotsharp_dirs.h
index 3466cb271d..35b564be30 100644
--- a/modules/mono/godotsharp_dirs.h
+++ b/modules/mono/godotsharp_dirs.h
@@ -49,11 +49,18 @@ String get_mono_logs_dir();
#ifdef TOOLS_ENABLED
String get_mono_solutions_dir();
String get_build_logs_dir();
-String get_custom_project_settings_dir();
-#endif
String get_project_sln_path();
String get_project_csproj_path();
+
+String get_data_mono_bin_dir();
+String get_data_editor_tools_dir();
+String get_data_editor_prebuilt_api_dir();
+#endif
+
+String get_data_mono_etc_dir();
+String get_data_mono_lib_dir();
+
} // namespace GodotSharpDirs
#endif // GODOTSHARP_DIRS_H
diff --git a/modules/mono/mono_gd/gd_mono.cpp b/modules/mono/mono_gd/gd_mono.cpp
index 9311aa3930..4d88cca6f1 100644
--- a/modules/mono/mono_gd/gd_mono.cpp
+++ b/modules/mono/mono_gd/gd_mono.cpp
@@ -162,50 +162,62 @@ void GDMono::initialize() {
mono_trace_set_printerr_handler(gdmono_MonoPrintCallback);
#endif
+ String assembly_rootdir;
+ String config_dir;
+
+#ifdef TOOLS_ENABLED
#ifdef WINDOWS_ENABLED
mono_reg_info = MonoRegUtils::find_mono();
- CharString assembly_dir;
- CharString config_dir;
-
if (mono_reg_info.assembly_dir.length() && DirAccess::exists(mono_reg_info.assembly_dir)) {
- assembly_dir = mono_reg_info.assembly_dir.utf8();
+ assembly_rootdir = mono_reg_info.assembly_dir;
}
if (mono_reg_info.config_dir.length() && DirAccess::exists(mono_reg_info.config_dir)) {
- config_dir = mono_reg_info.config_dir.utf8();
+ config_dir = mono_reg_info.config_dir;
}
-
- mono_set_dirs(assembly_dir.length() ? assembly_dir.get_data() : NULL,
- config_dir.length() ? config_dir.get_data() : NULL);
#elif OSX_ENABLED
- mono_set_dirs(NULL, NULL);
-
- {
- const char *assembly_rootdir = mono_assembly_getrootdir();
- const char *config_dir = mono_get_config_dir();
-
- if (!assembly_rootdir || !config_dir || !DirAccess::exists(assembly_rootdir) || !DirAccess::exists(config_dir)) {
- Vector<const char *> locations;
- locations.push_back("/Library/Frameworks/Mono.framework/Versions/Current/");
- locations.push_back("/usr/local/var/homebrew/linked/mono/");
-
- for (int i = 0; i < locations.size(); i++) {
- String hint_assembly_rootdir = path_join(locations[i], "lib");
- String hint_mscorlib_path = path_join(hint_assembly_rootdir, "mono", "4.5", "mscorlib.dll");
- String hint_config_dir = path_join(locations[i], "etc");
-
- if (FileAccess::exists(hint_mscorlib_path) && DirAccess::exists(hint_config_dir)) {
- mono_set_dirs(hint_assembly_rootdir.utf8().get_data(), hint_config_dir.utf8().get_data());
- break;
- }
+ const char *c_assembly_rootdir = mono_assembly_getrootdir();
+ const char *c_config_dir = mono_get_config_dir();
+
+ if (!c_assembly_rootdir || !c_config_dir || !DirAccess::exists(c_assembly_rootdir) || !DirAccess::exists(c_config_dir)) {
+ Vector<const char *> locations;
+ locations.push_back("/Library/Frameworks/Mono.framework/Versions/Current/");
+ locations.push_back("/usr/local/var/homebrew/linked/mono/");
+
+ for (int i = 0; i < locations.size(); i++) {
+ String hint_assembly_rootdir = path_join(locations[i], "lib");
+ String hint_mscorlib_path = path_join(hint_assembly_rootdir, "mono", "4.5", "mscorlib.dll");
+ String hint_config_dir = path_join(locations[i], "etc");
+
+ if (FileAccess::exists(hint_mscorlib_path) && DirAccess::exists(hint_config_dir)) {
+ assembly_rootdir = hint_assembly_rootdir;
+ config_dir = hint_config_dir;
+ break;
}
}
}
+#endif
+#endif // TOOLS_ENABLED
+
+ String bundled_assembly_rootdir = GodotSharpDirs::get_data_mono_lib_dir();
+ String bundled_config_dir = GodotSharpDirs::get_data_mono_etc_dir();
+
+#ifdef TOOLS_ENABLED
+ if (DirAccess::exists(bundled_assembly_rootdir) && DirAccess::exists(bundled_config_dir)) {
+ assembly_rootdir = bundled_assembly_rootdir;
+ config_dir = bundled_config_dir;
+ }
#else
- mono_set_dirs(NULL, NULL);
+ // These are always the directories in export templates
+ assembly_rootdir = bundled_assembly_rootdir;
+ config_dir = bundled_config_dir;
#endif
+ // Leak if we call mono_set_dirs more than once
+ mono_set_dirs(assembly_rootdir.length() ? assembly_rootdir.utf8().get_data() : NULL,
+ config_dir.length() ? config_dir.utf8().get_data() : NULL);
+
GDMonoAssembly::initialize();
#ifdef DEBUG_ENABLED
@@ -262,8 +274,11 @@ void GDMono::initialize() {
// Everything is fine with the api assemblies, load the project assembly
_load_project_assembly();
} else {
- if ((core_api_assembly && (core_api_assembly_out_of_sync || !GDMonoUtils::mono_cache.godot_api_cache_updated)) ||
- (editor_api_assembly && editor_api_assembly_out_of_sync)) {
+ if ((core_api_assembly && (core_api_assembly_out_of_sync || !GDMonoUtils::mono_cache.godot_api_cache_updated))
+#ifdef TOOLS_ENABLED
+ || (editor_api_assembly && editor_api_assembly_out_of_sync)
+#endif
+ ) {
#ifdef TOOLS_ENABLED
// The assembly was successfully loaded, but the full api could not be cached.
// This is most likely an outdated assembly loaded because of an invalid version in the
@@ -362,24 +377,34 @@ GDMonoAssembly **GDMono::get_loaded_assembly(const String &p_name) {
bool GDMono::load_assembly(const String &p_name, GDMonoAssembly **r_assembly, bool p_refonly) {
+ return load_assembly_from(p_name, String(), r_assembly, p_refonly);
+}
+
+bool GDMono::load_assembly(const String &p_name, MonoAssemblyName *p_aname, GDMonoAssembly **r_assembly, bool p_refonly) {
+
+ return load_assembly_from(p_name, String(), p_aname, r_assembly, p_refonly);
+}
+
+bool GDMono::load_assembly_from(const String &p_name, const String &p_basedir, GDMonoAssembly **r_assembly, bool p_refonly) {
+
CRASH_COND(!r_assembly);
MonoAssemblyName *aname = mono_assembly_name_new(p_name.utf8());
- bool result = load_assembly(p_name, aname, r_assembly, p_refonly);
+ bool result = load_assembly_from(p_name, p_basedir, aname, r_assembly, p_refonly);
mono_assembly_name_free(aname);
mono_free(aname);
return result;
}
-bool GDMono::load_assembly(const String &p_name, MonoAssemblyName *p_aname, GDMonoAssembly **r_assembly, bool p_refonly) {
+bool GDMono::load_assembly_from(const String &p_name, const String &p_basedir, MonoAssemblyName *p_aname, GDMonoAssembly **r_assembly, bool p_refonly) {
CRASH_COND(!r_assembly);
print_verbose("Mono: Loading assembly " + p_name + (p_refonly ? " (refonly)" : "") + "...");
MonoImageOpenStatus status = MONO_IMAGE_OK;
- MonoAssembly *assembly = mono_assembly_load_full(p_aname, NULL, &status, p_refonly);
+ MonoAssembly *assembly = mono_assembly_load_full(p_aname, p_basedir.length() ? p_basedir.utf8().get_data() : NULL, &status, p_refonly);
if (!assembly)
return false;
@@ -480,12 +505,10 @@ bool GDMono::_load_editor_api_assembly() {
if (editor_api_assembly)
return true;
-#ifdef TOOLS_ENABLED
if (metadata_is_api_assembly_invalidated(APIAssembly::API_EDITOR)) {
print_verbose("Mono: Skipping loading of Editor API assembly because it was invalidated");
return false;
}
-#endif
bool success = load_assembly(EDITOR_API_ASSEMBLY_NAME, &editor_api_assembly);
@@ -647,14 +670,18 @@ Error GDMono::_unload_scripts_domain() {
print_verbose("Mono: Unloading scripts domain...");
- _GodotSharp::get_singleton()->_dispose_callback();
-
if (mono_domain_get() != root_domain)
mono_domain_set(root_domain, true);
mono_gc_collect(mono_gc_max_generation());
- mono_domain_finalize(scripts_domain, 2000);
+ finalizing_scripts_domain = true;
+
+ if (!mono_domain_finalize(scripts_domain, 2000)) {
+ ERR_PRINT("Mono: Domain finalization timeout");
+ }
+
+ finalizing_scripts_domain = false;
mono_gc_collect(mono_gc_max_generation());
@@ -672,8 +699,6 @@ Error GDMono::_unload_scripts_domain() {
MonoDomain *domain = scripts_domain;
scripts_domain = NULL;
- _GodotSharp::get_singleton()->_dispose_callback();
-
MonoException *exc = NULL;
mono_domain_try_unload(domain, (MonoObject **)&exc);
@@ -772,11 +797,13 @@ Error GDMono::finalize_and_unload_domain(MonoDomain *p_domain) {
print_verbose("Mono: Unloading domain `" + domain_name + "`...");
- if (mono_domain_get() != root_domain)
+ if (mono_domain_get() == p_domain)
mono_domain_set(root_domain, true);
mono_gc_collect(mono_gc_max_generation());
- mono_domain_finalize(p_domain, 2000);
+ if (!mono_domain_finalize(p_domain, 2000)) {
+ ERR_PRINT("Mono: Domain finalization timeout");
+ }
mono_gc_collect(mono_gc_max_generation());
_domain_assemblies_cleanup(mono_domain_get_id(p_domain));
@@ -851,6 +878,7 @@ GDMono::GDMono() {
gdmono_log = memnew(GDMonoLog);
runtime_initialized = false;
+ finalizing_scripts_domain = false;
root_domain = NULL;
scripts_domain = NULL;
@@ -917,29 +945,6 @@ GDMono::~GDMono() {
_GodotSharp *_GodotSharp::singleton = NULL;
-void _GodotSharp::_dispose_callback() {
-
-#ifndef NO_THREADS
- queue_mutex->lock();
-#endif
-
- for (List<NodePath *>::Element *E = np_delete_queue.front(); E; E = E->next()) {
- memdelete(E->get());
- }
-
- for (List<RID *>::Element *E = rid_delete_queue.front(); E; E = E->next()) {
- memdelete(E->get());
- }
-
- np_delete_queue.clear();
- rid_delete_queue.clear();
- queue_empty = true;
-
-#ifndef NO_THREADS
- queue_mutex->unlock();
-#endif
-}
-
void _GodotSharp::attach_thread() {
GDMonoUtils::attach_current_thread();
@@ -988,6 +993,8 @@ bool _GodotSharp::is_domain_finalizing_for_unload(MonoDomain *p_domain) {
if (!p_domain)
return true;
+ if (p_domain == SCRIPTS_DOMAIN && GDMono::get_singleton()->is_finalizing_scripts_domain())
+ return true;
return mono_domain_is_unloading(p_domain);
}
@@ -1001,49 +1008,6 @@ bool _GodotSharp::is_runtime_initialized() {
return GDMono::get_singleton()->is_runtime_initialized();
}
-#define ENQUEUE_FOR_DISPOSAL(m_queue, m_inst) \
- m_queue.push_back(m_inst); \
- if (queue_empty) { \
- queue_empty = false; \
- if (!is_domain_finalizing_for_unload(SCRIPTS_DOMAIN)) { /* call_deferred may not be safe here */ \
- call_deferred("_dispose_callback"); \
- } \
- }
-
-void _GodotSharp::queue_dispose(NodePath *p_node_path) {
-
- if (GDMonoUtils::is_main_thread() && !is_domain_finalizing_for_unload(SCRIPTS_DOMAIN)) {
- memdelete(p_node_path);
- } else {
-#ifndef NO_THREADS
- queue_mutex->lock();
-#endif
-
- ENQUEUE_FOR_DISPOSAL(np_delete_queue, p_node_path);
-
-#ifndef NO_THREADS
- queue_mutex->unlock();
-#endif
- }
-}
-
-void _GodotSharp::queue_dispose(RID *p_rid) {
-
- if (GDMonoUtils::is_main_thread() && !is_domain_finalizing_for_unload(SCRIPTS_DOMAIN)) {
- memdelete(p_rid);
- } else {
-#ifndef NO_THREADS
- queue_mutex->lock();
-#endif
-
- ENQUEUE_FOR_DISPOSAL(rid_delete_queue, p_rid);
-
-#ifndef NO_THREADS
- queue_mutex->unlock();
-#endif
- }
-}
-
void _GodotSharp::_bind_methods() {
ClassDB::bind_method(D_METHOD("attach_thread"), &_GodotSharp::attach_thread);
@@ -1056,8 +1020,6 @@ void _GodotSharp::_bind_methods() {
ClassDB::bind_method(D_METHOD("is_runtime_shutting_down"), &_GodotSharp::is_runtime_shutting_down);
ClassDB::bind_method(D_METHOD("is_runtime_initialized"), &_GodotSharp::is_runtime_initialized);
-
- ClassDB::bind_method(D_METHOD("_dispose_callback"), &_GodotSharp::_dispose_callback);
}
_GodotSharp::_GodotSharp() {
diff --git a/modules/mono/mono_gd/gd_mono.h b/modules/mono/mono_gd/gd_mono.h
index 0c5503d28e..745dcc34eb 100644
--- a/modules/mono/mono_gd/gd_mono.h
+++ b/modules/mono/mono_gd/gd_mono.h
@@ -142,7 +142,7 @@ class GDMono {
GDMonoLog *gdmono_log;
-#ifdef WINDOWS_ENABLED
+#if defined(WINDOWS_ENABLED) && defined(TOOLS_ENABLED)
MonoRegInfo mono_reg_info;
#endif
@@ -172,6 +172,8 @@ public:
_FORCE_INLINE_ bool is_runtime_initialized() const { return runtime_initialized && !mono_runtime_is_shutting_down() /* stays true after shutdown finished */; }
+ _FORCE_INLINE_ bool is_finalizing_scripts_domain() { return finalizing_scripts_domain; }
+
_FORCE_INLINE_ MonoDomain *get_scripts_domain() { return scripts_domain; }
#ifdef TOOLS_ENABLED
_FORCE_INLINE_ MonoDomain *get_tools_domain() { return tools_domain; }
@@ -185,7 +187,7 @@ public:
_FORCE_INLINE_ GDMonoAssembly *get_editor_tools_assembly() const { return editor_tools_assembly; }
#endif
-#ifdef WINDOWS_ENABLED
+#if defined(WINDOWS_ENABLED) && defined(TOOLS_ENABLED)
const MonoRegInfo &get_mono_reg_info() { return mono_reg_info; }
#endif
@@ -197,6 +199,9 @@ public:
bool load_assembly(const String &p_name, GDMonoAssembly **r_assembly, bool p_refonly = false);
bool load_assembly(const String &p_name, MonoAssemblyName *p_aname, GDMonoAssembly **r_assembly, bool p_refonly = false);
+ bool load_assembly_from(const String &p_name, const String &p_basedir, GDMonoAssembly **r_assembly, bool p_refonly = false);
+ bool load_assembly_from(const String &p_name, const String &p_basedir, MonoAssemblyName *p_aname, GDMonoAssembly **r_assembly, bool p_refonly = false);
+
Error finalize_and_unload_domain(MonoDomain *p_domain);
void initialize();
@@ -205,12 +210,14 @@ public:
~GDMono();
};
-class GDMonoScopeDomain {
+namespace gdmono {
+
+class ScopeDomain {
MonoDomain *prev_domain;
public:
- GDMonoScopeDomain(MonoDomain *p_domain) {
+ ScopeDomain(MonoDomain *p_domain) {
MonoDomain *prev_domain = mono_domain_get();
if (prev_domain != p_domain) {
this->prev_domain = prev_domain;
@@ -220,23 +227,41 @@ public:
}
}
- ~GDMonoScopeDomain() {
+ ~ScopeDomain() {
if (prev_domain)
mono_domain_set(prev_domain, false);
}
};
-#define _GDMONO_SCOPE_DOMAIN_(m_mono_domain) \
- GDMonoScopeDomain __gdmono__scope__domain__(m_mono_domain); \
+class ScopeExitDomainUnload {
+ MonoDomain *domain;
+
+public:
+ ScopeExitDomainUnload(MonoDomain *p_domain) :
+ domain(p_domain) {
+ }
+
+ ~ScopeExitDomainUnload() {
+ if (domain)
+ GDMono::get_singleton()->finalize_and_unload_domain(domain);
+ }
+};
+
+} // namespace gdmono
+
+#define _GDMONO_SCOPE_DOMAIN_(m_mono_domain) \
+ gdmono::ScopeDomain __gdmono__scope__domain__(m_mono_domain); \
(void)__gdmono__scope__domain__;
+#define _GDMONO_SCOPE_EXIT_DOMAIN_UNLOAD_(m_mono_domain) \
+ gdmono::ScopeExitDomainUnload __gdmono__scope__exit__domain__unload__(m_mono_domain); \
+ (void)__gdmono__scope__exit__domain__unload__;
+
class _GodotSharp : public Object {
GDCLASS(_GodotSharp, Object)
friend class GDMono;
- void _dispose_callback();
-
bool _is_domain_finalizing_for_unload(int32_t p_domain_id);
List<NodePath *> np_delete_queue;
@@ -270,9 +295,6 @@ public:
bool is_runtime_shutting_down();
bool is_runtime_initialized();
- void queue_dispose(NodePath *p_node_path);
- void queue_dispose(RID *p_rid);
-
_GodotSharp();
~_GodotSharp();
};
diff --git a/modules/mono/mono_gd/gd_mono_assembly.cpp b/modules/mono/mono_gd/gd_mono_assembly.cpp
index 27ce39b6d7..1067c11e0e 100644
--- a/modules/mono/mono_gd/gd_mono_assembly.cpp
+++ b/modules/mono/mono_gd/gd_mono_assembly.cpp
@@ -46,6 +46,29 @@ bool GDMonoAssembly::in_preload = false;
Vector<String> GDMonoAssembly::search_dirs;
+void GDMonoAssembly::fill_search_dirs(Vector<String> &r_search_dirs, const String &p_custom_config) {
+
+ const char *rootdir = mono_assembly_getrootdir();
+ if (rootdir) {
+ String framework_dir = String(rootdir).plus_file("mono").plus_file("4.5");
+ r_search_dirs.push_back(framework_dir);
+ r_search_dirs.push_back(framework_dir.plus_file("Facades"));
+ }
+
+ if (p_custom_config.length()) {
+ r_search_dirs.push_back(GodotSharpDirs::get_res_temp_assemblies_base_dir().plus_file(p_custom_config));
+ } else {
+ r_search_dirs.push_back(GodotSharpDirs::get_res_temp_assemblies_dir());
+ }
+
+ r_search_dirs.push_back(GodotSharpDirs::get_res_assemblies_dir());
+ r_search_dirs.push_back(OS::get_singleton()->get_resource_dir());
+ r_search_dirs.push_back(OS::get_singleton()->get_executable_path().get_base_dir());
+#ifdef TOOLS_ENABLED
+ r_search_dirs.push_back(GodotSharpDirs::get_data_editor_tools_dir());
+#endif
+}
+
void GDMonoAssembly::assembly_load_hook(MonoAssembly *assembly, void *user_data) {
if (no_search)
@@ -93,35 +116,7 @@ MonoAssembly *GDMonoAssembly::_search_hook(MonoAssemblyName *aname, void *user_d
no_search = true; // Avoid the recursion madness
- String path;
- GDMonoAssembly *res = NULL;
-
- for (int i = 0; i < search_dirs.size(); i++) {
- const String &search_dir = search_dirs[i];
-
- if (has_extension) {
- path = search_dir.plus_file(name);
- if (FileAccess::exists(path)) {
- res = _load_assembly_from(name.get_basename(), path, refonly);
- if (res != NULL)
- break;
- }
- } else {
- path = search_dir.plus_file(name + ".dll");
- if (FileAccess::exists(path)) {
- res = _load_assembly_from(name, path, refonly);
- if (res != NULL)
- break;
- }
-
- path = search_dir.plus_file(name + ".exe");
- if (FileAccess::exists(path)) {
- res = _load_assembly_from(name, path, refonly);
- if (res != NULL)
- break;
- }
- }
- }
+ GDMonoAssembly *res = _load_assembly_search(name, search_dirs, refonly);
no_search = false;
@@ -130,31 +125,12 @@ MonoAssembly *GDMonoAssembly::_search_hook(MonoAssemblyName *aname, void *user_d
static _THREAD_LOCAL_(MonoImage *) image_corlib_loading = NULL;
-MonoAssembly *GDMonoAssembly::_preload_hook(MonoAssemblyName *aname, char **assemblies_path, void *user_data, bool refonly) {
+MonoAssembly *GDMonoAssembly::_preload_hook(MonoAssemblyName *aname, char **, void *user_data, bool refonly) {
(void)user_data; // UNUSED
if (search_dirs.empty()) {
- search_dirs.push_back(GodotSharpDirs::get_res_temp_assemblies_dir());
- search_dirs.push_back(GodotSharpDirs::get_res_assemblies_dir());
- search_dirs.push_back(OS::get_singleton()->get_resource_dir());
- search_dirs.push_back(OS::get_singleton()->get_executable_path().get_base_dir());
-#ifdef GD_MONO_EDITOR_ASSEMBLIES_DIR
- search_dirs.push_back(OS::get_singleton()->get_executable_path().get_base_dir().plus_file(_MKSTR(GD_MONO_EDITOR_ASSEMBLIES_DIR)).simplify_path());
-#endif
-
- const char *rootdir = mono_assembly_getrootdir();
- if (rootdir) {
- search_dirs.push_back(String(rootdir).plus_file("mono").plus_file("4.5"));
- search_dirs.push_back(String(rootdir).plus_file("mono").plus_file("4.5").plus_file("Facades"));
- }
-
- if (assemblies_path) {
- while (*assemblies_path) {
- search_dirs.push_back(*assemblies_path);
- ++assemblies_path;
- }
- }
+ fill_search_dirs(search_dirs);
}
{
@@ -188,27 +164,7 @@ MonoAssembly *GDMonoAssembly::_preload_hook(MonoAssemblyName *aname, char **asse
if (stored_assembly)
return (*stored_assembly)->get_assembly();
- String path;
-
- for (int i = 0; i < search_dirs.size(); i++) {
- const String &search_dir = search_dirs[i];
-
- if (has_extension) {
- path = search_dir.plus_file(name);
- if (FileAccess::exists(path)) {
- res = _load_assembly_from(name.get_basename(), path, refonly);
- if (res != NULL)
- break;
- }
- } else {
- path = search_dir.plus_file(name + ".dll");
- if (FileAccess::exists(path)) {
- res = _load_assembly_from(name, path, refonly);
- if (res != NULL)
- break;
- }
- }
- }
+ res = _load_assembly_search("mscorlib.dll", search_dirs, refonly);
}
no_search = false;
@@ -217,6 +173,43 @@ MonoAssembly *GDMonoAssembly::_preload_hook(MonoAssemblyName *aname, char **asse
return res ? res->get_assembly() : NULL;
}
+GDMonoAssembly *GDMonoAssembly::_load_assembly_search(const String &p_name, const Vector<String> &p_search_dirs, bool p_refonly) {
+
+ GDMonoAssembly *res = NULL;
+ String path;
+
+ bool has_extension = p_name.ends_with(".dll") || p_name.ends_with(".exe");
+
+ for (int i = 0; i < p_search_dirs.size(); i++) {
+ const String &search_dir = p_search_dirs[i];
+
+ if (has_extension) {
+ path = search_dir.plus_file(p_name);
+ if (FileAccess::exists(path)) {
+ res = _load_assembly_from(p_name.get_basename(), path, p_refonly);
+ if (res != NULL)
+ return res;
+ }
+ } else {
+ path = search_dir.plus_file(p_name + ".dll");
+ if (FileAccess::exists(path)) {
+ res = _load_assembly_from(p_name, path, p_refonly);
+ if (res != NULL)
+ return res;
+ }
+
+ path = search_dir.plus_file(p_name + ".exe");
+ if (FileAccess::exists(path)) {
+ res = _load_assembly_from(p_name, path, p_refonly);
+ if (res != NULL)
+ return res;
+ }
+ }
+ }
+
+ return NULL;
+}
+
GDMonoAssembly *GDMonoAssembly::_load_assembly_from(const String &p_name, const String &p_path, bool p_refonly) {
GDMonoAssembly *assembly = memnew(GDMonoAssembly(p_name, p_path));
@@ -464,19 +457,6 @@ GDMonoClass *GDMonoAssembly::get_object_derived_class(const StringName &p_class)
return match;
}
-GDMonoAssembly *GDMonoAssembly::load_from(const String &p_name, const String &p_path, bool p_refonly) {
-
- GDMonoAssembly **loaded_asm = GDMono::get_singleton()->get_loaded_assembly(p_name);
- if (loaded_asm)
- return *loaded_asm;
-
- no_search = true;
- GDMonoAssembly *res = _load_assembly_from(p_name, p_path, p_refonly);
- no_search = false;
-
- return res;
-}
-
GDMonoAssembly::GDMonoAssembly(const String &p_name, const String &p_path) {
loaded = false;
diff --git a/modules/mono/mono_gd/gd_mono_assembly.h b/modules/mono/mono_gd/gd_mono_assembly.h
index 0ba11ac412..4c9b1cb10d 100644
--- a/modules/mono/mono_gd/gd_mono_assembly.h
+++ b/modules/mono/mono_gd/gd_mono_assembly.h
@@ -102,6 +102,7 @@ class GDMonoAssembly {
static MonoAssembly *_preload_hook(MonoAssemblyName *aname, char **assemblies_path, void *user_data, bool refonly);
static GDMonoAssembly *_load_assembly_from(const String &p_name, const String &p_path, bool p_refonly);
+ static GDMonoAssembly *_load_assembly_search(const String &p_name, const Vector<String> &p_search_dirs, bool p_refonly);
static void _wrap_mono_assembly(MonoAssembly *assembly);
friend class GDMono;
@@ -125,7 +126,7 @@ public:
GDMonoClass *get_object_derived_class(const StringName &p_class);
- static GDMonoAssembly *load_from(const String &p_name, const String &p_path, bool p_refonly);
+ static void fill_search_dirs(Vector<String> &r_search_dirs, const String &p_custom_config = String());
GDMonoAssembly(const String &p_name, const String &p_path = String());
~GDMonoAssembly();
diff --git a/modules/mono/mono_gd/gd_mono_field.cpp b/modules/mono/mono_gd/gd_mono_field.cpp
index d3a673dc1b..fe41722af0 100644
--- a/modules/mono/mono_gd/gd_mono_field.cpp
+++ b/modules/mono/mono_gd/gd_mono_field.cpp
@@ -40,65 +40,71 @@ void GDMonoField::set_value_raw(MonoObject *p_object, void *p_ptr) {
}
void GDMonoField::set_value_from_variant(MonoObject *p_object, const Variant &p_value) {
-#define SET_FROM_STRUCT_AND_BREAK(m_type) \
- { \
- const m_type &val = p_value.operator ::m_type(); \
- MARSHALLED_OUT(m_type, val, raw); \
- mono_field_set_value(p_object, mono_field, raw); \
- break; \
+#define SET_FROM_STRUCT(m_type) \
+ { \
+ GDMonoMarshal::M_##m_type from = MARSHALLED_OUT(m_type, p_value.operator ::m_type()); \
+ mono_field_set_value(p_object, mono_field, &from); \
}
-#define SET_FROM_PRIMITIVE(m_type) \
- { \
- m_type val = p_value.operator m_type(); \
- mono_field_set_value(p_object, mono_field, &val); \
- break; \
- }
-
-#define SET_FROM_ARRAY_AND_BREAK(m_type) \
- { \
- MonoArray *managed = GDMonoMarshal::m_type##_to_mono_array(p_value.operator m_type()); \
- mono_field_set_value(p_object, mono_field, &managed); \
- break; \
+#define SET_FROM_ARRAY(m_type) \
+ { \
+ MonoArray *managed = GDMonoMarshal::m_type##_to_mono_array(p_value.operator ::m_type()); \
+ mono_field_set_value(p_object, mono_field, &managed); \
}
switch (type.type_encoding) {
case MONO_TYPE_BOOLEAN: {
- SET_FROM_PRIMITIVE(bool);
+ MonoBoolean val = p_value.operator bool();
+ mono_field_set_value(p_object, mono_field, &val);
+ } break;
+
+ case MONO_TYPE_CHAR: {
+ int16_t val = p_value.operator unsigned short();
+ mono_field_set_value(p_object, mono_field, &val);
} break;
case MONO_TYPE_I1: {
- SET_FROM_PRIMITIVE(signed char);
+ int8_t val = p_value.operator signed char();
+ mono_field_set_value(p_object, mono_field, &val);
} break;
case MONO_TYPE_I2: {
- SET_FROM_PRIMITIVE(signed short);
+ int16_t val = p_value.operator signed short();
+ mono_field_set_value(p_object, mono_field, &val);
} break;
case MONO_TYPE_I4: {
- SET_FROM_PRIMITIVE(signed int);
+ int32_t val = p_value.operator signed int();
+ mono_field_set_value(p_object, mono_field, &val);
} break;
case MONO_TYPE_I8: {
- SET_FROM_PRIMITIVE(int64_t);
+ int64_t val = p_value.operator int64_t();
+ mono_field_set_value(p_object, mono_field, &val);
} break;
case MONO_TYPE_U1: {
- SET_FROM_PRIMITIVE(unsigned char);
+ uint8_t val = p_value.operator unsigned char();
+ mono_field_set_value(p_object, mono_field, &val);
} break;
case MONO_TYPE_U2: {
- SET_FROM_PRIMITIVE(unsigned short);
+ uint16_t val = p_value.operator unsigned short();
+ mono_field_set_value(p_object, mono_field, &val);
} break;
case MONO_TYPE_U4: {
- SET_FROM_PRIMITIVE(unsigned int);
+ uint32_t val = p_value.operator unsigned int();
+ mono_field_set_value(p_object, mono_field, &val);
} break;
case MONO_TYPE_U8: {
- SET_FROM_PRIMITIVE(uint64_t);
+ uint64_t val = p_value.operator uint64_t();
+ mono_field_set_value(p_object, mono_field, &val);
} break;
case MONO_TYPE_R4: {
- SET_FROM_PRIMITIVE(float);
+ float val = p_value.operator float();
+ mono_field_set_value(p_object, mono_field, &val);
} break;
case MONO_TYPE_R8: {
- SET_FROM_PRIMITIVE(double);
+ double val = p_value.operator double();
+ mono_field_set_value(p_object, mono_field, &val);
} break;
case MONO_TYPE_STRING: {
@@ -109,38 +115,115 @@ void GDMonoField::set_value_from_variant(MonoObject *p_object, const Variant &p_
case MONO_TYPE_VALUETYPE: {
GDMonoClass *tclass = type.type_class;
- if (tclass == CACHED_CLASS(Vector2))
- SET_FROM_STRUCT_AND_BREAK(Vector2);
+ if (tclass == CACHED_CLASS(Vector2)) {
+ SET_FROM_STRUCT(Vector2);
+ break;
+ }
- if (tclass == CACHED_CLASS(Rect2))
- SET_FROM_STRUCT_AND_BREAK(Rect2);
+ if (tclass == CACHED_CLASS(Rect2)) {
+ SET_FROM_STRUCT(Rect2);
+ break;
+ }
- if (tclass == CACHED_CLASS(Transform2D))
- SET_FROM_STRUCT_AND_BREAK(Transform2D);
+ if (tclass == CACHED_CLASS(Transform2D)) {
+ SET_FROM_STRUCT(Transform2D);
+ break;
+ }
- if (tclass == CACHED_CLASS(Vector3))
- SET_FROM_STRUCT_AND_BREAK(Vector3);
+ if (tclass == CACHED_CLASS(Vector3)) {
+ SET_FROM_STRUCT(Vector3);
+ break;
+ }
- if (tclass == CACHED_CLASS(Basis))
- SET_FROM_STRUCT_AND_BREAK(Basis);
+ if (tclass == CACHED_CLASS(Basis)) {
+ SET_FROM_STRUCT(Basis);
+ break;
+ }
- if (tclass == CACHED_CLASS(Quat))
- SET_FROM_STRUCT_AND_BREAK(Quat);
+ if (tclass == CACHED_CLASS(Quat)) {
+ SET_FROM_STRUCT(Quat);
+ break;
+ }
- if (tclass == CACHED_CLASS(Transform))
- SET_FROM_STRUCT_AND_BREAK(Transform);
+ if (tclass == CACHED_CLASS(Transform)) {
+ SET_FROM_STRUCT(Transform);
+ break;
+ }
- if (tclass == CACHED_CLASS(AABB))
- SET_FROM_STRUCT_AND_BREAK(AABB);
+ if (tclass == CACHED_CLASS(AABB)) {
+ SET_FROM_STRUCT(AABB);
+ break;
+ }
- if (tclass == CACHED_CLASS(Color))
- SET_FROM_STRUCT_AND_BREAK(Color);
+ if (tclass == CACHED_CLASS(Color)) {
+ SET_FROM_STRUCT(Color);
+ break;
+ }
- if (tclass == CACHED_CLASS(Plane))
- SET_FROM_STRUCT_AND_BREAK(Plane);
+ if (tclass == CACHED_CLASS(Plane)) {
+ SET_FROM_STRUCT(Plane);
+ break;
+ }
- if (mono_class_is_enum(tclass->get_mono_ptr()))
- SET_FROM_PRIMITIVE(signed int);
+ if (mono_class_is_enum(tclass->get_mono_ptr())) {
+ MonoType *enum_basetype = mono_class_enum_basetype(tclass->get_mono_ptr());
+ switch (mono_type_get_type(enum_basetype)) {
+ case MONO_TYPE_BOOLEAN: {
+ MonoBoolean val = p_value.operator bool();
+ mono_field_set_value(p_object, mono_field, &val);
+ break;
+ }
+ case MONO_TYPE_CHAR: {
+ uint16_t val = p_value.operator unsigned short();
+ mono_field_set_value(p_object, mono_field, &val);
+ break;
+ }
+ case MONO_TYPE_I1: {
+ int8_t val = p_value.operator signed char();
+ mono_field_set_value(p_object, mono_field, &val);
+ break;
+ }
+ case MONO_TYPE_I2: {
+ int16_t val = p_value.operator signed short();
+ mono_field_set_value(p_object, mono_field, &val);
+ break;
+ }
+ case MONO_TYPE_I4: {
+ int32_t val = p_value.operator signed int();
+ mono_field_set_value(p_object, mono_field, &val);
+ break;
+ }
+ case MONO_TYPE_I8: {
+ int64_t val = p_value.operator int64_t();
+ mono_field_set_value(p_object, mono_field, &val);
+ break;
+ }
+ case MONO_TYPE_U1: {
+ uint8_t val = p_value.operator unsigned char();
+ mono_field_set_value(p_object, mono_field, &val);
+ break;
+ }
+ case MONO_TYPE_U2: {
+ uint16_t val = p_value.operator unsigned short();
+ mono_field_set_value(p_object, mono_field, &val);
+ break;
+ }
+ case MONO_TYPE_U4: {
+ uint32_t val = p_value.operator unsigned int();
+ mono_field_set_value(p_object, mono_field, &val);
+ break;
+ }
+ case MONO_TYPE_U8: {
+ uint64_t val = p_value.operator uint64_t();
+ mono_field_set_value(p_object, mono_field, &val);
+ break;
+ }
+ default: {
+ ERR_EXPLAIN(String() + "Attempted to convert Variant to a managed enum value of unmarshallable base type.");
+ ERR_FAIL();
+ }
+ }
+ }
ERR_EXPLAIN(String() + "Attempted to set the value of a field of unmarshallable type: " + tclass->get_name());
ERR_FAIL();
@@ -150,29 +233,45 @@ void GDMonoField::set_value_from_variant(MonoObject *p_object, const Variant &p_
case MONO_TYPE_SZARRAY: {
MonoArrayType *array_type = mono_type_get_array_type(type.type_class->get_mono_type());
- if (array_type->eklass == CACHED_CLASS_RAW(MonoObject))
- SET_FROM_ARRAY_AND_BREAK(Array);
+ if (array_type->eklass == CACHED_CLASS_RAW(MonoObject)) {
+ SET_FROM_ARRAY(Array);
+ break;
+ }
- if (array_type->eklass == CACHED_CLASS_RAW(uint8_t))
- SET_FROM_ARRAY_AND_BREAK(PoolByteArray);
+ if (array_type->eklass == CACHED_CLASS_RAW(uint8_t)) {
+ SET_FROM_ARRAY(PoolByteArray);
+ break;
+ }
- if (array_type->eklass == CACHED_CLASS_RAW(int32_t))
- SET_FROM_ARRAY_AND_BREAK(PoolIntArray);
+ if (array_type->eklass == CACHED_CLASS_RAW(int32_t)) {
+ SET_FROM_ARRAY(PoolIntArray);
+ break;
+ }
- if (array_type->eklass == REAL_T_MONOCLASS)
- SET_FROM_ARRAY_AND_BREAK(PoolRealArray);
+ if (array_type->eklass == REAL_T_MONOCLASS) {
+ SET_FROM_ARRAY(PoolRealArray);
+ break;
+ }
- if (array_type->eklass == CACHED_CLASS_RAW(String))
- SET_FROM_ARRAY_AND_BREAK(PoolStringArray);
+ if (array_type->eklass == CACHED_CLASS_RAW(String)) {
+ SET_FROM_ARRAY(PoolStringArray);
+ break;
+ }
- if (array_type->eklass == CACHED_CLASS_RAW(Vector2))
- SET_FROM_ARRAY_AND_BREAK(PoolVector2Array);
+ if (array_type->eklass == CACHED_CLASS_RAW(Vector2)) {
+ SET_FROM_ARRAY(PoolVector2Array);
+ break;
+ }
- if (array_type->eklass == CACHED_CLASS_RAW(Vector3))
- SET_FROM_ARRAY_AND_BREAK(PoolVector3Array);
+ if (array_type->eklass == CACHED_CLASS_RAW(Vector3)) {
+ SET_FROM_ARRAY(PoolVector3Array);
+ break;
+ }
- if (array_type->eklass == CACHED_CLASS_RAW(Color))
- SET_FROM_ARRAY_AND_BREAK(PoolColorArray);
+ if (array_type->eklass == CACHED_CLASS_RAW(Color)) {
+ SET_FROM_ARRAY(PoolColorArray);
+ break;
+ }
ERR_EXPLAIN(String() + "Attempted to convert Variant to a managed array of unmarshallable element type.");
ERR_FAIL();
@@ -220,32 +319,56 @@ void GDMonoField::set_value_from_variant(MonoObject *p_object, const Variant &p_
// Variant
switch (p_value.get_type()) {
case Variant::BOOL: {
- SET_FROM_PRIMITIVE(bool);
+ MonoBoolean val = p_value.operator bool();
+ mono_field_set_value(p_object, mono_field, &val);
} break;
case Variant::INT: {
- SET_FROM_PRIMITIVE(int);
+ int32_t val = p_value.operator signed int();
+ mono_field_set_value(p_object, mono_field, &val);
} break;
case Variant::REAL: {
#ifdef REAL_T_IS_DOUBLE
- SET_FROM_PRIMITIVE(double);
+ double val = p_value.operator double();
+ mono_field_set_value(p_object, mono_field, &val);
#else
- SET_FROM_PRIMITIVE(float);
+ float val = p_value.operator float();
+ mono_field_set_value(p_object, mono_field, &val);
#endif
} break;
case Variant::STRING: {
MonoString *mono_string = GDMonoMarshal::mono_string_from_godot(p_value);
mono_field_set_value(p_object, mono_field, mono_string);
} break;
- case Variant::VECTOR2: SET_FROM_STRUCT_AND_BREAK(Vector2);
- case Variant::RECT2: SET_FROM_STRUCT_AND_BREAK(Rect2);
- case Variant::VECTOR3: SET_FROM_STRUCT_AND_BREAK(Vector3);
- case Variant::TRANSFORM2D: SET_FROM_STRUCT_AND_BREAK(Transform2D);
- case Variant::PLANE: SET_FROM_STRUCT_AND_BREAK(Plane);
- case Variant::QUAT: SET_FROM_STRUCT_AND_BREAK(Quat);
- case Variant::AABB: SET_FROM_STRUCT_AND_BREAK(AABB);
- case Variant::BASIS: SET_FROM_STRUCT_AND_BREAK(Basis);
- case Variant::TRANSFORM: SET_FROM_STRUCT_AND_BREAK(Transform);
- case Variant::COLOR: SET_FROM_STRUCT_AND_BREAK(Color);
+ case Variant::VECTOR2: {
+ SET_FROM_STRUCT(Vector2);
+ } break;
+ case Variant::RECT2: {
+ SET_FROM_STRUCT(Rect2);
+ } break;
+ case Variant::VECTOR3: {
+ SET_FROM_STRUCT(Vector3);
+ } break;
+ case Variant::TRANSFORM2D: {
+ SET_FROM_STRUCT(Transform2D);
+ } break;
+ case Variant::PLANE: {
+ SET_FROM_STRUCT(Plane);
+ } break;
+ case Variant::QUAT: {
+ SET_FROM_STRUCT(Quat);
+ } break;
+ case Variant::AABB: {
+ SET_FROM_STRUCT(AABB);
+ } break;
+ case Variant::BASIS: {
+ SET_FROM_STRUCT(Basis);
+ } break;
+ case Variant::TRANSFORM: {
+ SET_FROM_STRUCT(Transform);
+ } break;
+ case Variant::COLOR: {
+ SET_FROM_STRUCT(Color);
+ } break;
case Variant::NODE_PATH: {
MonoObject *managed = GDMonoUtils::create_managed_from(p_value.operator NodePath());
mono_field_set_value(p_object, mono_field, managed);
@@ -267,14 +390,27 @@ void GDMonoField::set_value_from_variant(MonoObject *p_object, const Variant &p_
MonoObject *managed = GDMonoUtils::create_managed_from(p_value.operator Array(), CACHED_CLASS(Array));
mono_field_set_value(p_object, mono_field, managed);
} break;
- case Variant::POOL_BYTE_ARRAY: SET_FROM_ARRAY_AND_BREAK(PoolByteArray);
- case Variant::POOL_INT_ARRAY: SET_FROM_ARRAY_AND_BREAK(PoolIntArray);
- case Variant::POOL_REAL_ARRAY: SET_FROM_ARRAY_AND_BREAK(PoolRealArray);
- case Variant::POOL_STRING_ARRAY: SET_FROM_ARRAY_AND_BREAK(PoolStringArray);
- case Variant::POOL_VECTOR2_ARRAY: SET_FROM_ARRAY_AND_BREAK(PoolVector2Array);
- case Variant::POOL_VECTOR3_ARRAY: SET_FROM_ARRAY_AND_BREAK(PoolVector3Array);
- case Variant::POOL_COLOR_ARRAY: SET_FROM_ARRAY_AND_BREAK(PoolColorArray);
-#undef SET_FROM_ARRAY_AND_BREAK
+ case Variant::POOL_BYTE_ARRAY: {
+ SET_FROM_ARRAY(PoolByteArray);
+ } break;
+ case Variant::POOL_INT_ARRAY: {
+ SET_FROM_ARRAY(PoolIntArray);
+ } break;
+ case Variant::POOL_REAL_ARRAY: {
+ SET_FROM_ARRAY(PoolRealArray);
+ } break;
+ case Variant::POOL_STRING_ARRAY: {
+ SET_FROM_ARRAY(PoolStringArray);
+ } break;
+ case Variant::POOL_VECTOR2_ARRAY: {
+ SET_FROM_ARRAY(PoolVector2Array);
+ } break;
+ case Variant::POOL_VECTOR3_ARRAY: {
+ SET_FROM_ARRAY(PoolVector3Array);
+ } break;
+ case Variant::POOL_COLOR_ARRAY: {
+ SET_FROM_ARRAY(PoolColorArray);
+ } break;
default: break;
}
} break;
@@ -312,8 +448,8 @@ void GDMonoField::set_value_from_variant(MonoObject *p_object, const Variant &p_
} break;
}
+#undef SET_FROM_ARRAY_AND_BREAK
#undef SET_FROM_STRUCT_AND_BREAK
-#undef SET_FROM_PRIMITIVE
}
MonoObject *GDMonoField::get_value(MonoObject *p_object) {
diff --git a/modules/mono/mono_gd/gd_mono_header.h b/modules/mono/mono_gd/gd_mono_header.h
index 4f2efc7b92..51d0c9b356 100644
--- a/modules/mono/mono_gd/gd_mono_header.h
+++ b/modules/mono/mono_gd/gd_mono_header.h
@@ -55,14 +55,4 @@ struct ManagedType {
}
};
-typedef union {
- uint32_t _uint32;
- float _float;
-} mono_float;
-
-typedef union {
- uint64_t _uint64;
- float _double;
-} mono_double;
-
#endif // GD_MONO_HEADER_H
diff --git a/modules/mono/mono_gd/gd_mono_marshal.cpp b/modules/mono/mono_gd/gd_mono_marshal.cpp
index de91e71bab..2543f5dc47 100644
--- a/modules/mono/mono_gd/gd_mono_marshal.cpp
+++ b/modules/mono/mono_gd/gd_mono_marshal.cpp
@@ -35,20 +35,6 @@
namespace GDMonoMarshal {
-#define RETURN_BOXED_STRUCT(m_t, m_var_in) \
- { \
- const m_t &m_in = m_var_in->operator ::m_t(); \
- MARSHALLED_OUT(m_t, m_in, raw); \
- return mono_value_box(mono_domain_get(), CACHED_CLASS_RAW(m_t), raw); \
- }
-
-#define RETURN_UNBOXED_STRUCT(m_t, m_var_in) \
- { \
- float *raw = (float *)mono_object_unbox(m_var_in); \
- MARSHALLED_IN(m_t, raw, ret); \
- return ret; \
- }
-
Variant::Type managed_to_variant_type(const ManagedType &p_type) {
switch (p_type.type_encoding) {
case MONO_TYPE_BOOLEAN:
@@ -252,16 +238,21 @@ MonoObject *variant_to_mono_object(const Variant *p_var, const ManagedType &p_ty
return BOX_BOOLEAN(val);
}
+ case MONO_TYPE_CHAR: {
+ uint16_t val = p_var->operator unsigned short();
+ return BOX_UINT16(val);
+ }
+
case MONO_TYPE_I1: {
- char val = p_var->operator signed char();
+ int8_t val = p_var->operator signed char();
return BOX_INT8(val);
}
case MONO_TYPE_I2: {
- short val = p_var->operator signed short();
+ int16_t val = p_var->operator signed short();
return BOX_INT16(val);
}
case MONO_TYPE_I4: {
- int val = p_var->operator signed int();
+ int32_t val = p_var->operator signed int();
return BOX_INT32(val);
}
case MONO_TYPE_I8: {
@@ -270,15 +261,15 @@ MonoObject *variant_to_mono_object(const Variant *p_var, const ManagedType &p_ty
}
case MONO_TYPE_U1: {
- char val = p_var->operator unsigned char();
+ uint8_t val = p_var->operator unsigned char();
return BOX_UINT8(val);
}
case MONO_TYPE_U2: {
- short val = p_var->operator unsigned short();
+ uint16_t val = p_var->operator unsigned short();
return BOX_UINT16(val);
}
case MONO_TYPE_U4: {
- int val = p_var->operator unsigned int();
+ uint32_t val = p_var->operator unsigned int();
return BOX_UINT32(val);
}
case MONO_TYPE_U8: {
@@ -302,39 +293,105 @@ MonoObject *variant_to_mono_object(const Variant *p_var, const ManagedType &p_ty
case MONO_TYPE_VALUETYPE: {
GDMonoClass *tclass = p_type.type_class;
- if (tclass == CACHED_CLASS(Vector2))
- RETURN_BOXED_STRUCT(Vector2, p_var);
+ if (tclass == CACHED_CLASS(Vector2)) {
+ GDMonoMarshal::M_Vector2 from = MARSHALLED_OUT(Vector2, p_var->operator ::Vector2());
+ return mono_value_box(mono_domain_get(), CACHED_CLASS_RAW(Vector2), &from);
+ }
- if (tclass == CACHED_CLASS(Rect2))
- RETURN_BOXED_STRUCT(Rect2, p_var);
+ if (tclass == CACHED_CLASS(Rect2)) {
+ GDMonoMarshal::M_Rect2 from = MARSHALLED_OUT(Rect2, p_var->operator ::Rect2());
+ return mono_value_box(mono_domain_get(), CACHED_CLASS_RAW(Rect2), &from);
+ }
- if (tclass == CACHED_CLASS(Transform2D))
- RETURN_BOXED_STRUCT(Transform2D, p_var);
+ if (tclass == CACHED_CLASS(Transform2D)) {
+ GDMonoMarshal::M_Transform2D from = MARSHALLED_OUT(Transform2D, p_var->operator ::Transform2D());
+ return mono_value_box(mono_domain_get(), CACHED_CLASS_RAW(Transform2D), &from);
+ }
- if (tclass == CACHED_CLASS(Vector3))
- RETURN_BOXED_STRUCT(Vector3, p_var);
+ if (tclass == CACHED_CLASS(Vector3)) {
+ GDMonoMarshal::M_Vector3 from = MARSHALLED_OUT(Vector3, p_var->operator ::Vector3());
+ return mono_value_box(mono_domain_get(), CACHED_CLASS_RAW(Vector3), &from);
+ }
- if (tclass == CACHED_CLASS(Basis))
- RETURN_BOXED_STRUCT(Basis, p_var);
+ if (tclass == CACHED_CLASS(Basis)) {
+ GDMonoMarshal::M_Basis from = MARSHALLED_OUT(Basis, p_var->operator ::Basis());
+ return mono_value_box(mono_domain_get(), CACHED_CLASS_RAW(Basis), &from);
+ }
- if (tclass == CACHED_CLASS(Quat))
- RETURN_BOXED_STRUCT(Quat, p_var);
+ if (tclass == CACHED_CLASS(Quat)) {
+ GDMonoMarshal::M_Quat from = MARSHALLED_OUT(Quat, p_var->operator ::Quat());
+ return mono_value_box(mono_domain_get(), CACHED_CLASS_RAW(Quat), &from);
+ }
- if (tclass == CACHED_CLASS(Transform))
- RETURN_BOXED_STRUCT(Transform, p_var);
+ if (tclass == CACHED_CLASS(Transform)) {
+ GDMonoMarshal::M_Transform from = MARSHALLED_OUT(Transform, p_var->operator ::Transform());
+ return mono_value_box(mono_domain_get(), CACHED_CLASS_RAW(Transform), &from);
+ }
- if (tclass == CACHED_CLASS(AABB))
- RETURN_BOXED_STRUCT(AABB, p_var);
+ if (tclass == CACHED_CLASS(AABB)) {
+ GDMonoMarshal::M_AABB from = MARSHALLED_OUT(AABB, p_var->operator ::AABB());
+ return mono_value_box(mono_domain_get(), CACHED_CLASS_RAW(AABB), &from);
+ }
- if (tclass == CACHED_CLASS(Color))
- RETURN_BOXED_STRUCT(Color, p_var);
+ if (tclass == CACHED_CLASS(Color)) {
+ GDMonoMarshal::M_Color from = MARSHALLED_OUT(Color, p_var->operator ::Color());
+ return mono_value_box(mono_domain_get(), CACHED_CLASS_RAW(Color), &from);
+ }
- if (tclass == CACHED_CLASS(Plane))
- RETURN_BOXED_STRUCT(Plane, p_var);
+ if (tclass == CACHED_CLASS(Plane)) {
+ GDMonoMarshal::M_Plane from = MARSHALLED_OUT(Plane, p_var->operator ::Plane());
+ return mono_value_box(mono_domain_get(), CACHED_CLASS_RAW(Plane), &from);
+ }
if (mono_class_is_enum(tclass->get_mono_ptr())) {
- int val = p_var->operator signed int();
- return BOX_ENUM(tclass->get_mono_ptr(), val);
+ MonoType *enum_basetype = mono_class_enum_basetype(tclass->get_mono_ptr());
+ MonoClass *enum_baseclass = mono_class_from_mono_type(enum_basetype);
+ switch (mono_type_get_type(enum_basetype)) {
+ case MONO_TYPE_BOOLEAN: {
+ MonoBoolean val = p_var->operator bool();
+ return BOX_ENUM(enum_baseclass, val);
+ }
+ case MONO_TYPE_CHAR: {
+ uint16_t val = p_var->operator unsigned short();
+ return BOX_ENUM(enum_baseclass, val);
+ }
+ case MONO_TYPE_I1: {
+ int8_t val = p_var->operator signed char();
+ return BOX_ENUM(enum_baseclass, val);
+ }
+ case MONO_TYPE_I2: {
+ int16_t val = p_var->operator signed short();
+ return BOX_ENUM(enum_baseclass, val);
+ }
+ case MONO_TYPE_I4: {
+ int32_t val = p_var->operator signed int();
+ return BOX_ENUM(enum_baseclass, val);
+ }
+ case MONO_TYPE_I8: {
+ int64_t val = p_var->operator int64_t();
+ return BOX_ENUM(enum_baseclass, val);
+ }
+ case MONO_TYPE_U1: {
+ uint8_t val = p_var->operator unsigned char();
+ return BOX_ENUM(enum_baseclass, val);
+ }
+ case MONO_TYPE_U2: {
+ uint16_t val = p_var->operator unsigned short();
+ return BOX_ENUM(enum_baseclass, val);
+ }
+ case MONO_TYPE_U4: {
+ uint32_t val = p_var->operator unsigned int();
+ return BOX_ENUM(enum_baseclass, val);
+ }
+ case MONO_TYPE_U8: {
+ uint64_t val = p_var->operator uint64_t();
+ return BOX_ENUM(enum_baseclass, val);
+ }
+ default: {
+ ERR_EXPLAIN(String() + "Attempted to convert Variant to a managed enum value of unmarshallable base type.");
+ ERR_FAIL_V(NULL);
+ }
+ }
}
} break;
@@ -402,7 +459,7 @@ MonoObject *variant_to_mono_object(const Variant *p_var, const ManagedType &p_ty
return BOX_BOOLEAN(val);
}
case Variant::INT: {
- int val = p_var->operator signed int();
+ int32_t val = p_var->operator signed int();
return BOX_INT32(val);
}
case Variant::REAL: {
@@ -416,33 +473,52 @@ MonoObject *variant_to_mono_object(const Variant *p_var, const ManagedType &p_ty
}
case Variant::STRING:
return (MonoObject *)mono_string_from_godot(p_var->operator String());
- case Variant::VECTOR2:
- RETURN_BOXED_STRUCT(Vector2, p_var);
- case Variant::RECT2:
- RETURN_BOXED_STRUCT(Rect2, p_var);
- case Variant::VECTOR3:
- RETURN_BOXED_STRUCT(Vector3, p_var);
- case Variant::TRANSFORM2D:
- RETURN_BOXED_STRUCT(Transform2D, p_var);
- case Variant::PLANE:
- RETURN_BOXED_STRUCT(Plane, p_var);
- case Variant::QUAT:
- RETURN_BOXED_STRUCT(Quat, p_var);
- case Variant::AABB:
- RETURN_BOXED_STRUCT(AABB, p_var);
- case Variant::BASIS:
- RETURN_BOXED_STRUCT(Basis, p_var);
- case Variant::TRANSFORM:
- RETURN_BOXED_STRUCT(Transform, p_var);
- case Variant::COLOR:
- RETURN_BOXED_STRUCT(Color, p_var);
+ case Variant::VECTOR2: {
+ GDMonoMarshal::M_Vector2 from = MARSHALLED_OUT(Vector2, p_var->operator ::Vector2());
+ return mono_value_box(mono_domain_get(), CACHED_CLASS_RAW(Vector2), &from);
+ }
+ case Variant::RECT2: {
+ GDMonoMarshal::M_Rect2 from = MARSHALLED_OUT(Rect2, p_var->operator ::Rect2());
+ return mono_value_box(mono_domain_get(), CACHED_CLASS_RAW(Rect2), &from);
+ }
+ case Variant::VECTOR3: {
+ GDMonoMarshal::M_Vector3 from = MARSHALLED_OUT(Vector3, p_var->operator ::Vector3());
+ return mono_value_box(mono_domain_get(), CACHED_CLASS_RAW(Vector3), &from);
+ }
+ case Variant::TRANSFORM2D: {
+ GDMonoMarshal::M_Transform2D from = MARSHALLED_OUT(Transform2D, p_var->operator ::Transform2D());
+ return mono_value_box(mono_domain_get(), CACHED_CLASS_RAW(Transform2D), &from);
+ }
+ case Variant::PLANE: {
+ GDMonoMarshal::M_Plane from = MARSHALLED_OUT(Plane, p_var->operator ::Plane());
+ return mono_value_box(mono_domain_get(), CACHED_CLASS_RAW(Plane), &from);
+ }
+ case Variant::QUAT: {
+ GDMonoMarshal::M_Quat from = MARSHALLED_OUT(Quat, p_var->operator ::Quat());
+ return mono_value_box(mono_domain_get(), CACHED_CLASS_RAW(Quat), &from);
+ }
+ case Variant::AABB: {
+ GDMonoMarshal::M_AABB from = MARSHALLED_OUT(AABB, p_var->operator ::AABB());
+ return mono_value_box(mono_domain_get(), CACHED_CLASS_RAW(AABB), &from);
+ }
+ case Variant::BASIS: {
+ GDMonoMarshal::M_Basis from = MARSHALLED_OUT(Basis, p_var->operator ::Basis());
+ return mono_value_box(mono_domain_get(), CACHED_CLASS_RAW(Basis), &from);
+ }
+ case Variant::TRANSFORM: {
+ GDMonoMarshal::M_Transform from = MARSHALLED_OUT(Transform, p_var->operator ::Transform());
+ return mono_value_box(mono_domain_get(), CACHED_CLASS_RAW(Transform), &from);
+ }
+ case Variant::COLOR: {
+ GDMonoMarshal::M_Color from = MARSHALLED_OUT(Color, p_var->operator ::Color());
+ return mono_value_box(mono_domain_get(), CACHED_CLASS_RAW(Color), &from);
+ }
case Variant::NODE_PATH:
return GDMonoUtils::create_managed_from(p_var->operator NodePath());
case Variant::_RID:
return GDMonoUtils::create_managed_from(p_var->operator RID());
- case Variant::OBJECT: {
+ case Variant::OBJECT:
return GDMonoUtils::unmanaged_get_managed(p_var->operator Object *());
- }
case Variant::DICTIONARY:
return GDMonoUtils::create_managed_from(p_var->operator Dictionary(), CACHED_CLASS(Dictionary));
case Variant::ARRAY:
@@ -512,6 +588,9 @@ Variant mono_object_to_variant(MonoObject *p_obj) {
case MONO_TYPE_BOOLEAN:
return (bool)unbox<MonoBoolean>(p_obj);
+ case MONO_TYPE_CHAR:
+ return unbox<uint16_t>(p_obj);
+
case MONO_TYPE_I1:
return unbox<int8_t>(p_obj);
case MONO_TYPE_I2:
@@ -545,34 +624,34 @@ Variant mono_object_to_variant(MonoObject *p_obj) {
GDMonoClass *tclass = type.type_class;
if (tclass == CACHED_CLASS(Vector2))
- RETURN_UNBOXED_STRUCT(Vector2, p_obj);
+ return MARSHALLED_IN(Vector2, (GDMonoMarshal::M_Vector2 *)mono_object_unbox(p_obj));
if (tclass == CACHED_CLASS(Rect2))
- RETURN_UNBOXED_STRUCT(Rect2, p_obj);
+ return MARSHALLED_IN(Rect2, (GDMonoMarshal::M_Rect2 *)mono_object_unbox(p_obj));
if (tclass == CACHED_CLASS(Transform2D))
- RETURN_UNBOXED_STRUCT(Transform2D, p_obj);
+ return MARSHALLED_IN(Transform2D, (GDMonoMarshal::M_Transform2D *)mono_object_unbox(p_obj));
if (tclass == CACHED_CLASS(Vector3))
- RETURN_UNBOXED_STRUCT(Vector3, p_obj);
+ return MARSHALLED_IN(Vector3, (GDMonoMarshal::M_Vector3 *)mono_object_unbox(p_obj));
if (tclass == CACHED_CLASS(Basis))
- RETURN_UNBOXED_STRUCT(Basis, p_obj);
+ return MARSHALLED_IN(Basis, (GDMonoMarshal::M_Basis *)mono_object_unbox(p_obj));
if (tclass == CACHED_CLASS(Quat))
- RETURN_UNBOXED_STRUCT(Quat, p_obj);
+ return MARSHALLED_IN(Quat, (GDMonoMarshal::M_Quat *)mono_object_unbox(p_obj));
if (tclass == CACHED_CLASS(Transform))
- RETURN_UNBOXED_STRUCT(Transform, p_obj);
+ return MARSHALLED_IN(Transform, (GDMonoMarshal::M_Transform *)mono_object_unbox(p_obj));
if (tclass == CACHED_CLASS(AABB))
- RETURN_UNBOXED_STRUCT(AABB, p_obj);
+ return MARSHALLED_IN(AABB, (GDMonoMarshal::M_AABB *)mono_object_unbox(p_obj));
if (tclass == CACHED_CLASS(Color))
- RETURN_UNBOXED_STRUCT(Color, p_obj);
+ return MARSHALLED_IN(Color, (GDMonoMarshal::M_Color *)mono_object_unbox(p_obj));
if (tclass == CACHED_CLASS(Plane))
- RETURN_UNBOXED_STRUCT(Plane, p_obj);
+ return MARSHALLED_IN(Plane, (GDMonoMarshal::M_Plane *)mono_object_unbox(p_obj));
if (mono_class_is_enum(tclass->get_mono_ptr()))
return unbox<int32_t>(p_obj);
@@ -708,13 +787,13 @@ Array mono_array_to_Array(MonoArray *p_array) {
return ret;
}
-// TODO Optimize reading/writing from/to PoolArrays
-
MonoArray *PoolIntArray_to_mono_array(const PoolIntArray &p_array) {
+ PoolIntArray::Read r = p_array.read();
+
MonoArray *ret = mono_array_new(mono_domain_get(), CACHED_CLASS_RAW(int32_t), p_array.size());
for (int i = 0; i < p_array.size(); i++) {
- mono_array_set(ret, int32_t, i, p_array[i]);
+ mono_array_set(ret, int32_t, i, r[i]);
}
return ret;
@@ -726,19 +805,22 @@ PoolIntArray mono_array_to_PoolIntArray(MonoArray *p_array) {
return ret;
int length = mono_array_length(p_array);
ret.resize(length);
+ PoolIntArray::Write w = ret.write();
+
for (int i = 0; i < length; i++) {
- int32_t elem = mono_array_get(p_array, int32_t, i);
- ret.set(i, elem);
+ w[i] = mono_array_get(p_array, int32_t, i);
}
return ret;
}
MonoArray *PoolByteArray_to_mono_array(const PoolByteArray &p_array) {
+ PoolByteArray::Read r = p_array.read();
+
MonoArray *ret = mono_array_new(mono_domain_get(), CACHED_CLASS_RAW(uint8_t), p_array.size());
for (int i = 0; i < p_array.size(); i++) {
- mono_array_set(ret, uint8_t, i, p_array[i]);
+ mono_array_set(ret, uint8_t, i, r[i]);
}
return ret;
@@ -750,20 +832,22 @@ PoolByteArray mono_array_to_PoolByteArray(MonoArray *p_array) {
return ret;
int length = mono_array_length(p_array);
ret.resize(length);
+ PoolByteArray::Write w = ret.write();
for (int i = 0; i < length; i++) {
- uint8_t elem = mono_array_get(p_array, uint8_t, i);
- ret.set(i, elem);
+ w[i] = mono_array_get(p_array, uint8_t, i);
}
return ret;
}
MonoArray *PoolRealArray_to_mono_array(const PoolRealArray &p_array) {
+ PoolRealArray::Read r = p_array.read();
+
MonoArray *ret = mono_array_new(mono_domain_get(), REAL_T_MONOCLASS, p_array.size());
for (int i = 0; i < p_array.size(); i++) {
- mono_array_set(ret, real_t, i, p_array[i]);
+ mono_array_set(ret, real_t, i, r[i]);
}
return ret;
@@ -775,20 +859,22 @@ PoolRealArray mono_array_to_PoolRealArray(MonoArray *p_array) {
return ret;
int length = mono_array_length(p_array);
ret.resize(length);
+ PoolRealArray::Write w = ret.write();
for (int i = 0; i < length; i++) {
- real_t elem = mono_array_get(p_array, real_t, i);
- ret.set(i, elem);
+ w[i] = mono_array_get(p_array, real_t, i);
}
return ret;
}
MonoArray *PoolStringArray_to_mono_array(const PoolStringArray &p_array) {
+ PoolStringArray::Read r = p_array.read();
+
MonoArray *ret = mono_array_new(mono_domain_get(), CACHED_CLASS_RAW(String), p_array.size());
for (int i = 0; i < p_array.size(); i++) {
- MonoString *boxed = mono_string_from_godot(p_array[i]);
+ MonoString *boxed = mono_string_from_godot(r[i]);
mono_array_set(ret, MonoString *, i, boxed);
}
@@ -801,29 +887,24 @@ PoolStringArray mono_array_to_PoolStringArray(MonoArray *p_array) {
return ret;
int length = mono_array_length(p_array);
ret.resize(length);
+ PoolStringArray::Write w = ret.write();
for (int i = 0; i < length; i++) {
MonoString *elem = mono_array_get(p_array, MonoString *, i);
- ret.set(i, mono_string_to_godot(elem));
+ w[i] = mono_string_to_godot(elem);
}
return ret;
}
MonoArray *PoolColorArray_to_mono_array(const PoolColorArray &p_array) {
+ PoolColorArray::Read r = p_array.read();
+
MonoArray *ret = mono_array_new(mono_domain_get(), CACHED_CLASS_RAW(Color), p_array.size());
for (int i = 0; i < p_array.size(); i++) {
-#ifdef YOLOCOPY
- mono_array_set(ret, Color, i, p_array[i]);
-#else
- real_t *raw = (real_t *)mono_array_addr_with_size(ret, sizeof(real_t) * 4, i);
- const Color &elem = p_array[i];
- raw[0] = elem.r;
- raw[1] = elem.g;
- raw[2] = elem.b;
- raw[3] = elem.a;
-#endif
+ M_Color *raw = (M_Color *)mono_array_addr_with_size(ret, sizeof(M_Color), i);
+ *raw = MARSHALLED_OUT(Color, r[i]);
}
return ret;
@@ -835,28 +916,23 @@ PoolColorArray mono_array_to_PoolColorArray(MonoArray *p_array) {
return ret;
int length = mono_array_length(p_array);
ret.resize(length);
+ PoolColorArray::Write w = ret.write();
for (int i = 0; i < length; i++) {
- real_t *raw_elem = (real_t *)mono_array_addr_with_size(p_array, sizeof(real_t) * 4, i);
- MARSHALLED_IN(Color, raw_elem, elem);
- ret.set(i, elem);
+ w[i] = MARSHALLED_IN(Color, (M_Color *)mono_array_addr_with_size(p_array, sizeof(M_Color), i));
}
return ret;
}
MonoArray *PoolVector2Array_to_mono_array(const PoolVector2Array &p_array) {
+ PoolVector2Array::Read r = p_array.read();
+
MonoArray *ret = mono_array_new(mono_domain_get(), CACHED_CLASS_RAW(Vector2), p_array.size());
for (int i = 0; i < p_array.size(); i++) {
-#ifdef YOLOCOPY
- mono_array_set(ret, Vector2, i, p_array[i]);
-#else
- real_t *raw = (real_t *)mono_array_addr_with_size(ret, sizeof(real_t) * 2, i);
- const Vector2 &elem = p_array[i];
- raw[0] = elem.x;
- raw[1] = elem.y;
-#endif
+ M_Vector2 *raw = (M_Vector2 *)mono_array_addr_with_size(ret, sizeof(M_Vector2), i);
+ *raw = MARSHALLED_OUT(Vector2, r[i]);
}
return ret;
@@ -868,29 +944,23 @@ PoolVector2Array mono_array_to_PoolVector2Array(MonoArray *p_array) {
return ret;
int length = mono_array_length(p_array);
ret.resize(length);
+ PoolVector2Array::Write w = ret.write();
for (int i = 0; i < length; i++) {
- real_t *raw_elem = (real_t *)mono_array_addr_with_size(p_array, sizeof(real_t) * 2, i);
- MARSHALLED_IN(Vector2, raw_elem, elem);
- ret.set(i, elem);
+ w[i] = MARSHALLED_IN(Vector2, (M_Vector2 *)mono_array_addr_with_size(p_array, sizeof(M_Vector2), i));
}
return ret;
}
MonoArray *PoolVector3Array_to_mono_array(const PoolVector3Array &p_array) {
+ PoolVector3Array::Read r = p_array.read();
+
MonoArray *ret = mono_array_new(mono_domain_get(), CACHED_CLASS_RAW(Vector3), p_array.size());
for (int i = 0; i < p_array.size(); i++) {
-#ifdef YOLOCOPY
- mono_array_set(ret, Vector3, i, p_array[i]);
-#else
- real_t *raw = (real_t *)mono_array_addr_with_size(ret, sizeof(real_t) * 3, i);
- const Vector3 &elem = p_array[i];
- raw[0] = elem.x;
- raw[1] = elem.y;
- raw[2] = elem.z;
-#endif
+ M_Vector3 *raw = (M_Vector3 *)mono_array_addr_with_size(ret, sizeof(M_Vector3), i);
+ *raw = MARSHALLED_OUT(Vector3, r[i]);
}
return ret;
@@ -902,11 +972,10 @@ PoolVector3Array mono_array_to_PoolVector3Array(MonoArray *p_array) {
return ret;
int length = mono_array_length(p_array);
ret.resize(length);
+ PoolVector3Array::Write w = ret.write();
for (int i = 0; i < length; i++) {
- real_t *raw_elem = (real_t *)mono_array_addr_with_size(p_array, sizeof(real_t) * 3, i);
- MARSHALLED_IN(Vector3, raw_elem, elem);
- ret.set(i, elem);
+ w[i] = MARSHALLED_IN(Vector3, (M_Vector3 *)mono_array_addr_with_size(p_array, sizeof(M_Vector3), i));
}
return ret;
diff --git a/modules/mono/mono_gd/gd_mono_marshal.h b/modules/mono/mono_gd/gd_mono_marshal.h
index cc0ab5fa05..4002f2a225 100644
--- a/modules/mono/mono_gd/gd_mono_marshal.h
+++ b/modules/mono/mono_gd/gd_mono_marshal.h
@@ -147,78 +147,271 @@ PoolVector2Array mono_array_to_PoolVector2Array(MonoArray *p_array);
MonoArray *PoolVector3Array_to_mono_array(const PoolVector3Array &p_array);
PoolVector3Array mono_array_to_PoolVector3Array(MonoArray *p_array);
-#ifdef YOLO_COPY
-#define MARSHALLED_OUT(m_t, m_in, m_out) m_t *m_out = (m_t *)&m_in;
-#define MARSHALLED_IN(m_t, m_in, m_out) m_t m_out = *reinterpret_cast<m_t *>(m_in);
+// Structures
+
+namespace InteropLayout {
+
+enum {
+ MATCHES_float = (sizeof(float) == sizeof(uint32_t)),
+
+ MATCHES_double = (sizeof(double) == sizeof(uint64_t)),
+
+#ifdef REAL_T_IS_DOUBLE
+ MATCHES_real_t = (sizeof(real_t) == sizeof(uint64_t)),
#else
+ MATCHES_real_t = (sizeof(real_t) == sizeof(uint32_t)),
+#endif
-// Expects m_in to be of type float*
+ MATCHES_Vector2 = (MATCHES_real_t && (sizeof(Vector2) == (sizeof(real_t) * 2)) &&
+ offsetof(Vector2, x) == (sizeof(real_t) * 0) &&
+ offsetof(Vector2, y) == (sizeof(real_t) * 1)),
-#define MARSHALLED_OUT(m_t, m_in, m_out) MARSHALLED_OUT_##m_t(m_in, m_out)
-#define MARSHALLED_IN(m_t, m_in, m_out) MARSHALLED_IN_##m_t(m_in, m_out)
+ MATCHES_Rect2 = (MATCHES_Vector2 && (sizeof(Rect2) == (sizeof(Vector2) * 2)) &&
+ offsetof(Rect2, position) == (sizeof(Vector2) * 0) &&
+ offsetof(Rect2, size) == (sizeof(Vector2) * 1)),
-// Vector2
+ MATCHES_Transform2D = (MATCHES_Vector2 && (sizeof(Transform2D) == (sizeof(Vector2) * 3))), // No field offset required, it stores an array
-#define MARSHALLED_OUT_Vector2(m_in, m_out) real_t m_out[2] = { m_in.x, m_in.y };
-#define MARSHALLED_IN_Vector2(m_in, m_out) Vector2 m_out(m_in[0], m_in[1]);
+ MATCHES_Vector3 = (MATCHES_real_t && (sizeof(Vector3) == (sizeof(real_t) * 3)) &&
+ offsetof(Vector3, x) == (sizeof(real_t) * 0) &&
+ offsetof(Vector3, y) == (sizeof(real_t) * 1) &&
+ offsetof(Vector3, z) == (sizeof(real_t) * 2)),
-// Rect2
+ MATCHES_Basis = (MATCHES_Vector3 && (sizeof(Basis) == (sizeof(Vector3) * 3))), // No field offset required, it stores an array
-#define MARSHALLED_OUT_Rect2(m_in, m_out) real_t m_out[4] = { m_in.position.x, m_in.position.y, m_in.size.width, m_in.size.height };
-#define MARSHALLED_IN_Rect2(m_in, m_out) Rect2 m_out(m_in[0], m_in[1], m_in[2], m_in[3]);
+ MATCHES_Quat = (MATCHES_real_t && (sizeof(Quat) == (sizeof(real_t) * 4)) &&
+ offsetof(Quat, x) == (sizeof(real_t) * 0) &&
+ offsetof(Quat, y) == (sizeof(real_t) * 1) &&
+ offsetof(Quat, z) == (sizeof(real_t) * 2) &&
+ offsetof(Quat, w) == (sizeof(real_t) * 3)),
-// Transform2D
+ MATCHES_Transform = (MATCHES_Basis && MATCHES_Vector3 && (sizeof(Transform) == (sizeof(Basis) + sizeof(Vector3))) &&
+ offsetof(Transform, basis) == 0 &&
+ offsetof(Transform, origin) == sizeof(Basis)),
-#define MARSHALLED_OUT_Transform2D(m_in, m_out) real_t m_out[6] = { m_in[0].x, m_in[0].y, m_in[1].x, m_in[1].y, m_in[2].x, m_in[2].y };
-#define MARSHALLED_IN_Transform2D(m_in, m_out) Transform2D m_out(m_in[0], m_in[1], m_in[2], m_in[3], m_in[4], m_in[5]);
+ MATCHES_AABB = (MATCHES_Vector3 && (sizeof(AABB) == (sizeof(Vector3) * 2)) &&
+ offsetof(AABB, position) == (sizeof(Vector3) * 0) &&
+ offsetof(AABB, size) == (sizeof(Vector3) * 1)),
-// Vector3
+ MATCHES_Color = (MATCHES_float && (sizeof(Color) == (sizeof(float) * 4)) &&
+ offsetof(Color, r) == (sizeof(float) * 0) &&
+ offsetof(Color, g) == (sizeof(float) * 1) &&
+ offsetof(Color, b) == (sizeof(float) * 2) &&
+ offsetof(Color, a) == (sizeof(float) * 3)),
+
+ MATCHES_Plane = (MATCHES_Vector3 && MATCHES_real_t && (sizeof(Plane) == (sizeof(Vector3) + sizeof(real_t))) &&
+ offsetof(Plane, normal) == 0 &&
+ offsetof(Plane, d) == sizeof(Vector3))
+};
+
+// In the future we may force this if we want to ref return these structs
+#ifdef GD_MONO_FORCE_INTEROP_STRUCT_COPY
+// Sometimes clang-format can be an ass
+GD_STATIC_ASSERT(MATCHES_Vector2 &&MATCHES_Rect2 &&MATCHES_Transform2D &&MATCHES_Vector3 &&
+ MATCHES_Basis &&MATCHES_Quat &&MATCHES_Transform &&MATCHES_AABB &&MATCHES_Color &&MATCHES_Plane);
+#endif
-#define MARSHALLED_OUT_Vector3(m_in, m_out) real_t m_out[3] = { m_in.x, m_in.y, m_in.z };
-#define MARSHALLED_IN_Vector3(m_in, m_out) Vector3 m_out(m_in[0], m_in[1], m_in[2]);
+} // namespace InteropLayout
-// Basis
+#pragma pack(push, 1)
-#define MARSHALLED_OUT_Basis(m_in, m_out) real_t m_out[9] = { \
- m_in[0].x, m_in[0].y, m_in[0].z, \
- m_in[1].x, m_in[1].y, m_in[1].z, \
- m_in[2].x, m_in[2].y, m_in[2].z \
+struct M_Vector2 {
+ real_t x, y;
+
+ static _FORCE_INLINE_ Vector2 convert_to(const M_Vector2 &p_from) {
+ return Vector2(p_from.x, p_from.y);
+ }
+
+ static _FORCE_INLINE_ M_Vector2 convert_from(const Vector2 &p_from) {
+ M_Vector2 ret = { p_from.x, p_from.y };
+ return ret;
+ }
};
-#define MARSHALLED_IN_Basis(m_in, m_out) Basis m_out(m_in[0], m_in[1], m_in[2], m_in[3], m_in[4], m_in[5], m_in[6], m_in[7], m_in[8]);
-// Quat
+struct M_Rect2 {
+ M_Vector2 position;
+ M_Vector2 size;
-#define MARSHALLED_OUT_Quat(m_in, m_out) real_t m_out[4] = { m_in.x, m_in.y, m_in.z, m_in.w };
-#define MARSHALLED_IN_Quat(m_in, m_out) Quat m_out(m_in[0], m_in[1], m_in[2], m_in[3]);
+ static _FORCE_INLINE_ Rect2 convert_to(const M_Rect2 &p_from) {
+ return Rect2(M_Vector2::convert_to(p_from.position),
+ M_Vector2::convert_to(p_from.size));
+ }
-// Transform
+ static _FORCE_INLINE_ M_Rect2 convert_from(const Rect2 &p_from) {
+ M_Rect2 ret = { M_Vector2::convert_from(p_from.position), M_Vector2::convert_from(p_from.size) };
+ return ret;
+ }
+};
-#define MARSHALLED_OUT_Transform(m_in, m_out) real_t m_out[12] = { \
- m_in.basis[0].x, m_in.basis[0].y, m_in.basis[0].z, \
- m_in.basis[1].x, m_in.basis[1].y, m_in.basis[1].z, \
- m_in.basis[2].x, m_in.basis[2].y, m_in.basis[2].z, \
- m_in.origin.x, m_in.origin.y, m_in.origin.z \
+struct M_Transform2D {
+ M_Vector2 elements[3];
+
+ static _FORCE_INLINE_ Transform2D convert_to(const M_Transform2D &p_from) {
+ return Transform2D(p_from.elements[0].x, p_from.elements[0].y,
+ p_from.elements[1].x, p_from.elements[1].y,
+ p_from.elements[2].x, p_from.elements[2].y);
+ }
+
+ static _FORCE_INLINE_ M_Transform2D convert_from(const Transform2D &p_from) {
+ M_Transform2D ret = {
+ M_Vector2::convert_from(p_from.elements[0]),
+ M_Vector2::convert_from(p_from.elements[1]),
+ M_Vector2::convert_from(p_from.elements[2])
+ };
+ return ret;
+ }
};
-#define MARSHALLED_IN_Transform(m_in, m_out) Transform m_out( \
- Basis(m_in[0], m_in[1], m_in[2], m_in[3], m_in[4], m_in[5], m_in[6], m_in[7], m_in[8]), \
- Vector3(m_in[9], m_in[10], m_in[11]));
-// AABB
+struct M_Vector3 {
+ real_t x, y, z;
+
+ static _FORCE_INLINE_ Vector3 convert_to(const M_Vector3 &p_from) {
+ return Vector3(p_from.x, p_from.y, p_from.z);
+ }
-#define MARSHALLED_OUT_AABB(m_in, m_out) real_t m_out[6] = { m_in.position.x, m_in.position.y, m_in.position.z, m_in.size.x, m_in.size.y, m_in.size.z };
-#define MARSHALLED_IN_AABB(m_in, m_out) AABB m_out(Vector3(m_in[0], m_in[1], m_in[2]), Vector3(m_in[3], m_in[4], m_in[5]));
+ static _FORCE_INLINE_ M_Vector3 convert_from(const Vector3 &p_from) {
+ M_Vector3 ret = { p_from.x, p_from.y, p_from.z };
+ return ret;
+ }
+};
-// Color
+struct M_Basis {
+ M_Vector3 elements[3];
+
+ static _FORCE_INLINE_ Basis convert_to(const M_Basis &p_from) {
+ return Basis(M_Vector3::convert_to(p_from.elements[0]),
+ M_Vector3::convert_to(p_from.elements[1]),
+ M_Vector3::convert_to(p_from.elements[2]));
+ }
+
+ static _FORCE_INLINE_ M_Basis convert_from(const Basis &p_from) {
+ M_Basis ret = {
+ M_Vector3::convert_from(p_from.elements[0]),
+ M_Vector3::convert_from(p_from.elements[1]),
+ M_Vector3::convert_from(p_from.elements[2])
+ };
+ return ret;
+ }
+};
-#define MARSHALLED_OUT_Color(m_in, m_out) real_t m_out[4] = { m_in.r, m_in.g, m_in.b, m_in.a };
-#define MARSHALLED_IN_Color(m_in, m_out) Color m_out(m_in[0], m_in[1], m_in[2], m_in[3]);
+struct M_Quat {
+ real_t x, y, z, w;
-// Plane
+ static _FORCE_INLINE_ Quat convert_to(const M_Quat &p_from) {
+ return Quat(p_from.x, p_from.y, p_from.z, p_from.w);
+ }
-#define MARSHALLED_OUT_Plane(m_in, m_out) real_t m_out[4] = { m_in.normal.x, m_in.normal.y, m_in.normal.z, m_in.d };
-#define MARSHALLED_IN_Plane(m_in, m_out) Plane m_out(m_in[0], m_in[1], m_in[2], m_in[3]);
+ static _FORCE_INLINE_ M_Quat convert_from(const Quat &p_from) {
+ M_Quat ret = { p_from.x, p_from.y, p_from.z, p_from.w };
+ return ret;
+ }
+};
-#endif
+struct M_Transform {
+ M_Basis basis;
+ M_Vector3 origin;
+
+ static _FORCE_INLINE_ Transform convert_to(const M_Transform &p_from) {
+ return Transform(M_Basis::convert_to(p_from.basis), M_Vector3::convert_to(p_from.origin));
+ }
+
+ static _FORCE_INLINE_ M_Transform convert_from(const Transform &p_from) {
+ M_Transform ret = { M_Basis::convert_from(p_from.basis), M_Vector3::convert_from(p_from.origin) };
+ return ret;
+ }
+};
+
+struct M_AABB {
+ M_Vector3 position;
+ M_Vector3 size;
+
+ static _FORCE_INLINE_ AABB convert_to(const M_AABB &p_from) {
+ return AABB(M_Vector3::convert_to(p_from.position), M_Vector3::convert_to(p_from.size));
+ }
+
+ static _FORCE_INLINE_ M_AABB convert_from(const AABB &p_from) {
+ M_AABB ret = { M_Vector3::convert_from(p_from.position), M_Vector3::convert_from(p_from.size) };
+ return ret;
+ }
+};
+
+struct M_Color {
+ float r, g, b, a;
+
+ static _FORCE_INLINE_ Color convert_to(const M_Color &p_from) {
+ return Color(p_from.r, p_from.g, p_from.b, p_from.a);
+ }
+
+ static _FORCE_INLINE_ M_Color convert_from(const Color &p_from) {
+ M_Color ret = { p_from.r, p_from.g, p_from.b, p_from.a };
+ return ret;
+ }
+};
+
+struct M_Plane {
+ M_Vector3 normal;
+ real_t d;
+
+ static _FORCE_INLINE_ Plane convert_to(const M_Plane &p_from) {
+ return Plane(M_Vector3::convert_to(p_from.normal), p_from.d);
+ }
+
+ static _FORCE_INLINE_ M_Plane convert_from(const Plane &p_from) {
+ M_Plane ret = { M_Vector3::convert_from(p_from.normal), p_from.d };
+ return ret;
+ }
+};
+
+#pragma pack(pop)
+
+#define DECL_TYPE_MARSHAL_TEMPLATES(m_type) \
+ template <int> \
+ _FORCE_INLINE_ m_type marshalled_in_##m_type##_impl(const M_##m_type *p_from); \
+ \
+ template <> \
+ _FORCE_INLINE_ m_type marshalled_in_##m_type##_impl<0>(const M_##m_type *p_from) { \
+ return M_##m_type::convert_to(*p_from); \
+ } \
+ \
+ template <> \
+ _FORCE_INLINE_ m_type marshalled_in_##m_type##_impl<1>(const M_##m_type *p_from) { \
+ return *reinterpret_cast<const m_type *>(p_from); \
+ } \
+ \
+ _FORCE_INLINE_ m_type marshalled_in_##m_type(const M_##m_type *p_from) { \
+ return marshalled_in_##m_type##_impl<InteropLayout::MATCHES_##m_type>(p_from); \
+ } \
+ \
+ template <int> \
+ _FORCE_INLINE_ M_##m_type marshalled_out_##m_type##_impl(const m_type &p_from); \
+ \
+ template <> \
+ _FORCE_INLINE_ M_##m_type marshalled_out_##m_type##_impl<0>(const m_type &p_from) { \
+ return M_##m_type::convert_from(p_from); \
+ } \
+ \
+ template <> \
+ _FORCE_INLINE_ M_##m_type marshalled_out_##m_type##_impl<1>(const m_type &p_from) { \
+ return *reinterpret_cast<const M_##m_type *>(&p_from); \
+ } \
+ \
+ _FORCE_INLINE_ M_##m_type marshalled_out_##m_type(const m_type &p_from) { \
+ return marshalled_out_##m_type##_impl<InteropLayout::MATCHES_##m_type>(p_from); \
+ }
+
+DECL_TYPE_MARSHAL_TEMPLATES(Vector2)
+DECL_TYPE_MARSHAL_TEMPLATES(Rect2)
+DECL_TYPE_MARSHAL_TEMPLATES(Transform2D)
+DECL_TYPE_MARSHAL_TEMPLATES(Vector3)
+DECL_TYPE_MARSHAL_TEMPLATES(Basis)
+DECL_TYPE_MARSHAL_TEMPLATES(Quat)
+DECL_TYPE_MARSHAL_TEMPLATES(Transform)
+DECL_TYPE_MARSHAL_TEMPLATES(AABB)
+DECL_TYPE_MARSHAL_TEMPLATES(Color)
+DECL_TYPE_MARSHAL_TEMPLATES(Plane)
+
+#define MARSHALLED_IN(m_type, m_from_ptr) (GDMonoMarshal::marshalled_in_##m_type(m_from_ptr))
+#define MARSHALLED_OUT(m_type, m_from) (GDMonoMarshal::marshalled_out_##m_type(m_from))
} // namespace GDMonoMarshal
diff --git a/modules/mono/utils/macros.h b/modules/mono/utils/macros.h
index 337a86870e..40b47e8648 100644
--- a/modules/mono/utils/macros.h
+++ b/modules/mono/utils/macros.h
@@ -33,6 +33,15 @@
// noreturn
+#if __cpp_static_assert
+#define GD_STATIC_ASSERT(m_cond) static_assert((m_cond), "Condition '" #m_cond "' failed")
+#else
+#define _GD_STATIC_ASSERT_VARNAME_CONCAT_B(m_ignore, m_name) m_name
+#define _GD_STATIC_ASSERT_VARNAME_CONCAT_A(m_a, m_b) GD_STATIC_ASSERT_VARNAME_CONCAT_B(hello there, m_a##m_b)
+#define _GD_STATIC_ASSERT_VARNAME_CONCAT(m_a, m_b) GD_STATIC_ASSERT_VARNAME_CONCAT_A(m_a, m_b)
+#define GD_STATIC_ASSERT(m_cond) typedef int GD_STATIC_ASSERT_VARNAME_CONCAT(godot_static_assert_, __COUNTER__)[((m_cond) ? 1 : -1)]
+#endif
+
#undef _NO_RETURN_
#ifdef __GNUC__
diff --git a/modules/opensimplex/doc_classes/NoiseTexture.xml b/modules/opensimplex/doc_classes/NoiseTexture.xml
index 9642865c43..d88abb3180 100644
--- a/modules/opensimplex/doc_classes/NoiseTexture.xml
+++ b/modules/opensimplex/doc_classes/NoiseTexture.xml
@@ -12,24 +12,6 @@
<demos>
</demos>
<methods>
- <method name="set_height">
- <return type="void">
- </return>
- <argument index="0" name="height" type="int">
- </argument>
- <description>
- Set texture height.
- </description>
- </method>
- <method name="set_width">
- <return type="void">
- </return>
- <argument index="0" name="width" type="int">
- </argument>
- <description>
- Set texture width.
- </description>
- </method>
</methods>
<members>
<member name="as_normalmap" type="bool" setter="set_as_normalmap" getter="is_normalmap">
diff --git a/modules/thekla_unwrap/config.py b/modules/thekla_unwrap/config.py
index bd092bdc16..fad6095064 100644
--- a/modules/thekla_unwrap/config.py
+++ b/modules/thekla_unwrap/config.py
@@ -1,5 +1,6 @@
def can_build(env, platform):
- return (env['tools'] and platform not in ["android", "ios"])
+ #return (env['tools'] and platform not in ["android", "ios"])
+ return False
def configure(env):
pass
diff --git a/modules/theora/video_stream_theora.cpp b/modules/theora/video_stream_theora.cpp
index d72d74cf79..2a6bb0783b 100644
--- a/modules/theora/video_stream_theora.cpp
+++ b/modules/theora/video_stream_theora.cpp
@@ -730,7 +730,6 @@ RES ResourceFormatLoaderTheora::load(const String &p_path, const String &p_origi
if (r_error) {
*r_error = ERR_CANT_OPEN;
}
- memdelete(f);
return RES();
}
diff --git a/modules/visual_script/visual_script.cpp b/modules/visual_script/visual_script.cpp
index ff97c21fd9..52a30baaec 100644
--- a/modules/visual_script/visual_script.cpp
+++ b/modules/visual_script/visual_script.cpp
@@ -48,20 +48,22 @@ bool VisualScriptNode::is_breakpoint() const {
void VisualScriptNode::_notification(int p_what) {
if (p_what == NOTIFICATION_POSTINITIALIZE) {
-
- int dvc = get_input_value_port_count();
- for (int i = 0; i < dvc; i++) {
- Variant::Type expected = get_input_value_port_info(i).type;
- Variant::CallError ce;
- default_input_values.push_back(Variant::construct(expected, NULL, 0, ce, false));
- }
+ _update_input_ports();
}
}
-void VisualScriptNode::ports_changed_notify() {
-
+void VisualScriptNode::_update_input_ports() {
default_input_values.resize(MAX(default_input_values.size(), get_input_value_port_count())); //let it grow as big as possible, we don't want to lose values on resize
+ int port_count = get_input_value_port_count();
+ for (int i = 0; i < port_count; i++) {
+ Variant::Type expected = get_input_value_port_info(i).type;
+ Variant::CallError ce;
+ set_default_input_value(i, Variant::construct(expected, NULL, 0, ce, false));
+ }
+}
+void VisualScriptNode::ports_changed_notify() {
+ _update_input_ports();
emit_signal("ports_changed");
}
diff --git a/modules/visual_script/visual_script.h b/modules/visual_script/visual_script.h
index ea99ce4970..bd666447a3 100644
--- a/modules/visual_script/visual_script.h
+++ b/modules/visual_script/visual_script.h
@@ -52,6 +52,7 @@ class VisualScriptNode : public Resource {
Array _get_default_input_values() const;
void validate_input_default_values();
+ void _update_input_ports();
protected:
void _notification(int p_what);
diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp
index 79f71535ad..7fdd7fe446 100644
--- a/modules/visual_script/visual_script_editor.cpp
+++ b/modules/visual_script/visual_script_editor.cpp
@@ -1940,7 +1940,7 @@ void VisualScriptEditor::_draw_color_over_button(Object *obj, Color p_color) {
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<Texture> &p_preview, Variant p_ud) {
+void VisualScriptEditor::_button_resource_previewed(const String &p_path, const Ref<Texture> &p_preview, const Ref<Texture> &p_small_preview, Variant p_ud) {
Array ud = p_ud;
ERR_FAIL_COND(ud.size() != 2);
@@ -2639,7 +2639,7 @@ void VisualScriptEditor::_selected_connect_node(const String &p_text, const Stri
}
undo_redo->create_action(TTR("Add Node"));
undo_redo->add_do_method(script.ptr(), "add_node", edited_func, new_id, vnode_new, ofs);
- if (vnode_old.is_valid() && p_connecting == true) {
+ if (vnode_old.is_valid() && p_connecting) {
connect_seq(vnode_old, vnode_new, new_id);
connect_data(vnode_old, vnode_new, new_id);
}
@@ -2806,7 +2806,7 @@ void VisualScriptEditor::_selected_connect_node(const String &p_text, const Stri
}
}
Ref<VisualScriptNode> vnode_old = script->get_node(edited_func, port_action_node);
- if (vnode_old.is_valid() && p_connecting == true) {
+ if (vnode_old.is_valid() && p_connecting) {
connect_seq(vnode_old, vnode, port_action_new_node);
connect_data(vnode_old, vnode, port_action_new_node);
}
@@ -2816,7 +2816,7 @@ void VisualScriptEditor::_selected_connect_node(const String &p_text, const Stri
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 != NULL && vnode_operator->has_input_sequence_port() == false) {
+ if (vnode_operator != NULL && !vnode_operator->has_input_sequence_port()) {
return;
}
VisualScriptConstructor *vnode_constructor = Object::cast_to<VisualScriptConstructor>(vnode_new.ptr());
@@ -2826,7 +2826,7 @@ void VisualScriptEditor::connect_seq(Ref<VisualScriptNode> vnode_old, Ref<Visual
if (vnode_old->get_output_sequence_port_count() <= 0) {
return;
}
- if (vnode_new->has_input_sequence_port() == false) {
+ if (!vnode_new->has_input_sequence_port()) {
return;
}
diff --git a/modules/visual_script/visual_script_editor.h b/modules/visual_script/visual_script_editor.h
index fb90e346a4..97c75dae94 100644
--- a/modules/visual_script/visual_script_editor.h
+++ b/modules/visual_script/visual_script_editor.h
@@ -237,7 +237,7 @@ class VisualScriptEditor : public ScriptEditorBase {
void _selected_method(const String &p_method, const String &p_type);
void _draw_color_over_button(Object *obj, Color p_color);
- void _button_resource_previewed(const String &p_path, const Ref<Texture> &p_preview, Variant p_ud);
+ void _button_resource_previewed(const String &p_path, const Ref<Texture> &p_preview, const Ref<Texture> &p_small_preview, Variant p_ud);
VisualScriptNode::TypeGuess _guess_output_type(int p_port_action_node, int p_port_action_output, Set<int> &visited_nodes);
diff --git a/modules/visual_script/visual_script_nodes.cpp b/modules/visual_script/visual_script_nodes.cpp
index 5c880f48d1..99748af8a1 100644
--- a/modules/visual_script/visual_script_nodes.cpp
+++ b/modules/visual_script/visual_script_nodes.cpp
@@ -853,7 +853,7 @@ public:
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) {
- if (instance->get_variable(variable, p_outputs[0]) == false) {
+ if (!instance->get_variable(variable, p_outputs[0])) {
r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
r_error_str = RTR("VariableGet not found in script: ") + "'" + String(variable) + "'";
return false;
@@ -975,7 +975,7 @@ public:
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) {
- if (instance->set_variable(variable, *p_inputs[0]) == false) {
+ if (!instance->set_variable(variable, *p_inputs[0])) {
r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
r_error_str = RTR("VariableSet not found in script: ") + "'" + String(variable) + "'";
@@ -3708,18 +3708,18 @@ void register_visual_script_nodes() {
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)) + " ( ";
+ String name = "functions/constructors/" + Variant::get_type_name(Variant::Type(i)) + "(";
for (int j = 0; j < E->get().arguments.size(); j++) {
- if (j > 0)
+ if (j > 0) {
name += ", ";
- if (E->get().arguments.size() == 1)
+ }
+ if (E->get().arguments.size() == 1) {
name += Variant::get_type_name(E->get().arguments[j].type);
- else
+ } else {
name += E->get().arguments[j].name;
+ }
}
- name += ") ";
-
+ name += ")";
VisualScriptLanguage::singleton->add_register_func(name, create_constructor_node);
Pair<Variant::Type, MethodInfo> pair;
pair.first = Variant::Type(i);
diff --git a/modules/visual_script/visual_script_property_selector.cpp b/modules/visual_script/visual_script_property_selector.cpp
index cd29df9855..e5d12cb495 100644
--- a/modules/visual_script/visual_script_property_selector.cpp
+++ b/modules/visual_script/visual_script_property_selector.cpp
@@ -149,7 +149,7 @@ void VisualScriptPropertySelector::_update_search() {
Control::get_icon("PoolColorArray", "EditorIcons")
};
- if (!seq_connect && visual_script_generic == false) {
+ if (!seq_connect && !visual_script_generic) {
get_visual_node_names("flow_control/type_cast", Set<String>(), found, root, search_box);
get_visual_node_names("functions/built_in/print", Set<String>(), found, root, search_box);
get_visual_node_names("functions/by_type/" + Variant::get_type_name(type), Set<String>(), found, root, search_box);
@@ -228,7 +228,7 @@ void VisualScriptPropertySelector::_update_search() {
}
}
- if (seq_connect == true && visual_script_generic == false) {
+ if (seq_connect && !visual_script_generic) {
String text = search_box->get_text();
create_visualscript_item(String("VisualScriptCondition"), root, text, String("Condition"));
create_visualscript_item(String("VisualScriptSwitch"), root, text, String("Switch"));
@@ -304,31 +304,36 @@ void VisualScriptPropertySelector::_update_search() {
continue;
MethodInfo mi = E->get();
- String desc = mi.name.capitalize() + " (";
+ String desc_arguments;
+ if (mi.arguments.size() > 0) {
+ desc_arguments = "(";
+ for (int i = 0; i < mi.arguments.size(); i++) {
+
+ if (i > 0) {
+ desc_arguments += ", ";
+ }
+ if (mi.arguments[i].type == Variant::NIL) {
+ desc_arguments += "var";
+ } else if (mi.arguments[i].name.find(":") != -1) {
+ desc_arguments += mi.arguments[i].name.get_slice(":", 1);
+ mi.arguments[i].name = mi.arguments[i].name.get_slice(":", 0);
+ } else {
+ desc_arguments += Variant::get_type_name(mi.arguments[i].type);
+ }
+ }
+ desc_arguments += ")";
+ }
+ String desc_raw = mi.name + desc_arguments;
+ String desc = desc_raw.capitalize().replace("( ", "(");
if (search_box->get_text() != String() &&
name.findn(search_box->get_text()) == -1 &&
- desc.findn(search_box->get_text()) == -1)
+ desc.findn(search_box->get_text()) == -1 &&
+ desc_raw.findn(search_box->get_text()) == -1) {
continue;
-
- TreeItem *item = search_options->create_item(category ? category : root);
-
- for (int i = 0; i < mi.arguments.size(); i++) {
-
- if (i > 0)
- desc += ", ";
-
- if (mi.arguments[i].type == Variant::NIL)
- desc += "var";
- 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
- desc += Variant::get_type_name(mi.arguments[i].type);
}
- desc += ")";
-
+ TreeItem *item = search_options->create_item(category ? category : root);
item->set_text(0, desc);
item->set_icon(0, get_icon("MemberMethod", "EditorIcons"));
item->set_metadata(0, name);
@@ -392,7 +397,7 @@ void VisualScriptPropertySelector::get_visual_node_names(const String &root_filt
break;
}
}
- if (is_filter == true) {
+ if (is_filter) {
continue;
}
@@ -414,11 +419,16 @@ void VisualScriptPropertySelector::get_visual_node_names(const String &root_filt
String basic_type = Variant::get_type_name(vnode_function_call->get_basic_type());
type_name = basic_type.capitalize() + " ";
}
- VisualScriptBuiltinFunc *vnode_builtin_function_call = Object::cast_to<VisualScriptBuiltinFunc>(*VisualScriptLanguage::singleton->create_node_from_name(E->get()));
- if (vnode_builtin_function_call != NULL) {
- type_name = "Builtin ";
+
+ Vector<String> desc = path[path.size() - 1].replace("(", "( ").replace(")", " )").replace(",", ", ").split(" ");
+ for (size_t i = 0; i < desc.size(); i++) {
+ desc.write[i] = desc[i].capitalize();
+ if (desc[i].ends_with(",")) {
+ desc.write[i] = desc[i].replace(",", ", ");
+ }
}
- item->set_text(0, type_name + path[path.size() - 1].capitalize());
+
+ item->set_text(0, type_name + String("").join(desc));
item->set_icon(0, get_icon("VisualScript", "EditorIcons"));
item->set_selectable(0, true);
item->set_metadata(0, E->get());
diff --git a/modules/webm/video_stream_webm.cpp b/modules/webm/video_stream_webm.cpp
index d9a6ece085..675fc97b55 100644
--- a/modules/webm/video_stream_webm.cpp
+++ b/modules/webm/video_stream_webm.cpp
@@ -453,7 +453,6 @@ RES ResourceFormatLoaderWebm::load(const String &p_path, const String &p_origina
if (r_error) {
*r_error = ERR_CANT_OPEN;
}
- memdelete(f);
return RES();
}
diff --git a/modules/websocket/emws_server.cpp b/modules/websocket/emws_server.cpp
index ad4a758c0f..db02162699 100644
--- a/modules/websocket/emws_server.cpp
+++ b/modules/websocket/emws_server.cpp
@@ -71,6 +71,9 @@ int EMWSServer::get_peer_port(int p_peer_id) const {
void EMWSServer::disconnect_peer(int p_peer_id, int p_code, String p_reason) {
}
+void EMWSServer::poll() {
+}
+
EMWSServer::EMWSServer() {
}
diff --git a/modules/websocket/lws_client.cpp b/modules/websocket/lws_client.cpp
index cd814760e6..d71d091720 100644
--- a/modules/websocket/lws_client.cpp
+++ b/modules/websocket/lws_client.cpp
@@ -76,23 +76,11 @@ Error LWSClient::connect_to_host(String p_host, String p_path, uint16_t p_port,
ERR_FAIL_V(FAILED);
}
- char abuf[1024];
- char hbuf[1024];
- char pbuf[2048];
- String addr_str = (String)addr;
- strncpy(abuf, addr_str.ascii().get_data(), 1024);
- strncpy(hbuf, p_host.utf8().get_data(), 1024);
- strncpy(pbuf, p_path.utf8().get_data(), 2048);
-
i.context = context;
if (p_protocols.size() > 0)
i.protocol = _lws_ref->lws_names;
else
i.protocol = NULL;
- i.address = abuf;
- i.host = hbuf;
- i.path = pbuf;
- i.port = p_port;
if (p_ssl) {
i.ssl_connection = LCCSCF_USE_SSL;
@@ -102,7 +90,16 @@ Error LWSClient::connect_to_host(String p_host, String p_path, uint16_t p_port,
i.ssl_connection = 0;
}
+ // This String needs to survive till we call lws_client_connect_via_info
+ String addr_str = (String)addr;
+
+ i.address = addr_str.ascii().get_data();
+ i.host = p_host.utf8().get_data();
+ i.path = p_path.utf8().get_data();
+ i.port = p_port;
+
lws_client_connect_via_info(&i);
+
return OK;
};
diff --git a/modules/websocket/websocket_multiplayer.cpp b/modules/websocket/websocket_multiplayer.cpp
index b948c439df..873658559a 100644
--- a/modules/websocket/websocket_multiplayer.cpp
+++ b/modules/websocket/websocket_multiplayer.cpp
@@ -313,7 +313,7 @@ void WebSocketMultiplayerPeer::_process_multiplayer(Ref<WebSocketPeer> p_peer, u
} else if (to < 0) {
// All but one, for us if not excluded
- if (_peer_id != -p_peer_id)
+ if (_peer_id != -(int32_t)p_peer_id)
_store_pkt(from, to, in_buffer, data_size);
} else {
diff --git a/modules/xatlas_unwrap/config.py b/modules/xatlas_unwrap/config.py
index 962d33280f..2dda5db7e0 100644
--- a/modules/xatlas_unwrap/config.py
+++ b/modules/xatlas_unwrap/config.py
@@ -1,6 +1,6 @@
def can_build(env, platform):
- return False #xatlas is buggy
- #return (env['tools'] and platform not in ["android", "ios"])
+ #return False #xatlas is buggy
+ return (env['tools'] and platform not in ["android", "ios"])
def configure(env):
pass
diff --git a/modules/xatlas_unwrap/register_types.cpp b/modules/xatlas_unwrap/register_types.cpp
index 9df16aac70..57eea4eda6 100644
--- a/modules/xatlas_unwrap/register_types.cpp
+++ b/modules/xatlas_unwrap/register_types.cpp
@@ -75,8 +75,9 @@ bool xatlas_mesh_lightmap_unwrap_callback(float p_texel_size, const float *p_ver
xatlas::CharterOptions chart_options;
xatlas::PackerOptions pack_options;
+ pack_options.method = xatlas::PackMethod::TexelArea;
pack_options.texelArea = 1.0 / p_texel_size;
- pack_options.quality = 4;
+ pack_options.quality = 3;
xatlas::Atlas *atlas = xatlas::Create();
printf("adding mesh..\n");
@@ -93,7 +94,10 @@ bool xatlas_mesh_lightmap_unwrap_callback(float p_texel_size, const float *p_ver
float w = *r_size_hint_x;
float h = *r_size_hint_y;
- printf("final texsize: %f,%f\n", w, h);
+ if (w == 0 || h == 0) {
+ return false; //could not bake
+ }
+
const xatlas::OutputMesh *const *output_meshes = xatlas::GetOutputMeshes(atlas);
const xatlas::OutputMesh *output = output_meshes[0];
@@ -102,11 +106,17 @@ bool xatlas_mesh_lightmap_unwrap_callback(float p_texel_size, const float *p_ver
*r_uv = (float *)malloc(sizeof(float) * output->vertexCount * 2);
*r_index = (int *)malloc(sizeof(int) * output->indexCount);
+ float max_x = 0;
+ float max_y = 0;
for (int i = 0; i < output->vertexCount; i++) {
(*r_vertex)[i] = output->vertexArray[i].xref;
- (*r_uv)[i * 2 + 0] = output->vertexArray[i].uv[0];
- (*r_uv)[i * 2 + 1] = output->vertexArray[i].uv[1];
+ (*r_uv)[i * 2 + 0] = output->vertexArray[i].uv[0] / w;
+ (*r_uv)[i * 2 + 1] = output->vertexArray[i].uv[1] / h;
+ max_x = MAX(max_x, output->vertexArray[i].uv[0]);
+ max_y = MAX(max_y, output->vertexArray[i].uv[1]);
}
+
+ printf("final texsize: %f,%f - max %f,%f\n", w, h, max_x, max_y);
*r_vertex_count = output->vertexCount;
for (int i = 0; i < output->indexCount; i++) {
diff --git a/platform/android/build.gradle.template b/platform/android/build.gradle.template
index cc45fee95f..1603ea70d9 100644
--- a/platform/android/build.gradle.template
+++ b/platform/android/build.gradle.template
@@ -1,10 +1,11 @@
buildscript {
repositories {
+ google()
jcenter()
$$GRADLE_REPOSITORY_URLS$$
}
dependencies {
- classpath 'com.android.tools.build:gradle:2.3.3'
+ classpath 'com.android.tools.build:gradle:3.2.0'
$$GRADLE_CLASSPATH$$
}
}
@@ -32,7 +33,7 @@ android {
}
compileSdkVersion 27
- buildToolsVersion "27.0.3"
+ buildToolsVersion "28.0.3"
useLibrary 'org.apache.http.legacy'
packagingOptions {
@@ -75,9 +76,11 @@ android {
$$GRADLE_JNI_DIRS$$
]
}
+
applicationVariants.all { variant ->
- // ApplicationVariant is undocumented, but this method is widely used; may break with another version of the Android Gradle plugin
- variant.outputs.get(0).setOutputFile(new File("${projectDir}/../../../bin", "android_${variant.name}.apk"))
+ variant.outputs.all { output ->
+ output.outputFileName = "../../../../../../../bin/android_${variant.name}.apk"
+ }
}
}
diff --git a/platform/android/godot_android.cpp b/platform/android/godot_android.cpp
index 54692dc831..c46c6f7804 100644
--- a/platform/android/godot_android.cpp
+++ b/platform/android/godot_android.cpp
@@ -408,7 +408,7 @@ static void engine_draw_frame(struct engine *engine) {
// Just fill the screen with a color.
//glClearColor(0,1,0,1);
//glClear(GL_COLOR_BUFFER_BIT);
- if (engine->os && engine->os->main_loop_iterate() == true) {
+ if (engine->os && engine->os->main_loop_iterate()) {
engine->requested_quit = true;
return; //should exit instead
diff --git a/platform/android/java/gradle/wrapper/gradle-wrapper.properties b/platform/android/java/gradle/wrapper/gradle-wrapper.properties
index fe37fa74a9..6fb3a79546 100644
--- a/platform/android/java/gradle/wrapper/gradle-wrapper.properties
+++ b/platform/android/java/gradle/wrapper/gradle-wrapper.properties
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
diff --git a/platform/android/java_glue.cpp b/platform/android/java_glue.cpp
index c3be3a3f11..07e4048c12 100644
--- a/platform/android/java_glue.cpp
+++ b/platform/android/java_glue.cpp
@@ -883,6 +883,8 @@ static void _initialize_java_modules() {
ERR_EXPLAIN("Couldn't find proper initialize function 'public static Godot.SingletonBase Class::initialize(Activity p_activity)' initializer for singleton class: " + m);
ERR_CONTINUE(!initialize);
}
+ jobject obj = env->CallStaticObjectMethod(singletonClass, initialize, _godot_instance);
+ env->NewGlobalRef(obj);
}
}
}
@@ -974,7 +976,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_step(JNIEnv *env, job
os_android->process_gyroscope(gyroscope);
- if (os_android->main_loop_iterate() == true) {
+ if (os_android->main_loop_iterate()) {
jclass cls = env->FindClass("org/godotengine/godot/Godot");
jmethodID _finish = env->GetMethodID(cls, "forceQuit", "()V");
diff --git a/platform/haiku/haiku_direct_window.cpp b/platform/haiku/haiku_direct_window.cpp
index 150e90be65..6b64082250 100644
--- a/platform/haiku/haiku_direct_window.cpp
+++ b/platform/haiku/haiku_direct_window.cpp
@@ -86,7 +86,7 @@ void HaikuDirectWindow::DirectConnected(direct_buffer_info *info) {
void HaikuDirectWindow::MessageReceived(BMessage *message) {
switch (message->what) {
case REDRAW_MSG:
- if (Main::iteration() == true) {
+ if (Main::iteration()) {
view->EnableDirectMode(false);
Quit();
}
diff --git a/platform/iphone/gl_view.mm b/platform/iphone/gl_view.mm
index 478a3125af..2925b46007 100644
--- a/platform/iphone/gl_view.mm
+++ b/platform/iphone/gl_view.mm
@@ -53,7 +53,6 @@ static GLView *_instance = NULL;
static bool video_found_error = false;
static bool video_playing = false;
-static float video_previous_volume = 0.0f;
static CMTime video_current_time;
void _show_keyboard(String);
@@ -248,16 +247,6 @@ static int remove_touch(UITouch *p_touch) {
return remaining;
};
-static int get_first_id(UITouch *p_touch) {
-
- for (int i = 0; i < max_touches; i++) {
-
- if (touches[i] != NULL)
- return i;
- };
- return -1;
-};
-
static void clear_touches() {
for (int i = 0; i < max_touches; i++) {
@@ -751,7 +740,6 @@ static void clear_touches() {
[_instance.moviePlayerController stop];
[_instance.moviePlayerController.view removeFromSuperview];
- //[[MPMusicPlayerController applicationMusicPlayer] setVolume: video_previous_volume];
video_playing = false;
}
*/
diff --git a/platform/javascript/engine.js b/platform/javascript/engine.js
index c3ef5bbbb5..91458eb4c3 100644
--- a/platform/javascript/engine.js
+++ b/platform/javascript/engine.js
@@ -1,3 +1,6 @@
+ // The following is concatenated with generated code, and acts as the end
+ // of a wrapper for said code. See pre.js for the other part of the
+ // wrapper.
exposedLibs['PATH'] = PATH;
exposedLibs['FS'] = FS;
return Module;
diff --git a/platform/javascript/pre.js b/platform/javascript/pre.js
index 02194bc75e..a870e676ea 100644
--- a/platform/javascript/pre.js
+++ b/platform/javascript/pre.js
@@ -1,2 +1,5 @@
var Engine = {
RuntimeEnvironment: function(Module, exposedLibs) {
+ // The above is concatenated with generated code, and acts as the start of
+ // a wrapper for said code. See engine.js for the other part of the
+ // wrapper.
diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm
index 886ff4b332..70b49805d2 100644
--- a/platform/osx/os_osx.mm
+++ b/platform/osx/os_osx.mm
@@ -76,11 +76,6 @@
#define NSWindowStyleMaskBorderless NSBorderlessWindowMask
#endif
-static NSRect convertRectToBacking(NSRect contentRect) {
-
- return [OS_OSX::singleton->window_view convertRectToBacking:contentRect];
-}
-
static void get_key_modifier_state(unsigned int p_osx_state, Ref<InputEventWithModifiers> state) {
state->set_shift((p_osx_state & NSEventModifierFlagShift));
@@ -105,12 +100,13 @@ static int prev_mouse_y = 0;
static int button_mask = 0;
static bool mouse_down_control = false;
-static Vector2 get_mouse_pos(NSEvent *event) {
+static Vector2 get_mouse_pos(NSPoint locationInWindow, CGFloat backingScaleFactor) {
const NSRect contentRect = [OS_OSX::singleton->window_view frame];
- const NSPoint p = [event locationInWindow];
- mouse_x = p.x * OS_OSX::singleton->_mouse_scale([[event window] backingScaleFactor]);
- mouse_y = (contentRect.size.height - p.y) * OS_OSX::singleton->_mouse_scale([[event window] backingScaleFactor]);
+ const NSPoint p = locationInWindow;
+ const float s = OS_OSX::singleton->_mouse_scale(backingScaleFactor);
+ mouse_x = p.x * s;
+ mouse_y = (contentRect.size.height - p.y) * s;
return Vector2(mouse_x, mouse_y);
}
@@ -271,7 +267,7 @@ static Vector2 get_mouse_pos(NSEvent *event) {
float newDisplayScale = OS_OSX::singleton->is_hidpi_allowed() ? newBackingScaleFactor : 1.0;
const NSRect contentRect = [OS_OSX::singleton->window_view frame];
- const NSRect fbRect = contentRect; //convertRectToBacking(contentRect);
+ const NSRect fbRect = contentRect;
OS_OSX::singleton->window_size.width = fbRect.size.width * newDisplayScale;
OS_OSX::singleton->window_size.height = fbRect.size.height * newDisplayScale;
@@ -292,7 +288,7 @@ static Vector2 get_mouse_pos(NSEvent *event) {
[OS_OSX::singleton->context update];
const NSRect contentRect = [OS_OSX::singleton->window_view frame];
- const NSRect fbRect = contentRect; //convertRectToBacking(contentRect);
+ const NSRect fbRect = contentRect;
float displayScale = OS_OSX::singleton->_display_scale();
OS_OSX::singleton->window_size.width = fbRect.size.width * displayScale;
@@ -330,6 +326,13 @@ static Vector2 get_mouse_pos(NSEvent *event) {
- (void)windowDidBecomeKey:(NSNotification *)notification {
//_GodotInputWindowFocus(window, GL_TRUE);
//_GodotPlatformSetCursorMode(window, window->cursorMode);
+ [OS_OSX::singleton->context update];
+
+ get_mouse_pos(
+ [OS_OSX::singleton->window_object mouseLocationOutsideOfEventStream],
+ [OS_OSX::singleton->window_view backingScaleFactor]);
+ OS_OSX::singleton->input->set_mouse_position(Point2(mouse_x, mouse_y));
+
if (OS_OSX::singleton->get_main_loop())
OS_OSX::singleton->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_FOCUS_IN);
}
@@ -598,12 +601,13 @@ static void _mouseDownEvent(NSEvent *event, int index, int mask, bool pressed) {
mm->set_button_mask(button_mask);
prev_mouse_x = mouse_x;
prev_mouse_y = mouse_y;
- const Vector2 pos = get_mouse_pos(event);
+ const CGFloat backingScaleFactor = [[event window] backingScaleFactor];
+ const Vector2 pos = get_mouse_pos([event locationInWindow], backingScaleFactor);
mm->set_position(pos);
mm->set_global_position(pos);
Vector2 relativeMotion = Vector2();
- relativeMotion.x = [event deltaX] * OS_OSX::singleton -> _mouse_scale([[event window] backingScaleFactor]);
- relativeMotion.y = [event deltaY] * OS_OSX::singleton -> _mouse_scale([[event window] backingScaleFactor]);
+ relativeMotion.x = [event deltaX] * OS_OSX::singleton -> _mouse_scale(backingScaleFactor);
+ relativeMotion.y = [event deltaY] * OS_OSX::singleton -> _mouse_scale(backingScaleFactor);
mm->set_relative(relativeMotion);
get_key_modifier_state([event modifierFlags], mm);
@@ -686,7 +690,7 @@ static void _mouseDownEvent(NSEvent *event, int index, int mask, bool pressed) {
Ref<InputEventMagnifyGesture> ev;
ev.instance();
get_key_modifier_state([event modifierFlags], ev);
- ev->set_position(get_mouse_pos(event));
+ ev->set_position(get_mouse_pos([event locationInWindow], [[event window] backingScaleFactor]));
ev->set_factor([event magnification] + 1.0);
OS_OSX::singleton->push_input(ev);
}
@@ -1078,6 +1082,8 @@ inline void sendPanEvent(double dx, double dy, int modifierFlags) {
- (void)scrollWheel:(NSEvent *)event {
double deltaX, deltaY;
+ get_mouse_pos([event locationInWindow], [[event window] backingScaleFactor]);
+
deltaX = [event scrollingDeltaX];
deltaY = [event scrollingDeltaY];
@@ -1864,28 +1870,30 @@ bool OS_OSX::can_draw() const {
void OS_OSX::set_clipboard(const String &p_text) {
- NSArray *types = [NSArray arrayWithObjects:NSStringPboardType, nil];
+ NSString *copiedString = [NSString stringWithUTF8String:p_text.utf8().get_data()];
+ NSArray *copiedStringArray = [NSArray arrayWithObject:copiedString];
NSPasteboard *pasteboard = [NSPasteboard generalPasteboard];
- [pasteboard declareTypes:types owner:nil];
- [pasteboard setString:[NSString stringWithUTF8String:p_text.utf8().get_data()]
- forType:NSStringPboardType];
+ [pasteboard clearContents];
+ [pasteboard writeObjects:copiedStringArray];
}
String OS_OSX::get_clipboard() const {
NSPasteboard *pasteboard = [NSPasteboard generalPasteboard];
+ NSArray *classArray = [NSArray arrayWithObject:[NSString class]];
+ NSDictionary *options = [NSDictionary dictionary];
- if (![[pasteboard types] containsObject:NSStringPboardType]) {
- return "";
- }
+ BOOL ok = [pasteboard canReadObjectForClasses:classArray options:options];
- NSString *object = [pasteboard stringForType:NSStringPboardType];
- if (!object) {
+ if (!ok) {
return "";
}
- char *utfs = strdup([object UTF8String]);
+ NSArray *objectsToPaste = [pasteboard readObjectsForClasses:classArray options:options];
+ NSString *string = [objectsToPaste objectAtIndex:0];
+
+ char *utfs = strdup([string UTF8String]);
String ret;
ret.parse_utf8(utfs);
free(utfs);
diff --git a/platform/server/os_server.cpp b/platform/server/os_server.cpp
index 1069d6bbed..6a7038e946 100644
--- a/platform/server/os_server.cpp
+++ b/platform/server/os_server.cpp
@@ -221,7 +221,7 @@ void OS_Server::run() {
while (!force_quit) {
- if (Main::iteration() == true)
+ if (Main::iteration())
break;
};
diff --git a/platform/uwp/os_uwp.cpp b/platform/uwp/os_uwp.cpp
index f489c0894f..6410378593 100644
--- a/platform/uwp/os_uwp.cpp
+++ b/platform/uwp/os_uwp.cpp
@@ -864,7 +864,7 @@ void OSUWP::run() {
CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessAllIfPresent);
if (managed_object->alert_close_handle) continue;
process_events(); // get rid of pending events
- if (Main::iteration() == true)
+ if (Main::iteration())
break;
};
diff --git a/platform/windows/context_gl_win.cpp b/platform/windows/context_gl_win.cpp
index 794f6df31f..fd7cd69c37 100644
--- a/platform/windows/context_gl_win.cpp
+++ b/platform/windows/context_gl_win.cpp
@@ -91,18 +91,18 @@ Error ContextGL_Win::initialize() {
PFD_DRAW_TO_WINDOW | // Format Must Support Window
PFD_SUPPORT_OPENGL | // Format Must Support OpenGL
PFD_DOUBLEBUFFER,
- PFD_TYPE_RGBA,
- OS::get_singleton()->is_layered_allowed() ? 32 : 24,
- 0, 0, 0, 0, 0, 0, // Color Bits Ignored
- OS::get_singleton()->is_layered_allowed() ? 8 : 0, // Alpha Buffer
- 0, // Shift Bit Ignored
- 0, // No Accumulation Buffer
- 0, 0, 0, 0, // Accumulation Bits Ignored
- 24, // 24Bit Z-Buffer (Depth Buffer)
- 0, // No Stencil Buffer
- 0, // No Auxiliary Buffer
- PFD_MAIN_PLANE, // Main Drawing Layer
- 0, // Reserved
+ (BYTE)PFD_TYPE_RGBA,
+ OS::get_singleton()->is_layered_allowed() ? (BYTE)32 : (BYTE)24,
+ (BYTE)0, (BYTE)0, (BYTE)0, (BYTE)0, (BYTE)0, (BYTE)0, // Color Bits Ignored
+ OS::get_singleton()->is_layered_allowed() ? (BYTE)8 : (BYTE)0, // Alpha Buffer
+ (BYTE)0, // Shift Bit Ignored
+ (BYTE)0, // No Accumulation Buffer
+ (BYTE)0, (BYTE)0, (BYTE)0, (BYTE)0, // Accumulation Bits Ignored
+ (BYTE)24, // 24Bit Z-Buffer (Depth Buffer)
+ (BYTE)0, // No Stencil Buffer
+ (BYTE)0, // No Auxiliary Buffer
+ (BYTE)PFD_MAIN_PLANE, // Main Drawing Layer
+ (BYTE)0, // Reserved
0, 0, 0 // Layer Masks Ignored
};
diff --git a/platform/windows/joypad.cpp b/platform/windows/joypad.cpp
index b56fb6509e..99ac0214e0 100644
--- a/platform/windows/joypad.cpp
+++ b/platform/windows/joypad.cpp
@@ -163,7 +163,7 @@ bool JoypadWindows::setup_dinput_joypad(const DIDEVICEINSTANCE *instance) {
const GUID &guid = instance->guidProduct;
char uid[128];
- sprintf(uid, "%08lx%04hx%04hx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx",
+ 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]);
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp
index e8c209c0fc..ac130ac4f2 100644
--- a/platform/windows/os_windows.cpp
+++ b/platform/windows/os_windows.cpp
@@ -1204,7 +1204,14 @@ Error OS_Windows::initialize(const VideoMode &p_desired, int p_video_driver, int
AdjustWindowRectEx(&WindowRect, dwStyle, FALSE, dwExStyle);
- char *windowid = getenv("GODOT_WINDOWID");
+ char *windowid;
+#ifdef MINGW_ENABLED
+ windowid = getenv("GODOT_WINDOWID");
+#else
+ size_t len;
+ _dupenv_s(&windowid, &len, "GODOT_WINDOWID");
+#endif
+
if (windowid) {
// strtoull on mingw
@@ -1213,6 +1220,7 @@ Error OS_Windows::initialize(const VideoMode &p_desired, int p_video_driver, int
#else
hWnd = (HWND)_strtoui64(windowid, NULL, 0);
#endif
+ free(windowid);
SetLastError(0);
user_proc = (WNDPROC)GetWindowLongPtr(hWnd, GWLP_WNDPROC);
SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR)(WNDPROC)::WndProc);
@@ -1744,7 +1752,7 @@ void OS_Windows::set_window_size(const Size2 p_size) {
RECT rect;
GetWindowRect(hWnd, &rect);
- if (video_mode.borderless_window == false) {
+ if (!video_mode.borderless_window) {
RECT crect;
GetClientRect(hWnd, &crect);
@@ -2546,7 +2554,16 @@ void OS_Windows::set_icon(const Ref<Image> &p_icon) {
bool OS_Windows::has_environment(const String &p_var) const {
+#ifdef MINGW_ENABLED
return _wgetenv(p_var.c_str()) != NULL;
+#else
+ wchar_t *env;
+ size_t len;
+ _wdupenv_s(&env, &len, p_var.c_str());
+ const bool has_env = env != NULL;
+ free(env);
+ return has_env;
+#endif
};
String OS_Windows::get_environment(const String &p_var) const {
@@ -2737,7 +2754,7 @@ void OS_Windows::run() {
while (!force_quit) {
process_events(); // get rid of pending events
- if (Main::iteration() == true)
+ if (Main::iteration())
break;
};
@@ -2926,7 +2943,7 @@ bool OS_Windows::is_disable_crash_handler() const {
Error OS_Windows::move_to_trash(const String &p_path) {
SHFILEOPSTRUCTW sf;
WCHAR *from = new WCHAR[p_path.length() + 2];
- wcscpy(from, p_path.c_str());
+ wcscpy_s(from, p_path.length() + 1, p_path.c_str());
from[p_path.length() + 1] = 0;
sf.hwnd = hWnd;
diff --git a/platform/x11/godot_x11.cpp b/platform/x11/godot_x11.cpp
index 3241cbcbf9..21148f8e86 100644
--- a/platform/x11/godot_x11.cpp
+++ b/platform/x11/godot_x11.cpp
@@ -43,7 +43,7 @@ int main(int argc, char *argv[]) {
setlocale(LC_CTYPE, "");
char *cwd = (char *)malloc(PATH_MAX);
- getcwd(cwd, PATH_MAX);
+ char *ret = getcwd(cwd, PATH_MAX);
Error err = Main::setup(argv[0], argc - 1, &argv[1]);
if (err != OK) {
@@ -55,7 +55,8 @@ int main(int argc, char *argv[]) {
os.run(); // it is actually the OS that decides how to run
Main::cleanup();
- chdir(cwd);
+ if (ret)
+ chdir(cwd);
free(cwd);
return os.get_exit_code();
diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp
index 5be0b9304a..7c4c8f0eff 100644
--- a/platform/x11/os_x11.cpp
+++ b/platform/x11/os_x11.cpp
@@ -1096,7 +1096,7 @@ void OS_X11::set_window_size(const Size2 p_size) {
int old_h = xwa.height;
// If window resizable is disabled we need to update the attributes first
- if (is_window_resizable() == false) {
+ if (!is_window_resizable()) {
XSizeHints *xsh;
xsh = XAllocSizeHints();
xsh->flags = PMinSize | PMaxSize;
@@ -1688,7 +1688,7 @@ void OS_X11::handle_key_event(XKeyEvent *p_event, bool p_echo) {
}
} else {
//ignore
- if (last_is_pressed == false) {
+ if (!last_is_pressed) {
return;
}
}
@@ -2814,7 +2814,7 @@ void OS_X11::run() {
#ifdef JOYDEV_ENABLED
joypad->process_joypads();
#endif
- if (Main::iteration() == true)
+ if (Main::iteration())
break;
};
diff --git a/scene/2d/animated_sprite.cpp b/scene/2d/animated_sprite.cpp
index a33fc844a5..8a5910c10e 100644
--- a/scene/2d/animated_sprite.cpp
+++ b/scene/2d/animated_sprite.cpp
@@ -395,15 +395,17 @@ void AnimatedSprite::_notification(int p_what) {
int fc = frames->get_frame_count(animation);
if (frame >= fc - 1) {
if (frames->get_animation_loop(animation)) {
+ emit_signal(SceneStringNames::get_singleton()->animation_finished);
frame = 0;
} else {
+ if (!is_over) {
+ emit_signal(SceneStringNames::get_singleton()->animation_finished);
+ is_over = true;
+ }
frame = fc - 1;
}
} else {
frame++;
- if (frame == fc - 1) {
- emit_signal(SceneStringNames::get_singleton()->animation_finished);
- }
}
update();
@@ -625,6 +627,7 @@ void AnimatedSprite::_reset_timeout() {
return;
timeout = _get_frame_duration();
+ is_over = false;
}
void AnimatedSprite::set_animation(const StringName &p_animation) {
@@ -712,4 +715,5 @@ AnimatedSprite::AnimatedSprite() {
playing = false;
animation = "default";
timeout = 0;
+ is_over = false;
}
diff --git a/scene/2d/animated_sprite.h b/scene/2d/animated_sprite.h
index cc49465403..7270ee4d0e 100644
--- a/scene/2d/animated_sprite.h
+++ b/scene/2d/animated_sprite.h
@@ -135,6 +135,7 @@ class AnimatedSprite : public Node2D {
bool centered;
Point2 offset;
+ bool is_over;
float timeout;
bool hflip;
diff --git a/scene/2d/audio_stream_player_2d.cpp b/scene/2d/audio_stream_player_2d.cpp
index a1ae05d971..9de72a4fcd 100644
--- a/scene/2d/audio_stream_player_2d.cpp
+++ b/scene/2d/audio_stream_player_2d.cpp
@@ -179,7 +179,7 @@ void AudioStreamPlayer2D::_notification(int p_what) {
Physics2DDirectSpaceState::ShapeResult sr[MAX_INTERSECT_AREAS];
- int areas = space_state->intersect_point(global_pos, sr, MAX_INTERSECT_AREAS, Set<RID>(), area_mask);
+ 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++) {
diff --git a/scene/2d/camera_2d.cpp b/scene/2d/camera_2d.cpp
index 3b86ca76ea..788a39d05d 100644
--- a/scene/2d/camera_2d.cpp
+++ b/scene/2d/camera_2d.cpp
@@ -422,14 +422,14 @@ void Camera2D::clear_current() {
void Camera2D::set_limit(Margin p_margin, int p_limit) {
- ERR_FAIL_INDEX(p_margin, 4);
+ 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(p_margin, 4, 0);
+ ERR_FAIL_INDEX_V((int)p_margin, 4, 0);
return limit[p_margin];
}
@@ -446,14 +446,14 @@ bool Camera2D::is_limit_smoothing_enabled() const {
void Camera2D::set_drag_margin(Margin p_margin, float p_drag_margin) {
- ERR_FAIL_INDEX(p_margin, 4);
+ 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(p_margin, 4, 0);
+ ERR_FAIL_INDEX_V((int)p_margin, 4, 0);
return drag_margin[p_margin];
}
diff --git a/scene/2d/collision_polygon_2d.cpp b/scene/2d/collision_polygon_2d.cpp
index 508ceeaaf9..410b27c691 100644
--- a/scene/2d/collision_polygon_2d.cpp
+++ b/scene/2d/collision_polygon_2d.cpp
@@ -247,7 +247,7 @@ Vector<Point2> CollisionPolygon2D::get_polygon() const {
void CollisionPolygon2D::set_build_mode(BuildMode p_mode) {
- ERR_FAIL_INDEX(p_mode, 2);
+ ERR_FAIL_INDEX((int)p_mode, 2);
build_mode = p_mode;
if (parent) {
_build_polygon();
diff --git a/scene/2d/cpu_particles_2d.cpp b/scene/2d/cpu_particles_2d.cpp
index d29c6b37d5..e6dcd643be 100644
--- a/scene/2d/cpu_particles_2d.cpp
+++ b/scene/2d/cpu_particles_2d.cpp
@@ -985,7 +985,7 @@ void CPUParticles2D::_notification(int p_what) {
if (p_what == NOTIFICATION_INTERNAL_PROCESS) {
- if (particles.size() == 0)
+ if (particles.size() == 0 || !is_visible_in_tree())
return;
float delta = get_process_delta_time();
diff --git a/scene/2d/node_2d.cpp b/scene/2d/node_2d.cpp
index 29065a89b3..2f94c3c6f5 100644
--- a/scene/2d/node_2d.cpp
+++ b/scene/2d/node_2d.cpp
@@ -204,12 +204,6 @@ Size2 Node2D::get_scale() const {
return _scale;
}
-void Node2D::_notification(int p_what) {
-
- switch (p_what) {
- }
-}
-
Transform2D Node2D::get_transform() const {
return _mat;
diff --git a/scene/2d/node_2d.h b/scene/2d/node_2d.h
index 725686cdf8..924a84fb88 100644
--- a/scene/2d/node_2d.h
+++ b/scene/2d/node_2d.h
@@ -52,8 +52,6 @@ class Node2D : public CanvasItem {
void _update_xform_values();
protected:
- void _notification(int p_what);
-
static void _bind_methods();
public:
diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp
index 5b8d10ea85..67e25ec508 100644
--- a/scene/2d/tile_map.cpp
+++ b/scene/2d/tile_map.cpp
@@ -304,7 +304,7 @@ void TileMap::update_dirty_quadrants() {
}
q.occluder_instances.clear();
Ref<ShaderMaterial> prev_material;
- int prev_z_index;
+ int prev_z_index = 0;
RID prev_canvas_item;
RID prev_debug_canvas_item;
@@ -593,7 +593,7 @@ void TileMap::update_dirty_quadrants() {
if (quadrant_order_dirty) {
- int index = -0x80000000; //always must be drawn below children
+ 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();
diff --git a/scene/3d/audio_stream_player_3d.cpp b/scene/3d/audio_stream_player_3d.cpp
index b1f90b72e7..3046cad624 100644
--- a/scene/3d/audio_stream_player_3d.cpp
+++ b/scene/3d/audio_stream_player_3d.cpp
@@ -290,7 +290,7 @@ void AudioStreamPlayer3D::_notification(int p_what) {
PhysicsDirectSpaceState::ShapeResult sr[MAX_INTERSECT_AREAS];
- int areas = space_state->intersect_point(global_pos, sr, MAX_INTERSECT_AREAS, Set<RID>(), area_mask);
+ int areas = space_state->intersect_point(global_pos, sr, MAX_INTERSECT_AREAS, Set<RID>(), area_mask, false, true);
Area *area = NULL;
for (int i = 0; i < areas; i++) {
@@ -448,7 +448,7 @@ void AudioStreamPlayer3D::_notification(int p_what) {
//float dist_att_db = -20 * Math::log(dist + 0.00001); //logarithmic attenuation, like in real life
- float center_val[3] = { 0.5, 0.25, 0.16666 };
+ float center_val[3] = { 0.5f, 0.25f, 0.16666f };
AudioFrame center_frame(center_val[vol_index_max - 1], center_val[vol_index_max - 1]);
if (attenuation < 1.0) {
@@ -814,7 +814,7 @@ AudioStreamPlayer3D::AttenuationModel AudioStreamPlayer3D::get_attenuation_model
void AudioStreamPlayer3D::set_out_of_range_mode(OutOfRangeMode p_mode) {
- ERR_FAIL_INDEX(p_mode, 2);
+ ERR_FAIL_INDEX((int)p_mode, 2);
out_of_range_mode = p_mode;
}
diff --git a/scene/3d/baked_lightmap.cpp b/scene/3d/baked_lightmap.cpp
index 8f3fe8577e..62589bd67e 100644
--- a/scene/3d/baked_lightmap.cpp
+++ b/scene/3d/baked_lightmap.cpp
@@ -29,6 +29,7 @@
/*************************************************************************/
#include "baked_lightmap.h"
+#include "core/io/config_file.h"
#include "core/io/resource_saver.h"
#include "core/os/dir_access.h"
#include "core/os/os.h"
@@ -526,21 +527,60 @@ BakedLightmap::BakeError BakedLightmap::bake(Node *p_from_node, bool p_create_vi
tex_flags |= Texture::FLAG_CONVERT_TO_LINEAR;
}
- Ref<ImageTexture> tex;
- String image_path = save_path.plus_file(mesh_name + ".tex");
- bool set_path = true;
- if (ResourceCache::has(image_path)) {
- tex = Ref<Resource>((Resource *)ResourceCache::get(image_path));
- set_path = false;
- }
+ String image_path = save_path.plus_file(mesh_name);
+ Ref<Texture> texture;
- if (!tex.is_valid()) {
- tex.instance();
- }
+ if (ResourceLoader::import) {
+
+ bool srgb = false;
+ if (false && hdr) {
+ //save hdr
+ } else {
+ image_path += ".png";
+ print_line("image path saving png: " + image_path);
+ image->save_png(image_path);
+ srgb = true;
+ }
- tex->create_from_image(image, tex_flags);
+ if (!FileAccess::exists(image_path + ".import")) {
+ Ref<ConfigFile> config;
+ config.instance();
+ config->set_value("remap", "importer", "texture");
+ config->set_value("remap", "type", "StreamTexture");
+ config->set_value("params", "compress/mode", 2);
+ config->set_value("params", "detect_3d", false);
+ config->set_value("params", "flags/repeat", false);
+ config->set_value("params", "flags/filter", true);
+ config->set_value("params", "flags/mipmaps", false);
+ config->set_value("params", "flags/srgb", srgb);
+
+ config->save(image_path + ".import");
+ }
+
+ ResourceLoader::import(image_path);
+ texture = ResourceLoader::load(image_path); //if already loaded, it will be updated on refocus?
+ } else {
- err = ResourceSaver::save(image_path, tex, ResourceSaver::FLAG_CHANGE_PATH);
+ image_path += ".text";
+ Ref<ImageTexture> tex;
+ bool set_path = true;
+ if (ResourceCache::has(image_path)) {
+ tex = Ref<Resource>((Resource *)ResourceCache::get(image_path));
+ set_path = false;
+ }
+
+ if (!tex.is_valid()) {
+ tex.instance();
+ }
+
+ tex->create_from_image(image, tex_flags);
+
+ err = ResourceSaver::save(image_path, tex, ResourceSaver::FLAG_CHANGE_PATH);
+ if (set_path) {
+ tex->set_path(image_path);
+ }
+ texture = tex;
+ }
if (err != OK) {
if (bake_end_function) {
bake_end_function();
@@ -548,10 +588,7 @@ BakedLightmap::BakeError BakedLightmap::bake(Node *p_from_node, bool p_create_vi
ERR_FAIL_COND_V(err != OK, BAKE_ERROR_CANT_CREATE_IMAGE);
}
- if (set_path) {
- tex->set_path(image_path);
- }
- new_light_data->add_user(E->get().path, tex, E->get().instance_idx);
+ new_light_data->add_user(E->get().path, texture, E->get().instance_idx);
}
}
diff --git a/scene/3d/cpu_particles.cpp b/scene/3d/cpu_particles.cpp
index ec51c31674..35a2049bda 100644
--- a/scene/3d/cpu_particles.cpp
+++ b/scene/3d/cpu_particles.cpp
@@ -592,7 +592,7 @@ void CPUParticles::_particles_process(float p_delta) {
Vector3 direction_xz = Vector3(Math::sin(angle1_rad), 0, Math::cos(angle1_rad));
Vector3 direction_yz = Vector3(0, Math::sin(angle2_rad), Math::cos(angle2_rad));
- direction_yz.z = direction_yz.z / Math::sqrt(direction_yz.z); //better uniform distribution
+ direction_yz.z = direction_yz.z / MAX(0.0001, Math::sqrt(ABS(direction_yz.z))); //better uniform distribution
Vector3 direction = Vector3(direction_xz.x * direction_yz.z, direction_yz.y, direction_xz.z * direction_yz.z);
direction.normalize();
p.velocity = direction * parameters[PARAM_INITIAL_LINEAR_VELOCITY] * Math::lerp(1.0f, float(Math::randf()), randomness[PARAM_INITIAL_LINEAR_VELOCITY]);
@@ -977,6 +977,8 @@ void CPUParticles::_update_particle_data_buffer() {
ptr += 17;
}
+
+ can_update = true;
}
#ifndef NO_THREADS
@@ -989,8 +991,10 @@ void CPUParticles::_update_render_thread() {
#ifndef NO_THREADS
update_mutex->lock();
#endif
-
- VS::get_singleton()->multimesh_set_as_bulk_array(multimesh, particle_data);
+ if (can_update) {
+ VS::get_singleton()->multimesh_set_as_bulk_array(multimesh, particle_data);
+ can_update = false; //wait for next time
+ }
#ifndef NO_THREADS
update_mutex->unlock();
@@ -1032,7 +1036,7 @@ void CPUParticles::_notification(int p_what) {
if (p_what == NOTIFICATION_INTERNAL_PROCESS) {
- if (particles.size() == 0)
+ if (particles.size() == 0 || !is_visible_in_tree())
return;
float delta = get_process_delta_time();
@@ -1061,6 +1065,8 @@ void CPUParticles::_notification(int p_what) {
}
}
+ bool processed = false;
+
if (time == 0 && pre_process_time > 0.0) {
float frame_time;
@@ -1073,6 +1079,7 @@ void CPUParticles::_notification(int p_what) {
while (todo >= 0) {
_particles_process(frame_time);
+ processed = true;
todo -= frame_time;
}
}
@@ -1091,6 +1098,7 @@ void CPUParticles::_notification(int p_what) {
while (todo >= frame_time) {
_particles_process(frame_time);
+ processed = true;
todo -= decr;
}
@@ -1098,9 +1106,12 @@ void CPUParticles::_notification(int p_what) {
} else {
_particles_process(delta);
+ processed = true;
}
- _update_particle_data_buffer();
+ if (processed) {
+ _update_particle_data_buffer();
+ }
}
}
@@ -1424,6 +1435,8 @@ CPUParticles::CPUParticles() {
flags[i] = false;
}
+ can_update = false;
+
set_color(Color(1, 1, 1, 1));
#ifndef NO_THREADS
diff --git a/scene/3d/cpu_particles.h b/scene/3d/cpu_particles.h
index 4e29d8d4ce..77a144b70b 100644
--- a/scene/3d/cpu_particles.h
+++ b/scene/3d/cpu_particles.h
@@ -142,6 +142,8 @@ private:
int fixed_fps;
bool fractional_delta;
+ volatile bool can_update;
+
DrawOrder draw_order;
Ref<Mesh> mesh;
diff --git a/scene/3d/light.cpp b/scene/3d/light.cpp
index 7e1d60ab8e..11d61315ba 100644
--- a/scene/3d/light.cpp
+++ b/scene/3d/light.cpp
@@ -163,11 +163,6 @@ void Light::_update_visibility() {
if (!is_inside_tree())
return;
- // FIXME: Since the call to VS::instance_light_set_enabled was disabled below,
- // the whole logic became pointless so editor_ok triggers unused variable warnings.
- // Commenting out for now but this should be fixed/reimplemented so that editor_only
- // works as expected (GH-17989).
- /*
bool editor_ok = true;
#ifdef TOOLS_ENABLED
@@ -184,8 +179,8 @@ void Light::_update_visibility() {
}
#endif
- //VS::get_singleton()->instance_light_set_enabled(get_instance(),is_visible_in_tree() && editor_ok);
- */
+ VS::get_singleton()->instance_set_visible(get_instance(), is_visible_in_tree() && editor_ok);
+
_change_notify("geometry/visible");
}
diff --git a/scene/3d/mesh_instance.cpp b/scene/3d/mesh_instance.cpp
index 4cbf6f2de3..cf0317cd58 100644
--- a/scene/3d/mesh_instance.cpp
+++ b/scene/3d/mesh_instance.cpp
@@ -253,6 +253,11 @@ void MeshInstance::_notification(int p_what) {
}
}
+int MeshInstance::get_surface_material_count() const {
+
+ return materials.size();
+}
+
void MeshInstance::set_surface_material(int p_surface, const Ref<Material> &p_material) {
ERR_FAIL_INDEX(p_surface, materials.size());
@@ -359,6 +364,7 @@ void MeshInstance::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_skeleton_path", "skeleton_path"), &MeshInstance::set_skeleton_path);
ClassDB::bind_method(D_METHOD("get_skeleton_path"), &MeshInstance::get_skeleton_path);
+ ClassDB::bind_method(D_METHOD("get_surface_material_count"), &MeshInstance::get_surface_material_count);
ClassDB::bind_method(D_METHOD("set_surface_material", "surface", "material"), &MeshInstance::set_surface_material);
ClassDB::bind_method(D_METHOD("get_surface_material", "surface"), &MeshInstance::get_surface_material);
diff --git a/scene/3d/mesh_instance.h b/scene/3d/mesh_instance.h
index 0dfec538f9..0b5b4b9e7b 100644
--- a/scene/3d/mesh_instance.h
+++ b/scene/3d/mesh_instance.h
@@ -76,6 +76,7 @@ public:
void set_skeleton_path(const NodePath &p_skeleton);
NodePath get_skeleton_path();
+ int get_surface_material_count() const;
void set_surface_material(int p_surface, const Ref<Material> &p_material);
Ref<Material> get_surface_material(int p_surface) const;
diff --git a/scene/3d/voxel_light_baker.cpp b/scene/3d/voxel_light_baker.cpp
index 68359eac52..541f6047d9 100644
--- a/scene/3d/voxel_light_baker.cpp
+++ b/scene/3d/voxel_light_baker.cpp
@@ -1587,10 +1587,10 @@ Vector3 VoxelLightBaker::_compute_pixel_light_at_pos(const Vector3 &p_pos, const
Vector3 bitangent = tangent.cross(p_normal).normalized();
Basis normal_xform = Basis(tangent, bitangent, p_normal).transposed();
- const Vector3 *cone_dirs;
- const float *cone_weights;
- int cone_dir_count;
- float cone_aperture;
+ const Vector3 *cone_dirs = NULL;
+ const float *cone_weights = NULL;
+ int cone_dir_count = 0;
+ float cone_aperture = 0;
switch (bake_quality) {
case BAKE_QUALITY_LOW: {
@@ -1619,7 +1619,7 @@ Vector3 VoxelLightBaker::_compute_pixel_light_at_pos(const Vector3 &p_pos, const
Vector3(-0.700629, -0.509037, 0.5),
Vector3(0.267617, -0.823639, 0.5)
};
- static const float weights[6] = { 0.25, 0.15, 0.15, 0.15, 0.15, 0.15 };
+ static const float weights[6] = { 0.25f, 0.15f, 0.15f, 0.15f, 0.15f, 0.15f };
//
cone_dirs = dirs;
cone_dir_count = 6;
@@ -1641,7 +1641,7 @@ Vector3 VoxelLightBaker::_compute_pixel_light_at_pos(const Vector3 &p_pos, const
Vector3(0.19124006749743122, 0.39355745585016605, 0.8991883926788214),
Vector3(0.19124006749743122, -0.39355745585016605, 0.8991883926788214),
};
- static const float weights[10] = { 0.08571, 0.08571, 0.08571, 0.08571, 0.08571, 0.08571, 0.08571, 0.133333, 0.133333, 0.13333 };
+ static const float weights[10] = { 0.08571f, 0.08571f, 0.08571f, 0.08571f, 0.08571f, 0.08571f, 0.08571f, 0.133333f, 0.133333f, 0.13333f };
cone_dirs = dirs;
cone_dir_count = 10;
cone_aperture = 0.404; // tan(angle) 45 degrees
@@ -1875,7 +1875,7 @@ Error VoxelLightBaker::make_lightmap(const Transform &p_xform, Ref<Mesh> &p_mesh
if (bake_mode == BAKE_MODE_RAY_TRACE) {
//blur
//gauss kernel, 7 step sigma 2
- static const float gauss_kernel[4] = { 0.214607, 0.189879, 0.131514, 0.071303 };
+ static const float gauss_kernel[4] = { 0.214607f, 0.189879f, 0.131514f, 0.071303f };
//horizontal pass
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
diff --git a/scene/animation/animation_blend_space_2d.cpp b/scene/animation/animation_blend_space_2d.cpp
index f5f899a6cd..9321133d5f 100644
--- a/scene/animation/animation_blend_space_2d.cpp
+++ b/scene/animation/animation_blend_space_2d.cpp
@@ -468,7 +468,7 @@ float AnimationNodeBlendSpace2D::process(float p_time, bool p_seek) {
}
first = true;
- float mind;
+ float mind = 0;
for (int i = 0; i < blend_points_used; i++) {
bool found = false;
diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp
index 71fb97c2c6..6dfaacc776 100644
--- a/scene/gui/base_button.cpp
+++ b/scene/gui/base_button.cpp
@@ -368,7 +368,7 @@ BaseButton::DrawMode BaseButton::get_draw_mode() const {
return DRAW_DISABLED;
};
- if (status.press_attempt == false && status.hovering) {
+ if (!status.press_attempt && status.hovering) {
if (status.pressed)
return DRAW_HOVER_PRESSED;
diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp
index 03eee9c6d8..c5d3def4c1 100644
--- a/scene/gui/color_picker.cpp
+++ b/scene/gui/color_picker.cpp
@@ -159,7 +159,10 @@ void ColorPicker::_html_entered(const String &p_html) {
if (updating)
return;
+ float last_alpha = color.a;
color = Color::html(p_html);
+ if (!is_editing_alpha())
+ color.a = last_alpha;
if (!is_inside_tree())
return;
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index dc18895298..e155d0ef86 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -769,7 +769,7 @@ 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());
+ ERR_FAIL_COND(!get_viewport()->gui_is_dragging());
get_viewport()->_gui_set_drag_preview(this, p_control);
}
@@ -1079,7 +1079,7 @@ bool Control::has_constant_override(const StringName &p_name) const {
bool Control::has_icon(const StringName &p_name, const StringName &p_type) const {
if (p_type == StringName() || p_type == "") {
- if (has_icon_override(p_name) == true)
+ if (has_icon_override(p_name))
return true;
}
@@ -1113,7 +1113,7 @@ bool Control::has_icon(const StringName &p_name, const StringName &p_type) const
bool Control::has_shader(const StringName &p_name, const StringName &p_type) const {
if (p_type == StringName() || p_type == "") {
- if (has_shader_override(p_name) == true)
+ if (has_shader_override(p_name))
return true;
}
@@ -1146,7 +1146,7 @@ bool Control::has_shader(const StringName &p_name, const StringName &p_type) con
bool Control::has_stylebox(const StringName &p_name, const StringName &p_type) const {
if (p_type == StringName() || p_type == "") {
- if (has_stylebox_override(p_name) == true)
+ if (has_stylebox_override(p_name))
return true;
}
@@ -1179,7 +1179,7 @@ bool Control::has_stylebox(const StringName &p_name, const StringName &p_type) c
bool Control::has_font(const StringName &p_name, const StringName &p_type) const {
if (p_type == StringName() || p_type == "") {
- if (has_font_override(p_name) == true)
+ if (has_font_override(p_name))
return true;
}
@@ -1213,7 +1213,7 @@ bool Control::has_font(const StringName &p_name, const StringName &p_type) const
bool Control::has_color(const StringName &p_name, const StringName &p_type) const {
if (p_type == StringName() || p_type == "") {
- if (has_color_override(p_name) == true)
+ if (has_color_override(p_name))
return true;
}
@@ -1247,7 +1247,7 @@ bool Control::has_color(const StringName &p_name, const StringName &p_type) cons
bool Control::has_constant(const StringName &p_name, const StringName &p_type) const {
if (p_type == StringName() || p_type == "") {
- if (has_constant_override(p_name) == true)
+ if (has_constant_override(p_name))
return true;
}
@@ -2235,13 +2235,13 @@ String Control::_get_tooltip() const {
void Control::set_focus_neighbour(Margin p_margin, const NodePath &p_neighbour) {
- ERR_FAIL_INDEX(p_margin, 4);
+ 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(p_margin, 4, NodePath());
+ ERR_FAIL_INDEX_V((int)p_margin, 4, NodePath());
return data.focus_neighbour[p_margin];
}
diff --git a/scene/gui/gradient_edit.cpp b/scene/gui/gradient_edit.cpp
index 19ffe681ef..c13964d196 100644
--- a/scene/gui/gradient_edit.cpp
+++ b/scene/gui/gradient_edit.cpp
@@ -236,23 +236,23 @@ void GradientEdit::_gui_input(const Ref<InputEvent> &p_event) {
//Snap to nearest point if holding shift
if (mm->get_shift()) {
- float snap_treshhold = 0.03;
- float smallest_ofs = snap_treshhold;
- bool founded = false;
- int nearest_point;
+ float snap_threshold = 0.03;
+ float smallest_ofs = snap_threshold;
+ bool found = false;
+ int nearest_point = 0;
for (int i = 0; i < points.size(); ++i) {
if (i != grabbed) {
float temp_ofs = ABS(points[i].offset - newofs);
if (temp_ofs < smallest_ofs) {
smallest_ofs = temp_ofs;
nearest_point = i;
- if (founded)
+ if (found)
break;
- founded = true;
+ found = true;
}
}
}
- if (founded) {
+ if (found) {
if (points[nearest_point].offset < newofs)
newofs = points[nearest_point].offset + 0.00001;
else
diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp
index b4fd7484e9..b3bebc88ec 100644
--- a/scene/gui/graph_edit.cpp
+++ b/scene/gui/graph_edit.cpp
@@ -406,7 +406,7 @@ void GraphEdit::_top_layer_input(const Ref<InputEvent> &p_ev) {
connecting_color = Object::cast_to<GraphNode>(to)->get_connection_input_color(E->get().to_port);
connecting_target = false;
connecting_to = pos;
- just_disconected = true;
+ just_disconnected = true;
emit_signal("disconnection_request", E->get().from, E->get().from_port, E->get().to, E->get().to_port);
to = get_node(String(connecting_from)); //maybe it was erased
@@ -427,7 +427,7 @@ void GraphEdit::_top_layer_input(const Ref<InputEvent> &p_ev) {
connecting_color = gn->get_connection_output_color(j);
connecting_target = false;
connecting_to = pos;
- just_disconected = false;
+ just_disconnected = false;
return;
}
}
@@ -453,7 +453,7 @@ void GraphEdit::_top_layer_input(const Ref<InputEvent> &p_ev) {
connecting_color = Object::cast_to<GraphNode>(fr)->get_connection_output_color(E->get().from_port);
connecting_target = false;
connecting_to = pos;
- just_disconected = true;
+ just_disconnected = true;
emit_signal("disconnection_request", E->get().from, E->get().from_port, E->get().to, E->get().to_port);
fr = get_node(String(connecting_from)); //maybe it was erased
@@ -474,7 +474,7 @@ void GraphEdit::_top_layer_input(const Ref<InputEvent> &p_ev) {
connecting_color = gn->get_connection_input_color(j);
connecting_target = false;
connecting_to = pos;
- just_disconected = true;
+ just_disconnected = true;
return;
}
@@ -544,7 +544,7 @@ void GraphEdit::_top_layer_input(const Ref<InputEvent> &p_ev) {
}
emit_signal("connection_request", from, from_slot, to, to_slot);
- } else if (!just_disconected) {
+ } else if (!just_disconnected) {
String from = connecting_from;
int from_slot = connecting_index;
Vector2 ofs = Vector2(mb->get_position().x, mb->get_position().y);
@@ -1368,6 +1368,6 @@ GraphEdit::GraphEdit() {
zoom_hb->add_child(snap_amount);
setting_scroll_ofs = false;
- just_disconected = false;
+ just_disconnected = false;
set_clip_contents(true);
}
diff --git a/scene/gui/graph_edit.h b/scene/gui/graph_edit.h
index 31a449eb59..71165e3dc9 100644
--- a/scene/gui/graph_edit.h
+++ b/scene/gui/graph_edit.h
@@ -94,7 +94,7 @@ private:
Vector2 connecting_to;
String connecting_target_to;
int connecting_target_index;
- bool just_disconected;
+ bool just_disconnected;
bool dragging;
bool just_selected;
diff --git a/scene/gui/grid_container.cpp b/scene/gui/grid_container.cpp
index 278e4123d7..bb1d1d7695 100644
--- a/scene/gui/grid_container.cpp
+++ b/scene/gui/grid_container.cpp
@@ -184,8 +184,6 @@ 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);
- ClassDB::bind_method(D_METHOD("get_child_control_at_cell", "row", "column"),
- &GridContainer::get_child_control_at_cell);
ADD_PROPERTY(PropertyInfo(Variant::INT, "columns", PROPERTY_HINT_RANGE, "1,1024,1"), "set_columns", "get_columns");
}
@@ -241,21 +239,6 @@ Size2 GridContainer::get_minimum_size() const {
return ms;
}
-Control *GridContainer::get_child_control_at_cell(int row, int column) {
- Control *c;
- int grid_index = row * columns + column;
- for (int i = 0; i < get_child_count(); i++) {
- c = Object::cast_to<Control>(get_child(i));
- if (!c || !c->is_visible_in_tree())
- continue;
-
- if (grid_index == i) {
- break;
- }
- }
- return c;
-}
-
GridContainer::GridContainer() {
set_mouse_filter(MOUSE_FILTER_PASS);
diff --git a/scene/gui/grid_container.h b/scene/gui/grid_container.h
index 7e3470dc89..243d06f034 100644
--- a/scene/gui/grid_container.h
+++ b/scene/gui/grid_container.h
@@ -47,7 +47,6 @@ public:
void set_columns(int p_columns);
int get_columns() const;
virtual Size2 get_minimum_size() const;
- Control *get_child_control_at_cell(int row, int column);
GridContainer();
};
diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp
index 91dab27930..6ff2d232f0 100644
--- a/scene/gui/label.cpp
+++ b/scene/gui/label.cpp
@@ -511,7 +511,7 @@ void Label::regenerate_word_cache() {
void Label::set_align(Align p_align) {
- ERR_FAIL_INDEX(p_align, 4);
+ ERR_FAIL_INDEX((int)p_align, 4);
align = p_align;
update();
}
@@ -523,7 +523,7 @@ Label::Align Label::get_align() const {
void Label::set_valign(VAlign p_align) {
- ERR_FAIL_INDEX(p_align, 4);
+ ERR_FAIL_INDEX((int)p_align, 4);
valign = p_align;
update();
}
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp
index 9c43d5b308..c4373876b1 100644
--- a/scene/gui/line_edit.cpp
+++ b/scene/gui/line_edit.cpp
@@ -527,7 +527,7 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) {
void LineEdit::set_align(Align p_align) {
- ERR_FAIL_INDEX(p_align, 4);
+ ERR_FAIL_INDEX((int)p_align, 4);
align = p_align;
update();
}
@@ -1608,6 +1608,8 @@ LineEdit::LineEdit() {
text_changed_dirty = false;
placeholder_alpha = 0.6;
clear_button_enabled = false;
+ clear_button_status.press_attempt = false;
+ clear_button_status.pressing_inside = false;
deselect();
set_focus_mode(FOCUS_ALL);
diff --git a/scene/gui/nine_patch_rect.cpp b/scene/gui/nine_patch_rect.cpp
index b8f6ffe6d2..c6a34921c7 100644
--- a/scene/gui/nine_patch_rect.cpp
+++ b/scene/gui/nine_patch_rect.cpp
@@ -110,7 +110,7 @@ Ref<Texture> NinePatchRect::get_texture() const {
void NinePatchRect::set_patch_margin(Margin p_margin, int p_size) {
- ERR_FAIL_INDEX(p_margin, 4);
+ ERR_FAIL_INDEX((int)p_margin, 4);
margin[p_margin] = p_size;
update();
minimum_size_changed();
@@ -132,7 +132,7 @@ void NinePatchRect::set_patch_margin(Margin p_margin, int p_size) {
int NinePatchRect::get_patch_margin(Margin p_margin) const {
- ERR_FAIL_INDEX_V(p_margin, 4, 0);
+ ERR_FAIL_INDEX_V((int)p_margin, 4, 0);
return margin[p_margin];
}
diff --git a/scene/gui/tabs.cpp b/scene/gui/tabs.cpp
index c56b7d0f26..b7f8c74046 100644
--- a/scene/gui/tabs.cpp
+++ b/scene/gui/tabs.cpp
@@ -106,41 +106,8 @@ void Tabs::_gui_input(const Ref<InputEvent> &p_event) {
}
}
- // test hovering to display right or close button
- int hover_now = -1;
- int hover_buttons = -1;
- for (int i = 0; i < tabs.size(); i++) {
-
- if (i < offset)
- continue;
-
- Rect2 rect = get_tab_rect(i);
- if (rect.has_point(pos)) {
- hover_now = i;
- }
- if (tabs[i].rb_rect.has_point(pos)) {
- rb_hover = i;
- cb_hover = -1;
- hover_buttons = i;
- break;
- } else if (!tabs[i].disabled && tabs[i].cb_rect.has_point(pos)) {
- cb_hover = i;
- rb_hover = -1;
- hover_buttons = i;
- break;
- }
- }
- if (hover != hover_now) {
- hover = hover_now;
- emit_signal("tab_hover", hover);
- }
-
- if (hover_buttons == -1) { // no hover
- rb_hover = hover_buttons;
- cb_hover = hover_buttons;
- }
+ _update_hover();
update();
-
return;
}
@@ -522,6 +489,48 @@ Ref<Texture> Tabs::get_tab_right_button(int p_tab) const {
return tabs[p_tab].right_button;
}
+void Tabs::_update_hover() {
+
+ if (!is_inside_tree()) {
+ return;
+ }
+
+ const Point2 &pos = get_local_mouse_position();
+ // test hovering to display right or close button
+ int hover_now = -1;
+ int hover_buttons = -1;
+ for (int i = 0; i < tabs.size(); i++) {
+
+ if (i < offset)
+ continue;
+
+ Rect2 rect = get_tab_rect(i);
+ if (rect.has_point(pos)) {
+ hover_now = i;
+ }
+ if (tabs[i].rb_rect.has_point(pos)) {
+ rb_hover = i;
+ cb_hover = -1;
+ hover_buttons = i;
+ break;
+ } else if (!tabs[i].disabled && tabs[i].cb_rect.has_point(pos)) {
+ cb_hover = i;
+ rb_hover = -1;
+ hover_buttons = i;
+ break;
+ }
+ }
+ if (hover != hover_now) {
+ hover = hover_now;
+ emit_signal("tab_hover", hover);
+ }
+
+ if (hover_buttons == -1) { // no hover
+ rb_hover = hover_buttons;
+ cb_hover = hover_buttons;
+ }
+}
+
void Tabs::_update_cache() {
Ref<StyleBox> tab_disabled = get_stylebox("tab_disabled");
Ref<StyleBox> tab_bg = get_stylebox("tab_bg");
@@ -597,6 +606,7 @@ void Tabs::add_tab(const String &p_str, const Ref<Texture> &p_icon) {
tabs.push_back(t);
_update_cache();
+ call_deferred("_update_hover");
update();
minimum_size_changed();
}
@@ -604,6 +614,7 @@ void Tabs::add_tab(const String &p_str, const Ref<Texture> &p_icon) {
void Tabs::clear_tabs() {
tabs.clear();
current = 0;
+ call_deferred("_update_hover");
update();
}
@@ -614,6 +625,7 @@ void Tabs::remove_tab(int p_idx) {
if (current >= p_idx)
current--;
_update_cache();
+ call_deferred("_update_hover");
update();
minimum_size_changed();
@@ -931,6 +943,7 @@ 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);
ClassDB::bind_method(D_METHOD("set_current_tab", "tab_idx"), &Tabs::set_current_tab);
ClassDB::bind_method(D_METHOD("get_current_tab"), &Tabs::get_current_tab);
diff --git a/scene/gui/tabs.h b/scene/gui/tabs.h
index e204f4364b..a98744b804 100644
--- a/scene/gui/tabs.h
+++ b/scene/gui/tabs.h
@@ -97,6 +97,8 @@ private:
int get_tab_width(int p_idx) const;
void _ensure_no_over_offset();
+
+ void _update_hover();
void _update_cache();
protected:
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index c390c60a8c..f8a5c4cea3 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -334,15 +334,12 @@ void TextEdit::_update_scrollbars() {
h_scroll->set_begin(Point2(0, size.height - hmin.height));
h_scroll->set_end(Point2(size.width - vmin.width, size.height));
- int hscroll_rows = ((hmin.height - 1) / get_row_height()) + 1;
int visible_rows = get_visible_rows();
-
int total_rows = get_total_visible_rows();
if (scroll_past_end_of_file_enabled) {
total_rows += visible_rows - 1;
}
- int vscroll_pixels = v_scroll->get_combined_minimum_size().width;
int visible_width = size.width - cache.style_normal->get_minimum_size().width;
int total_width = text.get_max_width(true) + vmin.x;
@@ -367,12 +364,12 @@ void TextEdit::_update_scrollbars() {
} else {
- if (total_rows > visible_rows && total_width <= visible_width - vscroll_pixels) {
+ if (total_rows > visible_rows && total_width <= visible_width) {
//thanks yessopie for this clever bit of logic
use_hscroll = false;
}
- if (total_rows <= visible_rows - hscroll_rows && total_width > visible_width) {
+ if (total_rows <= visible_rows && total_width > visible_width) {
//thanks yessopie for this clever bit of logic
use_vscroll = false;
}
@@ -2334,9 +2331,9 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
// no need to indent if we are going upwards.
if (auto_indent && !(k->get_command() && k->get_shift())) {
- // indent once again if previous line will end with ':' or '{'
+ // indent once again if previous line will end with ':' or '{' and the line is not a comment
// (i.e. colon/brace precedes current cursor position)
- if (cursor.column > 0 && (text[cursor.line][cursor.column - 1] == ':' || text[cursor.line][cursor.column - 1] == '{')) {
+ if (cursor.column > 0 && (text[cursor.line][cursor.column - 1] == ':' || text[cursor.line][cursor.column - 1] == '{') && !is_line_comment(cursor.line)) {
if (indent_using_spaces) {
ins += space_indent;
} else {
@@ -3260,7 +3257,7 @@ void TextEdit::_scroll_down(real_t p_delta) {
}
if (smooth_scroll_enabled) {
- int max_v_scroll = v_scroll->get_max() - v_scroll->get_page();
+ int max_v_scroll = round(v_scroll->get_max() - v_scroll->get_page());
if (target_v_scroll > max_v_scroll) {
target_v_scroll = max_v_scroll;
v_scroll->set_value(target_v_scroll);
diff --git a/scene/gui/texture_progress.cpp b/scene/gui/texture_progress.cpp
index d28b4065fb..75f88dc4e6 100644
--- a/scene/gui/texture_progress.cpp
+++ b/scene/gui/texture_progress.cpp
@@ -59,14 +59,14 @@ Ref<Texture> TextureProgress::get_over_texture() const {
}
void TextureProgress::set_stretch_margin(Margin p_margin, int p_size) {
- ERR_FAIL_INDEX(p_margin, 4);
+ ERR_FAIL_INDEX((int)p_margin, 4);
stretch_margin[p_margin] = p_size;
update();
minimum_size_changed();
}
int TextureProgress::get_stretch_margin(Margin p_margin) const {
- ERR_FAIL_INDEX_V(p_margin, 4, 0);
+ ERR_FAIL_INDEX_V((int)p_margin, 4, 0);
return stretch_margin[p_margin];
}
@@ -148,9 +148,9 @@ Point2 TextureProgress::unit_val_to_uv(float val) {
float angle = (val * Math_TAU) - Math_PI * 0.5;
Point2 dir = Vector2(Math::cos(angle), Math::sin(angle));
float t1 = 1.0;
- float cp;
- float cq;
- float cr;
+ float cp = 0;
+ float cq = 0;
+ float cr = 0;
float edgeLeft = 0.0;
float edgeRight = 1.0;
float edgeBottom = 0.0;
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index 3a540d187b..0c11181f98 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -2183,6 +2183,7 @@ 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) accept_event();
@@ -2219,13 +2220,13 @@ void Tree::_gui_input(Ref<InputEvent> p_event) {
_go_left();
}
- } else if (p_event->is_action("ui_up") && p_event->is_pressed() && !k->get_command()) {
+ } else if (p_event->is_action("ui_up") && p_event->is_pressed() && !is_command) {
if (!cursor_can_exit_tree) accept_event();
_go_up();
- } else if (p_event->is_action("ui_down") && p_event->is_pressed() && !k->get_command()) {
+ } else if (p_event->is_action("ui_down") && p_event->is_pressed() && !is_command) {
if (!cursor_can_exit_tree) accept_event();
@@ -2933,7 +2934,7 @@ void Tree::_notification(int p_what) {
if (show_column_titles) {
- //title butons
+ //title buttons
int ofs = cache.bg->get_margin(MARGIN_LEFT);
for (int i = 0; i < columns.size(); i++) {
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index 8fd7dc1d7b..50e94e6db5 100644
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -2192,7 +2192,7 @@ void Node::_duplicate_signals(const Node *p_original, Node *p_copy) const {
if (p_copy->has_node(ptarget))
copytarget = p_copy->get_node(ptarget);
- if (copy && copytarget) {
+ if (copy && copytarget && !copy->is_connected(E->get().signal, copytarget, E->get().method)) {
copy->connect(E->get().signal, copytarget, E->get().method, E->get().binds, E->get().flags);
}
}
diff --git a/scene/resources/animation.cpp b/scene/resources/animation.cpp
index 80ad2ad739..5c01cadcd5 100644
--- a/scene/resources/animation.cpp
+++ b/scene/resources/animation.cpp
@@ -1901,7 +1901,7 @@ 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);
- ERR_FAIL_INDEX(p_mode, 4);
+ ERR_FAIL_INDEX((int)p_mode, 4);
ValueTrack *vt = static_cast<ValueTrack *>(t);
vt->update_mode = p_mode;
diff --git a/scene/resources/convex_polygon_shape.cpp b/scene/resources/convex_polygon_shape.cpp
index 9d47bca5ed..39488760cd 100644
--- a/scene/resources/convex_polygon_shape.cpp
+++ b/scene/resources/convex_polygon_shape.cpp
@@ -38,10 +38,9 @@ Vector<Vector3> ConvexPolygonShape::_gen_debug_mesh_lines() {
if (points.size() > 3) {
- QuickHull qh;
Vector<Vector3> varr = Variant(points);
Geometry::MeshData md;
- Error err = qh.build(varr, md);
+ Error err = QuickHull::build(varr, md);
if (err == OK) {
Vector<Vector3> lines;
lines.resize(md.edges.size() * 2);
diff --git a/scene/resources/dynamic_font.cpp b/scene/resources/dynamic_font.cpp
index 6790c35c4b..458cbf6718 100644
--- a/scene/resources/dynamic_font.cpp
+++ b/scene/resources/dynamic_font.cpp
@@ -201,10 +201,10 @@ Error DynamicFontAtSize::_load() {
if (FT_HAS_COLOR(face)) {
int best_match = 0;
- int diff = ABS(id.size - face->available_sizes[0].width);
+ int diff = ABS(id.size - ((int64_t)face->available_sizes[0].width));
scale_color_font = float(id.size) / face->available_sizes[0].width;
for (int i = 1; i < face->num_fixed_sizes; i++) {
- int ndiff = ABS(id.size - face->available_sizes[i].width);
+ int ndiff = ABS(id.size - ((int64_t)face->available_sizes[i].width));
if (ndiff < diff) {
best_match = i;
diff = ndiff;
diff --git a/scene/resources/particles_material.cpp b/scene/resources/particles_material.cpp
index 6f67ba8af1..ba48982fda 100644
--- a/scene/resources/particles_material.cpp
+++ b/scene/resources/particles_material.cpp
@@ -308,7 +308,7 @@ void ParticlesMaterial::_update_shader() {
code += " float angle2_rad = rand_from_seed_m1_p1(alt_seed) * spread_rad * (1.0 - flatness);\n";
code += " vec3 direction_xz = vec3(sin(angle1_rad), 0, cos(angle1_rad));\n";
code += " vec3 direction_yz = vec3(0, sin(angle2_rad), cos(angle2_rad));\n";
- code += " direction_yz.z = direction_yz.z / sqrt(direction_yz.z); // better uniform distribution\n";
+ code += " direction_yz.z = direction_yz.z / max(0.0001,sqrt(abs(direction_yz.z))); // better uniform distribution\n";
code += " vec3 direction = vec3(direction_xz.x * direction_yz.z, direction_yz.y, direction_xz.z * direction_yz.z);\n";
code += " direction = normalize(direction);\n";
code += " VELOCITY = direction * initial_linear_velocity * mix(1.0, rand_from_seed(alt_seed), initial_linear_velocity_random);\n";
diff --git a/scene/resources/shape.cpp b/scene/resources/shape.cpp
index 8ccca81acd..869f4a3a9b 100644
--- a/scene/resources/shape.cpp
+++ b/scene/resources/shape.cpp
@@ -101,7 +101,7 @@ void Shape::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_margin", "margin"), &Shape::set_margin);
ClassDB::bind_method(D_METHOD("get_margin"), &Shape::get_margin);
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "margin", PROPERTY_HINT_RANGE, "0.04,10,0.01"), "set_margin", "get_margin");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "margin", PROPERTY_HINT_RANGE, "0.04,10,0.001"), "set_margin", "get_margin");
}
Shape::Shape() :
diff --git a/scene/resources/style_box.cpp b/scene/resources/style_box.cpp
index fb81375b0a..05050a5ea2 100644
--- a/scene/resources/style_box.cpp
+++ b/scene/resources/style_box.cpp
@@ -136,7 +136,7 @@ Ref<Texture> StyleBoxTexture::get_normal_map() const {
void StyleBoxTexture::set_margin_size(Margin p_margin, float p_size) {
- ERR_FAIL_INDEX(p_margin, 4);
+ ERR_FAIL_INDEX((int)p_margin, 4);
margin[p_margin] = p_size;
emit_changed();
@@ -200,7 +200,7 @@ Size2 StyleBoxTexture::get_center_size() const {
void StyleBoxTexture::set_expand_margin_size(Margin p_expand_margin, float p_size) {
- ERR_FAIL_INDEX(p_expand_margin, 4);
+ ERR_FAIL_INDEX((int)p_expand_margin, 4);
expand_margin[p_expand_margin] = p_size;
emit_changed();
}
@@ -223,7 +223,7 @@ void StyleBoxTexture::set_expand_margin_size_all(float p_expand_margin_size) {
float StyleBoxTexture::get_expand_margin_size(Margin p_expand_margin) const {
- ERR_FAIL_INDEX_V(p_expand_margin, 4, 0);
+ ERR_FAIL_INDEX_V((int)p_expand_margin, 4, 0);
return expand_margin[p_expand_margin];
}
@@ -565,8 +565,6 @@ inline void draw_ring(Vector<Vector2> &verts, Vector<int> &indices, Vector<Color
vert_offset = 0;
}
int adapted_corner_detail = (corner_radius[0] == 0 && corner_radius[1] == 0 && corner_radius[2] == 0 && corner_radius[3] == 0) ? 1 : corner_detail;
- int rings = (border_width[0] == 0 && border_width[1] == 0 && border_width[2] == 0 && border_width[3] == 0) ? 1 : 2;
- rings = 2;
int ring_corner_radius[4];
set_inner_corner_radius(style_rect, ring_rect, corner_radius, ring_corner_radius);
@@ -592,7 +590,7 @@ inline void draw_ring(Vector<Vector2> &verts, Vector<int> &indices, Vector<Color
//calculate the vert array
for (int corner_index = 0; corner_index < 4; corner_index++) {
for (int detail = 0; detail <= adapted_corner_detail; detail++) {
- for (int inner_outer = (2 - rings); inner_outer < 2; inner_outer++) {
+ for (int inner_outer = 0; inner_outer < 2; inner_outer++) {
float radius;
Color color;
Point2 corner_point;
@@ -613,19 +611,17 @@ inline void draw_ring(Vector<Vector2> &verts, Vector<int> &indices, Vector<Color
}
}
- if (rings == 2) {
- int vert_count = (adapted_corner_detail + 1) * 4 * rings;
- //fill the indices and the colors for the border
- for (int i = 0; i < vert_count; i++) {
- //poly 1
- indices.push_back(vert_offset + ((i + 0) % vert_count));
- indices.push_back(vert_offset + ((i + 2) % vert_count));
- indices.push_back(vert_offset + ((i + 1) % vert_count));
- //poly 2
- indices.push_back(vert_offset + ((i + 1) % vert_count));
- indices.push_back(vert_offset + ((i + 2) % vert_count));
- indices.push_back(vert_offset + ((i + 3) % vert_count));
- }
+ int vert_count = (adapted_corner_detail + 1) * 4 * 2;
+ //fill the indices and the colors for the border
+ for (int i = 0; i < vert_count; i++) {
+ //poly 1
+ indices.push_back(vert_offset + ((i + 0) % vert_count));
+ indices.push_back(vert_offset + ((i + 2) % vert_count));
+ indices.push_back(vert_offset + ((i + 1) % vert_count));
+ //poly 2
+ indices.push_back(vert_offset + ((i + 1) % vert_count));
+ indices.push_back(vert_offset + ((i + 2) % vert_count));
+ indices.push_back(vert_offset + ((i + 3) % vert_count));
}
}
diff --git a/servers/audio/audio_stream.cpp b/servers/audio/audio_stream.cpp
index 7de0695e8c..02a0bed964 100644
--- a/servers/audio/audio_stream.cpp
+++ b/servers/audio/audio_stream.cpp
@@ -136,16 +136,20 @@ void AudioStreamPlaybackMicrophone::_mix_internal(AudioFrame *p_buffer, int p_fr
Vector<int32_t> buf = AudioDriver::get_singleton()->get_input_buffer();
unsigned int input_size = AudioDriver::get_singleton()->get_input_size();
+ int mix_rate = AudioDriver::get_singleton()->get_mix_rate();
+ int playback_delay = MIN(((50 * mix_rate) / 1000) * 2, buf.size() >> 1);
+#ifdef DEBUG_ENABLED
+ unsigned int input_position = AudioDriver::get_singleton()->get_input_position();
+#endif
- // p_frames is multiplied by two since an AudioFrame is stereo
- if ((p_frames + MICROPHONE_PLAYBACK_DELAY * 2) > input_size) {
+ if (playback_delay > input_size) {
for (int i = 0; i < p_frames; i++) {
p_buffer[i] = AudioFrame(0.0f, 0.0f);
}
input_ofs = 0;
} else {
for (int i = 0; i < p_frames; i++) {
- if (input_size >= input_ofs) {
+ if (input_size > input_ofs) {
float l = (buf[input_ofs++] >> 16) / 32768.f;
if (input_ofs >= buf.size()) {
input_ofs = 0;
@@ -162,6 +166,12 @@ void AudioStreamPlaybackMicrophone::_mix_internal(AudioFrame *p_buffer, int p_fr
}
}
+#ifdef DEBUG_ENABLED
+ if (input_ofs > input_position && (input_ofs - input_position) < (p_frames * 2)) {
+ print_verbose(String(get_class_name()) + " buffer underrun: input_position=" + itos(input_position) + " input_ofs=" + itos(input_ofs) + " input_size=" + itos(input_size));
+ }
+#endif
+
AudioDriver::get_singleton()->unlock();
}
diff --git a/servers/audio/audio_stream.h b/servers/audio/audio_stream.h
index 2740f86d55..f6ed45cc9c 100644
--- a/servers/audio/audio_stream.h
+++ b/servers/audio/audio_stream.h
@@ -122,8 +122,6 @@ class AudioStreamPlaybackMicrophone : public AudioStreamPlaybackResampled {
GDCLASS(AudioStreamPlaybackMicrophone, AudioStreamPlayback)
friend class AudioStreamMicrophone;
- static const int MICROPHONE_PLAYBACK_DELAY = 256;
-
bool active;
unsigned int input_ofs;
diff --git a/servers/audio/effects/reverb.cpp b/servers/audio/effects/reverb.cpp
index ef23e4aaf3..b032c91da2 100644
--- a/servers/audio/effects/reverb.cpp
+++ b/servers/audio/effects/reverb.cpp
@@ -36,22 +36,22 @@
const float Reverb::comb_tunings[MAX_COMBS] = {
//freeverb comb tunings
- 0.025306122448979593,
- 0.026938775510204082,
- 0.028956916099773241,
- 0.03074829931972789,
- 0.032244897959183672,
- 0.03380952380952381,
- 0.035306122448979592,
- 0.036666666666666667
+ 0.025306122448979593f,
+ 0.026938775510204082f,
+ 0.028956916099773241f,
+ 0.03074829931972789f,
+ 0.032244897959183672f,
+ 0.03380952380952381f,
+ 0.035306122448979592f,
+ 0.036666666666666667f
};
const float Reverb::allpass_tunings[MAX_ALLPASS] = {
//freeverb allpass tunings
- 0.0051020408163265302,
- 0.007732426303854875,
- 0.01,
- 0.012607709750566893
+ 0.0051020408163265302f,
+ 0.007732426303854875f,
+ 0.01f,
+ 0.012607709750566893f
};
void Reverb::process(float *p_src, float *p_dst, int p_frames) {
diff --git a/servers/audio_server.cpp b/servers/audio_server.cpp
index fead2f54da..37454d9253 100644
--- a/servers/audio_server.cpp
+++ b/servers/audio_server.cpp
@@ -80,6 +80,14 @@ double AudioDriver::get_mix_time() const {
return 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;
+ input_size = 0;
+}
+
void AudioDriver::input_buffer_write(int32_t sample) {
input_buffer.write[input_position++] = sample;
@@ -1297,6 +1305,7 @@ void AudioServer::_bind_methods() {
ADD_SIGNAL(MethodInfo("bus_layout_changed"));
BIND_ENUM_CONSTANT(SPEAKER_MODE_STEREO);
+ BIND_ENUM_CONSTANT(SPEAKER_SURROUND_31);
BIND_ENUM_CONSTANT(SPEAKER_SURROUND_51);
BIND_ENUM_CONSTANT(SPEAKER_SURROUND_71);
}
diff --git a/servers/audio_server.h b/servers/audio_server.h
index ba6569eb38..b12ca6e589 100644
--- a/servers/audio_server.h
+++ b/servers/audio_server.h
@@ -59,6 +59,7 @@ protected:
void audio_server_process(int p_frames, int32_t *p_buffer, bool p_update_mix_time = true);
void update_mix_time(int p_frames);
+ void input_buffer_init(int driver_buffer_frames);
void input_buffer_write(int32_t sample);
#ifdef DEBUG_ENABLED
diff --git a/servers/physics/collision_solver_sat.cpp b/servers/physics/collision_solver_sat.cpp
index 087ae570fb..f17f6f7014 100644
--- a/servers/physics/collision_solver_sat.cpp
+++ b/servers/physics/collision_solver_sat.cpp
@@ -98,7 +98,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::abs(rel_A.dot(c) )<_EDGE_IS_VALID_SUPPORT_TRESHOLD ) {
if (Math::abs(rel_A.dot(c)) < CMP_EPSILON) {
// should handle somehow..
diff --git a/servers/physics/collision_solver_sw.cpp b/servers/physics/collision_solver_sw.cpp
index 2f2f6d2908..86ef719f6f 100644
--- a/servers/physics/collision_solver_sw.cpp
+++ b/servers/physics/collision_solver_sw.cpp
@@ -31,7 +31,6 @@
#include "collision_solver_sw.h"
#include "collision_solver_sat.h"
-#include "collision_solver_sat.h"
#include "gjk_epa.h"
#define collision_solver sat_calculate_penetration
diff --git a/servers/physics/joints/generic_6dof_joint_sw.cpp b/servers/physics/joints/generic_6dof_joint_sw.cpp
index 9b1a41e80d..60505c08c5 100644
--- a/servers/physics/joints/generic_6dof_joint_sw.cpp
+++ b/servers/physics/joints/generic_6dof_joint_sw.cpp
@@ -83,7 +83,7 @@ int G6DOFRotationalLimitMotorSW::testLimitValue(real_t test_value) {
real_t G6DOFRotationalLimitMotorSW::solveAngularLimits(
real_t timeStep, Vector3 &axis, real_t jacDiagABInv,
BodySW *body0, BodySW *body1) {
- if (needApplyTorques() == false) return 0.0f;
+ if (!needApplyTorques()) return 0.0f;
real_t target_velocity = m_targetVelocity;
real_t maxMotorForce = m_maxMotorForce;
diff --git a/servers/physics/joints/generic_6dof_joint_sw.h b/servers/physics/joints/generic_6dof_joint_sw.h
index b350546c5d..035525c9e6 100644
--- a/servers/physics/joints/generic_6dof_joint_sw.h
+++ b/servers/physics/joints/generic_6dof_joint_sw.h
@@ -118,14 +118,12 @@ public:
//! Is limited
bool isLimited() {
- if (m_loLimit >= m_hiLimit) return false;
- return true;
+ return (m_loLimit < m_hiLimit);
}
//! Need apply correction
bool needApplyTorques() {
- if (m_currentLimit == 0 && m_enableMotor == false) return false;
- return true;
+ return (m_enableMotor || m_currentLimit != 0);
}
//! calculates error
diff --git a/servers/physics/shape_sw.cpp b/servers/physics/shape_sw.cpp
index e1c985f44f..e7fc821c2c 100644
--- a/servers/physics/shape_sw.cpp
+++ b/servers/physics/shape_sw.cpp
@@ -1047,7 +1047,7 @@ void FaceShapeSW::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_su
/** FIND SUPPORT VERTEX **/
int vert_support_idx = -1;
- real_t support_max;
+ real_t support_max = 0;
for (int i = 0; i < 3; i++) {
diff --git a/servers/physics_2d/body_pair_2d_sw.cpp b/servers/physics_2d/body_pair_2d_sw.cpp
index 2633edf7bb..93a05b74ef 100644
--- a/servers/physics_2d/body_pair_2d_sw.cpp
+++ b/servers/physics_2d/body_pair_2d_sw.cpp
@@ -138,7 +138,7 @@ void BodyPair2DSW::_validate_contacts() {
Contact &c = contacts[i];
bool erase = false;
- if (c.reused == false) {
+ if (!c.reused) {
//was left behind in previous frame
erase = true;
} else {
diff --git a/servers/physics_2d/step_2d_sw.cpp b/servers/physics_2d/step_2d_sw.cpp
index 0fb7af0c94..e4e1b03623 100644
--- a/servers/physics_2d/step_2d_sw.cpp
+++ b/servers/physics_2d/step_2d_sw.cpp
@@ -222,7 +222,7 @@ void Step2DSW::step(Space2DSW *p_space, real_t p_delta, int p_iterations) {
Constraint2DSW *prev_ci = NULL;
while (ci) {
- if (_setup_island(ci, p_delta) == true) {
+ if (_setup_island(ci, p_delta)) {
//removed the root from the island graph because it is not to be processed
diff --git a/servers/visual/shader_language.cpp b/servers/visual/shader_language.cpp
index 67a810bf1c..d52e121a13 100644
--- a/servers/visual/shader_language.cpp
+++ b/servers/visual/shader_language.cpp
@@ -3506,6 +3506,7 @@ ShaderLanguage::Node *ShaderLanguage::_reduce_expression(BlockNode *p_block, Sha
nv.sint = -cn->values[i].sint;
} break;
case TYPE_UINT: {
+ // FIXME: This can't work on uint
nv.uint = -cn->values[i].uint;
} break;
case TYPE_FLOAT: {
diff --git a/servers/visual/shader_types.cpp b/servers/visual/shader_types.cpp
index 57e8d86468..69acf52e17 100644
--- a/servers/visual/shader_types.cpp
+++ b/servers/visual/shader_types.cpp
@@ -109,6 +109,7 @@ ShaderTypes::ShaderTypes() {
shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["EMISSION"] = ShaderLanguage::TYPE_VEC3;
shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["SCREEN_TEXTURE"] = ShaderLanguage::TYPE_SAMPLER2D;
shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["DEPTH_TEXTURE"] = ShaderLanguage::TYPE_SAMPLER2D;
+ shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["DEPTH"] = ShaderLanguage::TYPE_FLOAT;
shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["SCREEN_UV"] = ShaderLanguage::TYPE_VEC2;
shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["POINT_COORD"] = constt(ShaderLanguage::TYPE_VEC2);
shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["ALPHA_SCISSOR"] = ShaderLanguage::TYPE_FLOAT;
diff --git a/servers/visual/visual_server_canvas.cpp b/servers/visual/visual_server_canvas.cpp
index 16cda0326d..3c8088c75c 100644
--- a/servers/visual/visual_server_canvas.cpp
+++ b/servers/visual/visual_server_canvas.cpp
@@ -689,7 +689,7 @@ void VisualServerCanvas::canvas_item_add_polygon(RID p_item, const Vector<Point2
if (indices.empty()) {
ERR_EXPLAIN("Bad Polygon!");
- ERR_FAIL_V();
+ ERR_FAIL();
}
Item::CommandPolygon *polygon = memnew(Item::CommandPolygon);
diff --git a/servers/visual/visual_server_scene.cpp b/servers/visual/visual_server_scene.cpp
index cd0702d20b..654994b83f 100644
--- a/servers/visual/visual_server_scene.cpp
+++ b/servers/visual/visual_server_scene.cpp
@@ -2831,7 +2831,7 @@ void VisualServerScene::_bake_gi_probe(Instance *p_gi_probe) {
RID rid = E->key();
const InstanceGIProbeData::LightCache &lc = E->get();
- if ((!probe_data->dynamic.light_cache_changes.has(rid) || !(probe_data->dynamic.light_cache_changes[rid] == lc)) && lc.visible) {
+ if ((!probe_data->dynamic.light_cache_changes.has(rid) || probe_data->dynamic.light_cache_changes[rid] != lc) && lc.visible) {
//erase light data
_bake_gi_probe_light(header, cells, local_data, leaves, leaf_count, lc, -1);
@@ -2844,7 +2844,7 @@ void VisualServerScene::_bake_gi_probe(Instance *p_gi_probe) {
RID rid = E->key();
const InstanceGIProbeData::LightCache &lc = E->get();
- if ((!probe_data->dynamic.light_cache.has(rid) || !(probe_data->dynamic.light_cache[rid] == lc)) && lc.visible) {
+ if ((!probe_data->dynamic.light_cache.has(rid) || probe_data->dynamic.light_cache[rid] != lc) && lc.visible) {
//add light data
_bake_gi_probe_light(header, cells, local_data, leaves, leaf_count, lc, 1);
@@ -3061,7 +3061,7 @@ bool VisualServerScene::_check_gi_probe(Instance *p_gi_probe) {
lc.transform = probe_data->dynamic.light_to_cell_xform * E->get()->transform;
lc.visible = E->get()->visible;
- if (!probe_data->dynamic.light_cache.has(E->get()->self) || !(probe_data->dynamic.light_cache[E->get()->self] == lc)) {
+ if (!probe_data->dynamic.light_cache.has(E->get()->self) || probe_data->dynamic.light_cache[E->get()->self] != lc) {
all_equal = false;
}
@@ -3081,7 +3081,7 @@ bool VisualServerScene::_check_gi_probe(Instance *p_gi_probe) {
lc.transform = probe_data->dynamic.light_to_cell_xform * E->get()->transform;
lc.visible = E->get()->visible;
- if (!probe_data->dynamic.light_cache.has(E->get()->self) || !(probe_data->dynamic.light_cache[E->get()->self] == lc)) {
+ if (!probe_data->dynamic.light_cache.has(E->get()->self) || probe_data->dynamic.light_cache[E->get()->self] != lc) {
all_equal = false;
}
@@ -3164,7 +3164,7 @@ void VisualServerScene::render_probes() {
force_lighting = true;
}
- if (probe->invalid == false && probe->dynamic.enabled) {
+ if (!probe->invalid && probe->dynamic.enabled) {
switch (probe->dynamic.updating_stage) {
case GI_UPDATE_STAGE_CHECK: {
diff --git a/servers/visual/visual_server_scene.h b/servers/visual/visual_server_scene.h
index bcd6d1d972..0d4737f268 100644
--- a/servers/visual/visual_server_scene.h
+++ b/servers/visual/visual_server_scene.h
@@ -355,6 +355,11 @@ public:
visible == p_cache.visible);
}
+ bool operator!=(const LightCache &p_cache) {
+
+ return !operator==(p_cache);
+ }
+
LightCache() {
type = VS::LIGHT_DIRECTIONAL;