summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/SCsub9
-rw-r--r--modules/arkit/SCsub6
-rw-r--r--modules/arkit/arkit_interface.h18
-rw-r--r--modules/arkit/arkit_interface.mm58
-rw-r--r--modules/arkit/config.py3
-rw-r--r--modules/arkit/register_types.cpp2
-rw-r--r--modules/assimp/SCsub150
-rw-r--r--modules/assimp/config.py3
-rw-r--r--modules/assimp/editor_scene_importer_assimp.cpp142
-rw-r--r--modules/assimp/editor_scene_importer_assimp.h20
-rw-r--r--modules/assimp/import_state.h28
-rw-r--r--modules/assimp/import_utils.h10
-rw-r--r--modules/basis_universal/SCsub42
-rw-r--r--modules/basis_universal/config.py1
-rw-r--r--modules/basis_universal/register_types.cpp37
-rw-r--r--modules/basis_universal/texture_basisu.cpp12
-rw-r--r--modules/bmp/SCsub4
-rw-r--r--modules/bmp/config.py1
-rw-r--r--modules/bmp/image_loader_bmp.cpp4
-rw-r--r--modules/bmp/register_types.cpp2
-rw-r--r--modules/bullet/SCsub358
-rw-r--r--modules/bullet/area_bullet.cpp48
-rw-r--r--modules/bullet/area_bullet.h16
-rw-r--r--modules/bullet/btRayShape.cpp1
-rw-r--r--modules/bullet/bullet_physics_server.cpp426
-rw-r--r--modules/bullet/bullet_physics_server.h20
-rw-r--r--modules/bullet/bullet_utilities.h2
-rw-r--r--modules/bullet/collision_object_bullet.cpp14
-rw-r--r--modules/bullet/collision_object_bullet.h8
-rw-r--r--modules/bullet/cone_twist_joint_bullet.cpp28
-rw-r--r--modules/bullet/cone_twist_joint_bullet.h6
-rw-r--r--modules/bullet/config.py10
-rw-r--r--modules/bullet/constraint_bullet.cpp4
-rw-r--r--modules/bullet/constraint_bullet.h2
-rw-r--r--modules/bullet/doc_classes/BulletPhysicsDirectBodyState.xml13
-rw-r--r--modules/bullet/doc_classes/BulletPhysicsServer.xml13
-rw-r--r--modules/bullet/generic_6dof_joint_bullet.cpp104
-rw-r--r--modules/bullet/generic_6dof_joint_bullet.h12
-rw-r--r--modules/bullet/godot_collision_configuration.cpp4
-rw-r--r--modules/bullet/godot_result_callbacks.cpp8
-rw-r--r--modules/bullet/godot_result_callbacks.h14
-rw-r--r--modules/bullet/hinge_joint_bullet.cpp58
-rw-r--r--modules/bullet/hinge_joint_bullet.h10
-rw-r--r--modules/bullet/joint_bullet.h4
-rw-r--r--modules/bullet/pin_joint_bullet.cpp16
-rw-r--r--modules/bullet/pin_joint_bullet.h6
-rw-r--r--modules/bullet/register_types.cpp8
-rw-r--r--modules/bullet/rid_bullet.h8
-rw-r--r--modules/bullet/rigid_body_bullet.cpp214
-rw-r--r--modules/bullet/rigid_body_bullet.h44
-rw-r--r--modules/bullet/shape_bullet.cpp46
-rw-r--r--modules/bullet/shape_bullet.h22
-rw-r--r--modules/bullet/slider_joint_bullet.cpp94
-rw-r--r--modules/bullet/slider_joint_bullet.h6
-rw-r--r--modules/bullet/soft_body_bullet.cpp24
-rw-r--r--modules/bullet/soft_body_bullet.h4
-rw-r--r--modules/bullet/space_bullet.cpp146
-rw-r--r--modules/bullet/space_bullet.h32
-rw-r--r--modules/camera/SCsub7
-rw-r--r--modules/camera/config.py3
-rw-r--r--modules/csg/SCsub4
-rw-r--r--modules/csg/config.py21
-rw-r--r--modules/csg/csg_gizmos.cpp146
-rw-r--r--modules/csg/csg_gizmos.h20
-rw-r--r--modules/csg/csg_shape.cpp610
-rw-r--r--modules/csg/csg_shape.h70
-rw-r--r--modules/csg/doc_classes/CSGBox3D.xml (renamed from modules/csg/doc_classes/CSGBox.xml)2
-rw-r--r--modules/csg/doc_classes/CSGCombiner.xml15
-rw-r--r--modules/csg/doc_classes/CSGCombiner3D.xml15
-rw-r--r--modules/csg/doc_classes/CSGCylinder3D.xml (renamed from modules/csg/doc_classes/CSGCylinder.xml)2
-rw-r--r--modules/csg/doc_classes/CSGMesh3D.xml (renamed from modules/csg/doc_classes/CSGMesh.xml)2
-rw-r--r--modules/csg/doc_classes/CSGPolygon3D.xml (renamed from modules/csg/doc_classes/CSGPolygon.xml)16
-rw-r--r--modules/csg/doc_classes/CSGPrimitive3D.xml (renamed from modules/csg/doc_classes/CSGPrimitive.xml)2
-rw-r--r--modules/csg/doc_classes/CSGShape3D.xml (renamed from modules/csg/doc_classes/CSGShape.xml)4
-rw-r--r--modules/csg/doc_classes/CSGSphere3D.xml (renamed from modules/csg/doc_classes/CSGSphere.xml)2
-rw-r--r--modules/csg/doc_classes/CSGTorus3D.xml (renamed from modules/csg/doc_classes/CSGTorus.xml)2
-rw-r--r--modules/csg/icons/CSGBox3D.svg (renamed from modules/csg/icons/CSGBox.svg)0
-rw-r--r--modules/csg/icons/CSGCapsule3D.svg (renamed from modules/csg/icons/CSGCapsule.svg)0
-rw-r--r--modules/csg/icons/CSGCombiner3D.svg (renamed from modules/csg/icons/CSGCombiner.svg)0
-rw-r--r--modules/csg/icons/CSGCylinder3D.svg (renamed from modules/csg/icons/CSGCylinder.svg)0
-rw-r--r--modules/csg/icons/CSGMesh3D.svg (renamed from modules/csg/icons/CSGMesh.svg)0
-rw-r--r--modules/csg/icons/CSGPolygon3D.svg (renamed from modules/csg/icons/CSGPolygon.svg)0
-rw-r--r--modules/csg/icons/CSGSphere3D.svg (renamed from modules/csg/icons/CSGSphere.svg)0
-rw-r--r--modules/csg/icons/CSGTorus3D.svg (renamed from modules/csg/icons/CSGTorus.svg)0
-rw-r--r--modules/csg/register_types.cpp18
-rw-r--r--modules/cvtt/SCsub6
-rw-r--r--modules/cvtt/config.py3
-rw-r--r--modules/dds/SCsub4
-rw-r--r--modules/dds/config.py1
-rw-r--r--modules/dds/texture_loader_dds.cpp2
-rw-r--r--modules/dds/texture_loader_dds.h2
-rw-r--r--modules/enet/SCsub6
-rw-r--r--modules/enet/config.py3
-rw-r--r--modules/enet/networked_multiplayer_enet.cpp28
-rw-r--r--modules/etc/SCsub34
-rw-r--r--modules/etc/config.py3
-rw-r--r--modules/etc/image_etc.cpp2
-rw-r--r--modules/etc/texture_loader_pkm.cpp2
-rw-r--r--modules/etc/texture_loader_pkm.h2
-rw-r--r--modules/freetype/SCsub30
-rw-r--r--modules/freetype/config.py1
-rw-r--r--modules/gdnative/SCsub17
-rw-r--r--modules/gdnative/android/android_gdn.cpp6
-rw-r--r--modules/gdnative/arvr/SCsub6
-rw-r--r--modules/gdnative/arvr/arvr_interface_gdnative.cpp439
-rw-r--r--modules/gdnative/config.py5
-rw-r--r--modules/gdnative/doc_classes/ARVRInterfaceGDNative.xml15
-rw-r--r--modules/gdnative/doc_classes/GDNativeLibrary.xml2
-rw-r--r--modules/gdnative/doc_classes/XRInterfaceGDNative.xml15
-rw-r--r--modules/gdnative/gdnative.cpp16
-rw-r--r--modules/gdnative/gdnative.h2
-rw-r--r--modules/gdnative/gdnative/gdnative.cpp8
-rw-r--r--modules/gdnative/gdnative_api.json28
-rw-r--r--modules/gdnative/gdnative_builders.py270
-rw-r--r--modules/gdnative/gdnative_library_editor_plugin.cpp36
-rw-r--r--modules/gdnative/include/nativescript/godot_nativescript.h4
-rw-r--r--modules/gdnative/include/pluginscript/godot_pluginscript.h12
-rw-r--r--modules/gdnative/include/xr/godot_xr.h (renamed from modules/gdnative/include/arvr/godot_arvr.h)37
-rw-r--r--modules/gdnative/nativescript/SCsub8
-rw-r--r--modules/gdnative/nativescript/api_generator.cpp14
-rw-r--r--modules/gdnative/nativescript/godot_nativescript.cpp14
-rw-r--r--modules/gdnative/nativescript/nativescript.cpp45
-rw-r--r--modules/gdnative/nativescript/nativescript.h10
-rw-r--r--modules/gdnative/net/SCsub9
-rw-r--r--modules/gdnative/net/multiplayer_peer_gdnative.cpp30
-rw-r--r--modules/gdnative/net/packet_peer_gdnative.cpp10
-rw-r--r--modules/gdnative/net/stream_peer_gdnative.cpp12
-rw-r--r--modules/gdnative/pluginscript/SCsub6
-rw-r--r--modules/gdnative/pluginscript/pluginscript_instance.cpp2
-rw-r--r--modules/gdnative/pluginscript/pluginscript_instance.h2
-rw-r--r--modules/gdnative/pluginscript/pluginscript_language.h2
-rw-r--r--modules/gdnative/pluginscript/pluginscript_loader.cpp4
-rw-r--r--modules/gdnative/pluginscript/pluginscript_loader.h2
-rw-r--r--modules/gdnative/pluginscript/pluginscript_script.cpp39
-rw-r--r--modules/gdnative/pluginscript/pluginscript_script.h2
-rw-r--r--modules/gdnative/register_types.cpp6
-rw-r--r--modules/gdnative/videodecoder/SCsub8
-rw-r--r--modules/gdnative/videodecoder/video_stream_gdnative.cpp50
-rw-r--r--modules/gdnative/videodecoder/video_stream_gdnative.h10
-rw-r--r--modules/gdnative/xr/SCsub6
-rw-r--r--modules/gdnative/xr/config.py (renamed from modules/gdnative/arvr/config.py)5
-rw-r--r--modules/gdnative/xr/register_types.cpp (renamed from modules/gdnative/arvr/register_types.cpp)9
-rw-r--r--modules/gdnative/xr/register_types.h (renamed from modules/gdnative/arvr/register_types.h)10
-rw-r--r--modules/gdnative/xr/xr_interface_gdnative.cpp428
-rw-r--r--modules/gdnative/xr/xr_interface_gdnative.h (renamed from modules/gdnative/arvr/arvr_interface_gdnative.h)34
-rw-r--r--modules/gdnavigation/SCsub34
-rw-r--r--modules/gdnavigation/config.py1
-rw-r--r--modules/gdnavigation/gd_navigation_server.cpp86
-rw-r--r--modules/gdnavigation/gd_navigation_server.h4
-rw-r--r--modules/gdnavigation/nav_map.cpp26
-rw-r--r--modules/gdnavigation/nav_region.cpp4
-rw-r--r--modules/gdnavigation/nav_region.h2
-rw-r--r--modules/gdnavigation/nav_utils.h6
-rw-r--r--modules/gdnavigation/navigation_mesh_editor_plugin.cpp22
-rw-r--r--modules/gdnavigation/navigation_mesh_editor_plugin.h6
-rw-r--r--modules/gdnavigation/navigation_mesh_generator.cpp92
-rw-r--r--modules/gdnavigation/navigation_mesh_generator.h2
-rw-r--r--modules/gdnavigation/register_types.cpp8
-rw-r--r--modules/gdnavigation/rvo_agent.cpp4
-rw-r--r--modules/gdscript/SCsub10
-rw-r--r--modules/gdscript/config.py4
-rw-r--r--modules/gdscript/doc_classes/@GDScript.xml8
-rw-r--r--modules/gdscript/doc_classes/GDScriptNativeClass.xml19
-rw-r--r--modules/gdscript/editor/gdscript_highlighter.cpp10
-rw-r--r--modules/gdscript/gdscript.cpp80
-rw-r--r--modules/gdscript/gdscript.h10
-rw-r--r--modules/gdscript/gdscript_compiler.cpp28
-rw-r--r--modules/gdscript/gdscript_editor.cpp107
-rw-r--r--modules/gdscript/gdscript_function.cpp71
-rw-r--r--modules/gdscript/gdscript_function.h4
-rw-r--r--modules/gdscript/gdscript_functions.cpp6
-rw-r--r--modules/gdscript/gdscript_parser.cpp366
-rw-r--r--modules/gdscript/gdscript_parser.h25
-rw-r--r--modules/gdscript/gdscript_tokenizer.cpp10
-rw-r--r--modules/gdscript/gdscript_tokenizer.h1
-rw-r--r--modules/gdscript/language_server/gdscript_extend_parser.cpp16
-rw-r--r--modules/gdscript/language_server/gdscript_language_protocol.cpp16
-rw-r--r--modules/gdscript/language_server/gdscript_language_server.cpp8
-rw-r--r--modules/gdscript/language_server/gdscript_text_document.cpp10
-rw-r--r--modules/gdscript/language_server/gdscript_workspace.cpp20
-rw-r--r--modules/gdscript/language_server/lsp.hpp8
-rw-r--r--modules/gdscript/register_types.cpp2
-rw-r--r--modules/glslang/SCsub12
-rw-r--r--modules/glslang/config.py1
-rw-r--r--modules/glslang/register_types.cpp2
-rw-r--r--modules/gridmap/SCsub4
-rw-r--r--modules/gridmap/config.py3
-rw-r--r--modules/gridmap/doc_classes/GridMap.xml2
-rw-r--r--modules/gridmap/grid_map.cpp158
-rw-r--r--modules/gridmap/grid_map.h14
-rw-r--r--modules/gridmap/grid_map_editor_plugin.cpp171
-rw-r--r--modules/gridmap/grid_map_editor_plugin.h10
-rw-r--r--modules/hdr/SCsub4
-rw-r--r--modules/hdr/config.py1
-rw-r--r--modules/hdr/register_types.cpp2
-rw-r--r--modules/jpg/SCsub4
-rw-r--r--modules/jpg/config.py1
-rw-r--r--modules/jpg/register_types.cpp2
-rw-r--r--modules/jsonrpc/SCsub4
-rw-r--r--modules/jsonrpc/config.py5
-rw-r--r--modules/jsonrpc/jsonrpc.cpp2
-rwxr-xr-xmodules/mbedtls/SCsub8
-rwxr-xr-xmodules/mbedtls/config.py1
-rw-r--r--modules/mbedtls/crypto_mbedtls.cpp26
-rw-r--r--modules/mbedtls/crypto_mbedtls.h4
-rw-r--r--modules/mbedtls/dtls_server_mbedtls.cpp2
-rwxr-xr-xmodules/mbedtls/packet_peer_mbed_dtls.cpp16
-rw-r--r--modules/mbedtls/ssl_context_mbedtls.cpp14
-rwxr-xr-xmodules/mbedtls/stream_peer_mbedtls.cpp14
-rw-r--r--modules/mobile_vr/SCsub6
-rw-r--r--modules/mobile_vr/config.py3
-rw-r--r--modules/mobile_vr/doc_classes/MobileVRInterface.xml8
-rw-r--r--modules/mobile_vr/mobile_vr_interface.cpp52
-rw-r--r--modules/mobile_vr/mobile_vr_interface.h14
-rw-r--r--modules/mobile_vr/register_types.cpp2
-rw-r--r--modules/modules_builders.py6
-rw-r--r--modules/mono/SCsub42
-rw-r--r--modules/mono/build_scripts/api_solution_build.py35
-rw-r--r--modules/mono/build_scripts/gen_cs_glue_version.py20
-rw-r--r--modules/mono/build_scripts/godot_tools_build.py23
-rw-r--r--modules/mono/build_scripts/make_android_mono_config.py20
-rw-r--r--modules/mono/build_scripts/mono_configure.py509
-rw-r--r--modules/mono/build_scripts/mono_reg_utils.py59
-rw-r--r--modules/mono/build_scripts/solution_builder.py132
-rw-r--r--modules/mono/class_db_api_json.cpp10
-rw-r--r--modules/mono/config.py59
-rw-r--r--modules/mono/csharp_script.cpp191
-rw-r--r--modules/mono/csharp_script.h12
-rw-r--r--modules/mono/editor/GodotTools/GodotTools.Core/FileUtils.cs27
-rw-r--r--modules/mono/editor/GodotTools/GodotTools.Core/GodotTools.Core.csproj1
-rw-r--r--modules/mono/editor/GodotTools/GodotTools.ProjectEditor/DotNetSolution.cs5
-rw-r--r--modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectUtils.cs62
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/BottomPanel.cs12
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/BuildTab.cs10
-rwxr-xr-xmodules/mono/editor/GodotTools/GodotTools/Export/AotBuilder.cs618
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs446
-rwxr-xr-xmodules/mono/editor/GodotTools/GodotTools/Export/XcodeHelper.cs93
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs51
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/GodotTools.csproj2
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/HotReloadAssemblyWatcher.cs2
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs44
-rw-r--r--modules/mono/editor/bindings_generator.cpp50
-rw-r--r--modules/mono/editor/bindings_generator.h20
-rw-r--r--modules/mono/editor/csharp_project.cpp4
-rw-r--r--modules/mono/editor/editor_internal_calls.cpp28
-rw-r--r--modules/mono/editor/godotsharp_export.cpp29
-rw-r--r--modules/mono/editor/godotsharp_export.h4
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Array.cs28
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Dictionary.cs31
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/DynamicObject.cs2
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/MarshalUtils.cs178
-rw-r--r--modules/mono/glue/base_object_glue.cpp14
-rw-r--r--modules/mono/glue/collections_glue.cpp26
-rw-r--r--modules/mono/glue/gd_glue.cpp18
-rw-r--r--modules/mono/glue/glue_header.h2
-rw-r--r--modules/mono/godotsharp_dirs.cpp6
-rw-r--r--modules/mono/managed_callable.cpp4
-rw-r--r--modules/mono/mono_gc_handle.cpp2
-rw-r--r--modules/mono/mono_gc_handle.h2
-rw-r--r--modules/mono/mono_gd/gd_mono.cpp213
-rw-r--r--modules/mono/mono_gd/gd_mono.h10
-rw-r--r--modules/mono/mono_gd/gd_mono_assembly.cpp295
-rw-r--r--modules/mono/mono_gd/gd_mono_assembly.h35
-rw-r--r--modules/mono/mono_gd/gd_mono_cache.cpp196
-rw-r--r--modules/mono/mono_gd/gd_mono_cache.h25
-rw-r--r--modules/mono/mono_gd/gd_mono_class.cpp94
-rw-r--r--modules/mono/mono_gd/gd_mono_class.h6
-rw-r--r--modules/mono/mono_gd/gd_mono_field.cpp117
-rw-r--r--modules/mono/mono_gd/gd_mono_internals.cpp4
-rw-r--r--modules/mono/mono_gd/gd_mono_log.cpp10
-rw-r--r--modules/mono/mono_gd/gd_mono_log.h9
-rw-r--r--modules/mono/mono_gd/gd_mono_marshal.cpp349
-rw-r--r--modules/mono/mono_gd/gd_mono_marshal.h13
-rw-r--r--modules/mono/mono_gd/gd_mono_method.cpp35
-rw-r--r--modules/mono/mono_gd/gd_mono_method.h6
-rw-r--r--modules/mono/mono_gd/gd_mono_method_thunk.h52
-rw-r--r--modules/mono/mono_gd/gd_mono_property.cpp32
-rw-r--r--modules/mono/mono_gd/gd_mono_property.h6
-rw-r--r--modules/mono/mono_gd/gd_mono_utils.cpp165
-rw-r--r--modules/mono/mono_gd/gd_mono_utils.h25
-rw-r--r--modules/mono/mono_gd/managed_type.h2
-rwxr-xr-x[-rw-r--r--]modules/mono/mono_gd/support/android_support.cpp (renamed from modules/mono/mono_gd/gd_mono_android.cpp)98
-rwxr-xr-x[-rw-r--r--]modules/mono/mono_gd/support/android_support.h (renamed from modules/mono/mono_gd/gd_mono_android.h)19
-rwxr-xr-xmodules/mono/mono_gd/support/ios_support.h51
-rwxr-xr-xmodules/mono/mono_gd/support/ios_support.mm151
-rw-r--r--modules/mono/register_types.cpp4
-rw-r--r--modules/mono/signal_awaiter_utils.cpp4
-rw-r--r--modules/mono/utils/mono_reg_utils.cpp6
-rw-r--r--modules/mono/utils/osx_utils.cpp6
-rw-r--r--modules/mono/utils/path_utils.cpp10
-rw-r--r--modules/mono/utils/string_utils.cpp2
-rw-r--r--modules/ogg/SCsub6
-rw-r--r--modules/ogg/config.py1
-rw-r--r--modules/opensimplex/SCsub4
-rw-r--r--modules/opensimplex/config.py9
-rw-r--r--modules/opensimplex/noise_texture.cpp25
-rw-r--r--modules/opus/SCsub31
-rw-r--r--modules/opus/config.py1
-rw-r--r--modules/pvr/SCsub4
-rw-r--r--modules/pvr/config.py1
-rw-r--r--modules/pvr/texture_loader_pvr.cpp4
-rw-r--r--modules/pvr/texture_loader_pvr.h2
-rw-r--r--modules/regex/SCsub16
-rw-r--r--modules/regex/config.py3
-rw-r--r--modules/regex/regex.cpp26
-rw-r--r--modules/squish/SCsub6
-rw-r--r--modules/squish/config.py1
-rw-r--r--modules/stb_vorbis/SCsub4
-rw-r--r--modules/stb_vorbis/audio_stream_ogg_vorbis.cpp23
-rw-r--r--modules/stb_vorbis/config.py3
-rw-r--r--modules/stb_vorbis/resource_importer_ogg_vorbis.h2
-rw-r--r--modules/svg/SCsub6
-rw-r--r--modules/svg/config.py1
-rw-r--r--modules/svg/image_loader_svg.cpp4
-rw-r--r--modules/svg/image_loader_svg.h2
-rw-r--r--modules/svg/register_types.cpp2
-rw-r--r--modules/tga/SCsub4
-rw-r--r--modules/tga/config.py1
-rw-r--r--modules/tga/image_loader_tga.cpp2
-rw-r--r--modules/tga/register_types.cpp2
-rw-r--r--modules/theora/SCsub60
-rw-r--r--modules/theora/config.py3
-rw-r--r--modules/theora/video_stream_theora.cpp16
-rw-r--r--modules/theora/video_stream_theora.h2
-rw-r--r--modules/tinyexr/SCsub4
-rw-r--r--modules/tinyexr/config.py3
-rw-r--r--modules/tinyexr/image_loader_tinyexr.cpp6
-rw-r--r--modules/tinyexr/register_types.cpp4
-rw-r--r--modules/upnp/SCsub6
-rw-r--r--modules/upnp/config.py5
-rw-r--r--modules/upnp/upnp.cpp29
-rw-r--r--modules/upnp/upnp_device.cpp30
-rw-r--r--modules/vhacd/SCsub6
-rw-r--r--modules/vhacd/config.py2
-rw-r--r--modules/vhacd/register_types.cpp2
-rw-r--r--modules/visual_script/SCsub4
-rw-r--r--modules/visual_script/config.py3
-rw-r--r--modules/visual_script/register_types.cpp4
-rw-r--r--modules/visual_script/visual_script.cpp62
-rw-r--r--modules/visual_script/visual_script.h6
-rw-r--r--modules/visual_script/visual_script_builtin_funcs.cpp10
-rw-r--r--modules/visual_script/visual_script_editor.cpp224
-rw-r--r--modules/visual_script/visual_script_editor.h4
-rw-r--r--modules/visual_script/visual_script_expression.cpp66
-rw-r--r--modules/visual_script/visual_script_expression.h2
-rw-r--r--modules/visual_script/visual_script_flow_control.cpp2
-rw-r--r--modules/visual_script/visual_script_func_nodes.cpp56
-rw-r--r--modules/visual_script/visual_script_nodes.cpp13
-rw-r--r--modules/visual_script/visual_script_property_selector.cpp104
-rw-r--r--modules/visual_script/visual_script_property_selector.h1
-rw-r--r--modules/visual_script/visual_script_yield_nodes.cpp18
-rw-r--r--modules/vorbis/SCsub18
-rw-r--r--modules/vorbis/config.py1
-rw-r--r--modules/webm/SCsub12
-rw-r--r--modules/webm/config.py5
-rw-r--r--modules/webm/libvpx/SCsub175
-rw-r--r--modules/webm/video_stream_webm.cpp36
-rw-r--r--modules/webm/video_stream_webm.h2
-rw-r--r--modules/webp/SCsub6
-rw-r--r--modules/webp/config.py1
-rw-r--r--modules/webp/image_loader_webp.cpp10
-rw-r--r--modules/webp/register_types.cpp2
-rw-r--r--modules/webrtc/SCsub8
-rw-r--r--modules/webrtc/config.py5
-rw-r--r--modules/webrtc/webrtc_data_channel_gdnative.cpp36
-rw-r--r--modules/webrtc/webrtc_data_channel_js.cpp4
-rw-r--r--modules/webrtc/webrtc_multiplayer.cpp3
-rw-r--r--modules/webrtc/webrtc_peer_connection.cpp4
-rw-r--r--modules/webrtc/webrtc_peer_connection_gdnative.cpp24
-rw-r--r--modules/webrtc/webrtc_peer_connection_js.cpp2
-rw-r--r--modules/websocket/SCsub6
-rw-r--r--modules/websocket/config.py5
-rw-r--r--modules/websocket/emws_server.cpp2
-rw-r--r--modules/websocket/packet_buffer.h4
-rw-r--r--modules/websocket/websocket_macros.h4
-rw-r--r--modules/websocket/websocket_multiplayer_peer.cpp10
-rw-r--r--modules/websocket/wsl_client.cpp4
-rw-r--r--modules/websocket/wsl_peer.cpp20
-rw-r--r--modules/websocket/wsl_peer.h6
-rw-r--r--modules/websocket/wsl_server.cpp2
-rw-r--r--modules/xatlas_unwrap/SCsub6
-rw-r--r--modules/xatlas_unwrap/config.py3
-rw-r--r--modules/xatlas_unwrap/register_types.cpp142
383 files changed, 7247 insertions, 6161 deletions
diff --git a/modules/SCsub b/modules/SCsub
index 5b39b18334..fb46c5f877 100644
--- a/modules/SCsub
+++ b/modules/SCsub
@@ -1,16 +1,17 @@
#!/usr/bin/env python
-Import('env')
+Import("env")
import modules_builders
env_modules = env.Clone()
-Export('env_modules')
+Export("env_modules")
# Header with MODULE_*_ENABLED defines.
env.CommandNoCache("modules_enabled.gen.h", Value(env.module_list), modules_builders.generate_modules_enabled)
+vs_sources = []
# libmodule_<name>.a for each active module.
for module in env.module_list:
env.modules_sources = []
@@ -23,6 +24,8 @@ for module in env.module_list:
lib = env_modules.add_library("module_%s" % module, env.modules_sources)
env.Prepend(LIBS=[lib])
+ if env["vsproj"]:
+ vs_sources += env.modules_sources
# libmodules.a with only register_module_types.
# Must be last so that all libmodule_<name>.a libraries are on the right side
@@ -31,3 +34,5 @@ env.modules_sources = []
env_modules.add_source_files(env.modules_sources, "register_module_types.gen.cpp")
lib = env_modules.add_library("modules", env.modules_sources)
env.Prepend(LIBS=[lib])
+if env["vsproj"]:
+ env.modules_sources += vs_sources
diff --git a/modules/arkit/SCsub b/modules/arkit/SCsub
index c05595ea2a..61c0a8248c 100644
--- a/modules/arkit/SCsub
+++ b/modules/arkit/SCsub
@@ -1,7 +1,7 @@
#!/usr/bin/env python
-Import('env')
-Import('env_modules')
+Import("env")
+Import("env_modules")
env_arkit = env_modules.Clone()
@@ -9,4 +9,4 @@ env_arkit = env_modules.Clone()
modules_sources = []
env_arkit.add_source_files(modules_sources, "*.cpp")
env_arkit.add_source_files(modules_sources, "*.mm")
-mod_lib = env_modules.add_library('#bin/libgodot_arkit_module' + env['LIBSUFFIX'], modules_sources)
+mod_lib = env_modules.add_library("#bin/libgodot_arkit_module" + env["LIBSUFFIX"], modules_sources)
diff --git a/modules/arkit/arkit_interface.h b/modules/arkit/arkit_interface.h
index 4f8f726816..1044f3cf6f 100644
--- a/modules/arkit/arkit_interface.h
+++ b/modules/arkit/arkit_interface.h
@@ -31,9 +31,9 @@
#ifndef ARKIT_INTERFACE_H
#define ARKIT_INTERFACE_H
-#include "servers/arvr/arvr_interface.h"
-#include "servers/arvr/arvr_positional_tracker.h"
#include "servers/camera/camera_feed.h"
+#include "servers/xr/xr_interface.h"
+#include "servers/xr/xr_positional_tracker.h"
/**
@author Bastiaan Olij <mux213@gmail.com>
@@ -44,8 +44,8 @@
// forward declaration for some needed objects
class ARKitShader;
-class ARKitInterface : public ARVRInterface {
- GDCLASS(ARKitInterface, ARVRInterface);
+class ARKitInterface : public XRInterface {
+ GDCLASS(ARKitInterface, XRInterface);
private:
bool initialized;
@@ -65,7 +65,7 @@ private:
Vector<uint8_t> img_data[2];
struct anchor_map {
- ARVRPositionalTracker *tracker;
+ XRPositionalTracker *tracker;
unsigned char uuid[16];
};
@@ -73,7 +73,7 @@ private:
unsigned int num_anchors;
unsigned int max_anchors;
anchor_map *anchors;
- ARVRPositionalTracker *get_anchor_for_uuid(const unsigned char *p_uuid);
+ XRPositionalTracker *get_anchor_for_uuid(const unsigned char *p_uuid);
void remove_anchor_for_uuid(const unsigned char *p_uuid);
void remove_all_anchors();
@@ -108,9 +108,9 @@ public:
virtual Size2 get_render_targetsize();
virtual bool is_stereo();
- virtual Transform get_transform_for_eye(ARVRInterface::Eyes p_eye, const Transform &p_cam_transform);
- virtual CameraMatrix get_projection_for_eye(ARVRInterface::Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far);
- virtual void commit_for_eye(ARVRInterface::Eyes p_eye, RID p_render_target, const Rect2 &p_screen_rect);
+ virtual Transform get_transform_for_eye(XRInterface::Eyes p_eye, const Transform &p_cam_transform);
+ virtual CameraMatrix get_projection_for_eye(XRInterface::Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far);
+ virtual void commit_for_eye(XRInterface::Eyes p_eye, RID p_render_target, const Rect2 &p_screen_rect);
virtual void process();
diff --git a/modules/arkit/arkit_interface.mm b/modules/arkit/arkit_interface.mm
index 39447e8dab..7de824815a 100644
--- a/modules/arkit/arkit_interface.mm
+++ b/modules/arkit/arkit_interface.mm
@@ -28,10 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "core/os/input.h"
+#include "core/input/input.h"
#include "core/os/os.h"
#include "scene/resources/surface_tool.h"
-#include "servers/visual/visual_server_globals.h"
+#include "servers/rendering/rendering_server_globals.h"
#import <ARKit/ARKit.h>
#import <UIKit/UIKit.h>
@@ -158,7 +158,7 @@ StringName ARKitInterface::get_name() const {
}
int ARKitInterface::get_capabilities() const {
- return ARKitInterface::ARVR_MONO + ARKitInterface::ARVR_AR;
+ return ARKitInterface::XR_MONO + ARKitInterface::XR_AR;
}
Array ARKitInterface::raycast(Vector2 p_screen_coord) {
@@ -218,8 +218,8 @@ bool ARKitInterface::is_initialized() const {
}
bool ARKitInterface::initialize() {
- ARVRServer *arvr_server = ARVRServer::get_singleton();
- ERR_FAIL_NULL_V(arvr_server, false);
+ XRServer *xr_server = XRServer::get_singleton();
+ ERR_FAIL_NULL_V(xr_server, false);
if (!initialized) {
print_line("initializing ARKit");
@@ -244,7 +244,7 @@ bool ARKitInterface::initialize() {
transform = Transform();
// make this our primary interface
- arvr_server->set_primary_interface(this);
+ xr_server->set_primary_interface(this);
// make sure we have our feed setup
if (feed.is_null()) {
@@ -270,10 +270,10 @@ bool ARKitInterface::initialize() {
void ARKitInterface::uninitialize() {
if (initialized) {
- ARVRServer *arvr_server = ARVRServer::get_singleton();
- if (arvr_server != NULL) {
+ XRServer *xr_server = XRServer::get_singleton();
+ if (xr_server != NULL) {
// no longer our primary interface
- arvr_server->clear_primary_interface_if(this);
+ xr_server->clear_primary_interface_if(this);
}
if (feed.is_valid()) {
@@ -303,22 +303,22 @@ Size2 ARKitInterface::get_render_targetsize() {
return target_size;
}
-Transform ARKitInterface::get_transform_for_eye(ARVRInterface::Eyes p_eye, const Transform &p_cam_transform) {
+Transform ARKitInterface::get_transform_for_eye(XRInterface::Eyes p_eye, const Transform &p_cam_transform) {
_THREAD_SAFE_METHOD_
Transform transform_for_eye;
- ARVRServer *arvr_server = ARVRServer::get_singleton();
- ERR_FAIL_NULL_V(arvr_server, transform_for_eye);
+ XRServer *xr_server = XRServer::get_singleton();
+ ERR_FAIL_NULL_V(xr_server, transform_for_eye);
if (initialized) {
- float world_scale = arvr_server->get_world_scale();
+ float world_scale = xr_server->get_world_scale();
// just scale our origin point of our transform, note that we really shouldn't be using world_scale in ARKit but....
transform_for_eye = transform;
transform_for_eye.origin *= world_scale;
- transform_for_eye = p_cam_transform * arvr_server->get_reference_frame() * transform_for_eye;
+ transform_for_eye = p_cam_transform * xr_server->get_reference_frame() * transform_for_eye;
} else {
// huh? well just return what we got....
transform_for_eye = p_cam_transform;
@@ -327,7 +327,7 @@ Transform ARKitInterface::get_transform_for_eye(ARVRInterface::Eyes p_eye, const
return transform_for_eye;
}
-CameraMatrix ARKitInterface::get_projection_for_eye(ARVRInterface::Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far) {
+CameraMatrix ARKitInterface::get_projection_for_eye(XRInterface::Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far) {
// Remember our near and far, it will be used in process when we obtain our projection from our ARKit session.
z_near = p_z_near;
z_far = p_z_far;
@@ -335,7 +335,7 @@ CameraMatrix ARKitInterface::get_projection_for_eye(ARVRInterface::Eyes p_eye, r
return projection;
}
-void ARKitInterface::commit_for_eye(ARVRInterface::Eyes p_eye, RID p_render_target, const Rect2 &p_screen_rect) {
+void ARKitInterface::commit_for_eye(XRInterface::Eyes p_eye, RID p_render_target, const Rect2 &p_screen_rect) {
_THREAD_SAFE_METHOD_
// We must have a valid render target
@@ -356,7 +356,7 @@ void ARKitInterface::commit_for_eye(ARVRInterface::Eyes p_eye, RID p_render_targ
VSG::rasterizer->blit_render_target_to_screen(p_render_target, screen_rect, 0);
}
-ARVRPositionalTracker *ARKitInterface::get_anchor_for_uuid(const unsigned char *p_uuid) {
+XRPositionalTracker *ARKitInterface::get_anchor_for_uuid(const unsigned char *p_uuid) {
if (anchors == NULL) {
num_anchors = 0;
max_anchors = 10;
@@ -377,8 +377,8 @@ ARVRPositionalTracker *ARKitInterface::get_anchor_for_uuid(const unsigned char *
ERR_FAIL_NULL_V(anchors, NULL);
}
- ARVRPositionalTracker *new_tracker = memnew(ARVRPositionalTracker);
- new_tracker->set_type(ARVRServer::TRACKER_ANCHOR);
+ XRPositionalTracker *new_tracker = memnew(XRPositionalTracker);
+ new_tracker->set_type(XRServer::TRACKER_ANCHOR);
char tracker_name[256];
sprintf(tracker_name, "Anchor %02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x", p_uuid[0], p_uuid[1], p_uuid[2], p_uuid[3], p_uuid[4], p_uuid[5], p_uuid[6], p_uuid[7], p_uuid[8], p_uuid[9], p_uuid[10], p_uuid[11], p_uuid[12], p_uuid[13], p_uuid[14], p_uuid[15]);
@@ -388,7 +388,7 @@ ARVRPositionalTracker *ARKitInterface::get_anchor_for_uuid(const unsigned char *
new_tracker->set_name(name);
// add our tracker
- ARVRServer::get_singleton()->add_tracker(new_tracker);
+ XRServer::get_singleton()->add_tracker(new_tracker);
anchors[num_anchors].tracker = new_tracker;
memcpy(anchors[num_anchors].uuid, p_uuid, 16);
num_anchors++;
@@ -401,7 +401,7 @@ void ARKitInterface::remove_anchor_for_uuid(const unsigned char *p_uuid) {
for (unsigned int i = 0; i < num_anchors; i++) {
if (memcmp(anchors[i].uuid, p_uuid, 16) == 0) {
// remove our tracker
- ARVRServer::get_singleton()->remove_tracker(anchors[i].tracker);
+ XRServer::get_singleton()->remove_tracker(anchors[i].tracker);
memdelete(anchors[i].tracker);
// bring remaining forward
@@ -421,7 +421,7 @@ void ARKitInterface::remove_all_anchors() {
if (anchors != NULL) {
for (unsigned int i = 0; i < num_anchors; i++) {
// remove our tracker
- ARVRServer::get_singleton()->remove_tracker(anchors[i].tracker);
+ XRServer::get_singleton()->remove_tracker(anchors[i].tracker);
memdelete(anchors[i].tracker);
};
@@ -582,16 +582,16 @@ void ARKitInterface::process() {
// strangely enough we have to states, rolling them up into one
if (camera.trackingState == ARTrackingStateNotAvailable) {
// no tracking, would be good if we black out the screen or something...
- tracking_state = ARVRInterface::ARVR_NOT_TRACKING;
+ tracking_state = XRInterface::XR_NOT_TRACKING;
} else {
if (camera.trackingState == ARTrackingStateNormal) {
- tracking_state = ARVRInterface::ARVR_NORMAL_TRACKING;
+ tracking_state = XRInterface::XR_NORMAL_TRACKING;
} else if (camera.trackingStateReason == ARTrackingStateReasonExcessiveMotion) {
- tracking_state = ARVRInterface::ARVR_EXCESSIVE_MOTION;
+ tracking_state = XRInterface::XR_EXCESSIVE_MOTION;
} else if (camera.trackingStateReason == ARTrackingStateReasonInsufficientFeatures) {
- tracking_state = ARVRInterface::ARVR_INSUFFICIENT_FEATURES;
+ tracking_state = XRInterface::XR_INSUFFICIENT_FEATURES;
} else {
- tracking_state = ARVRInterface::ARVR_UNKNOWN_TRACKING;
+ tracking_state = XRInterface::XR_UNKNOWN_TRACKING;
}
// copy our current frame transform
@@ -665,7 +665,7 @@ void ARKitInterface::_add_or_update_anchor(void *p_anchor) {
unsigned char uuid[16];
[anchor.identifier getUUIDBytes:uuid];
- ARVRPositionalTracker *tracker = get_anchor_for_uuid(uuid);
+ XRPositionalTracker *tracker = get_anchor_for_uuid(uuid);
if (tracker != NULL) {
// lets update our mesh! (using Arjens code as is for now)
// we should also probably limit how often we do this...
@@ -695,7 +695,7 @@ void ARKitInterface::_add_or_update_anchor(void *p_anchor) {
}
// Note, this also contains a scale factor which gives us an idea of the size of the anchor
- // We may extract that in our ARVRAnchor class
+ // We may extract that in our XRAnchor class
Basis b;
matrix_float4x4 m44 = anchor.transform;
b.elements[0].x = m44.columns[0][0];
diff --git a/modules/arkit/config.py b/modules/arkit/config.py
index 96e41826c5..e68603fc93 100644
--- a/modules/arkit/config.py
+++ b/modules/arkit/config.py
@@ -1,5 +1,6 @@
def can_build(env, platform):
- return platform == 'iphone'
+ return platform == "iphone"
+
def configure(env):
pass
diff --git a/modules/arkit/register_types.cpp b/modules/arkit/register_types.cpp
index c78b35529b..91069ab364 100644
--- a/modules/arkit/register_types.cpp
+++ b/modules/arkit/register_types.cpp
@@ -37,7 +37,7 @@ void register_arkit_types() {
Ref<ARKitInterface> arkit_interface;
arkit_interface.instance();
- ARVRServer::get_singleton()->add_interface(arkit_interface);
+ XRServer::get_singleton()->add_interface(arkit_interface);
}
void unregister_arkit_types() {
diff --git a/modules/assimp/SCsub b/modules/assimp/SCsub
index 90cdd7f5fc..f1d0c742b4 100644
--- a/modules/assimp/SCsub
+++ b/modules/assimp/SCsub
@@ -1,7 +1,7 @@
#!/usr/bin/env python
-Import('env')
-Import('env_modules')
+Import("env")
+Import("env_modules")
env_assimp = env_modules.Clone()
@@ -10,85 +10,85 @@ env_assimp = env_modules.Clone()
if True: # env['builtin_assimp']:
thirdparty_dir = "#thirdparty/assimp"
- env_assimp.Prepend(CPPPATH=['#thirdparty/assimp'])
- env_assimp.Prepend(CPPPATH=['#thirdparty/assimp/code'])
- env_assimp.Prepend(CPPPATH=['#thirdparty/assimp/include'])
+ env_assimp.Prepend(CPPPATH=["#thirdparty/assimp"])
+ env_assimp.Prepend(CPPPATH=["#thirdparty/assimp/code"])
+ env_assimp.Prepend(CPPPATH=["#thirdparty/assimp/include"])
- #env_assimp.Append(CPPDEFINES=['ASSIMP_DOUBLE_PRECISION']) # TODO default to what godot is compiled with for future double support
- env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_SINGLETHREADED'])
- env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_BOOST_WORKAROUND'])
- env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_OWN_ZLIB'])
- env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_EXPORT'])
+ # env_assimp.Append(CPPDEFINES=['ASSIMP_DOUBLE_PRECISION']) # TODO default to what godot is compiled with for future double support
+ env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_SINGLETHREADED"])
+ env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_BOOST_WORKAROUND"])
+ env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_OWN_ZLIB"])
+ env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_EXPORT"])
# Importers we don't need
- env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_3D_IMPORTER'])
- env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_3DS_IMPORTER'])
- env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_3MF_IMPORTER'])
- env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_AC_IMPORTER'])
- env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_AMF_IMPORTER'])
- env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_ASE_IMPORTER'])
- env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_ASSBIN_IMPORTER'])
- env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_B3D_IMPORTER'])
- env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_BLEND_IMPORTER'])
- env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_BVH_IMPORTER'])
- env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_C4D_IMPORTER'])
- env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_COB_IMPORTER'])
- env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_COLLADA_IMPORTER'])
- env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_CSM_IMPORTER'])
- env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_DXF_IMPORTER'])
- env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_GLTF2_IMPORTER'])
- env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_GLTF_IMPORTER'])
- env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_HMP_IMPORTER'])
- env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_IFC_IMPORTER'])
- env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_IRR_IMPORTER'])
- env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_IRRMESH_IMPORTER'])
- env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_LWO_IMPORTER'])
- env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_LWS_IMPORTER'])
- env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_M3D_IMPORTER'])
- env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_MD2_IMPORTER'])
- env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_MD3_IMPORTER'])
- env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_MD5_IMPORTER'])
- env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_MD5_IMPORTER'])
- env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_MDC_IMPORTER'])
- env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_MDL_IMPORTER'])
- env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_MMD_IMPORTER'])
- env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_MS3D_IMPORTER'])
- env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_NDO_IMPORTER'])
- env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_NFF_IMPORTER'])
- env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_OBJ_IMPORTER'])
- env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_OFF_IMPORTER'])
- env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_OGRE_IMPORTER'])
- env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_OPENGEX_IMPORTER'])
- env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_PLY_IMPORTER'])
- env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_Q3BSP_IMPORTER'])
- env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_Q3D_IMPORTER'])
- env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_RAW_IMPORTER'])
- env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_SIB_IMPORTER'])
- env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_SMD_IMPORTER'])
- env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_STEP_IMPORTER'])
- env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_STL_IMPORTER'])
- env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_TERRAGEN_IMPORTER'])
- env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_X3D_IMPORTER'])
- env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_XGL_IMPORTER'])
- env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_X_IMPORTER'])
+ env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_3D_IMPORTER"])
+ env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_3DS_IMPORTER"])
+ env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_3MF_IMPORTER"])
+ env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_AC_IMPORTER"])
+ env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_AMF_IMPORTER"])
+ env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_ASE_IMPORTER"])
+ env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_ASSBIN_IMPORTER"])
+ env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_B3D_IMPORTER"])
+ env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_BLEND_IMPORTER"])
+ env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_BVH_IMPORTER"])
+ env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_C4D_IMPORTER"])
+ env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_COB_IMPORTER"])
+ env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_COLLADA_IMPORTER"])
+ env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_CSM_IMPORTER"])
+ env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_DXF_IMPORTER"])
+ env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_GLTF2_IMPORTER"])
+ env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_GLTF_IMPORTER"])
+ env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_HMP_IMPORTER"])
+ env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_IFC_IMPORTER"])
+ env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_IRR_IMPORTER"])
+ env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_IRRMESH_IMPORTER"])
+ env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_LWO_IMPORTER"])
+ env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_LWS_IMPORTER"])
+ env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_M3D_IMPORTER"])
+ env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_MD2_IMPORTER"])
+ env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_MD3_IMPORTER"])
+ env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_MD5_IMPORTER"])
+ env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_MD5_IMPORTER"])
+ env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_MDC_IMPORTER"])
+ env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_MDL_IMPORTER"])
+ env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_MMD_IMPORTER"])
+ env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_MS3D_IMPORTER"])
+ env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_NDO_IMPORTER"])
+ env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_NFF_IMPORTER"])
+ env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_OBJ_IMPORTER"])
+ env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_OFF_IMPORTER"])
+ env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_OGRE_IMPORTER"])
+ env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_OPENGEX_IMPORTER"])
+ env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_PLY_IMPORTER"])
+ env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_Q3BSP_IMPORTER"])
+ env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_Q3D_IMPORTER"])
+ env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_RAW_IMPORTER"])
+ env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_SIB_IMPORTER"])
+ env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_SMD_IMPORTER"])
+ env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_STEP_IMPORTER"])
+ env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_STL_IMPORTER"])
+ env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_TERRAGEN_IMPORTER"])
+ env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_X3D_IMPORTER"])
+ env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_XGL_IMPORTER"])
+ env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_X_IMPORTER"])
+
+ if env["platform"] == "windows":
+ env_assimp.Append(CPPDEFINES=["PLATFORM_WINDOWS"])
+ env_assimp.Append(CPPDEFINES=[("PLATFORM", "WINDOWS")])
+ elif env["platform"] == "linuxbsd":
+ env_assimp.Append(CPPDEFINES=["PLATFORM_LINUX"])
+ env_assimp.Append(CPPDEFINES=[("PLATFORM", "LINUX")])
+ elif env["platform"] == "osx":
+ env_assimp.Append(CPPDEFINES=["PLATFORM_DARWIN"])
+ env_assimp.Append(CPPDEFINES=[("PLATFORM", "DARWIN")])
- if(env['platform'] == 'windows'):
- env_assimp.Append(CPPDEFINES=['PLATFORM_WINDOWS'])
- env_assimp.Append(CPPDEFINES=[('PLATFORM', 'WINDOWS')])
- elif(env['platform'] == 'x11'):
- env_assimp.Append(CPPDEFINES=['PLATFORM_LINUX'])
- env_assimp.Append(CPPDEFINES=[('PLATFORM', 'LINUX')])
- elif(env['platform'] == 'osx'):
- env_assimp.Append(CPPDEFINES=['PLATFORM_DARWIN'])
- env_assimp.Append(CPPDEFINES=[('PLATFORM', 'DARWIN')])
-
env_thirdparty = env_assimp.Clone()
env_thirdparty.disable_warnings()
- env_thirdparty.add_source_files(env.modules_sources, Glob('#thirdparty/assimp/code/CApi/*.cpp'))
- env_thirdparty.add_source_files(env.modules_sources, Glob('#thirdparty/assimp/code/Common/*.cpp'))
- env_thirdparty.add_source_files(env.modules_sources, Glob('#thirdparty/assimp/code/PostProcessing/*.cpp'))
- env_thirdparty.add_source_files(env.modules_sources, Glob('#thirdparty/assimp/code/Material/*.cpp'))
- env_thirdparty.add_source_files(env.modules_sources, Glob('#thirdparty/assimp/code/FBX/*.cpp'))
+ env_thirdparty.add_source_files(env.modules_sources, Glob("#thirdparty/assimp/code/CApi/*.cpp"))
+ env_thirdparty.add_source_files(env.modules_sources, Glob("#thirdparty/assimp/code/Common/*.cpp"))
+ env_thirdparty.add_source_files(env.modules_sources, Glob("#thirdparty/assimp/code/PostProcessing/*.cpp"))
+ env_thirdparty.add_source_files(env.modules_sources, Glob("#thirdparty/assimp/code/Material/*.cpp"))
+ env_thirdparty.add_source_files(env.modules_sources, Glob("#thirdparty/assimp/code/FBX/*.cpp"))
# Godot's own source files
env_assimp.add_source_files(env.modules_sources, "*.cpp")
diff --git a/modules/assimp/config.py b/modules/assimp/config.py
index 098f1eafa9..53b8f2f2e3 100644
--- a/modules/assimp/config.py
+++ b/modules/assimp/config.py
@@ -1,5 +1,6 @@
def can_build(env, platform):
- return env['tools']
+ return env["tools"]
+
def configure(env):
pass
diff --git a/modules/assimp/editor_scene_importer_assimp.cpp b/modules/assimp/editor_scene_importer_assimp.cpp
index 682a7e33c8..cc74674eff 100644
--- a/modules/assimp/editor_scene_importer_assimp.cpp
+++ b/modules/assimp/editor_scene_importer_assimp.cpp
@@ -32,9 +32,9 @@
#include "core/io/image_loader.h"
#include "editor/import/resource_importer_scene.h"
#include "import_utils.h"
-#include "scene/3d/camera.h"
-#include "scene/3d/light.h"
-#include "scene/3d/mesh_instance.h"
+#include "scene/3d/camera_3d.h"
+#include "scene/3d/light_3d.h"
+#include "scene/3d/mesh_instance_3d.h"
#include "scene/main/node.h"
#include "scene/resources/material.h"
#include "scene/resources/surface_tool.h"
@@ -62,7 +62,7 @@ aiBone *get_bone_by_name(const aiScene *scene, aiString bone_name) {
}
}
- return NULL;
+ return nullptr;
}
void EditorSceneImporterAssimp::get_extensions(List<String> *r_extensions) const {
@@ -149,7 +149,7 @@ Node *EditorSceneImporterAssimp::import_scene(const String &p_path, uint32_t p_f
0;
aiScene *scene = (aiScene *)importer.ReadFile(s_path.c_str(), post_process_Steps);
- ERR_FAIL_COND_V_MSG(scene == NULL, NULL, String("Open Asset Import failed to open: ") + String(importer.GetErrorString()));
+ ERR_FAIL_COND_V_MSG(scene == nullptr, nullptr, String("Open Asset Import failed to open: ") + String(importer.GetErrorString()));
return _generate_scene(p_path, scene, p_flags, p_bake_fps, max_bone_weights);
}
@@ -284,7 +284,7 @@ T EditorSceneImporterAssimp::_interpolate_track(const Vector<float> &p_times, co
aiBone *EditorSceneImporterAssimp::get_bone_from_stack(ImportState &state, aiString name) {
List<aiBone *>::Element *iter;
- aiBone *bone = NULL;
+ aiBone *bone = nullptr;
for (iter = state.bone_stack.front(); iter; iter = iter->next()) {
bone = (aiBone *)iter->get();
@@ -294,32 +294,32 @@ aiBone *EditorSceneImporterAssimp::get_bone_from_stack(ImportState &state, aiStr
}
}
- return NULL;
+ return nullptr;
}
-Spatial *
+Node3D *
EditorSceneImporterAssimp::_generate_scene(const String &p_path, aiScene *scene, const uint32_t p_flags, int p_bake_fps,
const int32_t p_max_bone_weights) {
- ERR_FAIL_COND_V(scene == NULL, NULL);
+ ERR_FAIL_COND_V(scene == nullptr, nullptr);
ImportState state;
state.path = p_path;
state.assimp_scene = scene;
state.max_bone_weights = p_max_bone_weights;
- state.animation_player = NULL;
+ state.animation_player = nullptr;
// populate light map
for (unsigned int l = 0; l < scene->mNumLights; l++) {
aiLight *ai_light = scene->mLights[l];
- ERR_CONTINUE(ai_light == NULL);
+ ERR_CONTINUE(ai_light == nullptr);
state.light_cache[AssimpUtils::get_assimp_string(ai_light->mName)] = l;
}
// fill camera cache
for (unsigned int c = 0; c < scene->mNumCameras; c++) {
aiCamera *ai_camera = scene->mCameras[c];
- ERR_CONTINUE(ai_camera == NULL);
+ ERR_CONTINUE(ai_camera == nullptr);
state.camera_cache[AssimpUtils::get_assimp_string(ai_camera->mName)] = c;
}
@@ -333,7 +333,7 @@ EditorSceneImporterAssimp::_generate_scene(const String &p_path, aiScene *scene,
RegenerateBoneStack(state);
- Node *last_valid_parent = NULL;
+ Node *last_valid_parent = nullptr;
List<const aiNode *>::Element *iter;
for (iter = state.nodes.front(); iter; iter = iter->next()) {
@@ -343,7 +343,7 @@ EditorSceneImporterAssimp::_generate_scene(const String &p_path, aiScene *scene,
String node_name = AssimpUtils::get_assimp_string(element_assimp_node->mName);
//print_verbose("node: " + node_name);
- Spatial *spatial = NULL;
+ Node3D *spatial = nullptr;
Transform transform = AssimpUtils::assimp_matrix_transform(element_assimp_node->mTransformation);
// retrieve this node bone
@@ -356,18 +356,18 @@ EditorSceneImporterAssimp::_generate_scene(const String &p_path, aiScene *scene,
} else if (state.armature_nodes.find(element_assimp_node)) {
// create skeleton
print_verbose("Making skeleton: " + node_name);
- Skeleton *skeleton = memnew(Skeleton);
+ Skeleton3D *skeleton = memnew(Skeleton3D);
spatial = skeleton;
if (!state.armature_skeletons.has(element_assimp_node)) {
state.armature_skeletons.insert(element_assimp_node, skeleton);
}
- } else if (bone != NULL) {
+ } else if (bone != nullptr) {
continue;
} else {
- spatial = memnew(Spatial);
+ spatial = memnew(Node3D);
}
- ERR_CONTINUE_MSG(spatial == NULL, "FBX Import - are we out of ram?");
+ ERR_CONTINUE_MSG(spatial == nullptr, "FBX Import - are we out of ram?");
// we on purpose set the transform and name after creating the node.
spatial->set_name(node_name);
@@ -381,13 +381,13 @@ EditorSceneImporterAssimp::_generate_scene(const String &p_path, aiScene *scene,
// flat node map parent lookup tool
state.flat_node_map.insert(element_assimp_node, spatial);
- Map<const aiNode *, Spatial *>::Element *parent_lookup = state.flat_node_map.find(parent_assimp_node);
+ Map<const aiNode *, Node3D *>::Element *parent_lookup = state.flat_node_map.find(parent_assimp_node);
// note: this always fails on the root node :) keep that in mind this is by design
if (parent_lookup) {
- Spatial *parent_node = parent_lookup->value();
+ Node3D *parent_node = parent_lookup->value();
- ERR_FAIL_COND_V_MSG(parent_node == NULL, state.root,
+ ERR_FAIL_COND_V_MSG(parent_node == nullptr, state.root,
"Parent node invalid even though lookup successful, out of ram?");
if (spatial != state.root) {
@@ -434,8 +434,8 @@ EditorSceneImporterAssimp::_generate_scene(const String &p_path, aiScene *scene,
aiNode *parent_node = bone_node->mParent;
String bone_name = AssimpUtils::get_anim_string_from_assimp(bone->mName);
- ERR_CONTINUE_MSG(armature_for_bone == NULL, "Armature for bone invalid: " + bone_name);
- Skeleton *skeleton = state.armature_skeletons[armature_for_bone];
+ ERR_CONTINUE_MSG(armature_for_bone == nullptr, "Armature for bone invalid: " + bone_name);
+ Skeleton3D *skeleton = state.armature_skeletons[armature_for_bone];
state.skeleton_bone_map[bone] = skeleton;
@@ -454,7 +454,7 @@ EditorSceneImporterAssimp::_generate_scene(const String &p_path, aiScene *scene,
skeleton->set_bone_rest(boneIdx, pform);
skeleton->set_bone_pose(boneIdx, pform);
- if (parent_node != NULL) {
+ if (parent_node != nullptr) {
int parent_bone_id = skeleton->find_bone(AssimpUtils::get_anim_string_from_assimp(parent_node->mName));
int current_bone_id = boneIdx;
skeleton->set_bone_parent(current_bone_id, parent_bone_id);
@@ -464,14 +464,14 @@ EditorSceneImporterAssimp::_generate_scene(const String &p_path, aiScene *scene,
print_verbose("generating mesh phase from skeletal mesh");
- List<Spatial *> cleanup_template_nodes;
+ List<Node3D *> cleanup_template_nodes;
- for (Map<const aiNode *, Spatial *>::Element *key_value_pair = state.flat_node_map.front(); key_value_pair; key_value_pair = key_value_pair->next()) {
+ for (Map<const aiNode *, Node3D *>::Element *key_value_pair = state.flat_node_map.front(); key_value_pair; key_value_pair = key_value_pair->next()) {
const aiNode *assimp_node = key_value_pair->key();
- Spatial *mesh_template = key_value_pair->value();
+ Node3D *mesh_template = key_value_pair->value();
- ERR_CONTINUE(assimp_node == NULL);
- ERR_CONTINUE(mesh_template == NULL);
+ ERR_CONTINUE(assimp_node == nullptr);
+ ERR_CONTINUE(mesh_template == nullptr);
Node *parent_node = mesh_template->get_parent();
@@ -479,7 +479,7 @@ EditorSceneImporterAssimp::_generate_scene(const String &p_path, aiScene *scene,
continue;
}
- if (parent_node == NULL) {
+ if (parent_node == nullptr) {
print_error("Found invalid parent node!");
continue; // root node
}
@@ -488,7 +488,7 @@ EditorSceneImporterAssimp::_generate_scene(const String &p_path, aiScene *scene,
Transform node_transform = AssimpUtils::assimp_matrix_transform(assimp_node->mTransformation);
if (assimp_node->mNumMeshes > 0) {
- MeshInstance *mesh = create_mesh(state, assimp_node, node_name, parent_node, node_transform);
+ MeshInstance3D *mesh = create_mesh(state, assimp_node, node_name, parent_node, node_transform);
if (mesh) {
parent_node->remove_child(mesh_template);
@@ -522,7 +522,7 @@ EditorSceneImporterAssimp::_generate_scene(const String &p_path, aiScene *scene,
}
}
- for (List<Spatial *>::Element *element = cleanup_template_nodes.front(); element; element = element->next()) {
+ for (List<Node3D *>::Element *element = cleanup_template_nodes.front(); element; element = element->next()) {
if (element->get()) {
memdelete(element->get());
}
@@ -559,7 +559,7 @@ EditorSceneImporterAssimp::_generate_scene(const String &p_path, aiScene *scene,
void EditorSceneImporterAssimp::_insert_animation_track(ImportState &scene, const aiAnimation *assimp_anim, int track_id,
int anim_fps, Ref<Animation> animation, float ticks_per_second,
- Skeleton *skeleton, const NodePath &node_path,
+ Skeleton3D *skeleton, const NodePath &node_path,
const String &node_name, aiBone *track_bone) {
const aiNodeAnim *assimp_track = assimp_anim->mChannels[track_id];
//make transform track
@@ -652,16 +652,16 @@ void EditorSceneImporterAssimp::_insert_animation_track(ImportState &scene, cons
// I really do not like this but need to figure out a better way of removing it later.
Node *EditorSceneImporterAssimp::get_node_by_name(ImportState &state, String name) {
- for (Map<const aiNode *, Spatial *>::Element *key_value_pair = state.flat_node_map.front(); key_value_pair; key_value_pair = key_value_pair->next()) {
+ for (Map<const aiNode *, Node3D *>::Element *key_value_pair = state.flat_node_map.front(); key_value_pair; key_value_pair = key_value_pair->next()) {
const aiNode *assimp_node = key_value_pair->key();
- Spatial *node = key_value_pair->value();
+ Node3D *node = key_value_pair->value();
String node_name = AssimpUtils::get_assimp_string(assimp_node->mName);
if (name == node_name && node) {
return node;
}
}
- return NULL;
+ return nullptr;
}
/* Bone stack is a fifo handler for multiple armatures since armatures aren't a thing in assimp (yet) */
@@ -691,7 +691,7 @@ void EditorSceneImporterAssimp::RegenerateBoneStack(ImportState &state, aiMesh *
// iterate over all the bones on the mesh for this node only!
for (unsigned int boneIndex = 0; boneIndex < mesh->mNumBones; boneIndex++) {
aiBone *bone = mesh->mBones[boneIndex];
- if (state.bone_stack.find(bone) == NULL) {
+ if (state.bone_stack.find(bone) == nullptr) {
state.bone_stack.push_back(bone);
}
}
@@ -711,7 +711,7 @@ void EditorSceneImporterAssimp::_import_animation(ImportState &state, int p_anim
print_verbose("import animation: " + name);
float ticks_per_second = anim->mTicksPerSecond;
- if (state.assimp_scene->mMetaData != NULL && Math::is_equal_approx(ticks_per_second, 0.0f)) {
+ if (state.assimp_scene->mMetaData != nullptr && Math::is_equal_approx(ticks_per_second, 0.0f)) {
int32_t time_mode = 0;
state.assimp_scene->mMetaData->Get("TimeMode", time_mode);
ticks_per_second = AssimpUtils::get_fbx_fps(time_mode, state.assimp_scene);
@@ -747,9 +747,9 @@ void EditorSceneImporterAssimp::_import_animation(ImportState &state, int p_anim
continue; //do not bother
}
- Skeleton *skeleton = NULL;
+ Skeleton3D *skeleton = nullptr;
NodePath node_path;
- aiBone *bone = NULL;
+ aiBone *bone = nullptr;
// Import skeleton bone animation for this track
// Any bone will do, no point in processing more than just what is in the skeleton
@@ -805,8 +805,8 @@ void EditorSceneImporterAssimp::_import_animation(ImportState &state, int p_anim
Node *item = get_node_by_name(state, mesh_name);
ERR_CONTINUE_MSG(!item, "failed to look up node by name");
- const MeshInstance *mesh_instance = Object::cast_to<MeshInstance>(item);
- ERR_CONTINUE(mesh_instance == NULL);
+ const MeshInstance3D *mesh_instance = Object::cast_to<MeshInstance3D>(item);
+ ERR_CONTINUE(mesh_instance == nullptr);
String base_path = state.root->get_path_to(mesh_instance);
@@ -842,7 +842,7 @@ void EditorSceneImporterAssimp::_import_animation(ImportState &state, int p_anim
Ref<Mesh>
EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &state, const Vector<int> &p_surface_indices,
const aiNode *assimp_node, Ref<Skin> &skin,
- Skeleton *&skeleton_assigned) {
+ Skeleton3D *&skeleton_assigned) {
Ref<ArrayMesh> mesh;
mesh.instance();
@@ -940,7 +940,7 @@ EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &stat
}
// Work out normal calculations? - this needs work it doesn't work properly on huestos
- if (ai_mesh->mNormals != NULL) {
+ if (ai_mesh->mNormals != nullptr) {
const aiVector3D normals = ai_mesh->mNormals[j];
const Vector3 godot_normal = Vector3(normals.x, normals.y, normals.z);
st->add_normal(godot_normal);
@@ -1208,9 +1208,9 @@ EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &stat
}
Array array_copy;
- array_copy.resize(VisualServer::ARRAY_MAX);
+ array_copy.resize(RenderingServer::ARRAY_MAX);
- for (int l = 0; l < VisualServer::ARRAY_MAX; l++) {
+ for (int l = 0; l < RenderingServer::ARRAY_MAX; l++) {
array_copy[l] = array_mesh[l].duplicate(true);
}
@@ -1224,13 +1224,13 @@ EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &stat
Vector3 position = Vector3(ai_pos.x, ai_pos.y, ai_pos.z);
vertices.ptrw()[l] = position;
}
- PackedVector3Array new_vertices = array_copy[VisualServer::ARRAY_VERTEX].duplicate(true);
+ PackedVector3Array new_vertices = array_copy[RenderingServer::ARRAY_VERTEX].duplicate(true);
ERR_CONTINUE(vertices.size() != new_vertices.size());
for (int32_t l = 0; l < new_vertices.size(); l++) {
Vector3 *w = new_vertices.ptrw();
w[l] = vertices[l];
}
- array_copy[VisualServer::ARRAY_VERTEX] = new_vertices;
+ array_copy[RenderingServer::ARRAY_VERTEX] = new_vertices;
}
int32_t color_set = 0;
@@ -1242,13 +1242,13 @@ EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &stat
Color color = Color(ai_color.r, ai_color.g, ai_color.b, ai_color.a);
colors.ptrw()[l] = color;
}
- PackedColorArray new_colors = array_copy[VisualServer::ARRAY_COLOR].duplicate(true);
+ PackedColorArray new_colors = array_copy[RenderingServer::ARRAY_COLOR].duplicate(true);
ERR_CONTINUE(colors.size() != new_colors.size());
for (int32_t l = 0; l < colors.size(); l++) {
Color *w = new_colors.ptrw();
w[l] = colors[l];
}
- array_copy[VisualServer::ARRAY_COLOR] = new_colors;
+ array_copy[RenderingServer::ARRAY_COLOR] = new_colors;
}
if (ai_mesh->mAnimMeshes[j]->HasNormals()) {
@@ -1259,13 +1259,13 @@ EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &stat
Vector3 normal = Vector3(ai_normal.x, ai_normal.y, ai_normal.z);
normals.ptrw()[l] = normal;
}
- PackedVector3Array new_normals = array_copy[VisualServer::ARRAY_NORMAL].duplicate(true);
+ PackedVector3Array new_normals = array_copy[RenderingServer::ARRAY_NORMAL].duplicate(true);
ERR_CONTINUE(normals.size() != new_normals.size());
for (int l = 0; l < normals.size(); l++) {
Vector3 *w = new_normals.ptrw();
w[l] = normals[l];
}
- array_copy[VisualServer::ARRAY_NORMAL] = new_normals;
+ array_copy[RenderingServer::ARRAY_NORMAL] = new_normals;
}
if (ai_mesh->mAnimMeshes[j]->HasTangentsAndBitangents()) {
@@ -1275,7 +1275,7 @@ EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &stat
for (size_t l = 0; l < num_vertices; l++) {
AssimpUtils::calc_tangent_from_mesh(ai_mesh, j, l, l, w);
}
- PackedFloat32Array new_tangents = array_copy[VisualServer::ARRAY_TANGENT].duplicate(true);
+ PackedFloat32Array new_tangents = array_copy[RenderingServer::ARRAY_TANGENT].duplicate(true);
ERR_CONTINUE(new_tangents.size() != tangents.size() * 4);
for (int32_t l = 0; l < tangents.size(); l++) {
new_tangents.ptrw()[l + 0] = tangents[l].r;
@@ -1283,7 +1283,7 @@ EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &stat
new_tangents.ptrw()[l + 2] = tangents[l].b;
new_tangents.ptrw()[l + 3] = tangents[l].a;
}
- array_copy[VisualServer::ARRAY_TANGENT] = new_tangents;
+ array_copy[RenderingServer::ARRAY_TANGENT] = new_tangents;
}
morphs[j] = array_copy;
@@ -1299,7 +1299,7 @@ EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &stat
/**
* Create a new mesh for the node supplied
*/
-MeshInstance *
+MeshInstance3D *
EditorSceneImporterAssimp::create_mesh(ImportState &state, const aiNode *assimp_node, const String &node_name, Node *active_node, Transform node_transform) {
/* MESH NODE */
Ref<Mesh> mesh;
@@ -1325,15 +1325,15 @@ EditorSceneImporterAssimp::create_mesh(ImportState &state, const aiNode *assimp_
mesh_key += itos(surface_indices[i]);
}
- Skeleton *skeleton = NULL;
- aiNode *armature = NULL;
+ Skeleton3D *skeleton = nullptr;
+ aiNode *armature = nullptr;
if (!state.mesh_cache.has(mesh_key)) {
mesh = _generate_mesh_from_surface_indices(state, surface_indices, assimp_node, skin, skeleton);
state.mesh_cache[mesh_key] = mesh;
}
- MeshInstance *mesh_node = memnew(MeshInstance);
+ MeshInstance3D *mesh_node = memnew(MeshInstance3D);
mesh = state.mesh_cache[mesh_key];
mesh_node->set_mesh(mesh);
@@ -1407,22 +1407,22 @@ EditorSceneImporterAssimp::create_mesh(ImportState &state, const aiNode *assimp_
* Create a light for the scene
* Automatically caches lights for lookup later
*/
-Spatial *EditorSceneImporterAssimp::create_light(
+Node3D *EditorSceneImporterAssimp::create_light(
ImportState &state,
const String &node_name,
Transform &look_at_transform) {
- Light *light = NULL;
+ Light3D *light = nullptr;
aiLight *assimp_light = state.assimp_scene->mLights[state.light_cache[node_name]];
- ERR_FAIL_COND_V(!assimp_light, NULL);
+ ERR_FAIL_COND_V(!assimp_light, nullptr);
if (assimp_light->mType == aiLightSource_DIRECTIONAL) {
- light = memnew(DirectionalLight);
+ light = memnew(DirectionalLight3D);
} else if (assimp_light->mType == aiLightSource_POINT) {
- light = memnew(OmniLight);
+ light = memnew(OmniLight3D);
} else if (assimp_light->mType == aiLightSource_SPOT) {
- light = memnew(SpotLight);
+ light = memnew(SpotLight3D);
}
- ERR_FAIL_COND_V(light == NULL, NULL);
+ ERR_FAIL_COND_V(light == nullptr, nullptr);
if (assimp_light->mType != aiLightSource_POINT) {
Vector3 pos = Vector3(
@@ -1453,15 +1453,15 @@ Spatial *EditorSceneImporterAssimp::create_light(
/**
* Create camera for the scene
*/
-Spatial *EditorSceneImporterAssimp::create_camera(
+Node3D *EditorSceneImporterAssimp::create_camera(
ImportState &state,
const String &node_name,
Transform &look_at_transform) {
aiCamera *camera = state.assimp_scene->mCameras[state.camera_cache[node_name]];
- ERR_FAIL_COND_V(!camera, NULL);
+ ERR_FAIL_COND_V(!camera, nullptr);
- Camera *camera_node = memnew(Camera);
- ERR_FAIL_COND_V(!camera_node, NULL);
+ Camera3D *camera_node = memnew(Camera3D);
+ ERR_FAIL_COND_V(!camera_node, nullptr);
float near = camera->mClipPlaneNear;
if (Math::is_equal_approx(near, 0.0f)) {
near = 0.1f;
@@ -1483,7 +1483,7 @@ void EditorSceneImporterAssimp::_generate_node(
ImportState &state,
const aiNode *assimp_node) {
- ERR_FAIL_COND(assimp_node == NULL);
+ ERR_FAIL_COND(assimp_node == nullptr);
state.nodes.push_back(assimp_node);
String parent_name = AssimpUtils::get_assimp_string(assimp_node->mParent->mName);
@@ -1498,7 +1498,7 @@ void EditorSceneImporterAssimp::_generate_node(
// is this an armature
// parent null
// and this is the first bone :)
- if (parent_bone == NULL && current_bone) {
+ if (parent_bone == nullptr && current_bone) {
state.armature_nodes.push_back(assimp_node->mParent);
print_verbose("found valid armature: " + parent_name);
}
diff --git a/modules/assimp/editor_scene_importer_assimp.h b/modules/assimp/editor_scene_importer_assimp.h
index 4cd50e7681..ab00a6c3aa 100644
--- a/modules/assimp/editor_scene_importer_assimp.h
+++ b/modules/assimp/editor_scene_importer_assimp.h
@@ -37,9 +37,9 @@
#include "core/vector.h"
#include "editor/import/resource_importer_scene.h"
#include "editor/project_settings_editor.h"
-#include "scene/3d/mesh_instance.h"
-#include "scene/3d/skeleton.h"
-#include "scene/3d/spatial.h"
+#include "scene/3d/mesh_instance_3d.h"
+#include "scene/3d/node_3d.h"
+#include "scene/3d/skeleton_3d.h"
#include "scene/animation/animation_player.h"
#include "scene/resources/animation.h"
#include "scene/resources/surface_tool.h"
@@ -90,29 +90,29 @@ private:
Ref<Mesh> _generate_mesh_from_surface_indices(ImportState &state, const Vector<int> &p_surface_indices,
const aiNode *assimp_node, Ref<Skin> &skin,
- Skeleton *&skeleton_assigned);
+ Skeleton3D *&skeleton_assigned);
// simple object creation functions
- Spatial *create_light(ImportState &state,
+ Node3D *create_light(ImportState &state,
const String &node_name,
Transform &look_at_transform);
- Spatial *create_camera(
+ Node3D *create_camera(
ImportState &state,
const String &node_name,
Transform &look_at_transform);
// non recursive - linear so must not use recursive arguments
- MeshInstance *create_mesh(ImportState &state, const aiNode *assimp_node, const String &node_name, Node *active_node, Transform node_transform);
+ MeshInstance3D *create_mesh(ImportState &state, const aiNode *assimp_node, const String &node_name, Node *active_node, Transform node_transform);
// recursive node generator
void _generate_node(ImportState &state, const aiNode *assimp_node);
void _insert_animation_track(ImportState &scene, const aiAnimation *assimp_anim, int track_id,
int anim_fps, Ref<Animation> animation, float ticks_per_second,
- Skeleton *skeleton, const NodePath &node_path,
+ Skeleton3D *skeleton, const NodePath &node_path,
const String &node_name, aiBone *track_bone);
void _import_animation(ImportState &state, int p_animation_index, int p_bake_fps);
Node *get_node_by_name(ImportState &state, String name);
aiBone *get_bone_from_stack(ImportState &state, aiString name);
- Spatial *_generate_scene(const String &p_path, aiScene *scene, const uint32_t p_flags, int p_bake_fps, const int32_t p_max_bone_weights);
+ Node3D *_generate_scene(const String &p_path, aiScene *scene, const uint32_t p_flags, int p_bake_fps, const int32_t p_max_bone_weights);
template <class T>
T _interpolate_track(const Vector<float> &p_times, const Vector<T> &p_values, float p_time, AssetImportAnimation::Interpolation p_interp);
@@ -138,7 +138,7 @@ public:
virtual void get_extensions(List<String> *r_extensions) const;
virtual uint32_t get_import_flags() const;
- virtual Node *import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps, Error *r_err = NULL);
+ virtual Node *import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps, Error *r_err = nullptr);
Ref<Image> load_image(ImportState &state, const aiScene *p_scene, String p_path);
static void RegenerateBoneStack(ImportState &state);
diff --git a/modules/assimp/import_state.h b/modules/assimp/import_state.h
index fbbbe23399..cda1a854f0 100644
--- a/modules/assimp/import_state.h
+++ b/modules/assimp/import_state.h
@@ -36,9 +36,9 @@
#include "core/vector.h"
#include "editor/import/resource_importer_scene.h"
#include "editor/project_settings_editor.h"
-#include "scene/3d/mesh_instance.h"
-#include "scene/3d/skeleton.h"
-#include "scene/3d/spatial.h"
+#include "scene/3d/mesh_instance_3d.h"
+#include "scene/3d/node_3d.h"
+#include "scene/3d/skeleton_3d.h"
#include "scene/animation/animation_player.h"
#include "scene/resources/animation.h"
#include "scene/resources/surface_tool.h"
@@ -57,7 +57,7 @@ namespace AssimpImporter {
struct ImportState {
String path;
- Spatial *root;
+ Node3D *root;
const aiScene *assimp_scene;
uint32_t max_bone_weights;
@@ -74,15 +74,15 @@ struct ImportState {
// Generation 3 - determinisitic iteration
// to lower potential recursion errors
List<const aiNode *> nodes;
- Map<const aiNode *, Spatial *> flat_node_map;
+ Map<const aiNode *, Node3D *> flat_node_map;
AnimationPlayer *animation_player;
// Generation 3 - deterministic armatures
// list of armature nodes - flat and simple to parse
// assimp node, node in godot
List<aiNode *> armature_nodes;
- Map<const aiNode *, Skeleton *> armature_skeletons;
- Map<aiBone *, Skeleton *> skeleton_bone_map;
+ Map<const aiNode *, Skeleton3D *> armature_skeletons;
+ Map<aiBone *, Skeleton3D *> skeleton_bone_map;
// Generation 3 - deterministic bone handling
// bones from the stack are popped when found
// this means we can detect
@@ -103,8 +103,8 @@ struct RecursiveState {
RecursiveState() {} // do not construct :)
RecursiveState(
Transform &_node_transform,
- Skeleton *_skeleton,
- Spatial *_new_node,
+ Skeleton3D *_skeleton,
+ Node3D *_new_node,
String &_node_name,
aiNode *_assimp_node,
Node *_parent_node,
@@ -118,12 +118,12 @@ struct RecursiveState {
bone(_bone) {}
Transform node_transform;
- Skeleton *skeleton = NULL;
- Spatial *new_node = NULL;
+ Skeleton3D *skeleton = nullptr;
+ Node3D *new_node = nullptr;
String node_name;
- aiNode *assimp_node = NULL;
- Node *parent_node = NULL;
- aiBone *bone = NULL;
+ aiNode *assimp_node = nullptr;
+ Node *parent_node = nullptr;
+ aiBone *bone = nullptr;
};
} // namespace AssimpImporter
diff --git a/modules/assimp/import_utils.h b/modules/assimp/import_utils.h
index 30c00f8765..f78931add3 100644
--- a/modules/assimp/import_utils.h
+++ b/modules/assimp/import_utils.h
@@ -233,7 +233,7 @@ public:
static Transform _get_global_assimp_node_transform(const aiNode *p_current_node) {
aiNode const *current_node = p_current_node;
Transform xform;
- while (current_node != NULL) {
+ while (current_node != nullptr) {
xform = assimp_matrix_transform(current_node->mTransformation) * xform;
current_node = current_node->mParent;
}
@@ -319,7 +319,7 @@ public:
*/
static void set_texture_mapping_mode(aiTextureMapMode *map_mode, Ref<ImageTexture> texture) {
ERR_FAIL_COND(texture.is_null());
- ERR_FAIL_COND(map_mode == NULL);
+ ERR_FAIL_COND(map_mode == nullptr);
// FIXME: Commented out during Vulkan port.
/*
aiTextureMapMode tex_mode = map_mode[0];
@@ -358,13 +358,13 @@ public:
print_verbose("Open Asset Import: Loading embedded texture " + filename);
if (tex->mHeight == 0) {
if (tex->CheckFormat("png")) {
- ERR_FAIL_COND_V(Image::_png_mem_loader_func == NULL, Ref<Image>());
+ ERR_FAIL_COND_V(Image::_png_mem_loader_func == nullptr, Ref<Image>());
Ref<Image> img = Image::_png_mem_loader_func((uint8_t *)tex->pcData, tex->mWidth);
ERR_FAIL_COND_V(img.is_null(), Ref<Image>());
state.path_to_image_cache.insert(p_path, img);
return img;
} else if (tex->CheckFormat("jpg")) {
- ERR_FAIL_COND_V(Image::_jpg_mem_loader_func == NULL, Ref<Image>());
+ ERR_FAIL_COND_V(Image::_jpg_mem_loader_func == nullptr, Ref<Image>());
Ref<Image> img = Image::_jpg_mem_loader_func((uint8_t *)tex->pcData, tex->mWidth);
ERR_FAIL_COND_V(img.is_null(), Ref<Image>());
state.path_to_image_cache.insert(p_path, img);
@@ -440,7 +440,7 @@ public:
String &path,
AssimpImageData &image_state) {
aiString ai_filename = aiString();
- if (AI_SUCCESS == ai_material->GetTexture(texture_type, 0, &ai_filename, NULL, NULL, NULL, NULL, image_state.map_mode)) {
+ if (AI_SUCCESS == ai_material->GetTexture(texture_type, 0, &ai_filename, nullptr, nullptr, nullptr, nullptr, image_state.map_mode)) {
return CreateAssimpTexture(state, ai_filename, filename, path, image_state);
}
diff --git a/modules/basis_universal/SCsub b/modules/basis_universal/SCsub
index 63324e920b..dc7b176d24 100644
--- a/modules/basis_universal/SCsub
+++ b/modules/basis_universal/SCsub
@@ -1,7 +1,7 @@
#!/usr/bin/env python
-Import('env')
-Import('env_modules')
+Import("env")
+Import("env_modules")
env_basisu = env_modules.Clone()
@@ -9,36 +9,38 @@ env_basisu = env_modules.Clone()
# Not unbundled so far since not widespread as shared library
thirdparty_dir = "#thirdparty/basis_universal/"
tool_sources = [
- "basisu_astc_decomp.cpp",
- "basisu_backend.cpp",
- "basisu_basis_file.cpp",
- "basisu_comp.cpp",
- "basisu_enc.cpp",
- "basisu_etc.cpp",
- "basisu_frontend.cpp",
- "basisu_global_selector_palette_helpers.cpp",
- "basisu_gpu_texture.cpp",
- "basisu_pvrtc1_4.cpp",
- "basisu_resample_filters.cpp",
- "basisu_resampler.cpp",
- "basisu_ssim.cpp",
- "lodepng.cpp",
+ "basisu_astc_decomp.cpp",
+ "basisu_backend.cpp",
+ "basisu_basis_file.cpp",
+ "basisu_comp.cpp",
+ "basisu_enc.cpp",
+ "basisu_etc.cpp",
+ "basisu_frontend.cpp",
+ "basisu_global_selector_palette_helpers.cpp",
+ "basisu_gpu_texture.cpp",
+ "basisu_pvrtc1_4.cpp",
+ "basisu_resample_filters.cpp",
+ "basisu_resampler.cpp",
+ "basisu_ssim.cpp",
+ "lodepng.cpp",
]
tool_sources = [thirdparty_dir + file for file in tool_sources]
transcoder_sources = [thirdparty_dir + "transcoder/basisu_transcoder.cpp"]
# Treat Basis headers as system headers to avoid raising warnings. Not supported on MSVC.
if not env.msvc:
- env_basisu.Append(CPPFLAGS=['-isystem', Dir(thirdparty_dir).path, '-isystem', Dir(thirdparty_dir + "transcoder").path])
+ env_basisu.Append(
+ CPPFLAGS=["-isystem", Dir(thirdparty_dir).path, "-isystem", Dir(thirdparty_dir + "transcoder").path]
+ )
else:
env_basisu.Prepend(CPPPATH=[thirdparty_dir, thirdparty_dir + "transcoder"])
-if env['target'] == "debug":
- env_basisu.Append(CPPFLAGS=["-DBASISU_DEVEL_MESSAGES=1", "-DBASISD_ENABLE_DEBUG_FLAGS=1"])
+if env["target"] == "debug":
+ env_basisu.Append(CPPFLAGS=["-DBASISU_DEVEL_MESSAGES=1", "-DBASISD_ENABLE_DEBUG_FLAGS=1"])
env_thirdparty = env_basisu.Clone()
env_thirdparty.disable_warnings()
-if env['tools']:
+if env["tools"]:
env_thirdparty.add_source_files(env.modules_sources, tool_sources)
env_thirdparty.add_source_files(env.modules_sources, transcoder_sources)
diff --git a/modules/basis_universal/config.py b/modules/basis_universal/config.py
index 1c8cd12a2d..d22f9454ed 100644
--- a/modules/basis_universal/config.py
+++ b/modules/basis_universal/config.py
@@ -1,5 +1,6 @@
def can_build(env, platform):
return True
+
def configure(env):
pass
diff --git a/modules/basis_universal/register_types.cpp b/modules/basis_universal/register_types.cpp
index 062b5b59f8..f31c889a6d 100644
--- a/modules/basis_universal/register_types.cpp
+++ b/modules/basis_universal/register_types.cpp
@@ -31,7 +31,7 @@
#include "register_types.h"
#include "core/os/os.h"
-#include "servers/visual_server.h"
+#include "servers/rendering_server.h"
#include "texture_basisu.h"
#ifdef TOOLS_ENABLED
@@ -98,7 +98,7 @@ static Vector<uint8_t> basis_universal_packer(const Ref<Image> &p_image, Image::
params.m_mip_gen = false; //sorry, please some day support provided mipmaps.
params.m_source_images.push_back(buimg);
- BasisDecompressFormat decompress_format;
+ BasisDecompressFormat decompress_format = BASIS_DECOMPRESS_RG;
params.m_check_for_alpha = false;
switch (p_channels) {
@@ -158,33 +158,34 @@ static Ref<Image> basis_universal_unpacker(const Vector<uint8_t> &p_buffer) {
const uint8_t *ptr = r;
int size = p_buffer.size();
- basist::transcoder_texture_format format;
- Image::Format imgfmt;
+ basist::transcoder_texture_format format = basist::transcoder_texture_format::cTFTotalTextureFormats;
+ Image::Format imgfmt = Image::FORMAT_MAX;
switch (*(uint32_t *)(ptr)) {
case BASIS_DECOMPRESS_RG: {
- if (VS::get_singleton()->has_os_feature("rgtc")) {
+ if (RS::get_singleton()->has_os_feature("rgtc")) {
format = basist::transcoder_texture_format::cTFBC5; // get this from renderer
imgfmt = Image::FORMAT_RGTC_RG;
- } else if (VS::get_singleton()->has_os_feature("etc2")) {
+ } else if (RS::get_singleton()->has_os_feature("etc2")) {
//unfortunately, basis universal does not support
//
ERR_FAIL_V(image); //unimplemented here
//format = basist::transcoder_texture_format::cTFETC1; // get this from renderer
//imgfmt = Image::FORMAT_RGTC_RG;
} else {
- //decompress
+ // FIXME: There wasn't anything here, but then imgformat is used uninitialized.
+ ERR_FAIL_V(image);
}
} break;
case BASIS_DECOMPRESS_RGB: {
- if (VS::get_singleton()->has_os_feature("bptc")) {
+ if (RS::get_singleton()->has_os_feature("bptc")) {
format = basist::transcoder_texture_format::cTFBC7_M6_OPAQUE_ONLY; // get this from renderer
imgfmt = Image::FORMAT_BPTC_RGBA;
- } else if (VS::get_singleton()->has_os_feature("s3tc")) {
+ } else if (RS::get_singleton()->has_os_feature("s3tc")) {
format = basist::transcoder_texture_format::cTFBC1; // get this from renderer
imgfmt = Image::FORMAT_DXT1;
- } else if (VS::get_singleton()->has_os_feature("etc")) {
+ } else if (RS::get_singleton()->has_os_feature("etc")) {
format = basist::transcoder_texture_format::cTFETC1; // get this from renderer
imgfmt = Image::FORMAT_ETC;
@@ -195,13 +196,13 @@ static Ref<Image> basis_universal_unpacker(const Vector<uint8_t> &p_buffer) {
} break;
case BASIS_DECOMPRESS_RGBA: {
- if (VS::get_singleton()->has_os_feature("bptc")) {
+ if (RS::get_singleton()->has_os_feature("bptc")) {
format = basist::transcoder_texture_format::cTFBC7_M5; // get this from renderer
imgfmt = Image::FORMAT_BPTC_RGBA;
- } else if (VS::get_singleton()->has_os_feature("s3tc")) {
+ } else if (RS::get_singleton()->has_os_feature("s3tc")) {
format = basist::transcoder_texture_format::cTFBC3; // get this from renderer
imgfmt = Image::FORMAT_DXT5;
- } else if (VS::get_singleton()->has_os_feature("etc2")) {
+ } else if (RS::get_singleton()->has_os_feature("etc2")) {
format = basist::transcoder_texture_format::cTFETC2; // get this from renderer
imgfmt = Image::FORMAT_ETC2_RGBA8;
} else {
@@ -211,10 +212,10 @@ static Ref<Image> basis_universal_unpacker(const Vector<uint8_t> &p_buffer) {
}
} break;
case BASIS_DECOMPRESS_RG_AS_RA: {
- if (VS::get_singleton()->has_os_feature("s3tc")) {
+ if (RS::get_singleton()->has_os_feature("s3tc")) {
format = basist::transcoder_texture_format::cTFBC3; // get this from renderer
imgfmt = Image::FORMAT_DXT5_RA_AS_RG;
- } else if (VS::get_singleton()->has_os_feature("etc2")) {
+ } else if (RS::get_singleton()->has_os_feature("etc2")) {
format = basist::transcoder_texture_format::cTFETC2; // get this from renderer
imgfmt = Image::FORMAT_ETC2_RGBA8;
} else {
@@ -228,7 +229,7 @@ static Ref<Image> basis_universal_unpacker(const Vector<uint8_t> &p_buffer) {
ptr += 4;
size -= 4;
- basist::basisu_transcoder tr(NULL);
+ basist::basisu_transcoder tr(nullptr);
ERR_FAIL_COND_V(!tr.validate_header(ptr, size), image);
@@ -281,7 +282,7 @@ void unregister_basis_universal_types() {
#ifdef TOOLS_ENABLED
delete sel_codebook;
- Image::basis_universal_packer = NULL;
+ Image::basis_universal_packer = nullptr;
#endif
- Image::basis_universal_unpacker = NULL;
+ Image::basis_universal_unpacker = nullptr;
}
diff --git a/modules/basis_universal/texture_basisu.cpp b/modules/basis_universal/texture_basisu.cpp
index 12f3241c98..2ed0340927 100644
--- a/modules/basis_universal/texture_basisu.cpp
+++ b/modules/basis_universal/texture_basisu.cpp
@@ -72,7 +72,7 @@ bool TextureBasisU::has_alpha() const {
void TextureBasisU::set_flags(uint32_t p_flags) {
flags = p_flags;
- VisualServer::get_singleton()->texture_set_flags(texture, p_flags);
+ RenderingServer::get_singleton()->texture_set_flags(texture, p_flags);
};
uint32_t TextureBasisU::get_flags() const {
@@ -105,7 +105,7 @@ void TextureBasisU::set_basisu_data(const Vector<uint8_t>& p_data) {
imgfmt = Image::FORMAT_ETC2_RGBA8;
};
- basist::basisu_transcoder tr(NULL);
+ basist::basisu_transcoder tr(nullptr);
ERR_FAIL_COND(!tr.validate_header(ptr, size));
@@ -144,8 +144,8 @@ void TextureBasisU::set_basisu_data(const Vector<uint8_t>& p_data) {
img.instance();
img->create(info.m_width, info.m_height, info.m_total_levels > 1, imgfmt, gpudata);
- VisualServer::get_singleton()->texture_allocate(texture, tex_size.x, tex_size.y, 0, img->get_format(), VS::TEXTURE_TYPE_2D, flags);
- VisualServer::get_singleton()->texture_set_data(texture, img);
+ RenderingServer::get_singleton()->texture_allocate(texture, tex_size.x, tex_size.y, 0, img->get_format(), RS::TEXTURE_TYPE_2D, flags);
+ RenderingServer::get_singleton()->texture_set_data(texture, img);
};
Error TextureBasisU::import(const Ref<Image>& p_img) {
@@ -221,13 +221,13 @@ Vector<uint8_t> TextureBasisU::get_basisu_data() const {
TextureBasisU::TextureBasisU() {
flags = FLAGS_DEFAULT;
- texture = VisualServer::get_singleton()->texture_create();
+ texture = RenderingServer::get_singleton()->texture_create();
};
TextureBasisU::~TextureBasisU() {
- VisualServer::get_singleton()->free(texture);
+ RenderingServer::get_singleton()->free(texture);
};
#endif
diff --git a/modules/bmp/SCsub b/modules/bmp/SCsub
index e7da7cf108..4f3405ff28 100644
--- a/modules/bmp/SCsub
+++ b/modules/bmp/SCsub
@@ -1,7 +1,7 @@
#!/usr/bin/env python
-Import('env')
-Import('env_modules')
+Import("env")
+Import("env_modules")
env_bmp = env_modules.Clone()
diff --git a/modules/bmp/config.py b/modules/bmp/config.py
index 1c8cd12a2d..d22f9454ed 100644
--- a/modules/bmp/config.py
+++ b/modules/bmp/config.py
@@ -1,5 +1,6 @@
def can_build(env, platform):
return True
+
def configure(env):
pass
diff --git a/modules/bmp/image_loader_bmp.cpp b/modules/bmp/image_loader_bmp.cpp
index 71e5076e78..ea2b2b548f 100644
--- a/modules/bmp/image_loader_bmp.cpp
+++ b/modules/bmp/image_loader_bmp.cpp
@@ -38,7 +38,7 @@ Error ImageLoaderBMP::convert_to_image(Ref<Image> p_image,
Error err = OK;
- if (p_buffer == NULL)
+ if (p_buffer == nullptr)
err = FAILED;
if (err == OK) {
@@ -151,7 +151,7 @@ Error ImageLoaderBMP::convert_to_image(Ref<Image> p_image,
line -= line_width;
}
- if (p_color_buffer == NULL || color_table_size == 0) { // regular pixels
+ if (p_color_buffer == nullptr || color_table_size == 0) { // regular pixels
p_image->create(width, height, 0, Image::FORMAT_RGBA8, data);
diff --git a/modules/bmp/register_types.cpp b/modules/bmp/register_types.cpp
index d5cc6c5eb3..6220e956d6 100644
--- a/modules/bmp/register_types.cpp
+++ b/modules/bmp/register_types.cpp
@@ -32,7 +32,7 @@
#include "image_loader_bmp.h"
-static ImageLoaderBMP *image_loader_bmp = NULL;
+static ImageLoaderBMP *image_loader_bmp = nullptr;
void register_bmp_types() {
image_loader_bmp = memnew(ImageLoaderBMP);
diff --git a/modules/bullet/SCsub b/modules/bullet/SCsub
index 02d0a31a69..6f64edce3d 100644
--- a/modules/bullet/SCsub
+++ b/modules/bullet/SCsub
@@ -1,208 +1,204 @@
#!/usr/bin/env python
-Import('env')
-Import('env_modules')
+Import("env")
+Import("env_modules")
env_bullet = env_modules.Clone()
# Thirdparty source files
-if env['builtin_bullet']:
+if env["builtin_bullet"]:
# Build only version 2 for now (as of 2.89)
# Sync file list with relevant upstream CMakeLists.txt for each folder.
thirdparty_dir = "#thirdparty/bullet/"
bullet2_src = [
# BulletCollision
- "BulletCollision/BroadphaseCollision/btAxisSweep3.cpp"
- , "BulletCollision/BroadphaseCollision/btBroadphaseProxy.cpp"
- , "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.cpp"
- , "BulletCollision/BroadphaseCollision/btDbvt.cpp"
- , "BulletCollision/BroadphaseCollision/btDbvtBroadphase.cpp"
- , "BulletCollision/BroadphaseCollision/btDispatcher.cpp"
- , "BulletCollision/BroadphaseCollision/btOverlappingPairCache.cpp"
- , "BulletCollision/BroadphaseCollision/btQuantizedBvh.cpp"
- , "BulletCollision/BroadphaseCollision/btSimpleBroadphase.cpp"
- , "BulletCollision/CollisionDispatch/btActivatingCollisionAlgorithm.cpp"
- , "BulletCollision/CollisionDispatch/btBoxBoxCollisionAlgorithm.cpp"
- , "BulletCollision/CollisionDispatch/btBox2dBox2dCollisionAlgorithm.cpp"
- , "BulletCollision/CollisionDispatch/btBoxBoxDetector.cpp"
- , "BulletCollision/CollisionDispatch/btCollisionDispatcher.cpp"
- , "BulletCollision/CollisionDispatch/btCollisionDispatcherMt.cpp"
- , "BulletCollision/CollisionDispatch/btCollisionObject.cpp"
- , "BulletCollision/CollisionDispatch/btCollisionWorld.cpp"
- , "BulletCollision/CollisionDispatch/btCollisionWorldImporter.cpp"
- , "BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.cpp"
- , "BulletCollision/CollisionDispatch/btCompoundCompoundCollisionAlgorithm.cpp"
- , "BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.cpp"
- , "BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.cpp"
- , "BulletCollision/CollisionDispatch/btConvexPlaneCollisionAlgorithm.cpp"
- , "BulletCollision/CollisionDispatch/btConvex2dConvex2dAlgorithm.cpp"
- , "BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.cpp"
- , "BulletCollision/CollisionDispatch/btEmptyCollisionAlgorithm.cpp"
- , "BulletCollision/CollisionDispatch/btGhostObject.cpp"
- , "BulletCollision/CollisionDispatch/btHashedSimplePairCache.cpp"
- , "BulletCollision/CollisionDispatch/btInternalEdgeUtility.cpp"
- , "BulletCollision/CollisionDispatch/btManifoldResult.cpp"
- , "BulletCollision/CollisionDispatch/btSimulationIslandManager.cpp"
- , "BulletCollision/CollisionDispatch/btSphereBoxCollisionAlgorithm.cpp"
- , "BulletCollision/CollisionDispatch/btSphereSphereCollisionAlgorithm.cpp"
- , "BulletCollision/CollisionDispatch/btSphereTriangleCollisionAlgorithm.cpp"
- , "BulletCollision/CollisionDispatch/btUnionFind.cpp"
- , "BulletCollision/CollisionDispatch/SphereTriangleDetector.cpp"
- , "BulletCollision/CollisionShapes/btBoxShape.cpp"
- , "BulletCollision/CollisionShapes/btBox2dShape.cpp"
- , "BulletCollision/CollisionShapes/btBvhTriangleMeshShape.cpp"
- , "BulletCollision/CollisionShapes/btCapsuleShape.cpp"
- , "BulletCollision/CollisionShapes/btCollisionShape.cpp"
- , "BulletCollision/CollisionShapes/btCompoundShape.cpp"
- , "BulletCollision/CollisionShapes/btConcaveShape.cpp"
- , "BulletCollision/CollisionShapes/btConeShape.cpp"
- , "BulletCollision/CollisionShapes/btConvexHullShape.cpp"
- , "BulletCollision/CollisionShapes/btConvexInternalShape.cpp"
- , "BulletCollision/CollisionShapes/btConvexPointCloudShape.cpp"
- , "BulletCollision/CollisionShapes/btConvexPolyhedron.cpp"
- , "BulletCollision/CollisionShapes/btConvexShape.cpp"
- , "BulletCollision/CollisionShapes/btConvex2dShape.cpp"
- , "BulletCollision/CollisionShapes/btConvexTriangleMeshShape.cpp"
- , "BulletCollision/CollisionShapes/btCylinderShape.cpp"
- , "BulletCollision/CollisionShapes/btEmptyShape.cpp"
- , "BulletCollision/CollisionShapes/btHeightfieldTerrainShape.cpp"
- , "BulletCollision/CollisionShapes/btMiniSDF.cpp"
- , "BulletCollision/CollisionShapes/btMinkowskiSumShape.cpp"
- , "BulletCollision/CollisionShapes/btMultimaterialTriangleMeshShape.cpp"
- , "BulletCollision/CollisionShapes/btMultiSphereShape.cpp"
- , "BulletCollision/CollisionShapes/btOptimizedBvh.cpp"
- , "BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp"
- , "BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.cpp"
- , "BulletCollision/CollisionShapes/btSdfCollisionShape.cpp"
- , "BulletCollision/CollisionShapes/btShapeHull.cpp"
- , "BulletCollision/CollisionShapes/btSphereShape.cpp"
- , "BulletCollision/CollisionShapes/btStaticPlaneShape.cpp"
- , "BulletCollision/CollisionShapes/btStridingMeshInterface.cpp"
- , "BulletCollision/CollisionShapes/btTetrahedronShape.cpp"
- , "BulletCollision/CollisionShapes/btTriangleBuffer.cpp"
- , "BulletCollision/CollisionShapes/btTriangleCallback.cpp"
- , "BulletCollision/CollisionShapes/btTriangleIndexVertexArray.cpp"
- , "BulletCollision/CollisionShapes/btTriangleIndexVertexMaterialArray.cpp"
- , "BulletCollision/CollisionShapes/btTriangleMesh.cpp"
- , "BulletCollision/CollisionShapes/btTriangleMeshShape.cpp"
- , "BulletCollision/CollisionShapes/btUniformScalingShape.cpp"
- , "BulletCollision/Gimpact/btContactProcessing.cpp"
- , "BulletCollision/Gimpact/btGenericPoolAllocator.cpp"
- , "BulletCollision/Gimpact/btGImpactBvh.cpp"
- , "BulletCollision/Gimpact/btGImpactCollisionAlgorithm.cpp"
- , "BulletCollision/Gimpact/btGImpactQuantizedBvh.cpp"
- , "BulletCollision/Gimpact/btGImpactShape.cpp"
- , "BulletCollision/Gimpact/btTriangleShapeEx.cpp"
- , "BulletCollision/Gimpact/gim_box_set.cpp"
- , "BulletCollision/Gimpact/gim_contact.cpp"
- , "BulletCollision/Gimpact/gim_memory.cpp"
- , "BulletCollision/Gimpact/gim_tri_collision.cpp"
- , "BulletCollision/NarrowPhaseCollision/btContinuousConvexCollision.cpp"
- , "BulletCollision/NarrowPhaseCollision/btConvexCast.cpp"
- , "BulletCollision/NarrowPhaseCollision/btGjkConvexCast.cpp"
- , "BulletCollision/NarrowPhaseCollision/btGjkEpa2.cpp"
- , "BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.cpp"
- , "BulletCollision/NarrowPhaseCollision/btGjkPairDetector.cpp"
- , "BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.cpp"
- , "BulletCollision/NarrowPhaseCollision/btPersistentManifold.cpp"
- , "BulletCollision/NarrowPhaseCollision/btRaycastCallback.cpp"
- , "BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.cpp"
- , "BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.cpp"
- , "BulletCollision/NarrowPhaseCollision/btPolyhedralContactClipping.cpp"
-
+ "BulletCollision/BroadphaseCollision/btAxisSweep3.cpp",
+ "BulletCollision/BroadphaseCollision/btBroadphaseProxy.cpp",
+ "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.cpp",
+ "BulletCollision/BroadphaseCollision/btDbvt.cpp",
+ "BulletCollision/BroadphaseCollision/btDbvtBroadphase.cpp",
+ "BulletCollision/BroadphaseCollision/btDispatcher.cpp",
+ "BulletCollision/BroadphaseCollision/btOverlappingPairCache.cpp",
+ "BulletCollision/BroadphaseCollision/btQuantizedBvh.cpp",
+ "BulletCollision/BroadphaseCollision/btSimpleBroadphase.cpp",
+ "BulletCollision/CollisionDispatch/btActivatingCollisionAlgorithm.cpp",
+ "BulletCollision/CollisionDispatch/btBoxBoxCollisionAlgorithm.cpp",
+ "BulletCollision/CollisionDispatch/btBox2dBox2dCollisionAlgorithm.cpp",
+ "BulletCollision/CollisionDispatch/btBoxBoxDetector.cpp",
+ "BulletCollision/CollisionDispatch/btCollisionDispatcher.cpp",
+ "BulletCollision/CollisionDispatch/btCollisionDispatcherMt.cpp",
+ "BulletCollision/CollisionDispatch/btCollisionObject.cpp",
+ "BulletCollision/CollisionDispatch/btCollisionWorld.cpp",
+ "BulletCollision/CollisionDispatch/btCollisionWorldImporter.cpp",
+ "BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.cpp",
+ "BulletCollision/CollisionDispatch/btCompoundCompoundCollisionAlgorithm.cpp",
+ "BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.cpp",
+ "BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.cpp",
+ "BulletCollision/CollisionDispatch/btConvexPlaneCollisionAlgorithm.cpp",
+ "BulletCollision/CollisionDispatch/btConvex2dConvex2dAlgorithm.cpp",
+ "BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.cpp",
+ "BulletCollision/CollisionDispatch/btEmptyCollisionAlgorithm.cpp",
+ "BulletCollision/CollisionDispatch/btGhostObject.cpp",
+ "BulletCollision/CollisionDispatch/btHashedSimplePairCache.cpp",
+ "BulletCollision/CollisionDispatch/btInternalEdgeUtility.cpp",
+ "BulletCollision/CollisionDispatch/btManifoldResult.cpp",
+ "BulletCollision/CollisionDispatch/btSimulationIslandManager.cpp",
+ "BulletCollision/CollisionDispatch/btSphereBoxCollisionAlgorithm.cpp",
+ "BulletCollision/CollisionDispatch/btSphereSphereCollisionAlgorithm.cpp",
+ "BulletCollision/CollisionDispatch/btSphereTriangleCollisionAlgorithm.cpp",
+ "BulletCollision/CollisionDispatch/btUnionFind.cpp",
+ "BulletCollision/CollisionDispatch/SphereTriangleDetector.cpp",
+ "BulletCollision/CollisionShapes/btBoxShape.cpp",
+ "BulletCollision/CollisionShapes/btBox2dShape.cpp",
+ "BulletCollision/CollisionShapes/btBvhTriangleMeshShape.cpp",
+ "BulletCollision/CollisionShapes/btCapsuleShape.cpp",
+ "BulletCollision/CollisionShapes/btCollisionShape.cpp",
+ "BulletCollision/CollisionShapes/btCompoundShape.cpp",
+ "BulletCollision/CollisionShapes/btConcaveShape.cpp",
+ "BulletCollision/CollisionShapes/btConeShape.cpp",
+ "BulletCollision/CollisionShapes/btConvexHullShape.cpp",
+ "BulletCollision/CollisionShapes/btConvexInternalShape.cpp",
+ "BulletCollision/CollisionShapes/btConvexPointCloudShape.cpp",
+ "BulletCollision/CollisionShapes/btConvexPolyhedron.cpp",
+ "BulletCollision/CollisionShapes/btConvexShape.cpp",
+ "BulletCollision/CollisionShapes/btConvex2dShape.cpp",
+ "BulletCollision/CollisionShapes/btConvexTriangleMeshShape.cpp",
+ "BulletCollision/CollisionShapes/btCylinderShape.cpp",
+ "BulletCollision/CollisionShapes/btEmptyShape.cpp",
+ "BulletCollision/CollisionShapes/btHeightfieldTerrainShape.cpp",
+ "BulletCollision/CollisionShapes/btMiniSDF.cpp",
+ "BulletCollision/CollisionShapes/btMinkowskiSumShape.cpp",
+ "BulletCollision/CollisionShapes/btMultimaterialTriangleMeshShape.cpp",
+ "BulletCollision/CollisionShapes/btMultiSphereShape.cpp",
+ "BulletCollision/CollisionShapes/btOptimizedBvh.cpp",
+ "BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp",
+ "BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.cpp",
+ "BulletCollision/CollisionShapes/btSdfCollisionShape.cpp",
+ "BulletCollision/CollisionShapes/btShapeHull.cpp",
+ "BulletCollision/CollisionShapes/btSphereShape.cpp",
+ "BulletCollision/CollisionShapes/btStaticPlaneShape.cpp",
+ "BulletCollision/CollisionShapes/btStridingMeshInterface.cpp",
+ "BulletCollision/CollisionShapes/btTetrahedronShape.cpp",
+ "BulletCollision/CollisionShapes/btTriangleBuffer.cpp",
+ "BulletCollision/CollisionShapes/btTriangleCallback.cpp",
+ "BulletCollision/CollisionShapes/btTriangleIndexVertexArray.cpp",
+ "BulletCollision/CollisionShapes/btTriangleIndexVertexMaterialArray.cpp",
+ "BulletCollision/CollisionShapes/btTriangleMesh.cpp",
+ "BulletCollision/CollisionShapes/btTriangleMeshShape.cpp",
+ "BulletCollision/CollisionShapes/btUniformScalingShape.cpp",
+ "BulletCollision/Gimpact/btContactProcessing.cpp",
+ "BulletCollision/Gimpact/btGenericPoolAllocator.cpp",
+ "BulletCollision/Gimpact/btGImpactBvh.cpp",
+ "BulletCollision/Gimpact/btGImpactCollisionAlgorithm.cpp",
+ "BulletCollision/Gimpact/btGImpactQuantizedBvh.cpp",
+ "BulletCollision/Gimpact/btGImpactShape.cpp",
+ "BulletCollision/Gimpact/btTriangleShapeEx.cpp",
+ "BulletCollision/Gimpact/gim_box_set.cpp",
+ "BulletCollision/Gimpact/gim_contact.cpp",
+ "BulletCollision/Gimpact/gim_memory.cpp",
+ "BulletCollision/Gimpact/gim_tri_collision.cpp",
+ "BulletCollision/NarrowPhaseCollision/btContinuousConvexCollision.cpp",
+ "BulletCollision/NarrowPhaseCollision/btConvexCast.cpp",
+ "BulletCollision/NarrowPhaseCollision/btGjkConvexCast.cpp",
+ "BulletCollision/NarrowPhaseCollision/btGjkEpa2.cpp",
+ "BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.cpp",
+ "BulletCollision/NarrowPhaseCollision/btGjkPairDetector.cpp",
+ "BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.cpp",
+ "BulletCollision/NarrowPhaseCollision/btPersistentManifold.cpp",
+ "BulletCollision/NarrowPhaseCollision/btRaycastCallback.cpp",
+ "BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.cpp",
+ "BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.cpp",
+ "BulletCollision/NarrowPhaseCollision/btPolyhedralContactClipping.cpp",
# BulletDynamics
- , "BulletDynamics/Character/btKinematicCharacterController.cpp"
- , "BulletDynamics/ConstraintSolver/btConeTwistConstraint.cpp"
- , "BulletDynamics/ConstraintSolver/btContactConstraint.cpp"
- , "BulletDynamics/ConstraintSolver/btFixedConstraint.cpp"
- , "BulletDynamics/ConstraintSolver/btGearConstraint.cpp"
- , "BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.cpp"
- , "BulletDynamics/ConstraintSolver/btGeneric6DofSpringConstraint.cpp"
- , "BulletDynamics/ConstraintSolver/btGeneric6DofSpring2Constraint.cpp"
- , "BulletDynamics/ConstraintSolver/btHinge2Constraint.cpp"
- , "BulletDynamics/ConstraintSolver/btHingeConstraint.cpp"
- , "BulletDynamics/ConstraintSolver/btPoint2PointConstraint.cpp"
- , "BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.cpp"
- , "BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolverMt.cpp"
- , "BulletDynamics/ConstraintSolver/btBatchedConstraints.cpp"
- , "BulletDynamics/ConstraintSolver/btNNCGConstraintSolver.cpp"
- , "BulletDynamics/ConstraintSolver/btSliderConstraint.cpp"
- , "BulletDynamics/ConstraintSolver/btSolve2LinearConstraint.cpp"
- , "BulletDynamics/ConstraintSolver/btTypedConstraint.cpp"
- , "BulletDynamics/ConstraintSolver/btUniversalConstraint.cpp"
- , "BulletDynamics/Dynamics/btDiscreteDynamicsWorld.cpp"
- , "BulletDynamics/Dynamics/btDiscreteDynamicsWorldMt.cpp"
- , "BulletDynamics/Dynamics/btSimulationIslandManagerMt.cpp"
- , "BulletDynamics/Dynamics/btRigidBody.cpp"
- , "BulletDynamics/Dynamics/btSimpleDynamicsWorld.cpp"
- #, "BulletDynamics/Dynamics/Bullet-C-API.cpp"
- , "BulletDynamics/Vehicle/btRaycastVehicle.cpp"
- , "BulletDynamics/Vehicle/btWheelInfo.cpp"
- , "BulletDynamics/Featherstone/btMultiBody.cpp"
- , "BulletDynamics/Featherstone/btMultiBodyConstraint.cpp"
- , "BulletDynamics/Featherstone/btMultiBodyConstraintSolver.cpp"
- , "BulletDynamics/Featherstone/btMultiBodyDynamicsWorld.cpp"
- , "BulletDynamics/Featherstone/btMultiBodyFixedConstraint.cpp"
- , "BulletDynamics/Featherstone/btMultiBodyGearConstraint.cpp"
- , "BulletDynamics/Featherstone/btMultiBodyJointLimitConstraint.cpp"
- , "BulletDynamics/Featherstone/btMultiBodyJointMotor.cpp"
- , "BulletDynamics/Featherstone/btMultiBodyMLCPConstraintSolver.cpp"
- , "BulletDynamics/Featherstone/btMultiBodyPoint2Point.cpp"
- , "BulletDynamics/Featherstone/btMultiBodySliderConstraint.cpp"
- , "BulletDynamics/Featherstone/btMultiBodySphericalJointMotor.cpp"
- , "BulletDynamics/MLCPSolvers/btDantzigLCP.cpp"
- , "BulletDynamics/MLCPSolvers/btMLCPSolver.cpp"
- , "BulletDynamics/MLCPSolvers/btLemkeAlgorithm.cpp"
-
+ "BulletDynamics/Character/btKinematicCharacterController.cpp",
+ "BulletDynamics/ConstraintSolver/btConeTwistConstraint.cpp",
+ "BulletDynamics/ConstraintSolver/btContactConstraint.cpp",
+ "BulletDynamics/ConstraintSolver/btFixedConstraint.cpp",
+ "BulletDynamics/ConstraintSolver/btGearConstraint.cpp",
+ "BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.cpp",
+ "BulletDynamics/ConstraintSolver/btGeneric6DofSpringConstraint.cpp",
+ "BulletDynamics/ConstraintSolver/btGeneric6DofSpring2Constraint.cpp",
+ "BulletDynamics/ConstraintSolver/btHinge2Constraint.cpp",
+ "BulletDynamics/ConstraintSolver/btHingeConstraint.cpp",
+ "BulletDynamics/ConstraintSolver/btPoint2PointConstraint.cpp",
+ "BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.cpp",
+ "BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolverMt.cpp",
+ "BulletDynamics/ConstraintSolver/btBatchedConstraints.cpp",
+ "BulletDynamics/ConstraintSolver/btNNCGConstraintSolver.cpp",
+ "BulletDynamics/ConstraintSolver/btSliderConstraint.cpp",
+ "BulletDynamics/ConstraintSolver/btSolve2LinearConstraint.cpp",
+ "BulletDynamics/ConstraintSolver/btTypedConstraint.cpp",
+ "BulletDynamics/ConstraintSolver/btUniversalConstraint.cpp",
+ "BulletDynamics/Dynamics/btDiscreteDynamicsWorld.cpp",
+ "BulletDynamics/Dynamics/btDiscreteDynamicsWorldMt.cpp",
+ "BulletDynamics/Dynamics/btSimulationIslandManagerMt.cpp",
+ "BulletDynamics/Dynamics/btRigidBody.cpp",
+ "BulletDynamics/Dynamics/btSimpleDynamicsWorld.cpp",
+ # "BulletDynamics/Dynamics/Bullet-C-API.cpp",
+ "BulletDynamics/Vehicle/btRaycastVehicle.cpp",
+ "BulletDynamics/Vehicle/btWheelInfo.cpp",
+ "BulletDynamics/Featherstone/btMultiBody.cpp",
+ "BulletDynamics/Featherstone/btMultiBodyConstraint.cpp",
+ "BulletDynamics/Featherstone/btMultiBodyConstraintSolver.cpp",
+ "BulletDynamics/Featherstone/btMultiBodyDynamicsWorld.cpp",
+ "BulletDynamics/Featherstone/btMultiBodyFixedConstraint.cpp",
+ "BulletDynamics/Featherstone/btMultiBodyGearConstraint.cpp",
+ "BulletDynamics/Featherstone/btMultiBodyJointLimitConstraint.cpp",
+ "BulletDynamics/Featherstone/btMultiBodyJointMotor.cpp",
+ "BulletDynamics/Featherstone/btMultiBodyMLCPConstraintSolver.cpp",
+ "BulletDynamics/Featherstone/btMultiBodyPoint2Point.cpp",
+ "BulletDynamics/Featherstone/btMultiBodySliderConstraint.cpp",
+ "BulletDynamics/Featherstone/btMultiBodySphericalJointMotor.cpp",
+ "BulletDynamics/MLCPSolvers/btDantzigLCP.cpp",
+ "BulletDynamics/MLCPSolvers/btMLCPSolver.cpp",
+ "BulletDynamics/MLCPSolvers/btLemkeAlgorithm.cpp",
# BulletInverseDynamics
- , "BulletInverseDynamics/IDMath.cpp"
- , "BulletInverseDynamics/MultiBodyTree.cpp"
- , "BulletInverseDynamics/details/MultiBodyTreeInitCache.cpp"
- , "BulletInverseDynamics/details/MultiBodyTreeImpl.cpp"
-
+ "BulletInverseDynamics/IDMath.cpp",
+ "BulletInverseDynamics/MultiBodyTree.cpp",
+ "BulletInverseDynamics/details/MultiBodyTreeInitCache.cpp",
+ "BulletInverseDynamics/details/MultiBodyTreeImpl.cpp",
# BulletSoftBody
- , "BulletSoftBody/btSoftBody.cpp"
- , "BulletSoftBody/btSoftBodyConcaveCollisionAlgorithm.cpp"
- , "BulletSoftBody/btSoftBodyHelpers.cpp"
- , "BulletSoftBody/btSoftBodyRigidBodyCollisionConfiguration.cpp"
- , "BulletSoftBody/btSoftRigidCollisionAlgorithm.cpp"
- , "BulletSoftBody/btSoftRigidDynamicsWorld.cpp"
- , "BulletSoftBody/btSoftMultiBodyDynamicsWorld.cpp"
- , "BulletSoftBody/btSoftSoftCollisionAlgorithm.cpp"
- , "BulletSoftBody/btDefaultSoftBodySolver.cpp"
- , "BulletSoftBody/btDeformableBackwardEulerObjective.cpp"
- , "BulletSoftBody/btDeformableBodySolver.cpp"
- , "BulletSoftBody/btDeformableMultiBodyConstraintSolver.cpp"
- , "BulletSoftBody/btDeformableContactProjection.cpp"
- , "BulletSoftBody/btDeformableMultiBodyDynamicsWorld.cpp"
- , "BulletSoftBody/btDeformableContactConstraint.cpp"
-
+ "BulletSoftBody/btSoftBody.cpp",
+ "BulletSoftBody/btSoftBodyConcaveCollisionAlgorithm.cpp",
+ "BulletSoftBody/btSoftBodyHelpers.cpp",
+ "BulletSoftBody/btSoftBodyRigidBodyCollisionConfiguration.cpp",
+ "BulletSoftBody/btSoftRigidCollisionAlgorithm.cpp",
+ "BulletSoftBody/btSoftRigidDynamicsWorld.cpp",
+ "BulletSoftBody/btSoftMultiBodyDynamicsWorld.cpp",
+ "BulletSoftBody/btSoftSoftCollisionAlgorithm.cpp",
+ "BulletSoftBody/btDefaultSoftBodySolver.cpp",
+ "BulletSoftBody/btDeformableBackwardEulerObjective.cpp",
+ "BulletSoftBody/btDeformableBodySolver.cpp",
+ "BulletSoftBody/btDeformableMultiBodyConstraintSolver.cpp",
+ "BulletSoftBody/btDeformableContactProjection.cpp",
+ "BulletSoftBody/btDeformableMultiBodyDynamicsWorld.cpp",
+ "BulletSoftBody/btDeformableContactConstraint.cpp",
+ "BulletSoftBody/poly34.cpp",
# clew
- , "clew/clew.c"
-
+ "clew/clew.c",
# LinearMath
- , "LinearMath/btAlignedAllocator.cpp"
- , "LinearMath/btConvexHull.cpp"
- , "LinearMath/btConvexHullComputer.cpp"
- , "LinearMath/btGeometryUtil.cpp"
- , "LinearMath/btPolarDecomposition.cpp"
- , "LinearMath/btQuickprof.cpp"
- , "LinearMath/btSerializer.cpp"
- , "LinearMath/btSerializer64.cpp"
- , "LinearMath/btThreads.cpp"
- , "LinearMath/btVector3.cpp"
- , "LinearMath/TaskScheduler/btTaskScheduler.cpp"
- , "LinearMath/TaskScheduler/btThreadSupportPosix.cpp"
- , "LinearMath/TaskScheduler/btThreadSupportWin32.cpp"
+ "LinearMath/btAlignedAllocator.cpp",
+ "LinearMath/btConvexHull.cpp",
+ "LinearMath/btConvexHullComputer.cpp",
+ "LinearMath/btGeometryUtil.cpp",
+ "LinearMath/btPolarDecomposition.cpp",
+ "LinearMath/btQuickprof.cpp",
+ "LinearMath/btSerializer.cpp",
+ "LinearMath/btSerializer64.cpp",
+ "LinearMath/btThreads.cpp",
+ "LinearMath/btVector3.cpp",
+ "LinearMath/TaskScheduler/btTaskScheduler.cpp",
+ "LinearMath/TaskScheduler/btThreadSupportPosix.cpp",
+ "LinearMath/TaskScheduler/btThreadSupportWin32.cpp",
]
thirdparty_sources = [thirdparty_dir + file for file in bullet2_src]
# Treat Bullet headers as system headers to avoid raising warnings. Not supported on MSVC.
if not env.msvc:
- env_bullet.Append(CPPFLAGS=['-isystem', Dir(thirdparty_dir).path])
+ env_bullet.Append(CPPFLAGS=["-isystem", Dir(thirdparty_dir).path])
else:
env_bullet.Prepend(CPPPATH=[thirdparty_dir])
# if env['target'] == "debug" or env['target'] == "release_debug":
diff --git a/modules/bullet/area_bullet.cpp b/modules/bullet/area_bullet.cpp
index e8a5c1475a..4d727529ef 100644
--- a/modules/bullet/area_bullet.cpp
+++ b/modules/bullet/area_bullet.cpp
@@ -46,7 +46,7 @@
AreaBullet::AreaBullet() :
RigidCollisionObjectBullet(CollisionObjectBullet::TYPE_AREA),
monitorable(true),
- spOv_mode(PhysicsServer::AREA_SPACE_OVERRIDE_DISABLED),
+ spOv_mode(PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED),
spOv_gravityPoint(false),
spOv_gravityPointDistanceScale(0),
spOv_gravityPointAttenuation(1),
@@ -86,11 +86,11 @@ void AreaBullet::dispatch_callbacks() {
switch (otherObj.state) {
case OVERLAP_STATE_ENTER:
otherObj.state = OVERLAP_STATE_INSIDE;
- call_event(otherObj.object, PhysicsServer::AREA_BODY_ADDED);
+ call_event(otherObj.object, PhysicsServer3D::AREA_BODY_ADDED);
otherObj.object->on_enter_area(this);
break;
case OVERLAP_STATE_EXIT:
- call_event(otherObj.object, PhysicsServer::AREA_BODY_REMOVED);
+ call_event(otherObj.object, PhysicsServer3D::AREA_BODY_REMOVED);
otherObj.object->on_exit_area(this);
overlappingObjects.remove(i); // Remove after callback
break;
@@ -101,7 +101,7 @@ void AreaBullet::dispatch_callbacks() {
}
}
-void AreaBullet::call_event(CollisionObjectBullet *p_otherObject, PhysicsServer::AreaBodyStatus p_status) {
+void AreaBullet::call_event(CollisionObjectBullet *p_otherObject, PhysicsServer3D::AreaBodyStatus p_status) {
InOutEventCallback &event = eventsCallbacks[static_cast<int>(p_otherObject->getType())];
Object *areaGodoObject = ObjectDB::get_instance(event.event_callback_id);
@@ -130,7 +130,7 @@ void AreaBullet::scratch() {
void AreaBullet::clear_overlaps(bool p_notify) {
for (int i = overlappingObjects.size() - 1; 0 <= i; --i) {
if (p_notify)
- call_event(overlappingObjects[i].object, PhysicsServer::AREA_BODY_REMOVED);
+ call_event(overlappingObjects[i].object, PhysicsServer3D::AREA_BODY_REMOVED);
overlappingObjects[i].object->on_exit_area(this);
}
overlappingObjects.clear();
@@ -140,7 +140,7 @@ void AreaBullet::remove_overlap(CollisionObjectBullet *p_object, bool p_notify)
for (int i = overlappingObjects.size() - 1; 0 <= i; --i) {
if (overlappingObjects[i].object == p_object) {
if (p_notify)
- call_event(overlappingObjects[i].object, PhysicsServer::AREA_BODY_REMOVED);
+ call_event(overlappingObjects[i].object, PhysicsServer3D::AREA_BODY_REMOVED);
overlappingObjects[i].object->on_exit_area(this);
overlappingObjects.remove(i);
break;
@@ -218,30 +218,30 @@ void AreaBullet::put_overlap_as_inside(int p_index) {
}
}
-void AreaBullet::set_param(PhysicsServer::AreaParameter p_param, const Variant &p_value) {
+void AreaBullet::set_param(PhysicsServer3D::AreaParameter p_param, const Variant &p_value) {
switch (p_param) {
- case PhysicsServer::AREA_PARAM_GRAVITY:
+ case PhysicsServer3D::AREA_PARAM_GRAVITY:
set_spOv_gravityMag(p_value);
break;
- case PhysicsServer::AREA_PARAM_GRAVITY_VECTOR:
+ case PhysicsServer3D::AREA_PARAM_GRAVITY_VECTOR:
set_spOv_gravityVec(p_value);
break;
- case PhysicsServer::AREA_PARAM_LINEAR_DAMP:
+ case PhysicsServer3D::AREA_PARAM_LINEAR_DAMP:
set_spOv_linearDump(p_value);
break;
- case PhysicsServer::AREA_PARAM_ANGULAR_DAMP:
+ case PhysicsServer3D::AREA_PARAM_ANGULAR_DAMP:
set_spOv_angularDump(p_value);
break;
- case PhysicsServer::AREA_PARAM_PRIORITY:
+ case PhysicsServer3D::AREA_PARAM_PRIORITY:
set_spOv_priority(p_value);
break;
- case PhysicsServer::AREA_PARAM_GRAVITY_IS_POINT:
+ case PhysicsServer3D::AREA_PARAM_GRAVITY_IS_POINT:
set_spOv_gravityPoint(p_value);
break;
- case PhysicsServer::AREA_PARAM_GRAVITY_DISTANCE_SCALE:
+ case PhysicsServer3D::AREA_PARAM_GRAVITY_DISTANCE_SCALE:
set_spOv_gravityPointDistanceScale(p_value);
break;
- case PhysicsServer::AREA_PARAM_GRAVITY_POINT_ATTENUATION:
+ case PhysicsServer3D::AREA_PARAM_GRAVITY_POINT_ATTENUATION:
set_spOv_gravityPointAttenuation(p_value);
break;
default:
@@ -249,23 +249,23 @@ void AreaBullet::set_param(PhysicsServer::AreaParameter p_param, const Variant &
}
}
-Variant AreaBullet::get_param(PhysicsServer::AreaParameter p_param) const {
+Variant AreaBullet::get_param(PhysicsServer3D::AreaParameter p_param) const {
switch (p_param) {
- case PhysicsServer::AREA_PARAM_GRAVITY:
+ case PhysicsServer3D::AREA_PARAM_GRAVITY:
return spOv_gravityMag;
- case PhysicsServer::AREA_PARAM_GRAVITY_VECTOR:
+ case PhysicsServer3D::AREA_PARAM_GRAVITY_VECTOR:
return spOv_gravityVec;
- case PhysicsServer::AREA_PARAM_LINEAR_DAMP:
+ case PhysicsServer3D::AREA_PARAM_LINEAR_DAMP:
return spOv_linearDump;
- case PhysicsServer::AREA_PARAM_ANGULAR_DAMP:
+ case PhysicsServer3D::AREA_PARAM_ANGULAR_DAMP:
return spOv_angularDump;
- case PhysicsServer::AREA_PARAM_PRIORITY:
+ case PhysicsServer3D::AREA_PARAM_PRIORITY:
return spOv_priority;
- case PhysicsServer::AREA_PARAM_GRAVITY_IS_POINT:
+ case PhysicsServer3D::AREA_PARAM_GRAVITY_IS_POINT:
return spOv_gravityPoint;
- case PhysicsServer::AREA_PARAM_GRAVITY_DISTANCE_SCALE:
+ case PhysicsServer3D::AREA_PARAM_GRAVITY_DISTANCE_SCALE:
return spOv_gravityPointDistanceScale;
- case PhysicsServer::AREA_PARAM_GRAVITY_POINT_ATTENUATION:
+ case PhysicsServer3D::AREA_PARAM_GRAVITY_POINT_ATTENUATION:
return spOv_gravityPointAttenuation;
default:
WARN_PRINT("Area doesn't support this parameter in the Bullet backend: " + itos(p_param));
diff --git a/modules/bullet/area_bullet.h b/modules/bullet/area_bullet.h
index 18888c6725..0272350510 100644
--- a/modules/bullet/area_bullet.h
+++ b/modules/bullet/area_bullet.h
@@ -33,7 +33,7 @@
#include "collision_object_bullet.h"
#include "core/vector.h"
-#include "servers/physics_server.h"
+#include "servers/physics_server_3d.h"
#include "space_bullet.h"
/**
@@ -65,7 +65,7 @@ public:
OverlapState state;
OverlappingObjectData() :
- object(NULL),
+ object(nullptr),
state(OVERLAP_STATE_ENTER) {}
OverlappingObjectData(CollisionObjectBullet *p_object, OverlapState p_state) :
object(p_object),
@@ -88,7 +88,7 @@ private:
Vector<OverlappingObjectData> overlappingObjects;
bool monitorable;
- PhysicsServer::AreaSpaceOverrideMode spOv_mode;
+ PhysicsServer3D::AreaSpaceOverrideMode spOv_mode;
bool spOv_gravityPoint;
real_t spOv_gravityPointDistanceScale;
real_t spOv_gravityPointAttenuation;
@@ -114,8 +114,8 @@ public:
bool is_monitoring() const;
- _FORCE_INLINE_ void set_spOv_mode(PhysicsServer::AreaSpaceOverrideMode p_mode) { spOv_mode = p_mode; }
- _FORCE_INLINE_ PhysicsServer::AreaSpaceOverrideMode get_spOv_mode() { return spOv_mode; }
+ _FORCE_INLINE_ void set_spOv_mode(PhysicsServer3D::AreaSpaceOverrideMode p_mode) { spOv_mode = p_mode; }
+ _FORCE_INLINE_ PhysicsServer3D::AreaSpaceOverrideMode get_spOv_mode() { return spOv_mode; }
_FORCE_INLINE_ void set_spOv_gravityPoint(bool p_isGP) { spOv_gravityPoint = p_isGP; }
_FORCE_INLINE_ bool is_spOv_gravityPoint() { return spOv_gravityPoint; }
@@ -146,7 +146,7 @@ public:
virtual void set_space(SpaceBullet *p_space);
virtual void dispatch_callbacks();
- void call_event(CollisionObjectBullet *p_otherObject, PhysicsServer::AreaBodyStatus p_status);
+ void call_event(CollisionObjectBullet *p_otherObject, PhysicsServer3D::AreaBodyStatus p_status);
void set_on_state_change(ObjectID p_id, const StringName &p_method, const Variant &p_udata = Variant());
void scratch();
@@ -162,8 +162,8 @@ public:
void put_overlap_as_exit(int p_index);
void put_overlap_as_inside(int p_index);
- void set_param(PhysicsServer::AreaParameter p_param, const Variant &p_value);
- Variant get_param(PhysicsServer::AreaParameter p_param) const;
+ void set_param(PhysicsServer3D::AreaParameter p_param, const Variant &p_value);
+ Variant get_param(PhysicsServer3D::AreaParameter p_param) const;
void set_event_callback(Type p_callbackObjectType, ObjectID p_id, const StringName &p_method);
bool has_event_callback(Type p_callbackObjectType);
diff --git a/modules/bullet/btRayShape.cpp b/modules/bullet/btRayShape.cpp
index 4071723a3e..0f54f848dc 100644
--- a/modules/bullet/btRayShape.cpp
+++ b/modules/bullet/btRayShape.cpp
@@ -43,6 +43,7 @@ btRayShape::btRayShape(btScalar length) :
m_shapeAxis(0, 0, 1) {
m_shapeType = CUSTOM_CONVEX_SHAPE_TYPE;
setLength(length);
+ slipsOnSlope = false;
}
btRayShape::~btRayShape() {
diff --git a/modules/bullet/bullet_physics_server.cpp b/modules/bullet/bullet_physics_server.cpp
index 89868babc6..2705c749a2 100644
--- a/modules/bullet/bullet_physics_server.cpp
+++ b/modules/bullet/bullet_physics_server.cpp
@@ -74,19 +74,19 @@
body->get_space()->add_constraint(joint, joint->is_disabled_collisions_between_bodies());
// <--------------- Joint creation asserts
-void BulletPhysicsServer::_bind_methods() {
- //ClassDB::bind_method(D_METHOD("DoTest"), &BulletPhysicsServer::DoTest);
+void BulletPhysicsServer3D::_bind_methods() {
+ //ClassDB::bind_method(D_METHOD("DoTest"), &BulletPhysicsServer3D::DoTest);
}
-BulletPhysicsServer::BulletPhysicsServer() :
- PhysicsServer(),
+BulletPhysicsServer3D::BulletPhysicsServer3D() :
+ PhysicsServer3D(),
active(true),
active_spaces_count(0) {}
-BulletPhysicsServer::~BulletPhysicsServer() {}
+BulletPhysicsServer3D::~BulletPhysicsServer3D() {}
-RID BulletPhysicsServer::shape_create(ShapeType p_shape) {
- ShapeBullet *shape = NULL;
+RID BulletPhysicsServer3D::shape_create(ShapeType p_shape) {
+ ShapeBullet *shape = nullptr;
switch (p_shape) {
case SHAPE_PLANE: {
@@ -133,51 +133,51 @@ RID BulletPhysicsServer::shape_create(ShapeType p_shape) {
CreateThenReturnRID(shape_owner, shape)
}
-void BulletPhysicsServer::shape_set_data(RID p_shape, const Variant &p_data) {
+void BulletPhysicsServer3D::shape_set_data(RID p_shape, const Variant &p_data) {
ShapeBullet *shape = shape_owner.getornull(p_shape);
ERR_FAIL_COND(!shape);
shape->set_data(p_data);
}
-void BulletPhysicsServer::shape_set_custom_solver_bias(RID p_shape, real_t p_bias) {
+void BulletPhysicsServer3D::shape_set_custom_solver_bias(RID p_shape, real_t p_bias) {
//WARN_PRINT("Bias not supported by Bullet physics engine");
}
-PhysicsServer::ShapeType BulletPhysicsServer::shape_get_type(RID p_shape) const {
+PhysicsServer3D::ShapeType BulletPhysicsServer3D::shape_get_type(RID p_shape) const {
ShapeBullet *shape = shape_owner.getornull(p_shape);
- ERR_FAIL_COND_V(!shape, PhysicsServer::SHAPE_CUSTOM);
+ ERR_FAIL_COND_V(!shape, PhysicsServer3D::SHAPE_CUSTOM);
return shape->get_type();
}
-Variant BulletPhysicsServer::shape_get_data(RID p_shape) const {
+Variant BulletPhysicsServer3D::shape_get_data(RID p_shape) const {
ShapeBullet *shape = shape_owner.getornull(p_shape);
ERR_FAIL_COND_V(!shape, Variant());
return shape->get_data();
}
-void BulletPhysicsServer::shape_set_margin(RID p_shape, real_t p_margin) {
+void BulletPhysicsServer3D::shape_set_margin(RID p_shape, real_t p_margin) {
ShapeBullet *shape = shape_owner.getornull(p_shape);
ERR_FAIL_COND(!shape);
shape->set_margin(p_margin);
}
-real_t BulletPhysicsServer::shape_get_margin(RID p_shape) const {
+real_t BulletPhysicsServer3D::shape_get_margin(RID p_shape) const {
ShapeBullet *shape = shape_owner.getornull(p_shape);
ERR_FAIL_COND_V(!shape, 0.0);
return shape->get_margin();
}
-real_t BulletPhysicsServer::shape_get_custom_solver_bias(RID p_shape) const {
+real_t BulletPhysicsServer3D::shape_get_custom_solver_bias(RID p_shape) const {
//WARN_PRINT("Bias not supported by Bullet physics engine");
return 0.;
}
-RID BulletPhysicsServer::space_create() {
+RID BulletPhysicsServer3D::space_create() {
SpaceBullet *space = bulletnew(SpaceBullet);
CreateThenReturnRID(space_owner, space);
}
-void BulletPhysicsServer::space_set_active(RID p_space, bool p_active) {
+void BulletPhysicsServer3D::space_set_active(RID p_space, bool p_active) {
SpaceBullet *space = space_owner.getornull(p_space);
ERR_FAIL_COND(!space);
@@ -195,64 +195,64 @@ void BulletPhysicsServer::space_set_active(RID p_space, bool p_active) {
}
}
-bool BulletPhysicsServer::space_is_active(RID p_space) const {
+bool BulletPhysicsServer3D::space_is_active(RID p_space) const {
SpaceBullet *space = space_owner.getornull(p_space);
ERR_FAIL_COND_V(!space, false);
return -1 != active_spaces.find(space);
}
-void BulletPhysicsServer::space_set_param(RID p_space, SpaceParameter p_param, real_t p_value) {
+void BulletPhysicsServer3D::space_set_param(RID p_space, SpaceParameter p_param, real_t p_value) {
SpaceBullet *space = space_owner.getornull(p_space);
ERR_FAIL_COND(!space);
space->set_param(p_param, p_value);
}
-real_t BulletPhysicsServer::space_get_param(RID p_space, SpaceParameter p_param) const {
+real_t BulletPhysicsServer3D::space_get_param(RID p_space, SpaceParameter p_param) const {
SpaceBullet *space = space_owner.getornull(p_space);
ERR_FAIL_COND_V(!space, 0);
return space->get_param(p_param);
}
-PhysicsDirectSpaceState *BulletPhysicsServer::space_get_direct_state(RID p_space) {
+PhysicsDirectSpaceState3D *BulletPhysicsServer3D::space_get_direct_state(RID p_space) {
SpaceBullet *space = space_owner.getornull(p_space);
- ERR_FAIL_COND_V(!space, NULL);
+ ERR_FAIL_COND_V(!space, nullptr);
return space->get_direct_state();
}
-void BulletPhysicsServer::space_set_debug_contacts(RID p_space, int p_max_contacts) {
+void BulletPhysicsServer3D::space_set_debug_contacts(RID p_space, int p_max_contacts) {
SpaceBullet *space = space_owner.getornull(p_space);
ERR_FAIL_COND(!space);
space->set_debug_contacts(p_max_contacts);
}
-Vector<Vector3> BulletPhysicsServer::space_get_contacts(RID p_space) const {
+Vector<Vector3> BulletPhysicsServer3D::space_get_contacts(RID p_space) const {
SpaceBullet *space = space_owner.getornull(p_space);
ERR_FAIL_COND_V(!space, Vector<Vector3>());
return space->get_debug_contacts();
}
-int BulletPhysicsServer::space_get_contact_count(RID p_space) const {
+int BulletPhysicsServer3D::space_get_contact_count(RID p_space) const {
SpaceBullet *space = space_owner.getornull(p_space);
ERR_FAIL_COND_V(!space, 0);
return space->get_debug_contact_count();
}
-RID BulletPhysicsServer::area_create() {
+RID BulletPhysicsServer3D::area_create() {
AreaBullet *area = bulletnew(AreaBullet);
area->set_collision_layer(1);
area->set_collision_mask(1);
CreateThenReturnRID(area_owner, area)
}
-void BulletPhysicsServer::area_set_space(RID p_area, RID p_space) {
+void BulletPhysicsServer3D::area_set_space(RID p_area, RID p_space) {
AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
- SpaceBullet *space = NULL;
+ SpaceBullet *space = nullptr;
if (p_space.is_valid()) {
space = space_owner.getornull(p_space);
ERR_FAIL_COND(!space);
@@ -260,26 +260,26 @@ void BulletPhysicsServer::area_set_space(RID p_area, RID p_space) {
area->set_space(space);
}
-RID BulletPhysicsServer::area_get_space(RID p_area) const {
+RID BulletPhysicsServer3D::area_get_space(RID p_area) const {
AreaBullet *area = area_owner.getornull(p_area);
return area->get_space()->get_self();
}
-void BulletPhysicsServer::area_set_space_override_mode(RID p_area, AreaSpaceOverrideMode p_mode) {
+void BulletPhysicsServer3D::area_set_space_override_mode(RID p_area, AreaSpaceOverrideMode p_mode) {
AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
area->set_spOv_mode(p_mode);
}
-PhysicsServer::AreaSpaceOverrideMode BulletPhysicsServer::area_get_space_override_mode(RID p_area) const {
+PhysicsServer3D::AreaSpaceOverrideMode BulletPhysicsServer3D::area_get_space_override_mode(RID p_area) const {
AreaBullet *area = area_owner.getornull(p_area);
- ERR_FAIL_COND_V(!area, PhysicsServer::AREA_SPACE_OVERRIDE_DISABLED);
+ ERR_FAIL_COND_V(!area, PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED);
return area->get_spOv_mode();
}
-void BulletPhysicsServer::area_add_shape(RID p_area, RID p_shape, const Transform &p_transform, bool p_disabled) {
+void BulletPhysicsServer3D::area_add_shape(RID p_area, RID p_shape, const Transform &p_transform, bool p_disabled) {
AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
@@ -289,7 +289,7 @@ void BulletPhysicsServer::area_add_shape(RID p_area, RID p_shape, const Transfor
area->add_shape(shape, p_transform, p_disabled);
}
-void BulletPhysicsServer::area_set_shape(RID p_area, int p_shape_idx, RID p_shape) {
+void BulletPhysicsServer3D::area_set_shape(RID p_area, int p_shape_idx, RID p_shape) {
AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
@@ -299,41 +299,41 @@ void BulletPhysicsServer::area_set_shape(RID p_area, int p_shape_idx, RID p_shap
area->set_shape(p_shape_idx, shape);
}
-void BulletPhysicsServer::area_set_shape_transform(RID p_area, int p_shape_idx, const Transform &p_transform) {
+void BulletPhysicsServer3D::area_set_shape_transform(RID p_area, int p_shape_idx, const Transform &p_transform) {
AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
area->set_shape_transform(p_shape_idx, p_transform);
}
-int BulletPhysicsServer::area_get_shape_count(RID p_area) const {
+int BulletPhysicsServer3D::area_get_shape_count(RID p_area) const {
AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND_V(!area, 0);
return area->get_shape_count();
}
-RID BulletPhysicsServer::area_get_shape(RID p_area, int p_shape_idx) const {
+RID BulletPhysicsServer3D::area_get_shape(RID p_area, int p_shape_idx) const {
AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND_V(!area, RID());
return area->get_shape(p_shape_idx)->get_self();
}
-Transform BulletPhysicsServer::area_get_shape_transform(RID p_area, int p_shape_idx) const {
+Transform BulletPhysicsServer3D::area_get_shape_transform(RID p_area, int p_shape_idx) const {
AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND_V(!area, Transform());
return area->get_shape_transform(p_shape_idx);
}
-void BulletPhysicsServer::area_remove_shape(RID p_area, int p_shape_idx) {
+void BulletPhysicsServer3D::area_remove_shape(RID p_area, int p_shape_idx) {
AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
return area->remove_shape_full(p_shape_idx);
}
-void BulletPhysicsServer::area_clear_shapes(RID p_area) {
+void BulletPhysicsServer3D::area_clear_shapes(RID p_area) {
AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
@@ -341,14 +341,14 @@ void BulletPhysicsServer::area_clear_shapes(RID p_area) {
area->remove_shape_full(0);
}
-void BulletPhysicsServer::area_set_shape_disabled(RID p_area, int p_shape_idx, bool p_disabled) {
+void BulletPhysicsServer3D::area_set_shape_disabled(RID p_area, int p_shape_idx, bool p_disabled) {
AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
area->set_shape_disabled(p_shape_idx, p_disabled);
}
-void BulletPhysicsServer::area_attach_object_instance_id(RID p_area, ObjectID p_id) {
+void BulletPhysicsServer3D::area_attach_object_instance_id(RID p_area, ObjectID p_id) {
if (space_owner.owns(p_area)) {
return;
}
@@ -357,7 +357,7 @@ void BulletPhysicsServer::area_attach_object_instance_id(RID p_area, ObjectID p_
area->set_instance_id(p_id);
}
-ObjectID BulletPhysicsServer::area_get_object_instance_id(RID p_area) const {
+ObjectID BulletPhysicsServer3D::area_get_object_instance_id(RID p_area) const {
if (space_owner.owns(p_area)) {
return ObjectID();
}
@@ -366,7 +366,7 @@ ObjectID BulletPhysicsServer::area_get_object_instance_id(RID p_area) const {
return area->get_instance_id();
}
-void BulletPhysicsServer::area_set_param(RID p_area, AreaParameter p_param, const Variant &p_value) {
+void BulletPhysicsServer3D::area_set_param(RID p_area, AreaParameter p_param, const Variant &p_value) {
if (space_owner.owns(p_area)) {
SpaceBullet *space = space_owner.getornull(p_area);
if (space) {
@@ -381,7 +381,7 @@ void BulletPhysicsServer::area_set_param(RID p_area, AreaParameter p_param, cons
}
}
-Variant BulletPhysicsServer::area_get_param(RID p_area, AreaParameter p_param) const {
+Variant BulletPhysicsServer3D::area_get_param(RID p_area, AreaParameter p_param) const {
if (space_owner.owns(p_area)) {
SpaceBullet *space = space_owner.getornull(p_area);
return space->get_param(p_param);
@@ -393,64 +393,64 @@ Variant BulletPhysicsServer::area_get_param(RID p_area, AreaParameter p_param) c
}
}
-void BulletPhysicsServer::area_set_transform(RID p_area, const Transform &p_transform) {
+void BulletPhysicsServer3D::area_set_transform(RID p_area, const Transform &p_transform) {
AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
area->set_transform(p_transform);
}
-Transform BulletPhysicsServer::area_get_transform(RID p_area) const {
+Transform BulletPhysicsServer3D::area_get_transform(RID p_area) const {
AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND_V(!area, Transform());
return area->get_transform();
}
-void BulletPhysicsServer::area_set_collision_mask(RID p_area, uint32_t p_mask) {
+void BulletPhysicsServer3D::area_set_collision_mask(RID p_area, uint32_t p_mask) {
AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
area->set_collision_mask(p_mask);
}
-void BulletPhysicsServer::area_set_collision_layer(RID p_area, uint32_t p_layer) {
+void BulletPhysicsServer3D::area_set_collision_layer(RID p_area, uint32_t p_layer) {
AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
area->set_collision_layer(p_layer);
}
-void BulletPhysicsServer::area_set_monitorable(RID p_area, bool p_monitorable) {
+void BulletPhysicsServer3D::area_set_monitorable(RID p_area, bool p_monitorable) {
AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
area->set_monitorable(p_monitorable);
}
-void BulletPhysicsServer::area_set_monitor_callback(RID p_area, Object *p_receiver, const StringName &p_method) {
+void BulletPhysicsServer3D::area_set_monitor_callback(RID p_area, Object *p_receiver, const StringName &p_method) {
AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
area->set_event_callback(CollisionObjectBullet::TYPE_RIGID_BODY, p_receiver ? p_receiver->get_instance_id() : ObjectID(), p_method);
}
-void BulletPhysicsServer::area_set_area_monitor_callback(RID p_area, Object *p_receiver, const StringName &p_method) {
+void BulletPhysicsServer3D::area_set_area_monitor_callback(RID p_area, Object *p_receiver, const StringName &p_method) {
AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
area->set_event_callback(CollisionObjectBullet::TYPE_AREA, p_receiver ? p_receiver->get_instance_id() : ObjectID(), p_method);
}
-void BulletPhysicsServer::area_set_ray_pickable(RID p_area, bool p_enable) {
+void BulletPhysicsServer3D::area_set_ray_pickable(RID p_area, bool p_enable) {
AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
area->set_ray_pickable(p_enable);
}
-bool BulletPhysicsServer::area_is_ray_pickable(RID p_area) const {
+bool BulletPhysicsServer3D::area_is_ray_pickable(RID p_area) const {
AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND_V(!area, false);
return area->is_ray_pickable();
}
-RID BulletPhysicsServer::body_create(BodyMode p_mode, bool p_init_sleeping) {
+RID BulletPhysicsServer3D::body_create(BodyMode p_mode, bool p_init_sleeping) {
RigidBodyBullet *body = bulletnew(RigidBodyBullet);
body->set_mode(p_mode);
body->set_collision_layer(1);
@@ -460,10 +460,10 @@ RID BulletPhysicsServer::body_create(BodyMode p_mode, bool p_init_sleeping) {
CreateThenReturnRID(rigid_body_owner, body);
}
-void BulletPhysicsServer::body_set_space(RID p_body, RID p_space) {
+void BulletPhysicsServer3D::body_set_space(RID p_body, RID p_space) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
- SpaceBullet *space = NULL;
+ SpaceBullet *space = nullptr;
if (p_space.is_valid()) {
space = space_owner.getornull(p_space);
@@ -476,7 +476,7 @@ void BulletPhysicsServer::body_set_space(RID p_body, RID p_space) {
body->set_space(space);
}
-RID BulletPhysicsServer::body_get_space(RID p_body) const {
+RID BulletPhysicsServer3D::body_get_space(RID p_body) const {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, RID());
@@ -486,19 +486,19 @@ RID BulletPhysicsServer::body_get_space(RID p_body) const {
return space->get_self();
}
-void BulletPhysicsServer::body_set_mode(RID p_body, PhysicsServer::BodyMode p_mode) {
+void BulletPhysicsServer3D::body_set_mode(RID p_body, PhysicsServer3D::BodyMode p_mode) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_mode(p_mode);
}
-PhysicsServer::BodyMode BulletPhysicsServer::body_get_mode(RID p_body) const {
+PhysicsServer3D::BodyMode BulletPhysicsServer3D::body_get_mode(RID p_body) const {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, BODY_MODE_STATIC);
return body->get_mode();
}
-void BulletPhysicsServer::body_add_shape(RID p_body, RID p_shape, const Transform &p_transform, bool p_disabled) {
+void BulletPhysicsServer3D::body_add_shape(RID p_body, RID p_shape, const Transform &p_transform, bool p_disabled) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -509,7 +509,7 @@ void BulletPhysicsServer::body_add_shape(RID p_body, RID p_shape, const Transfor
body->add_shape(shape, p_transform, p_disabled);
}
-void BulletPhysicsServer::body_set_shape(RID p_body, int p_shape_idx, RID p_shape) {
+void BulletPhysicsServer3D::body_set_shape(RID p_body, int p_shape_idx, RID p_shape) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -519,20 +519,20 @@ void BulletPhysicsServer::body_set_shape(RID p_body, int p_shape_idx, RID p_shap
body->set_shape(p_shape_idx, shape);
}
-void BulletPhysicsServer::body_set_shape_transform(RID p_body, int p_shape_idx, const Transform &p_transform) {
+void BulletPhysicsServer3D::body_set_shape_transform(RID p_body, int p_shape_idx, const Transform &p_transform) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_shape_transform(p_shape_idx, p_transform);
}
-int BulletPhysicsServer::body_get_shape_count(RID p_body) const {
+int BulletPhysicsServer3D::body_get_shape_count(RID p_body) const {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0);
return body->get_shape_count();
}
-RID BulletPhysicsServer::body_get_shape(RID p_body, int p_shape_idx) const {
+RID BulletPhysicsServer3D::body_get_shape(RID p_body, int p_shape_idx) const {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, RID());
@@ -542,113 +542,113 @@ RID BulletPhysicsServer::body_get_shape(RID p_body, int p_shape_idx) const {
return shape->get_self();
}
-Transform BulletPhysicsServer::body_get_shape_transform(RID p_body, int p_shape_idx) const {
+Transform BulletPhysicsServer3D::body_get_shape_transform(RID p_body, int p_shape_idx) const {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, Transform());
return body->get_shape_transform(p_shape_idx);
}
-void BulletPhysicsServer::body_set_shape_disabled(RID p_body, int p_shape_idx, bool p_disabled) {
+void BulletPhysicsServer3D::body_set_shape_disabled(RID p_body, int p_shape_idx, bool p_disabled) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_shape_disabled(p_shape_idx, p_disabled);
}
-void BulletPhysicsServer::body_remove_shape(RID p_body, int p_shape_idx) {
+void BulletPhysicsServer3D::body_remove_shape(RID p_body, int p_shape_idx) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->remove_shape_full(p_shape_idx);
}
-void BulletPhysicsServer::body_clear_shapes(RID p_body) {
+void BulletPhysicsServer3D::body_clear_shapes(RID p_body) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->remove_all_shapes();
}
-void BulletPhysicsServer::body_attach_object_instance_id(RID p_body, ObjectID p_id) {
+void BulletPhysicsServer3D::body_attach_object_instance_id(RID p_body, ObjectID p_id) {
CollisionObjectBullet *body = get_collisin_object(p_body);
ERR_FAIL_COND(!body);
body->set_instance_id(p_id);
}
-ObjectID BulletPhysicsServer::body_get_object_instance_id(RID p_body) const {
+ObjectID BulletPhysicsServer3D::body_get_object_instance_id(RID p_body) const {
CollisionObjectBullet *body = get_collisin_object(p_body);
ERR_FAIL_COND_V(!body, ObjectID());
return body->get_instance_id();
}
-void BulletPhysicsServer::body_set_enable_continuous_collision_detection(RID p_body, bool p_enable) {
+void BulletPhysicsServer3D::body_set_enable_continuous_collision_detection(RID p_body, bool p_enable) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_continuous_collision_detection(p_enable);
}
-bool BulletPhysicsServer::body_is_continuous_collision_detection_enabled(RID p_body) const {
+bool BulletPhysicsServer3D::body_is_continuous_collision_detection_enabled(RID p_body) const {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, false);
return body->is_continuous_collision_detection_enabled();
}
-void BulletPhysicsServer::body_set_collision_layer(RID p_body, uint32_t p_layer) {
+void BulletPhysicsServer3D::body_set_collision_layer(RID p_body, uint32_t p_layer) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_collision_layer(p_layer);
}
-uint32_t BulletPhysicsServer::body_get_collision_layer(RID p_body) const {
+uint32_t BulletPhysicsServer3D::body_get_collision_layer(RID p_body) const {
const RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0);
return body->get_collision_layer();
}
-void BulletPhysicsServer::body_set_collision_mask(RID p_body, uint32_t p_mask) {
+void BulletPhysicsServer3D::body_set_collision_mask(RID p_body, uint32_t p_mask) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_collision_mask(p_mask);
}
-uint32_t BulletPhysicsServer::body_get_collision_mask(RID p_body) const {
+uint32_t BulletPhysicsServer3D::body_get_collision_mask(RID p_body) const {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0);
return body->get_collision_mask();
}
-void BulletPhysicsServer::body_set_user_flags(RID p_body, uint32_t p_flags) {
+void BulletPhysicsServer3D::body_set_user_flags(RID p_body, uint32_t p_flags) {
// This function si not currently supported
}
-uint32_t BulletPhysicsServer::body_get_user_flags(RID p_body) const {
+uint32_t BulletPhysicsServer3D::body_get_user_flags(RID p_body) const {
// This function si not currently supported
return 0;
}
-void BulletPhysicsServer::body_set_param(RID p_body, BodyParameter p_param, float p_value) {
+void BulletPhysicsServer3D::body_set_param(RID p_body, BodyParameter p_param, float p_value) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_param(p_param, p_value);
}
-float BulletPhysicsServer::body_get_param(RID p_body, BodyParameter p_param) const {
+float BulletPhysicsServer3D::body_get_param(RID p_body, BodyParameter p_param) const {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0);
return body->get_param(p_param);
}
-void BulletPhysicsServer::body_set_kinematic_safe_margin(RID p_body, real_t p_margin) {
+void BulletPhysicsServer3D::body_set_kinematic_safe_margin(RID p_body, real_t p_margin) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -658,7 +658,7 @@ void BulletPhysicsServer::body_set_kinematic_safe_margin(RID p_body, real_t p_ma
}
}
-real_t BulletPhysicsServer::body_get_kinematic_safe_margin(RID p_body) const {
+real_t BulletPhysicsServer3D::body_get_kinematic_safe_margin(RID p_body) const {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0);
@@ -670,90 +670,90 @@ real_t BulletPhysicsServer::body_get_kinematic_safe_margin(RID p_body) const {
return 0;
}
-void BulletPhysicsServer::body_set_state(RID p_body, BodyState p_state, const Variant &p_variant) {
+void BulletPhysicsServer3D::body_set_state(RID p_body, BodyState p_state, const Variant &p_variant) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_state(p_state, p_variant);
}
-Variant BulletPhysicsServer::body_get_state(RID p_body, BodyState p_state) const {
+Variant BulletPhysicsServer3D::body_get_state(RID p_body, BodyState p_state) const {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, Variant());
return body->get_state(p_state);
}
-void BulletPhysicsServer::body_set_applied_force(RID p_body, const Vector3 &p_force) {
+void BulletPhysicsServer3D::body_set_applied_force(RID p_body, const Vector3 &p_force) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_applied_force(p_force);
}
-Vector3 BulletPhysicsServer::body_get_applied_force(RID p_body) const {
+Vector3 BulletPhysicsServer3D::body_get_applied_force(RID p_body) const {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, Vector3());
return body->get_applied_force();
}
-void BulletPhysicsServer::body_set_applied_torque(RID p_body, const Vector3 &p_torque) {
+void BulletPhysicsServer3D::body_set_applied_torque(RID p_body, const Vector3 &p_torque) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_applied_torque(p_torque);
}
-Vector3 BulletPhysicsServer::body_get_applied_torque(RID p_body) const {
+Vector3 BulletPhysicsServer3D::body_get_applied_torque(RID p_body) const {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, Vector3());
return body->get_applied_torque();
}
-void BulletPhysicsServer::body_add_central_force(RID p_body, const Vector3 &p_force) {
+void BulletPhysicsServer3D::body_add_central_force(RID p_body, const Vector3 &p_force) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->apply_central_force(p_force);
}
-void BulletPhysicsServer::body_add_force(RID p_body, const Vector3 &p_force, const Vector3 &p_pos) {
+void BulletPhysicsServer3D::body_add_force(RID p_body, const Vector3 &p_force, const Vector3 &p_pos) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->apply_force(p_force, p_pos);
}
-void BulletPhysicsServer::body_add_torque(RID p_body, const Vector3 &p_torque) {
+void BulletPhysicsServer3D::body_add_torque(RID p_body, const Vector3 &p_torque) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->apply_torque(p_torque);
}
-void BulletPhysicsServer::body_apply_central_impulse(RID p_body, const Vector3 &p_impulse) {
+void BulletPhysicsServer3D::body_apply_central_impulse(RID p_body, const Vector3 &p_impulse) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->apply_central_impulse(p_impulse);
}
-void BulletPhysicsServer::body_apply_impulse(RID p_body, const Vector3 &p_pos, const Vector3 &p_impulse) {
+void BulletPhysicsServer3D::body_apply_impulse(RID p_body, const Vector3 &p_pos, const Vector3 &p_impulse) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->apply_impulse(p_pos, p_impulse);
}
-void BulletPhysicsServer::body_apply_torque_impulse(RID p_body, const Vector3 &p_impulse) {
+void BulletPhysicsServer3D::body_apply_torque_impulse(RID p_body, const Vector3 &p_impulse) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->apply_torque_impulse(p_impulse);
}
-void BulletPhysicsServer::body_set_axis_velocity(RID p_body, const Vector3 &p_axis_velocity) {
+void BulletPhysicsServer3D::body_set_axis_velocity(RID p_body, const Vector3 &p_axis_velocity) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -764,19 +764,19 @@ void BulletPhysicsServer::body_set_axis_velocity(RID p_body, const Vector3 &p_ax
body->set_linear_velocity(v);
}
-void BulletPhysicsServer::body_set_axis_lock(RID p_body, BodyAxis p_axis, bool p_lock) {
+void BulletPhysicsServer3D::body_set_axis_lock(RID p_body, BodyAxis p_axis, bool p_lock) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_axis_lock(p_axis, p_lock);
}
-bool BulletPhysicsServer::body_is_axis_locked(RID p_body, BodyAxis p_axis) const {
+bool BulletPhysicsServer3D::body_is_axis_locked(RID p_body, BodyAxis p_axis) const {
const RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0);
return body->is_axis_locked(p_axis);
}
-void BulletPhysicsServer::body_add_collision_exception(RID p_body, RID p_body_b) {
+void BulletPhysicsServer3D::body_add_collision_exception(RID p_body, RID p_body_b) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -786,7 +786,7 @@ void BulletPhysicsServer::body_add_collision_exception(RID p_body, RID p_body_b)
body->add_collision_exception(other_body);
}
-void BulletPhysicsServer::body_remove_collision_exception(RID p_body, RID p_body_b) {
+void BulletPhysicsServer3D::body_remove_collision_exception(RID p_body, RID p_body_b) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -796,7 +796,7 @@ void BulletPhysicsServer::body_remove_collision_exception(RID p_body, RID p_body
body->remove_collision_exception(other_body);
}
-void BulletPhysicsServer::body_get_collision_exceptions(RID p_body, List<RID> *p_exceptions) {
+void BulletPhysicsServer3D::body_get_collision_exceptions(RID p_body, List<RID> *p_exceptions) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
for (int i = 0; i < body->get_exceptions().size(); i++) {
@@ -804,68 +804,68 @@ void BulletPhysicsServer::body_get_collision_exceptions(RID p_body, List<RID> *p
}
}
-void BulletPhysicsServer::body_set_max_contacts_reported(RID p_body, int p_contacts) {
+void BulletPhysicsServer3D::body_set_max_contacts_reported(RID p_body, int p_contacts) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_max_collisions_detection(p_contacts);
}
-int BulletPhysicsServer::body_get_max_contacts_reported(RID p_body) const {
+int BulletPhysicsServer3D::body_get_max_contacts_reported(RID p_body) const {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0);
return body->get_max_collisions_detection();
}
-void BulletPhysicsServer::body_set_contacts_reported_depth_threshold(RID p_body, float p_threshold) {
+void BulletPhysicsServer3D::body_set_contacts_reported_depth_threshold(RID p_body, float p_threshold) {
// Not supported by bullet and even Godot
}
-float BulletPhysicsServer::body_get_contacts_reported_depth_threshold(RID p_body) const {
+float BulletPhysicsServer3D::body_get_contacts_reported_depth_threshold(RID p_body) const {
// Not supported by bullet and even Godot
return 0.;
}
-void BulletPhysicsServer::body_set_omit_force_integration(RID p_body, bool p_omit) {
+void BulletPhysicsServer3D::body_set_omit_force_integration(RID p_body, bool p_omit) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_omit_forces_integration(p_omit);
}
-bool BulletPhysicsServer::body_is_omitting_force_integration(RID p_body) const {
+bool BulletPhysicsServer3D::body_is_omitting_force_integration(RID p_body) const {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, false);
return body->get_omit_forces_integration();
}
-void BulletPhysicsServer::body_set_force_integration_callback(RID p_body, Object *p_receiver, const StringName &p_method, const Variant &p_udata) {
+void BulletPhysicsServer3D::body_set_force_integration_callback(RID p_body, Object *p_receiver, const StringName &p_method, const Variant &p_udata) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_force_integration_callback(p_receiver ? p_receiver->get_instance_id() : ObjectID(), p_method, p_udata);
}
-void BulletPhysicsServer::body_set_ray_pickable(RID p_body, bool p_enable) {
+void BulletPhysicsServer3D::body_set_ray_pickable(RID p_body, bool p_enable) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_ray_pickable(p_enable);
}
-bool BulletPhysicsServer::body_is_ray_pickable(RID p_body) const {
+bool BulletPhysicsServer3D::body_is_ray_pickable(RID p_body) const {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, false);
return body->is_ray_pickable();
}
-PhysicsDirectBodyState *BulletPhysicsServer::body_get_direct_state(RID p_body) {
+PhysicsDirectBodyState3D *BulletPhysicsServer3D::body_get_direct_state(RID p_body) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
- ERR_FAIL_COND_V(!body, NULL);
- return BulletPhysicsDirectBodyState::get_singleton(body);
+ ERR_FAIL_COND_V(!body, nullptr);
+ return BulletPhysicsDirectBodyState3D::get_singleton(body);
}
-bool BulletPhysicsServer::body_test_motion(RID p_body, const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia, MotionResult *r_result, bool p_exclude_raycast_shapes) {
+bool BulletPhysicsServer3D::body_test_motion(RID p_body, const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia, MotionResult *r_result, bool p_exclude_raycast_shapes) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, false);
ERR_FAIL_COND_V(!body->get_space(), false);
@@ -873,7 +873,7 @@ bool BulletPhysicsServer::body_test_motion(RID p_body, const Transform &p_from,
return body->get_space()->test_body_motion(body, p_from, p_motion, p_infinite_inertia, r_result, p_exclude_raycast_shapes);
}
-int BulletPhysicsServer::body_test_ray_separation(RID p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, SeparationResult *r_results, int p_result_max, float p_margin) {
+int BulletPhysicsServer3D::body_test_ray_separation(RID p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, SeparationResult *r_results, int p_result_max, float p_margin) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0);
ERR_FAIL_COND_V(!body->get_space(), 0);
@@ -881,7 +881,7 @@ int BulletPhysicsServer::body_test_ray_separation(RID p_body, const Transform &p
return body->get_space()->test_ray_separation(body, p_transform, p_infinite_inertia, r_recover_motion, r_results, p_result_max, p_margin);
}
-RID BulletPhysicsServer::soft_body_create(bool p_init_sleeping) {
+RID BulletPhysicsServer3D::soft_body_create(bool p_init_sleeping) {
SoftBodyBullet *body = bulletnew(SoftBodyBullet);
body->set_collision_layer(1);
body->set_collision_mask(1);
@@ -890,17 +890,17 @@ RID BulletPhysicsServer::soft_body_create(bool p_init_sleeping) {
CreateThenReturnRID(soft_body_owner, body);
}
-void BulletPhysicsServer::soft_body_update_visual_server(RID p_body, class SoftBodyVisualServerHandler *p_visual_server_handler) {
+void BulletPhysicsServer3D::soft_body_update_rendering_server(RID p_body, class SoftBodyRenderingServerHandler *p_rendering_server_handler) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
- body->update_visual_server(p_visual_server_handler);
+ body->update_rendering_server(p_rendering_server_handler);
}
-void BulletPhysicsServer::soft_body_set_space(RID p_body, RID p_space) {
+void BulletPhysicsServer3D::soft_body_set_space(RID p_body, RID p_space) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
- SpaceBullet *space = NULL;
+ SpaceBullet *space = nullptr;
if (p_space.is_valid()) {
space = space_owner.getornull(p_space);
@@ -913,7 +913,7 @@ void BulletPhysicsServer::soft_body_set_space(RID p_body, RID p_space) {
body->set_space(space);
}
-RID BulletPhysicsServer::soft_body_get_space(RID p_body) const {
+RID BulletPhysicsServer3D::soft_body_get_space(RID p_body) const {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, RID());
@@ -923,42 +923,42 @@ RID BulletPhysicsServer::soft_body_get_space(RID p_body) const {
return space->get_self();
}
-void BulletPhysicsServer::soft_body_set_mesh(RID p_body, const REF &p_mesh) {
+void BulletPhysicsServer3D::soft_body_set_mesh(RID p_body, const REF &p_mesh) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_soft_mesh(p_mesh);
}
-void BulletPhysicsServer::soft_body_set_collision_layer(RID p_body, uint32_t p_layer) {
+void BulletPhysicsServer3D::soft_body_set_collision_layer(RID p_body, uint32_t p_layer) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_collision_layer(p_layer);
}
-uint32_t BulletPhysicsServer::soft_body_get_collision_layer(RID p_body) const {
+uint32_t BulletPhysicsServer3D::soft_body_get_collision_layer(RID p_body) const {
const SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0);
return body->get_collision_layer();
}
-void BulletPhysicsServer::soft_body_set_collision_mask(RID p_body, uint32_t p_mask) {
+void BulletPhysicsServer3D::soft_body_set_collision_mask(RID p_body, uint32_t p_mask) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_collision_mask(p_mask);
}
-uint32_t BulletPhysicsServer::soft_body_get_collision_mask(RID p_body) const {
+uint32_t BulletPhysicsServer3D::soft_body_get_collision_mask(RID p_body) const {
const SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0);
return body->get_collision_mask();
}
-void BulletPhysicsServer::soft_body_add_collision_exception(RID p_body, RID p_body_b) {
+void BulletPhysicsServer3D::soft_body_add_collision_exception(RID p_body, RID p_body_b) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -971,7 +971,7 @@ void BulletPhysicsServer::soft_body_add_collision_exception(RID p_body, RID p_bo
body->add_collision_exception(other_body);
}
-void BulletPhysicsServer::soft_body_remove_collision_exception(RID p_body, RID p_body_b) {
+void BulletPhysicsServer3D::soft_body_remove_collision_exception(RID p_body, RID p_body_b) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -984,7 +984,7 @@ void BulletPhysicsServer::soft_body_remove_collision_exception(RID p_body, RID p
body->remove_collision_exception(other_body);
}
-void BulletPhysicsServer::soft_body_get_collision_exceptions(RID p_body, List<RID> *p_exceptions) {
+void BulletPhysicsServer3D::soft_body_get_collision_exceptions(RID p_body, List<RID> *p_exceptions) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
for (int i = 0; i < body->get_exceptions().size(); i++) {
@@ -992,25 +992,25 @@ void BulletPhysicsServer::soft_body_get_collision_exceptions(RID p_body, List<RI
}
}
-void BulletPhysicsServer::soft_body_set_state(RID p_body, BodyState p_state, const Variant &p_variant) {
+void BulletPhysicsServer3D::soft_body_set_state(RID p_body, BodyState p_state, const Variant &p_variant) {
// FIXME: Must be implemented.
WARN_PRINT("soft_body_state is not implemented yet in Bullet backend.");
}
-Variant BulletPhysicsServer::soft_body_get_state(RID p_body, BodyState p_state) const {
+Variant BulletPhysicsServer3D::soft_body_get_state(RID p_body, BodyState p_state) const {
// FIXME: Must be implemented.
WARN_PRINT("soft_body_state is not implemented yet in Bullet backend.");
return Variant();
}
-void BulletPhysicsServer::soft_body_set_transform(RID p_body, const Transform &p_transform) {
+void BulletPhysicsServer3D::soft_body_set_transform(RID p_body, const Transform &p_transform) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_soft_transform(p_transform);
}
-Vector3 BulletPhysicsServer::soft_body_get_vertex_position(RID p_body, int vertex_index) const {
+Vector3 BulletPhysicsServer3D::soft_body_get_vertex_position(RID p_body, int vertex_index) const {
const SoftBodyBullet *body = soft_body_owner.getornull(p_body);
Vector3 pos;
ERR_FAIL_COND_V(!body, pos);
@@ -1019,133 +1019,133 @@ Vector3 BulletPhysicsServer::soft_body_get_vertex_position(RID p_body, int verte
return pos;
}
-void BulletPhysicsServer::soft_body_set_ray_pickable(RID p_body, bool p_enable) {
+void BulletPhysicsServer3D::soft_body_set_ray_pickable(RID p_body, bool p_enable) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_ray_pickable(p_enable);
}
-bool BulletPhysicsServer::soft_body_is_ray_pickable(RID p_body) const {
+bool BulletPhysicsServer3D::soft_body_is_ray_pickable(RID p_body) const {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, false);
return body->is_ray_pickable();
}
-void BulletPhysicsServer::soft_body_set_simulation_precision(RID p_body, int p_simulation_precision) {
+void BulletPhysicsServer3D::soft_body_set_simulation_precision(RID p_body, int p_simulation_precision) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_simulation_precision(p_simulation_precision);
}
-int BulletPhysicsServer::soft_body_get_simulation_precision(RID p_body) {
+int BulletPhysicsServer3D::soft_body_get_simulation_precision(RID p_body) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0.f);
return body->get_simulation_precision();
}
-void BulletPhysicsServer::soft_body_set_total_mass(RID p_body, real_t p_total_mass) {
+void BulletPhysicsServer3D::soft_body_set_total_mass(RID p_body, real_t p_total_mass) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_total_mass(p_total_mass);
}
-real_t BulletPhysicsServer::soft_body_get_total_mass(RID p_body) {
+real_t BulletPhysicsServer3D::soft_body_get_total_mass(RID p_body) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0.f);
return body->get_total_mass();
}
-void BulletPhysicsServer::soft_body_set_linear_stiffness(RID p_body, real_t p_stiffness) {
+void BulletPhysicsServer3D::soft_body_set_linear_stiffness(RID p_body, real_t p_stiffness) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_linear_stiffness(p_stiffness);
}
-real_t BulletPhysicsServer::soft_body_get_linear_stiffness(RID p_body) {
+real_t BulletPhysicsServer3D::soft_body_get_linear_stiffness(RID p_body) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0.f);
return body->get_linear_stiffness();
}
-void BulletPhysicsServer::soft_body_set_areaAngular_stiffness(RID p_body, real_t p_stiffness) {
+void BulletPhysicsServer3D::soft_body_set_areaAngular_stiffness(RID p_body, real_t p_stiffness) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_areaAngular_stiffness(p_stiffness);
}
-real_t BulletPhysicsServer::soft_body_get_areaAngular_stiffness(RID p_body) {
+real_t BulletPhysicsServer3D::soft_body_get_areaAngular_stiffness(RID p_body) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0.f);
return body->get_areaAngular_stiffness();
}
-void BulletPhysicsServer::soft_body_set_volume_stiffness(RID p_body, real_t p_stiffness) {
+void BulletPhysicsServer3D::soft_body_set_volume_stiffness(RID p_body, real_t p_stiffness) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_volume_stiffness(p_stiffness);
}
-real_t BulletPhysicsServer::soft_body_get_volume_stiffness(RID p_body) {
+real_t BulletPhysicsServer3D::soft_body_get_volume_stiffness(RID p_body) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0.f);
return body->get_volume_stiffness();
}
-void BulletPhysicsServer::soft_body_set_pressure_coefficient(RID p_body, real_t p_pressure_coefficient) {
+void BulletPhysicsServer3D::soft_body_set_pressure_coefficient(RID p_body, real_t p_pressure_coefficient) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_pressure_coefficient(p_pressure_coefficient);
}
-real_t BulletPhysicsServer::soft_body_get_pressure_coefficient(RID p_body) {
+real_t BulletPhysicsServer3D::soft_body_get_pressure_coefficient(RID p_body) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0.f);
return body->get_pressure_coefficient();
}
-void BulletPhysicsServer::soft_body_set_pose_matching_coefficient(RID p_body, real_t p_pose_matching_coefficient) {
+void BulletPhysicsServer3D::soft_body_set_pose_matching_coefficient(RID p_body, real_t p_pose_matching_coefficient) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
return body->set_pose_matching_coefficient(p_pose_matching_coefficient);
}
-real_t BulletPhysicsServer::soft_body_get_pose_matching_coefficient(RID p_body) {
+real_t BulletPhysicsServer3D::soft_body_get_pose_matching_coefficient(RID p_body) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0.f);
return body->get_pose_matching_coefficient();
}
-void BulletPhysicsServer::soft_body_set_damping_coefficient(RID p_body, real_t p_damping_coefficient) {
+void BulletPhysicsServer3D::soft_body_set_damping_coefficient(RID p_body, real_t p_damping_coefficient) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_damping_coefficient(p_damping_coefficient);
}
-real_t BulletPhysicsServer::soft_body_get_damping_coefficient(RID p_body) {
+real_t BulletPhysicsServer3D::soft_body_get_damping_coefficient(RID p_body) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0.f);
return body->get_damping_coefficient();
}
-void BulletPhysicsServer::soft_body_set_drag_coefficient(RID p_body, real_t p_drag_coefficient) {
+void BulletPhysicsServer3D::soft_body_set_drag_coefficient(RID p_body, real_t p_drag_coefficient) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_drag_coefficient(p_drag_coefficient);
}
-real_t BulletPhysicsServer::soft_body_get_drag_coefficient(RID p_body) {
+real_t BulletPhysicsServer3D::soft_body_get_drag_coefficient(RID p_body) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0.f);
return body->get_drag_coefficient();
}
-void BulletPhysicsServer::soft_body_move_point(RID p_body, int p_point_index, const Vector3 &p_global_position) {
+void BulletPhysicsServer3D::soft_body_move_point(RID p_body, int p_point_index, const Vector3 &p_global_position) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_node_position(p_point_index, p_global_position);
}
-Vector3 BulletPhysicsServer::soft_body_get_point_global_position(RID p_body, int p_point_index) {
+Vector3 BulletPhysicsServer3D::soft_body_get_point_global_position(RID p_body, int p_point_index) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, Vector3(0., 0., 0.));
Vector3 pos;
@@ -1153,7 +1153,7 @@ Vector3 BulletPhysicsServer::soft_body_get_point_global_position(RID p_body, int
return pos;
}
-Vector3 BulletPhysicsServer::soft_body_get_point_offset(RID p_body, int p_point_index) const {
+Vector3 BulletPhysicsServer3D::soft_body_get_point_offset(RID p_body, int p_point_index) const {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, Vector3());
Vector3 res;
@@ -1161,60 +1161,60 @@ Vector3 BulletPhysicsServer::soft_body_get_point_offset(RID p_body, int p_point_
return res;
}
-void BulletPhysicsServer::soft_body_remove_all_pinned_points(RID p_body) {
+void BulletPhysicsServer3D::soft_body_remove_all_pinned_points(RID p_body) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->reset_all_node_mass();
}
-void BulletPhysicsServer::soft_body_pin_point(RID p_body, int p_point_index, bool p_pin) {
+void BulletPhysicsServer3D::soft_body_pin_point(RID p_body, int p_point_index, bool p_pin) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_node_mass(p_point_index, p_pin ? 0 : 1);
}
-bool BulletPhysicsServer::soft_body_is_point_pinned(RID p_body, int p_point_index) {
+bool BulletPhysicsServer3D::soft_body_is_point_pinned(RID p_body, int p_point_index) {
SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0.f);
return body->get_node_mass(p_point_index);
}
-PhysicsServer::JointType BulletPhysicsServer::joint_get_type(RID p_joint) const {
+PhysicsServer3D::JointType BulletPhysicsServer3D::joint_get_type(RID p_joint) const {
JointBullet *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND_V(!joint, JOINT_PIN);
return joint->get_type();
}
-void BulletPhysicsServer::joint_set_solver_priority(RID p_joint, int p_priority) {
+void BulletPhysicsServer3D::joint_set_solver_priority(RID p_joint, int p_priority) {
// Joint priority not supported by bullet
}
-int BulletPhysicsServer::joint_get_solver_priority(RID p_joint) const {
+int BulletPhysicsServer3D::joint_get_solver_priority(RID p_joint) const {
// Joint priority not supported by bullet
return 0;
}
-void BulletPhysicsServer::joint_disable_collisions_between_bodies(RID p_joint, const bool p_disable) {
+void BulletPhysicsServer3D::joint_disable_collisions_between_bodies(RID p_joint, const bool p_disable) {
JointBullet *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND(!joint);
joint->disable_collisions_between_bodies(p_disable);
}
-bool BulletPhysicsServer::joint_is_disabled_collisions_between_bodies(RID p_joint) const {
+bool BulletPhysicsServer3D::joint_is_disabled_collisions_between_bodies(RID p_joint) const {
JointBullet *joint(joint_owner.getornull(p_joint));
ERR_FAIL_COND_V(!joint, false);
return joint->is_disabled_collisions_between_bodies();
}
-RID BulletPhysicsServer::joint_create_pin(RID p_body_A, const Vector3 &p_local_A, RID p_body_B, const Vector3 &p_local_B) {
+RID BulletPhysicsServer3D::joint_create_pin(RID p_body_A, const Vector3 &p_local_A, RID p_body_B, const Vector3 &p_local_B) {
RigidBodyBullet *body_A = rigid_body_owner.getornull(p_body_A);
ERR_FAIL_COND_V(!body_A, RID());
JointAssertSpace(body_A, "A", RID());
- RigidBodyBullet *body_B = NULL;
+ RigidBodyBullet *body_B = nullptr;
if (p_body_B.is_valid()) {
body_B = rigid_body_owner.getornull(p_body_B);
JointAssertSpace(body_B, "B", RID());
@@ -1229,7 +1229,7 @@ RID BulletPhysicsServer::joint_create_pin(RID p_body_A, const Vector3 &p_local_A
CreateThenReturnRID(joint_owner, joint);
}
-void BulletPhysicsServer::pin_joint_set_param(RID p_joint, PinJointParam p_param, float p_value) {
+void BulletPhysicsServer3D::pin_joint_set_param(RID p_joint, PinJointParam p_param, float p_value) {
JointBullet *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_PIN);
@@ -1237,7 +1237,7 @@ void BulletPhysicsServer::pin_joint_set_param(RID p_joint, PinJointParam p_param
pin_joint->set_param(p_param, p_value);
}
-float BulletPhysicsServer::pin_joint_get_param(RID p_joint, PinJointParam p_param) const {
+float BulletPhysicsServer3D::pin_joint_get_param(RID p_joint, PinJointParam p_param) const {
JointBullet *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND_V(!joint, 0);
ERR_FAIL_COND_V(joint->get_type() != JOINT_PIN, 0);
@@ -1245,7 +1245,7 @@ float BulletPhysicsServer::pin_joint_get_param(RID p_joint, PinJointParam p_para
return pin_joint->get_param(p_param);
}
-void BulletPhysicsServer::pin_joint_set_local_a(RID p_joint, const Vector3 &p_A) {
+void BulletPhysicsServer3D::pin_joint_set_local_a(RID p_joint, const Vector3 &p_A) {
JointBullet *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_PIN);
@@ -1253,7 +1253,7 @@ void BulletPhysicsServer::pin_joint_set_local_a(RID p_joint, const Vector3 &p_A)
pin_joint->setPivotInA(p_A);
}
-Vector3 BulletPhysicsServer::pin_joint_get_local_a(RID p_joint) const {
+Vector3 BulletPhysicsServer3D::pin_joint_get_local_a(RID p_joint) const {
JointBullet *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND_V(!joint, Vector3());
ERR_FAIL_COND_V(joint->get_type() != JOINT_PIN, Vector3());
@@ -1261,7 +1261,7 @@ Vector3 BulletPhysicsServer::pin_joint_get_local_a(RID p_joint) const {
return pin_joint->getPivotInA();
}
-void BulletPhysicsServer::pin_joint_set_local_b(RID p_joint, const Vector3 &p_B) {
+void BulletPhysicsServer3D::pin_joint_set_local_b(RID p_joint, const Vector3 &p_B) {
JointBullet *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_PIN);
@@ -1269,7 +1269,7 @@ void BulletPhysicsServer::pin_joint_set_local_b(RID p_joint, const Vector3 &p_B)
pin_joint->setPivotInB(p_B);
}
-Vector3 BulletPhysicsServer::pin_joint_get_local_b(RID p_joint) const {
+Vector3 BulletPhysicsServer3D::pin_joint_get_local_b(RID p_joint) const {
JointBullet *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND_V(!joint, Vector3());
ERR_FAIL_COND_V(joint->get_type() != JOINT_PIN, Vector3());
@@ -1277,12 +1277,12 @@ Vector3 BulletPhysicsServer::pin_joint_get_local_b(RID p_joint) const {
return pin_joint->getPivotInB();
}
-RID BulletPhysicsServer::joint_create_hinge(RID p_body_A, const Transform &p_hinge_A, RID p_body_B, const Transform &p_hinge_B) {
+RID BulletPhysicsServer3D::joint_create_hinge(RID p_body_A, const Transform &p_hinge_A, RID p_body_B, const Transform &p_hinge_B) {
RigidBodyBullet *body_A = rigid_body_owner.getornull(p_body_A);
ERR_FAIL_COND_V(!body_A, RID());
JointAssertSpace(body_A, "A", RID());
- RigidBodyBullet *body_B = NULL;
+ RigidBodyBullet *body_B = nullptr;
if (p_body_B.is_valid()) {
body_B = rigid_body_owner.getornull(p_body_B);
JointAssertSpace(body_B, "B", RID());
@@ -1297,12 +1297,12 @@ RID BulletPhysicsServer::joint_create_hinge(RID p_body_A, const Transform &p_hin
CreateThenReturnRID(joint_owner, joint);
}
-RID BulletPhysicsServer::joint_create_hinge_simple(RID p_body_A, const Vector3 &p_pivot_A, const Vector3 &p_axis_A, RID p_body_B, const Vector3 &p_pivot_B, const Vector3 &p_axis_B) {
+RID BulletPhysicsServer3D::joint_create_hinge_simple(RID p_body_A, const Vector3 &p_pivot_A, const Vector3 &p_axis_A, RID p_body_B, const Vector3 &p_pivot_B, const Vector3 &p_axis_B) {
RigidBodyBullet *body_A = rigid_body_owner.getornull(p_body_A);
ERR_FAIL_COND_V(!body_A, RID());
JointAssertSpace(body_A, "A", RID());
- RigidBodyBullet *body_B = NULL;
+ RigidBodyBullet *body_B = nullptr;
if (p_body_B.is_valid()) {
body_B = rigid_body_owner.getornull(p_body_B);
JointAssertSpace(body_B, "B", RID());
@@ -1317,7 +1317,7 @@ RID BulletPhysicsServer::joint_create_hinge_simple(RID p_body_A, const Vector3 &
CreateThenReturnRID(joint_owner, joint);
}
-void BulletPhysicsServer::hinge_joint_set_param(RID p_joint, HingeJointParam p_param, float p_value) {
+void BulletPhysicsServer3D::hinge_joint_set_param(RID p_joint, HingeJointParam p_param, float p_value) {
JointBullet *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_HINGE);
@@ -1325,7 +1325,7 @@ void BulletPhysicsServer::hinge_joint_set_param(RID p_joint, HingeJointParam p_p
hinge_joint->set_param(p_param, p_value);
}
-float BulletPhysicsServer::hinge_joint_get_param(RID p_joint, HingeJointParam p_param) const {
+float BulletPhysicsServer3D::hinge_joint_get_param(RID p_joint, HingeJointParam p_param) const {
JointBullet *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND_V(!joint, 0);
ERR_FAIL_COND_V(joint->get_type() != JOINT_HINGE, 0);
@@ -1333,7 +1333,7 @@ float BulletPhysicsServer::hinge_joint_get_param(RID p_joint, HingeJointParam p_
return hinge_joint->get_param(p_param);
}
-void BulletPhysicsServer::hinge_joint_set_flag(RID p_joint, HingeJointFlag p_flag, bool p_value) {
+void BulletPhysicsServer3D::hinge_joint_set_flag(RID p_joint, HingeJointFlag p_flag, bool p_value) {
JointBullet *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_HINGE);
@@ -1341,7 +1341,7 @@ void BulletPhysicsServer::hinge_joint_set_flag(RID p_joint, HingeJointFlag p_fla
hinge_joint->set_flag(p_flag, p_value);
}
-bool BulletPhysicsServer::hinge_joint_get_flag(RID p_joint, HingeJointFlag p_flag) const {
+bool BulletPhysicsServer3D::hinge_joint_get_flag(RID p_joint, HingeJointFlag p_flag) const {
JointBullet *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND_V(!joint, false);
ERR_FAIL_COND_V(joint->get_type() != JOINT_HINGE, false);
@@ -1349,12 +1349,12 @@ bool BulletPhysicsServer::hinge_joint_get_flag(RID p_joint, HingeJointFlag p_fla
return hinge_joint->get_flag(p_flag);
}
-RID BulletPhysicsServer::joint_create_slider(RID p_body_A, const Transform &p_local_frame_A, RID p_body_B, const Transform &p_local_frame_B) {
+RID BulletPhysicsServer3D::joint_create_slider(RID p_body_A, const Transform &p_local_frame_A, RID p_body_B, const Transform &p_local_frame_B) {
RigidBodyBullet *body_A = rigid_body_owner.getornull(p_body_A);
ERR_FAIL_COND_V(!body_A, RID());
JointAssertSpace(body_A, "A", RID());
- RigidBodyBullet *body_B = NULL;
+ RigidBodyBullet *body_B = nullptr;
if (p_body_B.is_valid()) {
body_B = rigid_body_owner.getornull(p_body_B);
JointAssertSpace(body_B, "B", RID());
@@ -1369,7 +1369,7 @@ RID BulletPhysicsServer::joint_create_slider(RID p_body_A, const Transform &p_lo
CreateThenReturnRID(joint_owner, joint);
}
-void BulletPhysicsServer::slider_joint_set_param(RID p_joint, SliderJointParam p_param, float p_value) {
+void BulletPhysicsServer3D::slider_joint_set_param(RID p_joint, SliderJointParam p_param, float p_value) {
JointBullet *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_SLIDER);
@@ -1377,7 +1377,7 @@ void BulletPhysicsServer::slider_joint_set_param(RID p_joint, SliderJointParam p
slider_joint->set_param(p_param, p_value);
}
-float BulletPhysicsServer::slider_joint_get_param(RID p_joint, SliderJointParam p_param) const {
+float BulletPhysicsServer3D::slider_joint_get_param(RID p_joint, SliderJointParam p_param) const {
JointBullet *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND_V(!joint, 0);
ERR_FAIL_COND_V(joint->get_type() != JOINT_SLIDER, 0);
@@ -1385,12 +1385,12 @@ float BulletPhysicsServer::slider_joint_get_param(RID p_joint, SliderJointParam
return slider_joint->get_param(p_param);
}
-RID BulletPhysicsServer::joint_create_cone_twist(RID p_body_A, const Transform &p_local_frame_A, RID p_body_B, const Transform &p_local_frame_B) {
+RID BulletPhysicsServer3D::joint_create_cone_twist(RID p_body_A, const Transform &p_local_frame_A, RID p_body_B, const Transform &p_local_frame_B) {
RigidBodyBullet *body_A = rigid_body_owner.getornull(p_body_A);
ERR_FAIL_COND_V(!body_A, RID());
JointAssertSpace(body_A, "A", RID());
- RigidBodyBullet *body_B = NULL;
+ RigidBodyBullet *body_B = nullptr;
if (p_body_B.is_valid()) {
body_B = rigid_body_owner.getornull(p_body_B);
JointAssertSpace(body_B, "B", RID());
@@ -1403,7 +1403,7 @@ RID BulletPhysicsServer::joint_create_cone_twist(RID p_body_A, const Transform &
CreateThenReturnRID(joint_owner, joint);
}
-void BulletPhysicsServer::cone_twist_joint_set_param(RID p_joint, ConeTwistJointParam p_param, float p_value) {
+void BulletPhysicsServer3D::cone_twist_joint_set_param(RID p_joint, ConeTwistJointParam p_param, float p_value) {
JointBullet *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_CONE_TWIST);
@@ -1411,7 +1411,7 @@ void BulletPhysicsServer::cone_twist_joint_set_param(RID p_joint, ConeTwistJoint
coneTwist_joint->set_param(p_param, p_value);
}
-float BulletPhysicsServer::cone_twist_joint_get_param(RID p_joint, ConeTwistJointParam p_param) const {
+float BulletPhysicsServer3D::cone_twist_joint_get_param(RID p_joint, ConeTwistJointParam p_param) const {
JointBullet *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND_V(!joint, 0.);
ERR_FAIL_COND_V(joint->get_type() != JOINT_CONE_TWIST, 0.);
@@ -1419,12 +1419,12 @@ float BulletPhysicsServer::cone_twist_joint_get_param(RID p_joint, ConeTwistJoin
return coneTwist_joint->get_param(p_param);
}
-RID BulletPhysicsServer::joint_create_generic_6dof(RID p_body_A, const Transform &p_local_frame_A, RID p_body_B, const Transform &p_local_frame_B) {
+RID BulletPhysicsServer3D::joint_create_generic_6dof(RID p_body_A, const Transform &p_local_frame_A, RID p_body_B, const Transform &p_local_frame_B) {
RigidBodyBullet *body_A = rigid_body_owner.getornull(p_body_A);
ERR_FAIL_COND_V(!body_A, RID());
JointAssertSpace(body_A, "A", RID());
- RigidBodyBullet *body_B = NULL;
+ RigidBodyBullet *body_B = nullptr;
if (p_body_B.is_valid()) {
body_B = rigid_body_owner.getornull(p_body_B);
JointAssertSpace(body_B, "B", RID());
@@ -1439,7 +1439,7 @@ RID BulletPhysicsServer::joint_create_generic_6dof(RID p_body_A, const Transform
CreateThenReturnRID(joint_owner, joint);
}
-void BulletPhysicsServer::generic_6dof_joint_set_param(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisParam p_param, float p_value) {
+void BulletPhysicsServer3D::generic_6dof_joint_set_param(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisParam p_param, float p_value) {
JointBullet *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_6DOF);
@@ -1447,7 +1447,7 @@ void BulletPhysicsServer::generic_6dof_joint_set_param(RID p_joint, Vector3::Axi
generic_6dof_joint->set_param(p_axis, p_param, p_value);
}
-float BulletPhysicsServer::generic_6dof_joint_get_param(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisParam p_param) {
+float BulletPhysicsServer3D::generic_6dof_joint_get_param(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisParam p_param) {
JointBullet *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND_V(!joint, 0);
ERR_FAIL_COND_V(joint->get_type() != JOINT_6DOF, 0);
@@ -1455,7 +1455,7 @@ float BulletPhysicsServer::generic_6dof_joint_get_param(RID p_joint, Vector3::Ax
return generic_6dof_joint->get_param(p_axis, p_param);
}
-void BulletPhysicsServer::generic_6dof_joint_set_flag(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisFlag p_flag, bool p_enable) {
+void BulletPhysicsServer3D::generic_6dof_joint_set_flag(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisFlag p_flag, bool p_enable) {
JointBullet *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_6DOF);
@@ -1463,7 +1463,7 @@ void BulletPhysicsServer::generic_6dof_joint_set_flag(RID p_joint, Vector3::Axis
generic_6dof_joint->set_flag(p_axis, p_flag, p_enable);
}
-bool BulletPhysicsServer::generic_6dof_joint_get_flag(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisFlag p_flag) {
+bool BulletPhysicsServer3D::generic_6dof_joint_get_flag(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisFlag p_flag) {
JointBullet *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND_V(!joint, false);
ERR_FAIL_COND_V(joint->get_type() != JOINT_6DOF, false);
@@ -1471,7 +1471,7 @@ bool BulletPhysicsServer::generic_6dof_joint_get_flag(RID p_joint, Vector3::Axis
return generic_6dof_joint->get_flag(p_axis, p_flag);
}
-void BulletPhysicsServer::generic_6dof_joint_set_precision(RID p_joint, int p_precision) {
+void BulletPhysicsServer3D::generic_6dof_joint_set_precision(RID p_joint, int p_precision) {
JointBullet *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_6DOF);
@@ -1479,7 +1479,7 @@ void BulletPhysicsServer::generic_6dof_joint_set_precision(RID p_joint, int p_pr
generic_6dof_joint->set_precision(p_precision);
}
-int BulletPhysicsServer::generic_6dof_joint_get_precision(RID p_joint) {
+int BulletPhysicsServer3D::generic_6dof_joint_get_precision(RID p_joint) {
JointBullet *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND_V(!joint, 0);
ERR_FAIL_COND_V(joint->get_type() != JOINT_6DOF, 0);
@@ -1487,7 +1487,7 @@ int BulletPhysicsServer::generic_6dof_joint_get_precision(RID p_joint) {
return generic_6dof_joint->get_precision();
}
-void BulletPhysicsServer::free(RID p_rid) {
+void BulletPhysicsServer3D::free(RID p_rid) {
if (shape_owner.owns(p_rid)) {
ShapeBullet *shape = shape_owner.getornull(p_rid);
@@ -1503,7 +1503,7 @@ void BulletPhysicsServer::free(RID p_rid) {
RigidBodyBullet *body = rigid_body_owner.getornull(p_rid);
- body->set_space(NULL);
+ body->set_space(nullptr);
body->remove_all_shapes(true, true);
@@ -1514,7 +1514,7 @@ void BulletPhysicsServer::free(RID p_rid) {
SoftBodyBullet *body = soft_body_owner.getornull(p_rid);
- body->set_space(NULL);
+ body->set_space(nullptr);
soft_body_owner.free(p_rid);
bulletdelete(body);
@@ -1523,7 +1523,7 @@ void BulletPhysicsServer::free(RID p_rid) {
AreaBullet *area = area_owner.getornull(p_rid);
- area->set_space(NULL);
+ area->set_space(nullptr);
area->remove_all_shapes(true, true);
@@ -1552,15 +1552,15 @@ void BulletPhysicsServer::free(RID p_rid) {
}
}
-void BulletPhysicsServer::init() {
- BulletPhysicsDirectBodyState::initSingleton();
+void BulletPhysicsServer3D::init() {
+ BulletPhysicsDirectBodyState3D::initSingleton();
}
-void BulletPhysicsServer::step(float p_deltaTime) {
+void BulletPhysicsServer3D::step(float p_deltaTime) {
if (!active)
return;
- BulletPhysicsDirectBodyState::singleton_setDeltaTime(p_deltaTime);
+ BulletPhysicsDirectBodyState3D::singleton_setDeltaTime(p_deltaTime);
for (int i = 0; i < active_spaces_count; ++i) {
@@ -1568,21 +1568,21 @@ void BulletPhysicsServer::step(float p_deltaTime) {
}
}
-void BulletPhysicsServer::sync() {
+void BulletPhysicsServer3D::sync() {
}
-void BulletPhysicsServer::flush_queries() {
+void BulletPhysicsServer3D::flush_queries() {
}
-void BulletPhysicsServer::finish() {
- BulletPhysicsDirectBodyState::destroySingleton();
+void BulletPhysicsServer3D::finish() {
+ BulletPhysicsDirectBodyState3D::destroySingleton();
}
-int BulletPhysicsServer::get_process_info(ProcessInfo p_info) {
+int BulletPhysicsServer3D::get_process_info(ProcessInfo p_info) {
return 0;
}
-CollisionObjectBullet *BulletPhysicsServer::get_collisin_object(RID p_object) const {
+CollisionObjectBullet *BulletPhysicsServer3D::get_collisin_object(RID p_object) const {
if (rigid_body_owner.owns(p_object)) {
return rigid_body_owner.getornull(p_object);
}
@@ -1592,15 +1592,15 @@ CollisionObjectBullet *BulletPhysicsServer::get_collisin_object(RID p_object) co
if (soft_body_owner.owns(p_object)) {
return soft_body_owner.getornull(p_object);
}
- return NULL;
+ return nullptr;
}
-RigidCollisionObjectBullet *BulletPhysicsServer::get_rigid_collisin_object(RID p_object) const {
+RigidCollisionObjectBullet *BulletPhysicsServer3D::get_rigid_collisin_object(RID p_object) const {
if (rigid_body_owner.owns(p_object)) {
return rigid_body_owner.getornull(p_object);
}
if (area_owner.owns(p_object)) {
return area_owner.getornull(p_object);
}
- return NULL;
+ return nullptr;
}
diff --git a/modules/bullet/bullet_physics_server.h b/modules/bullet/bullet_physics_server.h
index 6ea9a7a974..ea9c5e589e 100644
--- a/modules/bullet/bullet_physics_server.h
+++ b/modules/bullet/bullet_physics_server.h
@@ -36,7 +36,7 @@
#include "core/rid_owner.h"
#include "joint_bullet.h"
#include "rigid_body_bullet.h"
-#include "servers/physics_server.h"
+#include "servers/physics_server_3d.h"
#include "shape_bullet.h"
#include "soft_body_bullet.h"
#include "space_bullet.h"
@@ -44,8 +44,8 @@
@author AndreaCatania
*/
-class BulletPhysicsServer : public PhysicsServer {
- GDCLASS(BulletPhysicsServer, PhysicsServer);
+class BulletPhysicsServer3D : public PhysicsServer3D {
+ GDCLASS(BulletPhysicsServer3D, PhysicsServer3D);
friend class BulletPhysicsDirectSpaceState;
@@ -64,8 +64,8 @@ protected:
static void _bind_methods();
public:
- BulletPhysicsServer();
- ~BulletPhysicsServer();
+ BulletPhysicsServer3D();
+ ~BulletPhysicsServer3D();
_FORCE_INLINE_ RID_PtrOwner<SpaceBullet> *get_space_owner() {
return &space_owner;
@@ -111,7 +111,7 @@ public:
/// Not supported
virtual real_t space_get_param(RID p_space, SpaceParameter p_param) const;
- virtual PhysicsDirectSpaceState *space_get_direct_state(RID p_space);
+ virtual PhysicsDirectSpaceState3D *space_get_direct_state(RID p_space);
virtual void space_set_debug_contacts(RID p_space, int p_max_contacts);
virtual Vector<Vector3> space_get_contacts(RID p_space) const;
@@ -252,16 +252,16 @@ public:
virtual bool body_is_ray_pickable(RID p_body) const;
// this function only works on physics process, errors and returns null otherwise
- virtual PhysicsDirectBodyState *body_get_direct_state(RID p_body);
+ virtual PhysicsDirectBodyState3D *body_get_direct_state(RID p_body);
- virtual bool body_test_motion(RID p_body, const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia, MotionResult *r_result = NULL, bool p_exclude_raycast_shapes = true);
+ virtual bool body_test_motion(RID p_body, const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia, MotionResult *r_result = nullptr, bool p_exclude_raycast_shapes = true);
virtual int body_test_ray_separation(RID p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, SeparationResult *r_results, int p_result_max, float p_margin = 0.001);
/* SOFT BODY API */
virtual RID soft_body_create(bool p_init_sleeping = false);
- virtual void soft_body_update_visual_server(RID p_body, class SoftBodyVisualServerHandler *p_visual_server_handler);
+ virtual void soft_body_update_rendering_server(RID p_body, class SoftBodyRenderingServerHandler *p_rendering_server_handler);
virtual void soft_body_set_space(RID p_body, RID p_space);
virtual RID soft_body_get_space(RID p_body) const;
@@ -387,7 +387,7 @@ public:
}
static bool singleton_isActive() {
- return static_cast<BulletPhysicsServer *>(get_singleton())->active;
+ return static_cast<BulletPhysicsServer3D *>(get_singleton())->active;
}
bool isActive() {
diff --git a/modules/bullet/bullet_utilities.h b/modules/bullet/bullet_utilities.h
index 968cb38ba2..a5e33d9829 100644
--- a/modules/bullet/bullet_utilities.h
+++ b/modules/bullet/bullet_utilities.h
@@ -41,6 +41,6 @@
#define bulletdelete(cl) \
{ \
delete cl; \
- cl = NULL; \
+ cl = nullptr; \
}
#endif
diff --git a/modules/bullet/collision_object_bullet.cpp b/modules/bullet/collision_object_bullet.cpp
index 5b7e7281e4..1b72c2f577 100644
--- a/modules/bullet/collision_object_bullet.cpp
+++ b/modules/bullet/collision_object_bullet.cpp
@@ -60,7 +60,7 @@ void CollisionObjectBullet::ShapeWrapper::set_transform(const btTransform &p_tra
}
btTransform CollisionObjectBullet::ShapeWrapper::get_adjusted_transform() const {
- if (shape->get_type() == PhysicsServer::SHAPE_HEIGHTMAP) {
+ if (shape->get_type() == PhysicsServer3D::SHAPE_HEIGHTMAP) {
const HeightMapShapeBullet *hm_shape = (const HeightMapShapeBullet *)shape; // should be safe to cast now
btTransform adjusted_transform;
@@ -96,10 +96,10 @@ CollisionObjectBullet::CollisionObjectBullet(Type p_type) :
collisionsEnabled(true),
m_isStatic(false),
ray_pickable(false),
- bt_collision_object(NULL),
+ bt_collision_object(nullptr),
body_scale(1., 1., 1.),
force_shape_reset(false),
- space(NULL),
+ space(nullptr),
isTransformChanged(false) {}
CollisionObjectBullet::~CollisionObjectBullet() {
@@ -227,7 +227,7 @@ void CollisionObjectBullet::notify_transform_changed() {
RigidCollisionObjectBullet::RigidCollisionObjectBullet(Type p_type) :
CollisionObjectBullet(p_type),
- mainShape(NULL) {
+ mainShape(nullptr) {
}
RigidCollisionObjectBullet::~RigidCollisionObjectBullet() {
@@ -332,7 +332,7 @@ bool RigidCollisionObjectBullet::is_shape_disabled(int p_index) {
void RigidCollisionObjectBullet::shape_changed(int p_shape_index) {
ShapeWrapper &shp = shapes.write[p_shape_index];
if (shp.bt_shape == mainShape) {
- mainShape = NULL;
+ mainShape = nullptr;
}
bulletdelete(shp.bt_shape);
reload_shapes();
@@ -345,7 +345,7 @@ void RigidCollisionObjectBullet::reload_shapes() {
bulletdelete(mainShape);
}
- mainShape = NULL;
+ mainShape = nullptr;
ShapeWrapper *shpWrapper;
const int shape_count = shapes.size();
@@ -398,7 +398,7 @@ void RigidCollisionObjectBullet::internal_shape_destroy(int p_index, bool p_perm
ShapeWrapper &shp = shapes.write[p_index];
shp.shape->remove_owner(this, p_permanentlyFromThisBody);
if (shp.bt_shape == mainShape) {
- mainShape = NULL;
+ mainShape = nullptr;
}
bulletdelete(shp.bt_shape);
}
diff --git a/modules/bullet/collision_object_bullet.h b/modules/bullet/collision_object_bullet.h
index 42ba4aa907..25176458a7 100644
--- a/modules/bullet/collision_object_bullet.h
+++ b/modules/bullet/collision_object_bullet.h
@@ -76,20 +76,20 @@ public:
bool active;
ShapeWrapper() :
- shape(NULL),
- bt_shape(NULL),
+ shape(nullptr),
+ bt_shape(nullptr),
active(true) {}
ShapeWrapper(ShapeBullet *p_shape, const btTransform &p_transform, bool p_active) :
shape(p_shape),
- bt_shape(NULL),
+ bt_shape(nullptr),
active(p_active) {
set_transform(p_transform);
}
ShapeWrapper(ShapeBullet *p_shape, const Transform &p_transform, bool p_active) :
shape(p_shape),
- bt_shape(NULL),
+ bt_shape(nullptr),
active(p_active) {
set_transform(p_transform);
}
diff --git a/modules/bullet/cone_twist_joint_bullet.cpp b/modules/bullet/cone_twist_joint_bullet.cpp
index 23eb39fe7e..aac51034b8 100644
--- a/modules/bullet/cone_twist_joint_bullet.cpp
+++ b/modules/bullet/cone_twist_joint_bullet.cpp
@@ -64,43 +64,43 @@ ConeTwistJointBullet::ConeTwistJointBullet(RigidBodyBullet *rbA, RigidBodyBullet
setup(coneConstraint);
}
-void ConeTwistJointBullet::set_param(PhysicsServer::ConeTwistJointParam p_param, real_t p_value) {
+void ConeTwistJointBullet::set_param(PhysicsServer3D::ConeTwistJointParam p_param, real_t p_value) {
switch (p_param) {
- case PhysicsServer::CONE_TWIST_JOINT_SWING_SPAN:
+ case PhysicsServer3D::CONE_TWIST_JOINT_SWING_SPAN:
coneConstraint->setLimit(5, p_value);
coneConstraint->setLimit(4, p_value);
break;
- case PhysicsServer::CONE_TWIST_JOINT_TWIST_SPAN:
+ case PhysicsServer3D::CONE_TWIST_JOINT_TWIST_SPAN:
coneConstraint->setLimit(3, p_value);
break;
- case PhysicsServer::CONE_TWIST_JOINT_BIAS:
+ case PhysicsServer3D::CONE_TWIST_JOINT_BIAS:
coneConstraint->setLimit(coneConstraint->getSwingSpan1(), coneConstraint->getSwingSpan2(), coneConstraint->getTwistSpan(), coneConstraint->getLimitSoftness(), p_value, coneConstraint->getRelaxationFactor());
break;
- case PhysicsServer::CONE_TWIST_JOINT_SOFTNESS:
+ case PhysicsServer3D::CONE_TWIST_JOINT_SOFTNESS:
coneConstraint->setLimit(coneConstraint->getSwingSpan1(), coneConstraint->getSwingSpan2(), coneConstraint->getTwistSpan(), p_value, coneConstraint->getBiasFactor(), coneConstraint->getRelaxationFactor());
break;
- case PhysicsServer::CONE_TWIST_JOINT_RELAXATION:
+ case PhysicsServer3D::CONE_TWIST_JOINT_RELAXATION:
coneConstraint->setLimit(coneConstraint->getSwingSpan1(), coneConstraint->getSwingSpan2(), coneConstraint->getTwistSpan(), coneConstraint->getLimitSoftness(), coneConstraint->getBiasFactor(), p_value);
break;
- case PhysicsServer::CONE_TWIST_MAX:
+ case PhysicsServer3D::CONE_TWIST_MAX:
// Internal size value, nothing to do.
break;
}
}
-real_t ConeTwistJointBullet::get_param(PhysicsServer::ConeTwistJointParam p_param) const {
+real_t ConeTwistJointBullet::get_param(PhysicsServer3D::ConeTwistJointParam p_param) const {
switch (p_param) {
- case PhysicsServer::CONE_TWIST_JOINT_SWING_SPAN:
+ case PhysicsServer3D::CONE_TWIST_JOINT_SWING_SPAN:
return coneConstraint->getSwingSpan1();
- case PhysicsServer::CONE_TWIST_JOINT_TWIST_SPAN:
+ case PhysicsServer3D::CONE_TWIST_JOINT_TWIST_SPAN:
return coneConstraint->getTwistSpan();
- case PhysicsServer::CONE_TWIST_JOINT_BIAS:
+ case PhysicsServer3D::CONE_TWIST_JOINT_BIAS:
return coneConstraint->getBiasFactor();
- case PhysicsServer::CONE_TWIST_JOINT_SOFTNESS:
+ case PhysicsServer3D::CONE_TWIST_JOINT_SOFTNESS:
return coneConstraint->getLimitSoftness();
- case PhysicsServer::CONE_TWIST_JOINT_RELAXATION:
+ case PhysicsServer3D::CONE_TWIST_JOINT_RELAXATION:
return coneConstraint->getRelaxationFactor();
- case PhysicsServer::CONE_TWIST_MAX:
+ case PhysicsServer3D::CONE_TWIST_MAX:
// Internal size value, nothing to do.
return 0;
}
diff --git a/modules/bullet/cone_twist_joint_bullet.h b/modules/bullet/cone_twist_joint_bullet.h
index 134706f8bb..ed4baa9d1b 100644
--- a/modules/bullet/cone_twist_joint_bullet.h
+++ b/modules/bullet/cone_twist_joint_bullet.h
@@ -45,9 +45,9 @@ class ConeTwistJointBullet : public JointBullet {
public:
ConeTwistJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, const Transform &rbAFrame, const Transform &rbBFrame);
- virtual PhysicsServer::JointType get_type() const { return PhysicsServer::JOINT_CONE_TWIST; }
+ virtual PhysicsServer3D::JointType get_type() const { return PhysicsServer3D::JOINT_CONE_TWIST; }
- void set_param(PhysicsServer::ConeTwistJointParam p_param, real_t p_value);
- real_t get_param(PhysicsServer::ConeTwistJointParam p_param) const;
+ void set_param(PhysicsServer3D::ConeTwistJointParam p_param, real_t p_value);
+ real_t get_param(PhysicsServer3D::ConeTwistJointParam p_param) const;
};
#endif
diff --git a/modules/bullet/config.py b/modules/bullet/config.py
index 92dbcf5cb0..d22f9454ed 100644
--- a/modules/bullet/config.py
+++ b/modules/bullet/config.py
@@ -1,14 +1,6 @@
def can_build(env, platform):
return True
+
def configure(env):
pass
-
-def get_doc_classes():
- return [
- "BulletPhysicsDirectBodyState",
- "BulletPhysicsServer",
- ]
-
-def get_doc_path():
- return "doc_classes"
diff --git a/modules/bullet/constraint_bullet.cpp b/modules/bullet/constraint_bullet.cpp
index 7e90e2b488..469b58521e 100644
--- a/modules/bullet/constraint_bullet.cpp
+++ b/modules/bullet/constraint_bullet.cpp
@@ -38,8 +38,8 @@
*/
ConstraintBullet::ConstraintBullet() :
- space(NULL),
- constraint(NULL),
+ space(nullptr),
+ constraint(nullptr),
disabled_collisions_between_bodies(true) {}
void ConstraintBullet::setup(btTypedConstraint *p_constraint) {
diff --git a/modules/bullet/constraint_bullet.h b/modules/bullet/constraint_bullet.h
index 89ad150257..1946807bad 100644
--- a/modules/bullet/constraint_bullet.h
+++ b/modules/bullet/constraint_bullet.h
@@ -64,7 +64,7 @@ public:
public:
virtual ~ConstraintBullet() {
bulletdelete(constraint);
- constraint = NULL;
+ constraint = nullptr;
}
_FORCE_INLINE_ btTypedConstraint *get_bt_constraint() { return constraint; }
diff --git a/modules/bullet/doc_classes/BulletPhysicsDirectBodyState.xml b/modules/bullet/doc_classes/BulletPhysicsDirectBodyState.xml
deleted file mode 100644
index 5ea1b810a1..0000000000
--- a/modules/bullet/doc_classes/BulletPhysicsDirectBodyState.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<class name="BulletPhysicsDirectBodyState" inherits="PhysicsDirectBodyState" version="4.0">
- <brief_description>
- </brief_description>
- <description>
- </description>
- <tutorials>
- </tutorials>
- <methods>
- </methods>
- <constants>
- </constants>
-</class>
diff --git a/modules/bullet/doc_classes/BulletPhysicsServer.xml b/modules/bullet/doc_classes/BulletPhysicsServer.xml
deleted file mode 100644
index af8fb3c02c..0000000000
--- a/modules/bullet/doc_classes/BulletPhysicsServer.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<class name="BulletPhysicsServer" inherits="PhysicsServer" version="4.0">
- <brief_description>
- </brief_description>
- <description>
- </description>
- <tutorials>
- </tutorials>
- <methods>
- </methods>
- <constants>
- </constants>
-</class>
diff --git a/modules/bullet/generic_6dof_joint_bullet.cpp b/modules/bullet/generic_6dof_joint_bullet.cpp
index 45ab3d3bb2..638944df76 100644
--- a/modules/bullet/generic_6dof_joint_bullet.cpp
+++ b/modules/bullet/generic_6dof_joint_bullet.cpp
@@ -43,6 +43,12 @@
Generic6DOFJointBullet::Generic6DOFJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, const Transform &frameInA, const Transform &frameInB) :
JointBullet() {
+ for (int i = 0; i < 3; i++) {
+ for (int j = 0; j < PhysicsServer3D::G6DOF_JOINT_FLAG_MAX; j++) {
+ flags[i][j] = false;
+ }
+ }
+
Transform scaled_AFrame(frameInA.scaled(rbA->get_body_scale()));
scaled_AFrame.basis.rotref_posscale_decomposition(scaled_AFrame.basis);
@@ -118,62 +124,62 @@ void Generic6DOFJointBullet::set_angular_upper_limit(const Vector3 &angularUpper
sixDOFConstraint->setAngularUpperLimit(btVec);
}
-void Generic6DOFJointBullet::set_param(Vector3::Axis p_axis, PhysicsServer::G6DOFJointAxisParam p_param, real_t p_value) {
+void Generic6DOFJointBullet::set_param(Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisParam p_param, real_t p_value) {
ERR_FAIL_INDEX(p_axis, 3);
switch (p_param) {
- case PhysicsServer::G6DOF_JOINT_LINEAR_LOWER_LIMIT:
+ case PhysicsServer3D::G6DOF_JOINT_LINEAR_LOWER_LIMIT:
limits_lower[0][p_axis] = p_value;
- set_flag(p_axis, PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT, flags[p_axis][PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT]); // Reload bullet parameter
+ set_flag(p_axis, PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT, flags[p_axis][PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT]); // Reload bullet parameter
break;
- case PhysicsServer::G6DOF_JOINT_LINEAR_UPPER_LIMIT:
+ case PhysicsServer3D::G6DOF_JOINT_LINEAR_UPPER_LIMIT:
limits_upper[0][p_axis] = p_value;
- set_flag(p_axis, PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT, flags[p_axis][PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT]); // Reload bullet parameter
+ set_flag(p_axis, PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT, flags[p_axis][PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT]); // Reload bullet parameter
break;
- case PhysicsServer::G6DOF_JOINT_LINEAR_MOTOR_TARGET_VELOCITY:
+ case PhysicsServer3D::G6DOF_JOINT_LINEAR_MOTOR_TARGET_VELOCITY:
sixDOFConstraint->getTranslationalLimitMotor()->m_targetVelocity.m_floats[p_axis] = p_value;
break;
- case PhysicsServer::G6DOF_JOINT_LINEAR_MOTOR_FORCE_LIMIT:
+ case PhysicsServer3D::G6DOF_JOINT_LINEAR_MOTOR_FORCE_LIMIT:
sixDOFConstraint->getTranslationalLimitMotor()->m_maxMotorForce.m_floats[p_axis] = p_value;
break;
- case PhysicsServer::G6DOF_JOINT_LINEAR_SPRING_DAMPING:
+ case PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_DAMPING:
sixDOFConstraint->getTranslationalLimitMotor()->m_springDamping.m_floats[p_axis] = p_value;
break;
- case PhysicsServer::G6DOF_JOINT_LINEAR_SPRING_STIFFNESS:
+ case PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_STIFFNESS:
sixDOFConstraint->getTranslationalLimitMotor()->m_springStiffness.m_floats[p_axis] = p_value;
break;
- case PhysicsServer::G6DOF_JOINT_LINEAR_SPRING_EQUILIBRIUM_POINT:
+ case PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_EQUILIBRIUM_POINT:
sixDOFConstraint->getTranslationalLimitMotor()->m_equilibriumPoint.m_floats[p_axis] = p_value;
break;
- case PhysicsServer::G6DOF_JOINT_ANGULAR_LOWER_LIMIT:
+ case PhysicsServer3D::G6DOF_JOINT_ANGULAR_LOWER_LIMIT:
limits_lower[1][p_axis] = p_value;
- set_flag(p_axis, PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT, flags[p_axis][PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT]); // Reload bullet parameter
+ set_flag(p_axis, PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT, flags[p_axis][PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT]); // Reload bullet parameter
break;
- case PhysicsServer::G6DOF_JOINT_ANGULAR_UPPER_LIMIT:
+ case PhysicsServer3D::G6DOF_JOINT_ANGULAR_UPPER_LIMIT:
limits_upper[1][p_axis] = p_value;
- set_flag(p_axis, PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT, flags[p_axis][PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT]); // Reload bullet parameter
+ set_flag(p_axis, PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT, flags[p_axis][PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT]); // Reload bullet parameter
break;
- case PhysicsServer::G6DOF_JOINT_ANGULAR_RESTITUTION:
+ case PhysicsServer3D::G6DOF_JOINT_ANGULAR_RESTITUTION:
sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_bounce = p_value;
break;
- case PhysicsServer::G6DOF_JOINT_ANGULAR_ERP:
+ case PhysicsServer3D::G6DOF_JOINT_ANGULAR_ERP:
sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_stopERP = p_value;
break;
- case PhysicsServer::G6DOF_JOINT_ANGULAR_MOTOR_TARGET_VELOCITY:
+ case PhysicsServer3D::G6DOF_JOINT_ANGULAR_MOTOR_TARGET_VELOCITY:
sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_targetVelocity = p_value;
break;
- case PhysicsServer::G6DOF_JOINT_ANGULAR_MOTOR_FORCE_LIMIT:
+ case PhysicsServer3D::G6DOF_JOINT_ANGULAR_MOTOR_FORCE_LIMIT:
sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_maxMotorForce = p_value;
break;
- case PhysicsServer::G6DOF_JOINT_ANGULAR_SPRING_STIFFNESS:
+ case PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_STIFFNESS:
sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_springStiffness = p_value;
break;
- case PhysicsServer::G6DOF_JOINT_ANGULAR_SPRING_DAMPING:
+ case PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_DAMPING:
sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_springDamping = p_value;
break;
- case PhysicsServer::G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT:
+ case PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT:
sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_equilibriumPoint = p_value;
break;
- case PhysicsServer::G6DOF_JOINT_MAX:
+ case PhysicsServer3D::G6DOF_JOINT_MAX:
// Internal size value, nothing to do.
break;
default:
@@ -182,42 +188,42 @@ void Generic6DOFJointBullet::set_param(Vector3::Axis p_axis, PhysicsServer::G6DO
}
}
-real_t Generic6DOFJointBullet::get_param(Vector3::Axis p_axis, PhysicsServer::G6DOFJointAxisParam p_param) const {
+real_t Generic6DOFJointBullet::get_param(Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisParam p_param) const {
ERR_FAIL_INDEX_V(p_axis, 3, 0.);
switch (p_param) {
- case PhysicsServer::G6DOF_JOINT_LINEAR_LOWER_LIMIT:
+ case PhysicsServer3D::G6DOF_JOINT_LINEAR_LOWER_LIMIT:
return limits_lower[0][p_axis];
- case PhysicsServer::G6DOF_JOINT_LINEAR_UPPER_LIMIT:
+ case PhysicsServer3D::G6DOF_JOINT_LINEAR_UPPER_LIMIT:
return limits_upper[0][p_axis];
- case PhysicsServer::G6DOF_JOINT_LINEAR_MOTOR_TARGET_VELOCITY:
+ case PhysicsServer3D::G6DOF_JOINT_LINEAR_MOTOR_TARGET_VELOCITY:
return sixDOFConstraint->getTranslationalLimitMotor()->m_targetVelocity.m_floats[p_axis];
- case PhysicsServer::G6DOF_JOINT_LINEAR_MOTOR_FORCE_LIMIT:
+ case PhysicsServer3D::G6DOF_JOINT_LINEAR_MOTOR_FORCE_LIMIT:
return sixDOFConstraint->getTranslationalLimitMotor()->m_maxMotorForce.m_floats[p_axis];
- case PhysicsServer::G6DOF_JOINT_LINEAR_SPRING_DAMPING:
+ case PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_DAMPING:
return sixDOFConstraint->getTranslationalLimitMotor()->m_springDamping.m_floats[p_axis];
- case PhysicsServer::G6DOF_JOINT_LINEAR_SPRING_STIFFNESS:
+ case PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_STIFFNESS:
return sixDOFConstraint->getTranslationalLimitMotor()->m_springStiffness.m_floats[p_axis];
- case PhysicsServer::G6DOF_JOINT_LINEAR_SPRING_EQUILIBRIUM_POINT:
+ case PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_EQUILIBRIUM_POINT:
return sixDOFConstraint->getTranslationalLimitMotor()->m_equilibriumPoint.m_floats[p_axis];
- case PhysicsServer::G6DOF_JOINT_ANGULAR_LOWER_LIMIT:
+ case PhysicsServer3D::G6DOF_JOINT_ANGULAR_LOWER_LIMIT:
return limits_lower[1][p_axis];
- case PhysicsServer::G6DOF_JOINT_ANGULAR_UPPER_LIMIT:
+ case PhysicsServer3D::G6DOF_JOINT_ANGULAR_UPPER_LIMIT:
return limits_upper[1][p_axis];
- case PhysicsServer::G6DOF_JOINT_ANGULAR_RESTITUTION:
+ case PhysicsServer3D::G6DOF_JOINT_ANGULAR_RESTITUTION:
return sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_bounce;
- case PhysicsServer::G6DOF_JOINT_ANGULAR_ERP:
+ case PhysicsServer3D::G6DOF_JOINT_ANGULAR_ERP:
return sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_stopERP;
- case PhysicsServer::G6DOF_JOINT_ANGULAR_MOTOR_TARGET_VELOCITY:
+ case PhysicsServer3D::G6DOF_JOINT_ANGULAR_MOTOR_TARGET_VELOCITY:
return sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_targetVelocity;
- case PhysicsServer::G6DOF_JOINT_ANGULAR_MOTOR_FORCE_LIMIT:
+ case PhysicsServer3D::G6DOF_JOINT_ANGULAR_MOTOR_FORCE_LIMIT:
return sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_maxMotorForce;
- case PhysicsServer::G6DOF_JOINT_ANGULAR_SPRING_STIFFNESS:
+ case PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_STIFFNESS:
return sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_springStiffness;
- case PhysicsServer::G6DOF_JOINT_ANGULAR_SPRING_DAMPING:
+ case PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_DAMPING:
return sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_springDamping;
- case PhysicsServer::G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT:
+ case PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT:
return sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_equilibriumPoint;
- case PhysicsServer::G6DOF_JOINT_MAX:
+ case PhysicsServer3D::G6DOF_JOINT_MAX:
// Internal size value, nothing to do.
return 0;
default:
@@ -226,45 +232,45 @@ real_t Generic6DOFJointBullet::get_param(Vector3::Axis p_axis, PhysicsServer::G6
}
}
-void Generic6DOFJointBullet::set_flag(Vector3::Axis p_axis, PhysicsServer::G6DOFJointAxisFlag p_flag, bool p_value) {
+void Generic6DOFJointBullet::set_flag(Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisFlag p_flag, bool p_value) {
ERR_FAIL_INDEX(p_axis, 3);
flags[p_axis][p_flag] = p_value;
switch (p_flag) {
- case PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT:
+ case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT:
if (flags[p_axis][p_flag]) {
sixDOFConstraint->setLimit(p_axis, limits_lower[0][p_axis], limits_upper[0][p_axis]);
} else {
sixDOFConstraint->setLimit(p_axis, 0, -1); // Free
}
break;
- case PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT:
+ case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT:
if (flags[p_axis][p_flag]) {
sixDOFConstraint->setLimit(p_axis + 3, limits_lower[1][p_axis], limits_upper[1][p_axis]);
} else {
sixDOFConstraint->setLimit(p_axis + 3, 0, -1); // Free
}
break;
- case PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_SPRING:
+ case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_SPRING:
sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_enableSpring = p_value;
break;
- case PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_LINEAR_SPRING:
+ case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_SPRING:
sixDOFConstraint->getTranslationalLimitMotor()->m_enableSpring[p_axis] = p_value;
break;
- case PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_MOTOR:
+ case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_MOTOR:
sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_enableMotor = flags[p_axis][p_flag];
break;
- case PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_LINEAR_MOTOR:
+ case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_MOTOR:
sixDOFConstraint->getTranslationalLimitMotor()->m_enableMotor[p_axis] = flags[p_axis][p_flag];
break;
- case PhysicsServer::G6DOF_JOINT_FLAG_MAX:
+ case PhysicsServer3D::G6DOF_JOINT_FLAG_MAX:
// Internal size value, nothing to do.
break;
}
}
-bool Generic6DOFJointBullet::get_flag(Vector3::Axis p_axis, PhysicsServer::G6DOFJointAxisFlag p_flag) const {
+bool Generic6DOFJointBullet::get_flag(Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisFlag p_flag) const {
ERR_FAIL_INDEX_V(p_axis, 3, false);
return flags[p_axis][p_flag];
}
diff --git a/modules/bullet/generic_6dof_joint_bullet.h b/modules/bullet/generic_6dof_joint_bullet.h
index 75c8005811..316708bb11 100644
--- a/modules/bullet/generic_6dof_joint_bullet.h
+++ b/modules/bullet/generic_6dof_joint_bullet.h
@@ -45,12 +45,12 @@ class Generic6DOFJointBullet : public JointBullet {
// First is linear second is angular
Vector3 limits_lower[2];
Vector3 limits_upper[2];
- bool flags[3][PhysicsServer::G6DOF_JOINT_FLAG_MAX];
+ bool flags[3][PhysicsServer3D::G6DOF_JOINT_FLAG_MAX];
public:
Generic6DOFJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, const Transform &frameInA, const Transform &frameInB);
- virtual PhysicsServer::JointType get_type() const { return PhysicsServer::JOINT_6DOF; }
+ virtual PhysicsServer3D::JointType get_type() const { return PhysicsServer3D::JOINT_6DOF; }
Transform getFrameOffsetA() const;
Transform getFrameOffsetB() const;
@@ -63,11 +63,11 @@ public:
void set_angular_lower_limit(const Vector3 &angularLower);
void set_angular_upper_limit(const Vector3 &angularUpper);
- void set_param(Vector3::Axis p_axis, PhysicsServer::G6DOFJointAxisParam p_param, real_t p_value);
- real_t get_param(Vector3::Axis p_axis, PhysicsServer::G6DOFJointAxisParam p_param) const;
+ void set_param(Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisParam p_param, real_t p_value);
+ real_t get_param(Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisParam p_param) const;
- void set_flag(Vector3::Axis p_axis, PhysicsServer::G6DOFJointAxisFlag p_flag, bool p_value);
- bool get_flag(Vector3::Axis p_axis, PhysicsServer::G6DOFJointAxisFlag p_flag) const;
+ void set_flag(Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisFlag p_flag, bool p_value);
+ bool get_flag(Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisFlag p_flag) const;
void set_precision(int p_precision);
int get_precision() const;
diff --git a/modules/bullet/godot_collision_configuration.cpp b/modules/bullet/godot_collision_configuration.cpp
index f3e3a01a52..8e29845a36 100644
--- a/modules/bullet/godot_collision_configuration.cpp
+++ b/modules/bullet/godot_collision_configuration.cpp
@@ -42,7 +42,7 @@
GodotCollisionConfiguration::GodotCollisionConfiguration(const btDiscreteDynamicsWorld *world, const btDefaultCollisionConstructionInfo &constructionInfo) :
btDefaultCollisionConfiguration(constructionInfo) {
- void *mem = NULL;
+ void *mem = nullptr;
mem = btAlignedAlloc(sizeof(GodotRayWorldAlgorithm::CreateFunc), 16);
m_rayWorldCF = new (mem) GodotRayWorldAlgorithm::CreateFunc(world);
@@ -98,7 +98,7 @@ btCollisionAlgorithmCreateFunc *GodotCollisionConfiguration::getClosestPointsAlg
GodotSoftCollisionConfiguration::GodotSoftCollisionConfiguration(const btDiscreteDynamicsWorld *world, const btDefaultCollisionConstructionInfo &constructionInfo) :
btSoftBodyRigidBodyCollisionConfiguration(constructionInfo) {
- void *mem = NULL;
+ void *mem = nullptr;
mem = btAlignedAlloc(sizeof(GodotRayWorldAlgorithm::CreateFunc), 16);
m_rayWorldCF = new (mem) GodotRayWorldAlgorithm::CreateFunc(world);
diff --git a/modules/bullet/godot_result_callbacks.cpp b/modules/bullet/godot_result_callbacks.cpp
index 20467e3ef3..ad20a7e451 100644
--- a/modules/bullet/godot_result_callbacks.cpp
+++ b/modules/bullet/godot_result_callbacks.cpp
@@ -107,12 +107,12 @@ btScalar GodotAllConvexResultCallback::addSingleResult(btCollisionWorld::LocalCo
CollisionObjectBullet *gObj = static_cast<CollisionObjectBullet *>(convexResult.m_hitCollisionObject->getUserPointer());
- PhysicsDirectSpaceState::ShapeResult &result = m_results[count];
+ PhysicsDirectSpaceState3D::ShapeResult &result = m_results[count];
result.shape = convexResult.m_localShapeInfo->m_triangleIndex; // "m_triangleIndex" Is a odd name but contains the compound shape ID
result.rid = gObj->get_self();
result.collider_id = gObj->get_instance_id();
- result.collider = result.collider_id.is_null() ? NULL : ObjectDB::get_instance(result.collider_id);
+ result.collider = result.collider_id.is_null() ? nullptr : ObjectDB::get_instance(result.collider_id);
++count;
return 1; // not used by bullet
@@ -207,7 +207,7 @@ btScalar GodotAllContactResultCallback::addSingleResult(btManifoldPoint &cp, con
if (cp.getDistance() <= 0) {
- PhysicsDirectSpaceState::ShapeResult &result = m_results[m_count];
+ PhysicsDirectSpaceState3D::ShapeResult &result = m_results[m_count];
// Penetrated
CollisionObjectBullet *colObj;
@@ -220,7 +220,7 @@ btScalar GodotAllContactResultCallback::addSingleResult(btManifoldPoint &cp, con
}
result.collider_id = colObj->get_instance_id();
- result.collider = result.collider_id.is_null() ? NULL : ObjectDB::get_instance(result.collider_id);
+ result.collider = result.collider_id.is_null() ? nullptr : ObjectDB::get_instance(result.collider_id);
result.rid = colObj->get_self();
++m_count;
}
diff --git a/modules/bullet/godot_result_callbacks.h b/modules/bullet/godot_result_callbacks.h
index 4f634ed6f0..7e74a2b22e 100644
--- a/modules/bullet/godot_result_callbacks.h
+++ b/modules/bullet/godot_result_callbacks.h
@@ -31,7 +31,7 @@
#ifndef GODOT_RESULT_CALLBACKS_H
#define GODOT_RESULT_CALLBACKS_H
-#include "servers/physics_server.h"
+#include "servers/physics_server_3d.h"
#include <BulletCollision/BroadphaseCollision/btBroadphaseProxy.h>
#include <btBulletDynamicsCommon.h>
@@ -85,12 +85,12 @@ public:
// store all colliding object
struct GodotAllConvexResultCallback : public btCollisionWorld::ConvexResultCallback {
public:
- PhysicsDirectSpaceState::ShapeResult *m_results;
+ PhysicsDirectSpaceState3D::ShapeResult *m_results;
int m_resultMax;
const Set<RID> *m_exclude;
int count;
- GodotAllConvexResultCallback(PhysicsDirectSpaceState::ShapeResult *p_results, int p_resultMax, const Set<RID> *p_exclude) :
+ GodotAllConvexResultCallback(PhysicsDirectSpaceState3D::ShapeResult *p_results, int p_resultMax, const Set<RID> *p_exclude) :
m_results(p_results),
m_resultMax(p_resultMax),
m_exclude(p_exclude),
@@ -137,7 +137,7 @@ public:
struct GodotAllContactResultCallback : public btCollisionWorld::ContactResultCallback {
public:
const btCollisionObject *m_self_object;
- PhysicsDirectSpaceState::ShapeResult *m_results;
+ PhysicsDirectSpaceState3D::ShapeResult *m_results;
int m_resultMax;
const Set<RID> *m_exclude;
int m_count;
@@ -145,7 +145,7 @@ public:
bool collide_with_bodies;
bool collide_with_areas;
- GodotAllContactResultCallback(btCollisionObject *p_self_object, PhysicsDirectSpaceState::ShapeResult *p_results, int p_resultMax, const Set<RID> *p_exclude, bool p_collide_with_bodies, bool p_collide_with_areas) :
+ GodotAllContactResultCallback(btCollisionObject *p_self_object, PhysicsDirectSpaceState3D::ShapeResult *p_results, int p_resultMax, const Set<RID> *p_exclude, bool p_collide_with_bodies, bool p_collide_with_areas) :
m_self_object(p_self_object),
m_results(p_results),
m_resultMax(p_resultMax),
@@ -188,7 +188,7 @@ public:
struct GodotRestInfoContactResultCallback : public btCollisionWorld::ContactResultCallback {
public:
const btCollisionObject *m_self_object;
- PhysicsDirectSpaceState::ShapeRestInfo *m_result;
+ PhysicsDirectSpaceState3D::ShapeRestInfo *m_result;
const Set<RID> *m_exclude;
bool m_collided;
real_t m_min_distance;
@@ -197,7 +197,7 @@ public:
bool collide_with_bodies;
bool collide_with_areas;
- GodotRestInfoContactResultCallback(btCollisionObject *p_self_object, PhysicsDirectSpaceState::ShapeRestInfo *p_result, const Set<RID> *p_exclude, bool p_collide_with_bodies, bool p_collide_with_areas) :
+ GodotRestInfoContactResultCallback(btCollisionObject *p_self_object, PhysicsDirectSpaceState3D::ShapeRestInfo *p_result, const Set<RID> *p_exclude, bool p_collide_with_bodies, bool p_collide_with_areas) :
m_self_object(p_self_object),
m_result(p_result),
m_exclude(p_exclude),
diff --git a/modules/bullet/hinge_joint_bullet.cpp b/modules/bullet/hinge_joint_bullet.cpp
index 970732688a..4bea9f87c0 100644
--- a/modules/bullet/hinge_joint_bullet.cpp
+++ b/modules/bullet/hinge_joint_bullet.cpp
@@ -93,58 +93,58 @@ real_t HingeJointBullet::get_hinge_angle() {
return hingeConstraint->getHingeAngle();
}
-void HingeJointBullet::set_param(PhysicsServer::HingeJointParam p_param, real_t p_value) {
+void HingeJointBullet::set_param(PhysicsServer3D::HingeJointParam p_param, real_t p_value) {
switch (p_param) {
- case PhysicsServer::HINGE_JOINT_BIAS:
- WARN_DEPRECATED_MSG("The HingeJoint parameter \"bias\" is deprecated.");
+ case PhysicsServer3D::HINGE_JOINT_BIAS:
+ WARN_DEPRECATED_MSG("The HingeJoint3D parameter \"bias\" is deprecated.");
break;
- case PhysicsServer::HINGE_JOINT_LIMIT_UPPER:
+ case PhysicsServer3D::HINGE_JOINT_LIMIT_UPPER:
hingeConstraint->setLimit(hingeConstraint->getLowerLimit(), p_value, hingeConstraint->getLimitSoftness(), hingeConstraint->getLimitBiasFactor(), hingeConstraint->getLimitRelaxationFactor());
break;
- case PhysicsServer::HINGE_JOINT_LIMIT_LOWER:
+ case PhysicsServer3D::HINGE_JOINT_LIMIT_LOWER:
hingeConstraint->setLimit(p_value, hingeConstraint->getUpperLimit(), hingeConstraint->getLimitSoftness(), hingeConstraint->getLimitBiasFactor(), hingeConstraint->getLimitRelaxationFactor());
break;
- case PhysicsServer::HINGE_JOINT_LIMIT_BIAS:
+ case PhysicsServer3D::HINGE_JOINT_LIMIT_BIAS:
hingeConstraint->setLimit(hingeConstraint->getLowerLimit(), hingeConstraint->getUpperLimit(), hingeConstraint->getLimitSoftness(), p_value, hingeConstraint->getLimitRelaxationFactor());
break;
- case PhysicsServer::HINGE_JOINT_LIMIT_SOFTNESS:
+ case PhysicsServer3D::HINGE_JOINT_LIMIT_SOFTNESS:
hingeConstraint->setLimit(hingeConstraint->getLowerLimit(), hingeConstraint->getUpperLimit(), p_value, hingeConstraint->getLimitBiasFactor(), hingeConstraint->getLimitRelaxationFactor());
break;
- case PhysicsServer::HINGE_JOINT_LIMIT_RELAXATION:
+ case PhysicsServer3D::HINGE_JOINT_LIMIT_RELAXATION:
hingeConstraint->setLimit(hingeConstraint->getLowerLimit(), hingeConstraint->getUpperLimit(), hingeConstraint->getLimitSoftness(), hingeConstraint->getLimitBiasFactor(), p_value);
break;
- case PhysicsServer::HINGE_JOINT_MOTOR_TARGET_VELOCITY:
+ case PhysicsServer3D::HINGE_JOINT_MOTOR_TARGET_VELOCITY:
hingeConstraint->setMotorTargetVelocity(p_value);
break;
- case PhysicsServer::HINGE_JOINT_MOTOR_MAX_IMPULSE:
+ case PhysicsServer3D::HINGE_JOINT_MOTOR_MAX_IMPULSE:
hingeConstraint->setMaxMotorImpulse(p_value);
break;
- case PhysicsServer::HINGE_JOINT_MAX:
+ case PhysicsServer3D::HINGE_JOINT_MAX:
// Internal size value, nothing to do.
break;
}
}
-real_t HingeJointBullet::get_param(PhysicsServer::HingeJointParam p_param) const {
+real_t HingeJointBullet::get_param(PhysicsServer3D::HingeJointParam p_param) const {
switch (p_param) {
- case PhysicsServer::HINGE_JOINT_BIAS:
- WARN_DEPRECATED_MSG("The HingeJoint parameter \"bias\" is deprecated.");
+ case PhysicsServer3D::HINGE_JOINT_BIAS:
+ WARN_DEPRECATED_MSG("The HingeJoint3D parameter \"bias\" is deprecated.");
return 0;
- case PhysicsServer::HINGE_JOINT_LIMIT_UPPER:
+ case PhysicsServer3D::HINGE_JOINT_LIMIT_UPPER:
return hingeConstraint->getUpperLimit();
- case PhysicsServer::HINGE_JOINT_LIMIT_LOWER:
+ case PhysicsServer3D::HINGE_JOINT_LIMIT_LOWER:
return hingeConstraint->getLowerLimit();
- case PhysicsServer::HINGE_JOINT_LIMIT_BIAS:
+ case PhysicsServer3D::HINGE_JOINT_LIMIT_BIAS:
return hingeConstraint->getLimitBiasFactor();
- case PhysicsServer::HINGE_JOINT_LIMIT_SOFTNESS:
+ case PhysicsServer3D::HINGE_JOINT_LIMIT_SOFTNESS:
return hingeConstraint->getLimitSoftness();
- case PhysicsServer::HINGE_JOINT_LIMIT_RELAXATION:
+ case PhysicsServer3D::HINGE_JOINT_LIMIT_RELAXATION:
return hingeConstraint->getLimitRelaxationFactor();
- case PhysicsServer::HINGE_JOINT_MOTOR_TARGET_VELOCITY:
+ case PhysicsServer3D::HINGE_JOINT_MOTOR_TARGET_VELOCITY:
return hingeConstraint->getMotorTargetVelocity();
- case PhysicsServer::HINGE_JOINT_MOTOR_MAX_IMPULSE:
+ case PhysicsServer3D::HINGE_JOINT_MOTOR_MAX_IMPULSE:
return hingeConstraint->getMaxMotorImpulse();
- case PhysicsServer::HINGE_JOINT_MAX:
+ case PhysicsServer3D::HINGE_JOINT_MAX:
// Internal size value, nothing to do.
return 0;
}
@@ -152,25 +152,25 @@ real_t HingeJointBullet::get_param(PhysicsServer::HingeJointParam p_param) const
return 0;
}
-void HingeJointBullet::set_flag(PhysicsServer::HingeJointFlag p_flag, bool p_value) {
+void HingeJointBullet::set_flag(PhysicsServer3D::HingeJointFlag p_flag, bool p_value) {
switch (p_flag) {
- case PhysicsServer::HINGE_JOINT_FLAG_USE_LIMIT:
+ case PhysicsServer3D::HINGE_JOINT_FLAG_USE_LIMIT:
if (!p_value) {
hingeConstraint->setLimit(-Math_PI, Math_PI);
}
break;
- case PhysicsServer::HINGE_JOINT_FLAG_ENABLE_MOTOR:
+ case PhysicsServer3D::HINGE_JOINT_FLAG_ENABLE_MOTOR:
hingeConstraint->enableMotor(p_value);
break;
- case PhysicsServer::HINGE_JOINT_FLAG_MAX: break; // Can't happen, but silences warning
+ case PhysicsServer3D::HINGE_JOINT_FLAG_MAX: break; // Can't happen, but silences warning
}
}
-bool HingeJointBullet::get_flag(PhysicsServer::HingeJointFlag p_flag) const {
+bool HingeJointBullet::get_flag(PhysicsServer3D::HingeJointFlag p_flag) const {
switch (p_flag) {
- case PhysicsServer::HINGE_JOINT_FLAG_USE_LIMIT:
+ case PhysicsServer3D::HINGE_JOINT_FLAG_USE_LIMIT:
return true;
- case PhysicsServer::HINGE_JOINT_FLAG_ENABLE_MOTOR:
+ case PhysicsServer3D::HINGE_JOINT_FLAG_ENABLE_MOTOR:
return hingeConstraint->getEnableAngularMotor();
default:
return false;
diff --git a/modules/bullet/hinge_joint_bullet.h b/modules/bullet/hinge_joint_bullet.h
index d1061fe52f..120c40e5c0 100644
--- a/modules/bullet/hinge_joint_bullet.h
+++ b/modules/bullet/hinge_joint_bullet.h
@@ -44,14 +44,14 @@ public:
HingeJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, const Transform &frameA, const Transform &frameB);
HingeJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, const Vector3 &pivotInA, const Vector3 &pivotInB, const Vector3 &axisInA, const Vector3 &axisInB);
- virtual PhysicsServer::JointType get_type() const { return PhysicsServer::JOINT_HINGE; }
+ virtual PhysicsServer3D::JointType get_type() const { return PhysicsServer3D::JOINT_HINGE; }
real_t get_hinge_angle();
- void set_param(PhysicsServer::HingeJointParam p_param, real_t p_value);
- real_t get_param(PhysicsServer::HingeJointParam p_param) const;
+ void set_param(PhysicsServer3D::HingeJointParam p_param, real_t p_value);
+ real_t get_param(PhysicsServer3D::HingeJointParam p_param) const;
- void set_flag(PhysicsServer::HingeJointFlag p_flag, bool p_value);
- bool get_flag(PhysicsServer::HingeJointFlag p_flag) const;
+ void set_flag(PhysicsServer3D::HingeJointFlag p_flag, bool p_value);
+ bool get_flag(PhysicsServer3D::HingeJointFlag p_flag) const;
};
#endif
diff --git a/modules/bullet/joint_bullet.h b/modules/bullet/joint_bullet.h
index c840eb8f14..9cb8aab276 100644
--- a/modules/bullet/joint_bullet.h
+++ b/modules/bullet/joint_bullet.h
@@ -32,7 +32,7 @@
#define JOINT_BULLET_H
#include "constraint_bullet.h"
-#include "servers/physics_server.h"
+#include "servers/physics_server_3d.h"
/**
@author AndreaCatania
@@ -47,6 +47,6 @@ public:
JointBullet();
virtual ~JointBullet();
- virtual PhysicsServer::JointType get_type() const = 0;
+ virtual PhysicsServer3D::JointType get_type() const = 0;
};
#endif
diff --git a/modules/bullet/pin_joint_bullet.cpp b/modules/bullet/pin_joint_bullet.cpp
index 8d109f1866..68b40d7405 100644
--- a/modules/bullet/pin_joint_bullet.cpp
+++ b/modules/bullet/pin_joint_bullet.cpp
@@ -62,27 +62,27 @@ PinJointBullet::PinJointBullet(RigidBodyBullet *p_body_a, const Vector3 &p_pos_a
PinJointBullet::~PinJointBullet() {}
-void PinJointBullet::set_param(PhysicsServer::PinJointParam p_param, real_t p_value) {
+void PinJointBullet::set_param(PhysicsServer3D::PinJointParam p_param, real_t p_value) {
switch (p_param) {
- case PhysicsServer::PIN_JOINT_BIAS:
+ case PhysicsServer3D::PIN_JOINT_BIAS:
p2pConstraint->m_setting.m_tau = p_value;
break;
- case PhysicsServer::PIN_JOINT_DAMPING:
+ case PhysicsServer3D::PIN_JOINT_DAMPING:
p2pConstraint->m_setting.m_damping = p_value;
break;
- case PhysicsServer::PIN_JOINT_IMPULSE_CLAMP:
+ case PhysicsServer3D::PIN_JOINT_IMPULSE_CLAMP:
p2pConstraint->m_setting.m_impulseClamp = p_value;
break;
}
}
-real_t PinJointBullet::get_param(PhysicsServer::PinJointParam p_param) const {
+real_t PinJointBullet::get_param(PhysicsServer3D::PinJointParam p_param) const {
switch (p_param) {
- case PhysicsServer::PIN_JOINT_BIAS:
+ case PhysicsServer3D::PIN_JOINT_BIAS:
return p2pConstraint->m_setting.m_tau;
- case PhysicsServer::PIN_JOINT_DAMPING:
+ case PhysicsServer3D::PIN_JOINT_DAMPING:
return p2pConstraint->m_setting.m_damping;
- case PhysicsServer::PIN_JOINT_IMPULSE_CLAMP:
+ case PhysicsServer3D::PIN_JOINT_IMPULSE_CLAMP:
return p2pConstraint->m_setting.m_impulseClamp;
}
// Compiler doesn't seem to notice that all code paths are fulfilled...
diff --git a/modules/bullet/pin_joint_bullet.h b/modules/bullet/pin_joint_bullet.h
index d6e7a945b5..e7d05f34d4 100644
--- a/modules/bullet/pin_joint_bullet.h
+++ b/modules/bullet/pin_joint_bullet.h
@@ -46,10 +46,10 @@ public:
PinJointBullet(RigidBodyBullet *p_body_a, const Vector3 &p_pos_a, RigidBodyBullet *p_body_b, const Vector3 &p_pos_b);
~PinJointBullet();
- virtual PhysicsServer::JointType get_type() const { return PhysicsServer::JOINT_PIN; }
+ virtual PhysicsServer3D::JointType get_type() const { return PhysicsServer3D::JOINT_PIN; }
- void set_param(PhysicsServer::PinJointParam p_param, real_t p_value);
- real_t get_param(PhysicsServer::PinJointParam p_param) const;
+ void set_param(PhysicsServer3D::PinJointParam p_param, real_t p_value);
+ real_t get_param(PhysicsServer3D::PinJointParam p_param) const;
void setPivotInA(const Vector3 &p_pos);
void setPivotInB(const Vector3 &p_pos);
diff --git a/modules/bullet/register_types.cpp b/modules/bullet/register_types.cpp
index 7819b67cad..009d0dff63 100644
--- a/modules/bullet/register_types.cpp
+++ b/modules/bullet/register_types.cpp
@@ -39,15 +39,15 @@
*/
#ifndef _3D_DISABLED
-PhysicsServer *_createBulletPhysicsCallback() {
- return memnew(BulletPhysicsServer);
+PhysicsServer3D *_createBulletPhysicsCallback() {
+ return memnew(BulletPhysicsServer3D);
}
#endif
void register_bullet_types() {
#ifndef _3D_DISABLED
- PhysicsServerManager::register_server("Bullet", &_createBulletPhysicsCallback);
- PhysicsServerManager::set_default_server("Bullet", 1);
+ PhysicsServer3DManager::register_server("Bullet", &_createBulletPhysicsCallback);
+ PhysicsServer3DManager::set_default_server("Bullet", 1);
GLOBAL_DEF("physics/3d/active_soft_world", true);
ProjectSettings::get_singleton()->set_custom_property_info("physics/3d/active_soft_world", PropertyInfo(Variant::BOOL, "physics/3d/active_soft_world"));
diff --git a/modules/bullet/rid_bullet.h b/modules/bullet/rid_bullet.h
index b76641ca54..3551ca05f9 100644
--- a/modules/bullet/rid_bullet.h
+++ b/modules/bullet/rid_bullet.h
@@ -37,17 +37,17 @@
@author AndreaCatania
*/
-class BulletPhysicsServer;
+class BulletPhysicsServer3D;
class RIDBullet {
RID self;
- BulletPhysicsServer *physicsServer;
+ BulletPhysicsServer3D *physicsServer;
public:
_FORCE_INLINE_ void set_self(const RID &p_self) { self = p_self; }
_FORCE_INLINE_ RID get_self() const { return self; }
- _FORCE_INLINE_ void _set_physics_server(BulletPhysicsServer *p_physicsServer) { physicsServer = p_physicsServer; }
- _FORCE_INLINE_ BulletPhysicsServer *get_physics_server() const { return physicsServer; }
+ _FORCE_INLINE_ void _set_physics_server(BulletPhysicsServer3D *p_physicsServer) { physicsServer = p_physicsServer; }
+ _FORCE_INLINE_ BulletPhysicsServer3D *get_physics_server() const { return physicsServer; }
};
#endif
diff --git a/modules/bullet/rigid_body_bullet.cpp b/modules/bullet/rigid_body_bullet.cpp
index 80f42c8441..a4f9affa95 100644
--- a/modules/bullet/rigid_body_bullet.cpp
+++ b/modules/bullet/rigid_body_bullet.cpp
@@ -48,141 +48,141 @@
@author AndreaCatania
*/
-BulletPhysicsDirectBodyState *BulletPhysicsDirectBodyState::singleton = NULL;
+BulletPhysicsDirectBodyState3D *BulletPhysicsDirectBodyState3D::singleton = nullptr;
-Vector3 BulletPhysicsDirectBodyState::get_total_gravity() const {
+Vector3 BulletPhysicsDirectBodyState3D::get_total_gravity() const {
Vector3 gVec;
B_TO_G(body->btBody->getGravity(), gVec);
return gVec;
}
-float BulletPhysicsDirectBodyState::get_total_angular_damp() const {
+float BulletPhysicsDirectBodyState3D::get_total_angular_damp() const {
return body->btBody->getAngularDamping();
}
-float BulletPhysicsDirectBodyState::get_total_linear_damp() const {
+float BulletPhysicsDirectBodyState3D::get_total_linear_damp() const {
return body->btBody->getLinearDamping();
}
-Vector3 BulletPhysicsDirectBodyState::get_center_of_mass() const {
+Vector3 BulletPhysicsDirectBodyState3D::get_center_of_mass() const {
Vector3 gVec;
B_TO_G(body->btBody->getCenterOfMassPosition(), gVec);
return gVec;
}
-Basis BulletPhysicsDirectBodyState::get_principal_inertia_axes() const {
+Basis BulletPhysicsDirectBodyState3D::get_principal_inertia_axes() const {
return Basis();
}
-float BulletPhysicsDirectBodyState::get_inverse_mass() const {
+float BulletPhysicsDirectBodyState3D::get_inverse_mass() const {
return body->btBody->getInvMass();
}
-Vector3 BulletPhysicsDirectBodyState::get_inverse_inertia() const {
+Vector3 BulletPhysicsDirectBodyState3D::get_inverse_inertia() const {
Vector3 gVec;
B_TO_G(body->btBody->getInvInertiaDiagLocal(), gVec);
return gVec;
}
-Basis BulletPhysicsDirectBodyState::get_inverse_inertia_tensor() const {
+Basis BulletPhysicsDirectBodyState3D::get_inverse_inertia_tensor() const {
Basis gInertia;
B_TO_G(body->btBody->getInvInertiaTensorWorld(), gInertia);
return gInertia;
}
-void BulletPhysicsDirectBodyState::set_linear_velocity(const Vector3 &p_velocity) {
+void BulletPhysicsDirectBodyState3D::set_linear_velocity(const Vector3 &p_velocity) {
body->set_linear_velocity(p_velocity);
}
-Vector3 BulletPhysicsDirectBodyState::get_linear_velocity() const {
+Vector3 BulletPhysicsDirectBodyState3D::get_linear_velocity() const {
return body->get_linear_velocity();
}
-void BulletPhysicsDirectBodyState::set_angular_velocity(const Vector3 &p_velocity) {
+void BulletPhysicsDirectBodyState3D::set_angular_velocity(const Vector3 &p_velocity) {
body->set_angular_velocity(p_velocity);
}
-Vector3 BulletPhysicsDirectBodyState::get_angular_velocity() const {
+Vector3 BulletPhysicsDirectBodyState3D::get_angular_velocity() const {
return body->get_angular_velocity();
}
-void BulletPhysicsDirectBodyState::set_transform(const Transform &p_transform) {
+void BulletPhysicsDirectBodyState3D::set_transform(const Transform &p_transform) {
body->set_transform(p_transform);
}
-Transform BulletPhysicsDirectBodyState::get_transform() const {
+Transform BulletPhysicsDirectBodyState3D::get_transform() const {
return body->get_transform();
}
-void BulletPhysicsDirectBodyState::add_central_force(const Vector3 &p_force) {
+void BulletPhysicsDirectBodyState3D::add_central_force(const Vector3 &p_force) {
body->apply_central_force(p_force);
}
-void BulletPhysicsDirectBodyState::add_force(const Vector3 &p_force, const Vector3 &p_pos) {
+void BulletPhysicsDirectBodyState3D::add_force(const Vector3 &p_force, const Vector3 &p_pos) {
body->apply_force(p_force, p_pos);
}
-void BulletPhysicsDirectBodyState::add_torque(const Vector3 &p_torque) {
+void BulletPhysicsDirectBodyState3D::add_torque(const Vector3 &p_torque) {
body->apply_torque(p_torque);
}
-void BulletPhysicsDirectBodyState::apply_central_impulse(const Vector3 &p_impulse) {
+void BulletPhysicsDirectBodyState3D::apply_central_impulse(const Vector3 &p_impulse) {
body->apply_central_impulse(p_impulse);
}
-void BulletPhysicsDirectBodyState::apply_impulse(const Vector3 &p_pos, const Vector3 &p_impulse) {
+void BulletPhysicsDirectBodyState3D::apply_impulse(const Vector3 &p_pos, const Vector3 &p_impulse) {
body->apply_impulse(p_pos, p_impulse);
}
-void BulletPhysicsDirectBodyState::apply_torque_impulse(const Vector3 &p_impulse) {
+void BulletPhysicsDirectBodyState3D::apply_torque_impulse(const Vector3 &p_impulse) {
body->apply_torque_impulse(p_impulse);
}
-void BulletPhysicsDirectBodyState::set_sleep_state(bool p_enable) {
- body->set_activation_state(p_enable);
+void BulletPhysicsDirectBodyState3D::set_sleep_state(bool p_sleep) {
+ body->set_activation_state(!p_sleep);
}
-bool BulletPhysicsDirectBodyState::is_sleeping() const {
+bool BulletPhysicsDirectBodyState3D::is_sleeping() const {
return !body->is_active();
}
-int BulletPhysicsDirectBodyState::get_contact_count() const {
+int BulletPhysicsDirectBodyState3D::get_contact_count() const {
return body->collisionsCount;
}
-Vector3 BulletPhysicsDirectBodyState::get_contact_local_position(int p_contact_idx) const {
+Vector3 BulletPhysicsDirectBodyState3D::get_contact_local_position(int p_contact_idx) const {
return body->collisions[p_contact_idx].hitLocalLocation;
}
-Vector3 BulletPhysicsDirectBodyState::get_contact_local_normal(int p_contact_idx) const {
+Vector3 BulletPhysicsDirectBodyState3D::get_contact_local_normal(int p_contact_idx) const {
return body->collisions[p_contact_idx].hitNormal;
}
-float BulletPhysicsDirectBodyState::get_contact_impulse(int p_contact_idx) const {
+float BulletPhysicsDirectBodyState3D::get_contact_impulse(int p_contact_idx) const {
return body->collisions[p_contact_idx].appliedImpulse;
}
-int BulletPhysicsDirectBodyState::get_contact_local_shape(int p_contact_idx) const {
+int BulletPhysicsDirectBodyState3D::get_contact_local_shape(int p_contact_idx) const {
return body->collisions[p_contact_idx].local_shape;
}
-RID BulletPhysicsDirectBodyState::get_contact_collider(int p_contact_idx) const {
+RID BulletPhysicsDirectBodyState3D::get_contact_collider(int p_contact_idx) const {
return body->collisions[p_contact_idx].otherObject->get_self();
}
-Vector3 BulletPhysicsDirectBodyState::get_contact_collider_position(int p_contact_idx) const {
+Vector3 BulletPhysicsDirectBodyState3D::get_contact_collider_position(int p_contact_idx) const {
return body->collisions[p_contact_idx].hitWorldLocation;
}
-ObjectID BulletPhysicsDirectBodyState::get_contact_collider_id(int p_contact_idx) const {
+ObjectID BulletPhysicsDirectBodyState3D::get_contact_collider_id(int p_contact_idx) const {
return body->collisions[p_contact_idx].otherObject->get_instance_id();
}
-int BulletPhysicsDirectBodyState::get_contact_collider_shape(int p_contact_idx) const {
+int BulletPhysicsDirectBodyState3D::get_contact_collider_shape(int p_contact_idx) const {
return body->collisions[p_contact_idx].other_object_shape;
}
-Vector3 BulletPhysicsDirectBodyState::get_contact_collider_velocity_at_position(int p_contact_idx) const {
+Vector3 BulletPhysicsDirectBodyState3D::get_contact_collider_velocity_at_position(int p_contact_idx) const {
RigidBodyBullet::CollisionData &colDat = body->collisions.write[p_contact_idx];
btVector3 hitLocation;
@@ -194,7 +194,7 @@ Vector3 BulletPhysicsDirectBodyState::get_contact_collider_velocity_at_position(
return velocityAtPoint;
}
-PhysicsDirectSpaceState *BulletPhysicsDirectBodyState::get_space_state() {
+PhysicsDirectSpaceState3D *BulletPhysicsDirectBodyState3D::get_space_state() {
return body->get_space()->get_direct_state();
}
@@ -231,17 +231,17 @@ void RigidBodyBullet::KinematicUtilities::copyAllOwnerShapes() {
shapes.write[i].transform = shape_wrapper->transform;
shapes.write[i].transform.getOrigin() *= owner_scale;
switch (shape_wrapper->shape->get_type()) {
- case PhysicsServer::SHAPE_SPHERE:
- case PhysicsServer::SHAPE_BOX:
- case PhysicsServer::SHAPE_CAPSULE:
- case PhysicsServer::SHAPE_CYLINDER:
- case PhysicsServer::SHAPE_CONVEX_POLYGON:
- case PhysicsServer::SHAPE_RAY: {
+ case PhysicsServer3D::SHAPE_SPHERE:
+ case PhysicsServer3D::SHAPE_BOX:
+ case PhysicsServer3D::SHAPE_CAPSULE:
+ case PhysicsServer3D::SHAPE_CYLINDER:
+ case PhysicsServer3D::SHAPE_CONVEX_POLYGON:
+ case PhysicsServer3D::SHAPE_RAY: {
shapes.write[i].shape = static_cast<btConvexShape *>(shape_wrapper->shape->create_bt_shape(owner_scale * shape_wrapper->scale, safe_margin));
} break;
default:
WARN_PRINT("This shape is not supported for kinematic collision.");
- shapes.write[i].shape = NULL;
+ shapes.write[i].shape = nullptr;
}
}
}
@@ -257,7 +257,7 @@ void RigidBodyBullet::KinematicUtilities::just_delete_shapes(int new_size) {
RigidBodyBullet::RigidBodyBullet() :
RigidCollisionObjectBullet(CollisionObjectBullet::TYPE_RIGID_BODY),
- kinematic_utilities(NULL),
+ kinematic_utilities(nullptr),
locked_axis(0),
mass(1),
gravity_scale(1),
@@ -274,24 +274,24 @@ RigidBodyBullet::RigidBodyBullet() :
countGravityPointSpaces(0),
isScratchedSpaceOverrideModificator(false),
previousActiveState(true),
- force_integration_callback(NULL) {
+ force_integration_callback(nullptr) {
godotMotionState = bulletnew(GodotMotionState(this));
// Initial properties
const btVector3 localInertia(0, 0, 0);
- btRigidBody::btRigidBodyConstructionInfo cInfo(mass, godotMotionState, NULL, localInertia);
+ btRigidBody::btRigidBodyConstructionInfo cInfo(mass, godotMotionState, nullptr, localInertia);
btBody = bulletnew(btRigidBody(cInfo));
reload_shapes();
setupBulletCollisionObject(btBody);
- set_mode(PhysicsServer::BODY_MODE_RIGID);
+ set_mode(PhysicsServer3D::BODY_MODE_RIGID);
reload_axis_lock();
areasWhereIam.resize(maxAreasWhereIam);
for (int i = areasWhereIam.size() - 1; 0 <= i; --i) {
- areasWhereIam.write[i] = NULL;
+ areasWhereIam.write[i] = nullptr;
}
btBody->setSleepingThresholds(0.2, 0.2);
@@ -315,7 +315,7 @@ void RigidBodyBullet::init_kinematic_utilities() {
void RigidBodyBullet::destroy_kinematic_utilities() {
if (kinematic_utilities) {
memdelete(kinematic_utilities);
- kinematic_utilities = NULL;
+ kinematic_utilities = nullptr;
}
}
@@ -359,7 +359,7 @@ void RigidBodyBullet::dispatch_callbacks() {
if (omit_forces_integration)
btBody->clearForces();
- BulletPhysicsDirectBodyState *bodyDirect = BulletPhysicsDirectBodyState::get_singleton(this);
+ BulletPhysicsDirectBodyState3D *bodyDirect = BulletPhysicsDirectBodyState3D::get_singleton(this);
Variant variantBodyDirect = bodyDirect;
@@ -392,7 +392,7 @@ void RigidBodyBullet::set_force_integration_callback(ObjectID p_id, const String
if (force_integration_callback) {
memdelete(force_integration_callback);
- force_integration_callback = NULL;
+ force_integration_callback = nullptr;
}
if (p_id.is_valid()) {
@@ -487,29 +487,29 @@ void RigidBodyBullet::set_omit_forces_integration(bool p_omit) {
omit_forces_integration = p_omit;
}
-void RigidBodyBullet::set_param(PhysicsServer::BodyParameter p_param, real_t p_value) {
+void RigidBodyBullet::set_param(PhysicsServer3D::BodyParameter p_param, real_t p_value) {
switch (p_param) {
- case PhysicsServer::BODY_PARAM_BOUNCE:
+ case PhysicsServer3D::BODY_PARAM_BOUNCE:
btBody->setRestitution(p_value);
break;
- case PhysicsServer::BODY_PARAM_FRICTION:
+ case PhysicsServer3D::BODY_PARAM_FRICTION:
btBody->setFriction(p_value);
break;
- case PhysicsServer::BODY_PARAM_MASS: {
+ case PhysicsServer3D::BODY_PARAM_MASS: {
ERR_FAIL_COND(p_value < 0);
mass = p_value;
_internal_set_mass(p_value);
break;
}
- case PhysicsServer::BODY_PARAM_LINEAR_DAMP:
+ case PhysicsServer3D::BODY_PARAM_LINEAR_DAMP:
linearDamp = p_value;
btBody->setDamping(linearDamp, angularDamp);
break;
- case PhysicsServer::BODY_PARAM_ANGULAR_DAMP:
+ case PhysicsServer3D::BODY_PARAM_ANGULAR_DAMP:
angularDamp = p_value;
btBody->setDamping(linearDamp, angularDamp);
break;
- case PhysicsServer::BODY_PARAM_GRAVITY_SCALE:
+ case PhysicsServer3D::BODY_PARAM_GRAVITY_SCALE:
gravity_scale = p_value;
/// The Bullet gravity will be is set by reload_space_override_modificator
scratch_space_override_modificator();
@@ -519,21 +519,21 @@ void RigidBodyBullet::set_param(PhysicsServer::BodyParameter p_param, real_t p_v
}
}
-real_t RigidBodyBullet::get_param(PhysicsServer::BodyParameter p_param) const {
+real_t RigidBodyBullet::get_param(PhysicsServer3D::BodyParameter p_param) const {
switch (p_param) {
- case PhysicsServer::BODY_PARAM_BOUNCE:
+ case PhysicsServer3D::BODY_PARAM_BOUNCE:
return btBody->getRestitution();
- case PhysicsServer::BODY_PARAM_FRICTION:
+ case PhysicsServer3D::BODY_PARAM_FRICTION:
return btBody->getFriction();
- case PhysicsServer::BODY_PARAM_MASS: {
+ case PhysicsServer3D::BODY_PARAM_MASS: {
const btScalar invMass = btBody->getInvMass();
return 0 == invMass ? 0 : 1 / invMass;
}
- case PhysicsServer::BODY_PARAM_LINEAR_DAMP:
+ case PhysicsServer3D::BODY_PARAM_LINEAR_DAMP:
return linearDamp;
- case PhysicsServer::BODY_PARAM_ANGULAR_DAMP:
+ case PhysicsServer3D::BODY_PARAM_ANGULAR_DAMP:
return angularDamp;
- case PhysicsServer::BODY_PARAM_GRAVITY_SCALE:
+ case PhysicsServer3D::BODY_PARAM_GRAVITY_SCALE:
return gravity_scale;
default:
WARN_PRINT("Parameter " + itos(p_param) + " not supported by bullet");
@@ -541,31 +541,31 @@ real_t RigidBodyBullet::get_param(PhysicsServer::BodyParameter p_param) const {
}
}
-void RigidBodyBullet::set_mode(PhysicsServer::BodyMode p_mode) {
+void RigidBodyBullet::set_mode(PhysicsServer3D::BodyMode p_mode) {
// This is necessary to block force_integration untile next move
can_integrate_forces = false;
destroy_kinematic_utilities();
// The mode change is relevant to its mass
switch (p_mode) {
- case PhysicsServer::BODY_MODE_KINEMATIC:
- mode = PhysicsServer::BODY_MODE_KINEMATIC;
+ case PhysicsServer3D::BODY_MODE_KINEMATIC:
+ mode = PhysicsServer3D::BODY_MODE_KINEMATIC;
reload_axis_lock();
_internal_set_mass(0);
init_kinematic_utilities();
break;
- case PhysicsServer::BODY_MODE_STATIC:
- mode = PhysicsServer::BODY_MODE_STATIC;
+ case PhysicsServer3D::BODY_MODE_STATIC:
+ mode = PhysicsServer3D::BODY_MODE_STATIC;
reload_axis_lock();
_internal_set_mass(0);
break;
- case PhysicsServer::BODY_MODE_RIGID:
- mode = PhysicsServer::BODY_MODE_RIGID;
+ case PhysicsServer3D::BODY_MODE_RIGID:
+ mode = PhysicsServer3D::BODY_MODE_RIGID;
reload_axis_lock();
_internal_set_mass(0 == mass ? 1 : mass);
scratch_space_override_modificator();
break;
- case PhysicsServer::BODY_MODE_CHARACTER:
- mode = PhysicsServer::BODY_MODE_CHARACTER;
+ case PhysicsServer3D::BODY_MODE_CHARACTER:
+ mode = PhysicsServer3D::BODY_MODE_CHARACTER;
reload_axis_lock();
_internal_set_mass(0 == mass ? 1 : mass);
scratch_space_override_modificator();
@@ -575,26 +575,26 @@ void RigidBodyBullet::set_mode(PhysicsServer::BodyMode p_mode) {
btBody->setAngularVelocity(btVector3(0, 0, 0));
btBody->setLinearVelocity(btVector3(0, 0, 0));
}
-PhysicsServer::BodyMode RigidBodyBullet::get_mode() const {
+PhysicsServer3D::BodyMode RigidBodyBullet::get_mode() const {
return mode;
}
-void RigidBodyBullet::set_state(PhysicsServer::BodyState p_state, const Variant &p_variant) {
+void RigidBodyBullet::set_state(PhysicsServer3D::BodyState p_state, const Variant &p_variant) {
switch (p_state) {
- case PhysicsServer::BODY_STATE_TRANSFORM:
+ case PhysicsServer3D::BODY_STATE_TRANSFORM:
set_transform(p_variant);
break;
- case PhysicsServer::BODY_STATE_LINEAR_VELOCITY:
+ case PhysicsServer3D::BODY_STATE_LINEAR_VELOCITY:
set_linear_velocity(p_variant);
break;
- case PhysicsServer::BODY_STATE_ANGULAR_VELOCITY:
+ case PhysicsServer3D::BODY_STATE_ANGULAR_VELOCITY:
set_angular_velocity(p_variant);
break;
- case PhysicsServer::BODY_STATE_SLEEPING:
+ case PhysicsServer3D::BODY_STATE_SLEEPING:
set_activation_state(!bool(p_variant));
break;
- case PhysicsServer::BODY_STATE_CAN_SLEEP:
+ case PhysicsServer3D::BODY_STATE_CAN_SLEEP:
can_sleep = bool(p_variant);
if (!can_sleep) {
// Can't sleep
@@ -606,17 +606,17 @@ void RigidBodyBullet::set_state(PhysicsServer::BodyState p_state, const Variant
}
}
-Variant RigidBodyBullet::get_state(PhysicsServer::BodyState p_state) const {
+Variant RigidBodyBullet::get_state(PhysicsServer3D::BodyState p_state) const {
switch (p_state) {
- case PhysicsServer::BODY_STATE_TRANSFORM:
+ case PhysicsServer3D::BODY_STATE_TRANSFORM:
return get_transform();
- case PhysicsServer::BODY_STATE_LINEAR_VELOCITY:
+ case PhysicsServer3D::BODY_STATE_LINEAR_VELOCITY:
return get_linear_velocity();
- case PhysicsServer::BODY_STATE_ANGULAR_VELOCITY:
+ case PhysicsServer3D::BODY_STATE_ANGULAR_VELOCITY:
return get_angular_velocity();
- case PhysicsServer::BODY_STATE_SLEEPING:
+ case PhysicsServer3D::BODY_STATE_SLEEPING:
return !is_active();
- case PhysicsServer::BODY_STATE_CAN_SLEEP:
+ case PhysicsServer3D::BODY_STATE_CAN_SLEEP:
return can_sleep;
default:
WARN_PRINT("This state " + itos(p_state) + " is not supported by Bullet");
@@ -714,7 +714,7 @@ Vector3 RigidBodyBullet::get_applied_torque() const {
return gTotTorq;
}
-void RigidBodyBullet::set_axis_lock(PhysicsServer::BodyAxis p_axis, bool lock) {
+void RigidBodyBullet::set_axis_lock(PhysicsServer3D::BodyAxis p_axis, bool lock) {
if (lock) {
locked_axis |= p_axis;
} else {
@@ -724,18 +724,18 @@ void RigidBodyBullet::set_axis_lock(PhysicsServer::BodyAxis p_axis, bool lock) {
reload_axis_lock();
}
-bool RigidBodyBullet::is_axis_locked(PhysicsServer::BodyAxis p_axis) const {
+bool RigidBodyBullet::is_axis_locked(PhysicsServer3D::BodyAxis p_axis) const {
return locked_axis & p_axis;
}
void RigidBodyBullet::reload_axis_lock() {
- btBody->setLinearFactor(btVector3(float(!is_axis_locked(PhysicsServer::BODY_AXIS_LINEAR_X)), float(!is_axis_locked(PhysicsServer::BODY_AXIS_LINEAR_Y)), float(!is_axis_locked(PhysicsServer::BODY_AXIS_LINEAR_Z))));
- if (PhysicsServer::BODY_MODE_CHARACTER == mode) {
+ btBody->setLinearFactor(btVector3(float(!is_axis_locked(PhysicsServer3D::BODY_AXIS_LINEAR_X)), float(!is_axis_locked(PhysicsServer3D::BODY_AXIS_LINEAR_Y)), float(!is_axis_locked(PhysicsServer3D::BODY_AXIS_LINEAR_Z))));
+ if (PhysicsServer3D::BODY_MODE_CHARACTER == mode) {
/// When character angular is always locked
btBody->setAngularFactor(btVector3(0., 0., 0.));
} else {
- btBody->setAngularFactor(btVector3(float(!is_axis_locked(PhysicsServer::BODY_AXIS_ANGULAR_X)), float(!is_axis_locked(PhysicsServer::BODY_AXIS_ANGULAR_Y)), float(!is_axis_locked(PhysicsServer::BODY_AXIS_ANGULAR_Z))));
+ btBody->setAngularFactor(btVector3(float(!is_axis_locked(PhysicsServer3D::BODY_AXIS_ANGULAR_X)), float(!is_axis_locked(PhysicsServer3D::BODY_AXIS_ANGULAR_Y)), float(!is_axis_locked(PhysicsServer3D::BODY_AXIS_ANGULAR_Z))));
}
}
@@ -794,7 +794,7 @@ Vector3 RigidBodyBullet::get_angular_velocity() const {
}
void RigidBodyBullet::set_transform__bullet(const btTransform &p_global_transform) {
- if (mode == PhysicsServer::BODY_MODE_KINEMATIC) {
+ if (mode == PhysicsServer3D::BODY_MODE_KINEMATIC) {
if (space && space->get_delta_time() != 0)
btBody->setLinearVelocity((p_global_transform.getOrigin() - btBody->getWorldTransform().getOrigin()) / space->get_delta_time());
// The kinematic use MotionState class
@@ -847,7 +847,7 @@ void RigidBodyBullet::on_enter_area(AreaBullet *p_area) {
}
for (int i = 0; i < areaWhereIamCount; ++i) {
- if (NULL == areasWhereIam[i]) {
+ if (nullptr == areasWhereIam[i]) {
// This area has the highest priority
areasWhereIam.write[i] = p_area;
break;
@@ -862,7 +862,7 @@ void RigidBodyBullet::on_enter_area(AreaBullet *p_area) {
}
}
}
- if (PhysicsServer::AREA_SPACE_OVERRIDE_DISABLED != p_area->get_spOv_mode()) {
+ if (PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED != p_area->get_spOv_mode()) {
scratch_space_override_modificator();
}
@@ -894,8 +894,8 @@ void RigidBodyBullet::on_exit_area(AreaBullet *p_area) {
}
--areaWhereIamCount;
- areasWhereIam.write[areaWhereIamCount] = NULL; // Even if this is not required, I clear the last element to be safe
- if (PhysicsServer::AREA_SPACE_OVERRIDE_DISABLED != p_area->get_spOv_mode()) {
+ areasWhereIam.write[areaWhereIamCount] = nullptr; // Even if this is not required, I clear the last element to be safe
+ if (PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED != p_area->get_spOv_mode()) {
scratch_space_override_modificator();
}
}
@@ -904,7 +904,7 @@ void RigidBodyBullet::on_exit_area(AreaBullet *p_area) {
void RigidBodyBullet::reload_space_override_modificator() {
// Make sure that kinematic bodies have their total gravity calculated
- if (!is_active() && PhysicsServer::BODY_MODE_KINEMATIC != mode)
+ if (!is_active() && PhysicsServer3D::BODY_MODE_KINEMATIC != mode)
return;
Vector3 newGravity(space->get_gravity_direction() * space->get_gravity_magnitude());
@@ -920,7 +920,7 @@ void RigidBodyBullet::reload_space_override_modificator() {
currentArea = areasWhereIam[i];
- if (!currentArea || PhysicsServer::AREA_SPACE_OVERRIDE_DISABLED == currentArea->get_spOv_mode()) {
+ if (!currentArea || PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED == currentArea->get_spOv_mode()) {
continue;
}
@@ -954,11 +954,11 @@ void RigidBodyBullet::reload_space_override_modificator() {
}
switch (currentArea->get_spOv_mode()) {
- case PhysicsServer::AREA_SPACE_OVERRIDE_DISABLED:
+ case PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED:
/// This area does not affect gravity/damp. These are generally areas
/// that exist only to detect collisions, and objects entering or exiting them.
break;
- case PhysicsServer::AREA_SPACE_OVERRIDE_COMBINE:
+ case PhysicsServer3D::AREA_SPACE_OVERRIDE_COMBINE:
/// This area adds its gravity/damp values to whatever has been
/// calculated so far. This way, many overlapping areas can combine
/// their physics to make interesting
@@ -967,7 +967,7 @@ void RigidBodyBullet::reload_space_override_modificator() {
newAngularDamp += currentArea->get_spOv_angularDamp();
++countCombined;
break;
- case PhysicsServer::AREA_SPACE_OVERRIDE_COMBINE_REPLACE:
+ case PhysicsServer3D::AREA_SPACE_OVERRIDE_COMBINE_REPLACE:
/// This area adds its gravity/damp values to whatever has been calculated
/// so far. Then stops taking into account the rest of the areas, even the
/// default one.
@@ -976,7 +976,7 @@ void RigidBodyBullet::reload_space_override_modificator() {
newAngularDamp += currentArea->get_spOv_angularDamp();
++countCombined;
goto endAreasCycle;
- case PhysicsServer::AREA_SPACE_OVERRIDE_REPLACE:
+ case PhysicsServer3D::AREA_SPACE_OVERRIDE_REPLACE:
/// This area replaces any gravity/damp, even the default one, and
/// stops taking into account the rest of the areas.
newGravity = support_gravity;
@@ -984,7 +984,7 @@ void RigidBodyBullet::reload_space_override_modificator() {
newAngularDamp = currentArea->get_spOv_angularDamp();
countCombined = 1;
goto endAreasCycle;
- case PhysicsServer::AREA_SPACE_OVERRIDE_REPLACE_COMBINE:
+ case PhysicsServer3D::AREA_SPACE_OVERRIDE_REPLACE_COMBINE:
/// This area replaces any gravity/damp calculated so far, but keeps
/// calculating the rest of the areas, down to the default one.
newGravity = support_gravity;
@@ -1032,14 +1032,14 @@ void RigidBodyBullet::_internal_set_mass(real_t p_mass) {
const bool isDynamic = p_mass != 0.f;
if (isDynamic) {
- if (PhysicsServer::BODY_MODE_RIGID != mode && PhysicsServer::BODY_MODE_CHARACTER != mode)
+ if (PhysicsServer3D::BODY_MODE_RIGID != mode && PhysicsServer3D::BODY_MODE_CHARACTER != mode)
return;
m_isStatic = false;
if (mainShape)
mainShape->calculateLocalInertia(p_mass, localInertia);
- if (PhysicsServer::BODY_MODE_RIGID == mode) {
+ if (PhysicsServer3D::BODY_MODE_RIGID == mode) {
btBody->setCollisionFlags(clearedCurrentFlags); // Just set the flags without Kin and Static
} else {
@@ -1054,11 +1054,11 @@ void RigidBodyBullet::_internal_set_mass(real_t p_mass) {
}
} else {
- if (PhysicsServer::BODY_MODE_STATIC != mode && PhysicsServer::BODY_MODE_KINEMATIC != mode)
+ if (PhysicsServer3D::BODY_MODE_STATIC != mode && PhysicsServer3D::BODY_MODE_KINEMATIC != mode)
return;
m_isStatic = true;
- if (PhysicsServer::BODY_MODE_STATIC == mode) {
+ if (PhysicsServer3D::BODY_MODE_STATIC == mode) {
btBody->setCollisionFlags(clearedCurrentFlags | btCollisionObject::CF_STATIC_OBJECT);
} else {
diff --git a/modules/bullet/rigid_body_bullet.h b/modules/bullet/rigid_body_bullet.h
index ca599f7a77..420b5cc443 100644
--- a/modules/bullet/rigid_body_bullet.h
+++ b/modules/bullet/rigid_body_bullet.h
@@ -45,37 +45,37 @@ class AreaBullet;
class SpaceBullet;
class btRigidBody;
class GodotMotionState;
-class BulletPhysicsDirectBodyState;
+class BulletPhysicsDirectBodyState3D;
/// This class could be used in multi thread with few changes but currently
/// is set to be only in one single thread.
///
/// In the system there is only one object at a time that manage all bodies and is
-/// created by BulletPhysicsServer and is held by the "singleton" variable of this class
+/// created by BulletPhysicsServer3D and is held by the "singleton" variable of this class
/// Each time something require it, the body must be set again.
-class BulletPhysicsDirectBodyState : public PhysicsDirectBodyState {
- GDCLASS(BulletPhysicsDirectBodyState, PhysicsDirectBodyState);
+class BulletPhysicsDirectBodyState3D : public PhysicsDirectBodyState3D {
+ GDCLASS(BulletPhysicsDirectBodyState3D, PhysicsDirectBodyState3D);
- static BulletPhysicsDirectBodyState *singleton;
+ static BulletPhysicsDirectBodyState3D *singleton;
public:
/// This class avoid the creation of more object of this class
static void initSingleton() {
if (!singleton) {
- singleton = memnew(BulletPhysicsDirectBodyState);
+ singleton = memnew(BulletPhysicsDirectBodyState3D);
}
}
static void destroySingleton() {
memdelete(singleton);
- singleton = NULL;
+ singleton = nullptr;
}
static void singleton_setDeltaTime(real_t p_deltaTime) {
singleton->deltaTime = p_deltaTime;
}
- static BulletPhysicsDirectBodyState *get_singleton(RigidBodyBullet *p_body) {
+ static BulletPhysicsDirectBodyState3D *get_singleton(RigidBodyBullet *p_body) {
singleton->body = p_body;
return singleton;
}
@@ -85,7 +85,7 @@ public:
real_t deltaTime;
private:
- BulletPhysicsDirectBodyState() {}
+ BulletPhysicsDirectBodyState3D() {}
public:
virtual Vector3 get_total_gravity() const;
@@ -117,7 +117,7 @@ public:
virtual void apply_impulse(const Vector3 &p_pos, const Vector3 &p_impulse);
virtual void apply_torque_impulse(const Vector3 &p_impulse);
- virtual void set_sleep_state(bool p_enable);
+ virtual void set_sleep_state(bool p_sleep);
virtual bool is_sleeping() const;
virtual int get_contact_count() const;
@@ -138,7 +138,7 @@ public:
// Skip the execution of this function
}
- virtual PhysicsDirectSpaceState *get_space_state();
+ virtual PhysicsDirectSpaceState3D *get_space_state();
};
class RigidBodyBullet : public RigidCollisionObjectBullet {
@@ -166,7 +166,7 @@ public:
btTransform transform;
KinematicShape() :
- shape(NULL) {}
+ shape(nullptr) {}
bool is_active() const { return shape; }
};
@@ -187,12 +187,12 @@ public:
};
private:
- friend class BulletPhysicsDirectBodyState;
+ friend class BulletPhysicsDirectBodyState3D;
// This is required only for Kinematic movement
KinematicUtilities *kinematic_utilities;
- PhysicsServer::BodyMode mode;
+ PhysicsServer3D::BodyMode mode;
GodotMotionState *godotMotionState;
btRigidBody *btBody;
uint16_t locked_axis;
@@ -278,14 +278,14 @@ public:
void set_omit_forces_integration(bool p_omit);
_FORCE_INLINE_ bool get_omit_forces_integration() const { return omit_forces_integration; }
- void set_param(PhysicsServer::BodyParameter p_param, real_t);
- real_t get_param(PhysicsServer::BodyParameter p_param) const;
+ void set_param(PhysicsServer3D::BodyParameter p_param, real_t);
+ real_t get_param(PhysicsServer3D::BodyParameter p_param) const;
- void set_mode(PhysicsServer::BodyMode p_mode);
- PhysicsServer::BodyMode get_mode() const;
+ void set_mode(PhysicsServer3D::BodyMode p_mode);
+ PhysicsServer3D::BodyMode get_mode() const;
- void set_state(PhysicsServer::BodyState p_state, const Variant &p_variant);
- Variant get_state(PhysicsServer::BodyState p_state) const;
+ void set_state(PhysicsServer3D::BodyState p_state, const Variant &p_variant);
+ Variant get_state(PhysicsServer3D::BodyState p_state) const;
void apply_impulse(const Vector3 &p_pos, const Vector3 &p_impulse);
void apply_central_impulse(const Vector3 &p_impulse);
@@ -300,8 +300,8 @@ public:
void set_applied_torque(const Vector3 &p_torque);
Vector3 get_applied_torque() const;
- void set_axis_lock(PhysicsServer::BodyAxis p_axis, bool lock);
- bool is_axis_locked(PhysicsServer::BodyAxis p_axis) const;
+ void set_axis_lock(PhysicsServer3D::BodyAxis p_axis, bool lock);
+ bool is_axis_locked(PhysicsServer3D::BodyAxis p_axis) const;
void reload_axis_lock();
/// Doc:
diff --git a/modules/bullet/shape_bullet.cpp b/modules/bullet/shape_bullet.cpp
index 6780f89d9e..8ac26a0fdb 100644
--- a/modules/bullet/shape_bullet.cpp
+++ b/modules/bullet/shape_bullet.cpp
@@ -138,7 +138,7 @@ btScaledBvhTriangleMeshShape *ShapeBullet::create_shape_concave(btBvhTriangleMes
if (p_mesh_shape) {
return bulletnew(btScaledBvhTriangleMeshShape(p_mesh_shape, p_local_scaling));
} else {
- return NULL;
+ return nullptr;
}
}
@@ -150,7 +150,7 @@ btHeightfieldTerrainShape *ShapeBullet::create_shape_height_field(Vector<real_t>
btHeightfieldTerrainShape *heightfield = bulletnew(btHeightfieldTerrainShape(p_width, p_depth, heightsPtr, ignoredHeightScale, p_min_height, p_max_height, YAxis, PHY_FLOAT, flipQuadEdges));
- // The shape can be created without params when you do PhysicsServer.shape_create(PhysicsServer.SHAPE_HEIGHTMAP)
+ // The shape can be created without params when you do PhysicsServer3D.shape_create(PhysicsServer3D.SHAPE_HEIGHTMAP)
if (heightsPtr)
heightfield->buildAccelerator(16);
@@ -176,8 +176,8 @@ Variant PlaneShapeBullet::get_data() const {
return plane;
}
-PhysicsServer::ShapeType PlaneShapeBullet::get_type() const {
- return PhysicsServer::SHAPE_PLANE;
+PhysicsServer3D::ShapeType PlaneShapeBullet::get_type() const {
+ return PhysicsServer3D::SHAPE_PLANE;
}
void PlaneShapeBullet::setup(const Plane &p_plane) {
@@ -204,8 +204,8 @@ Variant SphereShapeBullet::get_data() const {
return radius;
}
-PhysicsServer::ShapeType SphereShapeBullet::get_type() const {
- return PhysicsServer::SHAPE_SPHERE;
+PhysicsServer3D::ShapeType SphereShapeBullet::get_type() const {
+ return PhysicsServer3D::SHAPE_SPHERE;
}
void SphereShapeBullet::setup(real_t p_radius) {
@@ -231,8 +231,8 @@ Variant BoxShapeBullet::get_data() const {
return g_half_extents;
}
-PhysicsServer::ShapeType BoxShapeBullet::get_type() const {
- return PhysicsServer::SHAPE_BOX;
+PhysicsServer3D::ShapeType BoxShapeBullet::get_type() const {
+ return PhysicsServer3D::SHAPE_BOX;
}
void BoxShapeBullet::setup(const Vector3 &p_half_extents) {
@@ -263,8 +263,8 @@ Variant CapsuleShapeBullet::get_data() const {
return d;
}
-PhysicsServer::ShapeType CapsuleShapeBullet::get_type() const {
- return PhysicsServer::SHAPE_CAPSULE;
+PhysicsServer3D::ShapeType CapsuleShapeBullet::get_type() const {
+ return PhysicsServer3D::SHAPE_CAPSULE;
}
void CapsuleShapeBullet::setup(real_t p_height, real_t p_radius) {
@@ -296,8 +296,8 @@ Variant CylinderShapeBullet::get_data() const {
return d;
}
-PhysicsServer::ShapeType CylinderShapeBullet::get_type() const {
- return PhysicsServer::SHAPE_CYLINDER;
+PhysicsServer3D::ShapeType CylinderShapeBullet::get_type() const {
+ return PhysicsServer3D::SHAPE_CYLINDER;
}
void CylinderShapeBullet::setup(real_t p_height, real_t p_radius) {
@@ -334,8 +334,8 @@ Variant ConvexPolygonShapeBullet::get_data() const {
return out_vertices;
}
-PhysicsServer::ShapeType ConvexPolygonShapeBullet::get_type() const {
- return PhysicsServer::SHAPE_CONVEX_POLYGON;
+PhysicsServer3D::ShapeType ConvexPolygonShapeBullet::get_type() const {
+ return PhysicsServer3D::SHAPE_CONVEX_POLYGON;
}
void ConvexPolygonShapeBullet::setup(const Vector<Vector3> &p_vertices) {
@@ -362,7 +362,7 @@ btCollisionShape *ConvexPolygonShapeBullet::create_bt_shape(const btVector3 &p_i
ConcavePolygonShapeBullet::ConcavePolygonShapeBullet() :
ShapeBullet(),
- meshShape(NULL) {}
+ meshShape(nullptr) {}
ConcavePolygonShapeBullet::~ConcavePolygonShapeBullet() {
if (meshShape) {
@@ -381,8 +381,8 @@ Variant ConcavePolygonShapeBullet::get_data() const {
return faces;
}
-PhysicsServer::ShapeType ConcavePolygonShapeBullet::get_type() const {
- return PhysicsServer::SHAPE_CONCAVE_POLYGON;
+PhysicsServer3D::ShapeType ConcavePolygonShapeBullet::get_type() const {
+ return PhysicsServer3D::SHAPE_CONCAVE_POLYGON;
}
void ConcavePolygonShapeBullet::setup(Vector<Vector3> p_faces) {
@@ -425,7 +425,7 @@ void ConcavePolygonShapeBullet::setup(Vector<Vector3> p_faces) {
btGenerateInternalEdgeInfo(meshShape, triangleInfoMap);
}
} else {
- meshShape = NULL;
+ meshShape = nullptr;
ERR_PRINT("The faces count are 0, the mesh shape cannot be created");
}
notifyShapeChanged();
@@ -434,7 +434,7 @@ void ConcavePolygonShapeBullet::setup(Vector<Vector3> p_faces) {
btCollisionShape *ConcavePolygonShapeBullet::create_bt_shape(const btVector3 &p_implicit_scale, real_t p_extra_edge) {
btCollisionShape *cs = ShapeBullet::create_shape_concave(meshShape);
if (!cs)
- // This is necessary since if 0 faces the creation of concave return NULL
+ // This is necessary since if 0 faces the creation of concave return null
cs = ShapeBullet::create_shape_empty();
cs->setLocalScaling(p_implicit_scale);
prepare(cs);
@@ -536,8 +536,8 @@ Variant HeightMapShapeBullet::get_data() const {
ERR_FAIL_V(Variant());
}
-PhysicsServer::ShapeType HeightMapShapeBullet::get_type() const {
- return PhysicsServer::SHAPE_HEIGHTMAP;
+PhysicsServer3D::ShapeType HeightMapShapeBullet::get_type() const {
+ return PhysicsServer3D::SHAPE_HEIGHTMAP;
}
void HeightMapShapeBullet::setup(Vector<real_t> &p_heights, int p_width, int p_depth, real_t p_min_height, real_t p_max_height) {
@@ -580,8 +580,8 @@ Variant RayShapeBullet::get_data() const {
return d;
}
-PhysicsServer::ShapeType RayShapeBullet::get_type() const {
- return PhysicsServer::SHAPE_RAY;
+PhysicsServer3D::ShapeType RayShapeBullet::get_type() const {
+ return PhysicsServer3D::SHAPE_RAY;
}
void RayShapeBullet::setup(real_t p_length, bool p_slips_on_slope) {
diff --git a/modules/bullet/shape_bullet.h b/modules/bullet/shape_bullet.h
index c8b5ca102a..0dbc616fe5 100644
--- a/modules/bullet/shape_bullet.h
+++ b/modules/bullet/shape_bullet.h
@@ -34,7 +34,7 @@
#include "core/math/geometry.h"
#include "core/variant.h"
#include "rid_bullet.h"
-#include "servers/physics_server.h"
+#include "servers/physics_server_3d.h"
#include <LinearMath/btAlignedObjectArray.h>
#include <LinearMath/btScalar.h>
@@ -78,7 +78,7 @@ public:
virtual void set_data(const Variant &p_data) = 0;
virtual Variant get_data() const = 0;
- virtual PhysicsServer::ShapeType get_type() const = 0;
+ virtual PhysicsServer3D::ShapeType get_type() const = 0;
public:
static class btEmptyShape *create_shape_empty();
@@ -103,7 +103,7 @@ public:
virtual void set_data(const Variant &p_data);
virtual Variant get_data() const;
- virtual PhysicsServer::ShapeType get_type() const;
+ virtual PhysicsServer3D::ShapeType get_type() const;
virtual btCollisionShape *create_bt_shape(const btVector3 &p_implicit_scale, real_t p_extra_edge = 0);
private:
@@ -120,7 +120,7 @@ public:
_FORCE_INLINE_ real_t get_radius() { return radius; }
virtual void set_data(const Variant &p_data);
virtual Variant get_data() const;
- virtual PhysicsServer::ShapeType get_type() const;
+ virtual PhysicsServer3D::ShapeType get_type() const;
virtual btCollisionShape *create_bt_shape(const btVector3 &p_implicit_scale, real_t p_extra_edge = 0);
private:
@@ -137,7 +137,7 @@ public:
_FORCE_INLINE_ const btVector3 &get_half_extents() { return half_extents; }
virtual void set_data(const Variant &p_data);
virtual Variant get_data() const;
- virtual PhysicsServer::ShapeType get_type() const;
+ virtual PhysicsServer3D::ShapeType get_type() const;
virtual btCollisionShape *create_bt_shape(const btVector3 &p_implicit_scale, real_t p_extra_edge = 0);
private:
@@ -156,7 +156,7 @@ public:
_FORCE_INLINE_ real_t get_radius() { return radius; }
virtual void set_data(const Variant &p_data);
virtual Variant get_data() const;
- virtual PhysicsServer::ShapeType get_type() const;
+ virtual PhysicsServer3D::ShapeType get_type() const;
virtual btCollisionShape *create_bt_shape(const btVector3 &p_implicit_scale, real_t p_extra_edge = 0);
private:
@@ -175,7 +175,7 @@ public:
_FORCE_INLINE_ real_t get_radius() { return radius; }
virtual void set_data(const Variant &p_data);
virtual Variant get_data() const;
- virtual PhysicsServer::ShapeType get_type() const;
+ virtual PhysicsServer3D::ShapeType get_type() const;
virtual btCollisionShape *create_bt_shape(const btVector3 &p_implicit_scale, real_t p_margin = 0);
private:
@@ -192,7 +192,7 @@ public:
virtual void set_data(const Variant &p_data);
void get_vertices(Vector<Vector3> &out_vertices);
virtual Variant get_data() const;
- virtual PhysicsServer::ShapeType get_type() const;
+ virtual PhysicsServer3D::ShapeType get_type() const;
virtual btCollisionShape *create_bt_shape(const btVector3 &p_implicit_scale, real_t p_extra_edge = 0);
private:
@@ -210,7 +210,7 @@ public:
virtual void set_data(const Variant &p_data);
virtual Variant get_data() const;
- virtual PhysicsServer::ShapeType get_type() const;
+ virtual PhysicsServer3D::ShapeType get_type() const;
virtual btCollisionShape *create_bt_shape(const btVector3 &p_implicit_scale, real_t p_extra_edge = 0);
private:
@@ -230,7 +230,7 @@ public:
virtual void set_data(const Variant &p_data);
virtual Variant get_data() const;
- virtual PhysicsServer::ShapeType get_type() const;
+ virtual PhysicsServer3D::ShapeType get_type() const;
virtual btCollisionShape *create_bt_shape(const btVector3 &p_implicit_scale, real_t p_extra_edge = 0);
private:
@@ -247,7 +247,7 @@ public:
virtual void set_data(const Variant &p_data);
virtual Variant get_data() const;
- virtual PhysicsServer::ShapeType get_type() const;
+ virtual PhysicsServer3D::ShapeType get_type() const;
virtual btCollisionShape *create_bt_shape(const btVector3 &p_implicit_scale, real_t p_extra_edge = 0);
private:
diff --git a/modules/bullet/slider_joint_bullet.cpp b/modules/bullet/slider_joint_bullet.cpp
index d9ebb9d580..f193daef39 100644
--- a/modules/bullet/slider_joint_bullet.cpp
+++ b/modules/bullet/slider_joint_bullet.cpp
@@ -342,58 +342,58 @@ real_t SliderJointBullet::getLinearPos() {
;
}
-void SliderJointBullet::set_param(PhysicsServer::SliderJointParam p_param, real_t p_value) {
+void SliderJointBullet::set_param(PhysicsServer3D::SliderJointParam p_param, real_t p_value) {
switch (p_param) {
- case PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_UPPER: setUpperLinLimit(p_value); break;
- case PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_LOWER: setLowerLinLimit(p_value); break;
- case PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_SOFTNESS: setSoftnessLimLin(p_value); break;
- case PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_RESTITUTION: setRestitutionLimLin(p_value); break;
- case PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_DAMPING: setDampingLimLin(p_value); break;
- case PhysicsServer::SLIDER_JOINT_LINEAR_MOTION_SOFTNESS: setSoftnessDirLin(p_value); break;
- case PhysicsServer::SLIDER_JOINT_LINEAR_MOTION_RESTITUTION: setRestitutionDirLin(p_value); break;
- case PhysicsServer::SLIDER_JOINT_LINEAR_MOTION_DAMPING: setDampingDirLin(p_value); break;
- case PhysicsServer::SLIDER_JOINT_LINEAR_ORTHOGONAL_SOFTNESS: setSoftnessOrthoLin(p_value); break;
- case PhysicsServer::SLIDER_JOINT_LINEAR_ORTHOGONAL_RESTITUTION: setRestitutionOrthoLin(p_value); break;
- case PhysicsServer::SLIDER_JOINT_LINEAR_ORTHOGONAL_DAMPING: setDampingOrthoLin(p_value); break;
- case PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_UPPER: setUpperAngLimit(p_value); break;
- case PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_LOWER: setLowerAngLimit(p_value); break;
- case PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS: setSoftnessLimAng(p_value); break;
- case PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_RESTITUTION: setRestitutionLimAng(p_value); break;
- case PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_DAMPING: setDampingLimAng(p_value); break;
- case PhysicsServer::SLIDER_JOINT_ANGULAR_MOTION_SOFTNESS: setSoftnessDirAng(p_value); break;
- case PhysicsServer::SLIDER_JOINT_ANGULAR_MOTION_RESTITUTION: setRestitutionDirAng(p_value); break;
- case PhysicsServer::SLIDER_JOINT_ANGULAR_MOTION_DAMPING: setDampingDirAng(p_value); break;
- case PhysicsServer::SLIDER_JOINT_ANGULAR_ORTHOGONAL_SOFTNESS: setSoftnessOrthoAng(p_value); break;
- case PhysicsServer::SLIDER_JOINT_ANGULAR_ORTHOGONAL_RESTITUTION: setRestitutionOrthoAng(p_value); break;
- case PhysicsServer::SLIDER_JOINT_ANGULAR_ORTHOGONAL_DAMPING: setDampingOrthoAng(p_value); break;
- case PhysicsServer::SLIDER_JOINT_MAX: break; // Can't happen, but silences warning
+ case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_UPPER: setUpperLinLimit(p_value); break;
+ case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_LOWER: setLowerLinLimit(p_value); break;
+ case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_SOFTNESS: setSoftnessLimLin(p_value); break;
+ case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_RESTITUTION: setRestitutionLimLin(p_value); break;
+ case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_DAMPING: setDampingLimLin(p_value); break;
+ case PhysicsServer3D::SLIDER_JOINT_LINEAR_MOTION_SOFTNESS: setSoftnessDirLin(p_value); break;
+ case PhysicsServer3D::SLIDER_JOINT_LINEAR_MOTION_RESTITUTION: setRestitutionDirLin(p_value); break;
+ case PhysicsServer3D::SLIDER_JOINT_LINEAR_MOTION_DAMPING: setDampingDirLin(p_value); break;
+ case PhysicsServer3D::SLIDER_JOINT_LINEAR_ORTHOGONAL_SOFTNESS: setSoftnessOrthoLin(p_value); break;
+ case PhysicsServer3D::SLIDER_JOINT_LINEAR_ORTHOGONAL_RESTITUTION: setRestitutionOrthoLin(p_value); break;
+ case PhysicsServer3D::SLIDER_JOINT_LINEAR_ORTHOGONAL_DAMPING: setDampingOrthoLin(p_value); break;
+ case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_UPPER: setUpperAngLimit(p_value); break;
+ case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_LOWER: setLowerAngLimit(p_value); break;
+ case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS: setSoftnessLimAng(p_value); break;
+ case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_RESTITUTION: setRestitutionLimAng(p_value); break;
+ case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_DAMPING: setDampingLimAng(p_value); break;
+ case PhysicsServer3D::SLIDER_JOINT_ANGULAR_MOTION_SOFTNESS: setSoftnessDirAng(p_value); break;
+ case PhysicsServer3D::SLIDER_JOINT_ANGULAR_MOTION_RESTITUTION: setRestitutionDirAng(p_value); break;
+ case PhysicsServer3D::SLIDER_JOINT_ANGULAR_MOTION_DAMPING: setDampingDirAng(p_value); break;
+ case PhysicsServer3D::SLIDER_JOINT_ANGULAR_ORTHOGONAL_SOFTNESS: setSoftnessOrthoAng(p_value); break;
+ case PhysicsServer3D::SLIDER_JOINT_ANGULAR_ORTHOGONAL_RESTITUTION: setRestitutionOrthoAng(p_value); break;
+ case PhysicsServer3D::SLIDER_JOINT_ANGULAR_ORTHOGONAL_DAMPING: setDampingOrthoAng(p_value); break;
+ case PhysicsServer3D::SLIDER_JOINT_MAX: break; // Can't happen, but silences warning
}
}
-real_t SliderJointBullet::get_param(PhysicsServer::SliderJointParam p_param) const {
+real_t SliderJointBullet::get_param(PhysicsServer3D::SliderJointParam p_param) const {
switch (p_param) {
- case PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_UPPER: return getUpperLinLimit();
- case PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_LOWER: return getLowerLinLimit();
- case PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_SOFTNESS: return getSoftnessLimLin();
- case PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_RESTITUTION: return getRestitutionLimLin();
- case PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_DAMPING: return getDampingLimLin();
- case PhysicsServer::SLIDER_JOINT_LINEAR_MOTION_SOFTNESS: return getSoftnessDirLin();
- case PhysicsServer::SLIDER_JOINT_LINEAR_MOTION_RESTITUTION: return getRestitutionDirLin();
- case PhysicsServer::SLIDER_JOINT_LINEAR_MOTION_DAMPING: return getDampingDirLin();
- case PhysicsServer::SLIDER_JOINT_LINEAR_ORTHOGONAL_SOFTNESS: return getSoftnessOrthoLin();
- case PhysicsServer::SLIDER_JOINT_LINEAR_ORTHOGONAL_RESTITUTION: return getRestitutionOrthoLin();
- case PhysicsServer::SLIDER_JOINT_LINEAR_ORTHOGONAL_DAMPING: return getDampingOrthoLin();
- case PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_UPPER: return getUpperAngLimit();
- case PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_LOWER: return getLowerAngLimit();
- case PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS: return getSoftnessLimAng();
- case PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_RESTITUTION: return getRestitutionLimAng();
- case PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_DAMPING: return getDampingLimAng();
- case PhysicsServer::SLIDER_JOINT_ANGULAR_MOTION_SOFTNESS: return getSoftnessDirAng();
- case PhysicsServer::SLIDER_JOINT_ANGULAR_MOTION_RESTITUTION: return getRestitutionDirAng();
- case PhysicsServer::SLIDER_JOINT_ANGULAR_MOTION_DAMPING: return getDampingDirAng();
- case PhysicsServer::SLIDER_JOINT_ANGULAR_ORTHOGONAL_SOFTNESS: return getSoftnessOrthoAng();
- case PhysicsServer::SLIDER_JOINT_ANGULAR_ORTHOGONAL_RESTITUTION: return getRestitutionOrthoAng();
- case PhysicsServer::SLIDER_JOINT_ANGULAR_ORTHOGONAL_DAMPING: return getDampingOrthoAng();
+ case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_UPPER: return getUpperLinLimit();
+ case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_LOWER: return getLowerLinLimit();
+ case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_SOFTNESS: return getSoftnessLimLin();
+ case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_RESTITUTION: return getRestitutionLimLin();
+ case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_DAMPING: return getDampingLimLin();
+ case PhysicsServer3D::SLIDER_JOINT_LINEAR_MOTION_SOFTNESS: return getSoftnessDirLin();
+ case PhysicsServer3D::SLIDER_JOINT_LINEAR_MOTION_RESTITUTION: return getRestitutionDirLin();
+ case PhysicsServer3D::SLIDER_JOINT_LINEAR_MOTION_DAMPING: return getDampingDirLin();
+ case PhysicsServer3D::SLIDER_JOINT_LINEAR_ORTHOGONAL_SOFTNESS: return getSoftnessOrthoLin();
+ case PhysicsServer3D::SLIDER_JOINT_LINEAR_ORTHOGONAL_RESTITUTION: return getRestitutionOrthoLin();
+ case PhysicsServer3D::SLIDER_JOINT_LINEAR_ORTHOGONAL_DAMPING: return getDampingOrthoLin();
+ case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_UPPER: return getUpperAngLimit();
+ case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_LOWER: return getLowerAngLimit();
+ case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS: return getSoftnessLimAng();
+ case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_RESTITUTION: return getRestitutionLimAng();
+ case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_DAMPING: return getDampingLimAng();
+ case PhysicsServer3D::SLIDER_JOINT_ANGULAR_MOTION_SOFTNESS: return getSoftnessDirAng();
+ case PhysicsServer3D::SLIDER_JOINT_ANGULAR_MOTION_RESTITUTION: return getRestitutionDirAng();
+ case PhysicsServer3D::SLIDER_JOINT_ANGULAR_MOTION_DAMPING: return getDampingDirAng();
+ case PhysicsServer3D::SLIDER_JOINT_ANGULAR_ORTHOGONAL_SOFTNESS: return getSoftnessOrthoAng();
+ case PhysicsServer3D::SLIDER_JOINT_ANGULAR_ORTHOGONAL_RESTITUTION: return getRestitutionOrthoAng();
+ case PhysicsServer3D::SLIDER_JOINT_ANGULAR_ORTHOGONAL_DAMPING: return getDampingOrthoAng();
default:
return 0;
}
diff --git a/modules/bullet/slider_joint_bullet.h b/modules/bullet/slider_joint_bullet.h
index d98a1b8c95..6410b952ed 100644
--- a/modules/bullet/slider_joint_bullet.h
+++ b/modules/bullet/slider_joint_bullet.h
@@ -46,7 +46,7 @@ public:
/// Reference frame is A
SliderJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, const Transform &frameInA, const Transform &frameInB);
- virtual PhysicsServer::JointType get_type() const { return PhysicsServer::JOINT_SLIDER; }
+ virtual PhysicsServer3D::JointType get_type() const { return PhysicsServer3D::JOINT_SLIDER; }
const RigidBodyBullet *getRigidBodyA() const;
const RigidBodyBullet *getRigidBodyB() const;
@@ -115,7 +115,7 @@ public:
real_t getMaxAngMotorForce();
real_t getLinearPos();
- void set_param(PhysicsServer::SliderJointParam p_param, real_t p_value);
- real_t get_param(PhysicsServer::SliderJointParam p_param) const;
+ void set_param(PhysicsServer3D::SliderJointParam p_param, real_t p_value);
+ real_t get_param(PhysicsServer3D::SliderJointParam p_param) const;
};
#endif
diff --git a/modules/bullet/soft_body_bullet.cpp b/modules/bullet/soft_body_bullet.cpp
index f21206dd0d..236bdc7c8a 100644
--- a/modules/bullet/soft_body_bullet.cpp
+++ b/modules/bullet/soft_body_bullet.cpp
@@ -32,12 +32,12 @@
#include "bullet_types_converter.h"
#include "bullet_utilities.h"
-#include "scene/3d/soft_body.h"
+#include "scene/3d/soft_body_3d.h"
#include "space_bullet.h"
SoftBodyBullet::SoftBodyBullet() :
CollisionObjectBullet(CollisionObjectBullet::TYPE_SOFT_BODY),
- bt_soft_body(NULL),
+ bt_soft_body(nullptr),
isScratched(false),
simulation_precision(5),
total_mass(1.),
@@ -76,7 +76,7 @@ void SoftBodyBullet::on_enter_area(AreaBullet *p_area) {}
void SoftBodyBullet::on_exit_area(AreaBullet *p_area) {}
-void SoftBodyBullet::update_visual_server(SoftBodyVisualServerHandler *p_visual_server_handler) {
+void SoftBodyBullet::update_rendering_server(SoftBodyRenderingServerHandler *p_rendering_server_handler) {
if (!bt_soft_body)
return;
@@ -96,8 +96,8 @@ void SoftBodyBullet::update_visual_server(SoftBodyVisualServerHandler *p_visual_
const int vs_indices_size(vs_indices->size());
for (int x = 0; x < vs_indices_size; ++x) {
- p_visual_server_handler->set_vertex((*vs_indices)[x], vertex_position);
- p_visual_server_handler->set_normal((*vs_indices)[x], vertex_normal);
+ p_rendering_server_handler->set_vertex((*vs_indices)[x], vertex_position);
+ p_rendering_server_handler->set_normal((*vs_indices)[x], vertex_normal);
}
}
@@ -112,7 +112,7 @@ void SoftBodyBullet::update_visual_server(SoftBodyVisualServerHandler *p_visual_
B_TO_G(aabb_min, aabb.position);
B_TO_G(size, aabb.size);
- p_visual_server_handler->set_aabb(aabb);
+ p_rendering_server_handler->set_aabb(aabb);
}
void SoftBodyBullet::set_soft_mesh(const Ref<Mesh> &p_mesh) {
@@ -129,8 +129,8 @@ void SoftBodyBullet::set_soft_mesh(const Ref<Mesh> &p_mesh) {
}
Array arrays = soft_mesh->surface_get_arrays(0);
- ERR_FAIL_COND(!(soft_mesh->surface_get_format(0) & VS::ARRAY_FORMAT_INDEX));
- set_trimesh_body_shape(arrays[VS::ARRAY_INDEX], arrays[VS::ARRAY_VERTEX]);
+ ERR_FAIL_COND(!(soft_mesh->surface_get_format(0) & RS::ARRAY_FORMAT_INDEX));
+ set_trimesh_body_shape(arrays[RS::ARRAY_INDEX], arrays[RS::ARRAY_VERTEX]);
}
void SoftBodyBullet::destroy_soft_body() {
@@ -144,7 +144,7 @@ void SoftBodyBullet::destroy_soft_body() {
}
destroyBulletCollisionObject();
- bt_soft_body = NULL;
+ bt_soft_body = nullptr;
}
void SoftBodyBullet::set_soft_transform(const Transform &p_transform) {
@@ -184,7 +184,7 @@ void SoftBodyBullet::get_node_offset(int p_node_index, Vector3 &r_offset) const
return;
Array arrays = soft_mesh->surface_get_arrays(0);
- Vector<Vector3> vertices(arrays[VS::ARRAY_VERTEX]);
+ Vector<Vector3> vertices(arrays[RS::ARRAY_VERTEX]);
if (0 <= p_node_index && vertices.size() > p_node_index) {
r_offset = vertices[p_node_index];
@@ -230,7 +230,7 @@ void SoftBodyBullet::reset_all_node_positions() {
return;
Array arrays = soft_mesh->surface_get_arrays(0);
- Vector<Vector3> vs_vertices(arrays[VS::ARRAY_VERTEX]);
+ Vector<Vector3> vs_vertices(arrays[RS::ARRAY_VERTEX]);
const Vector3 *vs_vertices_read = vs_vertices.ptr();
for (int vertex_index = bt_soft_body->m_nodes.size() - 1; 0 <= vertex_index; --vertex_index) {
@@ -404,7 +404,7 @@ void SoftBodyBullet::setup_soft_body() {
// Soft body setup
setupBulletCollisionObject(bt_soft_body);
- bt_soft_body->m_worldInfo = NULL; // Remove fake world info
+ bt_soft_body->m_worldInfo = nullptr; // Remove fake world info
bt_soft_body->getCollisionShape()->setMargin(0.01);
bt_soft_body->setCollisionFlags(bt_soft_body->getCollisionFlags() & (~(btCollisionObject::CF_KINEMATIC_OBJECT | btCollisionObject::CF_STATIC_OBJECT)));
diff --git a/modules/bullet/soft_body_bullet.h b/modules/bullet/soft_body_bullet.h
index 05d7e6ce3f..3c6871e0d6 100644
--- a/modules/bullet/soft_body_bullet.h
+++ b/modules/bullet/soft_body_bullet.h
@@ -43,7 +43,7 @@
#include "BulletSoftBody/btSoftBodyHelpers.h"
#include "collision_object_bullet.h"
#include "scene/resources/mesh.h"
-#include "servers/physics_server.h"
+#include "servers/physics_server_3d.h"
#ifdef x11_None
/// This is required to re add the macro None defined by x11 compiler
@@ -100,7 +100,7 @@ public:
_FORCE_INLINE_ btSoftBody *get_bt_soft_body() const { return bt_soft_body; }
- void update_visual_server(class SoftBodyVisualServerHandler *p_visual_server_handler);
+ void update_rendering_server(class SoftBodyRenderingServerHandler *p_rendering_server_handler);
void set_soft_mesh(const Ref<Mesh> &p_mesh);
void destroy_soft_body();
diff --git a/modules/bullet/space_bullet.cpp b/modules/bullet/space_bullet.cpp
index f6df97f11d..1659664ff9 100644
--- a/modules/bullet/space_bullet.cpp
+++ b/modules/bullet/space_bullet.cpp
@@ -39,7 +39,7 @@
#include "godot_collision_configuration.h"
#include "godot_collision_dispatcher.h"
#include "rigid_body_bullet.h"
-#include "servers/physics_server.h"
+#include "servers/physics_server_3d.h"
#include "soft_body_bullet.h"
#include <BulletCollision/BroadphaseCollision/btBroadphaseProxy.h>
@@ -59,7 +59,7 @@
*/
BulletPhysicsDirectSpaceState::BulletPhysicsDirectSpaceState(SpaceBullet *p_space) :
- PhysicsDirectSpaceState(),
+ PhysicsDirectSpaceState3D(),
space(p_space) {}
int BulletPhysicsDirectSpaceState::intersect_point(const Vector3 &p_point, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {
@@ -108,7 +108,7 @@ bool BulletPhysicsDirectSpaceState::intersect_ray(const Vector3 &p_from, const V
r_result.shape = btResult.m_shapeId;
r_result.rid = gObj->get_self();
r_result.collider_id = gObj->get_instance_id();
- r_result.collider = r_result.collider_id.is_null() ? NULL : ObjectDB::get_instance(r_result.collider_id);
+ r_result.collider = r_result.collider_id.is_null() ? nullptr : ObjectDB::get_instance(r_result.collider_id);
} else {
WARN_PRINT("The raycast performed has hit a collision object that is not part of Godot scene, please check it.");
}
@@ -309,7 +309,7 @@ Vector3 BulletPhysicsDirectSpaceState::get_closest_point_to_object_volume(RID p_
btPointCollector result;
btGjkPairDetector gjk_pair_detector(&point_shape, convex_shape, space->gjk_simplex_solver, space->gjk_epa_pen_solver);
- gjk_pair_detector.getClosestPoints(input, result, 0);
+ gjk_pair_detector.getClosestPoints(input, result, nullptr);
if (out_distance > result.m_distance) {
out_distance = result.m_distance;
@@ -332,14 +332,14 @@ Vector3 BulletPhysicsDirectSpaceState::get_closest_point_to_object_volume(RID p_
}
SpaceBullet::SpaceBullet() :
- broadphase(NULL),
- collisionConfiguration(NULL),
- dispatcher(NULL),
- solver(NULL),
- dynamicsWorld(NULL),
- soft_body_world_info(NULL),
- ghostPairCallback(NULL),
- godotFilterCallback(NULL),
+ broadphase(nullptr),
+ collisionConfiguration(nullptr),
+ dispatcher(nullptr),
+ solver(nullptr),
+ dynamicsWorld(nullptr),
+ soft_body_world_info(nullptr),
+ ghostPairCallback(nullptr),
+ godotFilterCallback(nullptr),
gravityDirection(0, -1, 0),
gravityMagnitude(10),
contactDebugCount(0),
@@ -366,27 +366,27 @@ void SpaceBullet::step(real_t p_delta_time) {
dynamicsWorld->stepSimulation(p_delta_time, 0, 0);
}
-void SpaceBullet::set_param(PhysicsServer::AreaParameter p_param, const Variant &p_value) {
+void SpaceBullet::set_param(PhysicsServer3D::AreaParameter p_param, const Variant &p_value) {
assert(dynamicsWorld);
switch (p_param) {
- case PhysicsServer::AREA_PARAM_GRAVITY:
+ case PhysicsServer3D::AREA_PARAM_GRAVITY:
gravityMagnitude = p_value;
update_gravity();
break;
- case PhysicsServer::AREA_PARAM_GRAVITY_VECTOR:
+ case PhysicsServer3D::AREA_PARAM_GRAVITY_VECTOR:
gravityDirection = p_value;
update_gravity();
break;
- case PhysicsServer::AREA_PARAM_LINEAR_DAMP:
- case PhysicsServer::AREA_PARAM_ANGULAR_DAMP:
+ case PhysicsServer3D::AREA_PARAM_LINEAR_DAMP:
+ case PhysicsServer3D::AREA_PARAM_ANGULAR_DAMP:
break; // No damp
- case PhysicsServer::AREA_PARAM_PRIORITY:
+ case PhysicsServer3D::AREA_PARAM_PRIORITY:
// Priority is always 0, the lower
break;
- case PhysicsServer::AREA_PARAM_GRAVITY_IS_POINT:
- case PhysicsServer::AREA_PARAM_GRAVITY_DISTANCE_SCALE:
- case PhysicsServer::AREA_PARAM_GRAVITY_POINT_ATTENUATION:
+ case PhysicsServer3D::AREA_PARAM_GRAVITY_IS_POINT:
+ case PhysicsServer3D::AREA_PARAM_GRAVITY_DISTANCE_SCALE:
+ case PhysicsServer3D::AREA_PARAM_GRAVITY_POINT_ATTENUATION:
break;
default:
WARN_PRINT("This set parameter (" + itos(p_param) + ") is ignored, the SpaceBullet doesn't support it.");
@@ -394,22 +394,22 @@ void SpaceBullet::set_param(PhysicsServer::AreaParameter p_param, const Variant
}
}
-Variant SpaceBullet::get_param(PhysicsServer::AreaParameter p_param) {
+Variant SpaceBullet::get_param(PhysicsServer3D::AreaParameter p_param) {
switch (p_param) {
- case PhysicsServer::AREA_PARAM_GRAVITY:
+ case PhysicsServer3D::AREA_PARAM_GRAVITY:
return gravityMagnitude;
- case PhysicsServer::AREA_PARAM_GRAVITY_VECTOR:
+ case PhysicsServer3D::AREA_PARAM_GRAVITY_VECTOR:
return gravityDirection;
- case PhysicsServer::AREA_PARAM_LINEAR_DAMP:
- case PhysicsServer::AREA_PARAM_ANGULAR_DAMP:
+ case PhysicsServer3D::AREA_PARAM_LINEAR_DAMP:
+ case PhysicsServer3D::AREA_PARAM_ANGULAR_DAMP:
return 0; // No damp
- case PhysicsServer::AREA_PARAM_PRIORITY:
+ case PhysicsServer3D::AREA_PARAM_PRIORITY:
return 0; // Priority is always 0, the lower
- case PhysicsServer::AREA_PARAM_GRAVITY_IS_POINT:
+ case PhysicsServer3D::AREA_PARAM_GRAVITY_IS_POINT:
return false;
- case PhysicsServer::AREA_PARAM_GRAVITY_DISTANCE_SCALE:
+ case PhysicsServer3D::AREA_PARAM_GRAVITY_DISTANCE_SCALE:
return 0;
- case PhysicsServer::AREA_PARAM_GRAVITY_POINT_ATTENUATION:
+ case PhysicsServer3D::AREA_PARAM_GRAVITY_POINT_ATTENUATION:
return 0;
default:
WARN_PRINT("This get parameter (" + itos(p_param) + ") is ignored, the SpaceBullet doesn't support it.");
@@ -417,32 +417,32 @@ Variant SpaceBullet::get_param(PhysicsServer::AreaParameter p_param) {
}
}
-void SpaceBullet::set_param(PhysicsServer::SpaceParameter p_param, real_t p_value) {
+void SpaceBullet::set_param(PhysicsServer3D::SpaceParameter p_param, real_t p_value) {
switch (p_param) {
- case PhysicsServer::SPACE_PARAM_CONTACT_RECYCLE_RADIUS:
- case PhysicsServer::SPACE_PARAM_CONTACT_MAX_SEPARATION:
- case PhysicsServer::SPACE_PARAM_BODY_MAX_ALLOWED_PENETRATION:
- case PhysicsServer::SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD:
- case PhysicsServer::SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD:
- case PhysicsServer::SPACE_PARAM_BODY_TIME_TO_SLEEP:
- case PhysicsServer::SPACE_PARAM_BODY_ANGULAR_VELOCITY_DAMP_RATIO:
- case PhysicsServer::SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS:
+ case PhysicsServer3D::SPACE_PARAM_CONTACT_RECYCLE_RADIUS:
+ case PhysicsServer3D::SPACE_PARAM_CONTACT_MAX_SEPARATION:
+ case PhysicsServer3D::SPACE_PARAM_BODY_MAX_ALLOWED_PENETRATION:
+ case PhysicsServer3D::SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD:
+ case PhysicsServer3D::SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD:
+ case PhysicsServer3D::SPACE_PARAM_BODY_TIME_TO_SLEEP:
+ case PhysicsServer3D::SPACE_PARAM_BODY_ANGULAR_VELOCITY_DAMP_RATIO:
+ case PhysicsServer3D::SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS:
default:
WARN_PRINT("This set parameter (" + itos(p_param) + ") is ignored, the SpaceBullet doesn't support it.");
break;
}
}
-real_t SpaceBullet::get_param(PhysicsServer::SpaceParameter p_param) {
+real_t SpaceBullet::get_param(PhysicsServer3D::SpaceParameter p_param) {
switch (p_param) {
- case PhysicsServer::SPACE_PARAM_CONTACT_RECYCLE_RADIUS:
- case PhysicsServer::SPACE_PARAM_CONTACT_MAX_SEPARATION:
- case PhysicsServer::SPACE_PARAM_BODY_MAX_ALLOWED_PENETRATION:
- case PhysicsServer::SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD:
- case PhysicsServer::SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD:
- case PhysicsServer::SPACE_PARAM_BODY_TIME_TO_SLEEP:
- case PhysicsServer::SPACE_PARAM_BODY_ANGULAR_VELOCITY_DAMP_RATIO:
- case PhysicsServer::SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS:
+ case PhysicsServer3D::SPACE_PARAM_CONTACT_RECYCLE_RADIUS:
+ case PhysicsServer3D::SPACE_PARAM_CONTACT_MAX_SEPARATION:
+ case PhysicsServer3D::SPACE_PARAM_BODY_MAX_ALLOWED_PENETRATION:
+ case PhysicsServer3D::SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD:
+ case PhysicsServer3D::SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD:
+ case PhysicsServer3D::SPACE_PARAM_BODY_TIME_TO_SLEEP:
+ case PhysicsServer3D::SPACE_PARAM_BODY_ANGULAR_VELOCITY_DAMP_RATIO:
+ case PhysicsServer3D::SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS:
default:
WARN_PRINT("The SpaceBullet doesn't support this get parameter (" + itos(p_param) + "), 0 is returned.");
return 0.f;
@@ -511,7 +511,7 @@ void SpaceBullet::remove_soft_body(SoftBodyBullet *p_body) {
if (is_using_soft_world()) {
if (p_body->get_bt_soft_body()) {
static_cast<btSoftRigidDynamicsWorld *>(dynamicsWorld)->removeSoftBody(p_body->get_bt_soft_body());
- p_body->get_bt_soft_body()->m_worldInfo = NULL;
+ p_body->get_bt_soft_body()->m_worldInfo = nullptr;
}
}
}
@@ -539,7 +539,7 @@ void SpaceBullet::remove_all_collision_objects() {
for (int i = dynamicsWorld->getNumCollisionObjects() - 1; 0 <= i; --i) {
btCollisionObject *btObj = dynamicsWorld->getCollisionObjectArray()[i];
CollisionObjectBullet *colObj = static_cast<CollisionObjectBullet *>(btObj->getUserPointer());
- colObj->set_space(NULL);
+ colObj->set_space(nullptr);
}
}
@@ -636,8 +636,8 @@ void SpaceBullet::destroy_world() {
/// The world elements (like: Collision Objects, Constraints, Shapes) are managed by godot
- dynamicsWorld->getBroadphase()->getOverlappingPairCache()->setInternalGhostPairCallback(NULL);
- dynamicsWorld->getPairCache()->setOverlapFilterCallback(NULL);
+ dynamicsWorld->getBroadphase()->getOverlappingPairCache()->setInternalGhostPairCallback(nullptr);
+ dynamicsWorld->getPairCache()->setOverlapFilterCallback(nullptr);
bulletdelete(ghostPairCallback);
bulletdelete(godotFilterCallback);
@@ -645,7 +645,7 @@ void SpaceBullet::destroy_world() {
// Deallocate world
dynamicsWorld->~btDiscreteDynamicsWorld();
free(dynamicsWorld);
- dynamicsWorld = NULL;
+ dynamicsWorld = nullptr;
bulletdelete(solver);
bulletdelete(broadphase);
@@ -741,7 +741,7 @@ void SpaceBullet::check_ghost_overlaps() {
static_cast<btConvexShape *>(other_body_shape),
gjk_simplex_solver,
gjk_epa_pen_solver);
- gjk_pair_detector.getClosestPoints(gjk_input, result, 0);
+ gjk_pair_detector.getClosestPoints(gjk_input, result, nullptr);
if (0 >= result.m_distance) {
hasOverlap = true;
@@ -750,10 +750,10 @@ void SpaceBullet::check_ghost_overlaps() {
} else {
- btCollisionObjectWrapper obA(NULL, area_shape, area->get_bt_ghost(), gjk_input.m_transformA, -1, y);
- btCollisionObjectWrapper obB(NULL, other_body_shape, otherObject->get_bt_collision_object(), gjk_input.m_transformB, -1, z);
+ btCollisionObjectWrapper obA(nullptr, area_shape, area->get_bt_ghost(), gjk_input.m_transformA, -1, y);
+ btCollisionObjectWrapper obB(nullptr, other_body_shape, otherObject->get_bt_collision_object(), gjk_input.m_transformB, -1, z);
- btCollisionAlgorithm *algorithm = dispatcher->findAlgorithm(&obA, &obB, NULL, BT_CONTACT_POINT_ALGORITHMS);
+ btCollisionAlgorithm *algorithm = dispatcher->findAlgorithm(&obA, &obB, nullptr, BT_CONTACT_POINT_ALGORITHMS);
if (!algorithm)
continue;
@@ -885,20 +885,20 @@ void SpaceBullet::update_gravity() {
#include "scene/3d/immediate_geometry.h"
-static ImmediateGeometry *motionVec(NULL);
-static ImmediateGeometry *normalLine(NULL);
+static ImmediateGeometry3D *motionVec(nullptr);
+static ImmediateGeometry3D *normalLine(nullptr);
static Ref<StandardMaterial3D> red_mat;
static Ref<StandardMaterial3D> blue_mat;
#endif
-bool SpaceBullet::test_body_motion(RigidBodyBullet *p_body, const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia, PhysicsServer::MotionResult *r_result, bool p_exclude_raycast_shapes) {
+bool SpaceBullet::test_body_motion(RigidBodyBullet *p_body, const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia, PhysicsServer3D::MotionResult *r_result, bool p_exclude_raycast_shapes) {
#if debug_test_motion
/// Yes I know this is not good, but I've used it as fast debugging hack.
/// I'm leaving it here just for speedup the other eventual debugs
if (!normalLine) {
- motionVec = memnew(ImmediateGeometry);
- normalLine = memnew(ImmediateGeometry);
+ motionVec = memnew(ImmediateGeometry3D);
+ normalLine = memnew(ImmediateGeometry3D);
SceneTree::get_singleton()->get_current_scene()->add_child(motionVec);
SceneTree::get_singleton()->get_current_scene()->add_child(normalLine);
@@ -951,7 +951,7 @@ bool SpaceBullet::test_body_motion(RigidBodyBullet *p_body, const Transform &p_f
Vector3 sup_line;
B_TO_G(body_safe_position.getOrigin(), sup_line);
motionVec->clear();
- motionVec->begin(Mesh::PRIMITIVE_LINES, NULL);
+ motionVec->begin(Mesh::PRIMITIVE_LINES, nullptr);
motionVec->add_vertex(sup_line);
motionVec->add_vertex(sup_line + p_motion * 10);
motionVec->end();
@@ -1028,7 +1028,7 @@ bool SpaceBullet::test_body_motion(RigidBodyBullet *p_body, const Transform &p_f
Vector3 sup_line2;
B_TO_G(motion, sup_line2);
normalLine->clear();
- normalLine->begin(Mesh::PRIMITIVE_LINES, NULL);
+ normalLine->begin(Mesh::PRIMITIVE_LINES, nullptr);
normalLine->add_vertex(r_result->collision_point);
normalLine->add_vertex(r_result->collision_point + r_result->collision_normal * 10);
normalLine->end();
@@ -1042,7 +1042,7 @@ bool SpaceBullet::test_body_motion(RigidBodyBullet *p_body, const Transform &p_f
return has_penetration;
}
-int SpaceBullet::test_ray_separation(RigidBodyBullet *p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, PhysicsServer::SeparationResult *r_results, int p_result_max, float p_margin) {
+int SpaceBullet::test_ray_separation(RigidBodyBullet *p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, PhysicsServer3D::SeparationResult *r_results, int p_result_max, float p_margin) {
btTransform body_transform;
G_TO_B(p_transform, body_transform);
@@ -1054,7 +1054,7 @@ int SpaceBullet::test_ray_separation(RigidBodyBullet *p_body, const Transform &p
int rays_found_this_round = 0;
for (int t(RECOVERING_MOVEMENT_CYCLES); 0 < t; --t) {
- PhysicsServer::SeparationResult *next_results = &r_results[rays_found];
+ PhysicsServer3D::SeparationResult *next_results = &r_results[rays_found];
rays_found_this_round = recover_from_penetration_ray(p_body, body_transform, RECOVERING_MOVEMENT_SCALE, p_infinite_inertia, p_result_max - rays_found, recover_motion, next_results);
rays_found += rays_found_this_round;
@@ -1124,7 +1124,7 @@ public:
if (cs->getNumChildShapes() > 1) {
const btDbvt *tree = cs->getDynamicAabbTree();
- ERR_FAIL_COND_V(tree == NULL, true);
+ ERR_FAIL_COND_V(tree == nullptr, true);
// Transform bounds into compound shape local space
const btTransform other_in_compound_space = co->getWorldTransform().inverse();
@@ -1275,7 +1275,7 @@ bool SpaceBullet::RFP_convex_convex_test(const btConvexShape *p_shapeA, const bt
// Perform GJK test
btPointCollector result;
btGjkPairDetector gjk_pair_detector(p_shapeA, p_shapeB, gjk_simplex_solver, gjk_epa_pen_solver);
- gjk_pair_detector.getClosestPoints(gjk_input, result, 0);
+ gjk_pair_detector.getClosestPoints(gjk_input, result, nullptr);
if (0 > result.m_distance) {
// Has penetration
r_delta_recover_movement += result.m_normalOnBInWorld * (result.m_distance * -1 * p_recover_movement_scale);
@@ -1302,10 +1302,10 @@ bool SpaceBullet::RFP_convex_world_test(const btConvexShape *p_shapeA, const btC
btTransform tA(p_transformA);
- btCollisionObjectWrapper obA(NULL, p_shapeA, p_objectA, tA, -1, p_shapeId_A);
- btCollisionObjectWrapper obB(NULL, p_shapeB, p_objectB, p_transformB, -1, p_shapeId_B);
+ btCollisionObjectWrapper obA(nullptr, p_shapeA, p_objectA, tA, -1, p_shapeId_A);
+ btCollisionObjectWrapper obB(nullptr, p_shapeB, p_objectB, p_transformB, -1, p_shapeId_B);
- btCollisionAlgorithm *algorithm = dispatcher->findAlgorithm(&obA, &obB, NULL, BT_CONTACT_POINT_ALGORITHMS);
+ btCollisionAlgorithm *algorithm = dispatcher->findAlgorithm(&obA, &obB, nullptr, BT_CONTACT_POINT_ALGORITHMS);
if (algorithm) {
GodotDeepPenetrationContactResultCallback contactPointResult(&obA, &obB);
//discrete collision detection query
@@ -1333,7 +1333,7 @@ bool SpaceBullet::RFP_convex_world_test(const btConvexShape *p_shapeA, const btC
return false;
}
-int SpaceBullet::add_separation_result(PhysicsServer::SeparationResult *r_result, const SpaceBullet::RecoverResult &p_recover_result, int p_shape_id, const btCollisionObject *p_other_object) const {
+int SpaceBullet::add_separation_result(PhysicsServer3D::SeparationResult *r_result, const SpaceBullet::RecoverResult &p_recover_result, int p_shape_id, const btCollisionObject *p_other_object) const {
// optimize results (ignore non-colliding)
if (p_recover_result.penetration_distance < 0.0) {
@@ -1355,7 +1355,7 @@ int SpaceBullet::add_separation_result(PhysicsServer::SeparationResult *r_result
}
}
-int SpaceBullet::recover_from_penetration_ray(RigidBodyBullet *p_body, const btTransform &p_body_position, btScalar p_recover_movement_scale, bool p_infinite_inertia, int p_result_max, btVector3 &r_delta_recover_movement, PhysicsServer::SeparationResult *r_results) {
+int SpaceBullet::recover_from_penetration_ray(RigidBodyBullet *p_body, const btTransform &p_body_position, btScalar p_recover_movement_scale, bool p_infinite_inertia, int p_result_max, btVector3 &r_delta_recover_movement, PhysicsServer3D::SeparationResult *r_results) {
// Calculate the cumulative AABB of all shapes of the kinematic body
btVector3 aabb_min, aabb_max;
diff --git a/modules/bullet/space_bullet.h b/modules/bullet/space_bullet.h
index 32372f1630..f9a8c063fd 100644
--- a/modules/bullet/space_bullet.h
+++ b/modules/bullet/space_bullet.h
@@ -35,7 +35,7 @@
#include "core/vector.h"
#include "godot_result_callbacks.h"
#include "rid_bullet.h"
-#include "servers/physics_server.h"
+#include "servers/physics_server_3d.h"
#include <BulletCollision/BroadphaseCollision/btBroadphaseProxy.h>
#include <BulletCollision/BroadphaseCollision/btOverlappingPairCache.h>
@@ -67,8 +67,8 @@ class btGjkEpaPenetrationDepthSolver;
extern ContactAddedCallback gContactAddedCallback;
-class BulletPhysicsDirectSpaceState : public PhysicsDirectSpaceState {
- GDCLASS(BulletPhysicsDirectSpaceState, PhysicsDirectSpaceState);
+class BulletPhysicsDirectSpaceState : public PhysicsDirectSpaceState3D {
+ GDCLASS(BulletPhysicsDirectSpaceState, PhysicsDirectSpaceState3D);
private:
SpaceBullet *space;
@@ -79,7 +79,7 @@ public:
virtual int intersect_point(const Vector3 &p_point, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false);
virtual bool intersect_ray(const Vector3 &p_from, const Vector3 &p_to, RayResult &r_result, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false, bool p_pick_ray = false);
virtual int intersect_shape(const RID &p_shape, const Transform &p_xform, float p_margin, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false);
- virtual bool cast_motion(const RID &p_shape, const Transform &p_xform, const Vector3 &p_motion, float p_margin, float &r_closest_safe, float &r_closest_unsafe, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false, ShapeRestInfo *r_info = NULL);
+ virtual bool cast_motion(const RID &p_shape, const Transform &p_xform, const Vector3 &p_motion, float p_margin, float &r_closest_safe, float &r_closest_unsafe, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false, ShapeRestInfo *r_info = nullptr);
/// Returns the list of contacts pairs in this order: Local contact, other body contact
virtual bool collide_shape(RID p_shape, const Transform &p_shape_xform, float p_margin, Vector3 *r_results, int p_result_max, int &r_result_count, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false);
virtual bool rest_info(RID p_shape, const Transform &p_shape_xform, float p_margin, ShapeRestInfo *r_info, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false);
@@ -131,15 +131,15 @@ public:
/// @param p_param:
/// AREA_PARAM_GRAVITY to set the gravity magnitude of entire world
/// AREA_PARAM_GRAVITY_VECTOR to set the gravity direction of entire world
- void set_param(PhysicsServer::AreaParameter p_param, const Variant &p_value);
+ void set_param(PhysicsServer3D::AreaParameter p_param, const Variant &p_value);
/// Used to get some parameters to Bullet world
/// @param p_param:
/// AREA_PARAM_GRAVITY to get the gravity magnitude of entire world
/// AREA_PARAM_GRAVITY_VECTOR to get the gravity direction of entire world
- Variant get_param(PhysicsServer::AreaParameter p_param);
+ Variant get_param(PhysicsServer3D::AreaParameter p_param);
- void set_param(PhysicsServer::SpaceParameter p_param, real_t p_value);
- real_t get_param(PhysicsServer::SpaceParameter p_param);
+ void set_param(PhysicsServer3D::SpaceParameter p_param, real_t p_value);
+ real_t get_param(PhysicsServer3D::SpaceParameter p_param);
void add_area(AreaBullet *p_area);
void remove_area(AreaBullet *p_area);
@@ -177,8 +177,8 @@ public:
void update_gravity();
- bool test_body_motion(RigidBodyBullet *p_body, const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia, PhysicsServer::MotionResult *r_result, bool p_exclude_raycast_shapes);
- int test_ray_separation(RigidBodyBullet *p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, PhysicsServer::SeparationResult *r_results, int p_result_max, float p_margin);
+ bool test_body_motion(RigidBodyBullet *p_body, const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia, PhysicsServer3D::MotionResult *r_result, bool p_exclude_raycast_shapes);
+ int test_ray_separation(RigidBodyBullet *p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, PhysicsServer3D::SeparationResult *r_results, int p_result_max, float p_margin);
private:
void create_empty_world(bool p_create_soft_world);
@@ -201,19 +201,19 @@ private:
pointWorld(0, 0, 0),
penetration_distance(1e20),
other_compound_shape_index(0),
- other_collision_object(NULL),
+ other_collision_object(nullptr),
local_shape_most_recovered(0) {}
};
- bool recover_from_penetration(RigidBodyBullet *p_body, const btTransform &p_body_position, btScalar p_recover_movement_scale, bool p_infinite_inertia, btVector3 &r_delta_recover_movement, RecoverResult *r_recover_result = NULL);
+ bool recover_from_penetration(RigidBodyBullet *p_body, const btTransform &p_body_position, btScalar p_recover_movement_scale, bool p_infinite_inertia, btVector3 &r_delta_recover_movement, RecoverResult *r_recover_result = nullptr);
/// This is an API that recover a kinematic object from penetration
/// This allow only Convex Convex test and it always use GJK algorithm, With this API we don't benefit of Bullet special accelerated functions
- bool RFP_convex_convex_test(const btConvexShape *p_shapeA, const btConvexShape *p_shapeB, btCollisionObject *p_objectB, int p_shapeId_A, int p_shapeId_B, const btTransform &p_transformA, const btTransform &p_transformB, btScalar p_recover_movement_scale, btVector3 &r_delta_recover_movement, RecoverResult *r_recover_result = NULL);
+ bool RFP_convex_convex_test(const btConvexShape *p_shapeA, const btConvexShape *p_shapeB, btCollisionObject *p_objectB, int p_shapeId_A, int p_shapeId_B, const btTransform &p_transformA, const btTransform &p_transformB, btScalar p_recover_movement_scale, btVector3 &r_delta_recover_movement, RecoverResult *r_recover_result = nullptr);
/// This is an API that recover a kinematic object from penetration
/// Using this we leave Bullet to select the best algorithm, For example GJK in case we have Convex Convex, or a Bullet accelerated algorithm
- bool RFP_convex_world_test(const btConvexShape *p_shapeA, const btCollisionShape *p_shapeB, btCollisionObject *p_objectA, btCollisionObject *p_objectB, int p_shapeId_A, int p_shapeId_B, const btTransform &p_transformA, const btTransform &p_transformB, btScalar p_recover_movement_scale, btVector3 &r_delta_recover_movement, RecoverResult *r_recover_result = NULL);
+ bool RFP_convex_world_test(const btConvexShape *p_shapeA, const btCollisionShape *p_shapeB, btCollisionObject *p_objectA, btCollisionObject *p_objectB, int p_shapeId_A, int p_shapeId_B, const btTransform &p_transformA, const btTransform &p_transformB, btScalar p_recover_movement_scale, btVector3 &r_delta_recover_movement, RecoverResult *r_recover_result = nullptr);
- int add_separation_result(PhysicsServer::SeparationResult *r_results, const SpaceBullet::RecoverResult &p_recover_result, int p_shape_id, const btCollisionObject *p_other_object) const;
- int recover_from_penetration_ray(RigidBodyBullet *p_body, const btTransform &p_body_position, btScalar p_recover_movement_scale, bool p_infinite_inertia, int p_result_max, btVector3 &r_delta_recover_movement, PhysicsServer::SeparationResult *r_results);
+ int add_separation_result(PhysicsServer3D::SeparationResult *r_results, const SpaceBullet::RecoverResult &p_recover_result, int p_shape_id, const btCollisionObject *p_other_object) const;
+ int recover_from_penetration_ray(RigidBodyBullet *p_body, const btTransform &p_body_position, btScalar p_recover_movement_scale, bool p_infinite_inertia, int p_result_max, btVector3 &r_delta_recover_movement, PhysicsServer3D::SeparationResult *r_results);
};
#endif
diff --git a/modules/camera/SCsub b/modules/camera/SCsub
index 23f031f06e..63c4e9fbab 100644
--- a/modules/camera/SCsub
+++ b/modules/camera/SCsub
@@ -1,7 +1,7 @@
#!/usr/bin/env python
-Import('env')
-Import('env_modules')
+Import("env")
+Import("env_modules")
env_camera = env_modules.Clone()
@@ -10,7 +10,7 @@ if env["platform"] == "iphone":
modules_sources = []
env_camera.add_source_files(modules_sources, "register_types.cpp")
env_camera.add_source_files(modules_sources, "camera_ios.mm")
- mod_lib = env_modules.add_library('#bin/libgodot_camera_module' + env['LIBSUFFIX'], modules_sources)
+ mod_lib = env_modules.add_library("#bin/libgodot_camera_module" + env["LIBSUFFIX"], modules_sources)
elif env["platform"] == "windows":
env_camera.add_source_files(env.modules_sources, "register_types.cpp")
@@ -19,4 +19,3 @@ elif env["platform"] == "windows":
elif env["platform"] == "osx":
env_camera.add_source_files(env.modules_sources, "register_types.cpp")
env_camera.add_source_files(env.modules_sources, "camera_osx.mm")
-
diff --git a/modules/camera/config.py b/modules/camera/config.py
index d308c04195..87d7542741 100644
--- a/modules/camera/config.py
+++ b/modules/camera/config.py
@@ -1,5 +1,6 @@
def can_build(env, platform):
- return platform == 'iphone' or platform == 'osx' or platform == 'windows'
+ return platform == "iphone" or platform == "osx" or platform == "windows"
+
def configure(env):
pass
diff --git a/modules/csg/SCsub b/modules/csg/SCsub
index 57c504efd8..641a42c187 100644
--- a/modules/csg/SCsub
+++ b/modules/csg/SCsub
@@ -1,7 +1,7 @@
#!/usr/bin/env python
-Import('env')
-Import('env_modules')
+Import("env")
+Import("env_modules")
env_csg = env_modules.Clone()
diff --git a/modules/csg/config.py b/modules/csg/config.py
index 38ccc66d91..9106cbceca 100644
--- a/modules/csg/config.py
+++ b/modules/csg/config.py
@@ -1,21 +1,24 @@
def can_build(env, platform):
return True
+
def configure(env):
pass
+
def get_doc_classes():
return [
- "CSGBox",
- "CSGCombiner",
- "CSGCylinder",
- "CSGMesh",
- "CSGPolygon",
- "CSGPrimitive",
- "CSGShape",
- "CSGSphere",
- "CSGTorus",
+ "CSGBox3D",
+ "CSGCombiner3D",
+ "CSGCylinder3D",
+ "CSGMesh3D",
+ "CSGPolygon3D",
+ "CSGPrimitive3D",
+ "CSGShape3D",
+ "CSGSphere3D",
+ "CSGTorus3D",
]
+
def get_doc_path():
return "doc_classes"
diff --git a/modules/csg/csg_gizmos.cpp b/modules/csg/csg_gizmos.cpp
index 1b63bccb06..fa176cb94e 100644
--- a/modules/csg/csg_gizmos.cpp
+++ b/modules/csg/csg_gizmos.cpp
@@ -32,7 +32,7 @@
///////////
-CSGShapeSpatialGizmoPlugin::CSGShapeSpatialGizmoPlugin() {
+CSGShape3DGizmoPlugin::CSGShape3DGizmoPlugin() {
Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/csg", Color(0.0, 0.4, 1, 0.15));
create_material("shape_union_material", gizmo_color);
@@ -49,46 +49,46 @@ CSGShapeSpatialGizmoPlugin::CSGShapeSpatialGizmoPlugin() {
create_handle_material("handles");
}
-String CSGShapeSpatialGizmoPlugin::get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_idx) const {
+String CSGShape3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const {
- CSGShape *cs = Object::cast_to<CSGShape>(p_gizmo->get_spatial_node());
+ CSGShape3D *cs = Object::cast_to<CSGShape3D>(p_gizmo->get_spatial_node());
- if (Object::cast_to<CSGSphere>(cs)) {
+ if (Object::cast_to<CSGSphere3D>(cs)) {
return "Radius";
}
- if (Object::cast_to<CSGBox>(cs)) {
+ if (Object::cast_to<CSGBox3D>(cs)) {
static const char *hname[3] = { "Width", "Height", "Depth" };
return hname[p_idx];
}
- if (Object::cast_to<CSGCylinder>(cs)) {
+ if (Object::cast_to<CSGCylinder3D>(cs)) {
return p_idx == 0 ? "Radius" : "Height";
}
- if (Object::cast_to<CSGTorus>(cs)) {
+ if (Object::cast_to<CSGTorus3D>(cs)) {
return p_idx == 0 ? "InnerRadius" : "OuterRadius";
}
return "";
}
-Variant CSGShapeSpatialGizmoPlugin::get_handle_value(EditorSpatialGizmo *p_gizmo, int p_idx) const {
+Variant CSGShape3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const {
- CSGShape *cs = Object::cast_to<CSGShape>(p_gizmo->get_spatial_node());
+ CSGShape3D *cs = Object::cast_to<CSGShape3D>(p_gizmo->get_spatial_node());
- if (Object::cast_to<CSGSphere>(cs)) {
+ if (Object::cast_to<CSGSphere3D>(cs)) {
- CSGSphere *s = Object::cast_to<CSGSphere>(cs);
+ CSGSphere3D *s = Object::cast_to<CSGSphere3D>(cs);
return s->get_radius();
}
- if (Object::cast_to<CSGBox>(cs)) {
+ if (Object::cast_to<CSGBox3D>(cs)) {
- CSGBox *s = Object::cast_to<CSGBox>(cs);
+ CSGBox3D *s = Object::cast_to<CSGBox3D>(cs);
switch (p_idx) {
case 0: return s->get_width();
case 1: return s->get_height();
@@ -96,23 +96,23 @@ Variant CSGShapeSpatialGizmoPlugin::get_handle_value(EditorSpatialGizmo *p_gizmo
}
}
- if (Object::cast_to<CSGCylinder>(cs)) {
+ if (Object::cast_to<CSGCylinder3D>(cs)) {
- CSGCylinder *s = Object::cast_to<CSGCylinder>(cs);
+ CSGCylinder3D *s = Object::cast_to<CSGCylinder3D>(cs);
return p_idx == 0 ? s->get_radius() : s->get_height();
}
- if (Object::cast_to<CSGTorus>(cs)) {
+ if (Object::cast_to<CSGTorus3D>(cs)) {
- CSGTorus *s = Object::cast_to<CSGTorus>(cs);
+ CSGTorus3D *s = Object::cast_to<CSGTorus3D>(cs);
return p_idx == 0 ? s->get_inner_radius() : s->get_outer_radius();
}
return Variant();
}
-void CSGShapeSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_idx, Camera *p_camera, const Point2 &p_point) {
+void CSGShape3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) {
- CSGShape *cs = Object::cast_to<CSGShape>(p_gizmo->get_spatial_node());
+ CSGShape3D *cs = Object::cast_to<CSGShape3D>(p_gizmo->get_spatial_node());
Transform gt = cs->get_global_transform();
//gt.orthonormalize();
@@ -123,15 +123,15 @@ void CSGShapeSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_i
Vector3 sg[2] = { gi.xform(ray_from), gi.xform(ray_from + ray_dir * 16384) };
- if (Object::cast_to<CSGSphere>(cs)) {
+ if (Object::cast_to<CSGSphere3D>(cs)) {
- CSGSphere *s = Object::cast_to<CSGSphere>(cs);
+ CSGSphere3D *s = Object::cast_to<CSGSphere3D>(cs);
Vector3 ra, rb;
Geometry::get_closest_points_between_segments(Vector3(), Vector3(4096, 0, 0), sg[0], sg[1], ra, rb);
float d = ra.x;
- if (SpatialEditor::get_singleton()->is_snap_enabled()) {
- d = Math::stepify(d, SpatialEditor::get_singleton()->get_translate_snap());
+ if (Node3DEditor::get_singleton()->is_snap_enabled()) {
+ d = Math::stepify(d, Node3DEditor::get_singleton()->get_translate_snap());
}
if (d < 0.001)
@@ -140,17 +140,17 @@ void CSGShapeSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_i
s->set_radius(d);
}
- if (Object::cast_to<CSGBox>(cs)) {
+ if (Object::cast_to<CSGBox3D>(cs)) {
- CSGBox *s = Object::cast_to<CSGBox>(cs);
+ CSGBox3D *s = Object::cast_to<CSGBox3D>(cs);
Vector3 axis;
axis[p_idx] = 1.0;
Vector3 ra, rb;
Geometry::get_closest_points_between_segments(Vector3(), axis * 4096, sg[0], sg[1], ra, rb);
float d = ra[p_idx];
- if (SpatialEditor::get_singleton()->is_snap_enabled()) {
- d = Math::stepify(d, SpatialEditor::get_singleton()->get_translate_snap());
+ if (Node3DEditor::get_singleton()->is_snap_enabled()) {
+ d = Math::stepify(d, Node3DEditor::get_singleton()->get_translate_snap());
}
if (d < 0.001)
@@ -163,17 +163,17 @@ void CSGShapeSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_i
}
}
- if (Object::cast_to<CSGCylinder>(cs)) {
+ if (Object::cast_to<CSGCylinder3D>(cs)) {
- CSGCylinder *s = Object::cast_to<CSGCylinder>(cs);
+ CSGCylinder3D *s = Object::cast_to<CSGCylinder3D>(cs);
Vector3 axis;
axis[p_idx == 0 ? 0 : 1] = 1.0;
Vector3 ra, rb;
Geometry::get_closest_points_between_segments(Vector3(), axis * 4096, sg[0], sg[1], ra, rb);
float d = axis.dot(ra);
- if (SpatialEditor::get_singleton()->is_snap_enabled()) {
- d = Math::stepify(d, SpatialEditor::get_singleton()->get_translate_snap());
+ if (Node3DEditor::get_singleton()->is_snap_enabled()) {
+ d = Math::stepify(d, Node3DEditor::get_singleton()->get_translate_snap());
}
if (d < 0.001)
@@ -185,17 +185,17 @@ void CSGShapeSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_i
s->set_height(d * 2.0);
}
- if (Object::cast_to<CSGTorus>(cs)) {
+ if (Object::cast_to<CSGTorus3D>(cs)) {
- CSGTorus *s = Object::cast_to<CSGTorus>(cs);
+ CSGTorus3D *s = Object::cast_to<CSGTorus3D>(cs);
Vector3 axis;
axis[0] = 1.0;
Vector3 ra, rb;
Geometry::get_closest_points_between_segments(Vector3(), axis * 4096, sg[0], sg[1], ra, rb);
float d = axis.dot(ra);
- if (SpatialEditor::get_singleton()->is_snap_enabled()) {
- d = Math::stepify(d, SpatialEditor::get_singleton()->get_translate_snap());
+ if (Node3DEditor::get_singleton()->is_snap_enabled()) {
+ d = Math::stepify(d, Node3DEditor::get_singleton()->get_translate_snap());
}
if (d < 0.001)
@@ -207,26 +207,26 @@ void CSGShapeSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_i
s->set_outer_radius(d);
}
}
-void CSGShapeSpatialGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) {
+void CSGShape3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) {
- CSGShape *cs = Object::cast_to<CSGShape>(p_gizmo->get_spatial_node());
+ CSGShape3D *cs = Object::cast_to<CSGShape3D>(p_gizmo->get_spatial_node());
- if (Object::cast_to<CSGSphere>(cs)) {
- CSGSphere *s = Object::cast_to<CSGSphere>(cs);
+ if (Object::cast_to<CSGSphere3D>(cs)) {
+ CSGSphere3D *s = Object::cast_to<CSGSphere3D>(cs);
if (p_cancel) {
s->set_radius(p_restore);
return;
}
- UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo();
+ UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo();
ur->create_action(TTR("Change Sphere Shape Radius"));
ur->add_do_method(s, "set_radius", s->get_radius());
ur->add_undo_method(s, "set_radius", p_restore);
ur->commit_action();
}
- if (Object::cast_to<CSGBox>(cs)) {
- CSGBox *s = Object::cast_to<CSGBox>(cs);
+ if (Object::cast_to<CSGBox3D>(cs)) {
+ CSGBox3D *s = Object::cast_to<CSGBox3D>(cs);
if (p_cancel) {
switch (p_idx) {
case 0: s->set_width(p_restore); break;
@@ -236,7 +236,7 @@ void CSGShapeSpatialGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int
return;
}
- UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo();
+ UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo();
ur->create_action(TTR("Change Box Shape Extents"));
static const char *method[3] = { "set_width", "set_height", "set_depth" };
float current = 0;
@@ -251,8 +251,8 @@ void CSGShapeSpatialGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int
ur->commit_action();
}
- if (Object::cast_to<CSGCylinder>(cs)) {
- CSGCylinder *s = Object::cast_to<CSGCylinder>(cs);
+ if (Object::cast_to<CSGCylinder3D>(cs)) {
+ CSGCylinder3D *s = Object::cast_to<CSGCylinder3D>(cs);
if (p_cancel) {
if (p_idx == 0)
s->set_radius(p_restore);
@@ -261,7 +261,7 @@ void CSGShapeSpatialGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int
return;
}
- UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo();
+ UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo();
if (p_idx == 0) {
ur->create_action(TTR("Change Cylinder Radius"));
ur->add_do_method(s, "set_radius", s->get_radius());
@@ -275,8 +275,8 @@ void CSGShapeSpatialGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int
ur->commit_action();
}
- if (Object::cast_to<CSGTorus>(cs)) {
- CSGTorus *s = Object::cast_to<CSGTorus>(cs);
+ if (Object::cast_to<CSGTorus3D>(cs)) {
+ CSGTorus3D *s = Object::cast_to<CSGTorus3D>(cs);
if (p_cancel) {
if (p_idx == 0)
s->set_inner_radius(p_restore);
@@ -285,7 +285,7 @@ void CSGShapeSpatialGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int
return;
}
- UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo();
+ UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo();
if (p_idx == 0) {
ur->create_action(TTR("Change Torus Inner Radius"));
ur->add_do_method(s, "set_inner_radius", s->get_inner_radius());
@@ -299,37 +299,37 @@ void CSGShapeSpatialGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int
ur->commit_action();
}
}
-bool CSGShapeSpatialGizmoPlugin::has_gizmo(Spatial *p_spatial) {
- return Object::cast_to<CSGSphere>(p_spatial) || Object::cast_to<CSGBox>(p_spatial) || Object::cast_to<CSGCylinder>(p_spatial) || Object::cast_to<CSGTorus>(p_spatial) || Object::cast_to<CSGMesh>(p_spatial) || Object::cast_to<CSGPolygon>(p_spatial);
+bool CSGShape3DGizmoPlugin::has_gizmo(Node3D *p_spatial) {
+ return Object::cast_to<CSGSphere3D>(p_spatial) || Object::cast_to<CSGBox3D>(p_spatial) || Object::cast_to<CSGCylinder3D>(p_spatial) || Object::cast_to<CSGTorus3D>(p_spatial) || Object::cast_to<CSGMesh3D>(p_spatial) || Object::cast_to<CSGPolygon3D>(p_spatial);
}
-String CSGShapeSpatialGizmoPlugin::get_name() const {
- return "CSGShapes";
+String CSGShape3DGizmoPlugin::get_name() const {
+ return "CSGShape3D";
}
-int CSGShapeSpatialGizmoPlugin::get_priority() const {
+int CSGShape3DGizmoPlugin::get_priority() const {
return -1;
}
-bool CSGShapeSpatialGizmoPlugin::is_selectable_when_hidden() const {
+bool CSGShape3DGizmoPlugin::is_selectable_when_hidden() const {
return true;
}
-void CSGShapeSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
+void CSGShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
- CSGShape *cs = Object::cast_to<CSGShape>(p_gizmo->get_spatial_node());
+ CSGShape3D *cs = Object::cast_to<CSGShape3D>(p_gizmo->get_spatial_node());
p_gizmo->clear();
Ref<Material> material;
switch (cs->get_operation()) {
- case CSGShape::OPERATION_UNION:
+ case CSGShape3D::OPERATION_UNION:
material = get_material("shape_union_material", p_gizmo);
break;
- case CSGShape::OPERATION_INTERSECTION:
+ case CSGShape3D::OPERATION_INTERSECTION:
material = get_material("shape_intersection_material", p_gizmo);
break;
- case CSGShape::OPERATION_SUBTRACTION:
+ case CSGShape3D::OPERATION_SUBTRACTION:
material = get_material("shape_subtraction_material", p_gizmo);
break;
}
@@ -366,13 +366,13 @@ void CSGShapeSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
Ref<Material> solid_material;
switch (cs->get_operation()) {
- case CSGShape::OPERATION_UNION:
+ case CSGShape3D::OPERATION_UNION:
solid_material = get_material("shape_union_solid_material", p_gizmo);
break;
- case CSGShape::OPERATION_INTERSECTION:
+ case CSGShape3D::OPERATION_INTERSECTION:
solid_material = get_material("shape_intersection_solid_material", p_gizmo);
break;
- case CSGShape::OPERATION_SUBTRACTION:
+ case CSGShape3D::OPERATION_SUBTRACTION:
solid_material = get_material("shape_subtraction_solid_material", p_gizmo);
break;
}
@@ -380,8 +380,8 @@ void CSGShapeSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
p_gizmo->add_mesh(mesh, false, Ref<SkinReference>(), solid_material);
}
- if (Object::cast_to<CSGSphere>(cs)) {
- CSGSphere *s = Object::cast_to<CSGSphere>(cs);
+ if (Object::cast_to<CSGSphere3D>(cs)) {
+ CSGSphere3D *s = Object::cast_to<CSGSphere3D>(cs);
float r = s->get_radius();
Vector<Vector3> handles;
@@ -389,8 +389,8 @@ void CSGShapeSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
p_gizmo->add_handles(handles, handles_material);
}
- if (Object::cast_to<CSGBox>(cs)) {
- CSGBox *s = Object::cast_to<CSGBox>(cs);
+ if (Object::cast_to<CSGBox3D>(cs)) {
+ CSGBox3D *s = Object::cast_to<CSGBox3D>(cs);
Vector<Vector3> handles;
handles.push_back(Vector3(s->get_width() * 0.5, 0, 0));
@@ -399,8 +399,8 @@ void CSGShapeSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
p_gizmo->add_handles(handles, handles_material);
}
- if (Object::cast_to<CSGCylinder>(cs)) {
- CSGCylinder *s = Object::cast_to<CSGCylinder>(cs);
+ if (Object::cast_to<CSGCylinder3D>(cs)) {
+ CSGCylinder3D *s = Object::cast_to<CSGCylinder3D>(cs);
Vector<Vector3> handles;
handles.push_back(Vector3(s->get_radius(), 0, 0));
@@ -408,8 +408,8 @@ void CSGShapeSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
p_gizmo->add_handles(handles, handles_material);
}
- if (Object::cast_to<CSGTorus>(cs)) {
- CSGTorus *s = Object::cast_to<CSGTorus>(cs);
+ if (Object::cast_to<CSGTorus3D>(cs)) {
+ CSGTorus3D *s = Object::cast_to<CSGTorus3D>(cs);
Vector<Vector3> handles;
handles.push_back(Vector3(s->get_inner_radius(), 0, 0));
@@ -419,6 +419,6 @@ void CSGShapeSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
}
EditorPluginCSG::EditorPluginCSG(EditorNode *p_editor) {
- Ref<CSGShapeSpatialGizmoPlugin> gizmo_plugin = Ref<CSGShapeSpatialGizmoPlugin>(memnew(CSGShapeSpatialGizmoPlugin));
- SpatialEditor::get_singleton()->add_gizmo_plugin(gizmo_plugin);
+ Ref<CSGShape3DGizmoPlugin> gizmo_plugin = Ref<CSGShape3DGizmoPlugin>(memnew(CSGShape3DGizmoPlugin));
+ Node3DEditor::get_singleton()->add_gizmo_plugin(gizmo_plugin);
}
diff --git a/modules/csg/csg_gizmos.h b/modules/csg/csg_gizmos.h
index 966b654802..7763989b2a 100644
--- a/modules/csg/csg_gizmos.h
+++ b/modules/csg/csg_gizmos.h
@@ -33,25 +33,25 @@
#include "csg_shape.h"
#include "editor/editor_plugin.h"
-#include "editor/spatial_editor_gizmos.h"
+#include "editor/node_3d_editor_gizmos.h"
-class CSGShapeSpatialGizmoPlugin : public EditorSpatialGizmoPlugin {
+class CSGShape3DGizmoPlugin : public EditorNode3DGizmoPlugin {
- GDCLASS(CSGShapeSpatialGizmoPlugin, EditorSpatialGizmoPlugin);
+ GDCLASS(CSGShape3DGizmoPlugin, EditorNode3DGizmoPlugin);
public:
- bool has_gizmo(Spatial *p_spatial);
+ bool has_gizmo(Node3D *p_spatial);
String get_name() const;
int get_priority() const;
bool is_selectable_when_hidden() const;
- void redraw(EditorSpatialGizmo *p_gizmo);
+ void redraw(EditorNode3DGizmo *p_gizmo);
- String get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_idx) const;
- Variant get_handle_value(EditorSpatialGizmo *p_gizmo, int p_idx) const;
- void set_handle(EditorSpatialGizmo *p_gizmo, int p_idx, Camera *p_camera, const Point2 &p_point);
- void commit_handle(EditorSpatialGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel);
+ String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const;
+ Variant get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const;
+ void set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point);
+ void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel);
- CSGShapeSpatialGizmoPlugin();
+ CSGShape3DGizmoPlugin();
};
class EditorPluginCSG : public EditorPlugin {
diff --git a/modules/csg/csg_shape.cpp b/modules/csg/csg_shape.cpp
index 54635ae320..d38ddf3f90 100644
--- a/modules/csg/csg_shape.cpp
+++ b/modules/csg/csg_shape.cpp
@@ -29,9 +29,9 @@
/*************************************************************************/
#include "csg_shape.h"
-#include "scene/3d/path.h"
+#include "scene/3d/path_3d.h"
-void CSGShape::set_use_collision(bool p_enable) {
+void CSGShape3D::set_use_collision(bool p_enable) {
if (use_collision == p_enable)
return;
@@ -43,52 +43,52 @@ void CSGShape::set_use_collision(bool p_enable) {
if (use_collision) {
root_collision_shape.instance();
- root_collision_instance = PhysicsServer::get_singleton()->body_create(PhysicsServer::BODY_MODE_STATIC);
- PhysicsServer::get_singleton()->body_set_state(root_collision_instance, PhysicsServer::BODY_STATE_TRANSFORM, get_global_transform());
- PhysicsServer::get_singleton()->body_add_shape(root_collision_instance, root_collision_shape->get_rid());
- PhysicsServer::get_singleton()->body_set_space(root_collision_instance, get_world()->get_space());
- PhysicsServer::get_singleton()->body_attach_object_instance_id(root_collision_instance, get_instance_id());
+ root_collision_instance = PhysicsServer3D::get_singleton()->body_create(PhysicsServer3D::BODY_MODE_STATIC);
+ PhysicsServer3D::get_singleton()->body_set_state(root_collision_instance, PhysicsServer3D::BODY_STATE_TRANSFORM, get_global_transform());
+ PhysicsServer3D::get_singleton()->body_add_shape(root_collision_instance, root_collision_shape->get_rid());
+ PhysicsServer3D::get_singleton()->body_set_space(root_collision_instance, get_world()->get_space());
+ PhysicsServer3D::get_singleton()->body_attach_object_instance_id(root_collision_instance, get_instance_id());
set_collision_layer(collision_layer);
set_collision_mask(collision_mask);
_make_dirty(); //force update
} else {
- PhysicsServer::get_singleton()->free(root_collision_instance);
+ PhysicsServer3D::get_singleton()->free(root_collision_instance);
root_collision_instance = RID();
root_collision_shape.unref();
}
_change_notify();
}
-bool CSGShape::is_using_collision() const {
+bool CSGShape3D::is_using_collision() const {
return use_collision;
}
-void CSGShape::set_collision_layer(uint32_t p_layer) {
+void CSGShape3D::set_collision_layer(uint32_t p_layer) {
collision_layer = p_layer;
if (root_collision_instance.is_valid()) {
- PhysicsServer::get_singleton()->body_set_collision_layer(root_collision_instance, p_layer);
+ PhysicsServer3D::get_singleton()->body_set_collision_layer(root_collision_instance, p_layer);
}
}
-uint32_t CSGShape::get_collision_layer() const {
+uint32_t CSGShape3D::get_collision_layer() const {
return collision_layer;
}
-void CSGShape::set_collision_mask(uint32_t p_mask) {
+void CSGShape3D::set_collision_mask(uint32_t p_mask) {
collision_mask = p_mask;
if (root_collision_instance.is_valid()) {
- PhysicsServer::get_singleton()->body_set_collision_mask(root_collision_instance, p_mask);
+ PhysicsServer3D::get_singleton()->body_set_collision_mask(root_collision_instance, p_mask);
}
}
-uint32_t CSGShape::get_collision_mask() const {
+uint32_t CSGShape3D::get_collision_mask() const {
return collision_mask;
}
-void CSGShape::set_collision_mask_bit(int p_bit, bool p_value) {
+void CSGShape3D::set_collision_mask_bit(int p_bit, bool p_value) {
uint32_t mask = get_collision_mask();
if (p_value)
@@ -98,12 +98,12 @@ void CSGShape::set_collision_mask_bit(int p_bit, bool p_value) {
set_collision_mask(mask);
}
-bool CSGShape::get_collision_mask_bit(int p_bit) const {
+bool CSGShape3D::get_collision_mask_bit(int p_bit) const {
return get_collision_mask() & (1 << p_bit);
}
-void CSGShape::set_collision_layer_bit(int p_bit, bool p_value) {
+void CSGShape3D::set_collision_layer_bit(int p_bit, bool p_value) {
uint32_t mask = get_collision_layer();
if (p_value)
@@ -113,25 +113,25 @@ void CSGShape::set_collision_layer_bit(int p_bit, bool p_value) {
set_collision_layer(mask);
}
-bool CSGShape::get_collision_layer_bit(int p_bit) const {
+bool CSGShape3D::get_collision_layer_bit(int p_bit) const {
return get_collision_layer() & (1 << p_bit);
}
-bool CSGShape::is_root_shape() const {
+bool CSGShape3D::is_root_shape() const {
return !parent;
}
-void CSGShape::set_snap(float p_snap) {
+void CSGShape3D::set_snap(float p_snap) {
snap = p_snap;
}
-float CSGShape::get_snap() const {
+float CSGShape3D::get_snap() const {
return snap;
}
-void CSGShape::_make_dirty() {
+void CSGShape3D::_make_dirty() {
if (!is_inside_tree())
return;
@@ -150,19 +150,19 @@ void CSGShape::_make_dirty() {
}
}
-CSGBrush *CSGShape::_get_brush() {
+CSGBrush *CSGShape3D::_get_brush() {
if (dirty) {
if (brush) {
memdelete(brush);
}
- brush = NULL;
+ brush = nullptr;
CSGBrush *n = _build_brush();
for (int i = 0; i < get_child_count(); i++) {
- CSGShape *child = Object::cast_to<CSGShape>(get_child(i));
+ CSGShape3D *child = Object::cast_to<CSGShape3D>(get_child(i));
if (!child)
continue;
if (!child->is_visible_in_tree())
@@ -185,9 +185,9 @@ CSGBrush *CSGShape::_get_brush() {
CSGBrushOperation bop;
switch (child->get_operation()) {
- case CSGShape::OPERATION_UNION: bop.merge_brushes(CSGBrushOperation::OPERATION_UNION, *n, *nn2, *nn, snap); break;
- case CSGShape::OPERATION_INTERSECTION: bop.merge_brushes(CSGBrushOperation::OPERATION_INTERSECTION, *n, *nn2, *nn, snap); break;
- case CSGShape::OPERATION_SUBTRACTION: bop.merge_brushes(CSGBrushOperation::OPERATION_SUBSTRACTION, *n, *nn2, *nn, snap); break;
+ case CSGShape3D::OPERATION_UNION: bop.merge_brushes(CSGBrushOperation::OPERATION_UNION, *n, *nn2, *nn, snap); break;
+ case CSGShape3D::OPERATION_INTERSECTION: bop.merge_brushes(CSGBrushOperation::OPERATION_INTERSECTION, *n, *nn2, *nn, snap); break;
+ case CSGShape3D::OPERATION_SUBTRACTION: bop.merge_brushes(CSGBrushOperation::OPERATION_SUBSTRACTION, *n, *nn2, *nn, snap); break;
}
memdelete(n);
memdelete(nn2);
@@ -218,18 +218,18 @@ CSGBrush *CSGShape::_get_brush() {
return brush;
}
-int CSGShape::mikktGetNumFaces(const SMikkTSpaceContext *pContext) {
+int CSGShape3D::mikktGetNumFaces(const SMikkTSpaceContext *pContext) {
ShapeUpdateSurface &surface = *((ShapeUpdateSurface *)pContext->m_pUserData);
return surface.vertices.size() / 3;
}
-int CSGShape::mikktGetNumVerticesOfFace(const SMikkTSpaceContext *pContext, const int iFace) {
+int CSGShape3D::mikktGetNumVerticesOfFace(const SMikkTSpaceContext *pContext, const int iFace) {
// always 3
return 3;
}
-void CSGShape::mikktGetPosition(const SMikkTSpaceContext *pContext, float fvPosOut[], const int iFace, const int iVert) {
+void CSGShape3D::mikktGetPosition(const SMikkTSpaceContext *pContext, float fvPosOut[], const int iFace, const int iVert) {
ShapeUpdateSurface &surface = *((ShapeUpdateSurface *)pContext->m_pUserData);
Vector3 v = surface.verticesw[iFace * 3 + iVert];
@@ -238,7 +238,7 @@ void CSGShape::mikktGetPosition(const SMikkTSpaceContext *pContext, float fvPosO
fvPosOut[2] = v.z;
}
-void CSGShape::mikktGetNormal(const SMikkTSpaceContext *pContext, float fvNormOut[], const int iFace, const int iVert) {
+void CSGShape3D::mikktGetNormal(const SMikkTSpaceContext *pContext, float fvNormOut[], const int iFace, const int iVert) {
ShapeUpdateSurface &surface = *((ShapeUpdateSurface *)pContext->m_pUserData);
Vector3 n = surface.normalsw[iFace * 3 + iVert];
@@ -247,7 +247,7 @@ void CSGShape::mikktGetNormal(const SMikkTSpaceContext *pContext, float fvNormOu
fvNormOut[2] = n.z;
}
-void CSGShape::mikktGetTexCoord(const SMikkTSpaceContext *pContext, float fvTexcOut[], const int iFace, const int iVert) {
+void CSGShape3D::mikktGetTexCoord(const SMikkTSpaceContext *pContext, float fvTexcOut[], const int iFace, const int iVert) {
ShapeUpdateSurface &surface = *((ShapeUpdateSurface *)pContext->m_pUserData);
Vector2 t = surface.uvsw[iFace * 3 + iVert];
@@ -255,7 +255,7 @@ void CSGShape::mikktGetTexCoord(const SMikkTSpaceContext *pContext, float fvTexc
fvTexcOut[1] = t.y;
}
-void CSGShape::mikktSetTSpaceDefault(const SMikkTSpaceContext *pContext, const float fvTangent[], const float fvBiTangent[], const float fMagS, const float fMagT,
+void CSGShape3D::mikktSetTSpaceDefault(const SMikkTSpaceContext *pContext, const float fvTangent[], const float fvBiTangent[], const float fMagS, const float fMagT,
const tbool bIsOrientationPreserving, const int iFace, const int iVert) {
ShapeUpdateSurface &surface = *((ShapeUpdateSurface *)pContext->m_pUserData);
@@ -273,7 +273,7 @@ void CSGShape::mikktSetTSpaceDefault(const SMikkTSpaceContext *pContext, const f
surface.tansw[i++] = d < 0 ? -1 : 1;
}
-void CSGShape::_update_shape() {
+void CSGShape3D::_update_shape() {
if (parent)
return;
@@ -296,20 +296,18 @@ void CSGShape::_update_shape() {
int mat = n->faces[i].material;
ERR_CONTINUE(mat < -1 || mat >= face_count.size());
int idx = mat == -1 ? face_count.size() - 1 : mat;
- if (n->faces[i].smooth) {
- Plane p(n->faces[i].vertices[0], n->faces[i].vertices[1], n->faces[i].vertices[2]);
+ Plane p(n->faces[i].vertices[0], n->faces[i].vertices[1], n->faces[i].vertices[2]);
- for (int j = 0; j < 3; j++) {
- Vector3 v = n->faces[i].vertices[j];
- Vector3 add;
- if (vec_map.lookup(v, add)) {
- add += p.normal;
- } else {
- add = p.normal;
- }
- vec_map.set(v, add);
+ for (int j = 0; j < 3; j++) {
+ Vector3 v = n->faces[i].vertices[j];
+ Vector3 add;
+ if (vec_map.lookup(v, add)) {
+ add += p.normal;
+ } else {
+ add = p.normal;
}
+ vec_map.set(v, add);
}
face_count.write[idx]++;
@@ -427,7 +425,7 @@ void CSGShape::_update_shape() {
mkif.m_getPosition = mikktGetPosition;
mkif.m_getTexCoord = mikktGetTexCoord;
mkif.m_setTSpace = mikktSetTSpaceDefault;
- mkif.m_setTSpaceBasic = NULL;
+ mkif.m_setTSpaceBasic = nullptr;
SMikkTSpaceContext msc;
msc.m_pInterface = &mkif;
@@ -460,11 +458,11 @@ void CSGShape::_update_shape() {
set_base(root_mesh->get_rid());
}
-AABB CSGShape::get_aabb() const {
+AABB CSGShape3D::get_aabb() const {
return node_aabb;
}
-Vector<Vector3> CSGShape::get_brush_faces() {
+Vector<Vector3> CSGShape3D::get_brush_faces() {
ERR_FAIL_COND_V(!is_inside_tree(), Vector<Vector3>());
CSGBrush *b = _get_brush();
if (!b) {
@@ -486,18 +484,18 @@ Vector<Vector3> CSGShape::get_brush_faces() {
return faces;
}
-Vector<Face3> CSGShape::get_faces(uint32_t p_usage_flags) const {
+Vector<Face3> CSGShape3D::get_faces(uint32_t p_usage_flags) const {
return Vector<Face3>();
}
-void CSGShape::_notification(int p_what) {
+void CSGShape3D::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
Node *parentn = get_parent();
if (parentn) {
- parent = Object::cast_to<CSGShape>(parentn);
+ parent = Object::cast_to<CSGShape3D>(parentn);
if (parent) {
set_base(RID());
root_mesh.unref();
@@ -506,11 +504,11 @@ void CSGShape::_notification(int p_what) {
if (use_collision && is_root_shape()) {
root_collision_shape.instance();
- root_collision_instance = PhysicsServer::get_singleton()->body_create(PhysicsServer::BODY_MODE_STATIC);
- PhysicsServer::get_singleton()->body_set_state(root_collision_instance, PhysicsServer::BODY_STATE_TRANSFORM, get_global_transform());
- PhysicsServer::get_singleton()->body_add_shape(root_collision_instance, root_collision_shape->get_rid());
- PhysicsServer::get_singleton()->body_set_space(root_collision_instance, get_world()->get_space());
- PhysicsServer::get_singleton()->body_attach_object_instance_id(root_collision_instance, get_instance_id());
+ root_collision_instance = PhysicsServer3D::get_singleton()->body_create(PhysicsServer3D::BODY_MODE_STATIC);
+ PhysicsServer3D::get_singleton()->body_set_state(root_collision_instance, PhysicsServer3D::BODY_STATE_TRANSFORM, get_global_transform());
+ PhysicsServer3D::get_singleton()->body_add_shape(root_collision_instance, root_collision_shape->get_rid());
+ PhysicsServer3D::get_singleton()->body_set_space(root_collision_instance, get_world()->get_space());
+ PhysicsServer3D::get_singleton()->body_attach_object_instance_id(root_collision_instance, get_instance_id());
set_collision_layer(collision_layer);
set_collision_mask(collision_mask);
}
@@ -536,10 +534,10 @@ void CSGShape::_notification(int p_what) {
if (parent)
parent->_make_dirty();
- parent = NULL;
+ parent = nullptr;
if (use_collision && is_root_shape() && root_collision_instance.is_valid()) {
- PhysicsServer::get_singleton()->free(root_collision_instance);
+ PhysicsServer3D::get_singleton()->free(root_collision_instance);
root_collision_instance = RID();
root_collision_shape.unref();
}
@@ -547,27 +545,27 @@ void CSGShape::_notification(int p_what) {
}
}
-void CSGShape::set_operation(Operation p_operation) {
+void CSGShape3D::set_operation(Operation p_operation) {
operation = p_operation;
_make_dirty();
update_gizmo();
}
-CSGShape::Operation CSGShape::get_operation() const {
+CSGShape3D::Operation CSGShape3D::get_operation() const {
return operation;
}
-void CSGShape::set_calculate_tangents(bool p_calculate_tangents) {
+void CSGShape3D::set_calculate_tangents(bool p_calculate_tangents) {
calculate_tangents = p_calculate_tangents;
_make_dirty();
}
-bool CSGShape::is_calculating_tangents() const {
+bool CSGShape3D::is_calculating_tangents() const {
return calculate_tangents;
}
-void CSGShape::_validate_property(PropertyInfo &property) const {
+void CSGShape3D::_validate_property(PropertyInfo &property) const {
bool is_collision_prefixed = property.name.begins_with("collision_");
if ((is_collision_prefixed || property.name.begins_with("use_collision")) && is_inside_tree() && !is_root_shape()) {
//hide collision if not root
@@ -577,7 +575,7 @@ void CSGShape::_validate_property(PropertyInfo &property) const {
}
}
-Array CSGShape::get_meshes() const {
+Array CSGShape3D::get_meshes() const {
if (root_mesh.is_valid()) {
Array arr;
@@ -589,36 +587,36 @@ Array CSGShape::get_meshes() const {
return Array();
}
-void CSGShape::_bind_methods() {
+void CSGShape3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_update_shape"), &CSGShape::_update_shape);
- ClassDB::bind_method(D_METHOD("is_root_shape"), &CSGShape::is_root_shape);
+ ClassDB::bind_method(D_METHOD("_update_shape"), &CSGShape3D::_update_shape);
+ ClassDB::bind_method(D_METHOD("is_root_shape"), &CSGShape3D::is_root_shape);
- ClassDB::bind_method(D_METHOD("set_operation", "operation"), &CSGShape::set_operation);
- ClassDB::bind_method(D_METHOD("get_operation"), &CSGShape::get_operation);
+ ClassDB::bind_method(D_METHOD("set_operation", "operation"), &CSGShape3D::set_operation);
+ ClassDB::bind_method(D_METHOD("get_operation"), &CSGShape3D::get_operation);
- ClassDB::bind_method(D_METHOD("set_snap", "snap"), &CSGShape::set_snap);
- ClassDB::bind_method(D_METHOD("get_snap"), &CSGShape::get_snap);
+ ClassDB::bind_method(D_METHOD("set_snap", "snap"), &CSGShape3D::set_snap);
+ ClassDB::bind_method(D_METHOD("get_snap"), &CSGShape3D::get_snap);
- ClassDB::bind_method(D_METHOD("set_use_collision", "operation"), &CSGShape::set_use_collision);
- ClassDB::bind_method(D_METHOD("is_using_collision"), &CSGShape::is_using_collision);
+ ClassDB::bind_method(D_METHOD("set_use_collision", "operation"), &CSGShape3D::set_use_collision);
+ ClassDB::bind_method(D_METHOD("is_using_collision"), &CSGShape3D::is_using_collision);
- ClassDB::bind_method(D_METHOD("set_collision_layer", "layer"), &CSGShape::set_collision_layer);
- ClassDB::bind_method(D_METHOD("get_collision_layer"), &CSGShape::get_collision_layer);
+ ClassDB::bind_method(D_METHOD("set_collision_layer", "layer"), &CSGShape3D::set_collision_layer);
+ ClassDB::bind_method(D_METHOD("get_collision_layer"), &CSGShape3D::get_collision_layer);
- ClassDB::bind_method(D_METHOD("set_collision_mask", "mask"), &CSGShape::set_collision_mask);
- ClassDB::bind_method(D_METHOD("get_collision_mask"), &CSGShape::get_collision_mask);
+ ClassDB::bind_method(D_METHOD("set_collision_mask", "mask"), &CSGShape3D::set_collision_mask);
+ ClassDB::bind_method(D_METHOD("get_collision_mask"), &CSGShape3D::get_collision_mask);
- ClassDB::bind_method(D_METHOD("set_collision_mask_bit", "bit", "value"), &CSGShape::set_collision_mask_bit);
- ClassDB::bind_method(D_METHOD("get_collision_mask_bit", "bit"), &CSGShape::get_collision_mask_bit);
+ ClassDB::bind_method(D_METHOD("set_collision_mask_bit", "bit", "value"), &CSGShape3D::set_collision_mask_bit);
+ ClassDB::bind_method(D_METHOD("get_collision_mask_bit", "bit"), &CSGShape3D::get_collision_mask_bit);
- ClassDB::bind_method(D_METHOD("set_collision_layer_bit", "bit", "value"), &CSGShape::set_collision_layer_bit);
- ClassDB::bind_method(D_METHOD("get_collision_layer_bit", "bit"), &CSGShape::get_collision_layer_bit);
+ ClassDB::bind_method(D_METHOD("set_collision_layer_bit", "bit", "value"), &CSGShape3D::set_collision_layer_bit);
+ ClassDB::bind_method(D_METHOD("get_collision_layer_bit", "bit"), &CSGShape3D::get_collision_layer_bit);
- ClassDB::bind_method(D_METHOD("set_calculate_tangents", "enabled"), &CSGShape::set_calculate_tangents);
- ClassDB::bind_method(D_METHOD("is_calculating_tangents"), &CSGShape::is_calculating_tangents);
+ ClassDB::bind_method(D_METHOD("set_calculate_tangents", "enabled"), &CSGShape3D::set_calculate_tangents);
+ ClassDB::bind_method(D_METHOD("is_calculating_tangents"), &CSGShape3D::is_calculating_tangents);
- ClassDB::bind_method(D_METHOD("get_meshes"), &CSGShape::get_meshes);
+ ClassDB::bind_method(D_METHOD("get_meshes"), &CSGShape3D::get_meshes);
ADD_PROPERTY(PropertyInfo(Variant::INT, "operation", PROPERTY_HINT_ENUM, "Union,Intersection,Subtraction"), "set_operation", "get_operation");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "snap", PROPERTY_HINT_RANGE, "0.0001,1,0.001"), "set_snap", "get_snap");
@@ -634,10 +632,10 @@ void CSGShape::_bind_methods() {
BIND_ENUM_CONSTANT(OPERATION_SUBTRACTION);
}
-CSGShape::CSGShape() {
+CSGShape3D::CSGShape3D() {
operation = OPERATION_UNION;
- parent = NULL;
- brush = NULL;
+ parent = nullptr;
+ brush = nullptr;
dirty = false;
snap = 0.001;
use_collision = false;
@@ -647,25 +645,25 @@ CSGShape::CSGShape() {
set_notify_local_transform(true);
}
-CSGShape::~CSGShape() {
+CSGShape3D::~CSGShape3D() {
if (brush) {
memdelete(brush);
- brush = NULL;
+ brush = nullptr;
}
}
//////////////////////////////////
-CSGBrush *CSGCombiner::_build_brush() {
+CSGBrush *CSGCombiner3D::_build_brush() {
- return NULL; //does not build anything
+ return nullptr; //does not build anything
}
-CSGCombiner::CSGCombiner() {
+CSGCombiner3D::CSGCombiner3D() {
}
/////////////////////
-CSGBrush *CSGPrimitive::_create_brush_from_arrays(const Vector<Vector3> &p_vertices, const Vector<Vector2> &p_uv, const Vector<bool> &p_smooth, const Vector<Ref<Material>> &p_materials) {
+CSGBrush *CSGPrimitive3D::_create_brush_from_arrays(const Vector<Vector3> &p_vertices, const Vector<Vector2> &p_uv, const Vector<bool> &p_smooth, const Vector<Ref<Material>> &p_materials) {
CSGBrush *brush = memnew(CSGBrush);
@@ -683,15 +681,15 @@ CSGBrush *CSGPrimitive::_create_brush_from_arrays(const Vector<Vector3> &p_verti
return brush;
}
-void CSGPrimitive::_bind_methods() {
+void CSGPrimitive3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_invert_faces", "invert_faces"), &CSGPrimitive::set_invert_faces);
- ClassDB::bind_method(D_METHOD("is_inverting_faces"), &CSGPrimitive::is_inverting_faces);
+ ClassDB::bind_method(D_METHOD("set_invert_faces", "invert_faces"), &CSGPrimitive3D::set_invert_faces);
+ ClassDB::bind_method(D_METHOD("is_inverting_faces"), &CSGPrimitive3D::is_inverting_faces);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "invert_faces"), "set_invert_faces", "is_inverting_faces");
}
-void CSGPrimitive::set_invert_faces(bool p_invert) {
+void CSGPrimitive3D::set_invert_faces(bool p_invert) {
if (invert_faces == p_invert)
return;
@@ -700,20 +698,20 @@ void CSGPrimitive::set_invert_faces(bool p_invert) {
_make_dirty();
}
-bool CSGPrimitive::is_inverting_faces() {
+bool CSGPrimitive3D::is_inverting_faces() {
return invert_faces;
}
-CSGPrimitive::CSGPrimitive() {
+CSGPrimitive3D::CSGPrimitive3D() {
invert_faces = false;
}
/////////////////////
-CSGBrush *CSGMesh::_build_brush() {
+CSGBrush *CSGMesh3D::_build_brush() {
if (!mesh.is_valid())
- return NULL;
+ return nullptr;
Vector<Vector3> vertices;
Vector<bool> smooth;
@@ -731,7 +729,7 @@ CSGBrush *CSGMesh::_build_brush() {
if (arrays.size() == 0) {
_make_dirty();
- ERR_FAIL_COND_V(arrays.size() == 0, NULL);
+ ERR_FAIL_COND_V(arrays.size() == 0, nullptr);
}
Vector<Vector3> avertices = arrays[Mesh::ARRAY_VERTEX];
@@ -741,19 +739,15 @@ CSGBrush *CSGMesh::_build_brush() {
const Vector3 *vr = avertices.ptr();
Vector<Vector3> anormals = arrays[Mesh::ARRAY_NORMAL];
- const Vector3 *nr;
- bool nr_used = false;
+ const Vector3 *nr = nullptr;
if (anormals.size()) {
nr = anormals.ptr();
- nr_used = true;
}
Vector<Vector2> auvs = arrays[Mesh::ARRAY_TEX_UV];
- const Vector2 *uvr;
- bool uvr_used = false;
+ const Vector2 *uvr = nullptr;
if (auvs.size()) {
uvr = auvs.ptr();
- uvr_used = true;
}
Ref<Material> mat;
@@ -789,10 +783,10 @@ CSGBrush *CSGMesh::_build_brush() {
for (int k = 0; k < 3; k++) {
int idx = ir[j + k];
vertex[k] = vr[idx];
- if (nr_used) {
+ if (nr) {
normal[k] = nr[idx];
}
- if (uvr_used) {
+ if (uvr) {
uv[k] = uvr[idx];
}
}
@@ -832,10 +826,10 @@ CSGBrush *CSGMesh::_build_brush() {
for (int k = 0; k < 3; k++) {
vertex[k] = vr[j + k];
- if (nr_used) {
+ if (nr) {
normal[k] = nr[j + k];
}
- if (uvr_used) {
+ if (uvr) {
uv[k] = uvr[j + k];
}
}
@@ -857,63 +851,63 @@ CSGBrush *CSGMesh::_build_brush() {
}
if (vertices.size() == 0)
- return NULL;
+ return nullptr;
return _create_brush_from_arrays(vertices, uvs, smooth, materials);
}
-void CSGMesh::_mesh_changed() {
+void CSGMesh3D::_mesh_changed() {
_make_dirty();
update_gizmo();
}
-void CSGMesh::set_material(const Ref<Material> &p_material) {
+void CSGMesh3D::set_material(const Ref<Material> &p_material) {
if (material == p_material)
return;
material = p_material;
_make_dirty();
}
-Ref<Material> CSGMesh::get_material() const {
+Ref<Material> CSGMesh3D::get_material() const {
return material;
}
-void CSGMesh::_bind_methods() {
+void CSGMesh3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_mesh", "mesh"), &CSGMesh::set_mesh);
- ClassDB::bind_method(D_METHOD("get_mesh"), &CSGMesh::get_mesh);
+ ClassDB::bind_method(D_METHOD("set_mesh", "mesh"), &CSGMesh3D::set_mesh);
+ ClassDB::bind_method(D_METHOD("get_mesh"), &CSGMesh3D::get_mesh);
- ClassDB::bind_method(D_METHOD("set_material", "material"), &CSGMesh::set_material);
- ClassDB::bind_method(D_METHOD("get_material"), &CSGMesh::get_material);
+ ClassDB::bind_method(D_METHOD("set_material", "material"), &CSGMesh3D::set_material);
+ ClassDB::bind_method(D_METHOD("get_material"), &CSGMesh3D::get_material);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "mesh", PROPERTY_HINT_RESOURCE_TYPE, "Mesh"), "set_mesh", "get_mesh");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "StandardMaterial3D,ShaderMaterial"), "set_material", "get_material");
}
-void CSGMesh::set_mesh(const Ref<Mesh> &p_mesh) {
+void CSGMesh3D::set_mesh(const Ref<Mesh> &p_mesh) {
if (mesh == p_mesh)
return;
if (mesh.is_valid()) {
- mesh->disconnect("changed", callable_mp(this, &CSGMesh::_mesh_changed));
+ mesh->disconnect("changed", callable_mp(this, &CSGMesh3D::_mesh_changed));
}
mesh = p_mesh;
if (mesh.is_valid()) {
- mesh->connect("changed", callable_mp(this, &CSGMesh::_mesh_changed));
+ mesh->connect("changed", callable_mp(this, &CSGMesh3D::_mesh_changed));
}
_make_dirty();
}
-Ref<Mesh> CSGMesh::get_mesh() {
+Ref<Mesh> CSGMesh3D::get_mesh() {
return mesh;
}
////////////////////////////////
-CSGBrush *CSGSphere::_build_brush() {
+CSGBrush *CSGSphere3D::_build_brush() {
// set our bounding box
@@ -1032,20 +1026,20 @@ CSGBrush *CSGSphere::_build_brush() {
return brush;
}
-void CSGSphere::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_radius", "radius"), &CSGSphere::set_radius);
- ClassDB::bind_method(D_METHOD("get_radius"), &CSGSphere::get_radius);
+void CSGSphere3D::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("set_radius", "radius"), &CSGSphere3D::set_radius);
+ ClassDB::bind_method(D_METHOD("get_radius"), &CSGSphere3D::get_radius);
- ClassDB::bind_method(D_METHOD("set_radial_segments", "radial_segments"), &CSGSphere::set_radial_segments);
- ClassDB::bind_method(D_METHOD("get_radial_segments"), &CSGSphere::get_radial_segments);
- ClassDB::bind_method(D_METHOD("set_rings", "rings"), &CSGSphere::set_rings);
- ClassDB::bind_method(D_METHOD("get_rings"), &CSGSphere::get_rings);
+ ClassDB::bind_method(D_METHOD("set_radial_segments", "radial_segments"), &CSGSphere3D::set_radial_segments);
+ ClassDB::bind_method(D_METHOD("get_radial_segments"), &CSGSphere3D::get_radial_segments);
+ ClassDB::bind_method(D_METHOD("set_rings", "rings"), &CSGSphere3D::set_rings);
+ ClassDB::bind_method(D_METHOD("get_rings"), &CSGSphere3D::get_rings);
- ClassDB::bind_method(D_METHOD("set_smooth_faces", "smooth_faces"), &CSGSphere::set_smooth_faces);
- ClassDB::bind_method(D_METHOD("get_smooth_faces"), &CSGSphere::get_smooth_faces);
+ ClassDB::bind_method(D_METHOD("set_smooth_faces", "smooth_faces"), &CSGSphere3D::set_smooth_faces);
+ ClassDB::bind_method(D_METHOD("get_smooth_faces"), &CSGSphere3D::get_smooth_faces);
- ClassDB::bind_method(D_METHOD("set_material", "material"), &CSGSphere::set_material);
- ClassDB::bind_method(D_METHOD("get_material"), &CSGSphere::get_material);
+ ClassDB::bind_method(D_METHOD("set_material", "material"), &CSGSphere3D::set_material);
+ ClassDB::bind_method(D_METHOD("get_material"), &CSGSphere3D::get_material);
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "radius", PROPERTY_HINT_RANGE, "0.001,100.0,0.001"), "set_radius", "get_radius");
ADD_PROPERTY(PropertyInfo(Variant::INT, "radial_segments", PROPERTY_HINT_RANGE, "1,100,1"), "set_radial_segments", "get_radial_segments");
@@ -1054,7 +1048,7 @@ void CSGSphere::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "StandardMaterial3D,ShaderMaterial"), "set_material", "get_material");
}
-void CSGSphere::set_radius(const float p_radius) {
+void CSGSphere3D::set_radius(const float p_radius) {
ERR_FAIL_COND(p_radius <= 0);
radius = p_radius;
_make_dirty();
@@ -1062,51 +1056,51 @@ void CSGSphere::set_radius(const float p_radius) {
_change_notify("radius");
}
-float CSGSphere::get_radius() const {
+float CSGSphere3D::get_radius() const {
return radius;
}
-void CSGSphere::set_radial_segments(const int p_radial_segments) {
+void CSGSphere3D::set_radial_segments(const int p_radial_segments) {
radial_segments = p_radial_segments > 4 ? p_radial_segments : 4;
_make_dirty();
update_gizmo();
}
-int CSGSphere::get_radial_segments() const {
+int CSGSphere3D::get_radial_segments() const {
return radial_segments;
}
-void CSGSphere::set_rings(const int p_rings) {
+void CSGSphere3D::set_rings(const int p_rings) {
rings = p_rings > 1 ? p_rings : 1;
_make_dirty();
update_gizmo();
}
-int CSGSphere::get_rings() const {
+int CSGSphere3D::get_rings() const {
return rings;
}
-void CSGSphere::set_smooth_faces(const bool p_smooth_faces) {
+void CSGSphere3D::set_smooth_faces(const bool p_smooth_faces) {
smooth_faces = p_smooth_faces;
_make_dirty();
}
-bool CSGSphere::get_smooth_faces() const {
+bool CSGSphere3D::get_smooth_faces() const {
return smooth_faces;
}
-void CSGSphere::set_material(const Ref<Material> &p_material) {
+void CSGSphere3D::set_material(const Ref<Material> &p_material) {
material = p_material;
_make_dirty();
}
-Ref<Material> CSGSphere::get_material() const {
+Ref<Material> CSGSphere3D::get_material() const {
return material;
}
-CSGSphere::CSGSphere() {
+CSGSphere3D::CSGSphere3D() {
// defaults
radius = 1.0;
radial_segments = 12;
@@ -1116,7 +1110,7 @@ CSGSphere::CSGSphere() {
///////////////
-CSGBrush *CSGBox::_build_brush() {
+CSGBrush *CSGBox3D::_build_brush() {
// set our bounding box
@@ -1221,18 +1215,18 @@ CSGBrush *CSGBox::_build_brush() {
return brush;
}
-void CSGBox::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_width", "width"), &CSGBox::set_width);
- ClassDB::bind_method(D_METHOD("get_width"), &CSGBox::get_width);
+void CSGBox3D::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("set_width", "width"), &CSGBox3D::set_width);
+ ClassDB::bind_method(D_METHOD("get_width"), &CSGBox3D::get_width);
- ClassDB::bind_method(D_METHOD("set_height", "height"), &CSGBox::set_height);
- ClassDB::bind_method(D_METHOD("get_height"), &CSGBox::get_height);
+ ClassDB::bind_method(D_METHOD("set_height", "height"), &CSGBox3D::set_height);
+ ClassDB::bind_method(D_METHOD("get_height"), &CSGBox3D::get_height);
- ClassDB::bind_method(D_METHOD("set_depth", "depth"), &CSGBox::set_depth);
- ClassDB::bind_method(D_METHOD("get_depth"), &CSGBox::get_depth);
+ ClassDB::bind_method(D_METHOD("set_depth", "depth"), &CSGBox3D::set_depth);
+ ClassDB::bind_method(D_METHOD("get_depth"), &CSGBox3D::get_depth);
- ClassDB::bind_method(D_METHOD("set_material", "material"), &CSGBox::set_material);
- ClassDB::bind_method(D_METHOD("get_material"), &CSGBox::get_material);
+ ClassDB::bind_method(D_METHOD("set_material", "material"), &CSGBox3D::set_material);
+ ClassDB::bind_method(D_METHOD("get_material"), &CSGBox3D::get_material);
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "width", PROPERTY_HINT_EXP_RANGE, "0.001,1000.0,0.001,or_greater"), "set_width", "get_width");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "height", PROPERTY_HINT_EXP_RANGE, "0.001,1000.0,0.001,or_greater"), "set_height", "get_height");
@@ -1240,52 +1234,52 @@ void CSGBox::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "StandardMaterial3D,ShaderMaterial"), "set_material", "get_material");
}
-void CSGBox::set_width(const float p_width) {
+void CSGBox3D::set_width(const float p_width) {
width = p_width;
_make_dirty();
update_gizmo();
_change_notify("width");
}
-float CSGBox::get_width() const {
+float CSGBox3D::get_width() const {
return width;
}
-void CSGBox::set_height(const float p_height) {
+void CSGBox3D::set_height(const float p_height) {
height = p_height;
_make_dirty();
update_gizmo();
_change_notify("height");
}
-float CSGBox::get_height() const {
+float CSGBox3D::get_height() const {
return height;
}
-void CSGBox::set_depth(const float p_depth) {
+void CSGBox3D::set_depth(const float p_depth) {
depth = p_depth;
_make_dirty();
update_gizmo();
_change_notify("depth");
}
-float CSGBox::get_depth() const {
+float CSGBox3D::get_depth() const {
return depth;
}
-void CSGBox::set_material(const Ref<Material> &p_material) {
+void CSGBox3D::set_material(const Ref<Material> &p_material) {
material = p_material;
_make_dirty();
update_gizmo();
}
-Ref<Material> CSGBox::get_material() const {
+Ref<Material> CSGBox3D::get_material() const {
return material;
}
-CSGBox::CSGBox() {
+CSGBox3D::CSGBox3D() {
// defaults
width = 2.0;
height = 2.0;
@@ -1294,7 +1288,7 @@ CSGBox::CSGBox() {
///////////////
-CSGBrush *CSGCylinder::_build_brush() {
+CSGBrush *CSGCylinder3D::_build_brush() {
// set our bounding box
@@ -1430,24 +1424,24 @@ CSGBrush *CSGCylinder::_build_brush() {
return brush;
}
-void CSGCylinder::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_radius", "radius"), &CSGCylinder::set_radius);
- ClassDB::bind_method(D_METHOD("get_radius"), &CSGCylinder::get_radius);
+void CSGCylinder3D::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("set_radius", "radius"), &CSGCylinder3D::set_radius);
+ ClassDB::bind_method(D_METHOD("get_radius"), &CSGCylinder3D::get_radius);
- ClassDB::bind_method(D_METHOD("set_height", "height"), &CSGCylinder::set_height);
- ClassDB::bind_method(D_METHOD("get_height"), &CSGCylinder::get_height);
+ ClassDB::bind_method(D_METHOD("set_height", "height"), &CSGCylinder3D::set_height);
+ ClassDB::bind_method(D_METHOD("get_height"), &CSGCylinder3D::get_height);
- ClassDB::bind_method(D_METHOD("set_sides", "sides"), &CSGCylinder::set_sides);
- ClassDB::bind_method(D_METHOD("get_sides"), &CSGCylinder::get_sides);
+ ClassDB::bind_method(D_METHOD("set_sides", "sides"), &CSGCylinder3D::set_sides);
+ ClassDB::bind_method(D_METHOD("get_sides"), &CSGCylinder3D::get_sides);
- ClassDB::bind_method(D_METHOD("set_cone", "cone"), &CSGCylinder::set_cone);
- ClassDB::bind_method(D_METHOD("is_cone"), &CSGCylinder::is_cone);
+ ClassDB::bind_method(D_METHOD("set_cone", "cone"), &CSGCylinder3D::set_cone);
+ ClassDB::bind_method(D_METHOD("is_cone"), &CSGCylinder3D::is_cone);
- ClassDB::bind_method(D_METHOD("set_material", "material"), &CSGCylinder::set_material);
- ClassDB::bind_method(D_METHOD("get_material"), &CSGCylinder::get_material);
+ ClassDB::bind_method(D_METHOD("set_material", "material"), &CSGCylinder3D::set_material);
+ ClassDB::bind_method(D_METHOD("get_material"), &CSGCylinder3D::get_material);
- ClassDB::bind_method(D_METHOD("set_smooth_faces", "smooth_faces"), &CSGCylinder::set_smooth_faces);
- ClassDB::bind_method(D_METHOD("get_smooth_faces"), &CSGCylinder::get_smooth_faces);
+ ClassDB::bind_method(D_METHOD("set_smooth_faces", "smooth_faces"), &CSGCylinder3D::set_smooth_faces);
+ ClassDB::bind_method(D_METHOD("get_smooth_faces"), &CSGCylinder3D::get_smooth_faces);
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "radius", PROPERTY_HINT_EXP_RANGE, "0.001,1000.0,0.001,or_greater"), "set_radius", "get_radius");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "height", PROPERTY_HINT_EXP_RANGE, "0.001,1000.0,0.001,or_greater"), "set_height", "get_height");
@@ -1457,70 +1451,70 @@ void CSGCylinder::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "StandardMaterial3D,ShaderMaterial"), "set_material", "get_material");
}
-void CSGCylinder::set_radius(const float p_radius) {
+void CSGCylinder3D::set_radius(const float p_radius) {
radius = p_radius;
_make_dirty();
update_gizmo();
_change_notify("radius");
}
-float CSGCylinder::get_radius() const {
+float CSGCylinder3D::get_radius() const {
return radius;
}
-void CSGCylinder::set_height(const float p_height) {
+void CSGCylinder3D::set_height(const float p_height) {
height = p_height;
_make_dirty();
update_gizmo();
_change_notify("height");
}
-float CSGCylinder::get_height() const {
+float CSGCylinder3D::get_height() const {
return height;
}
-void CSGCylinder::set_sides(const int p_sides) {
+void CSGCylinder3D::set_sides(const int p_sides) {
ERR_FAIL_COND(p_sides < 3);
sides = p_sides;
_make_dirty();
update_gizmo();
}
-int CSGCylinder::get_sides() const {
+int CSGCylinder3D::get_sides() const {
return sides;
}
-void CSGCylinder::set_cone(const bool p_cone) {
+void CSGCylinder3D::set_cone(const bool p_cone) {
cone = p_cone;
_make_dirty();
update_gizmo();
}
-bool CSGCylinder::is_cone() const {
+bool CSGCylinder3D::is_cone() const {
return cone;
}
-void CSGCylinder::set_smooth_faces(const bool p_smooth_faces) {
+void CSGCylinder3D::set_smooth_faces(const bool p_smooth_faces) {
smooth_faces = p_smooth_faces;
_make_dirty();
}
-bool CSGCylinder::get_smooth_faces() const {
+bool CSGCylinder3D::get_smooth_faces() const {
return smooth_faces;
}
-void CSGCylinder::set_material(const Ref<Material> &p_material) {
+void CSGCylinder3D::set_material(const Ref<Material> &p_material) {
material = p_material;
_make_dirty();
}
-Ref<Material> CSGCylinder::get_material() const {
+Ref<Material> CSGCylinder3D::get_material() const {
return material;
}
-CSGCylinder::CSGCylinder() {
+CSGCylinder3D::CSGCylinder3D() {
// defaults
radius = 1.0;
height = 1.0;
@@ -1531,7 +1525,7 @@ CSGCylinder::CSGCylinder() {
///////////////
-CSGBrush *CSGTorus::_build_brush() {
+CSGBrush *CSGTorus3D::_build_brush() {
// set our bounding box
@@ -1539,7 +1533,7 @@ CSGBrush *CSGTorus::_build_brush() {
float max_radius = outer_radius;
if (min_radius == max_radius)
- return NULL; //sorry, can't
+ return nullptr; //sorry, can't
if (min_radius > max_radius) {
SWAP(min_radius, max_radius);
@@ -1657,24 +1651,24 @@ CSGBrush *CSGTorus::_build_brush() {
return brush;
}
-void CSGTorus::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_inner_radius", "radius"), &CSGTorus::set_inner_radius);
- ClassDB::bind_method(D_METHOD("get_inner_radius"), &CSGTorus::get_inner_radius);
+void CSGTorus3D::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("set_inner_radius", "radius"), &CSGTorus3D::set_inner_radius);
+ ClassDB::bind_method(D_METHOD("get_inner_radius"), &CSGTorus3D::get_inner_radius);
- ClassDB::bind_method(D_METHOD("set_outer_radius", "radius"), &CSGTorus::set_outer_radius);
- ClassDB::bind_method(D_METHOD("get_outer_radius"), &CSGTorus::get_outer_radius);
+ ClassDB::bind_method(D_METHOD("set_outer_radius", "radius"), &CSGTorus3D::set_outer_radius);
+ ClassDB::bind_method(D_METHOD("get_outer_radius"), &CSGTorus3D::get_outer_radius);
- ClassDB::bind_method(D_METHOD("set_sides", "sides"), &CSGTorus::set_sides);
- ClassDB::bind_method(D_METHOD("get_sides"), &CSGTorus::get_sides);
+ ClassDB::bind_method(D_METHOD("set_sides", "sides"), &CSGTorus3D::set_sides);
+ ClassDB::bind_method(D_METHOD("get_sides"), &CSGTorus3D::get_sides);
- ClassDB::bind_method(D_METHOD("set_ring_sides", "sides"), &CSGTorus::set_ring_sides);
- ClassDB::bind_method(D_METHOD("get_ring_sides"), &CSGTorus::get_ring_sides);
+ ClassDB::bind_method(D_METHOD("set_ring_sides", "sides"), &CSGTorus3D::set_ring_sides);
+ ClassDB::bind_method(D_METHOD("get_ring_sides"), &CSGTorus3D::get_ring_sides);
- ClassDB::bind_method(D_METHOD("set_material", "material"), &CSGTorus::set_material);
- ClassDB::bind_method(D_METHOD("get_material"), &CSGTorus::get_material);
+ ClassDB::bind_method(D_METHOD("set_material", "material"), &CSGTorus3D::set_material);
+ ClassDB::bind_method(D_METHOD("get_material"), &CSGTorus3D::get_material);
- ClassDB::bind_method(D_METHOD("set_smooth_faces", "smooth_faces"), &CSGTorus::set_smooth_faces);
- ClassDB::bind_method(D_METHOD("get_smooth_faces"), &CSGTorus::get_smooth_faces);
+ ClassDB::bind_method(D_METHOD("set_smooth_faces", "smooth_faces"), &CSGTorus3D::set_smooth_faces);
+ ClassDB::bind_method(D_METHOD("get_smooth_faces"), &CSGTorus3D::get_smooth_faces);
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "inner_radius", PROPERTY_HINT_EXP_RANGE, "0.001,1000.0,0.001,or_greater"), "set_inner_radius", "get_inner_radius");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "outer_radius", PROPERTY_HINT_EXP_RANGE, "0.001,1000.0,0.001,or_greater"), "set_outer_radius", "get_outer_radius");
@@ -1684,71 +1678,71 @@ void CSGTorus::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "StandardMaterial3D,ShaderMaterial"), "set_material", "get_material");
}
-void CSGTorus::set_inner_radius(const float p_inner_radius) {
+void CSGTorus3D::set_inner_radius(const float p_inner_radius) {
inner_radius = p_inner_radius;
_make_dirty();
update_gizmo();
_change_notify("inner_radius");
}
-float CSGTorus::get_inner_radius() const {
+float CSGTorus3D::get_inner_radius() const {
return inner_radius;
}
-void CSGTorus::set_outer_radius(const float p_outer_radius) {
+void CSGTorus3D::set_outer_radius(const float p_outer_radius) {
outer_radius = p_outer_radius;
_make_dirty();
update_gizmo();
_change_notify("outer_radius");
}
-float CSGTorus::get_outer_radius() const {
+float CSGTorus3D::get_outer_radius() const {
return outer_radius;
}
-void CSGTorus::set_sides(const int p_sides) {
+void CSGTorus3D::set_sides(const int p_sides) {
ERR_FAIL_COND(p_sides < 3);
sides = p_sides;
_make_dirty();
update_gizmo();
}
-int CSGTorus::get_sides() const {
+int CSGTorus3D::get_sides() const {
return sides;
}
-void CSGTorus::set_ring_sides(const int p_ring_sides) {
+void CSGTorus3D::set_ring_sides(const int p_ring_sides) {
ERR_FAIL_COND(p_ring_sides < 3);
ring_sides = p_ring_sides;
_make_dirty();
update_gizmo();
}
-int CSGTorus::get_ring_sides() const {
+int CSGTorus3D::get_ring_sides() const {
return ring_sides;
}
-void CSGTorus::set_smooth_faces(const bool p_smooth_faces) {
+void CSGTorus3D::set_smooth_faces(const bool p_smooth_faces) {
smooth_faces = p_smooth_faces;
_make_dirty();
}
-bool CSGTorus::get_smooth_faces() const {
+bool CSGTorus3D::get_smooth_faces() const {
return smooth_faces;
}
-void CSGTorus::set_material(const Ref<Material> &p_material) {
+void CSGTorus3D::set_material(const Ref<Material> &p_material) {
material = p_material;
_make_dirty();
}
-Ref<Material> CSGTorus::get_material() const {
+Ref<Material> CSGTorus3D::get_material() const {
return material;
}
-CSGTorus::CSGTorus() {
+CSGTorus3D::CSGTorus3D() {
// defaults
inner_radius = 2.0;
outer_radius = 3.0;
@@ -1759,12 +1753,12 @@ CSGTorus::CSGTorus() {
///////////////
-CSGBrush *CSGPolygon::_build_brush() {
+CSGBrush *CSGPolygon3D::_build_brush() {
// set our bounding box
if (polygon.size() < 3)
- return NULL;
+ return nullptr;
Vector<Point2> final_polygon = polygon;
@@ -1775,9 +1769,9 @@ CSGBrush *CSGPolygon::_build_brush() {
Vector<int> triangles = Geometry::triangulate_polygon(final_polygon);
if (triangles.size() < 3)
- return NULL;
+ return nullptr;
- Path *path = NULL;
+ Path3D *path = nullptr;
Ref<Curve3D> curve;
// get bounds for our polygon
@@ -1800,32 +1794,32 @@ CSGBrush *CSGPolygon::_build_brush() {
if (mode == MODE_PATH) {
if (!has_node(path_node))
- return NULL;
+ return nullptr;
Node *n = get_node(path_node);
if (!n)
- return NULL;
- path = Object::cast_to<Path>(n);
+ return nullptr;
+ path = Object::cast_to<Path3D>(n);
if (!path)
- return NULL;
+ return nullptr;
if (path != path_cache) {
if (path_cache) {
- path_cache->disconnect("tree_exited", callable_mp(this, &CSGPolygon::_path_exited));
- path_cache->disconnect("curve_changed", callable_mp(this, &CSGPolygon::_path_changed));
- path_cache = NULL;
+ path_cache->disconnect("tree_exited", callable_mp(this, &CSGPolygon3D::_path_exited));
+ path_cache->disconnect("curve_changed", callable_mp(this, &CSGPolygon3D::_path_changed));
+ path_cache = nullptr;
}
path_cache = path;
- path_cache->connect("tree_exited", callable_mp(this, &CSGPolygon::_path_exited));
- path_cache->connect("curve_changed", callable_mp(this, &CSGPolygon::_path_changed));
- path_cache = NULL;
+ path_cache->connect("tree_exited", callable_mp(this, &CSGPolygon3D::_path_exited));
+ path_cache->connect("curve_changed", callable_mp(this, &CSGPolygon3D::_path_changed));
+ path_cache = nullptr;
}
curve = path->get_curve();
if (curve.is_null())
- return NULL;
+ return nullptr;
if (curve->get_baked_length() <= 0)
- return NULL;
+ return nullptr;
}
CSGBrush *brush = memnew(CSGBrush);
@@ -2231,17 +2225,17 @@ CSGBrush *CSGPolygon::_build_brush() {
return brush;
}
-void CSGPolygon::_notification(int p_what) {
+void CSGPolygon3D::_notification(int p_what) {
if (p_what == NOTIFICATION_EXIT_TREE) {
if (path_cache) {
- path_cache->disconnect("tree_exited", callable_mp(this, &CSGPolygon::_path_exited));
- path_cache->disconnect("curve_changed", callable_mp(this, &CSGPolygon::_path_changed));
- path_cache = NULL;
+ path_cache->disconnect("tree_exited", callable_mp(this, &CSGPolygon3D::_path_exited));
+ path_cache->disconnect("curve_changed", callable_mp(this, &CSGPolygon3D::_path_changed));
+ path_cache = nullptr;
}
}
}
-void CSGPolygon::_validate_property(PropertyInfo &property) const {
+void CSGPolygon3D::_validate_property(PropertyInfo &property) const {
if (property.name.begins_with("spin") && mode != MODE_SPIN) {
property.usage = 0;
}
@@ -2252,60 +2246,60 @@ void CSGPolygon::_validate_property(PropertyInfo &property) const {
property.usage = 0;
}
- CSGShape::_validate_property(property);
+ CSGShape3D::_validate_property(property);
}
-void CSGPolygon::_path_changed() {
+void CSGPolygon3D::_path_changed() {
_make_dirty();
update_gizmo();
}
-void CSGPolygon::_path_exited() {
- path_cache = NULL;
+void CSGPolygon3D::_path_exited() {
+ path_cache = nullptr;
}
-void CSGPolygon::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_polygon", "polygon"), &CSGPolygon::set_polygon);
- ClassDB::bind_method(D_METHOD("get_polygon"), &CSGPolygon::get_polygon);
+void CSGPolygon3D::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("set_polygon", "polygon"), &CSGPolygon3D::set_polygon);
+ ClassDB::bind_method(D_METHOD("get_polygon"), &CSGPolygon3D::get_polygon);
- ClassDB::bind_method(D_METHOD("set_mode", "mode"), &CSGPolygon::set_mode);
- ClassDB::bind_method(D_METHOD("get_mode"), &CSGPolygon::get_mode);
+ ClassDB::bind_method(D_METHOD("set_mode", "mode"), &CSGPolygon3D::set_mode);
+ ClassDB::bind_method(D_METHOD("get_mode"), &CSGPolygon3D::get_mode);
- ClassDB::bind_method(D_METHOD("set_depth", "depth"), &CSGPolygon::set_depth);
- ClassDB::bind_method(D_METHOD("get_depth"), &CSGPolygon::get_depth);
+ ClassDB::bind_method(D_METHOD("set_depth", "depth"), &CSGPolygon3D::set_depth);
+ ClassDB::bind_method(D_METHOD("get_depth"), &CSGPolygon3D::get_depth);
- ClassDB::bind_method(D_METHOD("set_spin_degrees", "degrees"), &CSGPolygon::set_spin_degrees);
- ClassDB::bind_method(D_METHOD("get_spin_degrees"), &CSGPolygon::get_spin_degrees);
+ ClassDB::bind_method(D_METHOD("set_spin_degrees", "degrees"), &CSGPolygon3D::set_spin_degrees);
+ ClassDB::bind_method(D_METHOD("get_spin_degrees"), &CSGPolygon3D::get_spin_degrees);
- ClassDB::bind_method(D_METHOD("set_spin_sides", "spin_sides"), &CSGPolygon::set_spin_sides);
- ClassDB::bind_method(D_METHOD("get_spin_sides"), &CSGPolygon::get_spin_sides);
+ ClassDB::bind_method(D_METHOD("set_spin_sides", "spin_sides"), &CSGPolygon3D::set_spin_sides);
+ ClassDB::bind_method(D_METHOD("get_spin_sides"), &CSGPolygon3D::get_spin_sides);
- ClassDB::bind_method(D_METHOD("set_path_node", "path"), &CSGPolygon::set_path_node);
- ClassDB::bind_method(D_METHOD("get_path_node"), &CSGPolygon::get_path_node);
+ ClassDB::bind_method(D_METHOD("set_path_node", "path"), &CSGPolygon3D::set_path_node);
+ ClassDB::bind_method(D_METHOD("get_path_node"), &CSGPolygon3D::get_path_node);
- ClassDB::bind_method(D_METHOD("set_path_interval", "distance"), &CSGPolygon::set_path_interval);
- ClassDB::bind_method(D_METHOD("get_path_interval"), &CSGPolygon::get_path_interval);
+ ClassDB::bind_method(D_METHOD("set_path_interval", "distance"), &CSGPolygon3D::set_path_interval);
+ ClassDB::bind_method(D_METHOD("get_path_interval"), &CSGPolygon3D::get_path_interval);
- ClassDB::bind_method(D_METHOD("set_path_rotation", "mode"), &CSGPolygon::set_path_rotation);
- ClassDB::bind_method(D_METHOD("get_path_rotation"), &CSGPolygon::get_path_rotation);
+ ClassDB::bind_method(D_METHOD("set_path_rotation", "mode"), &CSGPolygon3D::set_path_rotation);
+ ClassDB::bind_method(D_METHOD("get_path_rotation"), &CSGPolygon3D::get_path_rotation);
- ClassDB::bind_method(D_METHOD("set_path_local", "enable"), &CSGPolygon::set_path_local);
- ClassDB::bind_method(D_METHOD("is_path_local"), &CSGPolygon::is_path_local);
+ ClassDB::bind_method(D_METHOD("set_path_local", "enable"), &CSGPolygon3D::set_path_local);
+ ClassDB::bind_method(D_METHOD("is_path_local"), &CSGPolygon3D::is_path_local);
- ClassDB::bind_method(D_METHOD("set_path_continuous_u", "enable"), &CSGPolygon::set_path_continuous_u);
- ClassDB::bind_method(D_METHOD("is_path_continuous_u"), &CSGPolygon::is_path_continuous_u);
+ ClassDB::bind_method(D_METHOD("set_path_continuous_u", "enable"), &CSGPolygon3D::set_path_continuous_u);
+ ClassDB::bind_method(D_METHOD("is_path_continuous_u"), &CSGPolygon3D::is_path_continuous_u);
- ClassDB::bind_method(D_METHOD("set_path_joined", "enable"), &CSGPolygon::set_path_joined);
- ClassDB::bind_method(D_METHOD("is_path_joined"), &CSGPolygon::is_path_joined);
+ ClassDB::bind_method(D_METHOD("set_path_joined", "enable"), &CSGPolygon3D::set_path_joined);
+ ClassDB::bind_method(D_METHOD("is_path_joined"), &CSGPolygon3D::is_path_joined);
- ClassDB::bind_method(D_METHOD("set_material", "material"), &CSGPolygon::set_material);
- ClassDB::bind_method(D_METHOD("get_material"), &CSGPolygon::get_material);
+ ClassDB::bind_method(D_METHOD("set_material", "material"), &CSGPolygon3D::set_material);
+ ClassDB::bind_method(D_METHOD("get_material"), &CSGPolygon3D::get_material);
- ClassDB::bind_method(D_METHOD("set_smooth_faces", "smooth_faces"), &CSGPolygon::set_smooth_faces);
- ClassDB::bind_method(D_METHOD("get_smooth_faces"), &CSGPolygon::get_smooth_faces);
+ ClassDB::bind_method(D_METHOD("set_smooth_faces", "smooth_faces"), &CSGPolygon3D::set_smooth_faces);
+ ClassDB::bind_method(D_METHOD("get_smooth_faces"), &CSGPolygon3D::get_smooth_faces);
- ClassDB::bind_method(D_METHOD("_is_editable_3d_polygon"), &CSGPolygon::_is_editable_3d_polygon);
- ClassDB::bind_method(D_METHOD("_has_editable_3d_polygon_no_depth"), &CSGPolygon::_has_editable_3d_polygon_no_depth);
+ ClassDB::bind_method(D_METHOD("_is_editable_3d_polygon"), &CSGPolygon3D::_is_editable_3d_polygon);
+ ClassDB::bind_method(D_METHOD("_has_editable_3d_polygon_no_depth"), &CSGPolygon3D::_has_editable_3d_polygon_no_depth);
ADD_PROPERTY(PropertyInfo(Variant::PACKED_VECTOR2_ARRAY, "polygon"), "set_polygon", "get_polygon");
ADD_PROPERTY(PropertyInfo(Variant::INT, "mode", PROPERTY_HINT_ENUM, "Depth,Spin,Path"), "set_mode", "get_mode");
@@ -2330,148 +2324,148 @@ void CSGPolygon::_bind_methods() {
BIND_ENUM_CONSTANT(PATH_ROTATION_PATH_FOLLOW);
}
-void CSGPolygon::set_polygon(const Vector<Vector2> &p_polygon) {
+void CSGPolygon3D::set_polygon(const Vector<Vector2> &p_polygon) {
polygon = p_polygon;
_make_dirty();
update_gizmo();
}
-Vector<Vector2> CSGPolygon::get_polygon() const {
+Vector<Vector2> CSGPolygon3D::get_polygon() const {
return polygon;
}
-void CSGPolygon::set_mode(Mode p_mode) {
+void CSGPolygon3D::set_mode(Mode p_mode) {
mode = p_mode;
_make_dirty();
update_gizmo();
_change_notify();
}
-CSGPolygon::Mode CSGPolygon::get_mode() const {
+CSGPolygon3D::Mode CSGPolygon3D::get_mode() const {
return mode;
}
-void CSGPolygon::set_depth(const float p_depth) {
+void CSGPolygon3D::set_depth(const float p_depth) {
ERR_FAIL_COND(p_depth < 0.001);
depth = p_depth;
_make_dirty();
update_gizmo();
}
-float CSGPolygon::get_depth() const {
+float CSGPolygon3D::get_depth() const {
return depth;
}
-void CSGPolygon::set_path_continuous_u(bool p_enable) {
+void CSGPolygon3D::set_path_continuous_u(bool p_enable) {
path_continuous_u = p_enable;
_make_dirty();
}
-bool CSGPolygon::is_path_continuous_u() const {
+bool CSGPolygon3D::is_path_continuous_u() const {
return path_continuous_u;
}
-void CSGPolygon::set_spin_degrees(const float p_spin_degrees) {
+void CSGPolygon3D::set_spin_degrees(const float p_spin_degrees) {
ERR_FAIL_COND(p_spin_degrees < 0.01 || p_spin_degrees > 360);
spin_degrees = p_spin_degrees;
_make_dirty();
update_gizmo();
}
-float CSGPolygon::get_spin_degrees() const {
+float CSGPolygon3D::get_spin_degrees() const {
return spin_degrees;
}
-void CSGPolygon::set_spin_sides(const int p_spin_sides) {
+void CSGPolygon3D::set_spin_sides(const int p_spin_sides) {
ERR_FAIL_COND(p_spin_sides < 3);
spin_sides = p_spin_sides;
_make_dirty();
update_gizmo();
}
-int CSGPolygon::get_spin_sides() const {
+int CSGPolygon3D::get_spin_sides() const {
return spin_sides;
}
-void CSGPolygon::set_path_node(const NodePath &p_path) {
+void CSGPolygon3D::set_path_node(const NodePath &p_path) {
path_node = p_path;
_make_dirty();
update_gizmo();
}
-NodePath CSGPolygon::get_path_node() const {
+NodePath CSGPolygon3D::get_path_node() const {
return path_node;
}
-void CSGPolygon::set_path_interval(float p_interval) {
+void CSGPolygon3D::set_path_interval(float p_interval) {
ERR_FAIL_COND_MSG(p_interval < 0.001, "Path interval cannot be smaller than 0.001.");
path_interval = p_interval;
_make_dirty();
update_gizmo();
}
-float CSGPolygon::get_path_interval() const {
+float CSGPolygon3D::get_path_interval() const {
return path_interval;
}
-void CSGPolygon::set_path_rotation(PathRotation p_rotation) {
+void CSGPolygon3D::set_path_rotation(PathRotation p_rotation) {
path_rotation = p_rotation;
_make_dirty();
update_gizmo();
}
-CSGPolygon::PathRotation CSGPolygon::get_path_rotation() const {
+CSGPolygon3D::PathRotation CSGPolygon3D::get_path_rotation() const {
return path_rotation;
}
-void CSGPolygon::set_path_local(bool p_enable) {
+void CSGPolygon3D::set_path_local(bool p_enable) {
path_local = p_enable;
_make_dirty();
update_gizmo();
}
-bool CSGPolygon::is_path_local() const {
+bool CSGPolygon3D::is_path_local() const {
return path_local;
}
-void CSGPolygon::set_path_joined(bool p_enable) {
+void CSGPolygon3D::set_path_joined(bool p_enable) {
path_joined = p_enable;
_make_dirty();
update_gizmo();
}
-bool CSGPolygon::is_path_joined() const {
+bool CSGPolygon3D::is_path_joined() const {
return path_joined;
}
-void CSGPolygon::set_smooth_faces(const bool p_smooth_faces) {
+void CSGPolygon3D::set_smooth_faces(const bool p_smooth_faces) {
smooth_faces = p_smooth_faces;
_make_dirty();
}
-bool CSGPolygon::get_smooth_faces() const {
+bool CSGPolygon3D::get_smooth_faces() const {
return smooth_faces;
}
-void CSGPolygon::set_material(const Ref<Material> &p_material) {
+void CSGPolygon3D::set_material(const Ref<Material> &p_material) {
material = p_material;
_make_dirty();
}
-Ref<Material> CSGPolygon::get_material() const {
+Ref<Material> CSGPolygon3D::get_material() const {
return material;
}
-bool CSGPolygon::_is_editable_3d_polygon() const {
+bool CSGPolygon3D::_is_editable_3d_polygon() const {
return true;
}
-bool CSGPolygon::_has_editable_3d_polygon_no_depth() const {
+bool CSGPolygon3D::_has_editable_3d_polygon_no_depth() const {
return true;
}
-CSGPolygon::CSGPolygon() {
+CSGPolygon3D::CSGPolygon3D() {
// defaults
mode = MODE_DEPTH;
polygon.push_back(Vector2(0, 0));
@@ -2487,5 +2481,5 @@ CSGPolygon::CSGPolygon() {
path_local = false;
path_continuous_u = false;
path_joined = false;
- path_cache = NULL;
+ path_cache = nullptr;
}
diff --git a/modules/csg/csg_shape.h b/modules/csg/csg_shape.h
index fdbf979fe7..abab1ded20 100644
--- a/modules/csg/csg_shape.h
+++ b/modules/csg/csg_shape.h
@@ -34,12 +34,12 @@
#define CSGJS_HEADER_ONLY
#include "csg.h"
-#include "scene/3d/visual_instance.h"
-#include "scene/resources/concave_polygon_shape.h"
+#include "scene/3d/visual_instance_3d.h"
+#include "scene/resources/concave_polygon_shape_3d.h"
#include "thirdparty/misc/mikktspace.h"
-class CSGShape : public GeometryInstance {
- GDCLASS(CSGShape, GeometryInstance);
+class CSGShape3D : public GeometryInstance3D {
+ GDCLASS(CSGShape3D, GeometryInstance3D);
public:
enum Operation {
@@ -51,7 +51,7 @@ public:
private:
Operation operation;
- CSGShape *parent;
+ CSGShape3D *parent;
CSGBrush *brush;
@@ -63,7 +63,7 @@ private:
bool use_collision;
uint32_t collision_layer;
uint32_t collision_mask;
- Ref<ConcavePolygonShape> root_collision_shape;
+ Ref<ConcavePolygonShape3D> root_collision_shape;
RID root_collision_instance;
bool calculate_tangents;
@@ -111,7 +111,7 @@ protected:
static void _bind_methods();
- friend class CSGCombiner;
+ friend class CSGCombiner3D;
CSGBrush *_get_brush();
virtual void _validate_property(PropertyInfo &property) const;
@@ -149,24 +149,24 @@ public:
bool is_calculating_tangents() const;
bool is_root_shape() const;
- CSGShape();
- ~CSGShape();
+ CSGShape3D();
+ ~CSGShape3D();
};
-VARIANT_ENUM_CAST(CSGShape::Operation)
+VARIANT_ENUM_CAST(CSGShape3D::Operation)
-class CSGCombiner : public CSGShape {
- GDCLASS(CSGCombiner, CSGShape);
+class CSGCombiner3D : public CSGShape3D {
+ GDCLASS(CSGCombiner3D, CSGShape3D);
private:
virtual CSGBrush *_build_brush();
public:
- CSGCombiner();
+ CSGCombiner3D();
};
-class CSGPrimitive : public CSGShape {
- GDCLASS(CSGPrimitive, CSGShape);
+class CSGPrimitive3D : public CSGShape3D {
+ GDCLASS(CSGPrimitive3D, CSGShape3D);
private:
bool invert_faces;
@@ -179,11 +179,11 @@ public:
void set_invert_faces(bool p_invert);
bool is_inverting_faces();
- CSGPrimitive();
+ CSGPrimitive3D();
};
-class CSGMesh : public CSGPrimitive {
- GDCLASS(CSGMesh, CSGPrimitive);
+class CSGMesh3D : public CSGPrimitive3D {
+ GDCLASS(CSGMesh3D, CSGPrimitive3D);
virtual CSGBrush *_build_brush();
@@ -203,9 +203,9 @@ public:
Ref<Material> get_material() const;
};
-class CSGSphere : public CSGPrimitive {
+class CSGSphere3D : public CSGPrimitive3D {
- GDCLASS(CSGSphere, CSGPrimitive);
+ GDCLASS(CSGSphere3D, CSGPrimitive3D);
virtual CSGBrush *_build_brush();
Ref<Material> material;
@@ -233,12 +233,12 @@ public:
void set_smooth_faces(bool p_smooth_faces);
bool get_smooth_faces() const;
- CSGSphere();
+ CSGSphere3D();
};
-class CSGBox : public CSGPrimitive {
+class CSGBox3D : public CSGPrimitive3D {
- GDCLASS(CSGBox, CSGPrimitive);
+ GDCLASS(CSGBox3D, CSGPrimitive3D);
virtual CSGBrush *_build_brush();
Ref<Material> material;
@@ -262,12 +262,12 @@ public:
void set_material(const Ref<Material> &p_material);
Ref<Material> get_material() const;
- CSGBox();
+ CSGBox3D();
};
-class CSGCylinder : public CSGPrimitive {
+class CSGCylinder3D : public CSGPrimitive3D {
- GDCLASS(CSGCylinder, CSGPrimitive);
+ GDCLASS(CSGCylinder3D, CSGPrimitive3D);
virtual CSGBrush *_build_brush();
Ref<Material> material;
@@ -299,12 +299,12 @@ public:
void set_material(const Ref<Material> &p_material);
Ref<Material> get_material() const;
- CSGCylinder();
+ CSGCylinder3D();
};
-class CSGTorus : public CSGPrimitive {
+class CSGTorus3D : public CSGPrimitive3D {
- GDCLASS(CSGTorus, CSGPrimitive);
+ GDCLASS(CSGTorus3D, CSGPrimitive3D);
virtual CSGBrush *_build_brush();
Ref<Material> material;
@@ -336,12 +336,12 @@ public:
void set_material(const Ref<Material> &p_material);
Ref<Material> get_material() const;
- CSGTorus();
+ CSGTorus3D();
};
-class CSGPolygon : public CSGPrimitive {
+class CSGPolygon3D : public CSGPrimitive3D {
- GDCLASS(CSGPolygon, CSGPrimitive);
+ GDCLASS(CSGPolygon3D, CSGPrimitive3D);
public:
enum Mode {
@@ -431,10 +431,10 @@ public:
void set_material(const Ref<Material> &p_material);
Ref<Material> get_material() const;
- CSGPolygon();
+ CSGPolygon3D();
};
-VARIANT_ENUM_CAST(CSGPolygon::Mode)
-VARIANT_ENUM_CAST(CSGPolygon::PathRotation)
+VARIANT_ENUM_CAST(CSGPolygon3D::Mode)
+VARIANT_ENUM_CAST(CSGPolygon3D::PathRotation)
#endif // CSG_SHAPE_H
diff --git a/modules/csg/doc_classes/CSGBox.xml b/modules/csg/doc_classes/CSGBox3D.xml
index e2f0f8488a..492bf68c44 100644
--- a/modules/csg/doc_classes/CSGBox.xml
+++ b/modules/csg/doc_classes/CSGBox3D.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="CSGBox" inherits="CSGPrimitive" version="4.0">
+<class name="CSGBox3D" inherits="CSGPrimitive3D" version="4.0">
<brief_description>
A CSG Box shape.
</brief_description>
diff --git a/modules/csg/doc_classes/CSGCombiner.xml b/modules/csg/doc_classes/CSGCombiner.xml
deleted file mode 100644
index ab95d3c3ee..0000000000
--- a/modules/csg/doc_classes/CSGCombiner.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<class name="CSGCombiner" inherits="CSGShape" version="4.0">
- <brief_description>
- A CSG node that allows you to combine other CSG modifiers.
- </brief_description>
- <description>
- For complex arrangements of shapes, it is sometimes needed to add structure to your CSG nodes. The CSGCombiner node allows you to create this structure. The node encapsulates the result of the CSG operations of its children. In this way, it is possible to do operations on one set of shapes that are children of one CSGCombiner node, and a set of separate operations on a second set of shapes that are children of a second CSGCombiner node, and then do an operation that takes the two end results as its input to create the final shape.
- </description>
- <tutorials>
- </tutorials>
- <methods>
- </methods>
- <constants>
- </constants>
-</class>
diff --git a/modules/csg/doc_classes/CSGCombiner3D.xml b/modules/csg/doc_classes/CSGCombiner3D.xml
new file mode 100644
index 0000000000..b55111eee4
--- /dev/null
+++ b/modules/csg/doc_classes/CSGCombiner3D.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<class name="CSGCombiner3D" inherits="CSGShape3D" version="4.0">
+ <brief_description>
+ A CSG node that allows you to combine other CSG modifiers.
+ </brief_description>
+ <description>
+ For complex arrangements of shapes, it is sometimes needed to add structure to your CSG nodes. The CSGCombiner3D node allows you to create this structure. The node encapsulates the result of the CSG operations of its children. In this way, it is possible to do operations on one set of shapes that are children of one CSGCombiner3D node, and a set of separate operations on a second set of shapes that are children of a second CSGCombiner3D node, and then do an operation that takes the two end results as its input to create the final shape.
+ </description>
+ <tutorials>
+ </tutorials>
+ <methods>
+ </methods>
+ <constants>
+ </constants>
+</class>
diff --git a/modules/csg/doc_classes/CSGCylinder.xml b/modules/csg/doc_classes/CSGCylinder3D.xml
index 2dd8c6a8d0..bfd2a5d5f2 100644
--- a/modules/csg/doc_classes/CSGCylinder.xml
+++ b/modules/csg/doc_classes/CSGCylinder3D.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="CSGCylinder" inherits="CSGPrimitive" version="4.0">
+<class name="CSGCylinder3D" inherits="CSGPrimitive3D" version="4.0">
<brief_description>
A CSG Cylinder shape.
</brief_description>
diff --git a/modules/csg/doc_classes/CSGMesh.xml b/modules/csg/doc_classes/CSGMesh3D.xml
index f1fe2c286b..1bab8f4ee9 100644
--- a/modules/csg/doc_classes/CSGMesh.xml
+++ b/modules/csg/doc_classes/CSGMesh3D.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="CSGMesh" inherits="CSGPrimitive" version="4.0">
+<class name="CSGMesh3D" inherits="CSGPrimitive3D" version="4.0">
<brief_description>
A CSG Mesh shape that uses a mesh resource.
</brief_description>
diff --git a/modules/csg/doc_classes/CSGPolygon.xml b/modules/csg/doc_classes/CSGPolygon3D.xml
index 02b2e8b03f..c55fa0983e 100644
--- a/modules/csg/doc_classes/CSGPolygon.xml
+++ b/modules/csg/doc_classes/CSGPolygon3D.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="CSGPolygon" inherits="CSGPrimitive" version="4.0">
+<class name="CSGPolygon3D" inherits="CSGPrimitive3D" version="4.0">
<brief_description>
Extrudes a 2D polygon shape to create a 3D mesh.
</brief_description>
@@ -17,7 +17,7 @@
<member name="material" type="Material" setter="set_material" getter="get_material">
Material to use for the resulting mesh.
</member>
- <member name="mode" type="int" setter="set_mode" getter="get_mode" enum="CSGPolygon.Mode" default="0">
+ <member name="mode" type="int" setter="set_mode" getter="get_mode" enum="CSGPolygon3D.Mode" default="0">
Extrusion mode.
</member>
<member name="path_continuous_u" type="bool" setter="set_path_continuous_u" getter="is_path_continuous_u">
@@ -30,12 +30,12 @@
If [code]true[/code] the start and end of our path are joined together ensuring there is no seam when [member mode] is [constant MODE_PATH].
</member>
<member name="path_local" type="bool" setter="set_path_local" getter="is_path_local">
- If [code]false[/code] we extrude centered on our path, if [code]true[/code] we extrude in relation to the position of our CSGPolygon when [member mode] is [constant MODE_PATH].
+ If [code]false[/code] we extrude centered on our path, if [code]true[/code] we extrude in relation to the position of our CSGPolygon3D when [member mode] is [constant MODE_PATH].
</member>
<member name="path_node" type="NodePath" setter="set_path_node" getter="get_path_node">
- The [Shape] object containing the path along which we extrude when [member mode] is [constant MODE_PATH].
+ The [Shape3D] object containing the path along which we extrude when [member mode] is [constant MODE_PATH].
</member>
- <member name="path_rotation" type="int" setter="set_path_rotation" getter="get_path_rotation" enum="CSGPolygon.PathRotation">
+ <member name="path_rotation" type="int" setter="set_path_rotation" getter="get_path_rotation" enum="CSGPolygon3D.PathRotation">
The method by which each slice is rotated along the path when [member mode] is [constant MODE_PATH].
</member>
<member name="polygon" type="PackedVector2Array" setter="set_polygon" getter="get_polygon" default="PackedVector2Array( 0, 0, 0, 1, 1, 1, 1, 0 )">
@@ -53,13 +53,13 @@
</members>
<constants>
<constant name="MODE_DEPTH" value="0" enum="Mode">
- Shape is extruded to [member depth].
+ Shape3D is extruded to [member depth].
</constant>
<constant name="MODE_SPIN" value="1" enum="Mode">
- Shape is extruded by rotating it around an axis.
+ Shape3D is extruded by rotating it around an axis.
</constant>
<constant name="MODE_PATH" value="2" enum="Mode">
- Shape is extruded along a path set by a [Shape] set in [member path_node].
+ Shape3D is extruded along a path set by a [Shape3D] set in [member path_node].
</constant>
<constant name="PATH_ROTATION_POLYGON" value="0" enum="PathRotation">
Slice is not rotated.
diff --git a/modules/csg/doc_classes/CSGPrimitive.xml b/modules/csg/doc_classes/CSGPrimitive3D.xml
index ba395b7edd..31b7360fac 100644
--- a/modules/csg/doc_classes/CSGPrimitive.xml
+++ b/modules/csg/doc_classes/CSGPrimitive3D.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="CSGPrimitive" inherits="CSGShape" version="4.0">
+<class name="CSGPrimitive3D" inherits="CSGShape3D" version="4.0">
<brief_description>
Base class for CSG primitives.
</brief_description>
diff --git a/modules/csg/doc_classes/CSGShape.xml b/modules/csg/doc_classes/CSGShape3D.xml
index 64a2fb1840..43ce988c30 100644
--- a/modules/csg/doc_classes/CSGShape.xml
+++ b/modules/csg/doc_classes/CSGShape3D.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="CSGShape" inherits="GeometryInstance" version="4.0">
+<class name="CSGShape3D" inherits="GeometryInstance3D" version="4.0">
<brief_description>
The CSG base class.
</brief_description>
@@ -76,7 +76,7 @@
<member name="collision_mask" type="int" setter="set_collision_mask" getter="get_collision_mask" default="1">
The physics layers this CSG shape scans for collisions.
</member>
- <member name="operation" type="int" setter="set_operation" getter="get_operation" enum="CSGShape.Operation" default="0">
+ <member name="operation" type="int" setter="set_operation" getter="get_operation" enum="CSGShape3D.Operation" default="0">
The operation that is performed on this shape. This is ignored for the first CSG child node as the operation is between this node and the previous child of this nodes parent.
</member>
<member name="snap" type="float" setter="set_snap" getter="get_snap" default="0.001">
diff --git a/modules/csg/doc_classes/CSGSphere.xml b/modules/csg/doc_classes/CSGSphere3D.xml
index 847cc63586..4d5b3be099 100644
--- a/modules/csg/doc_classes/CSGSphere.xml
+++ b/modules/csg/doc_classes/CSGSphere3D.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="CSGSphere" inherits="CSGPrimitive" version="4.0">
+<class name="CSGSphere3D" inherits="CSGPrimitive3D" version="4.0">
<brief_description>
A CSG Sphere shape.
</brief_description>
diff --git a/modules/csg/doc_classes/CSGTorus.xml b/modules/csg/doc_classes/CSGTorus3D.xml
index 84a08edaf5..abe3eab913 100644
--- a/modules/csg/doc_classes/CSGTorus.xml
+++ b/modules/csg/doc_classes/CSGTorus3D.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="CSGTorus" inherits="CSGPrimitive" version="4.0">
+<class name="CSGTorus3D" inherits="CSGPrimitive3D" version="4.0">
<brief_description>
A CSG Torus shape.
</brief_description>
diff --git a/modules/csg/icons/CSGBox.svg b/modules/csg/icons/CSGBox3D.svg
index 67e34df444..67e34df444 100644
--- a/modules/csg/icons/CSGBox.svg
+++ b/modules/csg/icons/CSGBox3D.svg
diff --git a/modules/csg/icons/CSGCapsule.svg b/modules/csg/icons/CSGCapsule3D.svg
index 92a7b5a870..92a7b5a870 100644
--- a/modules/csg/icons/CSGCapsule.svg
+++ b/modules/csg/icons/CSGCapsule3D.svg
diff --git a/modules/csg/icons/CSGCombiner.svg b/modules/csg/icons/CSGCombiner3D.svg
index cce2902e24..cce2902e24 100644
--- a/modules/csg/icons/CSGCombiner.svg
+++ b/modules/csg/icons/CSGCombiner3D.svg
diff --git a/modules/csg/icons/CSGCylinder.svg b/modules/csg/icons/CSGCylinder3D.svg
index 645a74c79b..645a74c79b 100644
--- a/modules/csg/icons/CSGCylinder.svg
+++ b/modules/csg/icons/CSGCylinder3D.svg
diff --git a/modules/csg/icons/CSGMesh.svg b/modules/csg/icons/CSGMesh3D.svg
index 6e940a4aa5..6e940a4aa5 100644
--- a/modules/csg/icons/CSGMesh.svg
+++ b/modules/csg/icons/CSGMesh3D.svg
diff --git a/modules/csg/icons/CSGPolygon.svg b/modules/csg/icons/CSGPolygon3D.svg
index 71b03cb8e6..71b03cb8e6 100644
--- a/modules/csg/icons/CSGPolygon.svg
+++ b/modules/csg/icons/CSGPolygon3D.svg
diff --git a/modules/csg/icons/CSGSphere.svg b/modules/csg/icons/CSGSphere3D.svg
index f81b566993..f81b566993 100644
--- a/modules/csg/icons/CSGSphere.svg
+++ b/modules/csg/icons/CSGSphere3D.svg
diff --git a/modules/csg/icons/CSGTorus.svg b/modules/csg/icons/CSGTorus3D.svg
index 3d30aa47b2..3d30aa47b2 100644
--- a/modules/csg/icons/CSGTorus.svg
+++ b/modules/csg/icons/CSGTorus3D.svg
diff --git a/modules/csg/register_types.cpp b/modules/csg/register_types.cpp
index 677a20df38..40eef84b1b 100644
--- a/modules/csg/register_types.cpp
+++ b/modules/csg/register_types.cpp
@@ -37,15 +37,15 @@ void register_csg_types() {
#ifndef _3D_DISABLED
- ClassDB::register_virtual_class<CSGShape>();
- ClassDB::register_virtual_class<CSGPrimitive>();
- ClassDB::register_class<CSGMesh>();
- ClassDB::register_class<CSGSphere>();
- ClassDB::register_class<CSGBox>();
- ClassDB::register_class<CSGCylinder>();
- ClassDB::register_class<CSGTorus>();
- ClassDB::register_class<CSGPolygon>();
- ClassDB::register_class<CSGCombiner>();
+ ClassDB::register_virtual_class<CSGShape3D>();
+ ClassDB::register_virtual_class<CSGPrimitive3D>();
+ ClassDB::register_class<CSGMesh3D>();
+ ClassDB::register_class<CSGSphere3D>();
+ ClassDB::register_class<CSGBox3D>();
+ ClassDB::register_class<CSGCylinder3D>();
+ ClassDB::register_class<CSGTorus3D>();
+ ClassDB::register_class<CSGPolygon3D>();
+ ClassDB::register_class<CSGCombiner3D>();
#ifdef TOOLS_ENABLED
EditorPlugins::add_by_type<EditorPluginCSG>();
diff --git a/modules/cvtt/SCsub b/modules/cvtt/SCsub
index 746b23ca28..5438f7ebac 100644
--- a/modules/cvtt/SCsub
+++ b/modules/cvtt/SCsub
@@ -1,14 +1,14 @@
#!/usr/bin/env python
-Import('env')
-Import('env_modules')
+Import("env")
+Import("env_modules")
env_cvtt = env_modules.Clone()
# Thirdparty source files
thirdparty_dir = "#thirdparty/cvtt/"
thirdparty_sources = [
- "ConvectionKernels.cpp"
+ "ConvectionKernels.cpp",
]
thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
diff --git a/modules/cvtt/config.py b/modules/cvtt/config.py
index 098f1eafa9..53b8f2f2e3 100644
--- a/modules/cvtt/config.py
+++ b/modules/cvtt/config.py
@@ -1,5 +1,6 @@
def can_build(env, platform):
- return env['tools']
+ return env["tools"]
+
def configure(env):
pass
diff --git a/modules/dds/SCsub b/modules/dds/SCsub
index 3d92ff02d6..06980bd670 100644
--- a/modules/dds/SCsub
+++ b/modules/dds/SCsub
@@ -1,7 +1,7 @@
#!/usr/bin/env python
-Import('env')
-Import('env_modules')
+Import("env")
+Import("env_modules")
env_dds = env_modules.Clone()
diff --git a/modules/dds/config.py b/modules/dds/config.py
index 1c8cd12a2d..d22f9454ed 100644
--- a/modules/dds/config.py
+++ b/modules/dds/config.py
@@ -1,5 +1,6 @@
def can_build(env, platform):
return True
+
def configure(env):
pass
diff --git a/modules/dds/texture_loader_dds.cpp b/modules/dds/texture_loader_dds.cpp
index ae21156b8b..294d594135 100644
--- a/modules/dds/texture_loader_dds.cpp
+++ b/modules/dds/texture_loader_dds.cpp
@@ -94,7 +94,7 @@ static const DDSFormatInfo dds_format_info[DDS_MAX] = {
{ "GRAYSCALE_ALPHA", false, false, 1, 2, Image::FORMAT_LA8 }
};
-RES ResourceFormatDDS::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress) {
+RES ResourceFormatDDS::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, bool p_no_cache) {
if (r_error)
*r_error = ERR_CANT_OPEN;
diff --git a/modules/dds/texture_loader_dds.h b/modules/dds/texture_loader_dds.h
index de8088af90..ef08967df7 100644
--- a/modules/dds/texture_loader_dds.h
+++ b/modules/dds/texture_loader_dds.h
@@ -36,7 +36,7 @@
class ResourceFormatDDS : public ResourceFormatLoader {
public:
- virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL, bool p_use_sub_threads = false, float *r_progress = nullptr);
+ virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr, bool p_no_cache = false);
virtual void get_recognized_extensions(List<String> *p_extensions) const;
virtual bool handles_type(const String &p_type) const;
virtual String get_resource_type(const String &p_path) const;
diff --git a/modules/enet/SCsub b/modules/enet/SCsub
index 485c33b1a8..c8f4b3885e 100644
--- a/modules/enet/SCsub
+++ b/modules/enet/SCsub
@@ -1,13 +1,13 @@
#!/usr/bin/env python
-Import('env')
-Import('env_modules')
+Import("env")
+Import("env_modules")
env_enet = env_modules.Clone()
# Thirdparty source files
-if env['builtin_enet']:
+if env["builtin_enet"]:
thirdparty_dir = "#thirdparty/enet/"
thirdparty_sources = [
"godot.cpp",
diff --git a/modules/enet/config.py b/modules/enet/config.py
index 3e30bbe778..5fd343c75d 100644
--- a/modules/enet/config.py
+++ b/modules/enet/config.py
@@ -1,13 +1,16 @@
def can_build(env, platform):
return True
+
def configure(env):
pass
+
def get_doc_classes():
return [
"NetworkedMultiplayerENet",
]
+
def get_doc_path():
return "doc_classes"
diff --git a/modules/enet/networked_multiplayer_enet.cpp b/modules/enet/networked_multiplayer_enet.cpp
index 406eb467f0..444ffae713 100644
--- a/modules/enet/networked_multiplayer_enet.cpp
+++ b/modules/enet/networked_multiplayer_enet.cpp
@@ -154,7 +154,7 @@ Error NetworkedMultiplayerENet::create_client(const String &p_address, int p_por
p_in_bandwidth /* limit incoming bandwidth if > 0 */,
p_out_bandwidth /* limit outgoing bandwidth if > 0 */);
} else {
- host = enet_host_create(NULL /* create a client host */,
+ host = enet_host_create(nullptr /* create a client host */,
1 /* only allow 1 outgoing connection */,
channel_count /* allow up to channel_count to be used */,
p_in_bandwidth /* limit incoming bandwidth if > 0 */,
@@ -197,7 +197,7 @@ Error NetworkedMultiplayerENet::create_client(const String &p_address, int p_por
// Initiate connection, allocating enough channels
ENetPeer *peer = enet_host_connect(host, &address, channel_count, unique_id);
- if (peer == NULL) {
+ if (peer == nullptr) {
enet_host_destroy(host);
ERR_FAIL_COND_V_MSG(!peer, ERR_CANT_CREATE, "Couldn't connect to the ENet multiplayer server.");
}
@@ -276,12 +276,12 @@ void NetworkedMultiplayerENet::poll() {
if (E->key() == *new_id)
continue;
// Send existing peers to new peer
- ENetPacket *packet = enet_packet_create(NULL, 8, ENET_PACKET_FLAG_RELIABLE);
+ ENetPacket *packet = enet_packet_create(nullptr, 8, ENET_PACKET_FLAG_RELIABLE);
encode_uint32(SYSMSG_ADD_PEER, &packet->data[0]);
encode_uint32(E->key(), &packet->data[4]);
enet_peer_send(event.peer, SYSCH_CONFIG, packet);
// Send the new peer to existing peers
- packet = enet_packet_create(NULL, 8, ENET_PACKET_FLAG_RELIABLE);
+ packet = enet_packet_create(nullptr, 8, ENET_PACKET_FLAG_RELIABLE);
encode_uint32(SYSMSG_ADD_PEER, &packet->data[0]);
encode_uint32(*new_id, &packet->data[4]);
enet_peer_send(E->get(), SYSCH_CONFIG, packet);
@@ -320,7 +320,7 @@ void NetworkedMultiplayerENet::poll() {
if (E->key() == *id)
continue;
- ENetPacket *packet = enet_packet_create(NULL, 8, ENET_PACKET_FLAG_RELIABLE);
+ ENetPacket *packet = enet_packet_create(nullptr, 8, ENET_PACKET_FLAG_RELIABLE);
encode_uint32(SYSMSG_REMOVE_PEER, &packet->data[0]);
encode_uint32(*id, &packet->data[4]);
enet_peer_send(E->get(), SYSCH_CONFIG, packet);
@@ -346,7 +346,7 @@ void NetworkedMultiplayerENet::poll() {
switch (msg) {
case SYSMSG_ADD_PEER: {
- peer_map[id] = NULL;
+ peer_map[id] = nullptr;
emit_signal("peer_connected", id);
} break;
@@ -502,7 +502,7 @@ void NetworkedMultiplayerENet::disconnect_peer(int p_peer, bool now) {
continue;
}
- ENetPacket *packet = enet_packet_create(NULL, 8, ENET_PACKET_FLAG_RELIABLE);
+ ENetPacket *packet = enet_packet_create(nullptr, 8, ENET_PACKET_FLAG_RELIABLE);
encode_uint32(SYSMSG_REMOVE_PEER, &packet->data[0]);
encode_uint32(p_peer, &packet->data[4]);
enet_peer_send(E->get(), SYSCH_CONFIG, packet);
@@ -568,7 +568,7 @@ Error NetworkedMultiplayerENet::put_packet(const uint8_t *p_buffer, int p_buffer
if (transfer_channel > SYSCH_CONFIG)
channel = transfer_channel;
- Map<int, ENetPeer *>::Element *E = NULL;
+ Map<int, ENetPeer *>::Element *E = nullptr;
if (target_peer != 0) {
@@ -576,7 +576,7 @@ Error NetworkedMultiplayerENet::put_packet(const uint8_t *p_buffer, int p_buffer
ERR_FAIL_COND_V_MSG(!E, ERR_INVALID_PARAMETER, vformat("Invalid target peer: %d", target_peer));
}
- ENetPacket *packet = enet_packet_create(NULL, p_buffer_size + 8, packet_flags);
+ ENetPacket *packet = enet_packet_create(nullptr, p_buffer_size + 8, packet_flags);
encode_uint32(unique_id, &packet->data[0]); // Source ID
encode_uint32(target_peer, &packet->data[4]); // Dest ID
copymem(&packet->data[8], p_buffer, p_buffer_size);
@@ -625,7 +625,7 @@ void NetworkedMultiplayerENet::_pop_current_packet() {
if (current_packet.packet) {
enet_packet_destroy(current_packet.packet);
- current_packet.packet = NULL;
+ current_packet.packet = nullptr;
current_packet.from = 0;
current_packet.channel = -1;
}
@@ -771,7 +771,7 @@ void NetworkedMultiplayerENet::_setup_compressor() {
case COMPRESS_NONE: {
- enet_host_compress(host, NULL);
+ enet_host_compress(host, nullptr);
} break;
case COMPRESS_RANGE_CODER: {
enet_host_compress_with_range_coder(host);
@@ -794,7 +794,7 @@ IP_Address NetworkedMultiplayerENet::get_peer_address(int p_peer_id) const {
ERR_FAIL_COND_V_MSG(!peer_map.has(p_peer_id), IP_Address(), vformat("Peer ID %d not found in the list of peers.", p_peer_id));
ERR_FAIL_COND_V_MSG(!is_server() && p_peer_id != 1, IP_Address(), "Can't get the address of peers other than the server (ID -1) when acting as a client.");
- ERR_FAIL_COND_V_MSG(peer_map[p_peer_id] == NULL, IP_Address(), vformat("Peer ID %d found in the list of peers, but is null.", p_peer_id));
+ ERR_FAIL_COND_V_MSG(peer_map[p_peer_id] == nullptr, IP_Address(), vformat("Peer ID %d found in the list of peers, but is null.", p_peer_id));
IP_Address out;
#ifdef GODOT_ENET
@@ -810,7 +810,7 @@ int NetworkedMultiplayerENet::get_peer_port(int p_peer_id) const {
ERR_FAIL_COND_V_MSG(!peer_map.has(p_peer_id), 0, vformat("Peer ID %d not found in the list of peers.", p_peer_id));
ERR_FAIL_COND_V_MSG(!is_server() && p_peer_id != 1, 0, "Can't get the address of peers other than the server (ID -1) when acting as a client.");
- ERR_FAIL_COND_V_MSG(peer_map[p_peer_id] == NULL, 0, vformat("Peer ID %d found in the list of peers, but is null.", p_peer_id));
+ ERR_FAIL_COND_V_MSG(peer_map[p_peer_id] == nullptr, 0, vformat("Peer ID %d found in the list of peers, but is null.", p_peer_id));
#ifdef GODOT_ENET
return peer_map[p_peer_id]->address.port;
#else
@@ -910,7 +910,7 @@ NetworkedMultiplayerENet::NetworkedMultiplayerENet() {
server_relay = true;
unique_id = 0;
target_peer = 0;
- current_packet.packet = NULL;
+ current_packet.packet = nullptr;
transfer_mode = TRANSFER_MODE_RELIABLE;
channel_count = SYSCH_MAX;
transfer_channel = -1;
diff --git a/modules/etc/SCsub b/modules/etc/SCsub
index 1742d3534f..383bbf83c3 100644
--- a/modules/etc/SCsub
+++ b/modules/etc/SCsub
@@ -1,7 +1,7 @@
#!/usr/bin/env python
-Import('env')
-Import('env_modules')
+Import("env")
+Import("env_modules")
env_etc = env_modules.Clone()
@@ -9,21 +9,21 @@ env_etc = env_modules.Clone()
# Not unbundled so far since not widespread as shared library
thirdparty_dir = "#thirdparty/etc2comp/"
thirdparty_sources = [
- "EtcBlock4x4.cpp",
- "EtcBlock4x4Encoding.cpp",
- "EtcBlock4x4Encoding_ETC1.cpp",
- "EtcBlock4x4Encoding_R11.cpp",
- "EtcBlock4x4Encoding_RG11.cpp",
- "EtcBlock4x4Encoding_RGB8A1.cpp",
- "EtcBlock4x4Encoding_RGB8.cpp",
- "EtcBlock4x4Encoding_RGBA8.cpp",
- "Etc.cpp",
- "EtcDifferentialTrys.cpp",
- "EtcFilter.cpp",
- "EtcImage.cpp",
- "EtcIndividualTrys.cpp",
- "EtcMath.cpp",
- "EtcSortedBlockList.cpp",
+ "EtcBlock4x4.cpp",
+ "EtcBlock4x4Encoding.cpp",
+ "EtcBlock4x4Encoding_ETC1.cpp",
+ "EtcBlock4x4Encoding_R11.cpp",
+ "EtcBlock4x4Encoding_RG11.cpp",
+ "EtcBlock4x4Encoding_RGB8A1.cpp",
+ "EtcBlock4x4Encoding_RGB8.cpp",
+ "EtcBlock4x4Encoding_RGBA8.cpp",
+ "Etc.cpp",
+ "EtcDifferentialTrys.cpp",
+ "EtcFilter.cpp",
+ "EtcImage.cpp",
+ "EtcIndividualTrys.cpp",
+ "EtcMath.cpp",
+ "EtcSortedBlockList.cpp",
]
thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
diff --git a/modules/etc/config.py b/modules/etc/config.py
index 098f1eafa9..53b8f2f2e3 100644
--- a/modules/etc/config.py
+++ b/modules/etc/config.py
@@ -1,5 +1,6 @@
def can_build(env, platform):
- return env['tools']
+ return env["tools"]
+
def configure(env):
pass
diff --git a/modules/etc/image_etc.cpp b/modules/etc/image_etc.cpp
index b3f7b1d94f..223830f445 100644
--- a/modules/etc/image_etc.cpp
+++ b/modules/etc/image_etc.cpp
@@ -192,7 +192,7 @@ static void _compress_etc(Image *p_img, float p_lossy_quality, bool force_etc1_f
src_rgba_f[j] = Etc::ColorFloatRGBA::ConvertFromRGBA8(src[si], src[si + 1], src[si + 2], src[si + 3]);
}
- unsigned char *etc_data = NULL;
+ unsigned char *etc_data = nullptr;
unsigned int etc_data_len = 0;
unsigned int extended_width = 0, extended_height = 0;
Etc::Encode((float *)src_rgba_f, mipmap_w, mipmap_h, etc2comp_etc_format, error_metric, effort, num_cpus, num_cpus, &etc_data, &etc_data_len, &extended_width, &extended_height, &encoding_time);
diff --git a/modules/etc/texture_loader_pkm.cpp b/modules/etc/texture_loader_pkm.cpp
index ad0cc91c96..bfb2098dff 100644
--- a/modules/etc/texture_loader_pkm.cpp
+++ b/modules/etc/texture_loader_pkm.cpp
@@ -42,7 +42,7 @@ struct ETC1Header {
uint16_t origHeight;
};
-RES ResourceFormatPKM::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress) {
+RES ResourceFormatPKM::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, bool p_no_cache) {
if (r_error)
*r_error = ERR_CANT_OPEN;
diff --git a/modules/etc/texture_loader_pkm.h b/modules/etc/texture_loader_pkm.h
index d6011993e3..6507e0bdec 100644
--- a/modules/etc/texture_loader_pkm.h
+++ b/modules/etc/texture_loader_pkm.h
@@ -36,7 +36,7 @@
class ResourceFormatPKM : public ResourceFormatLoader {
public:
- virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL, bool p_use_sub_threads = false, float *r_progress = nullptr);
+ virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr, bool p_no_cache = false);
virtual void get_recognized_extensions(List<String> *p_extensions) const;
virtual bool handles_type(const String &p_type) const;
virtual String get_resource_type(const String &p_path) const;
diff --git a/modules/freetype/SCsub b/modules/freetype/SCsub
index 7b66aa1c76..bfc1658bb4 100644
--- a/modules/freetype/SCsub
+++ b/modules/freetype/SCsub
@@ -1,14 +1,12 @@
#!/usr/bin/env python
-Import('env')
-Import('env_modules')
-
-from compat import isbasestring
+Import("env")
+Import("env_modules")
env_freetype = env_modules.Clone()
# Thirdparty source files
-if env['builtin_freetype']:
+if env["builtin_freetype"]:
thirdparty_dir = "#thirdparty/freetype/"
thirdparty_sources = [
"src/autofit/autofit.c",
@@ -55,31 +53,31 @@ if env['builtin_freetype']:
]
thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
- if env['platform'] == 'uwp':
+ if env["platform"] == "uwp":
# Include header for UWP to fix build issues
- env_freetype.Append(CCFLAGS=['/FI', '"modules/freetype/uwpdef.h"'])
+ env_freetype.Append(CCFLAGS=["/FI", '"modules/freetype/uwpdef.h"'])
# Globally too, as freetype is used in scene (see bottom)
- env.Append(CCFLAGS=['/FI', '"modules/freetype/uwpdef.h"'])
+ env.Append(CCFLAGS=["/FI", '"modules/freetype/uwpdef.h"'])
env_freetype.Prepend(CPPPATH=[thirdparty_dir + "/include"])
# Also needed in main env for scene/
env.Prepend(CPPPATH=[thirdparty_dir + "/include"])
- env_freetype.Append(CPPDEFINES=['FT2_BUILD_LIBRARY', 'FT_CONFIG_OPTION_USE_PNG'])
- if (env['target'] == 'debug'):
- env_freetype.Append(CPPDEFINES=['ZLIB_DEBUG'])
+ env_freetype.Append(CPPDEFINES=["FT2_BUILD_LIBRARY", "FT_CONFIG_OPTION_USE_PNG"])
+ if env["target"] == "debug":
+ env_freetype.Append(CPPDEFINES=["ZLIB_DEBUG"])
# Also requires libpng headers
- if env['builtin_libpng']:
+ if env["builtin_libpng"]:
env_freetype.Prepend(CPPPATH=["#thirdparty/libpng"])
- sfnt = thirdparty_dir + 'src/sfnt/sfnt.c'
+ sfnt = thirdparty_dir + "src/sfnt/sfnt.c"
# Must be done after all CPPDEFINES are being set so we can copy them.
- if env['platform'] == 'javascript':
+ if env["platform"] == "javascript":
# Forcibly undefine this macro so SIMD is not used in this file,
# since currently unsupported in WASM
tmp_env = env_freetype.Clone()
- tmp_env.Append(CPPFLAGS=['-U__OPTIMIZE__'])
+ tmp_env.Append(CPPFLAGS=["-U__OPTIMIZE__"])
sfnt = tmp_env.Object(sfnt)
thirdparty_sources += [sfnt]
@@ -93,7 +91,7 @@ if env['builtin_freetype']:
# and then plain strings for system library. We insert between the two.
inserted = False
for idx, linklib in enumerate(env["LIBS"]):
- if isbasestring(linklib): # first system lib such as "X11", otherwise SCons lib object
+ if isinstance(linklib, (str, bytes)): # first system lib such as "X11", otherwise SCons lib object
env["LIBS"].insert(idx, lib)
inserted = True
break
diff --git a/modules/freetype/config.py b/modules/freetype/config.py
index 1c8cd12a2d..d22f9454ed 100644
--- a/modules/freetype/config.py
+++ b/modules/freetype/config.py
@@ -1,5 +1,6 @@
def can_build(env, platform):
return True
+
def configure(env):
pass
diff --git a/modules/gdnative/SCsub b/modules/gdnative/SCsub
index a18c75fa27..cab05549d2 100644
--- a/modules/gdnative/SCsub
+++ b/modules/gdnative/SCsub
@@ -1,7 +1,7 @@
#!/usr/bin/env python
-Import('env')
-Import('env_modules')
+Import("env")
+Import("env_modules")
env_gdnative = env_modules.Clone()
env_gdnative.add_source_files(env.modules_sources, "gdnative.cpp")
@@ -12,12 +12,12 @@ env_gdnative.add_source_files(env.modules_sources, "nativescript/*.cpp")
env_gdnative.add_source_files(env.modules_sources, "gdnative_library_singleton_editor.cpp")
env_gdnative.add_source_files(env.modules_sources, "gdnative_library_editor_plugin.cpp")
-env_gdnative.Prepend(CPPPATH=['#modules/gdnative/include/'])
+env_gdnative.Prepend(CPPPATH=["#modules/gdnative/include/"])
-Export('env_gdnative')
+Export("env_gdnative")
SConscript("net/SCsub")
-SConscript("arvr/SCsub")
+SConscript("xr/SCsub")
SConscript("pluginscript/SCsub")
SConscript("videodecoder/SCsub")
@@ -25,8 +25,11 @@ SConscript("videodecoder/SCsub")
from platform_methods import run_in_subprocess
import gdnative_builders
-_, gensource = env_gdnative.CommandNoCache(['include/gdnative_api_struct.gen.h', 'gdnative_api_struct.gen.cpp'],
- 'gdnative_api.json', run_in_subprocess(gdnative_builders.build_gdnative_api_struct))
+_, gensource = env_gdnative.CommandNoCache(
+ ["include/gdnative_api_struct.gen.h", "gdnative_api_struct.gen.cpp"],
+ "gdnative_api.json",
+ run_in_subprocess(gdnative_builders.build_gdnative_api_struct),
+)
env_gdnative.add_source_files(env.modules_sources, [gensource])
env.use_ptrcall = True
diff --git a/modules/gdnative/android/android_gdn.cpp b/modules/gdnative/android/android_gdn.cpp
index 6e0358342f..bc39be1813 100644
--- a/modules/gdnative/android/android_gdn.cpp
+++ b/modules/gdnative/android/android_gdn.cpp
@@ -50,7 +50,7 @@ JNIEnv *GDAPI godot_android_get_env() {
#ifdef __ANDROID__
return ThreadAndroid::get_env();
#else
- return NULL;
+ return nullptr;
#endif
}
@@ -59,7 +59,7 @@ jobject GDAPI godot_android_get_activity() {
OS_Android *os_android = (OS_Android *)OS::get_singleton();
return os_android->get_godot_java()->get_activity();
#else
- return NULL;
+ return nullptr;
#endif
}
@@ -68,7 +68,7 @@ jobject GDAPI godot_android_get_surface() {
OS_Android *os_android = (OS_Android *)OS::get_singleton();
return os_android->get_godot_java()->get_surface();
#else
- return NULL;
+ return nullptr;
#endif
}
diff --git a/modules/gdnative/arvr/SCsub b/modules/gdnative/arvr/SCsub
deleted file mode 100644
index 20eaa99592..0000000000
--- a/modules/gdnative/arvr/SCsub
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/usr/bin/env python
-
-Import('env')
-Import('env_gdnative')
-
-env_gdnative.add_source_files(env.modules_sources, '*.cpp')
diff --git a/modules/gdnative/arvr/arvr_interface_gdnative.cpp b/modules/gdnative/arvr/arvr_interface_gdnative.cpp
deleted file mode 100644
index a033c2b7f9..0000000000
--- a/modules/gdnative/arvr/arvr_interface_gdnative.cpp
+++ /dev/null
@@ -1,439 +0,0 @@
-/*************************************************************************/
-/* arvr_interface_gdnative.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#include "arvr_interface_gdnative.h"
-#include "main/input_default.h"
-#include "servers/arvr/arvr_positional_tracker.h"
-#include "servers/visual/visual_server_globals.h"
-
-void ARVRInterfaceGDNative::_bind_methods() {
- ADD_PROPERTY_DEFAULT("interface_is_initialized", false);
- ADD_PROPERTY_DEFAULT("ar_is_anchor_detection_enabled", false);
-}
-
-ARVRInterfaceGDNative::ARVRInterfaceGDNative() {
- print_verbose("Construct gdnative interface\n");
-
- // we won't have our data pointer until our library gets set
- data = NULL;
-
- interface = NULL;
-}
-
-ARVRInterfaceGDNative::~ARVRInterfaceGDNative() {
- print_verbose("Destruct gdnative interface\n");
-
- if (interface != NULL && is_initialized()) {
- uninitialize();
- };
-
- // cleanup after ourselves
- cleanup();
-}
-
-void ARVRInterfaceGDNative::cleanup() {
- if (interface != NULL) {
- interface->destructor(data);
- data = NULL;
- interface = NULL;
- }
-}
-
-void ARVRInterfaceGDNative::set_interface(const godot_arvr_interface_gdnative *p_interface) {
- // this should only be called once, just being paranoid..
- if (interface) {
- cleanup();
- }
-
- // bind to our interface
- interface = p_interface;
-
- // Now we do our constructing...
- data = interface->constructor((godot_object *)this);
-}
-
-StringName ARVRInterfaceGDNative::get_name() const {
-
- ERR_FAIL_COND_V(interface == NULL, StringName());
-
- godot_string result = interface->get_name(data);
-
- StringName name = *(String *)&result;
-
- godot_string_destroy(&result);
-
- return name;
-}
-
-int ARVRInterfaceGDNative::get_capabilities() const {
- int capabilities;
-
- ERR_FAIL_COND_V(interface == NULL, 0); // 0 = None
-
- capabilities = interface->get_capabilities(data);
-
- return capabilities;
-}
-
-bool ARVRInterfaceGDNative::get_anchor_detection_is_enabled() const {
-
- ERR_FAIL_COND_V(interface == NULL, false);
-
- return interface->get_anchor_detection_is_enabled(data);
-}
-
-void ARVRInterfaceGDNative::set_anchor_detection_is_enabled(bool p_enable) {
-
- ERR_FAIL_COND(interface == NULL);
-
- interface->set_anchor_detection_is_enabled(data, p_enable);
-}
-
-int ARVRInterfaceGDNative::get_camera_feed_id() {
-
- ERR_FAIL_COND_V(interface == NULL, 0);
-
- if ((interface->version.major > 1) || ((interface->version.major) == 1 && (interface->version.minor >= 1))) {
- return (unsigned int)interface->get_camera_feed_id(data);
- } else {
- return 0;
- }
-}
-
-bool ARVRInterfaceGDNative::is_stereo() {
- bool stereo;
-
- ERR_FAIL_COND_V(interface == NULL, false);
-
- stereo = interface->is_stereo(data);
-
- return stereo;
-}
-
-bool ARVRInterfaceGDNative::is_initialized() const {
-
- ERR_FAIL_COND_V(interface == NULL, false);
-
- return interface->is_initialized(data);
-}
-
-bool ARVRInterfaceGDNative::initialize() {
- ERR_FAIL_COND_V(interface == NULL, false);
-
- bool initialized = interface->initialize(data);
-
- if (initialized) {
- // if we successfully initialize our interface and we don't have a primary interface yet, this becomes our primary interface
-
- ARVRServer *arvr_server = ARVRServer::get_singleton();
- if ((arvr_server != NULL) && (arvr_server->get_primary_interface() == NULL)) {
- arvr_server->set_primary_interface(this);
- };
- };
-
- return initialized;
-}
-
-void ARVRInterfaceGDNative::uninitialize() {
- ERR_FAIL_COND(interface == NULL);
-
- ARVRServer *arvr_server = ARVRServer::get_singleton();
- if (arvr_server != NULL) {
- // Whatever happens, make sure this is no longer our primary interface
- arvr_server->clear_primary_interface_if(this);
- }
-
- interface->uninitialize(data);
-}
-
-Size2 ARVRInterfaceGDNative::get_render_targetsize() {
-
- ERR_FAIL_COND_V(interface == NULL, Size2());
-
- godot_vector2 result = interface->get_render_targetsize(data);
- Vector2 *vec = (Vector2 *)&result;
-
- return *vec;
-}
-
-Transform ARVRInterfaceGDNative::get_transform_for_eye(ARVRInterface::Eyes p_eye, const Transform &p_cam_transform) {
- Transform *ret;
-
- ERR_FAIL_COND_V(interface == NULL, Transform());
-
- godot_transform t = interface->get_transform_for_eye(data, (int)p_eye, (godot_transform *)&p_cam_transform);
-
- ret = (Transform *)&t;
-
- return *ret;
-}
-
-CameraMatrix ARVRInterfaceGDNative::get_projection_for_eye(ARVRInterface::Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far) {
- CameraMatrix cm;
-
- ERR_FAIL_COND_V(interface == NULL, CameraMatrix());
-
- interface->fill_projection_for_eye(data, (godot_real *)cm.matrix, (godot_int)p_eye, p_aspect, p_z_near, p_z_far);
-
- return cm;
-}
-
-unsigned int ARVRInterfaceGDNative::get_external_texture_for_eye(ARVRInterface::Eyes p_eye) {
-
- ERR_FAIL_COND_V(interface == NULL, 0);
-
- if ((interface->version.major > 1) || ((interface->version.major) == 1 && (interface->version.minor >= 1))) {
- return (unsigned int)interface->get_external_texture_for_eye(data, (godot_int)p_eye);
- } else {
- return 0;
- }
-}
-
-void ARVRInterfaceGDNative::commit_for_eye(ARVRInterface::Eyes p_eye, RID p_render_target, const Rect2 &p_screen_rect) {
-
- ERR_FAIL_COND(interface == NULL);
-
- interface->commit_for_eye(data, (godot_int)p_eye, (godot_rid *)&p_render_target, (godot_rect2 *)&p_screen_rect);
-}
-
-void ARVRInterfaceGDNative::process() {
- ERR_FAIL_COND(interface == NULL);
-
- interface->process(data);
-}
-
-void ARVRInterfaceGDNative::notification(int p_what) {
- ERR_FAIL_COND(interface == NULL);
-
- // this is only available in interfaces that implement 1.1 or later
- if ((interface->version.major > 1) || ((interface->version.major == 1) && (interface->version.minor > 0))) {
- interface->notification(data, p_what);
- }
-}
-
-/////////////////////////////////////////////////////////////////////////////////////
-// some helper callbacks
-
-extern "C" {
-
-void GDAPI godot_arvr_register_interface(const godot_arvr_interface_gdnative *p_interface) {
- // If our major version is 0 or bigger then 10, we're likely looking at our constructor pointer from an older plugin
- ERR_FAIL_COND_MSG((p_interface->version.major == 0) || (p_interface->version.major > 10), "GDNative ARVR interfaces build for Godot 3.0 are not supported.");
-
- Ref<ARVRInterfaceGDNative> new_interface;
- new_interface.instance();
- new_interface->set_interface((const godot_arvr_interface_gdnative *)p_interface);
- ARVRServer::get_singleton()->add_interface(new_interface);
-}
-
-godot_real GDAPI godot_arvr_get_worldscale() {
- ARVRServer *arvr_server = ARVRServer::get_singleton();
- ERR_FAIL_NULL_V(arvr_server, 1.0);
-
- return arvr_server->get_world_scale();
-}
-
-godot_transform GDAPI godot_arvr_get_reference_frame() {
- godot_transform reference_frame;
- Transform *reference_frame_ptr = (Transform *)&reference_frame;
-
- ARVRServer *arvr_server = ARVRServer::get_singleton();
- if (arvr_server != NULL) {
- *reference_frame_ptr = arvr_server->get_reference_frame();
- } else {
- godot_transform_new_identity(&reference_frame);
- }
-
- return reference_frame;
-}
-
-void GDAPI godot_arvr_blit(godot_int p_eye, godot_rid *p_render_target, godot_rect2 *p_rect) {
- // blits out our texture as is, handy for preview display of one of the eyes that is already rendered with lens distortion on an external HMD
- ARVRInterface::Eyes eye = (ARVRInterface::Eyes)p_eye;
-#if 0
- RID *render_target = (RID *)p_render_target;
-#endif
- Rect2 screen_rect = *(Rect2 *)p_rect;
-
- if (eye == ARVRInterface::EYE_LEFT) {
- screen_rect.size.x /= 2.0;
- } else if (p_eye == ARVRInterface::EYE_RIGHT) {
- screen_rect.size.x /= 2.0;
- screen_rect.position.x += screen_rect.size.x;
- }
-#ifndef _MSC_VER
-#warning this needs to be redone
-#endif
-#if 0
- VSG::rasterizer->blit_render_target_to_screen(*render_target, screen_rect, 0);
-#endif
-}
-
-godot_int GDAPI godot_arvr_get_texid(godot_rid *p_render_target) {
- // In order to send off our textures to display on our hardware we need the opengl texture ID instead of the render target RID
- // This is a handy function to expose that.
-#if 0
- RID *render_target = (RID *)p_render_target;
-
- RID eye_texture = VSG::storage->render_target_get_texture(*render_target);
-#endif
-
-#ifndef _MSC_VER
-#warning need to obtain this ID again
-#endif
- uint32_t texid = 0; //VS::get_singleton()->texture_get_texid(eye_texture);
-
- return texid;
-}
-
-godot_int GDAPI godot_arvr_add_controller(char *p_device_name, godot_int p_hand, godot_bool p_tracks_orientation, godot_bool p_tracks_position) {
- ARVRServer *arvr_server = ARVRServer::get_singleton();
- ERR_FAIL_NULL_V(arvr_server, 0);
-
- InputDefault *input = (InputDefault *)Input::get_singleton();
- ERR_FAIL_NULL_V(input, 0);
-
- ARVRPositionalTracker *new_tracker = memnew(ARVRPositionalTracker);
- new_tracker->set_name(p_device_name);
- new_tracker->set_type(ARVRServer::TRACKER_CONTROLLER);
- if (p_hand == 1) {
- new_tracker->set_hand(ARVRPositionalTracker::TRACKER_LEFT_HAND);
- } else if (p_hand == 2) {
- new_tracker->set_hand(ARVRPositionalTracker::TRACKER_RIGHT_HAND);
- }
-
- // also register as joystick...
- int joyid = input->get_unused_joy_id();
- if (joyid != -1) {
- new_tracker->set_joy_id(joyid);
- input->joy_connection_changed(joyid, true, p_device_name, "");
- }
-
- if (p_tracks_orientation) {
- Basis orientation;
- new_tracker->set_orientation(orientation);
- }
- if (p_tracks_position) {
- Vector3 position;
- new_tracker->set_position(position);
- }
-
- // add our tracker to our server and remember its pointer
- arvr_server->add_tracker(new_tracker);
-
- // note, this ID is only unique within controllers!
- return new_tracker->get_tracker_id();
-}
-
-void GDAPI godot_arvr_remove_controller(godot_int p_controller_id) {
- ARVRServer *arvr_server = ARVRServer::get_singleton();
- ERR_FAIL_NULL(arvr_server);
-
- InputDefault *input = (InputDefault *)Input::get_singleton();
- ERR_FAIL_NULL(input);
-
- ARVRPositionalTracker *remove_tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, p_controller_id);
- if (remove_tracker != NULL) {
- // unset our joystick if applicable
- int joyid = remove_tracker->get_joy_id();
- if (joyid != -1) {
- input->joy_connection_changed(joyid, false, "", "");
- remove_tracker->set_joy_id(-1);
- }
-
- // remove our tracker from our server
- arvr_server->remove_tracker(remove_tracker);
- memdelete(remove_tracker);
- }
-}
-
-void GDAPI godot_arvr_set_controller_transform(godot_int p_controller_id, godot_transform *p_transform, godot_bool p_tracks_orientation, godot_bool p_tracks_position) {
- ARVRServer *arvr_server = ARVRServer::get_singleton();
- ERR_FAIL_NULL(arvr_server);
-
- ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, p_controller_id);
- if (tracker != NULL) {
- Transform *transform = (Transform *)p_transform;
- if (p_tracks_orientation) {
- tracker->set_orientation(transform->basis);
- }
- if (p_tracks_position) {
- tracker->set_rw_position(transform->origin);
- }
- }
-}
-
-void GDAPI godot_arvr_set_controller_button(godot_int p_controller_id, godot_int p_button, godot_bool p_is_pressed) {
- ARVRServer *arvr_server = ARVRServer::get_singleton();
- ERR_FAIL_NULL(arvr_server);
-
- InputDefault *input = (InputDefault *)Input::get_singleton();
- ERR_FAIL_NULL(input);
-
- ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, p_controller_id);
- if (tracker != NULL) {
- int joyid = tracker->get_joy_id();
- if (joyid != -1) {
- input->joy_button(joyid, p_button, p_is_pressed);
- }
- }
-}
-
-void GDAPI godot_arvr_set_controller_axis(godot_int p_controller_id, godot_int p_axis, godot_real p_value, godot_bool p_can_be_negative) {
- ARVRServer *arvr_server = ARVRServer::get_singleton();
- ERR_FAIL_NULL(arvr_server);
-
- InputDefault *input = (InputDefault *)Input::get_singleton();
- ERR_FAIL_NULL(input);
-
- ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, p_controller_id);
- if (tracker != NULL) {
- int joyid = tracker->get_joy_id();
- if (joyid != -1) {
- InputDefault::JoyAxis jx;
- jx.min = p_can_be_negative ? -1 : 0;
- jx.value = p_value;
- input->joy_axis(joyid, p_axis, jx);
- }
- }
-}
-
-godot_real GDAPI godot_arvr_get_controller_rumble(godot_int p_controller_id) {
- ARVRServer *arvr_server = ARVRServer::get_singleton();
- ERR_FAIL_NULL_V(arvr_server, 0.0);
-
- ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, p_controller_id);
- if (tracker != NULL) {
- return tracker->get_rumble();
- }
-
- return 0.0;
-}
-}
diff --git a/modules/gdnative/config.py b/modules/gdnative/config.py
index b9e5afcdf3..4b997e4bfe 100644
--- a/modules/gdnative/config.py
+++ b/modules/gdnative/config.py
@@ -1,13 +1,15 @@
def can_build(env, platform):
return True
+
def configure(env):
env.use_ptrcall = True
+
def get_doc_classes():
return [
"@NativeScript",
- "ARVRInterfaceGDNative",
+ "XRInterfaceGDNative",
"GDNative",
"GDNativeLibrary",
"MultiplayerPeerGDNative",
@@ -20,5 +22,6 @@ def get_doc_classes():
"WebRTCDataChannelGDNative",
]
+
def get_doc_path():
return "doc_classes"
diff --git a/modules/gdnative/doc_classes/ARVRInterfaceGDNative.xml b/modules/gdnative/doc_classes/ARVRInterfaceGDNative.xml
deleted file mode 100644
index e8405b64a3..0000000000
--- a/modules/gdnative/doc_classes/ARVRInterfaceGDNative.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<class name="ARVRInterfaceGDNative" inherits="ARVRInterface" version="4.0">
- <brief_description>
- GDNative wrapper for an ARVR interface.
- </brief_description>
- <description>
- This is a wrapper class for GDNative implementations of the ARVR interface. To use a GDNative ARVR interface, simply instantiate this object and set your GDNative library containing the ARVR interface implementation.
- </description>
- <tutorials>
- </tutorials>
- <methods>
- </methods>
- <constants>
- </constants>
-</class>
diff --git a/modules/gdnative/doc_classes/GDNativeLibrary.xml b/modules/gdnative/doc_classes/GDNativeLibrary.xml
index 601e132d42..1aab864102 100644
--- a/modules/gdnative/doc_classes/GDNativeLibrary.xml
+++ b/modules/gdnative/doc_classes/GDNativeLibrary.xml
@@ -4,7 +4,7 @@
An external library containing functions or script classes to use in Godot.
</brief_description>
<description>
- A GDNative library can implement [NativeScript]s, global functions to call with the [GDNative] class, or low-level engine extensions through interfaces such as [ARVRInterfaceGDNative]. The library must be compiled for each platform and architecture that the project will run on.
+ A GDNative library can implement [NativeScript]s, global functions to call with the [GDNative] class, or low-level engine extensions through interfaces such as [XRInterfaceGDNative]. The library must be compiled for each platform and architecture that the project will run on.
</description>
<tutorials>
<link>https://docs.godotengine.org/en/latest/tutorials/plugins/gdnative/gdnative-c-example.html</link>
diff --git a/modules/gdnative/doc_classes/XRInterfaceGDNative.xml b/modules/gdnative/doc_classes/XRInterfaceGDNative.xml
new file mode 100644
index 0000000000..13de815793
--- /dev/null
+++ b/modules/gdnative/doc_classes/XRInterfaceGDNative.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<class name="XRInterfaceGDNative" inherits="XRInterface" version="4.0">
+ <brief_description>
+ GDNative wrapper for an XR interface.
+ </brief_description>
+ <description>
+ This is a wrapper class for GDNative implementations of the XR interface. To use a GDNative XR interface, simply instantiate this object and set your GDNative library containing the XR interface implementation.
+ </description>
+ <tutorials>
+ </tutorials>
+ <methods>
+ </methods>
+ <constants>
+ </constants>
+</class>
diff --git a/modules/gdnative/gdnative.cpp b/modules/gdnative/gdnative.cpp
index 0457a42f30..a131e3a78f 100644
--- a/modules/gdnative/gdnative.cpp
+++ b/modules/gdnative/gdnative.cpp
@@ -248,7 +248,7 @@ void GDNativeLibrary::_bind_methods() {
}
GDNative::GDNative() {
- native_handle = NULL;
+ native_handle = nullptr;
initialized = false;
}
@@ -338,7 +338,7 @@ bool GDNative::initialize() {
if (err || !library_init) {
OS::get_singleton()->close_dynamic_library(native_handle);
- native_handle = NULL;
+ native_handle = nullptr;
ERR_PRINT("Failed to obtain " + library->get_symbol_prefix() + "gdnative_init symbol");
return false;
}
@@ -408,7 +408,7 @@ bool GDNative::terminate() {
Error error = get_symbol(library->get_symbol_prefix() + terminate_symbol, library_terminate);
if (error || !library_terminate) {
OS::get_singleton()->close_dynamic_library(native_handle);
- native_handle = NULL;
+ native_handle = nullptr;
initialized = false;
return true;
}
@@ -426,7 +426,7 @@ bool GDNative::terminate() {
// GDNativeScriptLanguage::get_singleton()->initialized_libraries.erase(p_native_lib->path);
OS::get_singleton()->close_dynamic_library(native_handle);
- native_handle = NULL;
+ native_handle = nullptr;
return true;
}
@@ -466,7 +466,7 @@ Variant GDNative::call_native(StringName p_native_call_type, StringName p_proced
p_procedure_name,
procedure_handle);
- if (err != OK || procedure_handle == NULL) {
+ if (err != OK || procedure_handle == nullptr) {
return Variant();
}
@@ -493,7 +493,7 @@ Error GDNative::get_symbol(StringName p_procedure_name, void *&r_handle, bool p_
return result;
}
-RES GDNativeLibraryResourceLoader::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress) {
+RES GDNativeLibraryResourceLoader::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, bool p_no_cache) {
Ref<GDNativeLibrary> lib;
lib.instance();
@@ -544,11 +544,11 @@ Error GDNativeLibraryResourceSaver::save(const String &p_path, const RES &p_reso
}
bool GDNativeLibraryResourceSaver::recognize(const RES &p_resource) const {
- return Object::cast_to<GDNativeLibrary>(*p_resource) != NULL;
+ return Object::cast_to<GDNativeLibrary>(*p_resource) != nullptr;
}
void GDNativeLibraryResourceSaver::get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const {
- if (Object::cast_to<GDNativeLibrary>(*p_resource) != NULL) {
+ if (Object::cast_to<GDNativeLibrary>(*p_resource) != nullptr) {
p_extensions->push_back("gdnlib");
}
}
diff --git a/modules/gdnative/gdnative.h b/modules/gdnative/gdnative.h
index 9ef9c706d1..6d26c2141d 100644
--- a/modules/gdnative/gdnative.h
+++ b/modules/gdnative/gdnative.h
@@ -166,7 +166,7 @@ public:
class GDNativeLibraryResourceLoader : public ResourceFormatLoader {
public:
- virtual RES load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads = false, float *r_progress = nullptr);
+ virtual RES load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads = false, float *r_progress = nullptr, bool p_no_cache = false);
virtual void get_recognized_extensions(List<String> *p_extensions) const;
virtual bool handles_type(const String &p_type) const;
virtual String get_resource_type(const String &p_path) const;
diff --git a/modules/gdnative/gdnative/gdnative.cpp b/modules/gdnative/gdnative/gdnative.cpp
index d996b006a5..3175340448 100644
--- a/modules/gdnative/gdnative/gdnative.cpp
+++ b/modules/gdnative/gdnative/gdnative.cpp
@@ -95,7 +95,7 @@ godot_class_constructor GDAPI godot_get_class_constructor(const char *p_classnam
ClassDB::ClassInfo *class_info = ClassDB::classes.getptr(StringName(p_classname));
if (class_info)
return (godot_class_constructor)class_info->creation_func;
- return NULL;
+ return nullptr;
}
godot_dictionary GDAPI godot_get_global_constants() {
@@ -173,14 +173,14 @@ godot_object GDAPI *godot_instance_from_id(godot_int p_instance_id) {
void *godot_get_class_tag(const godot_string_name *p_class) {
StringName class_name = *(StringName *)p_class;
ClassDB::ClassInfo *class_info = ClassDB::classes.getptr(class_name);
- return class_info ? class_info->class_ptr : NULL;
+ return class_info ? class_info->class_ptr : nullptr;
}
godot_object *godot_object_cast_to(const godot_object *p_object, void *p_class_tag) {
- if (!p_object) return NULL;
+ if (!p_object) return nullptr;
Object *o = (Object *)p_object;
- return o->is_class_ptr(p_class_tag) ? (godot_object *)o : NULL;
+ return o->is_class_ptr(p_class_tag) ? (godot_object *)o : nullptr;
}
#ifdef __cplusplus
diff --git a/modules/gdnative/gdnative_api.json b/modules/gdnative/gdnative_api.json
index e1d6c0c867..9473a3d419 100644
--- a/modules/gdnative/gdnative_api.json
+++ b/modules/gdnative/gdnative_api.json
@@ -5935,8 +5935,8 @@
]
},
{
- "name": "arvr",
- "type": "ARVR",
+ "name": "xr",
+ "type": "XR",
"version": {
"major": 1,
"minor": 1
@@ -5944,24 +5944,24 @@
"next": null,
"api": [
{
- "name": "godot_arvr_register_interface",
+ "name": "godot_xr_register_interface",
"return_type": "void",
"arguments": [
- ["const godot_arvr_interface_gdnative *", "p_interface"]
+ ["const godot_xr_interface_gdnative *", "p_interface"]
]
},
{
- "name": "godot_arvr_get_worldscale",
+ "name": "godot_xr_get_worldscale",
"return_type": "godot_real",
"arguments": []
},
{
- "name": "godot_arvr_get_reference_frame",
+ "name": "godot_xr_get_reference_frame",
"return_type": "godot_transform",
"arguments": []
},
{
- "name": "godot_arvr_blit",
+ "name": "godot_xr_blit",
"return_type": "void",
"arguments": [
["godot_int", "p_eye"],
@@ -5970,14 +5970,14 @@
]
},
{
- "name": "godot_arvr_get_texid",
+ "name": "godot_xr_get_texid",
"return_type": "godot_int",
"arguments": [
["godot_rid *", "p_render_target"]
]
},
{
- "name": "godot_arvr_add_controller",
+ "name": "godot_xr_add_controller",
"return_type": "godot_int",
"arguments": [
["char *", "p_device_name"],
@@ -5987,14 +5987,14 @@
]
},
{
- "name": "godot_arvr_remove_controller",
+ "name": "godot_xr_remove_controller",
"return_type": "void",
"arguments": [
["godot_int", "p_controller_id"]
]
},
{
- "name": "godot_arvr_set_controller_transform",
+ "name": "godot_xr_set_controller_transform",
"return_type": "void",
"arguments": [
["godot_int", "p_controller_id"],
@@ -6004,7 +6004,7 @@
]
},
{
- "name": "godot_arvr_set_controller_button",
+ "name": "godot_xr_set_controller_button",
"return_type": "void",
"arguments": [
["godot_int", "p_controller_id"],
@@ -6013,7 +6013,7 @@
]
},
{
- "name": "godot_arvr_set_controller_axis",
+ "name": "godot_xr_set_controller_axis",
"return_type": "void",
"arguments": [
["godot_int", "p_controller_id"],
@@ -6023,7 +6023,7 @@
]
},
{
- "name": "godot_arvr_get_controller_rumble",
+ "name": "godot_xr_get_controller_rumble",
"return_type": "godot_real",
"arguments": [
["godot_int", "p_controller_id"]
diff --git a/modules/gdnative/gdnative_builders.py b/modules/gdnative/gdnative_builders.py
index 0d95a65b7e..620935795f 100644
--- a/modules/gdnative/gdnative_builders.py
+++ b/modules/gdnative/gdnative_builders.py
@@ -8,209 +8,249 @@ from platform_methods import subprocess_main
def _spaced(e):
- return e if e[-1] == '*' else e + ' '
+ return e if e[-1] == "*" else e + " "
def _build_gdnative_api_struct_header(api):
out = [
- '/* THIS FILE IS GENERATED DO NOT EDIT */',
- '#ifndef GODOT_GDNATIVE_API_STRUCT_H',
- '#define GODOT_GDNATIVE_API_STRUCT_H',
- '',
- '#include <gdnative/gdnative.h>',
- '#include <android/godot_android.h>',
- '#include <arvr/godot_arvr.h>',
- '#include <nativescript/godot_nativescript.h>',
- '#include <net/godot_net.h>',
- '#include <pluginscript/godot_pluginscript.h>',
- '#include <videodecoder/godot_videodecoder.h>',
- '',
- '#ifdef __cplusplus',
+ "/* THIS FILE IS GENERATED DO NOT EDIT */",
+ "#ifndef GODOT_GDNATIVE_API_STRUCT_H",
+ "#define GODOT_GDNATIVE_API_STRUCT_H",
+ "",
+ "#include <gdnative/gdnative.h>",
+ "#include <android/godot_android.h>",
+ "#include <xr/godot_xr.h>",
+ "#include <nativescript/godot_nativescript.h>",
+ "#include <net/godot_net.h>",
+ "#include <pluginscript/godot_pluginscript.h>",
+ "#include <videodecoder/godot_videodecoder.h>",
+ "",
+ "#ifdef __cplusplus",
'extern "C" {',
- '#endif',
- '',
- 'enum GDNATIVE_API_TYPES {',
- '\tGDNATIVE_' + api['core']['type'] + ','
+ "#endif",
+ "",
+ "enum GDNATIVE_API_TYPES {",
+ "\tGDNATIVE_" + api["core"]["type"] + ",",
]
- for ext in api['extensions']:
- out += ['\tGDNATIVE_EXT_' + ext['type'] + ',']
+ for ext in api["extensions"]:
+ out += ["\tGDNATIVE_EXT_" + ext["type"] + ","]
- out += ['};', '']
+ out += ["};", ""]
def generate_extension_struct(name, ext, include_version=True):
ret_val = []
- if ext['next']:
- ret_val += generate_extension_struct(name, ext['next'])
+ if ext["next"]:
+ ret_val += generate_extension_struct(name, ext["next"])
ret_val += [
- 'typedef struct godot_gdnative_ext_' + name + ('' if not include_version else ('_{0}_{1}'.format(ext['version']['major'], ext['version']['minor']))) + '_api_struct {',
- '\tunsigned int type;',
- '\tgodot_gdnative_api_version version;',
- '\tconst godot_gdnative_api_struct *next;'
+ "typedef struct godot_gdnative_ext_"
+ + name
+ + ("" if not include_version else ("_{0}_{1}".format(ext["version"]["major"], ext["version"]["minor"])))
+ + "_api_struct {",
+ "\tunsigned int type;",
+ "\tgodot_gdnative_api_version version;",
+ "\tconst godot_gdnative_api_struct *next;",
]
- for funcdef in ext['api']:
- args = ', '.join(['%s%s' % (_spaced(t), n) for t, n in funcdef['arguments']])
- ret_val.append('\t%s(*%s)(%s);' % (_spaced(funcdef['return_type']), funcdef['name'], args))
+ for funcdef in ext["api"]:
+ args = ", ".join(["%s%s" % (_spaced(t), n) for t, n in funcdef["arguments"]])
+ ret_val.append("\t%s(*%s)(%s);" % (_spaced(funcdef["return_type"]), funcdef["name"], args))
- ret_val += ['} godot_gdnative_ext_' + name + ('' if not include_version else ('_{0}_{1}'.format(ext['version']['major'], ext['version']['minor']))) + '_api_struct;', '']
+ ret_val += [
+ "} godot_gdnative_ext_"
+ + name
+ + ("" if not include_version else ("_{0}_{1}".format(ext["version"]["major"], ext["version"]["minor"])))
+ + "_api_struct;",
+ "",
+ ]
return ret_val
-
def generate_core_extension_struct(core):
ret_val = []
- if core['next']:
- ret_val += generate_core_extension_struct(core['next'])
+ if core["next"]:
+ ret_val += generate_core_extension_struct(core["next"])
ret_val += [
- 'typedef struct godot_gdnative_core_' + ('{0}_{1}'.format(core['version']['major'], core['version']['minor'])) + '_api_struct {',
- '\tunsigned int type;',
- '\tgodot_gdnative_api_version version;',
- '\tconst godot_gdnative_api_struct *next;',
+ "typedef struct godot_gdnative_core_"
+ + ("{0}_{1}".format(core["version"]["major"], core["version"]["minor"]))
+ + "_api_struct {",
+ "\tunsigned int type;",
+ "\tgodot_gdnative_api_version version;",
+ "\tconst godot_gdnative_api_struct *next;",
]
- for funcdef in core['api']:
- args = ', '.join(['%s%s' % (_spaced(t), n) for t, n in funcdef['arguments']])
- ret_val.append('\t%s(*%s)(%s);' % (_spaced(funcdef['return_type']), funcdef['name'], args))
+ for funcdef in core["api"]:
+ args = ", ".join(["%s%s" % (_spaced(t), n) for t, n in funcdef["arguments"]])
+ ret_val.append("\t%s(*%s)(%s);" % (_spaced(funcdef["return_type"]), funcdef["name"], args))
- ret_val += ['} godot_gdnative_core_' + '{0}_{1}'.format(core['version']['major'], core['version']['minor']) + '_api_struct;', '']
+ ret_val += [
+ "} godot_gdnative_core_"
+ + "{0}_{1}".format(core["version"]["major"], core["version"]["minor"])
+ + "_api_struct;",
+ "",
+ ]
return ret_val
-
- for ext in api['extensions']:
- name = ext['name']
+ for ext in api["extensions"]:
+ name = ext["name"]
out += generate_extension_struct(name, ext, False)
- if api['core']['next']:
- out += generate_core_extension_struct(api['core']['next'])
+ if api["core"]["next"]:
+ out += generate_core_extension_struct(api["core"]["next"])
out += [
- 'typedef struct godot_gdnative_core_api_struct {',
- '\tunsigned int type;',
- '\tgodot_gdnative_api_version version;',
- '\tconst godot_gdnative_api_struct *next;',
- '\tunsigned int num_extensions;',
- '\tconst godot_gdnative_api_struct **extensions;',
+ "typedef struct godot_gdnative_core_api_struct {",
+ "\tunsigned int type;",
+ "\tgodot_gdnative_api_version version;",
+ "\tconst godot_gdnative_api_struct *next;",
+ "\tunsigned int num_extensions;",
+ "\tconst godot_gdnative_api_struct **extensions;",
]
- for funcdef in api['core']['api']:
- args = ', '.join(['%s%s' % (_spaced(t), n) for t, n in funcdef['arguments']])
- out.append('\t%s(*%s)(%s);' % (_spaced(funcdef['return_type']), funcdef['name'], args))
+ for funcdef in api["core"]["api"]:
+ args = ", ".join(["%s%s" % (_spaced(t), n) for t, n in funcdef["arguments"]])
+ out.append("\t%s(*%s)(%s);" % (_spaced(funcdef["return_type"]), funcdef["name"], args))
out += [
- '} godot_gdnative_core_api_struct;',
- '',
- '#ifdef __cplusplus',
- '}',
- '#endif',
- '',
- '#endif // GODOT_GDNATIVE_API_STRUCT_H',
- ''
+ "} godot_gdnative_core_api_struct;",
+ "",
+ "#ifdef __cplusplus",
+ "}",
+ "#endif",
+ "",
+ "#endif // GODOT_GDNATIVE_API_STRUCT_H",
+ "",
]
- return '\n'.join(out)
+ return "\n".join(out)
def _build_gdnative_api_struct_source(api):
- out = [
- '/* THIS FILE IS GENERATED DO NOT EDIT */',
- '',
- '#include <gdnative_api_struct.gen.h>',
- ''
- ]
+ out = ["/* THIS FILE IS GENERATED DO NOT EDIT */", "", "#include <gdnative_api_struct.gen.h>", ""]
def get_extension_struct_name(name, ext, include_version=True):
- return 'godot_gdnative_ext_' + name + ('' if not include_version else ('_{0}_{1}'.format(ext['version']['major'], ext['version']['minor']))) + '_api_struct'
+ return (
+ "godot_gdnative_ext_"
+ + name
+ + ("" if not include_version else ("_{0}_{1}".format(ext["version"]["major"], ext["version"]["minor"])))
+ + "_api_struct"
+ )
def get_extension_struct_instance_name(name, ext, include_version=True):
- return 'api_extension_' + name + ('' if not include_version else ('_{0}_{1}'.format(ext['version']['major'], ext['version']['minor']))) + '_struct'
+ return (
+ "api_extension_"
+ + name
+ + ("" if not include_version else ("_{0}_{1}".format(ext["version"]["major"], ext["version"]["minor"])))
+ + "_struct"
+ )
def get_extension_struct_definition(name, ext, include_version=True):
ret_val = []
- if ext['next']:
- ret_val += get_extension_struct_definition(name, ext['next'])
+ if ext["next"]:
+ ret_val += get_extension_struct_definition(name, ext["next"])
ret_val += [
- 'extern const ' + get_extension_struct_name(name, ext, include_version) + ' ' + get_extension_struct_instance_name(name, ext, include_version) + ' = {',
- '\tGDNATIVE_EXT_' + ext['type'] + ',',
- '\t{' + str(ext['version']['major']) + ', ' + str(ext['version']['minor']) + '},',
- '\t' + ('NULL' if not ext['next'] else ('(const godot_gdnative_api_struct *)&' + get_extension_struct_instance_name(name, ext['next']))) + ','
+ "extern const "
+ + get_extension_struct_name(name, ext, include_version)
+ + " "
+ + get_extension_struct_instance_name(name, ext, include_version)
+ + " = {",
+ "\tGDNATIVE_EXT_" + ext["type"] + ",",
+ "\t{" + str(ext["version"]["major"]) + ", " + str(ext["version"]["minor"]) + "},",
+ "\t"
+ + (
+ "nullptr"
+ if not ext["next"]
+ else ("(const godot_gdnative_api_struct *)&" + get_extension_struct_instance_name(name, ext["next"]))
+ )
+ + ",",
]
- for funcdef in ext['api']:
- ret_val.append('\t%s,' % funcdef['name'])
+ for funcdef in ext["api"]:
+ ret_val.append("\t%s," % funcdef["name"])
- ret_val += ['};\n']
+ ret_val += ["};\n"]
return ret_val
-
def get_core_struct_definition(core):
ret_val = []
- if core['next']:
- ret_val += get_core_struct_definition(core['next'])
+ if core["next"]:
+ ret_val += get_core_struct_definition(core["next"])
ret_val += [
- 'extern const godot_gdnative_core_' + ('{0}_{1}_api_struct api_{0}_{1}'.format(core['version']['major'], core['version']['minor'])) + ' = {',
- '\tGDNATIVE_' + core['type'] + ',',
- '\t{' + str(core['version']['major']) + ', ' + str(core['version']['minor']) + '},',
- '\t' + ('NULL' if not core['next'] else ('(const godot_gdnative_api_struct *)& api_{0}_{1}'.format(core['next']['version']['major'], core['next']['version']['minor']))) + ','
+ "extern const godot_gdnative_core_"
+ + ("{0}_{1}_api_struct api_{0}_{1}".format(core["version"]["major"], core["version"]["minor"]))
+ + " = {",
+ "\tGDNATIVE_" + core["type"] + ",",
+ "\t{" + str(core["version"]["major"]) + ", " + str(core["version"]["minor"]) + "},",
+ "\t"
+ + (
+ "nullptr"
+ if not core["next"]
+ else (
+ "(const godot_gdnative_api_struct *)& api_{0}_{1}".format(
+ core["next"]["version"]["major"], core["next"]["version"]["minor"]
+ )
+ )
+ )
+ + ",",
]
- for funcdef in core['api']:
- ret_val.append('\t%s,' % funcdef['name'])
+ for funcdef in core["api"]:
+ ret_val.append("\t%s," % funcdef["name"])
- ret_val += ['};\n']
+ ret_val += ["};\n"]
return ret_val
- for ext in api['extensions']:
- name = ext['name']
+ for ext in api["extensions"]:
+ name = ext["name"]
out += get_extension_struct_definition(name, ext, False)
- out += ['', 'const godot_gdnative_api_struct *gdnative_extensions_pointers[] = {']
+ out += ["", "const godot_gdnative_api_struct *gdnative_extensions_pointers[] = {"]
- for ext in api['extensions']:
- name = ext['name']
- out += ['\t(godot_gdnative_api_struct *)&api_extension_' + name + '_struct,']
+ for ext in api["extensions"]:
+ name = ext["name"]
+ out += ["\t(godot_gdnative_api_struct *)&api_extension_" + name + "_struct,"]
- out += ['};\n']
+ out += ["};\n"]
- if api['core']['next']:
- out += get_core_struct_definition(api['core']['next'])
+ if api["core"]["next"]:
+ out += get_core_struct_definition(api["core"]["next"])
out += [
- 'extern const godot_gdnative_core_api_struct api_struct = {',
- '\tGDNATIVE_' + api['core']['type'] + ',',
- '\t{' + str(api['core']['version']['major']) + ', ' + str(api['core']['version']['minor']) + '},',
- '\t(const godot_gdnative_api_struct *)&api_1_1,',
- '\t' + str(len(api['extensions'])) + ',',
- '\tgdnative_extensions_pointers,',
+ "extern const godot_gdnative_core_api_struct api_struct = {",
+ "\tGDNATIVE_" + api["core"]["type"] + ",",
+ "\t{" + str(api["core"]["version"]["major"]) + ", " + str(api["core"]["version"]["minor"]) + "},",
+ "\t(const godot_gdnative_api_struct *)&api_1_1,",
+ "\t" + str(len(api["extensions"])) + ",",
+ "\tgdnative_extensions_pointers,",
]
- for funcdef in api['core']['api']:
- out.append('\t%s,' % funcdef['name'])
- out.append('};\n')
+ for funcdef in api["core"]["api"]:
+ out.append("\t%s," % funcdef["name"])
+ out.append("};\n")
- return '\n'.join(out)
+ return "\n".join(out)
def build_gdnative_api_struct(target, source, env):
- with open(source[0], 'r') as fd:
+ with open(source[0], "r") as fd:
api = json.load(fd)
header, source = target
- with open(header, 'w') as fd:
+ with open(header, "w") as fd:
fd.write(_build_gdnative_api_struct_header(api))
- with open(source, 'w') as fd:
+ with open(source, "w") as fd:
fd.write(_build_gdnative_api_struct_source(api))
-if __name__ == '__main__':
+if __name__ == "__main__":
subprocess_main(globals())
diff --git a/modules/gdnative/gdnative_library_editor_plugin.cpp b/modules/gdnative/gdnative_library_editor_plugin.cpp
index db90199e63..10ddd79d3a 100644
--- a/modules/gdnative/gdnative_library_editor_plugin.cpp
+++ b/modules/gdnative/gdnative_library_editor_plugin.cpp
@@ -77,9 +77,9 @@ void GDNativeLibraryEditor::_update_tree() {
platform->set_text(0, E->get().name);
platform->set_metadata(0, E->get().library_extension);
- platform->set_custom_bg_color(0, get_color("prop_category", "Editor"));
- platform->set_custom_bg_color(1, get_color("prop_category", "Editor"));
- platform->set_custom_bg_color(2, get_color("prop_category", "Editor"));
+ platform->set_custom_bg_color(0, get_theme_color("prop_category", "Editor"));
+ platform->set_custom_bg_color(1, get_theme_color("prop_category", "Editor"));
+ platform->set_custom_bg_color(2, get_theme_color("prop_category", "Editor"));
platform->set_selectable(0, false);
platform->set_expand_right(0, true);
@@ -91,35 +91,35 @@ void GDNativeLibraryEditor::_update_tree() {
bit->set_text(0, it->get());
bit->set_metadata(0, target);
bit->set_selectable(0, false);
- bit->set_custom_bg_color(0, get_color("prop_subsection", "Editor"));
+ bit->set_custom_bg_color(0, get_theme_color("prop_subsection", "Editor"));
- bit->add_button(1, get_icon("Folder", "EditorIcons"), BUTTON_SELECT_LIBRARY, false, TTR("Select the dynamic library for this entry"));
+ bit->add_button(1, get_theme_icon("Folder", "EditorIcons"), BUTTON_SELECT_LIBRARY, false, TTR("Select the dynamic library for this entry"));
String file = entry_configs[target].library;
if (!file.empty()) {
- bit->add_button(1, get_icon("Clear", "EditorIcons"), BUTTON_CLEAR_LIBRARY, false, TTR("Clear"));
+ bit->add_button(1, get_theme_icon("Clear", "EditorIcons"), BUTTON_CLEAR_LIBRARY, false, TTR("Clear"));
}
bit->set_text(1, file);
- bit->add_button(2, get_icon("Folder", "EditorIcons"), BUTTON_SELECT_DEPENDENCES, false, TTR("Select dependencies of the library for this entry"));
+ bit->add_button(2, get_theme_icon("Folder", "EditorIcons"), BUTTON_SELECT_DEPENDENCES, false, TTR("Select dependencies of the library for this entry"));
Array files = entry_configs[target].dependencies;
if (files.size()) {
- bit->add_button(2, get_icon("Clear", "EditorIcons"), BUTTON_CLEAR_DEPENDENCES, false, TTR("Clear"));
+ bit->add_button(2, get_theme_icon("Clear", "EditorIcons"), BUTTON_CLEAR_DEPENDENCES, false, TTR("Clear"));
}
bit->set_text(2, Variant(files));
- bit->add_button(3, get_icon("MoveUp", "EditorIcons"), BUTTON_MOVE_UP, false, TTR("Move Up"));
- bit->add_button(3, get_icon("MoveDown", "EditorIcons"), BUTTON_MOVE_DOWN, false, TTR("Move Down"));
- bit->add_button(3, get_icon("Remove", "EditorIcons"), BUTTON_ERASE_ENTRY, false, TTR("Remove current entry"));
+ bit->add_button(3, get_theme_icon("MoveUp", "EditorIcons"), BUTTON_MOVE_UP, false, TTR("Move Up"));
+ bit->add_button(3, get_theme_icon("MoveDown", "EditorIcons"), BUTTON_MOVE_DOWN, false, TTR("Move Down"));
+ bit->add_button(3, get_theme_icon("Remove", "EditorIcons"), BUTTON_ERASE_ENTRY, false, TTR("Remove current entry"));
}
TreeItem *new_arch = tree->create_item(platform);
new_arch->set_text(0, TTR("Double click to create a new entry"));
new_arch->set_text_align(0, TreeItem::ALIGN_CENTER);
- new_arch->set_custom_color(0, get_color("accent_color", "Editor"));
+ new_arch->set_custom_color(0, get_theme_color("accent_color", "Editor"));
new_arch->set_expand_right(0, true);
new_arch->set_metadata(1, E->key());
- platform->set_collapsed(collapsed_items.find(E->get().name) != NULL);
+ platform->set_collapsed(collapsed_items.find(E->get().name) != nullptr);
}
filter->set_text(text);
}
@@ -133,15 +133,15 @@ void GDNativeLibraryEditor::_on_item_button(Object *item, int column, int id) {
if (id == BUTTON_SELECT_LIBRARY || id == BUTTON_SELECT_DEPENDENCES) {
- EditorFileDialog::Mode mode = EditorFileDialog::MODE_OPEN_FILE;
+ EditorFileDialog::FileMode mode = EditorFileDialog::FILE_MODE_OPEN_FILE;
if (id == BUTTON_SELECT_DEPENDENCES)
- mode = EditorFileDialog::MODE_OPEN_FILES;
+ mode = EditorFileDialog::FILE_MODE_OPEN_FILES;
file_dialog->set_meta("target", target);
file_dialog->set_meta("section", section);
file_dialog->clear_filters();
file_dialog->add_filter(Object::cast_to<TreeItem>(item)->get_parent()->get_metadata(0));
- file_dialog->set_mode(mode);
+ file_dialog->set_file_mode(mode);
file_dialog->popup_centered_ratio();
} else if (id == BUTTON_CLEAR_LIBRARY) {
@@ -372,7 +372,7 @@ GDNativeLibraryEditor::GDNativeLibraryEditor() {
file_dialog = memnew(EditorFileDialog);
file_dialog->set_access(EditorFileDialog::ACCESS_RESOURCES);
- file_dialog->set_resizable(true);
+ //file_dialog->set_resizable(true);
add_child(file_dialog);
file_dialog->connect("file_selected", callable_mp(this, &GDNativeLibraryEditor::_on_library_selected));
file_dialog->connect("files_selected", callable_mp(this, &GDNativeLibraryEditor::_on_dependencies_selected));
@@ -382,7 +382,7 @@ GDNativeLibraryEditor::GDNativeLibraryEditor() {
new_architecture_dialog->set_title(TTR("Add an architecture entry"));
new_architecture_input = memnew(LineEdit);
new_architecture_dialog->add_child(new_architecture_input);
- new_architecture_dialog->set_custom_minimum_size(Vector2(300, 80) * EDSCALE);
+ // new_architecture_dialog->set_custom_minimum_size(Vector2(300, 80) * EDSCALE);
new_architecture_input->set_anchors_and_margins_preset(PRESET_HCENTER_WIDE, PRESET_MODE_MINSIZE, 5 * EDSCALE);
new_architecture_dialog->get_ok()->connect("pressed", callable_mp(this, &GDNativeLibraryEditor::_on_create_new_entry));
}
diff --git a/modules/gdnative/include/nativescript/godot_nativescript.h b/modules/gdnative/include/nativescript/godot_nativescript.h
index 1b131c8cf0..0fb5180103 100644
--- a/modules/gdnative/include/nativescript/godot_nativescript.h
+++ b/modules/gdnative/include/nativescript/godot_nativescript.h
@@ -54,7 +54,6 @@ typedef enum {
GODOT_PROPERTY_HINT_ENUM, ///< hint_text= "val1,val2,val3,etc"
GODOT_PROPERTY_HINT_EXP_EASING, /// exponential easing function (Math::ease)
GODOT_PROPERTY_HINT_LENGTH, ///< hint_text= "length" (as integer)
- GODOT_PROPERTY_HINT_SPRITE_FRAME, // FIXME: Obsolete: drop whenever we can break compat
GODOT_PROPERTY_HINT_KEY_ACCEL, ///< hint_text= "length" (as integer)
GODOT_PROPERTY_HINT_FLAGS, ///< hint_text= "flag1,flag2,etc" (as bit flags)
GODOT_PROPERTY_HINT_LAYERS_2D_RENDER,
@@ -96,8 +95,7 @@ typedef enum {
GODOT_PROPERTY_USAGE_INTERNATIONALIZED = 64, //hint for internationalized strings
GODOT_PROPERTY_USAGE_GROUP = 128, //used for grouping props in the editor
GODOT_PROPERTY_USAGE_CATEGORY = 256,
- GODOT_PROPERTY_USAGE_STORE_IF_NONZERO = 512, // FIXME: Obsolete: drop whenever we can break compat
- GODOT_PROPERTY_USAGE_STORE_IF_NONONE = 1024, // FIXME: Obsolete: drop whenever we can break compat
+ GODOT_PROPERTY_USAGE_SUBGROUP = 512,
GODOT_PROPERTY_USAGE_NO_INSTANCE_STATE = 2048,
GODOT_PROPERTY_USAGE_RESTART_IF_CHANGED = 4096,
GODOT_PROPERTY_USAGE_SCRIPT_VARIABLE = 8192,
diff --git a/modules/gdnative/include/pluginscript/godot_pluginscript.h b/modules/gdnative/include/pluginscript/godot_pluginscript.h
index 341e7f9e2b..406c3ba663 100644
--- a/modules/gdnative/include/pluginscript/godot_pluginscript.h
+++ b/modules/gdnative/include/pluginscript/godot_pluginscript.h
@@ -60,7 +60,7 @@ typedef struct {
//this is used by script languages that keep a reference counter of their own
//you can make make Ref<> not die when it reaches zero, so deleting the reference
//depends entirely from the script.
- // Note: You can set those function pointer to NULL if not needed.
+ // Note: You can set those function pointer to nullptr if not needed.
void (*refcount_incremented)(godot_pluginscript_instance_data *p_data);
bool (*refcount_decremented)(godot_pluginscript_instance_data *p_data); // return true if it can die
} godot_pluginscript_instance_desc;
@@ -119,18 +119,18 @@ typedef struct {
const char *name;
const char *type;
const char *extension;
- const char **recognized_extensions; // NULL terminated array
+ const char **recognized_extensions; // nullptr terminated array
godot_pluginscript_language_data *(*init)();
void (*finish)(godot_pluginscript_language_data *p_data);
- const char **reserved_words; // NULL terminated array
- const char **comment_delimiters; // NULL terminated array
- const char **string_delimiters; // NULL terminated array
+ const char **reserved_words; // nullptr terminated array
+ const char **comment_delimiters; // nullptr terminated array
+ const char **string_delimiters; // nullptr terminated array
godot_bool has_named_classes;
godot_bool supports_builtin_mode;
godot_string (*get_template_source_code)(godot_pluginscript_language_data *p_data, const godot_string *p_class_name, const godot_string *p_base_class_name);
godot_bool (*validate)(godot_pluginscript_language_data *p_data, const godot_string *p_script, int *r_line_error, int *r_col_error, godot_string *r_test_error, const godot_string *p_path, godot_packed_string_array *r_functions);
- int (*find_function)(godot_pluginscript_language_data *p_data, const godot_string *p_function, const godot_string *p_code); // Can be NULL
+ int (*find_function)(godot_pluginscript_language_data *p_data, const godot_string *p_function, const godot_string *p_code); // Can be nullptr
godot_string (*make_function)(godot_pluginscript_language_data *p_data, const godot_string *p_class, const godot_string *p_name, const godot_packed_string_array *p_args);
godot_error (*complete_code)(godot_pluginscript_language_data *p_data, const godot_string *p_code, const godot_string *p_path, godot_object *p_owner, godot_array *r_options, godot_bool *r_force, godot_string *r_call_hint);
void (*auto_indent_code)(godot_pluginscript_language_data *p_data, godot_string *p_code, int p_from_line, int p_to_line);
diff --git a/modules/gdnative/include/arvr/godot_arvr.h b/modules/gdnative/include/xr/godot_xr.h
index aaef31a855..22f7f021c4 100644
--- a/modules/gdnative/include/arvr/godot_arvr.h
+++ b/modules/gdnative/include/xr/godot_xr.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* godot_arvr.h */
+/* godot_xr.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef GODOT_NATIVEARVR_H
-#define GODOT_NATIVEARVR_H
+#ifndef GODOT_NATIVEXR_H
+#define GODOT_NATIVEXR_H
#include <gdnative/gdnative.h>
@@ -61,32 +61,31 @@ typedef struct {
void (*fill_projection_for_eye)(void *, godot_real *, godot_int, godot_real, godot_real, godot_real);
void (*commit_for_eye)(void *, godot_int, godot_rid *, godot_rect2 *);
void (*process)(void *);
- // only in 1.1 onwards
godot_int (*get_external_texture_for_eye)(void *, godot_int);
void (*notification)(void *, godot_int);
godot_int (*get_camera_feed_id)(void *);
-} godot_arvr_interface_gdnative;
+} godot_xr_interface_gdnative;
-void GDAPI godot_arvr_register_interface(const godot_arvr_interface_gdnative *p_interface);
+void GDAPI godot_xr_register_interface(const godot_xr_interface_gdnative *p_interface);
-// helper functions to access ARVRServer data
-godot_real GDAPI godot_arvr_get_worldscale();
-godot_transform GDAPI godot_arvr_get_reference_frame();
+// helper functions to access XRServer data
+godot_real GDAPI godot_xr_get_worldscale();
+godot_transform GDAPI godot_xr_get_reference_frame();
// helper functions for rendering
-void GDAPI godot_arvr_blit(godot_int p_eye, godot_rid *p_render_target, godot_rect2 *p_rect);
-godot_int GDAPI godot_arvr_get_texid(godot_rid *p_render_target);
+void GDAPI godot_xr_blit(godot_int p_eye, godot_rid *p_render_target, godot_rect2 *p_rect);
+godot_int GDAPI godot_xr_get_texid(godot_rid *p_render_target);
-// helper functions for updating ARVR controllers
-godot_int GDAPI godot_arvr_add_controller(char *p_device_name, godot_int p_hand, godot_bool p_tracks_orientation, godot_bool p_tracks_position);
-void GDAPI godot_arvr_remove_controller(godot_int p_controller_id);
-void GDAPI godot_arvr_set_controller_transform(godot_int p_controller_id, godot_transform *p_transform, godot_bool p_tracks_orientation, godot_bool p_tracks_position);
-void GDAPI godot_arvr_set_controller_button(godot_int p_controller_id, godot_int p_button, godot_bool p_is_pressed);
-void GDAPI godot_arvr_set_controller_axis(godot_int p_controller_id, godot_int p_axis, godot_real p_value, godot_bool p_can_be_negative);
-godot_real GDAPI godot_arvr_get_controller_rumble(godot_int p_controller_id);
+// helper functions for updating XR controllers
+godot_int GDAPI godot_xr_add_controller(char *p_device_name, godot_int p_hand, godot_bool p_tracks_orientation, godot_bool p_tracks_position);
+void GDAPI godot_xr_remove_controller(godot_int p_controller_id);
+void GDAPI godot_xr_set_controller_transform(godot_int p_controller_id, godot_transform *p_transform, godot_bool p_tracks_orientation, godot_bool p_tracks_position);
+void GDAPI godot_xr_set_controller_button(godot_int p_controller_id, godot_int p_button, godot_bool p_is_pressed);
+void GDAPI godot_xr_set_controller_axis(godot_int p_controller_id, godot_int p_axis, godot_real p_value, godot_bool p_can_be_negative);
+godot_real GDAPI godot_xr_get_controller_rumble(godot_int p_controller_id);
#ifdef __cplusplus
}
#endif
-#endif /* !GODOT_NATIVEARVR_H */
+#endif /* !GODOT_NATIVEXR_H */
diff --git a/modules/gdnative/nativescript/SCsub b/modules/gdnative/nativescript/SCsub
index 92c9d6630d..4212e87a87 100644
--- a/modules/gdnative/nativescript/SCsub
+++ b/modules/gdnative/nativescript/SCsub
@@ -1,9 +1,9 @@
#!/usr/bin/env python
-Import('env')
-Import('env_gdnative')
+Import("env")
+Import("env_gdnative")
-env_gdnative.add_source_files(env.modules_sources, '*.cpp')
+env_gdnative.add_source_files(env.modules_sources, "*.cpp")
-if "platform" in env and env["platform"] in ["x11", "iphone"]:
+if "platform" in env and env["platform"] in ["linuxbsd", "iphone"]:
env.Append(LINKFLAGS=["-rdynamic"])
diff --git a/modules/gdnative/nativescript/api_generator.cpp b/modules/gdnative/nativescript/api_generator.cpp
index 11fe746e90..3c0cfd0484 100644
--- a/modules/gdnative/nativescript/api_generator.cpp
+++ b/modules/gdnative/nativescript/api_generator.cpp
@@ -46,7 +46,7 @@ static Error save_file(const String &p_path, const List<String> &p_content) {
ERR_FAIL_COND_V(!file, ERR_FILE_CANT_WRITE);
- for (const List<String>::Element *e = p_content.front(); e != NULL; e = e->next()) {
+ for (const List<String>::Element *e = p_content.front(); e != nullptr; e = e->next()) {
file->store_string(e->get());
}
@@ -197,7 +197,7 @@ List<ClassAPI> generate_c_api_classes() {
api.push_back(global_constants_api);
}
- for (List<StringName>::Element *e = classes.front(); e != NULL; e = e->next()) {
+ for (List<StringName>::Element *e = classes.front(); e != nullptr; e = e->next()) {
StringName class_name = e->get();
ClassAPI class_api;
@@ -229,7 +229,7 @@ List<ClassAPI> generate_c_api_classes() {
List<String> constant;
ClassDB::get_integer_constant_list(class_name, &constant, true);
constant.sort_custom<NoCaseComparator>();
- for (List<String>::Element *c = constant.front(); c != NULL; c = c->next()) {
+ for (List<String>::Element *c = constant.front(); c != nullptr; c = c->next()) {
ConstantAPI constant_api;
constant_api.constant_name = c->get();
constant_api.constant_value = ClassDB::get_integer_constant(class_name, c->get());
@@ -284,7 +284,7 @@ List<ClassAPI> generate_c_api_classes() {
ClassDB::get_property_list(class_name, &properties, true);
properties.sort_custom<PropertyInfoComparator>();
- for (List<PropertyInfo>::Element *p = properties.front(); p != NULL; p = p->next()) {
+ for (List<PropertyInfo>::Element *p = properties.front(); p != nullptr; p = p->next()) {
PropertyAPI property_api;
property_api.name = p->get().name;
@@ -312,7 +312,7 @@ List<ClassAPI> generate_c_api_classes() {
ClassDB::get_method_list(class_name, &methods, true);
methods.sort_custom<MethodInfoComparator>();
- for (List<MethodInfo>::Element *m = methods.front(); m != NULL; m = m->next()) {
+ for (List<MethodInfo>::Element *m = methods.front(); m != nullptr; m = m->next()) {
MethodAPI method_api;
MethodBind *method_bind = ClassDB::get_method(class_name, m->get().name);
MethodInfo &method_info = m->get();
@@ -392,7 +392,7 @@ List<ClassAPI> generate_c_api_classes() {
enum_api.name = E->get();
ClassDB::get_enum_constants(class_name, E->get(), &value_names, true);
for (List<StringName>::Element *val_e = value_names.front(); val_e; val_e = val_e->next()) {
- int int_val = ClassDB::get_integer_constant(class_name, val_e->get(), NULL);
+ int int_val = ClassDB::get_integer_constant(class_name, val_e->get(), nullptr);
enum_api.values.push_back(Pair<int, String>(int_val, val_e->get()));
}
enum_api.values.sort_custom<PairSort<int, String>>();
@@ -417,7 +417,7 @@ static List<String> generate_c_api_json(const List<ClassAPI> &p_api) {
source.push_back("[\n");
- for (const List<ClassAPI>::Element *c = p_api.front(); c != NULL; c = c->next()) {
+ for (const List<ClassAPI>::Element *c = p_api.front(); c != nullptr; c = c->next()) {
ClassAPI api = c->get();
source.push_back("\t{\n");
diff --git a/modules/gdnative/nativescript/godot_nativescript.cpp b/modules/gdnative/nativescript/godot_nativescript.cpp
index f953206a34..0502458b4f 100644
--- a/modules/gdnative/nativescript/godot_nativescript.cpp
+++ b/modules/gdnative/nativescript/godot_nativescript.cpp
@@ -77,7 +77,7 @@ void GDAPI godot_nativescript_register_class(void *p_gdnative_handle, const char
}
} else {
- desc.base_data = NULL;
+ desc.base_data = nullptr;
desc.base_native_type = p_base;
}
@@ -111,7 +111,7 @@ void GDAPI godot_nativescript_register_tool_class(void *p_gdnative_handle, const
}
} else {
- desc.base_data = NULL;
+ desc.base_data = nullptr;
desc.base_native_type = p_base;
}
@@ -210,11 +210,11 @@ void GDAPI godot_nativescript_register_signal(void *p_gdnative_handle, const cha
void GDAPI *godot_nativescript_get_userdata(godot_object *p_instance) {
Object *instance = (Object *)p_instance;
if (!instance)
- return NULL;
+ return nullptr;
if (instance->get_script_instance() && instance->get_script_instance()->get_language() == NativeScriptLanguage::get_singleton()) {
return ((NativeScriptInstance *)instance->get_script_instance())->userdata;
}
- return NULL;
+ return nullptr;
}
/*
@@ -319,18 +319,18 @@ const void GDAPI *godot_nativescript_get_type_tag(const godot_object *p_object)
const Object *o = (Object *)p_object;
if (!o->get_script_instance()) {
- return NULL;
+ return nullptr;
} else {
NativeScript *script = Object::cast_to<NativeScript>(o->get_script_instance()->get_script().ptr());
if (!script) {
- return NULL;
+ return nullptr;
}
if (script->get_script_desc())
return script->get_script_desc()->type_tag;
}
- return NULL;
+ return nullptr;
}
int GDAPI godot_nativescript_register_instance_binding_data_functions(godot_instance_binding_functions p_binding_functions) {
diff --git a/modules/gdnative/nativescript/nativescript.cpp b/modules/gdnative/nativescript/nativescript.cpp
index fb88479ca3..ed3ec44bf7 100644
--- a/modules/gdnative/nativescript/nativescript.cpp
+++ b/modules/gdnative/nativescript/nativescript.cpp
@@ -111,6 +111,13 @@ void NativeScript::_placeholder_erased(PlaceHolderScriptInstance *p_placeholder)
#endif
+bool NativeScript::inherits_script(const Ref<Script> &p_script) const {
+#ifndef _MSC_VER
+#warning inheritance needs to be implemented in NativeScript
+#endif
+ return false;
+}
+
void NativeScript::set_class_name(String p_class_name) {
class_name = p_class_name;
}
@@ -204,7 +211,7 @@ ScriptInstance *NativeScript::instance_create(Object *p_this) {
NativeScriptDesc *script_data = get_script_desc();
if (!script_data) {
- return NULL;
+ return nullptr;
}
NativeScriptInstance *nsi = memnew(NativeScriptInstance);
@@ -214,7 +221,7 @@ ScriptInstance *NativeScript::instance_create(Object *p_this) {
#ifndef TOOLS_ENABLED
if (!ScriptServer::is_scripting_enabled()) {
- nsi->userdata = NULL;
+ nsi->userdata = nullptr;
} else {
nsi->userdata = script_data->create_func.create_func((godot_object *)p_this, script_data->create_func.method_data);
}
@@ -240,7 +247,7 @@ PlaceHolderScriptInstance *NativeScript::placeholder_instance_create(Object *p_t
return sins;
#else
- return NULL;
+ return nullptr;
#endif
}
@@ -738,7 +745,7 @@ Variant NativeScript::_new(const Variant **p_args, int p_argcount, Callable::Cal
r_error.error = Callable::CallError::CALL_OK;
REF ref;
- Object *owner = NULL;
+ Object *owner = nullptr;
if (!(script_data->base_native_type == "")) {
owner = ClassDB::instance(script_data->base_native_type);
@@ -886,7 +893,7 @@ void NativeScriptInstance::get_property_list(List<PropertyInfo> *p_properties) c
E->get().method.method_data,
userdata,
0,
- NULL);
+ nullptr);
Variant res = *(Variant *)&result;
godot_variant_destroy(&result);
@@ -1007,7 +1014,7 @@ void NativeScriptInstance::notification(int p_notification) {
String NativeScriptInstance::to_string(bool *r_valid) {
if (has_method(CoreStringNames::get_singleton()->_to_string)) {
Callable::CallError ce;
- Variant ret = call(CoreStringNames::get_singleton()->_to_string, NULL, 0, ce);
+ Variant ret = call(CoreStringNames::get_singleton()->_to_string, nullptr, 0, ce);
if (ce.error == Callable::CallError::CALL_OK) {
if (ret.get_type() != Variant::STRING) {
if (r_valid)
@@ -1026,7 +1033,7 @@ String NativeScriptInstance::to_string(bool *r_valid) {
void NativeScriptInstance::refcount_incremented() {
Callable::CallError err;
- call("_refcount_incremented", NULL, 0, err);
+ call("_refcount_incremented", nullptr, 0, err);
if (err.error != Callable::CallError::CALL_OK && err.error != Callable::CallError::CALL_ERROR_INVALID_METHOD) {
ERR_PRINT("Failed to invoke _refcount_incremented - should not happen");
}
@@ -1034,7 +1041,7 @@ void NativeScriptInstance::refcount_incremented() {
bool NativeScriptInstance::refcount_decremented() {
Callable::CallError err;
- Variant ret = call("_refcount_decremented", NULL, 0, err);
+ Variant ret = call("_refcount_decremented", nullptr, 0, err);
if (err.error != Callable::CallError::CALL_OK && err.error != Callable::CallError::CALL_ERROR_INVALID_METHOD) {
ERR_PRINT("Failed to invoke _refcount_decremented - should not happen");
return true; // assume we can destroy the object
@@ -1525,14 +1532,14 @@ void NativeScriptLanguage::unregister_binding_functions(int p_idx) {
}
void *NativeScriptLanguage::get_instance_binding_data(int p_idx, Object *p_object) {
- ERR_FAIL_INDEX_V(p_idx, binding_functions.size(), NULL);
+ ERR_FAIL_INDEX_V(p_idx, binding_functions.size(), nullptr);
- ERR_FAIL_COND_V_MSG(!binding_functions[p_idx].first, NULL, "Tried to get binding data for a nativescript binding that does not exist.");
+ ERR_FAIL_COND_V_MSG(!binding_functions[p_idx].first, nullptr, "Tried to get binding data for a nativescript binding that does not exist.");
Vector<void *> *binding_data = (Vector<void *> *)p_object->get_script_instance_binding(lang_idx);
if (!binding_data)
- return NULL; // should never happen.
+ return nullptr; // should never happen.
if (binding_data->size() <= p_idx) {
// okay, add new elements here.
@@ -1541,7 +1548,7 @@ void *NativeScriptLanguage::get_instance_binding_data(int p_idx, Object *p_objec
binding_data->resize(p_idx + 1);
for (int i = old_size; i <= p_idx; i++) {
- (*binding_data).write[i] = NULL;
+ (*binding_data).write[i] = nullptr;
}
}
@@ -1563,7 +1570,7 @@ void *NativeScriptLanguage::alloc_instance_binding_data(Object *p_object) {
binding_data->resize(binding_functions.size());
for (int i = 0; i < binding_functions.size(); i++) {
- (*binding_data).write[i] = NULL;
+ (*binding_data).write[i] = nullptr;
}
binding_instances.insert(binding_data);
@@ -1652,12 +1659,12 @@ void NativeScriptLanguage::set_global_type_tag(int p_idx, StringName p_class_nam
const void *NativeScriptLanguage::get_global_type_tag(int p_idx, StringName p_class_name) const {
if (!global_type_tags.has(p_idx))
- return NULL;
+ return nullptr;
const HashMap<StringName, const void *> &tags = global_type_tags[p_idx];
if (!tags.has(p_class_name))
- return NULL;
+ return nullptr;
const void *tag = tags.get(p_class_name);
@@ -1827,7 +1834,7 @@ void NativeReloadNode::_notification(int p_what) {
#ifdef TOOLS_ENABLED
switch (p_what) {
- case MainLoop::NOTIFICATION_WM_FOCUS_OUT: {
+ case NOTIFICATION_WM_FOCUS_OUT: {
if (unloaded)
break;
@@ -1862,7 +1869,7 @@ void NativeReloadNode::_notification(int p_what) {
} break;
- case MainLoop::NOTIFICATION_WM_FOCUS_IN: {
+ case NOTIFICATION_WM_FOCUS_IN: {
if (!unloaded)
break;
@@ -1931,7 +1938,7 @@ void NativeReloadNode::_notification(int p_what) {
#endif
}
-RES ResourceFormatLoaderNativeScript::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress) {
+RES ResourceFormatLoaderNativeScript::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, bool p_no_cache) {
return ResourceFormatLoaderText::singleton->load(p_path, p_original_path, r_error);
}
@@ -1956,7 +1963,7 @@ Error ResourceFormatSaverNativeScript::save(const String &p_path, const RES &p_r
}
bool ResourceFormatSaverNativeScript::recognize(const RES &p_resource) const {
- return Object::cast_to<NativeScript>(*p_resource) != NULL;
+ return Object::cast_to<NativeScript>(*p_resource) != nullptr;
}
void ResourceFormatSaverNativeScript::get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const {
diff --git a/modules/gdnative/nativescript/nativescript.h b/modules/gdnative/nativescript/nativescript.h
index aba3f6b2d0..7e7598e06c 100644
--- a/modules/gdnative/nativescript/nativescript.h
+++ b/modules/gdnative/nativescript/nativescript.h
@@ -95,7 +95,7 @@ struct NativeScriptDesc {
base(),
base_native_type(),
documentation(),
- type_tag(NULL) {
+ type_tag(nullptr) {
zeromem(&create_func, sizeof(godot_instance_create_func));
zeromem(&destroy_func, sizeof(godot_instance_destroy_func));
}
@@ -133,6 +133,8 @@ protected:
public:
inline NativeScriptDesc *get_script_desc() const;
+ bool inherits_script(const Ref<Script> &p_script) const;
+
void set_class_name(String p_class_name);
String get_class_name() const;
@@ -341,7 +343,7 @@ public:
virtual void get_comment_delimiters(List<String> *p_delimiters) const;
virtual void get_string_delimiters(List<String> *p_delimiters) const;
virtual Ref<Script> get_template(const String &p_class_name, const String &p_base_class_name) const;
- virtual bool validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path, List<String> *r_functions, List<ScriptLanguage::Warning> *r_warnings = NULL, Set<int> *r_safe_lines = NULL) const;
+ virtual bool validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path, List<String> *r_functions, List<ScriptLanguage::Warning> *r_warnings = nullptr, Set<int> *r_safe_lines = nullptr) const;
virtual Script *create_script() const;
virtual bool has_named_classes() const;
virtual bool supports_builtin_mode() const;
@@ -389,7 +391,7 @@ public:
inline NativeScriptDesc *NativeScript::get_script_desc() const {
Map<StringName, NativeScriptDesc>::Element *E = NativeScriptLanguage::singleton->library_classes[lib_path].find(class_name);
- return E ? &E->get() : NULL;
+ return E ? &E->get() : nullptr;
}
class NativeReloadNode : public Node {
@@ -406,7 +408,7 @@ public:
class ResourceFormatLoaderNativeScript : public ResourceFormatLoader {
public:
- virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL, bool p_use_sub_threads = false, float *r_progress = nullptr);
+ virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr, bool p_no_cache = false);
virtual void get_recognized_extensions(List<String> *p_extensions) const;
virtual bool handles_type(const String &p_type) const;
virtual String get_resource_type(const String &p_path) const;
diff --git a/modules/gdnative/net/SCsub b/modules/gdnative/net/SCsub
index 18ab9986b0..b76500c003 100644
--- a/modules/gdnative/net/SCsub
+++ b/modules/gdnative/net/SCsub
@@ -1,13 +1,12 @@
#!/usr/bin/env python
-Import('env')
-Import('env_gdnative')
+Import("env")
+Import("env_gdnative")
env_net = env_gdnative.Clone()
has_webrtc = env_net["module_webrtc_enabled"]
if has_webrtc:
- env_net.Append(CPPDEFINES=['WEBRTC_GDNATIVE_ENABLED'])
-
-env_net.add_source_files(env.modules_sources, '*.cpp')
+ env_net.Append(CPPDEFINES=["WEBRTC_GDNATIVE_ENABLED"])
+env_net.add_source_files(env.modules_sources, "*.cpp")
diff --git a/modules/gdnative/net/multiplayer_peer_gdnative.cpp b/modules/gdnative/net/multiplayer_peer_gdnative.cpp
index 8c43a79cc5..a95697ea65 100644
--- a/modules/gdnative/net/multiplayer_peer_gdnative.cpp
+++ b/modules/gdnative/net/multiplayer_peer_gdnative.cpp
@@ -31,7 +31,7 @@
#include "multiplayer_peer_gdnative.h"
MultiplayerPeerGDNative::MultiplayerPeerGDNative() {
- interface = NULL;
+ interface = nullptr;
}
MultiplayerPeerGDNative::~MultiplayerPeerGDNative() {
@@ -42,73 +42,73 @@ void MultiplayerPeerGDNative::set_native_multiplayer_peer(const godot_net_multip
}
Error MultiplayerPeerGDNative::get_packet(const uint8_t **r_buffer, int &r_buffer_size) {
- ERR_FAIL_COND_V(interface == NULL, ERR_UNCONFIGURED);
+ ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED);
return (Error)interface->get_packet(interface->data, r_buffer, &r_buffer_size);
}
Error MultiplayerPeerGDNative::put_packet(const uint8_t *p_buffer, int p_buffer_size) {
- ERR_FAIL_COND_V(interface == NULL, ERR_UNCONFIGURED);
+ ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED);
return (Error)interface->put_packet(interface->data, p_buffer, p_buffer_size);
}
int MultiplayerPeerGDNative::get_max_packet_size() const {
- ERR_FAIL_COND_V(interface == NULL, 0);
+ ERR_FAIL_COND_V(interface == nullptr, 0);
return interface->get_max_packet_size(interface->data);
}
int MultiplayerPeerGDNative::get_available_packet_count() const {
- ERR_FAIL_COND_V(interface == NULL, 0);
+ ERR_FAIL_COND_V(interface == nullptr, 0);
return interface->get_available_packet_count(interface->data);
}
/* NetworkedMultiplayerPeer */
void MultiplayerPeerGDNative::set_transfer_mode(TransferMode p_mode) {
- ERR_FAIL_COND(interface == NULL);
+ ERR_FAIL_COND(interface == nullptr);
interface->set_transfer_mode(interface->data, (godot_int)p_mode);
}
NetworkedMultiplayerPeer::TransferMode MultiplayerPeerGDNative::get_transfer_mode() const {
- ERR_FAIL_COND_V(interface == NULL, TRANSFER_MODE_UNRELIABLE);
+ ERR_FAIL_COND_V(interface == nullptr, TRANSFER_MODE_UNRELIABLE);
return (TransferMode)interface->get_transfer_mode(interface->data);
}
void MultiplayerPeerGDNative::set_target_peer(int p_peer_id) {
- ERR_FAIL_COND(interface == NULL);
+ ERR_FAIL_COND(interface == nullptr);
interface->set_target_peer(interface->data, p_peer_id);
}
int MultiplayerPeerGDNative::get_packet_peer() const {
- ERR_FAIL_COND_V(interface == NULL, 0);
+ ERR_FAIL_COND_V(interface == nullptr, 0);
return interface->get_packet_peer(interface->data);
}
bool MultiplayerPeerGDNative::is_server() const {
- ERR_FAIL_COND_V(interface == NULL, false);
+ ERR_FAIL_COND_V(interface == nullptr, false);
return interface->is_server(interface->data);
}
void MultiplayerPeerGDNative::poll() {
- ERR_FAIL_COND(interface == NULL);
+ ERR_FAIL_COND(interface == nullptr);
interface->poll(interface->data);
}
int MultiplayerPeerGDNative::get_unique_id() const {
- ERR_FAIL_COND_V(interface == NULL, 0);
+ ERR_FAIL_COND_V(interface == nullptr, 0);
return interface->get_unique_id(interface->data);
}
void MultiplayerPeerGDNative::set_refuse_new_connections(bool p_enable) {
- ERR_FAIL_COND(interface == NULL);
+ ERR_FAIL_COND(interface == nullptr);
interface->set_refuse_new_connections(interface->data, p_enable);
}
bool MultiplayerPeerGDNative::is_refusing_new_connections() const {
- ERR_FAIL_COND_V(interface == NULL, true);
+ ERR_FAIL_COND_V(interface == nullptr, true);
return interface->is_refusing_new_connections(interface->data);
}
NetworkedMultiplayerPeer::ConnectionStatus MultiplayerPeerGDNative::get_connection_status() const {
- ERR_FAIL_COND_V(interface == NULL, CONNECTION_DISCONNECTED);
+ ERR_FAIL_COND_V(interface == nullptr, CONNECTION_DISCONNECTED);
return (ConnectionStatus)interface->get_connection_status(interface->data);
}
diff --git a/modules/gdnative/net/packet_peer_gdnative.cpp b/modules/gdnative/net/packet_peer_gdnative.cpp
index 75e1e0b824..28135df3b6 100644
--- a/modules/gdnative/net/packet_peer_gdnative.cpp
+++ b/modules/gdnative/net/packet_peer_gdnative.cpp
@@ -31,7 +31,7 @@
#include "packet_peer_gdnative.h"
PacketPeerGDNative::PacketPeerGDNative() {
- interface = NULL;
+ interface = nullptr;
}
PacketPeerGDNative::~PacketPeerGDNative() {
@@ -45,22 +45,22 @@ void PacketPeerGDNative::_bind_methods() {
}
Error PacketPeerGDNative::get_packet(const uint8_t **r_buffer, int &r_buffer_size) {
- ERR_FAIL_COND_V(interface == NULL, ERR_UNCONFIGURED);
+ ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED);
return (Error)interface->get_packet(interface->data, r_buffer, &r_buffer_size);
}
Error PacketPeerGDNative::put_packet(const uint8_t *p_buffer, int p_buffer_size) {
- ERR_FAIL_COND_V(interface == NULL, ERR_UNCONFIGURED);
+ ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED);
return (Error)interface->put_packet(interface->data, p_buffer, p_buffer_size);
}
int PacketPeerGDNative::get_max_packet_size() const {
- ERR_FAIL_COND_V(interface == NULL, 0);
+ ERR_FAIL_COND_V(interface == nullptr, 0);
return interface->get_max_packet_size(interface->data);
}
int PacketPeerGDNative::get_available_packet_count() const {
- ERR_FAIL_COND_V(interface == NULL, 0);
+ ERR_FAIL_COND_V(interface == nullptr, 0);
return interface->get_available_packet_count(interface->data);
}
diff --git a/modules/gdnative/net/stream_peer_gdnative.cpp b/modules/gdnative/net/stream_peer_gdnative.cpp
index 22634daf5f..9dcb184115 100644
--- a/modules/gdnative/net/stream_peer_gdnative.cpp
+++ b/modules/gdnative/net/stream_peer_gdnative.cpp
@@ -31,7 +31,7 @@
#include "stream_peer_gdnative.h"
StreamPeerGDNative::StreamPeerGDNative() {
- interface = NULL;
+ interface = nullptr;
}
StreamPeerGDNative::~StreamPeerGDNative() {
@@ -45,27 +45,27 @@ void StreamPeerGDNative::_bind_methods() {
}
Error StreamPeerGDNative::put_data(const uint8_t *p_data, int p_bytes) {
- ERR_FAIL_COND_V(interface == NULL, ERR_UNCONFIGURED);
+ ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED);
return (Error)(interface->put_data(interface->data, p_data, p_bytes));
}
Error StreamPeerGDNative::put_partial_data(const uint8_t *p_data, int p_bytes, int &r_sent) {
- ERR_FAIL_COND_V(interface == NULL, ERR_UNCONFIGURED);
+ ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED);
return (Error)(interface->put_partial_data(interface->data, p_data, p_bytes, &r_sent));
}
Error StreamPeerGDNative::get_data(uint8_t *p_buffer, int p_bytes) {
- ERR_FAIL_COND_V(interface == NULL, ERR_UNCONFIGURED);
+ ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED);
return (Error)(interface->get_data(interface->data, p_buffer, p_bytes));
}
Error StreamPeerGDNative::get_partial_data(uint8_t *p_buffer, int p_bytes, int &r_received) {
- ERR_FAIL_COND_V(interface == NULL, ERR_UNCONFIGURED);
+ ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED);
return (Error)(interface->get_partial_data(interface->data, p_buffer, p_bytes, &r_received));
}
int StreamPeerGDNative::get_available_bytes() const {
- ERR_FAIL_COND_V(interface == NULL, 0);
+ ERR_FAIL_COND_V(interface == nullptr, 0);
return interface->get_available_bytes(interface->data);
}
diff --git a/modules/gdnative/pluginscript/SCsub b/modules/gdnative/pluginscript/SCsub
index 20eaa99592..0b2db3b504 100644
--- a/modules/gdnative/pluginscript/SCsub
+++ b/modules/gdnative/pluginscript/SCsub
@@ -1,6 +1,6 @@
#!/usr/bin/env python
-Import('env')
-Import('env_gdnative')
+Import("env")
+Import("env_gdnative")
-env_gdnative.add_source_files(env.modules_sources, '*.cpp')
+env_gdnative.add_source_files(env.modules_sources, "*.cpp")
diff --git a/modules/gdnative/pluginscript/pluginscript_instance.cpp b/modules/gdnative/pluginscript/pluginscript_instance.cpp
index 22e8372130..7d17a7d5ab 100644
--- a/modules/gdnative/pluginscript/pluginscript_instance.cpp
+++ b/modules/gdnative/pluginscript/pluginscript_instance.cpp
@@ -156,7 +156,7 @@ bool PluginScriptInstance::init(PluginScript *p_script, Object *p_owner) {
_script = Ref<PluginScript>(p_script);
_desc = &p_script->_desc->instance_desc;
_data = _desc->init(p_script->_data, (godot_object *)p_owner);
- ERR_FAIL_COND_V(_data == NULL, false);
+ ERR_FAIL_COND_V(_data == nullptr, false);
p_owner->set_script_instance(this);
return true;
}
diff --git a/modules/gdnative/pluginscript/pluginscript_instance.h b/modules/gdnative/pluginscript/pluginscript_instance.h
index c91ad643a7..6309b6fde3 100644
--- a/modules/gdnative/pluginscript/pluginscript_instance.h
+++ b/modules/gdnative/pluginscript/pluginscript_instance.h
@@ -55,7 +55,7 @@ public:
virtual bool set(const StringName &p_name, const Variant &p_value);
virtual bool get(const StringName &p_name, Variant &r_ret) const;
virtual void get_property_list(List<PropertyInfo> *p_properties) const;
- virtual Variant::Type get_property_type(const StringName &p_name, bool *r_is_valid = NULL) const;
+ virtual Variant::Type get_property_type(const StringName &p_name, bool *r_is_valid = nullptr) const;
virtual void get_method_list(List<MethodInfo> *p_list) const;
virtual bool has_method(const StringName &p_method) const;
diff --git a/modules/gdnative/pluginscript/pluginscript_language.h b/modules/gdnative/pluginscript/pluginscript_language.h
index 809034744a..dd6758713f 100644
--- a/modules/gdnative/pluginscript/pluginscript_language.h
+++ b/modules/gdnative/pluginscript/pluginscript_language.h
@@ -74,7 +74,7 @@ public:
virtual void get_comment_delimiters(List<String> *p_delimiters) const;
virtual void get_string_delimiters(List<String> *p_delimiters) const;
virtual Ref<Script> get_template(const String &p_class_name, const String &p_base_class_name) const;
- virtual bool validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path = "", List<String> *r_functions = NULL, List<ScriptLanguage::Warning> *r_warnings = NULL, Set<int> *r_safe_lines = NULL) const;
+ virtual bool validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path = "", List<String> *r_functions = nullptr, List<ScriptLanguage::Warning> *r_warnings = nullptr, Set<int> *r_safe_lines = nullptr) const;
virtual Script *create_script() const;
virtual bool has_named_classes() const;
virtual bool supports_builtin_mode() const;
diff --git a/modules/gdnative/pluginscript/pluginscript_loader.cpp b/modules/gdnative/pluginscript/pluginscript_loader.cpp
index 46db20b6c2..64582cc517 100644
--- a/modules/gdnative/pluginscript/pluginscript_loader.cpp
+++ b/modules/gdnative/pluginscript/pluginscript_loader.cpp
@@ -39,7 +39,7 @@ ResourceFormatLoaderPluginScript::ResourceFormatLoaderPluginScript(PluginScriptL
_language = language;
}
-RES ResourceFormatLoaderPluginScript::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress) {
+RES ResourceFormatLoaderPluginScript::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, bool p_no_cache) {
if (r_error)
*r_error = ERR_FILE_CANT_OPEN;
@@ -109,5 +109,5 @@ void ResourceFormatSaverPluginScript::get_recognized_extensions(const RES &p_res
bool ResourceFormatSaverPluginScript::recognize(const RES &p_resource) const {
- return Object::cast_to<PluginScript>(*p_resource) != NULL;
+ return Object::cast_to<PluginScript>(*p_resource) != nullptr;
}
diff --git a/modules/gdnative/pluginscript/pluginscript_loader.h b/modules/gdnative/pluginscript/pluginscript_loader.h
index a039072fdc..e47754490a 100644
--- a/modules/gdnative/pluginscript/pluginscript_loader.h
+++ b/modules/gdnative/pluginscript/pluginscript_loader.h
@@ -44,7 +44,7 @@ class ResourceFormatLoaderPluginScript : public ResourceFormatLoader {
public:
ResourceFormatLoaderPluginScript(PluginScriptLanguage *language);
- virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL, bool p_use_sub_threads = false, float *r_progress = nullptr);
+ virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr, bool p_no_cache = false);
virtual void get_recognized_extensions(List<String> *p_extensions) const;
virtual bool handles_type(const String &p_type) const;
virtual String get_resource_type(const String &p_path) const;
diff --git a/modules/gdnative/pluginscript/pluginscript_script.cpp b/modules/gdnative/pluginscript/pluginscript_script.cpp
index b7cbedc51a..6b303c8716 100644
--- a/modules/gdnative/pluginscript/pluginscript_script.cpp
+++ b/modules/gdnative/pluginscript/pluginscript_script.cpp
@@ -69,7 +69,7 @@ PluginScriptInstance *PluginScript::_create_instance(const Variant **p_args, int
} else {
r_error.error = Callable::CallError::CALL_ERROR_INSTANCE_IS_NULL;
memdelete(instance);
- ERR_FAIL_V(NULL);
+ ERR_FAIL_V(nullptr);
}
// Construct
@@ -93,7 +93,7 @@ Variant PluginScript::_new(const Variant **p_args, int p_argcount, Callable::Cal
}
REF ref;
- Object *owner = NULL;
+ Object *owner = nullptr;
if (get_instance_base_type() == "") {
owner = memnew(Reference);
@@ -140,6 +140,13 @@ bool PluginScript::can_instance() const {
return can;
}
+bool PluginScript::inherits_script(const Ref<Script> &p_script) const {
+#ifndef _MSC_VER
+#warning inheritance needs to be implemented in PluginScript
+#endif
+ return false;
+}
+
Ref<Script> PluginScript::get_base_script() const {
if (_ref_base_parent.is_valid()) {
return Ref<PluginScript>(_ref_base_parent);
@@ -175,7 +182,7 @@ void PluginScript::update_exports() {
// TODO: rename p_this "p_owner" ?
ScriptInstance *PluginScript::instance_create(Object *p_this) {
- ASSERT_SCRIPT_VALID_V(NULL);
+ ASSERT_SCRIPT_VALID_V(nullptr);
// TODO check script validity ?
if (!_tool && !ScriptServer::is_scripting_enabled()) {
#ifdef TOOLS_ENABLED
@@ -185,7 +192,7 @@ ScriptInstance *PluginScript::instance_create(Object *p_this) {
update_exports();
return si;
#else
- return NULL;
+ return nullptr;
#endif
}
@@ -197,12 +204,12 @@ ScriptInstance *PluginScript::instance_create(Object *p_this) {
// if (EngineDebugger::is_active()) {
// _language->debug_break_parse(get_path(), 0, msg);
// }
- ERR_FAIL_V_MSG(NULL, msg);
+ ERR_FAIL_V_MSG(nullptr, msg);
}
}
Callable::CallError unchecked_error;
- return _create_instance(NULL, 0, p_this, unchecked_error);
+ return _create_instance(nullptr, 0, p_this, unchecked_error);
}
bool PluginScript::instance_has(const Object *p_this) const {
@@ -296,7 +303,7 @@ Error PluginScript::reload(bool p_keep_state) {
_tool = manifest.is_tool;
Dictionary *members = (Dictionary *)&manifest.member_lines;
- for (const Variant *key = members->next(); key != NULL; key = members->next(key)) {
+ for (const Variant *key = members->next(); key != nullptr; key = members->next(key)) {
_member_lines[*key] = (*members)[*key];
}
Array *methods = (Array *)&manifest.methods;
@@ -366,14 +373,14 @@ Error PluginScript::reload(bool p_keep_state) {
void PluginScript::get_script_method_list(List<MethodInfo> *r_methods) const {
ASSERT_SCRIPT_VALID();
- for (Map<StringName, MethodInfo>::Element *e = _methods_info.front(); e != NULL; e = e->next()) {
+ for (Map<StringName, MethodInfo>::Element *e = _methods_info.front(); e != nullptr; e = e->next()) {
r_methods->push_back(e->get());
}
}
void PluginScript::get_script_property_list(List<PropertyInfo> *r_properties) const {
ASSERT_SCRIPT_VALID();
- for (Map<StringName, PropertyInfo>::Element *e = _properties_info.front(); e != NULL; e = e->next()) {
+ for (Map<StringName, PropertyInfo>::Element *e = _properties_info.front(); e != nullptr; e = e->next()) {
r_properties->push_back(e->get());
}
}
@@ -386,7 +393,7 @@ bool PluginScript::has_method(const StringName &p_method) const {
MethodInfo PluginScript::get_method_info(const StringName &p_method) const {
ASSERT_SCRIPT_VALID_V(MethodInfo());
const Map<StringName, MethodInfo>::Element *e = _methods_info.find(p_method);
- if (e != NULL) {
+ if (e != nullptr) {
return e->get();
} else {
return MethodInfo();
@@ -401,7 +408,7 @@ bool PluginScript::has_property(const StringName &p_method) const {
PropertyInfo PluginScript::get_property_info(const StringName &p_property) const {
ASSERT_SCRIPT_VALID_V(PropertyInfo());
const Map<StringName, PropertyInfo>::Element *e = _properties_info.find(p_property);
- if (e != NULL) {
+ if (e != nullptr) {
return e->get();
} else {
return PropertyInfo();
@@ -412,7 +419,7 @@ bool PluginScript::get_property_default_value(const StringName &p_property, Vari
ASSERT_SCRIPT_VALID_V(false);
#ifdef TOOLS_ENABLED
const Map<StringName, Variant>::Element *e = _properties_default_values.find(p_property);
- if (e != NULL) {
+ if (e != nullptr) {
r_value = e->get();
return true;
} else {
@@ -462,7 +469,7 @@ bool PluginScript::has_script_signal(const StringName &p_signal) const {
void PluginScript::get_script_signal_list(List<MethodInfo> *r_signals) const {
ASSERT_SCRIPT_VALID();
- for (Map<StringName, MethodInfo>::Element *e = _signals_info.front(); e != NULL; e = e->next()) {
+ for (Map<StringName, MethodInfo>::Element *e = _signals_info.front(); e != nullptr; e = e->next()) {
r_signals->push_back(e->get());
}
}
@@ -543,9 +550,9 @@ MultiplayerAPI::RPCMode PluginScript::get_rset_mode(const StringName &p_variable
}
PluginScript::PluginScript() :
- _data(NULL),
- _desc(NULL),
- _language(NULL),
+ _data(nullptr),
+ _desc(nullptr),
+ _language(nullptr),
_tool(false),
_valid(false),
_script_list(this) {
diff --git a/modules/gdnative/pluginscript/pluginscript_script.h b/modules/gdnative/pluginscript/pluginscript_script.h
index 5c93ae38f5..70b9ca980b 100644
--- a/modules/gdnative/pluginscript/pluginscript_script.h
+++ b/modules/gdnative/pluginscript/pluginscript_script.h
@@ -72,6 +72,8 @@ private:
protected:
static void _bind_methods();
+ bool inherits_script(const Ref<Script> &p_script) const;
+
PluginScriptInstance *_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, Callable::CallError &r_error);
Variant _new(const Variant **p_args, int p_argcount, Callable::CallError &r_error);
diff --git a/modules/gdnative/register_types.cpp b/modules/gdnative/register_types.cpp
index 397a020689..67a286ee2e 100644
--- a/modules/gdnative/register_types.cpp
+++ b/modules/gdnative/register_types.cpp
@@ -34,11 +34,11 @@
#include "gdnative.h"
-#include "arvr/register_types.h"
#include "nativescript/register_types.h"
#include "net/register_types.h"
#include "pluginscript/register_types.h"
#include "videodecoder/register_types.h"
+#include "xr/register_types.h"
#include "core/engine.h"
#include "core/io/resource_loader.h"
@@ -240,7 +240,7 @@ void register_gdnative_types() {
GDNativeCallRegistry::singleton->register_native_call_type("standard_varcall", cb_standard_varcall);
register_net_types();
- register_arvr_types();
+ register_xr_types();
register_nativescript_types();
register_pluginscript_types();
register_videodecoder_types();
@@ -305,7 +305,7 @@ void unregister_gdnative_types() {
unregister_videodecoder_types();
unregister_pluginscript_types();
unregister_nativescript_types();
- unregister_arvr_types();
+ unregister_xr_types();
unregister_net_types();
memdelete(GDNativeCallRegistry::singleton);
diff --git a/modules/gdnative/videodecoder/SCsub b/modules/gdnative/videodecoder/SCsub
index 04cc8ed604..5948b9a3dd 100644
--- a/modules/gdnative/videodecoder/SCsub
+++ b/modules/gdnative/videodecoder/SCsub
@@ -1,9 +1,9 @@
#!/usr/bin/env python
-Import('env')
-Import('env_modules')
+Import("env")
+Import("env_modules")
env_vsdecoder_gdnative = env_modules.Clone()
-env_vsdecoder_gdnative.Prepend(CPPPATH=['#modules/gdnative/include/'])
-env_vsdecoder_gdnative.add_source_files(env.modules_sources, '*.cpp')
+env_vsdecoder_gdnative.Prepend(CPPPATH=["#modules/gdnative/include/"])
+env_vsdecoder_gdnative.add_source_files(env.modules_sources, "*.cpp")
diff --git a/modules/gdnative/videodecoder/video_stream_gdnative.cpp b/modules/gdnative/videodecoder/video_stream_gdnative.cpp
index f6e2bad739..f7d87595af 100644
--- a/modules/gdnative/videodecoder/video_stream_gdnative.cpp
+++ b/modules/gdnative/videodecoder/video_stream_gdnative.cpp
@@ -33,7 +33,7 @@
#include "core/project_settings.h"
#include "servers/audio_server.h"
-VideoDecoderServer *VideoDecoderServer::instance = NULL;
+VideoDecoderServer *VideoDecoderServer::instance = nullptr;
static VideoDecoderServer decoder_server;
@@ -113,7 +113,7 @@ void GDAPI godot_videodecoder_register_decoder(const godot_videodecoder_interfac
// VideoStreamPlaybackGDNative starts here.
bool VideoStreamPlaybackGDNative::open_file(const String &p_file) {
- ERR_FAIL_COND_V(interface == NULL, false);
+ ERR_FAIL_COND_V(interface == nullptr, false);
file = FileAccess::open(p_file, FileAccess::READ);
bool file_opened = interface->open_file(data_struct, file);
@@ -150,7 +150,7 @@ void VideoStreamPlaybackGDNative::update(float p_delta) {
return;
}
time += p_delta;
- ERR_FAIL_COND(interface == NULL);
+ ERR_FAIL_COND(interface == nullptr);
interface->update(data_struct, p_delta);
// Don't mix if there's no audio (num_channels == 0).
@@ -189,7 +189,7 @@ void VideoStreamPlaybackGDNative::update(float p_delta) {
void VideoStreamPlaybackGDNative::update_texture() {
PackedByteArray *pba = (PackedByteArray *)interface->get_videoframe(data_struct);
- if (pba == NULL) {
+ if (pba == nullptr) {
playing = false;
return;
}
@@ -205,19 +205,19 @@ VideoStreamPlaybackGDNative::VideoStreamPlaybackGDNative() :
texture(Ref<ImageTexture>(memnew(ImageTexture))),
playing(false),
paused(false),
- mix_udata(NULL),
- mix_callback(NULL),
+ mix_udata(nullptr),
+ mix_callback(nullptr),
num_channels(-1),
time(0),
seek_backward(false),
mix_rate(0),
delay_compensation(0),
- pcm(NULL),
+ pcm(nullptr),
pcm_write_idx(0),
samples_decoded(0),
- file(NULL),
- interface(NULL),
- data_struct(NULL) {}
+ file(nullptr),
+ interface(nullptr),
+ data_struct(nullptr) {}
VideoStreamPlaybackGDNative::~VideoStreamPlaybackGDNative() {
cleanup();
@@ -228,16 +228,16 @@ void VideoStreamPlaybackGDNative::cleanup() {
interface->destructor(data_struct);
if (pcm)
memfree(pcm);
- pcm = NULL;
+ pcm = nullptr;
time = 0;
num_channels = -1;
- interface = NULL;
- data_struct = NULL;
+ interface = nullptr;
+ data_struct = nullptr;
}
void VideoStreamPlaybackGDNative::set_interface(const godot_videodecoder_interface_gdnative *p_interface) {
- ERR_FAIL_COND(p_interface == NULL);
- if (interface != NULL) {
+ ERR_FAIL_COND(p_interface == nullptr);
+ if (interface != nullptr) {
cleanup();
}
interface = p_interface;
@@ -272,7 +272,7 @@ void VideoStreamPlaybackGDNative::stop() {
}
void VideoStreamPlaybackGDNative::seek(float p_time) {
- ERR_FAIL_COND(interface == NULL);
+ ERR_FAIL_COND(interface == nullptr);
interface->seek(data_struct, p_time);
if (p_time < time)
seek_backward = true;
@@ -292,13 +292,13 @@ Ref<Texture2D> VideoStreamPlaybackGDNative::get_texture() const {
}
float VideoStreamPlaybackGDNative::get_length() const {
- ERR_FAIL_COND_V(interface == NULL, 0);
+ ERR_FAIL_COND_V(interface == nullptr, 0);
return interface->get_length(data_struct);
}
float VideoStreamPlaybackGDNative::get_playback_position() const {
- ERR_FAIL_COND_V(interface == NULL, 0);
+ ERR_FAIL_COND_V(interface == nullptr, 0);
return interface->get_playback_position(data_struct);
}
@@ -312,7 +312,7 @@ void VideoStreamPlaybackGDNative::set_loop(bool p_enable) {
}
void VideoStreamPlaybackGDNative::set_audio_track(int p_idx) {
- ERR_FAIL_COND(interface == NULL);
+ ERR_FAIL_COND(interface == nullptr);
interface->set_audio_track(data_struct, p_idx);
}
@@ -323,13 +323,13 @@ void VideoStreamPlaybackGDNative::set_mix_callback(AudioMixCallback p_callback,
}
int VideoStreamPlaybackGDNative::get_channels() const {
- ERR_FAIL_COND_V(interface == NULL, 0);
+ ERR_FAIL_COND_V(interface == nullptr, 0);
return (num_channels > 0) ? num_channels : 0;
}
int VideoStreamPlaybackGDNative::get_mix_rate() const {
- ERR_FAIL_COND_V(interface == NULL, 0);
+ ERR_FAIL_COND_V(interface == nullptr, 0);
return mix_rate;
}
@@ -339,13 +339,13 @@ int VideoStreamPlaybackGDNative::get_mix_rate() const {
Ref<VideoStreamPlayback> VideoStreamGDNative::instance_playback() {
Ref<VideoStreamPlaybackGDNative> pb = memnew(VideoStreamPlaybackGDNative);
VideoDecoderGDNative *decoder = decoder_server.get_decoder(file.get_extension().to_lower());
- if (decoder == NULL)
- return NULL;
+ if (decoder == nullptr)
+ return nullptr;
pb->set_interface(decoder->interface);
pb->set_audio_track(audio_track);
if (pb->open_file(file))
return pb;
- return NULL;
+ return nullptr;
}
void VideoStreamGDNative::set_file(const String &p_file) {
@@ -373,7 +373,7 @@ void VideoStreamGDNative::set_audio_track(int p_track) {
/* --- NOTE ResourceFormatLoaderVideoStreamGDNative starts here. ----- */
-RES ResourceFormatLoaderVideoStreamGDNative::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress) {
+RES ResourceFormatLoaderVideoStreamGDNative::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, bool p_no_cache) {
FileAccess *f = FileAccess::open(p_path, FileAccess::READ);
if (!f) {
if (r_error) {
diff --git a/modules/gdnative/videodecoder/video_stream_gdnative.h b/modules/gdnative/videodecoder/video_stream_gdnative.h
index 21b5245a16..092e10a0f5 100644
--- a/modules/gdnative/videodecoder/video_stream_gdnative.h
+++ b/modules/gdnative/videodecoder/video_stream_gdnative.h
@@ -42,7 +42,7 @@ struct VideoDecoderGDNative {
Vector<String> supported_extensions;
VideoDecoderGDNative() :
- interface(NULL),
+ interface(nullptr),
plugin_name("none") {}
VideoDecoderGDNative(const godot_videodecoder_interface_gdnative *p_interface) :
@@ -89,7 +89,7 @@ public:
VideoDecoderGDNative *get_decoder(const String &extension) {
if (extensions.size() == 0 || !extensions.has(extension))
- return NULL;
+ return nullptr;
return decoders[extensions[extension]];
}
@@ -102,7 +102,7 @@ public:
memdelete(decoders[i]);
}
decoders.clear();
- instance = NULL;
+ instance = nullptr;
}
};
@@ -194,12 +194,12 @@ public:
virtual void set_audio_track(int p_track);
virtual Ref<VideoStreamPlayback> instance_playback();
- VideoStreamGDNative() {}
+ VideoStreamGDNative() { audio_track = 0; }
};
class ResourceFormatLoaderVideoStreamGDNative : public ResourceFormatLoader {
public:
- virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL, bool p_use_sub_threads = false, float *r_progress = nullptr);
+ virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr, bool p_no_cache = false);
virtual void get_recognized_extensions(List<String> *p_extensions) const;
virtual bool handles_type(const String &p_type) const;
virtual String get_resource_type(const String &p_path) const;
diff --git a/modules/gdnative/xr/SCsub b/modules/gdnative/xr/SCsub
new file mode 100644
index 0000000000..0b2db3b504
--- /dev/null
+++ b/modules/gdnative/xr/SCsub
@@ -0,0 +1,6 @@
+#!/usr/bin/env python
+
+Import("env")
+Import("env_gdnative")
+
+env_gdnative.add_source_files(env.modules_sources, "*.cpp")
diff --git a/modules/gdnative/arvr/config.py b/modules/gdnative/xr/config.py
index 53bc827027..d22f9454ed 100644
--- a/modules/gdnative/arvr/config.py
+++ b/modules/gdnative/xr/config.py
@@ -1,5 +1,6 @@
def can_build(env, platform):
- return True
+ return True
+
def configure(env):
- pass
+ pass
diff --git a/modules/gdnative/arvr/register_types.cpp b/modules/gdnative/xr/register_types.cpp
index 0f6e2bca1a..da3a7dc4b8 100644
--- a/modules/gdnative/arvr/register_types.cpp
+++ b/modules/gdnative/xr/register_types.cpp
@@ -29,11 +29,12 @@
/*************************************************************************/
#include "register_types.h"
-#include "arvr_interface_gdnative.h"
+#include "xr_interface_gdnative.h"
-void register_arvr_types() {
- ClassDB::register_class<ARVRInterfaceGDNative>();
+void register_xr_types() {
+ ClassDB::register_class<XRInterfaceGDNative>();
+ ClassDB::add_compatibility_class("ARVRInterfaceGDNative", "XRInterfaceGDNative");
}
-void unregister_arvr_types() {
+void unregister_xr_types() {
}
diff --git a/modules/gdnative/arvr/register_types.h b/modules/gdnative/xr/register_types.h
index b0de6f7c14..2501d28651 100644
--- a/modules/gdnative/arvr/register_types.h
+++ b/modules/gdnative/xr/register_types.h
@@ -28,10 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef ARVR_REGISTER_TYPES_H
-#define ARVR_REGISTER_TYPES_H
+#ifndef XR_REGISTER_TYPES_H
+#define XR_REGISTER_TYPES_H
-void register_arvr_types();
-void unregister_arvr_types();
+void register_xr_types();
+void unregister_xr_types();
-#endif // ARVR_REGISTER_TYPES_H
+#endif // XR_REGISTER_TYPES_H
diff --git a/modules/gdnative/xr/xr_interface_gdnative.cpp b/modules/gdnative/xr/xr_interface_gdnative.cpp
new file mode 100644
index 0000000000..d65089a123
--- /dev/null
+++ b/modules/gdnative/xr/xr_interface_gdnative.cpp
@@ -0,0 +1,428 @@
+/*************************************************************************/
+/* xr_interface_gdnative.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#include "xr_interface_gdnative.h"
+#include "core/input/input.h"
+#include "servers/rendering/rendering_server_globals.h"
+#include "servers/xr/xr_positional_tracker.h"
+
+void XRInterfaceGDNative::_bind_methods() {
+ ADD_PROPERTY_DEFAULT("interface_is_initialized", false);
+ ADD_PROPERTY_DEFAULT("ar_is_anchor_detection_enabled", false);
+}
+
+XRInterfaceGDNative::XRInterfaceGDNative() {
+ print_verbose("Construct gdnative interface\n");
+
+ // we won't have our data pointer until our library gets set
+ data = nullptr;
+
+ interface = nullptr;
+}
+
+XRInterfaceGDNative::~XRInterfaceGDNative() {
+ print_verbose("Destruct gdnative interface\n");
+
+ if (interface != nullptr && is_initialized()) {
+ uninitialize();
+ };
+
+ // cleanup after ourselves
+ cleanup();
+}
+
+void XRInterfaceGDNative::cleanup() {
+ if (interface != nullptr) {
+ interface->destructor(data);
+ data = nullptr;
+ interface = nullptr;
+ }
+}
+
+void XRInterfaceGDNative::set_interface(const godot_xr_interface_gdnative *p_interface) {
+ // this should only be called once, just being paranoid..
+ if (interface) {
+ cleanup();
+ }
+
+ // bind to our interface
+ interface = p_interface;
+
+ // Now we do our constructing...
+ data = interface->constructor((godot_object *)this);
+}
+
+StringName XRInterfaceGDNative::get_name() const {
+
+ ERR_FAIL_COND_V(interface == nullptr, StringName());
+
+ godot_string result = interface->get_name(data);
+
+ StringName name = *(String *)&result;
+
+ godot_string_destroy(&result);
+
+ return name;
+}
+
+int XRInterfaceGDNative::get_capabilities() const {
+ int capabilities;
+
+ ERR_FAIL_COND_V(interface == nullptr, 0); // 0 = None
+
+ capabilities = interface->get_capabilities(data);
+
+ return capabilities;
+}
+
+bool XRInterfaceGDNative::get_anchor_detection_is_enabled() const {
+
+ ERR_FAIL_COND_V(interface == nullptr, false);
+
+ return interface->get_anchor_detection_is_enabled(data);
+}
+
+void XRInterfaceGDNative::set_anchor_detection_is_enabled(bool p_enable) {
+
+ ERR_FAIL_COND(interface == nullptr);
+
+ interface->set_anchor_detection_is_enabled(data, p_enable);
+}
+
+int XRInterfaceGDNative::get_camera_feed_id() {
+
+ ERR_FAIL_COND_V(interface == nullptr, 0);
+
+ return (unsigned int)interface->get_camera_feed_id(data);
+}
+
+bool XRInterfaceGDNative::is_stereo() {
+ bool stereo;
+
+ ERR_FAIL_COND_V(interface == nullptr, false);
+
+ stereo = interface->is_stereo(data);
+
+ return stereo;
+}
+
+bool XRInterfaceGDNative::is_initialized() const {
+
+ ERR_FAIL_COND_V(interface == nullptr, false);
+
+ return interface->is_initialized(data);
+}
+
+bool XRInterfaceGDNative::initialize() {
+ ERR_FAIL_COND_V(interface == nullptr, false);
+
+ bool initialized = interface->initialize(data);
+
+ if (initialized) {
+ // if we successfully initialize our interface and we don't have a primary interface yet, this becomes our primary interface
+
+ XRServer *xr_server = XRServer::get_singleton();
+ if ((xr_server != nullptr) && (xr_server->get_primary_interface() == nullptr)) {
+ xr_server->set_primary_interface(this);
+ };
+ };
+
+ return initialized;
+}
+
+void XRInterfaceGDNative::uninitialize() {
+ ERR_FAIL_COND(interface == nullptr);
+
+ XRServer *xr_server = XRServer::get_singleton();
+ if (xr_server != nullptr) {
+ // Whatever happens, make sure this is no longer our primary interface
+ xr_server->clear_primary_interface_if(this);
+ }
+
+ interface->uninitialize(data);
+}
+
+Size2 XRInterfaceGDNative::get_render_targetsize() {
+
+ ERR_FAIL_COND_V(interface == nullptr, Size2());
+
+ godot_vector2 result = interface->get_render_targetsize(data);
+ Vector2 *vec = (Vector2 *)&result;
+
+ return *vec;
+}
+
+Transform XRInterfaceGDNative::get_transform_for_eye(XRInterface::Eyes p_eye, const Transform &p_cam_transform) {
+ Transform *ret;
+
+ ERR_FAIL_COND_V(interface == nullptr, Transform());
+
+ godot_transform t = interface->get_transform_for_eye(data, (int)p_eye, (godot_transform *)&p_cam_transform);
+
+ ret = (Transform *)&t;
+
+ return *ret;
+}
+
+CameraMatrix XRInterfaceGDNative::get_projection_for_eye(XRInterface::Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far) {
+ CameraMatrix cm;
+
+ ERR_FAIL_COND_V(interface == nullptr, CameraMatrix());
+
+ interface->fill_projection_for_eye(data, (godot_real *)cm.matrix, (godot_int)p_eye, p_aspect, p_z_near, p_z_far);
+
+ return cm;
+}
+
+unsigned int XRInterfaceGDNative::get_external_texture_for_eye(XRInterface::Eyes p_eye) {
+
+ ERR_FAIL_COND_V(interface == nullptr, 0);
+
+ return (unsigned int)interface->get_external_texture_for_eye(data, (godot_int)p_eye);
+}
+
+void XRInterfaceGDNative::commit_for_eye(XRInterface::Eyes p_eye, RID p_render_target, const Rect2 &p_screen_rect) {
+
+ ERR_FAIL_COND(interface == nullptr);
+
+ interface->commit_for_eye(data, (godot_int)p_eye, (godot_rid *)&p_render_target, (godot_rect2 *)&p_screen_rect);
+}
+
+void XRInterfaceGDNative::process() {
+ ERR_FAIL_COND(interface == nullptr);
+
+ interface->process(data);
+}
+
+void XRInterfaceGDNative::notification(int p_what) {
+ ERR_FAIL_COND(interface == nullptr);
+
+ interface->notification(data, p_what);
+}
+
+/////////////////////////////////////////////////////////////////////////////////////
+// some helper callbacks
+
+extern "C" {
+
+void GDAPI godot_xr_register_interface(const godot_xr_interface_gdnative *p_interface) {
+ // Must be on a version 4 plugin
+ ERR_FAIL_COND_MSG(p_interface->version.major < 4, "GDNative XR interfaces build for Godot 3.x are not supported.");
+
+ Ref<XRInterfaceGDNative> new_interface;
+ new_interface.instance();
+ new_interface->set_interface((const godot_xr_interface_gdnative *)p_interface);
+ XRServer::get_singleton()->add_interface(new_interface);
+}
+
+godot_real GDAPI godot_xr_get_worldscale() {
+ XRServer *xr_server = XRServer::get_singleton();
+ ERR_FAIL_NULL_V(xr_server, 1.0);
+
+ return xr_server->get_world_scale();
+}
+
+godot_transform GDAPI godot_xr_get_reference_frame() {
+ godot_transform reference_frame;
+ Transform *reference_frame_ptr = (Transform *)&reference_frame;
+
+ XRServer *xr_server = XRServer::get_singleton();
+ if (xr_server != nullptr) {
+ *reference_frame_ptr = xr_server->get_reference_frame();
+ } else {
+ godot_transform_new_identity(&reference_frame);
+ }
+
+ return reference_frame;
+}
+
+void GDAPI godot_xr_blit(godot_int p_eye, godot_rid *p_render_target, godot_rect2 *p_rect) {
+ // blits out our texture as is, handy for preview display of one of the eyes that is already rendered with lens distortion on an external HMD
+ XRInterface::Eyes eye = (XRInterface::Eyes)p_eye;
+#if 0
+ RID *render_target = (RID *)p_render_target;
+#endif
+ Rect2 screen_rect = *(Rect2 *)p_rect;
+
+ if (eye == XRInterface::EYE_LEFT) {
+ screen_rect.size.x /= 2.0;
+ } else if (p_eye == XRInterface::EYE_RIGHT) {
+ screen_rect.size.x /= 2.0;
+ screen_rect.position.x += screen_rect.size.x;
+ }
+#ifndef _MSC_VER
+#warning this needs to be redone
+#endif
+#if 0
+ RSG::rasterizer->blit_render_target_to_screen(*render_target, screen_rect, 0);
+#endif
+}
+
+godot_int GDAPI godot_xr_get_texid(godot_rid *p_render_target) {
+ // In order to send off our textures to display on our hardware we need the opengl texture ID instead of the render target RID
+ // This is a handy function to expose that.
+#if 0
+ RID *render_target = (RID *)p_render_target;
+
+ RID eye_texture = RSG::storage->render_target_get_texture(*render_target);
+#endif
+
+#ifndef _MSC_VER
+#warning need to obtain this ID again
+#endif
+ uint32_t texid = 0; //RS::get_singleton()->texture_get_texid(eye_texture);
+
+ return texid;
+}
+
+godot_int GDAPI godot_xr_add_controller(char *p_device_name, godot_int p_hand, godot_bool p_tracks_orientation, godot_bool p_tracks_position) {
+ XRServer *xr_server = XRServer::get_singleton();
+ ERR_FAIL_NULL_V(xr_server, 0);
+
+ Input *input = Input::get_singleton();
+ ERR_FAIL_NULL_V(input, 0);
+
+ XRPositionalTracker *new_tracker = memnew(XRPositionalTracker);
+ new_tracker->set_name(p_device_name);
+ new_tracker->set_type(XRServer::TRACKER_CONTROLLER);
+ if (p_hand == 1) {
+ new_tracker->set_hand(XRPositionalTracker::TRACKER_LEFT_HAND);
+ } else if (p_hand == 2) {
+ new_tracker->set_hand(XRPositionalTracker::TRACKER_RIGHT_HAND);
+ }
+
+ // also register as joystick...
+ int joyid = input->get_unused_joy_id();
+ if (joyid != -1) {
+ new_tracker->set_joy_id(joyid);
+ input->joy_connection_changed(joyid, true, p_device_name, "");
+ }
+
+ if (p_tracks_orientation) {
+ Basis orientation;
+ new_tracker->set_orientation(orientation);
+ }
+ if (p_tracks_position) {
+ Vector3 position;
+ new_tracker->set_position(position);
+ }
+
+ // add our tracker to our server and remember its pointer
+ xr_server->add_tracker(new_tracker);
+
+ // note, this ID is only unique within controllers!
+ return new_tracker->get_tracker_id();
+}
+
+void GDAPI godot_xr_remove_controller(godot_int p_controller_id) {
+ XRServer *xr_server = XRServer::get_singleton();
+ ERR_FAIL_NULL(xr_server);
+
+ Input *input = Input::get_singleton();
+ ERR_FAIL_NULL(input);
+
+ XRPositionalTracker *remove_tracker = xr_server->find_by_type_and_id(XRServer::TRACKER_CONTROLLER, p_controller_id);
+ if (remove_tracker != nullptr) {
+ // unset our joystick if applicable
+ int joyid = remove_tracker->get_joy_id();
+ if (joyid != -1) {
+ input->joy_connection_changed(joyid, false, "", "");
+ remove_tracker->set_joy_id(-1);
+ }
+
+ // remove our tracker from our server
+ xr_server->remove_tracker(remove_tracker);
+ memdelete(remove_tracker);
+ }
+}
+
+void GDAPI godot_xr_set_controller_transform(godot_int p_controller_id, godot_transform *p_transform, godot_bool p_tracks_orientation, godot_bool p_tracks_position) {
+ XRServer *xr_server = XRServer::get_singleton();
+ ERR_FAIL_NULL(xr_server);
+
+ XRPositionalTracker *tracker = xr_server->find_by_type_and_id(XRServer::TRACKER_CONTROLLER, p_controller_id);
+ if (tracker != nullptr) {
+ Transform *transform = (Transform *)p_transform;
+ if (p_tracks_orientation) {
+ tracker->set_orientation(transform->basis);
+ }
+ if (p_tracks_position) {
+ tracker->set_rw_position(transform->origin);
+ }
+ }
+}
+
+void GDAPI godot_xr_set_controller_button(godot_int p_controller_id, godot_int p_button, godot_bool p_is_pressed) {
+ XRServer *xr_server = XRServer::get_singleton();
+ ERR_FAIL_NULL(xr_server);
+
+ Input *input = Input::get_singleton();
+ ERR_FAIL_NULL(input);
+
+ XRPositionalTracker *tracker = xr_server->find_by_type_and_id(XRServer::TRACKER_CONTROLLER, p_controller_id);
+ if (tracker != nullptr) {
+ int joyid = tracker->get_joy_id();
+ if (joyid != -1) {
+ input->joy_button(joyid, p_button, p_is_pressed);
+ }
+ }
+}
+
+void GDAPI godot_xr_set_controller_axis(godot_int p_controller_id, godot_int p_axis, godot_real p_value, godot_bool p_can_be_negative) {
+ XRServer *xr_server = XRServer::get_singleton();
+ ERR_FAIL_NULL(xr_server);
+
+ Input *input = Input::get_singleton();
+ ERR_FAIL_NULL(input);
+
+ XRPositionalTracker *tracker = xr_server->find_by_type_and_id(XRServer::TRACKER_CONTROLLER, p_controller_id);
+ if (tracker != nullptr) {
+ int joyid = tracker->get_joy_id();
+ if (joyid != -1) {
+ Input::JoyAxis jx;
+ jx.min = p_can_be_negative ? -1 : 0;
+ jx.value = p_value;
+ input->joy_axis(joyid, p_axis, jx);
+ }
+ }
+}
+
+godot_real GDAPI godot_xr_get_controller_rumble(godot_int p_controller_id) {
+ XRServer *xr_server = XRServer::get_singleton();
+ ERR_FAIL_NULL_V(xr_server, 0.0);
+
+ XRPositionalTracker *tracker = xr_server->find_by_type_and_id(XRServer::TRACKER_CONTROLLER, p_controller_id);
+ if (tracker != nullptr) {
+ return tracker->get_rumble();
+ }
+
+ return 0.0;
+}
+}
diff --git a/modules/gdnative/arvr/arvr_interface_gdnative.h b/modules/gdnative/xr/xr_interface_gdnative.h
index e38eb435c6..64f1282a7e 100644
--- a/modules/gdnative/arvr/arvr_interface_gdnative.h
+++ b/modules/gdnative/xr/xr_interface_gdnative.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* arvr_interface_gdnative.h */
+/* xr_interface_gdnative.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,11 +28,11 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef ARVR_INTERFACE_GDNATIVE_H
-#define ARVR_INTERFACE_GDNATIVE_H
+#ifndef XR_INTERFACE_GDNATIVE_H
+#define XR_INTERFACE_GDNATIVE_H
#include "modules/gdnative/gdnative.h"
-#include "servers/arvr/arvr_interface.h"
+#include "servers/xr/xr_interface.h"
/**
@authors Hinsbart & Karroffel & Mux213
@@ -40,23 +40,23 @@
This subclass of our AR/VR interface forms a bridge to GDNative.
*/
-class ARVRInterfaceGDNative : public ARVRInterface {
- GDCLASS(ARVRInterfaceGDNative, ARVRInterface);
+class XRInterfaceGDNative : public XRInterface {
+ GDCLASS(XRInterfaceGDNative, XRInterface);
void cleanup();
protected:
- const godot_arvr_interface_gdnative *interface;
+ const godot_xr_interface_gdnative *interface;
void *data;
static void _bind_methods();
public:
/** general interface information **/
- ARVRInterfaceGDNative();
- ~ARVRInterfaceGDNative();
+ XRInterfaceGDNative();
+ ~XRInterfaceGDNative();
- void set_interface(const godot_arvr_interface_gdnative *p_interface);
+ void set_interface(const godot_xr_interface_gdnative *p_interface);
virtual StringName get_name() const;
virtual int get_capabilities() const;
@@ -73,19 +73,19 @@ public:
/** rendering and internal **/
virtual Size2 get_render_targetsize();
virtual bool is_stereo();
- virtual Transform get_transform_for_eye(ARVRInterface::Eyes p_eye, const Transform &p_cam_transform);
+ virtual Transform get_transform_for_eye(XRInterface::Eyes p_eye, const Transform &p_cam_transform);
// we expose a Vector<float> version of this function to GDNative
- Vector<float> _get_projection_for_eye(ARVRInterface::Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far);
+ Vector<float> _get_projection_for_eye(XRInterface::Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far);
- // and a CameraMatrix version to ARVRServer
- virtual CameraMatrix get_projection_for_eye(ARVRInterface::Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far);
+ // and a CameraMatrix version to XRServer
+ virtual CameraMatrix get_projection_for_eye(XRInterface::Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far);
- virtual unsigned int get_external_texture_for_eye(ARVRInterface::Eyes p_eye);
- virtual void commit_for_eye(ARVRInterface::Eyes p_eye, RID p_render_target, const Rect2 &p_screen_rect);
+ virtual unsigned int get_external_texture_for_eye(XRInterface::Eyes p_eye);
+ virtual void commit_for_eye(XRInterface::Eyes p_eye, RID p_render_target, const Rect2 &p_screen_rect);
virtual void process();
virtual void notification(int p_what);
};
-#endif // ARVR_INTERFACE_GDNATIVE_H
+#endif // XR_INTERFACE_GDNATIVE_H
diff --git a/modules/gdnavigation/SCsub b/modules/gdnavigation/SCsub
index 9d462f92a7..877d601c6a 100644
--- a/modules/gdnavigation/SCsub
+++ b/modules/gdnavigation/SCsub
@@ -1,25 +1,25 @@
#!/usr/bin/env python
-Import('env')
-Import('env_modules')
+Import("env")
+Import("env_modules")
env_navigation = env_modules.Clone()
# Recast Thirdparty source files
-if env['builtin_recast']:
+if env["builtin_recast"]:
thirdparty_dir = "#thirdparty/recastnavigation/Recast/"
thirdparty_sources = [
- "Source/Recast.cpp",
- "Source/RecastAlloc.cpp",
- "Source/RecastArea.cpp",
- "Source/RecastAssert.cpp",
- "Source/RecastContour.cpp",
- "Source/RecastFilter.cpp",
- "Source/RecastLayers.cpp",
- "Source/RecastMesh.cpp",
- "Source/RecastMeshDetail.cpp",
- "Source/RecastRasterization.cpp",
- "Source/RecastRegion.cpp",
+ "Source/Recast.cpp",
+ "Source/RecastAlloc.cpp",
+ "Source/RecastArea.cpp",
+ "Source/RecastAssert.cpp",
+ "Source/RecastContour.cpp",
+ "Source/RecastFilter.cpp",
+ "Source/RecastLayers.cpp",
+ "Source/RecastMesh.cpp",
+ "Source/RecastMeshDetail.cpp",
+ "Source/RecastRasterization.cpp",
+ "Source/RecastRegion.cpp",
]
thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
@@ -31,11 +31,11 @@ if env['builtin_recast']:
# RVO Thirdparty source files
-if env['builtin_rvo2']:
+if env["builtin_rvo2"]:
thirdparty_dir = "#thirdparty/rvo2"
thirdparty_sources = [
- "/src/Agent.cpp",
- "/src/KdTree.cpp",
+ "/src/Agent.cpp",
+ "/src/KdTree.cpp",
]
thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
diff --git a/modules/gdnavigation/config.py b/modules/gdnavigation/config.py
index 1c8cd12a2d..d22f9454ed 100644
--- a/modules/gdnavigation/config.py
+++ b/modules/gdnavigation/config.py
@@ -1,5 +1,6 @@
def can_build(env, platform):
return True
+
def configure(env):
pass
diff --git a/modules/gdnavigation/gd_navigation_server.cpp b/modules/gdnavigation/gd_navigation_server.cpp
index a1f6ddfedc..278c27ae22 100644
--- a/modules/gdnavigation/gd_navigation_server.cpp
+++ b/modules/gdnavigation/gd_navigation_server.cpp
@@ -114,7 +114,7 @@
void GdNavigationServer::MERGE(_cmd_, F_NAME)(T_0 D_0, T_1 D_1, T_2 D_2, T_3 D_3)
GdNavigationServer::GdNavigationServer() :
- NavigationServer(),
+ NavigationServer3D(),
active(true) {
}
@@ -141,7 +141,7 @@ RID GdNavigationServer::map_create() const {
COMMAND_2(map_set_active, RID, p_map, bool, p_active) {
NavMap *map = map_owner.getornull(p_map);
- ERR_FAIL_COND(map == NULL);
+ ERR_FAIL_COND(map == nullptr);
if (p_active) {
if (!map_is_active(p_map)) {
@@ -154,84 +154,84 @@ COMMAND_2(map_set_active, RID, p_map, bool, p_active) {
bool GdNavigationServer::map_is_active(RID p_map) const {
NavMap *map = map_owner.getornull(p_map);
- ERR_FAIL_COND_V(map == NULL, false);
+ ERR_FAIL_COND_V(map == nullptr, false);
return active_maps.find(map) >= 0;
}
COMMAND_2(map_set_up, RID, p_map, Vector3, p_up) {
NavMap *map = map_owner.getornull(p_map);
- ERR_FAIL_COND(map == NULL);
+ ERR_FAIL_COND(map == nullptr);
map->set_up(p_up);
}
Vector3 GdNavigationServer::map_get_up(RID p_map) const {
const NavMap *map = map_owner.getornull(p_map);
- ERR_FAIL_COND_V(map == NULL, Vector3());
+ ERR_FAIL_COND_V(map == nullptr, Vector3());
return map->get_up();
}
COMMAND_2(map_set_cell_size, RID, p_map, real_t, p_cell_size) {
NavMap *map = map_owner.getornull(p_map);
- ERR_FAIL_COND(map == NULL);
+ ERR_FAIL_COND(map == nullptr);
map->set_cell_size(p_cell_size);
}
real_t GdNavigationServer::map_get_cell_size(RID p_map) const {
const NavMap *map = map_owner.getornull(p_map);
- ERR_FAIL_COND_V(map == NULL, 0);
+ ERR_FAIL_COND_V(map == nullptr, 0);
return map->get_cell_size();
}
COMMAND_2(map_set_edge_connection_margin, RID, p_map, real_t, p_connection_margin) {
NavMap *map = map_owner.getornull(p_map);
- ERR_FAIL_COND(map == NULL);
+ ERR_FAIL_COND(map == nullptr);
map->set_edge_connection_margin(p_connection_margin);
}
real_t GdNavigationServer::map_get_edge_connection_margin(RID p_map) const {
const NavMap *map = map_owner.getornull(p_map);
- ERR_FAIL_COND_V(map == NULL, 0);
+ ERR_FAIL_COND_V(map == nullptr, 0);
return map->get_edge_connection_margin();
}
Vector<Vector3> GdNavigationServer::map_get_path(RID p_map, Vector3 p_origin, Vector3 p_destination, bool p_optimize) const {
const NavMap *map = map_owner.getornull(p_map);
- ERR_FAIL_COND_V(map == NULL, Vector<Vector3>());
+ ERR_FAIL_COND_V(map == nullptr, Vector<Vector3>());
return map->get_path(p_origin, p_destination, p_optimize);
}
Vector3 GdNavigationServer::map_get_closest_point_to_segment(RID p_map, const Vector3 &p_from, const Vector3 &p_to, const bool p_use_collision) const {
const NavMap *map = map_owner.getornull(p_map);
- ERR_FAIL_COND_V(map == NULL, Vector3());
+ ERR_FAIL_COND_V(map == nullptr, Vector3());
return map->get_closest_point_to_segment(p_from, p_to, p_use_collision);
}
Vector3 GdNavigationServer::map_get_closest_point(RID p_map, const Vector3 &p_point) const {
const NavMap *map = map_owner.getornull(p_map);
- ERR_FAIL_COND_V(map == NULL, Vector3());
+ ERR_FAIL_COND_V(map == nullptr, Vector3());
return map->get_closest_point(p_point);
}
Vector3 GdNavigationServer::map_get_closest_point_normal(RID p_map, const Vector3 &p_point) const {
const NavMap *map = map_owner.getornull(p_map);
- ERR_FAIL_COND_V(map == NULL, Vector3());
+ ERR_FAIL_COND_V(map == nullptr, Vector3());
return map->get_closest_point_normal(p_point);
}
RID GdNavigationServer::map_get_closest_point_owner(RID p_map, const Vector3 &p_point) const {
const NavMap *map = map_owner.getornull(p_map);
- ERR_FAIL_COND_V(map == NULL, RID());
+ ERR_FAIL_COND_V(map == nullptr, RID());
return map->get_closest_point_owner(p_point);
}
@@ -247,20 +247,20 @@ RID GdNavigationServer::region_create() const {
COMMAND_2(region_set_map, RID, p_region, RID, p_map) {
NavRegion *region = region_owner.getornull(p_region);
- ERR_FAIL_COND(region == NULL);
+ ERR_FAIL_COND(region == nullptr);
- if (region->get_map() != NULL) {
+ if (region->get_map() != nullptr) {
if (region->get_map()->get_self() == p_map)
return; // Pointless
region->get_map()->remove_region(region);
- region->set_map(NULL);
+ region->set_map(nullptr);
}
if (p_map.is_valid()) {
NavMap *map = map_owner.getornull(p_map);
- ERR_FAIL_COND(map == NULL);
+ ERR_FAIL_COND(map == nullptr);
map->add_region(region);
region->set_map(map);
@@ -269,21 +269,21 @@ COMMAND_2(region_set_map, RID, p_region, RID, p_map) {
COMMAND_2(region_set_transform, RID, p_region, Transform, p_transform) {
NavRegion *region = region_owner.getornull(p_region);
- ERR_FAIL_COND(region == NULL);
+ ERR_FAIL_COND(region == nullptr);
region->set_transform(p_transform);
}
COMMAND_2(region_set_navmesh, RID, p_region, Ref<NavigationMesh>, p_nav_mesh) {
NavRegion *region = region_owner.getornull(p_region);
- ERR_FAIL_COND(region == NULL);
+ ERR_FAIL_COND(region == nullptr);
region->set_mesh(p_nav_mesh);
}
void GdNavigationServer::region_bake_navmesh(Ref<NavigationMesh> r_mesh, Node *p_node) const {
ERR_FAIL_COND(r_mesh.is_null());
- ERR_FAIL_COND(p_node == NULL);
+ ERR_FAIL_COND(p_node == nullptr);
#ifndef _3D_DISABLED
NavigationMeshGenerator::get_singleton()->clear(r_mesh);
@@ -302,7 +302,7 @@ RID GdNavigationServer::agent_create() const {
COMMAND_2(agent_set_map, RID, p_agent, RID, p_map) {
RvoAgent *agent = agent_owner.getornull(p_agent);
- ERR_FAIL_COND(agent == NULL);
+ ERR_FAIL_COND(agent == nullptr);
if (agent->get_map()) {
if (agent->get_map()->get_self() == p_map)
@@ -311,11 +311,11 @@ COMMAND_2(agent_set_map, RID, p_agent, RID, p_map) {
agent->get_map()->remove_agent(agent);
}
- agent->set_map(NULL);
+ agent->set_map(nullptr);
if (p_map.is_valid()) {
NavMap *map = map_owner.getornull(p_map);
- ERR_FAIL_COND(map == NULL);
+ ERR_FAIL_COND(map == nullptr);
agent->set_map(map);
map->add_agent(agent);
@@ -328,82 +328,82 @@ COMMAND_2(agent_set_map, RID, p_agent, RID, p_map) {
COMMAND_2(agent_set_neighbor_dist, RID, p_agent, real_t, p_dist) {
RvoAgent *agent = agent_owner.getornull(p_agent);
- ERR_FAIL_COND(agent == NULL);
+ ERR_FAIL_COND(agent == nullptr);
agent->get_agent()->neighborDist_ = p_dist;
}
COMMAND_2(agent_set_max_neighbors, RID, p_agent, int, p_count) {
RvoAgent *agent = agent_owner.getornull(p_agent);
- ERR_FAIL_COND(agent == NULL);
+ ERR_FAIL_COND(agent == nullptr);
agent->get_agent()->maxNeighbors_ = p_count;
}
COMMAND_2(agent_set_time_horizon, RID, p_agent, real_t, p_time) {
RvoAgent *agent = agent_owner.getornull(p_agent);
- ERR_FAIL_COND(agent == NULL);
+ ERR_FAIL_COND(agent == nullptr);
agent->get_agent()->timeHorizon_ = p_time;
}
COMMAND_2(agent_set_radius, RID, p_agent, real_t, p_radius) {
RvoAgent *agent = agent_owner.getornull(p_agent);
- ERR_FAIL_COND(agent == NULL);
+ ERR_FAIL_COND(agent == nullptr);
agent->get_agent()->radius_ = p_radius;
}
COMMAND_2(agent_set_max_speed, RID, p_agent, real_t, p_max_speed) {
RvoAgent *agent = agent_owner.getornull(p_agent);
- ERR_FAIL_COND(agent == NULL);
+ ERR_FAIL_COND(agent == nullptr);
agent->get_agent()->maxSpeed_ = p_max_speed;
}
COMMAND_2(agent_set_velocity, RID, p_agent, Vector3, p_velocity) {
RvoAgent *agent = agent_owner.getornull(p_agent);
- ERR_FAIL_COND(agent == NULL);
+ ERR_FAIL_COND(agent == nullptr);
agent->get_agent()->velocity_ = RVO::Vector3(p_velocity.x, p_velocity.y, p_velocity.z);
}
COMMAND_2(agent_set_target_velocity, RID, p_agent, Vector3, p_velocity) {
RvoAgent *agent = agent_owner.getornull(p_agent);
- ERR_FAIL_COND(agent == NULL);
+ ERR_FAIL_COND(agent == nullptr);
agent->get_agent()->prefVelocity_ = RVO::Vector3(p_velocity.x, p_velocity.y, p_velocity.z);
}
COMMAND_2(agent_set_position, RID, p_agent, Vector3, p_position) {
RvoAgent *agent = agent_owner.getornull(p_agent);
- ERR_FAIL_COND(agent == NULL);
+ ERR_FAIL_COND(agent == nullptr);
agent->get_agent()->position_ = RVO::Vector3(p_position.x, p_position.y, p_position.z);
}
COMMAND_2(agent_set_ignore_y, RID, p_agent, bool, p_ignore) {
RvoAgent *agent = agent_owner.getornull(p_agent);
- ERR_FAIL_COND(agent == NULL);
+ ERR_FAIL_COND(agent == nullptr);
agent->get_agent()->ignore_y_ = p_ignore;
}
bool GdNavigationServer::agent_is_map_changed(RID p_agent) const {
RvoAgent *agent = agent_owner.getornull(p_agent);
- ERR_FAIL_COND_V(agent == NULL, false);
+ ERR_FAIL_COND_V(agent == nullptr, false);
return agent->is_map_changed();
}
COMMAND_4(agent_set_callback, RID, p_agent, Object *, p_receiver, StringName, p_method, Variant, p_udata) {
RvoAgent *agent = agent_owner.getornull(p_agent);
- ERR_FAIL_COND(agent == NULL);
+ ERR_FAIL_COND(agent == nullptr);
- agent->set_callback(p_receiver == NULL ? ObjectID() : p_receiver->get_instance_id(), p_method, p_udata);
+ agent->set_callback(p_receiver == nullptr ? ObjectID() : p_receiver->get_instance_id(), p_method, p_udata);
if (agent->get_map()) {
- if (p_receiver == NULL) {
+ if (p_receiver == nullptr) {
agent->get_map()->remove_agent_as_controlled(agent);
} else {
agent->get_map()->set_agent_as_controlled(agent);
@@ -419,14 +419,14 @@ COMMAND_1(free, RID, p_object) {
std::vector<NavRegion *> regions = map->get_regions();
for (size_t i(0); i < regions.size(); i++) {
map->remove_region(regions[i]);
- regions[i]->set_map(NULL);
+ regions[i]->set_map(nullptr);
}
// Remove any assigned agent
std::vector<RvoAgent *> agents = map->get_agents();
for (size_t i(0); i < agents.size(); i++) {
map->remove_agent(agents[i]);
- agents[i]->set_map(NULL);
+ agents[i]->set_map(nullptr);
}
active_maps.erase(map);
@@ -437,9 +437,9 @@ COMMAND_1(free, RID, p_object) {
NavRegion *region = region_owner.getornull(p_object);
// Removes this region from the map if assigned
- if (region->get_map() != NULL) {
+ if (region->get_map() != nullptr) {
region->get_map()->remove_region(region);
- region->set_map(NULL);
+ region->set_map(nullptr);
}
region_owner.free(p_object);
@@ -449,9 +449,9 @@ COMMAND_1(free, RID, p_object) {
RvoAgent *agent = agent_owner.getornull(p_object);
// Removes this agent from the map if assigned
- if (agent->get_map() != NULL) {
+ if (agent->get_map() != nullptr) {
agent->get_map()->remove_agent(agent);
- agent->set_map(NULL);
+ agent->set_map(nullptr);
}
agent_owner.free(p_object);
diff --git a/modules/gdnavigation/gd_navigation_server.h b/modules/gdnavigation/gd_navigation_server.h
index e9f5c1ffe6..01d1a4fba9 100644
--- a/modules/gdnavigation/gd_navigation_server.h
+++ b/modules/gdnavigation/gd_navigation_server.h
@@ -33,7 +33,7 @@
#include "core/rid.h"
#include "core/rid_owner.h"
-#include "servers/navigation_server.h"
+#include "servers/navigation_server_3d.h"
#include "nav_map.h"
#include "nav_region.h"
@@ -67,7 +67,7 @@ struct SetCommand {
virtual void exec(GdNavigationServer *server) = 0;
};
-class GdNavigationServer : public NavigationServer {
+class GdNavigationServer : public NavigationServer3D {
Mutex commands_mutex;
/// Mutex used to make any operation threadsafe.
Mutex operations_mutex;
diff --git a/modules/gdnavigation/nav_map.cpp b/modules/gdnavigation/nav_map.cpp
index 338e49eb9f..7e6a3f7a26 100644
--- a/modules/gdnavigation/nav_map.cpp
+++ b/modules/gdnavigation/nav_map.cpp
@@ -81,8 +81,8 @@ gd::PointKey NavMap::get_point_key(const Vector3 &p_pos) const {
Vector<Vector3> NavMap::get_path(Vector3 p_origin, Vector3 p_destination, bool p_optimize) const {
- const gd::Polygon *begin_poly = NULL;
- const gd::Polygon *end_poly = NULL;
+ const gd::Polygon *begin_poly = nullptr;
+ const gd::Polygon *end_poly = nullptr;
Vector3 begin_point;
Vector3 end_point;
float begin_d = 1e20;
@@ -146,7 +146,7 @@ Vector<Vector3> NavMap::get_path(Vector3 p_origin, Vector3 p_destination, bool p
open_list.push_back(0);
- const gd::Polygon *reachable_end = NULL;
+ const gd::Polygon *reachable_end = nullptr;
float reachable_d = 1e30;
bool is_reachable = true;
@@ -215,7 +215,7 @@ Vector<Vector3> NavMap::get_path(Vector3 p_origin, Vector3 p_destination, bool p
// so use the further reachable polygon
ERR_BREAK_MSG(is_reachable == false, "It's not expect to not find the most reachable polygons");
is_reachable = false;
- if (reachable_end == NULL) {
+ if (reachable_end == nullptr) {
// The path is not found and there is not a way out.
break;
}
@@ -240,7 +240,7 @@ Vector<Vector3> NavMap::get_path(Vector3 p_origin, Vector3 p_destination, bool p
open_list.clear();
open_list.push_back(0);
- reachable_end = NULL;
+ reachable_end = nullptr;
continue;
}
@@ -249,7 +249,7 @@ Vector<Vector3> NavMap::get_path(Vector3 p_origin, Vector3 p_destination, bool p
least_cost_id = -1;
float least_cost = 1e30;
- for (auto element = open_list.front(); element != NULL; element = element->next()) {
+ for (auto element = open_list.front(); element != nullptr; element = element->next()) {
gd::NavigationPoly *np = &navigation_polys[element->get()];
float cost = np->traveled_distance;
#ifdef USE_ENTRY_POINT
@@ -366,7 +366,7 @@ Vector<Vector3> NavMap::get_path(Vector3 p_origin, Vector3 p_destination, bool p
p = &navigation_polys[p->prev_navigation_poly_id];
else
// The end
- p = NULL;
+ p = nullptr;
}
if (path[path.size() - 1] != begin_point)
@@ -637,12 +637,12 @@ void NavMap::sync() {
gd::Connection c;
c.A = &poly;
c.A_edge = p;
- c.B = NULL;
+ c.B = nullptr;
c.B_edge = -1;
connections[ek] = c;
- } else if (connection->get().B == NULL) {
- CRASH_COND(connection->get().A == NULL); // Unreachable
+ } else if (connection->get().B == nullptr) {
+ CRASH_COND(connection->get().A == nullptr); // Unreachable
// Connect the two Polygons by this edge
connection->get().B = &poly;
@@ -657,7 +657,7 @@ void NavMap::sync() {
connection->get().B->edges[connection->get().B_edge].other_edge = connection->get().A_edge;
} else {
// The edge is already connected with another edge, skip.
- ERR_PRINT("Attempted to merge a navigation mesh triangle edge with another already-merged edge. This happens when the Navigation's `cell_size` is different from the one used to generate the navigation mesh. This will cause navigation problem.");
+ ERR_PRINT("Attempted to merge a navigation mesh triangle edge with another already-merged edge. This happens when the Navigation3D's `cell_size` is different from the one used to generate the navigation mesh. This will cause navigation problem.");
}
}
}
@@ -667,8 +667,8 @@ void NavMap::sync() {
free_edges.reserve(connections.size());
for (auto connection_element = connections.front(); connection_element; connection_element = connection_element->next()) {
- if (connection_element->get().B == NULL) {
- CRASH_COND(connection_element->get().A == NULL); // Unreachable
+ if (connection_element->get().B == nullptr) {
+ CRASH_COND(connection_element->get().A == nullptr); // Unreachable
CRASH_COND(connection_element->get().A_edge < 0); // Unreachable
// This is a free edge
diff --git a/modules/gdnavigation/nav_region.cpp b/modules/gdnavigation/nav_region.cpp
index 0215821305..b91376f761 100644
--- a/modules/gdnavigation/nav_region.cpp
+++ b/modules/gdnavigation/nav_region.cpp
@@ -37,7 +37,7 @@
*/
NavRegion::NavRegion() :
- map(NULL),
+ map(nullptr),
polygons_dirty(true) {
}
@@ -71,7 +71,7 @@ void NavRegion::update_polygons() {
polygons.clear();
polygons_dirty = false;
- if (map == NULL) {
+ if (map == nullptr) {
return;
}
diff --git a/modules/gdnavigation/nav_region.h b/modules/gdnavigation/nav_region.h
index d99254d1ad..f35ee4bea0 100644
--- a/modules/gdnavigation/nav_region.h
+++ b/modules/gdnavigation/nav_region.h
@@ -34,7 +34,7 @@
#include "nav_rid.h"
#include "nav_utils.h"
-#include "scene/3d/navigation.h"
+#include "scene/3d/navigation_3d.h"
#include <vector>
/**
diff --git a/modules/gdnavigation/nav_utils.h b/modules/gdnavigation/nav_utils.h
index bdf9eb34a8..3401284c31 100644
--- a/modules/gdnavigation/nav_utils.h
+++ b/modules/gdnavigation/nav_utils.h
@@ -90,7 +90,7 @@ struct Edge {
Edge() {
this_edge = -1;
- other_polygon = NULL;
+ other_polygon = nullptr;
other_edge = -1;
}
};
@@ -119,8 +119,8 @@ struct Connection {
int B_edge;
Connection() {
- A = NULL;
- B = NULL;
+ A = nullptr;
+ B = nullptr;
A_edge = -1;
B_edge = -1;
}
diff --git a/modules/gdnavigation/navigation_mesh_editor_plugin.cpp b/modules/gdnavigation/navigation_mesh_editor_plugin.cpp
index e6ff7a7afa..abaf73ba6a 100644
--- a/modules/gdnavigation/navigation_mesh_editor_plugin.cpp
+++ b/modules/gdnavigation/navigation_mesh_editor_plugin.cpp
@@ -34,13 +34,13 @@
#include "core/io/marshalls.h"
#include "core/io/resource_saver.h"
#include "navigation_mesh_generator.h"
-#include "scene/3d/mesh_instance.h"
+#include "scene/3d/mesh_instance_3d.h"
#include "scene/gui/box_container.h"
void NavigationMeshEditor::_node_removed(Node *p_node) {
if (p_node == node) {
- node = NULL;
+ node = nullptr;
hide();
}
@@ -50,8 +50,8 @@ void NavigationMeshEditor::_notification(int p_option) {
if (p_option == NOTIFICATION_ENTER_TREE) {
- button_bake->set_icon(get_icon("Bake", "EditorIcons"));
- button_reset->set_icon(get_icon("Reload", "EditorIcons"));
+ button_bake->set_icon(get_theme_icon("Bake", "EditorIcons"));
+ button_reset->set_icon(get_theme_icon("Reload", "EditorIcons"));
}
}
@@ -61,7 +61,7 @@ void NavigationMeshEditor::_bake_pressed() {
ERR_FAIL_COND(!node);
if (!node->get_navigation_mesh().is_valid()) {
err_dialog->set_text(TTR("A NavigationMesh resource must be set or created for this node to work."));
- err_dialog->popup_centered_minsize();
+ err_dialog->popup_centered();
return;
}
@@ -84,9 +84,9 @@ void NavigationMeshEditor::_clear_pressed() {
}
}
-void NavigationMeshEditor::edit(NavigationRegion *p_nav_region) {
+void NavigationMeshEditor::edit(NavigationRegion3D *p_nav_region) {
- if (p_nav_region == NULL || node == p_nav_region) {
+ if (p_nav_region == nullptr || node == p_nav_region) {
return;
}
@@ -117,7 +117,7 @@ NavigationMeshEditor::NavigationMeshEditor() {
err_dialog = memnew(AcceptDialog);
add_child(err_dialog);
- node = NULL;
+ node = nullptr;
}
NavigationMeshEditor::~NavigationMeshEditor() {
@@ -125,12 +125,12 @@ NavigationMeshEditor::~NavigationMeshEditor() {
void NavigationMeshEditorPlugin::edit(Object *p_object) {
- navigation_mesh_editor->edit(Object::cast_to<NavigationRegion>(p_object));
+ navigation_mesh_editor->edit(Object::cast_to<NavigationRegion3D>(p_object));
}
bool NavigationMeshEditorPlugin::handles(Object *p_object) const {
- return p_object->is_class("NavigationRegion");
+ return p_object->is_class("NavigationRegion3D");
}
void NavigationMeshEditorPlugin::make_visible(bool p_visible) {
@@ -142,7 +142,7 @@ void NavigationMeshEditorPlugin::make_visible(bool p_visible) {
navigation_mesh_editor->hide();
navigation_mesh_editor->bake_hbox->hide();
- navigation_mesh_editor->edit(NULL);
+ navigation_mesh_editor->edit(nullptr);
}
}
diff --git a/modules/gdnavigation/navigation_mesh_editor_plugin.h b/modules/gdnavigation/navigation_mesh_editor_plugin.h
index 847ad4f63d..434981c9e0 100644
--- a/modules/gdnavigation/navigation_mesh_editor_plugin.h
+++ b/modules/gdnavigation/navigation_mesh_editor_plugin.h
@@ -36,7 +36,7 @@
#include "editor/editor_node.h"
#include "editor/editor_plugin.h"
-class NavigationRegion;
+class NavigationRegion3D;
class NavigationMeshEditor : public Control {
friend class NavigationMeshEditorPlugin;
@@ -50,7 +50,7 @@ class NavigationMeshEditor : public Control {
ToolButton *button_reset;
Label *bake_info;
- NavigationRegion *node;
+ NavigationRegion3D *node;
void _bake_pressed();
void _clear_pressed();
@@ -61,7 +61,7 @@ protected:
void _notification(int p_option);
public:
- void edit(NavigationRegion *p_nav_region);
+ void edit(NavigationRegion3D *p_nav_region);
NavigationMeshEditor();
~NavigationMeshEditor();
};
diff --git a/modules/gdnavigation/navigation_mesh_generator.cpp b/modules/gdnavigation/navigation_mesh_generator.cpp
index e7038b38a2..acb4f0461f 100644
--- a/modules/gdnavigation/navigation_mesh_generator.cpp
+++ b/modules/gdnavigation/navigation_mesh_generator.cpp
@@ -34,18 +34,18 @@
#include "core/math/quick_hull.h"
#include "core/os/thread.h"
-#include "scene/3d/collision_shape.h"
-#include "scene/3d/mesh_instance.h"
-#include "scene/3d/physics_body.h"
-#include "scene/resources/box_shape.h"
-#include "scene/resources/capsule_shape.h"
-#include "scene/resources/concave_polygon_shape.h"
-#include "scene/resources/convex_polygon_shape.h"
-#include "scene/resources/cylinder_shape.h"
+#include "scene/3d/collision_shape_3d.h"
+#include "scene/3d/mesh_instance_3d.h"
+#include "scene/3d/physics_body_3d.h"
+#include "scene/resources/box_shape_3d.h"
+#include "scene/resources/capsule_shape_3d.h"
+#include "scene/resources/concave_polygon_shape_3d.h"
+#include "scene/resources/convex_polygon_shape_3d.h"
+#include "scene/resources/cylinder_shape_3d.h"
#include "scene/resources/primitive_meshes.h"
-#include "scene/resources/shape.h"
-#include "scene/resources/sphere_shape.h"
-#include "scene/resources/world_margin_shape.h"
+#include "scene/resources/shape_3d.h"
+#include "scene/resources/sphere_shape_3d.h"
+#include "scene/resources/world_margin_shape_3d.h"
#include "modules/modules_enabled.gen.h"
#ifdef TOOLS_ENABLED
@@ -60,7 +60,7 @@
#include "modules/gridmap/grid_map.h"
#endif
-NavigationMeshGenerator *NavigationMeshGenerator::singleton = NULL;
+NavigationMeshGenerator *NavigationMeshGenerator::singleton = nullptr;
void NavigationMeshGenerator::_add_vertex(const Vector3 &p_vec3, Vector<float> &p_verticies) {
p_verticies.push_back(p_vec3.x);
@@ -140,9 +140,9 @@ void NavigationMeshGenerator::_add_faces(const PackedVector3Array &p_faces, cons
void NavigationMeshGenerator::_parse_geometry(Transform p_accumulated_transform, Node *p_node, Vector<float> &p_verticies, Vector<int> &p_indices, int p_generate_from, uint32_t p_collision_mask, bool p_recurse_children) {
- if (Object::cast_to<MeshInstance>(p_node) && p_generate_from != NavigationMesh::PARSED_GEOMETRY_STATIC_COLLIDERS) {
+ if (Object::cast_to<MeshInstance3D>(p_node) && p_generate_from != NavigationMesh::PARSED_GEOMETRY_STATIC_COLLIDERS) {
- MeshInstance *mesh_instance = Object::cast_to<MeshInstance>(p_node);
+ MeshInstance3D *mesh_instance = Object::cast_to<MeshInstance3D>(p_node);
Ref<Mesh> mesh = mesh_instance->get_mesh();
if (mesh.is_valid()) {
_add_mesh(mesh, p_accumulated_transform * mesh_instance->get_transform(), p_verticies, p_indices);
@@ -150,9 +150,9 @@ void NavigationMeshGenerator::_parse_geometry(Transform p_accumulated_transform,
}
#ifdef MODULE_CSG_ENABLED
- if (Object::cast_to<CSGShape>(p_node) && p_generate_from != NavigationMesh::PARSED_GEOMETRY_STATIC_COLLIDERS) {
+ if (Object::cast_to<CSGShape3D>(p_node) && p_generate_from != NavigationMesh::PARSED_GEOMETRY_STATIC_COLLIDERS) {
- CSGShape *csg_shape = Object::cast_to<CSGShape>(p_node);
+ CSGShape3D *csg_shape = Object::cast_to<CSGShape3D>(p_node);
Array meshes = csg_shape->get_meshes();
if (!meshes.empty()) {
Ref<Mesh> mesh = meshes[1];
@@ -163,22 +163,22 @@ void NavigationMeshGenerator::_parse_geometry(Transform p_accumulated_transform,
}
#endif
- if (Object::cast_to<StaticBody>(p_node) && p_generate_from != NavigationMesh::PARSED_GEOMETRY_MESH_INSTANCES) {
- StaticBody *static_body = Object::cast_to<StaticBody>(p_node);
+ if (Object::cast_to<StaticBody3D>(p_node) && p_generate_from != NavigationMesh::PARSED_GEOMETRY_MESH_INSTANCES) {
+ StaticBody3D *static_body = Object::cast_to<StaticBody3D>(p_node);
if (static_body->get_collision_layer() & p_collision_mask) {
for (int i = 0; i < p_node->get_child_count(); ++i) {
Node *child = p_node->get_child(i);
- if (Object::cast_to<CollisionShape>(child)) {
- CollisionShape *col_shape = Object::cast_to<CollisionShape>(child);
+ if (Object::cast_to<CollisionShape3D>(child)) {
+ CollisionShape3D *col_shape = Object::cast_to<CollisionShape3D>(child);
Transform transform = p_accumulated_transform * static_body->get_transform() * col_shape->get_transform();
Ref<Mesh> mesh;
- Ref<Shape> s = col_shape->get_shape();
+ Ref<Shape3D> s = col_shape->get_shape();
- BoxShape *box = Object::cast_to<BoxShape>(*s);
+ BoxShape3D *box = Object::cast_to<BoxShape3D>(*s);
if (box) {
Ref<CubeMesh> cube_mesh;
cube_mesh.instance();
@@ -186,7 +186,7 @@ void NavigationMeshGenerator::_parse_geometry(Transform p_accumulated_transform,
mesh = cube_mesh;
}
- CapsuleShape *capsule = Object::cast_to<CapsuleShape>(*s);
+ CapsuleShape3D *capsule = Object::cast_to<CapsuleShape3D>(*s);
if (capsule) {
Ref<CapsuleMesh> capsule_mesh;
capsule_mesh.instance();
@@ -195,7 +195,7 @@ void NavigationMeshGenerator::_parse_geometry(Transform p_accumulated_transform,
mesh = capsule_mesh;
}
- CylinderShape *cylinder = Object::cast_to<CylinderShape>(*s);
+ CylinderShape3D *cylinder = Object::cast_to<CylinderShape3D>(*s);
if (cylinder) {
Ref<CylinderMesh> cylinder_mesh;
cylinder_mesh.instance();
@@ -205,7 +205,7 @@ void NavigationMeshGenerator::_parse_geometry(Transform p_accumulated_transform,
mesh = cylinder_mesh;
}
- SphereShape *sphere = Object::cast_to<SphereShape>(*s);
+ SphereShape3D *sphere = Object::cast_to<SphereShape3D>(*s);
if (sphere) {
Ref<SphereMesh> sphere_mesh;
sphere_mesh.instance();
@@ -214,12 +214,12 @@ void NavigationMeshGenerator::_parse_geometry(Transform p_accumulated_transform,
mesh = sphere_mesh;
}
- ConcavePolygonShape *concave_polygon = Object::cast_to<ConcavePolygonShape>(*s);
+ ConcavePolygonShape3D *concave_polygon = Object::cast_to<ConcavePolygonShape3D>(*s);
if (concave_polygon) {
_add_faces(concave_polygon->get_faces(), transform, p_verticies, p_indices);
}
- ConvexPolygonShape *convex_polygon = Object::cast_to<ConvexPolygonShape>(*s);
+ ConvexPolygonShape3D *convex_polygon = Object::cast_to<ConvexPolygonShape3D>(*s);
if (convex_polygon) {
Vector<Vector3> varr = Variant(convex_polygon->get_points());
Geometry::MeshData md;
@@ -265,8 +265,8 @@ void NavigationMeshGenerator::_parse_geometry(Transform p_accumulated_transform,
}
#endif
- if (Object::cast_to<Spatial>(p_node)) {
- Spatial *spatial = Object::cast_to<Spatial>(p_node);
+ if (Object::cast_to<Node3D>(p_node)) {
+ Node3D *spatial = Object::cast_to<Node3D>(p_node);
p_accumulated_transform = p_accumulated_transform * spatial->get_transform();
}
@@ -405,7 +405,7 @@ void NavigationMeshGenerator::_build_recast_navigation_mesh(
ERR_FAIL_COND(!rcBuildCompactHeightfield(&ctx, cfg.walkableHeight, cfg.walkableClimb, *hf, *chf));
rcFreeHeightField(hf);
- hf = 0;
+ hf = nullptr;
#ifdef TOOLS_ENABLED
if (ep)
@@ -452,9 +452,9 @@ void NavigationMeshGenerator::_build_recast_navigation_mesh(
ERR_FAIL_COND(!rcBuildPolyMeshDetail(&ctx, *poly_mesh, *chf, cfg.detailSampleDist, cfg.detailSampleMaxError, *detail_mesh));
rcFreeCompactHeightfield(chf);
- chf = 0;
+ chf = nullptr;
rcFreeContourSet(cset);
- cset = 0;
+ cset = nullptr;
#ifdef TOOLS_ENABLED
if (ep)
@@ -464,9 +464,9 @@ void NavigationMeshGenerator::_build_recast_navigation_mesh(
_convert_detail_mesh_to_native_navigation_mesh(detail_mesh, p_nav_mesh);
rcFreePolyMesh(poly_mesh);
- poly_mesh = 0;
+ poly_mesh = nullptr;
rcFreePolyMeshDetail(detail_mesh);
- detail_mesh = 0;
+ detail_mesh = nullptr;
}
NavigationMeshGenerator *NavigationMeshGenerator::get_singleton() {
@@ -485,7 +485,7 @@ void NavigationMeshGenerator::bake(Ref<NavigationMesh> p_nav_mesh, Node *p_node)
ERR_FAIL_COND(!p_nav_mesh.is_valid());
#ifdef TOOLS_ENABLED
- EditorProgress *ep(NULL);
+ EditorProgress *ep(nullptr);
if (Engine::get_singleton()->is_editor_hint()) {
ep = memnew(EditorProgress("bake", TTR("Navigation Mesh Generator Setup:"), 11));
}
@@ -505,7 +505,7 @@ void NavigationMeshGenerator::bake(Ref<NavigationMesh> p_nav_mesh, Node *p_node)
p_node->get_tree()->get_nodes_in_group(p_nav_mesh->get_source_group_name(), &parse_nodes);
}
- Transform navmesh_xform = Object::cast_to<Spatial>(p_node)->get_transform().affine_inverse();
+ Transform navmesh_xform = Object::cast_to<Node3D>(p_node)->get_transform().affine_inverse();
for (const List<Node *>::Element *E = parse_nodes.front(); E; E = E->next()) {
int geometry_type = p_nav_mesh->get_parsed_geometry_type();
uint32_t collision_mask = p_nav_mesh->get_collision_mask();
@@ -515,11 +515,11 @@ void NavigationMeshGenerator::bake(Ref<NavigationMesh> p_nav_mesh, Node *p_node)
if (vertices.size() > 0 && indices.size() > 0) {
- rcHeightfield *hf = NULL;
- rcCompactHeightfield *chf = NULL;
- rcContourSet *cset = NULL;
- rcPolyMesh *poly_mesh = NULL;
- rcPolyMeshDetail *detail_mesh = NULL;
+ rcHeightfield *hf = nullptr;
+ rcCompactHeightfield *chf = nullptr;
+ rcContourSet *cset = nullptr;
+ rcPolyMesh *poly_mesh = nullptr;
+ rcPolyMeshDetail *detail_mesh = nullptr;
_build_recast_navigation_mesh(
p_nav_mesh,
@@ -535,19 +535,19 @@ void NavigationMeshGenerator::bake(Ref<NavigationMesh> p_nav_mesh, Node *p_node)
indices);
rcFreeHeightField(hf);
- hf = 0;
+ hf = nullptr;
rcFreeCompactHeightfield(chf);
- chf = 0;
+ chf = nullptr;
rcFreeContourSet(cset);
- cset = 0;
+ cset = nullptr;
rcFreePolyMesh(poly_mesh);
- poly_mesh = 0;
+ poly_mesh = nullptr;
rcFreePolyMeshDetail(detail_mesh);
- detail_mesh = 0;
+ detail_mesh = nullptr;
}
#ifdef TOOLS_ENABLED
diff --git a/modules/gdnavigation/navigation_mesh_generator.h b/modules/gdnavigation/navigation_mesh_generator.h
index d1f2e4b56f..c5f7b2ab81 100644
--- a/modules/gdnavigation/navigation_mesh_generator.h
+++ b/modules/gdnavigation/navigation_mesh_generator.h
@@ -33,7 +33,7 @@
#ifndef _3D_DISABLED
-#include "scene/3d/navigation_region.h"
+#include "scene/3d/navigation_region_3d.h"
#include <Recast.h>
diff --git a/modules/gdnavigation/register_types.cpp b/modules/gdnavigation/register_types.cpp
index d717733787..088b26bf17 100644
--- a/modules/gdnavigation/register_types.cpp
+++ b/modules/gdnavigation/register_types.cpp
@@ -32,7 +32,7 @@
#include "core/engine.h"
#include "gd_navigation_server.h"
-#include "servers/navigation_server.h"
+#include "servers/navigation_server_3d.h"
#ifndef _3D_DISABLED
#include "navigation_mesh_generator.h"
@@ -47,15 +47,15 @@
*/
#ifndef _3D_DISABLED
-NavigationMeshGenerator *_nav_mesh_generator = NULL;
+NavigationMeshGenerator *_nav_mesh_generator = nullptr;
#endif
-NavigationServer *new_server() {
+NavigationServer3D *new_server() {
return memnew(GdNavigationServer);
}
void register_gdnavigation_types() {
- NavigationServerManager::set_default_server(new_server);
+ NavigationServer3DManager::set_default_server(new_server);
#ifndef _3D_DISABLED
_nav_mesh_generator = memnew(NavigationMeshGenerator);
diff --git a/modules/gdnavigation/rvo_agent.cpp b/modules/gdnavigation/rvo_agent.cpp
index 677e525bbf..3c39f02c26 100644
--- a/modules/gdnavigation/rvo_agent.cpp
+++ b/modules/gdnavigation/rvo_agent.cpp
@@ -37,7 +37,7 @@
*/
RvoAgent::RvoAgent() :
- map(NULL) {
+ map(nullptr) {
callback.id = ObjectID();
}
@@ -70,7 +70,7 @@ void RvoAgent::dispatch_callback() {
return;
}
Object *obj = ObjectDB::get_instance(callback.id);
- if (obj == NULL) {
+ if (obj == nullptr) {
callback.id = ObjectID();
}
diff --git a/modules/gdscript/SCsub b/modules/gdscript/SCsub
index 74e653ce43..e58a1d8edc 100644
--- a/modules/gdscript/SCsub
+++ b/modules/gdscript/SCsub
@@ -1,19 +1,19 @@
#!/usr/bin/env python
-Import('env')
-Import('env_modules')
+Import("env")
+Import("env_modules")
env_gdscript = env_modules.Clone()
env_gdscript.add_source_files(env.modules_sources, "*.cpp")
-if env['tools']:
+if env["tools"]:
env_gdscript.add_source_files(env.modules_sources, "./editor/*.cpp")
# Those two modules are required for the language server protocol
- if env['module_jsonrpc_enabled'] and env['module_websocket_enabled']:
+ if env["module_jsonrpc_enabled"] and env["module_websocket_enabled"]:
env_gdscript.add_source_files(env.modules_sources, "./language_server/*.cpp")
else:
# Using a define in the disabled case, to avoid having an extra define
# in regular builds where all modules are enabled.
- env_gdscript.Append(CPPDEFINES=['GDSCRIPT_NO_LSP'])
+ env_gdscript.Append(CPPDEFINES=["GDSCRIPT_NO_LSP"])
diff --git a/modules/gdscript/config.py b/modules/gdscript/config.py
index a525eedaaa..6fc227e7f5 100644
--- a/modules/gdscript/config.py
+++ b/modules/gdscript/config.py
@@ -1,16 +1,18 @@
def can_build(env, platform):
return True
+
def configure(env):
pass
+
def get_doc_classes():
return [
"@GDScript",
"GDScript",
"GDScriptFunctionState",
- "GDScriptNativeClass",
]
+
def get_doc_path():
return "doc_classes"
diff --git a/modules/gdscript/doc_classes/@GDScript.xml b/modules/gdscript/doc_classes/@GDScript.xml
index 2f6f9f30a4..9324691df5 100644
--- a/modules/gdscript/doc_classes/@GDScript.xml
+++ b/modules/gdscript/doc_classes/@GDScript.xml
@@ -90,14 +90,18 @@
</return>
<argument index="0" name="condition" type="bool">
</argument>
+ <argument index="1" name="message" type="String" default="&quot;&quot;">
+ </argument>
<description>
- Asserts that the [code]condition[/code] is [code]true[/code] . If the [code]condition[/code] is [code]false[/code], an error is generated and the program is halted until you resume it. Only executes in debug builds, or when running the game from the editor. Use it for debugging purposes, to make sure a statement is [code]true[/code] during development.
+ Asserts that the [code]condition[/code] is [code]true[/code]. If the [code]condition[/code] is [code]false[/code], an error is generated and the program is halted until you resume it. Only executes in debug builds, or when running the game from the editor. Use it for debugging purposes, to make sure a statement is [code]true[/code] during development.
+ The optional [code]message[/code] argument, if given, is shown in addition to the generic "Assertion failed" message. You can use this to provide additional details about why the assertion failed.
[codeblock]
# Imagine we always want speed to be between 0 and 20
speed = -10
assert(speed &lt; 20) # True, the program will continue
assert(speed &gt;= 0) # False, the program will stop
assert(speed &gt;= 0 &amp;&amp; speed &lt; 20) # You can also combine the two conditional statements in one check
+ assert(speed &lt; 20, "speed = %f, but the speed limit is 20" % speed) # Show a message with clarifying details
[/codeblock]
</description>
</method>
@@ -1216,7 +1220,7 @@
<description>
Returns whether the given class exists in [ClassDB].
[codeblock]
- type_exists("Sprite") # Returns true
+ type_exists("Sprite2D") # Returns true
type_exists("Variant") # Returns false
[/codeblock]
</description>
diff --git a/modules/gdscript/doc_classes/GDScriptNativeClass.xml b/modules/gdscript/doc_classes/GDScriptNativeClass.xml
deleted file mode 100644
index 0a8982de8e..0000000000
--- a/modules/gdscript/doc_classes/GDScriptNativeClass.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<class name="GDScriptNativeClass" inherits="Reference" version="4.0">
- <brief_description>
- </brief_description>
- <description>
- </description>
- <tutorials>
- </tutorials>
- <methods>
- <method name="new">
- <return type="Variant">
- </return>
- <description>
- </description>
- </method>
- </methods>
- <constants>
- </constants>
-</class>
diff --git a/modules/gdscript/editor/gdscript_highlighter.cpp b/modules/gdscript/editor/gdscript_highlighter.cpp
index 687e1785be..0aca4dbc5e 100644
--- a/modules/gdscript/editor/gdscript_highlighter.cpp
+++ b/modules/gdscript/editor/gdscript_highlighter.cpp
@@ -358,11 +358,11 @@ List<String> GDScriptSyntaxHighlighter::get_supported_languages() {
}
void GDScriptSyntaxHighlighter::_update_cache() {
- font_color = text_editor->get_color("font_color");
- symbol_color = text_editor->get_color("symbol_color");
- function_color = text_editor->get_color("function_color");
- number_color = text_editor->get_color("number_color");
- member_color = text_editor->get_color("member_variable_color");
+ font_color = text_editor->get_theme_color("font_color");
+ symbol_color = text_editor->get_theme_color("symbol_color");
+ function_color = text_editor->get_theme_color("function_color");
+ number_color = text_editor->get_theme_color("number_color");
+ member_color = text_editor->get_theme_color("member_variable_color");
const String text_editor_color_theme = EditorSettings::get_singleton()->get("text_editor/theme/color_theme");
const bool default_theme = text_editor_color_theme == "Default";
diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp
index 05e9f8652e..98366f7957 100644
--- a/modules/gdscript/gdscript.cpp
+++ b/modules/gdscript/gdscript.cpp
@@ -114,13 +114,13 @@ GDScriptInstance *GDScript::_create_instance(const Variant **p_args, int p_argco
if (r_error.error != Callable::CallError::CALL_OK) {
instance->script = Ref<GDScript>();
- instance->owner->set_script_instance(NULL);
+ instance->owner->set_script_instance(nullptr);
{
MutexLock lock(GDScriptLanguage::singleton->lock);
instances.erase(p_owner);
}
- ERR_FAIL_COND_V(r_error.error != Callable::CallError::CALL_OK, NULL); //error constructing
+ ERR_FAIL_COND_V(r_error.error != Callable::CallError::CALL_OK, nullptr); //error constructing
}
//@TODO make thread safe
@@ -138,7 +138,7 @@ Variant GDScript::_new(const Variant **p_args, int p_argcount, Callable::CallErr
r_error.error = Callable::CallError::CALL_OK;
REF ref;
- Object *owner = NULL;
+ Object *owner = nullptr;
GDScript *_baseptr = this;
while (_baseptr->_base) {
@@ -158,7 +158,7 @@ Variant GDScript::_new(const Variant **p_args, int p_argcount, Callable::CallErr
ref = REF(r);
}
- GDScriptInstance *instance = _create_instance(p_args, p_argcount, owner, r != NULL, r_error);
+ GDScriptInstance *instance = _create_instance(p_args, p_argcount, owner, r != nullptr, r_error);
if (!instance) {
if (ref.is_null()) {
memdelete(owner); //no owner, sorry
@@ -318,12 +318,12 @@ ScriptInstance *GDScript::instance_create(Object *p_this) {
if (EngineDebugger::is_active()) {
GDScriptLanguage::get_singleton()->debug_break_parse(get_path(), 1, "Script inherits from native type '" + String(top->native->get_name()) + "', so it can't be instanced in object of type: '" + p_this->get_class() + "'");
}
- ERR_FAIL_V_MSG(NULL, "Script inherits from native type '" + String(top->native->get_name()) + "', so it can't be instanced in object of type '" + p_this->get_class() + "'" + ".");
+ ERR_FAIL_V_MSG(nullptr, "Script inherits from native type '" + String(top->native->get_name()) + "', so it can't be instanced in object of type '" + p_this->get_class() + "'" + ".");
}
}
Callable::CallError unchecked_error;
- return _create_instance(NULL, 0, p_this, Object::cast_to<Reference>(p_this) != NULL, unchecked_error);
+ return _create_instance(nullptr, 0, p_this, Object::cast_to<Reference>(p_this) != nullptr, unchecked_error);
}
PlaceHolderScriptInstance *GDScript::placeholder_instance_create(Object *p_this) {
@@ -333,7 +333,7 @@ PlaceHolderScriptInstance *GDScript::placeholder_instance_create(Object *p_this)
_update_exports();
return si;
#else
- return NULL;
+ return nullptr;
#endif
}
@@ -688,7 +688,7 @@ Variant GDScript::call(const StringName &p_method, const Variant **p_args, int p
ERR_FAIL_COND_V_MSG(!E->get()->is_static(), Variant(), "Can't call non-static function '" + String(p_method) + "' in script.");
- return E->get()->call(NULL, p_args, p_argcount, r_error);
+ return E->get()->call(nullptr, p_args, p_argcount, r_error);
}
top = top->_base;
}
@@ -895,6 +895,24 @@ Ref<GDScript> GDScript::get_base() const {
return base;
}
+bool GDScript::inherits_script(const Ref<Script> &p_script) const {
+ Ref<GDScript> gd = p_script;
+ if (gd.is_null()) {
+ return false;
+ }
+
+ const GDScript *s = this;
+
+ while (s) {
+ if (s == p_script.ptr()) {
+ return true;
+ }
+ s = s->_base;
+ }
+
+ return false;
+}
+
bool GDScript::has_script_signal(const StringName &p_signal) const {
if (_signals.has(p_signal))
return true;
@@ -938,9 +956,9 @@ GDScript::GDScript() :
valid = false;
subclass_count = 0;
- initializer = NULL;
- _base = NULL;
- _owner = NULL;
+ initializer = nullptr;
+ _base = nullptr;
+ _owner = nullptr;
tool = false;
#ifdef TOOLS_ENABLED
source_changed_cache = false;
@@ -964,7 +982,7 @@ void GDScript::_save_orphaned_subclasses() {
Vector<ClassRefWithName> weak_subclasses;
// collect subclasses ObjectID and name
for (Map<StringName, Ref<GDScript>>::Element *E = subclasses.front(); E; E = E->next()) {
- E->get()->_owner = NULL; //bye, you are no longer owned cause I died
+ E->get()->_owner = nullptr; //bye, you are no longer owned cause I died
ClassRefWithName subclass;
subclass.id = E->get()->get_instance_id();
subclass.fully_qualified_name = E->get()->fully_qualified_name;
@@ -1028,7 +1046,7 @@ void GDScript::_init_rpc_methods_properties() {
if (sub_E)
cscript = sub_E->get().ptr();
else
- cscript = NULL;
+ cscript = nullptr;
}
// Sort so we are 100% that they are always the same.
@@ -1120,7 +1138,7 @@ bool GDScriptInstance::get(const StringName &p_name, Variant &r_ret) const {
if (E) {
if (E->get().getter) {
Callable::CallError err;
- r_ret = const_cast<GDScriptInstance *>(this)->call(E->get().getter, NULL, 0, err);
+ r_ret = const_cast<GDScriptInstance *>(this)->call(E->get().getter, nullptr, 0, err);
if (err.error == Callable::CallError::CALL_OK) {
return true;
}
@@ -1194,7 +1212,7 @@ void GDScriptInstance::get_property_list(List<PropertyInfo> *p_properties) const
if (E) {
Callable::CallError err;
- Variant ret = const_cast<GDScriptFunction *>(E->get())->call(const_cast<GDScriptInstance *>(this), NULL, 0, err);
+ Variant ret = const_cast<GDScriptFunction *>(E->get())->call(const_cast<GDScriptInstance *>(this), nullptr, 0, err);
if (err.error == Callable::CallError::CALL_OK) {
ERR_FAIL_COND_MSG(ret.get_type() != Variant::ARRAY, "Wrong type for _get_property_list, must be an array of dictionaries.");
@@ -1351,7 +1369,7 @@ void GDScriptInstance::notification(int p_notification) {
String GDScriptInstance::to_string(bool *r_valid) {
if (has_method(CoreStringNames::get_singleton()->_to_string)) {
Callable::CallError ce;
- Variant ret = call(CoreStringNames::get_singleton()->_to_string, NULL, 0, ce);
+ Variant ret = call(CoreStringNames::get_singleton()->_to_string, nullptr, 0, ce);
if (ce.error == Callable::CallError::CALL_OK) {
if (ret.get_type() != Variant::STRING) {
if (r_valid)
@@ -1450,7 +1468,7 @@ void GDScriptInstance::reload_members() {
}
GDScriptInstance::GDScriptInstance() {
- owner = NULL;
+ owner = nullptr;
base_ref = false;
}
@@ -1464,7 +1482,7 @@ GDScriptInstance::~GDScriptInstance() {
/************* SCRIPT LANGUAGE **************/
-GDScriptLanguage *GDScriptLanguage::singleton = NULL;
+GDScriptLanguage *GDScriptLanguage::singleton = nullptr;
String GDScriptLanguage::get_name() const {
@@ -1900,7 +1918,7 @@ void GDScriptLanguage::get_reserved_words(List<String> *p_words) const {
"remotesync",
"mastersync",
"puppetsync",
- 0
+ nullptr
};
const char **w = _reserved_words;
@@ -1933,7 +1951,7 @@ String GDScriptLanguage::get_global_class_name(const String &p_path, String *r_b
String source = f->get_as_utf8_string();
GDScriptParser parser;
- parser.parse(source, p_path.get_base_dir(), true, p_path, false, NULL, true);
+ parser.parse(source, p_path.get_base_dir(), true, p_path, false, nullptr, true);
if (parser.get_parse_tree() && parser.get_parse_tree()->type == GDScriptParser::Node::TYPE_CLASS) {
@@ -1954,7 +1972,7 @@ String GDScriptLanguage::get_global_class_name(const String &p_path, String *r_b
if (subclass->extends_file) {
if (subclass->extends_class.size() == 0) {
get_global_class_name(subclass->extends_file, r_base_type);
- subclass = NULL;
+ subclass = nullptr;
break;
} else {
Vector<StringName> extend_classes = subclass->extends_class;
@@ -1973,7 +1991,7 @@ String GDScriptLanguage::get_global_class_name(const String &p_path, String *r_b
subpath = path.get_base_dir().plus_file(subpath).simplify_path();
}
- if (OK != subparser.parse(subsource, subpath.get_base_dir(), true, subpath, false, NULL, true)) {
+ if (OK != subparser.parse(subsource, subpath.get_base_dir(), true, subpath, false, nullptr, true)) {
break;
}
path = subpath;
@@ -1994,20 +2012,20 @@ String GDScriptLanguage::get_global_class_name(const String &p_path, String *r_b
}
}
if (!found) {
- subclass = NULL;
+ subclass = nullptr;
break;
}
}
}
} else if (subclass->extends_class.size() == 1) {
*r_base_type = subclass->extends_class[0];
- subclass = NULL;
+ subclass = nullptr;
} else {
break;
}
} else {
*r_base_type = "Reference";
- subclass = NULL;
+ subclass = nullptr;
}
}
}
@@ -2168,7 +2186,7 @@ String GDScriptWarning::get_name_from_code(Code p_code) {
"UNSAFE_CALL_ARGUMENT",
"DEPRECATED_KEYWORD",
"STANDALONE_TERNARY",
- NULL
+ nullptr
};
return names[(int)p_code];
@@ -2215,7 +2233,7 @@ GDScriptLanguage::GDScriptLanguage() {
} else {
_debug_max_call_stack = 0;
- _call_stack = NULL;
+ _call_stack = nullptr;
}
#ifdef DEBUG_ENABLED
@@ -2236,7 +2254,7 @@ GDScriptLanguage::~GDScriptLanguage() {
if (_call_stack) {
memdelete_arr(_call_stack);
}
- singleton = NULL;
+ singleton = nullptr;
}
void GDScriptLanguage::add_orphan_subclass(const String &p_qualified_name, const ObjectID &p_subclass) {
@@ -2257,7 +2275,7 @@ Ref<GDScript> GDScriptLanguage::get_orphan_subclass(const String &p_qualified_na
/*************** RESOURCE ***************/
-RES ResourceFormatLoaderGDScript::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress) {
+RES ResourceFormatLoaderGDScript::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, bool p_no_cache) {
if (r_error)
*r_error = ERR_FILE_CANT_OPEN;
@@ -2319,7 +2337,7 @@ void ResourceFormatLoaderGDScript::get_dependencies(const String &p_path, List<S
}
GDScriptParser parser;
- if (OK != parser.parse(source, p_path.get_base_dir(), true, p_path, false, NULL, true)) {
+ if (OK != parser.parse(source, p_path.get_base_dir(), true, p_path, false, nullptr, true)) {
return;
}
@@ -2363,5 +2381,5 @@ void ResourceFormatSaverGDScript::get_recognized_extensions(const RES &p_resourc
}
bool ResourceFormatSaverGDScript::recognize(const RES &p_resource) const {
- return Object::cast_to<GDScript>(*p_resource) != NULL;
+ return Object::cast_to<GDScript>(*p_resource) != nullptr;
}
diff --git a/modules/gdscript/gdscript.h b/modules/gdscript/gdscript.h
index 3fedc604bf..5fdc25669f 100644
--- a/modules/gdscript/gdscript.h
+++ b/modules/gdscript/gdscript.h
@@ -151,6 +151,8 @@ protected:
public:
virtual bool is_valid() const { return valid; }
+ bool inherits_script(const Ref<Script> &p_script) const;
+
const Map<StringName, Ref<GDScript>> &get_subclasses() const { return subclasses; }
const Map<StringName, Variant> &get_constants() const { return constants; }
const Set<StringName> &get_members() const { return members; }
@@ -260,7 +262,7 @@ public:
virtual bool set(const StringName &p_name, const Variant &p_value);
virtual bool get(const StringName &p_name, Variant &r_ret) const;
virtual void get_property_list(List<PropertyInfo> *p_properties) const;
- virtual Variant::Type get_property_type(const StringName &p_name, bool *r_is_valid = NULL) const;
+ virtual Variant::Type get_property_type(const StringName &p_name, bool *r_is_valid = nullptr) const;
virtual void get_method_list(List<MethodInfo> *p_list) const;
virtual bool has_method(const StringName &p_method) const;
@@ -483,7 +485,7 @@ public:
virtual Ref<Script> get_template(const String &p_class_name, const String &p_base_class_name) const;
virtual bool is_using_templates();
virtual void make_template(const String &p_class_name, const String &p_base_class_name, Ref<Script> &p_script);
- virtual bool validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path = "", List<String> *r_functions = NULL, List<ScriptLanguage::Warning> *r_warnings = NULL, Set<int> *r_safe_lines = NULL) const;
+ virtual bool validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path = "", List<String> *r_functions = nullptr, List<ScriptLanguage::Warning> *r_warnings = nullptr, Set<int> *r_safe_lines = nullptr) const;
virtual Script *create_script() const;
virtual bool has_named_classes() const;
virtual bool supports_builtin_mode() const;
@@ -534,7 +536,7 @@ public:
/* GLOBAL CLASSES */
virtual bool handles_global_class_type(const String &p_type) const;
- virtual String get_global_class_name(const String &p_path, String *r_base_type = NULL, String *r_icon_path = NULL) const;
+ virtual String get_global_class_name(const String &p_path, String *r_base_type = nullptr, String *r_icon_path = nullptr) const;
void add_orphan_subclass(const String &p_qualified_name, const ObjectID &p_subclass);
Ref<GDScript> get_orphan_subclass(const String &p_qualified_name);
@@ -545,7 +547,7 @@ public:
class ResourceFormatLoaderGDScript : public ResourceFormatLoader {
public:
- virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL, bool p_use_sub_threads = false, float *r_progress = nullptr);
+ virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr, bool p_no_cache = false);
virtual void get_recognized_extensions(List<String> *p_extensions) const;
virtual bool handles_type(const String &p_type) const;
virtual String get_resource_type(const String &p_path) const;
diff --git a/modules/gdscript/gdscript_compiler.cpp b/modules/gdscript/gdscript_compiler.cpp
index fb514aab0c..2bbec29043 100644
--- a/modules/gdscript/gdscript_compiler.cpp
+++ b/modules/gdscript/gdscript_compiler.cpp
@@ -46,7 +46,7 @@ bool GDScriptCompiler::_is_class_member_property(CodeGen &codegen, const StringN
bool GDScriptCompiler::_is_class_member_property(GDScript *owner, const StringName &p_name) {
GDScript *scr = owner;
- GDScriptNativeClass *nc = NULL;
+ GDScriptNativeClass *nc = nullptr;
while (scr) {
if (scr->native.is_valid())
@@ -265,7 +265,7 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
while (owner) {
GDScript *scr = owner;
- GDScriptNativeClass *nc = NULL;
+ GDScriptNativeClass *nc = nullptr;
while (scr) {
if (scr->constants.has(identifier)) {
@@ -1700,14 +1700,14 @@ Error GDScriptCompiler::_parse_function(GDScript *p_script, const GDScriptParser
gdfunc->_constant_count = codegen.constant_map.size();
gdfunc->constants.resize(codegen.constant_map.size());
gdfunc->_constants_ptr = gdfunc->constants.ptrw();
- const Variant *K = NULL;
+ const Variant *K = nullptr;
while ((K = codegen.constant_map.next(K))) {
int idx = codegen.constant_map[*K];
gdfunc->constants.write[idx] = *K;
}
} else {
- gdfunc->_constants_ptr = NULL;
+ gdfunc->_constants_ptr = nullptr;
gdfunc->_constant_count = 0;
}
//global names
@@ -1722,7 +1722,7 @@ Error GDScriptCompiler::_parse_function(GDScript *p_script, const GDScriptParser
gdfunc->_global_names_count = gdfunc->global_names.size();
} else {
- gdfunc->_global_names_ptr = NULL;
+ gdfunc->_global_names_ptr = nullptr;
gdfunc->_global_names_count = 0;
}
@@ -1746,7 +1746,7 @@ Error GDScriptCompiler::_parse_function(GDScript *p_script, const GDScriptParser
} else {
- gdfunc->_code_ptr = NULL;
+ gdfunc->_code_ptr = nullptr;
gdfunc->_code_size = 0;
}
@@ -1757,7 +1757,7 @@ Error GDScriptCompiler::_parse_function(GDScript *p_script, const GDScriptParser
gdfunc->_default_arg_ptr = &gdfunc->default_arguments[0];
} else {
gdfunc->_default_arg_count = 0;
- gdfunc->_default_arg_ptr = NULL;
+ gdfunc->_default_arg_ptr = nullptr;
}
gdfunc->_argument_count = p_func ? p_func->arguments.size() : 0;
@@ -1838,7 +1838,7 @@ Error GDScriptCompiler::_parse_class_level(GDScript *p_script, const GDScriptPar
p_script->native = Ref<GDScriptNativeClass>();
p_script->base = Ref<GDScript>();
- p_script->_base = NULL;
+ p_script->_base = nullptr;
p_script->members.clear();
p_script->constants.clear();
for (Map<StringName, GDScriptFunction *>::Element *E = p_script->member_functions.front(); E; E = E->next()) {
@@ -1848,7 +1848,7 @@ Error GDScriptCompiler::_parse_class_level(GDScript *p_script, const GDScriptPar
p_script->member_indices.clear();
p_script->member_info.clear();
p_script->_signals.clear();
- p_script->initializer = NULL;
+ p_script->initializer = nullptr;
p_script->tool = p_class->tool;
p_script->name = p_class->name;
@@ -1962,7 +1962,7 @@ Error GDScriptCompiler::_parse_class_level(GDScript *p_script, const GDScriptPar
if (c->base.is_valid()) {
c = c->base.ptr();
} else {
- c = NULL;
+ c = nullptr;
}
}
@@ -2032,14 +2032,14 @@ Error GDScriptCompiler::_parse_class_blocks(GDScript *p_script, const GDScriptPa
if (!has_initializer) {
//create a constructor
- Error err = _parse_function(p_script, p_class, NULL);
+ Error err = _parse_function(p_script, p_class, nullptr);
if (err)
return err;
}
if (!has_ready && p_class->ready->statements.size()) {
//create a constructor
- Error err = _parse_function(p_script, p_class, NULL, true);
+ Error err = _parse_function(p_script, p_class, nullptr, true);
if (err)
return err;
}
@@ -2077,7 +2077,7 @@ Error GDScriptCompiler::_parse_class_blocks(GDScript *p_script, const GDScriptPa
/* STEP 2, INITIALIZE AND CONSTRUCT */
Callable::CallError ce;
- p_script->initializer->call(instance, NULL, 0, ce);
+ p_script->initializer->call(instance, nullptr, 0, ce);
if (ce.error != Callable::CallError::CALL_OK) {
//well, tough luck, not goinna do anything here
@@ -2162,7 +2162,7 @@ Error GDScriptCompiler::compile(const GDScriptParser *p_parser, GDScript *p_scri
// Create scripts for subclasses beforehand so they can be referenced
_make_scripts(p_script, static_cast<const GDScriptParser::ClassNode *>(root), p_keep_state);
- p_script->_owner = NULL;
+ p_script->_owner = nullptr;
Error err = _parse_class_level(p_script, static_cast<const GDScriptParser::ClassNode *>(root), p_keep_state);
if (err)
diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp
index 98e09159ec..7ad0682637 100644
--- a/modules/gdscript/gdscript_editor.cpp
+++ b/modules/gdscript/gdscript_editor.cpp
@@ -336,9 +336,9 @@ void GDScriptLanguage::debug_get_stack_level_members(int p_level, List<String> *
ScriptInstance *GDScriptLanguage::debug_get_stack_level_instance(int p_level) {
if (_debug_parse_err_line >= 0)
- return NULL;
+ return nullptr;
- ERR_FAIL_INDEX_V(p_level, _debug_call_stack_pos, NULL);
+ ERR_FAIL_INDEX_V(p_level, _debug_call_stack_pos, nullptr);
int l = _debug_call_stack_pos - p_level - 1;
ScriptInstance *instance = _call_stack[l].instance;
@@ -430,6 +430,8 @@ void GDScriptLanguage::get_public_functions(List<MethodInfo> *p_functions) const
mi.name = "assert";
mi.return_val.type = Variant::NIL;
mi.arguments.push_back(PropertyInfo(Variant::BOOL, "condition"));
+ mi.arguments.push_back(PropertyInfo(Variant::STRING, "message"));
+ mi.default_arguments.push_back(String());
p_functions->push_back(mi);
}
}
@@ -499,10 +501,10 @@ struct GDScriptCompletionContext {
uint32_t depth;
GDScriptCompletionContext() :
- _class(NULL),
- function(NULL),
- block(NULL),
- base(NULL),
+ _class(nullptr),
+ function(nullptr),
+ block(nullptr),
+ base(nullptr),
line(0),
depth(0) {}
};
@@ -514,7 +516,7 @@ struct GDScriptCompletionIdentifier {
const GDScriptParser::Node *assigned_expression;
GDScriptCompletionIdentifier() :
- assigned_expression(NULL) {}
+ assigned_expression(nullptr) {}
};
static void _get_directory_contents(EditorFileSystemDirectory *p_dir, Map<String, ScriptCodeCompletionOption> &r_list) {
@@ -909,7 +911,7 @@ static bool _guess_expression_type(GDScriptCompletionContext &p_context, const G
Variant ret = mb->call(baseptr, (const Variant **)argptr.ptr(), argptr.size(), ce);
if (ce.error == Callable::CallError::CALL_OK && ret.get_type() != Variant::NIL) {
- if (ret.get_type() != Variant::OBJECT || ret.operator Object *() != NULL) {
+ if (ret.get_type() != Variant::OBJECT || ret.operator Object *() != nullptr) {
r_type = _type_from_variant(ret);
found = true;
}
@@ -963,7 +965,7 @@ static bool _guess_expression_type(GDScriptCompletionContext &p_context, const G
break;
}
- const GDScriptParser::DictionaryNode *dn = NULL;
+ const GDScriptParser::DictionaryNode *dn = nullptr;
if (op->arguments[0]->type == GDScriptParser::Node::TYPE_DICTIONARY) {
dn = static_cast<const GDScriptParser::DictionaryNode *>(op->arguments[0]);
} else if (base.assigned_expression && base.assigned_expression->type == GDScriptParser::Node::TYPE_DICTIONARY) {
@@ -1017,7 +1019,7 @@ static bool _guess_expression_type(GDScriptCompletionContext &p_context, const G
}
// Look if it is a dictionary node
- const GDScriptParser::DictionaryNode *dn = NULL;
+ const GDScriptParser::DictionaryNode *dn = nullptr;
if (op->arguments[0]->type == GDScriptParser::Node::TYPE_DICTIONARY) {
dn = static_cast<const GDScriptParser::DictionaryNode *>(op->arguments[0]);
} else if (base.assigned_expression && base.assigned_expression->type == GDScriptParser::Node::TYPE_DICTIONARY) {
@@ -1041,7 +1043,7 @@ static bool _guess_expression_type(GDScriptCompletionContext &p_context, const G
// Look if it is an array node
if (!found && index.value.is_num()) {
int idx = index.value;
- const GDScriptParser::ArrayNode *an = NULL;
+ const GDScriptParser::ArrayNode *an = nullptr;
if (op->arguments[0]->type == GDScriptParser::Node::TYPE_ARRAY) {
an = static_cast<const GDScriptParser::ArrayNode *>(op->arguments[0]);
} else if (base.assigned_expression && base.assigned_expression->type == GDScriptParser::Node::TYPE_ARRAY) {
@@ -1061,7 +1063,7 @@ static bool _guess_expression_type(GDScriptCompletionContext &p_context, const G
found = _guess_identifier_type_from_base(c, base, id, r_type);
} else if (!found && index.type.kind == GDScriptParser::DataType::BUILTIN) {
Callable::CallError err;
- Variant base_val = Variant::construct(base.type.builtin_type, NULL, 0, err);
+ Variant base_val = Variant::construct(base.type.builtin_type, nullptr, 0, err);
bool valid = false;
Variant res = base_val.get(index.value, &valid);
if (valid) {
@@ -1116,9 +1118,9 @@ static bool _guess_expression_type(GDScriptCompletionContext &p_context, const G
Callable::CallError ce;
bool v1_use_value = p1.value.get_type() != Variant::NIL && p1.value.get_type() != Variant::OBJECT;
- Variant v1 = (v1_use_value) ? p1.value : Variant::construct(p1.type.builtin_type, NULL, 0, ce);
+ Variant v1 = (v1_use_value) ? p1.value : Variant::construct(p1.type.builtin_type, nullptr, 0, ce);
bool v2_use_value = p2.value.get_type() != Variant::NIL && p2.value.get_type() != Variant::OBJECT;
- Variant v2 = (v2_use_value) ? p2.value : Variant::construct(p2.type.builtin_type, NULL, 0, ce);
+ Variant v2 = (v2_use_value) ? p2.value : Variant::construct(p2.type.builtin_type, nullptr, 0, ce);
// avoid potential invalid ops
if ((vop == Variant::OP_DIVIDE || vop == Variant::OP_MODULE) && v2.get_type() == Variant::INT) {
v2 = 1;
@@ -1173,7 +1175,7 @@ static bool _guess_identifier_type(GDScriptCompletionContext &p_context, const S
// Look in blocks first
const GDScriptParser::BlockNode *blk = p_context.block;
int last_assign_line = -1;
- const GDScriptParser::Node *last_assigned_expression = NULL;
+ const GDScriptParser::Node *last_assigned_expression = nullptr;
GDScriptParser::DataType var_type;
while (blk) {
if (blk->variables.has(p_identifier)) {
@@ -1227,7 +1229,7 @@ static bool _guess_identifier_type(GDScriptCompletionContext &p_context, const S
r_type.type.is_meta_type = false; // Right-hand of `is` will be a meta type, but the left-hand value is not
// Not an assignment, it shouldn't carry any value
r_type.value = Variant();
- r_type.assigned_expression = NULL;
+ r_type.assigned_expression = nullptr;
return true;
}
@@ -1271,8 +1273,8 @@ static bool _guess_identifier_type(GDScriptCompletionContext &p_context, const S
return false;
}
GDScriptCompletionContext c = p_context;
- c.function = NULL;
- c.block = NULL;
+ c.function = nullptr;
+ c.block = nullptr;
return _guess_expression_type(c, op->arguments[1], r_type);
}
}
@@ -1534,7 +1536,7 @@ static bool _guess_identifier_type_from_base(GDScriptCompletionContext &p_contex
} break;
case GDScriptParser::DataType::BUILTIN: {
Callable::CallError err;
- Variant tmp = Variant::construct(base_type.builtin_type, NULL, 0, err);
+ Variant tmp = Variant::construct(base_type.builtin_type, nullptr, 0, err);
if (err.error != Callable::CallError::CALL_OK) {
return false;
@@ -1612,7 +1614,7 @@ static bool _guess_method_return_type_from_base(GDScriptCompletionContext &p_con
for (int i = 0; i < base_type.class_type->static_functions.size(); i++) {
if (base_type.class_type->static_functions[i]->name == p_method) {
int last_return_line = -1;
- const GDScriptParser::Node *last_returned_value = NULL;
+ const GDScriptParser::Node *last_returned_value = nullptr;
GDScriptCompletionContext c = p_context;
c._class = base_type.class_type;
c.function = base_type.class_type->static_functions[i];
@@ -1629,7 +1631,7 @@ static bool _guess_method_return_type_from_base(GDScriptCompletionContext &p_con
for (int i = 0; i < base_type.class_type->functions.size(); i++) {
if (base_type.class_type->functions[i]->name == p_method) {
int last_return_line = -1;
- const GDScriptParser::Node *last_returned_value = NULL;
+ const GDScriptParser::Node *last_returned_value = nullptr;
GDScriptCompletionContext c = p_context;
c._class = base_type.class_type;
c.function = base_type.class_type->functions[i];
@@ -1704,7 +1706,7 @@ static bool _guess_method_return_type_from_base(GDScriptCompletionContext &p_con
} break;
case GDScriptParser::DataType::BUILTIN: {
Callable::CallError err;
- Variant tmp = Variant::construct(base_type.builtin_type, NULL, 0, err);
+ Variant tmp = Variant::construct(base_type.builtin_type, nullptr, 0, err);
if (err.error != Callable::CallError::CALL_OK) {
return false;
}
@@ -1911,8 +1913,8 @@ static void _find_identifiers_in_class(const GDScriptCompletionContext &p_contex
base_type.value = p_context.base;
GDScriptCompletionContext c = p_context;
- c.block = NULL;
- c.function = NULL;
+ c.block = nullptr;
+ c.function = nullptr;
_find_identifiers_in_base(c, base_type, p_only_functions, r_result);
}
@@ -1932,8 +1934,8 @@ static void _find_identifiers_in_base(const GDScriptCompletionContext &p_context
case GDScriptParser::DataType::CLASS: {
GDScriptCompletionContext c = p_context;
c._class = base_type.class_type;
- c.block = NULL;
- c.function = NULL;
+ c.block = nullptr;
+ c.function = nullptr;
_find_identifiers_in_class(c, _static, p_only_functions, false, r_result);
base_type = base_type.class_type->base_type;
} break;
@@ -2055,7 +2057,7 @@ static void _find_identifiers_in_base(const GDScriptCompletionContext &p_context
List<PropertyInfo> pinfo;
ClassDB::get_property_list(type, &pinfo);
for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
- if (E->get().usage & (PROPERTY_USAGE_GROUP | PROPERTY_USAGE_CATEGORY)) {
+ if (E->get().usage & (PROPERTY_USAGE_GROUP | PROPERTY_USAGE_SUBGROUP | PROPERTY_USAGE_CATEGORY)) {
continue;
}
if (E->get().name.find("/") != -1) {
@@ -2089,14 +2091,14 @@ static void _find_identifiers_in_base(const GDScriptCompletionContext &p_context
} break;
case GDScriptParser::DataType::BUILTIN: {
Callable::CallError err;
- Variant tmp = Variant::construct(base_type.builtin_type, NULL, 0, err);
+ Variant tmp = Variant::construct(base_type.builtin_type, nullptr, 0, err);
if (err.error != Callable::CallError::CALL_OK) {
return;
}
if (!p_only_functions) {
List<PropertyInfo> members;
- p_base.value.get_property_list(&members);
+ tmp.get_property_list(&members);
for (List<PropertyInfo>::Element *E = members.front(); E; E = E->next()) {
if (String(E->get().name).find("/") == -1) {
@@ -2148,13 +2150,13 @@ static void _find_identifiers(const GDScriptCompletionContext &p_context, bool p
}
const GDScriptParser::ClassNode *clss = p_context._class;
- bool _static = !p_context.function || p_context.function->_static;
+ bool _static = p_context.function && p_context.function->_static;
while (clss) {
GDScriptCompletionContext c = p_context;
c._class = clss;
- c.block = NULL;
- c.function = NULL;
+ c.block = nullptr;
+ c.function = nullptr;
_find_identifiers_in_class(c, _static, p_only_functions, false, r_result);
_static = true;
clss = clss->owner;
@@ -2188,7 +2190,7 @@ static void _find_identifiers(const GDScriptCompletionContext &p_context, bool p
"const", "enum", "export", "onready", "static", "var", "break", "continue", "if", "elif",
"else", "for", "pass", "return", "match", "while", "remote", "master", "puppet",
"remotesync", "mastersync", "puppetsync",
- 0
+ nullptr
};
const char **kw = _keywords;
@@ -2234,6 +2236,8 @@ static void _find_call_arguments(const GDScriptCompletionContext &p_context, con
const String quote_style = EDITOR_DEF("text_editor/completion/use_single_quotes", false) ? "'" : "\"";
+#define IS_METHOD_SIGNAL(m_method) (m_method == "connect" || m_method == "disconnect" || m_method == "is_connected" || m_method == "emit_signal")
+
while (base_type.has_type) {
switch (base_type.kind) {
case GDScriptParser::DataType::CLASS: {
@@ -2250,7 +2254,7 @@ static void _find_call_arguments(const GDScriptCompletionContext &p_context, con
}
}
- if ((p_method == "connect" || p_method == "emit_signal") && p_argidx == 0) {
+ if (IS_METHOD_SIGNAL(p_method) && p_argidx == 0) {
for (int i = 0; i < base_type.class_type->_signals.size(); i++) {
ScriptCodeCompletionOption option(base_type.class_type->_signals[i].name.operator String(), ScriptCodeCompletionOption::KIND_SIGNAL);
option.insert_text = quote_style + option.display + quote_style;
@@ -2263,7 +2267,7 @@ static void _find_call_arguments(const GDScriptCompletionContext &p_context, con
case GDScriptParser::DataType::GDSCRIPT: {
Ref<GDScript> gds = base_type.script_type;
if (gds.is_valid()) {
- if ((p_method == "connect" || p_method == "emit_signal") && p_argidx == 0) {
+ if (IS_METHOD_SIGNAL(p_method) && p_argidx == 0) {
List<MethodInfo> signals;
gds->get_script_signal_list(&signals);
for (List<MethodInfo>::Element *E = signals.front(); E; E = E->next()) {
@@ -2325,7 +2329,7 @@ static void _find_call_arguments(const GDScriptCompletionContext &p_context, con
}
}
- if ((p_method == "connect" || p_method == "emit_signal") && p_argidx == 0) {
+ if (IS_METHOD_SIGNAL(p_method) && p_argidx == 0) {
List<MethodInfo> signals;
ClassDB::get_signal_list(class_name, &signals);
for (List<MethodInfo>::Element *E = signals.front(); E; E = E->next()) {
@@ -2334,6 +2338,7 @@ static void _find_call_arguments(const GDScriptCompletionContext &p_context, con
r_result.insert(option.display, option);
}
}
+#undef IS_METHOD_SIGNAL
if (ClassDB::is_parent_class(class_name, "Node") && (p_method == "get_node" || p_method == "has_node") && p_argidx == 0) {
// Get autoloads
@@ -2373,7 +2378,7 @@ static void _find_call_arguments(const GDScriptCompletionContext &p_context, con
case GDScriptParser::DataType::BUILTIN: {
if (base.get_type() == Variant::NIL) {
Callable::CallError err;
- base = Variant::construct(base_type.builtin_type, NULL, 0, err);
+ base = Variant::construct(base_type.builtin_type, nullptr, 0, err);
if (err.error != Callable::CallError::CALL_OK) {
return;
}
@@ -2542,7 +2547,7 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_path
context.function = parser.get_completion_function();
context.line = parser.get_completion_line();
- if (!context._class || context._class->owner == NULL) {
+ if (!context._class || context._class->owner == nullptr) {
context.base = p_owner;
context.base_path = p_path.get_base_dir();
}
@@ -2626,13 +2631,13 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_path
}
GDScriptCompletionContext c = context;
- c.function = NULL;
- c.block = NULL;
- c.base = base.value.get_type() == Variant::OBJECT ? base.value.operator Object *() : NULL;
+ c.function = nullptr;
+ c.block = nullptr;
+ c.base = base.value.get_type() == Variant::OBJECT ? base.value.operator Object *() : nullptr;
if (base.type.kind == GDScriptParser::DataType::CLASS) {
c._class = base.type.class_type;
} else {
- c._class = NULL;
+ c._class = nullptr;
}
_find_identifiers_in_base(c, base, is_function, options);
@@ -2818,8 +2823,8 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_path
for (Map<StringName, GDScriptParser::ClassNode::Constant>::Element *E = clss->constant_expressions.front(); E; E = E->next()) {
GDScriptCompletionIdentifier constant;
GDScriptCompletionContext c = context;
- c.function = NULL;
- c.block = NULL;
+ c.function = nullptr;
+ c.block = nullptr;
c.line = E->value().expression->line;
if (_guess_expression_type(c, E->value().expression, constant)) {
if (constant.type.has_type && constant.type.is_meta_type) {
@@ -2887,9 +2892,9 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_path
}
GDScriptCompletionContext c = context;
- c._class = NULL;
- c.function = NULL;
- c.block = NULL;
+ c._class = nullptr;
+ c.function = nullptr;
+ c.block = nullptr;
bool finding = true;
index = index.right(index.find(".") + 1);
while (index.find(".") != -1) {
@@ -2917,8 +2922,8 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_path
GDScriptCompletionIdentifier constant;
GDScriptCompletionContext c2 = context;
c2._class = base_type.class_type;
- c2.function = NULL;
- c2.block = NULL;
+ c2.function = nullptr;
+ c2.block = nullptr;
c2.line = E->value().expression->line;
if (_guess_expression_type(c2, E->value().expression, constant)) {
if (constant.type.has_type && constant.type.is_meta_type) {
@@ -3220,7 +3225,7 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co
v = v_ref;
} else {
Callable::CallError err;
- v = Variant::construct(base_type.builtin_type, NULL, 0, err);
+ v = Variant::construct(base_type.builtin_type, nullptr, 0, err);
if (err.error != Callable::CallError::CALL_OK) {
break;
}
@@ -3440,7 +3445,7 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol
// We cannot determine the exact nature of the identifier here
// Otherwise these codes would work
StringName enumName = ClassDB::get_integer_constant_enum("@GlobalScope", p_symbol, true);
- if (enumName != NULL) {
+ if (enumName != nullptr) {
r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS_ENUM;
r_result.class_name = "@GlobalScope";
r_result.class_member = enumName;
diff --git a/modules/gdscript/gdscript_function.cpp b/modules/gdscript/gdscript_function.cpp
index 0721c25388..4e0891921e 100644
--- a/modules/gdscript/gdscript_function.cpp
+++ b/modules/gdscript/gdscript_function.cpp
@@ -45,7 +45,7 @@ Variant *GDScriptFunction::_get_variant(int p_address, GDScriptInstance *p_insta
#ifdef DEBUG_ENABLED
if (unlikely(!p_instance)) {
r_error = "Cannot access self without instance.";
- return NULL;
+ return nullptr;
}
#endif
return &self;
@@ -58,7 +58,7 @@ Variant *GDScriptFunction::_get_variant(int p_address, GDScriptInstance *p_insta
#ifdef DEBUG_ENABLED
if (unlikely(!p_instance)) {
r_error = "Cannot access member without instance.";
- return NULL;
+ return nullptr;
}
#endif
//member indexing is O(1)
@@ -69,7 +69,7 @@ Variant *GDScriptFunction::_get_variant(int p_address, GDScriptInstance *p_insta
//todo change to index!
GDScript *s = p_script;
#ifdef DEBUG_ENABLED
- ERR_FAIL_INDEX_V(address, _global_names_count, NULL);
+ ERR_FAIL_INDEX_V(address, _global_names_count, nullptr);
#endif
const StringName *sn = &_global_names_ptr[address];
@@ -86,31 +86,31 @@ Variant *GDScriptFunction::_get_variant(int p_address, GDScriptInstance *p_insta
s = s->_base;
}
- ERR_FAIL_V_MSG(NULL, "GDScriptCompiler bug.");
+ ERR_FAIL_V_MSG(nullptr, "GDScriptCompiler bug.");
} break;
case ADDR_TYPE_LOCAL_CONSTANT: {
#ifdef DEBUG_ENABLED
- ERR_FAIL_INDEX_V(address, _constant_count, NULL);
+ ERR_FAIL_INDEX_V(address, _constant_count, nullptr);
#endif
return &_constants_ptr[address];
} break;
case ADDR_TYPE_STACK:
case ADDR_TYPE_STACK_VARIABLE: {
#ifdef DEBUG_ENABLED
- ERR_FAIL_INDEX_V(address, _stack_size, NULL);
+ ERR_FAIL_INDEX_V(address, _stack_size, nullptr);
#endif
return &p_stack[address];
} break;
case ADDR_TYPE_GLOBAL: {
#ifdef DEBUG_ENABLED
- ERR_FAIL_INDEX_V(address, GDScriptLanguage::get_singleton()->get_global_array_size(), NULL);
+ ERR_FAIL_INDEX_V(address, GDScriptLanguage::get_singleton()->get_global_array_size(), nullptr);
#endif
return &GDScriptLanguage::get_singleton()->get_global_array()[address];
} break;
#ifdef TOOLS_ENABLED
case ADDR_TYPE_NAMED_GLOBAL: {
#ifdef DEBUG_ENABLED
- ERR_FAIL_INDEX_V(address, _named_globals_count, NULL);
+ ERR_FAIL_INDEX_V(address, _named_globals_count, nullptr);
#endif
StringName id = _named_globals_ptr[address];
@@ -118,7 +118,7 @@ Variant *GDScriptFunction::_get_variant(int p_address, GDScriptInstance *p_insta
return (Variant *)&GDScriptLanguage::get_singleton()->get_named_globals_map()[id];
} else {
r_error = "Autoload singleton '" + String(id) + "' has been removed.";
- return NULL;
+ return nullptr;
}
} break;
#endif
@@ -127,8 +127,8 @@ Variant *GDScriptFunction::_get_variant(int p_address, GDScriptInstance *p_insta
} break;
}
- ERR_FAIL_V_MSG(NULL, "Bad code! (unknown addressing mode).");
- return NULL;
+ ERR_FAIL_V_MSG(nullptr, "Bad code! (unknown addressing mode).");
+ return nullptr;
}
#ifdef DEBUG_ENABLED
@@ -272,7 +272,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
Variant self;
Variant static_ref;
Variant retvalue;
- Variant *stack = NULL;
+ Variant *stack = nullptr;
Variant **call_args;
int defarg = 0;
@@ -337,15 +337,10 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
}
if (!argument_types[i].is_type(*p_args[i], true)) {
- if (argument_types[i].is_type(Variant(), true)) {
- memnew_placement(&stack[i], Variant);
- continue;
- } else {
- r_err.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
- r_err.argument = i;
- r_err.expected = argument_types[i].kind == GDScriptDataType::BUILTIN ? argument_types[i].builtin_type : Variant::OBJECT;
- return Variant();
- }
+ r_err.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ r_err.argument = i;
+ r_err.expected = argument_types[i].kind == GDScriptDataType::BUILTIN ? argument_types[i].builtin_type : Variant::OBJECT;
+ return Variant();
}
if (argument_types[i].kind == GDScriptDataType::BUILTIN) {
Variant arg = Variant::construct(argument_types[i].builtin_type, &p_args[i], 1, r_err);
@@ -358,7 +353,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
memnew_placement(&stack[i], Variant);
}
} else {
- stack = NULL;
+ stack = nullptr;
}
if (_call_size) {
@@ -366,12 +361,12 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
call_args = (Variant **)&aptr[sizeof(Variant) * _stack_size];
} else {
- call_args = NULL;
+ call_args = nullptr;
}
} else {
- stack = NULL;
- call_args = NULL;
+ stack = nullptr;
+ call_args = nullptr;
}
if (p_instance) {
@@ -490,7 +485,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
GET_VARIANT_PTR(dst, 3);
#ifdef DEBUG_ENABLED
- if (b->get_type() != Variant::OBJECT || b->operator Object *() == NULL) {
+ if (b->get_type() != Variant::OBJECT || b->operator Object *() == nullptr) {
err_text = "Right operand of 'is' is not a class.";
OPCODE_BREAK;
@@ -498,7 +493,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
#endif
bool extends_ok = false;
- if (a->get_type() == Variant::OBJECT && a->operator Object *() != NULL) {
+ if (a->get_type() == Variant::OBJECT && a->operator Object *() != nullptr) {
#ifdef DEBUG_ENABLED
bool was_freed;
@@ -855,7 +850,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
OPCODE_BREAK;
}
- if (src->get_type() != Variant::NIL && src->operator Object *() != NULL) {
+ if (src->get_type() != Variant::NIL && src->operator Object *() != nullptr) {
ScriptInstance *scr_inst = src->operator Object *()->get_script_instance();
if (!scr_inst) {
@@ -960,7 +955,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
bool valid = false;
- if (src->get_type() != Variant::NIL && src->operator Object *() != NULL) {
+ if (src->get_type() != Variant::NIL && src->operator Object *() != nullptr) {
ScriptInstance *scr_inst = src->operator Object *()->get_script_instance();
@@ -1099,7 +1094,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
base->call_ptr(*methodname, (const Variant **)argptrs, argc, ret, err);
} else {
- base->call_ptr(*methodname, (const Variant **)argptrs, argc, NULL, err);
+ base->call_ptr(*methodname, (const Variant **)argptrs, argc, nullptr, err);
}
#ifdef DEBUG_ENABLED
if (GDScriptLanguage::get_singleton()->profiling) {
@@ -1137,7 +1132,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
}
#endif
- //_call_func(NULL,base,*methodname,ip,argc,p_instance,stack);
+ //_call_func(nullptr,base,*methodname,ip,argc,p_instance,stack);
ip += argc + 1;
}
DISPATCH_OPCODE;
@@ -1216,7 +1211,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
const GDScript *gds = _script;
- const Map<StringName, GDScriptFunction *>::Element *E = NULL;
+ const Map<StringName, GDScriptFunction *>::Element *E = nullptr;
while (gds->base.ptr()) {
gds = gds->base.ptr();
E = gds->member_functions.find(*methodname);
@@ -1767,7 +1762,7 @@ GDScriptFunction::GDScriptFunction() :
rpc_mode = MultiplayerAPI::RPC_MODE_DISABLED;
name = "<anonymous>";
#ifdef DEBUG_ENABLED
- _func_cname = NULL;
+ _func_cname = nullptr;
{
MutexLock lock(GDScriptLanguage::get_singleton()->lock);
@@ -1834,7 +1829,7 @@ Variant GDScriptFunctionState::_signal_callback(const Variant **p_args, int p_ar
bool GDScriptFunctionState::is_valid(bool p_extended_check) const {
- if (function == NULL)
+ if (function == nullptr)
return false;
if (p_extended_check) {
@@ -1859,7 +1854,7 @@ Variant GDScriptFunctionState::resume(const Variant &p_arg) {
state.result = p_arg;
Callable::CallError err;
- Variant ret = function->call(NULL, NULL, 0, err, &state);
+ Variant ret = function->call(nullptr, nullptr, 0, err, &state);
bool completed = true;
@@ -1873,7 +1868,7 @@ Variant GDScriptFunctionState::resume(const Variant &p_arg) {
}
}
- function = NULL; //cleaned up;
+ function = nullptr; //cleaned up;
state.result = Variant();
if (completed) {
@@ -1909,12 +1904,12 @@ void GDScriptFunctionState::_bind_methods() {
GDScriptFunctionState::GDScriptFunctionState() {
- function = NULL;
+ function = nullptr;
}
GDScriptFunctionState::~GDScriptFunctionState() {
- if (function != NULL) {
+ if (function != nullptr) {
//never called, deinitialize stack
for (int i = 0; i < state.stack_size; i++) {
Variant *v = (Variant *)&state.stack[sizeof(Variant) * i];
diff --git a/modules/gdscript/gdscript_function.h b/modules/gdscript/gdscript_function.h
index 0afffcac73..acfc0a95b4 100644
--- a/modules/gdscript/gdscript_function.h
+++ b/modules/gdscript/gdscript_function.h
@@ -105,7 +105,7 @@ struct GDScriptDataType {
return false;
}
- Ref<Script> base = obj && obj->get_script_instance() ? obj->get_script_instance()->get_script() : NULL;
+ Ref<Script> base = obj && obj->get_script_instance() ? obj->get_script_instance()->get_script() : nullptr;
bool valid = false;
while (base.is_valid()) {
if (base == script_type) {
@@ -339,7 +339,7 @@ public:
return default_arguments[p_idx];
}
- Variant call(GDScriptInstance *p_instance, const Variant **p_args, int p_argcount, Callable::CallError &r_err, CallState *p_state = NULL);
+ Variant call(GDScriptInstance *p_instance, const Variant **p_args, int p_argcount, Callable::CallError &r_err, CallState *p_state = nullptr);
_FORCE_INLINE_ MultiplayerAPI::RPCMode get_rpc_mode() const { return rpc_mode; }
GDScriptFunction();
diff --git a/modules/gdscript/gdscript_functions.cpp b/modules/gdscript/gdscript_functions.cpp
index aaa308f40f..9154d6eb89 100644
--- a/modules/gdscript/gdscript_functions.cpp
+++ b/modules/gdscript/gdscript_functions.cpp
@@ -858,7 +858,7 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
PackedByteArray barr;
int len;
- Error err = encode_variant(*p_args[0], NULL, len, full_objects);
+ Error err = encode_variant(*p_args[0], nullptr, len, full_objects);
if (err) {
r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
@@ -908,7 +908,7 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
Variant ret;
{
const uint8_t *r = varr.ptr();
- Error err = decode_variant(ret, r, varr.size(), NULL, allow_objects);
+ Error err = decode_variant(ret, r, varr.size(), nullptr, allow_objects);
if (err != OK) {
r_ret = RTR("Not enough bytes for decoding bytes, or invalid format.");
r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
@@ -1198,7 +1198,7 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
}
}
- r_ret = gdscr->_new(NULL, 0, r_error);
+ r_ret = gdscr->_new(nullptr, 0, r_error);
GDScriptInstance *ins = static_cast<GDScriptInstance *>(static_cast<Object *>(r_ret)->get_script_instance());
Ref<GDScript> gd_ref = ins->get_script();
diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp
index 7fcb2cc423..411512d631 100644
--- a/modules/gdscript/gdscript_parser.cpp
+++ b/modules/gdscript/gdscript_parser.cpp
@@ -242,7 +242,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
Vector<Expression> expression;
- Node *expr = NULL;
+ Node *expr = nullptr;
int op_line = tokenizer->get_token_line(); // when operators are created at the bottom, the line might have been changed (\n found)
@@ -276,12 +276,12 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
Node *subexpr = _parse_expression(p_parent, p_static, p_allow_assign, p_parsing_constant);
parenthesis--;
if (!subexpr)
- return NULL;
+ return nullptr;
if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
_set_error("Expected ')' in expression");
- return NULL;
+ return nullptr;
}
tokenizer->advance();
@@ -318,7 +318,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
if (tokenizer->get_token_constant().get_type() != Variant::STRING) {
_set_error("Expected string constant or identifier after '$' or '/'.");
- return NULL;
+ return nullptr;
}
path += String(tokenizer->get_token_constant());
@@ -355,7 +355,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
if (path == "") {
_set_error("Path expected after $.");
- return NULL;
+ return nullptr;
}
OperatorNode *op = alloc_node<OperatorNode>();
@@ -427,7 +427,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
tokenizer->advance();
if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_OPEN) {
_set_error("Expected '(' after 'preload'");
- return NULL;
+ return nullptr;
}
tokenizer->advance();
@@ -476,7 +476,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
if (!valid) {
_set_error("expected string constant as 'preload' argument.");
- return NULL;
+ return nullptr;
}
if (!path.is_abs_path() && base_path != "")
@@ -485,7 +485,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
if (path == self_path) {
_set_error("Can't preload itself (use 'get_script()').");
- return NULL;
+ return nullptr;
}
Ref<Resource> res;
@@ -503,26 +503,26 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
if (!FileAccess::exists(path)) {
_set_error("Can't preload resource at path: " + path);
- return NULL;
+ return nullptr;
} else if (ScriptCodeCompletionCache::get_singleton()) {
res = ScriptCodeCompletionCache::get_singleton()->get_cached_resource(path);
}
}
if (!res.is_valid()) {
_set_error("Can't preload resource at path: " + path);
- return NULL;
+ return nullptr;
}
}
if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
_set_error("Expected ')' after 'preload' path");
- return NULL;
+ return nullptr;
}
Ref<GDScript> gds = res;
if (gds.is_valid() && !gds->is_valid()) {
_set_error("Couldn't fully preload the script, possible cyclic reference or compilation error. Use \"load()\" instead if a cyclic reference is intended.");
- return NULL;
+ return nullptr;
}
tokenizer->advance();
@@ -536,7 +536,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
if (!current_function) {
_set_error("\"yield()\" can only be used inside function blocks.");
- return NULL;
+ return nullptr;
}
current_function->has_yield = true;
@@ -544,7 +544,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
tokenizer->advance();
if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_OPEN) {
_set_error("Expected \"(\" after \"yield\".");
- return NULL;
+ return nullptr;
}
tokenizer->advance();
@@ -565,12 +565,12 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
Node *object = _parse_and_reduce_expression(p_parent, p_static);
if (!object)
- return NULL;
+ return nullptr;
yield->arguments.push_back(object);
if (tokenizer->get_token() != GDScriptTokenizer::TK_COMMA) {
_set_error("Expected \",\" after the first argument of \"yield\".");
- return NULL;
+ return nullptr;
}
tokenizer->advance();
@@ -591,12 +591,12 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
Node *signal = _parse_and_reduce_expression(p_parent, p_static);
if (!signal)
- return NULL;
+ return nullptr;
yield->arguments.push_back(signal);
if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
_set_error("Expected \")\" after the second argument of \"yield\".");
- return NULL;
+ return nullptr;
}
parenthesis--;
@@ -610,7 +610,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
if (p_static) {
_set_error("\"self\" isn't allowed in a static function or constant expression.");
- return NULL;
+ return nullptr;
}
//constant defined by tokenizer
SelfNode *self = alloc_node<SelfNode>();
@@ -631,7 +631,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
if (identifier == StringName()) {
_set_error("Built-in type constant or static function expected after \".\".");
- return NULL;
+ return nullptr;
}
if (!Variant::has_constant(bi_type, identifier)) {
@@ -657,7 +657,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
op->arguments.push_back(id);
if (!_parse_arguments(op, op->arguments, p_static, true, p_parsing_constant))
- return NULL;
+ return nullptr;
expr = op;
} else {
@@ -674,7 +674,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
}
if (!valid) {
_set_error("Static constant '" + identifier.operator String() + "' not present in built-in type " + Variant::get_type_name(bi_type) + ".");
- return NULL;
+ return nullptr;
}
}
} else {
@@ -746,10 +746,17 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
if (tokenizer->get_token() == GDScriptTokenizer::TK_CURSOR) {
_make_completable_call(0);
completion_node = op;
+
+ if (op->arguments[0]->type == GDScriptParser::Node::Type::TYPE_BUILT_IN_FUNCTION) {
+ BuiltInFunctionNode *bn = static_cast<BuiltInFunctionNode *>(op->arguments[0]);
+ if (bn->function == GDScriptFunctions::Function::RESOURCE_LOAD) {
+ completion_type = COMPLETION_RESOURCE_PATH;
+ }
+ }
}
if (!replaced) {
if (!_parse_arguments(op, op->arguments, p_static, true, p_parsing_constant))
- return NULL;
+ return nullptr;
expr = op;
}
} else if (tokenizer->is_token_literal(0, true)) {
@@ -789,7 +796,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
if (lv->assignments == 0) {
if (!lv->datatype.has_type) {
_set_error("Using assignment with operation on a variable that was never assigned.");
- return NULL;
+ return nullptr;
}
_add_warning(GDScriptWarning::UNASSIGNED_VARIABLE_OP_ASSIGN, -1, identifier.operator String());
}
@@ -827,6 +834,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
//check from singletons
ConstantNode *constant = alloc_node<ConstantNode>();
constant->value = GDScriptLanguage::get_singleton()->get_named_globals_map()[identifier];
+ constant->datatype = _type_from_variant(constant->value);
expr = constant;
bfn = true;
}
@@ -837,6 +845,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
if (scr.is_valid() && scr->is_valid()) {
ConstantNode *constant = alloc_node<ConstantNode>();
constant->value = scr;
+ constant->datatype = _type_from_variant(constant->value);
expr = constant;
bfn = true;
}
@@ -852,6 +861,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
if (parent_constants.has(identifier)) {
ConstantNode *constant = alloc_node<ConstantNode>();
constant->value = parent_constants[identifier];
+ constant->datatype = _type_from_variant(constant->value);
expr = constant;
bfn = true;
}
@@ -912,7 +922,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
if (e.op != OperatorNode::OP_NOT && tokenizer->get_token() == GDScriptTokenizer::TK_OP_NOT) {
_set_error("Misplaced 'not'.");
- return NULL;
+ return nullptr;
}
expression.push_back(e);
@@ -921,7 +931,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
/*
Node *subexpr=_parse_expression(op,p_static);
if (!subexpr)
- return NULL;
+ return nullptr;
op->arguments.push_back(subexpr);
expr=op;*/
@@ -929,7 +939,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
// 'is' operator with built-in type
if (!expr) {
_set_error("Expected identifier before 'is' operator");
- return NULL;
+ return nullptr;
}
OperatorNode *op = alloc_node<OperatorNode>();
op->op = OperatorNode::OP_IS_BUILTIN;
@@ -955,7 +965,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
if (tokenizer->get_token() == GDScriptTokenizer::TK_EOF) {
_set_error("Unterminated array");
- return NULL;
+ return nullptr;
} else if (tokenizer->get_token() == GDScriptTokenizer::TK_BRACKET_CLOSE) {
tokenizer->advance();
@@ -966,7 +976,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
} else if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) {
if (!expecting_comma) {
_set_error("expression or ']' expected");
- return NULL;
+ return nullptr;
}
expecting_comma = false;
@@ -975,11 +985,11 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
//parse expression
if (expecting_comma) {
_set_error("',' or ']' expected");
- return NULL;
+ return nullptr;
}
Node *n = _parse_expression(arr, p_static, p_allow_assign, p_parsing_constant);
if (!n)
- return NULL;
+ return nullptr;
arr->elements.push_back(n);
expecting_comma = true;
}
@@ -1001,7 +1011,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
};
- Node *key = NULL;
+ Node *key = nullptr;
Set<Variant> keys;
DictExpect expecting = DICT_EXPECT_KEY;
@@ -1011,17 +1021,17 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
if (tokenizer->get_token() == GDScriptTokenizer::TK_EOF) {
_set_error("Unterminated dictionary");
- return NULL;
+ return nullptr;
} else if (tokenizer->get_token() == GDScriptTokenizer::TK_CURLY_BRACKET_CLOSE) {
if (expecting == DICT_EXPECT_COLON) {
_set_error("':' expected");
- return NULL;
+ return nullptr;
}
if (expecting == DICT_EXPECT_VALUE) {
_set_error("value expected");
- return NULL;
+ return nullptr;
}
tokenizer->advance();
break;
@@ -1032,15 +1042,15 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
if (expecting == DICT_EXPECT_KEY) {
_set_error("key or '}' expected");
- return NULL;
+ return nullptr;
}
if (expecting == DICT_EXPECT_VALUE) {
_set_error("value expected");
- return NULL;
+ return nullptr;
}
if (expecting == DICT_EXPECT_COLON) {
_set_error("':' expected");
- return NULL;
+ return nullptr;
}
expecting = DICT_EXPECT_KEY;
@@ -1050,15 +1060,15 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
if (expecting == DICT_EXPECT_KEY) {
_set_error("key or '}' expected");
- return NULL;
+ return nullptr;
}
if (expecting == DICT_EXPECT_VALUE) {
_set_error("value expected");
- return NULL;
+ return nullptr;
}
if (expecting == DICT_EXPECT_COMMA) {
_set_error("',' or '}' expected");
- return NULL;
+ return nullptr;
}
expecting = DICT_EXPECT_VALUE;
@@ -1067,11 +1077,11 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
if (expecting == DICT_EXPECT_COMMA) {
_set_error("',' or '}' expected");
- return NULL;
+ return nullptr;
}
if (expecting == DICT_EXPECT_COLON) {
_set_error("':' expected");
- return NULL;
+ return nullptr;
}
if (expecting == DICT_EXPECT_KEY) {
@@ -1089,7 +1099,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
//python/js style more flexible
key = _parse_expression(dict, p_static, p_allow_assign, p_parsing_constant);
if (!key)
- return NULL;
+ return nullptr;
expecting = DICT_EXPECT_COLON;
}
}
@@ -1097,7 +1107,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
if (expecting == DICT_EXPECT_VALUE) {
Node *value = _parse_expression(dict, p_static, p_allow_assign, p_parsing_constant);
if (!value)
- return NULL;
+ return nullptr;
expecting = DICT_EXPECT_COMMA;
if (key->type == GDScriptParser::Node::TYPE_CONSTANT) {
@@ -1105,7 +1115,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
if (keys.has(keyName)) {
_set_error("Duplicate key found in Dictionary literal");
- return NULL;
+ return nullptr;
}
keys.insert(keyName);
}
@@ -1114,7 +1124,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
pair.key = key;
pair.value = value;
dict->elements.push_back(pair);
- key = NULL;
+ key = nullptr;
}
}
}
@@ -1142,12 +1152,12 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_OPEN) {
if (!is_completion) {
_set_error("Expected '(' for parent function call.");
- return NULL;
+ return nullptr;
}
} else {
tokenizer->advance();
if (!_parse_arguments(op, op->arguments, p_static, false, p_parsing_constant)) {
- return NULL;
+ return nullptr;
}
}
@@ -1166,10 +1176,10 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
//find list [ or find dictionary {
_set_error("Error parsing expression, misplaced: " + String(tokenizer->get_token_name(tokenizer->get_token())));
- return NULL; //nothing
+ return nullptr; //nothing
}
- ERR_FAIL_COND_V_MSG(!expr, NULL, "GDScriptParser bug, couldn't figure out what expression is.");
+ ERR_FAIL_COND_V_MSG(!expr, nullptr, "GDScriptParser bug, couldn't figure out what expression is.");
/******************/
/* Parse Indexing */
@@ -1186,7 +1196,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
if (tokenizer->get_token(1) != GDScriptTokenizer::TK_CURSOR && !tokenizer->is_token_literal(1)) {
// We check with is_token_literal, as this allows us to use match/sync/etc. as a name
_set_error("Expected identifier as member");
- return NULL;
+ return nullptr;
} else if (tokenizer->get_token(2) == GDScriptTokenizer::TK_PARENTHESIS_OPEN) {
//call!!
OperatorNode *op = alloc_node<OperatorNode>();
@@ -1212,7 +1222,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
completion_node = op;
}
if (!_parse_arguments(op, op->arguments, p_static, true, p_parsing_constant))
- return NULL;
+ return nullptr;
expr = op;
} else {
@@ -1251,12 +1261,12 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
Node *subexpr = _parse_expression(op, p_static, p_allow_assign, p_parsing_constant);
if (!subexpr) {
- return NULL;
+ return nullptr;
}
if (tokenizer->get_token() != GDScriptTokenizer::TK_BRACKET_CLOSE) {
_set_error("Expected ']'");
- return NULL;
+ return nullptr;
}
op->arguments.push_back(expr);
@@ -1276,12 +1286,12 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
if (tokenizer->get_token() == GDScriptTokenizer::TK_PR_AS) {
if (has_casting) {
_set_error("Unexpected 'as'.");
- return NULL;
+ return nullptr;
}
CastNode *cn = alloc_node<CastNode>();
if (!_parse_type(cn->cast_type)) {
_set_error("Expected type after 'as'.");
- return NULL;
+ return nullptr;
}
has_casting = true;
cn->source_node = expr;
@@ -1313,7 +1323,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
#define _VALIDATE_ASSIGN \
if (!p_allow_assign || has_casting) { \
_set_error("Unexpected assign."); \
- return NULL; \
+ return nullptr; \
} \
p_allow_assign = false;
@@ -1479,7 +1489,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
default: {
_set_error("GDScriptParser bug, invalid operator in expression: " + itos(expression[i].op));
- return NULL;
+ return nullptr;
}
}
@@ -1488,7 +1498,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
// <= is used for right to left
if (error) {
_set_error("Unexpected operator");
- return NULL;
+ return nullptr;
}
next_op = i;
min_priority = priority;
@@ -1500,7 +1510,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
if (next_op == -1) {
_set_error("Yet another parser bug....");
- ERR_FAIL_V(NULL);
+ ERR_FAIL_V(nullptr);
}
// OK! create operator..
@@ -1513,7 +1523,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
if (expr_pos == expression.size()) {
//can happen..
_set_error("Unexpected end of expression...");
- return NULL;
+ return nullptr;
}
}
@@ -1532,16 +1542,16 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
} else if (is_ternary) {
if (next_op < 1 || next_op >= (expression.size() - 1)) {
_set_error("Parser bug...");
- ERR_FAIL_V(NULL);
+ ERR_FAIL_V(nullptr);
}
if (next_op >= (expression.size() - 2) || expression[next_op + 2].op != OperatorNode::OP_TERNARY_ELSE) {
_set_error("Expected else after ternary if.");
- return NULL;
+ return nullptr;
}
if (next_op >= (expression.size() - 3)) {
_set_error("Expected value after ternary else.");
- return NULL;
+ return nullptr;
}
OperatorNode *op = alloc_node<OperatorNode>();
@@ -1551,7 +1561,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
if (expression[next_op - 1].is_op) {
_set_error("Parser bug...");
- ERR_FAIL_V(NULL);
+ ERR_FAIL_V(nullptr);
}
if (expression[next_op + 1].is_op) {
@@ -1561,7 +1571,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
// due to how precedence works, unaries will always disappear first
_set_error("Unexpected two consecutive operators after ternary if.");
- return NULL;
+ return nullptr;
}
if (expression[next_op + 3].is_op) {
@@ -1571,7 +1581,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
// due to how precedence works, unaries will always disappear first
_set_error("Unexpected two consecutive operators after ternary else.");
- return NULL;
+ return nullptr;
}
op->arguments.push_back(expression[next_op + 1].node); //next expression goes as first
@@ -1588,7 +1598,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
if (next_op < 1 || next_op >= (expression.size() - 1)) {
_set_error("Parser bug...");
- ERR_FAIL_V(NULL);
+ ERR_FAIL_V(nullptr);
}
OperatorNode *op = alloc_node<OperatorNode>();
@@ -1598,7 +1608,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
if (expression[next_op - 1].is_op) {
_set_error("Parser bug...");
- ERR_FAIL_V(NULL);
+ ERR_FAIL_V(nullptr);
}
if (expression[next_op + 1].is_op) {
@@ -1608,7 +1618,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
// due to how precedence works, unaries will always disappear first
_set_error("Unexpected two consecutive operators.");
- return NULL;
+ return nullptr;
}
op->arguments.push_back(expression[next_op - 1].node); //expression goes as left
@@ -1725,7 +1735,7 @@ GDScriptParser::Node *GDScriptParser::_reduce_expression(Node *p_node, bool p_to
if ((op->arguments[0]->type == Node::TYPE_TYPE || (op->arguments[0]->type == Node::TYPE_BUILT_IN_FUNCTION && GDScriptFunctions::is_deterministic(static_cast<BuiltInFunctionNode *>(op->arguments[0])->function))) && last_not_constant == 0) {
//native type constructor or intrinsic function
- const Variant **vptr = NULL;
+ const Variant **vptr = nullptr;
Vector<Variant *> ptrs;
if (op->arguments.size() > 1) {
@@ -2015,13 +2025,45 @@ GDScriptParser::Node *GDScriptParser::_parse_and_reduce_expression(Node *p_paren
Node *expr = _parse_expression(p_parent, p_static, p_allow_assign, p_reduce_const);
if (!expr || error_set)
- return NULL;
+ return nullptr;
expr = _reduce_expression(expr, p_reduce_const);
if (!expr || error_set)
- return NULL;
+ return nullptr;
return expr;
}
+bool GDScriptParser::_reduce_export_var_type(Variant &p_value, int p_line) {
+
+ if (p_value.get_type() == Variant::ARRAY) {
+ Array arr = p_value;
+ for (int i = 0; i < arr.size(); i++) {
+ if (!_reduce_export_var_type(arr[i], p_line)) return false;
+ }
+ return true;
+ }
+
+ if (p_value.get_type() == Variant::DICTIONARY) {
+ Dictionary dict = p_value;
+ for (int i = 0; i < dict.size(); i++) {
+ Variant value = dict.get_value_at_index(i);
+ if (!_reduce_export_var_type(value, p_line)) return false;
+ }
+ return true;
+ }
+
+ // validate type
+ DataType type = _type_from_variant(p_value);
+ if (type.kind == DataType::BUILTIN) {
+ return true;
+ } else if (type.kind == DataType::NATIVE) {
+ if (ClassDB::is_parent_class(type.native_type, "Resource")) {
+ return true;
+ }
+ }
+ _set_error("Invalid export type. Only built-in and native resource types can be exported.", p_line);
+ return false;
+}
+
bool GDScriptParser::_recover_from_completion() {
if (!completion_found) {
@@ -2046,10 +2088,10 @@ GDScriptParser::PatternNode *GDScriptParser::_parse_pattern(bool p_static) {
GDScriptTokenizer::Token token = tokenizer->get_token();
if (error_set)
- return NULL;
+ return nullptr;
if (token == GDScriptTokenizer::TK_EOF) {
- return NULL;
+ return nullptr;
}
switch (token) {
@@ -2078,13 +2120,13 @@ GDScriptParser::PatternNode *GDScriptParser::_parse_pattern(bool p_static) {
break;
} else {
_set_error("'..' pattern only allowed at the end of an array pattern");
- return NULL;
+ return nullptr;
}
}
PatternNode *sub_pattern = _parse_pattern(p_static);
if (!sub_pattern) {
- return NULL;
+ return nullptr;
}
pattern->array.push_back(sub_pattern);
@@ -2097,7 +2139,7 @@ GDScriptParser::PatternNode *GDScriptParser::_parse_pattern(bool p_static) {
break;
} else {
_set_error("Not a valid pattern");
- return NULL;
+ return nullptr;
}
}
} break;
@@ -2106,7 +2148,7 @@ GDScriptParser::PatternNode *GDScriptParser::_parse_pattern(bool p_static) {
tokenizer->advance();
if (!tokenizer->is_token_literal()) {
_set_error("Expected identifier for binding variable name.");
- return NULL;
+ return nullptr;
}
pattern->pt_type = GDScriptParser::PatternNode::PT_BIND;
pattern->bind = tokenizer->get_token_literal();
@@ -2115,7 +2157,7 @@ GDScriptParser::PatternNode *GDScriptParser::_parse_pattern(bool p_static) {
while (bl) {
if (bl->variables.has(pattern->bind)) {
_set_error("Binding name of '" + pattern->bind.operator String() + "' is already declared in this scope.");
- return NULL;
+ return nullptr;
}
bl = bl->parent_block;
}
@@ -2150,19 +2192,19 @@ GDScriptParser::PatternNode *GDScriptParser::_parse_pattern(bool p_static) {
break;
} else {
_set_error("'..' pattern only allowed at the end of a dictionary pattern");
- return NULL;
+ return nullptr;
}
}
Node *key = _parse_and_reduce_expression(pattern, p_static);
if (!key) {
_set_error("Not a valid key in pattern");
- return NULL;
+ return nullptr;
}
if (key->type != GDScriptParser::Node::TYPE_CONSTANT) {
_set_error("Not a constant expression as key");
- return NULL;
+ return nullptr;
}
if (tokenizer->get_token() == GDScriptTokenizer::TK_COLON) {
@@ -2171,12 +2213,12 @@ GDScriptParser::PatternNode *GDScriptParser::_parse_pattern(bool p_static) {
PatternNode *value = _parse_pattern(p_static);
if (!value) {
_set_error("Expected pattern in dictionary value");
- return NULL;
+ return nullptr;
}
pattern->dictionary.insert(static_cast<ConstantNode *>(key), value);
} else {
- pattern->dictionary.insert(static_cast<ConstantNode *>(key), NULL);
+ pattern->dictionary.insert(static_cast<ConstantNode *>(key), nullptr);
}
if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) {
@@ -2187,7 +2229,7 @@ GDScriptParser::PatternNode *GDScriptParser::_parse_pattern(bool p_static) {
break;
} else {
_set_error("Not a valid pattern");
- return NULL;
+ return nullptr;
}
}
} break;
@@ -2200,7 +2242,7 @@ GDScriptParser::PatternNode *GDScriptParser::_parse_pattern(bool p_static) {
Node *value = _parse_and_reduce_expression(pattern, p_static);
if (!value) {
_set_error("Expect constant expression or variables in a pattern");
- return NULL;
+ return nullptr;
}
if (value->type == Node::TYPE_OPERATOR) {
@@ -2212,19 +2254,19 @@ GDScriptParser::PatternNode *GDScriptParser::_parse_pattern(bool p_static) {
if (op_node->op != OperatorNode::OP_INDEX_NAMED) {
_set_error("Invalid operator in pattern. Only index (`A.B`) is allowed");
- return NULL;
+ return nullptr;
}
current_value = op_node->arguments[0];
}
if (current_value->type != Node::TYPE_IDENTIFIER) {
_set_error("Only constant expression or variables allowed in a pattern");
- return NULL;
+ return nullptr;
}
} else if (value->type != Node::TYPE_IDENTIFIER && value->type != Node::TYPE_CONSTANT) {
_set_error("Only constant expressions or variables allowed in a pattern");
- return NULL;
+ return nullptr;
}
pattern->pt_type = PatternNode::PT_CONSTANT;
@@ -2332,7 +2374,7 @@ void GDScriptParser::_generate_pattern(PatternNode *p_pattern, Node *p_node_to_m
return;
}
- OperatorNode *type_comp = NULL;
+ OperatorNode *type_comp = nullptr;
// static type check if possible
if (pattern_type.has_type && to_match_type.has_type) {
@@ -2386,6 +2428,7 @@ void GDScriptParser::_generate_pattern(PatternNode *p_pattern, Node *p_node_to_m
// a bind always matches
ConstantNode *true_value = alloc_node<ConstantNode>();
true_value->value = Variant(true);
+ true_value->datatype = _type_from_variant(true_value->value);
p_resulting_node = true_value;
} break;
case PatternNode::PT_ARRAY: {
@@ -2402,7 +2445,7 @@ void GDScriptParser::_generate_pattern(PatternNode *p_pattern, Node *p_node_to_m
// typeof(value_to_match) == TYPE_ARRAY && value_to_match.size() == length
{
- OperatorNode *type_comp = NULL;
+ OperatorNode *type_comp = nullptr;
// static type check if possible
if (to_match_type.has_type) {
// must be an array
@@ -2432,6 +2475,7 @@ void GDScriptParser::_generate_pattern(PatternNode *p_pattern, Node *p_node_to_m
// size
ConstantNode *length = alloc_node<ConstantNode>();
length->value = Variant(open_ended ? p_pattern->array.size() - 1 : p_pattern->array.size());
+ length->datatype = _type_from_variant(length->value);
OperatorNode *call = alloc_node<OperatorNode>();
call->op = OperatorNode::OP_CALL;
@@ -2461,10 +2505,11 @@ void GDScriptParser::_generate_pattern(PatternNode *p_pattern, Node *p_node_to_m
for (int i = 0; i < p_pattern->array.size(); i++) {
PatternNode *pattern = p_pattern->array[i];
- Node *condition = NULL;
+ Node *condition = nullptr;
ConstantNode *index = alloc_node<ConstantNode>();
index->value = Variant(i);
+ index->datatype = _type_from_variant(index->value);
OperatorNode *indexed_value = alloc_node<OperatorNode>();
indexed_value->op = OperatorNode::OP_INDEX;
@@ -2495,7 +2540,7 @@ void GDScriptParser::_generate_pattern(PatternNode *p_pattern, Node *p_node_to_m
// typeof(value_to_match) == TYPE_DICTIONARY && value_to_match.size() == length
{
- OperatorNode *type_comp = NULL;
+ OperatorNode *type_comp = nullptr;
// static type check if possible
if (to_match_type.has_type) {
// must be an dictionary
@@ -2525,6 +2570,7 @@ void GDScriptParser::_generate_pattern(PatternNode *p_pattern, Node *p_node_to_m
// size
ConstantNode *length = alloc_node<ConstantNode>();
length->value = Variant(open_ended ? p_pattern->dictionary.size() - 1 : p_pattern->dictionary.size());
+ length->datatype = _type_from_variant(length->value);
OperatorNode *call = alloc_node<OperatorNode>();
call->op = OperatorNode::OP_CALL;
@@ -2553,7 +2599,7 @@ void GDScriptParser::_generate_pattern(PatternNode *p_pattern, Node *p_node_to_m
for (Map<ConstantNode *, PatternNode *>::Element *e = p_pattern->dictionary.front(); e; e = e->next()) {
- Node *condition = NULL;
+ Node *condition = nullptr;
// check for has, then for pattern
@@ -2601,6 +2647,7 @@ void GDScriptParser::_generate_pattern(PatternNode *p_pattern, Node *p_node_to_m
// simply generate a `true`
ConstantNode *true_value = alloc_node<ConstantNode>();
true_value->value = Variant(true);
+ true_value->datatype = _type_from_variant(true_value->value);
p_resulting_node = true_value;
} break;
default: {
@@ -2629,7 +2676,7 @@ void GDScriptParser::_transform_match_statment(MatchNode *p_match_statement) {
PatternBranchNode *branch = p_match_statement->branches[i];
MatchNode::CompiledPatternBranch compiled_branch;
- compiled_branch.compiled_pattern = NULL;
+ compiled_branch.compiled_pattern = nullptr;
Map<StringName, Node *> binding;
@@ -2638,7 +2685,7 @@ void GDScriptParser::_transform_match_statment(MatchNode *p_match_statement) {
_mark_line_as_safe(pattern->line);
Map<StringName, Node *> bindings;
- Node *resulting_node = NULL;
+ Node *resulting_node = nullptr;
_generate_pattern(pattern, id, resulting_node, bindings);
if (!resulting_node) {
@@ -2683,6 +2730,7 @@ void GDScriptParser::_transform_match_statment(MatchNode *p_match_statement) {
LocalVarNode *local_var = branch->body->variables[e->key()];
local_var->assign = e->value();
local_var->set_datatype(local_var->assign->get_datatype());
+ local_var->assignments++;
IdentifierNode *id2 = alloc_node<IdentifierNode>();
id2->name = local_var->name;
@@ -2785,6 +2833,7 @@ void GDScriptParser::_parse_block(BlockNode *p_block, bool p_static) {
return;
}
+ _mark_line_as_safe(line);
NewLineNode *nl2 = alloc_node<NewLineNode>();
nl2->line = line;
p_block->statements.push_back(nl2);
@@ -2838,7 +2887,7 @@ void GDScriptParser::_parse_block(BlockNode *p_block, bool p_static) {
lv->line = var_line;
p_block->statements.push_back(lv);
- Node *assigned = NULL;
+ Node *assigned = nullptr;
if (tokenizer->get_token() == GDScriptTokenizer::TK_COLON) {
if (tokenizer->get_token(1) == GDScriptTokenizer::TK_OP_ASSIGN) {
@@ -3113,7 +3162,6 @@ void GDScriptParser::_parse_block(BlockNode *p_block, bool p_static) {
}
} else {
constant = false;
- break;
}
}
@@ -3299,6 +3347,8 @@ void GDScriptParser::_parse_block(BlockNode *p_block, bool p_static) {
return;
}
+ int assert_line = tokenizer->get_token_line();
+
tokenizer->advance();
Vector<Node *> args;
@@ -3312,14 +3362,21 @@ void GDScriptParser::_parse_block(BlockNode *p_block, bool p_static) {
return;
}
+#ifdef DEBUG_ENABLED
+ // Mark as safe, let type check mark as unsafe if needed
+ _mark_line_as_safe(assert_line);
+ _reduce_node_type(args[0]);
+#endif
AssertNode *an = alloc_node<AssertNode>();
an->condition = _reduce_expression(args[0], p_static);
+ an->line = assert_line;
if (args.size() == 2) {
an->message = _reduce_expression(args[1], p_static);
} else {
ConstantNode *message_node = alloc_node<ConstantNode>();
message_node->value = String();
+ message_node->datatype = _type_from_variant(message_node->value);
an->message = message_node;
}
@@ -3674,6 +3731,12 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
_set_error("A constant named \"" + String(name) + "\" already exists in the outer class scope (at line" + itos(outer_class->constant_expressions[name].expression->line) + ").");
return;
}
+ for (int i = 0; i < outer_class->variables.size(); i++) {
+ if (outer_class->variables[i].identifier == name) {
+ _set_error("A variable named \"" + String(name) + "\" already exists in the outer class scope (at line " + itos(outer_class->variables[i].line) + ").");
+ return;
+ }
+ }
outer_class = outer_class->owner;
}
@@ -3935,7 +3998,7 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
current_function = function;
Node *arg = _parse_and_reduce_expression(p_class, _static);
- current_function = NULL;
+ current_function = nullptr;
cparent->arguments.push_back(arg);
if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) {
@@ -3990,7 +4053,7 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
function->body = block;
current_block = block;
_parse_block(block, _static);
- current_block = NULL;
+ current_block = nullptr;
//arguments
} break;
@@ -4736,7 +4799,7 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
}
member.identifier = tokenizer->get_token_literal();
- member.expression = NULL;
+ member.expression = nullptr;
member._export.name = member.identifier;
member.line = tokenizer->get_token_line();
member.usages = 0;
@@ -4816,7 +4879,7 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
#ifdef TOOLS_ENABLED
Callable::CallError ce;
- member.default_value = Variant::construct(member._export.type, NULL, 0, ce);
+ member.default_value = Variant::construct(member._export.type, nullptr, 0, ce);
#endif
if (tokenizer->get_token() == GDScriptTokenizer::TK_OP_ASSIGN) {
@@ -4864,12 +4927,15 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
_set_error("Can't accept a null constant expression for inferring export type.");
return;
}
+
+ if (!_reduce_export_var_type(cn->value, member.line)) return;
+
member._export.type = cn->value.get_type();
member._export.usage |= PROPERTY_USAGE_SCRIPT_VARIABLE;
if (cn->value.get_type() == Variant::OBJECT) {
Object *obj = cn->value;
Resource *res = Object::cast_to<Resource>(obj);
- if (res == NULL) {
+ if (res == nullptr) {
_set_error("The exported constant isn't a type or resource.");
return;
}
@@ -5257,7 +5323,7 @@ void GDScriptParser::_determine_inheritance(ClassNode *p_class, bool p_recursive
Ref<GDScript> script;
StringName native;
- ClassNode *base_class = NULL;
+ ClassNode *base_class = nullptr;
if (path != "") {
//path (and optionally subclasses)
@@ -5319,7 +5385,7 @@ void GDScriptParser::_determine_inheritance(ClassNode *p_class, bool p_recursive
_set_error("The class \"" + base + "\" couldn't be fully loaded (script error or cyclic dependency).", p_class->line);
return;
}
- p = NULL;
+ p = nullptr;
} else {
List<PropertyInfo> props;
ProjectSettings::get_singleton()->get_property_list(&props);
@@ -5342,7 +5408,7 @@ void GDScriptParser::_determine_inheritance(ClassNode *p_class, bool p_recursive
_set_error("Class '" + base + "' could not be fully loaded (script error or cyclic inheritance).", p_class->line);
return;
}
- p = NULL;
+ p = nullptr;
}
}
}
@@ -5662,7 +5728,7 @@ GDScriptParser::DataType GDScriptParser::_resolve_type(const DataType &p_source,
StringName id = full_name[name_part];
DataType base_type = result;
- ClassNode *p = NULL;
+ ClassNode *p = nullptr;
if (name_part == 0) {
if (ScriptServer::is_global_class(id)) {
String script_path = ScriptServer::get_global_class_path(id);
@@ -5944,7 +6010,7 @@ GDScriptParser::DataType GDScriptParser::_get_operation_type(const Variant::Oper
a = a_ref;
} else {
Callable::CallError err;
- a = Variant::construct(a_type, NULL, 0, err);
+ a = Variant::construct(a_type, nullptr, 0, err);
if (err.error != Callable::CallError::CALL_OK) {
r_valid = false;
return DataType();
@@ -5957,7 +6023,7 @@ GDScriptParser::DataType GDScriptParser::_get_operation_type(const Variant::Oper
b = b_ref;
} else {
Callable::CallError err;
- b = Variant::construct(b_type, NULL, 0, err);
+ b = Variant::construct(b_type, nullptr, 0, err);
if (err.error != Callable::CallError::CALL_OK) {
r_valid = false;
return DataType();
@@ -6118,7 +6184,7 @@ bool GDScriptParser::_is_type_compatible(const DataType &p_container, const Data
StringName expr_native;
Ref<Script> expr_script;
- ClassNode *expr_class = NULL;
+ ClassNode *expr_class = nullptr;
switch (p_expression.kind) {
case DataType::NATIVE: {
@@ -6229,12 +6295,14 @@ GDScriptParser::Node *GDScriptParser::_get_default_value_for_type(const DataType
} else {
ConstantNode *c = alloc_node<ConstantNode>();
Callable::CallError err;
- c->value = Variant::construct(p_type.builtin_type, NULL, 0, err);
+ c->value = Variant::construct(p_type.builtin_type, nullptr, 0, err);
+ c->datatype = _type_from_variant(c->value);
result = c;
}
} else {
ConstantNode *c = alloc_node<ConstantNode>();
c->value = Variant();
+ c->datatype = _type_from_variant(c->value);
result = c;
}
@@ -6308,7 +6376,7 @@ GDScriptParser::DataType GDScriptParser::_reduce_node_type(Node *p_node) {
int idx = current_function->arguments.find(id->name);
node_type = current_function->argument_types[idx];
} else {
- node_type = _reduce_identifier_type(NULL, id->name, id->line, false);
+ node_type = _reduce_identifier_type(nullptr, id->name, id->line, false);
}
} break;
case Node::TYPE_CAST: {
@@ -6542,7 +6610,7 @@ GDScriptParser::DataType GDScriptParser::_reduce_node_type(Node *p_node) {
} break;
default: {
Callable::CallError err;
- Variant temp = Variant::construct(base_type.builtin_type, NULL, 0, err);
+ Variant temp = Variant::construct(base_type.builtin_type, nullptr, 0, err);
bool valid = false;
Variant res = temp.get(member_id->name.operator String(), &valid);
@@ -6563,6 +6631,7 @@ GDScriptParser::DataType GDScriptParser::_reduce_node_type(Node *p_node) {
node_type = _reduce_identifier_type(&base_type, member_id->name, op->line, true);
#ifdef DEBUG_ENABLED
if (!node_type.has_type) {
+ _mark_line_as_unsafe(op->line);
_add_warning(GDScriptWarning::UNSAFE_PROPERTY_ACCESS, op->line, member_id->name.operator String(), base_type.to_string());
}
#endif // DEBUG_ENABLED
@@ -6671,7 +6740,7 @@ GDScriptParser::DataType GDScriptParser::_reduce_node_type(Node *p_node) {
}
default: {
Callable::CallError err;
- Variant temp = Variant::construct(base_type.builtin_type, NULL, 0, err);
+ Variant temp = Variant::construct(base_type.builtin_type, nullptr, 0, err);
bool valid = false;
Variant res = temp.get(cn->value, &valid);
@@ -6778,8 +6847,8 @@ bool GDScriptParser::_get_function_signature(DataType &p_base_type, const String
r_default_arg_count = 0;
DataType original_type = p_base_type;
- ClassNode *base = NULL;
- FunctionNode *callee = NULL;
+ ClassNode *base = nullptr;
+ FunctionNode *callee = nullptr;
if (p_base_type.kind == DataType::CLASS) {
base = p_base_type.class_type;
@@ -7112,7 +7181,7 @@ GDScriptParser::DataType GDScriptParser::_reduce_function_call_type(const Operat
if (base_type.kind == DataType::BUILTIN) {
Callable::CallError err;
- Variant tmp = Variant::construct(base_type.builtin_type, NULL, 0, err);
+ Variant tmp = Variant::construct(base_type.builtin_type, nullptr, 0, err);
if (check_types) {
if (!tmp.has_method(callee_name)) {
@@ -7276,7 +7345,7 @@ bool GDScriptParser::_get_member_type(const DataType &p_base_type, const StringN
DataType base_type = p_base_type;
// Check classes in current file
- ClassNode *base = NULL;
+ ClassNode *base = nullptr;
if (base_type.kind == DataType::CLASS) {
base = base_type.class_type;
}
@@ -7365,6 +7434,8 @@ bool GDScriptParser::_get_member_type(const DataType &p_base_type, const StringN
}
}
+#define IS_USAGE_MEMBER(m_usage) (!(m_usage & (PROPERTY_USAGE_GROUP | PROPERTY_USAGE_SUBGROUP | PROPERTY_USAGE_CATEGORY)))
+
// Check other script types
while (scr.is_valid()) {
Map<StringName, Variant> constants;
@@ -7377,7 +7448,7 @@ bool GDScriptParser::_get_member_type(const DataType &p_base_type, const StringN
List<PropertyInfo> properties;
scr->get_script_property_list(&properties);
for (List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) {
- if (E->get().name == p_member) {
+ if (E->get().name == p_member && IS_USAGE_MEMBER(E->get().usage)) {
r_member_type = _type_from_property(E->get());
return true;
}
@@ -7419,7 +7490,7 @@ bool GDScriptParser::_get_member_type(const DataType &p_base_type, const StringN
List<PropertyInfo> properties;
ClassDB::get_property_list(native, &properties);
for (List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) {
- if (E->get().name == p_member) {
+ if (E->get().name == p_member && IS_USAGE_MEMBER(E->get().usage)) {
// Check if a getter exists
StringName getter_name = ClassDB::get_property_getter(native, p_member);
if (getter_name != StringName()) {
@@ -7459,7 +7530,7 @@ bool GDScriptParser::_get_member_type(const DataType &p_base_type, const StringN
List<PropertyInfo> properties;
ClassDB::get_property_list(native, &properties);
for (List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) {
- if (E->get().name == p_member) {
+ if (E->get().name == p_member && IS_USAGE_MEMBER(E->get().usage)) {
// Check if a getter exists
StringName getter_name = ClassDB::get_property_getter(native, p_member);
if (getter_name != StringName()) {
@@ -7481,6 +7552,7 @@ bool GDScriptParser::_get_member_type(const DataType &p_base_type, const StringN
}
}
}
+#undef IS_USAGE_MEMBER
return false;
}
@@ -7994,8 +8066,8 @@ void GDScriptParser::_check_class_blocks_types(ClassNode *p_class) {
current_block = current_function->body;
_mark_line_as_safe(current_function->line);
_check_block_types(current_block);
- current_block = NULL;
- current_function = NULL;
+ current_block = nullptr;
+ current_function = nullptr;
if (error_set) return;
}
@@ -8004,8 +8076,8 @@ void GDScriptParser::_check_class_blocks_types(ClassNode *p_class) {
current_block = current_function->body;
_mark_line_as_safe(current_function->line);
_check_block_types(current_block);
- current_block = NULL;
- current_function = NULL;
+ current_block = nullptr;
+ current_function = nullptr;
if (error_set) return;
}
@@ -8054,7 +8126,7 @@ static String _find_function_name(const GDScriptParser::OperatorNode *p_call) {
void GDScriptParser::_check_block_types(BlockNode *p_block) {
- Node *last_var_assign = NULL;
+ Node *last_var_assign = nullptr;
// Check each statement
for (List<Node *>::Element *E = p_block->statements.front(); E; E = E->next()) {
@@ -8108,6 +8180,7 @@ void GDScriptParser::_check_block_types(BlockNode *p_block) {
ConstantNode *tgt_type = alloc_node<ConstantNode>();
tgt_type->line = lv->line;
tgt_type->value = (int)lv->datatype.builtin_type;
+ tgt_type->datatype = _type_from_variant(tgt_type->value);
OperatorNode *convert_call = alloc_node<OperatorNode>();
convert_call->line = lv->line;
@@ -8243,6 +8316,7 @@ void GDScriptParser::_check_block_types(BlockNode *p_block) {
ConstantNode *tgt_type = alloc_node<ConstantNode>();
tgt_type->line = op->line;
tgt_type->value = (int)lh_type.builtin_type;
+ tgt_type->datatype = _type_from_variant(tgt_type->value);
OperatorNode *convert_call = alloc_node<OperatorNode>();
convert_call->line = op->line;
@@ -8445,7 +8519,7 @@ void GDScriptParser::_add_warning(int p_code, int p_line, const Vector<String> &
warn.symbols = p_symbols;
warn.line = p_line == -1 ? tokenizer->get_token_line() : p_line;
- List<GDScriptWarning>::Element *before = NULL;
+ List<GDScriptWarning>::Element *before = nullptr;
for (List<GDScriptWarning>::Element *E = warnings.front(); E; E = E->next()) {
if (E->get().line > warn.line) {
break;
@@ -8512,8 +8586,8 @@ Error GDScriptParser::_parse(const String &p_base_path) {
}
current_class = main_class;
- current_function = NULL;
- current_block = NULL;
+ current_function = nullptr;
+ current_block = nullptr;
if (for_completion) check_types = false;
@@ -8576,7 +8650,7 @@ Error GDScriptParser::parse_bytecode(const Vector<uint8_t> &p_bytecode, const St
tokenizer = tb;
Error ret = _parse(p_base_path);
memdelete(tb);
- tokenizer = NULL;
+ tokenizer = nullptr;
return ret;
}
@@ -8597,7 +8671,7 @@ Error GDScriptParser::parse(const String &p_code, const String &p_base_path, boo
tokenizer = tt;
Error ret = _parse(p_base_path);
memdelete(tt);
- tokenizer = NULL;
+ tokenizer = nullptr;
return ret;
}
@@ -8620,21 +8694,21 @@ void GDScriptParser::clear() {
memdelete(l);
}
- head = NULL;
- list = NULL;
+ head = nullptr;
+ list = nullptr;
completion_type = COMPLETION_NONE;
- completion_node = NULL;
- completion_class = NULL;
- completion_function = NULL;
- completion_block = NULL;
- current_block = NULL;
- current_class = NULL;
+ completion_node = nullptr;
+ completion_class = nullptr;
+ completion_function = nullptr;
+ completion_block = nullptr;
+ current_block = nullptr;
+ current_class = nullptr;
completion_found = false;
rpc_mode = MultiplayerAPI::RPC_MODE_DISABLED;
- current_function = NULL;
+ current_function = nullptr;
validating = false;
for_completion = false;
@@ -8651,7 +8725,7 @@ void GDScriptParser::clear() {
dependencies.clear();
error = "";
#ifdef DEBUG_ENABLED
- safe_lines = NULL;
+ safe_lines = nullptr;
#endif // DEBUG_ENABLED
}
@@ -8707,9 +8781,9 @@ int GDScriptParser::get_completion_identifier_is_function() {
GDScriptParser::GDScriptParser() {
- head = NULL;
- list = NULL;
- tokenizer = NULL;
+ head = nullptr;
+ list = nullptr;
+ tokenizer = nullptr;
pending_newline = -1;
clear();
}
diff --git a/modules/gdscript/gdscript_parser.h b/modules/gdscript/gdscript_parser.h
index c74d7dd856..f254352423 100644
--- a/modules/gdscript/gdscript_parser.h
+++ b/modules/gdscript/gdscript_parser.h
@@ -102,7 +102,7 @@ public:
infer_type(false),
may_yield(false),
builtin_type(Variant::NIL),
- class_type(NULL) {}
+ class_type(nullptr) {}
};
struct Node {
@@ -201,7 +201,7 @@ public:
extends_used = false;
classname_used = false;
end_line = -1;
- owner = NULL;
+ owner = nullptr;
}
};
@@ -248,11 +248,11 @@ public:
List<BlockNode *> sub_blocks;
int end_line;
BlockNode() {
- if_condition = NULL;
+ if_condition = nullptr;
type = TYPE_BLOCK;
end_line = -1;
- parent_block = NULL;
- parent_class = NULL;
+ parent_block = nullptr;
+ parent_class = nullptr;
has_return = false;
}
};
@@ -276,7 +276,7 @@ public:
virtual void set_datatype(const DataType &p_datatype) { datatype = p_datatype; }
IdentifierNode() {
type = TYPE_IDENTIFIER;
- declared_block = NULL;
+ declared_block = nullptr;
}
};
@@ -292,8 +292,8 @@ public:
virtual void set_datatype(const DataType &p_datatype) { datatype = p_datatype; }
LocalVarNode() {
type = TYPE_LOCAL_VAR;
- assign = NULL;
- assign_op = NULL;
+ assign = nullptr;
+ assign_op = nullptr;
assignments = 0;
usages = 0;
}
@@ -465,8 +465,8 @@ public:
ControlFlowNode() {
type = TYPE_CONTROL_FLOW;
cf_type = CF_IF;
- body = NULL;
- body_else = NULL;
+ body = nullptr;
+ body_else = nullptr;
}
};
@@ -608,11 +608,12 @@ private:
bool _recover_from_completion();
bool _parse_arguments(Node *p_parent, Vector<Node *> &p_args, bool p_static, bool p_can_codecomplete = false, bool p_parsing_constant = false);
- bool _enter_indent_block(BlockNode *p_block = NULL);
+ bool _enter_indent_block(BlockNode *p_block = nullptr);
bool _parse_newline();
Node *_parse_expression(Node *p_parent, bool p_static, bool p_allow_assign = false, bool p_parsing_constant = false);
Node *_reduce_expression(Node *p_node, bool p_to_const = false);
Node *_parse_and_reduce_expression(Node *p_parent, bool p_static, bool p_reduce_const = false, bool p_allow_assign = false);
+ bool _reduce_export_var_type(Variant &p_value, int p_line = 0);
PatternNode *_parse_pattern(bool p_static);
void _parse_pattern_block(BlockNode *p_block, Vector<PatternBranchNode *> &p_branches, bool p_static);
@@ -665,7 +666,7 @@ public:
#ifdef DEBUG_ENABLED
const List<GDScriptWarning> &get_warnings() const { return warnings; }
#endif // DEBUG_ENABLED
- Error parse(const String &p_code, const String &p_base_path = "", bool p_just_validate = false, const String &p_self_path = "", bool p_for_completion = false, Set<int> *r_safe_lines = NULL, bool p_dependencies_only = false);
+ Error parse(const String &p_code, const String &p_base_path = "", bool p_just_validate = false, const String &p_self_path = "", bool p_for_completion = false, Set<int> *r_safe_lines = nullptr, bool p_dependencies_only = false);
Error parse_bytecode(const Vector<uint8_t> &p_bytecode, const String &p_base_path = "", const String &p_self_path = "");
bool is_tool_script() const;
diff --git a/modules/gdscript/gdscript_tokenizer.cpp b/modules/gdscript/gdscript_tokenizer.cpp
index 9064998d32..d42ca52731 100644
--- a/modules/gdscript/gdscript_tokenizer.cpp
+++ b/modules/gdscript/gdscript_tokenizer.cpp
@@ -178,7 +178,7 @@ static const _bit _type_list[] = {
{ Variant::PACKED_VECTOR2_ARRAY, "PackedVector2Array" },
{ Variant::PACKED_VECTOR3_ARRAY, "PackedVector3Array" },
{ Variant::PACKED_COLOR_ARRAY, "PackedColorArray" },
- { Variant::VARIANT_MAX, NULL },
+ { Variant::VARIANT_MAX, nullptr },
};
struct _kws {
@@ -236,7 +236,7 @@ static const _kws _keyword_list[] = {
{ GDScriptTokenizer::TK_WILDCARD, "_" },
{ GDScriptTokenizer::TK_CONST_INF, "INF" },
{ GDScriptTokenizer::TK_CONST_NAN, "NAN" },
- { GDScriptTokenizer::TK_ERROR, NULL }
+ { GDScriptTokenizer::TK_ERROR, nullptr }
};
const char *GDScriptTokenizer::get_token_name(Token p_token) {
@@ -1075,7 +1075,7 @@ void GDScriptTokenizerText::set_code(const String &p_code) {
if (len) {
_code = &code[0];
} else {
- _code = NULL;
+ _code = nullptr;
}
code_pos = 0;
line = 1; //it is stand-ar-ized that lines begin in 1 in code..
@@ -1358,7 +1358,7 @@ Vector<uint8_t> GDScriptTokenizerBuffer::parse_code_string(const String &p_code)
}
Map<int, Variant> rev_constant_map;
- const Variant *K = NULL;
+ const Variant *K = nullptr;
while ((K = constant_map.next(K))) {
rev_constant_map[constant_map[*K]] = *K;
}
@@ -1407,7 +1407,7 @@ Vector<uint8_t> GDScriptTokenizerBuffer::parse_code_string(const String &p_code)
int len;
// Objects cannot be constant, never encode objects
- Error err = encode_variant(E->get(), NULL, len, false);
+ Error err = encode_variant(E->get(), nullptr, len, false);
ERR_FAIL_COND_V_MSG(err != OK, Vector<uint8_t>(), "Error when trying to encode Variant.");
int pos = buf.size();
buf.resize(pos + len);
diff --git a/modules/gdscript/gdscript_tokenizer.h b/modules/gdscript/gdscript_tokenizer.h
index 1b432ae8c1..180ec3c77e 100644
--- a/modules/gdscript/gdscript_tokenizer.h
+++ b/modules/gdscript/gdscript_tokenizer.h
@@ -32,6 +32,7 @@
#define GDSCRIPT_TOKENIZER_H
#include "core/pair.h"
+#include "core/set.h"
#include "core/string_name.h"
#include "core/ustring.h"
#include "core/variant.h"
diff --git a/modules/gdscript/language_server/gdscript_extend_parser.cpp b/modules/gdscript/language_server/gdscript_extend_parser.cpp
index 0f6f13944b..b2c6b0e1ab 100644
--- a/modules/gdscript/language_server/gdscript_extend_parser.cpp
+++ b/modules/gdscript/language_server/gdscript_extend_parser.cpp
@@ -327,7 +327,7 @@ void ExtendGDScriptParser::parse_function_symbol(const GDScriptParser::FunctionN
int default_value_idx = i - (p_func->arguments.size() - p_func->default_values.size());
if (default_value_idx >= 0) {
const GDScriptParser::ConstantNode *const_node = dynamic_cast<const GDScriptParser::ConstantNode *>(p_func->default_values[default_value_idx]);
- if (const_node == NULL) {
+ if (const_node == nullptr) {
const GDScriptParser::OperatorNode *operator_node = dynamic_cast<const GDScriptParser::OperatorNode *>(p_func->default_values[default_value_idx]);
if (operator_node) {
const_node = dynamic_cast<const GDScriptParser::ConstantNode *>(operator_node->next);
@@ -507,7 +507,7 @@ String ExtendGDScriptParser::get_uri() const {
}
const lsp::DocumentSymbol *ExtendGDScriptParser::search_symbol_defined_at_line(int p_line, const lsp::DocumentSymbol &p_parent) const {
- const lsp::DocumentSymbol *ret = NULL;
+ const lsp::DocumentSymbol *ret = nullptr;
if (p_line < p_parent.range.start.line) {
return ret;
} else if (p_parent.range.start.line == p_line) {
@@ -591,7 +591,7 @@ const lsp::DocumentSymbol *ExtendGDScriptParser::get_member_symbol(const String
}
}
- return NULL;
+ return nullptr;
}
const List<lsp::DocumentLink> &ExtendGDScriptParser::get_document_links() const {
@@ -602,7 +602,7 @@ const Array &ExtendGDScriptParser::get_member_completions() {
if (member_completions.empty()) {
- const String *name = members.next(NULL);
+ const String *name = members.next(nullptr);
while (name) {
const lsp::DocumentSymbol *symbol = members.get(*name);
@@ -613,11 +613,11 @@ const Array &ExtendGDScriptParser::get_member_completions() {
name = members.next(name);
}
- const String *_class = inner_classes.next(NULL);
+ const String *_class = inner_classes.next(nullptr);
while (_class) {
const ClassMembers *inner_class = inner_classes.getptr(*_class);
- const String *member_name = inner_class->next(NULL);
+ const String *member_name = inner_class->next(nullptr);
while (member_name) {
const lsp::DocumentSymbol *symbol = inner_class->get(*member_name);
lsp::CompletionItem item = symbol->make_completion_item();
@@ -648,7 +648,7 @@ Dictionary ExtendGDScriptParser::dump_function_api(const GDScriptParser::Functio
int default_value_idx = i - (p_func->arguments.size() - p_func->default_values.size());
if (default_value_idx >= 0) {
const GDScriptParser::ConstantNode *const_node = dynamic_cast<const GDScriptParser::ConstantNode *>(p_func->default_values[default_value_idx]);
- if (const_node == NULL) {
+ if (const_node == nullptr) {
const GDScriptParser::OperatorNode *operator_node = dynamic_cast<const GDScriptParser::OperatorNode *>(p_func->default_values[default_value_idx]);
if (operator_node) {
const_node = dynamic_cast<const GDScriptParser::ConstantNode *>(operator_node->next);
@@ -778,7 +778,7 @@ Error ExtendGDScriptParser::parse(const String &p_code, const String &p_path) {
path = p_path;
lines = p_code.split("\n");
- Error err = GDScriptParser::parse(p_code, p_path.get_base_dir(), false, p_path, false, NULL, false);
+ Error err = GDScriptParser::parse(p_code, p_path.get_base_dir(), false, p_path, false, nullptr, false);
update_diagnostics();
update_symbols();
update_document_links(p_code);
diff --git a/modules/gdscript/language_server/gdscript_language_protocol.cpp b/modules/gdscript/language_server/gdscript_language_protocol.cpp
index 2243a7b81d..69662e96f7 100644
--- a/modules/gdscript/language_server/gdscript_language_protocol.cpp
+++ b/modules/gdscript/language_server/gdscript_language_protocol.cpp
@@ -35,7 +35,7 @@
#include "editor/editor_log.h"
#include "editor/editor_node.h"
-GDScriptLanguageProtocol *GDScriptLanguageProtocol::singleton = NULL;
+GDScriptLanguageProtocol *GDScriptLanguageProtocol::singleton = nullptr;
Error GDScriptLanguageProtocol::LSPeer::handle_data() {
int read = 0;
@@ -191,7 +191,7 @@ Dictionary GDScriptLanguageProtocol::initialize(const Dictionary &p_params) {
Dictionary request = make_notification("gdscrip_client/changeWorkspace", params);
Ref<LSPeer> peer = clients.get(latest_client_id);
- if (peer != NULL) {
+ if (peer != nullptr) {
String msg = JSON::print(request);
msg = format_output(msg);
(*peer)->res_queue.push_back(msg.utf8());
@@ -230,26 +230,26 @@ void GDScriptLanguageProtocol::poll() {
if (server->is_connection_available()) {
on_client_connected();
}
- const int *id = NULL;
+ const int *id = nullptr;
while ((id = clients.next(id))) {
Ref<LSPeer> peer = clients.get(*id);
StreamPeerTCP::Status status = peer->connection->get_status();
if (status == StreamPeerTCP::STATUS_NONE || status == StreamPeerTCP::STATUS_ERROR) {
on_client_disconnected(*id);
- id = NULL;
+ id = nullptr;
} else {
if (peer->connection->get_available_bytes() > 0) {
latest_client_id = *id;
Error err = peer->handle_data();
if (err != OK && err != ERR_BUSY) {
on_client_disconnected(*id);
- id = NULL;
+ id = nullptr;
}
}
Error err = peer->send_data();
if (err != OK && err != ERR_BUSY) {
on_client_disconnected(*id);
- id = NULL;
+ id = nullptr;
}
}
}
@@ -260,7 +260,7 @@ Error GDScriptLanguageProtocol::start(int p_port, const IP_Address &p_bind_ip) {
}
void GDScriptLanguageProtocol::stop() {
- const int *id = NULL;
+ const int *id = nullptr;
while ((id = clients.next(id))) {
Ref<LSPeer> peer = clients.get(*id);
peer->connection->disconnect_from_host();
@@ -274,7 +274,7 @@ void GDScriptLanguageProtocol::notify_client(const String &p_method, const Varia
p_client_id = latest_client_id;
}
Ref<LSPeer> peer = clients.get(p_client_id);
- ERR_FAIL_COND(peer == NULL);
+ ERR_FAIL_COND(peer == nullptr);
Dictionary message = make_notification(p_method, p_params);
String msg = JSON::print(message);
diff --git a/modules/gdscript/language_server/gdscript_language_server.cpp b/modules/gdscript/language_server/gdscript_language_server.cpp
index 7170c63058..e1d86ecdd4 100644
--- a/modules/gdscript/language_server/gdscript_language_server.cpp
+++ b/modules/gdscript/language_server/gdscript_language_server.cpp
@@ -35,7 +35,7 @@
#include "editor/editor_node.h"
GDScriptLanguageServer::GDScriptLanguageServer() {
- thread = NULL;
+ thread = nullptr;
thread_running = false;
started = false;
@@ -87,7 +87,7 @@ void GDScriptLanguageServer::start() {
if (protocol.start(port, IP_Address("127.0.0.1")) == OK) {
EditorNode::get_log()->add_message("--- GDScript language server started ---", EditorLog::MSG_TYPE_EDITOR);
if (use_thread) {
- ERR_FAIL_COND(thread != NULL);
+ ERR_FAIL_COND(thread != nullptr);
thread_running = true;
thread = Thread::create(GDScriptLanguageServer::thread_main, this);
}
@@ -98,11 +98,11 @@ void GDScriptLanguageServer::start() {
void GDScriptLanguageServer::stop() {
if (use_thread) {
- ERR_FAIL_COND(NULL == thread);
+ ERR_FAIL_COND(nullptr == thread);
thread_running = false;
Thread::wait_to_finish(thread);
memdelete(thread);
- thread = NULL;
+ thread = nullptr;
}
protocol.stop();
started = false;
diff --git a/modules/gdscript/language_server/gdscript_text_document.cpp b/modules/gdscript/language_server/gdscript_text_document.cpp
index d5723fd20f..f065b33570 100644
--- a/modules/gdscript/language_server/gdscript_text_document.cpp
+++ b/modules/gdscript/language_server/gdscript_text_document.cpp
@@ -35,6 +35,7 @@
#include "editor/plugins/script_text_editor.h"
#include "gdscript_extend_parser.h"
#include "gdscript_language_protocol.h"
+#include "servers/display_server.h"
void GDScriptTextDocument::_bind_methods() {
ClassDB::bind_method(D_METHOD("didOpen"), &GDScriptTextDocument::didOpen);
@@ -89,12 +90,12 @@ void GDScriptTextDocument::initialize() {
const HashMap<StringName, ClassMembers> &native_members = GDScriptLanguageProtocol::get_singleton()->get_workspace()->native_members;
- const StringName *class_ptr = native_members.next(NULL);
+ const StringName *class_ptr = native_members.next(nullptr);
while (class_ptr) {
const ClassMembers &members = native_members.get(*class_ptr);
- const String *name = members.next(NULL);
+ const String *name = members.next(nullptr);
while (name) {
const lsp::DocumentSymbol *symbol = members.get(*name);
@@ -226,7 +227,7 @@ Dictionary GDScriptTextDocument::resolve(const Dictionary &p_params) {
lsp::CompletionParams params;
Variant data = p_params["data"];
- const lsp::DocumentSymbol *symbol = NULL;
+ const lsp::DocumentSymbol *symbol = nullptr;
if (data.get_type() == Variant::DICTIONARY) {
@@ -419,7 +420,8 @@ void GDScriptTextDocument::sync_script_content(const String &p_path, const Strin
void GDScriptTextDocument::show_native_symbol_in_editor(const String &p_symbol_id) {
ScriptEditor::get_singleton()->call_deferred("_help_class_goto", p_symbol_id);
- OS::get_singleton()->move_window_to_foreground();
+
+ DisplayServer::get_singleton()->window_move_to_foreground();
}
Array GDScriptTextDocument::find_symbols(const lsp::TextDocumentPositionParams &p_location, List<const lsp::DocumentSymbol *> &r_list) {
diff --git a/modules/gdscript/language_server/gdscript_workspace.cpp b/modules/gdscript/language_server/gdscript_workspace.cpp
index 205257b8f2..32fc8f36f0 100644
--- a/modules/gdscript/language_server/gdscript_workspace.cpp
+++ b/modules/gdscript/language_server/gdscript_workspace.cpp
@@ -93,7 +93,7 @@ const lsp::DocumentSymbol *GDScriptWorkspace::get_native_symbol(const String &p_
class_name = ClassDB::get_parent_class(class_name);
}
- return NULL;
+ return nullptr;
}
const lsp::DocumentSymbol *GDScriptWorkspace::get_script_symbol(const String &p_path) const {
@@ -101,7 +101,7 @@ const lsp::DocumentSymbol *GDScriptWorkspace::get_script_symbol(const String &p_
if (S) {
return &(S->get()->get_symbols());
}
- return NULL;
+ return nullptr;
}
void GDScriptWorkspace::reload_all_workspace_scripts() {
@@ -152,7 +152,7 @@ ExtendGDScriptParser *GDScriptWorkspace::get_parse_successed_script(const String
if (S) {
return S->get();
}
- return NULL;
+ return nullptr;
}
ExtendGDScriptParser *GDScriptWorkspace::get_parse_result(const String &p_path) {
@@ -164,7 +164,7 @@ ExtendGDScriptParser *GDScriptWorkspace::get_parse_result(const String &p_path)
if (S) {
return S->get();
}
- return NULL;
+ return nullptr;
}
Array GDScriptWorkspace::symbol(const Dictionary &p_params) {
@@ -402,7 +402,7 @@ void GDScriptWorkspace::_get_owners(EditorFileSystemDirectory *efsd, String p_pa
}
Node *GDScriptWorkspace::_get_owner_scene_node(String p_path) {
- Node *owner_scene_node = NULL;
+ Node *owner_scene_node = nullptr;
List<String> owners;
_get_owners(EditorFileSystem::get_singleton()->get_filesystem(), p_path, owners);
@@ -438,7 +438,7 @@ void GDScriptWorkspace::completion(const lsp::CompletionParams &p_params, List<S
const lsp::DocumentSymbol *GDScriptWorkspace::resolve_symbol(const lsp::TextDocumentPositionParams &p_doc_pos, const String &p_symbol_name, bool p_func_requred) {
- const lsp::DocumentSymbol *symbol = NULL;
+ const lsp::DocumentSymbol *symbol = nullptr;
String path = get_file_path(p_doc_pos.textDocument.uri);
if (const ExtendGDScriptParser *parser = get_parse_result(path)) {
@@ -466,7 +466,7 @@ const lsp::DocumentSymbol *GDScriptWorkspace::resolve_symbol(const lsp::TextDocu
} else {
ScriptLanguage::LookupResult ret;
- if (OK == GDScriptLanguage::get_singleton()->lookup_code(parser->get_text_for_lookup_symbol(pos, symbol_identifier, p_func_requred), symbol_identifier, path, NULL, ret)) {
+ if (OK == GDScriptLanguage::get_singleton()->lookup_code(parser->get_text_for_lookup_symbol(pos, symbol_identifier, p_func_requred), symbol_identifier, path, nullptr, ret)) {
if (ret.type == ScriptLanguage::LookupResult::RESULT_SCRIPT_LOCATION) {
@@ -506,7 +506,7 @@ void GDScriptWorkspace::resolve_related_symbols(const lsp::TextDocumentPositionP
Vector2i offset;
symbol_identifier = parser->get_identifier_under_position(p_doc_pos.position, offset);
- const StringName *class_ptr = native_members.next(NULL);
+ const StringName *class_ptr = native_members.next(nullptr);
while (class_ptr) {
const ClassMembers &members = native_members.get(*class_ptr);
if (const lsp::DocumentSymbol *const *symbol = members.getptr(symbol_identifier)) {
@@ -523,7 +523,7 @@ void GDScriptWorkspace::resolve_related_symbols(const lsp::TextDocumentPositionP
}
const HashMap<String, ClassMembers> &inner_classes = script->get_inner_classes();
- const String *_class = inner_classes.next(NULL);
+ const String *_class = inner_classes.next(nullptr);
while (_class) {
const ClassMembers *inner_class = inner_classes.getptr(*_class);
@@ -552,7 +552,7 @@ const lsp::DocumentSymbol *GDScriptWorkspace::resolve_native_symbol(const lsp::N
}
}
- return NULL;
+ return nullptr;
}
void GDScriptWorkspace::resolve_document_links(const String &p_uri, List<lsp::DocumentLink> &r_list) {
diff --git a/modules/gdscript/language_server/lsp.hpp b/modules/gdscript/language_server/lsp.hpp
index a2dcc48820..124fcbfed8 100644
--- a/modules/gdscript/language_server/lsp.hpp
+++ b/modules/gdscript/language_server/lsp.hpp
@@ -33,7 +33,7 @@
#include "core/class_db.h"
#include "core/list.h"
-#include "editor/doc/doc_data.h"
+#include "editor/doc_data.h"
namespace lsp {
@@ -156,7 +156,7 @@ struct LocationLink {
* Used as the underlined span for mouse interaction. Defaults to the word range at
* the mouse position.
*/
- Range *originSelectionRange = NULL;
+ Range *originSelectionRange = nullptr;
/**
* The target resource identifier of this link.
@@ -1686,8 +1686,8 @@ struct InitializeResult {
struct GodotNativeClassInfo {
String name;
- const DocData::ClassDoc *class_doc = NULL;
- const ClassDB::ClassInfo *class_info = NULL;
+ const DocData::ClassDoc *class_doc = nullptr;
+ const ClassDB::ClassInfo *class_info = nullptr;
Dictionary to_json() {
Dictionary dict;
diff --git a/modules/gdscript/register_types.cpp b/modules/gdscript/register_types.cpp
index b5eb09d6ba..62b9d94d6c 100644
--- a/modules/gdscript/register_types.cpp
+++ b/modules/gdscript/register_types.cpp
@@ -37,7 +37,7 @@
#include "gdscript.h"
#include "gdscript_tokenizer.h"
-GDScriptLanguage *script_language_gd = NULL;
+GDScriptLanguage *script_language_gd = nullptr;
Ref<ResourceFormatLoaderGDScript> resource_loader_gd;
Ref<ResourceFormatSaverGDScript> resource_saver_gd;
diff --git a/modules/glslang/SCsub b/modules/glslang/SCsub
index ae102238f2..c1d23a138b 100644
--- a/modules/glslang/SCsub
+++ b/modules/glslang/SCsub
@@ -1,12 +1,12 @@
#!/usr/bin/env python
-Import('env')
-Import('env_modules')
+Import("env")
+Import("env_modules")
env_glslang = env_modules.Clone()
# Thirdparty source files
-if env['builtin_glslang']:
+if env["builtin_glslang"]:
thirdparty_dir = "#thirdparty/glslang/"
thirdparty_sources = [
"glslang/MachineIndependent/RemoveTree.cpp",
@@ -48,10 +48,10 @@ if env['builtin_glslang']:
"SPIRV/doc.cpp",
"SPIRV/SPVRemapper.cpp",
"SPIRV/SpvPostProcess.cpp",
- "SPIRV/Logger.cpp"
+ "SPIRV/Logger.cpp",
]
- if (env["platform"]=="windows"):
+ if env["platform"] == "windows":
thirdparty_sources.append("glslang/OSDependent/Windows/ossource.cpp")
else:
thirdparty_sources.append("glslang/OSDependent/Unix/ossource.cpp")
@@ -60,7 +60,7 @@ if env['builtin_glslang']:
# Treat glslang headers as system headers to avoid raising warnings. Not supported on MSVC.
if not env.msvc:
- env_glslang.Append(CPPFLAGS=['-isystem', Dir(thirdparty_dir).path])
+ env_glslang.Append(CPPFLAGS=["-isystem", Dir(thirdparty_dir).path])
else:
env_glslang.Prepend(CPPPATH=[thirdparty_dir])
diff --git a/modules/glslang/config.py b/modules/glslang/config.py
index 1c8cd12a2d..d22f9454ed 100644
--- a/modules/glslang/config.py
+++ b/modules/glslang/config.py
@@ -1,5 +1,6 @@
def can_build(env, platform):
return True
+
def configure(env):
pass
diff --git a/modules/glslang/register_types.cpp b/modules/glslang/register_types.cpp
index d2b4a18fc7..2540ba476c 100644
--- a/modules/glslang/register_types.cpp
+++ b/modules/glslang/register_types.cpp
@@ -30,7 +30,7 @@
#include "register_types.h"
-#include "servers/visual/rendering_device.h"
+#include "servers/rendering/rendering_device.h"
#include <SPIRV/GlslangToSpv.h>
#include <glslang/Include/Types.h>
diff --git a/modules/gridmap/SCsub b/modules/gridmap/SCsub
index 62b8a0ff93..970ce534f0 100644
--- a/modules/gridmap/SCsub
+++ b/modules/gridmap/SCsub
@@ -1,7 +1,7 @@
#!/usr/bin/env python
-Import('env')
-Import('env_modules')
+Import("env")
+Import("env_modules")
env_gridmap = env_modules.Clone()
diff --git a/modules/gridmap/config.py b/modules/gridmap/config.py
index 5022116c9b..a6319fe1ea 100644
--- a/modules/gridmap/config.py
+++ b/modules/gridmap/config.py
@@ -1,13 +1,16 @@
def can_build(env, platform):
return True
+
def configure(env):
pass
+
def get_doc_classes():
return [
"GridMap",
]
+
def get_doc_path():
return "doc_classes"
diff --git a/modules/gridmap/doc_classes/GridMap.xml b/modules/gridmap/doc_classes/GridMap.xml
index 37ebb3e5d5..a213069e19 100644
--- a/modules/gridmap/doc_classes/GridMap.xml
+++ b/modules/gridmap/doc_classes/GridMap.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="GridMap" inherits="Spatial" version="4.0">
+<class name="GridMap" inherits="Node3D" version="4.0">
<brief_description>
Node for 3D tile-based maps.
</brief_description>
diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cpp
index 7273a014f0..df7c2f397f 100644
--- a/modules/gridmap/grid_map.cpp
+++ b/modules/gridmap/grid_map.cpp
@@ -32,12 +32,12 @@
#include "core/io/marshalls.h"
#include "core/message_queue.h"
-#include "scene/3d/light.h"
+#include "scene/3d/light_3d.h"
#include "scene/resources/mesh_library.h"
#include "scene/resources/surface_tool.h"
#include "scene/scene_string_names.h"
-#include "servers/navigation_server.h"
-#include "servers/visual_server.h"
+#include "servers/navigation_server_3d.h"
+#include "servers/rendering_server.h"
bool GridMap::_set(const StringName &p_name, const Variant &p_value) {
@@ -76,12 +76,12 @@ bool GridMap::_set(const StringName &p_name, const Variant &p_value) {
BakedMesh bm;
bm.mesh = meshes[i];
ERR_CONTINUE(!bm.mesh.is_valid());
- bm.instance = VS::get_singleton()->instance_create();
- VS::get_singleton()->get_singleton()->instance_set_base(bm.instance, bm.mesh->get_rid());
- VS::get_singleton()->instance_attach_object_instance_id(bm.instance, get_instance_id());
+ bm.instance = RS::get_singleton()->instance_create();
+ RS::get_singleton()->get_singleton()->instance_set_base(bm.instance, bm.mesh->get_rid());
+ RS::get_singleton()->instance_attach_object_instance_id(bm.instance, get_instance_id());
if (is_inside_tree()) {
- VS::get_singleton()->instance_set_scenario(bm.instance, get_world()->get_scenario());
- VS::get_singleton()->instance_set_transform(bm.instance, get_global_transform());
+ RS::get_singleton()->instance_set_scenario(bm.instance, get_world()->get_scenario());
+ RS::get_singleton()->instance_set_transform(bm.instance, get_global_transform());
}
baked_meshes.push_back(bm);
}
@@ -306,17 +306,17 @@ void GridMap::set_cell_item(int p_x, int p_y, int p_z, int p_item, int p_rot) {
//create octant because it does not exist
Octant *g = memnew(Octant);
g->dirty = true;
- g->static_body = PhysicsServer::get_singleton()->body_create(PhysicsServer::BODY_MODE_STATIC);
- PhysicsServer::get_singleton()->body_attach_object_instance_id(g->static_body, get_instance_id());
- PhysicsServer::get_singleton()->body_set_collision_layer(g->static_body, collision_layer);
- PhysicsServer::get_singleton()->body_set_collision_mask(g->static_body, collision_mask);
+ g->static_body = PhysicsServer3D::get_singleton()->body_create(PhysicsServer3D::BODY_MODE_STATIC);
+ PhysicsServer3D::get_singleton()->body_attach_object_instance_id(g->static_body, get_instance_id());
+ PhysicsServer3D::get_singleton()->body_set_collision_layer(g->static_body, collision_layer);
+ PhysicsServer3D::get_singleton()->body_set_collision_mask(g->static_body, collision_mask);
SceneTree *st = SceneTree::get_singleton();
if (st && st->is_debugging_collisions_hint()) {
- g->collision_debug = VisualServer::get_singleton()->mesh_create();
- g->collision_debug_instance = VisualServer::get_singleton()->instance_create();
- VisualServer::get_singleton()->instance_set_base(g->collision_debug_instance, g->collision_debug);
+ g->collision_debug = RenderingServer::get_singleton()->mesh_create();
+ g->collision_debug_instance = RenderingServer::get_singleton()->instance_create();
+ RenderingServer::get_singleton()->instance_set_base(g->collision_debug_instance, g->collision_debug);
}
octant_map[octantkey] = g;
@@ -392,14 +392,14 @@ void GridMap::_octant_transform(const OctantKey &p_key) {
ERR_FAIL_COND(!octant_map.has(p_key));
Octant &g = *octant_map[p_key];
- PhysicsServer::get_singleton()->body_set_state(g.static_body, PhysicsServer::BODY_STATE_TRANSFORM, get_global_transform());
+ PhysicsServer3D::get_singleton()->body_set_state(g.static_body, PhysicsServer3D::BODY_STATE_TRANSFORM, get_global_transform());
if (g.collision_debug_instance.is_valid()) {
- VS::get_singleton()->instance_set_transform(g.collision_debug_instance, get_global_transform());
+ RS::get_singleton()->instance_set_transform(g.collision_debug_instance, get_global_transform());
}
for (int i = 0; i < g.multimesh_instances.size(); i++) {
- VS::get_singleton()->instance_set_transform(g.multimesh_instances[i].instance, get_global_transform());
+ RS::get_singleton()->instance_set_transform(g.multimesh_instances[i].instance, get_global_transform());
}
}
@@ -410,17 +410,17 @@ bool GridMap::_octant_update(const OctantKey &p_key) {
return false;
//erase body shapes
- PhysicsServer::get_singleton()->body_clear_shapes(g.static_body);
+ PhysicsServer3D::get_singleton()->body_clear_shapes(g.static_body);
//erase body shapes debug
if (g.collision_debug.is_valid()) {
- VS::get_singleton()->mesh_clear(g.collision_debug);
+ RS::get_singleton()->mesh_clear(g.collision_debug);
}
//erase navigation
for (Map<IndexKey, Octant::NavMesh>::Element *E = g.navmesh_ids.front(); E; E = E->next()) {
- NavigationServer::get_singleton()->free(E->get().region);
+ NavigationServer3D::get_singleton()->free(E->get().region);
}
g.navmesh_ids.clear();
@@ -428,8 +428,8 @@ bool GridMap::_octant_update(const OctantKey &p_key) {
for (int i = 0; i < g.multimesh_instances.size(); i++) {
- VS::get_singleton()->free(g.multimesh_instances[i].instance);
- VS::get_singleton()->free(g.multimesh_instances[i].multimesh);
+ RS::get_singleton()->free(g.multimesh_instances[i].instance);
+ RS::get_singleton()->free(g.multimesh_instances[i].multimesh);
}
g.multimesh_instances.clear();
@@ -484,7 +484,7 @@ bool GridMap::_octant_update(const OctantKey &p_key) {
// add the item's shape
if (!shapes[i].shape.is_valid())
continue;
- PhysicsServer::get_singleton()->body_add_shape(g.static_body, shapes[i].shape->get_rid(), xform * shapes[i].local_transform);
+ PhysicsServer3D::get_singleton()->body_add_shape(g.static_body, shapes[i].shape->get_rid(), xform * shapes[i].local_transform);
if (g.collision_debug.is_valid()) {
shapes.write[i].shape->add_vertices_to_array(col_debug, xform * shapes[i].local_transform);
}
@@ -497,10 +497,10 @@ bool GridMap::_octant_update(const OctantKey &p_key) {
nm.xform = xform * mesh_library->get_item_navmesh_transform(c.item);
if (navigation) {
- RID region = NavigationServer::get_singleton()->region_create();
- NavigationServer::get_singleton()->region_set_navmesh(region, navmesh);
- NavigationServer::get_singleton()->region_set_transform(region, navigation->get_global_transform() * nm.xform);
- NavigationServer::get_singleton()->region_set_map(region, navigation->get_rid());
+ RID region = NavigationServer3D::get_singleton()->region_create();
+ NavigationServer3D::get_singleton()->region_set_navmesh(region, navmesh);
+ NavigationServer3D::get_singleton()->region_set_transform(region, navigation->get_global_transform() * nm.xform);
+ NavigationServer3D::get_singleton()->region_set_map(region, navigation->get_rid());
nm.region = region;
}
g.navmesh_ids[E->get()] = nm;
@@ -513,13 +513,13 @@ bool GridMap::_octant_update(const OctantKey &p_key) {
for (Map<int, List<Pair<Transform, IndexKey>>>::Element *E = multimesh_items.front(); E; E = E->next()) {
Octant::MultimeshInstance mmi;
- RID mm = VS::get_singleton()->multimesh_create();
- VS::get_singleton()->multimesh_allocate(mm, E->get().size(), VS::MULTIMESH_TRANSFORM_3D);
- VS::get_singleton()->multimesh_set_mesh(mm, mesh_library->get_item_mesh(E->key())->get_rid());
+ RID mm = RS::get_singleton()->multimesh_create();
+ RS::get_singleton()->multimesh_allocate(mm, E->get().size(), RS::MULTIMESH_TRANSFORM_3D);
+ RS::get_singleton()->multimesh_set_mesh(mm, mesh_library->get_item_mesh(E->key())->get_rid());
int idx = 0;
for (List<Pair<Transform, IndexKey>>::Element *F = E->get().front(); F; F = F->next()) {
- VS::get_singleton()->multimesh_instance_set_transform(mm, idx, F->get().first);
+ RS::get_singleton()->multimesh_instance_set_transform(mm, idx, F->get().first);
#ifdef TOOLS_ENABLED
Octant::MultimeshInstance::Item it;
@@ -532,12 +532,12 @@ bool GridMap::_octant_update(const OctantKey &p_key) {
idx++;
}
- RID instance = VS::get_singleton()->instance_create();
- VS::get_singleton()->instance_set_base(instance, mm);
+ RID instance = RS::get_singleton()->instance_create();
+ RS::get_singleton()->instance_set_base(instance, mm);
if (is_inside_tree()) {
- VS::get_singleton()->instance_set_scenario(instance, get_world()->get_scenario());
- VS::get_singleton()->instance_set_transform(instance, get_global_transform());
+ RS::get_singleton()->instance_set_scenario(instance, get_world()->get_scenario());
+ RS::get_singleton()->instance_set_transform(instance, get_global_transform());
}
mmi.multimesh = mm;
@@ -550,13 +550,13 @@ bool GridMap::_octant_update(const OctantKey &p_key) {
if (col_debug.size()) {
Array arr;
- arr.resize(VS::ARRAY_MAX);
- arr[VS::ARRAY_VERTEX] = col_debug;
+ arr.resize(RS::ARRAY_MAX);
+ arr[RS::ARRAY_VERTEX] = col_debug;
- VS::get_singleton()->mesh_add_surface_from_arrays(g.collision_debug, VS::PRIMITIVE_LINES, arr);
+ RS::get_singleton()->mesh_add_surface_from_arrays(g.collision_debug, RS::PRIMITIVE_LINES, arr);
SceneTree *st = SceneTree::get_singleton();
if (st) {
- VS::get_singleton()->mesh_surface_set_material(g.collision_debug, 0, st->get_debug_collision_material()->get_rid());
+ RS::get_singleton()->mesh_surface_set_material(g.collision_debug, 0, st->get_debug_collision_material()->get_rid());
}
}
@@ -567,8 +567,8 @@ bool GridMap::_octant_update(const OctantKey &p_key) {
void GridMap::_reset_physic_bodies_collision_filters() {
for (Map<OctantKey, Octant *>::Element *E = octant_map.front(); E; E = E->next()) {
- PhysicsServer::get_singleton()->body_set_collision_layer(E->get()->static_body, collision_layer);
- PhysicsServer::get_singleton()->body_set_collision_mask(E->get()->static_body, collision_mask);
+ PhysicsServer3D::get_singleton()->body_set_collision_layer(E->get()->static_body, collision_layer);
+ PhysicsServer3D::get_singleton()->body_set_collision_mask(E->get()->static_body, collision_mask);
}
}
@@ -576,17 +576,17 @@ void GridMap::_octant_enter_world(const OctantKey &p_key) {
ERR_FAIL_COND(!octant_map.has(p_key));
Octant &g = *octant_map[p_key];
- PhysicsServer::get_singleton()->body_set_state(g.static_body, PhysicsServer::BODY_STATE_TRANSFORM, get_global_transform());
- PhysicsServer::get_singleton()->body_set_space(g.static_body, get_world()->get_space());
+ PhysicsServer3D::get_singleton()->body_set_state(g.static_body, PhysicsServer3D::BODY_STATE_TRANSFORM, get_global_transform());
+ PhysicsServer3D::get_singleton()->body_set_space(g.static_body, get_world()->get_space());
if (g.collision_debug_instance.is_valid()) {
- VS::get_singleton()->instance_set_scenario(g.collision_debug_instance, get_world()->get_scenario());
- VS::get_singleton()->instance_set_transform(g.collision_debug_instance, get_global_transform());
+ RS::get_singleton()->instance_set_scenario(g.collision_debug_instance, get_world()->get_scenario());
+ RS::get_singleton()->instance_set_transform(g.collision_debug_instance, get_global_transform());
}
for (int i = 0; i < g.multimesh_instances.size(); i++) {
- VS::get_singleton()->instance_set_scenario(g.multimesh_instances[i].instance, get_world()->get_scenario());
- VS::get_singleton()->instance_set_transform(g.multimesh_instances[i].instance, get_global_transform());
+ RS::get_singleton()->instance_set_scenario(g.multimesh_instances[i].instance, get_world()->get_scenario());
+ RS::get_singleton()->instance_set_transform(g.multimesh_instances[i].instance, get_global_transform());
}
if (navigation && mesh_library.is_valid()) {
@@ -595,10 +595,10 @@ void GridMap::_octant_enter_world(const OctantKey &p_key) {
if (cell_map.has(F->key()) && F->get().region.is_valid() == false) {
Ref<NavigationMesh> nm = mesh_library->get_item_navmesh(cell_map[F->key()].item);
if (nm.is_valid()) {
- RID region = NavigationServer::get_singleton()->region_create();
- NavigationServer::get_singleton()->region_set_navmesh(region, nm);
- NavigationServer::get_singleton()->region_set_transform(region, navigation->get_global_transform() * F->get().xform);
- NavigationServer::get_singleton()->region_set_map(region, navigation->get_rid());
+ RID region = NavigationServer3D::get_singleton()->region_create();
+ NavigationServer3D::get_singleton()->region_set_navmesh(region, nm);
+ NavigationServer3D::get_singleton()->region_set_transform(region, navigation->get_global_transform() * F->get().xform);
+ NavigationServer3D::get_singleton()->region_set_map(region, navigation->get_rid());
F->get().region = region;
}
}
@@ -610,23 +610,23 @@ void GridMap::_octant_exit_world(const OctantKey &p_key) {
ERR_FAIL_COND(!octant_map.has(p_key));
Octant &g = *octant_map[p_key];
- PhysicsServer::get_singleton()->body_set_state(g.static_body, PhysicsServer::BODY_STATE_TRANSFORM, get_global_transform());
- PhysicsServer::get_singleton()->body_set_space(g.static_body, RID());
+ PhysicsServer3D::get_singleton()->body_set_state(g.static_body, PhysicsServer3D::BODY_STATE_TRANSFORM, get_global_transform());
+ PhysicsServer3D::get_singleton()->body_set_space(g.static_body, RID());
if (g.collision_debug_instance.is_valid()) {
- VS::get_singleton()->instance_set_scenario(g.collision_debug_instance, RID());
+ RS::get_singleton()->instance_set_scenario(g.collision_debug_instance, RID());
}
for (int i = 0; i < g.multimesh_instances.size(); i++) {
- VS::get_singleton()->instance_set_scenario(g.multimesh_instances[i].instance, RID());
+ RS::get_singleton()->instance_set_scenario(g.multimesh_instances[i].instance, RID());
}
if (navigation) {
for (Map<IndexKey, Octant::NavMesh>::Element *F = g.navmesh_ids.front(); F; F = F->next()) {
if (F->get().region.is_valid()) {
- NavigationServer::get_singleton()->free(F->get().region);
+ NavigationServer3D::get_singleton()->free(F->get().region);
F->get().region = RID();
}
}
@@ -639,15 +639,15 @@ void GridMap::_octant_clean_up(const OctantKey &p_key) {
Octant &g = *octant_map[p_key];
if (g.collision_debug.is_valid())
- VS::get_singleton()->free(g.collision_debug);
+ RS::get_singleton()->free(g.collision_debug);
if (g.collision_debug_instance.is_valid())
- VS::get_singleton()->free(g.collision_debug_instance);
+ RS::get_singleton()->free(g.collision_debug_instance);
- PhysicsServer::get_singleton()->free(g.static_body);
+ PhysicsServer3D::get_singleton()->free(g.static_body);
// Erase navigation
for (Map<IndexKey, Octant::NavMesh>::Element *E = g.navmesh_ids.front(); E; E = E->next()) {
- NavigationServer::get_singleton()->free(E->get().region);
+ NavigationServer3D::get_singleton()->free(E->get().region);
}
g.navmesh_ids.clear();
@@ -655,8 +655,8 @@ void GridMap::_octant_clean_up(const OctantKey &p_key) {
for (int i = 0; i < g.multimesh_instances.size(); i++) {
- VS::get_singleton()->free(g.multimesh_instances[i].instance);
- VS::get_singleton()->free(g.multimesh_instances[i].multimesh);
+ RS::get_singleton()->free(g.multimesh_instances[i].instance);
+ RS::get_singleton()->free(g.multimesh_instances[i].multimesh);
}
g.multimesh_instances.clear();
}
@@ -667,14 +667,14 @@ void GridMap::_notification(int p_what) {
case NOTIFICATION_ENTER_WORLD: {
- Spatial *c = this;
+ Node3D *c = this;
while (c) {
- navigation = Object::cast_to<Navigation>(c);
+ navigation = Object::cast_to<Navigation3D>(c);
if (navigation) {
break;
}
- c = Object::cast_to<Spatial>(c->get_parent());
+ c = Object::cast_to<Node3D>(c->get_parent());
}
last_transform = get_global_transform();
@@ -684,8 +684,8 @@ void GridMap::_notification(int p_what) {
}
for (int i = 0; i < baked_meshes.size(); i++) {
- VS::get_singleton()->instance_set_scenario(baked_meshes[i].instance, get_world()->get_scenario());
- VS::get_singleton()->instance_set_transform(baked_meshes[i].instance, get_global_transform());
+ RS::get_singleton()->instance_set_scenario(baked_meshes[i].instance, get_world()->get_scenario());
+ RS::get_singleton()->instance_set_transform(baked_meshes[i].instance, get_global_transform());
}
} break;
@@ -702,7 +702,7 @@ void GridMap::_notification(int p_what) {
last_transform = new_xform;
for (int i = 0; i < baked_meshes.size(); i++) {
- VS::get_singleton()->instance_set_transform(baked_meshes[i].instance, get_global_transform());
+ RS::get_singleton()->instance_set_transform(baked_meshes[i].instance, get_global_transform());
}
} break;
@@ -712,13 +712,13 @@ void GridMap::_notification(int p_what) {
_octant_exit_world(E->key());
}
- navigation = NULL;
+ navigation = nullptr;
//_queue_octants_dirty(MAP_DIRTY_INSTANCES|MAP_DIRTY_TRANSFORMS);
//_update_octants_callback();
//_update_area_instances();
for (int i = 0; i < baked_meshes.size(); i++) {
- VS::get_singleton()->instance_set_scenario(baked_meshes[i].instance, RID());
+ RS::get_singleton()->instance_set_scenario(baked_meshes[i].instance, RID());
}
} break;
@@ -738,7 +738,7 @@ void GridMap::_update_visibility() {
Octant *octant = e->value();
for (int i = 0; i < octant->multimesh_instances.size(); i++) {
const Octant::MultimeshInstance &mi = octant->multimesh_instances[i];
- VS::get_singleton()->instance_set_visible(mi.instance, is_visible());
+ RS::get_singleton()->instance_set_visible(mi.instance, is_visible());
}
}
}
@@ -975,7 +975,7 @@ Vector3 GridMap::_get_offset() const {
void GridMap::clear_baked_meshes() {
for (int i = 0; i < baked_meshes.size(); i++) {
- VS::get_singleton()->free(baked_meshes[i].instance);
+ RS::get_singleton()->free(baked_meshes[i].instance);
}
baked_meshes.clear();
@@ -1050,12 +1050,12 @@ void GridMap::make_baked_meshes(bool p_gen_lightmap_uv, float p_lightmap_uv_texe
BakedMesh bm;
bm.mesh = mesh;
- bm.instance = VS::get_singleton()->instance_create();
- VS::get_singleton()->get_singleton()->instance_set_base(bm.instance, bm.mesh->get_rid());
- VS::get_singleton()->instance_attach_object_instance_id(bm.instance, get_instance_id());
+ bm.instance = RS::get_singleton()->instance_create();
+ RS::get_singleton()->get_singleton()->instance_set_base(bm.instance, bm.mesh->get_rid());
+ RS::get_singleton()->instance_attach_object_instance_id(bm.instance, get_instance_id());
if (is_inside_tree()) {
- VS::get_singleton()->instance_set_scenario(bm.instance, get_world()->get_scenario());
- VS::get_singleton()->instance_set_transform(bm.instance, get_global_transform());
+ RS::get_singleton()->instance_set_scenario(bm.instance, get_world()->get_scenario());
+ RS::get_singleton()->instance_set_transform(bm.instance, get_global_transform());
}
if (p_gen_lightmap_uv) {
@@ -1107,7 +1107,7 @@ GridMap::GridMap() {
clip_above = true;
cell_scale = 1.0;
- navigation = NULL;
+ navigation = nullptr;
set_notify_transform(true);
recreating_octants = false;
}
diff --git a/modules/gridmap/grid_map.h b/modules/gridmap/grid_map.h
index cc1c8c2923..3f3da09fe9 100644
--- a/modules/gridmap/grid_map.h
+++ b/modules/gridmap/grid_map.h
@@ -31,17 +31,17 @@
#ifndef GRID_MAP_H
#define GRID_MAP_H
-#include "scene/3d/navigation.h"
-#include "scene/3d/spatial.h"
+#include "scene/3d/navigation_3d.h"
+#include "scene/3d/node_3d.h"
#include "scene/resources/mesh_library.h"
#include "scene/resources/multimesh.h"
//heh heh, godotsphir!! this shares no code and the design is completely different with previous projects i've done..
//should scale better with hardware that supports instancing
-class GridMap : public Spatial {
+class GridMap : public Node3D {
- GDCLASS(GridMap, Spatial);
+ GDCLASS(GridMap, Node3D);
enum {
MAP_DIRTY_TRANSFORMS = 1,
@@ -147,7 +147,7 @@ class GridMap : public Spatial {
int octant_size;
bool center_x, center_y, center_z;
float cell_scale;
- Navigation *navigation;
+ Navigation3D *navigation;
bool clip;
bool clip_above;
@@ -166,10 +166,10 @@ class GridMap : public Spatial {
struct BakeLight {
- VS::LightType type;
+ RS::LightType type;
Vector3 pos;
Vector3 dir;
- float param[VS::LIGHT_PARAM_MAX];
+ float param[RS::LIGHT_PARAM_MAX];
};
_FORCE_INLINE_ Vector3 _octant_get_offset(const OctantKey &p_key) const {
diff --git a/modules/gridmap/grid_map_editor_plugin.cpp b/modules/gridmap/grid_map_editor_plugin.cpp
index a656ee8b63..9c3101945a 100644
--- a/modules/gridmap/grid_map_editor_plugin.cpp
+++ b/modules/gridmap/grid_map_editor_plugin.cpp
@@ -29,19 +29,20 @@
/*************************************************************************/
#include "grid_map_editor_plugin.h"
-#include "core/os/input.h"
+#include "core/input/input.h"
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
-#include "editor/plugins/spatial_editor_plugin.h"
-#include "scene/3d/camera.h"
+#include "editor/plugins/node_3d_editor_plugin.h"
+#include "scene/3d/camera_3d.h"
#include "core/math/geometry.h"
#include "core/os/keyboard.h"
+#include "scene/main/window.h"
void GridMapEditor::_node_removed(Node *p_node) {
if (p_node == node)
- node = NULL;
+ node = nullptr;
}
void GridMapEditor::_configure() {
@@ -280,8 +281,8 @@ void GridMapEditor::_update_cursor_transform() {
cursor_transform = node->get_global_transform() * cursor_transform;
if (cursor_instance.is_valid()) {
- VisualServer::get_singleton()->instance_set_transform(cursor_instance, cursor_transform);
- VisualServer::get_singleton()->instance_set_visible(cursor_instance, cursor_visible);
+ RenderingServer::get_singleton()->instance_set_transform(cursor_instance, cursor_transform);
+ RenderingServer::get_singleton()->instance_set_visible(cursor_instance, cursor_visible);
}
}
@@ -291,9 +292,9 @@ void GridMapEditor::_update_selection_transform() {
if (!selection.active) {
- VisualServer::get_singleton()->instance_set_transform(selection_instance, xf_zero);
+ RenderingServer::get_singleton()->instance_set_transform(selection_instance, xf_zero);
for (int i = 0; i < 3; i++) {
- VisualServer::get_singleton()->instance_set_transform(selection_level_instance[i], xf_zero);
+ RenderingServer::get_singleton()->instance_set_transform(selection_level_instance[i], xf_zero);
}
return;
}
@@ -302,11 +303,11 @@ void GridMapEditor::_update_selection_transform() {
xf.scale((Vector3(1, 1, 1) + (selection.end - selection.begin)) * node->get_cell_size());
xf.origin = selection.begin * node->get_cell_size();
- VisualServer::get_singleton()->instance_set_transform(selection_instance, node->get_global_transform() * xf);
+ RenderingServer::get_singleton()->instance_set_transform(selection_instance, node->get_global_transform() * xf);
for (int i = 0; i < 3; i++) {
if (i != edit_axis || (edit_floor[edit_axis] < selection.begin[edit_axis]) || (edit_floor[edit_axis] > selection.end[edit_axis] + 1)) {
- VisualServer::get_singleton()->instance_set_transform(selection_level_instance[i], xf_zero);
+ RenderingServer::get_singleton()->instance_set_transform(selection_level_instance[i], xf_zero);
} else {
Vector3 scale = (selection.end - selection.begin + Vector3(1, 1, 1));
@@ -321,7 +322,7 @@ void GridMapEditor::_update_selection_transform() {
xf2.basis.scale(scale);
xf2.origin = pos;
- VisualServer::get_singleton()->instance_set_transform(selection_level_instance[i], xf2);
+ RenderingServer::get_singleton()->instance_set_transform(selection_level_instance[i], xf2);
}
}
}
@@ -361,7 +362,7 @@ void GridMapEditor::_set_selection(bool p_active, const Vector3 &p_begin, const
options->get_popup()->set_item_disabled(options->get_popup()->get_item_index(MENU_OPTION_SELECTION_FILL), !selection.active);
}
-bool GridMapEditor::do_input_action(Camera *p_camera, const Point2 &p_point, bool p_click) {
+bool GridMapEditor::do_input_action(Camera3D *p_camera, const Point2 &p_point, bool p_click) {
if (!spatial_editor)
return false;
@@ -374,7 +375,7 @@ bool GridMapEditor::do_input_action(Camera *p_camera, const Point2 &p_point, boo
if (input_action != INPUT_PICK && input_action != INPUT_SELECT && input_action != INPUT_PASTE && !mesh_library->has_item(selected_palette))
return false;
- Camera *camera = p_camera;
+ Camera3D *camera = p_camera;
Vector3 from = camera->project_ray_origin(p_point);
Vector3 normal = camera->project_ray_normal(p_point);
Transform local_xform = node->get_global_transform().affine_inverse();
@@ -415,7 +416,7 @@ bool GridMapEditor::do_input_action(Camera *p_camera, const Point2 &p_point, boo
}
}
- VS::get_singleton()->instance_set_transform(grid_instance[edit_axis], node->get_global_transform() * edit_grid_xform);
+ RS::get_singleton()->instance_set_transform(grid_instance[edit_axis], node->get_global_transform() * edit_grid_xform);
if (cursor_instance.is_valid()) {
@@ -527,7 +528,7 @@ void GridMapEditor::_clear_clipboard_data() {
for (List<ClipboardItem>::Element *E = clipboard_items.front(); E; E = E->next()) {
- VisualServer::get_singleton()->free(E->get().instance);
+ RenderingServer::get_singleton()->free(E->get().instance);
}
clipboard_items.clear();
@@ -555,7 +556,7 @@ void GridMapEditor::_set_clipboard_data() {
item.cell_item = itm;
item.grid_offset = Vector3(i, j, k) - selection.begin;
item.orientation = node->get_cell_item_orientation(i, j, k);
- item.instance = VisualServer::get_singleton()->instance_create2(mesh->get_rid(), get_tree()->get_root()->get_world()->get_scenario());
+ item.instance = RenderingServer::get_singleton()->instance_create2(mesh->get_rid(), get_tree()->get_root()->get_world()->get_scenario());
clipboard_items.push_back(item);
}
@@ -569,7 +570,7 @@ void GridMapEditor::_update_paste_indicator() {
Transform xf;
xf.basis.set_zero();
- VisualServer::get_singleton()->instance_set_transform(paste_instance, xf);
+ RenderingServer::get_singleton()->instance_set_transform(paste_instance, xf);
return;
}
@@ -583,7 +584,7 @@ void GridMapEditor::_update_paste_indicator() {
xf.basis = rot * xf.basis;
xf.translate((-center * node->get_cell_size()) / scale);
- VisualServer::get_singleton()->instance_set_transform(paste_instance, node->get_global_transform() * xf);
+ RenderingServer::get_singleton()->instance_set_transform(paste_instance, node->get_global_transform() * xf);
for (List<ClipboardItem>::Element *E = clipboard_items.front(); E; E = E->next()) {
@@ -598,7 +599,7 @@ void GridMapEditor::_update_paste_indicator() {
item_rot.set_orthogonal_index(item.orientation);
xf.basis = item_rot * xf.basis * node->get_cell_scale();
- VisualServer::get_singleton()->instance_set_transform(item.instance, node->get_global_transform() * xf);
+ RenderingServer::get_singleton()->instance_set_transform(item.instance, node->get_global_transform() * xf);
}
}
@@ -638,7 +639,7 @@ void GridMapEditor::_do_paste() {
_clear_clipboard_data();
}
-bool GridMapEditor::forward_spatial_input_event(Camera *p_camera, const Ref<InputEvent> &p_event) {
+bool GridMapEditor::forward_spatial_input_event(Camera3D *p_camera, const Ref<InputEvent> &p_event) {
if (!node) {
return false;
}
@@ -659,8 +660,8 @@ bool GridMapEditor::forward_spatial_input_event(Camera *p_camera, const Ref<Inpu
}
if (mb->is_pressed()) {
- SpatialEditorViewport::NavigationScheme nav_scheme = (SpatialEditorViewport::NavigationScheme)EditorSettings::get_singleton()->get("editors/3d/navigation/navigation_scheme").operator int();
- if ((nav_scheme == SpatialEditorViewport::NAVIGATION_MAYA || nav_scheme == SpatialEditorViewport::NAVIGATION_MODO) && mb->get_alt()) {
+ Node3DEditorViewport::NavigationScheme nav_scheme = (Node3DEditorViewport::NavigationScheme)EditorSettings::get_singleton()->get("editors/3d/navigation/navigation_scheme").operator int();
+ if ((nav_scheme == Node3DEditorViewport::NAVIGATION_MAYA || nav_scheme == Node3DEditorViewport::NAVIGATION_MODO) && mb->get_alt()) {
input_action = INPUT_NONE;
} else if (mb->get_button_index() == BUTTON_LEFT) {
@@ -895,7 +896,7 @@ void GridMapEditor::update_palette() {
Ref<MeshLibrary> mesh_library = node->get_mesh_library();
if (mesh_library.is_null()) {
- last_mesh_library = NULL;
+ last_mesh_library = nullptr;
search_box->set_text("");
search_box->set_editable(false);
info_message->show();
@@ -963,16 +964,16 @@ void GridMapEditor::edit(GridMap *p_gridmap) {
_update_selection_transform();
_update_paste_indicator();
- spatial_editor = Object::cast_to<SpatialEditorPlugin>(editor->get_editor_plugin_screen());
+ spatial_editor = Object::cast_to<Node3DEditorPlugin>(editor->get_editor_plugin_screen());
if (!node) {
set_process(false);
for (int i = 0; i < 3; i++) {
- VisualServer::get_singleton()->instance_set_visible(grid_instance[i], false);
+ RenderingServer::get_singleton()->instance_set_visible(grid_instance[i], false);
}
if (cursor_instance.is_valid()) {
- VisualServer::get_singleton()->instance_set_visible(cursor_instance, false);
+ RenderingServer::get_singleton()->instance_set_visible(cursor_instance, false);
}
return;
@@ -1010,7 +1011,7 @@ void GridMapEditor::update_grid() {
edit_grid_xform.basis = Basis();
for (int i = 0; i < 3; i++) {
- VisualServer::get_singleton()->instance_set_visible(grid_instance[i], i == edit_axis);
+ RenderingServer::get_singleton()->instance_set_visible(grid_instance[i], i == edit_axis);
}
updating = true;
@@ -1022,7 +1023,7 @@ void GridMapEditor::_draw_grids(const Vector3 &cell_size) {
Vector3 edited_floor = node->has_meta("_editor_floor_") ? node->get_meta("_editor_floor_") : Variant();
for (int i = 0; i < 3; i++) {
- VS::get_singleton()->mesh_clear(grid[i]);
+ RS::get_singleton()->mesh_clear(grid[i]);
edit_floor[i] = edited_floor[i];
}
@@ -1064,11 +1065,11 @@ void GridMapEditor::_draw_grids(const Vector3 &cell_size) {
}
Array d;
- d.resize(VS::ARRAY_MAX);
- d[VS::ARRAY_VERTEX] = grid_points[i];
- d[VS::ARRAY_COLOR] = grid_colors[i];
- VisualServer::get_singleton()->mesh_add_surface_from_arrays(grid[i], VisualServer::PRIMITIVE_LINES, d);
- VisualServer::get_singleton()->mesh_surface_set_material(grid[i], 0, indicator_mat->get_rid());
+ d.resize(RS::ARRAY_MAX);
+ d[RS::ARRAY_VERTEX] = grid_points[i];
+ d[RS::ARRAY_COLOR] = grid_colors[i];
+ RenderingServer::get_singleton()->mesh_add_surface_from_arrays(grid[i], RenderingServer::PRIMITIVE_LINES, d);
+ RenderingServer::get_singleton()->mesh_surface_set_material(grid[i], 0, indicator_mat->get_rid());
}
}
@@ -1081,13 +1082,13 @@ void GridMapEditor::_notification(int p_what) {
mesh_library_palette->connect("item_selected", callable_mp(this, &GridMapEditor::_item_selected_cbk));
for (int i = 0; i < 3; i++) {
- grid[i] = VS::get_singleton()->mesh_create();
- grid_instance[i] = VS::get_singleton()->instance_create2(grid[i], get_tree()->get_root()->get_world()->get_scenario());
- selection_level_instance[i] = VisualServer::get_singleton()->instance_create2(selection_level_mesh[i], get_tree()->get_root()->get_world()->get_scenario());
+ grid[i] = RS::get_singleton()->mesh_create();
+ grid_instance[i] = RS::get_singleton()->instance_create2(grid[i], get_tree()->get_root()->get_world()->get_scenario());
+ selection_level_instance[i] = RenderingServer::get_singleton()->instance_create2(selection_level_mesh[i], get_tree()->get_root()->get_world()->get_scenario());
}
- selection_instance = VisualServer::get_singleton()->instance_create2(selection_mesh, get_tree()->get_root()->get_world()->get_scenario());
- paste_instance = VisualServer::get_singleton()->instance_create2(paste_mesh, get_tree()->get_root()->get_world()->get_scenario());
+ selection_instance = RenderingServer::get_singleton()->instance_create2(selection_mesh, get_tree()->get_root()->get_world()->get_scenario());
+ paste_instance = RenderingServer::get_singleton()->instance_create2(paste_mesh, get_tree()->get_root()->get_world()->get_scenario());
_update_selection_transform();
_update_paste_indicator();
@@ -1099,15 +1100,15 @@ void GridMapEditor::_notification(int p_what) {
for (int i = 0; i < 3; i++) {
- VS::get_singleton()->free(grid_instance[i]);
- VS::get_singleton()->free(grid[i]);
+ RS::get_singleton()->free(grid_instance[i]);
+ RS::get_singleton()->free(grid[i]);
grid_instance[i] = RID();
grid[i] = RID();
- VisualServer::get_singleton()->free(selection_level_instance[i]);
+ RenderingServer::get_singleton()->free(selection_level_instance[i]);
}
- VisualServer::get_singleton()->free(selection_instance);
- VisualServer::get_singleton()->free(paste_instance);
+ RenderingServer::get_singleton()->free(selection_instance);
+ RenderingServer::get_singleton()->free(paste_instance);
selection_instance = RID();
paste_instance = RID();
} break;
@@ -1122,7 +1123,7 @@ void GridMapEditor::_notification(int p_what) {
if (xf != grid_xform) {
for (int i = 0; i < 3; i++) {
- VS::get_singleton()->instance_set_transform(grid_instance[i], xf * edit_grid_xform);
+ RS::get_singleton()->instance_set_transform(grid_instance[i], xf * edit_grid_xform);
}
grid_xform = xf;
}
@@ -1139,15 +1140,15 @@ void GridMapEditor::_notification(int p_what) {
p.d = edit_floor[edit_axis] * node->get_cell_size()[edit_axis];
p = node->get_transform().xform(p); // plane to snap
- SpatialEditorPlugin *sep = Object::cast_to<SpatialEditorPlugin>(editor->get_editor_plugin_screen());
+ Node3DEditorPlugin *sep = Object::cast_to<Node3DEditorPlugin>(editor->get_editor_plugin_screen());
if (sep)
sep->snap_cursor_to_plane(p);
}
} break;
case NOTIFICATION_THEME_CHANGED: {
- options->set_icon(get_icon("GridMap", "EditorIcons"));
- search_box->set_right_icon(get_icon("Search", "EditorIcons"));
+ options->set_icon(get_theme_icon("GridMap", "EditorIcons"));
+ search_box->set_right_icon(get_theme_icon("Search", "EditorIcons"));
} break;
}
}
@@ -1158,7 +1159,7 @@ void GridMapEditor::_update_cursor_instance() {
}
if (cursor_instance.is_valid())
- VisualServer::get_singleton()->free(cursor_instance);
+ RenderingServer::get_singleton()->free(cursor_instance);
cursor_instance = RID();
if (selected_palette >= 0) {
@@ -1167,8 +1168,8 @@ void GridMapEditor::_update_cursor_instance() {
Ref<Mesh> mesh = node->get_mesh_library()->get_item_mesh(selected_palette);
if (!mesh.is_null() && mesh->get_rid().is_valid()) {
- cursor_instance = VisualServer::get_singleton()->instance_create2(mesh->get_rid(), get_tree()->get_root()->get_world()->get_scenario());
- VisualServer::get_singleton()->instance_set_transform(cursor_instance, cursor_transform);
+ cursor_instance = RenderingServer::get_singleton()->instance_create2(mesh->get_rid(), get_tree()->get_root()->get_world()->get_scenario());
+ RenderingServer::get_singleton()->instance_set_transform(cursor_instance, cursor_transform);
}
}
}
@@ -1216,7 +1217,7 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
spatial_editor_hb = memnew(HBoxContainer);
spatial_editor_hb->set_h_size_flags(SIZE_EXPAND_FILL);
spatial_editor_hb->set_alignment(BoxContainer::ALIGN_END);
- SpatialEditor::get_singleton()->add_control_to_menu_panel(spatial_editor_hb);
+ Node3DEditor::get_singleton()->add_control_to_menu_panel(spatial_editor_hb);
spin_box_label = memnew(Label);
spin_box_label->set_text(TTR("Floor:"));
@@ -1226,7 +1227,7 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
floor->set_min(-32767);
floor->set_max(32767);
floor->set_step(1);
- floor->get_line_edit()->add_constant_override("minimum_spaces", 16);
+ floor->get_line_edit()->add_theme_constant_override("minimum_spaces", 16);
spatial_editor_hb->add_child(floor);
floor->connect("value_changed", callable_mp(this, &GridMapEditor::_floor_changed));
@@ -1304,14 +1305,14 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
mode_thumbnail = memnew(ToolButton);
mode_thumbnail->set_toggle_mode(true);
mode_thumbnail->set_pressed(true);
- mode_thumbnail->set_icon(p_editor->get_gui_base()->get_icon("FileThumbnail", "EditorIcons"));
+ mode_thumbnail->set_icon(p_editor->get_gui_base()->get_theme_icon("FileThumbnail", "EditorIcons"));
hb->add_child(mode_thumbnail);
mode_thumbnail->connect("pressed", callable_mp(this, &GridMapEditor::_set_display_mode), varray(DISPLAY_THUMBNAIL));
mode_list = memnew(ToolButton);
mode_list->set_toggle_mode(true);
mode_list->set_pressed(false);
- mode_list->set_icon(p_editor->get_gui_base()->get_icon("FileList", "EditorIcons"));
+ mode_list->set_icon(p_editor->get_gui_base()->get_theme_icon("FileList", "EditorIcons"));
hb->add_child(mode_list);
mode_list->connect("pressed", callable_mp(this, &GridMapEditor::_set_display_mode), varray(DISPLAY_LIST));
@@ -1352,8 +1353,8 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
lock_view = false;
cursor_rot = 0;
- selection_mesh = VisualServer::get_singleton()->mesh_create();
- paste_mesh = VisualServer::get_singleton()->mesh_create();
+ selection_mesh = RenderingServer::get_singleton()->mesh_create();
+ paste_mesh = RenderingServer::get_singleton()->mesh_create();
{
// Selection mesh create.
@@ -1430,16 +1431,16 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
}
Array d;
- d.resize(VS::ARRAY_MAX);
+ d.resize(RS::ARRAY_MAX);
inner_mat.instance();
inner_mat->set_albedo(Color(0.7, 0.7, 1.0, 0.2));
inner_mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
inner_mat->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
- d[VS::ARRAY_VERTEX] = triangles;
- VisualServer::get_singleton()->mesh_add_surface_from_arrays(selection_mesh, VS::PRIMITIVE_TRIANGLES, d);
- VisualServer::get_singleton()->mesh_surface_set_material(selection_mesh, 0, inner_mat->get_rid());
+ d[RS::ARRAY_VERTEX] = triangles;
+ RenderingServer::get_singleton()->mesh_add_surface_from_arrays(selection_mesh, RS::PRIMITIVE_TRIANGLES, d);
+ RenderingServer::get_singleton()->mesh_surface_set_material(selection_mesh, 0, inner_mat->get_rid());
outer_mat.instance();
outer_mat->set_albedo(Color(0.7, 0.7, 1.0, 0.8));
@@ -1453,23 +1454,23 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
selection_floor_mat->set_on_top_of_alpha();
selection_floor_mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
- d[VS::ARRAY_VERTEX] = lines;
- VisualServer::get_singleton()->mesh_add_surface_from_arrays(selection_mesh, VS::PRIMITIVE_LINES, d);
- VisualServer::get_singleton()->mesh_surface_set_material(selection_mesh, 1, outer_mat->get_rid());
+ d[RS::ARRAY_VERTEX] = lines;
+ RenderingServer::get_singleton()->mesh_add_surface_from_arrays(selection_mesh, RS::PRIMITIVE_LINES, d);
+ RenderingServer::get_singleton()->mesh_surface_set_material(selection_mesh, 1, outer_mat->get_rid());
- d[VS::ARRAY_VERTEX] = triangles;
- VisualServer::get_singleton()->mesh_add_surface_from_arrays(paste_mesh, VS::PRIMITIVE_TRIANGLES, d);
- VisualServer::get_singleton()->mesh_surface_set_material(paste_mesh, 0, inner_mat->get_rid());
+ d[RS::ARRAY_VERTEX] = triangles;
+ RenderingServer::get_singleton()->mesh_add_surface_from_arrays(paste_mesh, RS::PRIMITIVE_TRIANGLES, d);
+ RenderingServer::get_singleton()->mesh_surface_set_material(paste_mesh, 0, inner_mat->get_rid());
- d[VS::ARRAY_VERTEX] = lines;
- VisualServer::get_singleton()->mesh_add_surface_from_arrays(paste_mesh, VS::PRIMITIVE_LINES, d);
- VisualServer::get_singleton()->mesh_surface_set_material(paste_mesh, 1, outer_mat->get_rid());
+ d[RS::ARRAY_VERTEX] = lines;
+ RenderingServer::get_singleton()->mesh_add_surface_from_arrays(paste_mesh, RS::PRIMITIVE_LINES, d);
+ RenderingServer::get_singleton()->mesh_surface_set_material(paste_mesh, 1, outer_mat->get_rid());
for (int i = 0; i < 3; i++) {
- d[VS::ARRAY_VERTEX] = square[i];
- selection_level_mesh[i] = VS::get_singleton()->mesh_create();
- VisualServer::get_singleton()->mesh_add_surface_from_arrays(selection_level_mesh[i], VS::PRIMITIVE_LINES, d);
- VisualServer::get_singleton()->mesh_surface_set_material(selection_level_mesh[i], 0, selection_floor_mat->get_rid());
+ d[RS::ARRAY_VERTEX] = square[i];
+ selection_level_mesh[i] = RS::get_singleton()->mesh_create();
+ RenderingServer::get_singleton()->mesh_add_surface_from_arrays(selection_level_mesh[i], RS::PRIMITIVE_LINES, d);
+ RenderingServer::get_singleton()->mesh_surface_set_material(selection_level_mesh[i], 0, selection_floor_mat->get_rid());
}
}
@@ -1492,24 +1493,24 @@ GridMapEditor::~GridMapEditor() {
for (int i = 0; i < 3; i++) {
if (grid[i].is_valid())
- VisualServer::get_singleton()->free(grid[i]);
+ RenderingServer::get_singleton()->free(grid[i]);
if (grid_instance[i].is_valid())
- VisualServer::get_singleton()->free(grid_instance[i]);
+ RenderingServer::get_singleton()->free(grid_instance[i]);
if (cursor_instance.is_valid())
- VisualServer::get_singleton()->free(cursor_instance);
+ RenderingServer::get_singleton()->free(cursor_instance);
if (selection_level_instance[i].is_valid())
- VisualServer::get_singleton()->free(selection_level_instance[i]);
+ RenderingServer::get_singleton()->free(selection_level_instance[i]);
if (selection_level_mesh[i].is_valid())
- VisualServer::get_singleton()->free(selection_level_mesh[i]);
+ RenderingServer::get_singleton()->free(selection_level_mesh[i]);
}
- VisualServer::get_singleton()->free(selection_mesh);
+ RenderingServer::get_singleton()->free(selection_mesh);
if (selection_instance.is_valid())
- VisualServer::get_singleton()->free(selection_instance);
+ RenderingServer::get_singleton()->free(selection_instance);
- VisualServer::get_singleton()->free(paste_mesh);
+ RenderingServer::get_singleton()->free(paste_mesh);
if (paste_instance.is_valid())
- VisualServer::get_singleton()->free(paste_instance);
+ RenderingServer::get_singleton()->free(paste_instance);
}
void GridMapEditorPlugin::_notification(int p_what) {
@@ -1518,10 +1519,10 @@ void GridMapEditorPlugin::_notification(int p_what) {
switch ((int)EditorSettings::get_singleton()->get("editors/grid_map/editor_side")) {
case 0: { // Left.
- SpatialEditor::get_singleton()->get_palette_split()->move_child(grid_map_editor, 0);
+ Node3DEditor::get_singleton()->get_palette_split()->move_child(grid_map_editor, 0);
} break;
case 1: { // Right.
- SpatialEditor::get_singleton()->get_palette_split()->move_child(grid_map_editor, 1);
+ Node3DEditor::get_singleton()->get_palette_split()->move_child(grid_map_editor, 1);
} break;
}
}
@@ -1547,7 +1548,7 @@ void GridMapEditorPlugin::make_visible(bool p_visible) {
grid_map_editor->spatial_editor_hb->hide();
grid_map_editor->hide();
- grid_map_editor->edit(NULL);
+ grid_map_editor->edit(nullptr);
grid_map_editor->set_process(false);
}
}
diff --git a/modules/gridmap/grid_map_editor_plugin.h b/modules/gridmap/grid_map_editor_plugin.h
index d6459cee0a..fd880e8b7b 100644
--- a/modules/gridmap/grid_map_editor_plugin.h
+++ b/modules/gridmap/grid_map_editor_plugin.h
@@ -36,7 +36,7 @@
#include "editor/pane_drag.h"
#include "grid_map.h"
-class SpatialEditorPlugin;
+class Node3DEditorPlugin;
class GridMapEditor : public VBoxContainer {
GDCLASS(GridMapEditor, VBoxContainer);
@@ -188,7 +188,7 @@ class GridMapEditor : public VBoxContainer {
};
- SpatialEditorPlugin *spatial_editor;
+ Node3DEditorPlugin *spatial_editor;
struct AreaDisplay {
@@ -232,7 +232,7 @@ class GridMapEditor : public VBoxContainer {
void _delete_selection();
void _fill_selection();
- bool do_input_action(Camera *p_camera, const Point2 &p_point, bool p_click);
+ bool do_input_action(Camera3D *p_camera, const Point2 &p_point, bool p_click);
friend class GridMapEditorPlugin;
@@ -242,7 +242,7 @@ protected:
static void _bind_methods();
public:
- bool forward_spatial_input_event(Camera *p_camera, const Ref<InputEvent> &p_event);
+ bool forward_spatial_input_event(Camera3D *p_camera, const Ref<InputEvent> &p_event);
void edit(GridMap *p_gridmap);
GridMapEditor() {}
@@ -261,7 +261,7 @@ protected:
void _notification(int p_what);
public:
- virtual bool forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event) { return grid_map_editor->forward_spatial_input_event(p_camera, p_event); }
+ virtual bool forward_spatial_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event) { return grid_map_editor->forward_spatial_input_event(p_camera, p_event); }
virtual String get_name() const { return "GridMap"; }
bool has_main_screen() const { return false; }
virtual void edit(Object *p_object);
diff --git a/modules/hdr/SCsub b/modules/hdr/SCsub
index c960e8126b..a709397c9a 100644
--- a/modules/hdr/SCsub
+++ b/modules/hdr/SCsub
@@ -1,7 +1,7 @@
#!/usr/bin/env python
-Import('env')
-Import('env_modules')
+Import("env")
+Import("env_modules")
env_hdr = env_modules.Clone()
diff --git a/modules/hdr/config.py b/modules/hdr/config.py
index 1c8cd12a2d..d22f9454ed 100644
--- a/modules/hdr/config.py
+++ b/modules/hdr/config.py
@@ -1,5 +1,6 @@
def can_build(env, platform):
return True
+
def configure(env):
pass
diff --git a/modules/hdr/register_types.cpp b/modules/hdr/register_types.cpp
index 2ef6b7cd07..5f2d1578c5 100644
--- a/modules/hdr/register_types.cpp
+++ b/modules/hdr/register_types.cpp
@@ -32,7 +32,7 @@
#include "image_loader_hdr.h"
-static ImageLoaderHDR *image_loader_hdr = NULL;
+static ImageLoaderHDR *image_loader_hdr = nullptr;
void register_hdr_types() {
diff --git a/modules/jpg/SCsub b/modules/jpg/SCsub
index 96e8e704dd..8ee8e6dd6e 100644
--- a/modules/jpg/SCsub
+++ b/modules/jpg/SCsub
@@ -1,7 +1,7 @@
#!/usr/bin/env python
-Import('env')
-Import('env_modules')
+Import("env")
+Import("env_modules")
env_jpg = env_modules.Clone()
diff --git a/modules/jpg/config.py b/modules/jpg/config.py
index 1c8cd12a2d..d22f9454ed 100644
--- a/modules/jpg/config.py
+++ b/modules/jpg/config.py
@@ -1,5 +1,6 @@
def can_build(env, platform):
return True
+
def configure(env):
pass
diff --git a/modules/jpg/register_types.cpp b/modules/jpg/register_types.cpp
index f6077d5c68..61375fef10 100644
--- a/modules/jpg/register_types.cpp
+++ b/modules/jpg/register_types.cpp
@@ -32,7 +32,7 @@
#include "image_loader_jpegd.h"
-static ImageLoaderJPG *image_loader_jpg = NULL;
+static ImageLoaderJPG *image_loader_jpg = nullptr;
void register_jpg_types() {
diff --git a/modules/jsonrpc/SCsub b/modules/jsonrpc/SCsub
index 13c9ffb253..fe5312670a 100644
--- a/modules/jsonrpc/SCsub
+++ b/modules/jsonrpc/SCsub
@@ -1,7 +1,7 @@
#!/usr/bin/env python
-Import('env')
-Import('env_modules')
+Import("env")
+Import("env_modules")
env_jsonrpc = env_modules.Clone()
env_jsonrpc.add_source_files(env.modules_sources, "*.cpp")
diff --git a/modules/jsonrpc/config.py b/modules/jsonrpc/config.py
index 53bc827027..d22f9454ed 100644
--- a/modules/jsonrpc/config.py
+++ b/modules/jsonrpc/config.py
@@ -1,5 +1,6 @@
def can_build(env, platform):
- return True
+ return True
+
def configure(env):
- pass
+ pass
diff --git a/modules/jsonrpc/jsonrpc.cpp b/modules/jsonrpc/jsonrpc.cpp
index 014b65e3e2..393269d422 100644
--- a/modules/jsonrpc/jsonrpc.cpp
+++ b/modules/jsonrpc/jsonrpc.cpp
@@ -119,7 +119,7 @@ Variant JSONRPC::process_action(const Variant &p_action, bool p_process_arr_elem
id = dict["id"];
}
- if (object == NULL || !object->has_method(method)) {
+ if (object == nullptr || !object->has_method(method)) {
ret = make_response_error(JSONRPC::METHOD_NOT_FOUND, "Method not found", id);
} else {
Variant call_ret = object->callv(method, args);
diff --git a/modules/mbedtls/SCsub b/modules/mbedtls/SCsub
index 0c6c703e16..5f5d25a3ee 100755
--- a/modules/mbedtls/SCsub
+++ b/modules/mbedtls/SCsub
@@ -1,11 +1,11 @@
#!/usr/bin/env python
-Import('env')
-Import('env_modules')
+Import("env")
+Import("env_modules")
env_mbed_tls = env_modules.Clone()
-if env['builtin_mbedtls']:
+if env["builtin_mbedtls"]:
# Thirdparty source files
thirdparty_sources = [
"aes.c",
@@ -86,7 +86,7 @@ if env['builtin_mbedtls']:
"x509_csr.c",
"x509write_crt.c",
"x509write_csr.c",
- "xtea.c"
+ "xtea.c",
]
thirdparty_dir = "#thirdparty/mbedtls/library/"
diff --git a/modules/mbedtls/config.py b/modules/mbedtls/config.py
index 1c8cd12a2d..d22f9454ed 100755
--- a/modules/mbedtls/config.py
+++ b/modules/mbedtls/config.py
@@ -1,5 +1,6 @@
def can_build(env, platform):
return True
+
def configure(env):
pass
diff --git a/modules/mbedtls/crypto_mbedtls.cpp b/modules/mbedtls/crypto_mbedtls.cpp
index c8a8240a19..a47a4503a5 100644
--- a/modules/mbedtls/crypto_mbedtls.cpp
+++ b/modules/mbedtls/crypto_mbedtls.cpp
@@ -66,7 +66,7 @@ Error CryptoKeyMbedTLS::load(String p_path) {
}
memdelete(f);
- int ret = mbedtls_pk_parse_key(&pkey, out.ptr(), out.size(), NULL, 0);
+ int ret = mbedtls_pk_parse_key(&pkey, out.ptr(), out.size(), nullptr, 0);
// We MUST zeroize the memory for safety!
mbedtls_platform_zeroize(out.ptrw(), out.size());
ERR_FAIL_COND_V_MSG(ret, FAILED, "Error parsing private key '" + itos(ret) + "'.");
@@ -167,11 +167,11 @@ void CryptoMbedTLS::initialize_crypto() {
}
void CryptoMbedTLS::finalize_crypto() {
- Crypto::_create = NULL;
- Crypto::_load_default_certificates = NULL;
+ Crypto::_create = nullptr;
+ Crypto::_load_default_certificates = nullptr;
if (default_certs) {
memdelete(default_certs);
- default_certs = NULL;
+ default_certs = nullptr;
}
X509CertificateMbedTLS::finalize();
CryptoKeyMbedTLS::finalize();
@@ -180,7 +180,7 @@ void CryptoMbedTLS::finalize_crypto() {
CryptoMbedTLS::CryptoMbedTLS() {
mbedtls_ctr_drbg_init(&ctr_drbg);
mbedtls_entropy_init(&entropy);
- int ret = mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy, NULL, 0);
+ int ret = mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy, nullptr, 0);
if (ret != 0) {
ERR_PRINT(" failed\n ! mbedtls_ctr_drbg_seed returned an error" + itos(ret));
}
@@ -191,17 +191,17 @@ CryptoMbedTLS::~CryptoMbedTLS() {
mbedtls_entropy_free(&entropy);
}
-X509CertificateMbedTLS *CryptoMbedTLS::default_certs = NULL;
+X509CertificateMbedTLS *CryptoMbedTLS::default_certs = nullptr;
X509CertificateMbedTLS *CryptoMbedTLS::get_default_certificates() {
return default_certs;
}
void CryptoMbedTLS::load_default_certificates(String p_path) {
- ERR_FAIL_COND(default_certs != NULL);
+ ERR_FAIL_COND(default_certs != nullptr);
default_certs = memnew(X509CertificateMbedTLS);
- ERR_FAIL_COND(default_certs == NULL);
+ ERR_FAIL_COND(default_certs == nullptr);
if (p_path != "") {
// Use certs defined in project settings.
@@ -227,15 +227,15 @@ Ref<CryptoKey> CryptoMbedTLS::generate_rsa(int p_bytes) {
Ref<CryptoKeyMbedTLS> out;
out.instance();
int ret = mbedtls_pk_setup(&(out->pkey), mbedtls_pk_info_from_type(MBEDTLS_PK_RSA));
- ERR_FAIL_COND_V(ret != 0, NULL);
+ ERR_FAIL_COND_V(ret != 0, nullptr);
ret = mbedtls_rsa_gen_key(mbedtls_pk_rsa(out->pkey), mbedtls_ctr_drbg_random, &ctr_drbg, p_bytes, 65537);
- ERR_FAIL_COND_V(ret != 0, NULL);
+ ERR_FAIL_COND_V(ret != 0, nullptr);
return out;
}
Ref<X509Certificate> CryptoMbedTLS::generate_self_signed_certificate(Ref<CryptoKey> p_key, String p_issuer_name, String p_not_before, String p_not_after) {
Ref<CryptoKeyMbedTLS> key = static_cast<Ref<CryptoKeyMbedTLS>>(p_key);
- ERR_FAIL_COND_V_MSG(key.is_null(), NULL, "Invalid private key argument.");
+ ERR_FAIL_COND_V_MSG(key.is_null(), nullptr, "Invalid private key argument.");
mbedtls_x509write_cert crt;
mbedtls_x509write_crt_init(&crt);
@@ -250,7 +250,7 @@ Ref<X509Certificate> CryptoMbedTLS::generate_self_signed_certificate(Ref<CryptoK
mbedtls_mpi_init(&serial);
uint8_t rand_serial[20];
mbedtls_ctr_drbg_random(&ctr_drbg, rand_serial, 20);
- ERR_FAIL_COND_V(mbedtls_mpi_read_binary(&serial, rand_serial, 20), NULL);
+ ERR_FAIL_COND_V(mbedtls_mpi_read_binary(&serial, rand_serial, 20), nullptr);
mbedtls_x509write_crt_set_serial(&crt, &serial);
mbedtls_x509write_crt_set_validity(&crt, p_not_before.utf8().get_data(), p_not_after.utf8().get_data());
@@ -268,7 +268,7 @@ Ref<X509Certificate> CryptoMbedTLS::generate_self_signed_certificate(Ref<CryptoK
mbedtls_mpi_free(&serial);
mbedtls_x509write_crt_free(&crt);
ERR_PRINT("Generated invalid certificate: " + itos(err));
- return NULL;
+ return nullptr;
}
mbedtls_mpi_free(&serial);
diff --git a/modules/mbedtls/crypto_mbedtls.h b/modules/mbedtls/crypto_mbedtls.h
index 6c1c0e255d..db3d00a5e3 100644
--- a/modules/mbedtls/crypto_mbedtls.h
+++ b/modules/mbedtls/crypto_mbedtls.h
@@ -49,7 +49,7 @@ private:
public:
static CryptoKey *create();
static void make_default() { CryptoKey::_create = create; }
- static void finalize() { CryptoKey::_create = NULL; }
+ static void finalize() { CryptoKey::_create = nullptr; }
virtual Error load(String p_path);
virtual Error save(String p_path);
@@ -78,7 +78,7 @@ private:
public:
static X509Certificate *create();
static void make_default() { X509Certificate::_create = create; }
- static void finalize() { X509Certificate::_create = NULL; }
+ static void finalize() { X509Certificate::_create = nullptr; }
virtual Error load(String p_path);
virtual Error load_from_memory(const uint8_t *p_buffer, int p_len);
diff --git a/modules/mbedtls/dtls_server_mbedtls.cpp b/modules/mbedtls/dtls_server_mbedtls.cpp
index 215b511758..f31f067f4e 100644
--- a/modules/mbedtls/dtls_server_mbedtls.cpp
+++ b/modules/mbedtls/dtls_server_mbedtls.cpp
@@ -65,7 +65,7 @@ void DTLSServerMbedTLS::initialize() {
}
void DTLSServerMbedTLS::finalize() {
- _create = NULL;
+ _create = nullptr;
available = false;
}
diff --git a/modules/mbedtls/packet_peer_mbed_dtls.cpp b/modules/mbedtls/packet_peer_mbed_dtls.cpp
index bdf36ad1b1..b2aa5f5827 100755
--- a/modules/mbedtls/packet_peer_mbed_dtls.cpp
+++ b/modules/mbedtls/packet_peer_mbed_dtls.cpp
@@ -36,11 +36,11 @@
int PacketPeerMbedDTLS::bio_send(void *ctx, const unsigned char *buf, size_t len) {
- if (buf == NULL || len <= 0) return 0;
+ if (buf == nullptr || len <= 0) return 0;
PacketPeerMbedDTLS *sp = (PacketPeerMbedDTLS *)ctx;
- ERR_FAIL_COND_V(sp == NULL, 0);
+ ERR_FAIL_COND_V(sp == nullptr, 0);
Error err = sp->base->put_packet((const uint8_t *)buf, len);
if (err == ERR_BUSY) {
@@ -53,11 +53,11 @@ int PacketPeerMbedDTLS::bio_send(void *ctx, const unsigned char *buf, size_t len
int PacketPeerMbedDTLS::bio_recv(void *ctx, unsigned char *buf, size_t len) {
- if (buf == NULL || len <= 0) return 0;
+ if (buf == nullptr || len <= 0) return 0;
PacketPeerMbedDTLS *sp = (PacketPeerMbedDTLS *)ctx;
- ERR_FAIL_COND_V(sp == NULL, 0);
+ ERR_FAIL_COND_V(sp == nullptr, 0);
int pc = sp->base->get_available_packet_count();
if (pc == 0) {
@@ -125,7 +125,7 @@ Error PacketPeerMbedDTLS::connect_to_peer(Ref<PacketPeerUDP> p_base, bool p_vali
ERR_FAIL_COND_V(err != OK, err);
mbedtls_ssl_set_hostname(ssl_ctx->get_context(), p_for_hostname.utf8().get_data());
- mbedtls_ssl_set_bio(ssl_ctx->get_context(), this, bio_send, bio_recv, NULL);
+ mbedtls_ssl_set_bio(ssl_ctx->get_context(), this, bio_send, bio_recv, nullptr);
mbedtls_ssl_set_timer_cb(ssl_ctx->get_context(), &timer, mbedtls_timing_set_delay, mbedtls_timing_get_delay);
status = STATUS_HANDSHAKING;
@@ -154,7 +154,7 @@ Error PacketPeerMbedDTLS::accept_peer(Ref<PacketPeerUDP> p_base, Ref<CryptoKey>
ERR_FAIL_V_MSG(FAILED, "Error setting DTLS client cookie");
}
- mbedtls_ssl_set_bio(ssl_ctx->get_context(), this, bio_send, bio_recv, NULL);
+ mbedtls_ssl_set_bio(ssl_ctx->get_context(), this, bio_send, bio_recv, nullptr);
mbedtls_ssl_set_timer_cb(ssl_ctx->get_context(), &timer, mbedtls_timing_set_delay, mbedtls_timing_get_delay);
status = STATUS_HANDSHAKING;
@@ -223,7 +223,7 @@ void PacketPeerMbedDTLS::poll() {
ERR_FAIL_COND(!base.is_valid());
- int ret = mbedtls_ssl_read(ssl_ctx->get_context(), NULL, 0);
+ int ret = mbedtls_ssl_read(ssl_ctx->get_context(), nullptr, 0);
if (ret < 0 && ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE) {
if (ret == MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY) {
@@ -292,6 +292,6 @@ void PacketPeerMbedDTLS::initialize_dtls() {
}
void PacketPeerMbedDTLS::finalize_dtls() {
- _create = NULL;
+ _create = nullptr;
available = false;
}
diff --git a/modules/mbedtls/ssl_context_mbedtls.cpp b/modules/mbedtls/ssl_context_mbedtls.cpp
index 52630bd98c..1ffb9bda05 100644
--- a/modules/mbedtls/ssl_context_mbedtls.cpp
+++ b/modules/mbedtls/ssl_context_mbedtls.cpp
@@ -53,7 +53,7 @@ Error CookieContextMbedTLS::setup() {
mbedtls_ssl_cookie_init(&cookie_ctx);
inited = true;
- int ret = mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy, NULL, 0);
+ int ret = mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy, nullptr, 0);
if (ret != 0) {
clear(); // Never leave unusable resources around.
ERR_FAIL_V_MSG(FAILED, "mbedtls_ctr_drbg_seed returned an error " + itos(ret));
@@ -94,7 +94,7 @@ Error SSLContextMbedTLS::_setup(int p_endpoint, int p_transport, int p_authmode)
mbedtls_entropy_init(&entropy);
inited = true;
- int ret = mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy, NULL, 0);
+ int ret = mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy, nullptr, 0);
if (ret != 0) {
clear(); // Never leave unusable resources around.
ERR_FAIL_V_MSG(FAILED, "mbedtls_ctr_drbg_seed returned an error " + itos(ret));
@@ -134,7 +134,7 @@ Error SSLContextMbedTLS::init_server(int p_transport, int p_authmode, Ref<Crypto
}
// Adding CA chain if available.
if (certs->cert.next) {
- mbedtls_ssl_conf_ca_chain(&conf, certs->cert.next, NULL);
+ mbedtls_ssl_conf_ca_chain(&conf, certs->cert.next, nullptr);
}
// DTLS Cookies
if (p_transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM) {
@@ -153,7 +153,7 @@ Error SSLContextMbedTLS::init_client(int p_transport, int p_authmode, Ref<X509Ce
Error err = _setup(MBEDTLS_SSL_IS_CLIENT, p_transport, p_authmode);
ERR_FAIL_COND_V(err != OK, err);
- X509CertificateMbedTLS *cas = NULL;
+ X509CertificateMbedTLS *cas = nullptr;
if (p_valid_cas.is_valid()) {
// Locking CA certificates
@@ -163,14 +163,14 @@ Error SSLContextMbedTLS::init_client(int p_transport, int p_authmode, Ref<X509Ce
} else {
// Fall back to default certificates (no need to lock those).
cas = CryptoMbedTLS::get_default_certificates();
- if (cas == NULL) {
+ if (cas == nullptr) {
clear();
ERR_FAIL_V_MSG(ERR_UNCONFIGURED, "SSL module failed to initialize!");
}
}
// Set valid CAs
- mbedtls_ssl_conf_ca_chain(&conf, &(cas->cert), NULL);
+ mbedtls_ssl_conf_ca_chain(&conf, &(cas->cert), nullptr);
mbedtls_ssl_setup(&ssl, &conf);
return OK;
}
@@ -195,7 +195,7 @@ void SSLContextMbedTLS::clear() {
}
mbedtls_ssl_context *SSLContextMbedTLS::get_context() {
- ERR_FAIL_COND_V(!inited, NULL);
+ ERR_FAIL_COND_V(!inited, nullptr);
return &ssl;
}
diff --git a/modules/mbedtls/stream_peer_mbedtls.cpp b/modules/mbedtls/stream_peer_mbedtls.cpp
index 03c5922267..983095c536 100755
--- a/modules/mbedtls/stream_peer_mbedtls.cpp
+++ b/modules/mbedtls/stream_peer_mbedtls.cpp
@@ -35,11 +35,11 @@
int StreamPeerMbedTLS::bio_send(void *ctx, const unsigned char *buf, size_t len) {
- if (buf == NULL || len <= 0) return 0;
+ if (buf == nullptr || len <= 0) return 0;
StreamPeerMbedTLS *sp = (StreamPeerMbedTLS *)ctx;
- ERR_FAIL_COND_V(sp == NULL, 0);
+ ERR_FAIL_COND_V(sp == nullptr, 0);
int sent;
Error err = sp->base->put_partial_data((const uint8_t *)buf, len, sent);
@@ -54,11 +54,11 @@ int StreamPeerMbedTLS::bio_send(void *ctx, const unsigned char *buf, size_t len)
int StreamPeerMbedTLS::bio_recv(void *ctx, unsigned char *buf, size_t len) {
- if (buf == NULL || len <= 0) return 0;
+ if (buf == nullptr || len <= 0) return 0;
StreamPeerMbedTLS *sp = (StreamPeerMbedTLS *)ctx;
- ERR_FAIL_COND_V(sp == NULL, 0);
+ ERR_FAIL_COND_V(sp == nullptr, 0);
int got;
Error err = sp->base->get_partial_data((uint8_t *)buf, len, got);
@@ -112,7 +112,7 @@ Error StreamPeerMbedTLS::connect_to_stream(Ref<StreamPeer> p_base, bool p_valida
ERR_FAIL_COND_V(err != OK, err);
mbedtls_ssl_set_hostname(ssl_ctx->get_context(), p_for_hostname.utf8().get_data());
- mbedtls_ssl_set_bio(ssl_ctx->get_context(), this, bio_send, bio_recv, NULL);
+ mbedtls_ssl_set_bio(ssl_ctx->get_context(), this, bio_send, bio_recv, nullptr);
status = STATUS_HANDSHAKING;
@@ -133,7 +133,7 @@ Error StreamPeerMbedTLS::accept_stream(Ref<StreamPeer> p_base, Ref<CryptoKey> p_
base = p_base;
- mbedtls_ssl_set_bio(ssl_ctx->get_context(), this, bio_send, bio_recv, NULL);
+ mbedtls_ssl_set_bio(ssl_ctx->get_context(), this, bio_send, bio_recv, nullptr);
status = STATUS_HANDSHAKING;
@@ -320,5 +320,5 @@ void StreamPeerMbedTLS::initialize_ssl() {
void StreamPeerMbedTLS::finalize_ssl() {
available = false;
- _create = NULL;
+ _create = nullptr;
}
diff --git a/modules/mobile_vr/SCsub b/modules/mobile_vr/SCsub
index 4bd184f025..e6c43228b4 100644
--- a/modules/mobile_vr/SCsub
+++ b/modules/mobile_vr/SCsub
@@ -1,8 +1,8 @@
#!/usr/bin/env python
-Import('env')
-Import('env_modules')
+Import("env")
+Import("env_modules")
env_mobile_vr = env_modules.Clone()
-env_mobile_vr.add_source_files(env.modules_sources, '*.cpp')
+env_mobile_vr.add_source_files(env.modules_sources, "*.cpp")
diff --git a/modules/mobile_vr/config.py b/modules/mobile_vr/config.py
index e85fa631dd..ee401c1a2a 100644
--- a/modules/mobile_vr/config.py
+++ b/modules/mobile_vr/config.py
@@ -1,13 +1,16 @@
def can_build(env, platform):
return True
+
def configure(env):
pass
+
def get_doc_classes():
return [
"MobileVRInterface",
]
+
def get_doc_path():
return "doc_classes"
diff --git a/modules/mobile_vr/doc_classes/MobileVRInterface.xml b/modules/mobile_vr/doc_classes/MobileVRInterface.xml
index 7552abe61d..120535bd41 100644
--- a/modules/mobile_vr/doc_classes/MobileVRInterface.xml
+++ b/modules/mobile_vr/doc_classes/MobileVRInterface.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="MobileVRInterface" inherits="ARVRInterface" version="4.0">
+<class name="MobileVRInterface" inherits="XRInterface" version="4.0">
<brief_description>
Generic mobile VR implementation.
</brief_description>
@@ -8,9 +8,9 @@
Note that even though there is no positional tracking, the camera will assume the headset is at a height of 1.85 meters. You can change this by setting [member eye_height].
You can initialise this interface as follows:
[codeblock]
- var interface = ARVRServer.find_interface("Native mobile")
+ var interface = XRServer.find_interface("Native mobile")
if interface and interface.initialize():
- get_viewport().arvr = true
+ get_viewport().xr = true
[/codeblock]
</description>
<tutorials>
@@ -25,7 +25,7 @@
The width of the display in centimeters.
</member>
<member name="eye_height" type="float" setter="set_eye_height" getter="get_eye_height" default="1.85">
- The height at which the camera is placed in relation to the ground (i.e. [ARVROrigin] node).
+ The height at which the camera is placed in relation to the ground (i.e. [XROrigin3D] node).
</member>
<member name="iod" type="float" setter="set_iod" getter="get_iod" default="6.0">
The interocular distance, also known as the interpupillary distance. The distance between the pupils of the left and right eye.
diff --git a/modules/mobile_vr/mobile_vr_interface.cpp b/modules/mobile_vr/mobile_vr_interface.cpp
index 2f1d95cd42..48276c0d3d 100644
--- a/modules/mobile_vr/mobile_vr_interface.cpp
+++ b/modules/mobile_vr/mobile_vr_interface.cpp
@@ -29,16 +29,18 @@
/*************************************************************************/
#include "mobile_vr_interface.h"
-#include "core/os/input.h"
+
+#include "core/input/input.h"
#include "core/os/os.h"
-#include "servers/visual/visual_server_globals.h"
+#include "servers/display_server.h"
+#include "servers/rendering/rendering_server_globals.h"
StringName MobileVRInterface::get_name() const {
return "Native mobile";
};
int MobileVRInterface::get_capabilities() const {
- return ARVRInterface::ARVR_STEREO;
+ return XRInterface::XR_STEREO;
};
Vector3 MobileVRInterface::scale_magneto(const Vector3 &p_magnetometer) {
@@ -164,7 +166,7 @@ void MobileVRInterface::set_position_from_sensors() {
rotate.rotate(orientation.get_axis(2), gyro.z * delta_time);
orientation = rotate * orientation;
- tracking_state = ARVRInterface::ARVR_NORMAL_TRACKING;
+ tracking_state = XRInterface::XR_NORMAL_TRACKING;
};
///@TODO improve this, the magnetometer is very fidgity sometimes flipping the axis for no apparent reason (probably a bug on my part)
@@ -176,7 +178,7 @@ void MobileVRInterface::set_position_from_sensors() {
transform_quat = transform_quat.slerp(acc_mag_quat, 0.1);
orientation = Basis(transform_quat);
- tracking_state = ARVRInterface::ARVR_NORMAL_TRACKING;
+ tracking_state = XRInterface::XR_NORMAL_TRACKING;
} else if (has_grav) {
// use gravity vector to make sure down is down...
// transform gravity into our world space
@@ -296,8 +298,8 @@ bool MobileVRInterface::is_initialized() const {
};
bool MobileVRInterface::initialize() {
- ARVRServer *arvr_server = ARVRServer::get_singleton();
- ERR_FAIL_NULL_V(arvr_server, false);
+ XRServer *xr_server = XRServer::get_singleton();
+ ERR_FAIL_NULL_V(xr_server, false);
if (!initialized) {
// reset our sensor data and orientation
@@ -313,7 +315,7 @@ bool MobileVRInterface::initialize() {
orientation = Basis();
// make this our primary interface
- arvr_server->set_primary_interface(this);
+ xr_server->set_primary_interface(this);
last_ticks = OS::get_singleton()->get_ticks_usec();
@@ -325,10 +327,10 @@ bool MobileVRInterface::initialize() {
void MobileVRInterface::uninitialize() {
if (initialized) {
- ARVRServer *arvr_server = ARVRServer::get_singleton();
- if (arvr_server != NULL) {
+ XRServer *xr_server = XRServer::get_singleton();
+ if (xr_server != nullptr) {
// no longer our primary interface
- arvr_server->clear_primary_interface_if(this);
+ xr_server->clear_primary_interface_if(this);
}
initialized = false;
@@ -339,7 +341,7 @@ Size2 MobileVRInterface::get_render_targetsize() {
_THREAD_SAFE_METHOD_
// we use half our window size
- Size2 target_size = OS::get_singleton()->get_window_size();
+ Size2 target_size = DisplayServer::get_singleton()->window_get_size();
target_size.x *= 0.5 * oversample;
target_size.y *= oversample;
@@ -347,22 +349,22 @@ Size2 MobileVRInterface::get_render_targetsize() {
return target_size;
};
-Transform MobileVRInterface::get_transform_for_eye(ARVRInterface::Eyes p_eye, const Transform &p_cam_transform) {
+Transform MobileVRInterface::get_transform_for_eye(XRInterface::Eyes p_eye, const Transform &p_cam_transform) {
_THREAD_SAFE_METHOD_
Transform transform_for_eye;
- ARVRServer *arvr_server = ARVRServer::get_singleton();
- ERR_FAIL_NULL_V(arvr_server, transform_for_eye);
+ XRServer *xr_server = XRServer::get_singleton();
+ ERR_FAIL_NULL_V(xr_server, transform_for_eye);
if (initialized) {
- float world_scale = arvr_server->get_world_scale();
+ float world_scale = xr_server->get_world_scale();
// we don't need to check for the existence of our HMD, doesn't effect our values...
// note * 0.01 to convert cm to m and * 0.5 as we're moving half in each direction...
- if (p_eye == ARVRInterface::EYE_LEFT) {
+ if (p_eye == XRInterface::EYE_LEFT) {
transform_for_eye.origin.x = -(intraocular_dist * 0.01 * 0.5 * world_scale);
- } else if (p_eye == ARVRInterface::EYE_RIGHT) {
+ } else if (p_eye == XRInterface::EYE_RIGHT) {
transform_for_eye.origin.x = intraocular_dist * 0.01 * 0.5 * world_scale;
} else {
// for mono we don't reposition, we want our center position.
@@ -373,7 +375,7 @@ Transform MobileVRInterface::get_transform_for_eye(ARVRInterface::Eyes p_eye, co
hmd_transform.basis = orientation;
hmd_transform.origin = Vector3(0.0, eye_height * world_scale, 0.0);
- transform_for_eye = p_cam_transform * (arvr_server->get_reference_frame()) * hmd_transform * transform_for_eye;
+ transform_for_eye = p_cam_transform * (xr_server->get_reference_frame()) * hmd_transform * transform_for_eye;
} else {
// huh? well just return what we got....
transform_for_eye = p_cam_transform;
@@ -382,12 +384,12 @@ Transform MobileVRInterface::get_transform_for_eye(ARVRInterface::Eyes p_eye, co
return transform_for_eye;
};
-CameraMatrix MobileVRInterface::get_projection_for_eye(ARVRInterface::Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far) {
+CameraMatrix MobileVRInterface::get_projection_for_eye(XRInterface::Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far) {
_THREAD_SAFE_METHOD_
CameraMatrix eye;
- if (p_eye == ARVRInterface::EYE_MONO) {
+ if (p_eye == XRInterface::EYE_MONO) {
///@TODO for now hardcode some of this, what is really needed here is that this needs to be in sync with the real cameras properties
// which probably means implementing a specific class for iOS and Android. For now this is purely here as an example.
// Note also that if you use a normal viewport with AR/VR turned off you can still use the tracker output of this interface
@@ -395,13 +397,13 @@ CameraMatrix MobileVRInterface::get_projection_for_eye(ARVRInterface::Eyes p_eye
// This will make more sense when we implement ARkit on iOS (probably a separate interface).
eye.set_perspective(60.0, p_aspect, p_z_near, p_z_far, false);
} else {
- eye.set_for_hmd(p_eye == ARVRInterface::EYE_LEFT ? 1 : 2, p_aspect, intraocular_dist, display_width, display_to_lens, oversample, p_z_near, p_z_far);
+ eye.set_for_hmd(p_eye == XRInterface::EYE_LEFT ? 1 : 2, p_aspect, intraocular_dist, display_width, display_to_lens, oversample, p_z_near, p_z_far);
};
return eye;
};
-void MobileVRInterface::commit_for_eye(ARVRInterface::Eyes p_eye, RID p_render_target, const Rect2 &p_screen_rect) {
+void MobileVRInterface::commit_for_eye(XRInterface::Eyes p_eye, RID p_render_target, const Rect2 &p_screen_rect) {
_THREAD_SAFE_METHOD_
// We must have a valid render target
@@ -416,9 +418,9 @@ void MobileVRInterface::commit_for_eye(ARVRInterface::Eyes p_eye, RID p_render_t
// we output half a screen
dest.size.x *= 0.5;
- if (p_eye == ARVRInterface::EYE_LEFT) {
+ if (p_eye == XRInterface::EYE_LEFT) {
eye_center.x = ((-intraocular_dist / 2.0) + (display_width / 4.0)) / (display_width / 2.0);
- } else if (p_eye == ARVRInterface::EYE_RIGHT) {
+ } else if (p_eye == XRInterface::EYE_RIGHT) {
dest.position.x = dest.size.x;
eye_center.x = ((intraocular_dist / 2.0) - (display_width / 4.0)) / (display_width / 2.0);
}
diff --git a/modules/mobile_vr/mobile_vr_interface.h b/modules/mobile_vr/mobile_vr_interface.h
index c762c9b799..3a9ed1314a 100644
--- a/modules/mobile_vr/mobile_vr_interface.h
+++ b/modules/mobile_vr/mobile_vr_interface.h
@@ -31,8 +31,8 @@
#ifndef MOBILE_VR_INTERFACE_H
#define MOBILE_VR_INTERFACE_H
-#include "servers/arvr/arvr_interface.h"
-#include "servers/arvr/arvr_positional_tracker.h"
+#include "servers/xr/xr_interface.h"
+#include "servers/xr/xr_positional_tracker.h"
/**
@author Bastiaan Olij <mux213@gmail.com>
@@ -47,8 +47,8 @@
more advanced interfaces.
*/
-class MobileVRInterface : public ARVRInterface {
- GDCLASS(MobileVRInterface, ARVRInterface);
+class MobileVRInterface : public XRInterface {
+ GDCLASS(MobileVRInterface, XRInterface);
private:
bool initialized;
@@ -137,9 +137,9 @@ public:
virtual Size2 get_render_targetsize();
virtual bool is_stereo();
- virtual Transform get_transform_for_eye(ARVRInterface::Eyes p_eye, const Transform &p_cam_transform);
- virtual CameraMatrix get_projection_for_eye(ARVRInterface::Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far);
- virtual void commit_for_eye(ARVRInterface::Eyes p_eye, RID p_render_target, const Rect2 &p_screen_rect);
+ virtual Transform get_transform_for_eye(XRInterface::Eyes p_eye, const Transform &p_cam_transform);
+ virtual CameraMatrix get_projection_for_eye(XRInterface::Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far);
+ virtual void commit_for_eye(XRInterface::Eyes p_eye, RID p_render_target, const Rect2 &p_screen_rect);
virtual void process();
virtual void notification(int p_what);
diff --git a/modules/mobile_vr/register_types.cpp b/modules/mobile_vr/register_types.cpp
index faf6c3b151..75638d47c4 100644
--- a/modules/mobile_vr/register_types.cpp
+++ b/modules/mobile_vr/register_types.cpp
@@ -37,7 +37,7 @@ void register_mobile_vr_types() {
Ref<MobileVRInterface> mobile_vr;
mobile_vr.instance();
- ARVRServer::get_singleton()->add_interface(mobile_vr);
+ XRServer::get_singleton()->add_interface(mobile_vr);
}
void unregister_mobile_vr_types() {
diff --git a/modules/modules_builders.py b/modules/modules_builders.py
index 0e9cba2b0b..e7be6380d1 100644
--- a/modules/modules_builders.py
+++ b/modules/modules_builders.py
@@ -7,10 +7,10 @@ from platform_methods import subprocess_main
def generate_modules_enabled(target, source, env):
- with open(target[0].path, 'w') as f:
+ with open(target[0].path, "w") as f:
for module in env.module_list:
- f.write('#define %s\n' % ("MODULE_" + module.upper() + "_ENABLED"))
+ f.write("#define %s\n" % ("MODULE_" + module.upper() + "_ENABLED"))
-if __name__ == '__main__':
+if __name__ == "__main__":
subprocess_main(globals())
diff --git a/modules/mono/SCsub b/modules/mono/SCsub
index 5f03fafdcf..c723b210cb 100644
--- a/modules/mono/SCsub
+++ b/modules/mono/SCsub
@@ -2,46 +2,56 @@
import build_scripts.mono_configure as mono_configure
-Import('env')
-Import('env_modules')
+Import("env")
+Import("env_modules")
env_mono = env_modules.Clone()
-if env_mono['tools']:
+if env_mono["tools"]:
# NOTE: It is safe to generate this file here, since this is still executed serially
import build_scripts.gen_cs_glue_version as gen_cs_glue_version
- gen_cs_glue_version.generate_header('glue/GodotSharp', 'glue/cs_glue_version.gen.h')
+
+ gen_cs_glue_version.generate_header("glue/GodotSharp", "glue/cs_glue_version.gen.h")
# Glue sources
-if env_mono['mono_glue']:
- env_mono.Append(CPPDEFINES=['MONO_GLUE_ENABLED'])
+if env_mono["mono_glue"]:
+ env_mono.Append(CPPDEFINES=["MONO_GLUE_ENABLED"])
import os.path
- if not os.path.isfile('glue/mono_glue.gen.cpp'):
+
+ if not os.path.isfile("glue/mono_glue.gen.cpp"):
raise RuntimeError("Mono glue sources not found. Did you forget to run '--generate-mono-glue'?")
-if env_mono['tools'] or env_mono['target'] != 'release':
- env_mono.Append(CPPDEFINES=['GD_MONO_HOT_RELOAD'])
+if env_mono["tools"] or env_mono["target"] != "release":
+ env_mono.Append(CPPDEFINES=["GD_MONO_HOT_RELOAD"])
# Configure Mono
mono_configure.configure(env, env_mono)
-if env_mono['tools'] and env_mono['mono_glue']:
+if env_mono["tools"] and env_mono["mono_glue"]:
# Build Godot API solution
import build_scripts.api_solution_build as api_solution_build
+
api_sln_cmd = api_solution_build.build(env_mono)
# Build GodotTools
import build_scripts.godot_tools_build as godot_tools_build
+
godot_tools_build.build(env_mono, api_sln_cmd)
# Add sources
-env_mono.add_source_files(env.modules_sources, '*.cpp')
-env_mono.add_source_files(env.modules_sources, 'glue/*.cpp')
-env_mono.add_source_files(env.modules_sources, 'mono_gd/*.cpp')
-env_mono.add_source_files(env.modules_sources, 'utils/*.cpp')
+env_mono.add_source_files(env.modules_sources, "*.cpp")
+env_mono.add_source_files(env.modules_sources, "glue/*.cpp")
+env_mono.add_source_files(env.modules_sources, "mono_gd/*.cpp")
+env_mono.add_source_files(env.modules_sources, "utils/*.cpp")
+
+env_mono.add_source_files(env.modules_sources, "mono_gd/support/*.cpp")
+
+if env["platform"] in ["osx", "iphone"]:
+ env_mono.add_source_files(env.modules_sources, "mono_gd/support/*.mm")
+ env_mono.add_source_files(env.modules_sources, "mono_gd/support/*.m")
-if env['tools']:
- env_mono.add_source_files(env.modules_sources, 'editor/*.cpp')
+if env["tools"]:
+ env_mono.add_source_files(env.modules_sources, "editor/*.cpp")
diff --git a/modules/mono/build_scripts/api_solution_build.py b/modules/mono/build_scripts/api_solution_build.py
index 639197c285..9abac22df6 100644
--- a/modules/mono/build_scripts/api_solution_build.py
+++ b/modules/mono/build_scripts/api_solution_build.py
@@ -8,21 +8,22 @@ from SCons.Script import Dir
def build_api_solution(source, target, env):
# source and target elements are of type SCons.Node.FS.File, hence why we convert them to str
- module_dir = env['module_dir']
+ module_dir = env["module_dir"]
- solution_path = os.path.join(module_dir, 'glue/GodotSharp/GodotSharp.sln')
+ solution_path = os.path.join(module_dir, "glue/GodotSharp/GodotSharp.sln")
- build_config = env['solution_build_config']
+ build_config = env["solution_build_config"]
- extra_msbuild_args = ['/p:NoWarn=1591'] # Ignore missing documentation warnings
+ extra_msbuild_args = ["/p:NoWarn=1591"] # Ignore missing documentation warnings
from .solution_builder import build_solution
+
build_solution(env, solution_path, build_config, extra_msbuild_args=extra_msbuild_args)
# Copy targets
- core_src_dir = os.path.abspath(os.path.join(solution_path, os.pardir, 'GodotSharp', 'bin', build_config))
- editor_src_dir = os.path.abspath(os.path.join(solution_path, os.pardir, 'GodotSharpEditor', 'bin', build_config))
+ core_src_dir = os.path.abspath(os.path.join(solution_path, os.pardir, "GodotSharp", "bin", build_config))
+ editor_src_dir = os.path.abspath(os.path.join(solution_path, os.pardir, "GodotSharpEditor", "bin", build_config))
dst_dir = os.path.abspath(os.path.join(str(target[0]), os.pardir))
@@ -32,6 +33,7 @@ def build_api_solution(source, target, env):
def copy_target(target_path):
from shutil import copy
+
filename = os.path.basename(target_path)
src_path = os.path.join(core_src_dir, filename)
@@ -45,23 +47,28 @@ def build_api_solution(source, target, env):
def build(env_mono):
- assert env_mono['tools']
+ assert env_mono["tools"]
target_filenames = [
- 'GodotSharp.dll', 'GodotSharp.pdb', 'GodotSharp.xml',
- 'GodotSharpEditor.dll', 'GodotSharpEditor.pdb', 'GodotSharpEditor.xml'
+ "GodotSharp.dll",
+ "GodotSharp.pdb",
+ "GodotSharp.xml",
+ "GodotSharpEditor.dll",
+ "GodotSharpEditor.pdb",
+ "GodotSharpEditor.xml",
]
depend_cmd = []
- for build_config in ['Debug', 'Release']:
- output_dir = Dir('#bin').abspath
- editor_api_dir = os.path.join(output_dir, 'GodotSharp', 'Api', build_config)
+ for build_config in ["Debug", "Release"]:
+ output_dir = Dir("#bin").abspath
+ editor_api_dir = os.path.join(output_dir, "GodotSharp", "Api", build_config)
targets = [os.path.join(editor_api_dir, filename) for filename in target_filenames]
- cmd = env_mono.CommandNoCache(targets, depend_cmd, build_api_solution,
- module_dir=os.getcwd(), solution_build_config=build_config)
+ cmd = env_mono.CommandNoCache(
+ targets, depend_cmd, build_api_solution, module_dir=os.getcwd(), solution_build_config=build_config
+ )
env_mono.AlwaysBuild(cmd)
# Make the Release build of the API solution depend on the Debug build.
diff --git a/modules/mono/build_scripts/gen_cs_glue_version.py b/modules/mono/build_scripts/gen_cs_glue_version.py
index 5d1056c2fc..98bbb4d9be 100644
--- a/modules/mono/build_scripts/gen_cs_glue_version.py
+++ b/modules/mono/build_scripts/gen_cs_glue_version.py
@@ -1,20 +1,20 @@
-
def generate_header(solution_dir, version_header_dst):
import os
+
latest_mtime = 0
for root, dirs, files in os.walk(solution_dir, topdown=True):
- dirs[:] = [d for d in dirs if d not in ['Generated']] # Ignored generated files
- files = [f for f in files if f.endswith('.cs')]
+ dirs[:] = [d for d in dirs if d not in ["Generated"]] # Ignored generated files
+ files = [f for f in files if f.endswith(".cs")]
for file in files:
filepath = os.path.join(root, file)
mtime = os.path.getmtime(filepath)
latest_mtime = mtime if mtime > latest_mtime else latest_mtime
- glue_version = int(latest_mtime) # The latest modified time will do for now
+ glue_version = int(latest_mtime) # The latest modified time will do for now
- with open(version_header_dst, 'w') as version_header:
- version_header.write('/* THIS FILE IS GENERATED DO NOT EDIT */\n')
- version_header.write('#ifndef CS_GLUE_VERSION_H\n')
- version_header.write('#define CS_GLUE_VERSION_H\n\n')
- version_header.write('#define CS_GLUE_VERSION UINT32_C(' + str(glue_version) + ')\n')
- version_header.write('\n#endif // CS_GLUE_VERSION_H\n')
+ with open(version_header_dst, "w") as version_header:
+ version_header.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
+ version_header.write("#ifndef CS_GLUE_VERSION_H\n")
+ version_header.write("#define CS_GLUE_VERSION_H\n\n")
+ version_header.write("#define CS_GLUE_VERSION UINT32_C(" + str(glue_version) + ")\n")
+ version_header.write("\n#endif // CS_GLUE_VERSION_H\n")
diff --git a/modules/mono/build_scripts/godot_tools_build.py b/modules/mono/build_scripts/godot_tools_build.py
index 99341c631e..cffacf2577 100644
--- a/modules/mono/build_scripts/godot_tools_build.py
+++ b/modules/mono/build_scripts/godot_tools_build.py
@@ -8,30 +8,31 @@ from SCons.Script import Dir
def build_godot_tools(source, target, env):
# source and target elements are of type SCons.Node.FS.File, hence why we convert them to str
- module_dir = env['module_dir']
+ module_dir = env["module_dir"]
- solution_path = os.path.join(module_dir, 'editor/GodotTools/GodotTools.sln')
- build_config = 'Debug' if env['target'] == 'debug' else 'Release'
+ solution_path = os.path.join(module_dir, "editor/GodotTools/GodotTools.sln")
+ build_config = "Debug" if env["target"] == "debug" else "Release"
# Custom build target to make sure output is always copied to the data dir.
- extra_build_args = ['/Target:Build;GodotTools:BuildAlwaysCopyToDataDir']
+ extra_build_args = ["/Target:Build;GodotTools:BuildAlwaysCopyToDataDir"]
+
+ from .solution_builder import build_solution, nuget_restore
- from . solution_builder import build_solution, nuget_restore
nuget_restore(env, solution_path)
build_solution(env, solution_path, build_config, extra_build_args)
# No need to copy targets. The GodotTools csproj takes care of copying them.
def build(env_mono, api_sln_cmd):
- assert env_mono['tools']
+ assert env_mono["tools"]
- output_dir = Dir('#bin').abspath
- editor_tools_dir = os.path.join(output_dir, 'GodotSharp', 'Tools')
+ output_dir = Dir("#bin").abspath
+ editor_tools_dir = os.path.join(output_dir, "GodotSharp", "Tools")
- target_filenames = ['GodotTools.dll']
+ target_filenames = ["GodotTools.dll"]
- if env_mono['target'] == 'debug':
- target_filenames += ['GodotTools.pdb']
+ if env_mono["target"] == "debug":
+ target_filenames += ["GodotTools.pdb"]
targets = [os.path.join(editor_tools_dir, filename) for filename in target_filenames]
diff --git a/modules/mono/build_scripts/make_android_mono_config.py b/modules/mono/build_scripts/make_android_mono_config.py
index 0afd939c57..d276d7d886 100644
--- a/modules/mono/build_scripts/make_android_mono_config.py
+++ b/modules/mono/build_scripts/make_android_mono_config.py
@@ -1,24 +1,24 @@
-
def generate_compressed_config(config_src, output_dir):
import os.path
- from compat import byte_to_str
# Source file
- with open(os.path.join(output_dir, 'android_mono_config.gen.cpp'), 'w') as cpp:
- with open(config_src, 'rb') as f:
+ with open(os.path.join(output_dir, "android_mono_config.gen.cpp"), "w") as cpp:
+ with open(config_src, "rb") as f:
buf = f.read()
decompr_size = len(buf)
import zlib
+
buf = zlib.compress(buf)
compr_size = len(buf)
- bytes_seq_str = ''
+ bytes_seq_str = ""
for i, buf_idx in enumerate(range(compr_size)):
if i > 0:
- bytes_seq_str += ', '
- bytes_seq_str += byte_to_str(buf[buf_idx])
+ bytes_seq_str += ", "
+ bytes_seq_str += str(buf[buf_idx])
- cpp.write('''/* THIS FILE IS GENERATED DO NOT EDIT */
+ cpp.write(
+ """/* THIS FILE IS GENERATED DO NOT EDIT */
#include "android_mono_config.h"
#ifdef ANDROID_ENABLED
@@ -49,4 +49,6 @@ String get_godot_android_mono_config() {
}
#endif // ANDROID_ENABLED
-''' % (compr_size, decompr_size, bytes_seq_str))
+"""
+ % (compr_size, decompr_size, bytes_seq_str)
+ )
diff --git a/modules/mono/build_scripts/mono_configure.py b/modules/mono/build_scripts/mono_configure.py
index 9a6198f13a..23f01b3cca 100644
--- a/modules/mono/build_scripts/mono_configure.py
+++ b/modules/mono/build_scripts/mono_configure.py
@@ -5,178 +5,230 @@ import subprocess
from SCons.Script import Dir, Environment
-if os.name == 'nt':
+if os.name == "nt":
from . import mono_reg_utils as monoreg
android_arch_dirs = {
- 'armv7': 'armeabi-v7a',
- 'arm64v8': 'arm64-v8a',
- 'x86': 'x86',
- 'x86_64': 'x86_64'
+ "armv7": "armeabi-v7a",
+ "arm64v8": "arm64-v8a",
+ "x86": "x86",
+ "x86_64": "x86_64",
}
def get_android_out_dir(env):
- return os.path.join(Dir('#platform/android/java/lib/libs').abspath,
- 'release' if env['target'] == 'release' else 'debug',
- android_arch_dirs[env['android_arch']])
-
-
-def find_file_in_dir(directory, files, prefix='', extension=''):
- if not extension.startswith('.'):
- extension = '.' + extension
- for curfile in files:
- if os.path.isfile(os.path.join(directory, prefix + curfile + extension)):
- return curfile
- return ''
-
-
-def copy_file(src_dir, dst_dir, name):
+ return os.path.join(
+ Dir("#platform/android/java/lib/libs").abspath,
+ "release" if env["target"] == "release" else "debug",
+ android_arch_dirs[env["android_arch"]],
+ )
+
+
+def find_name_in_dir_files(directory, names, prefixes=[""], extensions=[""]):
+ for extension in extensions:
+ if extension and not extension.startswith("."):
+ extension = "." + extension
+ for prefix in prefixes:
+ for curname in names:
+ if os.path.isfile(os.path.join(directory, prefix + curname + extension)):
+ return curname
+ return ""
+
+
+def find_file_in_dir(directory, names, prefixes=[""], extensions=[""]):
+ for extension in extensions:
+ if extension and not extension.startswith("."):
+ extension = "." + extension
+ for prefix in prefixes:
+ for curname in names:
+ filename = prefix + curname + extension
+ if os.path.isfile(os.path.join(directory, filename)):
+ return filename
+ return ""
+
+
+def copy_file(src_dir, dst_dir, src_name, dst_name=""):
from shutil import copy
- src_path = os.path.join(Dir(src_dir).abspath, name)
+ src_path = os.path.join(Dir(src_dir).abspath, src_name)
dst_dir = Dir(dst_dir).abspath
if not os.path.isdir(dst_dir):
os.makedirs(dst_dir)
- copy(src_path, dst_dir)
+ if dst_name:
+ copy(src_path, os.path.join(dst_dir, dst_name))
+ else:
+ copy(src_path, dst_dir)
def is_desktop(platform):
- return platform in ['windows', 'osx', 'x11', 'server', 'uwp', 'haiku']
+ return platform in ["windows", "osx", "linuxbsd", "server", "uwp", "haiku"]
def is_unix_like(platform):
- return platform in ['osx', 'x11', 'server', 'android', 'haiku']
+ return platform in ["osx", "linuxbsd", "server", "android", "haiku", "iphone"]
def module_supports_tools_on(platform):
- return platform not in ['android', 'javascript']
+ return platform not in ["android", "javascript", "iphone"]
def find_wasm_src_dir(mono_root):
hint_dirs = [
- os.path.join(mono_root, 'src'),
- os.path.join(mono_root, '../src'),
+ os.path.join(mono_root, "src"),
+ os.path.join(mono_root, "../src"),
]
for hint_dir in hint_dirs:
- if os.path.isfile(os.path.join(hint_dir, 'driver.c')):
+ if os.path.isfile(os.path.join(hint_dir, "driver.c")):
return hint_dir
- return ''
+ return ""
def configure(env, env_mono):
- bits = env['bits']
- is_android = env['platform'] == 'android'
- is_javascript = env['platform'] == 'javascript'
+ bits = env["bits"]
+ is_android = env["platform"] == "android"
+ is_javascript = env["platform"] == "javascript"
+ is_ios = env["platform"] == "iphone"
+ is_ios_sim = is_ios and env["arch"] in ["x86", "x86_64"]
- tools_enabled = env['tools']
- mono_static = env['mono_static']
- copy_mono_root = env['copy_mono_root']
+ tools_enabled = env["tools"]
+ mono_static = env["mono_static"]
+ copy_mono_root = env["copy_mono_root"]
- mono_prefix = env['mono_prefix']
+ mono_prefix = env["mono_prefix"]
- mono_lib_names = ['mono-2.0-sgen', 'monosgen-2.0']
+ mono_lib_names = ["mono-2.0-sgen", "monosgen-2.0"]
- is_travis = os.environ.get('TRAVIS') == 'true'
+ is_travis = os.environ.get("TRAVIS") == "true"
if is_travis:
# Travis CI may have a Mono version lower than 5.12
- env_mono.Append(CPPDEFINES=['NO_PENDING_EXCEPTIONS'])
+ env_mono.Append(CPPDEFINES=["NO_PENDING_EXCEPTIONS"])
- if is_android and not env['android_arch'] in android_arch_dirs:
- raise RuntimeError('This module does not support the specified \'android_arch\': ' + env['android_arch'])
+ if is_android and not env["android_arch"] in android_arch_dirs:
+ raise RuntimeError("This module does not support the specified 'android_arch': " + env["android_arch"])
- if tools_enabled and not module_supports_tools_on(env['platform']):
+ if tools_enabled and not module_supports_tools_on(env["platform"]):
# TODO:
# Android: We have to add the data directory to the apk, concretely the Api and Tools folders.
- raise RuntimeError('This module does not currently support building for this platform with tools enabled')
+ raise RuntimeError("This module does not currently support building for this platform with tools enabled")
if is_android and mono_static:
- # Android: When static linking and doing something that requires libmono-native, we get a dlopen error as libmono-native seems to depend on libmonosgen-2.0
- raise RuntimeError('Statically linking Mono is not currently supported on this platform')
+ # FIXME: When static linking and doing something that requires libmono-native, we get a dlopen error as 'libmono-native'
+ # seems to depend on 'libmonosgen-2.0'. Could be fixed by re-directing to '__Internal' with a dllmap or in the dlopen hook.
+ raise RuntimeError("Statically linking Mono is not currently supported for this platform")
+
+ if not mono_static and (is_javascript or is_ios):
+ raise RuntimeError("Dynamically linking Mono is not currently supported for this platform")
+
+ if not mono_prefix and (os.getenv("MONO32_PREFIX") or os.getenv("MONO64_PREFIX")):
+ print(
+ "WARNING: The environment variables 'MONO32_PREFIX' and 'MONO64_PREFIX' are deprecated; use the 'mono_prefix' SCons parameter instead"
+ )
+
+ # Although we don't support building with tools for any platform where we currently use static AOT,
+ # if these are supported in the future, we won't be using static AOT for them as that would be
+ # too restrictive for the editor. These builds would probably be made to only use the interpreter.
+ mono_aot_static = (is_ios and not is_ios_sim) and not env["tools"]
- if is_javascript:
- mono_static = True
+ # Static AOT is only supported on the root domain
+ mono_single_appdomain = mono_aot_static
- if not mono_prefix and (os.getenv('MONO32_PREFIX') or os.getenv('MONO64_PREFIX')):
- print("WARNING: The environment variables 'MONO32_PREFIX' and 'MONO64_PREFIX' are deprecated; use the 'mono_prefix' SCons parameter instead")
+ if mono_single_appdomain:
+ env_mono.Append(CPPDEFINES=["GD_MONO_SINGLE_APPDOMAIN"])
- if env['platform'] == 'windows':
+ if (env["tools"] or env["target"] != "release") and not mono_single_appdomain:
+ env_mono.Append(CPPDEFINES=["GD_MONO_HOT_RELOAD"])
+
+ if env["platform"] == "windows":
mono_root = mono_prefix
- if not mono_root and os.name == 'nt':
+ if not mono_root and os.name == "nt":
mono_root = monoreg.find_mono_root_dir(bits)
if not mono_root:
- raise RuntimeError("Mono installation directory not found; specify one manually with the 'mono_prefix' SCons parameter")
+ raise RuntimeError(
+ "Mono installation directory not found; specify one manually with the 'mono_prefix' SCons parameter"
+ )
- print('Found Mono root directory: ' + mono_root)
+ print("Found Mono root directory: " + mono_root)
- mono_lib_path = os.path.join(mono_root, 'lib')
+ mono_lib_path = os.path.join(mono_root, "lib")
env.Append(LIBPATH=mono_lib_path)
- env_mono.Prepend(CPPPATH=os.path.join(mono_root, 'include', 'mono-2.0'))
+ env_mono.Prepend(CPPPATH=os.path.join(mono_root, "include", "mono-2.0"))
+
+ lib_suffixes = [".lib"]
- lib_suffix = Environment()['LIBSUFFIX']
+ if not env.msvc:
+ # MingW supports both '.a' and '.lib'
+ lib_suffixes.insert(0, ".a")
if mono_static:
if env.msvc:
- mono_static_lib_name = 'libmono-static-sgen'
+ mono_static_lib_name = "libmono-static-sgen"
else:
- mono_static_lib_name = 'libmonosgen-2.0'
+ mono_static_lib_name = "libmonosgen-2.0"
- if not os.path.isfile(os.path.join(mono_lib_path, mono_static_lib_name + lib_suffix)):
- raise RuntimeError('Could not find static mono library in: ' + mono_lib_path)
+ mono_static_lib_file = find_file_in_dir(mono_lib_path, [mono_static_lib_name], extensions=lib_suffixes)
+
+ if not mono_static_lib_file:
+ raise RuntimeError("Could not find static mono library in: " + mono_lib_path)
if env.msvc:
- env.Append(LINKFLAGS=mono_static_lib_name + lib_suffix)
+ env.Append(LINKFLAGS=mono_static_lib_file)
- env.Append(LINKFLAGS='Mincore' + lib_suffix)
- env.Append(LINKFLAGS='msvcrt' + lib_suffix)
- env.Append(LINKFLAGS='LIBCMT' + lib_suffix)
- env.Append(LINKFLAGS='Psapi' + lib_suffix)
+ env.Append(LINKFLAGS="Mincore.lib")
+ env.Append(LINKFLAGS="msvcrt.lib")
+ env.Append(LINKFLAGS="LIBCMT.lib")
+ env.Append(LINKFLAGS="Psapi.lib")
else:
- env.Append(LINKFLAGS=os.path.join(mono_lib_path, mono_static_lib_name + lib_suffix))
+ mono_static_lib_file_path = os.path.join(mono_lib_path, mono_static_lib_file)
+ env.Append(LINKFLAGS=["-Wl,-whole-archive", mono_static_lib_file_path, "-Wl,-no-whole-archive"])
- env.Append(LIBS=['psapi'])
- env.Append(LIBS=['version'])
+ env.Append(LIBS=["psapi"])
+ env.Append(LIBS=["version"])
else:
- mono_lib_name = find_file_in_dir(mono_lib_path, mono_lib_names, extension=lib_suffix)
+ mono_lib_name = find_name_in_dir_files(
+ mono_lib_path, mono_lib_names, prefixes=["", "lib"], extensions=lib_suffixes
+ )
if not mono_lib_name:
- raise RuntimeError('Could not find mono library in: ' + mono_lib_path)
+ raise RuntimeError("Could not find mono library in: " + mono_lib_path)
if env.msvc:
- env.Append(LINKFLAGS=mono_lib_name + lib_suffix)
+ env.Append(LINKFLAGS=mono_lib_name + ".lib")
else:
env.Append(LIBS=[mono_lib_name])
- mono_bin_path = os.path.join(mono_root, 'bin')
+ mono_bin_path = os.path.join(mono_root, "bin")
- mono_dll_name = find_file_in_dir(mono_bin_path, mono_lib_names, extension='.dll')
+ mono_dll_file = find_file_in_dir(mono_bin_path, mono_lib_names, prefixes=["", "lib"], extensions=[".dll"])
- if not mono_dll_name:
- raise RuntimeError('Could not find mono shared library in: ' + mono_bin_path)
+ if not mono_dll_file:
+ raise RuntimeError("Could not find mono shared library in: " + mono_bin_path)
- copy_file(mono_bin_path, '#bin', mono_dll_name + '.dll')
+ copy_file(mono_bin_path, "#bin", mono_dll_file)
else:
- is_apple = env['platform'] in ['osx', 'iphone']
+ is_apple = env["platform"] in ["osx", "iphone"]
+ is_macos = is_apple and not is_ios
- sharedlib_ext = '.dylib' if is_apple else '.so'
+ sharedlib_ext = ".dylib" if is_apple else ".so"
mono_root = mono_prefix
- mono_lib_path = ''
- mono_so_name = ''
+ mono_lib_path = ""
+ mono_so_file = ""
- if not mono_root and (is_android or is_javascript):
- raise RuntimeError("Mono installation directory not found; specify one manually with the 'mono_prefix' SCons parameter")
+ if not mono_root and (is_android or is_javascript or is_ios):
+ raise RuntimeError(
+ "Mono installation directory not found; specify one manually with the 'mono_prefix' SCons parameter"
+ )
- if not mono_root and is_apple:
+ if not mono_root and is_macos:
# Try with some known directories under OSX
- hint_dirs = ['/Library/Frameworks/Mono.framework/Versions/Current', '/usr/local/var/homebrew/linked/mono']
+ hint_dirs = ["/Library/Frameworks/Mono.framework/Versions/Current", "/usr/local/var/homebrew/linked/mono"]
for hint_dir in hint_dirs:
if os.path.isdir(hint_dir):
mono_root = hint_dir
@@ -187,126 +239,165 @@ def configure(env, env_mono):
if not mono_root and mono_static:
mono_root = pkgconfig_try_find_mono_root(mono_lib_names, sharedlib_ext)
if not mono_root:
- raise RuntimeError("Building with mono_static=yes, but failed to find the mono prefix with pkg-config; " + \
- "specify one manually with the 'mono_prefix' SCons parameter")
+ raise RuntimeError(
+ "Building with mono_static=yes, but failed to find the mono prefix with pkg-config; "
+ + "specify one manually with the 'mono_prefix' SCons parameter"
+ )
+
+ if is_ios and not is_ios_sim:
+ env_mono.Append(CPPDEFINES=["IOS_DEVICE"])
if mono_root:
- print('Found Mono root directory: ' + mono_root)
+ print("Found Mono root directory: " + mono_root)
- mono_lib_path = os.path.join(mono_root, 'lib')
+ mono_lib_path = os.path.join(mono_root, "lib")
env.Append(LIBPATH=[mono_lib_path])
- env_mono.Prepend(CPPPATH=os.path.join(mono_root, 'include', 'mono-2.0'))
+ env_mono.Prepend(CPPPATH=os.path.join(mono_root, "include", "mono-2.0"))
- mono_lib = find_file_in_dir(mono_lib_path, mono_lib_names, prefix='lib', extension='.a')
+ mono_lib = find_name_in_dir_files(mono_lib_path, mono_lib_names, prefixes=["lib"], extensions=[".a"])
if not mono_lib:
- raise RuntimeError('Could not find mono library in: ' + mono_lib_path)
+ raise RuntimeError("Could not find mono library in: " + mono_lib_path)
- env_mono.Append(CPPDEFINES=['_REENTRANT'])
+ env_mono.Append(CPPDEFINES=["_REENTRANT"])
if mono_static:
- env.Append(LINKFLAGS=['-rdynamic'])
+ env.Append(LINKFLAGS=["-rdynamic"])
- mono_lib_file = os.path.join(mono_lib_path, 'lib' + mono_lib + '.a')
+ mono_lib_file = os.path.join(mono_lib_path, "lib" + mono_lib + ".a")
if is_apple:
- env.Append(LINKFLAGS=['-Wl,-force_load,' + mono_lib_file])
+ if is_macos:
+ env.Append(LINKFLAGS=["-Wl,-force_load," + mono_lib_file])
+ else:
+ arch = env["arch"]
+
+ def copy_mono_lib(libname_wo_ext):
+ copy_file(
+ mono_lib_path, "#bin", libname_wo_ext + ".a", "%s.iphone.%s.a" % (libname_wo_ext, arch)
+ )
+
+ # Copy Mono libraries to the output folder. These are meant to be bundled with
+ # the export templates and added to the Xcode project when exporting a game.
+ copy_mono_lib("lib" + mono_lib)
+ copy_mono_lib("libmono-native")
+ copy_mono_lib("libmono-profiler-log")
+
+ if not is_ios_sim:
+ copy_mono_lib("libmono-ee-interp")
+ copy_mono_lib("libmono-icall-table")
+ copy_mono_lib("libmono-ilgen")
else:
- assert is_desktop(env['platform']) or is_android or is_javascript
- env.Append(LINKFLAGS=['-Wl,-whole-archive', mono_lib_file, '-Wl,-no-whole-archive'])
+ assert is_desktop(env["platform"]) or is_android or is_javascript
+ env.Append(LINKFLAGS=["-Wl,-whole-archive", mono_lib_file, "-Wl,-no-whole-archive"])
if is_javascript:
- env.Append(LIBS=['mono-icall-table', 'mono-native', 'mono-ilgen', 'mono-ee-interp'])
+ env.Append(LIBS=["mono-icall-table", "mono-native", "mono-ilgen", "mono-ee-interp"])
- wasm_src_dir = os.path.join(mono_root, 'src')
+ wasm_src_dir = os.path.join(mono_root, "src")
if not os.path.isdir(wasm_src_dir):
- raise RuntimeError('Could not find mono wasm src directory')
+ raise RuntimeError("Could not find mono wasm src directory")
# Ideally this should be defined only for 'driver.c', but I can't fight scons for another 2 hours
- env_mono.Append(CPPDEFINES=['CORE_BINDINGS'])
-
- env_mono.add_source_files(env.modules_sources, [
- os.path.join(wasm_src_dir, 'driver.c'),
- os.path.join(wasm_src_dir, 'zlib-helper.c'),
- os.path.join(wasm_src_dir, 'corebindings.c')
- ])
-
- env.Append(LINKFLAGS=[
- '--js-library', os.path.join(wasm_src_dir, 'library_mono.js'),
- '--js-library', os.path.join(wasm_src_dir, 'binding_support.js'),
- '--js-library', os.path.join(wasm_src_dir, 'dotnet_support.js')
- ])
+ env_mono.Append(CPPDEFINES=["CORE_BINDINGS"])
+
+ env_mono.add_source_files(
+ env.modules_sources,
+ [
+ os.path.join(wasm_src_dir, "driver.c"),
+ os.path.join(wasm_src_dir, "zlib-helper.c"),
+ os.path.join(wasm_src_dir, "corebindings.c"),
+ ],
+ )
+
+ env.Append(
+ LINKFLAGS=[
+ "--js-library",
+ os.path.join(wasm_src_dir, "library_mono.js"),
+ "--js-library",
+ os.path.join(wasm_src_dir, "binding_support.js"),
+ "--js-library",
+ os.path.join(wasm_src_dir, "dotnet_support.js"),
+ ]
+ )
else:
env.Append(LIBS=[mono_lib])
- if is_apple:
- env.Append(LIBS=['iconv', 'pthread'])
+ if is_macos:
+ env.Append(LIBS=["iconv", "pthread"])
elif is_android:
- pass # Nothing
+ pass # Nothing
+ elif is_ios:
+ pass # Nothing, linking is delegated to the exported Xcode project
elif is_javascript:
- env.Append(LIBS=['m', 'rt', 'dl', 'pthread'])
+ env.Append(LIBS=["m", "rt", "dl", "pthread"])
else:
- env.Append(LIBS=['m', 'rt', 'dl', 'pthread'])
+ env.Append(LIBS=["m", "rt", "dl", "pthread"])
if not mono_static:
- mono_so_name = find_file_in_dir(mono_lib_path, mono_lib_names, prefix='lib', extension=sharedlib_ext)
+ mono_so_file = find_file_in_dir(
+ mono_lib_path, mono_lib_names, prefixes=["lib"], extensions=[sharedlib_ext]
+ )
- if not mono_so_name:
- raise RuntimeError('Could not find mono shared library in: ' + mono_lib_path)
-
- copy_file(mono_lib_path, '#bin', 'lib' + mono_so_name + sharedlib_ext)
+ if not mono_so_file:
+ raise RuntimeError("Could not find mono shared library in: " + mono_lib_path)
else:
assert not mono_static
# TODO: Add option to force using pkg-config
- print('Mono root directory not found. Using pkg-config instead')
+ print("Mono root directory not found. Using pkg-config instead")
- env.ParseConfig('pkg-config monosgen-2 --libs')
- env_mono.ParseConfig('pkg-config monosgen-2 --cflags')
+ env.ParseConfig("pkg-config monosgen-2 --libs")
+ env_mono.ParseConfig("pkg-config monosgen-2 --cflags")
tmpenv = Environment()
- tmpenv.AppendENVPath('PKG_CONFIG_PATH', os.getenv('PKG_CONFIG_PATH'))
- tmpenv.ParseConfig('pkg-config monosgen-2 --libs-only-L')
+ tmpenv.AppendENVPath("PKG_CONFIG_PATH", os.getenv("PKG_CONFIG_PATH"))
+ tmpenv.ParseConfig("pkg-config monosgen-2 --libs-only-L")
- for hint_dir in tmpenv['LIBPATH']:
- name_found = find_file_in_dir(hint_dir, mono_lib_names, prefix='lib', extension=sharedlib_ext)
- if name_found:
+ for hint_dir in tmpenv["LIBPATH"]:
+ file_found = find_file_in_dir(hint_dir, mono_lib_names, prefixes=["lib"], extensions=[sharedlib_ext])
+ if file_found:
mono_lib_path = hint_dir
- mono_so_name = name_found
+ mono_so_file = file_found
break
- if not mono_so_name:
- raise RuntimeError('Could not find mono shared library in: ' + str(tmpenv['LIBPATH']))
+ if not mono_so_file:
+ raise RuntimeError("Could not find mono shared library in: " + str(tmpenv["LIBPATH"]))
if not mono_static:
- libs_output_dir = get_android_out_dir(env) if is_android else '#bin'
- copy_file(mono_lib_path, libs_output_dir, 'lib' + mono_so_name + sharedlib_ext)
+ libs_output_dir = get_android_out_dir(env) if is_android else "#bin"
+ copy_file(mono_lib_path, libs_output_dir, mono_so_file)
if not tools_enabled:
- if is_desktop(env['platform']):
+ if is_desktop(env["platform"]):
if not mono_root:
- mono_root = subprocess.check_output(['pkg-config', 'mono-2', '--variable=prefix']).decode('utf8').strip()
+ mono_root = (
+ subprocess.check_output(["pkg-config", "mono-2", "--variable=prefix"]).decode("utf8").strip()
+ )
make_template_dir(env, mono_root)
elif is_android:
# Compress Android Mono Config
from . import make_android_mono_config
+
module_dir = os.getcwd()
- config_file_path = os.path.join(module_dir, 'build_scripts', 'mono_android_config.xml')
- make_android_mono_config.generate_compressed_config(config_file_path, 'mono_gd/')
+ config_file_path = os.path.join(module_dir, "build_scripts", "mono_android_config.xml")
+ make_android_mono_config.generate_compressed_config(config_file_path, "mono_gd/")
# Copy the required shared libraries
copy_mono_shared_libs(env, mono_root, None)
elif is_javascript:
- pass # No data directory for this platform
+ pass # No data directory for this platform
+ elif is_ios:
+ pass # No data directory for this platform
if copy_mono_root:
if not mono_root:
- mono_root = subprocess.check_output(['pkg-config', 'mono-2', '--variable=prefix']).decode('utf8').strip()
+ mono_root = subprocess.check_output(["pkg-config", "mono-2", "--variable=prefix"]).decode("utf8").strip()
if tools_enabled:
- copy_mono_root_files(env, mono_root)
+ copy_mono_root_files(env, mono_root)
else:
print("Ignoring option: 'copy_mono_root'; only available for builds with 'tools' enabled.")
@@ -314,26 +405,26 @@ def configure(env, env_mono):
def make_template_dir(env, mono_root):
from shutil import rmtree
- platform = env['platform']
- target = env['target']
+ platform = env["platform"]
+ target = env["target"]
- template_dir_name = ''
+ template_dir_name = ""
assert is_desktop(platform)
- template_dir_name = 'data.mono.%s.%s.%s' % (platform, env['bits'], target)
+ template_dir_name = "data.mono.%s.%s.%s" % (platform, env["bits"], target)
- output_dir = Dir('#bin').abspath
+ 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')
+ 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
+ rmtree(template_mono_root_dir) # Clean first
# Copy etc/mono/
- template_mono_config_dir = os.path.join(template_mono_root_dir, '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, platform)
# Copy the required shared libraries
@@ -347,18 +438,18 @@ def copy_mono_root_files(env, mono_root):
from shutil import rmtree
if not mono_root:
- raise RuntimeError('Mono installation directory not found')
+ raise RuntimeError("Mono installation directory not found")
- output_dir = Dir('#bin').abspath
- editor_mono_root_dir = os.path.join(output_dir, 'GodotSharp', 'Mono')
+ 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
+ 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'])
+ 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
@@ -366,20 +457,20 @@ def copy_mono_root_files(env, mono_root):
# 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')
+ 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')
+ 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')):
+ 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')):
+ for assembly in glob(os.path.join(mono_framework_facades_dir, "*.dll")):
copy(assembly, editor_mono_framework_facades_dir)
@@ -391,28 +482,28 @@ def copy_mono_etc_dir(mono_root, target_mono_config_dir, platform):
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')
+ mono_etc_dir = os.path.join(mono_root, "etc", "mono")
if not os.path.isdir(mono_etc_dir):
- 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')]
+ 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')
+ 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'))
- if os.path.isdir(os.path.join(mono_etc_dir, 'mconfig')):
- copy_tree(os.path.join(mono_etc_dir, 'mconfig'), os.path.join(target_mono_config_dir, 'mconfig'))
+ 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"))
+ if os.path.isdir(os.path.join(mono_etc_dir, "mconfig")):
+ 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, '*')):
+ for file in glob(os.path.join(mono_etc_dir, "*")):
if os.path.isfile(file):
copy(file, target_mono_config_dir)
@@ -424,48 +515,66 @@ def copy_mono_shared_libs(env, mono_root, target_mono_root_dir):
if os.path.isfile(src):
copy(src, dst)
- platform = env['platform']
+ platform = env["platform"]
- if platform == 'windows':
- src_mono_bin_dir = os.path.join(mono_root, 'bin')
- target_mono_bin_dir = os.path.join(target_mono_root_dir, 'bin')
+ if platform == "windows":
+ src_mono_bin_dir = os.path.join(mono_root, "bin")
+ 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)
- mono_posix_helper_name = find_file_in_dir(src_mono_bin_dir, ['MonoPosixHelper', 'libMonoPosixHelper'], extension='.dll')
- copy(os.path.join(src_mono_bin_dir, mono_posix_helper_name + '.dll'), os.path.join(target_mono_bin_dir, 'MonoPosixHelper.dll'))
+ mono_posix_helper_file = find_file_in_dir(
+ src_mono_bin_dir, ["MonoPosixHelper"], prefixes=["", "lib"], extensions=[".dll"]
+ )
+ copy(
+ os.path.join(src_mono_bin_dir, mono_posix_helper_file),
+ os.path.join(target_mono_bin_dir, "MonoPosixHelper.dll"),
+ )
# For newer versions
- btls_dll_path = os.path.join(src_mono_bin_dir, 'libmono-btls-shared.dll')
+ btls_dll_path = os.path.join(src_mono_bin_dir, "libmono-btls-shared.dll")
if os.path.isfile(btls_dll_path):
copy(btls_dll_path, target_mono_bin_dir)
else:
- target_mono_lib_dir = get_android_out_dir(env) if platform == 'android' else os.path.join(target_mono_root_dir, 'lib')
+ target_mono_lib_dir = (
+ get_android_out_dir(env) if platform == "android" else os.path.join(target_mono_root_dir, "lib")
+ )
if not os.path.isdir(target_mono_lib_dir):
os.makedirs(target_mono_lib_dir)
lib_file_names = []
- if platform == 'osx':
- lib_file_names = [lib_name + '.dylib' for lib_name in [
- 'libmono-btls-shared', 'libmono-native-compat', 'libMonoPosixHelper'
- ]]
+ if platform == "osx":
+ lib_file_names = [
+ lib_name + ".dylib"
+ for lib_name in ["libmono-btls-shared", "libmono-native-compat", "libMonoPosixHelper"]
+ ]
elif is_unix_like(platform):
- lib_file_names = [lib_name + '.so' for lib_name in [
- 'libmono-btls-shared', 'libmono-ee-interp', 'libmono-native', 'libMonoPosixHelper',
- 'libmono-profiler-aot', 'libmono-profiler-coverage', 'libmono-profiler-log', 'libMonoSupportW'
- ]]
+ lib_file_names = [
+ lib_name + ".so"
+ for lib_name in [
+ "libmono-btls-shared",
+ "libmono-ee-interp",
+ "libmono-native",
+ "libMonoPosixHelper",
+ "libmono-profiler-aot",
+ "libmono-profiler-coverage",
+ "libmono-profiler-log",
+ "libMonoSupportW",
+ ]
+ ]
for lib_file_name in lib_file_names:
- copy_if_exists(os.path.join(mono_root, 'lib', lib_file_name), target_mono_lib_dir)
+ copy_if_exists(os.path.join(mono_root, "lib", lib_file_name), target_mono_lib_dir)
+
def pkgconfig_try_find_mono_root(mono_lib_names, sharedlib_ext):
tmpenv = Environment()
- tmpenv.AppendENVPath('PKG_CONFIG_PATH', os.getenv('PKG_CONFIG_PATH'))
- tmpenv.ParseConfig('pkg-config monosgen-2 --libs-only-L')
- for hint_dir in tmpenv['LIBPATH']:
- name_found = find_file_in_dir(hint_dir, mono_lib_names, prefix='lib', extension=sharedlib_ext)
- if name_found and os.path.isdir(os.path.join(hint_dir, '..', 'include', 'mono-2.0')):
- return os.path.join(hint_dir, '..')
- return ''
+ tmpenv.AppendENVPath("PKG_CONFIG_PATH", os.getenv("PKG_CONFIG_PATH"))
+ tmpenv.ParseConfig("pkg-config monosgen-2 --libs-only-L")
+ for hint_dir in tmpenv["LIBPATH"]:
+ name_found = find_name_in_dir_files(hint_dir, mono_lib_names, prefixes=["lib"], extensions=[sharedlib_ext])
+ if name_found and os.path.isdir(os.path.join(hint_dir, "..", "include", "mono-2.0")):
+ return os.path.join(hint_dir, "..")
+ return ""
diff --git a/modules/mono/build_scripts/mono_reg_utils.py b/modules/mono/build_scripts/mono_reg_utils.py
index b2c48f0a61..3090a4759a 100644
--- a/modules/mono/build_scripts/mono_reg_utils.py
+++ b/modules/mono/build_scripts/mono_reg_utils.py
@@ -1,21 +1,16 @@
import os
import platform
-from compat import decode_utf8
-
-if os.name == 'nt':
+if os.name == "nt":
import sys
- if sys.version_info < (3,):
- import _winreg as winreg
- else:
- import winreg
+ import winreg
def _reg_open_key(key, subkey):
try:
return winreg.OpenKey(key, subkey)
except (WindowsError, OSError):
- if platform.architecture()[0] == '32bit':
+ if platform.architecture()[0] == "32bit":
bitness_sam = winreg.KEY_WOW64_64KEY
else:
bitness_sam = winreg.KEY_WOW64_32KEY
@@ -25,12 +20,12 @@ def _reg_open_key(key, subkey):
def _reg_open_key_bits(key, subkey, bits):
sam = winreg.KEY_READ
- if platform.architecture()[0] == '32bit':
- if bits == '64':
+ if platform.architecture()[0] == "32bit":
+ if bits == "64":
# Force 32bit process to search in 64bit registry
sam |= winreg.KEY_WOW64_64KEY
else:
- if bits == '32':
+ if bits == "32":
# Force 64bit process to search in 32bit registry
sam |= winreg.KEY_WOW64_32KEY
@@ -40,7 +35,7 @@ def _reg_open_key_bits(key, subkey, bits):
def _find_mono_in_reg(subkey, bits):
try:
with _reg_open_key_bits(winreg.HKEY_LOCAL_MACHINE, subkey, bits) as hKey:
- value = winreg.QueryValueEx(hKey, 'SdkInstallRoot')[0]
+ value = winreg.QueryValueEx(hKey, "SdkInstallRoot")[0]
return value
except (WindowsError, OSError):
return None
@@ -49,70 +44,70 @@ def _find_mono_in_reg(subkey, bits):
def _find_mono_in_reg_old(subkey, bits):
try:
with _reg_open_key_bits(winreg.HKEY_LOCAL_MACHINE, subkey, bits) as hKey:
- default_clr = winreg.QueryValueEx(hKey, 'DefaultCLR')[0]
+ default_clr = winreg.QueryValueEx(hKey, "DefaultCLR")[0]
if default_clr:
- return _find_mono_in_reg(subkey + '\\' + default_clr, bits)
+ return _find_mono_in_reg(subkey + "\\" + default_clr, bits)
return None
except (WindowsError, EnvironmentError):
return None
def find_mono_root_dir(bits):
- root_dir = _find_mono_in_reg(r'SOFTWARE\Mono', bits)
+ root_dir = _find_mono_in_reg(r"SOFTWARE\Mono", bits)
if root_dir is not None:
return str(root_dir)
- root_dir = _find_mono_in_reg_old(r'SOFTWARE\Novell\Mono', bits)
+ root_dir = _find_mono_in_reg_old(r"SOFTWARE\Novell\Mono", bits)
if root_dir is not None:
return str(root_dir)
- return ''
+ return ""
def find_msbuild_tools_path_reg():
import subprocess
- vswhere = os.getenv('PROGRAMFILES(X86)')
+ vswhere = os.getenv("PROGRAMFILES(X86)")
if not vswhere:
- vswhere = os.getenv('PROGRAMFILES')
- vswhere += r'\Microsoft Visual Studio\Installer\vswhere.exe'
+ vswhere = os.getenv("PROGRAMFILES")
+ vswhere += r"\Microsoft Visual Studio\Installer\vswhere.exe"
- vswhere_args = ['-latest', '-products', '*', '-requires', 'Microsoft.Component.MSBuild']
+ vswhere_args = ["-latest", "-products", "*", "-requires", "Microsoft.Component.MSBuild"]
try:
lines = subprocess.check_output([vswhere] + vswhere_args).splitlines()
for line in lines:
- parts = decode_utf8(line).split(':', 1)
+ parts = line.decode("utf-8").split(":", 1)
- if len(parts) < 2 or parts[0] != 'installationPath':
+ if len(parts) < 2 or parts[0] != "installationPath":
continue
val = parts[1].strip()
if not val:
- raise ValueError('Value of `installationPath` entry is empty')
+ raise ValueError("Value of `installationPath` entry is empty")
# Since VS2019, the directory is simply named "Current"
- msbuild_dir = os.path.join(val, 'MSBuild\\Current\\Bin')
+ msbuild_dir = os.path.join(val, "MSBuild\\Current\\Bin")
if os.path.isdir(msbuild_dir):
return msbuild_dir
# Directory name "15.0" is used in VS 2017
- return os.path.join(val, 'MSBuild\\15.0\\Bin')
+ return os.path.join(val, "MSBuild\\15.0\\Bin")
- raise ValueError('Cannot find `installationPath` entry')
+ raise ValueError("Cannot find `installationPath` entry")
except ValueError as e:
- print('Error reading output from vswhere: ' + e.message)
+ print("Error reading output from vswhere: " + e.message)
except WindowsError:
- pass # Fine, vswhere not found
+ pass # Fine, vswhere not found
except (subprocess.CalledProcessError, OSError):
pass
# Try to find 14.0 in the Registry
try:
- subkey = r'SOFTWARE\Microsoft\MSBuild\ToolsVersions\14.0'
+ subkey = r"SOFTWARE\Microsoft\MSBuild\ToolsVersions\14.0"
with _reg_open_key(winreg.HKEY_LOCAL_MACHINE, subkey) as hKey:
- value = winreg.QueryValueEx(hKey, 'MSBuildToolsPath')[0]
+ value = winreg.QueryValueEx(hKey, "MSBuildToolsPath")[0]
return value
except (WindowsError, OSError):
- return ''
+ return ""
diff --git a/modules/mono/build_scripts/solution_builder.py b/modules/mono/build_scripts/solution_builder.py
index d1529a64d2..db6b4ff7aa 100644
--- a/modules/mono/build_scripts/solution_builder.py
+++ b/modules/mono/build_scripts/solution_builder.py
@@ -1,4 +1,3 @@
-
import os
@@ -8,35 +7,38 @@ verbose = False
def find_nuget_unix():
import os
- if 'NUGET_PATH' in os.environ:
- hint_path = os.environ['NUGET_PATH']
+ if "NUGET_PATH" in os.environ:
+ hint_path = os.environ["NUGET_PATH"]
if os.path.isfile(hint_path) and os.access(hint_path, os.X_OK):
return hint_path
- hint_path = os.path.join(hint_path, 'nuget')
+ hint_path = os.path.join(hint_path, "nuget")
if os.path.isfile(hint_path) and os.access(hint_path, os.X_OK):
return hint_path
import os.path
import sys
- hint_dirs = ['/opt/novell/mono/bin']
- if sys.platform == 'darwin':
- hint_dirs = ['/Library/Frameworks/Mono.framework/Versions/Current/bin', '/usr/local/var/homebrew/linked/mono/bin'] + hint_dirs
+ hint_dirs = ["/opt/novell/mono/bin"]
+ if sys.platform == "darwin":
+ hint_dirs = [
+ "/Library/Frameworks/Mono.framework/Versions/Current/bin",
+ "/usr/local/var/homebrew/linked/mono/bin",
+ ] + hint_dirs
for hint_dir in hint_dirs:
- hint_path = os.path.join(hint_dir, 'nuget')
+ hint_path = os.path.join(hint_dir, "nuget")
if os.path.isfile(hint_path):
return hint_path
- elif os.path.isfile(hint_path + '.exe'):
- return hint_path + '.exe'
+ elif os.path.isfile(hint_path + ".exe"):
+ return hint_path + ".exe"
- for hint_dir in os.environ['PATH'].split(os.pathsep):
+ for hint_dir in os.environ["PATH"].split(os.pathsep):
hint_dir = hint_dir.strip('"')
- hint_path = os.path.join(hint_dir, 'nuget')
+ hint_path = os.path.join(hint_dir, "nuget")
if os.path.isfile(hint_path) and os.access(hint_path, os.X_OK):
return hint_path
- if os.path.isfile(hint_path + '.exe') and os.access(hint_path + '.exe', os.X_OK):
- return hint_path + '.exe'
+ if os.path.isfile(hint_path + ".exe") and os.access(hint_path + ".exe", os.X_OK):
+ return hint_path + ".exe"
return None
@@ -44,30 +46,30 @@ def find_nuget_unix():
def find_nuget_windows(env):
import os
- if 'NUGET_PATH' in os.environ:
- hint_path = os.environ['NUGET_PATH']
+ if "NUGET_PATH" in os.environ:
+ hint_path = os.environ["NUGET_PATH"]
if os.path.isfile(hint_path) and os.access(hint_path, os.X_OK):
return hint_path
- hint_path = os.path.join(hint_path, 'nuget.exe')
+ hint_path = os.path.join(hint_path, "nuget.exe")
if os.path.isfile(hint_path) and os.access(hint_path, os.X_OK):
return hint_path
- from . mono_reg_utils import find_mono_root_dir
+ from .mono_reg_utils import find_mono_root_dir
- mono_root = env['mono_prefix'] or find_mono_root_dir(env['bits'])
+ mono_root = env["mono_prefix"] or find_mono_root_dir(env["bits"])
if mono_root:
- mono_bin_dir = os.path.join(mono_root, 'bin')
- nuget_mono = os.path.join(mono_bin_dir, 'nuget.bat')
+ mono_bin_dir = os.path.join(mono_root, "bin")
+ nuget_mono = os.path.join(mono_bin_dir, "nuget.bat")
if os.path.isfile(nuget_mono):
return nuget_mono
# Standalone NuGet
- for hint_dir in os.environ['PATH'].split(os.pathsep):
+ for hint_dir in os.environ["PATH"].split(os.pathsep):
hint_dir = hint_dir.strip('"')
- hint_path = os.path.join(hint_dir, 'nuget.exe')
+ hint_path = os.path.join(hint_dir, "nuget.exe")
if os.path.isfile(hint_path) and os.access(hint_path, os.X_OK):
return hint_path
@@ -78,52 +80,55 @@ def find_msbuild_unix(filename):
import os.path
import sys
- hint_dirs = ['/opt/novell/mono/bin']
- if sys.platform == 'darwin':
- hint_dirs = ['/Library/Frameworks/Mono.framework/Versions/Current/bin', '/usr/local/var/homebrew/linked/mono/bin'] + hint_dirs
+ hint_dirs = ["/opt/novell/mono/bin"]
+ if sys.platform == "darwin":
+ hint_dirs = [
+ "/Library/Frameworks/Mono.framework/Versions/Current/bin",
+ "/usr/local/var/homebrew/linked/mono/bin",
+ ] + hint_dirs
for hint_dir in hint_dirs:
hint_path = os.path.join(hint_dir, filename)
if os.path.isfile(hint_path):
return hint_path
- elif os.path.isfile(hint_path + '.exe'):
- return hint_path + '.exe'
+ elif os.path.isfile(hint_path + ".exe"):
+ return hint_path + ".exe"
- for hint_dir in os.environ['PATH'].split(os.pathsep):
+ for hint_dir in os.environ["PATH"].split(os.pathsep):
hint_dir = hint_dir.strip('"')
hint_path = os.path.join(hint_dir, filename)
if os.path.isfile(hint_path) and os.access(hint_path, os.X_OK):
return hint_path
- if os.path.isfile(hint_path + '.exe') and os.access(hint_path + '.exe', os.X_OK):
- return hint_path + '.exe'
+ if os.path.isfile(hint_path + ".exe") and os.access(hint_path + ".exe", os.X_OK):
+ return hint_path + ".exe"
return None
def find_msbuild_windows(env):
- from . mono_reg_utils import find_mono_root_dir, find_msbuild_tools_path_reg
+ from .mono_reg_utils import find_mono_root_dir, find_msbuild_tools_path_reg
- mono_root = env['mono_prefix'] or find_mono_root_dir(env['bits'])
+ mono_root = env["mono_prefix"] or find_mono_root_dir(env["bits"])
if not mono_root:
- raise RuntimeError('Cannot find mono root directory')
+ raise RuntimeError("Cannot find mono root directory")
- mono_bin_dir = os.path.join(mono_root, 'bin')
- msbuild_mono = os.path.join(mono_bin_dir, 'msbuild.bat')
+ mono_bin_dir = os.path.join(mono_root, "bin")
+ msbuild_mono = os.path.join(mono_bin_dir, "msbuild.bat")
msbuild_tools_path = find_msbuild_tools_path_reg()
if msbuild_tools_path:
- return (os.path.join(msbuild_tools_path, 'MSBuild.exe'), {})
+ return (os.path.join(msbuild_tools_path, "MSBuild.exe"), {})
if os.path.isfile(msbuild_mono):
# The (Csc/Vbc/Fsc)ToolExe environment variables are required when
# building with Mono's MSBuild. They must point to the batch files
# in Mono's bin directory to make sure they are executed with Mono.
mono_msbuild_env = {
- 'CscToolExe': os.path.join(mono_bin_dir, 'csc.bat'),
- 'VbcToolExe': os.path.join(mono_bin_dir, 'vbc.bat'),
- 'FscToolExe': os.path.join(mono_bin_dir, 'fsharpc.bat')
+ "CscToolExe": os.path.join(mono_bin_dir, "csc.bat"),
+ "VbcToolExe": os.path.join(mono_bin_dir, "vbc.bat"),
+ "FscToolExe": os.path.join(mono_bin_dir, "fsharpc.bat"),
}
return (msbuild_mono, mono_msbuild_env)
@@ -132,7 +137,7 @@ def find_msbuild_windows(env):
def run_command(command, args, env_override=None, name=None):
def cmd_args_to_str(cmd_args):
- return ' '.join([arg if not ' ' in arg else '"%s"' % arg for arg in cmd_args])
+ return " ".join([arg if not " " in arg else '"%s"' % arg for arg in cmd_args])
args = [command] + args
@@ -143,6 +148,7 @@ def run_command(command, args, env_override=None, name=None):
print("Running '%s': %s" % (name, cmd_args_to_str(args)))
import subprocess
+
try:
if env_override is None:
subprocess.check_call(args)
@@ -154,61 +160,61 @@ def run_command(command, args, env_override=None, name=None):
def nuget_restore(env, *args):
global verbose
- verbose = env['verbose']
+ verbose = env["verbose"]
# Find NuGet
- nuget_path = find_nuget_windows(env) if os.name == 'nt' else find_nuget_unix()
+ nuget_path = find_nuget_windows(env) if os.name == "nt" else find_nuget_unix()
if nuget_path is None:
- raise RuntimeError('Cannot find NuGet executable')
+ raise RuntimeError("Cannot find NuGet executable")
- print('NuGet path: ' + nuget_path)
+ print("NuGet path: " + nuget_path)
# Do NuGet restore
- run_command(nuget_path, ['restore'] + list(args), name='nuget restore')
+ run_command(nuget_path, ["restore"] + list(args), name="nuget restore")
def build_solution(env, solution_path, build_config, extra_msbuild_args=[]):
global verbose
- verbose = env['verbose']
+ verbose = env["verbose"]
msbuild_env = os.environ.copy()
# Needed when running from Developer Command Prompt for VS
- if 'PLATFORM' in msbuild_env:
- del msbuild_env['PLATFORM']
+ if "PLATFORM" in msbuild_env:
+ del msbuild_env["PLATFORM"]
# Find MSBuild
- if os.name == 'nt':
+ if os.name == "nt":
msbuild_info = find_msbuild_windows(env)
if msbuild_info is None:
- raise RuntimeError('Cannot find MSBuild executable')
+ raise RuntimeError("Cannot find MSBuild executable")
msbuild_path = msbuild_info[0]
msbuild_env.update(msbuild_info[1])
else:
- msbuild_path = find_msbuild_unix('msbuild')
+ msbuild_path = find_msbuild_unix("msbuild")
if msbuild_path is None:
- xbuild_fallback = env['xbuild_fallback']
+ xbuild_fallback = env["xbuild_fallback"]
- if xbuild_fallback and os.name == 'nt':
- print('Option \'xbuild_fallback\' not supported on Windows')
+ if xbuild_fallback and os.name == "nt":
+ print("Option 'xbuild_fallback' not supported on Windows")
xbuild_fallback = False
if xbuild_fallback:
- print('Cannot find MSBuild executable, trying with xbuild')
- print('Warning: xbuild is deprecated')
+ print("Cannot find MSBuild executable, trying with xbuild")
+ print("Warning: xbuild is deprecated")
- msbuild_path = find_msbuild_unix('xbuild')
+ msbuild_path = find_msbuild_unix("xbuild")
if msbuild_path is None:
- raise RuntimeError('Cannot find xbuild executable')
+ raise RuntimeError("Cannot find xbuild executable")
else:
- raise RuntimeError('Cannot find MSBuild executable')
+ raise RuntimeError("Cannot find MSBuild executable")
- print('MSBuild path: ' + msbuild_path)
+ print("MSBuild path: " + msbuild_path)
# Build solution
- msbuild_args = [solution_path, '/p:Configuration=' + build_config]
+ msbuild_args = [solution_path, "/p:Configuration=" + build_config]
msbuild_args += extra_msbuild_args
- run_command(msbuild_path, msbuild_args, env_override=msbuild_env, name='msbuild')
+ run_command(msbuild_path, msbuild_args, env_override=msbuild_env, name="msbuild")
diff --git a/modules/mono/class_db_api_json.cpp b/modules/mono/class_db_api_json.cpp
index b04e53bd81..384685d04b 100644
--- a/modules/mono/class_db_api_json.cpp
+++ b/modules/mono/class_db_api_json.cpp
@@ -42,7 +42,7 @@ void class_db_api_to_json(const String &p_output_file, ClassDB::APIType p_api) {
List<StringName> names;
- const StringName *k = NULL;
+ const StringName *k = nullptr;
while ((k = ClassDB::classes.next(k))) {
@@ -67,7 +67,7 @@ void class_db_api_to_json(const String &p_output_file, ClassDB::APIType p_api) {
List<StringName> snames;
- k = NULL;
+ k = nullptr;
while ((k = t->method_map.next(k))) {
@@ -132,7 +132,7 @@ void class_db_api_to_json(const String &p_output_file, ClassDB::APIType p_api) {
List<StringName> snames;
- k = NULL;
+ k = nullptr;
while ((k = t->constant_map.next(k))) {
@@ -160,7 +160,7 @@ void class_db_api_to_json(const String &p_output_file, ClassDB::APIType p_api) {
List<StringName> snames;
- k = NULL;
+ k = nullptr;
while ((k = t->signal_map.next(k))) {
@@ -196,7 +196,7 @@ void class_db_api_to_json(const String &p_output_file, ClassDB::APIType p_api) {
List<StringName> snames;
- k = NULL;
+ k = nullptr;
while ((k = t->property_setget.next(k))) {
diff --git a/modules/mono/config.py b/modules/mono/config.py
index a5d3059ecc..106ca6e028 100644
--- a/modules/mono/config.py
+++ b/modules/mono/config.py
@@ -1,43 +1,70 @@
+supported_platforms = ["windows", "osx", "linuxbsd", "server", "android", "haiku", "javascript", "iphone"]
+
+
def can_build(env, platform):
return True
def configure(env):
- if env['platform'] not in ['windows', 'osx', 'x11', 'server', 'android', 'haiku', 'javascript']:
- raise RuntimeError('This module does not currently support building for this platform')
+ platform = env["platform"]
+
+ if platform not in supported_platforms:
+ raise RuntimeError("This module does not currently support building for this platform")
env.use_ptrcall = True
- env.add_module_version_string('mono')
+ env.add_module_version_string("mono")
from SCons.Script import BoolVariable, PathVariable, Variables, Help
+ default_mono_static = platform in ["iphone", "javascript"]
+ default_mono_bundles_zlib = platform in ["javascript"]
+
envvars = Variables()
- envvars.Add(PathVariable('mono_prefix', 'Path to the mono installation directory for the target platform and architecture', '', PathVariable.PathAccept))
- envvars.Add(BoolVariable('mono_static', 'Statically link mono', False))
- envvars.Add(BoolVariable('mono_glue', 'Build with the mono glue sources', True))
- envvars.Add(BoolVariable('copy_mono_root', 'Make a copy of the mono installation directory to bundle with the editor', False))
- envvars.Add(BoolVariable('xbuild_fallback', 'If MSBuild is not found, fallback to xbuild', False))
+ envvars.Add(
+ PathVariable(
+ "mono_prefix",
+ "Path to the mono installation directory for the target platform and architecture",
+ "",
+ PathVariable.PathAccept,
+ )
+ )
+ envvars.Add(BoolVariable("mono_static", "Statically link mono", default_mono_static))
+ envvars.Add(BoolVariable("mono_glue", "Build with the mono glue sources", True))
+ envvars.Add(
+ BoolVariable(
+ "copy_mono_root", "Make a copy of the mono installation directory to bundle with the editor", False
+ )
+ )
+ envvars.Add(BoolVariable("xbuild_fallback", "If MSBuild is not found, fallback to xbuild", False))
+
+ # TODO: It would be great if this could be detected automatically instead
+ envvars.Add(
+ BoolVariable(
+ "mono_bundles_zlib", "Specify if the Mono runtime was built with bundled zlib", default_mono_bundles_zlib
+ )
+ )
+
envvars.Update(env)
Help(envvars.GenerateHelpText(env))
- if env['platform'] == 'javascript':
- # Mono wasm already has zlib builtin, so we need this workaround to avoid symbol collisions
- print('Compiling with Mono wasm disables \'builtin_zlib\'')
- env['builtin_zlib'] = False
+ if env["mono_bundles_zlib"]:
+ # Mono may come with zlib bundled for WASM or on newer version when built with MinGW.
+ print("This Mono runtime comes with zlib bundled. Disabling 'builtin_zlib'...")
+ env["builtin_zlib"] = False
thirdparty_zlib_dir = "#thirdparty/zlib/"
env.Prepend(CPPPATH=[thirdparty_zlib_dir])
def get_doc_classes():
return [
- '@C#',
- 'CSharpScript',
- 'GodotSharp',
+ "@C#",
+ "CSharpScript",
+ "GodotSharp",
]
def get_doc_path():
- return 'doc_classes'
+ return "doc_classes"
def is_enabled():
diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp
index 28bacbd0f0..f5911275c9 100644
--- a/modules/mono/csharp_script.cpp
+++ b/modules/mono/csharp_script.cpp
@@ -158,7 +158,7 @@ void CSharpLanguage::finish() {
if (gdmono) {
memdelete(gdmono);
- gdmono = NULL;
+ gdmono = nullptr;
}
// Clear here, after finalizing all domains to make sure there is nothing else referencing the elements.
@@ -316,7 +316,8 @@ void CSharpLanguage::get_string_delimiters(List<String> *p_delimiters) const {
p_delimiters->push_back("' '"); // character literal
p_delimiters->push_back("\" \""); // regular string literal
- p_delimiters->push_back("@\" \""); // verbatim string literal
+ // Verbatim string literals (`@" "`) don't render correctly, so don't highlight them.
+ // Generic string highlighting suffices as a workaround for now.
}
static String get_base_class_name(const String &p_base_class_name, const String p_class_name) {
@@ -613,7 +614,7 @@ Vector<ScriptLanguage::StackInfo> CSharpLanguage::stack_trace_get_info(MonoObjec
GD_MONO_SCOPE_THREAD_ATTACH;
- MonoException *exc = NULL;
+ MonoException *exc = nullptr;
MonoArray *frames = CACHED_METHOD_THUNK(System_Diagnostics_StackTrace, GetFrames).invoke(p_stack_trace, &exc);
@@ -678,14 +679,14 @@ void CSharpLanguage::pre_unsafe_unreference(Object *p_obj) {
void CSharpLanguage::frame() {
- if (gdmono && gdmono->is_runtime_initialized() && gdmono->get_core_api_assembly() != NULL) {
+ if (gdmono && gdmono->is_runtime_initialized() && gdmono->get_core_api_assembly() != nullptr) {
const Ref<MonoGCHandleRef> &task_scheduler_handle = GDMonoCache::cached_data.task_scheduler_handle;
if (task_scheduler_handle.is_valid()) {
MonoObject *task_scheduler = task_scheduler_handle->get_target();
if (task_scheduler) {
- MonoException *exc = NULL;
+ MonoException *exc = nullptr;
CACHED_METHOD_THUNK(GodotTaskScheduler, Activate).invoke(task_scheduler, &exc);
if (exc) {
@@ -763,7 +764,7 @@ bool CSharpLanguage::is_assembly_reloading_needed() {
if (proj_assembly) {
String proj_asm_path = proj_assembly->get_path();
- if (!FileAccess::exists(proj_assembly->get_path())) {
+ if (!FileAccess::exists(proj_asm_path)) {
// Maybe it wasn't loaded from the default path, so check this as well
proj_asm_path = GodotSharpDirs::get_res_temp_assemblies_dir().plus_file(appname_safe);
if (!FileAccess::exists(proj_asm_path))
@@ -812,7 +813,7 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) {
Array serialized_data;
MonoObject *managed_serialized_data = GDMonoMarshal::variant_to_mono_object(serialized_data);
- MonoException *exc = NULL;
+ MonoException *exc = nullptr;
bool success = (bool)CACHED_METHOD_THUNK(DelegateUtils, TrySerializeDelegate).invoke(delegate, managed_serialized_data, &exc);
if (exc) {
@@ -945,7 +946,7 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) {
// Restore Variant properties state, it will be kept by the placeholder until the next script reloading
for (List<Pair<StringName, Variant>>::Element *G = scr->pending_reload_state[obj_id].properties.front(); G; G = G->next()) {
- placeholder->property_set_fallback(G->get().first, G->get().second, NULL);
+ placeholder->property_set_fallback(G->get().first, G->get().second, nullptr);
}
scr->pending_reload_state.erase(obj_id);
@@ -979,12 +980,12 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) {
GDMonoAssembly *project_assembly = gdmono->get_project_assembly();
// Search in project and tools assemblies first as those are the most likely to have the class
- GDMonoClass *script_class = (project_assembly ? project_assembly->get_class(class_namespace, class_name) : NULL);
+ GDMonoClass *script_class = (project_assembly ? project_assembly->get_class(class_namespace, class_name) : nullptr);
#ifdef TOOLS_ENABLED
if (!script_class) {
GDMonoAssembly *tools_assembly = gdmono->get_tools_assembly();
- script_class = (tools_assembly ? tools_assembly->get_class(class_namespace, class_name) : NULL);
+ script_class = (tools_assembly ? tools_assembly->get_class(class_namespace, class_name) : nullptr);
}
#endif
@@ -1055,7 +1056,7 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) {
continue;
}
#else
- CRASH_COND(si != NULL);
+ CRASH_COND(si != nullptr);
#endif
// Re-create script instance
obj->set_script(script); // will create the script instance as well
@@ -1104,9 +1105,9 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) {
const CSharpScript::EventSignal &event_signal = match->value();
MonoObject *managed_serialized_data = GDMonoMarshal::variant_to_mono_object(serialized_data);
- MonoDelegate *delegate = NULL;
+ MonoDelegate *delegate = nullptr;
- MonoException *exc = NULL;
+ MonoException *exc = nullptr;
bool success = (bool)CACHED_METHOD_THUNK(DelegateUtils, TryDeserializeDelegate).invoke(managed_serialized_data, &delegate, &exc);
if (exc) {
@@ -1115,7 +1116,7 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) {
}
if (success) {
- ERR_CONTINUE(delegate == NULL);
+ ERR_CONTINUE(delegate == nullptr);
event_signal.field->set_value(csi->get_mono_object(), (MonoObject *)delegate);
} else if (OS::get_singleton()->is_stdout_verbose()) {
OS::get_singleton()->print("Failed to deserialize event signal delegate\n");
@@ -1140,9 +1141,9 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) {
const Array &serialized_data = elem->value();
MonoObject *managed_serialized_data = GDMonoMarshal::variant_to_mono_object(serialized_data);
- MonoDelegate *delegate = NULL;
+ MonoDelegate *delegate = nullptr;
- MonoException *exc = NULL;
+ MonoException *exc = nullptr;
bool success = (bool)CACHED_METHOD_THUNK(DelegateUtils, TryDeserializeDelegate).invoke(managed_serialized_data, &delegate, &exc);
if (exc) {
@@ -1151,7 +1152,7 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) {
}
if (success) {
- ERR_CONTINUE(delegate == NULL);
+ ERR_CONTINUE(delegate == nullptr);
managed_callable->set_delegate(delegate);
} else if (OS::get_singleton()->is_stdout_verbose()) {
OS::get_singleton()->print("Failed to deserialize delegate\n");
@@ -1291,7 +1292,7 @@ void CSharpLanguage::_on_scripts_domain_unloaded() {
for (SelfList<ManagedCallable> *elem = ManagedCallable::instances.first(); elem; elem = elem->next()) {
ManagedCallable *managed_callable = elem->self();
managed_callable->delegate_handle.release();
- managed_callable->delegate_invoke = NULL;
+ managed_callable->delegate_invoke = nullptr;
}
}
@@ -1306,17 +1307,17 @@ void CSharpLanguage::_editor_init_callback() {
// Initialize GodotSharpEditor
GDMonoClass *editor_klass = GDMono::get_singleton()->get_tools_assembly()->get_class("GodotTools", "GodotSharpEditor");
- CRASH_COND(editor_klass == NULL);
+ CRASH_COND(editor_klass == nullptr);
MonoObject *mono_object = mono_object_new(mono_domain_get(), editor_klass->get_mono_ptr());
- CRASH_COND(mono_object == NULL);
+ CRASH_COND(mono_object == nullptr);
- MonoException *exc = NULL;
+ MonoException *exc = nullptr;
GDMonoUtils::runtime_object_init(mono_object, editor_klass, &exc);
UNHANDLED_EXCEPTION(exc);
EditorPlugin *godotsharp_editor = Object::cast_to<EditorPlugin>(GDMonoMarshal::mono_object_to_variant(mono_object));
- CRASH_COND(godotsharp_editor == NULL);
+ CRASH_COND(godotsharp_editor == nullptr);
// Enable it as a plugin
EditorNode::add_editor_plugin(godotsharp_editor);
@@ -1353,7 +1354,7 @@ void CSharpLanguage::release_script_gchandle(MonoObject *p_expected_obj, MonoGCH
// already released and could have been replaced) or if we can't get its target MonoObject*
// (which doesn't necessarily mean it was released, and we want it released in order to
// avoid locking other threads unnecessarily).
- if (target == p_expected_obj || target == NULL) {
+ if (target == p_expected_obj || target == nullptr) {
p_gchandle.release();
}
}
@@ -1379,7 +1380,7 @@ bool CSharpLanguage::setup_csharp_script_binding(CSharpScriptBinding &r_script_b
// I don't trust you
if (p_object->get_script_instance()) {
CSharpInstance *csharp_instance = CAST_CSHARP_INSTANCE(p_object->get_script_instance());
- CRASH_COND(csharp_instance != NULL && !csharp_instance->is_destructing_script_instance());
+ CRASH_COND(csharp_instance != nullptr && !csharp_instance->is_destructing_script_instance());
}
#endif
@@ -1433,7 +1434,7 @@ void *CSharpLanguage::alloc_instance_binding_data(Object *p_object) {
CSharpScriptBinding script_binding;
if (!setup_csharp_script_binding(script_binding, p_object))
- return NULL;
+ return nullptr;
return (void *)insert_script_binding(p_object, script_binding);
}
@@ -1445,7 +1446,7 @@ Map<Object *, CSharpScriptBinding>::Element *CSharpLanguage::insert_script_bindi
void CSharpLanguage::free_instance_binding_data(void *p_data) {
- if (GDMono::get_singleton() == NULL) {
+ if (GDMono::get_singleton() == nullptr) {
#ifdef DEBUG_ENABLED
CRASH_COND(!script_bindings.empty());
#endif
@@ -1470,7 +1471,7 @@ void CSharpLanguage::free_instance_binding_data(void *p_data) {
// This is done to avoid trying to dispose the native instance from Dispose(bool).
MonoObject *mono_object = script_binding.gchandle.get_target();
if (mono_object) {
- CACHED_FIELD(GodotObject, ptr)->set_value_raw(mono_object, NULL);
+ CACHED_FIELD(GodotObject, ptr)->set_value_raw(mono_object, nullptr);
}
script_binding.gchandle.release();
}
@@ -1562,7 +1563,7 @@ CSharpInstance *CSharpInstance::create_for_managed_type(Object *p_owner, CSharpS
Reference *ref = Object::cast_to<Reference>(p_owner);
- instance->base_ref = ref != NULL;
+ instance->base_ref = ref != nullptr;
instance->owner = p_owner;
instance->gchandle = p_gchandle;
@@ -1576,7 +1577,7 @@ CSharpInstance *CSharpInstance::create_for_managed_type(Object *p_owner, CSharpS
MonoObject *CSharpInstance::get_mono_object() const {
- ERR_FAIL_COND_V(gchandle.is_released(), NULL);
+ ERR_FAIL_COND_V(gchandle.is_released(), nullptr);
return gchandle.get_target();
}
@@ -1661,7 +1662,7 @@ bool CSharpInstance::get(const StringName &p_name, Variant &r_ret) const {
GDMonoProperty *property = top->get_property(p_name);
if (property) {
- MonoException *exc = NULL;
+ MonoException *exc = nullptr;
MonoObject *value = property->get_value(mono_object, &exc);
if (exc) {
r_ret = Variant();
@@ -1742,7 +1743,7 @@ void CSharpInstance::get_event_signals_state_for_reloading(List<Pair<StringName,
Array serialized_data;
MonoObject *managed_serialized_data = GDMonoMarshal::variant_to_mono_object(serialized_data);
- MonoException *exc = NULL;
+ MonoException *exc = nullptr;
bool success = (bool)CACHED_METHOD_THUNK(DelegateUtils, TrySerializeDelegate).invoke(delegate_field_value, managed_serialized_data, &exc);
if (exc) {
@@ -1909,7 +1910,7 @@ bool CSharpInstance::_reference_owner_unsafe() {
#ifdef DEBUG_ENABLED
CRASH_COND(!base_ref);
- CRASH_COND(owner == NULL);
+ CRASH_COND(owner == nullptr);
CRASH_COND(unsafe_referenced); // already referenced
#endif
@@ -1931,7 +1932,7 @@ bool CSharpInstance::_unreference_owner_unsafe() {
#ifdef DEBUG_ENABLED
CRASH_COND(!base_ref);
- CRASH_COND(owner == NULL);
+ CRASH_COND(owner == nullptr);
#endif
if (!unsafe_referenced)
@@ -1952,13 +1953,13 @@ bool CSharpInstance::_unreference_owner_unsafe() {
MonoObject *CSharpInstance::_internal_new_managed() {
// Search the constructor first, to fail with an error if it's not found before allocating anything else.
GDMonoMethod *ctor = script->script_class->get_method(CACHED_STRING_NAME(dotctor), 0);
- ERR_FAIL_NULL_V_MSG(ctor, NULL,
+ ERR_FAIL_NULL_V_MSG(ctor, nullptr,
"Cannot create script instance because the class does not define a parameterless constructor: '" + script->get_path() + "'.");
CSharpLanguage::get_singleton()->release_script_gchandle(gchandle);
- ERR_FAIL_NULL_V(owner, NULL);
- ERR_FAIL_COND_V(script.is_null(), NULL);
+ ERR_FAIL_NULL_V(owner, nullptr);
+ ERR_FAIL_COND_V(script.is_null(), nullptr);
MonoObject *mono_object = mono_object_new(mono_domain_get(), script->script_class->get_mono_ptr());
@@ -1970,9 +1971,9 @@ MonoObject *CSharpInstance::_internal_new_managed() {
// Not ok for the owner to die here. If there is a situation where this can happen, it will be considered a bug.
CRASH_COND(die == true);
- owner = NULL;
+ owner = nullptr;
- ERR_FAIL_V_MSG(NULL, "Failed to allocate memory for the object.");
+ ERR_FAIL_V_MSG(nullptr, "Failed to allocate memory for the object.");
}
// Tie managed to unmanaged
@@ -1984,7 +1985,7 @@ MonoObject *CSharpInstance::_internal_new_managed() {
CACHED_FIELD(GodotObject, ptr)->set_value_raw(mono_object, owner);
// Construct
- ctor->invoke_raw(mono_object, NULL);
+ ctor->invoke_raw(mono_object, nullptr);
return mono_object;
}
@@ -2065,7 +2066,7 @@ void CSharpInstance::refcount_incremented() {
#ifdef DEBUG_ENABLED
CRASH_COND(!base_ref);
- CRASH_COND(owner == NULL);
+ CRASH_COND(owner == nullptr);
#endif
Reference *ref_owner = Object::cast_to<Reference>(owner);
@@ -2088,7 +2089,7 @@ bool CSharpInstance::refcount_decremented() {
#ifdef DEBUG_ENABLED
CRASH_COND(!base_ref);
- CRASH_COND(owner == NULL);
+ CRASH_COND(owner == nullptr);
#endif
Reference *ref_owner = Object::cast_to<Reference>(owner);
@@ -2180,7 +2181,7 @@ void CSharpInstance::notification(int p_notification) {
MonoObject *mono_object = get_mono_object();
ERR_FAIL_NULL(mono_object);
- MonoException *exc = NULL;
+ MonoException *exc = nullptr;
GDMonoUtils::dispose(mono_object, &exc);
if (exc) {
@@ -2225,13 +2226,13 @@ String CSharpInstance::to_string(bool *r_valid) {
MonoObject *mono_object = get_mono_object();
- if (mono_object == NULL) {
+ if (mono_object == nullptr) {
if (r_valid)
*r_valid = false;
return String();
}
- MonoException *exc = NULL;
+ MonoException *exc = nullptr;
MonoString *result = GDMonoUtils::object_to_string(mono_object, &exc);
if (exc) {
@@ -2241,7 +2242,7 @@ String CSharpInstance::to_string(bool *r_valid) {
return String();
}
- if (result == NULL) {
+ if (result == nullptr) {
if (r_valid)
*r_valid = false;
return String();
@@ -2275,13 +2276,13 @@ CSharpInstance::~CSharpInstance() {
// This destructor is not called from the owners destructor.
// This could be being called from the owner's set_script_instance method,
// meaning this script is being replaced with another one. If this is the case,
- // we must call Dispose here, because Dispose calls owner->set_script_instance(NULL)
+ // we must call Dispose here, because Dispose calls owner->set_script_instance(nullptr)
// and that would mess up with the new script instance if called later.
MonoObject *mono_object = gchandle.get_target();
if (mono_object) {
- MonoException *exc = NULL;
+ MonoException *exc = nullptr;
GDMonoUtils::dispose(mono_object, &exc);
if (exc) {
@@ -2311,7 +2312,7 @@ CSharpInstance::~CSharpInstance() {
CRASH_COND(die == true); // `owner_keep_alive` holds a reference, so it can't die
void *data = owner->get_script_instance_binding(CSharpLanguage::get_singleton()->get_language_index());
- CRASH_COND(data == NULL);
+ CRASH_COND(data == nullptr);
CSharpScriptBinding &script_binding = ((Map<Object *, CSharpScriptBinding>::Element *)data)->get();
@@ -2454,11 +2455,11 @@ bool CSharpScript::_update_exports() {
GDMonoMethod *ctor = script_class->get_method(CACHED_STRING_NAME(dotctor), 0);
- ERR_FAIL_NULL_V_MSG(ctor, NULL,
+ ERR_FAIL_NULL_V_MSG(ctor, false,
"Cannot construct temporary MonoObject because the class does not define a parameterless constructor: '" + get_path() + "'.");
- MonoException *ctor_exc = NULL;
- ctor->invoke(tmp_object, NULL, &ctor_exc);
+ MonoException *ctor_exc = nullptr;
+ ctor->invoke(tmp_object, nullptr, &ctor_exc);
Object *tmp_native = GDMonoMarshal::unbox<Object *>(CACHED_FIELD(GodotObject, ptr)->get_value(tmp_object));
@@ -2466,7 +2467,7 @@ bool CSharpScript::_update_exports() {
// TODO: Should we free 'tmp_native' if the exception was thrown after its creation?
GDMonoUtils::free_gchandle(tmp_pinned_gchandle);
- tmp_object = NULL;
+ tmp_object = nullptr;
ERR_PRINT("Exception thrown from constructor of temporary MonoObject:");
GDMonoUtils::debug_print_unhandled_exception(ctor_exc);
@@ -2513,7 +2514,7 @@ bool CSharpScript::_update_exports() {
exported_members_cache.push_front(prop_info);
if (tmp_object) {
- MonoException *exc = NULL;
+ MonoException *exc = nullptr;
MonoObject *ret = property->get_value(tmp_object, &exc);
if (exc) {
exported_members_defval_cache[member_name] = Variant();
@@ -2532,11 +2533,11 @@ bool CSharpScript::_update_exports() {
}
// Need to check this here, before disposal
- bool base_ref = Object::cast_to<Reference>(tmp_native) != NULL;
+ bool base_ref = Object::cast_to<Reference>(tmp_native) != nullptr;
// Dispose the temporary managed instance
- MonoException *exc = NULL;
+ MonoException *exc = nullptr;
GDMonoUtils::dispose(tmp_object, &exc);
if (exc) {
@@ -2545,7 +2546,7 @@ bool CSharpScript::_update_exports() {
}
GDMonoUtils::free_gchandle(tmp_pinned_gchandle);
- tmp_object = NULL;
+ tmp_object = nullptr;
if (tmp_native && !base_ref) {
Node *node = Object::cast_to<Node>(tmp_native);
@@ -2608,9 +2609,9 @@ void CSharpScript::load_script_signals(GDMonoClass *p_class, GDMonoClass *p_nati
List<StringName> found_event_signals;
- void *iter = NULL;
- MonoEvent *raw_event = NULL;
- while ((raw_event = mono_class_get_events(top->get_mono_ptr(), &iter)) != NULL) {
+ void *iter = nullptr;
+ MonoEvent *raw_event = nullptr;
+ while ((raw_event = mono_class_get_events(top->get_mono_ptr(), &iter)) != nullptr) {
MonoCustomAttrInfo *event_attrs = mono_custom_attrs_from_event(top->get_mono_ptr(), raw_event);
if (event_attrs) {
if (mono_custom_attrs_has_attr(event_attrs, CACHED_CLASS(SignalAttribute)->get_mono_ptr())) {
@@ -2810,7 +2811,7 @@ int CSharpScript::_try_get_member_export_hint(IMonoClassMember *p_member, Manage
// Instead of using mono_field_get_value_object, we can do this without boxing. Check the
// internal mono functions: ves_icall_System_Enum_GetEnumValuesAndNames and the get_enum_field.
- MonoObject *val_obj = mono_field_get_value_object(mono_domain_get(), field, NULL);
+ MonoObject *val_obj = mono_field_get_value_object(mono_domain_get(), field, nullptr);
ERR_FAIL_NULL_V_MSG(val_obj, -1, "Failed to get '" + enum_field_name + "' constant enum value.");
@@ -2834,7 +2835,7 @@ int CSharpScript::_try_get_member_export_hint(IMonoClassMember *p_member, Manage
}
} else if (p_variant_type == Variant::OBJECT && CACHED_CLASS(GodotResource)->is_assignable_from(p_type.type_class)) {
GDMonoClass *field_native_class = GDMonoUtils::get_class_native_base(p_type.type_class);
- CRASH_COND(field_native_class == NULL);
+ CRASH_COND(field_native_class == nullptr);
r_hint = PROPERTY_HINT_RESOURCE_TYPE;
r_hint_string = String(NATIVE_GDMONOCLASS_NAME(field_native_class));
@@ -2876,14 +2877,14 @@ void CSharpScript::_clear() {
tool = false;
valid = false;
- base = NULL;
- native = NULL;
- script_class = NULL;
+ base = nullptr;
+ native = nullptr;
+ script_class = nullptr;
}
Variant CSharpScript::call(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
- if (unlikely(GDMono::get_singleton() == NULL)) {
+ if (unlikely(GDMono::get_singleton() == nullptr)) {
// Probably not the best error but eh.
r_error.error = Callable::CallError::CALL_ERROR_INSTANCE_IS_NULL;
return Variant();
@@ -2897,7 +2898,7 @@ Variant CSharpScript::call(const StringName &p_method, const Variant **p_args, i
GDMonoMethod *method = top->get_method(p_method, p_argcount);
if (method && method->is_static()) {
- MonoObject *result = method->invoke(NULL, p_args);
+ MonoObject *result = method->invoke(nullptr, p_args);
if (result) {
return GDMonoMarshal::mono_object_to_variant(result);
@@ -2959,7 +2960,7 @@ Ref<CSharpScript> CSharpScript::create_for_managed_type(GDMonoClass *p_class, GD
// This method should not fail, only assertions allowed
- CRASH_COND(p_class == NULL);
+ CRASH_COND(p_class == nullptr);
// TODO OPTIMIZE: Cache the 'CSharpScript' associated with this 'p_class' instead of allocating a new one every time
Ref<CSharpScript> script = memnew(CSharpScript);
@@ -2973,13 +2974,13 @@ void CSharpScript::initialize_for_managed_type(Ref<CSharpScript> p_script, GDMon
// This method should not fail, only assertions allowed
- CRASH_COND(p_class == NULL);
+ CRASH_COND(p_class == nullptr);
p_script->name = p_class->get_name();
p_script->script_class = p_class;
p_script->native = p_native;
- CRASH_COND(p_script->native == NULL);
+ CRASH_COND(p_script->native == nullptr);
GDMonoClass *base = p_script->script_class->get_parent_class();
@@ -3045,12 +3046,12 @@ bool CSharpScript::can_instance() const {
// For tool scripts, this will never fire if the class is not found. That's because we
// don't know if it's a tool script if we can't find the class to access the attributes.
if (extra_cond && !script_class) {
- if (GDMono::get_singleton()->get_project_assembly() == NULL) {
+ if (GDMono::get_singleton()->get_project_assembly() == nullptr) {
// The project assembly is not loaded
- ERR_FAIL_V_MSG(NULL, "Cannot instance script because the project assembly is not loaded. Script: '" + get_path() + "'.");
+ ERR_FAIL_V_MSG(false, "Cannot instance script because the project assembly is not loaded. Script: '" + get_path() + "'.");
} else {
// The project assembly is loaded, but the class could not found
- ERR_FAIL_V_MSG(NULL, "Cannot instance script because the class '" + name + "' could not be found. Script: '" + get_path() + "'.");
+ ERR_FAIL_V_MSG(false, "Cannot instance script because the class '" + name + "' could not be found. Script: '" + get_path() + "'.");
}
}
@@ -3073,13 +3074,13 @@ CSharpInstance *CSharpScript::_create_instance(const Variant **p_args, int p_arg
// Search the constructor first, to fail with an error if it's not found before allocating anything else.
GDMonoMethod *ctor = script_class->get_method(CACHED_STRING_NAME(dotctor), p_argcount);
- if (ctor == NULL) {
- ERR_FAIL_COND_V_MSG(p_argcount == 0, NULL,
+ if (ctor == nullptr) {
+ ERR_FAIL_COND_V_MSG(p_argcount == 0, nullptr,
"Cannot create script instance. The class '" + script_class->get_full_name() +
"' does not define a parameterless constructor." +
(get_path().empty() ? String() : " Path: '" + get_path() + "'."));
- ERR_FAIL_V_MSG(NULL, "Constructor not found.");
+ ERR_FAIL_V_MSG(nullptr, "Constructor not found.");
}
Ref<Reference> ref;
@@ -3091,13 +3092,13 @@ CSharpInstance *CSharpScript::_create_instance(const Variant **p_args, int p_arg
// If the object had a script instance binding, dispose it before adding the CSharpInstance
if (p_owner->has_script_instance_binding(CSharpLanguage::get_singleton()->get_language_index())) {
void *data = p_owner->get_script_instance_binding(CSharpLanguage::get_singleton()->get_language_index());
- CRASH_COND(data == NULL);
+ CRASH_COND(data == nullptr);
CSharpScriptBinding &script_binding = ((Map<Object *, CSharpScriptBinding>::Element *)data)->get();
if (script_binding.inited && !script_binding.gchandle.is_released()) {
MonoObject *mono_object = script_binding.gchandle.get_target();
if (mono_object) {
- MonoException *exc = NULL;
+ MonoException *exc = nullptr;
GDMonoUtils::dispose(mono_object, &exc);
if (exc) {
@@ -3122,15 +3123,15 @@ CSharpInstance *CSharpScript::_create_instance(const Variant **p_args, int p_arg
if (!mono_object) {
// Important to clear this before destroying the script instance here
instance->script = Ref<CSharpScript>();
- instance->owner = NULL;
+ instance->owner = nullptr;
bool die = instance->_unreference_owner_unsafe();
// Not ok for the owner to die here. If there is a situation where this can happen, it will be considered a bug.
CRASH_COND(die == true);
- p_owner->set_script_instance(NULL);
+ p_owner->set_script_instance(nullptr);
r_error.error = Callable::CallError::CALL_ERROR_INSTANCE_IS_NULL;
- ERR_FAIL_V_MSG(NULL, "Failed to allocate memory for the object.");
+ ERR_FAIL_V_MSG(nullptr, "Failed to allocate memory for the object.");
}
// Tie managed to unmanaged
@@ -3176,7 +3177,7 @@ Variant CSharpScript::_new(const Variant **p_args, int p_argcount, Callable::Cal
ref = REF(r);
}
- CSharpInstance *instance = _create_instance(p_args, p_argcount, owner, r != NULL, r_error);
+ CSharpInstance *instance = _create_instance(p_args, p_argcount, owner, r != nullptr, r_error);
if (!instance) {
if (ref.is_null()) {
memdelete(owner); //no owner, sorry
@@ -3205,15 +3206,15 @@ ScriptInstance *CSharpScript::instance_create(Object *p_this) {
"Script inherits from native type '" + String(native_name) +
"', so it can't be instanced in object of type: '" + p_this->get_class() + "'");
}
- ERR_FAIL_V_MSG(NULL, "Script inherits from native type '" + String(native_name) +
- "', so it can't be instanced in object of type: '" + p_this->get_class() + "'.");
+ ERR_FAIL_V_MSG(nullptr, "Script inherits from native type '" + String(native_name) +
+ "', so it can't be instanced in object of type: '" + p_this->get_class() + "'.");
}
}
GD_MONO_SCOPE_THREAD_ATTACH;
Callable::CallError unchecked_error;
- return _create_instance(NULL, 0, p_this, Object::cast_to<Reference>(p_this) != NULL, unchecked_error);
+ return _create_instance(nullptr, 0, p_this, Object::cast_to<Reference>(p_this) != nullptr, unchecked_error);
}
PlaceHolderScriptInstance *CSharpScript::placeholder_instance_create(Object *p_this) {
@@ -3224,7 +3225,7 @@ PlaceHolderScriptInstance *CSharpScript::placeholder_instance_create(Object *p_t
_update_exports();
return si;
#else
- return NULL;
+ return nullptr;
#endif
}
@@ -3332,7 +3333,7 @@ Error CSharpScript::reload(bool p_keep_state) {
script_class = project_assembly->get_object_derived_class(name);
}
- valid = script_class != NULL;
+ valid = script_class != nullptr;
if (script_class) {
#ifdef DEBUG_ENABLED
@@ -3354,7 +3355,7 @@ Error CSharpScript::reload(bool p_keep_state) {
native = GDMonoUtils::get_class_native_base(script_class);
- CRASH_COND(native == NULL);
+ CRASH_COND(native == nullptr);
GDMonoClass *base_class = script_class->get_parent_class();
@@ -3535,6 +3536,18 @@ void CSharpScript::get_script_signal_list(List<MethodInfo> *r_signals) const {
}
}
+bool CSharpScript::inherits_script(const Ref<Script> &p_script) const {
+ Ref<CSharpScript> cs = p_script;
+ if (cs.is_null()) {
+ return false;
+ }
+
+#ifndef _MSC_VER
+#warning TODO: Implement CSharpScript::inherits_script and other relevant changes after GH-38063.
+#endif
+ return false;
+}
+
Ref<Script> CSharpScript::get_base_script() const {
// TODO search in metadata file once we have it, not important any way?
@@ -3672,7 +3685,7 @@ CSharpScript::~CSharpScript() {
/*************** RESOURCE ***************/
-RES ResourceFormatLoaderCSharpScript::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress) {
+RES ResourceFormatLoaderCSharpScript::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, bool p_no_cache) {
if (r_error)
*r_error = ERR_FILE_CANT_OPEN;
@@ -3766,7 +3779,7 @@ void ResourceFormatSaverCSharpScript::get_recognized_extensions(const RES &p_res
bool ResourceFormatSaverCSharpScript::recognize(const RES &p_resource) const {
- return Object::cast_to<CSharpScript>(p_resource.ptr()) != NULL;
+ return Object::cast_to<CSharpScript>(p_resource.ptr()) != nullptr;
}
CSharpLanguage::StringNameCache::StringNameCache() {
diff --git a/modules/mono/csharp_script.h b/modules/mono/csharp_script.h
index 53b4aa6c20..05e2857538 100644
--- a/modules/mono/csharp_script.h
+++ b/modules/mono/csharp_script.h
@@ -77,8 +77,8 @@ public:
};
struct EventSignal {
- GDMonoField *field = NULL;
- GDMonoMethod *invoke_method = NULL;
+ GDMonoField *field = nullptr;
+ GDMonoMethod *invoke_method = nullptr;
Vector<SignalParameter> parameters;
};
@@ -194,6 +194,8 @@ public:
virtual bool is_tool() const { return tool; }
virtual bool is_valid() const { return valid; }
+ bool inherits_script(const Ref<Script> &p_script) const;
+
virtual Ref<Script> get_base_script() const;
virtual ScriptLanguage *get_language() const;
@@ -331,8 +333,8 @@ struct CSharpScriptBinding {
CSharpScriptBinding() :
inited(false),
- wrapper_class(NULL),
- owner(NULL) {
+ wrapper_class(nullptr),
+ owner(nullptr) {
}
};
@@ -530,7 +532,7 @@ public:
class ResourceFormatLoaderCSharpScript : public ResourceFormatLoader {
public:
- virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr);
+ virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr, bool p_no_cache = false);
virtual void get_recognized_extensions(List<String> *p_extensions) const;
virtual bool handles_type(const String &p_type) const;
virtual String get_resource_type(const String &p_path) const;
diff --git a/modules/mono/editor/GodotTools/GodotTools.Core/FileUtils.cs b/modules/mono/editor/GodotTools/GodotTools.Core/FileUtils.cs
new file mode 100644
index 0000000000..85760a3705
--- /dev/null
+++ b/modules/mono/editor/GodotTools/GodotTools.Core/FileUtils.cs
@@ -0,0 +1,27 @@
+using System.IO;
+
+namespace GodotTools.Core
+{
+ public static class FileUtils
+ {
+ public static void SaveBackupCopy(string filePath)
+ {
+ string backupPathBase = filePath + ".old";
+ string backupPath = backupPathBase;
+
+ const int maxAttempts = 5;
+ int attempt = 1;
+
+ while (File.Exists(backupPath) && attempt <= maxAttempts)
+ {
+ backupPath = backupPathBase + "." + (attempt);
+ attempt++;
+ }
+
+ if (attempt > maxAttempts + 1)
+ return;
+
+ File.Copy(filePath, backupPath, overwrite: true);
+ }
+ }
+}
diff --git a/modules/mono/editor/GodotTools/GodotTools.Core/GodotTools.Core.csproj b/modules/mono/editor/GodotTools/GodotTools.Core/GodotTools.Core.csproj
index 2c35ef540a..c9ea7d3a2c 100644
--- a/modules/mono/editor/GodotTools/GodotTools.Core/GodotTools.Core.csproj
+++ b/modules/mono/editor/GodotTools/GodotTools.Core/GodotTools.Core.csproj
@@ -31,6 +31,7 @@
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
+ <Compile Include="FileUtils.cs" />
<Compile Include="ProcessExtensions.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="StringExtensions.cs" />
diff --git a/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/DotNetSolution.cs b/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/DotNetSolution.cs
index 9afd9adeb1..6f318aab4a 100644
--- a/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/DotNetSolution.cs
+++ b/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/DotNetSolution.cs
@@ -153,7 +153,12 @@ EndProject";
var result = regex.Replace(input,m => dict[m.Value]);
if (result != input)
+ {
+ // Save a copy of the solution before replacing it
+ FileUtils.SaveBackupCopy(slnPath);
+
File.WriteAllText(slnPath, result);
+ }
}
}
}
diff --git a/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectUtils.cs b/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectUtils.cs
index 1776b46e6a..f2ebef1a7d 100644
--- a/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectUtils.cs
+++ b/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectUtils.cs
@@ -9,8 +9,28 @@ using Microsoft.Build.Construction;
namespace GodotTools.ProjectEditor
{
+ public sealed class MSBuildProject
+ {
+ public ProjectRootElement Root { get; }
+
+ public bool HasUnsavedChanges { get; set; }
+
+ public void Save() => Root.Save();
+
+ public MSBuildProject(ProjectRootElement root)
+ {
+ Root = root;
+ }
+ }
+
public static class ProjectUtils
{
+ public static MSBuildProject Open(string path)
+ {
+ var root = ProjectRootElement.Open(path);
+ return root != null ? new MSBuildProject(root) : null;
+ }
+
public static void AddItemToProjectChecked(string projectPath, string itemType, string include)
{
var dir = Directory.GetParent(projectPath).FullName;
@@ -43,7 +63,6 @@ namespace GodotTools.ProjectEditor
public static void RemoveItemFromProjectChecked(string projectPath, string itemType, string include)
{
- var dir = Directory.GetParent(projectPath).FullName;
var root = ProjectRootElement.Open(projectPath);
Debug.Assert(root != null);
@@ -150,12 +169,9 @@ namespace GodotTools.ProjectEditor
}
/// Simple function to make sure the Api assembly references are configured correctly
- public static void FixApiHintPath(string projectPath)
+ public static void FixApiHintPath(MSBuildProject project)
{
- var root = ProjectRootElement.Open(projectPath);
- Debug.Assert(root != null);
-
- bool dirty = false;
+ var root = project.Root;
void AddPropertyIfNotPresent(string name, string condition, string value)
{
@@ -170,7 +186,7 @@ namespace GodotTools.ProjectEditor
}
root.AddProperty(name, value).Condition = " " + condition + " ";
- dirty = true;
+ project.HasUnsavedChanges = true;
}
AddPropertyIfNotPresent(name: "ApiConfiguration",
@@ -212,7 +228,7 @@ namespace GodotTools.ProjectEditor
}
referenceWithHintPath.AddMetadata("HintPath", hintPath);
- dirty = true;
+ project.HasUnsavedChanges = true;
return;
}
@@ -221,14 +237,14 @@ namespace GodotTools.ProjectEditor
{
// Found a Reference item without a HintPath
referenceWithoutHintPath.AddMetadata("HintPath", hintPath);
- dirty = true;
+ project.HasUnsavedChanges = true;
return;
}
}
// Found no Reference item at all. Add it.
root.AddItem("Reference", referenceName).Condition = " " + condition + " ";
- dirty = true;
+ project.HasUnsavedChanges = true;
}
const string coreProjectName = "GodotSharp";
@@ -242,17 +258,11 @@ namespace GodotTools.ProjectEditor
SetReferenceHintPath(coreProjectName, coreCondition, coreHintPath);
SetReferenceHintPath(editorProjectName, editorCondition, editorHintPath);
-
- if (dirty)
- root.Save();
}
- public static void MigrateFromOldConfigNames(string projectPath)
+ public static void MigrateFromOldConfigNames(MSBuildProject project)
{
- var root = ProjectRootElement.Open(projectPath);
- Debug.Assert(root != null);
-
- bool dirty = false;
+ var root = project.Root;
bool hasGodotProjectGeneratorVersion = false;
bool foundOldConfiguration = false;
@@ -267,7 +277,7 @@ namespace GodotTools.ProjectEditor
{
configItem.Value = "Debug";
foundOldConfiguration = true;
- dirty = true;
+ project.HasUnsavedChanges = true;
}
}
@@ -275,7 +285,7 @@ namespace GodotTools.ProjectEditor
{
root.PropertyGroups.First(g => g.Condition == string.Empty)?
.AddProperty("GodotProjectGeneratorVersion", Assembly.GetExecutingAssembly().GetName().Version.ToString());
- dirty = true;
+ project.HasUnsavedChanges = true;
}
if (!foundOldConfiguration)
@@ -301,7 +311,7 @@ namespace GodotTools.ProjectEditor
foreach (var propertyGroup in root.PropertyGroups.Where(g => g.Condition.Trim() == oldCondition))
{
propertyGroup.Condition = " " + newCondition + " ";
- dirty = true;
+ project.HasUnsavedChanges = true;
}
foreach (var propertyGroup in root.PropertyGroups)
@@ -309,14 +319,14 @@ namespace GodotTools.ProjectEditor
foreach (var prop in propertyGroup.Properties.Where(p => p.Condition.Trim() == oldCondition))
{
prop.Condition = " " + newCondition + " ";
- dirty = true;
+ project.HasUnsavedChanges = true;
}
}
foreach (var itemGroup in root.ItemGroups.Where(g => g.Condition.Trim() == oldCondition))
{
itemGroup.Condition = " " + newCondition + " ";
- dirty = true;
+ project.HasUnsavedChanges = true;
}
foreach (var itemGroup in root.ItemGroups)
@@ -324,7 +334,7 @@ namespace GodotTools.ProjectEditor
foreach (var item in itemGroup.Items.Where(item => item.Condition.Trim() == oldCondition))
{
item.Condition = " " + newCondition + " ";
- dirty = true;
+ project.HasUnsavedChanges = true;
}
}
}
@@ -340,10 +350,6 @@ namespace GodotTools.ProjectEditor
MigrateConfigurationConditions("Release", "ExportRelease");
MigrateConfigurationConditions("Tools", "Debug"); // Must be last
}
-
-
- if (dirty)
- root.Save();
}
}
}
diff --git a/modules/mono/editor/GodotTools/GodotTools/BottomPanel.cs b/modules/mono/editor/GodotTools/GodotTools/BottomPanel.cs
index e4c8759802..3cf495f025 100644
--- a/modules/mono/editor/GodotTools/GodotTools/BottomPanel.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/BottomPanel.cs
@@ -205,9 +205,9 @@ namespace GodotTools
if (what == EditorSettings.NotificationEditorSettingsChanged)
{
var editorBaseControl = editorInterface.GetBaseControl();
- panelTabs.AddStyleboxOverride("panel", editorBaseControl.GetStylebox("DebuggerPanel", "EditorStyles"));
- panelTabs.AddStyleboxOverride("tab_fg", editorBaseControl.GetStylebox("DebuggerTabFG", "EditorStyles"));
- panelTabs.AddStyleboxOverride("tab_bg", editorBaseControl.GetStylebox("DebuggerTabBG", "EditorStyles"));
+ panelTabs.AddThemeStyleboxOverride("panel", editorBaseControl.GetThemeStylebox("DebuggerPanel", "EditorStyles"));
+ panelTabs.AddThemeStyleboxOverride("tab_fg", editorBaseControl.GetThemeStylebox("DebuggerTabFG", "EditorStyles"));
+ panelTabs.AddThemeStyleboxOverride("tab_bg", editorBaseControl.GetThemeStylebox("DebuggerTabBG", "EditorStyles"));
}
}
@@ -258,9 +258,9 @@ namespace GodotTools
RectMinSize = new Vector2(0, 228) * EditorScale,
SizeFlagsVertical = (int)SizeFlags.ExpandFill
};
- panelTabs.AddStyleboxOverride("panel", editorBaseControl.GetStylebox("DebuggerPanel", "EditorStyles"));
- panelTabs.AddStyleboxOverride("tab_fg", editorBaseControl.GetStylebox("DebuggerTabFG", "EditorStyles"));
- panelTabs.AddStyleboxOverride("tab_bg", editorBaseControl.GetStylebox("DebuggerTabBG", "EditorStyles"));
+ panelTabs.AddThemeStyleboxOverride("panel", editorBaseControl.GetThemeStylebox("DebuggerPanel", "EditorStyles"));
+ panelTabs.AddThemeStyleboxOverride("tab_fg", editorBaseControl.GetThemeStylebox("DebuggerTabFG", "EditorStyles"));
+ panelTabs.AddThemeStyleboxOverride("tab_bg", editorBaseControl.GetThemeStylebox("DebuggerTabBG", "EditorStyles"));
AddChild(panelTabs);
{
diff --git a/modules/mono/editor/GodotTools/GodotTools/BuildTab.cs b/modules/mono/editor/GodotTools/GodotTools/BuildTab.cs
index b2459b69ad..938c3d8be1 100644
--- a/modules/mono/editor/GodotTools/GodotTools/BuildTab.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/BuildTab.cs
@@ -46,12 +46,12 @@ namespace GodotTools
get
{
if (!BuildExited)
- return GetIcon("Stop", "EditorIcons");
+ return GetThemeIcon("Stop", "EditorIcons");
if (BuildResult == BuildResults.Error)
- return GetIcon("StatusError", "EditorIcons");
+ return GetThemeIcon("StatusError", "EditorIcons");
- return GetIcon("StatusSuccess", "EditorIcons");
+ return GetThemeIcon("StatusSuccess", "EditorIcons");
}
}
@@ -145,8 +145,8 @@ namespace GodotTools
{
issuesList.Clear();
- using (var warningIcon = GetIcon("Warning", "EditorIcons"))
- using (var errorIcon = GetIcon("Error", "EditorIcons"))
+ using (var warningIcon = GetThemeIcon("Warning", "EditorIcons"))
+ using (var errorIcon = GetThemeIcon("Error", "EditorIcons"))
{
for (int i = 0; i < issues.Count; i++)
{
diff --git a/modules/mono/editor/GodotTools/GodotTools/Export/AotBuilder.cs b/modules/mono/editor/GodotTools/GodotTools/Export/AotBuilder.cs
new file mode 100755
index 0000000000..f1765f7e19
--- /dev/null
+++ b/modules/mono/editor/GodotTools/GodotTools/Export/AotBuilder.cs
@@ -0,0 +1,618 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.IO;
+using System.Linq;
+using System.Text;
+using GodotTools.Internals;
+using Directory = GodotTools.Utils.Directory;
+using File = GodotTools.Utils.File;
+using OS = GodotTools.Utils.OS;
+using Path = System.IO.Path;
+
+namespace GodotTools.Export
+{
+ public struct AotOptions
+ {
+ public bool EnableLLVM;
+ public bool LLVMOnly;
+ public string LLVMPath;
+ public string LLVMOutputPath;
+
+ public bool FullAot;
+
+ private bool _useInterpreter;
+ public bool UseInterpreter { get => _useInterpreter && !LLVMOnly; set => _useInterpreter = value; }
+
+ public string[] ExtraAotOptions;
+ public string[] ExtraOptimizerOptions;
+
+ public string ToolchainPath;
+ }
+
+ public static class AotBuilder
+ {
+ public static void CompileAssemblies(ExportPlugin exporter, AotOptions aotOpts, string[] features, string platform, bool isDebug, string bclDir, string outputDir, string outputDataDir, IDictionary<string, string> assemblies)
+ {
+ // TODO: WASM
+
+ string aotTempDir = Path.Combine(Path.GetTempPath(), $"godot-aot-{Process.GetCurrentProcess().Id}");
+
+ if (!Directory.Exists(aotTempDir))
+ Directory.CreateDirectory(aotTempDir);
+
+ var assembliesPrepared = new Dictionary<string, string>();
+
+ foreach (var dependency in assemblies)
+ {
+ string assemblyName = dependency.Key;
+ string assemblyPath = dependency.Value;
+
+ string assemblyPathInBcl = Path.Combine(bclDir, assemblyName + ".dll");
+
+ if (File.Exists(assemblyPathInBcl))
+ {
+ // Don't create teporaries for assemblies from the BCL
+ assembliesPrepared.Add(assemblyName, assemblyPathInBcl);
+ }
+ else
+ {
+ string tempAssemblyPath = Path.Combine(aotTempDir, assemblyName + ".dll");
+ File.Copy(assemblyPath, tempAssemblyPath);
+ assembliesPrepared.Add(assemblyName, tempAssemblyPath);
+ }
+ }
+
+ if (platform == OS.Platforms.iOS)
+ {
+ var architectures = GetEnablediOSArchs(features).ToArray();
+ CompileAssembliesForiOS(exporter, isDebug, architectures, aotOpts, aotTempDir, assembliesPrepared, bclDir);
+ }
+ else if (platform == OS.Platforms.Android)
+ {
+ var abis = GetEnabledAndroidAbis(features).ToArray();
+ CompileAssembliesForAndroid(exporter, isDebug, abis, aotOpts, aotTempDir, assembliesPrepared, bclDir);
+ }
+ else
+ {
+ string bits = features.Contains("64") ? "64" : features.Contains("32") ? "32" : null;
+ CompileAssembliesForDesktop(exporter, platform, isDebug, bits, aotOpts, aotTempDir, outputDataDir, assembliesPrepared, bclDir);
+ }
+ }
+
+ public static void CompileAssembliesForAndroid(ExportPlugin exporter, bool isDebug, string[] abis, AotOptions aotOpts, string aotTempDir, IDictionary<string, string> assemblies, string bclDir)
+ {
+
+ foreach (var assembly in assemblies)
+ {
+ string assemblyName = assembly.Key;
+ string assemblyPath = assembly.Value;
+
+ // Not sure if the 'lib' prefix is an Android thing or just Godot being picky,
+ // but we use '-aot-' as well just in case to avoid conflicts with other libs.
+ string outputFileName = "lib-aot-" + assemblyName + ".dll.so";
+
+ foreach (string abi in abis)
+ {
+ string aotAbiTempDir = Path.Combine(aotTempDir, abi);
+ string soFilePath = Path.Combine(aotAbiTempDir, outputFileName);
+
+ var compilerArgs = GetAotCompilerArgs(OS.Platforms.Android, isDebug, abi, aotOpts, assemblyPath, soFilePath);
+
+ // Make sure the output directory exists
+ Directory.CreateDirectory(aotAbiTempDir);
+
+ string compilerDirPath = Path.Combine(GodotSharpDirs.DataEditorToolsDir, "aot-compilers", $"{OS.Platforms.Android}-{abi}");
+
+ ExecuteCompiler(FindCrossCompiler(compilerDirPath), compilerArgs, bclDir);
+
+ // The Godot exporter expects us to pass the abi in the tags parameter
+ exporter.AddSharedObject(soFilePath, tags: new[] { abi });
+ }
+ }
+ }
+
+ public static void CompileAssembliesForDesktop(ExportPlugin exporter, string platform, bool isDebug, string bits, AotOptions aotOpts, string aotTempDir, string outputDataDir, IDictionary<string, string> assemblies, string bclDir)
+ {
+ foreach (var assembly in assemblies)
+ {
+ string assemblyName = assembly.Key;
+ string assemblyPath = assembly.Value;
+
+ string outputFileExtension = platform == OS.Platforms.Windows ? ".dll" :
+ platform == OS.Platforms.OSX ? ".dylib" :
+ ".so";
+
+ string outputFileName = assemblyName + ".dll" + outputFileExtension;
+ string tempOutputFilePath = Path.Combine(aotTempDir, outputFileName);
+
+ var compilerArgs = GetAotCompilerArgs(platform, isDebug, bits, aotOpts, assemblyPath, tempOutputFilePath);
+
+ string compilerDirPath = GetMonoCrossDesktopDirName(platform, bits);
+
+ ExecuteCompiler(FindCrossCompiler(compilerDirPath), compilerArgs, bclDir);
+
+ if (platform == OS.Platforms.OSX)
+ {
+ exporter.AddSharedObject(tempOutputFilePath, tags: null);
+ }
+ else
+ {
+ string outputDataLibDir = Path.Combine(outputDataDir, "Mono", platform == OS.Platforms.Windows ? "bin" : "lib");
+ File.Copy(tempOutputFilePath, Path.Combine(outputDataLibDir, outputFileName));
+ }
+ }
+ }
+
+ public static void CompileAssembliesForiOS(ExportPlugin exporter, bool isDebug, string[] architectures, AotOptions aotOpts, string aotTempDir, IDictionary<string, string> assemblies, string bclDir)
+ {
+ var cppCode = new StringBuilder();
+ var aotModuleInfoSymbols = new List<string>(assemblies.Count);
+
+ // {arch: paths}
+ var objFilePathsForiOSArch = architectures.ToDictionary(arch => arch, arch => new List<string>(assemblies.Count));
+
+ foreach (var assembly in assemblies)
+ {
+ string assemblyName = assembly.Key;
+ string assemblyPath = assembly.Value;
+
+ string asmFileName = assemblyName + ".dll.S";
+ string objFileName = assemblyName + ".dll.o";
+
+ foreach (string arch in architectures)
+ {
+ string aotArchTempDir = Path.Combine(aotTempDir, arch);
+ string asmFilePath = Path.Combine(aotArchTempDir, asmFileName);
+
+ var compilerArgs = GetAotCompilerArgs(OS.Platforms.iOS, isDebug, arch, aotOpts, assemblyPath, asmFilePath);
+
+ // Make sure the output directory exists
+ Directory.CreateDirectory(aotArchTempDir);
+
+ string compilerDirPath = Path.Combine(GodotSharpDirs.DataEditorToolsDir, "aot-compilers", $"{OS.Platforms.iOS}-{arch}");
+
+ ExecuteCompiler(FindCrossCompiler(compilerDirPath), compilerArgs, bclDir);
+
+ // Assembling
+ bool isSim = arch == "i386" || arch == "x86_64"; // Shouldn't really happen as we don't do AOT for the simulator
+ string versionMinName = isSim ? "iphonesimulator" : "iphoneos";
+ string iOSPlatformName = isSim ? "iPhoneSimulator" : "iPhoneOS";
+ const string versionMin = "10.0"; // TODO: Turn this hard-coded version into an exporter setting
+ string iOSSdkPath = Path.Combine(XcodeHelper.XcodePath,
+ $"Contents/Developer/Platforms/{iOSPlatformName}.platform/Developer/SDKs/{iOSPlatformName}.sdk");
+
+ string objFilePath = Path.Combine(aotArchTempDir, objFileName);
+
+ var clangArgs = new List<string>()
+ {
+ "-isysroot", iOSSdkPath,
+ "-Qunused-arguments",
+ $"-m{versionMinName}-version-min={versionMin}",
+ "-arch", arch,
+ "-c",
+ "-o", objFilePath,
+ "-x", "assembler"
+ };
+
+ if (isDebug)
+ clangArgs.Add("-DDEBUG");
+
+ clangArgs.Add(asmFilePath);
+
+ int clangExitCode = OS.ExecuteCommand(XcodeHelper.FindXcodeTool("clang"), clangArgs);
+ if (clangExitCode != 0)
+ throw new Exception($"Command 'clang' exited with code: {clangExitCode}");
+
+ objFilePathsForiOSArch[arch].Add(objFilePath);
+ }
+
+ aotModuleInfoSymbols.Add($"mono_aot_module_{AssemblyNameToAotSymbol(assemblyName)}_info");
+ }
+
+ // Generate driver code
+ cppCode.AppendLine("#if defined(__arm__) || defined(__arm64__) || defined(__aarch64__)");
+ cppCode.AppendLine("#define IOS_DEVICE");
+ cppCode.AppendLine("#endif");
+
+ cppCode.AppendLine("#ifdef IOS_DEVICE");
+ cppCode.AppendLine("extern \"C\" {");
+ cppCode.AppendLine("// Mono API");
+ cppCode.AppendLine(@"
+typedef enum {
+MONO_AOT_MODE_NONE,
+MONO_AOT_MODE_NORMAL,
+MONO_AOT_MODE_HYBRID,
+MONO_AOT_MODE_FULL,
+MONO_AOT_MODE_LLVMONLY,
+MONO_AOT_MODE_INTERP,
+MONO_AOT_MODE_INTERP_LLVMONLY,
+MONO_AOT_MODE_LLVMONLY_INTERP,
+MONO_AOT_MODE_LAST = 1000,
+} MonoAotMode;");
+ cppCode.AppendLine("void mono_jit_set_aot_mode(MonoAotMode);");
+ cppCode.AppendLine("void mono_aot_register_module(void *);");
+
+ if (aotOpts.UseInterpreter)
+ {
+ cppCode.AppendLine("void mono_ee_interp_init(const char *);");
+ cppCode.AppendLine("void mono_icall_table_init();");
+ cppCode.AppendLine("void mono_marshal_ilgen_init();");
+ cppCode.AppendLine("void mono_method_builder_ilgen_init();");
+ cppCode.AppendLine("void mono_sgen_mono_ilgen_init();");
+ }
+
+ foreach (string symbol in aotModuleInfoSymbols)
+ cppCode.AppendLine($"extern void *{symbol};");
+
+ cppCode.AppendLine("void gd_mono_setup_aot() {");
+
+ foreach (string symbol in aotModuleInfoSymbols)
+ cppCode.AppendLine($"\tmono_aot_register_module({symbol});");
+
+ if (aotOpts.UseInterpreter)
+ {
+ cppCode.AppendLine("\tmono_icall_table_init();");
+ cppCode.AppendLine("\tmono_marshal_ilgen_init();");
+ cppCode.AppendLine("\tmono_method_builder_ilgen_init();");
+ cppCode.AppendLine("\tmono_sgen_mono_ilgen_init();");
+ cppCode.AppendLine("\tmono_ee_interp_init(0);");
+ }
+
+ string aotModeStr = null;
+
+ if (aotOpts.LLVMOnly)
+ {
+ aotModeStr = "MONO_AOT_MODE_LLVMONLY"; // --aot=llvmonly
+ }
+ else
+ {
+ if (aotOpts.UseInterpreter)
+ aotModeStr = "MONO_AOT_MODE_INTERP"; // --aot=interp or --aot=interp,full
+ else if (aotOpts.FullAot)
+ aotModeStr = "MONO_AOT_MODE_FULL"; // --aot=full
+ }
+
+ // One of the options above is always set for iOS
+ Debug.Assert(aotModeStr != null);
+
+ cppCode.AppendLine($"\tmono_jit_set_aot_mode({aotModeStr});");
+
+ cppCode.AppendLine("} // gd_mono_setup_aot");
+ cppCode.AppendLine("} // extern \"C\"");
+ cppCode.AppendLine("#endif // IOS_DEVICE");
+
+ // Add the driver code to the Xcode project
+ exporter.AddIosCppCode(cppCode.ToString());
+
+ // Archive the AOT object files into a static library
+
+ var arFilePathsForAllArchs = new List<string>();
+ string projectAssemblyName = GodotSharpEditor.ProjectAssemblyName;
+
+ foreach (var archPathsPair in objFilePathsForiOSArch)
+ {
+ string arch = archPathsPair.Key;
+ var objFilePaths = archPathsPair.Value;
+
+ string arOutputFilePath = Path.Combine(aotTempDir, $"lib-aot-{projectAssemblyName}.{arch}.a");
+
+ var arArgs = new List<string>()
+ {
+ "cr",
+ arOutputFilePath
+ };
+
+ foreach (string objFilePath in objFilePaths)
+ arArgs.Add(objFilePath);
+
+ int arExitCode = OS.ExecuteCommand(XcodeHelper.FindXcodeTool("ar"), arArgs);
+ if (arExitCode != 0)
+ throw new Exception($"Command 'ar' exited with code: {arExitCode}");
+
+ arFilePathsForAllArchs.Add(arOutputFilePath);
+ }
+
+ // It's lipo time
+
+ string fatOutputFileName = $"lib-aot-{projectAssemblyName}.fat.a";
+ string fatOutputFilePath = Path.Combine(aotTempDir, fatOutputFileName);
+
+ var lipoArgs = new List<string>();
+ lipoArgs.Add("-create");
+ lipoArgs.AddRange(arFilePathsForAllArchs);
+ lipoArgs.Add("-output");
+ lipoArgs.Add(fatOutputFilePath);
+
+ int lipoExitCode = OS.ExecuteCommand(XcodeHelper.FindXcodeTool("lipo"), lipoArgs);
+ if (lipoExitCode != 0)
+ throw new Exception($"Command 'lipo' exited with code: {lipoExitCode}");
+
+ // TODO: Add the AOT lib and interpreter libs as device only to supress warnings when targeting the simulator
+
+ // Add the fat AOT static library to the Xcode project
+ exporter.AddIosProjectStaticLib(fatOutputFilePath);
+
+ // Add the required Mono libraries to the Xcode project
+
+ string MonoLibFile(string libFileName) => libFileName + ".iphone.fat.a";
+
+ string MonoLibFromTemplate(string libFileName) =>
+ Path.Combine(Internal.FullTemplatesDir, "iphone-mono-libs", MonoLibFile(libFileName));
+
+ exporter.AddIosProjectStaticLib(MonoLibFromTemplate("libmonosgen-2.0"));
+
+ exporter.AddIosProjectStaticLib(MonoLibFromTemplate("libmono-native"));
+
+ if (aotOpts.UseInterpreter)
+ {
+ exporter.AddIosProjectStaticLib(MonoLibFromTemplate("libmono-ee-interp"));
+ exporter.AddIosProjectStaticLib(MonoLibFromTemplate("libmono-icall-table"));
+ exporter.AddIosProjectStaticLib(MonoLibFromTemplate("libmono-ilgen"));
+ }
+
+ // TODO: Turn into an exporter option
+ bool enableProfiling = false;
+ if (enableProfiling)
+ exporter.AddIosProjectStaticLib(MonoLibFromTemplate("libmono-profiler-log"));
+
+ // Add frameworks required by Mono to the Xcode project
+ exporter.AddIosFramework("libiconv.tbd");
+ exporter.AddIosFramework("GSS.framework");
+ exporter.AddIosFramework("CFNetwork.framework");
+
+ // Force load and export dynamic are needed for the linker to not strip required symbols.
+ // In theory we shouldn't be relying on this for P/Invoked functions (as is the case with
+ // functions in System.Native/libmono-native). Instead, we should use cecil to search for
+ // DllImports in assemblies and pass them to 'ld' as '-u/--undefined {pinvoke_symbol}'.
+ exporter.AddIosLinkerFlags("-rdynamic");
+ exporter.AddIosLinkerFlags($"-force_load \"$(SRCROOT)/{MonoLibFile("libmono-native")}\"");
+ }
+
+ /// Converts an assembly name to a valid symbol name in the same way the AOT compiler does
+ private static string AssemblyNameToAotSymbol(string assemblyName)
+ {
+ var builder = new StringBuilder();
+
+ foreach (var charByte in Encoding.UTF8.GetBytes(assemblyName))
+ {
+ char @char = (char)charByte;
+ builder.Append(Char.IsLetterOrDigit(@char) || @char == '_' ? @char : '_');
+ }
+
+ return builder.ToString();
+ }
+
+ private static IEnumerable<string> GetAotCompilerArgs(string platform, bool isDebug, string target, AotOptions aotOpts, string assemblyPath, string outputFilePath)
+ {
+ // TODO: LLVM
+
+ bool aotSoftDebug = isDebug && !aotOpts.EnableLLVM;
+ bool aotDwarfDebug = platform == OS.Platforms.iOS;
+
+ var aotOptions = new List<string>();
+ var optimizerOptions = new List<string>();
+
+ if (aotOpts.LLVMOnly)
+ {
+ aotOptions.Add("llvmonly");
+ }
+ else
+ {
+ // Can be both 'interp' and 'full'
+ if (aotOpts.UseInterpreter)
+ aotOptions.Add("interp");
+ if (aotOpts.FullAot)
+ aotOptions.Add("full");
+ }
+
+ aotOptions.Add(aotSoftDebug ? "soft-debug" : "nodebug");
+
+ if (aotDwarfDebug)
+ aotOptions.Add("dwarfdebug");
+
+ if (platform == OS.Platforms.Android)
+ {
+ string abi = target;
+
+ string androidToolchain = aotOpts.ToolchainPath;
+
+ if (string.IsNullOrEmpty(androidToolchain))
+ {
+ androidToolchain = Path.Combine(GodotSharpDirs.DataEditorToolsDir, "android-toolchains", $"{abi}"); // TODO: $"{abi}-{apiLevel}{(clang?"clang":"")}"
+
+ if (!Directory.Exists(androidToolchain))
+ throw new FileNotFoundException("Missing android toolchain. Specify one in the AOT export settings.");
+ }
+ else if (!Directory.Exists(androidToolchain))
+ {
+ throw new FileNotFoundException("Android toolchain not found: " + androidToolchain);
+ }
+
+ var androidToolPrefixes = new Dictionary<string, string>
+ {
+ ["armeabi-v7a"] = "arm-linux-androideabi-",
+ ["arm64-v8a"] = "aarch64-linux-android-",
+ ["x86"] = "i686-linux-android-",
+ ["x86_64"] = "x86_64-linux-android-"
+ };
+
+ aotOptions.Add("tool-prefix=" + Path.Combine(androidToolchain, "bin", androidToolPrefixes[abi]));
+
+ string triple = GetAndroidTriple(abi);
+ aotOptions.Add($"mtriple={triple}");
+ }
+ else if (platform == OS.Platforms.iOS)
+ {
+ if (!aotOpts.LLVMOnly && !aotOpts.UseInterpreter)
+ optimizerOptions.Add("gsharedvt");
+
+ aotOptions.Add("static");
+
+ // I couldn't get the Mono cross-compiler to do assembling, so we'll have to do it ourselves
+ aotOptions.Add("asmonly");
+
+ aotOptions.Add("direct-icalls");
+
+ if (aotSoftDebug)
+ aotOptions.Add("no-direct-calls");
+
+ if (aotOpts.LLVMOnly || !aotOpts.UseInterpreter)
+ aotOptions.Add("direct-pinvoke");
+
+ string arch = target;
+ aotOptions.Add($"mtriple={arch}-ios");
+ }
+
+ aotOptions.Add($"outfile={outputFilePath}");
+
+ if (aotOpts.EnableLLVM)
+ {
+ aotOptions.Add($"llvm-path={aotOpts.LLVMPath}");
+ aotOptions.Add($"llvm-outfile={aotOpts.LLVMOutputPath}");
+ }
+
+ if (aotOpts.ExtraAotOptions.Length > 0)
+ aotOptions.AddRange(aotOpts.ExtraAotOptions);
+
+ if (aotOpts.ExtraOptimizerOptions.Length > 0)
+ optimizerOptions.AddRange(aotOpts.ExtraOptimizerOptions);
+
+ string EscapeOption(string option) => option.Contains(',') ? $"\"{option}\"" : option;
+ string OptionsToString(IEnumerable<string> options) => string.Join(",", options.Select(EscapeOption));
+
+ var runtimeArgs = new List<string>();
+
+ // The '--debug' runtime option is required when using the 'soft-debug' and 'dwarfdebug' AOT options
+ if (aotSoftDebug || aotDwarfDebug)
+ runtimeArgs.Add("--debug");
+
+ if (aotOpts.EnableLLVM)
+ runtimeArgs.Add("--llvm");
+
+ runtimeArgs.Add(aotOptions.Count > 0 ? $"--aot={OptionsToString(aotOptions)}" : "--aot");
+
+ if (optimizerOptions.Count > 0)
+ runtimeArgs.Add($"-O={OptionsToString(optimizerOptions)}");
+
+ runtimeArgs.Add(assemblyPath);
+
+ return runtimeArgs;
+ }
+
+ private static void ExecuteCompiler(string compiler, IEnumerable<string> compilerArgs, string bclDir)
+ {
+ // TODO: Once we move to .NET Standard 2.1 we can use ProcessStartInfo.ArgumentList instead
+ string CmdLineArgsToString(IEnumerable<string> args)
+ {
+ // Not perfect, but as long as we are careful...
+ return string.Join(" ", args.Select(arg => arg.Contains(" ") ? $@"""{arg}""" : arg));
+ }
+
+ using (var process = new Process())
+ {
+ process.StartInfo = new ProcessStartInfo(compiler, CmdLineArgsToString(compilerArgs))
+ {
+ UseShellExecute = false
+ };
+
+ process.StartInfo.EnvironmentVariables.Remove("MONO_ENV_OPTIONS");
+ process.StartInfo.EnvironmentVariables.Remove("MONO_THREADS_SUSPEND");
+ process.StartInfo.EnvironmentVariables.Add("MONO_PATH", bclDir);
+
+ Console.WriteLine($"Running: \"{process.StartInfo.FileName}\" {process.StartInfo.Arguments}");
+
+ if (!process.Start())
+ throw new Exception("Failed to start process for Mono AOT compiler");
+
+ process.WaitForExit();
+
+ if (process.ExitCode != 0)
+ throw new Exception($"Mono AOT compiler exited with code: {process.ExitCode}");
+ }
+ }
+
+ private static IEnumerable<string> GetEnablediOSArchs(string[] features)
+ {
+ var iosArchs = new[]
+ {
+ "armv7",
+ "arm64"
+ };
+
+ return iosArchs.Where(features.Contains);
+ }
+
+ private static IEnumerable<string> GetEnabledAndroidAbis(string[] features)
+ {
+ var androidAbis = new[]
+ {
+ "armeabi-v7a",
+ "arm64-v8a",
+ "x86",
+ "x86_64"
+ };
+
+ return androidAbis.Where(features.Contains);
+ }
+
+ private static string GetAndroidTriple(string abi)
+ {
+ var abiArchs = new Dictionary<string, string>
+ {
+ ["armeabi-v7a"] = "armv7",
+ ["arm64-v8a"] = "aarch64-v8a",
+ ["x86"] = "i686",
+ ["x86_64"] = "x86_64"
+ };
+
+ string arch = abiArchs[abi];
+
+ return $"{arch}-linux-android";
+ }
+
+ private static string GetMonoCrossDesktopDirName(string platform, string bits)
+ {
+ switch (platform)
+ {
+ case OS.Platforms.Windows:
+ case OS.Platforms.UWP:
+ {
+ string arch = bits == "64" ? "x86_64" : "i686";
+ return $"windows-{arch}";
+ }
+ case OS.Platforms.OSX:
+ {
+ Debug.Assert(bits == null || bits == "64");
+ string arch = "x86_64";
+ return $"{platform}-{arch}";
+ }
+ case OS.Platforms.X11:
+ case OS.Platforms.Server:
+ {
+ string arch = bits == "64" ? "x86_64" : "i686";
+ return $"linux-{arch}";
+ }
+ case OS.Platforms.Haiku:
+ {
+ string arch = bits == "64" ? "x86_64" : "i686";
+ return $"{platform}-{arch}";
+ }
+ default:
+ throw new NotSupportedException($"Platform not supported: {platform}");
+ }
+ }
+
+ // TODO: Replace this for a specific path for each platform
+ private static string FindCrossCompiler(string monoCrossBin)
+ {
+ string exeExt = OS.IsWindows ? ".exe" : string.Empty;
+
+ var files = new DirectoryInfo(monoCrossBin).GetFiles($"*mono-sgen{exeExt}", SearchOption.TopDirectoryOnly);
+ if (files.Length > 0)
+ return Path.Combine(monoCrossBin, files[0].Name);
+
+ throw new FileNotFoundException($"Cannot find the mono runtime executable in {monoCrossBin}");
+ }
+ }
+}
diff --git a/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs b/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs
index 022005ad0b..2ceb4888a2 100644
--- a/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs
@@ -29,15 +29,13 @@ namespace GodotTools.Export
All = CJK | MidEast | Other | Rare | West
}
- private void AddI18NAssemblies(Godot.Collections.Dictionary<string, string> assemblies, string platform)
+ private void AddI18NAssemblies(Godot.Collections.Dictionary<string, string> assemblies, string bclDir)
{
- var codesets = (I18NCodesets) ProjectSettings.GetSetting("mono/export/i18n_codesets");
+ var codesets = (I18NCodesets)ProjectSettings.GetSetting("mono/export/i18n_codesets");
if (codesets == I18NCodesets.None)
return;
- string bclDir = DeterminePlatformBclDir(platform) ?? typeof(object).Assembly.Location.GetBaseDir();
-
void AddI18NAssembly(string name) => assemblies.Add(name, Path.Combine(bclDir, $"{name}.dll"));
AddI18NAssembly("I18N");
@@ -73,6 +71,7 @@ namespace GodotTools.Export
GlobalDef("mono/export/aot/enabled", false);
GlobalDef("mono/export/aot/full_aot", false);
+ GlobalDef("mono/export/aot/use_interpreter", true);
// --aot or --aot=opt1,opt2 (use 'mono --aot=help AuxAssembly.dll' to list AOT options)
GlobalDef("mono/export/aot/extra_aot_options", new string[] { });
@@ -86,9 +85,11 @@ namespace GodotTools.Export
private void AddFile(string srcPath, string dstPath, bool remap = false)
{
+ // Add file to the PCK
AddFile(dstPath.Replace("\\", "/"), File.ReadAllBytes(srcPath), remap);
}
+ // With this method we can override how a file is exported in the PCK
public override void _ExportFile(string path, string type, string[] features)
{
base._ExportFile(path, type, features);
@@ -110,6 +111,8 @@ namespace GodotTools.Export
// Sadly, Godot prints errors when adding an empty file (nothing goes wrong, it's just noise).
// Because of this, we add a file which contains a line break.
AddFile(path, System.Text.Encoding.UTF8.GetBytes("\n"), remap: false);
+
+ // Tell the Godot exporter that we already took care of the file
Skip();
}
}
@@ -165,18 +168,13 @@ namespace GodotTools.Export
// Add dependency assemblies
- var dependencies = new Godot.Collections.Dictionary<string, string>();
-
- var projectDllName = (string)ProjectSettings.GetSetting("application/config/name");
- if (projectDllName.Empty())
- {
- projectDllName = "UnnamedProject";
- }
+ var assemblies = new Godot.Collections.Dictionary<string, string>();
+ string projectDllName = GodotSharpEditor.ProjectAssemblyName;
string projectDllSrcDir = Path.Combine(GodotSharpDirs.ResTempAssembliesBaseDir, buildConfig);
string projectDllSrcPath = Path.Combine(projectDllSrcDir, $"{projectDllName}.dll");
- dependencies[projectDllName] = projectDllSrcPath;
+ assemblies[projectDllName] = projectDllSrcPath;
if (platform == OS.Platforms.Android)
{
@@ -186,13 +184,15 @@ namespace GodotTools.Export
if (!File.Exists(monoAndroidAssemblyPath))
throw new FileNotFoundException("Assembly not found: 'Mono.Android'", monoAndroidAssemblyPath);
- dependencies["Mono.Android"] = monoAndroidAssemblyPath;
+ assemblies["Mono.Android"] = monoAndroidAssemblyPath;
}
- var initialDependencies = dependencies.Duplicate();
- internal_GetExportedAssemblyDependencies(initialDependencies, buildConfig, DeterminePlatformBclDir(platform), dependencies);
+ string bclDir = DeterminePlatformBclDir(platform);
+
+ var initialAssemblies = assemblies.Duplicate();
+ internal_GetExportedAssemblyDependencies(initialAssemblies, buildConfig, bclDir, assemblies);
- AddI18NAssemblies(dependencies, platform);
+ AddI18NAssemblies(assemblies, bclDir);
string outputDataDir = null;
@@ -211,27 +211,62 @@ namespace GodotTools.Export
Directory.CreateDirectory(outputDataGameAssembliesDir);
}
- foreach (var dependency in dependencies)
+ foreach (var assembly in assemblies)
{
- string dependSrcPath = dependency.Value;
-
- if (assembliesInsidePck)
- {
- string dependDstPath = Path.Combine(resAssembliesDir, dependSrcPath.GetFile());
- AddFile(dependSrcPath, dependDstPath);
- }
- else
+ void AddToAssembliesDir(string fileSrcPath)
{
- string dependDstPath = Path.Combine(outputDataDir, "Assemblies", dependSrcPath.GetFile());
- File.Copy(dependSrcPath, dependDstPath);
+ if (assembliesInsidePck)
+ {
+ string fileDstPath = Path.Combine(resAssembliesDir, fileSrcPath.GetFile());
+ AddFile(fileSrcPath, fileDstPath);
+ }
+ else
+ {
+ Debug.Assert(outputDataDir != null);
+ string fileDstPath = Path.Combine(outputDataDir, "Assemblies", fileSrcPath.GetFile());
+ File.Copy(fileSrcPath, fileDstPath);
+ }
}
+
+ string assemblySrcPath = assembly.Value;
+
+ string assemblyPathWithoutExtension = Path.ChangeExtension(assemblySrcPath, null);
+ string pdbSrcPath = assemblyPathWithoutExtension + ".pdb";
+
+ AddToAssembliesDir(assemblySrcPath);
+
+ if (File.Exists(pdbSrcPath))
+ AddToAssembliesDir(pdbSrcPath);
}
- // AOT
+ // AOT compilation
+ bool aotEnabled = platform == OS.Platforms.iOS || (bool)ProjectSettings.GetSetting("mono/export/aot/enabled");
- if ((bool)ProjectSettings.GetSetting("mono/export/aot/enabled"))
+ if (aotEnabled)
{
- AotCompileDependencies(features, platform, isDebug, outputDir, outputDataDir, dependencies);
+ string aotToolchainPath = null;
+
+ if (platform == OS.Platforms.Android)
+ aotToolchainPath = (string)ProjectSettings.GetSetting("mono/export/aot/android_toolchain_path");
+
+ if (aotToolchainPath == string.Empty)
+ aotToolchainPath = null; // Don't risk it being used as current working dir
+
+ // TODO: LLVM settings are hard-coded and disabled for now
+ var aotOpts = new AotOptions
+ {
+ EnableLLVM = false,
+ LLVMOnly = false,
+ LLVMPath = "",
+ LLVMOutputPath = "",
+ FullAot = platform == OS.Platforms.iOS || (bool)(ProjectSettings.GetSetting("mono/export/aot/full_aot") ?? false),
+ UseInterpreter = (bool)ProjectSettings.GetSetting("mono/export/aot/use_interpreter"),
+ ExtraAotOptions = (string[])ProjectSettings.GetSetting("mono/export/aot/extra_aot_options") ?? new string[] { },
+ ExtraOptimizerOptions = (string[])ProjectSettings.GetSetting("mono/export/aot/extra_optimizer_options") ?? new string[] { },
+ ToolchainPath = aotToolchainPath
+ };
+
+ AotBuilder.CompileAssemblies(this, aotOpts, features, platform, isDebug, bclDir, outputDir, outputDataDir, assemblies);
}
}
@@ -258,7 +293,8 @@ namespace GodotTools.Export
{
string target = isDebug ? "release_debug" : "release";
- // NOTE: Bits is ok for now as all platforms with a data directory have it, but that may change in the future.
+ // NOTE: Bits is ok for now as all platforms with a data directory only have one or two architectures.
+ // However, this may change in the future if we add arm linux or windows desktop templates.
string bits = features.Contains("64") ? "64" : "32";
string TemplateDirName() => $"data.mono.{platform}.{bits}.{target}";
@@ -284,7 +320,7 @@ namespace GodotTools.Export
if (!validTemplatePathFound)
throw new FileNotFoundException("Data template directory not found", templateDirPath);
- string outputDataDir = Path.Combine(outputDir, DataDirName);
+ string outputDataDir = Path.Combine(outputDir, DetermineDataDirNameForProject());
if (Directory.Exists(outputDataDir))
Directory.Delete(outputDataDir, recursive: true); // Clean first
@@ -304,333 +340,10 @@ namespace GodotTools.Export
return outputDataDir;
}
- private void AotCompileDependencies(string[] features, string platform, bool isDebug, string outputDir, string outputDataDir, IDictionary<string, string> dependencies)
- {
- // TODO: WASM
-
- string bclDir = DeterminePlatformBclDir(platform) ?? typeof(object).Assembly.Location.GetBaseDir();
-
- string aotTempDir = Path.Combine(Path.GetTempPath(), $"godot-aot-{Process.GetCurrentProcess().Id}");
-
- if (!Directory.Exists(aotTempDir))
- Directory.CreateDirectory(aotTempDir);
-
- var assemblies = new Dictionary<string, string>();
-
- foreach (var dependency in dependencies)
- {
- string assemblyName = dependency.Key;
- string assemblyPath = dependency.Value;
-
- string assemblyPathInBcl = Path.Combine(bclDir, assemblyName + ".dll");
-
- if (File.Exists(assemblyPathInBcl))
- {
- // Don't create teporaries for assemblies from the BCL
- assemblies.Add(assemblyName, assemblyPathInBcl);
- }
- else
- {
- string tempAssemblyPath = Path.Combine(aotTempDir, assemblyName + ".dll");
- File.Copy(assemblyPath, tempAssemblyPath);
- assemblies.Add(assemblyName, tempAssemblyPath);
- }
- }
-
- foreach (var assembly in assemblies)
- {
- string assemblyName = assembly.Key;
- string assemblyPath = assembly.Value;
-
- string sharedLibExtension = platform == OS.Platforms.Windows ? ".dll" :
- platform == OS.Platforms.OSX ? ".dylib" :
- platform == OS.Platforms.HTML5 ? ".wasm" :
- ".so";
-
- string outputFileName = assemblyName + ".dll" + sharedLibExtension;
-
- if (platform == OS.Platforms.Android)
- {
- // Not sure if the 'lib' prefix is an Android thing or just Godot being picky,
- // but we use '-aot-' as well just in case to avoid conflicts with other libs.
- outputFileName = "lib-aot-" + outputFileName;
- }
-
- string outputFilePath = null;
- string tempOutputFilePath;
-
- switch (platform)
- {
- case OS.Platforms.OSX:
- tempOutputFilePath = Path.Combine(aotTempDir, outputFileName);
- break;
- case OS.Platforms.Android:
- tempOutputFilePath = Path.Combine(aotTempDir, "%%ANDROID_ABI%%", outputFileName);
- break;
- case OS.Platforms.HTML5:
- tempOutputFilePath = Path.Combine(aotTempDir, outputFileName);
- outputFilePath = Path.Combine(outputDir, outputFileName);
- break;
- default:
- tempOutputFilePath = Path.Combine(aotTempDir, outputFileName);
- outputFilePath = Path.Combine(outputDataDir, "Mono", platform == OS.Platforms.Windows ? "bin" : "lib", outputFileName);
- break;
- }
-
- var data = new Dictionary<string, string>();
- var enabledAndroidAbis = platform == OS.Platforms.Android ? GetEnabledAndroidAbis(features).ToArray() : null;
-
- if (platform == OS.Platforms.Android)
- {
- Debug.Assert(enabledAndroidAbis != null);
-
- foreach (var abi in enabledAndroidAbis)
- {
- data["abi"] = abi;
- var outputFilePathForThisAbi = tempOutputFilePath.Replace("%%ANDROID_ABI%%", abi);
-
- AotCompileAssembly(platform, isDebug, data, assemblyPath, outputFilePathForThisAbi);
-
- AddSharedObject(outputFilePathForThisAbi, tags: new[] { abi });
- }
- }
- else
- {
- string bits = features.Contains("64") ? "64" : features.Contains("64") ? "32" : null;
-
- if (bits != null)
- data["bits"] = bits;
-
- AotCompileAssembly(platform, isDebug, data, assemblyPath, tempOutputFilePath);
-
- if (platform == OS.Platforms.OSX)
- {
- AddSharedObject(tempOutputFilePath, tags: null);
- }
- else
- {
- Debug.Assert(outputFilePath != null);
- File.Copy(tempOutputFilePath, outputFilePath);
- }
- }
- }
- }
-
- private static void AotCompileAssembly(string platform, bool isDebug, Dictionary<string, string> data, string assemblyPath, string outputFilePath)
- {
- // Make sure the output directory exists
- Directory.CreateDirectory(outputFilePath.GetBaseDir());
-
- string exeExt = OS.IsWindows ? ".exe" : string.Empty;
-
- string monoCrossDirName = DetermineMonoCrossDirName(platform, data);
- string monoCrossRoot = Path.Combine(GodotSharpDirs.DataEditorToolsDir, "aot-compilers", monoCrossDirName);
- string monoCrossBin = Path.Combine(monoCrossRoot, "bin");
-
- string toolPrefix = DetermineToolPrefix(monoCrossBin);
- string monoExeName = System.IO.File.Exists(Path.Combine(monoCrossBin, $"{toolPrefix}mono{exeExt}")) ? "mono" : "mono-sgen";
-
- string compilerCommand = Path.Combine(monoCrossBin, $"{toolPrefix}{monoExeName}{exeExt}");
-
- bool fullAot = (bool)ProjectSettings.GetSetting("mono/export/aot/full_aot");
-
- string EscapeOption(string option) => option.Contains(',') ? $"\"{option}\"" : option;
- string OptionsToString(IEnumerable<string> options) => string.Join(",", options.Select(EscapeOption));
-
- var aotOptions = new List<string>();
- var optimizerOptions = new List<string>();
-
- if (fullAot)
- aotOptions.Add("full");
-
- aotOptions.Add(isDebug ? "soft-debug" : "nodebug");
-
- if (platform == OS.Platforms.Android)
- {
- string abi = data["abi"];
-
- string androidToolchain = (string)ProjectSettings.GetSetting("mono/export/aot/android_toolchain_path");
-
- if (string.IsNullOrEmpty(androidToolchain))
- {
- androidToolchain = Path.Combine(GodotSharpDirs.DataEditorToolsDir, "android-toolchains", $"{abi}"); // TODO: $"{abi}-{apiLevel}{(clang?"clang":"")}"
-
- if (!Directory.Exists(androidToolchain))
- throw new FileNotFoundException("Missing android toolchain. Specify one in the AOT export settings.");
- }
- else if (!Directory.Exists(androidToolchain))
- {
- throw new FileNotFoundException("Android toolchain not found: " + androidToolchain);
- }
-
- var androidToolPrefixes = new Dictionary<string, string>
- {
- ["armeabi-v7a"] = "arm-linux-androideabi-",
- ["arm64-v8a"] = "aarch64-linux-android-",
- ["x86"] = "i686-linux-android-",
- ["x86_64"] = "x86_64-linux-android-"
- };
-
- aotOptions.Add("tool-prefix=" + Path.Combine(androidToolchain, "bin", androidToolPrefixes[abi]));
-
- string triple = GetAndroidTriple(abi);
- aotOptions.Add($"mtriple={triple}");
- }
-
- aotOptions.Add($"outfile={outputFilePath}");
-
- var extraAotOptions = (string[])ProjectSettings.GetSetting("mono/export/aot/extra_aot_options");
- var extraOptimizerOptions = (string[])ProjectSettings.GetSetting("mono/export/aot/extra_optimizer_options");
-
- if (extraAotOptions.Length > 0)
- aotOptions.AddRange(extraAotOptions);
-
- if (extraOptimizerOptions.Length > 0)
- optimizerOptions.AddRange(extraOptimizerOptions);
-
- var compilerArgs = new List<string>();
-
- if (isDebug)
- compilerArgs.Add("--debug"); // Required for --aot=soft-debug
-
- compilerArgs.Add(aotOptions.Count > 0 ? $"--aot={OptionsToString(aotOptions)}" : "--aot");
-
- if (optimizerOptions.Count > 0)
- compilerArgs.Add($"-O={OptionsToString(optimizerOptions)}");
-
- compilerArgs.Add(ProjectSettings.GlobalizePath(assemblyPath));
-
- // TODO: Once we move to .NET Standard 2.1 we can use ProcessStartInfo.ArgumentList instead
- string CmdLineArgsToString(IEnumerable<string> args)
- {
- // Not perfect, but as long as we are careful...
- return string.Join(" ", args.Select(arg => arg.Contains(" ") ? $@"""{arg}""" : arg));
- }
-
- using (var process = new Process())
- {
- process.StartInfo = new ProcessStartInfo(compilerCommand, CmdLineArgsToString(compilerArgs))
- {
- UseShellExecute = false
- };
-
- string platformBclDir = DeterminePlatformBclDir(platform);
- process.StartInfo.EnvironmentVariables.Add("MONO_PATH", string.IsNullOrEmpty(platformBclDir) ?
- typeof(object).Assembly.Location.GetBaseDir() :
- platformBclDir);
-
- Console.WriteLine($"Running: \"{process.StartInfo.FileName}\" {process.StartInfo.Arguments}");
-
- if (!process.Start())
- throw new Exception("Failed to start process for Mono AOT compiler");
-
- process.WaitForExit();
-
- if (process.ExitCode != 0)
- throw new Exception($"Mono AOT compiler exited with error code: {process.ExitCode}");
-
- if (!System.IO.File.Exists(outputFilePath))
- throw new Exception("Mono AOT compiler finished successfully but the output file is missing");
- }
- }
-
- private static string DetermineMonoCrossDirName(string platform, IReadOnlyDictionary<string, string> data)
- {
- switch (platform)
- {
- case OS.Platforms.Windows:
- case OS.Platforms.UWP:
- {
- string arch = data["bits"] == "64" ? "x86_64" : "i686";
- return $"windows-{arch}";
- }
- case OS.Platforms.OSX:
- {
- string arch = "x86_64";
- return $"{platform}-{arch}";
- }
- case OS.Platforms.X11:
- case OS.Platforms.Server:
- {
- string arch = data["bits"] == "64" ? "x86_64" : "i686";
- return $"linux-{arch}";
- }
- case OS.Platforms.Haiku:
- {
- string arch = data["bits"] == "64" ? "x86_64" : "i686";
- return $"{platform}-{arch}";
- }
- case OS.Platforms.Android:
- {
- string abi = data["abi"];
- return $"{platform}-{abi}";
- }
- case OS.Platforms.HTML5:
- return "wasm-wasm32";
- default:
- throw new NotSupportedException($"Platform not supported: {platform}");
- }
- }
-
- private static string DetermineToolPrefix(string monoCrossBin)
- {
- string exeExt = OS.IsWindows ? ".exe" : string.Empty;
-
- if (System.IO.File.Exists(Path.Combine(monoCrossBin, $"mono{exeExt}")))
- return string.Empty;
-
- if (System.IO.File.Exists(Path.Combine(monoCrossBin, $"mono-sgen{exeExt}" + exeExt)))
- return string.Empty;
-
- var files = new DirectoryInfo(monoCrossBin).GetFiles($"*mono{exeExt}" + exeExt, SearchOption.TopDirectoryOnly);
- if (files.Length > 0)
- {
- string fileName = files[0].Name;
- return fileName.Substring(0, fileName.Length - $"mono{exeExt}".Length);
- }
-
- files = new DirectoryInfo(monoCrossBin).GetFiles($"*mono-sgen{exeExt}" + exeExt, SearchOption.TopDirectoryOnly);
- if (files.Length > 0)
- {
- string fileName = files[0].Name;
- return fileName.Substring(0, fileName.Length - $"mono-sgen{exeExt}".Length);
- }
-
- throw new FileNotFoundException($"Cannot find the mono runtime executable in {monoCrossBin}");
- }
-
- private static IEnumerable<string> GetEnabledAndroidAbis(string[] features)
- {
- var androidAbis = new[]
- {
- "armeabi-v7a",
- "arm64-v8a",
- "x86",
- "x86_64"
- };
-
- return androidAbis.Where(features.Contains);
- }
-
- private static string GetAndroidTriple(string abi)
- {
- var abiArchs = new Dictionary<string, string>
- {
- ["armeabi-v7a"] = "armv7",
- ["arm64-v8a"] = "aarch64-v8a",
- ["x86"] = "i686",
- ["x86_64"] = "x86_64"
- };
-
- string arch = abiArchs[abi];
-
- return $"{arch}-linux-android";
- }
-
private static bool PlatformHasTemplateDir(string platform)
{
// OSX export templates are contained in a zip, so we place our custom template inside it and let Godot do the rest.
- return !new[] { OS.Platforms.OSX, OS.Platforms.Android, OS.Platforms.HTML5 }.Contains(platform);
+ return !new[] { OS.Platforms.OSX, OS.Platforms.Android, OS.Platforms.iOS, OS.Platforms.HTML5 }.Contains(platform);
}
private static string DeterminePlatformFromFeatures(IEnumerable<string> features)
@@ -665,7 +378,7 @@ namespace GodotTools.Export
if (PlatformRequiresCustomBcl(platform))
throw new FileNotFoundException($"Missing BCL (Base Class Library) for platform: {platform}");
- platformBclDir = null; // Use the one we're running on
+ platformBclDir = typeof(object).Assembly.Location.GetBaseDir(); // Use the one we're running on
}
}
@@ -678,7 +391,7 @@ namespace GodotTools.Export
/// </summary>
private static bool PlatformRequiresCustomBcl(string platform)
{
- if (new[] { OS.Platforms.Android, OS.Platforms.HTML5 }.Contains(platform))
+ if (new[] { OS.Platforms.Android, OS.Platforms.iOS, OS.Platforms.HTML5 }.Contains(platform))
return true;
// The 'net_4_x' BCL is not compatible between Windows and the other platforms.
@@ -707,6 +420,8 @@ namespace GodotTools.Export
return "net_4_x";
case OS.Platforms.Android:
return "monodroid";
+ case OS.Platforms.iOS:
+ return "monotouch";
case OS.Platforms.HTML5:
return "wasm";
default:
@@ -714,18 +429,15 @@ namespace GodotTools.Export
}
}
- private static string DataDirName
+ private static string DetermineDataDirNameForProject()
{
- get
- {
- var appName = (string)ProjectSettings.GetSetting("application/config/name");
- string appNameSafe = appName.ToSafeDirName(allowDirSeparator: false);
- return $"data_{appNameSafe}";
- }
+ var appName = (string)ProjectSettings.GetSetting("application/config/name");
+ string appNameSafe = appName.ToSafeDirName(allowDirSeparator: false);
+ return $"data_{appNameSafe}";
}
[MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void internal_GetExportedAssemblyDependencies(Godot.Collections.Dictionary<string, string> initialDependencies,
- string buildConfig, string customBclDir, Godot.Collections.Dictionary<string, string> dependencies);
+ private static extern void internal_GetExportedAssemblyDependencies(Godot.Collections.Dictionary<string, string> initialAssemblies,
+ string buildConfig, string customBclDir, Godot.Collections.Dictionary<string, string> dependencyAssemblies);
}
}
diff --git a/modules/mono/editor/GodotTools/GodotTools/Export/XcodeHelper.cs b/modules/mono/editor/GodotTools/GodotTools/Export/XcodeHelper.cs
new file mode 100755
index 0000000000..219b7a698a
--- /dev/null
+++ b/modules/mono/editor/GodotTools/GodotTools/Export/XcodeHelper.cs
@@ -0,0 +1,93 @@
+using System;
+using System.IO;
+
+namespace GodotTools.Export
+{
+ public static class XcodeHelper
+ {
+ private static string _XcodePath = null;
+
+ public static string XcodePath
+ {
+ get
+ {
+ if (_XcodePath == null)
+ {
+ _XcodePath = FindXcode();
+
+ if (_XcodePath == null)
+ throw new Exception("Could not find Xcode");
+ }
+
+ return _XcodePath;
+ }
+ }
+
+ private static string FindSelectedXcode()
+ {
+ var outputWrapper = new Godot.Collections.Array();
+
+ int exitCode = Godot.OS.Execute("xcode-select", new string[] { "--print-path" }, blocking: true, output: outputWrapper);
+
+ if (exitCode == 0)
+ {
+ string output = (string)outputWrapper[0];
+ return output.Trim();
+ }
+
+ Console.Error.WriteLine($"'xcode-select --print-path' exited with code: {exitCode}");
+
+ return null;
+ }
+
+ public static string FindXcode()
+ {
+ string selectedXcode = FindSelectedXcode();
+ if (selectedXcode != null)
+ {
+ if (Directory.Exists(Path.Combine(selectedXcode, "Contents", "Developer")))
+ return selectedXcode;
+
+ // The path already pointed to Contents/Developer
+ var dirInfo = new DirectoryInfo(selectedXcode);
+ if (dirInfo.Name != "Developer" || dirInfo.Parent.Name != "Contents")
+ {
+ Console.WriteLine(Path.GetDirectoryName(selectedXcode));
+ Console.WriteLine(System.IO.Directory.GetParent(selectedXcode).Name);
+ Console.Error.WriteLine("Unrecognized path for selected Xcode");
+ }
+ else
+ {
+ return System.IO.Path.GetFullPath($"{selectedXcode}/../..");
+ }
+ }
+ else
+ {
+ Console.Error.WriteLine("Could not find the selected Xcode; trying with a hint path");
+ }
+
+ const string XcodeHintPath = "/Applications/Xcode.app";
+
+ if (Directory.Exists(XcodeHintPath))
+ {
+ if (Directory.Exists(Path.Combine(XcodeHintPath, "Contents", "Developer")))
+ return XcodeHintPath;
+
+ Console.Error.WriteLine($"Found Xcode at '{XcodeHintPath}' but it's missing the 'Contents/Developer' sub-directory");
+ }
+
+ return null;
+ }
+
+ public static string FindXcodeTool(string toolName)
+ {
+ string XcodeDefaultToolchain = Path.Combine(XcodePath, "Contents", "Developer", "Toolchains", "XcodeDefault.xctoolchain");
+
+ string path = Path.Combine(XcodeDefaultToolchain, "usr", "bin", toolName);
+ if (File.Exists(path))
+ return path;
+
+ throw new FileNotFoundException($"Cannot find Xcode tool: {toolName}");
+ }
+ }
+}
diff --git a/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs b/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs
index e6d5dd9895..c070cb16d9 100644
--- a/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs
@@ -1,4 +1,5 @@
using Godot;
+using GodotTools.Core;
using GodotTools.Export;
using GodotTools.Utils;
using System;
@@ -36,6 +37,17 @@ namespace GodotTools
public BottomPanel BottomPanel { get; private set; }
+ public static string ProjectAssemblyName
+ {
+ get
+ {
+ var projectAssemblyName = (string)ProjectSettings.GetSetting("application/config/name");
+ if (string.IsNullOrEmpty(projectAssemblyName))
+ projectAssemblyName = "UnnamedProject";
+ return projectAssemblyName;
+ }
+ }
+
private bool CreateProjectSolution()
{
using (var pr = new EditorProgress("create_csharp_solution", "Generating solution...".TTR(), 3))
@@ -45,9 +57,7 @@ namespace GodotTools
string resourceDir = ProjectSettings.GlobalizePath("res://");
string path = resourceDir;
- string name = (string)ProjectSettings.GetSetting("application/config/name");
- if (name.Empty())
- name = "UnnamedProject";
+ string name = ProjectAssemblyName;
string guid = CsProjOperations.GenerateGameProject(path, name);
@@ -119,7 +129,7 @@ namespace GodotTools
{
bool showOnStart = (bool)editorSettings.GetSetting("mono/editor/show_info_on_start");
aboutDialogCheckBox.Pressed = showOnStart;
- aboutDialog.PopupCenteredMinsize();
+ aboutDialog.PopupCentered();
}
private void _MenuOptionPressed(int id)
@@ -157,10 +167,10 @@ namespace GodotTools
bool showInfoDialog = (bool)editorSettings.GetSetting("mono/editor/show_info_on_start");
if (showInfoDialog)
{
- aboutDialog.PopupExclusive = true;
+ aboutDialog.Exclusive = true;
_ShowAboutDialog();
// Once shown a first time, it can be seen again via the Mono menu - it doesn't have to be exclusive from that time on.
- aboutDialog.PopupExclusive = false;
+ aboutDialog.Exclusive = false;
}
var fileSystemDock = GetEditorInterface().GetFileSystemDock();
@@ -203,9 +213,9 @@ namespace GodotTools
public void ShowErrorDialog(string message, string title = "Error")
{
- errorDialog.WindowTitle = title;
+ errorDialog.Title = title;
errorDialog.DialogText = message;
- errorDialog.PopupCenteredMinsize();
+ errorDialog.PopupCentered();
}
private static string _vsCodePath = string.Empty;
@@ -374,7 +384,6 @@ namespace GodotTools
menuPopup = new PopupMenu();
menuPopup.Hide();
- menuPopup.SetAsToplevel(true);
AddToolSubmenuItem("Mono", menuPopup);
@@ -383,7 +392,7 @@ namespace GodotTools
menuPopup.AddItem("About C# support".TTR(), (int)MenuOptions.AboutCSharp);
aboutDialog = new AcceptDialog();
editorBaseControl.AddChild(aboutDialog);
- aboutDialog.WindowTitle = "Important: C# support is not feature-complete";
+ aboutDialog.Title = "Important: C# support is not feature-complete";
// We don't use DialogText as the default AcceptDialog Label doesn't play well with the TextureRect and CheckBox
// we'll add. Instead we add containers and a new autowrapped Label inside.
@@ -397,7 +406,7 @@ namespace GodotTools
aboutVBox.AddChild(aboutHBox);
var aboutIcon = new TextureRect();
- aboutIcon.Texture = aboutIcon.GetIcon("NodeWarning", "EditorIcons");
+ aboutIcon.Texture = aboutIcon.GetThemeIcon("NodeWarning", "EditorIcons");
aboutHBox.AddChild(aboutIcon);
var aboutLabel = new Label();
@@ -434,13 +443,27 @@ namespace GodotTools
{
// Migrate solution from old configuration names to: Debug, ExportDebug and ExportRelease
DotNetSolution.MigrateFromOldConfigNames(GodotSharpDirs.ProjectSlnPath);
+
+ var msbuildProject = ProjectUtils.Open(GodotSharpDirs.ProjectCsProjPath)
+ ?? throw new Exception("Cannot open C# project");
+
+ // NOTE: The order in which changes are made to the project is important
+
// Migrate csproj from old configuration names to: Debug, ExportDebug and ExportRelease
- ProjectUtils.MigrateFromOldConfigNames(GodotSharpDirs.ProjectCsProjPath);
+ ProjectUtils.MigrateFromOldConfigNames(msbuildProject);
- // Apply the other fixes after configurations are migrated
+ // Apply the other fixes only after configurations have been migrated
// Make sure the existing project has Api assembly references configured correctly
- ProjectUtils.FixApiHintPath(GodotSharpDirs.ProjectCsProjPath);
+ ProjectUtils.FixApiHintPath(msbuildProject);
+
+ if (msbuildProject.HasUnsavedChanges)
+ {
+ // Save a copy of the project before replacing it
+ FileUtils.SaveBackupCopy(GodotSharpDirs.ProjectCsProjPath);
+
+ msbuildProject.Save();
+ }
}
catch (Exception e)
{
diff --git a/modules/mono/editor/GodotTools/GodotTools/GodotTools.csproj b/modules/mono/editor/GodotTools/GodotTools/GodotTools.csproj
index 379dfd9f7d..ac9379adf8 100644
--- a/modules/mono/editor/GodotTools/GodotTools/GodotTools.csproj
+++ b/modules/mono/editor/GodotTools/GodotTools/GodotTools.csproj
@@ -51,7 +51,9 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Build\MsBuildFinder.cs" />
+ <Compile Include="Export\AotBuilder.cs" />
<Compile Include="Export\ExportPlugin.cs" />
+ <Compile Include="Export\XcodeHelper.cs" />
<Compile Include="ExternalEditorId.cs" />
<Compile Include="Ides\GodotIdeManager.cs" />
<Compile Include="Ides\GodotIdeServer.cs" />
diff --git a/modules/mono/editor/GodotTools/GodotTools/HotReloadAssemblyWatcher.cs b/modules/mono/editor/GodotTools/GodotTools/HotReloadAssemblyWatcher.cs
index 1d19fab706..ae05710f4f 100644
--- a/modules/mono/editor/GodotTools/GodotTools/HotReloadAssemblyWatcher.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/HotReloadAssemblyWatcher.cs
@@ -10,7 +10,7 @@ namespace GodotTools
public override void _Notification(int what)
{
- if (what == MainLoop.NotificationWmFocusIn)
+ if (what == Node.NotificationWmFocusIn)
{
RestartTimer();
diff --git a/modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs b/modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs
index 279e67b3eb..b057ac12c6 100644
--- a/modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs
@@ -5,6 +5,7 @@ using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
+using JetBrains.Annotations;
namespace GodotTools.Utils
{
@@ -26,6 +27,7 @@ namespace GodotTools.Utils
public const string UWP = "UWP";
public const string Haiku = "Haiku";
public const string Android = "Android";
+ public const string iOS = "iOS";
public const string HTML5 = "HTML5";
}
@@ -33,11 +35,12 @@ namespace GodotTools.Utils
{
public const string Windows = "windows";
public const string OSX = "osx";
- public const string X11 = "x11";
+ public const string X11 = "linuxbsd";
public const string Server = "server";
public const string UWP = "uwp";
public const string Haiku = "haiku";
public const string Android = "android";
+ public const string iOS = "iphone";
public const string HTML5 = "javascript";
}
@@ -50,6 +53,7 @@ namespace GodotTools.Utils
[Names.UWP] = Platforms.UWP,
[Names.Haiku] = Platforms.Haiku,
[Names.Android] = Platforms.Android,
+ [Names.iOS] = Platforms.iOS,
[Names.HTML5] = Platforms.HTML5
};
@@ -65,6 +69,7 @@ namespace GodotTools.Utils
private static readonly Lazy<bool> _isUWP = new Lazy<bool>(() => IsOS(Names.UWP));
private static readonly Lazy<bool> _isHaiku = new Lazy<bool>(() => IsOS(Names.Haiku));
private static readonly Lazy<bool> _isAndroid = new Lazy<bool>(() => IsOS(Names.Android));
+ private static readonly Lazy<bool> _isiOS = new Lazy<bool>(() => IsOS(Names.iOS));
private static readonly Lazy<bool> _isHTML5 = new Lazy<bool>(() => IsOS(Names.HTML5));
public static bool IsWindows => _isWindows.Value || IsUWP;
@@ -74,10 +79,11 @@ namespace GodotTools.Utils
public static bool IsUWP => _isUWP.Value;
public static bool IsHaiku => _isHaiku.Value;
public static bool IsAndroid => _isAndroid.Value;
+ public static bool IsiOS => _isiOS.Value;
public static bool IsHTML5 => _isHTML5.Value;
private static bool? _isUnixCache;
- private static readonly string[] UnixLikePlatforms = { Names.OSX, Names.X11, Names.Server, Names.Haiku, Names.Android };
+ private static readonly string[] UnixLikePlatforms = { Names.OSX, Names.X11, Names.Server, Names.Haiku, Names.Android, Names.iOS };
public static bool IsUnixLike()
{
@@ -91,12 +97,12 @@ namespace GodotTools.Utils
public static char PathSep => IsWindows ? ';' : ':';
- public static string PathWhich(string name)
+ public static string PathWhich([NotNull] string name)
{
return IsWindows ? PathWhichWindows(name) : PathWhichUnix(name);
}
- private static string PathWhichWindows(string name)
+ private static string PathWhichWindows([NotNull] string name)
{
string[] windowsExts = Environment.GetEnvironmentVariable("PATHEXT")?.Split(PathSep) ?? new string[] { };
string[] pathDirs = Environment.GetEnvironmentVariable("PATH")?.Split(PathSep);
@@ -121,7 +127,7 @@ namespace GodotTools.Utils
select path + ext).FirstOrDefault(File.Exists);
}
- private static string PathWhichUnix(string name)
+ private static string PathWhichUnix([NotNull] string name)
{
string[] pathDirs = Environment.GetEnvironmentVariable("PATH")?.Split(PathSep);
@@ -163,5 +169,33 @@ namespace GodotTools.Utils
User32Dll.AllowSetForegroundWindow(process.Id); // allows application to focus itself
}
}
+
+ public static int ExecuteCommand(string command, IEnumerable<string> arguments)
+ {
+ // TODO: Once we move to .NET Standard 2.1 we can use ProcessStartInfo.ArgumentList instead
+ string CmdLineArgsToString(IEnumerable<string> args)
+ {
+ // Not perfect, but as long as we are careful...
+ return string.Join(" ", args.Select(arg => arg.Contains(" ") ? $@"""{arg}""" : arg));
+ }
+
+ var startInfo = new ProcessStartInfo(command, CmdLineArgsToString(arguments));
+
+ Console.WriteLine($"Executing: \"{startInfo.FileName}\" {startInfo.Arguments}");
+
+ // Print the output
+ startInfo.RedirectStandardOutput = false;
+ startInfo.RedirectStandardError = false;
+
+ startInfo.UseShellExecute = false;
+
+ using (var process = new Process { StartInfo = startInfo })
+ {
+ process.Start();
+ process.WaitForExit();
+
+ return process.ExitCode;
+ }
+ }
}
}
diff --git a/modules/mono/editor/bindings_generator.cpp b/modules/mono/editor/bindings_generator.cpp
index 9a5de6db16..ee92a6234a 100644
--- a/modules/mono/editor/bindings_generator.cpp
+++ b/modules/mono/editor/bindings_generator.cpp
@@ -411,7 +411,7 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf
xml_output.append("\"/>");
} else {
// Try to find as global enum constant
- const EnumInterface *target_ienum = NULL;
+ const EnumInterface *target_ienum = nullptr;
for (const List<EnumInterface>::Element *E = global_enums.front(); E; E = E->next()) {
target_ienum = &E->get();
@@ -449,7 +449,7 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf
xml_output.append("\"/>");
} else {
// Try to find as enum constant in the current class
- const EnumInterface *target_ienum = NULL;
+ const EnumInterface *target_ienum = nullptr;
for (const List<EnumInterface>::Element *E = target_itype->enums.front(); E; E = E->next()) {
target_ienum = &E->get();
@@ -782,7 +782,7 @@ void BindingsGenerator::_generate_global_constants(StringBuilder &p_output) {
const ConstantInterface &iconstant = E->get();
if (iconstant.const_doc && iconstant.const_doc->description.size()) {
- String xml_summary = bbcode_to_xml(fix_doc_description(iconstant.const_doc->description), NULL);
+ String xml_summary = bbcode_to_xml(fix_doc_description(iconstant.const_doc->description), nullptr);
Vector<String> summary_lines = xml_summary.length() ? xml_summary.split("\n") : Vector<String>();
if (summary_lines.size()) {
@@ -843,7 +843,7 @@ void BindingsGenerator::_generate_global_constants(StringBuilder &p_output) {
const ConstantInterface &iconstant = F->get();
if (iconstant.const_doc && iconstant.const_doc->description.size()) {
- String xml_summary = bbcode_to_xml(fix_doc_description(iconstant.const_doc->description), NULL);
+ String xml_summary = bbcode_to_xml(fix_doc_description(iconstant.const_doc->description), nullptr);
Vector<String> summary_lines = xml_summary.length() ? xml_summary.split("\n") : Vector<String>();
if (summary_lines.size()) {
@@ -1406,7 +1406,7 @@ Error BindingsGenerator::_generate_cs_property(const BindingsGenerator::TypeInte
const TypeInterface *current_type = &p_itype;
while (!setter && current_type->base_name != StringName()) {
OrderedHashMap<StringName, TypeInterface>::Element base_match = obj_types.find(current_type->base_name);
- ERR_FAIL_COND_V(!base_match, ERR_BUG);
+ ERR_FAIL_COND_V_MSG(!base_match, ERR_BUG, "Type not found '" + current_type->base_name + "'. Inherited by '" + current_type->name + "'.");
current_type = &base_match.get();
setter = current_type->find_method_by_name(p_iprop.setter);
}
@@ -1417,7 +1417,7 @@ Error BindingsGenerator::_generate_cs_property(const BindingsGenerator::TypeInte
current_type = &p_itype;
while (!getter && current_type->base_name != StringName()) {
OrderedHashMap<StringName, TypeInterface>::Element base_match = obj_types.find(current_type->base_name);
- ERR_FAIL_COND_V(!base_match, ERR_BUG);
+ ERR_FAIL_COND_V_MSG(!base_match, ERR_BUG, "Type not found '" + current_type->base_name + "'. Inherited by '" + current_type->name + "'.");
current_type = &base_match.get();
getter = current_type->find_method_by_name(p_iprop.getter);
}
@@ -1494,7 +1494,7 @@ Error BindingsGenerator::_generate_cs_property(const BindingsGenerator::TypeInte
if (idx_arg.type.cname != name_cache.type_int) {
// Assume the index parameter is an enum
const TypeInterface *idx_arg_type = _get_type_or_null(idx_arg.type);
- CRASH_COND(idx_arg_type == NULL);
+ CRASH_COND(idx_arg_type == nullptr);
p_output.append("(" + idx_arg_type->proxy_name + ")" + itos(p_iprop.index));
} else {
p_output.append(itos(p_iprop.index));
@@ -1522,7 +1522,7 @@ Error BindingsGenerator::_generate_cs_property(const BindingsGenerator::TypeInte
if (idx_arg.type.cname != name_cache.type_int) {
// Assume the index parameter is an enum
const TypeInterface *idx_arg_type = _get_type_or_null(idx_arg.type);
- CRASH_COND(idx_arg_type == NULL);
+ CRASH_COND(idx_arg_type == nullptr);
p_output.append("(" + idx_arg_type->proxy_name + ")" + itos(p_iprop.index) + ", ");
} else {
p_output.append(itos(p_iprop.index) + ", ");
@@ -1631,7 +1631,7 @@ Error BindingsGenerator::_generate_cs_method(const BindingsGenerator::TypeInterf
// Generate method
{
if (!p_imethod.is_virtual && !p_imethod.requires_object_call) {
- p_output.append(MEMBER_BEGIN "[DebuggerBrowsable(DebuggerBrowsableState.Never)]" MEMBER_BEGIN "private static IntPtr ");
+ p_output.append(MEMBER_BEGIN "[DebuggerBrowsable(DebuggerBrowsableState.Never)]" MEMBER_BEGIN "private static readonly IntPtr ");
p_output.append(method_bind_field);
p_output.append(" = Object." ICALL_GET_METHODBIND "(" BINDINGS_NATIVE_NAME_FIELD ", \"");
p_output.append(p_imethod.name);
@@ -2121,7 +2121,7 @@ Error BindingsGenerator::_generate_glue_method(const BindingsGenerator::TypeInte
if (return_type->is_object_type) {
ptrcall_return_type = return_type->is_reference ? "Ref<Reference>" : return_type->c_type;
- initialization = return_type->is_reference ? "" : " = NULL";
+ initialization = return_type->is_reference ? "" : " = nullptr";
} else {
ptrcall_return_type = return_type->c_type;
}
@@ -2130,10 +2130,10 @@ Error BindingsGenerator::_generate_glue_method(const BindingsGenerator::TypeInte
p_output.append(" " C_LOCAL_RET);
p_output.append(initialization + ";\n");
- String fail_ret = return_type->c_type_out.ends_with("*") && !return_type->ret_as_byref_arg ? "NULL" : return_type->c_type_out + "()";
+ String fail_ret = return_type->c_type_out.ends_with("*") && !return_type->ret_as_byref_arg ? "nullptr" : return_type->c_type_out + "()";
if (return_type->ret_as_byref_arg) {
- p_output.append("\tif (" CS_PARAM_INSTANCE " == NULL) { *arg_ret = ");
+ p_output.append("\tif (" CS_PARAM_INSTANCE " == nullptr) { *arg_ret = ");
p_output.append(fail_ret);
p_output.append("; ERR_FAIL_MSG(\"Parameter ' arg_ret ' is null.\"); }\n");
} else {
@@ -2187,7 +2187,7 @@ Error BindingsGenerator::_generate_glue_method(const BindingsGenerator::TypeInte
}
p_output.append(CS_PARAM_METHODBIND "->call(" CS_PARAM_INSTANCE ", ");
- p_output.append(p_imethod.arguments.size() ? C_LOCAL_PTRCALL_ARGS ".ptr()" : "NULL");
+ p_output.append(p_imethod.arguments.size() ? C_LOCAL_PTRCALL_ARGS ".ptr()" : "nullptr");
p_output.append(", total_length, vcall_error);\n");
if (!ret_void) {
@@ -2198,8 +2198,8 @@ Error BindingsGenerator::_generate_glue_method(const BindingsGenerator::TypeInte
}
} else {
p_output.append("\t" CS_PARAM_METHODBIND "->ptrcall(" CS_PARAM_INSTANCE ", ");
- p_output.append(p_imethod.arguments.size() ? C_LOCAL_PTRCALL_ARGS ", " : "NULL, ");
- p_output.append(!ret_void ? "&" C_LOCAL_RET ");\n" : "NULL);\n");
+ p_output.append(p_imethod.arguments.size() ? C_LOCAL_PTRCALL_ARGS ", " : "nullptr, ");
+ p_output.append(!ret_void ? "&" C_LOCAL_RET ");\n" : "nullptr);\n");
}
if (!ret_void) {
@@ -2241,11 +2241,11 @@ const BindingsGenerator::TypeInterface *BindingsGenerator::_get_type_or_null(con
// Enum not found. Most likely because none of its constants were bound, so it's empty. That's fine. Use int instead.
const Map<StringName, TypeInterface>::Element *int_match = builtin_types.find(name_cache.type_int);
- ERR_FAIL_NULL_V(int_match, NULL);
+ ERR_FAIL_NULL_V(int_match, nullptr);
return &int_match->get();
}
- return NULL;
+ return nullptr;
}
const BindingsGenerator::TypeInterface *BindingsGenerator::_get_type_or_placeholder(const TypeReference &p_typeref) {
@@ -2383,7 +2383,7 @@ bool BindingsGenerator::_populate_object_type_interfaces() {
for (const List<PropertyInfo>::Element *E = property_list.front(); E; E = E->next()) {
const PropertyInfo &property = E->get();
- if (property.usage & PROPERTY_USAGE_GROUP || property.usage & PROPERTY_USAGE_CATEGORY)
+ if (property.usage & PROPERTY_USAGE_GROUP || property.usage & PROPERTY_USAGE_SUBGROUP || property.usage & PROPERTY_USAGE_CATEGORY)
continue;
PropertyInterface iprop;
@@ -2412,7 +2412,7 @@ bool BindingsGenerator::_populate_object_type_interfaces() {
iprop.proxy_name = iprop.proxy_name.replace("/", "__"); // Some members have a slash...
- iprop.prop_doc = NULL;
+ iprop.prop_doc = nullptr;
for (int i = 0; i < itype.class_doc->properties.size(); i++) {
const DocData::PropertyDoc &prop_doc = itype.class_doc->properties[i];
@@ -2457,7 +2457,7 @@ bool BindingsGenerator::_populate_object_type_interfaces() {
PropertyInfo return_info = method_info.return_val;
- MethodBind *m = imethod.is_virtual ? NULL : ClassDB::get_method(type_cname, method_info.name);
+ MethodBind *m = imethod.is_virtual ? nullptr : ClassDB::get_method(type_cname, method_info.name);
imethod.is_vararg = m && m->is_vararg();
@@ -2603,7 +2603,7 @@ bool BindingsGenerator::_populate_object_type_interfaces() {
// Populate signals
const HashMap<StringName, MethodInfo> &signal_map = class_info->signal_map;
- const StringName *k = NULL;
+ const StringName *k = nullptr;
while ((k = signal_map.next(k))) {
SignalInterface isignal;
@@ -2685,7 +2685,7 @@ bool BindingsGenerator::_populate_object_type_interfaces() {
ClassDB::get_integer_constant_list(type_cname, &constants, true);
const HashMap<StringName, List<StringName>> &enum_map = class_info->enum_map;
- k = NULL;
+ k = nullptr;
while ((k = enum_map.next(k))) {
StringName enum_proxy_cname = *k;
@@ -2707,7 +2707,7 @@ bool BindingsGenerator::_populate_object_type_interfaces() {
ConstantInterface iconstant(constant_name, snake_to_pascal_case(constant_name, true), *value);
- iconstant.const_doc = NULL;
+ iconstant.const_doc = nullptr;
for (int i = 0; i < itype.class_doc->constants.size(); i++) {
const DocData::ConstantDoc &const_doc = itype.class_doc->constants[i];
@@ -2742,7 +2742,7 @@ bool BindingsGenerator::_populate_object_type_interfaces() {
ConstantInterface iconstant(constant_name, snake_to_pascal_case(constant_name, true), *value);
- iconstant.const_doc = NULL;
+ iconstant.const_doc = nullptr;
for (int i = 0; i < itype.class_doc->constants.size(); i++) {
const DocData::ConstantDoc &const_doc = itype.class_doc->constants[i];
@@ -3262,7 +3262,7 @@ void BindingsGenerator::_populate_global_constants() {
String constant_name = GlobalConstants::get_global_constant_name(i);
- const DocData::ConstantDoc *const_doc = NULL;
+ const DocData::ConstantDoc *const_doc = nullptr;
for (int j = 0; j < global_scope_doc.constants.size(); j++) {
const DocData::ConstantDoc &curr_const_doc = global_scope_doc.constants[j];
diff --git a/modules/mono/editor/bindings_generator.h b/modules/mono/editor/bindings_generator.h
index b133923c25..7c87c688db 100644
--- a/modules/mono/editor/bindings_generator.h
+++ b/modules/mono/editor/bindings_generator.h
@@ -33,7 +33,7 @@
#include "core/class_db.h"
#include "core/string_builder.h"
-#include "editor/doc/doc_data.h"
+#include "editor/doc_data.h"
#include "editor/editor_help.h"
#if defined(DEBUG_METHODS_ENABLED) && defined(TOOLS_ENABLED)
@@ -176,7 +176,7 @@ class BindingsGenerator {
is_virtual = false;
requires_object_call = false;
is_internal = false;
- method_doc = NULL;
+ method_doc = nullptr;
is_deprecated = false;
}
};
@@ -202,7 +202,7 @@ class BindingsGenerator {
}
SignalInterface() {
- method_doc = NULL;
+ method_doc = nullptr;
is_deprecated = false;
}
};
@@ -376,7 +376,7 @@ class BindingsGenerator {
return &E->get();
}
- return NULL;
+ return nullptr;
}
const PropertyInterface *find_property_by_name(const StringName &p_cname) const {
@@ -385,7 +385,7 @@ class BindingsGenerator {
return &E->get();
}
- return NULL;
+ return nullptr;
}
const PropertyInterface *find_property_by_proxy_name(const String &p_proxy_name) const {
@@ -394,7 +394,7 @@ class BindingsGenerator {
return &E->get();
}
- return NULL;
+ return nullptr;
}
const MethodInterface *find_method_by_proxy_name(const String &p_proxy_name) const {
@@ -403,7 +403,7 @@ class BindingsGenerator {
return &E->get();
}
- return NULL;
+ return nullptr;
}
private:
@@ -498,7 +498,7 @@ class BindingsGenerator {
c_arg_in = "%s";
- class_doc = NULL;
+ class_doc = nullptr;
}
};
@@ -622,7 +622,7 @@ class BindingsGenerator {
if (it->get().name == p_name) return it;
it = it->next();
}
- return NULL;
+ return nullptr;
}
const ConstantInterface *find_constant_by_name(const String &p_name, const List<ConstantInterface> &p_constants) const {
@@ -631,7 +631,7 @@ class BindingsGenerator {
return &E->get();
}
- return NULL;
+ return nullptr;
}
inline String get_unique_sig(const TypeInterface &p_type) {
diff --git a/modules/mono/editor/csharp_project.cpp b/modules/mono/editor/csharp_project.cpp
index 872f45ba91..e5c2d023d3 100644
--- a/modules/mono/editor/csharp_project.cpp
+++ b/modules/mono/editor/csharp_project.cpp
@@ -57,8 +57,8 @@ void add_item(const String &p_project_path, const String &p_item_type, const Str
Variant item_type = p_item_type;
Variant include = p_include;
const Variant *args[3] = { &project_path, &item_type, &include };
- MonoException *exc = NULL;
- klass->get_method("AddItemToProjectChecked", 3)->invoke(NULL, args, &exc);
+ MonoException *exc = nullptr;
+ klass->get_method("AddItemToProjectChecked", 3)->invoke(nullptr, args, &exc);
if (exc) {
GDMonoUtils::debug_print_unhandled_exception(exc);
diff --git a/modules/mono/editor/editor_internal_calls.cpp b/modules/mono/editor/editor_internal_calls.cpp
index 31996a03d0..c3e7e67ae9 100644
--- a/modules/mono/editor/editor_internal_calls.cpp
+++ b/modules/mono/editor/editor_internal_calls.cpp
@@ -95,7 +95,7 @@ MonoString *godot_icall_GodotSharpDirs_MonoSolutionsDir() {
#ifdef TOOLS_ENABLED
return GDMonoMarshal::mono_string_from_godot(GodotSharpDirs::get_mono_solutions_dir());
#else
- return NULL;
+ return nullptr;
#endif
}
@@ -103,7 +103,7 @@ MonoString *godot_icall_GodotSharpDirs_BuildLogsDirs() {
#ifdef TOOLS_ENABLED
return GDMonoMarshal::mono_string_from_godot(GodotSharpDirs::get_build_logs_dir());
#else
- return NULL;
+ return nullptr;
#endif
}
@@ -111,7 +111,7 @@ MonoString *godot_icall_GodotSharpDirs_ProjectSlnPath() {
#ifdef TOOLS_ENABLED
return GDMonoMarshal::mono_string_from_godot(GodotSharpDirs::get_project_sln_path());
#else
- return NULL;
+ return nullptr;
#endif
}
@@ -119,7 +119,7 @@ MonoString *godot_icall_GodotSharpDirs_ProjectCsProjPath() {
#ifdef TOOLS_ENABLED
return GDMonoMarshal::mono_string_from_godot(GodotSharpDirs::get_project_csproj_path());
#else
- return NULL;
+ return nullptr;
#endif
}
@@ -127,7 +127,7 @@ MonoString *godot_icall_GodotSharpDirs_DataEditorToolsDir() {
#ifdef TOOLS_ENABLED
return GDMonoMarshal::mono_string_from_godot(GodotSharpDirs::get_data_editor_tools_dir());
#else
- return NULL;
+ return nullptr;
#endif
}
@@ -135,7 +135,7 @@ MonoString *godot_icall_GodotSharpDirs_DataEditorPrebuiltApiDir() {
#ifdef TOOLS_ENABLED
return GDMonoMarshal::mono_string_from_godot(GodotSharpDirs::get_data_editor_prebuilt_api_dir());
#else
- return NULL;
+ return nullptr;
#endif
}
@@ -151,7 +151,7 @@ MonoString *godot_icall_GodotSharpDirs_DataMonoBinDir() {
#ifdef WINDOWS_ENABLED
return GDMonoMarshal::mono_string_from_godot(GodotSharpDirs::get_data_mono_bin_dir());
#else
- return NULL;
+ return nullptr;
#endif
}
@@ -202,7 +202,7 @@ uint32_t godot_icall_BindingsGenerator_CsGlueVersion() {
}
int32_t godot_icall_ScriptClassParser_ParseFile(MonoString *p_filepath, MonoObject *p_classes, MonoString **r_error_str) {
- *r_error_str = NULL;
+ *r_error_str = nullptr;
String filepath = GDMonoMarshal::mono_string_to_godot(p_filepath);
@@ -231,14 +231,14 @@ int32_t godot_icall_ScriptClassParser_ParseFile(MonoString *p_filepath, MonoObje
return err;
}
-uint32_t godot_icall_ExportPlugin_GetExportedAssemblyDependencies(MonoObject *p_initial_dependencies,
- MonoString *p_build_config, MonoString *p_custom_bcl_dir, MonoObject *r_dependencies) {
- Dictionary initial_dependencies = GDMonoMarshal::mono_object_to_variant(p_initial_dependencies);
+uint32_t godot_icall_ExportPlugin_GetExportedAssemblyDependencies(MonoObject *p_initial_assemblies,
+ MonoString *p_build_config, MonoString *p_custom_bcl_dir, MonoObject *r_assembly_dependencies) {
+ Dictionary initial_dependencies = GDMonoMarshal::mono_object_to_variant(p_initial_assemblies);
String build_config = GDMonoMarshal::mono_string_to_godot(p_build_config);
String custom_bcl_dir = GDMonoMarshal::mono_string_to_godot(p_custom_bcl_dir);
- Dictionary dependencies = GDMonoMarshal::mono_object_to_variant(r_dependencies);
+ Dictionary assembly_dependencies = GDMonoMarshal::mono_object_to_variant(r_assembly_dependencies);
- return GodotSharpExport::get_exported_assembly_dependencies(initial_dependencies, build_config, custom_bcl_dir, dependencies);
+ return GodotSharpExport::get_exported_assembly_dependencies(initial_dependencies, build_config, custom_bcl_dir, assembly_dependencies);
}
MonoString *godot_icall_Internal_UpdateApiAssembliesFromPrebuilt(MonoString *p_config) {
@@ -335,7 +335,7 @@ MonoString *godot_icall_Internal_MonoWindowsInstallRoot() {
String install_root_dir = GDMono::get_singleton()->get_mono_reg_info().install_root_dir;
return GDMonoMarshal::mono_string_from_godot(install_root_dir);
#else
- return NULL;
+ return nullptr;
#endif
}
diff --git a/modules/mono/editor/godotsharp_export.cpp b/modules/mono/editor/godotsharp_export.cpp
index ce0b6ad0e6..4126da16be 100644
--- a/modules/mono/editor/godotsharp_export.cpp
+++ b/modules/mono/editor/godotsharp_export.cpp
@@ -50,16 +50,16 @@ String get_assemblyref_name(MonoImage *p_image, int index) {
return String::utf8(mono_metadata_string_heap(p_image, cols[MONO_ASSEMBLYREF_NAME]));
}
-Error get_assembly_dependencies(GDMonoAssembly *p_assembly, const Vector<String> &p_search_dirs, Dictionary &r_dependencies) {
+Error get_assembly_dependencies(GDMonoAssembly *p_assembly, const Vector<String> &p_search_dirs, Dictionary &r_assembly_dependencies) {
MonoImage *image = p_assembly->get_image();
for (int i = 0; i < mono_image_get_table_rows(image, MONO_TABLE_ASSEMBLYREF); i++) {
String ref_name = get_assemblyref_name(image, i);
- if (r_dependencies.has(ref_name))
+ if (r_assembly_dependencies.has(ref_name))
continue;
- GDMonoAssembly *ref_assembly = NULL;
+ GDMonoAssembly *ref_assembly = nullptr;
String path;
bool has_extension = ref_name.ends_with(".dll") || ref_name.ends_with(".exe");
@@ -70,21 +70,21 @@ Error get_assembly_dependencies(GDMonoAssembly *p_assembly, const Vector<String>
path = search_dir.plus_file(ref_name);
if (FileAccess::exists(path)) {
GDMono::get_singleton()->load_assembly_from(ref_name.get_basename(), path, &ref_assembly, true);
- if (ref_assembly != NULL)
+ if (ref_assembly != nullptr)
break;
}
} else {
path = search_dir.plus_file(ref_name + ".dll");
if (FileAccess::exists(path)) {
GDMono::get_singleton()->load_assembly_from(ref_name, path, &ref_assembly, true);
- if (ref_assembly != NULL)
+ if (ref_assembly != nullptr)
break;
}
path = search_dir.plus_file(ref_name + ".exe");
if (FileAccess::exists(path)) {
GDMono::get_singleton()->load_assembly_from(ref_name, path, &ref_assembly, true);
- if (ref_assembly != NULL)
+ if (ref_assembly != nullptr)
break;
}
}
@@ -92,17 +92,18 @@ Error get_assembly_dependencies(GDMonoAssembly *p_assembly, const Vector<String>
ERR_FAIL_COND_V_MSG(!ref_assembly, ERR_CANT_RESOLVE, "Cannot load assembly (refonly): '" + ref_name + "'.");
- r_dependencies[ref_name] = ref_assembly->get_path();
+ // Use the path we got from the search. Don't try to get the path from the loaded assembly as we can't trust it will be from the selected BCL dir.
+ r_assembly_dependencies[ref_name] = path;
- Error err = get_assembly_dependencies(ref_assembly, p_search_dirs, r_dependencies);
+ Error err = get_assembly_dependencies(ref_assembly, p_search_dirs, r_assembly_dependencies);
ERR_FAIL_COND_V_MSG(err != OK, err, "Cannot load one of the dependencies for the assembly: '" + ref_name + "'.");
}
return OK;
}
-Error get_exported_assembly_dependencies(const Dictionary &p_initial_dependencies,
- const String &p_build_config, const String &p_custom_bcl_dir, Dictionary &r_dependencies) {
+Error get_exported_assembly_dependencies(const Dictionary &p_initial_assemblies,
+ const String &p_build_config, const String &p_custom_bcl_dir, Dictionary &r_assembly_dependencies) {
MonoDomain *export_domain = GDMonoUtils::create_domain("GodotEngine.Domain.ProjectExport");
ERR_FAIL_NULL_V(export_domain, FAILED);
_GDMONO_SCOPE_EXIT_DOMAIN_UNLOAD_(export_domain);
@@ -112,16 +113,16 @@ Error get_exported_assembly_dependencies(const Dictionary &p_initial_dependencie
Vector<String> search_dirs;
GDMonoAssembly::fill_search_dirs(search_dirs, p_build_config, p_custom_bcl_dir);
- for (const Variant *key = p_initial_dependencies.next(); key; key = p_initial_dependencies.next(key)) {
+ for (const Variant *key = p_initial_assemblies.next(); key; key = p_initial_assemblies.next(key)) {
String assembly_name = *key;
- String assembly_path = p_initial_dependencies[*key];
+ String assembly_path = p_initial_assemblies[*key];
- GDMonoAssembly *assembly = NULL;
+ GDMonoAssembly *assembly = nullptr;
bool load_success = GDMono::get_singleton()->load_assembly_from(assembly_name, assembly_path, &assembly, /* refonly: */ true);
ERR_FAIL_COND_V_MSG(!load_success, ERR_CANT_RESOLVE, "Cannot load assembly (refonly): '" + assembly_name + "'.");
- Error err = get_assembly_dependencies(assembly, search_dirs, r_dependencies);
+ Error err = get_assembly_dependencies(assembly, search_dirs, r_assembly_dependencies);
if (err != OK)
return err;
}
diff --git a/modules/mono/editor/godotsharp_export.h b/modules/mono/editor/godotsharp_export.h
index 36138f81b7..9ab57755de 100644
--- a/modules/mono/editor/godotsharp_export.h
+++ b/modules/mono/editor/godotsharp_export.h
@@ -41,8 +41,8 @@ namespace GodotSharpExport {
Error get_assembly_dependencies(GDMonoAssembly *p_assembly, const Vector<String> &p_search_dirs, Dictionary &r_dependencies);
-Error get_exported_assembly_dependencies(const Dictionary &p_initial_dependencies,
- const String &p_build_config, const String &p_custom_lib_dir, Dictionary &r_dependencies);
+Error get_exported_assembly_dependencies(const Dictionary &p_initial_assemblies,
+ const String &p_build_config, const String &p_custom_lib_dir, Dictionary &r_assembly_dependencies);
} // namespace GodotSharpExport
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Array.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Array.cs
index aba1065498..a963810d63 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Array.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Array.cs
@@ -15,10 +15,7 @@ namespace Godot.Collections
public override bool IsInvalid
{
- get
- {
- return handle == IntPtr.Zero;
- }
+ get { return handle == IntPtr.Zero; }
}
protected override bool ReleaseHandle()
@@ -43,7 +40,8 @@ namespace Godot.Collections
if (collection == null)
throw new NullReferenceException($"Parameter '{nameof(collection)} cannot be null.'");
- MarshalUtils.EnumerableToArray(collection, GetPtr());
+ foreach (object element in collection)
+ Add(element);
}
internal Array(ArraySafeHandle handle)
@@ -272,14 +270,8 @@ namespace Godot.Collections
public T this[int index]
{
- get
- {
- return (T)Array.godot_icall_Array_At_Generic(GetPtr(), index, elemTypeEncoding, elemTypeClass);
- }
- set
- {
- objectArray[index] = value;
- }
+ get { return (T)Array.godot_icall_Array_At_Generic(GetPtr(), index, elemTypeEncoding, elemTypeClass); }
+ set { objectArray[index] = value; }
}
public int IndexOf(T item)
@@ -301,18 +293,12 @@ namespace Godot.Collections
public int Count
{
- get
- {
- return objectArray.Count;
- }
+ get { return objectArray.Count; }
}
public bool IsReadOnly
{
- get
- {
- return objectArray.IsReadOnly;
- }
+ get { return objectArray.IsReadOnly; }
}
public void Add(T item)
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Dictionary.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Dictionary.cs
index d72109de92..213fc181c1 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Dictionary.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Dictionary.cs
@@ -15,10 +15,7 @@ namespace Godot.Collections
public override bool IsInvalid
{
- get
- {
- return handle == IntPtr.Zero;
- }
+ get { return handle == IntPtr.Zero; }
}
protected override bool ReleaseHandle()
@@ -45,7 +42,8 @@ namespace Godot.Collections
if (dictionary == null)
throw new NullReferenceException($"Parameter '{nameof(dictionary)} cannot be null.'");
- MarshalUtils.IDictionaryToDictionary(dictionary, GetPtr());
+ foreach (DictionaryEntry entry in dictionary)
+ Add(entry.Key, entry.Value);
}
internal Dictionary(DictionarySafeHandle handle)
@@ -330,14 +328,8 @@ namespace Godot.Collections
public TValue this[TKey key]
{
- get
- {
- return (TValue)Dictionary.godot_icall_Dictionary_GetValue_Generic(objectDict.GetPtr(), key, valTypeEncoding, valTypeClass);
- }
- set
- {
- objectDict[key] = value;
- }
+ get { return (TValue)Dictionary.godot_icall_Dictionary_GetValue_Generic(objectDict.GetPtr(), key, valTypeEncoding, valTypeClass); }
+ set { objectDict[key] = value; }
}
public ICollection<TKey> Keys
@@ -385,18 +377,12 @@ namespace Godot.Collections
public int Count
{
- get
- {
- return objectDict.Count;
- }
+ get { return objectDict.Count; }
}
public bool IsReadOnly
{
- get
- {
- return objectDict.IsReadOnly;
- }
+ get { return objectDict.IsReadOnly; }
}
public void Add(KeyValuePair<TKey, TValue> item)
@@ -440,7 +426,8 @@ namespace Godot.Collections
public bool Remove(KeyValuePair<TKey, TValue> item)
{
- return Dictionary.godot_icall_Dictionary_Remove(GetPtr(), item.Key, item.Value); ;
+ return Dictionary.godot_icall_Dictionary_Remove(GetPtr(), item.Key, item.Value);
+ ;
}
// IEnumerable<KeyValuePair<TKey, TValue>>
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/DynamicObject.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/DynamicObject.cs
index a0f105d55e..c4c911b863 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/DynamicObject.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/DynamicObject.cs
@@ -23,7 +23,7 @@ namespace Godot
/// <example>
/// This sample shows how to use <see cref="Godot.DynamicGodotObject"/> to dynamically access the engine members of a <see cref="Godot.Object"/>.
/// <code>
- /// dynamic sprite = GetNode("Sprite").DynamicGodotObject;
+ /// dynamic sprite = GetNode("Sprite2D").DynamicGodotObject;
/// sprite.add_child(this);
///
/// if ((sprite.hframes * sprite.vframes) &gt; 0)
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/MarshalUtils.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/MarshalUtils.cs
index a1d63a62ef..c59d083080 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/MarshalUtils.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/MarshalUtils.cs
@@ -16,10 +16,8 @@ namespace Godot
/// <exception cref="System.InvalidOperationException">
/// <paramref name="type"/> is not a generic type. That is, IsGenericType returns false.
/// </exception>
- static bool TypeIsGenericArray(Type type)
- {
- return type.GetGenericTypeDefinition() == typeof(Godot.Collections.Array<>);
- }
+ static bool TypeIsGenericArray(Type type) =>
+ type.GetGenericTypeDefinition() == typeof(Godot.Collections.Array<>);
/// <summary>
/// Returns <see langword="true"/> if the generic type definition of <paramref name="type"/>
@@ -28,10 +26,20 @@ namespace Godot
/// <exception cref="System.InvalidOperationException">
/// <paramref name="type"/> is not a generic type. That is, IsGenericType returns false.
/// </exception>
- static bool TypeIsGenericDictionary(Type type)
- {
- return type.GetGenericTypeDefinition() == typeof(Godot.Collections.Dictionary<,>);
- }
+ static bool TypeIsGenericDictionary(Type type) =>
+ type.GetGenericTypeDefinition() == typeof(Godot.Collections.Dictionary<,>);
+
+ static bool TypeIsSystemGenericList(Type type) =>
+ type.GetGenericTypeDefinition() == typeof(System.Collections.Generic.List<>);
+
+ static bool TypeIsSystemGenericDictionary(Type type) =>
+ type.GetGenericTypeDefinition() == typeof(System.Collections.Generic.Dictionary<,>);
+
+ static bool TypeIsGenericIEnumerable(Type type) => type.GetGenericTypeDefinition() == typeof(IEnumerable<>);
+
+ static bool TypeIsGenericICollection(Type type) => type.GetGenericTypeDefinition() == typeof(ICollection<>);
+
+ static bool TypeIsGenericIDictionary(Type type) => type.GetGenericTypeDefinition() == typeof(IDictionary<,>);
static void ArrayGetElementType(Type arrayType, out Type elementType)
{
@@ -45,105 +53,6 @@ namespace Godot
valueType = genericArgs[1];
}
- static bool GenericIEnumerableIsAssignableFromType(Type type)
- {
- if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(IEnumerable<>))
- return true;
-
- foreach (var interfaceType in type.GetInterfaces())
- {
- if (interfaceType.IsGenericType && interfaceType.GetGenericTypeDefinition() == typeof(IEnumerable<>))
- return true;
- }
-
- Type baseType = type.BaseType;
-
- if (baseType == null)
- return false;
-
- return GenericIEnumerableIsAssignableFromType(baseType);
- }
-
- static bool GenericIDictionaryIsAssignableFromType(Type type)
- {
- if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(IDictionary<,>))
- return true;
-
- foreach (var interfaceType in type.GetInterfaces())
- {
- if (interfaceType.IsGenericType && interfaceType.GetGenericTypeDefinition() == typeof(IDictionary<,>))
- return true;
- }
-
- Type baseType = type.BaseType;
-
- if (baseType == null)
- return false;
-
- return GenericIDictionaryIsAssignableFromType(baseType);
- }
-
- static bool GenericIEnumerableIsAssignableFromType(Type type, out Type elementType)
- {
- if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(IEnumerable<>))
- {
- elementType = type.GetGenericArguments()[0];
- return true;
- }
-
- foreach (var interfaceType in type.GetInterfaces())
- {
- if (interfaceType.IsGenericType && interfaceType.GetGenericTypeDefinition() == typeof(IEnumerable<>))
- {
- elementType = interfaceType.GetGenericArguments()[0];
- return true;
- }
- }
-
- Type baseType = type.BaseType;
-
- if (baseType == null)
- {
- elementType = null;
- return false;
- }
-
- return GenericIEnumerableIsAssignableFromType(baseType, out elementType);
- }
-
- static bool GenericIDictionaryIsAssignableFromType(Type type, out Type keyType, out Type valueType)
- {
- if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(IDictionary<,>))
- {
- var genericArgs = type.GetGenericArguments();
- keyType = genericArgs[0];
- valueType = genericArgs[1];
- return true;
- }
-
- foreach (var interfaceType in type.GetInterfaces())
- {
- if (interfaceType.IsGenericType && interfaceType.GetGenericTypeDefinition() == typeof(IDictionary<,>))
- {
- var genericArgs = interfaceType.GetGenericArguments();
- keyType = genericArgs[0];
- valueType = genericArgs[1];
- return true;
- }
- }
-
- Type baseType = type.BaseType;
-
- if (baseType == null)
- {
- keyType = null;
- valueType = null;
- return false;
- }
-
- return GenericIDictionaryIsAssignableFromType(baseType, out keyType, out valueType);
- }
-
static Type MakeGenericArrayType(Type elemType)
{
return typeof(Godot.Collections.Array<>).MakeGenericType(elemType);
@@ -153,60 +62,5 @@ namespace Godot
{
return typeof(Godot.Collections.Dictionary<,>).MakeGenericType(keyType, valueType);
}
-
- // TODO Add support for IEnumerable<T> and IDictionary<TKey, TValue>
- // TODO: EnumerableToArray and IDictionaryToDictionary can be optimized
-
- internal static void EnumerableToArray(IEnumerable enumerable, IntPtr godotArrayPtr)
- {
- if (enumerable is ICollection collection)
- {
- int count = collection.Count;
-
- object[] tempArray = new object[count];
- collection.CopyTo(tempArray, 0);
-
- for (int i = 0; i < count; i++)
- {
- Array.godot_icall_Array_Add(godotArrayPtr, tempArray[i]);
- }
- }
- else
- {
- foreach (object element in enumerable)
- {
- Array.godot_icall_Array_Add(godotArrayPtr, element);
- }
- }
- }
-
- internal static void IDictionaryToDictionary(IDictionary dictionary, IntPtr godotDictionaryPtr)
- {
- foreach (DictionaryEntry entry in dictionary)
- {
- Dictionary.godot_icall_Dictionary_Add(godotDictionaryPtr, entry.Key, entry.Value);
- }
- }
-
- internal static void GenericIDictionaryToDictionary(object dictionary, IntPtr godotDictionaryPtr)
- {
-#if DEBUG
- if (!GenericIDictionaryIsAssignableFromType(dictionary.GetType()))
- throw new InvalidOperationException("The type does not implement IDictionary<,>");
-#endif
-
- // TODO: Can we optimize this?
-
- var keys = ((IEnumerable)dictionary.GetType().GetProperty("Keys").GetValue(dictionary)).GetEnumerator();
- var values = ((IEnumerable)dictionary.GetType().GetProperty("Values").GetValue(dictionary)).GetEnumerator();
-
- while (keys.MoveNext() && values.MoveNext())
- {
- object key = keys.Current;
- object value = values.Current;
-
- Dictionary.godot_icall_Dictionary_Add(godotDictionaryPtr, key, value);
- }
- }
}
}
diff --git a/modules/mono/glue/base_object_glue.cpp b/modules/mono/glue/base_object_glue.cpp
index 120668d1ef..f370883320 100644
--- a/modules/mono/glue/base_object_glue.cpp
+++ b/modules/mono/glue/base_object_glue.cpp
@@ -51,7 +51,7 @@ Object *godot_icall_Object_Ctor(MonoObject *p_obj) {
void godot_icall_Object_Disposed(MonoObject *p_obj, Object *p_ptr) {
#ifdef DEBUG_ENABLED
- CRASH_COND(p_ptr == NULL);
+ CRASH_COND(p_ptr == nullptr);
#endif
if (p_ptr->get_script_instance()) {
@@ -59,7 +59,7 @@ void godot_icall_Object_Disposed(MonoObject *p_obj, Object *p_ptr) {
if (cs_instance) {
if (!cs_instance->is_destructing_script_instance()) {
cs_instance->mono_object_disposed(p_obj);
- p_ptr->set_script_instance(NULL);
+ p_ptr->set_script_instance(nullptr);
}
return;
}
@@ -80,7 +80,7 @@ void godot_icall_Object_Disposed(MonoObject *p_obj, Object *p_ptr) {
void godot_icall_Reference_Disposed(MonoObject *p_obj, Object *p_ptr, MonoBoolean p_is_finalizer) {
#ifdef DEBUG_ENABLED
- CRASH_COND(p_ptr == NULL);
+ CRASH_COND(p_ptr == nullptr);
// This is only called with Reference derived classes
CRASH_COND(!Object::cast_to<Reference>(p_ptr));
#endif
@@ -99,7 +99,7 @@ void godot_icall_Reference_Disposed(MonoObject *p_obj, Object *p_ptr, MonoBoolea
if (delete_owner) {
memdelete(ref);
} else if (remove_script_instance) {
- ref->set_script_instance(NULL);
+ ref->set_script_instance(nullptr);
}
}
return;
@@ -141,7 +141,7 @@ MethodBind *godot_icall_Object_ClassDB_get_method(StringName *p_type, MonoString
MonoObject *godot_icall_Object_weakref(Object *p_ptr) {
if (!p_ptr)
- return NULL;
+ return nullptr;
Ref<WeakRef> wref;
Reference *ref = Object::cast_to<Reference>(p_ptr);
@@ -149,7 +149,7 @@ MonoObject *godot_icall_Object_weakref(Object *p_ptr) {
if (ref) {
REF r = ref;
if (!r.is_valid())
- return NULL;
+ return nullptr;
wref.instance();
wref->set_ref(r);
@@ -230,7 +230,7 @@ MonoBoolean godot_icall_DynamicGodotObject_SetMember(Object *p_ptr, MonoString *
MonoString *godot_icall_Object_ToString(Object *p_ptr) {
#ifdef DEBUG_ENABLED
// Cannot happen in C#; would get an ObjectDisposedException instead.
- CRASH_COND(p_ptr == NULL);
+ CRASH_COND(p_ptr == nullptr);
#endif
// Can't call 'Object::to_string()' here, as that can end up calling 'ToString' again resulting in an endless circular loop.
String result = "[" + p_ptr->get_class() + ":" + itos(p_ptr->get_instance_id()) + "]";
diff --git a/modules/mono/glue/collections_glue.cpp b/modules/mono/glue/collections_glue.cpp
index b7fa7fcab2..4e3dc9c4ea 100644
--- a/modules/mono/glue/collections_glue.cpp
+++ b/modules/mono/glue/collections_glue.cpp
@@ -49,7 +49,7 @@ void godot_icall_Array_Dtor(Array *ptr) {
MonoObject *godot_icall_Array_At(Array *ptr, int index) {
if (index < 0 || index >= ptr->size()) {
GDMonoUtils::set_pending_exception(mono_get_exception_index_out_of_range());
- return NULL;
+ return nullptr;
}
return GDMonoMarshal::variant_to_mono_object(ptr->operator[](index));
}
@@ -57,7 +57,7 @@ MonoObject *godot_icall_Array_At(Array *ptr, int index) {
MonoObject *godot_icall_Array_At_Generic(Array *ptr, int index, uint32_t type_encoding, GDMonoClass *type_class) {
if (index < 0 || index >= ptr->size()) {
GDMonoUtils::set_pending_exception(mono_get_exception_index_out_of_range());
- return NULL;
+ return nullptr;
}
return GDMonoMarshal::variant_to_mono_object(ptr->operator[](index), ManagedType(type_encoding, type_class));
}
@@ -162,28 +162,28 @@ void godot_icall_Dictionary_Dtor(Dictionary *ptr) {
MonoObject *godot_icall_Dictionary_GetValue(Dictionary *ptr, MonoObject *key) {
Variant *ret = ptr->getptr(GDMonoMarshal::mono_object_to_variant(key));
- if (ret == NULL) {
+ if (ret == nullptr) {
MonoObject *exc = mono_object_new(mono_domain_get(), CACHED_CLASS(KeyNotFoundException)->get_mono_ptr());
#ifdef DEBUG_ENABLED
CRASH_COND(!exc);
#endif
GDMonoUtils::runtime_object_init(exc, CACHED_CLASS(KeyNotFoundException));
GDMonoUtils::set_pending_exception((MonoException *)exc);
- return NULL;
+ return nullptr;
}
return GDMonoMarshal::variant_to_mono_object(ret);
}
MonoObject *godot_icall_Dictionary_GetValue_Generic(Dictionary *ptr, MonoObject *key, uint32_t type_encoding, GDMonoClass *type_class) {
Variant *ret = ptr->getptr(GDMonoMarshal::mono_object_to_variant(key));
- if (ret == NULL) {
+ if (ret == nullptr) {
MonoObject *exc = mono_object_new(mono_domain_get(), CACHED_CLASS(KeyNotFoundException)->get_mono_ptr());
#ifdef DEBUG_ENABLED
CRASH_COND(!exc);
#endif
GDMonoUtils::runtime_object_init(exc, CACHED_CLASS(KeyNotFoundException));
GDMonoUtils::set_pending_exception((MonoException *)exc);
- return NULL;
+ return nullptr;
}
return GDMonoMarshal::variant_to_mono_object(ret, ManagedType(type_encoding, type_class));
}
@@ -207,7 +207,7 @@ int godot_icall_Dictionary_Count(Dictionary *ptr) {
void godot_icall_Dictionary_Add(Dictionary *ptr, MonoObject *key, MonoObject *value) {
Variant varKey = GDMonoMarshal::mono_object_to_variant(key);
Variant *ret = ptr->getptr(varKey);
- if (ret != NULL) {
+ if (ret != nullptr) {
GDMonoUtils::set_pending_exception(mono_get_exception_argument("key", "An element with the same key already exists"));
return;
}
@@ -221,7 +221,7 @@ void godot_icall_Dictionary_Clear(Dictionary *ptr) {
MonoBoolean godot_icall_Dictionary_Contains(Dictionary *ptr, MonoObject *key, MonoObject *value) {
// no dupes
Variant *ret = ptr->getptr(GDMonoMarshal::mono_object_to_variant(key));
- return ret != NULL && *ret == GDMonoMarshal::mono_object_to_variant(value);
+ return ret != nullptr && *ret == GDMonoMarshal::mono_object_to_variant(value);
}
MonoBoolean godot_icall_Dictionary_ContainsKey(Dictionary *ptr, MonoObject *key) {
@@ -241,7 +241,7 @@ MonoBoolean godot_icall_Dictionary_Remove(Dictionary *ptr, MonoObject *key, Mono
// no dupes
Variant *ret = ptr->getptr(varKey);
- if (ret != NULL && *ret == GDMonoMarshal::mono_object_to_variant(value)) {
+ if (ret != nullptr && *ret == GDMonoMarshal::mono_object_to_variant(value)) {
ptr->erase(varKey);
return true;
}
@@ -251,8 +251,8 @@ MonoBoolean godot_icall_Dictionary_Remove(Dictionary *ptr, MonoObject *key, Mono
MonoBoolean godot_icall_Dictionary_TryGetValue(Dictionary *ptr, MonoObject *key, MonoObject **value) {
Variant *ret = ptr->getptr(GDMonoMarshal::mono_object_to_variant(key));
- if (ret == NULL) {
- *value = NULL;
+ if (ret == nullptr) {
+ *value = nullptr;
return false;
}
*value = GDMonoMarshal::variant_to_mono_object(ret);
@@ -261,8 +261,8 @@ MonoBoolean godot_icall_Dictionary_TryGetValue(Dictionary *ptr, MonoObject *key,
MonoBoolean godot_icall_Dictionary_TryGetValue_Generic(Dictionary *ptr, MonoObject *key, MonoObject **value, uint32_t type_encoding, GDMonoClass *type_class) {
Variant *ret = ptr->getptr(GDMonoMarshal::mono_object_to_variant(key));
- if (ret == NULL) {
- *value = NULL;
+ if (ret == nullptr) {
+ *value = nullptr;
return false;
}
*value = GDMonoMarshal::variant_to_mono_object(ret, ManagedType(type_encoding, type_class));
diff --git a/modules/mono/glue/gd_glue.cpp b/modules/mono/glue/gd_glue.cpp
index 1576d31a3b..2da39a916a 100644
--- a/modules/mono/glue/gd_glue.cpp
+++ b/modules/mono/glue/gd_glue.cpp
@@ -45,7 +45,7 @@
MonoObject *godot_icall_GD_bytes2var(MonoArray *p_bytes, MonoBoolean p_allow_objects) {
Variant ret;
PackedByteArray varr = GDMonoMarshal::mono_array_to_PackedByteArray(p_bytes);
- Error err = decode_variant(ret, varr.ptr(), varr.size(), NULL, p_allow_objects);
+ Error err = decode_variant(ret, varr.ptr(), varr.size(), nullptr, p_allow_objects);
if (err != OK) {
ret = RTR("Not enough bytes for decoding bytes, or invalid format.");
}
@@ -57,7 +57,7 @@ MonoObject *godot_icall_GD_convert(MonoObject *p_what, int32_t p_type) {
const Variant *args[1] = { &what };
Callable::CallError ce;
Variant ret = Variant::construct(Variant::Type(p_type), args, 1, ce);
- ERR_FAIL_COND_V(ce.error != Callable::CallError::CALL_OK, NULL);
+ ERR_FAIL_COND_V(ce.error != Callable::CallError::CALL_OK, nullptr);
return GDMonoMarshal::variant_to_mono_object(ret);
}
@@ -76,7 +76,7 @@ void godot_icall_GD_print(MonoArray *p_what) {
for (int i = 0; i < length; i++) {
MonoObject *elem = mono_array_get(p_what, MonoObject *, i);
- MonoException *exc = NULL;
+ MonoException *exc = nullptr;
String elem_str = GDMonoMarshal::mono_object_to_variant_string(elem, &exc);
if (exc) {
@@ -98,7 +98,7 @@ void godot_icall_GD_printerr(MonoArray *p_what) {
for (int i = 0; i < length; i++) {
MonoObject *elem = mono_array_get(p_what, MonoObject *, i);
- MonoException *exc = NULL;
+ MonoException *exc = nullptr;
String elem_str = GDMonoMarshal::mono_object_to_variant_string(elem, &exc);
if (exc) {
@@ -119,7 +119,7 @@ void godot_icall_GD_printraw(MonoArray *p_what) {
for (int i = 0; i < length; i++) {
MonoObject *elem = mono_array_get(p_what, MonoObject *, i);
- MonoException *exc = NULL;
+ MonoException *exc = nullptr;
String elem_str = GDMonoMarshal::mono_object_to_variant_string(elem, &exc);
if (exc) {
@@ -140,7 +140,7 @@ void godot_icall_GD_prints(MonoArray *p_what) {
for (int i = 0; i < length; i++) {
MonoObject *elem = mono_array_get(p_what, MonoObject *, i);
- MonoException *exc = NULL;
+ MonoException *exc = nullptr;
String elem_str = GDMonoMarshal::mono_object_to_variant_string(elem, &exc);
if (exc) {
@@ -164,7 +164,7 @@ void godot_icall_GD_printt(MonoArray *p_what) {
for (int i = 0; i < length; i++) {
MonoObject *elem = mono_array_get(p_what, MonoObject *, i);
- MonoException *exc = NULL;
+ MonoException *exc = nullptr;
String elem_str = GDMonoMarshal::mono_object_to_variant_string(elem, &exc);
if (exc) {
@@ -259,8 +259,8 @@ MonoArray *godot_icall_GD_var2bytes(MonoObject *p_var, MonoBoolean p_full_object
PackedByteArray barr;
int len;
- Error err = encode_variant(var, NULL, len, p_full_objects);
- ERR_FAIL_COND_V_MSG(err != OK, NULL, "Unexpected error encoding variable to bytes, likely unserializable type found (Object or RID).");
+ Error err = encode_variant(var, nullptr, len, p_full_objects);
+ ERR_FAIL_COND_V_MSG(err != OK, nullptr, "Unexpected error encoding variable to bytes, likely unserializable type found (Object or RID).");
barr.resize(len);
encode_variant(var, barr.ptrw(), len, p_full_objects);
diff --git a/modules/mono/glue/glue_header.h b/modules/mono/glue/glue_header.h
index 8130b0cc39..ee99a300b9 100644
--- a/modules/mono/glue/glue_header.h
+++ b/modules/mono/glue/glue_header.h
@@ -70,7 +70,7 @@ void godot_register_glue_header_icalls() {
#include "../mono_gd/gd_mono_utils.h"
#define GODOTSHARP_INSTANCE_OBJECT(m_instance, m_type) \
- static ClassDB::ClassInfo *ci = NULL; \
+ static ClassDB::ClassInfo *ci = nullptr; \
if (!ci) { \
ci = ClassDB::classes.getptr(m_type); \
} \
diff --git a/modules/mono/godotsharp_dirs.cpp b/modules/mono/godotsharp_dirs.cpp
index 828ab73c82..d596163926 100644
--- a/modules/mono/godotsharp_dirs.cpp
+++ b/modules/mono/godotsharp_dirs.cpp
@@ -40,7 +40,7 @@
#endif
#ifdef ANDROID_ENABLED
-#include "mono_gd/gd_mono_android.h"
+#include "mono_gd/support/android_support.h"
#endif
#include "mono_gd/gd_mono.h"
@@ -169,7 +169,7 @@ private:
data_mono_etc_dir = data_mono_root_dir.plus_file("etc");
#ifdef ANDROID_ENABLED
- data_mono_lib_dir = GDMonoAndroid::get_app_native_lib_dir();
+ data_mono_lib_dir = gdmono::android::support::get_app_native_lib_dir();
#else
data_mono_lib_dir = data_mono_root_dir.plus_file("lib");
#endif
@@ -206,7 +206,7 @@ private:
data_mono_etc_dir = data_mono_root_dir.plus_file("etc");
#ifdef ANDROID_ENABLED
- data_mono_lib_dir = GDMonoAndroid::get_app_native_lib_dir();
+ data_mono_lib_dir = gdmono::android::support::get_app_native_lib_dir();
#else
data_mono_lib_dir = data_mono_root_dir.plus_file("lib");
data_game_assemblies_dir = data_dir_root.plus_file("Assemblies");
diff --git a/modules/mono/managed_callable.cpp b/modules/mono/managed_callable.cpp
index a9cf64d1cc..dfd78a8244 100644
--- a/modules/mono/managed_callable.cpp
+++ b/modules/mono/managed_callable.cpp
@@ -99,7 +99,7 @@ void ManagedCallable::call(const Variant **p_arguments, int p_argcount, Variant
MonoObject *delegate = delegate_handle.get_target();
- MonoException *exc = NULL;
+ MonoException *exc = nullptr;
MonoObject *ret = delegate_invoke->invoke(delegate, p_arguments, &exc);
if (exc) {
@@ -119,7 +119,7 @@ void ManagedCallable::set_delegate(MonoDelegate *p_delegate) {
ManagedCallable::ManagedCallable(MonoDelegate *p_delegate) {
#ifdef DEBUG_ENABLED
- CRASH_COND(p_delegate == NULL);
+ CRASH_COND(p_delegate == nullptr);
#endif
set_delegate(p_delegate);
diff --git a/modules/mono/mono_gc_handle.cpp b/modules/mono/mono_gc_handle.cpp
index 4b6d7269e9..e362d5affb 100644
--- a/modules/mono/mono_gc_handle.cpp
+++ b/modules/mono/mono_gc_handle.cpp
@@ -34,7 +34,7 @@
void MonoGCHandleData::release() {
#ifdef DEBUG_ENABLED
- CRASH_COND(handle && GDMono::get_singleton() == NULL);
+ CRASH_COND(handle && GDMono::get_singleton() == nullptr);
#endif
if (handle && GDMono::get_singleton()->is_runtime_initialized()) {
diff --git a/modules/mono/mono_gc_handle.h b/modules/mono/mono_gc_handle.h
index 705b2265ba..fbcb405b0d 100644
--- a/modules/mono/mono_gc_handle.h
+++ b/modules/mono/mono_gc_handle.h
@@ -53,7 +53,7 @@ struct MonoGCHandleData {
_FORCE_INLINE_ bool is_released() const { return !handle; }
_FORCE_INLINE_ bool is_weak() const { return type == gdmono::GCHandleType::WEAK_HANDLE; }
- _FORCE_INLINE_ MonoObject *get_target() const { return handle ? mono_gchandle_get_target(handle) : NULL; }
+ _FORCE_INLINE_ MonoObject *get_target() const { return handle ? mono_gchandle_get_target(handle) : nullptr; }
void release();
diff --git a/modules/mono/mono_gd/gd_mono.cpp b/modules/mono/mono_gd/gd_mono.cpp
index eb4c263745..3298c5da4c 100644
--- a/modules/mono/mono_gd/gd_mono.cpp
+++ b/modules/mono/mono_gd/gd_mono.cpp
@@ -58,14 +58,25 @@
#ifdef ANDROID_ENABLED
#include "android_mono_config.h"
-#include "gd_mono_android.h"
+#include "support/android_support.h"
+#elif defined(IPHONE_ENABLED)
+#include "support/ios_support.h"
+#endif
+
+#if defined(TOOL_ENABLED) && defined(GD_MONO_SINGLE_APPDOMAIN)
+// This will no longer be the case if we replace appdomains with AssemblyLoadContext
+#error "Editor build requires support for multiple appdomains"
+#endif
+
+#if defined(GD_MONO_HOT_RELOAD) && defined(GD_MONO_SINGLE_APPDOMAIN)
+#error "Hot reloading requires multiple appdomains"
#endif
// TODO:
// This has turn into a gigantic mess. There's too much going on here. Too much #ifdef as well.
// It's just painful to read... It needs to be re-structured. Please, clean this up, future me.
-GDMono *GDMono::singleton = NULL;
+GDMono *GDMono::singleton = nullptr;
namespace {
@@ -118,12 +129,8 @@ void gd_mono_profiler_init() {
}
}
-#if defined(DEBUG_ENABLED)
-
void gd_mono_debug_init() {
- mono_debug_init(MONO_DEBUG_FORMAT_MONO);
-
CharString da_args = OS::get_singleton()->get_environment("GODOT_MONO_DEBUGGER_AGENT").utf8();
#ifdef TOOLS_ENABLED
@@ -148,6 +155,10 @@ void gd_mono_debug_init() {
return; // Exported games don't use the project settings to setup the debugger agent
#endif
+ // Debugging enabled
+
+ mono_debug_init(MONO_DEBUG_FORMAT_MONO);
+
// --debugger-agent=help
const char *options[] = {
"--soft-breakpoints",
@@ -156,7 +167,6 @@ void gd_mono_debug_init() {
mono_jit_parse_options(2, (char **)options);
}
-#endif // defined(DEBUG_ENABLED)
#endif // !defined(JAVASCRIPT_ENABLED)
#if defined(JAVASCRIPT_ENABLED)
@@ -164,6 +174,7 @@ MonoDomain *gd_initialize_mono_runtime() {
const char *vfs_prefix = "managed";
int enable_debugging = 0;
+ // TODO: Provide a way to enable debugging on WASM release builds.
#ifdef DEBUG_ENABLED
enable_debugging = 1;
#endif
@@ -174,11 +185,16 @@ MonoDomain *gd_initialize_mono_runtime() {
}
#else
MonoDomain *gd_initialize_mono_runtime() {
-#ifdef DEBUG_ENABLED
gd_mono_debug_init();
+
+#if defined(IPHONE_ENABLED) || defined(ANDROID_ENABLED)
+ // I don't know whether this actually matters or not
+ const char *runtime_version = "mobile";
+#else
+ const char *runtime_version = "v4.0.30319";
#endif
- return mono_jit_init_version("GodotEngine.RootDomain", "v4.0.30319");
+ return mono_jit_init_version("GodotEngine.RootDomain", runtime_version);
}
#endif
@@ -314,14 +330,22 @@ void GDMono::initialize() {
determine_mono_dirs(assembly_rootdir, config_dir);
// 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);
+ mono_set_dirs(assembly_rootdir.length() ? assembly_rootdir.utf8().get_data() : nullptr,
+ config_dir.length() ? config_dir.utf8().get_data() : nullptr);
add_mono_shared_libs_dir_to_path();
#endif
+#ifdef ANDROID_ENABLED
+ mono_config_parse_memory(get_godot_android_mono_config().utf8().get_data());
+#else
+ mono_config_parse(nullptr);
+#endif
+
#if defined(ANDROID_ENABLED)
- GDMonoAndroid::initialize();
+ gdmono::android::support::initialize();
+#elif defined(IPHONE_ENABLED)
+ gdmono::ios::support::initialize();
#endif
GDMonoAssembly::initialize();
@@ -330,13 +354,7 @@ void GDMono::initialize() {
gd_mono_profiler_init();
#endif
-#ifdef ANDROID_ENABLED
- mono_config_parse_memory(get_godot_android_mono_config().utf8().get_data());
-#else
- mono_config_parse(NULL);
-#endif
-
- mono_install_unhandled_exception_hook(&unhandled_exception_hook, NULL);
+ mono_install_unhandled_exception_hook(&unhandled_exception_hook, nullptr);
#ifndef TOOLS_ENABLED
// Exported games that don't use C# must still work. They likely don't ship with mscorlib.
@@ -355,7 +373,7 @@ void GDMono::initialize() {
#endif
// NOTE: Internal calls must be registered after the Mono runtime initialization.
- // Otherwise registration fails with the error: 'assertion 'hash != NULL' failed'.
+ // Otherwise registration fails with the error: 'assertion 'hash != nullptr' failed'.
root_domain = gd_initialize_mono_runtime();
ERR_FAIL_NULL_MSG(root_domain, "Mono: Failed to initialize runtime.");
@@ -371,15 +389,19 @@ void GDMono::initialize() {
print_verbose("Mono: Runtime initialized");
#if defined(ANDROID_ENABLED)
- GDMonoAndroid::register_internal_calls();
+ gdmono::android::support::register_internal_calls();
#endif
// mscorlib assembly MUST be present at initialization
bool corlib_loaded = _load_corlib_assembly();
ERR_FAIL_COND_MSG(!corlib_loaded, "Mono: Failed to load mscorlib assembly.");
+#ifndef GD_MONO_SINGLE_APPDOMAIN
Error domain_load_err = _load_scripts_domain();
ERR_FAIL_COND_MSG(domain_load_err != OK, "Mono: Failed to load scripts domain.");
+#else
+ scripts_domain = root_domain;
+#endif
_register_internal_calls();
@@ -491,11 +513,15 @@ void GDMono::add_assembly(uint32_t p_domain_id, GDMonoAssembly *p_assembly) {
assemblies[p_domain_id][p_assembly->get_name()] = p_assembly;
}
-GDMonoAssembly **GDMono::get_loaded_assembly(const String &p_name) {
+GDMonoAssembly *GDMono::get_loaded_assembly(const String &p_name) {
+
+ if (p_name == "mscorlib")
+ return get_corlib_assembly();
MonoDomain *domain = mono_domain_get();
uint32_t domain_id = domain ? mono_domain_get_id(domain) : 0;
- return assemblies[domain_id].getptr(p_name);
+ GDMonoAssembly **result = assemblies[domain_id].getptr(p_name);
+ return result ? *result : nullptr;
}
bool GDMono::load_assembly(const String &p_name, GDMonoAssembly **r_assembly, bool p_refonly) {
@@ -517,7 +543,7 @@ bool GDMono::load_assembly(const String &p_name, MonoAssemblyName *p_aname, GDMo
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, nullptr, &status, p_refonly);
if (!assembly)
return false;
@@ -528,7 +554,7 @@ bool GDMono::load_assembly(const String &p_name, MonoAssemblyName *p_aname, GDMo
GDMonoAssembly **stored_assembly = assemblies[domain_id].getptr(p_name);
- ERR_FAIL_COND_V(stored_assembly == NULL, false);
+ ERR_FAIL_COND_V(stored_assembly == nullptr, false);
ERR_FAIL_COND_V((*stored_assembly)->get_assembly() != assembly, false);
*r_assembly = *stored_assembly;
@@ -549,14 +575,6 @@ bool GDMono::load_assembly_from(const String &p_name, const String &p_path, GDMo
if (!assembly)
return false;
-#ifdef DEBUG_ENABLED
- uint32_t domain_id = mono_domain_get_id(mono_domain_get());
- GDMonoAssembly **stored_assembly = assemblies[domain_id].getptr(p_name);
-
- ERR_FAIL_COND_V(stored_assembly == NULL, false);
- ERR_FAIL_COND_V(*stored_assembly != assembly, false);
-#endif
-
*r_assembly = assembly;
print_verbose("Mono: Assembly " + p_name + (p_refonly ? " (refonly)" : "") + " loaded from path: " + (*r_assembly)->get_path());
@@ -576,15 +594,15 @@ ApiAssemblyInfo::Version ApiAssemblyInfo::Version::get_from_loaded_assembly(GDMo
if (nativecalls_klass) {
GDMonoField *api_hash_field = nativecalls_klass->get_field("godot_api_hash");
if (api_hash_field)
- api_assembly_version.godot_api_hash = GDMonoMarshal::unbox<uint64_t>(api_hash_field->get_value(NULL));
+ api_assembly_version.godot_api_hash = GDMonoMarshal::unbox<uint64_t>(api_hash_field->get_value(nullptr));
GDMonoField *binds_ver_field = nativecalls_klass->get_field("bindings_version");
if (binds_ver_field)
- api_assembly_version.bindings_version = GDMonoMarshal::unbox<uint32_t>(binds_ver_field->get_value(NULL));
+ api_assembly_version.bindings_version = GDMonoMarshal::unbox<uint32_t>(binds_ver_field->get_value(nullptr));
GDMonoField *cs_glue_ver_field = nativecalls_klass->get_field("cs_glue_version");
if (cs_glue_ver_field)
- api_assembly_version.cs_glue_version = GDMonoMarshal::unbox<uint32_t>(cs_glue_ver_field->get_value(NULL));
+ api_assembly_version.cs_glue_version = GDMonoMarshal::unbox<uint32_t>(cs_glue_ver_field->get_value(nullptr));
}
return api_assembly_version;
@@ -715,7 +733,7 @@ bool GDMono::_temp_domain_load_are_assemblies_out_of_sync(const String &p_config
GDMono::LoadedApiAssembly temp_editor_api_assembly;
if (!_try_load_api_assemblies(temp_core_api_assembly, temp_editor_api_assembly,
- p_config, /* refonly: */ true, /* loaded_callback: */ NULL)) {
+ p_config, /* refonly: */ true, /* loaded_callback: */ nullptr)) {
return temp_core_api_assembly.out_of_sync || temp_editor_api_assembly.out_of_sync;
}
@@ -894,8 +912,8 @@ void GDMono::_load_api_assemblies() {
bool api_assemblies_loaded = _try_load_api_assemblies_preset();
+#if defined(TOOLS_ENABLED) && !defined(GD_MONO_SINGLE_APPDOMAIN)
if (!api_assemblies_loaded) {
-#ifdef TOOLS_ENABLED
// The API assemblies are out of sync or some other error happened. Fine, try one more time, but
// this time update them from the prebuilt assemblies directory before trying to load them again.
@@ -916,8 +934,8 @@ void GDMono::_load_api_assemblies() {
// 4. Try loading the updated assemblies
api_assemblies_loaded = _try_load_api_assemblies_preset();
-#endif
}
+#endif
if (!api_assemblies_loaded) {
// welp... too bad
@@ -982,8 +1000,8 @@ void GDMono::_install_trace_listener() {
GDMonoClass *debug_utils = get_core_api_assembly()->get_class(BINDINGS_NAMESPACE, "DebuggingUtils");
GDMonoMethod *install_func = debug_utils->get_method("InstallTraceListener");
- MonoException *exc = NULL;
- install_func->invoke_raw(NULL, NULL, &exc);
+ MonoException *exc = nullptr;
+ install_func->invoke_raw(nullptr, nullptr, &exc);
if (exc) {
GDMonoUtils::debug_print_unhandled_exception(exc);
ERR_PRINT("Failed to install 'System.Diagnostics.Trace' listener.");
@@ -991,9 +1009,10 @@ void GDMono::_install_trace_listener() {
#endif
}
+#ifndef GD_MONO_SINGLE_APPDOMAIN
Error GDMono::_load_scripts_domain() {
- ERR_FAIL_COND_V(scripts_domain != NULL, ERR_BUG);
+ ERR_FAIL_COND_V(scripts_domain != nullptr, ERR_BUG);
print_verbose("Mono: Loading scripts domain...");
@@ -1010,7 +1029,7 @@ Error GDMono::_unload_scripts_domain() {
ERR_FAIL_NULL_V(scripts_domain, ERR_BUG);
- print_verbose("Mono: Unloading scripts domain...");
+ print_verbose("Mono: Finalizing scripts domain...");
if (mono_domain_get() != root_domain)
mono_domain_set(root_domain, true);
@@ -1029,21 +1048,23 @@ Error GDMono::_unload_scripts_domain() {
_domain_assemblies_cleanup(mono_domain_get_id(scripts_domain));
- core_api_assembly.assembly = NULL;
+ core_api_assembly.assembly = nullptr;
#ifdef TOOLS_ENABLED
- editor_api_assembly.assembly = NULL;
+ editor_api_assembly.assembly = nullptr;
#endif
- project_assembly = NULL;
+ project_assembly = nullptr;
#ifdef TOOLS_ENABLED
- tools_assembly = NULL;
- tools_project_editor_assembly = NULL;
+ tools_assembly = nullptr;
+ tools_project_editor_assembly = nullptr;
#endif
MonoDomain *domain = scripts_domain;
- scripts_domain = NULL;
+ scripts_domain = nullptr;
+
+ print_verbose("Mono: Unloading scripts domain...");
- MonoException *exc = NULL;
+ MonoException *exc = nullptr;
mono_domain_try_unload(domain, (MonoObject **)&exc);
if (exc) {
@@ -1054,6 +1075,7 @@ Error GDMono::_unload_scripts_domain() {
return OK;
}
+#endif
#ifdef GD_MONO_HOT_RELOAD
Error GDMono::reload_scripts_domain() {
@@ -1092,9 +1114,10 @@ Error GDMono::reload_scripts_domain() {
}
#endif
+#ifndef GD_MONO_SINGLE_APPDOMAIN
Error GDMono::finalize_and_unload_domain(MonoDomain *p_domain) {
- CRASH_COND(p_domain == NULL);
+ CRASH_COND(p_domain == nullptr);
CRASH_COND(p_domain == GDMono::get_singleton()->get_scripts_domain()); // Should use _unload_scripts_domain() instead
String domain_name = mono_domain_get_friendly_name(p_domain);
@@ -1112,7 +1135,7 @@ Error GDMono::finalize_and_unload_domain(MonoDomain *p_domain) {
_domain_assemblies_cleanup(mono_domain_get_id(p_domain));
- MonoException *exc = NULL;
+ MonoException *exc = nullptr;
mono_domain_try_unload(p_domain, (MonoObject **)&exc);
if (exc) {
@@ -1123,6 +1146,7 @@ Error GDMono::finalize_and_unload_domain(MonoDomain *p_domain) {
return OK;
}
+#endif
GDMonoClass *GDMono::get_class(MonoClass *p_raw_class) {
@@ -1134,7 +1158,7 @@ GDMonoClass *GDMono::get_class(MonoClass *p_raw_class) {
uint32_t domain_id = mono_domain_get_id(mono_domain_get());
HashMap<String, GDMonoAssembly *> &domain_assemblies = assemblies[domain_id];
- const String *k = NULL;
+ const String *k = nullptr;
while ((k = domain_assemblies.next(k))) {
GDMonoAssembly *assembly = domain_assemblies.get(*k);
if (assembly->get_image() == image) {
@@ -1145,30 +1169,34 @@ GDMonoClass *GDMono::get_class(MonoClass *p_raw_class) {
}
}
- return NULL;
+ return nullptr;
}
GDMonoClass *GDMono::get_class(const StringName &p_namespace, const StringName &p_name) {
+ GDMonoClass *klass = corlib_assembly->get_class(p_namespace, p_name);
+ if (klass)
+ return klass;
+
uint32_t domain_id = mono_domain_get_id(mono_domain_get());
HashMap<String, GDMonoAssembly *> &domain_assemblies = assemblies[domain_id];
- const String *k = NULL;
+ const String *k = nullptr;
while ((k = domain_assemblies.next(k))) {
GDMonoAssembly *assembly = domain_assemblies.get(*k);
- GDMonoClass *klass = assembly->get_class(p_namespace, p_name);
+ klass = assembly->get_class(p_namespace, p_name);
if (klass)
return klass;
}
- return NULL;
+ return nullptr;
}
void GDMono::_domain_assemblies_cleanup(uint32_t p_domain_id) {
HashMap<String, GDMonoAssembly *> &domain_assemblies = assemblies[p_domain_id];
- const String *k = NULL;
+ const String *k = nullptr;
while ((k = domain_assemblies.next(k))) {
memdelete(domain_assemblies.get(*k));
}
@@ -1202,14 +1230,14 @@ GDMono::GDMono() {
runtime_initialized = false;
finalizing_scripts_domain = false;
- root_domain = NULL;
- scripts_domain = NULL;
+ root_domain = nullptr;
+ scripts_domain = nullptr;
- corlib_assembly = NULL;
- project_assembly = NULL;
+ corlib_assembly = nullptr;
+ project_assembly = nullptr;
#ifdef TOOLS_ENABLED
- tools_assembly = NULL;
- tools_project_editor_assembly = NULL;
+ tools_assembly = nullptr;
+ tools_project_editor_assembly = nullptr;
#endif
api_core_hash = 0;
@@ -1223,18 +1251,50 @@ GDMono::GDMono() {
GDMono::~GDMono() {
if (is_runtime_initialized()) {
+#ifndef GD_MONO_SINGLE_APPDOMAIN
if (scripts_domain) {
Error err = _unload_scripts_domain();
if (err != OK) {
ERR_PRINT("Mono: Failed to unload scripts domain.");
}
}
+#else
+ CRASH_COND(scripts_domain != root_domain);
+
+ print_verbose("Mono: Finalizing scripts domain...");
+
+ if (mono_domain_get() != root_domain)
+ mono_domain_set(root_domain, true);
+
+ finalizing_scripts_domain = true;
+
+ if (!mono_domain_finalize(root_domain, 2000)) {
+ ERR_PRINT("Mono: Domain finalization timeout.");
+ }
- const uint32_t *k = NULL;
+ finalizing_scripts_domain = false;
+
+ mono_gc_collect(mono_gc_max_generation());
+
+ GDMonoCache::clear_godot_api_cache();
+
+ _domain_assemblies_cleanup(mono_domain_get_id(root_domain));
+
+ core_api_assembly.assembly = nullptr;
+
+ project_assembly = nullptr;
+
+ root_domain = nullptr;
+ scripts_domain = nullptr;
+
+ // Leave the rest to 'mono_jit_cleanup'
+#endif
+
+ const uint32_t *k = nullptr;
while ((k = assemblies.next(k))) {
HashMap<String, GDMonoAssembly *> &domain_assemblies = assemblies.get(*k);
- const String *kk = NULL;
+ const String *kk = nullptr;
while ((kk = domain_assemblies.next(kk))) {
memdelete(domain_assemblies.get(*kk));
}
@@ -1245,22 +1305,22 @@ GDMono::~GDMono() {
mono_jit_cleanup(root_domain);
-#if defined(ANDROID_ENABLED)
- GDMonoAndroid::cleanup();
-#endif
-
print_verbose("Mono: Finalized");
runtime_initialized = false;
}
+#if defined(ANDROID_ENABLED)
+ gdmono::android::support::cleanup();
+#endif
+
if (gdmono_log)
memdelete(gdmono_log);
- singleton = NULL;
+ singleton = nullptr;
}
-_GodotSharp *_GodotSharp::singleton = NULL;
+_GodotSharp *_GodotSharp::singleton = nullptr;
void _GodotSharp::attach_thread() {
@@ -1288,7 +1348,7 @@ int32_t _GodotSharp::get_scripts_domain_id() {
bool _GodotSharp::is_scripts_domain_loaded() {
- return GDMono::get_singleton()->is_runtime_initialized() && GDMono::get_singleton()->get_scripts_domain() != NULL;
+ return GDMono::get_singleton()->is_runtime_initialized() && GDMono::get_singleton()->get_scripts_domain() != nullptr;
}
bool _GodotSharp::_is_domain_finalizing_for_unload(int32_t p_domain_id) {
@@ -1327,7 +1387,10 @@ bool _GodotSharp::is_runtime_initialized() {
void _GodotSharp::_reload_assemblies(bool p_soft_reload) {
#ifdef GD_MONO_HOT_RELOAD
- CSharpLanguage::get_singleton()->reload_assemblies(p_soft_reload);
+ // This method may be called more than once with `call_deferred`, so we need to check
+ // again if reloading is needed to avoid reloading multiple times unnecessarily.
+ if (CSharpLanguage::get_singleton()->is_assembly_reloading_needed())
+ CSharpLanguage::get_singleton()->reload_assemblies(p_soft_reload);
#endif
}
@@ -1353,5 +1416,5 @@ _GodotSharp::_GodotSharp() {
_GodotSharp::~_GodotSharp() {
- singleton = NULL;
+ singleton = nullptr;
}
diff --git a/modules/mono/mono_gd/gd_mono.h b/modules/mono/mono_gd/gd_mono.h
index 9528c64f8d..4898833e8e 100644
--- a/modules/mono/mono_gd/gd_mono.h
+++ b/modules/mono/mono_gd/gd_mono.h
@@ -91,7 +91,7 @@ public:
bool out_of_sync;
LoadedApiAssembly() :
- assembly(NULL),
+ assembly(nullptr),
out_of_sync(false) {
}
};
@@ -144,8 +144,10 @@ private:
void _register_internal_calls();
+#ifndef GD_MONO_SINGLE_APPDOMAIN
Error _load_scripts_domain();
Error _unload_scripts_domain();
+#endif
void _domain_assemblies_cleanup(uint32_t p_domain_id);
@@ -198,7 +200,7 @@ public:
#ifdef TOOLS_ENABLED
bool copy_prebuilt_api_assembly(ApiAssemblyInfo::Type p_api_type, const String &p_config);
- String update_api_assemblies_from_prebuilt(const String &p_config, const bool *p_core_api_out_of_sync = NULL, const bool *p_editor_api_out_of_sync = NULL);
+ String update_api_assemblies_from_prebuilt(const String &p_config, const bool *p_core_api_out_of_sync = nullptr, const bool *p_editor_api_out_of_sync = nullptr);
#endif
static GDMono *get_singleton() { return singleton; }
@@ -209,7 +211,7 @@ public:
// Do not use these, unless you know what you're doing
void add_assembly(uint32_t p_domain_id, GDMonoAssembly *p_assembly);
- GDMonoAssembly **get_loaded_assembly(const String &p_name);
+ GDMonoAssembly *get_loaded_assembly(const String &p_name);
_FORCE_INLINE_ bool is_runtime_initialized() const { return runtime_initialized && !mono_runtime_is_shutting_down() /* stays true after shutdown finished */; }
@@ -263,7 +265,7 @@ public:
this->prev_domain = prev_domain;
mono_domain_set(p_domain, false);
} else {
- this->prev_domain = NULL;
+ this->prev_domain = nullptr;
}
}
diff --git a/modules/mono/mono_gd/gd_mono_assembly.cpp b/modules/mono/mono_gd/gd_mono_assembly.cpp
index 6da1db249c..0f211eebc6 100644
--- a/modules/mono/mono_gd/gd_mono_assembly.cpp
+++ b/modules/mono/mono_gd/gd_mono_assembly.cpp
@@ -42,9 +42,6 @@
#include "gd_mono_cache.h"
#include "gd_mono_class.h"
-bool GDMonoAssembly::no_search = false;
-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 String &p_custom_bcl_dir) {
@@ -94,19 +91,30 @@ void GDMonoAssembly::fill_search_dirs(Vector<String> &r_search_dirs, const Strin
#endif
}
+// This is how these assembly loading hooks work:
+//
+// - The 'search' hook checks if the assembly has already been loaded, to avoid loading again.
+// - The 'preload' hook does the actual loading and is only called if the
+// 'search' hook didn't find the assembly in the list of loaded assemblies.
+// - The 'load' hook is called after the assembly has been loaded. Its job is to add the
+// assembly to the list of loaded assemblies so that the 'search' hook can look it up.
+
void GDMonoAssembly::assembly_load_hook(MonoAssembly *assembly, void *user_data) {
- if (no_search)
- return;
-
- // If our search and preload hooks fail to load the assembly themselves, the mono runtime still might.
- // Just do Assembly.LoadFrom("/Full/Path/On/Disk.dll");
- // In this case, we wouldn't have the assembly known in GDMono, which causes crashes
- // if any class inside the assembly is looked up by Godot.
- // And causing a lookup like that is as easy as throwing an exception defined in it...
- // No, we can't make the assembly load hooks smart enough because they get passed a MonoAssemblyName* only,
- // not the disk path passed to say Assembly.LoadFrom().
- _wrap_mono_assembly(assembly);
+ String name = String::utf8(mono_assembly_name_get_name(mono_assembly_get_name(assembly)));
+
+ MonoImage *image = mono_assembly_get_image(assembly);
+
+ GDMonoAssembly *gdassembly = memnew(GDMonoAssembly(name, image, assembly));
+
+#ifdef GD_MONO_HOT_RELOAD
+ const char *path = mono_image_get_filename(image);
+ if (FileAccess::exists(path))
+ gdassembly->modified_time = FileAccess::get_modified_time(path);
+#endif
+
+ MonoDomain *domain = mono_domain_get();
+ GDMono::get_singleton()->add_assembly(domain ? mono_domain_get_id(domain) : 0, gdassembly);
}
MonoAssembly *GDMonoAssembly::assembly_search_hook(MonoAssemblyName *aname, void *user_data) {
@@ -132,71 +140,24 @@ MonoAssembly *GDMonoAssembly::_search_hook(MonoAssemblyName *aname, void *user_d
String name = String::utf8(mono_assembly_name_get_name(aname));
bool has_extension = name.ends_with(".dll") || name.ends_with(".exe");
- if (no_search)
- return NULL;
-
- GDMonoAssembly **loaded_asm = GDMono::get_singleton()->get_loaded_assembly(has_extension ? name.get_basename() : name);
+ GDMonoAssembly *loaded_asm = GDMono::get_singleton()->get_loaded_assembly(has_extension ? name.get_basename() : name);
if (loaded_asm)
- return (*loaded_asm)->get_assembly();
-
- no_search = true; // Avoid the recursion madness
-
- GDMonoAssembly *res = _load_assembly_search(name, search_dirs, refonly);
+ return loaded_asm->get_assembly();
- no_search = false;
-
- return res ? res->get_assembly() : NULL;
+ return nullptr;
}
-static thread_local MonoImage *image_corlib_loading = NULL;
-
MonoAssembly *GDMonoAssembly::_preload_hook(MonoAssemblyName *aname, char **, void *user_data, bool refonly) {
(void)user_data; // UNUSED
- {
- // If we find the assembly here, we load it with 'mono_assembly_load_from_full',
- // which in turn invokes load hooks before returning the MonoAssembly to us.
- // One of the load hooks is 'load_aot_module'. This hook can end up calling preload hooks
- // again for the same assembly in certain in certain circumstances (the 'do_load_image' part).
- // If this is the case and we return NULL due to the no_search condition below,
- // it will result in an internal crash later on. Therefore we need to return the assembly we didn't
- // get yet from 'mono_assembly_load_from_full'. Luckily we have the image, which already got it.
- // This must be done here. If done in search hooks, it would cause 'mono_assembly_load_from_full'
- // to think another MonoAssembly for this assembly was already loaded, making it delete its own,
- // when in fact both pointers were the same... This hooks thing is confusing.
- if (image_corlib_loading) {
- return mono_image_get_assembly(image_corlib_loading);
- }
- }
-
- if (no_search)
- return NULL;
-
- no_search = true;
- in_preload = true;
-
String name = String::utf8(mono_assembly_name_get_name(aname));
- bool has_extension = name.ends_with(".dll");
-
- GDMonoAssembly *res = NULL;
- if (has_extension ? name == "mscorlib.dll" : name == "mscorlib") {
- GDMonoAssembly **stored_assembly = GDMono::get_singleton()->get_loaded_assembly(has_extension ? name.get_basename() : name);
- if (stored_assembly)
- return (*stored_assembly)->get_assembly();
-
- res = _load_assembly_search("mscorlib.dll", search_dirs, refonly);
- }
-
- no_search = false;
- in_preload = false;
-
- return res ? res->get_assembly() : NULL;
+ return _load_assembly_search(name, search_dirs, refonly);
}
-GDMonoAssembly *GDMonoAssembly::_load_assembly_search(const String &p_name, const Vector<String> &p_search_dirs, bool p_refonly) {
+MonoAssembly *GDMonoAssembly::_load_assembly_search(const String &p_name, const Vector<String> &p_search_dirs, bool p_refonly) {
- GDMonoAssembly *res = NULL;
+ MonoAssembly *res = nullptr;
String path;
bool has_extension = p_name.ends_with(".dll") || p_name.ends_with(".exe");
@@ -207,28 +168,28 @@ GDMonoAssembly *GDMonoAssembly::_load_assembly_search(const String &p_name, cons
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)
+ res = _real_load_assembly_from(path, p_refonly);
+ if (res != nullptr)
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)
+ res = _real_load_assembly_from(path, p_refonly);
+ if (res != nullptr)
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)
+ res = _real_load_assembly_from(path, p_refonly);
+ if (res != nullptr)
return res;
}
}
}
- return NULL;
+ return nullptr;
}
String GDMonoAssembly::find_assembly(const String &p_name) {
@@ -258,91 +219,50 @@ String GDMonoAssembly::find_assembly(const String &p_name) {
return String();
}
-GDMonoAssembly *GDMonoAssembly::_load_assembly_from(const String &p_name, const String &p_path, bool p_refonly) {
-
- GDMonoAssembly *assembly = memnew(GDMonoAssembly(p_name, p_path));
-
- Error err = assembly->load(p_refonly);
-
- if (err != OK) {
- memdelete(assembly);
- ERR_FAIL_V(NULL);
- }
-
- MonoDomain *domain = mono_domain_get();
- GDMono::get_singleton()->add_assembly(domain ? mono_domain_get_id(domain) : 0, assembly);
-
- return assembly;
-}
-
-void GDMonoAssembly::_wrap_mono_assembly(MonoAssembly *assembly) {
- String name = String::utf8(mono_assembly_name_get_name(mono_assembly_get_name(assembly)));
-
- MonoImage *image = mono_assembly_get_image(assembly);
-
- GDMonoAssembly *gdassembly = memnew(GDMonoAssembly(name, mono_image_get_filename(image)));
- Error err = gdassembly->wrapper_for_image(image);
-
- if (err != OK) {
- memdelete(gdassembly);
- ERR_FAIL();
- }
-
- MonoDomain *domain = mono_domain_get();
- GDMono::get_singleton()->add_assembly(domain ? mono_domain_get_id(domain) : 0, gdassembly);
-}
-
void GDMonoAssembly::initialize() {
fill_search_dirs(search_dirs);
- mono_install_assembly_search_hook(&assembly_search_hook, NULL);
- mono_install_assembly_refonly_search_hook(&assembly_refonly_search_hook, NULL);
- mono_install_assembly_preload_hook(&assembly_preload_hook, NULL);
- mono_install_assembly_refonly_preload_hook(&assembly_refonly_preload_hook, NULL);
- mono_install_assembly_load_hook(&assembly_load_hook, NULL);
+ mono_install_assembly_search_hook(&assembly_search_hook, nullptr);
+ mono_install_assembly_refonly_search_hook(&assembly_refonly_search_hook, nullptr);
+ mono_install_assembly_preload_hook(&assembly_preload_hook, nullptr);
+ mono_install_assembly_refonly_preload_hook(&assembly_refonly_preload_hook, nullptr);
+ mono_install_assembly_load_hook(&assembly_load_hook, nullptr);
}
-Error GDMonoAssembly::load(bool p_refonly) {
-
- ERR_FAIL_COND_V(loaded, ERR_FILE_ALREADY_IN_USE);
-
- refonly = p_refonly;
-
- uint64_t last_modified_time = FileAccess::get_modified_time(path);
+MonoAssembly *GDMonoAssembly::_real_load_assembly_from(const String &p_path, bool p_refonly) {
- Vector<uint8_t> data = FileAccess::get_file_as_array(path);
- ERR_FAIL_COND_V(data.empty(), ERR_FILE_CANT_READ);
+ Vector<uint8_t> data = FileAccess::get_file_as_array(p_path);
+ ERR_FAIL_COND_V_MSG(data.empty(), nullptr, "Could read the assembly in the specified location");
String image_filename;
#ifdef ANDROID_ENABLED
- if (path.begins_with("res://")) {
- image_filename = path.substr(6, path.length());
+ if (p_path.begins_with("res://")) {
+ image_filename = p_path.substr(6, p_path.length());
} else {
- image_filename = ProjectSettings::get_singleton()->globalize_path(path);
+ image_filename = ProjectSettings::get_singleton()->globalize_path(p_path);
}
#else
// FIXME: globalize_path does not work on exported games
- image_filename = ProjectSettings::get_singleton()->globalize_path(path);
+ image_filename = ProjectSettings::get_singleton()->globalize_path(p_path);
#endif
MonoImageOpenStatus status = MONO_IMAGE_OK;
- image = mono_image_open_from_data_with_name(
+ MonoImage *image = mono_image_open_from_data_with_name(
(char *)&data[0], data.size(),
- true, &status, refonly,
- image_filename.utf8().get_data());
+ true, &status, p_refonly,
+ image_filename.utf8());
- ERR_FAIL_COND_V(status != MONO_IMAGE_OK, ERR_FILE_CANT_OPEN);
- ERR_FAIL_NULL_V(image, ERR_FILE_CANT_OPEN);
+ ERR_FAIL_COND_V_MSG(status != MONO_IMAGE_OK || !image, nullptr, "Failed to open assembly image from the loaded data");
#ifdef DEBUG_ENABLED
Vector<uint8_t> pdb_data;
- String pdb_path(path + ".pdb");
+ String pdb_path(p_path + ".pdb");
if (!FileAccess::exists(pdb_path)) {
- pdb_path = path.get_basename() + ".pdb"; // without .dll
+ pdb_path = p_path.get_basename() + ".pdb"; // without .dll
if (!FileAccess::exists(pdb_path))
goto no_pdb;
@@ -357,44 +277,34 @@ no_pdb:
#endif
- bool is_corlib_preload = in_preload && name == "mscorlib";
+ bool need_manual_load_hook = mono_image_get_assembly(image) != nullptr; // Re-using an existing image with an assembly loaded
- if (is_corlib_preload)
- image_corlib_loading = image;
+ status = MONO_IMAGE_OK;
- assembly = mono_assembly_load_from_full(image, image_filename.utf8().get_data(), &status, refonly);
+ MonoAssembly *assembly = mono_assembly_load_from_full(image, image_filename.utf8().get_data(), &status, p_refonly);
- if (is_corlib_preload)
- image_corlib_loading = NULL;
+ ERR_FAIL_COND_V_MSG(status != MONO_IMAGE_OK || !assembly, nullptr, "Failed to load assembly for image");
- ERR_FAIL_COND_V(status != MONO_IMAGE_OK || assembly == NULL, ERR_FILE_CANT_OPEN);
+ if (need_manual_load_hook) {
+ // For some reason if an assembly survived domain reloading (maybe because it's referenced somewhere else),
+ // the mono internal search hook don't detect it, yet mono_image_open_from_data_with_name re-uses the image
+ // and assembly, and mono_assembly_load_from_full doesn't call the load hook. We need to call it manually.
+ String name = String::utf8(mono_assembly_name_get_name(mono_assembly_get_name(assembly)));
+ bool has_extension = name.ends_with(".dll") || name.ends_with(".exe");
+ GDMonoAssembly *loaded_asm = GDMono::get_singleton()->get_loaded_assembly(has_extension ? name.get_basename() : name);
+ if (!loaded_asm)
+ assembly_load_hook(assembly, nullptr);
+ }
// Decrement refcount which was previously incremented by mono_image_open_from_data_with_name
mono_image_close(image);
- loaded = true;
- modified_time = last_modified_time;
-
- return OK;
-}
-
-Error GDMonoAssembly::wrapper_for_image(MonoImage *p_image) {
-
- ERR_FAIL_COND_V(loaded, ERR_FILE_ALREADY_IN_USE);
-
- assembly = mono_image_get_assembly(p_image);
- ERR_FAIL_NULL_V(assembly, FAILED);
-
- image = p_image;
-
- loaded = true;
-
- return OK;
+ return assembly;
}
void GDMonoAssembly::unload() {
- ERR_FAIL_COND(!loaded);
+ ERR_FAIL_NULL(image); // Should not be called if already unloaded
for (Map<MonoClass *, GDMonoClass *>::Element *E = cached_raw.front(); E; E = E->next()) {
memdelete(E->value());
@@ -403,14 +313,17 @@ void GDMonoAssembly::unload() {
cached_classes.clear();
cached_raw.clear();
- assembly = NULL;
- image = NULL;
- loaded = false;
+ assembly = nullptr;
+ image = nullptr;
+}
+
+String GDMonoAssembly::get_path() const {
+ return String::utf8(mono_image_get_filename(image));
}
GDMonoClass *GDMonoAssembly::get_class(const StringName &p_namespace, const StringName &p_name) {
- ERR_FAIL_COND_V(!loaded, NULL);
+ ERR_FAIL_NULL_V(image, nullptr);
ClassKey key(p_namespace, p_name);
@@ -422,7 +335,7 @@ GDMonoClass *GDMonoAssembly::get_class(const StringName &p_namespace, const Stri
MonoClass *mono_class = mono_class_from_name(image, String(p_namespace).utf8(), String(p_name).utf8());
if (!mono_class)
- return NULL;
+ return nullptr;
GDMonoClass *wrapped_class = memnew(GDMonoClass(p_namespace, p_name, mono_class, this));
@@ -434,7 +347,7 @@ GDMonoClass *GDMonoAssembly::get_class(const StringName &p_namespace, const Stri
GDMonoClass *GDMonoAssembly::get_class(MonoClass *p_mono_class) {
- ERR_FAIL_COND_V(!loaded, NULL);
+ ERR_FAIL_NULL_V(image, nullptr);
Map<MonoClass *, GDMonoClass *>::Element *match = cached_raw.find(p_mono_class);
@@ -454,7 +367,7 @@ GDMonoClass *GDMonoAssembly::get_class(MonoClass *p_mono_class) {
GDMonoClass *GDMonoAssembly::get_object_derived_class(const StringName &p_class) {
- GDMonoClass *match = NULL;
+ GDMonoClass *match = nullptr;
if (gdobject_class_cache_updated) {
Map<StringName, GDMonoClass *>::Element *result = gdobject_class_cache.find(p_class);
@@ -486,7 +399,7 @@ GDMonoClass *GDMonoAssembly::get_object_derived_class(const StringName &p_class)
GDMonoClass *current_nested = nested_classes.front()->get();
nested_classes.pop_back();
- void *iter = NULL;
+ void *iter = nullptr;
while (true) {
MonoClass *raw_nested = mono_class_get_nested_types(current_nested->get_mono_ptr(), &iter);
@@ -514,32 +427,38 @@ GDMonoClass *GDMonoAssembly::get_object_derived_class(const StringName &p_class)
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;
-#ifdef DEBUG_ENABLED
- CRASH_COND(!FileAccess::exists(p_path));
-#endif
- no_search = true;
- GDMonoAssembly *res = _load_assembly_from(p_name, p_path, p_refonly);
- no_search = false;
- return res;
-}
+ if (p_name == "mscorlib" || p_name == "mscorlib.dll")
+ return GDMono::get_singleton()->get_corlib_assembly();
-GDMonoAssembly::GDMonoAssembly(const String &p_name, const String &p_path) {
+ // We need to manually call the search hook in this case, as it won't be called in the next step
+ MonoAssemblyName *aname = mono_assembly_name_new(p_name.utf8());
+ MonoAssembly *assembly = mono_assembly_invoke_search_hook(aname);
+ mono_assembly_name_free(aname);
+ mono_free(aname);
+
+ if (!assembly) {
+ assembly = _real_load_assembly_from(p_path, p_refonly);
+ ERR_FAIL_NULL_V(assembly, nullptr);
+ }
- loaded = false;
- gdobject_class_cache_updated = false;
- name = p_name;
- path = p_path;
- refonly = false;
- modified_time = 0;
- assembly = NULL;
- image = NULL;
+ GDMonoAssembly *loaded_asm = GDMono::get_singleton()->get_loaded_assembly(p_name);
+ ERR_FAIL_NULL_V_MSG(loaded_asm, nullptr, "Loaded assembly missing from table. Did we not receive the load hook?");
+
+ return loaded_asm;
+}
+
+GDMonoAssembly::GDMonoAssembly(const String &p_name, MonoImage *p_image, MonoAssembly *p_assembly) :
+ name(p_name),
+ image(p_image),
+ assembly(p_assembly),
+#ifdef GD_MONO_HOT_RELOAD
+ modified_time(0),
+#endif
+ gdobject_class_cache_updated(false) {
}
GDMonoAssembly::~GDMonoAssembly() {
- if (loaded)
+ if (image)
unload();
}
diff --git a/modules/mono/mono_gd/gd_mono_assembly.h b/modules/mono/mono_gd/gd_mono_assembly.h
index 4740e10339..43c8225b74 100644
--- a/modules/mono/mono_gd/gd_mono_assembly.h
+++ b/modules/mono/mono_gd/gd_mono_assembly.h
@@ -68,24 +68,20 @@ class GDMonoAssembly {
StringName class_name;
};
- MonoAssembly *assembly;
+ String name;
MonoImage *image;
+ MonoAssembly *assembly;
- bool refonly;
- bool loaded;
-
- String name;
- String path;
+#ifdef GD_MONO_HOT_RELOAD
uint64_t modified_time;
-
- HashMap<ClassKey, GDMonoClass *, ClassKey::Hasher> cached_classes;
- Map<MonoClass *, GDMonoClass *> cached_raw;
+#endif
bool gdobject_class_cache_updated;
Map<StringName, GDMonoClass *> gdobject_class_cache;
- static bool no_search;
- static bool in_preload;
+ HashMap<ClassKey, GDMonoClass *, ClassKey::Hasher> cached_classes;
+ Map<MonoClass *, GDMonoClass *> cached_raw;
+
static Vector<String> search_dirs;
static void assembly_load_hook(MonoAssembly *assembly, void *user_data);
@@ -97,25 +93,24 @@ class GDMonoAssembly {
static MonoAssembly *_search_hook(MonoAssemblyName *aname, void *user_data, bool refonly);
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);
+ static MonoAssembly *_real_load_assembly_from(const String &p_path, bool p_refonly);
+ static MonoAssembly *_load_assembly_search(const String &p_name, const Vector<String> &p_search_dirs, bool p_refonly);
friend class GDMono;
static void initialize();
public:
- Error load(bool p_refonly);
- Error wrapper_for_image(MonoImage *p_image);
void unload();
- _FORCE_INLINE_ bool is_refonly() const { return refonly; }
- _FORCE_INLINE_ bool is_loaded() const { return loaded; }
_FORCE_INLINE_ MonoImage *get_image() const { return image; }
_FORCE_INLINE_ MonoAssembly *get_assembly() const { return assembly; }
_FORCE_INLINE_ String get_name() const { return name; }
- _FORCE_INLINE_ String get_path() const { return path; }
+
+#ifdef GD_MONO_HOT_RELOAD
_FORCE_INLINE_ uint64_t get_modified_time() const { return modified_time; }
+#endif
+
+ String get_path() const;
GDMonoClass *get_class(const StringName &p_namespace, const StringName &p_name);
GDMonoClass *get_class(MonoClass *p_mono_class);
@@ -128,7 +123,7 @@ public:
static GDMonoAssembly *load_from(const String &p_name, const String &p_path, bool p_refonly);
- GDMonoAssembly(const String &p_name, const String &p_path = String());
+ GDMonoAssembly(const String &p_name, MonoImage *p_image, MonoAssembly *p_assembly);
~GDMonoAssembly();
};
diff --git a/modules/mono/mono_gd/gd_mono_cache.cpp b/modules/mono/mono_gd/gd_mono_cache.cpp
index be0b846702..5ddf18d544 100644
--- a/modules/mono/mono_gd/gd_mono_cache.cpp
+++ b/modules/mono/mono_gd/gd_mono_cache.cpp
@@ -40,11 +40,11 @@ namespace GDMonoCache {
CachedData cached_data;
-#define CACHE_AND_CHECK(m_var, m_val) \
- { \
- CRASH_COND(m_var != NULL); \
- m_var = m_val; \
- ERR_FAIL_COND_MSG(m_var == NULL, "Mono Cache: Member " #m_var " is null."); \
+#define CACHE_AND_CHECK(m_var, m_val) \
+ { \
+ CRASH_COND(m_var != nullptr); \
+ m_var = m_val; \
+ ERR_FAIL_COND_MSG(m_var == nullptr, "Mono Cache: Member " #m_var " is null."); \
}
#define CACHE_CLASS_AND_CHECK(m_class, m_val) CACHE_AND_CHECK(cached_data.class_##m_class, m_val)
@@ -54,12 +54,12 @@ CachedData cached_data;
#define CACHE_METHOD_AND_CHECK(m_class, m_method, m_val) CACHE_AND_CHECK(cached_data.method_##m_class##_##m_method, m_val)
#define CACHE_PROPERTY_AND_CHECK(m_class, m_property, m_val) CACHE_AND_CHECK(cached_data.property_##m_class##_##m_property, m_val)
-#define CACHE_METHOD_THUNK_AND_CHECK_IMPL(m_var, m_val) \
- { \
- CRASH_COND(!m_var.is_null()); \
- ERR_FAIL_COND_MSG(m_val == NULL, "Mono Cache: Method for member " #m_var " is null."); \
- m_var.set_from_method(m_val); \
- ERR_FAIL_COND_MSG(m_var.is_null(), "Mono Cache: Member " #m_var " is null."); \
+#define CACHE_METHOD_THUNK_AND_CHECK_IMPL(m_var, m_val) \
+ { \
+ CRASH_COND(!m_var.is_null()); \
+ ERR_FAIL_COND_MSG(m_val == nullptr, "Mono Cache: Method for member " #m_var " is null."); \
+ m_var.set_from_method(m_val); \
+ ERR_FAIL_COND_MSG(m_var.is_null(), "Mono Cache: Member " #m_var " is null."); \
}
#define CACHE_METHOD_THUNK_AND_CHECK(m_class, m_method, m_val) CACHE_METHOD_THUNK_AND_CHECK_IMPL(cached_data.methodthunk_##m_class##_##m_method, m_val)
@@ -68,93 +68,94 @@ void CachedData::clear_corlib_cache() {
corlib_cache_updated = false;
- class_MonoObject = NULL;
- class_bool = NULL;
- class_int8_t = NULL;
- class_int16_t = NULL;
- class_int32_t = NULL;
- class_int64_t = NULL;
- class_uint8_t = NULL;
- class_uint16_t = NULL;
- class_uint32_t = NULL;
- class_uint64_t = NULL;
- class_float = NULL;
- class_double = NULL;
- class_String = NULL;
- class_IntPtr = NULL;
-
- class_System_Collections_IEnumerable = NULL;
- class_System_Collections_IDictionary = NULL;
+ class_MonoObject = nullptr;
+ class_bool = nullptr;
+ class_int8_t = nullptr;
+ class_int16_t = nullptr;
+ class_int32_t = nullptr;
+ class_int64_t = nullptr;
+ class_uint8_t = nullptr;
+ class_uint16_t = nullptr;
+ class_uint32_t = nullptr;
+ class_uint64_t = nullptr;
+ class_float = nullptr;
+ class_double = nullptr;
+ class_String = nullptr;
+ class_IntPtr = nullptr;
+
+ class_System_Collections_IEnumerable = nullptr;
+ class_System_Collections_ICollection = nullptr;
+ class_System_Collections_IDictionary = nullptr;
#ifdef DEBUG_ENABLED
- class_System_Diagnostics_StackTrace = NULL;
+ class_System_Diagnostics_StackTrace = nullptr;
methodthunk_System_Diagnostics_StackTrace_GetFrames.nullify();
- method_System_Diagnostics_StackTrace_ctor_bool = NULL;
- method_System_Diagnostics_StackTrace_ctor_Exception_bool = NULL;
+ method_System_Diagnostics_StackTrace_ctor_bool = nullptr;
+ method_System_Diagnostics_StackTrace_ctor_Exception_bool = nullptr;
#endif
- class_KeyNotFoundException = NULL;
+ class_KeyNotFoundException = nullptr;
}
void CachedData::clear_godot_api_cache() {
godot_api_cache_updated = false;
- rawclass_Dictionary = NULL;
-
- class_Vector2 = NULL;
- class_Vector2i = NULL;
- class_Rect2 = NULL;
- class_Rect2i = NULL;
- class_Transform2D = NULL;
- class_Vector3 = NULL;
- class_Vector3i = NULL;
- class_Basis = NULL;
- class_Quat = NULL;
- class_Transform = NULL;
- class_AABB = NULL;
- class_Color = NULL;
- class_Plane = NULL;
- class_StringName = NULL;
- class_NodePath = NULL;
- class_RID = NULL;
- class_GodotObject = NULL;
- class_GodotResource = NULL;
- class_Node = NULL;
- class_Control = NULL;
- class_Spatial = NULL;
- class_WeakRef = NULL;
- class_Callable = NULL;
- class_SignalInfo = NULL;
- class_Array = NULL;
- class_Dictionary = NULL;
- class_MarshalUtils = NULL;
- class_ISerializationListener = NULL;
+ rawclass_Dictionary = nullptr;
+
+ class_Vector2 = nullptr;
+ class_Vector2i = nullptr;
+ class_Rect2 = nullptr;
+ class_Rect2i = nullptr;
+ class_Transform2D = nullptr;
+ class_Vector3 = nullptr;
+ class_Vector3i = nullptr;
+ class_Basis = nullptr;
+ class_Quat = nullptr;
+ class_Transform = nullptr;
+ class_AABB = nullptr;
+ class_Color = nullptr;
+ class_Plane = nullptr;
+ class_StringName = nullptr;
+ class_NodePath = nullptr;
+ class_RID = nullptr;
+ class_GodotObject = nullptr;
+ class_GodotResource = nullptr;
+ class_Node = nullptr;
+ class_Control = nullptr;
+ class_Node3D = nullptr;
+ class_WeakRef = nullptr;
+ class_Callable = nullptr;
+ class_SignalInfo = nullptr;
+ class_Array = nullptr;
+ class_Dictionary = nullptr;
+ class_MarshalUtils = nullptr;
+ class_ISerializationListener = nullptr;
#ifdef DEBUG_ENABLED
- class_DebuggingUtils = NULL;
+ class_DebuggingUtils = nullptr;
methodthunk_DebuggingUtils_GetStackFrameInfo.nullify();
#endif
- class_ExportAttribute = NULL;
- field_ExportAttribute_hint = NULL;
- field_ExportAttribute_hintString = NULL;
- class_SignalAttribute = NULL;
- class_ToolAttribute = NULL;
- class_RemoteAttribute = NULL;
- class_MasterAttribute = NULL;
- class_PuppetAttribute = NULL;
- class_RemoteSyncAttribute = NULL;
- class_MasterSyncAttribute = NULL;
- class_PuppetSyncAttribute = NULL;
- class_GodotMethodAttribute = NULL;
- field_GodotMethodAttribute_methodName = NULL;
-
- field_GodotObject_ptr = NULL;
- field_StringName_ptr = NULL;
- field_NodePath_ptr = NULL;
- field_Image_ptr = NULL;
- field_RID_ptr = NULL;
+ class_ExportAttribute = nullptr;
+ field_ExportAttribute_hint = nullptr;
+ field_ExportAttribute_hintString = nullptr;
+ class_SignalAttribute = nullptr;
+ class_ToolAttribute = nullptr;
+ class_RemoteAttribute = nullptr;
+ class_MasterAttribute = nullptr;
+ class_PuppetAttribute = nullptr;
+ class_RemoteSyncAttribute = nullptr;
+ class_MasterSyncAttribute = nullptr;
+ class_PuppetSyncAttribute = nullptr;
+ class_GodotMethodAttribute = nullptr;
+ field_GodotMethodAttribute_methodName = nullptr;
+
+ field_GodotObject_ptr = nullptr;
+ field_StringName_ptr = nullptr;
+ field_NodePath_ptr = nullptr;
+ field_Image_ptr = nullptr;
+ field_RID_ptr = nullptr;
methodthunk_GodotObject_Dispose.nullify();
methodthunk_Array_GetPtr.nullify();
@@ -171,22 +172,18 @@ void CachedData::clear_godot_api_cache() {
methodthunk_MarshalUtils_TypeIsGenericArray.nullify();
methodthunk_MarshalUtils_TypeIsGenericDictionary.nullify();
+ methodthunk_MarshalUtils_TypeIsSystemGenericList.nullify();
+ methodthunk_MarshalUtils_TypeIsSystemGenericDictionary.nullify();
+ methodthunk_MarshalUtils_TypeIsGenericIEnumerable.nullify();
+ methodthunk_MarshalUtils_TypeIsGenericICollection.nullify();
+ methodthunk_MarshalUtils_TypeIsGenericIDictionary.nullify();
methodthunk_MarshalUtils_ArrayGetElementType.nullify();
methodthunk_MarshalUtils_DictionaryGetKeyValueTypes.nullify();
- methodthunk_MarshalUtils_GenericIEnumerableIsAssignableFromType.nullify();
- methodthunk_MarshalUtils_GenericIDictionaryIsAssignableFromType.nullify();
- methodthunk_MarshalUtils_GenericIEnumerableIsAssignableFromType_with_info.nullify();
- methodthunk_MarshalUtils_GenericIDictionaryIsAssignableFromType_with_info.nullify();
-
methodthunk_MarshalUtils_MakeGenericArrayType.nullify();
methodthunk_MarshalUtils_MakeGenericDictionaryType.nullify();
- methodthunk_MarshalUtils_EnumerableToArray.nullify();
- methodthunk_MarshalUtils_IDictionaryToDictionary.nullify();
- methodthunk_MarshalUtils_GenericIDictionaryToDictionary.nullify();
-
// End of MarshalUtils methods
task_scheduler_handle = Ref<MonoGCHandleRef>();
@@ -213,6 +210,7 @@ void update_corlib_cache() {
CACHE_CLASS_AND_CHECK(IntPtr, GDMono::get_singleton()->get_corlib_assembly()->get_class(mono_get_intptr_class()));
CACHE_CLASS_AND_CHECK(System_Collections_IEnumerable, GDMono::get_singleton()->get_corlib_assembly()->get_class("System.Collections", "IEnumerable"));
+ CACHE_CLASS_AND_CHECK(System_Collections_ICollection, GDMono::get_singleton()->get_corlib_assembly()->get_class("System.Collections", "ICollection"));
CACHE_CLASS_AND_CHECK(System_Collections_IDictionary, GDMono::get_singleton()->get_corlib_assembly()->get_class("System.Collections", "IDictionary"));
#ifdef DEBUG_ENABLED
@@ -251,7 +249,7 @@ void update_godot_api_cache() {
CACHE_CLASS_AND_CHECK(GodotResource, GODOT_API_CLASS(Resource));
CACHE_CLASS_AND_CHECK(Node, GODOT_API_CLASS(Node));
CACHE_CLASS_AND_CHECK(Control, GODOT_API_CLASS(Control));
- CACHE_CLASS_AND_CHECK(Spatial, GODOT_API_CLASS(Spatial));
+ CACHE_CLASS_AND_CHECK(Node3D, GODOT_API_CLASS(Node3D));
CACHE_CLASS_AND_CHECK(WeakRef, GODOT_API_CLASS(WeakRef));
CACHE_CLASS_AND_CHECK(Callable, GODOT_API_CLASS(Callable));
CACHE_CLASS_AND_CHECK(SignalInfo, GODOT_API_CLASS(SignalInfo));
@@ -297,22 +295,18 @@ void update_godot_api_cache() {
CACHE_METHOD_THUNK_AND_CHECK(MarshalUtils, TypeIsGenericArray, GODOT_API_CLASS(MarshalUtils)->get_method("TypeIsGenericArray", 1));
CACHE_METHOD_THUNK_AND_CHECK(MarshalUtils, TypeIsGenericDictionary, GODOT_API_CLASS(MarshalUtils)->get_method("TypeIsGenericDictionary", 1));
+ CACHE_METHOD_THUNK_AND_CHECK(MarshalUtils, TypeIsSystemGenericList, GODOT_API_CLASS(MarshalUtils)->get_method("TypeIsSystemGenericList", 1));
+ CACHE_METHOD_THUNK_AND_CHECK(MarshalUtils, TypeIsSystemGenericDictionary, GODOT_API_CLASS(MarshalUtils)->get_method("TypeIsSystemGenericDictionary", 1));
+ CACHE_METHOD_THUNK_AND_CHECK(MarshalUtils, TypeIsGenericIEnumerable, GODOT_API_CLASS(MarshalUtils)->get_method("TypeIsGenericIEnumerable", 1));
+ CACHE_METHOD_THUNK_AND_CHECK(MarshalUtils, TypeIsGenericICollection, GODOT_API_CLASS(MarshalUtils)->get_method("TypeIsGenericICollection", 1));
+ CACHE_METHOD_THUNK_AND_CHECK(MarshalUtils, TypeIsGenericIDictionary, GODOT_API_CLASS(MarshalUtils)->get_method("TypeIsGenericIDictionary", 1));
CACHE_METHOD_THUNK_AND_CHECK(MarshalUtils, ArrayGetElementType, GODOT_API_CLASS(MarshalUtils)->get_method("ArrayGetElementType", 2));
CACHE_METHOD_THUNK_AND_CHECK(MarshalUtils, DictionaryGetKeyValueTypes, GODOT_API_CLASS(MarshalUtils)->get_method("DictionaryGetKeyValueTypes", 3));
- CACHE_METHOD_THUNK_AND_CHECK(MarshalUtils, GenericIEnumerableIsAssignableFromType, GODOT_API_CLASS(MarshalUtils)->get_method("GenericIEnumerableIsAssignableFromType", 1));
- CACHE_METHOD_THUNK_AND_CHECK(MarshalUtils, GenericIDictionaryIsAssignableFromType, GODOT_API_CLASS(MarshalUtils)->get_method("GenericIDictionaryIsAssignableFromType", 1));
- CACHE_METHOD_THUNK_AND_CHECK(MarshalUtils, GenericIEnumerableIsAssignableFromType_with_info, GODOT_API_CLASS(MarshalUtils)->get_method("GenericIEnumerableIsAssignableFromType", 2));
- CACHE_METHOD_THUNK_AND_CHECK(MarshalUtils, GenericIDictionaryIsAssignableFromType_with_info, GODOT_API_CLASS(MarshalUtils)->get_method("GenericIDictionaryIsAssignableFromType", 3));
-
CACHE_METHOD_THUNK_AND_CHECK(MarshalUtils, MakeGenericArrayType, GODOT_API_CLASS(MarshalUtils)->get_method("MakeGenericArrayType", 1));
CACHE_METHOD_THUNK_AND_CHECK(MarshalUtils, MakeGenericDictionaryType, GODOT_API_CLASS(MarshalUtils)->get_method("MakeGenericDictionaryType", 2));
- CACHE_METHOD_THUNK_AND_CHECK(MarshalUtils, EnumerableToArray, GODOT_API_CLASS(MarshalUtils)->get_method("EnumerableToArray", 2));
- CACHE_METHOD_THUNK_AND_CHECK(MarshalUtils, IDictionaryToDictionary, GODOT_API_CLASS(MarshalUtils)->get_method("IDictionaryToDictionary", 2));
- CACHE_METHOD_THUNK_AND_CHECK(MarshalUtils, GenericIDictionaryToDictionary, GODOT_API_CLASS(MarshalUtils)->get_method("GenericIDictionaryToDictionary", 2));
-
// End of MarshalUtils methods
#ifdef DEBUG_ENABLED
diff --git a/modules/mono/mono_gd/gd_mono_cache.h b/modules/mono/mono_gd/gd_mono_cache.h
index b2dacee67c..3cf2bd6ce5 100644
--- a/modules/mono/mono_gd/gd_mono_cache.h
+++ b/modules/mono/mono_gd/gd_mono_cache.h
@@ -58,6 +58,7 @@ struct CachedData {
GDMonoClass *class_IntPtr; // System.IntPtr
GDMonoClass *class_System_Collections_IEnumerable;
+ GDMonoClass *class_System_Collections_ICollection;
GDMonoClass *class_System_Collections_IDictionary;
#ifdef DEBUG_ENABLED
@@ -92,7 +93,7 @@ struct CachedData {
GDMonoClass *class_GodotResource;
GDMonoClass *class_Node;
GDMonoClass *class_Control;
- GDMonoClass *class_Spatial;
+ GDMonoClass *class_Node3D;
GDMonoClass *class_WeakRef;
GDMonoClass *class_Callable;
GDMonoClass *class_SignalInfo;
@@ -141,22 +142,18 @@ struct CachedData {
GDMonoMethodThunkR<MonoBoolean, MonoReflectionType *> methodthunk_MarshalUtils_TypeIsGenericArray;
GDMonoMethodThunkR<MonoBoolean, MonoReflectionType *> methodthunk_MarshalUtils_TypeIsGenericDictionary;
+ GDMonoMethodThunkR<MonoBoolean, MonoReflectionType *> methodthunk_MarshalUtils_TypeIsSystemGenericList;
+ GDMonoMethodThunkR<MonoBoolean, MonoReflectionType *> methodthunk_MarshalUtils_TypeIsSystemGenericDictionary;
+ GDMonoMethodThunkR<MonoBoolean, MonoReflectionType *> methodthunk_MarshalUtils_TypeIsGenericIEnumerable;
+ GDMonoMethodThunkR<MonoBoolean, MonoReflectionType *> methodthunk_MarshalUtils_TypeIsGenericICollection;
+ GDMonoMethodThunkR<MonoBoolean, MonoReflectionType *> methodthunk_MarshalUtils_TypeIsGenericIDictionary;
GDMonoMethodThunk<MonoReflectionType *, MonoReflectionType **> methodthunk_MarshalUtils_ArrayGetElementType;
GDMonoMethodThunk<MonoReflectionType *, MonoReflectionType **, MonoReflectionType **> methodthunk_MarshalUtils_DictionaryGetKeyValueTypes;
- GDMonoMethodThunkR<MonoBoolean, MonoReflectionType *> methodthunk_MarshalUtils_GenericIEnumerableIsAssignableFromType;
- GDMonoMethodThunkR<MonoBoolean, MonoReflectionType *> methodthunk_MarshalUtils_GenericIDictionaryIsAssignableFromType;
- GDMonoMethodThunkR<MonoBoolean, MonoReflectionType *, MonoReflectionType **> methodthunk_MarshalUtils_GenericIEnumerableIsAssignableFromType_with_info;
- GDMonoMethodThunkR<MonoBoolean, MonoReflectionType *, MonoReflectionType **, MonoReflectionType **> methodthunk_MarshalUtils_GenericIDictionaryIsAssignableFromType_with_info;
-
GDMonoMethodThunkR<MonoReflectionType *, MonoReflectionType *> methodthunk_MarshalUtils_MakeGenericArrayType;
GDMonoMethodThunkR<MonoReflectionType *, MonoReflectionType *, MonoReflectionType *> methodthunk_MarshalUtils_MakeGenericDictionaryType;
- GDMonoMethodThunk<MonoObject *, Array *> methodthunk_MarshalUtils_EnumerableToArray;
- GDMonoMethodThunk<MonoObject *, Dictionary *> methodthunk_MarshalUtils_IDictionaryToDictionary;
- GDMonoMethodThunk<MonoObject *, Dictionary *> methodthunk_MarshalUtils_GenericIDictionaryToDictionary;
-
// End of MarshalUtils methods
Ref<MonoGCHandleRef> task_scheduler_handle;
@@ -186,14 +183,6 @@ inline void clear_godot_api_cache() {
cached_data.clear_godot_api_cache();
}
-_FORCE_INLINE_ bool tools_godot_api_check() {
-#ifdef TOOLS_ENABLED
- return cached_data.godot_api_cache_updated;
-#else
- return true; // Assume it's updated if this was called, otherwise it's a bug
-#endif
-}
-
} // namespace GDMonoCache
#define CACHED_CLASS(m_class) (GDMonoCache::cached_data.class_##m_class)
diff --git a/modules/mono/mono_gd/gd_mono_class.cpp b/modules/mono/mono_gd/gd_mono_class.cpp
index 648f5f6c6b..2c65f7e3a0 100644
--- a/modules/mono/mono_gd/gd_mono_class.cpp
+++ b/modules/mono/mono_gd/gd_mono_class.cpp
@@ -31,6 +31,7 @@
#include "gd_mono_class.h"
#include <mono/metadata/attrdefs.h>
+#include <mono/metadata/debug-helpers.h>
#include "gd_mono_assembly.h"
#include "gd_mono_cache.h"
@@ -40,7 +41,7 @@ String GDMonoClass::get_full_name(MonoClass *p_mono_class) {
// mono_type_get_full_name is not exposed to embedders, but this seems to do the job
MonoReflectionType *type_obj = mono_type_get_object(mono_domain_get(), get_mono_type(p_mono_class));
- MonoException *exc = NULL;
+ MonoException *exc = nullptr;
MonoString *str = GDMonoUtils::object_to_string((MonoObject *)type_obj, &exc);
UNHANDLED_EXCEPTION(exc);
@@ -55,7 +56,11 @@ String GDMonoClass::get_full_name() const {
return get_full_name(mono_class);
}
-MonoType *GDMonoClass::get_mono_type() {
+String GDMonoClass::get_type_desc() const {
+ return GDMonoUtils::get_type_desc(get_mono_type());
+}
+
+MonoType *GDMonoClass::get_mono_type() const {
// Careful, you cannot compare two MonoType*.
// There is mono_metadata_type_equal, how is this different from comparing two MonoClass*?
return get_mono_type(mono_class);
@@ -76,12 +81,12 @@ bool GDMonoClass::is_assignable_from(GDMonoClass *p_from) const {
GDMonoClass *GDMonoClass::get_parent_class() {
MonoClass *parent_mono_class = mono_class_get_parent(mono_class);
- return parent_mono_class ? GDMono::get_singleton()->get_class(parent_mono_class) : NULL;
+ return parent_mono_class ? GDMono::get_singleton()->get_class(parent_mono_class) : nullptr;
}
GDMonoClass *GDMonoClass::get_nesting_class() {
MonoClass *nesting_type = mono_class_get_nesting_type(mono_class);
- return nesting_type ? GDMono::get_singleton()->get_class(nesting_type) : NULL;
+ return nesting_type ? GDMono::get_singleton()->get_class(nesting_type) : nullptr;
}
#ifdef TOOLS_ENABLED
@@ -92,9 +97,9 @@ Vector<MonoClassField *> GDMonoClass::get_enum_fields() {
Vector<MonoClassField *> enum_fields;
- void *iter = NULL;
- MonoClassField *raw_field = NULL;
- while ((raw_field = mono_class_get_fields(get_mono_ptr(), &iter)) != NULL) {
+ void *iter = nullptr;
+ MonoClassField *raw_field = nullptr;
+ while ((raw_field = mono_class_get_fields(get_mono_ptr(), &iter)) != nullptr) {
uint32_t field_flags = mono_field_get_flags(raw_field);
// Enums have an instance field named value__ which holds the value of the enum.
@@ -126,21 +131,21 @@ bool GDMonoClass::has_attribute(GDMonoClass *p_attr_class) {
MonoObject *GDMonoClass::get_attribute(GDMonoClass *p_attr_class) {
#ifdef DEBUG_ENABLED
- ERR_FAIL_NULL_V(p_attr_class, NULL);
+ ERR_FAIL_NULL_V(p_attr_class, nullptr);
#endif
if (!attrs_fetched)
fetch_attributes();
if (!attributes)
- return NULL;
+ return nullptr;
return mono_custom_attrs_get_attr(attributes, p_attr_class->get_mono_ptr());
}
void GDMonoClass::fetch_attributes() {
- ERR_FAIL_COND(attributes != NULL);
+ ERR_FAIL_COND(attributes != nullptr);
attributes = mono_custom_attrs_from_class(get_mono_ptr());
attrs_fetched = true;
@@ -153,9 +158,9 @@ void GDMonoClass::fetch_methods_with_godot_api_checks(GDMonoClass *p_native_base
if (methods_fetched)
return;
- void *iter = NULL;
- MonoMethod *raw_method = NULL;
- while ((raw_method = mono_class_get_methods(get_mono_ptr(), &iter)) != NULL) {
+ void *iter = nullptr;
+ MonoMethod *raw_method = nullptr;
+ while ((raw_method = mono_class_get_methods(get_mono_ptr(), &iter)) != nullptr) {
StringName name = mono_method_get_name(raw_method);
// get_method implicitly fetches methods and adds them to this->methods
@@ -198,7 +203,7 @@ void GDMonoClass::fetch_methods_with_godot_api_checks(GDMonoClass *p_native_base
}
#endif
- uint32_t flags = mono_method_get_flags(method->mono_method, NULL);
+ uint32_t flags = mono_method_get_flags(method->mono_method, nullptr);
if (!(flags & MONO_METHOD_ATTR_VIRTUAL))
continue;
@@ -242,21 +247,21 @@ void GDMonoClass::fetch_methods_with_godot_api_checks(GDMonoClass *p_native_base
GDMonoMethod *GDMonoClass::get_fetched_method_unknown_params(const StringName &p_name) {
- ERR_FAIL_COND_V(!methods_fetched, NULL);
+ ERR_FAIL_COND_V(!methods_fetched, nullptr);
- const MethodKey *k = NULL;
+ const MethodKey *k = nullptr;
while ((k = methods.next(k))) {
if (k->name == p_name)
return methods.get(*k);
}
- return NULL;
+ return nullptr;
}
bool GDMonoClass::has_fetched_method_unknown_params(const StringName &p_name) {
- return get_fetched_method_unknown_params(p_name) != NULL;
+ return get_fetched_method_unknown_params(p_name) != nullptr;
}
bool GDMonoClass::implements_interface(GDMonoClass *p_interface) {
@@ -264,6 +269,12 @@ bool GDMonoClass::implements_interface(GDMonoClass *p_interface) {
return mono_class_implements_interface(mono_class, p_interface->get_mono_ptr());
}
+bool GDMonoClass::has_public_parameterless_ctor() {
+
+ GDMonoMethod *ctor = get_method(".ctor", 0);
+ return ctor && ctor->get_visibility() == IMonoClassMember::PUBLIC;
+}
+
GDMonoMethod *GDMonoClass::get_method(const StringName &p_name, int p_params_count) {
MethodKey key = MethodKey(p_name, p_params_count);
@@ -274,7 +285,7 @@ GDMonoMethod *GDMonoClass::get_method(const StringName &p_name, int p_params_cou
return *match;
if (methods_fetched)
- return NULL;
+ return nullptr;
MonoMethod *raw_method = mono_class_get_method_from_name(mono_class, String(p_name).utf8().get_data(), p_params_count);
@@ -285,7 +296,7 @@ GDMonoMethod *GDMonoClass::get_method(const StringName &p_name, int p_params_cou
return method;
}
- return NULL;
+ return nullptr;
}
GDMonoMethod *GDMonoClass::get_method(MonoMethod *p_raw_method) {
@@ -307,7 +318,7 @@ GDMonoMethod *GDMonoClass::get_method(MonoMethod *p_raw_method, const StringName
GDMonoMethod *GDMonoClass::get_method(MonoMethod *p_raw_method, const StringName &p_name, int p_params_count) {
- ERR_FAIL_NULL_V(p_raw_method, NULL);
+ ERR_FAIL_NULL_V(p_raw_method, nullptr);
MethodKey key = MethodKey(p_name, p_params_count);
@@ -328,7 +339,10 @@ GDMonoMethod *GDMonoClass::get_method_with_desc(const String &p_description, boo
MonoMethod *method = mono_method_desc_search_in_class(desc, mono_class);
mono_method_desc_free(desc);
- ERR_FAIL_COND_V(mono_method_get_class(method) != mono_class, NULL);
+ if (!method)
+ return nullptr;
+
+ ERR_FAIL_COND_V(mono_method_get_class(method) != mono_class, nullptr);
return get_method(method);
}
@@ -341,7 +355,7 @@ GDMonoField *GDMonoClass::get_field(const StringName &p_name) {
return result->value();
if (fields_fetched)
- return NULL;
+ return nullptr;
MonoClassField *raw_field = mono_class_get_field_from_name(mono_class, String(p_name).utf8().get_data());
@@ -352,7 +366,7 @@ GDMonoField *GDMonoClass::get_field(const StringName &p_name) {
return field;
}
- return NULL;
+ return nullptr;
}
const Vector<GDMonoField *> &GDMonoClass::get_all_fields() {
@@ -360,9 +374,9 @@ const Vector<GDMonoField *> &GDMonoClass::get_all_fields() {
if (fields_fetched)
return fields_list;
- void *iter = NULL;
- MonoClassField *raw_field = NULL;
- while ((raw_field = mono_class_get_fields(mono_class, &iter)) != NULL) {
+ void *iter = nullptr;
+ MonoClassField *raw_field = nullptr;
+ while ((raw_field = mono_class_get_fields(mono_class, &iter)) != nullptr) {
StringName name = mono_field_get_name(raw_field);
Map<StringName, GDMonoField *>::Element *match = fields.find(name);
@@ -389,7 +403,7 @@ GDMonoProperty *GDMonoClass::get_property(const StringName &p_name) {
return result->value();
if (properties_fetched)
- return NULL;
+ return nullptr;
MonoProperty *raw_property = mono_class_get_property_from_name(mono_class, String(p_name).utf8().get_data());
@@ -400,7 +414,7 @@ GDMonoProperty *GDMonoClass::get_property(const StringName &p_name) {
return property;
}
- return NULL;
+ return nullptr;
}
const Vector<GDMonoProperty *> &GDMonoClass::get_all_properties() {
@@ -408,9 +422,9 @@ const Vector<GDMonoProperty *> &GDMonoClass::get_all_properties() {
if (properties_fetched)
return properties_list;
- void *iter = NULL;
- MonoProperty *raw_property = NULL;
- while ((raw_property = mono_class_get_properties(mono_class, &iter)) != NULL) {
+ void *iter = nullptr;
+ MonoProperty *raw_property = nullptr;
+ while ((raw_property = mono_class_get_properties(mono_class, &iter)) != nullptr) {
StringName name = mono_property_get_name(raw_property);
Map<StringName, GDMonoProperty *>::Element *match = properties.find(name);
@@ -433,9 +447,9 @@ const Vector<GDMonoClass *> &GDMonoClass::get_all_delegates() {
if (delegates_fetched)
return delegates_list;
- void *iter = NULL;
- MonoClass *raw_class = NULL;
- while ((raw_class = mono_class_get_nested_types(mono_class, &iter)) != NULL) {
+ void *iter = nullptr;
+ MonoClass *raw_class = nullptr;
+ while ((raw_class = mono_class_get_nested_types(mono_class, &iter)) != nullptr) {
if (mono_class_is_delegate(raw_class)) {
StringName name = mono_class_get_name(raw_class);
@@ -459,9 +473,9 @@ const Vector<GDMonoClass *> &GDMonoClass::get_all_delegates() {
const Vector<GDMonoMethod *> &GDMonoClass::get_all_methods() {
if (!method_list_fetched) {
- void *iter = NULL;
- MonoMethod *raw_method = NULL;
- while ((raw_method = mono_class_get_methods(get_mono_ptr(), &iter)) != NULL) {
+ void *iter = nullptr;
+ MonoMethod *raw_method = nullptr;
+ while ((raw_method = mono_class_get_methods(get_mono_ptr(), &iter)) != nullptr) {
method_list.push_back(memnew(GDMonoMethod(mono_method_get_name(raw_method), raw_method)));
}
@@ -479,7 +493,7 @@ GDMonoClass::GDMonoClass(const StringName &p_namespace, const StringName &p_name
assembly = p_assembly;
attrs_fetched = false;
- attributes = NULL;
+ attributes = nullptr;
methods_fetched = false;
method_list_fetched = false;
@@ -512,7 +526,7 @@ GDMonoClass::~GDMonoClass() {
Vector<GDMonoMethod *> deleted_methods;
deleted_methods.resize(methods.size());
- const MethodKey *k = NULL;
+ const MethodKey *k = nullptr;
while ((k = methods.next(k))) {
GDMonoMethod *method = methods.get(*k);
diff --git a/modules/mono/mono_gd/gd_mono_class.h b/modules/mono/mono_gd/gd_mono_class.h
index 0c9a8cdafe..9237aae057 100644
--- a/modules/mono/mono_gd/gd_mono_class.h
+++ b/modules/mono/mono_gd/gd_mono_class.h
@@ -31,8 +31,6 @@
#ifndef GD_MONO_CLASS_H
#define GD_MONO_CLASS_H
-#include <mono/metadata/debug-helpers.h>
-
#include "core/map.h"
#include "core/ustring.h"
@@ -107,7 +105,8 @@ public:
static MonoType *get_mono_type(MonoClass *p_mono_class);
String get_full_name() const;
- MonoType *get_mono_type();
+ String get_type_desc() const;
+ MonoType *get_mono_type() const;
uint32_t get_flags() const;
bool is_static() const;
@@ -137,6 +136,7 @@ public:
void fetch_methods_with_godot_api_checks(GDMonoClass *p_native_base);
bool implements_interface(GDMonoClass *p_interface);
+ bool has_public_parameterless_ctor();
GDMonoMethod *get_method(const StringName &p_name, int p_params_count = 0);
GDMonoMethod *get_method(MonoMethod *p_raw_method);
diff --git a/modules/mono/mono_gd/gd_mono_field.cpp b/modules/mono/mono_gd/gd_mono_field.cpp
index 11942c47d9..e76cb84d43 100644
--- a/modules/mono/mono_gd/gd_mono_field.cpp
+++ b/modules/mono/mono_gd/gd_mono_field.cpp
@@ -116,7 +116,7 @@ void GDMonoField::set_value_from_variant(MonoObject *p_object, const Variant &p_
case MONO_TYPE_STRING: {
if (p_value.get_type() == Variant::NIL) {
// Otherwise, Variant -> String would return the string "Null"
- MonoString *mono_string = NULL;
+ MonoString *mono_string = nullptr;
mono_field_set_value(p_object, mono_field, mono_string);
} else {
MonoString *mono_string = GDMonoMarshal::mono_string_from_godot(p_value);
@@ -322,6 +322,13 @@ void GDMonoField::set_value_from_variant(MonoObject *p_object, const Variant &p_
break;
}
+ GDMonoClass *array_type_class = GDMono::get_singleton()->get_class(array_type->eklass);
+ if (CACHED_CLASS(GodotObject)->is_assignable_from(array_type_class)) {
+ MonoArray *managed = GDMonoMarshal::Array_to_mono_array(p_value.operator ::Array(), array_type_class);
+ mono_field_set_value(p_object, mono_field, managed);
+ break;
+ }
+
ERR_FAIL_MSG("Attempted to convert Variant to a managed array of unmarshallable element type.");
} break;
@@ -353,56 +360,22 @@ void GDMonoField::set_value_from_variant(MonoObject *p_object, const Variant &p_
break;
}
- if (CACHED_CLASS(Dictionary) == type_class) {
+ // Godot.Collections.Dictionary or IDictionary
+ if (CACHED_CLASS(Dictionary) == type_class || type_class == CACHED_CLASS(System_Collections_IDictionary)) {
MonoObject *managed = GDMonoUtils::create_managed_from(p_value.operator Dictionary(), CACHED_CLASS(Dictionary));
mono_field_set_value(p_object, mono_field, managed);
break;
}
- if (CACHED_CLASS(Array) == type_class) {
+ // Godot.Collections.Array or ICollection or IEnumerable
+ if (CACHED_CLASS(Array) == type_class ||
+ type_class == CACHED_CLASS(System_Collections_ICollection) ||
+ type_class == CACHED_CLASS(System_Collections_IEnumerable)) {
MonoObject *managed = GDMonoUtils::create_managed_from(p_value.operator Array(), CACHED_CLASS(Array));
mono_field_set_value(p_object, mono_field, managed);
break;
}
- // The order in which we check the following interfaces is very important (dictionaries and generics first)
-
- MonoReflectionType *reftype = mono_type_get_object(mono_domain_get(), type_class->get_mono_type());
-
- MonoReflectionType *key_reftype, *value_reftype;
- if (GDMonoUtils::Marshal::generic_idictionary_is_assignable_from(reftype, &key_reftype, &value_reftype)) {
- MonoObject *managed = GDMonoUtils::create_managed_from(p_value.operator Dictionary(),
- GDMonoUtils::Marshal::make_generic_dictionary_type(key_reftype, value_reftype));
- mono_field_set_value(p_object, mono_field, managed);
- break;
- }
-
- if (type_class->implements_interface(CACHED_CLASS(System_Collections_IDictionary))) {
- MonoObject *managed = GDMonoUtils::create_managed_from(p_value.operator Dictionary(), CACHED_CLASS(Dictionary));
- mono_field_set_value(p_object, mono_field, managed);
- break;
- }
-
- MonoReflectionType *elem_reftype;
- if (GDMonoUtils::Marshal::generic_ienumerable_is_assignable_from(reftype, &elem_reftype)) {
- MonoObject *managed = GDMonoUtils::create_managed_from(p_value.operator Array(),
- GDMonoUtils::Marshal::make_generic_array_type(elem_reftype));
- mono_field_set_value(p_object, mono_field, managed);
- break;
- }
-
- if (type_class->implements_interface(CACHED_CLASS(System_Collections_IEnumerable))) {
- if (GDMonoCache::tools_godot_api_check()) {
- MonoObject *managed = GDMonoUtils::create_managed_from(p_value.operator Array(), CACHED_CLASS(Array));
- mono_field_set_value(p_object, mono_field, managed);
- break;
- } else {
- MonoObject *managed = (MonoObject *)GDMonoMarshal::Array_to_mono_array(p_value.operator Array());
- mono_field_set_value(p_object, mono_field, managed);
- break;
- }
- }
-
ERR_FAIL_MSG("Attempted to set the value of a field of unmarshallable type: '" + type_class->get_name() + "'.");
} break;
@@ -535,52 +508,62 @@ void GDMonoField::set_value_from_variant(MonoObject *p_object, const Variant &p_
case MONO_TYPE_GENERICINST: {
MonoReflectionType *reftype = mono_type_get_object(mono_domain_get(), type.type_class->get_mono_type());
+ // Godot.Collections.Dictionary<TKey, TValue>
if (GDMonoUtils::Marshal::type_is_generic_dictionary(reftype)) {
MonoObject *managed = GDMonoUtils::create_managed_from(p_value.operator Dictionary(), type.type_class);
mono_field_set_value(p_object, mono_field, managed);
break;
}
+ // Godot.Collections.Array<T>
if (GDMonoUtils::Marshal::type_is_generic_array(reftype)) {
MonoObject *managed = GDMonoUtils::create_managed_from(p_value.operator Array(), type.type_class);
mono_field_set_value(p_object, mono_field, managed);
break;
}
- // The order in which we check the following interfaces is very important (dictionaries and generics first)
-
- MonoReflectionType *key_reftype, *value_reftype;
- if (GDMonoUtils::Marshal::generic_idictionary_is_assignable_from(reftype, &key_reftype, &value_reftype)) {
- MonoObject *managed = GDMonoUtils::create_managed_from(p_value.operator Dictionary(),
- GDMonoUtils::Marshal::make_generic_dictionary_type(key_reftype, value_reftype));
+ // System.Collections.Generic.Dictionary<TKey, TValue>
+ if (GDMonoUtils::Marshal::type_is_system_generic_dictionary(reftype)) {
+ MonoReflectionType *key_reftype = nullptr;
+ MonoReflectionType *value_reftype = nullptr;
+ GDMonoUtils::Marshal::dictionary_get_key_value_types(reftype, &key_reftype, &value_reftype);
+ MonoObject *managed = GDMonoMarshal::Dictionary_to_system_generic_dict(p_value.operator Dictionary(),
+ type.type_class, key_reftype, value_reftype);
mono_field_set_value(p_object, mono_field, managed);
break;
}
- if (type.type_class->implements_interface(CACHED_CLASS(System_Collections_IDictionary))) {
- MonoObject *managed = GDMonoUtils::create_managed_from(p_value.operator Dictionary(), CACHED_CLASS(Dictionary));
+ // System.Collections.Generic.List<T>
+ if (GDMonoUtils::Marshal::type_is_system_generic_list(reftype)) {
+ MonoReflectionType *elem_reftype = nullptr;
+ GDMonoUtils::Marshal::array_get_element_type(reftype, &elem_reftype);
+ MonoObject *managed = GDMonoMarshal::Array_to_system_generic_list(p_value.operator Array(),
+ type.type_class, elem_reftype);
mono_field_set_value(p_object, mono_field, managed);
break;
}
- MonoReflectionType *elem_reftype;
- if (GDMonoUtils::Marshal::generic_ienumerable_is_assignable_from(reftype, &elem_reftype)) {
- MonoObject *managed = GDMonoUtils::create_managed_from(p_value.operator Array(),
- GDMonoUtils::Marshal::make_generic_array_type(elem_reftype));
+ // IDictionary<TKey, TValue>
+ if (GDMonoUtils::Marshal::type_is_generic_idictionary(reftype)) {
+ MonoReflectionType *key_reftype;
+ MonoReflectionType *value_reftype;
+ GDMonoUtils::Marshal::dictionary_get_key_value_types(reftype, &key_reftype, &value_reftype);
+ GDMonoClass *godot_dict_class = GDMonoUtils::Marshal::make_generic_dictionary_type(key_reftype, value_reftype);
+
+ MonoObject *managed = GDMonoUtils::create_managed_from(p_value.operator Dictionary(), godot_dict_class);
mono_field_set_value(p_object, mono_field, managed);
break;
}
- if (type.type_class->implements_interface(CACHED_CLASS(System_Collections_IEnumerable))) {
- if (GDMonoCache::tools_godot_api_check()) {
- MonoObject *managed = GDMonoUtils::create_managed_from(p_value.operator Array(), CACHED_CLASS(Array));
- mono_field_set_value(p_object, mono_field, managed);
- break;
- } else {
- MonoObject *managed = (MonoObject *)GDMonoMarshal::Array_to_mono_array(p_value.operator Array());
- mono_field_set_value(p_object, mono_field, managed);
- break;
- }
+ // ICollection<T> or IEnumerable<T>
+ if (GDMonoUtils::Marshal::type_is_generic_icollection(reftype) || GDMonoUtils::Marshal::type_is_generic_ienumerable(reftype)) {
+ MonoReflectionType *elem_reftype;
+ GDMonoUtils::Marshal::array_get_element_type(reftype, &elem_reftype);
+ GDMonoClass *godot_array_class = GDMonoUtils::Marshal::make_generic_array_type(elem_reftype);
+
+ MonoObject *managed = GDMonoUtils::create_managed_from(p_value.operator Array(), godot_array_class);
+ mono_field_set_value(p_object, mono_field, managed);
+ break;
}
} break;
@@ -623,19 +606,19 @@ bool GDMonoField::has_attribute(GDMonoClass *p_attr_class) {
}
MonoObject *GDMonoField::get_attribute(GDMonoClass *p_attr_class) {
- ERR_FAIL_NULL_V(p_attr_class, NULL);
+ ERR_FAIL_NULL_V(p_attr_class, nullptr);
if (!attrs_fetched)
fetch_attributes();
if (!attributes)
- return NULL;
+ return nullptr;
return mono_custom_attrs_get_attr(attributes, p_attr_class->get_mono_ptr());
}
void GDMonoField::fetch_attributes() {
- ERR_FAIL_COND(attributes != NULL);
+ ERR_FAIL_COND(attributes != nullptr);
attributes = mono_custom_attrs_from_field(owner->get_mono_ptr(), mono_field);
attrs_fetched = true;
}
@@ -671,7 +654,7 @@ GDMonoField::GDMonoField(MonoClassField *p_mono_field, GDMonoClass *p_owner) {
type.type_class = GDMono::get_singleton()->get_class(field_type_class);
attrs_fetched = false;
- attributes = NULL;
+ attributes = nullptr;
}
GDMonoField::~GDMonoField() {
diff --git a/modules/mono/mono_gd/gd_mono_internals.cpp b/modules/mono/mono_gd/gd_mono_internals.cpp
index 53e642f317..1898785699 100644
--- a/modules/mono/mono_gd/gd_mono_internals.cpp
+++ b/modules/mono/mono_gd/gd_mono_internals.cpp
@@ -61,7 +61,7 @@ void tie_managed_to_unmanaged(MonoObject *managed, Object *unmanaged) {
GDMonoClass *native = GDMonoUtils::get_class_native_base(klass);
- CRASH_COND(native == NULL);
+ CRASH_COND(native == nullptr);
if (native == klass) {
// If it's just a wrapper Godot class and not a custom inheriting class, then attach a
@@ -119,7 +119,7 @@ void unhandled_exception(MonoException *p_exc) {
if (GDMono::get_singleton()->get_unhandled_exception_policy() == GDMono::POLICY_TERMINATE_APP) {
// Too bad 'mono_invoke_unhandled_exception_hook' is not exposed to embedders
- GDMono::unhandled_exception_hook((MonoObject *)p_exc, NULL);
+ GDMono::unhandled_exception_hook((MonoObject *)p_exc, nullptr);
GD_UNREACHABLE();
} else {
#ifdef DEBUG_ENABLED
diff --git a/modules/mono/mono_gd/gd_mono_log.cpp b/modules/mono/mono_gd/gd_mono_log.cpp
index 76828a66e0..ca16c2b76a 100644
--- a/modules/mono/mono_gd/gd_mono_log.cpp
+++ b/modules/mono/mono_gd/gd_mono_log.cpp
@@ -46,13 +46,13 @@ static CharString get_default_log_level() {
#endif
}
-GDMonoLog *GDMonoLog::singleton = NULL;
+GDMonoLog *GDMonoLog::singleton = nullptr;
-#if !defined(JAVASCRIPT_ENABLED)
+#ifdef GD_MONO_LOG_ENABLED
static int get_log_level_id(const char *p_log_level) {
- const char *valid_log_levels[] = { "error", "critical", "warning", "message", "info", "debug", NULL };
+ const char *valid_log_levels[] = { "error", "critical", "warning", "message", "info", "debug", nullptr };
int i = 0;
while (valid_log_levels[i]) {
@@ -191,7 +191,7 @@ GDMonoLog::GDMonoLog() {
GDMonoLog::~GDMonoLog() {
- singleton = NULL;
+ singleton = nullptr;
if (log_file) {
log_file->close();
@@ -213,7 +213,7 @@ GDMonoLog::GDMonoLog() {
GDMonoLog::~GDMonoLog() {
- singleton = NULL;
+ singleton = nullptr;
}
#endif // !defined(JAVASCRIPT_ENABLED)
diff --git a/modules/mono/mono_gd/gd_mono_log.h b/modules/mono/mono_gd/gd_mono_log.h
index ecf4c78b1a..1fc21f7df5 100644
--- a/modules/mono/mono_gd/gd_mono_log.h
+++ b/modules/mono/mono_gd/gd_mono_log.h
@@ -35,13 +35,18 @@
#include "core/typedefs.h"
-#if !defined(JAVASCRIPT_ENABLED)
+#if !defined(JAVASCRIPT_ENABLED) && !defined(IPHONE_ENABLED)
+// We have custom mono log callbacks for WASM and iOS
+#define GD_MONO_LOG_ENABLED
+#endif
+
+#ifdef GD_MONO_LOG_ENABLED
#include "core/os/file_access.h"
#endif
class GDMonoLog {
-#if !defined(JAVASCRIPT_ENABLED)
+#ifdef GD_MONO_LOG_ENABLED
int log_level_id;
FileAccess *log_file;
diff --git a/modules/mono/mono_gd/gd_mono_marshal.cpp b/modules/mono/mono_gd/gd_mono_marshal.cpp
index 0de5352752..91ee07388b 100644
--- a/modules/mono/mono_gd/gd_mono_marshal.cpp
+++ b/modules/mono/mono_gd/gd_mono_marshal.cpp
@@ -154,6 +154,10 @@ Variant::Type managed_to_variant_type(const ManagedType &p_type, bool *r_nil_is_
if (array_type->eklass == CACHED_CLASS_RAW(Color))
return Variant::PACKED_COLOR_ARRAY;
+
+ GDMonoClass *array_type_class = GDMono::get_singleton()->get_class(array_type->eklass);
+ if (CACHED_CLASS(GodotObject)->is_assignable_from(array_type_class))
+ return Variant::ARRAY;
} break;
case MONO_TYPE_CLASS: {
@@ -184,23 +188,14 @@ Variant::Type managed_to_variant_type(const ManagedType &p_type, bool *r_nil_is_
return Variant::ARRAY;
}
- // The order in which we check the following interfaces is very important (dictionaries and generics first)
-
- MonoReflectionType *reftype = mono_type_get_object(mono_domain_get(), type_class->get_mono_type());
-
- if (GDMonoUtils::Marshal::generic_idictionary_is_assignable_from(reftype)) {
- return Variant::DICTIONARY;
- }
-
- if (type_class->implements_interface(CACHED_CLASS(System_Collections_IDictionary))) {
+ // IDictionary
+ if (p_type.type_class == CACHED_CLASS(System_Collections_IDictionary)) {
return Variant::DICTIONARY;
}
- if (GDMonoUtils::Marshal::generic_ienumerable_is_assignable_from(reftype)) {
- return Variant::ARRAY;
- }
-
- if (type_class->implements_interface(CACHED_CLASS(System_Collections_IEnumerable))) {
+ // ICollection or IEnumerable
+ if (p_type.type_class == CACHED_CLASS(System_Collections_ICollection) ||
+ p_type.type_class == CACHED_CLASS(System_Collections_IEnumerable)) {
return Variant::ARRAY;
}
} break;
@@ -214,27 +209,33 @@ Variant::Type managed_to_variant_type(const ManagedType &p_type, bool *r_nil_is_
case MONO_TYPE_GENERICINST: {
MonoReflectionType *reftype = mono_type_get_object(mono_domain_get(), p_type.type_class->get_mono_type());
+ // Godot.Collections.Dictionary<TKey, TValue>
if (GDMonoUtils::Marshal::type_is_generic_dictionary(reftype)) {
return Variant::DICTIONARY;
}
+ // Godot.Collections.Array<T>
if (GDMonoUtils::Marshal::type_is_generic_array(reftype)) {
return Variant::ARRAY;
}
- // The order in which we check the following interfaces is very important (dictionaries and generics first)
-
- if (GDMonoUtils::Marshal::generic_idictionary_is_assignable_from(reftype))
- return Variant::DICTIONARY;
-
- if (p_type.type_class->implements_interface(CACHED_CLASS(System_Collections_IDictionary))) {
+ // System.Collections.Generic.Dictionary<TKey, TValue>
+ if (GDMonoUtils::Marshal::type_is_system_generic_dictionary(reftype)) {
return Variant::DICTIONARY;
}
- if (GDMonoUtils::Marshal::generic_ienumerable_is_assignable_from(reftype))
+ // System.Collections.Generic.List<T>
+ if (GDMonoUtils::Marshal::type_is_system_generic_list(reftype)) {
return Variant::ARRAY;
+ }
- if (p_type.type_class->implements_interface(CACHED_CLASS(System_Collections_IEnumerable))) {
+ // IDictionary<TKey, TValue>
+ if (GDMonoUtils::Marshal::type_is_generic_idictionary(reftype)) {
+ return Variant::DICTIONARY;
+ }
+
+ // ICollection<T> or IEnumerable<T>
+ if (GDMonoUtils::Marshal::type_is_generic_icollection(reftype) || GDMonoUtils::Marshal::type_is_generic_ienumerable(reftype)) {
return Variant::ARRAY;
}
} break;
@@ -252,10 +253,20 @@ Variant::Type managed_to_variant_type(const ManagedType &p_type, bool *r_nil_is_
bool try_get_array_element_type(const ManagedType &p_array_type, ManagedType &r_elem_type) {
switch (p_array_type.type_encoding) {
+ case MONO_TYPE_ARRAY:
+ case MONO_TYPE_SZARRAY: {
+ MonoArrayType *array_type = mono_type_get_array_type(p_array_type.type_class->get_mono_type());
+ GDMonoClass *array_type_class = GDMono::get_singleton()->get_class(array_type->eklass);
+ r_elem_type = ManagedType::from_class(array_type_class);
+ return true;
+ } break;
case MONO_TYPE_GENERICINST: {
MonoReflectionType *array_reftype = mono_type_get_object(mono_domain_get(), p_array_type.type_class->get_mono_type());
- if (GDMonoUtils::Marshal::type_is_generic_array(array_reftype)) {
+ if (GDMonoUtils::Marshal::type_is_generic_array(array_reftype) ||
+ GDMonoUtils::Marshal::type_is_system_generic_list(array_reftype) ||
+ GDMonoUtils::Marshal::type_is_generic_icollection(array_reftype) ||
+ GDMonoUtils::Marshal::type_is_generic_ienumerable(array_reftype)) {
MonoReflectionType *elem_reftype;
GDMonoUtils::Marshal::array_get_element_type(array_reftype, &elem_reftype);
@@ -263,12 +274,6 @@ bool try_get_array_element_type(const ManagedType &p_array_type, ManagedType &r_
r_elem_type = ManagedType::from_reftype(elem_reftype);
return true;
}
-
- MonoReflectionType *elem_reftype;
- if (GDMonoUtils::Marshal::generic_ienumerable_is_assignable_from(array_reftype, &elem_reftype)) {
- r_elem_type = ManagedType::from_reftype(elem_reftype);
- return true;
- }
} break;
default: {
} break;
@@ -282,7 +287,9 @@ bool try_get_dictionary_key_value_types(const ManagedType &p_dictionary_type, Ma
case MONO_TYPE_GENERICINST: {
MonoReflectionType *dict_reftype = mono_type_get_object(mono_domain_get(), p_dictionary_type.type_class->get_mono_type());
- if (GDMonoUtils::Marshal::type_is_generic_dictionary(dict_reftype)) {
+ if (GDMonoUtils::Marshal::type_is_generic_dictionary(dict_reftype) ||
+ GDMonoUtils::Marshal::type_is_system_generic_dictionary(dict_reftype) ||
+ GDMonoUtils::Marshal::type_is_generic_idictionary(dict_reftype)) {
MonoReflectionType *key_reftype;
MonoReflectionType *value_reftype;
@@ -292,13 +299,6 @@ bool try_get_dictionary_key_value_types(const ManagedType &p_dictionary_type, Ma
r_value_type = ManagedType::from_reftype(value_reftype);
return true;
}
-
- MonoReflectionType *key_reftype, *value_reftype;
- if (GDMonoUtils::Marshal::generic_idictionary_is_assignable_from(dict_reftype, &key_reftype, &value_reftype)) {
- r_key_type = ManagedType::from_reftype(key_reftype);
- r_value_type = ManagedType::from_reftype(value_reftype);
- return true;
- }
} break;
default: {
} break;
@@ -410,7 +410,7 @@ MonoObject *variant_to_mono_object(const Variant *p_var, const ManagedType &p_ty
case MONO_TYPE_STRING: {
if (p_var->get_type() == Variant::NIL)
- return NULL; // Otherwise, Variant -> String would return the string "Null"
+ return nullptr; // Otherwise, Variant -> String would return the string "Null"
return (MonoObject *)mono_string_from_godot(p_var->operator String());
} break;
@@ -537,7 +537,7 @@ MonoObject *variant_to_mono_object(const Variant *p_var, const ManagedType &p_ty
return BOX_ENUM(enum_baseclass, val);
}
default: {
- ERR_FAIL_V_MSG(NULL, "Attempted to convert Variant to a managed enum value of unmarshallable base type.");
+ ERR_FAIL_V_MSG(nullptr, "Attempted to convert Variant to a managed enum value of unmarshallable base type.");
}
}
}
@@ -577,7 +577,11 @@ MonoObject *variant_to_mono_object(const Variant *p_var, const ManagedType &p_ty
if (array_type->eklass == CACHED_CLASS_RAW(Color))
return (MonoObject *)PackedColorArray_to_mono_array(p_var->operator PackedColorArray());
- ERR_FAIL_V_MSG(NULL, "Attempted to convert Variant to a managed array of unmarshallable element type.");
+ GDMonoClass *array_type_class = GDMono::get_singleton()->get_class(array_type->eklass);
+ if (CACHED_CLASS(GodotObject)->is_assignable_from(array_type_class))
+ return (MonoObject *)Array_to_mono_array(p_var->operator Array(), array_type_class);
+
+ ERR_FAIL_V_MSG(nullptr, "Attempted to convert Variant to a managed array of unmarshallable element type.");
} break;
case MONO_TYPE_CLASS: {
@@ -600,41 +604,17 @@ MonoObject *variant_to_mono_object(const Variant *p_var, const ManagedType &p_ty
return GDMonoUtils::create_managed_from(p_var->operator RID());
}
- if (CACHED_CLASS(Dictionary) == type_class) {
+ // Godot.Collections.Dictionary or IDictionary
+ if (CACHED_CLASS(Dictionary) == type_class || CACHED_CLASS(System_Collections_IDictionary) == type_class) {
return GDMonoUtils::create_managed_from(p_var->operator Dictionary(), CACHED_CLASS(Dictionary));
}
- if (CACHED_CLASS(Array) == type_class) {
+ // Godot.Collections.Array or ICollection or IEnumerable
+ if (CACHED_CLASS(Array) == type_class ||
+ CACHED_CLASS(System_Collections_ICollection) == type_class ||
+ CACHED_CLASS(System_Collections_IEnumerable) == type_class) {
return GDMonoUtils::create_managed_from(p_var->operator Array(), CACHED_CLASS(Array));
}
-
- // The order in which we check the following interfaces is very important (dictionaries and generics first)
-
- MonoReflectionType *reftype = mono_type_get_object(mono_domain_get(), type_class->get_mono_type());
-
- MonoReflectionType *key_reftype, *value_reftype;
- if (GDMonoUtils::Marshal::generic_idictionary_is_assignable_from(reftype, &key_reftype, &value_reftype)) {
- return GDMonoUtils::create_managed_from(p_var->operator Dictionary(),
- GDMonoUtils::Marshal::make_generic_dictionary_type(key_reftype, value_reftype));
- }
-
- if (type_class->implements_interface(CACHED_CLASS(System_Collections_IDictionary))) {
- return GDMonoUtils::create_managed_from(p_var->operator Dictionary(), CACHED_CLASS(Dictionary));
- }
-
- MonoReflectionType *elem_reftype;
- if (GDMonoUtils::Marshal::generic_ienumerable_is_assignable_from(reftype, &elem_reftype)) {
- return GDMonoUtils::create_managed_from(p_var->operator Array(),
- GDMonoUtils::Marshal::make_generic_array_type(elem_reftype));
- }
-
- if (type_class->implements_interface(CACHED_CLASS(System_Collections_IEnumerable))) {
- if (GDMonoCache::tools_godot_api_check()) {
- return GDMonoUtils::create_managed_from(p_var->operator Array(), CACHED_CLASS(Array));
- } else {
- return (MonoObject *)GDMonoMarshal::Array_to_mono_array(p_var->operator Array());
- }
- }
} break;
case MONO_TYPE_OBJECT: {
// Variant
@@ -749,51 +729,61 @@ MonoObject *variant_to_mono_object(const Variant *p_var, const ManagedType &p_ty
case Variant::PACKED_COLOR_ARRAY:
return (MonoObject *)PackedColorArray_to_mono_array(p_var->operator PackedColorArray());
default:
- return NULL;
+ return nullptr;
}
break;
case MONO_TYPE_GENERICINST: {
MonoReflectionType *reftype = mono_type_get_object(mono_domain_get(), p_type.type_class->get_mono_type());
+ // Godot.Collections.Dictionary<TKey, TValue>
if (GDMonoUtils::Marshal::type_is_generic_dictionary(reftype)) {
return GDMonoUtils::create_managed_from(p_var->operator Dictionary(), p_type.type_class);
}
+ // Godot.Collections.Array<T>
if (GDMonoUtils::Marshal::type_is_generic_array(reftype)) {
return GDMonoUtils::create_managed_from(p_var->operator Array(), p_type.type_class);
}
- // The order in which we check the following interfaces is very important (dictionaries and generics first)
-
- MonoReflectionType *key_reftype, *value_reftype;
- if (GDMonoUtils::Marshal::generic_idictionary_is_assignable_from(reftype, &key_reftype, &value_reftype)) {
- return GDMonoUtils::create_managed_from(p_var->operator Dictionary(),
- GDMonoUtils::Marshal::make_generic_dictionary_type(key_reftype, value_reftype));
+ // System.Collections.Generic.Dictionary<TKey, TValue>
+ if (GDMonoUtils::Marshal::type_is_system_generic_dictionary(reftype)) {
+ MonoReflectionType *key_reftype = nullptr;
+ MonoReflectionType *value_reftype = nullptr;
+ GDMonoUtils::Marshal::dictionary_get_key_value_types(reftype, &key_reftype, &value_reftype);
+ return Dictionary_to_system_generic_dict(p_var->operator Dictionary(), p_type.type_class, key_reftype, value_reftype);
}
- if (p_type.type_class->implements_interface(CACHED_CLASS(System_Collections_IDictionary))) {
- return GDMonoUtils::create_managed_from(p_var->operator Dictionary(), CACHED_CLASS(Dictionary));
+ // System.Collections.Generic.List<T>
+ if (GDMonoUtils::Marshal::type_is_system_generic_list(reftype)) {
+ MonoReflectionType *elem_reftype = nullptr;
+ GDMonoUtils::Marshal::array_get_element_type(reftype, &elem_reftype);
+ return Array_to_system_generic_list(p_var->operator Array(), p_type.type_class, elem_reftype);
}
- MonoReflectionType *elem_reftype;
- if (GDMonoUtils::Marshal::generic_ienumerable_is_assignable_from(reftype, &elem_reftype)) {
- return GDMonoUtils::create_managed_from(p_var->operator Array(),
- GDMonoUtils::Marshal::make_generic_array_type(elem_reftype));
+ // IDictionary<TKey, TValue>
+ if (GDMonoUtils::Marshal::type_is_generic_idictionary(reftype)) {
+ MonoReflectionType *key_reftype;
+ MonoReflectionType *value_reftype;
+ GDMonoUtils::Marshal::dictionary_get_key_value_types(reftype, &key_reftype, &value_reftype);
+ GDMonoClass *godot_dict_class = GDMonoUtils::Marshal::make_generic_dictionary_type(key_reftype, value_reftype);
+
+ return GDMonoUtils::create_managed_from(p_var->operator Dictionary(), godot_dict_class);
}
- if (p_type.type_class->implements_interface(CACHED_CLASS(System_Collections_IEnumerable))) {
- if (GDMonoCache::tools_godot_api_check()) {
- return GDMonoUtils::create_managed_from(p_var->operator Array(), CACHED_CLASS(Array));
- } else {
- return (MonoObject *)GDMonoMarshal::Array_to_mono_array(p_var->operator Array());
- }
+ // ICollection<T> or IEnumerable<T>
+ if (GDMonoUtils::Marshal::type_is_generic_icollection(reftype) || GDMonoUtils::Marshal::type_is_generic_ienumerable(reftype)) {
+ MonoReflectionType *elem_reftype;
+ GDMonoUtils::Marshal::array_get_element_type(reftype, &elem_reftype);
+ GDMonoClass *godot_array_class = GDMonoUtils::Marshal::make_generic_array_type(elem_reftype);
+
+ return GDMonoUtils::create_managed_from(p_var->operator Array(), godot_array_class);
}
} break;
} break;
}
- ERR_FAIL_V_MSG(NULL, "Attempted to convert Variant to an unmarshallable managed type. Name: '" +
- p_type.type_class->get_name() + "' Encoding: " + itos(p_type.type_encoding) + ".");
+ ERR_FAIL_V_MSG(nullptr, "Attempted to convert Variant to an unmarshallable managed type. Name: '" +
+ p_type.type_class->get_name() + "' Encoding: " + itos(p_type.type_encoding) + ".");
}
Variant mono_object_to_variant_impl(MonoObject *p_obj, const ManagedType &p_type, bool p_fail_with_err = true) {
@@ -831,7 +821,7 @@ Variant mono_object_to_variant_impl(MonoObject *p_obj, const ManagedType &p_type
return unbox<double>(p_obj);
case MONO_TYPE_STRING: {
- if (p_obj == NULL)
+ if (p_obj == nullptr)
return Variant(); // NIL
return mono_string_to_godot_not_null((MonoString *)p_obj);
} break;
@@ -922,6 +912,10 @@ Variant mono_object_to_variant_impl(MonoObject *p_obj, const ManagedType &p_type
if (array_type->eklass == CACHED_CLASS_RAW(Color))
return mono_array_to_PackedColorArray((MonoArray *)p_obj);
+ GDMonoClass *array_type_class = GDMono::get_singleton()->get_class(array_type->eklass);
+ if (CACHED_CLASS(GodotObject)->is_assignable_from(array_type_class))
+ return mono_array_to_Array((MonoArray *)p_obj);
+
if (p_fail_with_err) {
ERR_FAIL_V_MSG(Variant(), "Attempted to convert a managed array of unmarshallable element type to Variant.");
} else {
@@ -935,7 +929,7 @@ Variant mono_object_to_variant_impl(MonoObject *p_obj, const ManagedType &p_type
// GodotObject
if (CACHED_CLASS(GodotObject)->is_assignable_from(type_class)) {
Object *ptr = unbox<Object *>(CACHED_FIELD(GodotObject, ptr)->get_value(p_obj));
- if (ptr != NULL) {
+ if (ptr != nullptr) {
Reference *ref = Object::cast_to<Reference>(ptr);
return ref ? Variant(Ref<Reference>(ref)) : Variant(ptr);
}
@@ -957,74 +951,55 @@ Variant mono_object_to_variant_impl(MonoObject *p_obj, const ManagedType &p_type
return ptr ? Variant(*ptr) : Variant();
}
- if (CACHED_CLASS(Array) == type_class) {
- MonoException *exc = NULL;
- Array *ptr = CACHED_METHOD_THUNK(Array, GetPtr).invoke(p_obj, &exc);
- UNHANDLED_EXCEPTION(exc);
- return ptr ? Variant(*ptr) : Variant();
- }
-
+ // Godot.Collections.Dictionary
if (CACHED_CLASS(Dictionary) == type_class) {
- MonoException *exc = NULL;
+ MonoException *exc = nullptr;
Dictionary *ptr = CACHED_METHOD_THUNK(Dictionary, GetPtr).invoke(p_obj, &exc);
UNHANDLED_EXCEPTION(exc);
return ptr ? Variant(*ptr) : Variant();
}
- // The order in which we check the following interfaces is very important (dictionaries and generics first)
-
- MonoReflectionType *reftype = mono_type_get_object(mono_domain_get(), type_class->get_mono_type());
-
- if (GDMonoUtils::Marshal::generic_idictionary_is_assignable_from(reftype)) {
- return GDMonoUtils::Marshal::generic_idictionary_to_dictionary(p_obj);
- }
-
- if (type_class->implements_interface(CACHED_CLASS(System_Collections_IDictionary))) {
- return GDMonoUtils::Marshal::idictionary_to_dictionary(p_obj);
- }
-
- if (GDMonoUtils::Marshal::generic_ienumerable_is_assignable_from(reftype)) {
- return GDMonoUtils::Marshal::enumerable_to_array(p_obj);
- }
-
- if (type_class->implements_interface(CACHED_CLASS(System_Collections_IEnumerable))) {
- return GDMonoUtils::Marshal::enumerable_to_array(p_obj);
+ // Godot.Collections.Array
+ if (CACHED_CLASS(Array) == type_class) {
+ MonoException *exc = nullptr;
+ Array *ptr = CACHED_METHOD_THUNK(Array, GetPtr).invoke(p_obj, &exc);
+ UNHANDLED_EXCEPTION(exc);
+ return ptr ? Variant(*ptr) : Variant();
}
} break;
case MONO_TYPE_GENERICINST: {
MonoReflectionType *reftype = mono_type_get_object(mono_domain_get(), p_type.type_class->get_mono_type());
+ // Godot.Collections.Dictionary<TKey, TValue>
if (GDMonoUtils::Marshal::type_is_generic_dictionary(reftype)) {
- MonoException *exc = NULL;
+ MonoException *exc = nullptr;
MonoObject *ret = p_type.type_class->get_method("GetPtr")->invoke(p_obj, &exc);
UNHANDLED_EXCEPTION(exc);
return *unbox<Dictionary *>(ret);
}
+ // Godot.Collections.Array<T>
if (GDMonoUtils::Marshal::type_is_generic_array(reftype)) {
- MonoException *exc = NULL;
+ MonoException *exc = nullptr;
MonoObject *ret = p_type.type_class->get_method("GetPtr")->invoke(p_obj, &exc);
UNHANDLED_EXCEPTION(exc);
return *unbox<Array *>(ret);
}
- // The order in which we check the following interfaces is very important (dictionaries and generics first)
-
- if (GDMonoUtils::Marshal::generic_idictionary_is_assignable_from(reftype)) {
- return GDMonoUtils::Marshal::generic_idictionary_to_dictionary(p_obj);
- }
-
- if (p_type.type_class->implements_interface(CACHED_CLASS(System_Collections_IDictionary))) {
- return GDMonoUtils::Marshal::idictionary_to_dictionary(p_obj);
+ // System.Collections.Generic.Dictionary<TKey, TValue>
+ if (GDMonoUtils::Marshal::type_is_system_generic_dictionary(reftype)) {
+ MonoReflectionType *key_reftype = nullptr;
+ MonoReflectionType *value_reftype = nullptr;
+ GDMonoUtils::Marshal::dictionary_get_key_value_types(reftype, &key_reftype, &value_reftype);
+ return system_generic_dict_to_Dictionary(p_obj, p_type.type_class, key_reftype, value_reftype);
}
- if (GDMonoUtils::Marshal::generic_ienumerable_is_assignable_from(reftype)) {
- return GDMonoUtils::Marshal::enumerable_to_array(p_obj);
- }
-
- if (p_type.type_class->implements_interface(CACHED_CLASS(System_Collections_IEnumerable))) {
- return GDMonoUtils::Marshal::enumerable_to_array(p_obj);
+ // System.Collections.Generic.List<T>
+ if (GDMonoUtils::Marshal::type_is_system_generic_list(reftype)) {
+ MonoReflectionType *elem_reftype = nullptr;
+ GDMonoUtils::Marshal::array_get_element_type(reftype, &elem_reftype);
+ return system_generic_list_to_Array(p_obj, p_type.type_class, elem_reftype);
}
} break;
}
@@ -1064,9 +1039,9 @@ String mono_object_to_variant_string(MonoObject *p_obj, MonoException **r_exc) {
ManagedType type = ManagedType::from_class(mono_object_get_class(p_obj));
Variant var = GDMonoMarshal::mono_object_to_variant_no_err(p_obj, type);
- if (var.get_type() == Variant::NIL && p_obj != NULL) {
+ if (var.get_type() == Variant::NIL && p_obj != nullptr) {
// Cannot convert MonoObject* to Variant; fallback to 'ToString()'.
- MonoException *exc = NULL;
+ MonoException *exc = nullptr;
MonoString *mono_str = GDMonoUtils::object_to_string(p_obj, &exc);
if (exc) {
@@ -1081,6 +1056,80 @@ String mono_object_to_variant_string(MonoObject *p_obj, MonoException **r_exc) {
}
}
+MonoObject *Dictionary_to_system_generic_dict(const Dictionary &p_dict, GDMonoClass *p_class, MonoReflectionType *p_key_reftype, MonoReflectionType *p_value_reftype) {
+ String ctor_desc = ":.ctor(System.Collections.Generic.IDictionary`2<" + GDMonoUtils::get_type_desc(p_key_reftype) +
+ ", " + GDMonoUtils::get_type_desc(p_value_reftype) + ">)";
+ GDMonoMethod *ctor = p_class->get_method_with_desc(ctor_desc, true);
+ CRASH_COND(ctor == nullptr);
+
+ MonoObject *mono_object = mono_object_new(mono_domain_get(), p_class->get_mono_ptr());
+ ERR_FAIL_NULL_V(mono_object, nullptr);
+
+ GDMonoClass *godot_dict_class = GDMonoUtils::Marshal::make_generic_dictionary_type(p_key_reftype, p_value_reftype);
+ MonoObject *godot_dict = GDMonoUtils::create_managed_from(p_dict, godot_dict_class);
+
+ void *ctor_args[1] = { godot_dict };
+
+ MonoException *exc = nullptr;
+ ctor->invoke_raw(mono_object, ctor_args, &exc);
+ UNHANDLED_EXCEPTION(exc);
+
+ return mono_object;
+}
+
+Dictionary system_generic_dict_to_Dictionary(MonoObject *p_obj, [[maybe_unused]] GDMonoClass *p_class, MonoReflectionType *p_key_reftype, MonoReflectionType *p_value_reftype) {
+ GDMonoClass *godot_dict_class = GDMonoUtils::Marshal::make_generic_dictionary_type(p_key_reftype, p_value_reftype);
+ String ctor_desc = ":.ctor(System.Collections.Generic.IDictionary`2<" + GDMonoUtils::get_type_desc(p_key_reftype) +
+ ", " + GDMonoUtils::get_type_desc(p_value_reftype) + ">)";
+ GDMonoMethod *godot_dict_ctor = godot_dict_class->get_method_with_desc(ctor_desc, true);
+ CRASH_COND(godot_dict_ctor == nullptr);
+
+ MonoObject *godot_dict = mono_object_new(mono_domain_get(), godot_dict_class->get_mono_ptr());
+ ERR_FAIL_NULL_V(godot_dict, Dictionary());
+
+ void *ctor_args[1] = { p_obj };
+
+ MonoException *exc = nullptr;
+ godot_dict_ctor->invoke_raw(godot_dict, ctor_args, &exc);
+ UNHANDLED_EXCEPTION(exc);
+
+ exc = nullptr;
+ MonoObject *ret = godot_dict_class->get_method("GetPtr")->invoke(godot_dict, &exc);
+ UNHANDLED_EXCEPTION(exc);
+
+ return *unbox<Dictionary *>(ret);
+}
+
+MonoObject *Array_to_system_generic_list(const Array &p_array, GDMonoClass *p_class, MonoReflectionType *p_elem_reftype) {
+ GDMonoClass *elem_class = ManagedType::from_reftype(p_elem_reftype).type_class;
+
+ String ctor_desc = ":.ctor(System.Collections.Generic.IEnumerable`1<" + elem_class->get_type_desc() + ">)";
+ GDMonoMethod *ctor = p_class->get_method_with_desc(ctor_desc, true);
+ CRASH_COND(ctor == nullptr);
+
+ MonoObject *mono_object = mono_object_new(mono_domain_get(), p_class->get_mono_ptr());
+ ERR_FAIL_NULL_V(mono_object, nullptr);
+
+ void *ctor_args[1] = { Array_to_mono_array(p_array, elem_class) };
+
+ MonoException *exc = nullptr;
+ ctor->invoke_raw(mono_object, ctor_args, &exc);
+ UNHANDLED_EXCEPTION(exc);
+
+ return mono_object;
+}
+
+Array system_generic_list_to_Array(MonoObject *p_obj, GDMonoClass *p_class, [[maybe_unused]] MonoReflectionType *p_elem_reftype) {
+ GDMonoMethod *to_array = p_class->get_method("ToArray", 0);
+ CRASH_COND(to_array == nullptr);
+
+ MonoException *exc = nullptr;
+ MonoArray *mono_array = (MonoArray *)to_array->invoke_raw(p_obj, nullptr, &exc);
+ UNHANDLED_EXCEPTION(exc);
+
+ return mono_array_to_Array(mono_array);
+}
+
MonoArray *Array_to_mono_array(const Array &p_array) {
int length = p_array.size();
MonoArray *ret = mono_array_new(mono_domain_get(), CACHED_CLASS_RAW(MonoObject), length);
@@ -1093,6 +1142,18 @@ MonoArray *Array_to_mono_array(const Array &p_array) {
return ret;
}
+MonoArray *Array_to_mono_array(const Array &p_array, GDMonoClass *p_array_type_class) {
+ int length = p_array.size();
+ MonoArray *ret = mono_array_new(mono_domain_get(), p_array_type_class->get_mono_ptr(), length);
+
+ for (int i = 0; i < length; i++) {
+ MonoObject *boxed = variant_to_mono_object(p_array[i]);
+ mono_array_setref(ret, i, boxed);
+ }
+
+ return ret;
+}
+
Array mono_array_to_Array(MonoArray *p_array) {
Array ret;
if (!p_array)
@@ -1393,7 +1454,7 @@ Callable managed_to_callable(const M_Callable &p_managed_callable) {
} else {
Object *target = p_managed_callable.target ?
unbox<Object *>(CACHED_FIELD(GodotObject, ptr)->get_value(p_managed_callable.target)) :
- NULL;
+ nullptr;
StringName *method_ptr = unbox<StringName *>(CACHED_FIELD(StringName, ptr)->get_value(p_managed_callable.method_string_name));
StringName method = method_ptr ? *method_ptr : StringName();
return Callable(target, method);
@@ -1408,7 +1469,7 @@ M_Callable callable_to_managed(const Callable &p_callable) {
if (compare_equal_func == ManagedCallable::compare_equal_func_ptr) {
ManagedCallable *managed_callable = static_cast<ManagedCallable *>(custom);
return {
- NULL, NULL,
+ nullptr, nullptr,
managed_callable->get_delegate()
};
} else if (compare_equal_func == SignalAwaiterCallable::compare_equal_func_ptr) {
@@ -1416,30 +1477,30 @@ M_Callable callable_to_managed(const Callable &p_callable) {
return {
GDMonoUtils::unmanaged_get_managed(ObjectDB::get_instance(signal_awaiter_callable->get_object())),
GDMonoUtils::create_managed_from(signal_awaiter_callable->get_signal()),
- NULL
+ nullptr
};
} else if (compare_equal_func == EventSignalCallable::compare_equal_func_ptr) {
EventSignalCallable *event_signal_callable = static_cast<EventSignalCallable *>(custom);
return {
GDMonoUtils::unmanaged_get_managed(ObjectDB::get_instance(event_signal_callable->get_object())),
GDMonoUtils::create_managed_from(event_signal_callable->get_signal()),
- NULL
+ nullptr
};
}
// Some other CallableCustom. We only support ManagedCallable.
- return { NULL, NULL, NULL };
+ return { nullptr, nullptr, nullptr };
} else {
MonoObject *target_managed = GDMonoUtils::unmanaged_get_managed(p_callable.get_object());
MonoObject *method_string_name_managed = GDMonoUtils::create_managed_from(p_callable.get_method());
- return { target_managed, method_string_name_managed, NULL };
+ return { target_managed, method_string_name_managed, nullptr };
}
}
Signal managed_to_signal_info(const M_SignalInfo &p_managed_signal) {
Object *owner = p_managed_signal.owner ?
unbox<Object *>(CACHED_FIELD(GodotObject, ptr)->get_value(p_managed_signal.owner)) :
- NULL;
+ nullptr;
StringName *name_ptr = unbox<StringName *>(CACHED_FIELD(StringName, ptr)->get_value(p_managed_signal.name_string_name));
StringName name = name_ptr ? *name_ptr : StringName();
return Signal(owner, name);
diff --git a/modules/mono/mono_gd/gd_mono_marshal.h b/modules/mono/mono_gd/gd_mono_marshal.h
index 7d09f46b00..f2d887e6d6 100644
--- a/modules/mono/mono_gd/gd_mono_marshal.h
+++ b/modules/mono/mono_gd/gd_mono_marshal.h
@@ -63,7 +63,7 @@ T *unbox_addr(MonoObject *p_obj) {
#define BOX_PTR(x) mono_value_box(mono_domain_get(), CACHED_CLASS_RAW(IntPtr), x)
#define BOX_ENUM(m_enum_class, x) mono_value_box(mono_domain_get(), m_enum_class, &x)
-Variant::Type managed_to_variant_type(const ManagedType &p_type, bool *r_nil_is_variant = NULL);
+Variant::Type managed_to_variant_type(const ManagedType &p_type, bool *r_nil_is_variant = nullptr);
bool try_get_array_element_type(const ManagedType &p_array_type, ManagedType &r_elem_type);
bool try_get_dictionary_key_value_types(const ManagedType &p_dictionary_type, ManagedType &r_key_type, ManagedType &r_value_type);
@@ -81,7 +81,7 @@ _FORCE_INLINE_ String mono_string_to_godot_not_null(MonoString *p_mono_string) {
}
_FORCE_INLINE_ String mono_string_to_godot(MonoString *p_mono_string) {
- if (p_mono_string == NULL)
+ if (p_mono_string == nullptr)
return String();
return mono_string_to_godot_not_null(p_mono_string);
@@ -123,9 +123,18 @@ Variant mono_object_to_variant_no_err(MonoObject *p_obj, const ManagedType &p_ty
/// If the MonoObject* cannot be converted to Variant, then 'ToString()' is called instead.
String mono_object_to_variant_string(MonoObject *p_obj, MonoException **r_exc);
+// System.Collections.Generic
+
+MonoObject *Dictionary_to_system_generic_dict(const Dictionary &p_dict, GDMonoClass *p_class, MonoReflectionType *p_key_reftype, MonoReflectionType *p_value_reftype);
+Dictionary system_generic_dict_to_Dictionary(MonoObject *p_obj, GDMonoClass *p_class, MonoReflectionType *p_key_reftype, MonoReflectionType *p_value_reftype);
+
+MonoObject *Array_to_system_generic_list(const Array &p_array, GDMonoClass *p_class, MonoReflectionType *p_elem_reftype);
+Array system_generic_list_to_Array(MonoObject *p_obj, GDMonoClass *p_class, MonoReflectionType *p_elem_reftype);
+
// Array
MonoArray *Array_to_mono_array(const Array &p_array);
+MonoArray *Array_to_mono_array(const Array &p_array, GDMonoClass *p_array_type_class);
Array mono_array_to_Array(MonoArray *p_array);
// PackedInt32Array
diff --git a/modules/mono/mono_gd/gd_mono_method.cpp b/modules/mono/mono_gd/gd_mono_method.cpp
index e6a1ec2697..432aa74a6f 100644
--- a/modules/mono/mono_gd/gd_mono_method.cpp
+++ b/modules/mono/mono_gd/gd_mono_method.cpp
@@ -30,13 +30,14 @@
#include "gd_mono_method.h"
+#include <mono/metadata/attrdefs.h>
+#include <mono/metadata/debug-helpers.h>
+
#include "gd_mono_cache.h"
#include "gd_mono_class.h"
#include "gd_mono_marshal.h"
#include "gd_mono_utils.h"
-#include <mono/metadata/attrdefs.h>
-
void GDMonoMethod::_update_signature() {
// Apparently MonoMethodSignature needs not to be freed.
// mono_method_signature caches the result, we don't need to cache it ourselves.
@@ -58,9 +59,9 @@ void GDMonoMethod::_update_signature(MonoMethodSignature *p_method_sig) {
}
}
- void *iter = NULL;
+ void *iter = nullptr;
MonoType *param_raw_type;
- while ((param_raw_type = mono_signature_get_params(p_method_sig, &iter)) != NULL) {
+ while ((param_raw_type = mono_signature_get_params(p_method_sig, &iter)) != nullptr) {
ManagedType param_type;
param_type.type_encoding = mono_type_get_type(param_raw_type);
@@ -81,11 +82,11 @@ GDMonoClass *GDMonoMethod::get_enclosing_class() const {
}
bool GDMonoMethod::is_static() {
- return mono_method_get_flags(mono_method, NULL) & MONO_METHOD_ATTR_STATIC;
+ return mono_method_get_flags(mono_method, nullptr) & MONO_METHOD_ATTR_STATIC;
}
IMonoClassMember::Visibility GDMonoMethod::get_visibility() {
- switch (mono_method_get_flags(mono_method, NULL) & MONO_METHOD_ATTR_ACCESS_MASK) {
+ switch (mono_method_get_flags(mono_method, nullptr) & MONO_METHOD_ATTR_ACCESS_MASK) {
case MONO_METHOD_ATTR_PRIVATE:
return IMonoClassMember::PRIVATE;
case MONO_METHOD_ATTR_FAM_AND_ASSEM:
@@ -102,7 +103,7 @@ IMonoClassMember::Visibility GDMonoMethod::get_visibility() {
}
MonoObject *GDMonoMethod::invoke(MonoObject *p_object, const Variant **p_params, MonoException **r_exc) const {
- MonoException *exc = NULL;
+ MonoException *exc = nullptr;
MonoObject *ret;
if (params_count > 0) {
@@ -115,11 +116,11 @@ MonoObject *GDMonoMethod::invoke(MonoObject *p_object, const Variant **p_params,
ret = GDMonoUtils::runtime_invoke_array(mono_method, p_object, params, &exc);
} else {
- ret = GDMonoUtils::runtime_invoke(mono_method, p_object, NULL, &exc);
+ ret = GDMonoUtils::runtime_invoke(mono_method, p_object, nullptr, &exc);
}
if (exc) {
- ret = NULL;
+ ret = nullptr;
if (r_exc) {
*r_exc = exc;
} else {
@@ -131,16 +132,16 @@ MonoObject *GDMonoMethod::invoke(MonoObject *p_object, const Variant **p_params,
}
MonoObject *GDMonoMethod::invoke(MonoObject *p_object, MonoException **r_exc) const {
- ERR_FAIL_COND_V(get_parameters_count() > 0, NULL);
- return invoke_raw(p_object, NULL, r_exc);
+ ERR_FAIL_COND_V(get_parameters_count() > 0, nullptr);
+ return invoke_raw(p_object, nullptr, r_exc);
}
MonoObject *GDMonoMethod::invoke_raw(MonoObject *p_object, void **p_params, MonoException **r_exc) const {
- MonoException *exc = NULL;
+ MonoException *exc = nullptr;
MonoObject *ret = GDMonoUtils::runtime_invoke(mono_method, p_object, p_params, &exc);
if (exc) {
- ret = NULL;
+ ret = nullptr;
if (r_exc) {
*r_exc = exc;
} else {
@@ -164,19 +165,19 @@ bool GDMonoMethod::has_attribute(GDMonoClass *p_attr_class) {
}
MonoObject *GDMonoMethod::get_attribute(GDMonoClass *p_attr_class) {
- ERR_FAIL_NULL_V(p_attr_class, NULL);
+ ERR_FAIL_NULL_V(p_attr_class, nullptr);
if (!attrs_fetched)
fetch_attributes();
if (!attributes)
- return NULL;
+ return nullptr;
return mono_custom_attrs_get_attr(attributes, p_attr_class->get_mono_ptr());
}
void GDMonoMethod::fetch_attributes() {
- ERR_FAIL_COND(attributes != NULL);
+ ERR_FAIL_COND(attributes != nullptr);
attributes = mono_custom_attrs_from_method(mono_method);
attrs_fetched = true;
}
@@ -281,7 +282,7 @@ GDMonoMethod::GDMonoMethod(StringName p_name, MonoMethod *p_method) {
method_info_fetched = false;
attrs_fetched = false;
- attributes = NULL;
+ attributes = nullptr;
_update_signature();
}
diff --git a/modules/mono/mono_gd/gd_mono_method.h b/modules/mono/mono_gd/gd_mono_method.h
index d4379f41fe..54b2eba3e8 100644
--- a/modules/mono/mono_gd/gd_mono_method.h
+++ b/modules/mono/mono_gd/gd_mono_method.h
@@ -76,9 +76,9 @@ public:
_FORCE_INLINE_ int get_parameters_count() const { return params_count; }
_FORCE_INLINE_ ManagedType get_return_type() const { return return_type; }
- MonoObject *invoke(MonoObject *p_object, const Variant **p_params, MonoException **r_exc = NULL) const;
- MonoObject *invoke(MonoObject *p_object, MonoException **r_exc = NULL) const;
- MonoObject *invoke_raw(MonoObject *p_object, void **p_params, MonoException **r_exc = NULL) const;
+ MonoObject *invoke(MonoObject *p_object, const Variant **p_params, MonoException **r_exc = nullptr) const;
+ MonoObject *invoke(MonoObject *p_object, MonoException **r_exc = nullptr) const;
+ MonoObject *invoke_raw(MonoObject *p_object, void **p_params, MonoException **r_exc = nullptr) const;
String get_full_name(bool p_signature = false) const;
String get_full_name_no_class() const;
diff --git a/modules/mono/mono_gd/gd_mono_method_thunk.h b/modules/mono/mono_gd/gd_mono_method_thunk.h
index d8c9a5eb02..0e05e974e9 100644
--- a/modules/mono/mono_gd/gd_mono_method_thunk.h
+++ b/modules/mono/mono_gd/gd_mono_method_thunk.h
@@ -39,7 +39,7 @@
#include "gd_mono_method.h"
#include "gd_mono_utils.h"
-#if !defined(JAVASCRIPT_ENABLED)
+#if !defined(JAVASCRIPT_ENABLED) && !defined(IPHONE_ENABLED)
#define HAVE_METHOD_THUNKS
#endif
@@ -60,16 +60,16 @@ public:
}
_FORCE_INLINE_ bool is_null() {
- return mono_method_thunk == NULL;
+ return mono_method_thunk == nullptr;
}
_FORCE_INLINE_ void nullify() {
- mono_method_thunk = NULL;
+ mono_method_thunk = nullptr;
}
_FORCE_INLINE_ void set_from_method(GDMonoMethod *p_mono_method) {
#ifdef DEBUG_ENABLED
- CRASH_COND(p_mono_method == NULL);
+ CRASH_COND(p_mono_method == nullptr);
CRASH_COND(p_mono_method->get_return_type().type_encoding != MONO_TYPE_VOID);
if (p_mono_method->is_static()) {
@@ -82,7 +82,7 @@ public:
}
GDMonoMethodThunk() :
- mono_method_thunk(NULL) {
+ mono_method_thunk(nullptr) {
}
explicit GDMonoMethodThunk(GDMonoMethod *p_mono_method) {
@@ -106,16 +106,16 @@ public:
}
_FORCE_INLINE_ bool is_null() {
- return mono_method_thunk == NULL;
+ return mono_method_thunk == nullptr;
}
_FORCE_INLINE_ void nullify() {
- mono_method_thunk = NULL;
+ mono_method_thunk = nullptr;
}
_FORCE_INLINE_ void set_from_method(GDMonoMethod *p_mono_method) {
#ifdef DEBUG_ENABLED
- CRASH_COND(p_mono_method == NULL);
+ CRASH_COND(p_mono_method == nullptr);
CRASH_COND(p_mono_method->get_return_type().type_encoding == MONO_TYPE_VOID);
if (p_mono_method->is_static()) {
@@ -128,12 +128,12 @@ public:
}
GDMonoMethodThunkR() :
- mono_method_thunk(NULL) {
+ mono_method_thunk(nullptr) {
}
explicit GDMonoMethodThunkR(GDMonoMethod *p_mono_method) {
#ifdef DEBUG_ENABLED
- CRASH_COND(p_mono_method == NULL);
+ CRASH_COND(p_mono_method == nullptr);
#endif
mono_method_thunk = (M)mono_method_get_unmanaged_thunk(p_mono_method->get_mono_ptr());
}
@@ -146,7 +146,7 @@ struct VariadicInvokeMonoMethodImpl {
static void invoke(GDMonoMethod *p_mono_method, P1 p_arg1, ParamTypes... p_args, MonoException **r_exc) {
if (p_mono_method->is_static()) {
void *args[ThunkParamCount] = { p_arg1, p_args... };
- p_mono_method->invoke_raw(NULL, args, r_exc);
+ p_mono_method->invoke_raw(nullptr, args, r_exc);
} else {
void *args[ThunkParamCount] = { p_args... };
p_mono_method->invoke_raw((MonoObject *)p_arg1, args, r_exc);
@@ -167,7 +167,7 @@ struct VariadicInvokeMonoMethod<0> {
#ifdef DEBUG_ENABLED
CRASH_COND(!p_mono_method->is_static());
#endif
- p_mono_method->invoke_raw(NULL, NULL, r_exc);
+ p_mono_method->invoke_raw(nullptr, nullptr, r_exc);
}
};
@@ -176,9 +176,9 @@ struct VariadicInvokeMonoMethod<1, P1> {
static void invoke(GDMonoMethod *p_mono_method, P1 p_arg1, MonoException **r_exc) {
if (p_mono_method->is_static()) {
void *args[1] = { p_arg1 };
- p_mono_method->invoke_raw(NULL, args, r_exc);
+ p_mono_method->invoke_raw(nullptr, args, r_exc);
} else {
- p_mono_method->invoke_raw((MonoObject *)p_arg1, NULL, r_exc);
+ p_mono_method->invoke_raw((MonoObject *)p_arg1, nullptr, r_exc);
}
}
};
@@ -203,7 +203,7 @@ struct VariadicInvokeMonoMethodRImpl {
static R invoke(GDMonoMethod *p_mono_method, P1 p_arg1, ParamTypes... p_args, MonoException **r_exc) {
if (p_mono_method->is_static()) {
void *args[ThunkParamCount] = { p_arg1, p_args... };
- MonoObject *r = p_mono_method->invoke_raw(NULL, args, r_exc);
+ MonoObject *r = p_mono_method->invoke_raw(nullptr, args, r_exc);
return unbox_if_needed<R>(r, p_mono_method->get_return_type());
} else {
void *args[ThunkParamCount] = { p_args... };
@@ -226,7 +226,7 @@ struct VariadicInvokeMonoMethodR<0, R> {
#ifdef DEBUG_ENABLED
CRASH_COND(!p_mono_method->is_static());
#endif
- MonoObject *r = p_mono_method->invoke_raw(NULL, NULL, r_exc);
+ MonoObject *r = p_mono_method->invoke_raw(nullptr, nullptr, r_exc);
return unbox_if_needed<R>(r, p_mono_method->get_return_type());
}
};
@@ -236,10 +236,10 @@ struct VariadicInvokeMonoMethodR<1, R, P1> {
static R invoke(GDMonoMethod *p_mono_method, P1 p_arg1, MonoException **r_exc) {
if (p_mono_method->is_static()) {
void *args[1] = { p_arg1 };
- MonoObject *r = p_mono_method->invoke_raw(NULL, args, r_exc);
+ MonoObject *r = p_mono_method->invoke_raw(nullptr, args, r_exc);
return unbox_if_needed<R>(r, p_mono_method->get_return_type());
} else {
- MonoObject *r = p_mono_method->invoke_raw((MonoObject *)p_arg1, NULL, r_exc);
+ MonoObject *r = p_mono_method->invoke_raw((MonoObject *)p_arg1, nullptr, r_exc);
return unbox_if_needed<R>(r, p_mono_method->get_return_type());
}
}
@@ -256,16 +256,16 @@ public:
}
_FORCE_INLINE_ bool is_null() {
- return mono_method == NULL;
+ return mono_method == nullptr;
}
_FORCE_INLINE_ void nullify() {
- mono_method = NULL;
+ mono_method = nullptr;
}
_FORCE_INLINE_ void set_from_method(GDMonoMethod *p_mono_method) {
#ifdef DEBUG_ENABLED
- CRASH_COND(p_mono_method == NULL);
+ CRASH_COND(p_mono_method == nullptr);
CRASH_COND(p_mono_method->get_return_type().type_encoding != MONO_TYPE_VOID);
if (p_mono_method->is_static()) {
@@ -278,7 +278,7 @@ public:
}
GDMonoMethodThunk() :
- mono_method(NULL) {
+ mono_method(nullptr) {
}
explicit GDMonoMethodThunk(GDMonoMethod *p_mono_method) {
@@ -297,16 +297,16 @@ public:
}
_FORCE_INLINE_ bool is_null() {
- return mono_method == NULL;
+ return mono_method == nullptr;
}
_FORCE_INLINE_ void nullify() {
- mono_method = NULL;
+ mono_method = nullptr;
}
_FORCE_INLINE_ void set_from_method(GDMonoMethod *p_mono_method) {
#ifdef DEBUG_ENABLED
- CRASH_COND(p_mono_method == NULL);
+ CRASH_COND(p_mono_method == nullptr);
CRASH_COND(p_mono_method->get_return_type().type_encoding == MONO_TYPE_VOID);
if (p_mono_method->is_static()) {
@@ -319,7 +319,7 @@ public:
}
GDMonoMethodThunkR() :
- mono_method(NULL) {
+ mono_method(nullptr) {
}
explicit GDMonoMethodThunkR(GDMonoMethod *p_mono_method) {
diff --git a/modules/mono/mono_gd/gd_mono_property.cpp b/modules/mono/mono_gd/gd_mono_property.cpp
index 3b5ce58d80..c3e7598f2d 100644
--- a/modules/mono/mono_gd/gd_mono_property.cpp
+++ b/modules/mono/mono_gd/gd_mono_property.cpp
@@ -57,7 +57,7 @@ GDMonoProperty::GDMonoProperty(MonoProperty *p_mono_property, GDMonoClass *p_own
MonoMethodSignature *setter_sig = mono_method_signature(prop_method);
- void *iter = NULL;
+ void *iter = nullptr;
MonoType *param_raw_type = mono_signature_get_params(setter_sig, &iter);
type.type_encoding = mono_type_get_type(param_raw_type);
@@ -66,7 +66,7 @@ GDMonoProperty::GDMonoProperty(MonoProperty *p_mono_property, GDMonoClass *p_own
}
attrs_fetched = false;
- attributes = NULL;
+ attributes = nullptr;
}
GDMonoProperty::~GDMonoProperty() {
@@ -77,17 +77,17 @@ GDMonoProperty::~GDMonoProperty() {
bool GDMonoProperty::is_static() {
MonoMethod *prop_method = mono_property_get_get_method(mono_property);
- if (prop_method == NULL)
+ if (prop_method == nullptr)
prop_method = mono_property_get_set_method(mono_property);
- return mono_method_get_flags(prop_method, NULL) & MONO_METHOD_ATTR_STATIC;
+ return mono_method_get_flags(prop_method, nullptr) & MONO_METHOD_ATTR_STATIC;
}
IMonoClassMember::Visibility GDMonoProperty::get_visibility() {
MonoMethod *prop_method = mono_property_get_get_method(mono_property);
- if (prop_method == NULL)
+ if (prop_method == nullptr)
prop_method = mono_property_get_set_method(mono_property);
- switch (mono_method_get_flags(prop_method, NULL) & MONO_METHOD_ATTR_ACCESS_MASK) {
+ switch (mono_method_get_flags(prop_method, nullptr) & MONO_METHOD_ATTR_ACCESS_MASK) {
case MONO_METHOD_ATTR_PRIVATE:
return IMonoClassMember::PRIVATE;
case MONO_METHOD_ATTR_FAM_AND_ASSEM:
@@ -116,36 +116,36 @@ bool GDMonoProperty::has_attribute(GDMonoClass *p_attr_class) {
}
MonoObject *GDMonoProperty::get_attribute(GDMonoClass *p_attr_class) {
- ERR_FAIL_NULL_V(p_attr_class, NULL);
+ ERR_FAIL_NULL_V(p_attr_class, nullptr);
if (!attrs_fetched)
fetch_attributes();
if (!attributes)
- return NULL;
+ return nullptr;
return mono_custom_attrs_get_attr(attributes, p_attr_class->get_mono_ptr());
}
void GDMonoProperty::fetch_attributes() {
- ERR_FAIL_COND(attributes != NULL);
+ ERR_FAIL_COND(attributes != nullptr);
attributes = mono_custom_attrs_from_property(owner->get_mono_ptr(), mono_property);
attrs_fetched = true;
}
bool GDMonoProperty::has_getter() {
- return mono_property_get_get_method(mono_property) != NULL;
+ return mono_property_get_get_method(mono_property) != nullptr;
}
bool GDMonoProperty::has_setter() {
- return mono_property_get_set_method(mono_property) != NULL;
+ return mono_property_get_set_method(mono_property) != nullptr;
}
void GDMonoProperty::set_value(MonoObject *p_object, MonoObject *p_value, MonoException **r_exc) {
MonoMethod *prop_method = mono_property_get_set_method(mono_property);
MonoArray *params = mono_array_new(mono_domain_get(), CACHED_CLASS_RAW(MonoObject), 1);
mono_array_setref(params, 0, p_value);
- MonoException *exc = NULL;
+ MonoException *exc = nullptr;
GDMonoUtils::runtime_invoke_array(prop_method, p_object, params, &exc);
if (exc) {
if (r_exc) {
@@ -157,7 +157,7 @@ void GDMonoProperty::set_value(MonoObject *p_object, MonoObject *p_value, MonoEx
}
void GDMonoProperty::set_value(MonoObject *p_object, void **p_params, MonoException **r_exc) {
- MonoException *exc = NULL;
+ MonoException *exc = nullptr;
GDMonoUtils::property_set_value(mono_property, p_object, p_params, &exc);
if (exc) {
@@ -170,11 +170,11 @@ void GDMonoProperty::set_value(MonoObject *p_object, void **p_params, MonoExcept
}
MonoObject *GDMonoProperty::get_value(MonoObject *p_object, MonoException **r_exc) {
- MonoException *exc = NULL;
- MonoObject *ret = GDMonoUtils::property_get_value(mono_property, p_object, NULL, &exc);
+ MonoException *exc = nullptr;
+ MonoObject *ret = GDMonoUtils::property_get_value(mono_property, p_object, nullptr, &exc);
if (exc) {
- ret = NULL;
+ ret = nullptr;
if (r_exc) {
*r_exc = exc;
} else {
diff --git a/modules/mono/mono_gd/gd_mono_property.h b/modules/mono/mono_gd/gd_mono_property.h
index 2aec64f565..4653758a86 100644
--- a/modules/mono/mono_gd/gd_mono_property.h
+++ b/modules/mono/mono_gd/gd_mono_property.h
@@ -65,9 +65,9 @@ public:
_FORCE_INLINE_ ManagedType get_type() const { return type; }
- void set_value(MonoObject *p_object, MonoObject *p_value, MonoException **r_exc = NULL);
- void set_value(MonoObject *p_object, void **p_params, MonoException **r_exc = NULL);
- MonoObject *get_value(MonoObject *p_object, MonoException **r_exc = NULL);
+ void set_value(MonoObject *p_object, MonoObject *p_value, MonoException **r_exc = nullptr);
+ void set_value(MonoObject *p_object, void **p_params, MonoException **r_exc = nullptr);
+ MonoObject *get_value(MonoObject *p_object, MonoException **r_exc = nullptr);
bool get_bool_value(MonoObject *p_object);
int get_int_value(MonoObject *p_object);
diff --git a/modules/mono/mono_gd/gd_mono_utils.cpp b/modules/mono/mono_gd/gd_mono_utils.cpp
index cdb26ae61b..f9d492dabb 100644
--- a/modules/mono/mono_gd/gd_mono_utils.cpp
+++ b/modules/mono/mono_gd/gd_mono_utils.cpp
@@ -30,6 +30,7 @@
#include "gd_mono_utils.h"
+#include <mono/metadata/debug-helpers.h>
#include <mono/metadata/exception.h>
#include "core/debugger/engine_debugger.h"
@@ -57,7 +58,7 @@ namespace GDMonoUtils {
MonoObject *unmanaged_get_managed(Object *unmanaged) {
if (!unmanaged)
- return NULL;
+ return nullptr;
if (unmanaged->get_script_instance()) {
CSharpInstance *cs_instance = CAST_CSHARP_INSTANCE(unmanaged->get_script_instance());
@@ -71,7 +72,7 @@ MonoObject *unmanaged_get_managed(Object *unmanaged) {
void *data = unmanaged->get_script_instance_binding(CSharpLanguage::get_singleton()->get_language_index());
- ERR_FAIL_NULL_V(data, NULL);
+ ERR_FAIL_NULL_V(data, nullptr);
CSharpScriptBinding &script_binding = ((Map<Object *, CSharpScriptBinding>::Element *)data)->value();
@@ -82,7 +83,7 @@ MonoObject *unmanaged_get_managed(Object *unmanaged) {
// Already had a binding that needs to be setup
CSharpLanguage::get_singleton()->setup_csharp_script_binding(script_binding, unmanaged);
- ERR_FAIL_COND_V(!script_binding.inited, NULL);
+ ERR_FAIL_COND_V(!script_binding.inited, nullptr);
}
}
@@ -99,11 +100,11 @@ MonoObject *unmanaged_get_managed(Object *unmanaged) {
#ifdef DEBUG_ENABLED
CRASH_COND(script_binding.type_name == StringName());
- CRASH_COND(script_binding.wrapper_class == NULL);
+ CRASH_COND(script_binding.wrapper_class == nullptr);
#endif
MonoObject *mono_object = GDMonoUtils::create_managed_for_godot_object(script_binding.wrapper_class, script_binding.type_name, unmanaged);
- ERR_FAIL_NULL_V(mono_object, NULL);
+ ERR_FAIL_NULL_V(mono_object, nullptr);
gchandle = MonoGCHandleData::new_strong_handle(mono_object);
@@ -127,10 +128,15 @@ void set_main_thread(MonoThread *p_thread) {
}
MonoThread *attach_current_thread() {
- ERR_FAIL_COND_V(!GDMono::get_singleton()->is_runtime_initialized(), NULL);
+ ERR_FAIL_COND_V(!GDMono::get_singleton()->is_runtime_initialized(), nullptr);
MonoDomain *scripts_domain = GDMono::get_singleton()->get_scripts_domain();
+#ifndef GD_MONO_SINGLE_APPDOMAIN
MonoThread *mono_thread = mono_thread_attach(scripts_domain ? scripts_domain : mono_get_root_domain());
- ERR_FAIL_NULL_V(mono_thread, NULL);
+#else
+ // The scripts domain is the root domain
+ MonoThread *mono_thread = mono_thread_attach(scripts_domain);
+#endif
+ ERR_FAIL_NULL_V(mono_thread, nullptr);
return mono_thread;
}
@@ -152,7 +158,7 @@ MonoThread *get_current_thread() {
}
bool is_thread_attached() {
- return mono_domain_get() != NULL;
+ return mono_domain_get() != nullptr;
}
uint32_t new_strong_gchandle(MonoObject *p_object) {
@@ -174,11 +180,11 @@ void free_gchandle(uint32_t p_gchandle) {
void runtime_object_init(MonoObject *p_this_obj, GDMonoClass *p_class, MonoException **r_exc) {
GDMonoMethod *ctor = p_class->get_method(".ctor", 0);
ERR_FAIL_NULL(ctor);
- ctor->invoke_raw(p_this_obj, NULL, r_exc);
+ ctor->invoke_raw(p_this_obj, nullptr, r_exc);
}
bool mono_delegate_equal(MonoDelegate *p_a, MonoDelegate *p_b) {
- MonoException *exc = NULL;
+ MonoException *exc = nullptr;
MonoBoolean res = CACHED_METHOD_THUNK(Delegate, Equals).invoke((MonoObject *)p_a, (MonoObject *)p_b, &exc);
UNHANDLED_EXCEPTION(exc);
return (bool)res;
@@ -221,18 +227,18 @@ GDMonoClass *get_class_native_base(GDMonoClass *p_class) {
if (assembly == GDMono::get_singleton()->get_editor_api_assembly())
return klass;
#endif
- } while ((klass = klass->get_parent_class()) != NULL);
+ } while ((klass = klass->get_parent_class()) != nullptr);
- return NULL;
+ return nullptr;
}
MonoObject *create_managed_for_godot_object(GDMonoClass *p_class, const StringName &p_native, Object *p_object) {
bool parent_is_object_class = ClassDB::is_parent_class(p_object->get_class_name(), p_native);
- ERR_FAIL_COND_V_MSG(!parent_is_object_class, NULL,
+ ERR_FAIL_COND_V_MSG(!parent_is_object_class, nullptr,
"Type inherits from native type '" + p_native + "', so it can't be instanced in object of type: '" + p_object->get_class() + "'.");
MonoObject *mono_object = mono_object_new(mono_domain_get(), p_class->get_mono_ptr());
- ERR_FAIL_NULL_V(mono_object, NULL);
+ ERR_FAIL_NULL_V(mono_object, nullptr);
CACHED_FIELD(GodotObject, ptr)->set_value_raw(mono_object, p_object);
@@ -244,7 +250,7 @@ MonoObject *create_managed_for_godot_object(GDMonoClass *p_class, const StringNa
MonoObject *create_managed_from(const StringName &p_from) {
MonoObject *mono_object = mono_object_new(mono_domain_get(), CACHED_CLASS_RAW(StringName));
- ERR_FAIL_NULL_V(mono_object, NULL);
+ ERR_FAIL_NULL_V(mono_object, nullptr);
// Construct
GDMonoUtils::runtime_object_init(mono_object, CACHED_CLASS(StringName));
@@ -256,7 +262,7 @@ MonoObject *create_managed_from(const StringName &p_from) {
MonoObject *create_managed_from(const NodePath &p_from) {
MonoObject *mono_object = mono_object_new(mono_domain_get(), CACHED_CLASS_RAW(NodePath));
- ERR_FAIL_NULL_V(mono_object, NULL);
+ ERR_FAIL_NULL_V(mono_object, nullptr);
// Construct
GDMonoUtils::runtime_object_init(mono_object, CACHED_CLASS(NodePath));
@@ -268,7 +274,7 @@ MonoObject *create_managed_from(const NodePath &p_from) {
MonoObject *create_managed_from(const RID &p_from) {
MonoObject *mono_object = mono_object_new(mono_domain_get(), CACHED_CLASS_RAW(RID));
- ERR_FAIL_NULL_V(mono_object, NULL);
+ ERR_FAIL_NULL_V(mono_object, nullptr);
// Construct
GDMonoUtils::runtime_object_init(mono_object, CACHED_CLASS(RID));
@@ -280,15 +286,15 @@ MonoObject *create_managed_from(const RID &p_from) {
MonoObject *create_managed_from(const Array &p_from, GDMonoClass *p_class) {
MonoObject *mono_object = mono_object_new(mono_domain_get(), p_class->get_mono_ptr());
- ERR_FAIL_NULL_V(mono_object, NULL);
+ ERR_FAIL_NULL_V(mono_object, nullptr);
// Search constructor that takes a pointer as parameter
MonoMethod *m;
- void *iter = NULL;
+ void *iter = nullptr;
while ((m = mono_class_get_methods(p_class->get_mono_ptr(), &iter))) {
if (strcmp(mono_method_get_name(m), ".ctor") == 0) {
MonoMethodSignature *sig = mono_method_signature(m);
- void *front = NULL;
+ void *front = nullptr;
if (mono_signature_get_param_count(sig) == 1 &&
mono_class_from_mono_type(mono_signature_get_params(sig, &front)) == CACHED_CLASS(IntPtr)->get_mono_ptr()) {
break;
@@ -296,12 +302,12 @@ MonoObject *create_managed_from(const Array &p_from, GDMonoClass *p_class) {
}
}
- CRASH_COND(m == NULL);
+ CRASH_COND(m == nullptr);
Array *new_array = memnew(Array(p_from));
void *args[1] = { &new_array };
- MonoException *exc = NULL;
+ MonoException *exc = nullptr;
GDMonoUtils::runtime_invoke(m, mono_object, args, &exc);
UNHANDLED_EXCEPTION(exc);
@@ -310,15 +316,15 @@ MonoObject *create_managed_from(const Array &p_from, GDMonoClass *p_class) {
MonoObject *create_managed_from(const Dictionary &p_from, GDMonoClass *p_class) {
MonoObject *mono_object = mono_object_new(mono_domain_get(), p_class->get_mono_ptr());
- ERR_FAIL_NULL_V(mono_object, NULL);
+ ERR_FAIL_NULL_V(mono_object, nullptr);
// Search constructor that takes a pointer as parameter
MonoMethod *m;
- void *iter = NULL;
+ void *iter = nullptr;
while ((m = mono_class_get_methods(p_class->get_mono_ptr(), &iter))) {
if (strcmp(mono_method_get_name(m), ".ctor") == 0) {
MonoMethodSignature *sig = mono_method_signature(m);
- void *front = NULL;
+ void *front = nullptr;
if (mono_signature_get_param_count(sig) == 1 &&
mono_class_from_mono_type(mono_signature_get_params(sig, &front)) == CACHED_CLASS(IntPtr)->get_mono_ptr()) {
break;
@@ -326,12 +332,12 @@ MonoObject *create_managed_from(const Dictionary &p_from, GDMonoClass *p_class)
}
}
- CRASH_COND(m == NULL);
+ CRASH_COND(m == nullptr);
Dictionary *new_dict = memnew(Dictionary(p_from));
void *args[1] = { &new_dict };
- MonoException *exc = NULL;
+ MonoException *exc = nullptr;
GDMonoUtils::runtime_invoke(m, mono_object, args, &exc);
UNHANDLED_EXCEPTION(exc);
@@ -341,7 +347,7 @@ MonoObject *create_managed_from(const Dictionary &p_from, GDMonoClass *p_class)
MonoDomain *create_domain(const String &p_friendly_name) {
print_verbose("Mono: Creating domain '" + p_friendly_name + "'...");
- MonoDomain *domain = mono_domain_create_appdomain((char *)p_friendly_name.utf8().get_data(), NULL);
+ MonoDomain *domain = mono_domain_create_appdomain((char *)p_friendly_name.utf8().get_data(), nullptr);
if (domain) {
// Workaround to avoid this exception:
@@ -353,6 +359,14 @@ MonoDomain *create_domain(const String &p_friendly_name) {
return domain;
}
+String get_type_desc(MonoType *p_type) {
+ return mono_type_full_name(p_type);
+}
+
+String get_type_desc(MonoReflectionType *p_reftype) {
+ return get_type_desc(mono_reflection_type_get_type(p_reftype));
+}
+
String get_exception_name_and_message(MonoException *p_exc) {
String res;
@@ -366,7 +380,7 @@ String get_exception_name_and_message(MonoException *p_exc) {
res += ": ";
MonoProperty *prop = mono_class_get_property_from_name(klass, "Message");
- MonoString *msg = (MonoString *)property_get_value(prop, (MonoObject *)p_exc, NULL, NULL);
+ MonoString *msg = (MonoString *)property_get_value(prop, (MonoObject *)p_exc, nullptr, nullptr);
res += GDMonoMarshal::mono_string_to_godot(msg);
return res;
@@ -377,7 +391,7 @@ void set_exception_message(MonoException *p_exc, String message) {
MonoProperty *prop = mono_class_get_property_from_name(klass, "Message");
MonoString *msg = GDMonoMarshal::mono_string_from_godot(message);
void *params[1] = { msg };
- property_set_value(prop, (MonoObject *)p_exc, params, NULL);
+ property_set_value(prop, (MonoObject *)p_exc, params, nullptr);
}
void debug_print_unhandled_exception(MonoException *p_exc) {
@@ -410,14 +424,14 @@ void debug_send_unhandled_exception_error(MonoException *p_exc) {
Vector<ScriptLanguage::StackInfo> si;
String exc_msg;
- while (p_exc != NULL) {
+ while (p_exc != nullptr) {
GDMonoClass *st_klass = CACHED_CLASS(System_Diagnostics_StackTrace);
MonoObject *stack_trace = mono_object_new(mono_domain_get(), st_klass->get_mono_ptr());
MonoBoolean need_file_info = true;
void *ctor_args[2] = { p_exc, &need_file_info };
- MonoException *unexpected_exc = NULL;
+ MonoException *unexpected_exc = nullptr;
CACHED_METHOD(System_Diagnostics_StackTrace, ctor_Exception_bool)->invoke_raw(stack_trace, ctor_args, &unexpected_exc);
if (unexpected_exc) {
@@ -426,7 +440,7 @@ void debug_send_unhandled_exception_error(MonoException *p_exc) {
}
Vector<ScriptLanguage::StackInfo> _si;
- if (stack_trace != NULL) {
+ if (stack_trace != nullptr) {
_si = CSharpLanguage::get_singleton()->stack_trace_get_info(stack_trace);
for (int i = _si.size() - 1; i >= 0; i--)
si.insert(0, _si[i]);
@@ -436,10 +450,10 @@ void debug_send_unhandled_exception_error(MonoException *p_exc) {
GDMonoClass *exc_class = GDMono::get_singleton()->get_class(mono_get_exception_class());
GDMonoProperty *inner_exc_prop = exc_class->get_property("InnerException");
- CRASH_COND(inner_exc_prop == NULL);
+ CRASH_COND(inner_exc_prop == nullptr);
MonoObject *inner_exc = inner_exc_prop->get_value((MonoObject *)p_exc);
- if (inner_exc != NULL)
+ if (inner_exc != nullptr)
si.insert(0, separator);
p_exc = (MonoException *)inner_exc;
@@ -565,7 +579,7 @@ namespace Marshal {
bool type_is_generic_array(MonoReflectionType *p_reftype) {
NO_GLUE_RET(false);
- MonoException *exc = NULL;
+ MonoException *exc = nullptr;
MonoBoolean res = CACHED_METHOD_THUNK(MarshalUtils, TypeIsGenericArray).invoke(p_reftype, &exc);
UNHANDLED_EXCEPTION(exc);
return (bool)res;
@@ -573,94 +587,75 @@ bool type_is_generic_array(MonoReflectionType *p_reftype) {
bool type_is_generic_dictionary(MonoReflectionType *p_reftype) {
NO_GLUE_RET(false);
- MonoException *exc = NULL;
+ MonoException *exc = nullptr;
MonoBoolean res = CACHED_METHOD_THUNK(MarshalUtils, TypeIsGenericDictionary).invoke(p_reftype, &exc);
UNHANDLED_EXCEPTION(exc);
return (bool)res;
}
-void array_get_element_type(MonoReflectionType *p_array_reftype, MonoReflectionType **r_elem_reftype) {
- MonoException *exc = NULL;
- CACHED_METHOD_THUNK(MarshalUtils, ArrayGetElementType).invoke(p_array_reftype, r_elem_reftype, &exc);
- UNHANDLED_EXCEPTION(exc);
-}
-
-void dictionary_get_key_value_types(MonoReflectionType *p_dict_reftype, MonoReflectionType **r_key_reftype, MonoReflectionType **r_value_reftype) {
- MonoException *exc = NULL;
- CACHED_METHOD_THUNK(MarshalUtils, DictionaryGetKeyValueTypes).invoke(p_dict_reftype, r_key_reftype, r_value_reftype, &exc);
- UNHANDLED_EXCEPTION(exc);
-}
-
-bool generic_ienumerable_is_assignable_from(MonoReflectionType *p_reftype) {
+bool type_is_system_generic_list(MonoReflectionType *p_reftype) {
NO_GLUE_RET(false);
- MonoException *exc = NULL;
- MonoBoolean res = CACHED_METHOD_THUNK(MarshalUtils, GenericIEnumerableIsAssignableFromType).invoke(p_reftype, &exc);
+ MonoException *exc = nullptr;
+ MonoBoolean res = CACHED_METHOD_THUNK(MarshalUtils, TypeIsSystemGenericList).invoke(p_reftype, &exc);
UNHANDLED_EXCEPTION(exc);
return (bool)res;
}
-bool generic_idictionary_is_assignable_from(MonoReflectionType *p_reftype) {
+bool type_is_system_generic_dictionary(MonoReflectionType *p_reftype) {
NO_GLUE_RET(false);
- MonoException *exc = NULL;
- MonoBoolean res = CACHED_METHOD_THUNK(MarshalUtils, GenericIDictionaryIsAssignableFromType).invoke(p_reftype, &exc);
+ MonoException *exc = nullptr;
+ MonoBoolean res = CACHED_METHOD_THUNK(MarshalUtils, TypeIsSystemGenericDictionary).invoke(p_reftype, &exc);
UNHANDLED_EXCEPTION(exc);
return (bool)res;
}
-bool generic_ienumerable_is_assignable_from(MonoReflectionType *p_reftype, MonoReflectionType **r_elem_reftype) {
+bool type_is_generic_ienumerable(MonoReflectionType *p_reftype) {
NO_GLUE_RET(false);
- MonoException *exc = NULL;
- MonoBoolean res = CACHED_METHOD_THUNK(MarshalUtils, GenericIEnumerableIsAssignableFromType_with_info).invoke(p_reftype, r_elem_reftype, &exc);
+ MonoException *exc = nullptr;
+ MonoBoolean res = CACHED_METHOD_THUNK(MarshalUtils, TypeIsGenericIEnumerable).invoke(p_reftype, &exc);
UNHANDLED_EXCEPTION(exc);
return (bool)res;
}
-bool generic_idictionary_is_assignable_from(MonoReflectionType *p_reftype, MonoReflectionType **r_key_reftype, MonoReflectionType **r_value_reftype) {
+bool type_is_generic_icollection(MonoReflectionType *p_reftype) {
NO_GLUE_RET(false);
- MonoException *exc = NULL;
- MonoBoolean res = CACHED_METHOD_THUNK(MarshalUtils, GenericIDictionaryIsAssignableFromType_with_info).invoke(p_reftype, r_key_reftype, r_value_reftype, &exc);
+ MonoException *exc = nullptr;
+ MonoBoolean res = CACHED_METHOD_THUNK(MarshalUtils, TypeIsGenericICollection).invoke(p_reftype, &exc);
UNHANDLED_EXCEPTION(exc);
return (bool)res;
}
-Array enumerable_to_array(MonoObject *p_enumerable) {
- NO_GLUE_RET(Array());
- Array result;
- MonoException *exc = NULL;
- CACHED_METHOD_THUNK(MarshalUtils, EnumerableToArray).invoke(p_enumerable, &result, &exc);
+bool type_is_generic_idictionary(MonoReflectionType *p_reftype) {
+ NO_GLUE_RET(false);
+ MonoException *exc = nullptr;
+ MonoBoolean res = CACHED_METHOD_THUNK(MarshalUtils, TypeIsGenericIDictionary).invoke(p_reftype, &exc);
UNHANDLED_EXCEPTION(exc);
- return result;
+ return (bool)res;
}
-Dictionary idictionary_to_dictionary(MonoObject *p_idictionary) {
- NO_GLUE_RET(Dictionary());
- Dictionary result;
- MonoException *exc = NULL;
- CACHED_METHOD_THUNK(MarshalUtils, IDictionaryToDictionary).invoke(p_idictionary, &result, &exc);
+void array_get_element_type(MonoReflectionType *p_array_reftype, MonoReflectionType **r_elem_reftype) {
+ MonoException *exc = nullptr;
+ CACHED_METHOD_THUNK(MarshalUtils, ArrayGetElementType).invoke(p_array_reftype, r_elem_reftype, &exc);
UNHANDLED_EXCEPTION(exc);
- return result;
}
-Dictionary generic_idictionary_to_dictionary(MonoObject *p_generic_idictionary) {
- NO_GLUE_RET(Dictionary());
- Dictionary result;
- MonoException *exc = NULL;
- CACHED_METHOD_THUNK(MarshalUtils, GenericIDictionaryToDictionary).invoke(p_generic_idictionary, &result, &exc);
+void dictionary_get_key_value_types(MonoReflectionType *p_dict_reftype, MonoReflectionType **r_key_reftype, MonoReflectionType **r_value_reftype) {
+ MonoException *exc = nullptr;
+ CACHED_METHOD_THUNK(MarshalUtils, DictionaryGetKeyValueTypes).invoke(p_dict_reftype, r_key_reftype, r_value_reftype, &exc);
UNHANDLED_EXCEPTION(exc);
- return result;
}
GDMonoClass *make_generic_array_type(MonoReflectionType *p_elem_reftype) {
- NO_GLUE_RET(NULL);
- MonoException *exc = NULL;
+ NO_GLUE_RET(nullptr);
+ MonoException *exc = nullptr;
MonoReflectionType *reftype = CACHED_METHOD_THUNK(MarshalUtils, MakeGenericArrayType).invoke(p_elem_reftype, &exc);
UNHANDLED_EXCEPTION(exc);
return GDMono::get_singleton()->get_class(mono_class_from_mono_type(mono_reflection_type_get_type(reftype)));
}
GDMonoClass *make_generic_dictionary_type(MonoReflectionType *p_key_reftype, MonoReflectionType *p_value_reftype) {
- NO_GLUE_RET(NULL);
- MonoException *exc = NULL;
+ NO_GLUE_RET(nullptr);
+ MonoException *exc = nullptr;
MonoReflectionType *reftype = CACHED_METHOD_THUNK(MarshalUtils, MakeGenericDictionaryType).invoke(p_key_reftype, p_value_reftype, &exc);
UNHANDLED_EXCEPTION(exc);
return GDMono::get_singleton()->get_class(mono_class_from_mono_type(mono_reflection_type_get_type(reftype)));
@@ -669,7 +664,7 @@ GDMonoClass *make_generic_dictionary_type(MonoReflectionType *p_key_reftype, Mon
} // namespace Marshal
ScopeThreadAttach::ScopeThreadAttach() :
- mono_thread(NULL) {
+ mono_thread(nullptr) {
if (likely(GDMono::get_singleton()->is_runtime_initialized()) && unlikely(!mono_domain_get())) {
mono_thread = GDMonoUtils::attach_current_thread();
}
@@ -682,7 +677,7 @@ ScopeThreadAttach::~ScopeThreadAttach() {
}
StringName get_native_godot_class_name(GDMonoClass *p_class) {
- MonoObject *native_name_obj = p_class->get_field(BINDINGS_NATIVE_NAME_FIELD)->get_value(NULL);
+ MonoObject *native_name_obj = p_class->get_field(BINDINGS_NATIVE_NAME_FIELD)->get_value(nullptr);
StringName *ptr = GDMonoMarshal::unbox<StringName *>(CACHED_FIELD(StringName, ptr)->get_value(native_name_obj));
return ptr ? *ptr : StringName();
}
diff --git a/modules/mono/mono_gd/gd_mono_utils.h b/modules/mono/mono_gd/gd_mono_utils.h
index fd02907d87..e3011ade5d 100644
--- a/modules/mono/mono_gd/gd_mono_utils.h
+++ b/modules/mono/mono_gd/gd_mono_utils.h
@@ -41,7 +41,7 @@
#include "core/reference.h"
#define UNHANDLED_EXCEPTION(m_exc) \
- if (unlikely(m_exc != NULL)) { \
+ if (unlikely(m_exc != nullptr)) { \
GDMonoUtils::debug_unhandled_exception(m_exc); \
GD_UNREACHABLE(); \
}
@@ -52,22 +52,18 @@ namespace Marshal {
bool type_is_generic_array(MonoReflectionType *p_reftype);
bool type_is_generic_dictionary(MonoReflectionType *p_reftype);
+bool type_is_system_generic_list(MonoReflectionType *p_reftype);
+bool type_is_system_generic_dictionary(MonoReflectionType *p_reftype);
+bool type_is_generic_ienumerable(MonoReflectionType *p_reftype);
+bool type_is_generic_icollection(MonoReflectionType *p_reftype);
+bool type_is_generic_idictionary(MonoReflectionType *p_reftype);
void array_get_element_type(MonoReflectionType *p_array_reftype, MonoReflectionType **r_elem_reftype);
void dictionary_get_key_value_types(MonoReflectionType *p_dict_reftype, MonoReflectionType **r_key_reftype, MonoReflectionType **r_value_reftype);
-bool generic_ienumerable_is_assignable_from(MonoReflectionType *p_reftype);
-bool generic_idictionary_is_assignable_from(MonoReflectionType *p_reftype);
-bool generic_ienumerable_is_assignable_from(MonoReflectionType *p_reftype, MonoReflectionType **r_elem_reftype);
-bool generic_idictionary_is_assignable_from(MonoReflectionType *p_reftype, MonoReflectionType **r_key_reftype, MonoReflectionType **r_value_reftype);
-
GDMonoClass *make_generic_array_type(MonoReflectionType *p_elem_reftype);
GDMonoClass *make_generic_dictionary_type(MonoReflectionType *p_key_reftype, MonoReflectionType *p_value_reftype);
-Array enumerable_to_array(MonoObject *p_enumerable);
-Dictionary idictionary_to_dictionary(MonoObject *p_idictionary);
-Dictionary generic_idictionary_to_dictionary(MonoObject *p_generic_idictionary);
-
} // namespace Marshal
_FORCE_INLINE_ void hash_combine(uint32_t &p_hash, const uint32_t &p_with_hash) {
@@ -77,7 +73,7 @@ _FORCE_INLINE_ void hash_combine(uint32_t &p_hash, const uint32_t &p_with_hash)
/**
* If the object has a csharp script, returns the target of the gchandle stored in the script instance
* Otherwise returns a newly constructed MonoObject* which is attached to the object
- * Returns NULL on error
+ * Returns nullptr on error
*/
MonoObject *unmanaged_get_managed(Object *unmanaged);
@@ -89,7 +85,7 @@ MonoThread *get_current_thread();
bool is_thread_attached();
_FORCE_INLINE_ bool is_main_thread() {
- return mono_domain_get() != NULL && mono_thread_get_main() == mono_thread_current();
+ return mono_domain_get() != nullptr && mono_thread_get_main() == mono_thread_current();
}
uint32_t new_strong_gchandle(MonoObject *p_object);
@@ -97,7 +93,7 @@ uint32_t new_strong_gchandle_pinned(MonoObject *p_object);
uint32_t new_weak_gchandle(MonoObject *p_object);
void free_gchandle(uint32_t p_gchandle);
-void runtime_object_init(MonoObject *p_this_obj, GDMonoClass *p_class, MonoException **r_exc = NULL);
+void runtime_object_init(MonoObject *p_this_obj, GDMonoClass *p_class, MonoException **r_exc = nullptr);
bool mono_delegate_equal(MonoDelegate *p_a, MonoDelegate *p_b);
@@ -115,6 +111,9 @@ MonoObject *create_managed_from(const Dictionary &p_from, GDMonoClass *p_class);
MonoDomain *create_domain(const String &p_friendly_name);
+String get_type_desc(MonoType *p_type);
+String get_type_desc(MonoReflectionType *p_reftype);
+
String get_exception_name_and_message(MonoException *p_exc);
void set_exception_message(MonoException *p_exc, String message);
diff --git a/modules/mono/mono_gd/managed_type.h b/modules/mono/mono_gd/managed_type.h
index 11b832d0cc..84d1837853 100644
--- a/modules/mono/mono_gd/managed_type.h
+++ b/modules/mono/mono_gd/managed_type.h
@@ -46,7 +46,7 @@ struct ManagedType {
ManagedType() :
type_encoding(0),
- type_class(NULL) {
+ type_class(nullptr) {
}
ManagedType(int p_type_encoding, GDMonoClass *p_type_class) :
diff --git a/modules/mono/mono_gd/gd_mono_android.cpp b/modules/mono/mono_gd/support/android_support.cpp
index 761368878f..8bcdeec9dd 100644..100755
--- a/modules/mono/mono_gd/gd_mono_android.cpp
+++ b/modules/mono/mono_gd/support/android_support.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* gd_mono_android.cpp */
+/* android_support.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,7 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "gd_mono_android.h"
+#include "android_support.h"
#if defined(ANDROID_ENABLED)
@@ -49,14 +49,16 @@
#include "platform/android/os_android.h"
#include "platform/android/thread_jandroid.h"
-#include "../utils/path_utils.h"
-#include "../utils/string_utils.h"
-#include "gd_mono_cache.h"
-#include "gd_mono_marshal.h"
+#include "../../utils/path_utils.h"
+#include "../../utils/string_utils.h"
+#include "../gd_mono_cache.h"
+#include "../gd_mono_marshal.h"
// Warning: JNI boilerplate ahead... continue at your own risk
-namespace GDMonoAndroid {
+namespace gdmono {
+namespace android {
+namespace support {
template <typename T>
struct ScopedLocalRef {
@@ -67,7 +69,7 @@ struct ScopedLocalRef {
_FORCE_INLINE_ operator T() const { return local_ref; }
_FORCE_INLINE_ operator jvalue() const { return (jvalue)local_ref; }
- _FORCE_INLINE_ operator bool() const { return local_ref != NULL; }
+ _FORCE_INLINE_ operator bool() const { return local_ref != nullptr; }
_FORCE_INLINE_ bool operator==(std::nullptr_t) const {
return local_ref == nullptr;
@@ -122,7 +124,7 @@ String determine_app_native_lib_dir() {
String result;
- const char *const nativeLibraryDirUtf8 = env->GetStringUTFChars(nativeLibraryDir, NULL);
+ const char *const nativeLibraryDirUtf8 = env->GetStringUTFChars(nativeLibraryDir, nullptr);
if (nativeLibraryDirUtf8) {
result.parse_utf8(nativeLibraryDirUtf8);
env->ReleaseStringUTFChars(nativeLibraryDir, nativeLibraryDirUtf8);
@@ -150,21 +152,21 @@ int gd_mono_convert_dl_flags(int flags) {
return lflags;
}
-#ifndef GD_MONO_ANDROID_SO_NAME
-#define GD_MONO_ANDROID_SO_NAME "libmonosgen-2.0.so"
+#ifndef GD_MONO_SO_NAME
+#define GD_MONO_SO_NAME "libmonosgen-2.0.so"
#endif
-const char *mono_so_name = GD_MONO_ANDROID_SO_NAME;
+const char *mono_so_name = GD_MONO_SO_NAME;
const char *godot_so_name = "libgodot_android.so";
-void *mono_dl_handle = NULL;
-void *godot_dl_handle = NULL;
+void *mono_dl_handle = nullptr;
+void *godot_dl_handle = nullptr;
void *try_dlopen(const String &p_so_path, int p_flags) {
if (!FileAccess::exists(p_so_path)) {
if (OS::get_singleton()->is_stdout_verbose())
OS::get_singleton()->print("Cannot find shared library: '%s'\n", p_so_path.utf8().get_data());
- return NULL;
+ return nullptr;
}
int lflags = gd_mono_convert_dl_flags(p_flags);
@@ -174,7 +176,7 @@ void *try_dlopen(const String &p_so_path, int p_flags) {
if (!handle) {
if (OS::get_singleton()->is_stdout_verbose())
OS::get_singleton()->print("Failed to open shared library: '%s'. Error: '%s'\n", p_so_path.utf8().get_data(), dlerror());
- return NULL;
+ return nullptr;
}
if (OS::get_singleton()->is_stdout_verbose())
@@ -184,7 +186,7 @@ void *try_dlopen(const String &p_so_path, int p_flags) {
}
void *gd_mono_android_dlopen(const char *p_name, int p_flags, char **r_err, void *p_user_data) {
- if (p_name == NULL) {
+ if (p_name == nullptr) {
// __Internal
if (!mono_dl_handle) {
@@ -209,7 +211,7 @@ void *gd_mono_android_dlopen(const char *p_name, int p_flags, char **r_err, void
return try_dlopen(so_path, p_flags);
}
- return NULL;
+ return nullptr;
}
void *gd_mono_android_dlsym(void *p_handle, const char *p_name, char **r_err, void *p_user_data) {
@@ -230,7 +232,7 @@ void *gd_mono_android_dlsym(void *p_handle, const char *p_name, char **r_err, vo
if (r_err)
*r_err = str_format_new("%s\n", dlerror());
- return NULL;
+ return nullptr;
}
void *gd_mono_android_dlclose(void *p_handle, void *p_user_data) {
@@ -238,9 +240,9 @@ void *gd_mono_android_dlclose(void *p_handle, void *p_user_data) {
// Not sure if this ever happens. Does Mono close the handle for the main module?
if (p_handle == mono_dl_handle)
- mono_dl_handle = NULL;
+ mono_dl_handle = nullptr;
- return NULL;
+ return nullptr;
}
int32_t build_version_sdk_int = 0;
@@ -265,7 +267,7 @@ int32_t get_build_version_sdk_int() {
return build_version_sdk_int;
}
-jobject certStore = NULL; // KeyStore
+jobject certStore = nullptr; // KeyStore
MonoBoolean _gd_mono_init_cert_store() {
// The JNI code is the equivalent of:
@@ -293,7 +295,7 @@ MonoBoolean _gd_mono_init_cert_store() {
if (jni_exception_check(env))
return 0;
- env->CallVoidMethod(certStoreLocal, load, NULL);
+ env->CallVoidMethod(certStoreLocal, load, nullptr);
if (jni_exception_check(env))
return 0;
@@ -317,7 +319,7 @@ MonoArray *_gd_mono_android_cert_store_lookup(MonoString *p_alias) {
if (!mono_error_ok(&mono_error)) {
ERR_PRINT(String() + "Failed to convert MonoString* to UTF-8: '" + mono_error_get_message(&mono_error) + "'.");
mono_error_cleanup(&mono_error);
- return NULL;
+ return nullptr;
}
JNIEnv *env = ThreadAndroid::get_env();
@@ -326,20 +328,20 @@ MonoArray *_gd_mono_android_cert_store_lookup(MonoString *p_alias) {
mono_free(alias_utf8);
ScopedLocalRef<jclass> keyStoreClass(env, env->FindClass("java/security/KeyStore"));
- ERR_FAIL_NULL_V(keyStoreClass, NULL);
+ ERR_FAIL_NULL_V(keyStoreClass, nullptr);
ScopedLocalRef<jclass> certificateClass(env, env->FindClass("java/security/cert/Certificate"));
- ERR_FAIL_NULL_V(certificateClass, NULL);
+ ERR_FAIL_NULL_V(certificateClass, nullptr);
jmethodID getCertificate = env->GetMethodID(keyStoreClass, "getCertificate", "(Ljava/lang/String;)Ljava/security/cert/Certificate;");
- ERR_FAIL_NULL_V(getCertificate, NULL);
+ ERR_FAIL_NULL_V(getCertificate, nullptr);
jmethodID getEncoded = env->GetMethodID(certificateClass, "getEncoded", "()[B");
- ERR_FAIL_NULL_V(getEncoded, NULL);
+ ERR_FAIL_NULL_V(getEncoded, nullptr);
ScopedLocalRef<jobject> certificate(env, env->CallObjectMethod(certStore, getCertificate, js_alias.get()));
if (!certificate)
- return NULL;
+ return nullptr;
ScopedLocalRef<jbyteArray> encoded(env, (jbyteArray)env->CallObjectMethod(certificate, getEncoded));
jsize encodedLength = env->GetArrayLength(encoded);
@@ -352,11 +354,16 @@ MonoArray *_gd_mono_android_cert_store_lookup(MonoString *p_alias) {
return encoded_ret;
}
+void register_internal_calls() {
+ mono_add_internal_call("Android.Runtime.AndroidEnvironment::_gd_mono_init_cert_store", (void *)_gd_mono_init_cert_store);
+ mono_add_internal_call("Android.Runtime.AndroidEnvironment::_gd_mono_android_cert_store_lookup", (void *)_gd_mono_android_cert_store_lookup);
+}
+
void initialize() {
// We need to set this environment variable to make the monodroid BCL use btls instead of legacy as the default provider
OS::get_singleton()->set_environment("XA_TLS_PROVIDER", "btls");
- mono_dl_fallback_register(gd_mono_android_dlopen, gd_mono_android_dlsym, gd_mono_android_dlclose, NULL);
+ mono_dl_fallback_register(gd_mono_android_dlopen, gd_mono_android_dlsym, gd_mono_android_dlclose, nullptr);
String app_native_lib_dir = get_app_native_lib_dir();
String so_path = path::join(app_native_lib_dir, godot_so_name);
@@ -364,31 +371,28 @@ void initialize() {
godot_dl_handle = try_dlopen(so_path, gd_mono_convert_dl_flags(MONO_DL_LAZY));
}
-void register_internal_calls() {
- mono_add_internal_call("Android.Runtime.AndroidEnvironment::_gd_mono_init_cert_store", (void *)_gd_mono_init_cert_store);
- mono_add_internal_call("Android.Runtime.AndroidEnvironment::_gd_mono_android_cert_store_lookup", (void *)_gd_mono_android_cert_store_lookup);
-}
-
void cleanup() {
// This is called after shutting down the Mono runtime
if (mono_dl_handle)
- gd_mono_android_dlclose(mono_dl_handle, NULL);
+ gd_mono_android_dlclose(mono_dl_handle, nullptr);
if (godot_dl_handle)
- gd_mono_android_dlclose(godot_dl_handle, NULL);
+ gd_mono_android_dlclose(godot_dl_handle, nullptr);
JNIEnv *env = ThreadAndroid::get_env();
if (certStore) {
env->DeleteGlobalRef(certStore);
- certStore = NULL;
+ certStore = nullptr;
}
}
-} // namespace GDMonoAndroid
+} // namespace support
+} // namespace android
+} // namespace gdmono
-using namespace GDMonoAndroid;
+using namespace gdmono::android::support;
// The following are P/Invoke functions required by the monodroid profile of the BCL.
// These are P/Invoke functions and not internal calls, hence why they use
@@ -417,7 +421,7 @@ GD_PINVOKE_EXPORT int32_t monodroid_get_system_property(const char *p_name, char
memcpy(*r_value, prop_value_str, len);
(*r_value)[len] = '\0';
} else {
- *r_value = NULL;
+ *r_value = nullptr;
}
}
@@ -604,7 +608,7 @@ GD_PINVOKE_EXPORT int32_t _monodroid_get_dns_servers(void **r_dns_servers_array)
if (!r_dns_servers_array)
return -1;
- *r_dns_servers_array = NULL;
+ *r_dns_servers_array = nullptr;
char *dns_servers[dns_servers_len];
int dns_servers_count = 0;
@@ -648,23 +652,23 @@ GD_PINVOKE_EXPORT const char *_monodroid_timezone_get_default_id() {
JNIEnv *env = ThreadAndroid::get_env();
ScopedLocalRef<jclass> timeZoneClass(env, env->FindClass("java/util/TimeZone"));
- ERR_FAIL_NULL_V(timeZoneClass, NULL);
+ ERR_FAIL_NULL_V(timeZoneClass, nullptr);
jmethodID getDefault = env->GetStaticMethodID(timeZoneClass, "getDefault", "()Ljava/util/TimeZone;");
- ERR_FAIL_NULL_V(getDefault, NULL);
+ ERR_FAIL_NULL_V(getDefault, nullptr);
jmethodID getID = env->GetMethodID(timeZoneClass, "getID", "()Ljava/lang/String;");
- ERR_FAIL_NULL_V(getID, NULL);
+ ERR_FAIL_NULL_V(getID, nullptr);
ScopedLocalRef<jobject> defaultTimeZone(env, env->CallStaticObjectMethod(timeZoneClass, getDefault));
if (!defaultTimeZone)
- return NULL;
+ return nullptr;
ScopedLocalRef<jstring> defaultTimeZoneID(env, (jstring)env->CallObjectMethod(defaultTimeZone, getID));
if (!defaultTimeZoneID)
- return NULL;
+ return nullptr;
const char *default_time_zone_id = env->GetStringUTFChars(defaultTimeZoneID, 0);
diff --git a/modules/mono/mono_gd/gd_mono_android.h b/modules/mono/mono_gd/support/android_support.h
index 0e04847924..dc2e6c95ed 100644..100755
--- a/modules/mono/mono_gd/gd_mono_android.h
+++ b/modules/mono/mono_gd/support/android_support.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* gd_mono_android.h */
+/* android_support.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,25 +28,28 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef GD_MONO_ANDROID_H
-#define GD_MONO_ANDROID_H
+#ifndef ANDROID_SUPPORT_H
+#define ANDROID_SUPPORT_H
#if defined(ANDROID_ENABLED)
#include "core/ustring.h"
-namespace GDMonoAndroid {
+namespace gdmono {
+namespace android {
+namespace support {
String get_app_native_lib_dir();
void initialize();
+void cleanup();
void register_internal_calls();
-void cleanup();
-
-} // namespace GDMonoAndroid
+} // namespace support
+} // namespace android
+} // namespace gdmono
#endif // ANDROID_ENABLED
-#endif // GD_MONO_ANDROID_H
+#endif // ANDROID_SUPPORT_H
diff --git a/modules/mono/mono_gd/support/ios_support.h b/modules/mono/mono_gd/support/ios_support.h
new file mode 100755
index 0000000000..e28af120e3
--- /dev/null
+++ b/modules/mono/mono_gd/support/ios_support.h
@@ -0,0 +1,51 @@
+/*************************************************************************/
+/* ios_support.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifndef IOS_SUPPORT_H
+#define IOS_SUPPORT_H
+
+#if defined(IPHONE_ENABLED)
+
+#include "core/ustring.h"
+
+namespace gdmono {
+namespace ios {
+namespace support {
+
+void initialize();
+void cleanup();
+
+} // namespace support
+} // namespace ios
+} // namespace gdmono
+
+#endif // IPHONE_ENABLED
+
+#endif // IOS_SUPPORT_H
diff --git a/modules/mono/mono_gd/support/ios_support.mm b/modules/mono/mono_gd/support/ios_support.mm
new file mode 100755
index 0000000000..e3d1a647fd
--- /dev/null
+++ b/modules/mono/mono_gd/support/ios_support.mm
@@ -0,0 +1,151 @@
+/*************************************************************************/
+/* ios_support.mm */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#include "ios_support.h"
+
+#if defined(IPHONE_ENABLED)
+
+#import <Foundation/Foundation.h>
+#include <os/log.h>
+
+#include "core/ustring.h"
+
+#include "../gd_mono_marshal.h"
+
+// Implemented mostly following: https://github.com/mono/mono/blob/master/sdks/ios/app/runtime.m
+
+// Definition generated by the Godot exporter
+extern "C" void gd_mono_setup_aot();
+
+namespace gdmono {
+namespace ios {
+namespace support {
+
+void ios_mono_log_callback(const char *log_domain, const char *log_level, const char *message, mono_bool fatal, void *user_data) {
+ os_log_info(OS_LOG_DEFAULT, "(%s %s) %s", log_domain, log_level, message);
+ if (fatal) {
+ os_log_info(OS_LOG_DEFAULT, "Exit code: %d.", 1);
+ exit(1);
+ }
+}
+
+void initialize() {
+ mono_dllmap_insert(NULL, "System.Native", NULL, "__Internal", NULL);
+ mono_dllmap_insert(NULL, "System.IO.Compression.Native", NULL, "__Internal", NULL);
+ mono_dllmap_insert(NULL, "System.Security.Cryptography.Native.Apple", NULL, "__Internal", NULL);
+
+#ifdef IOS_DEVICE
+ // This function is defined in an auto-generated source file
+ gd_mono_setup_aot();
+#endif
+
+ mono_set_signal_chaining(true);
+ mono_set_crash_chaining(true);
+}
+
+void cleanup() {
+}
+
+} // namespace support
+} // namespace ios
+} // namespace gdmono
+
+// The following are P/Invoke functions required by the monotouch profile of the BCL.
+// These are P/Invoke functions and not internal calls, hence why they use
+// 'mono_bool' and 'const char*' instead of 'MonoBoolean' and 'MonoString*'.
+
+#define GD_PINVOKE_EXPORT extern "C" __attribute__((visibility("default")))
+
+GD_PINVOKE_EXPORT const char *xamarin_get_locale_country_code() {
+ NSLocale *locale = [NSLocale currentLocale];
+ NSString *countryCode = [locale objectForKey:NSLocaleCountryCode];
+ if (countryCode == NULL) {
+ return strdup("US");
+ }
+ return strdup([countryCode UTF8String]);
+}
+
+GD_PINVOKE_EXPORT void xamarin_log(const uint16_t *p_unicode_message) {
+ int length = 0;
+ const uint16_t *ptr = p_unicode_message;
+ while (*ptr++)
+ length += sizeof(uint16_t);
+ NSString *msg = [[NSString alloc] initWithBytes:p_unicode_message length:length encoding:NSUTF16LittleEndianStringEncoding];
+
+ os_log_info(OS_LOG_DEFAULT, "%{public}@", msg);
+}
+
+GD_PINVOKE_EXPORT const char *xamarin_GetFolderPath(int p_folder) {
+ NSSearchPathDirectory dd = (NSSearchPathDirectory)p_folder;
+ NSURL *url = [[[NSFileManager defaultManager] URLsForDirectory:dd inDomains:NSUserDomainMask] lastObject];
+ NSString *path = [url path];
+ return strdup([path UTF8String]);
+}
+
+GD_PINVOKE_EXPORT char *xamarin_timezone_get_local_name() {
+ NSTimeZone *tz = nil;
+ tz = [NSTimeZone localTimeZone];
+ NSString *name = [tz name];
+ return (name != nil) ? strdup([name UTF8String]) : strdup("Local");
+}
+
+GD_PINVOKE_EXPORT char **xamarin_timezone_get_names(uint32_t *p_count) {
+ NSArray *array = [NSTimeZone knownTimeZoneNames];
+ *p_count = array.count;
+ char **result = (char **)malloc(sizeof(char *) * (*p_count));
+ for (uint32_t i = 0; i < *p_count; i++) {
+ NSString *s = [array objectAtIndex:i];
+ result[i] = strdup(s.UTF8String);
+ }
+ return result;
+}
+
+GD_PINVOKE_EXPORT void *xamarin_timezone_get_data(const char *p_name, uint32_t *p_size) { // FIXME: uint32_t since Dec 2019, unsigned long before
+ NSTimeZone *tz = nil;
+ if (p_name) {
+ NSString *n = [[NSString alloc] initWithUTF8String:p_name];
+ tz = [[[NSTimeZone alloc] initWithName:n] autorelease];
+ [n release];
+ } else {
+ tz = [NSTimeZone localTimeZone];
+ }
+ NSData *data = [tz data];
+ *p_size = [data length];
+ void *result = malloc(*p_size);
+ memcpy(result, data.bytes, *p_size);
+ return result;
+}
+
+GD_PINVOKE_EXPORT void xamarin_start_wwan(const char *p_uri) {
+ // FIXME: What's this for? No idea how to implement.
+ os_log_error(OS_LOG_DEFAULT, "Not implemented: 'xamarin_start_wwan'");
+}
+
+#endif // IPHONE_ENABLED
diff --git a/modules/mono/register_types.cpp b/modules/mono/register_types.cpp
index 4823ba3679..94431e7c30 100644
--- a/modules/mono/register_types.cpp
+++ b/modules/mono/register_types.cpp
@@ -34,11 +34,11 @@
#include "csharp_script.h"
-CSharpLanguage *script_language_cs = NULL;
+CSharpLanguage *script_language_cs = nullptr;
Ref<ResourceFormatLoaderCSharpScript> resource_loader_cs;
Ref<ResourceFormatSaverCSharpScript> resource_saver_cs;
-_GodotSharp *_godotsharp = NULL;
+_GodotSharp *_godotsharp = nullptr;
void register_mono_types() {
ClassDB::register_class<CSharpScript>();
diff --git a/modules/mono/signal_awaiter_utils.cpp b/modules/mono/signal_awaiter_utils.cpp
index 25e5a41215..e77a2e98f2 100644
--- a/modules/mono/signal_awaiter_utils.cpp
+++ b/modules/mono/signal_awaiter_utils.cpp
@@ -121,7 +121,7 @@ void SignalAwaiterCallable::call(const Variant **p_arguments, int p_argcount, Va
return;
}
- MonoException *exc = NULL;
+ MonoException *exc = nullptr;
CACHED_METHOD_THUNK(SignalAwaiter, SignalCallback).invoke(awaiter, signal_args, &exc);
if (exc) {
@@ -210,7 +210,7 @@ void EventSignalCallable::call(const Variant **p_arguments, int p_argcount, Vari
return;
}
- MonoException *exc = NULL;
+ MonoException *exc = nullptr;
event_signal->invoke_method->invoke(delegate_field_value, p_arguments, &exc);
if (exc) {
diff --git a/modules/mono/utils/mono_reg_utils.cpp b/modules/mono/utils/mono_reg_utils.cpp
index c1cd5f1db4..8f0ad8ba5e 100644
--- a/modules/mono/utils/mono_reg_utils.cpp
+++ b/modules/mono/utils/mono_reg_utils.cpp
@@ -73,13 +73,13 @@ LONG _RegKeyQueryString(HKEY hKey, const String &p_value_name, String &r_value)
buffer.resize(512);
DWORD dwBufferSize = buffer.size();
- LONG res = RegQueryValueExW(hKey, p_value_name.c_str(), 0, NULL, (LPBYTE)buffer.ptr(), &dwBufferSize);
+ LONG res = RegQueryValueExW(hKey, p_value_name.c_str(), 0, nullptr, (LPBYTE)buffer.ptr(), &dwBufferSize);
if (res == ERROR_MORE_DATA) {
// dwBufferSize now contains the actual size
Vector<WCHAR> buffer;
buffer.resize(dwBufferSize);
- res = RegQueryValueExW(hKey, p_value_name.c_str(), 0, NULL, (LPBYTE)buffer.ptr(), &dwBufferSize);
+ res = RegQueryValueExW(hKey, p_value_name.c_str(), 0, nullptr, (LPBYTE)buffer.ptr(), &dwBufferSize);
}
if (res == ERROR_SUCCESS) {
@@ -180,7 +180,7 @@ String find_msbuild_tools_path() {
String output;
int exit_code;
- OS::get_singleton()->execute(vswhere_path, vswhere_args, true, NULL, &output, &exit_code);
+ OS::get_singleton()->execute(vswhere_path, vswhere_args, true, nullptr, &output, &exit_code);
if (exit_code == 0) {
Vector<String> lines = output.split("\n");
diff --git a/modules/mono/utils/osx_utils.cpp b/modules/mono/utils/osx_utils.cpp
index 432b306414..8fadf3c109 100644
--- a/modules/mono/utils/osx_utils.cpp
+++ b/modules/mono/utils/osx_utils.cpp
@@ -39,9 +39,9 @@
bool osx_is_app_bundle_installed(const String &p_bundle_id) {
- CFURLRef app_url = NULL;
- CFStringRef bundle_id = CFStringCreateWithCString(NULL, p_bundle_id.utf8(), kCFStringEncodingUTF8);
- OSStatus result = LSFindApplicationForInfo(kLSUnknownCreator, bundle_id, NULL, NULL, &app_url);
+ CFURLRef app_url = nullptr;
+ CFStringRef bundle_id = CFStringCreateWithCString(nullptr, p_bundle_id.utf8(), kCFStringEncodingUTF8);
+ OSStatus result = LSFindApplicationForInfo(kLSUnknownCreator, bundle_id, nullptr, nullptr, &app_url);
CFRelease(bundle_id);
if (app_url)
diff --git a/modules/mono/utils/path_utils.cpp b/modules/mono/utils/path_utils.cpp
index 545da6c79e..973375a471 100644
--- a/modules/mono/utils/path_utils.cpp
+++ b/modules/mono/utils/path_utils.cpp
@@ -80,7 +80,7 @@ String find_executable(const String &p_name) {
String cwd() {
#ifdef WINDOWS_ENABLED
- const DWORD expected_size = ::GetCurrentDirectoryW(0, NULL);
+ const DWORD expected_size = ::GetCurrentDirectoryW(0, nullptr);
String buffer;
buffer.resize((int)expected_size);
@@ -90,7 +90,7 @@ String cwd() {
return buffer.simplify_path();
#else
char buffer[PATH_MAX];
- if (::getcwd(buffer, sizeof(buffer)) == NULL)
+ if (::getcwd(buffer, sizeof(buffer)) == nullptr)
return ".";
String result;
@@ -114,12 +114,12 @@ String realpath(const String &p_path) {
// Open file without read/write access
HANDLE hFile = ::CreateFileW(p_path.c_str(), 0,
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
- NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+ nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
if (hFile == INVALID_HANDLE_VALUE)
return p_path;
- const DWORD expected_size = ::GetFinalPathNameByHandleW(hFile, NULL, 0, FILE_NAME_NORMALIZED);
+ const DWORD expected_size = ::GetFinalPathNameByHandleW(hFile, nullptr, 0, FILE_NAME_NORMALIZED);
if (expected_size == 0) {
::CloseHandle(hFile);
@@ -133,7 +133,7 @@ String realpath(const String &p_path) {
::CloseHandle(hFile);
return buffer.simplify_path();
#elif UNIX_ENABLED
- char *resolved_path = ::realpath(p_path.utf8().get_data(), NULL);
+ char *resolved_path = ::realpath(p_path.utf8().get_data(), nullptr);
if (!resolved_path)
return p_path;
diff --git a/modules/mono/utils/string_utils.cpp b/modules/mono/utils/string_utils.cpp
index 49c4fb3f73..907811355f 100644
--- a/modules/mono/utils/string_utils.cpp
+++ b/modules/mono/utils/string_utils.cpp
@@ -212,7 +212,7 @@ String str_format(const char *p_format, ...) {
#define gd_vscprintf(m_format, m_args_copy) _vscprintf(m_format, m_args_copy)
#else
#define gd_vsnprintf(m_buffer, m_count, m_format, m_args_copy) vsnprintf(m_buffer, m_count, m_format, m_args_copy)
-#define gd_vscprintf(m_format, m_args_copy) vsnprintf(NULL, 0, p_format, m_args_copy)
+#define gd_vscprintf(m_format, m_args_copy) vsnprintf(nullptr, 0, p_format, m_args_copy)
#endif
String str_format(const char *p_format, va_list p_list) {
diff --git a/modules/ogg/SCsub b/modules/ogg/SCsub
index 44c7963cd3..e768fb4ae8 100644
--- a/modules/ogg/SCsub
+++ b/modules/ogg/SCsub
@@ -1,7 +1,7 @@
#!/usr/bin/env python
-Import('env')
-Import('env_modules')
+Import("env")
+Import("env_modules")
# Only kept to build the thirdparty library used by the theora and webm
# modules.
@@ -9,7 +9,7 @@ Import('env_modules')
env_ogg = env_modules.Clone()
# Thirdparty source files
-if env['builtin_libogg']:
+if env["builtin_libogg"]:
thirdparty_dir = "#thirdparty/libogg/"
thirdparty_sources = [
"bitwise.c",
diff --git a/modules/ogg/config.py b/modules/ogg/config.py
index 1c8cd12a2d..d22f9454ed 100644
--- a/modules/ogg/config.py
+++ b/modules/ogg/config.py
@@ -1,5 +1,6 @@
def can_build(env, platform):
return True
+
def configure(env):
pass
diff --git a/modules/opensimplex/SCsub b/modules/opensimplex/SCsub
index 311d33b047..52d8b145ef 100644
--- a/modules/opensimplex/SCsub
+++ b/modules/opensimplex/SCsub
@@ -1,7 +1,7 @@
#!/usr/bin/env python
-Import('env')
-Import('env_modules')
+Import("env")
+Import("env_modules")
env_opensimplex = env_modules.Clone()
diff --git a/modules/opensimplex/config.py b/modules/opensimplex/config.py
index c1010ad433..90b85dbd70 100644
--- a/modules/opensimplex/config.py
+++ b/modules/opensimplex/config.py
@@ -1,14 +1,17 @@
def can_build(env, platform):
- return True
+ return True
+
def configure(env):
- pass
+ pass
+
def get_doc_classes():
return [
"NoiseTexture",
- "OpenSimplexNoise"
+ "OpenSimplexNoise",
]
+
def get_doc_path():
return "doc_classes"
diff --git a/modules/opensimplex/noise_texture.cpp b/modules/opensimplex/noise_texture.cpp
index 8e5b04f995..2018f90e9f 100644
--- a/modules/opensimplex/noise_texture.cpp
+++ b/modules/opensimplex/noise_texture.cpp
@@ -34,7 +34,7 @@
NoiseTexture::NoiseTexture() {
update_queued = false;
- noise_thread = NULL;
+ noise_thread = nullptr;
regen_queued = false;
first_time = true;
@@ -50,7 +50,7 @@ NoiseTexture::NoiseTexture() {
NoiseTexture::~NoiseTexture() {
if (texture.is_valid()) {
- VS::get_singleton()->free(texture);
+ RS::get_singleton()->free(texture);
}
if (noise_thread) {
Thread::wait_to_finish(noise_thread);
@@ -100,10 +100,10 @@ void NoiseTexture::_set_texture_data(const Ref<Image> &p_image) {
data = p_image;
if (data.is_valid()) {
if (texture.is_valid()) {
- RID new_texture = VS::get_singleton()->texture_2d_create(p_image);
- VS::get_singleton()->texture_replace(texture, new_texture);
+ RID new_texture = RS::get_singleton()->texture_2d_create(p_image);
+ RS::get_singleton()->texture_replace(texture, new_texture);
} else {
- texture = VS::get_singleton()->texture_2d_create(p_image);
+ texture = RS::get_singleton()->texture_2d_create(p_image);
}
}
emit_changed();
@@ -114,7 +114,7 @@ void NoiseTexture::_thread_done(const Ref<Image> &p_image) {
_set_texture_data(p_image);
Thread::wait_to_finish(noise_thread);
memdelete(noise_thread);
- noise_thread = NULL;
+ noise_thread = nullptr;
if (regen_queued) {
noise_thread = Thread::create(_thread_function, this);
regen_queued = false;
@@ -137,14 +137,19 @@ void NoiseTexture::_queue_update() {
Ref<Image> NoiseTexture::_generate_texture() {
- if (noise.is_null()) return Ref<Image>();
+ // Prevent memdelete due to unref() on other thread.
+ Ref<OpenSimplexNoise> ref_noise = noise;
+
+ if (ref_noise.is_null()) {
+ return Ref<Image>();
+ }
Ref<Image> image;
if (seamless) {
- image = noise->get_seamless_image(size.x);
+ image = ref_noise->get_seamless_image(size.x);
} else {
- image = noise->get_image(size.x, size.y);
+ image = ref_noise->get_image(size.x, size.y);
}
if (as_normalmap) {
@@ -254,7 +259,7 @@ int NoiseTexture::get_height() const {
RID NoiseTexture::get_rid() const {
if (!texture.is_valid()) {
- texture = VS::get_singleton()->texture_2d_placeholder_create();
+ texture = RS::get_singleton()->texture_2d_placeholder_create();
}
return texture;
diff --git a/modules/opus/SCsub b/modules/opus/SCsub
index fec2911d6d..e51590d808 100644
--- a/modules/opus/SCsub
+++ b/modules/opus/SCsub
@@ -1,7 +1,7 @@
#!/usr/bin/env python
-Import('env')
-Import('env_modules')
+Import("env")
+Import("env_modules")
# Only kept to build the thirdparty library used by the webm module.
# AudioStreamOpus was dropped in 3.0 due to incompatibility with the new audio
@@ -10,11 +10,10 @@ Import('env_modules')
env_opus = env_modules.Clone()
# Thirdparty source files
-if env['builtin_opus']:
+if env["builtin_opus"]:
thirdparty_dir = "#thirdparty/opus/"
thirdparty_sources = [
-
# Sync with opus_sources.mk
"opus.c",
"opus_decoder.c",
@@ -23,17 +22,14 @@ if env['builtin_opus']:
"opus_multistream_encoder.c",
"opus_multistream_decoder.c",
"repacketizer.c",
-
"analysis.c",
"mlp.c",
"mlp_data.c",
-
# Sync with libopusfile Makefile.am
"info.c",
"internal.c",
"opusfile.c",
"stream.c",
-
# Sync with celt_sources.mk
"celt/bands.c",
"celt/celt.c",
@@ -53,12 +49,11 @@ if env['builtin_opus']:
"celt/quant_bands.c",
"celt/rate.c",
"celt/vq.c",
- #"celt/arm/arm_celt_map.c",
- #"celt/arm/armcpu.c",
- #"celt/arm/celt_ne10_fft.c",
- #"celt/arm/celt_ne10_mdct.c",
- #"celt/arm/celt_neon_intr.c",
-
+ # "celt/arm/arm_celt_map.c",
+ # "celt/arm/armcpu.c",
+ # "celt/arm/celt_ne10_fft.c",
+ # "celt/arm/celt_ne10_mdct.c",
+ # "celt/arm/celt_neon_intr.c",
# Sync with silk_sources.mk
"silk/CNG.c",
"silk/code_signs.c",
@@ -207,7 +202,7 @@ if env['builtin_opus']:
thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources + opus_sources_silk]
# also requires libogg
- if env['builtin_libogg']:
+ if env["builtin_libogg"]:
env_opus.Prepend(CPPPATH=["#thirdparty/libogg"])
env_opus.Append(CPPDEFINES=["HAVE_CONFIG_H"])
@@ -223,14 +218,14 @@ if env['builtin_opus']:
env_opus.Prepend(CPPPATH=[thirdparty_dir + "/" + dir for dir in thirdparty_include_paths])
if env["platform"] == "android":
- if ("android_arch" in env and env["android_arch"] == "armv7"):
+ if "android_arch" in env and env["android_arch"] == "armv7":
env_opus.Append(CPPDEFINES=["OPUS_ARM_OPT"])
- elif ("android_arch" in env and env["android_arch"] == "arm64v8"):
+ elif "android_arch" in env and env["android_arch"] == "arm64v8":
env_opus.Append(CPPDEFINES=["OPUS_ARM64_OPT"])
elif env["platform"] == "iphone":
- if ("arch" in env and env["arch"] == "arm"):
+ if "arch" in env and env["arch"] == "arm":
env_opus.Append(CPPDEFINES=["OPUS_ARM_OPT"])
- elif ("arch" in env and env["arch"] == "arm64"):
+ elif "arch" in env and env["arch"] == "arm64":
env_opus.Append(CPPDEFINES=["OPUS_ARM64_OPT"])
env_thirdparty = env_opus.Clone()
diff --git a/modules/opus/config.py b/modules/opus/config.py
index 1c8cd12a2d..d22f9454ed 100644
--- a/modules/opus/config.py
+++ b/modules/opus/config.py
@@ -1,5 +1,6 @@
def can_build(env, platform):
return True
+
def configure(env):
pass
diff --git a/modules/pvr/SCsub b/modules/pvr/SCsub
index 18da38fbbd..e0baf851f1 100644
--- a/modules/pvr/SCsub
+++ b/modules/pvr/SCsub
@@ -1,7 +1,7 @@
#!/usr/bin/env python
-Import('env')
-Import('env_modules')
+Import("env")
+Import("env_modules")
env_pvr = env_modules.Clone()
diff --git a/modules/pvr/config.py b/modules/pvr/config.py
index 1c8cd12a2d..d22f9454ed 100644
--- a/modules/pvr/config.py
+++ b/modules/pvr/config.py
@@ -1,5 +1,6 @@
def can_build(env, platform):
return True
+
def configure(env):
pass
diff --git a/modules/pvr/texture_loader_pvr.cpp b/modules/pvr/texture_loader_pvr.cpp
index 179c6f692b..a8e8a9a2f1 100644
--- a/modules/pvr/texture_loader_pvr.cpp
+++ b/modules/pvr/texture_loader_pvr.cpp
@@ -51,7 +51,7 @@ enum PVRFLags {
};
-RES ResourceFormatPVR::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress) {
+RES ResourceFormatPVR::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, bool p_no_cache) {
if (r_error)
*r_error = ERR_CANT_OPEN;
@@ -534,7 +534,7 @@ static void decompress_pvrtc(PVRTCBlock *p_comp_img, const int p_2bit, const int
// local neighbourhood of blocks
PVRTCBlock *p_blocks[2][2];
- PVRTCBlock *prev[2][2] = { { NULL, NULL }, { NULL, NULL } };
+ PVRTCBlock *prev[2][2] = { { nullptr, nullptr }, { nullptr, nullptr } };
struct
{
diff --git a/modules/pvr/texture_loader_pvr.h b/modules/pvr/texture_loader_pvr.h
index c990c3612b..07ef129689 100644
--- a/modules/pvr/texture_loader_pvr.h
+++ b/modules/pvr/texture_loader_pvr.h
@@ -36,7 +36,7 @@
class ResourceFormatPVR : public ResourceFormatLoader {
public:
- virtual RES load(const String &p_path, const String &p_original_path, Error *r_error = NULL, bool p_use_sub_threads = false, float *r_progress = nullptr);
+ virtual RES load(const String &p_path, const String &p_original_path, Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr, bool p_no_cache = false);
virtual void get_recognized_extensions(List<String> *p_extensions) const;
virtual bool handles_type(const String &p_type) const;
virtual String get_resource_type(const String &p_path) const;
diff --git a/modules/regex/SCsub b/modules/regex/SCsub
index 6238cd3d9f..753650adcb 100644
--- a/modules/regex/SCsub
+++ b/modules/regex/SCsub
@@ -1,16 +1,16 @@
#!/usr/bin/env python
-Import('env')
-Import('env_modules')
+Import("env")
+Import("env_modules")
env_regex = env_modules.Clone()
-if env['builtin_pcre2']:
- thirdparty_dir = '#thirdparty/pcre2/src/'
- thirdparty_flags = ['PCRE2_STATIC', 'HAVE_CONFIG_H']
+if env["builtin_pcre2"]:
+ thirdparty_dir = "#thirdparty/pcre2/src/"
+ thirdparty_flags = ["PCRE2_STATIC", "HAVE_CONFIG_H"]
- if env['builtin_pcre2_with_jit']:
- thirdparty_flags.append('SUPPORT_JIT')
+ if env["builtin_pcre2_with_jit"]:
+ thirdparty_flags.append("SUPPORT_JIT")
thirdparty_sources = [
"pcre2_auto_possess.c",
@@ -24,7 +24,7 @@ if env['builtin_pcre2']:
"pcre2_extuni.c",
"pcre2_find_bracket.c",
"pcre2_jit_compile.c",
- #"pcre2_jit_match.c", "pcre2_jit_misc.c", # these files are included in pcre2_jit_compile.c.
+ # "pcre2_jit_match.c", "pcre2_jit_misc.c", # these files are included in pcre2_jit_compile.c.
"pcre2_maketables.c",
"pcre2_match.c",
"pcre2_match_data.c",
diff --git a/modules/regex/config.py b/modules/regex/config.py
index 42cfe3b43c..df9f44cb95 100644
--- a/modules/regex/config.py
+++ b/modules/regex/config.py
@@ -1,14 +1,17 @@
def can_build(env, platform):
return True
+
def configure(env):
pass
+
def get_doc_classes():
return [
"RegEx",
"RegExMatch",
]
+
def get_doc_path():
return "doc_classes"
diff --git a/modules/regex/regex.cpp b/modules/regex/regex.cpp
index 53d1a1dd65..25cc580591 100644
--- a/modules/regex/regex.cpp
+++ b/modules/regex/regex.cpp
@@ -80,7 +80,7 @@ Dictionary RegExMatch::get_names() const {
Dictionary result;
- for (const Map<String, int>::Element *i = names.front(); i != NULL; i = i->next()) {
+ for (const Map<String, int>::Element *i = names.front(); i != nullptr; i = i->next()) {
result[i->key()] = i->value();
}
@@ -180,14 +180,14 @@ void RegEx::clear() {
if (code) {
pcre2_code_free_16((pcre2_code_16 *)code);
- code = NULL;
+ code = nullptr;
}
} else {
if (code) {
pcre2_code_free_32((pcre2_code_32 *)code);
- code = NULL;
+ code = nullptr;
}
}
}
@@ -242,7 +242,7 @@ Error RegEx::compile(const String &p_pattern) {
Ref<RegExMatch> RegEx::search(const String &p_subject, int p_offset, int p_end) const {
- ERR_FAIL_COND_V(!is_valid(), NULL);
+ ERR_FAIL_COND_V(!is_valid(), nullptr);
Ref<RegExMatch> result = memnew(RegExMatch);
@@ -263,7 +263,7 @@ Ref<RegExMatch> RegEx::search(const String &p_subject, int p_offset, int p_end)
if (res < 0) {
pcre2_match_data_free_16(match);
- return NULL;
+ return nullptr;
}
uint32_t size = pcre2_get_ovector_count_16(match);
@@ -295,7 +295,7 @@ Ref<RegExMatch> RegEx::search(const String &p_subject, int p_offset, int p_end)
pcre2_match_data_free_32(match);
pcre2_match_context_free_32(mctx);
- return NULL;
+ return nullptr;
}
uint32_t size = pcre2_get_ovector_count_32(match);
@@ -431,7 +431,7 @@ String RegEx::sub(const String &p_subject, const String &p_replacement, bool p_a
bool RegEx::is_valid() const {
- return (code != NULL);
+ return (code != nullptr);
}
String RegEx::get_pattern() const {
@@ -479,26 +479,26 @@ RegEx::RegEx() {
if (sizeof(CharType) == 2) {
- general_ctx = pcre2_general_context_create_16(&_regex_malloc, &_regex_free, NULL);
+ general_ctx = pcre2_general_context_create_16(&_regex_malloc, &_regex_free, nullptr);
} else {
- general_ctx = pcre2_general_context_create_32(&_regex_malloc, &_regex_free, NULL);
+ general_ctx = pcre2_general_context_create_32(&_regex_malloc, &_regex_free, nullptr);
}
- code = NULL;
+ code = nullptr;
}
RegEx::RegEx(const String &p_pattern) {
if (sizeof(CharType) == 2) {
- general_ctx = pcre2_general_context_create_16(&_regex_malloc, &_regex_free, NULL);
+ general_ctx = pcre2_general_context_create_16(&_regex_malloc, &_regex_free, nullptr);
} else {
- general_ctx = pcre2_general_context_create_32(&_regex_malloc, &_regex_free, NULL);
+ general_ctx = pcre2_general_context_create_32(&_regex_malloc, &_regex_free, nullptr);
}
- code = NULL;
+ code = nullptr;
compile(p_pattern);
}
diff --git a/modules/squish/SCsub b/modules/squish/SCsub
index 15320bcd0c..b31032403f 100644
--- a/modules/squish/SCsub
+++ b/modules/squish/SCsub
@@ -1,12 +1,12 @@
#!/usr/bin/env python
-Import('env')
-Import('env_modules')
+Import("env")
+Import("env_modules")
env_squish = env_modules.Clone()
# Thirdparty source files
-if env['builtin_squish']:
+if env["builtin_squish"]:
thirdparty_dir = "#thirdparty/squish/"
thirdparty_sources = [
"alpha.cpp",
diff --git a/modules/squish/config.py b/modules/squish/config.py
index 1c8cd12a2d..d22f9454ed 100644
--- a/modules/squish/config.py
+++ b/modules/squish/config.py
@@ -1,5 +1,6 @@
def can_build(env, platform):
return True
+
def configure(env):
pass
diff --git a/modules/stb_vorbis/SCsub b/modules/stb_vorbis/SCsub
index d14939a3b1..266c87c802 100644
--- a/modules/stb_vorbis/SCsub
+++ b/modules/stb_vorbis/SCsub
@@ -1,7 +1,7 @@
#!/usr/bin/env python
-Import('env')
-Import('env_modules')
+Import("env")
+Import("env_modules")
env_stb_vorbis = env_modules.Clone()
diff --git a/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp b/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp
index 42f341cef7..9609c234ec 100644
--- a/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp
+++ b/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp
@@ -122,7 +122,7 @@ void AudioStreamPlaybackOGGVorbis::seek(float p_time) {
AudioStreamPlaybackOGGVorbis::~AudioStreamPlaybackOGGVorbis() {
if (ogg_alloc.alloc_buffer) {
stb_vorbis_close(ogg_stream);
- AudioServer::get_singleton()->audio_data_free(ogg_alloc.alloc_buffer);
+ memfree(ogg_alloc.alloc_buffer);
}
}
@@ -130,11 +130,11 @@ Ref<AudioStreamPlayback> AudioStreamOGGVorbis::instance_playback() {
Ref<AudioStreamPlaybackOGGVorbis> ovs;
- ERR_FAIL_COND_V(data == NULL, ovs);
+ ERR_FAIL_COND_V(data == nullptr, ovs);
ovs.instance();
ovs->vorbis_stream = Ref<AudioStreamOGGVorbis>(this);
- ovs->ogg_alloc.alloc_buffer = (char *)AudioServer::get_singleton()->audio_data_alloc(decode_mem_size);
+ ovs->ogg_alloc.alloc_buffer = (char *)memalloc(decode_mem_size);
ovs->ogg_alloc.alloc_buffer_length_in_bytes = decode_mem_size;
ovs->frames_mixed = 0;
ovs->active = false;
@@ -143,8 +143,8 @@ Ref<AudioStreamPlayback> AudioStreamOGGVorbis::instance_playback() {
ovs->ogg_stream = stb_vorbis_open_memory((const unsigned char *)data, data_len, &error, &ovs->ogg_alloc);
if (!ovs->ogg_stream) {
- AudioServer::get_singleton()->audio_data_free(ovs->ogg_alloc.alloc_buffer);
- ovs->ogg_alloc.alloc_buffer = NULL;
+ memfree(ovs->ogg_alloc.alloc_buffer);
+ ovs->ogg_alloc.alloc_buffer = nullptr;
ERR_FAIL_COND_V(!ovs->ogg_stream, Ref<AudioStreamPlaybackOGGVorbis>());
}
@@ -158,8 +158,8 @@ String AudioStreamOGGVorbis::get_stream_name() const {
void AudioStreamOGGVorbis::clear_data() {
if (data) {
- AudioServer::get_singleton()->audio_data_free(data);
- data = NULL;
+ memfree(data);
+ data = nullptr;
data_len = 0;
}
}
@@ -172,7 +172,7 @@ void AudioStreamOGGVorbis::set_data(const Vector<uint8_t> &p_data) {
uint32_t alloc_try = 1024;
Vector<char> alloc_mem;
char *w;
- stb_vorbis *ogg_stream = NULL;
+ stb_vorbis *ogg_stream = nullptr;
stb_vorbis_alloc ogg_alloc;
while (alloc_try < MAX_TEST_MEM) {
@@ -194,7 +194,7 @@ void AudioStreamOGGVorbis::set_data(const Vector<uint8_t> &p_data) {
} else {
ERR_FAIL_COND(alloc_try == MAX_TEST_MEM);
- ERR_FAIL_COND(ogg_stream == NULL);
+ ERR_FAIL_COND(ogg_stream == nullptr);
stb_vorbis_info info = stb_vorbis_get_info(ogg_stream);
@@ -210,7 +210,8 @@ void AudioStreamOGGVorbis::set_data(const Vector<uint8_t> &p_data) {
// free any existing data
clear_data();
- data = AudioServer::get_singleton()->audio_data_alloc(src_data_len, src_datar);
+ data = memalloc(src_data_len);
+ copymem(data, src_datar, src_data_len);
data_len = src_data_len;
break;
@@ -273,7 +274,7 @@ void AudioStreamOGGVorbis::_bind_methods() {
AudioStreamOGGVorbis::AudioStreamOGGVorbis() {
- data = NULL;
+ data = nullptr;
data_len = 0;
length = 0;
sample_rate = 1;
diff --git a/modules/stb_vorbis/config.py b/modules/stb_vorbis/config.py
index 200b8dfd50..1eb0a8cf33 100644
--- a/modules/stb_vorbis/config.py
+++ b/modules/stb_vorbis/config.py
@@ -1,13 +1,16 @@
def can_build(env, platform):
return True
+
def configure(env):
pass
+
def get_doc_classes():
return [
"AudioStreamOGGVorbis",
]
+
def get_doc_path():
return "doc_classes"
diff --git a/modules/stb_vorbis/resource_importer_ogg_vorbis.h b/modules/stb_vorbis/resource_importer_ogg_vorbis.h
index 43541bcf3c..8d6f71a456 100644
--- a/modules/stb_vorbis/resource_importer_ogg_vorbis.h
+++ b/modules/stb_vorbis/resource_importer_ogg_vorbis.h
@@ -50,7 +50,7 @@ public:
virtual void get_import_options(List<ImportOption> *r_options, int p_preset = 0) const;
virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const;
- virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = NULL, Variant *r_metadata = NULL);
+ virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr);
ResourceImporterOGGVorbis();
};
diff --git a/modules/svg/SCsub b/modules/svg/SCsub
index 7961d1f33e..0bfba34fe5 100644
--- a/modules/svg/SCsub
+++ b/modules/svg/SCsub
@@ -1,14 +1,14 @@
#!/usr/bin/env python
-Import('env')
-Import('env_modules')
+Import("env")
+Import("env_modules")
env_svg = env_modules.Clone()
# Thirdparty source files
thirdparty_dir = "#thirdparty/nanosvg/"
thirdparty_sources = [
- "nanosvg.cc"
+ "nanosvg.cc",
]
thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
diff --git a/modules/svg/config.py b/modules/svg/config.py
index 1c8cd12a2d..d22f9454ed 100644
--- a/modules/svg/config.py
+++ b/modules/svg/config.py
@@ -1,5 +1,6 @@
def can_build(env, platform):
return True
+
def configure(env):
pass
diff --git a/modules/svg/image_loader_svg.cpp b/modules/svg/image_loader_svg.cpp
index e9d30d015a..3c2784f8de 100644
--- a/modules/svg/image_loader_svg.cpp
+++ b/modules/svg/image_loader_svg.cpp
@@ -65,7 +65,7 @@ inline void change_nsvg_paint_color(NSVGpaint *p_paint, const uint32_t p_old, co
void ImageLoaderSVG::_convert_colors(NSVGimage *p_svg_image) {
- for (NSVGshape *shape = p_svg_image->shapes; shape != NULL; shape = shape->next) {
+ for (NSVGshape *shape = p_svg_image->shapes; shape != nullptr; shape = shape->next) {
for (int i = 0; i < replace_colors.old_colors.size(); i++) {
change_nsvg_paint_color(&(shape->stroke), replace_colors.old_colors[i], replace_colors.new_colors[i]);
@@ -98,7 +98,7 @@ Error ImageLoaderSVG::_create_image(Ref<Image> p_image, const Vector<uint8_t> *p
NSVGimage *svg_image;
const uint8_t *src_r = p_data->ptr();
svg_image = nsvgParse((char *)src_r, "px", 96);
- if (svg_image == NULL) {
+ if (svg_image == nullptr) {
ERR_PRINT("SVG Corrupted");
return ERR_FILE_CORRUPT;
}
diff --git a/modules/svg/image_loader_svg.h b/modules/svg/image_loader_svg.h
index def2885199..0fa4a0fdf4 100644
--- a/modules/svg/image_loader_svg.h
+++ b/modules/svg/image_loader_svg.h
@@ -63,7 +63,7 @@ class ImageLoaderSVG : public ImageFormatLoader {
static Error _create_image(Ref<Image> p_image, const Vector<uint8_t> *p_data, float p_scale, bool upsample, bool convert_colors = false);
public:
- static void set_convert_colors(Dictionary *p_replace_color = NULL);
+ static void set_convert_colors(Dictionary *p_replace_color = nullptr);
static Error create_image_from_string(Ref<Image> p_image, const char *p_svg_str, float p_scale, bool upsample, bool convert_colors = false);
virtual Error load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear, float p_scale);
diff --git a/modules/svg/register_types.cpp b/modules/svg/register_types.cpp
index b0782dae88..37875313aa 100644
--- a/modules/svg/register_types.cpp
+++ b/modules/svg/register_types.cpp
@@ -32,7 +32,7 @@
#include "image_loader_svg.h"
-static ImageLoaderSVG *image_loader_svg = NULL;
+static ImageLoaderSVG *image_loader_svg = nullptr;
void register_svg_types() {
diff --git a/modules/tga/SCsub b/modules/tga/SCsub
index 7e405f405c..067caa6ea0 100644
--- a/modules/tga/SCsub
+++ b/modules/tga/SCsub
@@ -1,7 +1,7 @@
#!/usr/bin/env python
-Import('env')
-Import('env_modules')
+Import("env")
+Import("env_modules")
env_tga = env_modules.Clone()
diff --git a/modules/tga/config.py b/modules/tga/config.py
index 1c8cd12a2d..d22f9454ed 100644
--- a/modules/tga/config.py
+++ b/modules/tga/config.py
@@ -1,5 +1,6 @@
def can_build(env, platform):
return True
+
def configure(env):
pass
diff --git a/modules/tga/image_loader_tga.cpp b/modules/tga/image_loader_tga.cpp
index 0e904fdd76..fc9d727bb0 100644
--- a/modules/tga/image_loader_tga.cpp
+++ b/modules/tga/image_loader_tga.cpp
@@ -283,7 +283,7 @@ Error ImageLoaderTGA::load_image(Ref<Image> p_image, FileAccess *f, bool p_force
uint8_t *uncompressed_buffer_w = uncompressed_buffer.ptrw();
const uint8_t *uncompressed_buffer_r;
- const uint8_t *buffer = NULL;
+ const uint8_t *buffer = nullptr;
if (is_encoded) {
diff --git a/modules/tga/register_types.cpp b/modules/tga/register_types.cpp
index 359f4d785e..0d9268ebbf 100644
--- a/modules/tga/register_types.cpp
+++ b/modules/tga/register_types.cpp
@@ -32,7 +32,7 @@
#include "image_loader_tga.h"
-static ImageLoaderTGA *image_loader_tga = NULL;
+static ImageLoaderTGA *image_loader_tga = nullptr;
void register_tga_types() {
diff --git a/modules/theora/SCsub b/modules/theora/SCsub
index ff65d2f8ec..a01e65b4b0 100644
--- a/modules/theora/SCsub
+++ b/modules/theora/SCsub
@@ -1,71 +1,71 @@
#!/usr/bin/env python
-Import('env')
-Import('env_modules')
+Import("env")
+Import("env_modules")
env_theora = env_modules.Clone()
# Thirdparty source files
-if env['builtin_libtheora']:
+if env["builtin_libtheora"]:
thirdparty_dir = "#thirdparty/libtheora/"
thirdparty_sources = [
- #"analyze.c",
- #"apiwrapper.c",
+ # "analyze.c",
+ # "apiwrapper.c",
"bitpack.c",
"cpu.c",
- #"decapiwrapper.c",
+ # "decapiwrapper.c",
"decinfo.c",
"decode.c",
"dequant.c",
- #"encapiwrapper.c",
- #"encfrag.c",
- #"encinfo.c",
- #"encode.c",
- #"encoder_disabled.c",
- #"enquant.c",
- #"fdct.c",
+ # "encapiwrapper.c",
+ # "encfrag.c",
+ # "encinfo.c",
+ # "encode.c",
+ # "encoder_disabled.c",
+ # "enquant.c",
+ # "fdct.c",
"fragment.c",
"huffdec.c",
- #"huffenc.c",
+ # "huffenc.c",
"idct.c",
"info.c",
"internal.c",
- #"mathops.c",
- #"mcenc.c",
+ # "mathops.c",
+ # "mcenc.c",
"quant.c",
- #"rate.c",
+ # "rate.c",
"state.c",
- #"tokenize.c",
+ # "tokenize.c",
]
thirdparty_sources_x86 = [
- #"x86/mmxencfrag.c",
- #"x86/mmxfdct.c",
+ # "x86/mmxencfrag.c",
+ # "x86/mmxfdct.c",
"x86/mmxfrag.c",
"x86/mmxidct.c",
"x86/mmxstate.c",
- #"x86/sse2fdct.c",
- #"x86/x86enc.c",
+ # "x86/sse2fdct.c",
+ # "x86/x86enc.c",
"x86/x86state.c",
]
thirdparty_sources_x86_vc = [
- #"x86_vc/mmxencfrag.c",
- #"x86_vc/mmxfdct.c",
+ # "x86_vc/mmxencfrag.c",
+ # "x86_vc/mmxfdct.c",
"x86_vc/mmxfrag.c",
"x86_vc/mmxidct.c",
"x86_vc/mmxstate.c",
- #"x86_vc/x86enc.c",
+ # "x86_vc/x86enc.c",
"x86_vc/x86state.c",
]
- if (env["x86_libtheora_opt_gcc"]):
+ if env["x86_libtheora_opt_gcc"]:
thirdparty_sources += thirdparty_sources_x86
- if (env["x86_libtheora_opt_vc"]):
+ if env["x86_libtheora_opt_vc"]:
thirdparty_sources += thirdparty_sources_x86_vc
- if (env["x86_libtheora_opt_gcc"] or env["x86_libtheora_opt_vc"]):
+ if env["x86_libtheora_opt_gcc"] or env["x86_libtheora_opt_vc"]:
env_theora.Append(CPPDEFINES=["OC_X86_ASM"])
thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
@@ -73,9 +73,9 @@ if env['builtin_libtheora']:
env_theora.Prepend(CPPPATH=[thirdparty_dir])
# also requires libogg and libvorbis
- if env['builtin_libogg']:
+ if env["builtin_libogg"]:
env_theora.Prepend(CPPPATH=["#thirdparty/libogg"])
- if env['builtin_libvorbis']:
+ if env["builtin_libvorbis"]:
env_theora.Prepend(CPPPATH=["#thirdparty/libvorbis"])
env_thirdparty = env_theora.Clone()
diff --git a/modules/theora/config.py b/modules/theora/config.py
index c7713d7607..413acce2df 100644
--- a/modules/theora/config.py
+++ b/modules/theora/config.py
@@ -1,13 +1,16 @@
def can_build(env, platform):
return True
+
def configure(env):
pass
+
def get_doc_classes():
return [
"VideoStreamTheora",
]
+
def get_doc_path():
return "doc_classes"
diff --git a/modules/theora/video_stream_theora.cpp b/modules/theora/video_stream_theora.cpp
index ee44c6bf05..b9f276fb12 100644
--- a/modules/theora/video_stream_theora.cpp
+++ b/modules/theora/video_stream_theora.cpp
@@ -144,7 +144,7 @@ void VideoStreamPlaybackTheora::clear() {
thread_sem->post(); //just in case
Thread::wait_to_finish(thread);
memdelete(thread);
- thread = NULL;
+ thread = nullptr;
ring_buffer.clear();
#endif
@@ -159,7 +159,7 @@ void VideoStreamPlaybackTheora::clear() {
if (file) {
memdelete(file);
}
- file = NULL;
+ file = nullptr;
playing = false;
};
@@ -167,7 +167,7 @@ void VideoStreamPlaybackTheora::set_file(const String &p_file) {
ERR_FAIL_COND(playing);
ogg_packet op;
- th_setup_info *ts = NULL;
+ th_setup_info *ts = nullptr;
file_name = p_file;
if (file) {
@@ -674,7 +674,7 @@ void VideoStreamPlaybackTheora::_streaming_thread(void *ud) {
VideoStreamPlaybackTheora::VideoStreamPlaybackTheora() {
- file = NULL;
+ file = nullptr;
theora_p = 0;
vorbis_p = 0;
videobuf_ready = 0;
@@ -685,8 +685,8 @@ VideoStreamPlaybackTheora::VideoStreamPlaybackTheora() {
buffering = false;
texture = Ref<ImageTexture>(memnew(ImageTexture));
- mix_callback = NULL;
- mix_udata = NULL;
+ mix_callback = nullptr;
+ mix_udata = nullptr;
audio_track = 0;
delay_compensation = 0;
audio_frames_wrote = 0;
@@ -696,7 +696,7 @@ VideoStreamPlaybackTheora::VideoStreamPlaybackTheora() {
ring_buffer.resize(rb_power);
read_buffer.resize(RB_SIZE_KB * 1024);
thread_sem = Semaphore::create();
- thread = NULL;
+ thread = nullptr;
thread_exit = false;
thread_eof = false;
@@ -725,7 +725,7 @@ void VideoStreamTheora::_bind_methods() {
////////////
-RES ResourceFormatLoaderTheora::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress) {
+RES ResourceFormatLoaderTheora::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, bool p_no_cache) {
FileAccess *f = FileAccess::open(p_path, FileAccess::READ);
if (!f) {
diff --git a/modules/theora/video_stream_theora.h b/modules/theora/video_stream_theora.h
index da3558ce34..f98368ed8b 100644
--- a/modules/theora/video_stream_theora.h
+++ b/modules/theora/video_stream_theora.h
@@ -187,7 +187,7 @@ public:
class ResourceFormatLoaderTheora : public ResourceFormatLoader {
public:
- virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL, bool p_use_sub_threads = false, float *r_progress = nullptr);
+ virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr, bool p_no_cache = false);
virtual void get_recognized_extensions(List<String> *p_extensions) const;
virtual bool handles_type(const String &p_type) const;
virtual String get_resource_type(const String &p_path) const;
diff --git a/modules/tinyexr/SCsub b/modules/tinyexr/SCsub
index 97f9797b58..e7fd44fabd 100644
--- a/modules/tinyexr/SCsub
+++ b/modules/tinyexr/SCsub
@@ -1,7 +1,7 @@
#!/usr/bin/env python
-Import('env')
-Import('env_modules')
+Import("env")
+Import("env_modules")
env_tinyexr = env_modules.Clone()
diff --git a/modules/tinyexr/config.py b/modules/tinyexr/config.py
index 098f1eafa9..53b8f2f2e3 100644
--- a/modules/tinyexr/config.py
+++ b/modules/tinyexr/config.py
@@ -1,5 +1,6 @@
def can_build(env, platform):
- return env['tools']
+ return env["tools"]
+
def configure(env):
pass
diff --git a/modules/tinyexr/image_loader_tinyexr.cpp b/modules/tinyexr/image_loader_tinyexr.cpp
index 41938f5b42..1c0f3cd03e 100644
--- a/modules/tinyexr/image_loader_tinyexr.cpp
+++ b/modules/tinyexr/image_loader_tinyexr.cpp
@@ -56,7 +56,7 @@ Error ImageLoaderTinyEXR::load_image(Ref<Image> p_image, FileAccess *f, bool p_f
EXRVersion exr_version;
EXRImage exr_image;
EXRHeader exr_header;
- const char *err = NULL;
+ const char *err = nullptr;
InitEXRHeader(&exr_header);
@@ -194,7 +194,7 @@ Error ImageLoaderTinyEXR::load_image(Ref<Image> p_image, FileAccess *f, bool p_f
const float *r_channel_start = reinterpret_cast<const float *>(tile.images[idxR]);
const float *g_channel_start = reinterpret_cast<const float *>(tile.images[idxG]);
const float *b_channel_start = reinterpret_cast<const float *>(tile.images[idxB]);
- const float *a_channel_start = NULL;
+ const float *a_channel_start = nullptr;
if (idxA != -1) {
a_channel_start = reinterpret_cast<const float *>(tile.images[idxA]);
@@ -206,7 +206,7 @@ Error ImageLoaderTinyEXR::load_image(Ref<Image> p_image, FileAccess *f, bool p_f
const float *r_channel = r_channel_start + y * tile_width;
const float *g_channel = g_channel_start + y * tile_width;
const float *b_channel = b_channel_start + y * tile_width;
- const float *a_channel = NULL;
+ const float *a_channel = nullptr;
if (a_channel_start) {
a_channel = a_channel_start + y * tile_width;
diff --git a/modules/tinyexr/register_types.cpp b/modules/tinyexr/register_types.cpp
index d8529fd893..af05a411e1 100644
--- a/modules/tinyexr/register_types.cpp
+++ b/modules/tinyexr/register_types.cpp
@@ -33,7 +33,7 @@
#include "image_loader_tinyexr.h"
#include "image_saver_tinyexr.h"
-static ImageLoaderTinyEXR *image_loader_tinyexr = NULL;
+static ImageLoaderTinyEXR *image_loader_tinyexr = nullptr;
void register_tinyexr_types() {
@@ -47,5 +47,5 @@ void unregister_tinyexr_types() {
memdelete(image_loader_tinyexr);
- Image::save_exr_func = NULL;
+ Image::save_exr_func = nullptr;
}
diff --git a/modules/upnp/SCsub b/modules/upnp/SCsub
index 3f56a69594..2e129e15ca 100644
--- a/modules/upnp/SCsub
+++ b/modules/upnp/SCsub
@@ -1,13 +1,13 @@
#!/usr/bin/env python
-Import('env')
-Import('env_modules')
+Import("env")
+Import("env_modules")
env_upnp = env_modules.Clone()
# Thirdparty source files
-if env['builtin_miniupnpc']:
+if env["builtin_miniupnpc"]:
thirdparty_dir = "#thirdparty/miniupnpc/"
thirdparty_sources = [
"miniupnpc.c",
diff --git a/modules/upnp/config.py b/modules/upnp/config.py
index 8724ff1a51..3e15b940a1 100644
--- a/modules/upnp/config.py
+++ b/modules/upnp/config.py
@@ -1,14 +1,17 @@
def can_build(env, platform):
return True
+
def configure(env):
pass
+
def get_doc_classes():
return [
"UPNP",
- "UPNPDevice"
+ "UPNPDevice",
]
+
def get_doc_path():
return "doc_classes"
diff --git a/modules/upnp/upnp.cpp b/modules/upnp/upnp.cpp
index 5ef7575b0c..988bf3017d 100644
--- a/modules/upnp/upnp.cpp
+++ b/modules/upnp/upnp.cpp
@@ -44,9 +44,8 @@ bool UPNP::is_common_device(const String &dev) const {
}
int UPNP::discover(int timeout, int ttl, const String &device_filter) {
- ERR_FAIL_COND_V(timeout < 0, UPNP_RESULT_INVALID_PARAM);
- ERR_FAIL_COND_V(ttl < 0, UPNP_RESULT_INVALID_PARAM);
- ERR_FAIL_COND_V(ttl > 255, UPNP_RESULT_INVALID_PARAM);
+ ERR_FAIL_COND_V_MSG(timeout < 0, UPNP_RESULT_INVALID_PARAM, "The response's wait time can't be negative.");
+ ERR_FAIL_COND_V_MSG(ttl < 0 || ttl > 255, UPNP_RESULT_INVALID_PARAM, "The time-to-live must be set between 0 and 255 (inclusive).");
devices.clear();
@@ -54,9 +53,9 @@ int UPNP::discover(int timeout, int ttl, const String &device_filter) {
struct UPNPDev *devlist;
if (is_common_device(device_filter)) {
- devlist = upnpDiscover(timeout, discover_multicast_if.utf8().get_data(), NULL, discover_local_port, discover_ipv6, ttl, &error);
+ devlist = upnpDiscover(timeout, discover_multicast_if.utf8().get_data(), nullptr, discover_local_port, discover_ipv6, ttl, &error);
} else {
- devlist = upnpDiscoverAll(timeout, discover_multicast_if.utf8().get_data(), NULL, discover_local_port, discover_ipv6, ttl, &error);
+ devlist = upnpDiscoverAll(timeout, discover_multicast_if.utf8().get_data(), nullptr, discover_local_port, discover_ipv6, ttl, &error);
}
if (error != UPNPDISCOVER_SUCCESS) {
@@ -133,7 +132,7 @@ void UPNP::parse_igd(Ref<UPNPDevice> dev, UPNPDev *devlist) {
parserootdesc(xml, size, &data);
free(xml);
- xml = 0;
+ xml = nullptr;
GetUPNPUrls(urls, &data, dev->get_description_url().utf8().get_data(), 0);
@@ -235,20 +234,20 @@ int UPNP::get_device_count() const {
}
Ref<UPNPDevice> UPNP::get_device(int index) const {
- ERR_FAIL_INDEX_V(index, devices.size(), NULL);
+ ERR_FAIL_INDEX_V(index, devices.size(), nullptr);
return devices.get(index);
}
void UPNP::add_device(Ref<UPNPDevice> device) {
- ERR_FAIL_COND(device == NULL);
+ ERR_FAIL_COND(device == nullptr);
devices.push_back(device);
}
void UPNP::set_device(int index, Ref<UPNPDevice> device) {
ERR_FAIL_INDEX(index, devices.size());
- ERR_FAIL_COND(device == NULL);
+ ERR_FAIL_COND(device == nullptr);
devices.set(index, device);
}
@@ -264,17 +263,17 @@ void UPNP::clear_devices() {
}
Ref<UPNPDevice> UPNP::get_gateway() const {
- ERR_FAIL_COND_V(devices.size() < 1, NULL);
+ ERR_FAIL_COND_V_MSG(devices.size() < 1, nullptr, "Couldn't find any UPNPDevices.");
for (int i = 0; i < devices.size(); i++) {
Ref<UPNPDevice> dev = get_device(i);
- if (dev != NULL && dev->is_valid_gateway()) {
+ if (dev != nullptr && dev->is_valid_gateway()) {
return dev;
}
}
- return NULL;
+ return nullptr;
}
void UPNP::set_discover_multicast_if(const String &m_if) {
@@ -304,7 +303,7 @@ bool UPNP::is_discover_ipv6() const {
String UPNP::query_external_address() const {
Ref<UPNPDevice> dev = get_gateway();
- if (dev == NULL) {
+ if (dev == nullptr) {
return "";
}
@@ -314,7 +313,7 @@ String UPNP::query_external_address() const {
int UPNP::add_port_mapping(int port, int port_internal, String desc, String proto, int duration) const {
Ref<UPNPDevice> dev = get_gateway();
- if (dev == NULL) {
+ if (dev == nullptr) {
return UPNP_RESULT_NO_GATEWAY;
}
@@ -326,7 +325,7 @@ int UPNP::add_port_mapping(int port, int port_internal, String desc, String prot
int UPNP::delete_port_mapping(int port, String proto) const {
Ref<UPNPDevice> dev = get_gateway();
- if (dev == NULL) {
+ if (dev == nullptr) {
return UPNP_RESULT_NO_GATEWAY;
}
diff --git a/modules/upnp/upnp_device.cpp b/modules/upnp/upnp_device.cpp
index 6edfbc2d7d..40eb6106a0 100644
--- a/modules/upnp/upnp_device.cpp
+++ b/modules/upnp/upnp_device.cpp
@@ -35,7 +35,7 @@
#include <miniupnpc/upnpcommands.h>
String UPNPDevice::query_external_address() const {
- ERR_FAIL_COND_V(!is_valid_gateway(), "");
+ ERR_FAIL_COND_V_MSG(!is_valid_gateway(), "", "The Internet Gateway Device must be valid.");
char addr[16];
int i = UPNP_GetExternalIPAddress(
@@ -43,17 +43,17 @@ String UPNPDevice::query_external_address() const {
igd_service_type.utf8().get_data(),
(char *)&addr);
- ERR_FAIL_COND_V(i != UPNPCOMMAND_SUCCESS, "");
+ ERR_FAIL_COND_V_MSG(i != UPNPCOMMAND_SUCCESS, "", "Couldn't get external IP address.");
return String(addr);
}
int UPNPDevice::add_port_mapping(int port, int port_internal, String desc, String proto, int duration) const {
- ERR_FAIL_COND_V(!is_valid_gateway(), UPNP::UPNP_RESULT_INVALID_GATEWAY);
- ERR_FAIL_COND_V(port < 1 || port > 65535, UPNP::UPNP_RESULT_INVALID_PORT);
- ERR_FAIL_COND_V(port_internal < 0 || port_internal > 65535, UPNP::UPNP_RESULT_INVALID_PORT); // Needs to allow 0 because 0 signifies "use external port as internal port"
- ERR_FAIL_COND_V(proto != "UDP" && proto != "TCP", UPNP::UPNP_RESULT_INVALID_PROTOCOL);
- ERR_FAIL_COND_V(duration < 0, UPNP::UPNP_RESULT_INVALID_DURATION);
+ ERR_FAIL_COND_V_MSG(!is_valid_gateway(), UPNP::UPNP_RESULT_INVALID_GATEWAY, "The Internet Gateway Device must be valid.");
+ ERR_FAIL_COND_V_MSG(port < 1 || port > 65535, UPNP::UPNP_RESULT_INVALID_PORT, "The port number must be set between 1 and 65535 (inclusive).");
+ ERR_FAIL_COND_V_MSG(port_internal < 0 || port_internal > 65535, UPNP::UPNP_RESULT_INVALID_PORT, "The port number must be set between 0 and 65535 (inclusive)."); // Needs to allow 0 because 0 signifies "use external port as internal port"
+ ERR_FAIL_COND_V_MSG(proto != "UDP" && proto != "TCP", UPNP::UPNP_RESULT_INVALID_PROTOCOL, "The protocol must be either TCP or UDP.");
+ ERR_FAIL_COND_V_MSG(duration < 0, UPNP::UPNP_RESULT_INVALID_DURATION, "The port mapping's lease duration can't be negative.");
if (port_internal < 1) {
port_internal = port;
@@ -65,29 +65,29 @@ int UPNPDevice::add_port_mapping(int port, int port_internal, String desc, Strin
itos(port).utf8().get_data(),
itos(port_internal).utf8().get_data(),
igd_our_addr.utf8().get_data(),
- desc.empty() ? 0 : desc.utf8().get_data(),
+ desc.empty() ? nullptr : desc.utf8().get_data(),
proto.utf8().get_data(),
- NULL, // Remote host, always NULL as IGDs don't support it
- duration > 0 ? itos(duration).utf8().get_data() : 0);
+ nullptr, // Remote host, always nullptr as IGDs don't support it
+ duration > 0 ? itos(duration).utf8().get_data() : nullptr);
- ERR_FAIL_COND_V(i != UPNPCOMMAND_SUCCESS, UPNP::upnp_result(i));
+ ERR_FAIL_COND_V_MSG(i != UPNPCOMMAND_SUCCESS, UPNP::upnp_result(i), "Couldn't add port mapping.");
return UPNP::UPNP_RESULT_SUCCESS;
}
int UPNPDevice::delete_port_mapping(int port, String proto) const {
- ERR_FAIL_COND_V(port < 1 || port > 65535, UPNP::UPNP_RESULT_INVALID_PORT);
- ERR_FAIL_COND_V(proto != "UDP" && proto != "TCP", UPNP::UPNP_RESULT_INVALID_PROTOCOL);
+ ERR_FAIL_COND_V_MSG(port < 1 || port > 65535, UPNP::UPNP_RESULT_INVALID_PORT, "The port number must be set between 1 and 65535 (inclusive).");
+ ERR_FAIL_COND_V_MSG(proto != "UDP" && proto != "TCP", UPNP::UPNP_RESULT_INVALID_PROTOCOL, "The protocol must be either TCP or UDP.");
int i = UPNP_DeletePortMapping(
igd_control_url.utf8().get_data(),
igd_service_type.utf8().get_data(),
itos(port).utf8().get_data(),
proto.utf8().get_data(),
- NULL // Remote host, always NULL as IGDs don't support it
+ nullptr // Remote host, always nullptr as IGDs don't support it
);
- ERR_FAIL_COND_V(i != UPNPCOMMAND_SUCCESS, UPNP::upnp_result(i));
+ ERR_FAIL_COND_V_MSG(i != UPNPCOMMAND_SUCCESS, UPNP::upnp_result(i), "Couldn't delete port mapping.");
return UPNP::UPNP_RESULT_SUCCESS;
}
diff --git a/modules/vhacd/SCsub b/modules/vhacd/SCsub
index 685976dc33..ecd432b275 100644
--- a/modules/vhacd/SCsub
+++ b/modules/vhacd/SCsub
@@ -1,7 +1,7 @@
#!/usr/bin/env python
-Import('env')
-Import('env_modules')
+Import("env")
+Import("env_modules")
env_vhacd = env_modules.Clone()
@@ -19,7 +19,7 @@ thirdparty_sources = [
"src/btAlignedAllocator.cpp",
"src/vhacdRaycastMesh.cpp",
"src/VHACD.cpp",
- "src/btConvexHullComputer.cpp"
+ "src/btConvexHullComputer.cpp",
]
thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
diff --git a/modules/vhacd/config.py b/modules/vhacd/config.py
index 9ced70d2fb..d22f9454ed 100644
--- a/modules/vhacd/config.py
+++ b/modules/vhacd/config.py
@@ -1,6 +1,6 @@
def can_build(env, platform):
return True
+
def configure(env):
pass
-
diff --git a/modules/vhacd/register_types.cpp b/modules/vhacd/register_types.cpp
index 7deb20f6e7..c006a9deec 100644
--- a/modules/vhacd/register_types.cpp
+++ b/modules/vhacd/register_types.cpp
@@ -84,5 +84,5 @@ void register_vhacd_types() {
}
void unregister_vhacd_types() {
- Mesh::convex_composition_function = NULL;
+ Mesh::convex_composition_function = nullptr;
}
diff --git a/modules/visual_script/SCsub b/modules/visual_script/SCsub
index 3c3d2caa57..16faea08d7 100644
--- a/modules/visual_script/SCsub
+++ b/modules/visual_script/SCsub
@@ -1,7 +1,7 @@
#!/usr/bin/env python
-Import('env')
-Import('env_modules')
+Import("env")
+Import("env_modules")
env_vs = env_modules.Clone()
diff --git a/modules/visual_script/config.py b/modules/visual_script/config.py
index 087a13a200..bd459ca344 100644
--- a/modules/visual_script/config.py
+++ b/modules/visual_script/config.py
@@ -1,9 +1,11 @@
def can_build(env, platform):
return True
+
def configure(env):
pass
+
def get_doc_classes():
return [
"@VisualScript",
@@ -56,5 +58,6 @@ def get_doc_classes():
"VisualScriptYield",
]
+
def get_doc_path():
return "doc_classes"
diff --git a/modules/visual_script/register_types.cpp b/modules/visual_script/register_types.cpp
index 63bd88ad81..5ea84a32c4 100644
--- a/modules/visual_script/register_types.cpp
+++ b/modules/visual_script/register_types.cpp
@@ -41,9 +41,9 @@
#include "visual_script_nodes.h"
#include "visual_script_yield_nodes.h"
-VisualScriptLanguage *visual_script_language = NULL;
+VisualScriptLanguage *visual_script_language = nullptr;
#ifdef TOOLS_ENABLED
-static _VisualScriptEditor *vs_editor_singleton = NULL;
+static _VisualScriptEditor *vs_editor_singleton = nullptr;
#endif
void register_visual_script_types() {
diff --git a/modules/visual_script/visual_script.cpp b/modules/visual_script/visual_script.cpp
index d00cc6986f..fe1d82f977 100644
--- a/modules/visual_script/visual_script.cpp
+++ b/modules/visual_script/visual_script.cpp
@@ -94,7 +94,7 @@ void VisualScriptNode::validate_input_default_values() {
default_input_values[i] = Variant::construct(expected, &existingp, 1, ce, false);
if (ce.error != Callable::CallError::CALL_OK) {
//could not convert? force..
- default_input_values[i] = Variant::construct(expected, NULL, 0, ce, false);
+ default_input_values[i] = Variant::construct(expected, nullptr, 0, ce, false);
}
}
}
@@ -158,8 +158,8 @@ VisualScriptNode::VisualScriptNode() {
VisualScriptNodeInstance::VisualScriptNodeInstance() {
- sequence_outputs = NULL;
- input_ports = NULL;
+ sequence_outputs = nullptr;
+ input_ports = nullptr;
}
VisualScriptNodeInstance::~VisualScriptNodeInstance() {
@@ -727,6 +727,26 @@ void VisualScript::rename_variable(const StringName &p_name, const StringName &p
variables[p_new_name] = variables[p_name];
variables.erase(p_name);
+
+ List<StringName> funcs;
+ get_function_list(&funcs);
+ for (List<StringName>::Element *F = funcs.front(); F; F = F->next()) { // loop through all the functions
+ List<int> ids;
+ get_node_list(F->get(), &ids);
+ for (List<int>::Element *E = ids.front(); E; E = E->next()) {
+ Ref<VisualScriptVariableGet> nodeget = get_node(F->get(), E->get());
+ if (nodeget.is_valid()) {
+ if (nodeget->get_variable() == p_name)
+ nodeget->set_variable(p_new_name);
+ } else {
+ Ref<VisualScriptVariableSet> nodeset = get_node(F->get(), E->get());
+ if (nodeset.is_valid()) {
+ if (nodeset->get_variable() == p_name)
+ nodeset->set_variable(p_new_name);
+ }
+ }
+ }
+ }
}
void VisualScript::add_custom_signal(const StringName &p_name) {
@@ -1440,6 +1460,10 @@ VisualScript::VisualScript() {
is_tool_script = false;
}
+bool VisualScript::inherits_script(const Ref<Script> &p_script) const {
+ return this == p_script.ptr(); //there is no inheritance in visual scripts, so this is enough
+}
+
StringName VisualScript::get_default_func() const {
return StringName("f_312843592");
}
@@ -1594,7 +1618,7 @@ void VisualScriptInstance::_dependency_step(VisualScriptNodeInstance *node, int
output_args[i] = &variant_stack[node->output_ports[i]];
}
- Variant *working_mem = node->working_mem_idx >= 0 ? &variant_stack[node->working_mem_idx] : (Variant *)NULL;
+ Variant *working_mem = node->working_mem_idx >= 0 ? &variant_stack[node->working_mem_idx] : (Variant *)nullptr;
node->step(input_args, output_args, VisualScriptNodeInstance::START_MODE_BEGIN_SEQUENCE, working_mem, r_error, error_str);
//ignore return
@@ -1615,8 +1639,8 @@ Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p
const Variant **input_args = (const Variant **)(sequence_bits + f->node_count);
Variant **output_args = (Variant **)(input_args + max_input_args);
int flow_max = f->flow_stack_size;
- int *flow_stack = flow_max ? (int *)(output_args + max_output_args) : (int *)NULL;
- int *pass_stack = flow_stack ? (int *)(flow_stack + flow_max) : (int *)NULL;
+ int *flow_stack = flow_max ? (int *)(output_args + max_output_args) : (int *)nullptr;
+ int *pass_stack = flow_stack ? (int *)(flow_stack + flow_max) : (int *)nullptr;
String error_str;
@@ -1624,7 +1648,7 @@ Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p
bool error = false;
int current_node_id = f->node;
Variant return_value;
- Variant *working_mem = NULL;
+ Variant *working_mem = nullptr;
int flow_stack_pos = p_flow_stack_pos;
@@ -1643,7 +1667,7 @@ Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p
VSDEBUG("AT STACK POS: " + itos(flow_stack_pos));
//setup working mem
- working_mem = node->working_mem_idx >= 0 ? &variant_stack[node->working_mem_idx] : (Variant *)NULL;
+ working_mem = node->working_mem_idx >= 0 ? &variant_stack[node->working_mem_idx] : (Variant *)nullptr;
VSDEBUG("WORKING MEM: " + itos(node->working_mem_idx));
@@ -1817,7 +1841,7 @@ Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p
break; //exit function requested, bye
}
- VisualScriptNodeInstance *next = NULL; //next node
+ VisualScriptNodeInstance *next = nullptr; //next node
if ((ret == output || ret & VisualScriptNodeInstance::STEP_FLAG_PUSH_STACK_BIT) && node->sequence_output_count) {
//if no exit bit was set, and has sequence outputs, guess next node
@@ -2033,8 +2057,8 @@ Variant VisualScriptInstance::call(const StringName &p_method, const Variant **p
const Variant **input_args = (const Variant **)(sequence_bits + f->node_count);
Variant **output_args = (Variant **)(input_args + max_input_args);
int flow_max = f->flow_stack_size;
- int *flow_stack = flow_max ? (int *)(output_args + max_output_args) : (int *)NULL;
- int *pass_stack = flow_stack ? (int *)(flow_stack + flow_max) : (int *)NULL;
+ int *flow_stack = flow_max ? (int *)(output_args + max_output_args) : (int *)nullptr;
+ int *pass_stack = flow_stack ? (int *)(flow_stack + flow_max) : (int *)nullptr;
for (int i = 0; i < f->node_count; i++) {
sequence_bits[i] = false; //all starts as false
@@ -2097,7 +2121,7 @@ void VisualScriptInstance::notification(int p_notification) {
String VisualScriptInstance::to_string(bool *r_valid) {
if (has_method(CoreStringNames::get_singleton()->_to_string)) {
Callable::CallError ce;
- Variant ret = call(CoreStringNames::get_singleton()->_to_string, NULL, 0, ce);
+ Variant ret = call(CoreStringNames::get_singleton()->_to_string, nullptr, 0, ce);
if (ce.error == Callable::CallError::CALL_OK) {
if (ret.get_type() != Variant::STRING) {
if (r_valid)
@@ -2237,12 +2261,12 @@ void VisualScriptInstance::create(const Ref<VisualScript> &p_script, Object *p_o
instance->id = F->key();
instance->input_port_count = node->get_input_value_port_count();
- instance->input_ports = NULL;
+ instance->input_ports = nullptr;
instance->output_port_count = node->get_output_value_port_count();
- instance->output_ports = NULL;
+ instance->output_ports = nullptr;
instance->sequence_output_count = node->get_output_sequence_port_count();
instance->sequence_index = function.node_count++;
- instance->sequence_outputs = NULL;
+ instance->sequence_outputs = nullptr;
instance->pass_idx = -1;
if (instance->input_port_count) {
@@ -2263,7 +2287,7 @@ void VisualScriptInstance::create(const Ref<VisualScript> &p_script, Object *p_o
if (instance->sequence_output_count) {
instance->sequence_outputs = memnew_arr(VisualScriptNodeInstance *, instance->sequence_output_count);
for (int i = 0; i < instance->sequence_output_count; i++) {
- instance->sequence_outputs[i] = NULL; //if it remains null, flow ends here
+ instance->sequence_outputs[i] = nullptr; //if it remains null, flow ends here
}
}
@@ -2797,7 +2821,7 @@ int VisualScriptLanguage::profiling_get_frame_data(ProfilingInfo *p_info_arr, in
return 0;
}
-VisualScriptLanguage *VisualScriptLanguage::singleton = NULL;
+VisualScriptLanguage *VisualScriptLanguage::singleton = nullptr;
void VisualScriptLanguage::add_register_func(const String &p_name, VisualScriptNodeRegisterFunc p_func) {
@@ -2844,7 +2868,7 @@ VisualScriptLanguage::VisualScriptLanguage() {
} else {
_debug_max_call_stack = 0;
- _call_stack = NULL;
+ _call_stack = nullptr;
}
}
@@ -2853,5 +2877,5 @@ VisualScriptLanguage::~VisualScriptLanguage() {
if (_call_stack) {
memdelete_arr(_call_stack);
}
- singleton = NULL;
+ singleton = nullptr;
}
diff --git a/modules/visual_script/visual_script.h b/modules/visual_script/visual_script.h
index 20273316b4..c154e56703 100644
--- a/modules/visual_script/visual_script.h
+++ b/modules/visual_script/visual_script.h
@@ -272,6 +272,8 @@ protected:
static void _bind_methods();
public:
+ bool inherits_script(const Ref<Script> &p_script) const;
+
// TODO: Remove it in future when breaking changes are acceptable
StringName get_default_func() const;
void add_function(const StringName &p_name);
@@ -420,7 +422,7 @@ public:
virtual bool set(const StringName &p_name, const Variant &p_value);
virtual bool get(const StringName &p_name, Variant &r_ret) const;
virtual void get_property_list(List<PropertyInfo> *p_properties) const;
- virtual Variant::Type get_property_type(const StringName &p_name, bool *r_is_valid = NULL) const;
+ virtual Variant::Type get_property_type(const StringName &p_name, bool *r_is_valid = nullptr) const;
virtual void get_method_list(List<MethodInfo> *p_list) const;
virtual bool has_method(const StringName &p_method) const;
@@ -596,7 +598,7 @@ public:
virtual Ref<Script> get_template(const String &p_class_name, const String &p_base_class_name) const;
virtual bool is_using_templates();
virtual void make_template(const String &p_class_name, const String &p_base_class_name, Ref<Script> &p_script);
- virtual bool validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path = "", List<String> *r_functions = NULL, List<ScriptLanguage::Warning> *r_warnings = NULL, Set<int> *r_safe_lines = NULL) const;
+ virtual bool validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path = "", List<String> *r_functions = nullptr, List<ScriptLanguage::Warning> *r_warnings = nullptr, Set<int> *r_safe_lines = nullptr) const;
virtual Script *create_script() const;
virtual bool has_named_classes() const;
virtual bool supports_builtin_mode() const;
diff --git a/modules/visual_script/visual_script_builtin_funcs.cpp b/modules/visual_script/visual_script_builtin_funcs.cpp
index 07f152efd4..bb291b1cb6 100644
--- a/modules/visual_script/visual_script_builtin_funcs.cpp
+++ b/modules/visual_script/visual_script_builtin_funcs.cpp
@@ -506,10 +506,12 @@ PropertyInfo VisualScriptBuiltinFunc::get_output_value_port_info(int p_idx) cons
case MATH_CEIL: {
t = Variant::FLOAT;
} break;
- case MATH_POSMOD:
- case MATH_ROUND: {
+ case MATH_POSMOD: {
t = Variant::INT;
} break;
+ case MATH_ROUND: {
+ t = Variant::FLOAT;
+ } break;
case MATH_ABS: {
t = Variant::NIL;
} break;
@@ -1231,7 +1233,7 @@ void VisualScriptBuiltinFunc::exec_func(BuiltinFunc p_func, const Variant **p_in
PackedByteArray barr;
int len;
bool full_objects = *p_inputs[1];
- Error err = encode_variant(*p_inputs[0], NULL, len, full_objects);
+ Error err = encode_variant(*p_inputs[0], nullptr, len, full_objects);
if (err) {
r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
@@ -1267,7 +1269,7 @@ void VisualScriptBuiltinFunc::exec_func(BuiltinFunc p_func, const Variant **p_in
Variant ret;
{
const uint8_t *r = varr.ptr();
- Error err = decode_variant(ret, r, varr.size(), NULL, allow_objects);
+ Error err = decode_variant(ret, r, varr.size(), nullptr, allow_objects);
if (err != OK) {
r_error_str = RTR("Not enough bytes for decoding bytes, or invalid format.");
r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp
index ca255ebf82..9a4076bec4 100644
--- a/modules/visual_script/visual_script_editor.cpp
+++ b/modules/visual_script/visual_script_editor.cpp
@@ -30,15 +30,15 @@
#include "visual_script_editor.h"
+#include "core/input/input.h"
#include "core/object.h"
-#include "core/os/input.h"
#include "core/os/keyboard.h"
#include "core/script_language.h"
#include "core/variant.h"
#include "editor/editor_node.h"
#include "editor/editor_resource_preview.h"
#include "editor/editor_scale.h"
-#include "scene/main/viewport.h"
+#include "scene/main/window.h"
#include "visual_script_expression.h"
#include "visual_script_flow_control.h"
#include "visual_script_func_nodes.h"
@@ -182,7 +182,7 @@ public:
_change_notify();
}
- VisualScriptEditorSignalEdit() { undo_redo = NULL; }
+ VisualScriptEditorSignalEdit() { undo_redo = nullptr; }
};
class VisualScriptEditorVariableEdit : public Object {
@@ -335,7 +335,7 @@ public:
_change_notify();
}
- VisualScriptEditorVariableEdit() { undo_redo = NULL; }
+ VisualScriptEditorVariableEdit() { undo_redo = nullptr; }
};
static Color _color_from_type(Variant::Type p_type, bool dark_theme = true) {
@@ -350,8 +350,11 @@ static Color _color_from_type(Variant::Type p_type, bool dark_theme = true) {
case Variant::STRING: color = Color(0.42, 0.65, 0.93); break;
case Variant::VECTOR2: color = Color(0.74, 0.57, 0.95); break;
+ case Variant::VECTOR2I: color = Color(0.74, 0.57, 0.95); break;
case Variant::RECT2: color = Color(0.95, 0.57, 0.65); break;
+ case Variant::RECT2I: color = Color(0.95, 0.57, 0.65); break;
case Variant::VECTOR3: color = Color(0.84, 0.49, 0.93); break;
+ case Variant::VECTOR3I: color = Color(0.84, 0.49, 0.93); break;
case Variant::TRANSFORM2D: color = Color(0.77, 0.93, 0.41); break;
case Variant::PLANE: color = Color(0.97, 0.44, 0.44); break;
case Variant::QUAT: color = Color(0.93, 0.41, 0.64); break;
@@ -389,8 +392,11 @@ static Color _color_from_type(Variant::Type p_type, bool dark_theme = true) {
case Variant::STRING: color = Color(0.27, 0.56, 0.91); break;
case Variant::VECTOR2: color = Color(0.68, 0.46, 0.93); break;
+ case Variant::VECTOR2I: color = Color(0.68, 0.46, 0.93); break;
case Variant::RECT2: color = Color(0.93, 0.46, 0.56); break;
+ case Variant::RECT2I: color = Color(0.93, 0.46, 0.56); break;
case Variant::VECTOR3: color = Color(0.86, 0.42, 0.93); break;
+ case Variant::VECTOR3I: color = Color(0.86, 0.42, 0.93); break;
case Variant::TRANSFORM2D: color = Color(0.59, 0.81, 0.1); break;
case Variant::PLANE: color = Color(0.97, 0.44, 0.44); break;
case Variant::QUAT: color = Color(0.93, 0.41, 0.64); break;
@@ -504,36 +510,41 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
select_func_text->hide();
Ref<Texture2D> type_icons[Variant::VARIANT_MAX] = {
- Control::get_icon("Variant", "EditorIcons"),
- Control::get_icon("bool", "EditorIcons"),
- Control::get_icon("int", "EditorIcons"),
- Control::get_icon("float", "EditorIcons"),
- Control::get_icon("String", "EditorIcons"),
- Control::get_icon("Vector2", "EditorIcons"),
- Control::get_icon("Rect2", "EditorIcons"),
- Control::get_icon("Vector3", "EditorIcons"),
- Control::get_icon("Transform2D", "EditorIcons"),
- Control::get_icon("Plane", "EditorIcons"),
- Control::get_icon("Quat", "EditorIcons"),
- Control::get_icon("AABB", "EditorIcons"),
- Control::get_icon("Basis", "EditorIcons"),
- Control::get_icon("Transform", "EditorIcons"),
- Control::get_icon("Color", "EditorIcons"),
- Control::get_icon("NodePath", "EditorIcons"),
- Control::get_icon("RID", "EditorIcons"),
- Control::get_icon("MiniObject", "EditorIcons"),
- Control::get_icon("Dictionary", "EditorIcons"),
- Control::get_icon("Array", "EditorIcons"),
- Control::get_icon("PackedByteArray", "EditorIcons"),
- Control::get_icon("PackedInt32Array", "EditorIcons"),
- Control::get_icon("PackedFloat32Array", "EditorIcons"),
- Control::get_icon("PackedStringArray", "EditorIcons"),
- Control::get_icon("PackedVector2Array", "EditorIcons"),
- Control::get_icon("PackedVector3Array", "EditorIcons"),
- Control::get_icon("PackedColorArray", "EditorIcons")
+ Control::get_theme_icon("Variant", "EditorIcons"),
+ Control::get_theme_icon("bool", "EditorIcons"),
+ Control::get_theme_icon("int", "EditorIcons"),
+ Control::get_theme_icon("float", "EditorIcons"),
+ Control::get_theme_icon("String", "EditorIcons"),
+ Control::get_theme_icon("Vector2", "EditorIcons"),
+ Control::get_theme_icon("Vector2i", "EditorIcons"),
+ Control::get_theme_icon("Rect2", "EditorIcons"),
+ Control::get_theme_icon("Rect2i", "EditorIcons"),
+ Control::get_theme_icon("Vector3", "EditorIcons"),
+ Control::get_theme_icon("Vector3i", "EditorIcons"),
+ Control::get_theme_icon("Transform2D", "EditorIcons"),
+ Control::get_theme_icon("Plane", "EditorIcons"),
+ Control::get_theme_icon("Quat", "EditorIcons"),
+ Control::get_theme_icon("AABB", "EditorIcons"),
+ Control::get_theme_icon("Basis", "EditorIcons"),
+ Control::get_theme_icon("Transform", "EditorIcons"),
+ Control::get_theme_icon("Color", "EditorIcons"),
+ Control::get_theme_icon("NodePath", "EditorIcons"),
+ Control::get_theme_icon("RID", "EditorIcons"),
+ Control::get_theme_icon("MiniObject", "EditorIcons"),
+ Control::get_theme_icon("Callable", "EditorIcons"),
+ Control::get_theme_icon("Signal", "EditorIcons"),
+ Control::get_theme_icon("Dictionary", "EditorIcons"),
+ Control::get_theme_icon("Array", "EditorIcons"),
+ Control::get_theme_icon("PackedByteArray", "EditorIcons"),
+ Control::get_theme_icon("PackedInt32Array", "EditorIcons"),
+ Control::get_theme_icon("PackedFloat32Array", "EditorIcons"),
+ Control::get_theme_icon("PackedStringArray", "EditorIcons"),
+ Control::get_theme_icon("PackedVector2Array", "EditorIcons"),
+ Control::get_theme_icon("PackedVector3Array", "EditorIcons"),
+ Control::get_theme_icon("PackedColorArray", "EditorIcons")
};
- Ref<Texture2D> seq_port = Control::get_icon("VisualShaderPort", "EditorIcons");
+ Ref<Texture2D> seq_port = Control::get_theme_icon("VisualShaderPort", "EditorIcons");
for (List<StringName>::Element *F = funcs.front(); F; F = F->next()) { // loop through all the functions
@@ -596,7 +607,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
LineEdit *line_edit = memnew(LineEdit);
line_edit->set_text(node->get_text());
line_edit->set_expand_to_text_length(true);
- line_edit->add_font_override("font", get_font("source", "EditorFonts"));
+ line_edit->add_theme_font_override("font", get_theme_font("source", "EditorFonts"));
gnode->add_child(line_edit);
line_edit->connect("text_changed", callable_mp(this, &VisualScriptEditor::_expression_text_changed), varray(E->get()));
} else {
@@ -637,14 +648,14 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
mono_color.a = 0.85;
c = mono_color;
}
- gnode->add_color_override("title_color", c);
+ gnode->add_theme_color_override("title_color", c);
c.a = 0.7;
- gnode->add_color_override("close_color", c);
- gnode->add_color_override("resizer_color", ic);
- gnode->add_style_override("frame", sbf);
+ gnode->add_theme_color_override("close_color", c);
+ gnode->add_theme_color_override("resizer_color", ic);
+ gnode->add_theme_style_override("frame", sbf);
}
- const Color mono_color = get_color("mono_color", "Editor");
+ const Color mono_color = get_theme_color("mono_color", "Editor");
int slot_idx = 0;
@@ -750,7 +761,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
}
Button *rmbtn = memnew(Button);
- rmbtn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("Remove", "EditorIcons"));
+ rmbtn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Remove", "EditorIcons"));
hbc->add_child(rmbtn);
rmbtn->connect("pressed", callable_mp(this, &VisualScriptEditor::_remove_input_port), varray(E->get(), i), CONNECT_DEFERRED);
} else {
@@ -812,7 +823,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
if (is_vslist) {
Button *rmbtn = memnew(Button);
- rmbtn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("Remove", "EditorIcons"));
+ rmbtn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Remove", "EditorIcons"));
hbc->add_child(rmbtn);
rmbtn->connect("pressed", callable_mp(this, &VisualScriptEditor::_remove_output_port), varray(E->get(), i), CONNECT_DEFERRED);
@@ -856,7 +867,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
gnode->add_child(vbc);
- bool dark_theme = get_constant("dark_theme", "Editor");
+ bool dark_theme = get_theme_constant("dark_theme", "Editor");
if (i < mixed_seq_ports) {
gnode->set_slot(slot_idx, left_ok, left_type, _color_from_type(left_type, dark_theme), true, TYPE_SEQUENCE, mono_color, Ref<Texture2D>(), seq_port);
} else {
@@ -940,9 +951,9 @@ void VisualScriptEditor::_update_members() {
TreeItem *functions = members->create_item(root);
functions->set_selectable(0, false);
functions->set_text(0, TTR("Functions:"));
- functions->add_button(0, Control::get_icon("Override", "EditorIcons"), 1, false, TTR("Override an existing built-in function."));
- functions->add_button(0, Control::get_icon("Add", "EditorIcons"), 0, false, TTR("Create a new function."));
- functions->set_custom_color(0, Control::get_color("mono_color", "Editor"));
+ functions->add_button(0, Control::get_theme_icon("Override", "EditorIcons"), 1, false, TTR("Override an existing built-in function."));
+ functions->add_button(0, Control::get_theme_icon("Add", "EditorIcons"), 0, false, TTR("Create a new function."));
+ functions->set_custom_color(0, Control::get_theme_color("mono_color", "Editor"));
List<StringName> func_names;
script->get_function_list(&func_names);
@@ -956,7 +967,7 @@ void VisualScriptEditor::_update_members() {
ti->set_text(0, E->get());
ti->set_selectable(0, true);
ti->set_metadata(0, E->get());
- ti->add_button(0, Control::get_icon("Edit", "EditorIcons"), 0);
+ ti->add_button(0, Control::get_theme_icon("Edit", "EditorIcons"), 0);
if (selected == E->get())
ti->select(0);
}
@@ -964,37 +975,42 @@ void VisualScriptEditor::_update_members() {
TreeItem *variables = members->create_item(root);
variables->set_selectable(0, false);
variables->set_text(0, TTR("Variables:"));
- variables->add_button(0, Control::get_icon("Add", "EditorIcons"), -1, false, TTR("Create a new variable."));
- variables->set_custom_color(0, Control::get_color("mono_color", "Editor"));
+ variables->add_button(0, Control::get_theme_icon("Add", "EditorIcons"), -1, false, TTR("Create a new variable."));
+ variables->set_custom_color(0, Control::get_theme_color("mono_color", "Editor"));
Ref<Texture2D> type_icons[Variant::VARIANT_MAX] = {
- Control::get_icon("Variant", "EditorIcons"),
- Control::get_icon("bool", "EditorIcons"),
- Control::get_icon("int", "EditorIcons"),
- Control::get_icon("float", "EditorIcons"),
- Control::get_icon("String", "EditorIcons"),
- Control::get_icon("Vector2", "EditorIcons"),
- Control::get_icon("Rect2", "EditorIcons"),
- Control::get_icon("Vector3", "EditorIcons"),
- Control::get_icon("Transform2D", "EditorIcons"),
- Control::get_icon("Plane", "EditorIcons"),
- Control::get_icon("Quat", "EditorIcons"),
- Control::get_icon("AABB", "EditorIcons"),
- Control::get_icon("Basis", "EditorIcons"),
- Control::get_icon("Transform", "EditorIcons"),
- Control::get_icon("Color", "EditorIcons"),
- Control::get_icon("NodePath", "EditorIcons"),
- Control::get_icon("RID", "EditorIcons"),
- Control::get_icon("MiniObject", "EditorIcons"),
- Control::get_icon("Dictionary", "EditorIcons"),
- Control::get_icon("Array", "EditorIcons"),
- Control::get_icon("PackedByteArray", "EditorIcons"),
- Control::get_icon("PackedInt32Array", "EditorIcons"),
- Control::get_icon("PackedFloat32Array", "EditorIcons"),
- Control::get_icon("PackedStringArray", "EditorIcons"),
- Control::get_icon("PackedVector2Array", "EditorIcons"),
- Control::get_icon("PackedVector3Array", "EditorIcons"),
- Control::get_icon("PackedColorArray", "EditorIcons")
+ Control::get_theme_icon("Variant", "EditorIcons"),
+ Control::get_theme_icon("bool", "EditorIcons"),
+ Control::get_theme_icon("int", "EditorIcons"),
+ Control::get_theme_icon("float", "EditorIcons"),
+ Control::get_theme_icon("String", "EditorIcons"),
+ Control::get_theme_icon("Vector2", "EditorIcons"),
+ Control::get_theme_icon("Vector2i", "EditorIcons"),
+ Control::get_theme_icon("Rect2", "EditorIcons"),
+ Control::get_theme_icon("Rect2i", "EditorIcons"),
+ Control::get_theme_icon("Vector3", "EditorIcons"),
+ Control::get_theme_icon("Vector3i", "EditorIcons"),
+ Control::get_theme_icon("Transform2D", "EditorIcons"),
+ Control::get_theme_icon("Plane", "EditorIcons"),
+ Control::get_theme_icon("Quat", "EditorIcons"),
+ Control::get_theme_icon("AABB", "EditorIcons"),
+ Control::get_theme_icon("Basis", "EditorIcons"),
+ Control::get_theme_icon("Transform", "EditorIcons"),
+ Control::get_theme_icon("Color", "EditorIcons"),
+ Control::get_theme_icon("NodePath", "EditorIcons"),
+ Control::get_theme_icon("RID", "EditorIcons"),
+ Control::get_theme_icon("MiniObject", "EditorIcons"),
+ Control::get_theme_icon("Callable", "EditorIcons"),
+ Control::get_theme_icon("Signal", "EditorIcons"),
+ Control::get_theme_icon("Dictionary", "EditorIcons"),
+ Control::get_theme_icon("Array", "EditorIcons"),
+ Control::get_theme_icon("PackedByteArray", "EditorIcons"),
+ Control::get_theme_icon("PackedInt32Array", "EditorIcons"),
+ Control::get_theme_icon("PackedFloat32Array", "EditorIcons"),
+ Control::get_theme_icon("PackedStringArray", "EditorIcons"),
+ Control::get_theme_icon("PackedVector2Array", "EditorIcons"),
+ Control::get_theme_icon("PackedVector3Array", "EditorIcons"),
+ Control::get_theme_icon("PackedColorArray", "EditorIcons")
};
List<StringName> var_names;
@@ -1017,8 +1033,8 @@ void VisualScriptEditor::_update_members() {
TreeItem *_signals = members->create_item(root);
_signals->set_selectable(0, false);
_signals->set_text(0, TTR("Signals:"));
- _signals->add_button(0, Control::get_icon("Add", "EditorIcons"), -1, false, TTR("Create a new signal."));
- _signals->set_custom_color(0, Control::get_color("mono_color", "Editor"));
+ _signals->add_button(0, Control::get_theme_icon("Add", "EditorIcons"), -1, false, TTR("Create a new signal."));
+ _signals->set_custom_color(0, Control::get_theme_color("mono_color", "Editor"));
List<StringName> signal_names;
script->get_custom_signal_list(&signal_names);
@@ -1034,12 +1050,12 @@ void VisualScriptEditor::_update_members() {
String base_type = script->get_instance_base_type();
String icon_type = base_type;
- if (!Control::has_icon(base_type, "EditorIcons")) {
+ if (!Control::has_theme_icon(base_type, "EditorIcons")) {
icon_type = "Object";
}
base_type_select->set_text(base_type);
- base_type_select->set_icon(Control::get_icon(icon_type, "EditorIcons"));
+ base_type_select->set_icon(Control::get_theme_icon(icon_type, "EditorIcons"));
updating_members = false;
}
@@ -1155,6 +1171,8 @@ void VisualScriptEditor::_member_edited() {
undo_redo->add_undo_method(script.ptr(), "rename_variable", new_name, name);
undo_redo->add_do_method(this, "_update_members");
undo_redo->add_undo_method(this, "_update_members");
+ undo_redo->add_do_method(this, "_update_graph");
+ undo_redo->add_undo_method(this, "_update_graph");
undo_redo->add_do_method(this, "emit_signal", "edited_script_changed");
undo_redo->add_undo_method(this, "emit_signal", "edited_script_changed");
undo_redo->commit_action();
@@ -1252,7 +1270,7 @@ void VisualScriptEditor::_add_func_input() {
hbox->add_child(type_box);
Button *delete_button = memnew(Button);
- delete_button->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("Remove", "EditorIcons"));
+ delete_button->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Remove", "EditorIcons"));
delete_button->set_tooltip(vformat(TTR("Delete input port")));
hbox->add_child(delete_button);
@@ -1262,7 +1280,7 @@ void VisualScriptEditor::_add_func_input() {
}
func_input_vbox->add_child(hbox);
- hbox->set_meta("id", hbox->get_position_in_parent());
+ hbox->set_meta("id", hbox->get_index());
delete_button->connect("pressed", callable_mp(this, &VisualScriptEditor::_remove_func_input), varray(hbox));
@@ -1932,7 +1950,7 @@ bool VisualScriptEditor::can_drop_data_fw(const Point2 &p_point, const Variant &
static Node *_find_script_node(Node *p_edited_scene, Node *p_current_node, const Ref<Script> &script) {
if (p_edited_scene != p_current_node && p_current_node->get_owner() != p_edited_scene)
- return NULL;
+ return nullptr;
Ref<Script> scr = p_current_node->get_script();
@@ -1945,7 +1963,7 @@ static Node *_find_script_node(Node *p_edited_scene, Node *p_current_node, const
return n;
}
- return NULL;
+ return nullptr;
}
void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
@@ -2377,7 +2395,7 @@ void VisualScriptEditor::_draw_color_over_button(Object *obj, Color p_color) {
if (!button)
return;
- Ref<StyleBox> normal = get_stylebox("normal", "Button");
+ Ref<StyleBox> normal = get_theme_stylebox("normal", "Button");
button->draw_rect(Rect2(normal->get_offset(), button->get_size() - normal->get_minimum_size()), p_color);
}
@@ -2459,9 +2477,9 @@ String VisualScriptEditor::get_name() {
return name;
}
-Ref<Texture2D> VisualScriptEditor::get_icon() {
+Ref<Texture2D> VisualScriptEditor::get_theme_icon() {
- return Control::get_icon("VisualScript", "EditorIcons");
+ return Control::get_theme_icon("VisualScript", "EditorIcons");
}
bool VisualScriptEditor::is_unsaved() {
@@ -3447,7 +3465,7 @@ void VisualScriptEditor::connect_data(Ref<VisualScriptNode> vnode_old, Ref<Visua
undo_redo->create_action(TTR("Connect Node Data"));
VisualScriptReturn *vnode_return = Object::cast_to<VisualScriptReturn>(vnode.ptr());
- if (vnode_return != NULL && vnode_old->get_output_value_port_count() > 0) {
+ if (vnode_return != nullptr && vnode_old->get_output_value_port_count() > 0) {
vnode_return->set_enable_return_value(true);
}
if (vnode_old->get_output_value_port_count() <= 0) {
@@ -3713,11 +3731,11 @@ 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()) {
+ if (vnode_operator != nullptr && !vnode_operator->has_input_sequence_port()) {
return;
}
VisualScriptConstructor *vnode_constructor = Object::cast_to<VisualScriptConstructor>(vnode_new.ptr());
- if (vnode_constructor != NULL) {
+ if (vnode_constructor != nullptr) {
return;
}
if (vnode_old->get_output_sequence_port_count() <= 0) {
@@ -3889,7 +3907,7 @@ void VisualScriptEditor::_default_value_edited(Node *p_button, int p_id, int p_i
}
}
- if (default_value_edit->edit(NULL, pinfo.name, pinfo.type, existing, pinfo.hint, pinfo.hint_string)) {
+ if (default_value_edit->edit(nullptr, pinfo.name, pinfo.type, existing, pinfo.hint, pinfo.hint_string)) {
if (pinfo.hint == PROPERTY_HINT_MULTILINE_TEXT)
default_value_edit->popup_centered_ratio();
else
@@ -3917,7 +3935,9 @@ void VisualScriptEditor::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_READY: {
variable_editor->connect("changed", callable_mp(this, &VisualScriptEditor::_update_members));
+ variable_editor->connect("changed", callable_mp(this, &VisualScriptEditor::_update_graph), varray(-1), CONNECT_DEFERRED);
signal_editor->connect("changed", callable_mp(this, &VisualScriptEditor::_update_members));
+ signal_editor->connect("changed", callable_mp(this, &VisualScriptEditor::_update_graph), varray(-1), CONNECT_DEFERRED);
[[fallthrough]];
}
case NOTIFICATION_THEME_CHANGED: {
@@ -3925,9 +3945,9 @@ void VisualScriptEditor::_notification(int p_what) {
return;
}
- edit_variable_edit->add_style_override("bg", get_stylebox("bg", "Tree"));
- edit_signal_edit->add_style_override("bg", get_stylebox("bg", "Tree"));
- func_input_scroll->add_style_override("bg", get_stylebox("bg", "Tree"));
+ edit_variable_edit->add_theme_style_override("bg", get_theme_stylebox("bg", "Tree"));
+ edit_signal_edit->add_theme_style_override("bg", get_theme_stylebox("bg", "Tree"));
+ func_input_scroll->add_theme_style_override("bg", get_theme_stylebox("bg", "Tree"));
Ref<Theme> tm = EditorNode::get_singleton()->get_theme_base()->get_theme();
@@ -4479,9 +4499,9 @@ void VisualScriptEditor::_member_rmb_selected(const Vector2 &p_pos) {
TreeItem *root = members->get_root();
- Ref<Texture2D> del_icon = Control::get_icon("Remove", "EditorIcons");
+ Ref<Texture2D> del_icon = Control::get_theme_icon("Remove", "EditorIcons");
- Ref<Texture2D> edit_icon = Control::get_icon("Edit", "EditorIcons");
+ Ref<Texture2D> edit_icon = Control::get_theme_icon("Edit", "EditorIcons");
if (ti->get_parent() == root->get_children()) {
@@ -4578,7 +4598,7 @@ void VisualScriptEditor::_member_option(int p_option) {
} else if (p_option == MEMBER_EDIT) {
variable_editor->edit(name);
edit_variable_dialog->set_title(TTR("Editing Variable:") + " " + name);
- edit_variable_dialog->popup_centered_minsize(Size2(400, 200) * EDSCALE);
+ edit_variable_dialog->popup_centered(Size2(400, 200) * EDSCALE);
}
} break;
case MEMBER_SIGNAL: {
@@ -4599,7 +4619,7 @@ void VisualScriptEditor::_member_option(int p_option) {
} else if (p_option == MEMBER_EDIT) {
signal_editor->edit(name);
edit_signal_dialog->set_title(TTR("Editing Signal:") + " " + name);
- edit_signal_dialog->popup_centered_minsize(Size2(400, 300) * EDSCALE);
+ edit_signal_dialog->popup_centered(Size2(400, 300) * EDSCALE);
}
} break;
}
@@ -4629,6 +4649,7 @@ void VisualScriptEditor::_bind_methods() {
ClassDB::bind_method("_input", &VisualScriptEditor::_input);
ClassDB::bind_method("_update_graph_connections", &VisualScriptEditor::_update_graph_connections);
+ ClassDB::bind_method("_update_members", &VisualScriptEditor::_update_members);
ClassDB::bind_method("_generic_search", &VisualScriptEditor::_generic_search);
}
@@ -4687,10 +4708,9 @@ VisualScriptEditor::VisualScriptEditor() {
add_child(member_popup);
member_popup->connect("id_pressed", callable_mp(this, &VisualScriptEditor::_member_option));
- function_name_edit = memnew(PopupDialog);
+ function_name_edit = memnew(AcceptDialog);
function_name_box = memnew(LineEdit);
function_name_edit->add_child(function_name_box);
- function_name_edit->set_h_size_flags(SIZE_EXPAND);
function_name_box->connect("gui_input", callable_mp(this, &VisualScriptEditor::_fn_name_box_input));
function_name_box->set_expand_to_text_length(true);
add_child(function_name_edit);
@@ -4770,7 +4790,6 @@ VisualScriptEditor::VisualScriptEditor() {
func_input_scroll->add_child(func_input_vbox);
function_create_dialog = memnew(ConfirmationDialog);
- function_create_dialog->set_v_size_flags(SIZE_EXPAND_FILL);
function_create_dialog->set_title(TTR("Create Function"));
function_create_dialog->add_child(function_vb);
function_create_dialog->get_ok()->set_text(TTR("Create"));
@@ -4859,7 +4878,6 @@ VisualScriptEditor::VisualScriptEditor() {
new_connect_node_select = memnew(VisualScriptPropertySelector);
add_child(new_connect_node_select);
- new_connect_node_select->set_resizable(true);
new_connect_node_select->connect("selected", callable_mp(this, &VisualScriptEditor::_selected_connect_node));
new_connect_node_select->get_cancel()->connect("pressed", callable_mp(this, &VisualScriptEditor::_cancel_connect_node));
@@ -4881,10 +4899,10 @@ static ScriptEditorBase *create_editor(const RES &p_resource) {
return memnew(VisualScriptEditor);
}
- return NULL;
+ return nullptr;
}
-VisualScriptEditor::Clipboard *VisualScriptEditor::clipboard = NULL;
+VisualScriptEditor::Clipboard *VisualScriptEditor::clipboard = nullptr;
void VisualScriptEditor::free_clipboard() {
if (clipboard)
@@ -4920,7 +4938,7 @@ Ref<VisualScriptNode> _VisualScriptEditor::create_node_custom(const String &p_na
return node;
}
-_VisualScriptEditor *_VisualScriptEditor::singleton = NULL;
+_VisualScriptEditor *_VisualScriptEditor::singleton = nullptr;
Map<String, REF> _VisualScriptEditor::custom_nodes;
_VisualScriptEditor::_VisualScriptEditor() {
diff --git a/modules/visual_script/visual_script_editor.h b/modules/visual_script/visual_script_editor.h
index 6ff00cf0a6..d9494e4d04 100644
--- a/modules/visual_script/visual_script_editor.h
+++ b/modules/visual_script/visual_script_editor.h
@@ -114,7 +114,7 @@ class VisualScriptEditor : public ScriptEditorBase {
UndoRedo *undo_redo;
Tree *members;
- PopupDialog *function_name_edit;
+ AcceptDialog *function_name_edit;
LineEdit *function_name_box;
Label *hint_text;
@@ -298,7 +298,7 @@ public:
virtual Vector<String> get_functions();
virtual void reload_text();
virtual String get_name();
- virtual Ref<Texture2D> get_icon();
+ virtual Ref<Texture2D> get_theme_icon();
virtual bool is_unsaved();
virtual Variant get_edit_state();
virtual void set_edit_state(const Variant &p_state);
diff --git a/modules/visual_script/visual_script_expression.cpp b/modules/visual_script/visual_script_expression.cpp
index c52315a477..71ed483d65 100644
--- a/modules/visual_script/visual_script_expression.cpp
+++ b/modules/visual_script/visual_script_expression.cpp
@@ -652,12 +652,12 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
while (true) {
//keep appending stuff to expression
- ENode *expr = NULL;
+ ENode *expr = nullptr;
Token tk;
_get_token(tk);
if (error_set)
- return NULL;
+ return nullptr;
switch (tk.type) {
case TK_CURLY_BRACKET_OPEN: {
@@ -675,18 +675,18 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
//parse an expression
ENode *expr2 = _parse_expression();
if (!expr2)
- return NULL;
+ return nullptr;
dn->dict.push_back(expr2);
_get_token(tk);
if (tk.type != TK_COLON) {
_set_error("Expected ':'");
- return NULL;
+ return nullptr;
}
expr2 = _parse_expression();
if (!expr2)
- return NULL;
+ return nullptr;
dn->dict.push_back(expr2);
@@ -719,7 +719,7 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
//parse an expression
ENode *expr2 = _parse_expression();
if (!expr2)
- return NULL;
+ return nullptr;
an->array.push_back(expr2);
cofs = str_ofs;
@@ -739,11 +739,11 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
//a suexpression
ENode *e = _parse_expression();
if (error_set)
- return NULL;
+ return nullptr;
_get_token(tk);
if (tk.type != TK_PARENTHESIS_CLOSE) {
_set_error("Expected ')'");
- return NULL;
+ return nullptr;
}
expr = e;
@@ -766,7 +766,7 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
expr = input;
} else {
_set_error("Invalid input identifier '" + what + "'. For script variables, use self (locals are for inputs)." + what);
- return NULL;
+ return nullptr;
}
} break;
case TK_SELF: {
@@ -786,7 +786,7 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
_get_token(tk);
if (tk.type != TK_PARENTHESIS_OPEN) {
_set_error("Expected '('");
- return NULL;
+ return nullptr;
}
ConstructorNode *constructor = alloc_node<ConstructorNode>();
@@ -803,7 +803,7 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
//parse an expression
ENode *expr2 = _parse_expression();
if (!expr2)
- return NULL;
+ return nullptr;
constructor->arguments.push_back(expr2);
@@ -827,7 +827,7 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
_get_token(tk);
if (tk.type != TK_PARENTHESIS_OPEN) {
_set_error("Expected '('");
- return NULL;
+ return nullptr;
}
BuiltinFuncNode *bifunc = alloc_node<BuiltinFuncNode>();
@@ -844,7 +844,7 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
//parse an expression
ENode *expr2 = _parse_expression();
if (!expr2)
- return NULL;
+ return nullptr;
bifunc->arguments.push_back(expr2);
@@ -886,7 +886,7 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
default: {
_set_error("Expected expression.");
- return NULL;
+ return nullptr;
} break;
}
@@ -896,7 +896,7 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
int cofs2 = str_ofs;
_get_token(tk);
if (error_set)
- return NULL;
+ return nullptr;
bool done = false;
@@ -909,14 +909,14 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
ENode *what = _parse_expression();
if (!what)
- return NULL;
+ return nullptr;
index->index = what;
_get_token(tk);
if (tk.type != TK_BRACKET_CLOSE) {
_set_error("Expected ']' at end of index.");
- return NULL;
+ return nullptr;
}
expr = index;
@@ -926,7 +926,7 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
_get_token(tk);
if (tk.type != TK_IDENTIFIER) {
_set_error("Expected identifier after '.'");
- return NULL;
+ return nullptr;
}
StringName identifier = tk.value;
@@ -950,7 +950,7 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
//parse an expression
ENode *expr2 = _parse_expression();
if (!expr2)
- return NULL;
+ return nullptr;
func_call->arguments.push_back(expr2);
@@ -1000,7 +1000,7 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
int cofs = str_ofs;
_get_token(tk);
if (error_set)
- return NULL;
+ return nullptr;
Variant::Operator op = Variant::OP_MAX;
@@ -1107,7 +1107,7 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
default: {
_set_error("Parser bug, invalid operator in expression: " + itos(expression[i].op));
- return NULL;
+ return nullptr;
}
}
@@ -1124,7 +1124,7 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
if (next_op == -1) {
_set_error("Yet another parser bug....");
- ERR_FAIL_V(NULL);
+ ERR_FAIL_V(nullptr);
}
// OK! create operator..
@@ -1137,7 +1137,7 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
if (expr_pos == expression.size()) {
//can happen..
_set_error("Unexpected end of expression...");
- return NULL;
+ return nullptr;
}
}
@@ -1147,7 +1147,7 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
OperatorNode *op = alloc_node<OperatorNode>();
op->op = expression[i].op;
op->nodes[0] = expression[i + 1].node;
- op->nodes[1] = NULL;
+ op->nodes[1] = nullptr;
expression.write[i].is_op = false;
expression.write[i].node = op;
expression.remove(i + 1);
@@ -1157,7 +1157,7 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
if (next_op < 1 || next_op >= (expression.size() - 1)) {
_set_error("Parser bug...");
- ERR_FAIL_V(NULL);
+ ERR_FAIL_V(nullptr);
}
OperatorNode *op = alloc_node<OperatorNode>();
@@ -1166,7 +1166,7 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
if (expression[next_op - 1].is_op) {
_set_error("Parser bug...");
- ERR_FAIL_V(NULL);
+ ERR_FAIL_V(nullptr);
}
if (expression[next_op + 1].is_op) {
@@ -1176,7 +1176,7 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
// due to how precedence works, unaries will always disappear first
_set_error("Unexpected two consecutive operators.");
- return NULL;
+ return nullptr;
}
op->nodes[0] = expression[next_op - 1].node; //expression goes as left
@@ -1199,8 +1199,8 @@ bool VisualScriptExpression::_compile_expression() {
if (nodes) {
memdelete(nodes);
- nodes = NULL;
- root = NULL;
+ nodes = nullptr;
+ root = nullptr;
}
error_str = String();
@@ -1210,11 +1210,11 @@ bool VisualScriptExpression::_compile_expression() {
root = _parse_expression();
if (error_set) {
- root = NULL;
+ root = nullptr;
if (nodes) {
memdelete(nodes);
}
- nodes = NULL;
+ nodes = nullptr;
return true;
}
@@ -1478,8 +1478,8 @@ VisualScriptExpression::VisualScriptExpression() {
output_type = Variant::NIL;
expression_dirty = true;
error_set = true;
- root = NULL;
- nodes = NULL;
+ root = nullptr;
+ nodes = nullptr;
sequenced = false;
}
diff --git a/modules/visual_script/visual_script_expression.h b/modules/visual_script/visual_script_expression.h
index d131713ef0..61b50ff99d 100644
--- a/modules/visual_script/visual_script_expression.h
+++ b/modules/visual_script/visual_script_expression.h
@@ -138,7 +138,7 @@ class VisualScriptExpression : public VisualScriptNode {
Type type;
- ENode() { next = NULL; }
+ ENode() { next = nullptr; }
virtual ~ENode() {
if (next) {
memdelete(next);
diff --git a/modules/visual_script/visual_script_flow_control.cpp b/modules/visual_script/visual_script_flow_control.cpp
index 475893e86d..8a644c6860 100644
--- a/modules/visual_script/visual_script_flow_control.cpp
+++ b/modules/visual_script/visual_script_flow_control.cpp
@@ -934,6 +934,6 @@ void register_visual_script_flow_control_nodes() {
VisualScriptLanguage::singleton->add_register_func("flow_control/iterator", create_node_generic<VisualScriptIterator>);
VisualScriptLanguage::singleton->add_register_func("flow_control/sequence", create_node_generic<VisualScriptSequence>);
VisualScriptLanguage::singleton->add_register_func("flow_control/switch", create_node_generic<VisualScriptSwitch>);
- //VisualScriptLanguage::singleton->add_register_func("flow_control/input_filter", create_node_generic<VisualScriptInputFilter>);
+ //VisualScriptLanguage::singleton->add_register_func("flow_control/input", create_node_generic<VisualScriptInputFilter>);
VisualScriptLanguage::singleton->add_register_func("flow_control/type_cast", create_node_generic<VisualScriptTypeCast>);
}
diff --git a/modules/visual_script/visual_script_func_nodes.cpp b/modules/visual_script/visual_script_func_nodes.cpp
index 011432ef39..3b6ae369ae 100644
--- a/modules/visual_script/visual_script_func_nodes.cpp
+++ b/modules/visual_script/visual_script_func_nodes.cpp
@@ -58,7 +58,7 @@ bool VisualScriptFunctionCall::has_input_sequence_port() const {
static Node *_find_script_node(Node *p_edited_scene, Node *p_current_node, const Ref<Script> &script) {
if (p_edited_scene != p_current_node && p_current_node->get_owner() != p_edited_scene)
- return NULL;
+ return nullptr;
Ref<Script> scr = p_current_node->get_script();
@@ -71,7 +71,7 @@ static Node *_find_script_node(Node *p_edited_scene, Node *p_current_node, const
return n;
}
- return NULL;
+ return nullptr;
}
#endif
@@ -80,33 +80,33 @@ Node *VisualScriptFunctionCall::_get_base_node() const {
#ifdef TOOLS_ENABLED
Ref<Script> script = get_visual_script();
if (!script.is_valid())
- return NULL;
+ return nullptr;
MainLoop *main_loop = OS::get_singleton()->get_main_loop();
SceneTree *scene_tree = Object::cast_to<SceneTree>(main_loop);
if (!scene_tree)
- return NULL;
+ return nullptr;
Node *edited_scene = scene_tree->get_edited_scene_root();
if (!edited_scene)
- return NULL;
+ return nullptr;
Node *script_node = _find_script_node(edited_scene, edited_scene, script);
if (!script_node)
- return NULL;
+ return nullptr;
if (!script_node->has_node(base_path))
- return NULL;
+ return nullptr;
Node *path_to = script_node->get_node(base_path);
return path_to;
#else
- return NULL;
+ return nullptr;
#endif
}
@@ -955,34 +955,34 @@ Node *VisualScriptPropertySet::_get_base_node() const {
#ifdef TOOLS_ENABLED
Ref<Script> script = get_visual_script();
if (!script.is_valid())
- return NULL;
+ return nullptr;
MainLoop *main_loop = OS::get_singleton()->get_main_loop();
SceneTree *scene_tree = Object::cast_to<SceneTree>(main_loop);
if (!scene_tree)
- return NULL;
+ return nullptr;
Node *edited_scene = scene_tree->get_edited_scene_root();
if (!edited_scene)
- return NULL;
+ return nullptr;
Node *script_node = _find_script_node(edited_scene, edited_scene, script);
if (!script_node)
- return NULL;
+ return nullptr;
if (!script_node->has_node(base_path))
- return NULL;
+ return nullptr;
Node *path_to = script_node->get_node(base_path);
return path_to;
#else
- return NULL;
+ return nullptr;
#endif
}
@@ -1021,7 +1021,7 @@ void VisualScriptPropertySet::_adjust_input_index(PropertyInfo &pinfo) const {
Variant v;
Callable::CallError ce;
- v = Variant::construct(pinfo.type, NULL, 0, ce);
+ v = Variant::construct(pinfo.type, nullptr, 0, ce);
Variant i = v.get(index);
pinfo.type = i.get_type();
}
@@ -1168,7 +1168,7 @@ void VisualScriptPropertySet::_update_cache() {
Variant v;
Callable::CallError ce;
- v = Variant::construct(basic_type, NULL, 0, ce);
+ v = Variant::construct(basic_type, nullptr, 0, ce);
List<PropertyInfo> pinfo;
v.get_property_list(&pinfo);
@@ -1185,7 +1185,7 @@ void VisualScriptPropertySet::_update_cache() {
StringName type;
Ref<Script> script;
- Node *node = NULL;
+ Node *node = nullptr;
if (call_mode == CALL_MODE_NODE_PATH) {
@@ -1410,7 +1410,7 @@ void VisualScriptPropertySet::_validate_property(PropertyInfo &property) const {
if (property.name == "index") {
Callable::CallError ce;
- Variant v = Variant::construct(type_cache.type, NULL, 0, ce);
+ Variant v = Variant::construct(type_cache.type, nullptr, 0, ce);
List<PropertyInfo> plist;
v.get_property_list(&plist);
String options = "";
@@ -1735,34 +1735,34 @@ Node *VisualScriptPropertyGet::_get_base_node() const {
#ifdef TOOLS_ENABLED
Ref<Script> script = get_visual_script();
if (!script.is_valid())
- return NULL;
+ return nullptr;
MainLoop *main_loop = OS::get_singleton()->get_main_loop();
SceneTree *scene_tree = Object::cast_to<SceneTree>(main_loop);
if (!scene_tree)
- return NULL;
+ return nullptr;
Node *edited_scene = scene_tree->get_edited_scene_root();
if (!edited_scene)
- return NULL;
+ return nullptr;
Node *script_node = _find_script_node(edited_scene, edited_scene, script);
if (!script_node)
- return NULL;
+ return nullptr;
if (!script_node->has_node(base_path))
- return NULL;
+ return nullptr;
Node *path_to = script_node->get_node(base_path);
return path_to;
#else
- return NULL;
+ return nullptr;
#endif
}
@@ -1876,7 +1876,7 @@ void VisualScriptPropertyGet::_update_cache() {
Variant v;
Callable::CallError ce;
- v = Variant::construct(basic_type, NULL, 0, ce);
+ v = Variant::construct(basic_type, nullptr, 0, ce);
List<PropertyInfo> pinfo;
v.get_property_list(&pinfo);
@@ -1894,7 +1894,7 @@ void VisualScriptPropertyGet::_update_cache() {
StringName type;
Ref<Script> script;
- Node *node = NULL;
+ Node *node = nullptr;
if (call_mode == CALL_MODE_NODE_PATH) {
@@ -2125,7 +2125,7 @@ void VisualScriptPropertyGet::_validate_property(PropertyInfo &property) const {
if (property.name == "index") {
Callable::CallError ce;
- Variant v = Variant::construct(type_cache, NULL, 0, ce);
+ Variant v = Variant::construct(type_cache, nullptr, 0, ce);
List<PropertyInfo> plist;
v.get_property_list(&plist);
String options = "";
@@ -2501,7 +2501,7 @@ void register_visual_script_func_nodes() {
Variant::Type t = Variant::Type(i);
String type_name = Variant::get_type_name(t);
Callable::CallError ce;
- Variant vt = Variant::construct(t, NULL, 0, ce);
+ Variant vt = Variant::construct(t, nullptr, 0, ce);
List<MethodInfo> ml;
vt.get_method_list(&ml);
diff --git a/modules/visual_script/visual_script_nodes.cpp b/modules/visual_script/visual_script_nodes.cpp
index 41c1ea4ca2..52399d29d0 100644
--- a/modules/visual_script/visual_script_nodes.cpp
+++ b/modules/visual_script/visual_script_nodes.cpp
@@ -32,7 +32,7 @@
#include "core/engine.h"
#include "core/global_constants.h"
-#include "core/os/input.h"
+#include "core/input/input.h"
#include "core/os/os.h"
#include "core/project_settings.h"
#include "scene/main/node.h"
@@ -1483,7 +1483,7 @@ void VisualScriptConstant::set_constant_type(Variant::Type p_type) {
type = p_type;
Callable::CallError ce;
- value = Variant::construct(type, NULL, 0, ce);
+ value = Variant::construct(type, nullptr, 0, ce);
ports_changed_notify();
_change_notify();
}
@@ -2548,7 +2548,7 @@ VisualScriptNodeInstance *VisualScriptSceneNode::instance(VisualScriptInstance *
static Node *_find_script_node(Node *p_edited_scene, Node *p_current_node, const Ref<Script> &script) {
if (p_edited_scene != p_current_node && p_current_node->get_owner() != p_edited_scene)
- return NULL;
+ return nullptr;
Ref<Script> scr = p_current_node->get_script();
@@ -2561,7 +2561,7 @@ static Node *_find_script_node(Node *p_edited_scene, Node *p_current_node, const
return n;
}
- return NULL;
+ return nullptr;
}
#endif
@@ -4006,7 +4006,7 @@ void VisualScriptDeconstruct::_update_elements() {
elements.clear();
Variant v;
Callable::CallError ce;
- v = Variant::construct(type, NULL, 0, ce);
+ v = Variant::construct(type, nullptr, 0, ce);
List<PropertyInfo> pinfo;
v.get_property_list(&pinfo);
@@ -4184,9 +4184,12 @@ void register_visual_script_nodes() {
VisualScriptLanguage::singleton->add_register_func("operators/logic/select", create_node_generic<VisualScriptSelect>);
VisualScriptLanguage::singleton->add_register_func("functions/deconstruct/" + Variant::get_type_name(Variant::Type::VECTOR2), create_node_deconst_typed<Variant::Type::VECTOR2>);
+ VisualScriptLanguage::singleton->add_register_func("functions/deconstruct/" + Variant::get_type_name(Variant::Type::VECTOR2I), create_node_deconst_typed<Variant::Type::VECTOR2I>);
VisualScriptLanguage::singleton->add_register_func("functions/deconstruct/" + Variant::get_type_name(Variant::Type::VECTOR3), create_node_deconst_typed<Variant::Type::VECTOR3>);
+ VisualScriptLanguage::singleton->add_register_func("functions/deconstruct/" + Variant::get_type_name(Variant::Type::VECTOR3I), create_node_deconst_typed<Variant::Type::VECTOR3I>);
VisualScriptLanguage::singleton->add_register_func("functions/deconstruct/" + Variant::get_type_name(Variant::Type::COLOR), create_node_deconst_typed<Variant::Type::COLOR>);
VisualScriptLanguage::singleton->add_register_func("functions/deconstruct/" + Variant::get_type_name(Variant::Type::RECT2), create_node_deconst_typed<Variant::Type::RECT2>);
+ VisualScriptLanguage::singleton->add_register_func("functions/deconstruct/" + Variant::get_type_name(Variant::Type::RECT2I), create_node_deconst_typed<Variant::Type::RECT2I>);
VisualScriptLanguage::singleton->add_register_func("functions/deconstruct/" + Variant::get_type_name(Variant::Type::TRANSFORM2D), create_node_deconst_typed<Variant::Type::TRANSFORM2D>);
VisualScriptLanguage::singleton->add_register_func("functions/deconstruct/" + Variant::get_type_name(Variant::Type::PLANE), create_node_deconst_typed<Variant::Type::PLANE>);
VisualScriptLanguage::singleton->add_register_func("functions/deconstruct/" + Variant::get_type_name(Variant::Type::QUAT), create_node_deconst_typed<Variant::Type::QUAT>);
diff --git a/modules/visual_script/visual_script_property_selector.cpp b/modules/visual_script/visual_script_property_selector.cpp
index d799f19143..f57853078d 100644
--- a/modules/visual_script/visual_script_property_selector.cpp
+++ b/modules/visual_script/visual_script_property_selector.cpp
@@ -39,7 +39,7 @@
#include "modules/visual_script/visual_script_func_nodes.h"
#include "modules/visual_script/visual_script_nodes.h"
#include "scene/main/node.h"
-#include "scene/main/viewport.h"
+#include "scene/main/window.h"
void VisualScriptPropertySelector::_text_changed(const String &p_newtext) {
_update_search();
@@ -97,37 +97,37 @@ void VisualScriptPropertySelector::_update_search() {
for (List<StringName>::Element *E = base_list.front(); E; E = E->next()) {
List<MethodInfo> methods;
List<PropertyInfo> props;
- TreeItem *category = NULL;
+ TreeItem *category = nullptr;
Ref<Texture2D> type_icons[Variant::VARIANT_MAX] = {
- Control::get_icon("Variant", "EditorIcons"),
- Control::get_icon("bool", "EditorIcons"),
- Control::get_icon("int", "EditorIcons"),
- Control::get_icon("float", "EditorIcons"),
- Control::get_icon("String", "EditorIcons"),
- Control::get_icon("Vector2", "EditorIcons"),
- Control::get_icon("Rect2", "EditorIcons"),
- Control::get_icon("Vector3", "EditorIcons"),
- Control::get_icon("Transform2D", "EditorIcons"),
- Control::get_icon("Plane", "EditorIcons"),
- Control::get_icon("Quat", "EditorIcons"),
- Control::get_icon("AABB", "EditorIcons"),
- Control::get_icon("Basis", "EditorIcons"),
- Control::get_icon("Transform", "EditorIcons"),
- Control::get_icon("Color", "EditorIcons"),
- Control::get_icon("Path", "EditorIcons"),
- Control::get_icon("RID", "EditorIcons"),
- Control::get_icon("Object", "EditorIcons"),
- Control::get_icon("Dictionary", "EditorIcons"),
- Control::get_icon("Array", "EditorIcons"),
- Control::get_icon("PackedByteArray", "EditorIcons"),
- Control::get_icon("PackedInt32Array", "EditorIcons"),
- Control::get_icon("PackedFloat32Array", "EditorIcons"),
- Control::get_icon("PackedInt64Array", "EditorIcons"),
- Control::get_icon("PackedFloat64Array", "EditorIcons"),
- Control::get_icon("PackedStringArray", "EditorIcons"),
- Control::get_icon("PackedVector2Array", "EditorIcons"),
- Control::get_icon("PackedVector3Array", "EditorIcons"),
- Control::get_icon("PackedColorArray", "EditorIcons")
+ vbc->get_theme_icon("Variant", "EditorIcons"),
+ vbc->get_theme_icon("bool", "EditorIcons"),
+ vbc->get_theme_icon("int", "EditorIcons"),
+ vbc->get_theme_icon("float", "EditorIcons"),
+ vbc->get_theme_icon("String", "EditorIcons"),
+ vbc->get_theme_icon("Vector2", "EditorIcons"),
+ vbc->get_theme_icon("Rect2", "EditorIcons"),
+ vbc->get_theme_icon("Vector3", "EditorIcons"),
+ vbc->get_theme_icon("Transform2D", "EditorIcons"),
+ vbc->get_theme_icon("Plane", "EditorIcons"),
+ vbc->get_theme_icon("Quat", "EditorIcons"),
+ vbc->get_theme_icon("AABB", "EditorIcons"),
+ vbc->get_theme_icon("Basis", "EditorIcons"),
+ vbc->get_theme_icon("Transform", "EditorIcons"),
+ vbc->get_theme_icon("Color", "EditorIcons"),
+ vbc->get_theme_icon("Path", "EditorIcons"),
+ vbc->get_theme_icon("RID", "EditorIcons"),
+ vbc->get_theme_icon("Object", "EditorIcons"),
+ vbc->get_theme_icon("Dictionary", "EditorIcons"),
+ vbc->get_theme_icon("Array", "EditorIcons"),
+ vbc->get_theme_icon("PackedByteArray", "EditorIcons"),
+ vbc->get_theme_icon("PackedInt32Array", "EditorIcons"),
+ vbc->get_theme_icon("PackedFloat32Array", "EditorIcons"),
+ vbc->get_theme_icon("PackedInt64Array", "EditorIcons"),
+ vbc->get_theme_icon("PackedFloat64Array", "EditorIcons"),
+ vbc->get_theme_icon("PackedStringArray", "EditorIcons"),
+ vbc->get_theme_icon("PackedVector2Array", "EditorIcons"),
+ vbc->get_theme_icon("PackedVector3Array", "EditorIcons"),
+ vbc->get_theme_icon("PackedColorArray", "EditorIcons")
};
{
String b = String(E->get());
@@ -196,7 +196,7 @@ void VisualScriptPropertySelector::_update_search() {
if (type != Variant::NIL) {
Variant v;
Callable::CallError ce;
- v = Variant::construct(type, NULL, 0, ce);
+ v = Variant::construct(type, nullptr, 0, ce);
v.get_method_list(&methods);
} else {
@@ -252,7 +252,7 @@ void VisualScriptPropertySelector::_update_search() {
TreeItem *item = search_options->create_item(category ? category : root);
item->set_text(0, desc);
- item->set_icon(0, get_icon("MemberMethod", "EditorIcons"));
+ item->set_icon(0, vbc->get_theme_icon("MemberMethod", "EditorIcons"));
item->set_metadata(0, name);
item->set_selectable(0, true);
@@ -264,7 +264,7 @@ void VisualScriptPropertySelector::_update_search() {
item->set_metadata(2, connecting);
}
- if (category && category->get_children() == NULL) {
+ if (category && category->get_children() == nullptr) {
memdelete(category); //old category was unused
}
}
@@ -304,19 +304,19 @@ void VisualScriptPropertySelector::_update_search() {
}
TreeItem *selected_item = search_options->search_item_text(search_box->get_text());
- if (!found && selected_item != NULL) {
+ if (!found && selected_item != nullptr) {
selected_item->select(0);
found = true;
}
- get_ok()->set_disabled(root->get_children() == NULL);
+ get_ok()->set_disabled(root->get_children() == nullptr);
}
void VisualScriptPropertySelector::create_visualscript_item(const String &name, TreeItem *const root, const String &search_input, const String &text) {
if (search_input == String() || text.findn(search_input) != -1) {
TreeItem *item = search_options->create_item(root);
item->set_text(0, text);
- item->set_icon(0, get_icon("VisualScript", "EditorIcons"));
+ item->set_icon(0, vbc->get_theme_icon("VisualScript", "EditorIcons"));
item->set_metadata(0, name);
item->set_metadata(1, "action");
item->set_selectable(0, true);
@@ -399,7 +399,7 @@ void VisualScriptPropertySelector::get_visual_node_names(const String &root_filt
}
item->set_text(0, type_name + String("").join(desc));
- item->set_icon(0, get_icon("VisualScript", "EditorIcons"));
+ item->set_icon(0, vbc->get_theme_icon("VisualScript", "EditorIcons"));
item->set_selectable(0, true);
item->set_metadata(0, E->get());
item->set_selectable(0, true);
@@ -416,7 +416,7 @@ void VisualScriptPropertySelector::_confirmed() {
if (!ti)
return;
emit_signal("selected", ti->get_metadata(0), ti->get_metadata(1), ti->get_metadata(2));
- hide();
+ set_visible(false);
}
void VisualScriptPropertySelector::_item_selected() {
@@ -481,7 +481,7 @@ void VisualScriptPropertySelector::_item_selected() {
List<String> *names = memnew(List<String>);
VisualScriptLanguage::singleton->get_registered_node_names(names);
- if (names->find(name) != NULL) {
+ if (names->find(name) != nullptr) {
Ref<VisualScriptOperator> operator_node = VisualScriptLanguage::singleton->create_node_from_name(name);
if (operator_node.is_valid()) {
Map<String, DocData::ClassDoc>::Element *F = dd->class_list.find(operator_node->get_class_name());
@@ -519,7 +519,7 @@ void VisualScriptPropertySelector::_item_selected() {
}
void VisualScriptPropertySelector::_hide_requested() {
- _closed(); // From WindowDialog.
+ _cancel_pressed(); // From AcceptDialog.
}
void VisualScriptPropertySelector::_notification(int p_what) {
@@ -536,7 +536,7 @@ void VisualScriptPropertySelector::select_method_from_base_type(const String &p_
selected = p_current;
type = Variant::NIL;
properties = false;
- instance = NULL;
+ instance = nullptr;
virtuals_only = p_virtuals_only;
show_window(.5f);
@@ -561,7 +561,7 @@ void VisualScriptPropertySelector::select_from_base_type(const String &p_base, c
type = Variant::NIL;
properties = true;
visual_script_generic = false;
- instance = NULL;
+ instance = nullptr;
virtuals_only = p_virtuals_only;
show_window(.5f);
@@ -585,7 +585,7 @@ void VisualScriptPropertySelector::select_from_script(const Ref<Script> &p_scrip
script = p_script->get_instance_id();
properties = true;
visual_script_generic = false;
- instance = NULL;
+ instance = nullptr;
virtuals_only = false;
show_window(.5f);
@@ -607,7 +607,7 @@ void VisualScriptPropertySelector::select_from_basic_type(Variant::Type p_type,
type = p_type;
properties = true;
visual_script_generic = false;
- instance = NULL;
+ instance = nullptr;
virtuals_only = false;
show_window(.5f);
@@ -628,7 +628,7 @@ void VisualScriptPropertySelector::select_from_action(const String &p_type, cons
type = Variant::NIL;
properties = false;
visual_script_generic = false;
- instance = NULL;
+ instance = nullptr;
virtuals_only = false;
show_window(.5f);
@@ -670,7 +670,7 @@ void VisualScriptPropertySelector::select_from_visual_script(const String &p_bas
type = Variant::NIL;
properties = true;
visual_script_generic = true;
- instance = NULL;
+ instance = nullptr;
virtuals_only = false;
show_window(.5f);
if (clear_text)
@@ -684,12 +684,8 @@ void VisualScriptPropertySelector::select_from_visual_script(const String &p_bas
}
void VisualScriptPropertySelector::show_window(float p_screen_ratio) {
- Rect2 rect;
- Point2 window_size = get_viewport_rect().size;
- rect.size = (window_size * p_screen_ratio).floor();
- rect.size.x = rect.size.x / 2.2f;
- rect.position = ((window_size - rect.size) / 2.0f).floor();
- popup(rect);
+
+ popup_centered_ratio(p_screen_ratio);
}
void VisualScriptPropertySelector::_bind_methods() {
@@ -699,7 +695,7 @@ void VisualScriptPropertySelector::_bind_methods() {
VisualScriptPropertySelector::VisualScriptPropertySelector() {
- VBoxContainer *vbc = memnew(VBoxContainer);
+ vbc = memnew(VBoxContainer);
add_child(vbc);
//set_child_rect(vbc);
search_box = memnew(LineEdit);
diff --git a/modules/visual_script/visual_script_property_selector.h b/modules/visual_script/visual_script_property_selector.h
index f438ca1f5b..cc49b2863d 100644
--- a/modules/visual_script/visual_script_property_selector.h
+++ b/modules/visual_script/visual_script_property_selector.h
@@ -64,6 +64,7 @@ class VisualScriptPropertySelector : public ConfirmationDialog {
Object *instance;
bool virtuals_only;
bool seq_connect;
+ VBoxContainer *vbc;
Vector<Variant::Type> type_filter;
diff --git a/modules/visual_script/visual_script_yield_nodes.cpp b/modules/visual_script/visual_script_yield_nodes.cpp
index 858074742e..b300aec385 100644
--- a/modules/visual_script/visual_script_yield_nodes.cpp
+++ b/modules/visual_script/visual_script_yield_nodes.cpp
@@ -228,7 +228,7 @@ bool VisualScriptYieldSignal::has_input_sequence_port() const {
static Node *_find_script_node(Node *p_edited_scene, Node *p_current_node, const Ref<Script> &script) {
if (p_edited_scene != p_current_node && p_current_node->get_owner() != p_edited_scene)
- return NULL;
+ return nullptr;
Ref<Script> scr = p_current_node->get_script();
@@ -241,7 +241,7 @@ static Node *_find_script_node(Node *p_edited_scene, Node *p_current_node, const
return n;
}
- return NULL;
+ return nullptr;
}
#endif
@@ -250,33 +250,33 @@ Node *VisualScriptYieldSignal::_get_base_node() const {
#ifdef TOOLS_ENABLED
Ref<Script> script = get_visual_script();
if (!script.is_valid())
- return NULL;
+ return nullptr;
MainLoop *main_loop = OS::get_singleton()->get_main_loop();
SceneTree *scene_tree = Object::cast_to<SceneTree>(main_loop);
if (!scene_tree)
- return NULL;
+ return nullptr;
Node *edited_scene = scene_tree->get_edited_scene_root();
if (!edited_scene)
- return NULL;
+ return nullptr;
Node *script_node = _find_script_node(edited_scene, edited_scene, script);
if (!script_node)
- return NULL;
+ return nullptr;
if (!script_node->has_node(base_path))
- return NULL;
+ return nullptr;
Node *path_to = script_node->get_node(base_path);
return path_to;
#else
- return NULL;
+ return nullptr;
#endif
}
@@ -516,7 +516,7 @@ public:
} else {
//yield
- Object *object = NULL;
+ Object *object = nullptr;
switch (call_mode) {
diff --git a/modules/vorbis/SCsub b/modules/vorbis/SCsub
index bde4359595..05d46757d3 100644
--- a/modules/vorbis/SCsub
+++ b/modules/vorbis/SCsub
@@ -1,7 +1,7 @@
#!/usr/bin/env python
-Import('env')
-Import('env_modules')
+Import("env")
+Import("env_modules")
# Only kept to build the thirdparty library used by the theora and webm
# modules. We now use stb_vorbis for AudioStreamOGGVorbis.
@@ -11,11 +11,11 @@ env_vorbis = env_modules.Clone()
stub = True
# Thirdparty source files
-if env['builtin_libvorbis']:
+if env["builtin_libvorbis"]:
thirdparty_dir = "#thirdparty/libvorbis/"
thirdparty_sources = [
- #"analysis.c",
- #"barkmel.c",
+ # "analysis.c",
+ # "barkmel.c",
"bitrate.c",
"block.c",
"codebook.c",
@@ -29,14 +29,14 @@ if env['builtin_libvorbis']:
"mapping0.c",
"mdct.c",
"psy.c",
- #"psytune.c",
+ # "psytune.c",
"registry.c",
"res0.c",
"sharedbook.c",
"smallft.c",
"synthesis.c",
- #"tone.c",
- #"vorbisenc.c",
+ # "tone.c",
+ # "vorbisenc.c",
"vorbisfile.c",
"window.c",
]
@@ -46,7 +46,7 @@ if env['builtin_libvorbis']:
env_vorbis.Prepend(CPPPATH=[thirdparty_dir])
# also requires libogg
- if env['builtin_libogg']:
+ if env["builtin_libogg"]:
env_vorbis.Prepend(CPPPATH=["#thirdparty/libogg"])
env_thirdparty = env_vorbis.Clone()
diff --git a/modules/vorbis/config.py b/modules/vorbis/config.py
index 1c8cd12a2d..d22f9454ed 100644
--- a/modules/vorbis/config.py
+++ b/modules/vorbis/config.py
@@ -1,5 +1,6 @@
def can_build(env, platform):
return True
+
def configure(env):
pass
diff --git a/modules/webm/SCsub b/modules/webm/SCsub
index 32e6727656..247b4ead37 100644
--- a/modules/webm/SCsub
+++ b/modules/webm/SCsub
@@ -1,7 +1,7 @@
#!/usr/bin/env python
-Import('env')
-Import('env_modules')
+Import("env")
+Import("env_modules")
env_webm = env_modules.Clone()
@@ -18,14 +18,14 @@ thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
env_webm.Prepend(CPPPATH=[thirdparty_dir, thirdparty_dir + "libwebm/"])
# also requires libogg, libvorbis and libopus
-if env['builtin_libogg']:
+if env["builtin_libogg"]:
env_webm.Prepend(CPPPATH=["#thirdparty/libogg"])
-if env['builtin_libvorbis']:
+if env["builtin_libvorbis"]:
env_webm.Prepend(CPPPATH=["#thirdparty/libvorbis"])
-if env['builtin_opus']:
+if env["builtin_opus"]:
env_webm.Prepend(CPPPATH=["#thirdparty/opus"])
-if env['builtin_libvpx']:
+if env["builtin_libvpx"]:
env_webm.Prepend(CPPPATH=["#thirdparty/libvpx"])
SConscript("libvpx/SCsub")
diff --git a/modules/webm/config.py b/modules/webm/config.py
index ba4dcce2f5..93b49d177a 100644
--- a/modules/webm/config.py
+++ b/modules/webm/config.py
@@ -1,13 +1,16 @@
def can_build(env, platform):
- return platform not in ['iphone']
+ return platform not in ["iphone"]
+
def configure(env):
pass
+
def get_doc_classes():
return [
"VideoStreamWebm",
]
+
def get_doc_path():
return "doc_classes"
diff --git a/modules/webm/libvpx/SCsub b/modules/webm/libvpx/SCsub
index 14fa6c1268..dd6866ad0e 100644
--- a/modules/webm/libvpx/SCsub
+++ b/modules/webm/libvpx/SCsub
@@ -1,7 +1,7 @@
#!/usr/bin/env python
-Import('env')
-Import('env_modules')
+Import("env")
+Import("env_modules")
# Thirdparty sources
@@ -9,9 +9,7 @@ libvpx_dir = "#thirdparty/libvpx/"
libvpx_sources = [
"vp8/vp8_dx_iface.c",
-
"vp8/common/generic/systemdependent.c",
-
"vp8/common/alloccommon.c",
"vp8/common/blockd.c",
"vp8/common/copy_c.c",
@@ -37,16 +35,12 @@ libvpx_sources = [
"vp8/common/swapyv12buffer.c",
"vp8/common/treecoder.c",
"vp8/common/vp8_loopfilter.c",
-
"vp8/decoder/dboolhuff.c",
"vp8/decoder/decodeframe.c",
"vp8/decoder/decodemv.c",
"vp8/decoder/detokenize.c",
"vp8/decoder/onyxd_if.c",
-
-
"vp9/vp9_dx_iface.c",
-
"vp9/common/vp9_alloccommon.c",
"vp9/common/vp9_blockd.c",
"vp9/common/vp9_common_data.c",
@@ -69,21 +63,16 @@ libvpx_sources = [
"vp9/common/vp9_seg_common.c",
"vp9/common/vp9_thread_common.c",
"vp9/common/vp9_tile_common.c",
-
"vp9/decoder/vp9_decodeframe.c",
"vp9/decoder/vp9_decodemv.c",
"vp9/decoder/vp9_decoder.c",
"vp9/decoder/vp9_detokenize.c",
"vp9/decoder/vp9_dsubexp.c",
"vp9/decoder/vp9_dthread.c",
-
-
"vpx/src/vpx_codec.c",
"vpx/src/vpx_decoder.c",
"vpx/src/vpx_image.c",
"vpx/src/vpx_psnr.c",
-
-
"vpx_dsp/bitreader.c",
"vpx_dsp/bitreader_buffer.c",
"vpx_dsp/intrapred.c",
@@ -92,18 +81,11 @@ libvpx_sources = [
"vpx_dsp/prob.c",
"vpx_dsp/vpx_convolve.c",
"vpx_dsp/vpx_dsp_rtcd.c",
-
-
"vpx_mem/vpx_mem.c",
-
-
"vpx_scale/vpx_scale_rtcd.c",
-
"vpx_scale/generic/yv12config.c",
"vpx_scale/generic/yv12extend.c",
-
-
- "vpx_util/vpx_thread.c"
+ "vpx_util/vpx_thread.c",
]
libvpx_sources_mt = [
@@ -114,29 +96,23 @@ libvpx_sources_intrin_x86 = [
"vp8/common/x86/filter_x86.c",
"vp8/common/x86/loopfilter_x86.c",
"vp8/common/x86/vp8_asm_stubs.c",
-
-
- "vpx_dsp/x86/vpx_asm_stubs.c"
+ "vpx_dsp/x86/vpx_asm_stubs.c",
]
libvpx_sources_intrin_x86_mmx = [
"vp8/common/x86/idct_blk_mmx.c",
]
libvpx_sources_intrin_x86_sse2 = [
"vp8/common/x86/idct_blk_sse2.c",
-
-
"vp9/common/x86/vp9_idct_intrin_sse2.c",
-
-
"vpx_dsp/x86/inv_txfm_sse2.c",
"vpx_dsp/x86/loopfilter_sse2.c",
]
libvpx_sources_intrin_x86_ssse3 = [
- "vpx_dsp/x86/vpx_subpixel_8t_intrin_ssse3.c"
+ "vpx_dsp/x86/vpx_subpixel_8t_intrin_ssse3.c",
]
libvpx_sources_intrin_x86_avx2 = [
"vpx_dsp/x86/loopfilter_avx2.c",
- "vpx_dsp/x86/vpx_subpixel_8t_intrin_avx2.c"
+ "vpx_dsp/x86/vpx_subpixel_8t_intrin_avx2.c",
]
libvpx_sources_x86asm = [
"vp8/common/x86/copy_sse2.asm",
@@ -153,8 +129,6 @@ libvpx_sources_x86asm = [
"vp8/common/x86/subpixel_sse2.asm",
"vp8/common/x86/subpixel_ssse3.asm",
"vp8/common/x86/vp8_loopfilter_mmx.asm",
-
-
"vpx_dsp/x86/intrapred_sse2.asm",
"vpx_dsp/x86/intrapred_ssse3.asm",
"vpx_dsp/x86/inv_wht_sse2.asm",
@@ -163,21 +137,15 @@ libvpx_sources_x86asm = [
"vpx_dsp/x86/vpx_subpixel_8t_ssse3.asm",
"vpx_dsp/x86/vpx_subpixel_bilinear_sse2.asm",
"vpx_dsp/x86/vpx_subpixel_bilinear_ssse3.asm",
-
-
- "vpx_ports/emms.asm"
+ "vpx_ports/emms.asm",
]
libvpx_sources_x86_64asm = [
"vp8/common/x86/loopfilter_block_sse2_x86_64.asm",
-
-
- "vpx_dsp/x86/inv_txfm_ssse3_x86_64.asm"
+ "vpx_dsp/x86/inv_txfm_ssse3_x86_64.asm",
]
libvpx_sources_arm = [
"vpx_ports/arm_cpudetect.c",
-
-
"vp8/common/arm/loopfilter_arm.c",
]
libvpx_sources_arm_neon = [
@@ -196,12 +164,8 @@ libvpx_sources_arm_neon = [
"vp8/common/arm/neon/shortidct4x4llm_neon.c",
"vp8/common/arm/neon/sixtappredict_neon.c",
"vp8/common/arm/neon/vp8_loopfilter_neon.c",
-
-
"vp9/common/arm/neon/vp9_iht4x4_add_neon.c",
"vp9/common/arm/neon/vp9_iht8x8_add_neon.c",
-
-
"vpx_dsp/arm/idct16x16_1_add_neon.c",
"vpx_dsp/arm/idct16x16_add_neon.c",
"vpx_dsp/arm/idct16x16_neon.c",
@@ -220,22 +184,22 @@ libvpx_sources_arm_neon = [
"vpx_dsp/arm/vpx_convolve8_neon.c",
"vpx_dsp/arm/vpx_convolve_avg_neon.c",
"vpx_dsp/arm/vpx_convolve_copy_neon.c",
- "vpx_dsp/arm/vpx_convolve_neon.c"
+ "vpx_dsp/arm/vpx_convolve_neon.c",
]
libvpx_sources_arm_neon_gas = [
"vpx_dsp/arm/gas/intrapred_neon_asm.s",
"vpx_dsp/arm/gas/loopfilter_mb_neon.s",
- "vpx_dsp/arm/gas/save_reg_neon.s"
+ "vpx_dsp/arm/gas/save_reg_neon.s",
]
libvpx_sources_arm_neon_armasm_ms = [
"vpx_dsp/arm/armasm_ms/intrapred_neon_asm.asm",
"vpx_dsp/arm/armasm_ms/loopfilter_mb_neon.asm",
- "vpx_dsp/arm/armasm_ms/save_reg_neon.asm"
+ "vpx_dsp/arm/armasm_ms/save_reg_neon.asm",
]
libvpx_sources_arm_neon_gas_apple = [
"vpx_dsp/arm/gas_apple/intrapred_neon_asm.s",
"vpx_dsp/arm/gas_apple/loopfilter_mb_neon.s",
- "vpx_dsp/arm/gas_apple/save_reg_neon.s"
+ "vpx_dsp/arm/gas_apple/save_reg_neon.s",
]
libvpx_sources = [libvpx_dir + file for file in libvpx_sources]
@@ -258,25 +222,43 @@ env_libvpx = env_modules.Clone()
env_libvpx.disable_warnings()
env_libvpx.Prepend(CPPPATH=[libvpx_dir])
-webm_multithread = env["platform"] != 'javascript'
+webm_multithread = env["platform"] != "javascript"
cpu_bits = env["bits"]
webm_cpu_x86 = False
webm_cpu_arm = False
-if env["platform"] == 'uwp':
- if 'arm' in env["PROGSUFFIX"]:
+if env["platform"] == "uwp":
+ if "arm" in env["PROGSUFFIX"]:
webm_cpu_arm = True
else:
webm_cpu_x86 = True
else:
import platform
- is_x11_or_server_arm = ((env["platform"] == 'x11' or env["platform"] == 'server') and (platform.machine().startswith('arm') or platform.machine().startswith('aarch')))
- is_ios_x86 = (env["platform"] == 'iphone' and ("arch" in env and env["arch"].startswith('x86')))
- is_android_x86 = (env["platform"] == 'android' and env["android_arch"].startswith('x86'))
+
+ is_x11_or_server_arm = (env["platform"] == "linuxbsd" or env["platform"] == "server") and (
+ platform.machine().startswith("arm") or platform.machine().startswith("aarch")
+ )
+ is_ios_x86 = env["platform"] == "iphone" and ("arch" in env and env["arch"].startswith("x86"))
+ is_android_x86 = env["platform"] == "android" and env["android_arch"].startswith("x86")
if is_android_x86:
- cpu_bits = '32' if env["android_arch"] == 'x86' else '64'
- webm_cpu_x86 = not is_x11_or_server_arm and (cpu_bits == '32' or cpu_bits == '64') and (env["platform"] == 'windows' or env["platform"] == 'x11' or env["platform"] == 'osx' or env["platform"] == 'haiku' or is_android_x86 or is_ios_x86)
- webm_cpu_arm = is_x11_or_server_arm or (not is_ios_x86 and env["platform"] == 'iphone') or (not is_android_x86 and env["platform"] == 'android')
+ cpu_bits = "32" if env["android_arch"] == "x86" else "64"
+ webm_cpu_x86 = (
+ not is_x11_or_server_arm
+ and (cpu_bits == "32" or cpu_bits == "64")
+ and (
+ env["platform"] == "windows"
+ or env["platform"] == "linuxbsd"
+ or env["platform"] == "osx"
+ or env["platform"] == "haiku"
+ or is_android_x86
+ or is_ios_x86
+ )
+ )
+ webm_cpu_arm = (
+ is_x11_or_server_arm
+ or (not is_ios_x86 and env["platform"] == "iphone")
+ or (not is_android_x86 and env["platform"] == "android")
+ )
if webm_cpu_x86:
import subprocess
@@ -306,38 +288,43 @@ if webm_cpu_x86:
webm_simd_optimizations = False
if webm_cpu_x86:
- if env["platform"] == 'windows' or env["platform"] == 'uwp':
- env_libvpx["ASFORMAT"] = 'win'
- elif env["platform"] == 'osx' or env["platform"] == "iphone":
- env_libvpx["ASFORMAT"] = 'macho'
+ if env["platform"] == "windows" or env["platform"] == "uwp":
+ env_libvpx["ASFORMAT"] = "win"
+ elif env["platform"] == "osx" or env["platform"] == "iphone":
+ env_libvpx["ASFORMAT"] = "macho"
else:
- env_libvpx["ASFORMAT"] = 'elf'
+ env_libvpx["ASFORMAT"] = "elf"
env_libvpx["ASFORMAT"] += cpu_bits
- env_libvpx["AS"] = 'yasm'
- env_libvpx["ASFLAGS"] = '-I' + libvpx_dir[1:] + ' -f $ASFORMAT -D $ASCPU'
- env_libvpx["ASCOM"] = '$AS $ASFLAGS -o $TARGET $SOURCES'
+ env_libvpx["AS"] = "yasm"
+ env_libvpx["ASFLAGS"] = "-I" + libvpx_dir[1:] + " -f $ASFORMAT -D $ASCPU"
+ env_libvpx["ASCOM"] = "$AS $ASFLAGS -o $TARGET $SOURCES"
- if cpu_bits == '32':
- env_libvpx["ASCPU"] = 'X86_32'
- elif cpu_bits == '64':
- env_libvpx["ASCPU"] = 'X86_64'
+ if cpu_bits == "32":
+ env_libvpx["ASCPU"] = "X86_32"
+ elif cpu_bits == "64":
+ env_libvpx["ASCPU"] = "X86_64"
- env_libvpx.Append(CPPDEFINES=['WEBM_X86ASM'])
+ env_libvpx.Append(CPPDEFINES=["WEBM_X86ASM"])
webm_simd_optimizations = True
if webm_cpu_arm:
- if env["platform"] == 'iphone':
- env_libvpx["ASFLAGS"] = '-arch armv7'
- elif env["platform"] == 'android' and env["android_arch"] == 'armv7' or env["platform"] == 'x11' or env["platform"] == 'server':
- env_libvpx["ASFLAGS"] = '-mfpu=neon'
- elif env["platform"] == 'uwp':
- env_libvpx["AS"] = 'armasm'
- env_libvpx["ASFLAGS"] = ''
- env_libvpx["ASCOM"] = '$AS $ASFLAGS -o $TARGET $SOURCES'
-
- env_libvpx.Append(CPPDEFINES=['WEBM_ARMASM'])
+ if env["platform"] == "iphone":
+ env_libvpx["ASFLAGS"] = "-arch armv7"
+ elif (
+ env["platform"] == "android"
+ and env["android_arch"] == "armv7"
+ or env["platform"] == "linuxbsd"
+ or env["platform"] == "server"
+ ):
+ env_libvpx["ASFLAGS"] = "-mfpu=neon"
+ elif env["platform"] == "uwp":
+ env_libvpx["AS"] = "armasm"
+ env_libvpx["ASFLAGS"] = ""
+ env_libvpx["ASCOM"] = "$AS $ASFLAGS -o $TARGET $SOURCES"
+
+ env_libvpx.Append(CPPDEFINES=["WEBM_ARMASM"])
webm_simd_optimizations = True
@@ -350,45 +337,49 @@ if webm_multithread:
env_libvpx.add_source_files(env.modules_sources, libvpx_sources_mt)
if webm_cpu_x86:
- is_clang_or_gcc = ('gcc' in os.path.basename(env["CC"])) or ('clang' in os.path.basename(env["CC"])) or ("osxcross" in env)
+ is_clang_or_gcc = (
+ ("gcc" in os.path.basename(env["CC"])) or ("clang" in os.path.basename(env["CC"])) or ("osxcross" in env)
+ )
env_libvpx_mmx = env_libvpx.Clone()
- if cpu_bits == '32' and is_clang_or_gcc:
- env_libvpx_mmx.Append(CCFLAGS=['-mmmx'])
+ if cpu_bits == "32" and is_clang_or_gcc:
+ env_libvpx_mmx.Append(CCFLAGS=["-mmmx"])
env_libvpx_mmx.add_source_files(env.modules_sources, libvpx_sources_intrin_x86_mmx)
env_libvpx_sse2 = env_libvpx.Clone()
- if cpu_bits == '32' and is_clang_or_gcc:
- env_libvpx_sse2.Append(CCFLAGS=['-msse2'])
+ if cpu_bits == "32" and is_clang_or_gcc:
+ env_libvpx_sse2.Append(CCFLAGS=["-msse2"])
env_libvpx_sse2.add_source_files(env.modules_sources, libvpx_sources_intrin_x86_sse2)
env_libvpx_ssse3 = env_libvpx.Clone()
if is_clang_or_gcc:
- env_libvpx_ssse3.Append(CCFLAGS=['-mssse3'])
+ env_libvpx_ssse3.Append(CCFLAGS=["-mssse3"])
env_libvpx_ssse3.add_source_files(env.modules_sources, libvpx_sources_intrin_x86_ssse3)
env_libvpx_avx2 = env_libvpx.Clone()
if is_clang_or_gcc:
- env_libvpx_avx2.Append(CCFLAGS=['-mavx2'])
+ env_libvpx_avx2.Append(CCFLAGS=["-mavx2"])
env_libvpx_avx2.add_source_files(env.modules_sources, libvpx_sources_intrin_x86_avx2)
env_libvpx.add_source_files(env.modules_sources, libvpx_sources_intrin_x86)
env_libvpx.add_source_files(env.modules_sources, libvpx_sources_x86asm)
- if cpu_bits == '64':
+ if cpu_bits == "64":
env_libvpx.add_source_files(env.modules_sources, libvpx_sources_x86_64asm)
elif webm_cpu_arm:
env_libvpx.add_source_files(env.modules_sources, libvpx_sources_arm)
- if env["platform"] == 'android':
+ if env["platform"] == "android":
env_libvpx.Prepend(CPPPATH=[libvpx_dir + "third_party/android"])
env_libvpx.add_source_files(env.modules_sources, [libvpx_dir + "third_party/android/cpu-features.c"])
env_libvpx_neon = env_libvpx.Clone()
env_libvpx_neon.add_source_files(env.modules_sources, libvpx_sources_arm_neon)
- if env["platform"] == 'uwp':
+ if env["platform"] == "uwp":
env_libvpx.add_source_files(env.modules_sources, libvpx_sources_arm_neon_armasm_ms)
- elif env["platform"] == 'iphone':
+ elif env["platform"] == "iphone":
env_libvpx.add_source_files(env.modules_sources, libvpx_sources_arm_neon_gas_apple)
- elif (is_x11_or_server_arm and cpu_bits == '32') or (env["platform"] == 'android' and not env["android_arch"] == 'arm64v8'):
+ elif (is_x11_or_server_arm and cpu_bits == "32") or (
+ env["platform"] == "android" and not env["android_arch"] == "arm64v8"
+ ):
env_libvpx.add_source_files(env.modules_sources, libvpx_sources_arm_neon_gas)
diff --git a/modules/webm/video_stream_webm.cpp b/modules/webm/video_stream_webm.cpp
index 265383831e..a2d0f78f5f 100644
--- a/modules/webm/video_stream_webm.cpp
+++ b/modules/webm/video_stream_webm.cpp
@@ -96,17 +96,17 @@ private:
VideoStreamPlaybackWebm::VideoStreamPlaybackWebm() :
audio_track(0),
- webm(NULL),
- video(NULL),
- audio(NULL),
- video_frames(NULL),
- audio_frame(NULL),
+ webm(nullptr),
+ video(nullptr),
+ audio(nullptr),
+ video_frames(nullptr),
+ audio_frame(nullptr),
video_frames_pos(0),
video_frames_capacity(0),
num_decoded_samples(0),
samples_offset(-1),
- mix_callback(NULL),
- mix_udata(NULL),
+ mix_callback(nullptr),
+ mix_udata(nullptr),
playing(false),
paused(false),
delay_compensation(0.0),
@@ -114,7 +114,7 @@ VideoStreamPlaybackWebm::VideoStreamPlaybackWebm() :
video_frame_delay(0.0),
video_pos(0.0),
texture(memnew(ImageTexture)),
- pcm(NULL) {}
+ pcm(nullptr) {}
VideoStreamPlaybackWebm::~VideoStreamPlaybackWebm() {
delete_pointers();
@@ -137,7 +137,7 @@ bool VideoStreamPlaybackWebm::open_file(const String &p_file) {
} else {
memdelete(audio);
- audio = NULL;
+ audio = nullptr;
}
frame_data.resize((webm->getWidth() * webm->getHeight()) << 2);
@@ -149,10 +149,10 @@ bool VideoStreamPlaybackWebm::open_file(const String &p_file) {
return true;
}
memdelete(video);
- video = NULL;
+ video = nullptr;
}
memdelete(webm);
- webm = NULL;
+ webm = nullptr;
return false;
}
@@ -162,13 +162,13 @@ void VideoStreamPlaybackWebm::stop() {
delete_pointers();
- pcm = NULL;
+ pcm = nullptr;
- audio_frame = NULL;
- video_frames = NULL;
+ audio_frame = nullptr;
+ video_frames = nullptr;
- video = NULL;
- audio = NULL;
+ video = nullptr;
+ audio = nullptr;
open_file(file_name); //Should not fail here...
@@ -447,7 +447,7 @@ Ref<VideoStreamPlayback> VideoStreamWebm::instance_playback() {
pb->set_audio_track(audio_track);
if (pb->open_file(file))
return pb;
- return NULL;
+ return nullptr;
}
void VideoStreamWebm::set_file(const String &p_file) {
@@ -474,7 +474,7 @@ void VideoStreamWebm::set_audio_track(int p_track) {
////////////
-RES ResourceFormatLoaderWebm::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress) {
+RES ResourceFormatLoaderWebm::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, bool p_no_cache) {
FileAccess *f = FileAccess::open(p_path, FileAccess::READ);
if (!f) {
diff --git a/modules/webm/video_stream_webm.h b/modules/webm/video_stream_webm.h
index 3feaa1278f..6677fb85aa 100644
--- a/modules/webm/video_stream_webm.h
+++ b/modules/webm/video_stream_webm.h
@@ -128,7 +128,7 @@ public:
class ResourceFormatLoaderWebm : public ResourceFormatLoader {
public:
- virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL, bool p_use_sub_threads = false, float *r_progress = nullptr);
+ virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr, bool p_no_cache = false);
virtual void get_recognized_extensions(List<String> *p_extensions) const;
virtual bool handles_type(const String &p_type) const;
virtual String get_resource_type(const String &p_path) const;
diff --git a/modules/webp/SCsub b/modules/webp/SCsub
index 666628bb44..58f2bb35e6 100644
--- a/modules/webp/SCsub
+++ b/modules/webp/SCsub
@@ -1,12 +1,12 @@
#!/usr/bin/env python
-Import('env')
-Import('env_modules')
+Import("env")
+Import("env_modules")
env_webp = env_modules.Clone()
# Thirdparty source files
-if env['builtin_libwebp']:
+if env["builtin_libwebp"]:
thirdparty_dir = "#thirdparty/libwebp/"
thirdparty_sources = [
"dec/alpha_dec.c",
diff --git a/modules/webp/config.py b/modules/webp/config.py
index 1c8cd12a2d..d22f9454ed 100644
--- a/modules/webp/config.py
+++ b/modules/webp/config.py
@@ -1,5 +1,6 @@
def can_build(env, platform):
return True
+
def configure(env):
pass
diff --git a/modules/webp/image_loader_webp.cpp b/modules/webp/image_loader_webp.cpp
index 09a8985472..0998977bb4 100644
--- a/modules/webp/image_loader_webp.cpp
+++ b/modules/webp/image_loader_webp.cpp
@@ -52,7 +52,7 @@ static Vector<uint8_t> _webp_lossy_pack(const Ref<Image> &p_image, float p_quali
Vector<uint8_t> data = img->get_data();
const uint8_t *r = data.ptr();
- uint8_t *dst_buff = NULL;
+ uint8_t *dst_buff = nullptr;
size_t dst_size = 0;
if (img->get_format() == Image::FORMAT_RGB8) {
@@ -101,9 +101,9 @@ static Ref<Image> _webp_lossy_unpack(const Vector<uint8_t> &p_buffer) {
bool errdec = false;
if (features.has_alpha) {
- errdec = WebPDecodeRGBAInto(&r[4], size, dst_w, datasize, 4 * features.width) == NULL;
+ errdec = WebPDecodeRGBAInto(&r[4], size, dst_w, datasize, 4 * features.width) == nullptr;
} else {
- errdec = WebPDecodeRGBInto(&r[4], size, dst_w, datasize, 3 * features.width) == NULL;
+ errdec = WebPDecodeRGBInto(&r[4], size, dst_w, datasize, 3 * features.width) == nullptr;
}
ERR_FAIL_COND_V_MSG(errdec, Ref<Image>(), "Failed decoding WebP image.");
@@ -128,9 +128,9 @@ Error webp_load_image_from_buffer(Image *p_image, const uint8_t *p_buffer, int p
bool errdec = false;
if (features.has_alpha) {
- errdec = WebPDecodeRGBAInto(p_buffer, p_buffer_len, dst_w, datasize, 4 * features.width) == NULL;
+ errdec = WebPDecodeRGBAInto(p_buffer, p_buffer_len, dst_w, datasize, 4 * features.width) == nullptr;
} else {
- errdec = WebPDecodeRGBInto(p_buffer, p_buffer_len, dst_w, datasize, 3 * features.width) == NULL;
+ errdec = WebPDecodeRGBInto(p_buffer, p_buffer_len, dst_w, datasize, 3 * features.width) == nullptr;
}
ERR_FAIL_COND_V_MSG(errdec, ERR_FILE_CORRUPT, "Failed decoding WebP image.");
diff --git a/modules/webp/register_types.cpp b/modules/webp/register_types.cpp
index 12a0c05f44..fe945b01d4 100644
--- a/modules/webp/register_types.cpp
+++ b/modules/webp/register_types.cpp
@@ -32,7 +32,7 @@
#include "image_loader_webp.h"
-static ImageLoaderWEBP *image_loader_webp = NULL;
+static ImageLoaderWEBP *image_loader_webp = nullptr;
void register_webp_types() {
diff --git a/modules/webrtc/SCsub b/modules/webrtc/SCsub
index 868553b879..20b4c8f8d2 100644
--- a/modules/webrtc/SCsub
+++ b/modules/webrtc/SCsub
@@ -1,15 +1,15 @@
#!/usr/bin/env python
-Import('env')
-Import('env_modules')
+Import("env")
+Import("env_modules")
# Thirdparty source files
env_webrtc = env_modules.Clone()
use_gdnative = env_webrtc["module_gdnative_enabled"]
-if use_gdnative: # GDNative is retained in Javascript for export compatibility
- env_webrtc.Append(CPPDEFINES=['WEBRTC_GDNATIVE_ENABLED'])
+if use_gdnative: # GDNative is retained in Javascript for export compatibility
+ env_webrtc.Append(CPPDEFINES=["WEBRTC_GDNATIVE_ENABLED"])
env_webrtc.Prepend(CPPPATH=["#modules/gdnative/include/"])
env_webrtc.add_source_files(env.modules_sources, "*.cpp")
diff --git a/modules/webrtc/config.py b/modules/webrtc/config.py
index 48b4c33c5d..0a075ccef1 100644
--- a/modules/webrtc/config.py
+++ b/modules/webrtc/config.py
@@ -1,15 +1,18 @@
def can_build(env, platform):
return True
+
def configure(env):
pass
+
def get_doc_classes():
return [
"WebRTCPeerConnection",
"WebRTCDataChannel",
- "WebRTCMultiplayer"
+ "WebRTCMultiplayer",
]
+
def get_doc_path():
return "doc_classes"
diff --git a/modules/webrtc/webrtc_data_channel_gdnative.cpp b/modules/webrtc/webrtc_data_channel_gdnative.cpp
index b0c4b473fc..67ad2c07ce 100644
--- a/modules/webrtc/webrtc_data_channel_gdnative.cpp
+++ b/modules/webrtc/webrtc_data_channel_gdnative.cpp
@@ -39,94 +39,94 @@ void WebRTCDataChannelGDNative::_bind_methods() {
}
WebRTCDataChannelGDNative::WebRTCDataChannelGDNative() {
- interface = NULL;
+ interface = nullptr;
}
WebRTCDataChannelGDNative::~WebRTCDataChannelGDNative() {
}
Error WebRTCDataChannelGDNative::poll() {
- ERR_FAIL_COND_V(interface == NULL, ERR_UNCONFIGURED);
+ ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED);
return (Error)interface->poll(interface->data);
}
void WebRTCDataChannelGDNative::close() {
- ERR_FAIL_COND(interface == NULL);
+ ERR_FAIL_COND(interface == nullptr);
interface->close(interface->data);
}
void WebRTCDataChannelGDNative::set_write_mode(WriteMode p_mode) {
- ERR_FAIL_COND(interface == NULL);
+ ERR_FAIL_COND(interface == nullptr);
interface->set_write_mode(interface->data, p_mode);
}
WebRTCDataChannel::WriteMode WebRTCDataChannelGDNative::get_write_mode() const {
- ERR_FAIL_COND_V(interface == NULL, WRITE_MODE_BINARY);
+ ERR_FAIL_COND_V(interface == nullptr, WRITE_MODE_BINARY);
return (WriteMode)interface->get_write_mode(interface->data);
}
bool WebRTCDataChannelGDNative::was_string_packet() const {
- ERR_FAIL_COND_V(interface == NULL, false);
+ ERR_FAIL_COND_V(interface == nullptr, false);
return interface->was_string_packet(interface->data);
}
WebRTCDataChannel::ChannelState WebRTCDataChannelGDNative::get_ready_state() const {
- ERR_FAIL_COND_V(interface == NULL, STATE_CLOSED);
+ ERR_FAIL_COND_V(interface == nullptr, STATE_CLOSED);
return (ChannelState)interface->get_ready_state(interface->data);
}
String WebRTCDataChannelGDNative::get_label() const {
- ERR_FAIL_COND_V(interface == NULL, "");
+ ERR_FAIL_COND_V(interface == nullptr, "");
return String(interface->get_label(interface->data));
}
bool WebRTCDataChannelGDNative::is_ordered() const {
- ERR_FAIL_COND_V(interface == NULL, false);
+ ERR_FAIL_COND_V(interface == nullptr, false);
return interface->is_ordered(interface->data);
}
int WebRTCDataChannelGDNative::get_id() const {
- ERR_FAIL_COND_V(interface == NULL, -1);
+ ERR_FAIL_COND_V(interface == nullptr, -1);
return interface->get_id(interface->data);
}
int WebRTCDataChannelGDNative::get_max_packet_life_time() const {
- ERR_FAIL_COND_V(interface == NULL, -1);
+ ERR_FAIL_COND_V(interface == nullptr, -1);
return interface->get_max_packet_life_time(interface->data);
}
int WebRTCDataChannelGDNative::get_max_retransmits() const {
- ERR_FAIL_COND_V(interface == NULL, -1);
+ ERR_FAIL_COND_V(interface == nullptr, -1);
return interface->get_max_retransmits(interface->data);
}
String WebRTCDataChannelGDNative::get_protocol() const {
- ERR_FAIL_COND_V(interface == NULL, "");
+ ERR_FAIL_COND_V(interface == nullptr, "");
return String(interface->get_protocol(interface->data));
}
bool WebRTCDataChannelGDNative::is_negotiated() const {
- ERR_FAIL_COND_V(interface == NULL, false);
+ ERR_FAIL_COND_V(interface == nullptr, false);
return interface->is_negotiated(interface->data);
}
Error WebRTCDataChannelGDNative::get_packet(const uint8_t **r_buffer, int &r_buffer_size) {
- ERR_FAIL_COND_V(interface == NULL, ERR_UNCONFIGURED);
+ ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED);
return (Error)interface->get_packet(interface->data, r_buffer, &r_buffer_size);
}
Error WebRTCDataChannelGDNative::put_packet(const uint8_t *p_buffer, int p_buffer_size) {
- ERR_FAIL_COND_V(interface == NULL, ERR_UNCONFIGURED);
+ ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED);
return (Error)interface->put_packet(interface->data, p_buffer, p_buffer_size);
}
int WebRTCDataChannelGDNative::get_max_packet_size() const {
- ERR_FAIL_COND_V(interface == NULL, 0);
+ ERR_FAIL_COND_V(interface == nullptr, 0);
return interface->get_max_packet_size(interface->data);
}
int WebRTCDataChannelGDNative::get_available_packet_count() const {
- ERR_FAIL_COND_V(interface == NULL, 0);
+ ERR_FAIL_COND_V(interface == nullptr, 0);
return interface->get_available_packet_count(interface->data);
}
diff --git a/modules/webrtc/webrtc_data_channel_js.cpp b/modules/webrtc/webrtc_data_channel_js.cpp
index 37203a4ec9..1b360720a2 100644
--- a/modules/webrtc/webrtc_data_channel_js.cpp
+++ b/modules/webrtc/webrtc_data_channel_js.cpp
@@ -334,7 +334,7 @@ WebRTCDataChannelJS::WebRTCDataChannelJS(int js_id) {
stringToUTF8(str, ptr, len+1);
return ptr;
}, js_id);
- if(str != NULL) {
+ if(str != nullptr) {
_label.parse_utf8(str);
EM_ASM({ _free($0) }, str);
}
@@ -347,7 +347,7 @@ WebRTCDataChannelJS::WebRTCDataChannelJS(int js_id) {
stringToUTF8(str, ptr, len+1);
return ptr;
}, js_id);
- if(str != NULL) {
+ if(str != nullptr) {
_protocol.parse_utf8(str);
EM_ASM({ _free($0) }, str);
}
diff --git a/modules/webrtc/webrtc_multiplayer.cpp b/modules/webrtc/webrtc_multiplayer.cpp
index c24ae3468f..78a4d1e61a 100644
--- a/modules/webrtc/webrtc_multiplayer.cpp
+++ b/modules/webrtc/webrtc_multiplayer.cpp
@@ -316,7 +316,7 @@ Error WebRTCMultiplayer::put_packet(const uint8_t *p_buffer, int p_buffer_size)
break;
}
- Map<int, Ref<ConnectedPeer>>::Element *E = NULL;
+ Map<int, Ref<ConnectedPeer>>::Element *E = nullptr;
if (target_peer > 0) {
@@ -371,6 +371,7 @@ WebRTCMultiplayer::WebRTCMultiplayer() {
unique_id = 0;
next_packet_peer = 0;
target_peer = 0;
+ client_count = 0;
transfer_mode = TRANSFER_MODE_RELIABLE;
refuse_connections = false;
connection_status = CONNECTION_DISCONNECTED;
diff --git a/modules/webrtc/webrtc_peer_connection.cpp b/modules/webrtc/webrtc_peer_connection.cpp
index 90c62e2495..399e4f09ff 100644
--- a/modules/webrtc/webrtc_peer_connection.cpp
+++ b/modules/webrtc/webrtc_peer_connection.cpp
@@ -30,7 +30,7 @@
#include "webrtc_peer_connection.h"
-WebRTCPeerConnection *(*WebRTCPeerConnection::_create)() = NULL;
+WebRTCPeerConnection *(*WebRTCPeerConnection::_create)() = nullptr;
Ref<WebRTCPeerConnection> WebRTCPeerConnection::create_ref() {
@@ -40,7 +40,7 @@ Ref<WebRTCPeerConnection> WebRTCPeerConnection::create_ref() {
WebRTCPeerConnection *WebRTCPeerConnection::create() {
if (!_create)
- return NULL;
+ return nullptr;
return _create();
}
diff --git a/modules/webrtc/webrtc_peer_connection_gdnative.cpp b/modules/webrtc/webrtc_peer_connection_gdnative.cpp
index 411ad50275..f082646629 100644
--- a/modules/webrtc/webrtc_peer_connection_gdnative.cpp
+++ b/modules/webrtc/webrtc_peer_connection_gdnative.cpp
@@ -36,12 +36,12 @@
#include "modules/gdnative/nativescript/nativescript.h"
#include "webrtc_data_channel_gdnative.h"
-const godot_net_webrtc_library *WebRTCPeerConnectionGDNative::default_library = NULL;
+const godot_net_webrtc_library *WebRTCPeerConnectionGDNative::default_library = nullptr;
Error WebRTCPeerConnectionGDNative::set_default_library(const godot_net_webrtc_library *p_lib) {
if (default_library) {
const godot_net_webrtc_library *old = default_library;
- default_library = NULL;
+ default_library = nullptr;
old->unregistered();
}
default_library = p_lib;
@@ -64,54 +64,54 @@ void WebRTCPeerConnectionGDNative::_bind_methods() {
}
WebRTCPeerConnectionGDNative::WebRTCPeerConnectionGDNative() {
- interface = NULL;
+ interface = nullptr;
}
WebRTCPeerConnectionGDNative::~WebRTCPeerConnectionGDNative() {
}
Error WebRTCPeerConnectionGDNative::initialize(Dictionary p_config) {
- ERR_FAIL_COND_V(interface == NULL, ERR_UNCONFIGURED);
+ ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED);
return (Error)interface->initialize(interface->data, (const godot_dictionary *)&p_config);
}
Ref<WebRTCDataChannel> WebRTCPeerConnectionGDNative::create_data_channel(String p_label, Dictionary p_options) {
- ERR_FAIL_COND_V(interface == NULL, NULL);
+ ERR_FAIL_COND_V(interface == nullptr, nullptr);
return (WebRTCDataChannel *)interface->create_data_channel(interface->data, p_label.utf8().get_data(), (const godot_dictionary *)&p_options);
}
Error WebRTCPeerConnectionGDNative::create_offer() {
- ERR_FAIL_COND_V(interface == NULL, ERR_UNCONFIGURED);
+ ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED);
return (Error)interface->create_offer(interface->data);
}
Error WebRTCPeerConnectionGDNative::set_local_description(String p_type, String p_sdp) {
- ERR_FAIL_COND_V(interface == NULL, ERR_UNCONFIGURED);
+ ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED);
return (Error)interface->set_local_description(interface->data, p_type.utf8().get_data(), p_sdp.utf8().get_data());
}
Error WebRTCPeerConnectionGDNative::set_remote_description(String p_type, String p_sdp) {
- ERR_FAIL_COND_V(interface == NULL, ERR_UNCONFIGURED);
+ ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED);
return (Error)interface->set_remote_description(interface->data, p_type.utf8().get_data(), p_sdp.utf8().get_data());
}
Error WebRTCPeerConnectionGDNative::add_ice_candidate(String sdpMidName, int sdpMlineIndexName, String sdpName) {
- ERR_FAIL_COND_V(interface == NULL, ERR_UNCONFIGURED);
+ ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED);
return (Error)interface->add_ice_candidate(interface->data, sdpMidName.utf8().get_data(), sdpMlineIndexName, sdpName.utf8().get_data());
}
Error WebRTCPeerConnectionGDNative::poll() {
- ERR_FAIL_COND_V(interface == NULL, ERR_UNCONFIGURED);
+ ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED);
return (Error)interface->poll(interface->data);
}
void WebRTCPeerConnectionGDNative::close() {
- ERR_FAIL_COND(interface == NULL);
+ ERR_FAIL_COND(interface == nullptr);
interface->close(interface->data);
}
WebRTCPeerConnection::ConnectionState WebRTCPeerConnectionGDNative::get_connection_state() const {
- ERR_FAIL_COND_V(interface == NULL, STATE_DISCONNECTED);
+ ERR_FAIL_COND_V(interface == nullptr, STATE_DISCONNECTED);
return (ConnectionState)interface->get_connection_state(interface->data);
}
diff --git a/modules/webrtc/webrtc_peer_connection_js.cpp b/modules/webrtc/webrtc_peer_connection_js.cpp
index a84dabab72..593c3a5162 100644
--- a/modules/webrtc/webrtc_peer_connection_js.cpp
+++ b/modules/webrtc/webrtc_peer_connection_js.cpp
@@ -279,7 +279,7 @@ Ref<WebRTCDataChannel> WebRTCPeerConnectionJS::create_data_channel(String p_chan
}
}, _js_id, p_channel.utf8().get_data(), config.utf8().get_data());
/* clang-format on */
- ERR_FAIL_COND_V(id == 0, NULL);
+ ERR_FAIL_COND_V(id == 0, nullptr);
return memnew(WebRTCDataChannelJS(id));
}
diff --git a/modules/websocket/SCsub b/modules/websocket/SCsub
index 033169411f..af60055855 100644
--- a/modules/websocket/SCsub
+++ b/modules/websocket/SCsub
@@ -1,13 +1,13 @@
#!/usr/bin/env python
-Import('env')
-Import('env_modules')
+Import("env")
+Import("env_modules")
# Thirdparty source files
env_ws = env_modules.Clone()
-if env['builtin_wslay'] and not env["platform"] == "javascript": # already builtin for javascript
+if env["builtin_wslay"] and not env["platform"] == "javascript": # already builtin for javascript
wslay_dir = "#thirdparty/wslay/"
wslay_sources = [
"wslay_net.c",
diff --git a/modules/websocket/config.py b/modules/websocket/config.py
index f59ef432b4..9e27a1a0fe 100644
--- a/modules/websocket/config.py
+++ b/modules/websocket/config.py
@@ -1,16 +1,19 @@
def can_build(env, platform):
return True
+
def configure(env):
pass
+
def get_doc_classes():
return [
"WebSocketClient",
"WebSocketMultiplayerPeer",
"WebSocketPeer",
- "WebSocketServer"
+ "WebSocketServer",
]
+
def get_doc_path():
return "doc_classes"
diff --git a/modules/websocket/emws_server.cpp b/modules/websocket/emws_server.cpp
index 8ceefa42b6..95cffb4775 100644
--- a/modules/websocket/emws_server.cpp
+++ b/modules/websocket/emws_server.cpp
@@ -50,7 +50,7 @@ bool EMWSServer::has_peer(int p_id) const {
}
Ref<WebSocketPeer> EMWSServer::get_peer(int p_id) const {
- return NULL;
+ return nullptr;
}
Vector<String> EMWSServer::get_protocols() const {
diff --git a/modules/websocket/packet_buffer.h b/modules/websocket/packet_buffer.h
index ea3658c827..5f5f0e20cd 100644
--- a/modules/websocket/packet_buffer.h
+++ b/modules/websocket/packet_buffer.h
@@ -63,7 +63,7 @@ public:
ERR_FAIL_COND_V(p_info && _packets.space_left() < 1, ERR_OUT_OF_MEMORY);
#endif
- // If p_info is NULL, only the payload is written
+ // If p_info is nullptr, only the payload is written
if (p_info) {
_Packet p;
p.size = p_size;
@@ -71,7 +71,7 @@ public:
_packets.write(p);
}
- // If p_payload is NULL, only the packet information is written.
+ // If p_payload is nullptr, only the packet information is written.
if (p_payload) {
_payload.write((const uint8_t *)p_payload, p_size);
}
diff --git a/modules/websocket/websocket_macros.h b/modules/websocket/websocket_macros.h
index 8aa01a70ed..f7eafcff1f 100644
--- a/modules/websocket/websocket_macros.h
+++ b/modules/websocket/websocket_macros.h
@@ -56,13 +56,13 @@ public:\
static CNAME *create() {\
\
if (!_create)\
- return NULL;\
+ return nullptr;\
return _create();\
}\
protected:\
#define GDCINULL(CNAME) \
-CNAME *(*CNAME::_create)() = NULL;
+CNAME *(*CNAME::_create)() = nullptr;
#define GDCIIMPL(IMPNAME, CNAME) \
public:\
diff --git a/modules/websocket/websocket_multiplayer_peer.cpp b/modules/websocket/websocket_multiplayer_peer.cpp
index 9eb1445b35..9b71b32e33 100644
--- a/modules/websocket/websocket_multiplayer_peer.cpp
+++ b/modules/websocket/websocket_multiplayer_peer.cpp
@@ -42,7 +42,7 @@ WebSocketMultiplayerPeer::WebSocketMultiplayerPeer() {
_current_packet.source = 0;
_current_packet.destination = 0;
_current_packet.size = 0;
- _current_packet.data = NULL;
+ _current_packet.data = nullptr;
}
WebSocketMultiplayerPeer::~WebSocketMultiplayerPeer() {
@@ -74,12 +74,12 @@ int WebSocketMultiplayerPeer::_gen_unique_id() const {
void WebSocketMultiplayerPeer::_clear() {
_peer_map.clear();
- if (_current_packet.data != NULL)
+ if (_current_packet.data != nullptr)
memfree(_current_packet.data);
for (List<Packet>::Element *E = _incoming_packets.front(); E; E = E->next()) {
memfree(E->get().data);
- E->get().data = NULL;
+ E->get().data = nullptr;
}
_incoming_packets.clear();
@@ -109,9 +109,9 @@ Error WebSocketMultiplayerPeer::get_packet(const uint8_t **r_buffer, int &r_buff
r_buffer_size = 0;
- if (_current_packet.data != NULL) {
+ if (_current_packet.data != nullptr) {
memfree(_current_packet.data);
- _current_packet.data = NULL;
+ _current_packet.data = nullptr;
}
_current_packet = _incoming_packets.front()->get();
diff --git a/modules/websocket/wsl_client.cpp b/modules/websocket/wsl_client.cpp
index bada750ec2..9f05500eb9 100644
--- a/modules/websocket/wsl_client.cpp
+++ b/modules/websocket/wsl_client.cpp
@@ -279,7 +279,7 @@ void WSLClient::poll() {
Ref<WebSocketPeer> WSLClient::get_peer(int p_peer_id) const {
- ERR_FAIL_COND_V(p_peer_id != 1, NULL);
+ ERR_FAIL_COND_V(p_peer_id != 1, nullptr);
return _peer;
}
@@ -298,7 +298,7 @@ NetworkedMultiplayerPeer::ConnectionStatus WSLClient::get_connection_status() co
void WSLClient::disconnect_from_host(int p_code, String p_reason) {
_peer->close(p_code, p_reason);
- _connection = Ref<StreamPeer>(NULL);
+ _connection = Ref<StreamPeer>(nullptr);
_tcp = Ref<StreamPeerTCP>(memnew(StreamPeerTCP));
_key = "";
diff --git a/modules/websocket/wsl_peer.cpp b/modules/websocket/wsl_peer.cpp
index ff32e83dc1..44b71f70f4 100644
--- a/modules/websocket/wsl_peer.cpp
+++ b/modules/websocket/wsl_peer.cpp
@@ -69,7 +69,7 @@ void WSLPeer::_wsl_destroy(struct PeerData **p_data) {
}
wslay_event_context_free(data->ctx);
memdelete(data);
- *p_data = NULL;
+ *p_data = nullptr;
}
bool WSLPeer::_wsl_poll(struct PeerData *p_data) {
@@ -163,9 +163,9 @@ wslay_event_callbacks wsl_callbacks = {
wsl_recv_callback,
wsl_send_callback,
wsl_genmask_callback,
- NULL, /* on_frame_recv_start_callback */
- NULL, /* on_frame_recv_callback */
- NULL, /* on_frame_recv_end_callback */
+ nullptr, /* on_frame_recv_start_callback */
+ nullptr, /* on_frame_recv_callback */
+ nullptr, /* on_frame_recv_end_callback */
wsl_msg_recv_callback
};
@@ -199,8 +199,8 @@ Error WSLPeer::parse_message(const wslay_event_on_msg_recv_arg *arg) {
}
void WSLPeer::make_context(PeerData *p_data, unsigned int p_in_buf_size, unsigned int p_in_pkt_size, unsigned int p_out_buf_size, unsigned int p_out_pkt_size) {
- ERR_FAIL_COND(_data != NULL);
- ERR_FAIL_COND(p_data == NULL);
+ ERR_FAIL_COND(_data != nullptr);
+ ERR_FAIL_COND(p_data == nullptr);
_in_buffer.resize(p_in_pkt_size, p_in_buf_size);
_packet_buffer.resize((1 << MAX(p_in_buf_size, p_out_buf_size)));
@@ -229,7 +229,7 @@ void WSLPeer::poll() {
return;
if (_wsl_poll(_data)) {
- _data = NULL;
+ _data = nullptr;
}
}
@@ -284,7 +284,7 @@ bool WSLPeer::was_string_packet() const {
bool WSLPeer::is_connected_to_host() const {
- return _data != NULL;
+ return _data != nullptr;
}
void WSLPeer::close_now() {
@@ -330,7 +330,7 @@ void WSLPeer::invalidate() {
}
WSLPeer::WSLPeer() {
- _data = NULL;
+ _data = nullptr;
_is_string = 0;
close_code = -1;
write_mode = WRITE_MODE_BINARY;
@@ -341,7 +341,7 @@ WSLPeer::~WSLPeer() {
close();
invalidate();
_wsl_destroy(&_data);
- _data = NULL;
+ _data = nullptr;
}
#endif // JAVASCRIPT_ENABLED
diff --git a/modules/websocket/wsl_peer.h b/modules/websocket/wsl_peer.h
index 00549cd9bc..3b0639831a 100644
--- a/modules/websocket/wsl_peer.h
+++ b/modules/websocket/wsl_peer.h
@@ -67,10 +67,10 @@ public:
valid = false;
is_server = false;
id = 1;
- ctx = NULL;
- obj = NULL;
+ ctx = nullptr;
+ obj = nullptr;
closing = false;
- peer = NULL;
+ peer = nullptr;
}
};
diff --git a/modules/websocket/wsl_server.cpp b/modules/websocket/wsl_server.cpp
index b66cdf3ea2..6f155a6ffa 100644
--- a/modules/websocket/wsl_server.cpp
+++ b/modules/websocket/wsl_server.cpp
@@ -265,7 +265,7 @@ bool WSLServer::has_peer(int p_id) const {
}
Ref<WebSocketPeer> WSLServer::get_peer(int p_id) const {
- ERR_FAIL_COND_V(!has_peer(p_id), NULL);
+ ERR_FAIL_COND_V(!has_peer(p_id), nullptr);
return _peer_map[p_id];
}
diff --git a/modules/xatlas_unwrap/SCsub b/modules/xatlas_unwrap/SCsub
index b242fd4673..c659349d05 100644
--- a/modules/xatlas_unwrap/SCsub
+++ b/modules/xatlas_unwrap/SCsub
@@ -1,12 +1,12 @@
#!/usr/bin/env python
-Import('env')
-Import('env_modules')
+Import("env")
+Import("env_modules")
env_xatlas_unwrap = env_modules.Clone()
# Thirdparty source files
-if env['builtin_xatlas']:
+if env["builtin_xatlas"]:
thirdparty_dir = "#thirdparty/xatlas/"
thirdparty_sources = [
"xatlas.cpp",
diff --git a/modules/xatlas_unwrap/config.py b/modules/xatlas_unwrap/config.py
index bd092bdc16..2e73c51626 100644
--- a/modules/xatlas_unwrap/config.py
+++ b/modules/xatlas_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"]
+
def configure(env):
pass
diff --git a/modules/xatlas_unwrap/register_types.cpp b/modules/xatlas_unwrap/register_types.cpp
index c69b566525..8c5525bed3 100644
--- a/modules/xatlas_unwrap/register_types.cpp
+++ b/modules/xatlas_unwrap/register_types.cpp
@@ -32,14 +32,91 @@
#include "core/error_macros.h"
+#include "core/crypto/crypto_core.h"
+
#include "thirdparty/xatlas/xatlas.h"
#include <stdio.h>
#include <stdlib.h>
-extern bool (*array_mesh_lightmap_unwrap_callback)(float p_texel_size, const float *p_vertices, const float *p_normals, int p_vertex_count, const int *p_indices, const int *p_face_materials, int p_index_count, float **r_uv, int **r_vertex, int *r_vertex_count, int **r_index, int *r_index_count, int *r_size_hint_x, int *r_size_hint_y);
+extern bool (*array_mesh_lightmap_unwrap_callback)(float p_texel_size, const float *p_vertices, const float *p_normals, int p_vertex_count, const int *p_indices, int p_index_count, float **r_uv, int **r_vertex, int *r_vertex_count, int **r_index, int *r_index_count, int *r_size_hint_x, int *r_size_hint_y, int *&r_cache_data, unsigned int &r_cache_size, bool &r_used_cache);
+
+bool xatlas_mesh_lightmap_unwrap_callback(float p_texel_size, const float *p_vertices, const float *p_normals, int p_vertex_count, const int *p_indices, int p_index_count, float **r_uvs, int **r_vertices, int *r_vertex_count, int **r_indices, int *r_index_count, int *r_size_hint_x, int *r_size_hint_y, int *&r_cache_data, unsigned int &r_cache_size, bool &r_used_cache) {
+
+ CryptoCore::MD5Context ctx;
+ ctx.start();
+
+ ctx.update((unsigned char *)&p_texel_size, sizeof(float));
+ ctx.update((unsigned char *)p_indices, sizeof(int) * p_index_count);
+ ctx.update((unsigned char *)p_vertices, sizeof(float) * p_vertex_count);
+ ctx.update((unsigned char *)p_normals, sizeof(float) * p_vertex_count);
+
+ unsigned char hash[16];
+ ctx.finish(hash);
+
+ bool cached = false;
+ unsigned int cache_idx = 0;
+
+ if (r_used_cache && r_cache_size) {
+ //Check if hash is in cache data
+
+ int *cache_data = r_cache_data;
+ int n_entries = cache_data[0];
+ unsigned int r_idx = 1;
+ for (int i = 0; i < n_entries; ++i) {
+ if (memcmp(&cache_data[r_idx], hash, 16) == 0) {
+ cached = true;
+ cache_idx = r_idx;
+ break;
+ }
+
+ r_idx += 4; // hash
+ r_idx += 2; // size hint
+
+ int vertex_count = cache_data[r_idx];
+ r_idx += 1; // vertex count
+ r_idx += vertex_count; // vertex
+ r_idx += vertex_count * 2; // uvs
+
+ int index_count = cache_data[r_idx];
+ r_idx += 1; // index count
+ r_idx += index_count; // indices
+ }
+ }
-bool xatlas_mesh_lightmap_unwrap_callback(float p_texel_size, const float *p_vertices, const float *p_normals, int p_vertex_count, const int *p_indices, const int *p_face_materials, int p_index_count, float **r_uv, int **r_vertex, int *r_vertex_count, int **r_index, int *r_index_count, int *r_size_hint_x, int *r_size_hint_y) {
+ if (r_used_cache && cached) {
+ int *cache_data = r_cache_data;
+
+ // Return cache data pointer to the caller
+ r_cache_data = &cache_data[cache_idx];
+
+ cache_idx += 4;
+
+ // Load size
+ *r_size_hint_x = cache_data[cache_idx];
+ *r_size_hint_y = cache_data[cache_idx + 1];
+ cache_idx += 2;
+
+ // Load vertices
+ *r_vertex_count = cache_data[cache_idx];
+ cache_idx++;
+ *r_vertices = &cache_data[cache_idx];
+ cache_idx += *r_vertex_count;
+
+ // Load UVs
+ *r_uvs = (float *)&cache_data[cache_idx];
+ cache_idx += *r_vertex_count * 2;
+
+ // Load indices
+ *r_index_count = cache_data[cache_idx];
+ cache_idx++;
+ *r_indices = &cache_data[cache_idx];
+
+ // Return cache data size to the caller
+ r_cache_size = sizeof(int) * (4 + 2 + 1 + *r_vertex_count + (*r_vertex_count * 2) + 1 + *r_index_count); // hash + size hint + vertex_count + vertices + uvs + index_count + indices
+ r_used_cache = true;
+ return true;
+ }
//set up input mesh
xatlas::MeshDecl input_mesh;
@@ -52,7 +129,7 @@ bool xatlas_mesh_lightmap_unwrap_callback(float p_texel_size, const float *p_ver
input_mesh.vertexPositionStride = sizeof(float) * 3;
input_mesh.vertexNormalData = p_normals;
input_mesh.vertexNormalStride = sizeof(uint32_t) * 3;
- input_mesh.vertexUvData = NULL;
+ input_mesh.vertexUvData = nullptr;
input_mesh.vertexUvStride = 0;
xatlas::ChartOptions chart_options;
@@ -68,7 +145,7 @@ bool xatlas_mesh_lightmap_unwrap_callback(float p_texel_size, const float *p_ver
ERR_FAIL_COND_V_MSG(err != xatlas::AddMeshError::Enum::Success, false, xatlas::StringForEnum(err));
printf("Generate..\n");
- xatlas::Generate(atlas, chart_options, NULL, pack_options);
+ xatlas::Generate(atlas, chart_options, nullptr, pack_options);
*r_size_hint_x = atlas->width;
*r_size_hint_y = atlas->height;
@@ -82,16 +159,16 @@ bool xatlas_mesh_lightmap_unwrap_callback(float p_texel_size, const float *p_ver
const xatlas::Mesh &output = atlas->meshes[0];
- *r_vertex = (int *)malloc(sizeof(int) * output.vertexCount);
- *r_uv = (float *)malloc(sizeof(float) * output.vertexCount * 2);
- *r_index = (int *)malloc(sizeof(int) * output.indexCount);
+ *r_vertices = (int *)malloc(sizeof(int) * output.vertexCount);
+ *r_uvs = (float *)malloc(sizeof(float) * output.vertexCount * 2);
+ *r_indices = (int *)malloc(sizeof(int) * output.indexCount);
float max_x = 0;
float max_y = 0;
for (uint32_t i = 0; i < output.vertexCount; i++) {
- (*r_vertex)[i] = output.vertexArray[i].xref;
- (*r_uv)[i * 2 + 0] = output.vertexArray[i].uv[0] / w;
- (*r_uv)[i * 2 + 1] = output.vertexArray[i].uv[1] / h;
+ (*r_vertices)[i] = output.vertexArray[i].xref;
+ (*r_uvs)[i * 2 + 0] = output.vertexArray[i].uv[0] / w;
+ (*r_uvs)[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]);
}
@@ -100,13 +177,54 @@ bool xatlas_mesh_lightmap_unwrap_callback(float p_texel_size, const float *p_ver
*r_vertex_count = output.vertexCount;
for (uint32_t i = 0; i < output.indexCount; i++) {
- (*r_index)[i] = output.indexArray[i];
+ (*r_indices)[i] = output.indexArray[i];
}
*r_index_count = output.indexCount;
xatlas::Destroy(atlas);
- printf("Done\n");
+
+ if (r_used_cache) {
+ unsigned int new_cache_size = 4 + 2 + 1 + *r_vertex_count + (*r_vertex_count * 2) + 1 + *r_index_count; // hash + size hint + vertex_count + vertices + uvs + index_count + indices
+ new_cache_size *= sizeof(int);
+ int *new_cache_data = (int *)memalloc(new_cache_size);
+ unsigned int new_cache_idx = 0;
+
+ // hash
+ memcpy(&new_cache_data[new_cache_idx], hash, 16);
+ new_cache_idx += 4;
+
+ // size hint
+ new_cache_data[new_cache_idx] = *r_size_hint_x;
+ new_cache_data[new_cache_idx + 1] = *r_size_hint_y;
+ new_cache_idx += 2;
+
+ // vertex count
+ new_cache_data[new_cache_idx] = *r_vertex_count;
+ new_cache_idx++;
+
+ // vertices
+ memcpy(&new_cache_data[new_cache_idx], *r_vertices, sizeof(int) * *r_vertex_count);
+ new_cache_idx += *r_vertex_count;
+
+ // uvs
+ memcpy(&new_cache_data[new_cache_idx], *r_uvs, sizeof(float) * *r_vertex_count * 2);
+ new_cache_idx += *r_vertex_count * 2;
+
+ // index count
+ new_cache_data[new_cache_idx] = *r_index_count;
+ new_cache_idx++;
+
+ // indices
+ memcpy(&new_cache_data[new_cache_idx], *r_indices, sizeof(int) * *r_index_count);
+ new_cache_idx += *r_index_count;
+
+ // Return cache data to the caller
+ r_cache_data = new_cache_data;
+ r_cache_size = new_cache_size;
+ r_used_cache = false;
+ }
+
return true;
}