summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/basis_universal/register_types.cpp2
-rw-r--r--modules/basis_universal/texture_basisu.cpp2
-rw-r--r--modules/bmp/image_loader_bmp.cpp2
-rw-r--r--modules/camera/camera_osx.mm6
-rw-r--r--modules/csg/csg.h2
-rw-r--r--modules/csg/csg_shape.cpp6
-rw-r--r--modules/csg/doc_classes/CSGBox3D.xml2
-rw-r--r--modules/csg/doc_classes/CSGPolygon3D.xml2
-rw-r--r--modules/dds/register_types.cpp2
-rw-r--r--modules/dds/texture_loader_dds.cpp2
-rw-r--r--modules/enet/networked_multiplayer_enet.cpp5
-rw-r--r--modules/fbx/data/fbx_bone.h2
-rw-r--r--modules/fbx/data/fbx_material.cpp12
-rw-r--r--modules/fbx/data/fbx_material.h6
-rw-r--r--modules/fbx/data/fbx_mesh_data.cpp6
-rw-r--r--modules/fbx/data/fbx_mesh_data.h2
-rw-r--r--modules/fbx/data/fbx_node.h2
-rw-r--r--modules/fbx/data/fbx_skeleton.h4
-rw-r--r--modules/fbx/data/pivot_transform.h4
-rw-r--r--modules/fbx/editor_scene_importer_fbx.cpp26
-rw-r--r--modules/fbx/fbx_parser/FBXParser.cpp2
-rw-r--r--modules/fbx/register_types.cpp2
-rw-r--r--modules/fbx/tools/import_utils.h10
-rw-r--r--modules/fbx/tools/validation_tools.h5
-rw-r--r--modules/gdnative/doc_classes/GDNative.xml2
-rw-r--r--modules/gdnative/gdnative.cpp12
-rw-r--r--modules/gdnative/gdnative.h4
-rw-r--r--modules/gdnative/gdnative/variant.cpp12
-rw-r--r--modules/gdnative/gdnative_api.json6
-rw-r--r--modules/gdnative/gdnative_library_editor_plugin.cpp4
-rw-r--r--modules/gdnative/include/gdnative/variant.h2
-rw-r--r--modules/gdnative/include/pluginscript/godot_pluginscript.h2
-rw-r--r--modules/gdnative/include/xr/godot_xr.h27
-rw-r--r--modules/gdnative/nativescript/api_generator.cpp45
-rw-r--r--modules/gdnative/nativescript/nativescript.cpp14
-rw-r--r--modules/gdnative/nativescript/nativescript.h4
-rw-r--r--modules/gdnative/nativescript/register_types.cpp4
-rw-r--r--modules/gdnative/pluginscript/pluginscript_language.cpp21
-rw-r--r--modules/gdnative/pluginscript/pluginscript_language.h2
-rw-r--r--modules/gdnative/pluginscript/pluginscript_loader.cpp2
-rw-r--r--modules/gdnative/pluginscript/pluginscript_script.cpp24
-rw-r--r--modules/gdnative/pluginscript/pluginscript_script.h2
-rw-r--r--modules/gdnative/pluginscript/register_types.cpp2
-rw-r--r--modules/gdnative/register_types.cpp8
-rw-r--r--modules/gdnative/videodecoder/register_types.cpp2
-rw-r--r--modules/gdnative/videodecoder/video_stream_gdnative.cpp2
-rw-r--r--modules/gdnative/videodecoder/video_stream_gdnative.h2
-rw-r--r--modules/gdnative/xr/xr_interface_gdnative.cpp61
-rw-r--r--modules/gdnative/xr/xr_interface_gdnative.h14
-rw-r--r--modules/gdnavigation/navigation_mesh_generator.cpp10
-rw-r--r--modules/gdscript/doc_classes/@GDScript.xml6
-rw-r--r--modules/gdscript/editor/gdscript_highlighter.cpp2
-rw-r--r--modules/gdscript/gdscript.cpp54
-rw-r--r--modules/gdscript/gdscript.h22
-rw-r--r--modules/gdscript/gdscript_analyzer.cpp12
-rw-r--r--modules/gdscript/gdscript_analyzer.h2
-rw-r--r--modules/gdscript/gdscript_byte_codegen.cpp8
-rw-r--r--modules/gdscript/gdscript_cache.cpp6
-rw-r--r--modules/gdscript/gdscript_cache.h4
-rw-r--r--modules/gdscript/gdscript_compiler.cpp9
-rw-r--r--modules/gdscript/gdscript_editor.cpp28
-rw-r--r--modules/gdscript/gdscript_function.h6
-rw-r--r--modules/gdscript/gdscript_lambda_callable.h2
-rw-r--r--modules/gdscript/gdscript_parser.cpp4
-rw-r--r--modules/gdscript/gdscript_parser.h2
-rw-r--r--modules/gdscript/gdscript_vm.cpp8
-rw-r--r--modules/gdscript/language_server/gdscript_extend_parser.cpp10
-rw-r--r--modules/gdscript/language_server/gdscript_language_protocol.cpp11
-rw-r--r--modules/gdscript/language_server/gdscript_language_protocol.h2
-rw-r--r--modules/gdscript/language_server/gdscript_language_server.cpp2
-rw-r--r--modules/gdscript/language_server/gdscript_text_document.h8
-rw-r--r--modules/gdscript/language_server/gdscript_workspace.cpp6
-rw-r--r--modules/gdscript/language_server/gdscript_workspace.h4
-rw-r--r--modules/gdscript/language_server/lsp.hpp4
-rw-r--r--modules/gdscript/register_types.cpp14
-rw-r--r--modules/gdscript/tests/gdscript_test_runner.cpp16
-rw-r--r--modules/gdscript/tests/gdscript_test_runner_suite.h8
-rw-r--r--modules/gdscript/tests/test_gdscript.cpp4
-rw-r--r--modules/glslang/register_types.cpp4
-rw-r--r--modules/gltf/doc_classes/GLTFAccessor.xml4
-rw-r--r--modules/gltf/doc_classes/GLTFLight.xml2
-rw-r--r--modules/gltf/doc_classes/GLTFMesh.xml2
-rw-r--r--modules/gltf/doc_classes/GLTFNode.xml10
-rw-r--r--modules/gltf/doc_classes/GLTFSkeleton.xml4
-rw-r--r--modules/gltf/doc_classes/GLTFSkin.xml8
-rw-r--r--modules/gltf/doc_classes/GLTFSpecGloss.xml4
-rw-r--r--modules/gltf/doc_classes/GLTFState.xml6
-rw-r--r--modules/gltf/doc_classes/PackedSceneGLTF.xml2
-rw-r--r--modules/gltf/editor_scene_exporter_gltf_plugin.cpp2
-rw-r--r--modules/gltf/editor_scene_importer_gltf.cpp15
-rw-r--r--modules/gltf/editor_scene_importer_gltf.h1
-rw-r--r--modules/gltf/gltf_document.cpp140
-rw-r--r--modules/gltf/register_types.cpp2
-rw-r--r--modules/gridmap/doc_classes/GridMap.xml2
-rw-r--r--modules/gridmap/grid_map.cpp4
-rw-r--r--modules/gridmap/grid_map_editor_plugin.cpp40
-rw-r--r--modules/gridmap/grid_map_editor_plugin.h1
-rw-r--r--modules/jpg/image_loader_jpegd.cpp2
-rw-r--r--modules/jsonrpc/jsonrpc.cpp13
-rw-r--r--modules/lightmapper_rd/lightmapper_rd.cpp34
-rw-r--r--modules/mbedtls/crypto_mbedtls.cpp6
-rw-r--r--modules/mbedtls/dtls_server_mbedtls.cpp4
-rw-r--r--modules/mbedtls/packet_peer_mbed_dtls.cpp4
-rw-r--r--modules/mbedtls/ssl_context_mbedtls.h8
-rw-r--r--modules/mbedtls/stream_peer_mbedtls.cpp4
-rw-r--r--modules/minimp3/audio_stream_mp3.cpp4
-rw-r--r--modules/minimp3/doc_classes/AudioStreamMP3.xml2
-rw-r--r--modules/minimp3/register_types.cpp2
-rw-r--r--modules/minimp3/resource_importer_mp3.cpp4
-rw-r--r--modules/mobile_vr/mobile_vr_interface.cpp87
-rw-r--r--modules/mobile_vr/mobile_vr_interface.h14
-rw-r--r--modules/mobile_vr/register_types.cpp2
-rw-r--r--modules/mono/class_db_api_json.cpp5
-rw-r--r--modules/mono/csharp_script.cpp135
-rw-r--r--modules/mono/csharp_script.h13
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/Build/BuildInfo.cs2
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/Build/BuildOutputView.cs2
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs6
-rw-r--r--modules/mono/editor/bindings_generator.cpp29
-rw-r--r--modules/mono/editor/bindings_generator.h10
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/AABB.cs4
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Basis.cs18
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Color.cs4
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Extensions/PackedSceneExtensions.cs8
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Object.base.cs4
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Plane.cs4
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Quaternion.cs17
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2.cs4
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Transform2D.cs18
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Transform3D.cs18
-rw-r--r--modules/mono/glue/base_object_glue.cpp38
-rw-r--r--modules/mono/glue/glue_header.h2
-rw-r--r--modules/mono/godotsharp_dirs.cpp2
-rw-r--r--modules/mono/mono_gc_handle.h6
-rw-r--r--modules/mono/mono_gd/gd_mono.cpp8
-rw-r--r--modules/mono/mono_gd/gd_mono_assembly.cpp2
-rw-r--r--modules/mono/mono_gd/gd_mono_internals.cpp14
-rw-r--r--modules/mono/mono_gd/gd_mono_log.cpp6
-rw-r--r--modules/mono/mono_gd/gd_mono_log.h2
-rw-r--r--modules/mono/mono_gd/gd_mono_marshal.cpp4
-rw-r--r--modules/mono/mono_gd/gd_mono_utils.cpp16
-rw-r--r--modules/mono/mono_gd/gd_mono_utils.h2
-rw-r--r--modules/mono/register_types.cpp4
-rw-r--r--modules/mono/signal_awaiter_utils.h2
-rw-r--r--modules/mono/utils/mono_reg_utils.cpp2
-rw-r--r--modules/mono/utils/path_utils.cpp6
-rw-r--r--modules/mono/utils/string_utils.cpp2
-rw-r--r--modules/opensimplex/doc_classes/NoiseTexture.xml2
-rw-r--r--modules/opensimplex/doc_classes/OpenSimplexNoise.xml2
-rw-r--r--modules/opensimplex/noise_texture.cpp2
-rw-r--r--modules/opensimplex/noise_texture.h2
-rw-r--r--modules/opensimplex/open_simplex_noise.h2
-rw-r--r--modules/pvr/image_compress_pvrtc.cpp8
-rw-r--r--modules/pvr/register_types.cpp2
-rw-r--r--modules/pvr/texture_loader_pvr.cpp2
-rw-r--r--modules/raycast/raycast_occlusion_cull.h2
-rw-r--r--modules/regex/doc_classes/RegEx.xml2
-rw-r--r--modules/regex/doc_classes/RegExMatch.xml4
-rw-r--r--modules/regex/regex.h10
-rw-r--r--modules/stb_vorbis/audio_stream_ogg_vorbis.cpp4
-rw-r--r--modules/stb_vorbis/doc_classes/AudioStreamOGGVorbis.xml2
-rw-r--r--modules/stb_vorbis/register_types.cpp2
-rw-r--r--modules/stb_vorbis/resource_importer_ogg_vorbis.cpp4
-rw-r--r--modules/text_server_adv/dynamic_font_adv.cpp2
-rw-r--r--modules/text_server_adv/text_server_adv.cpp30
-rw-r--r--modules/text_server_fb/dynamic_font_fb.cpp2
-rw-r--r--modules/text_server_fb/text_server_fb.cpp14
-rw-r--r--modules/tga/image_loader_tga.cpp24
-rw-r--r--modules/tga/image_loader_tga.h4
-rw-r--r--modules/theora/register_types.cpp2
-rw-r--r--modules/theora/video_stream_theora.cpp2
-rw-r--r--modules/theora/video_stream_theora.h2
-rw-r--r--modules/upnp/doc_classes/UPNP.xml2
-rw-r--r--modules/upnp/doc_classes/UPNPDevice.xml2
-rw-r--r--modules/upnp/upnp.cpp2
-rw-r--r--modules/upnp/upnp.h6
-rw-r--r--modules/upnp/upnp_device.h6
-rw-r--r--modules/visual_script/doc_classes/VisualScript.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptClassConstant.xml4
-rw-r--r--modules/visual_script/doc_classes/VisualScriptComment.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptEmitSignal.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptFunctionCall.xml4
-rw-r--r--modules/visual_script/doc_classes/VisualScriptFunctionState.xml4
-rw-r--r--modules/visual_script/doc_classes/VisualScriptInputAction.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptLocalVar.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptLocalVarSet.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptPropertyGet.xml4
-rw-r--r--modules/visual_script/doc_classes/VisualScriptPropertySet.xml4
-rw-r--r--modules/visual_script/doc_classes/VisualScriptTypeCast.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptVariableGet.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptVariableSet.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptYieldSignal.xml4
-rw-r--r--modules/visual_script/visual_script.cpp10
-rw-r--r--modules/visual_script/visual_script.h12
-rw-r--r--modules/visual_script/visual_script_builtin_funcs.cpp4
-rw-r--r--modules/visual_script/visual_script_builtin_funcs.h2
-rw-r--r--modules/visual_script/visual_script_editor.cpp222
-rw-r--r--modules/visual_script/visual_script_editor.h3
-rw-r--r--modules/visual_script/visual_script_expression.cpp2
-rw-r--r--modules/visual_script/visual_script_expression.h2
-rw-r--r--modules/visual_script/visual_script_flow_control.cpp16
-rw-r--r--modules/visual_script/visual_script_flow_control.h14
-rw-r--r--modules/visual_script/visual_script_func_nodes.cpp16
-rw-r--r--modules/visual_script/visual_script_func_nodes.h8
-rw-r--r--modules/visual_script/visual_script_nodes.cpp260
-rw-r--r--modules/visual_script/visual_script_nodes.h56
-rw-r--r--modules/visual_script/visual_script_property_selector.cpp7
-rw-r--r--modules/visual_script/visual_script_yield_nodes.cpp12
-rw-r--r--modules/visual_script/visual_script_yield_nodes.h4
-rw-r--r--modules/webm/register_types.cpp2
-rw-r--r--modules/webm/video_stream_webm.cpp4
-rw-r--r--modules/webp/image_loader_webp.cpp77
-rw-r--r--modules/webrtc/doc_classes/WebRTCPeerConnection.xml2
-rw-r--r--modules/webrtc/webrtc_multiplayer.h2
-rw-r--r--modules/webrtc/webrtc_peer_connection.h4
-rw-r--r--modules/websocket/doc_classes/WebSocketClient.xml4
-rw-r--r--modules/websocket/doc_classes/WebSocketServer.xml5
-rw-r--r--modules/websocket/emws_server.h2
-rw-r--r--modules/websocket/websocket_client.cpp13
-rw-r--r--modules/websocket/websocket_server.cpp19
-rw-r--r--modules/websocket/websocket_server.h6
-rw-r--r--modules/websocket/wsl_client.cpp5
-rw-r--r--modules/websocket/wsl_server.cpp8
-rw-r--r--modules/websocket/wsl_server.h6
-rw-r--r--modules/webxr/register_types.cpp2
-rw-r--r--modules/webxr/webxr_interface_js.cpp29
-rw-r--r--modules/webxr/webxr_interface_js.h5
227 files changed, 1415 insertions, 1156 deletions
diff --git a/modules/basis_universal/register_types.cpp b/modules/basis_universal/register_types.cpp
index 772ac87dbf..23639a4f2f 100644
--- a/modules/basis_universal/register_types.cpp
+++ b/modules/basis_universal/register_types.cpp
@@ -260,7 +260,7 @@ static Ref<Image> basis_universal_unpacker(const Vector<uint8_t> &p_buffer) {
};
};
- image.instance();
+ image.instantiate();
image->create(info.m_width, info.m_height, info.m_total_levels > 1, imgfmt, gpudata);
return image;
diff --git a/modules/basis_universal/texture_basisu.cpp b/modules/basis_universal/texture_basisu.cpp
index 6a5f6313c4..9e917420ce 100644
--- a/modules/basis_universal/texture_basisu.cpp
+++ b/modules/basis_universal/texture_basisu.cpp
@@ -130,7 +130,7 @@ void TextureBasisU::set_basisu_data(const Vector<uint8_t>& p_data) {
};
Ref<Image> img;
- img.instance();
+ img.instantiate();
img->create(info.m_width, info.m_height, info.m_total_levels > 1, imgfmt, gpudata);
RenderingServer::get_singleton()->texture_allocate(texture, tex_size.x, tex_size.y, 0, img->get_format(), RS::TEXTURE_TYPE_2D, flags);
diff --git a/modules/bmp/image_loader_bmp.cpp b/modules/bmp/image_loader_bmp.cpp
index 27b49a6609..171895ed24 100644
--- a/modules/bmp/image_loader_bmp.cpp
+++ b/modules/bmp/image_loader_bmp.cpp
@@ -298,7 +298,7 @@ static Ref<Image> _bmp_mem_loader_func(const uint8_t *p_bmp, int p_size) {
Error open_memfile_error = memfile.open_custom(p_bmp, p_size);
ERR_FAIL_COND_V_MSG(open_memfile_error, Ref<Image>(), "Could not create memfile for BMP image buffer.");
Ref<Image> img;
- img.instance();
+ img.instantiate();
Error load_error = ImageLoaderBMP().load_image(img, &memfile, false, 1.0f);
ERR_FAIL_COND_V_MSG(load_error, Ref<Image>(), "Failed to load BMP image.");
return img;
diff --git a/modules/camera/camera_osx.mm b/modules/camera/camera_osx.mm
index 9b59b68075..6bc56add20 100644
--- a/modules/camera/camera_osx.mm
+++ b/modules/camera/camera_osx.mm
@@ -162,7 +162,7 @@
uint8_t *w = img_data[0].ptrw();
memcpy(w, dataY, new_width * new_height);
- img[0].instance();
+ img[0].instantiate();
img[0]->create(new_width, new_height, 0, Image::FORMAT_R8, img_data[0]);
}
@@ -181,7 +181,7 @@
memcpy(w, dataCbCr, 2 * new_width * new_height);
///TODO GLES2 doesn't support FORMAT_RG8, need to do some form of conversion
- img[1].instance();
+ img[1].instantiate();
img[1]->create(new_width, new_height, 0, Image::FORMAT_RG8, img_data[1]);
}
@@ -341,7 +341,7 @@ void CameraOSX::update_feeds() {
if (!found) {
Ref<CameraFeedOSX> newfeed;
- newfeed.instance();
+ newfeed.instantiate();
newfeed->set_device(device);
// assume display camera so inverse
diff --git a/modules/csg/csg.h b/modules/csg/csg.h
index 4bd79e15a9..c872860486 100644
--- a/modules/csg/csg.h
+++ b/modules/csg/csg.h
@@ -36,7 +36,7 @@
#include "core/math/transform_3d.h"
#include "core/math/vector2.h"
#include "core/math/vector3.h"
-#include "core/object/reference.h"
+#include "core/object/ref_counted.h"
#include "core/templates/list.h"
#include "core/templates/map.h"
#include "core/templates/oa_hash_map.h"
diff --git a/modules/csg/csg_shape.cpp b/modules/csg/csg_shape.cpp
index d6690bb96c..6b0c2604e3 100644
--- a/modules/csg/csg_shape.cpp
+++ b/modules/csg/csg_shape.cpp
@@ -44,7 +44,7 @@ void CSGShape3D::set_use_collision(bool p_enable) {
}
if (use_collision) {
- root_collision_shape.instance();
+ root_collision_shape.instantiate();
root_collision_instance = PhysicsServer3D::get_singleton()->body_create();
PhysicsServer3D::get_singleton()->body_set_mode(root_collision_instance, PhysicsServer3D::BODY_MODE_STATIC);
PhysicsServer3D::get_singleton()->body_set_state(root_collision_instance, PhysicsServer3D::BODY_STATE_TRANSFORM, get_global_transform());
@@ -411,7 +411,7 @@ void CSGShape3D::_update_shape() {
}
}
- root_mesh.instance();
+ root_mesh.instantiate();
//create surfaces
for (int i = 0; i < surfaces.size(); i++) {
@@ -498,7 +498,7 @@ void CSGShape3D::_notification(int p_what) {
}
if (use_collision && is_root_shape()) {
- root_collision_shape.instance();
+ root_collision_shape.instantiate();
root_collision_instance = PhysicsServer3D::get_singleton()->body_create();
PhysicsServer3D::get_singleton()->body_set_mode(root_collision_instance, PhysicsServer3D::BODY_MODE_STATIC);
PhysicsServer3D::get_singleton()->body_set_state(root_collision_instance, PhysicsServer3D::BODY_STATE_TRANSFORM, get_global_transform());
diff --git a/modules/csg/doc_classes/CSGBox3D.xml b/modules/csg/doc_classes/CSGBox3D.xml
index b1d0454b76..5bb1c4e75b 100644
--- a/modules/csg/doc_classes/CSGBox3D.xml
+++ b/modules/csg/doc_classes/CSGBox3D.xml
@@ -14,7 +14,7 @@
<member name="material" type="Material" setter="set_material" getter="get_material">
The material used to render the box.
</member>
- <member name="size" type="Vector3" setter="set_size" getter="get_size" default="Vector3( 2, 2, 2 )">
+ <member name="size" type="Vector3" setter="set_size" getter="get_size" default="Vector3(2, 2, 2)">
The box's width, height and depth.
</member>
</members>
diff --git a/modules/csg/doc_classes/CSGPolygon3D.xml b/modules/csg/doc_classes/CSGPolygon3D.xml
index c55fa0983e..4f29786779 100644
--- a/modules/csg/doc_classes/CSGPolygon3D.xml
+++ b/modules/csg/doc_classes/CSGPolygon3D.xml
@@ -38,7 +38,7 @@
<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 )">
+ <member name="polygon" type="PackedVector2Array" setter="set_polygon" getter="get_polygon" default="PackedVector2Array(0, 0, 0, 1, 1, 1, 1, 0)">
Point array that defines the shape that we'll extrude.
</member>
<member name="smooth_faces" type="bool" setter="set_smooth_faces" getter="get_smooth_faces" default="false">
diff --git a/modules/dds/register_types.cpp b/modules/dds/register_types.cpp
index 1444d33171..60282c3f36 100644
--- a/modules/dds/register_types.cpp
+++ b/modules/dds/register_types.cpp
@@ -35,7 +35,7 @@
static Ref<ResourceFormatDDS> resource_loader_dds;
void register_dds_types() {
- resource_loader_dds.instance();
+ resource_loader_dds.instantiate();
ResourceLoader::add_resource_format_loader(resource_loader_dds);
}
diff --git a/modules/dds/texture_loader_dds.cpp b/modules/dds/texture_loader_dds.cpp
index 2fef576b77..fced61a600 100644
--- a/modules/dds/texture_loader_dds.cpp
+++ b/modules/dds/texture_loader_dds.cpp
@@ -30,7 +30,7 @@
#include "texture_loader_dds.h"
-#include "core/os/file_access.h"
+#include "core/io/file_access.h"
#define PF_FOURCC(s) ((uint32_t)(((s)[3] << 24U) | ((s)[2] << 16U) | ((s)[1] << 8U) | ((s)[0])))
diff --git a/modules/enet/networked_multiplayer_enet.cpp b/modules/enet/networked_multiplayer_enet.cpp
index 9491373013..94260e8c13 100644
--- a/modules/enet/networked_multiplayer_enet.cpp
+++ b/modules/enet/networked_multiplayer_enet.cpp
@@ -362,7 +362,10 @@ void NetworkedMultiplayerENet::poll() {
// To myself and only myself
incoming_packets.push_back(packet);
} else if (!server_relay) {
- // No other destination is allowed when server is not relaying
+ // When relaying is disabled, other destinations will only be processed by the server.
+ if (target == 0 || target < -1) {
+ incoming_packets.push_back(packet);
+ }
continue;
} else if (target == 0) {
// Re-send to everyone but sender :|
diff --git a/modules/fbx/data/fbx_bone.h b/modules/fbx/data/fbx_bone.h
index efba147b89..83918ad1e2 100644
--- a/modules/fbx/data/fbx_bone.h
+++ b/modules/fbx/data/fbx_bone.h
@@ -38,7 +38,7 @@
struct PivotTransform;
-struct FBXBone : public Reference {
+struct FBXBone : public RefCounted {
uint64_t parent_bone_id = 0;
uint64_t bone_id = 0;
diff --git a/modules/fbx/data/fbx_material.cpp b/modules/fbx/data/fbx_material.cpp
index d54ac86e9f..cf5d70fa5b 100644
--- a/modules/fbx/data/fbx_material.cpp
+++ b/modules/fbx/data/fbx_material.cpp
@@ -160,7 +160,7 @@ Ref<StandardMaterial3D> FBXMaterial::import_material(ImportState &state) {
const String p_fbx_current_directory = state.path;
Ref<StandardMaterial3D> spatial_material;
- spatial_material.instance();
+ spatial_material.instantiate();
// read the material file
// is material two sided
@@ -223,7 +223,7 @@ Ref<StandardMaterial3D> FBXMaterial::import_material(ImportState &state) {
} else if (fbx_texture_data != nullptr && fbx_texture_data->Media() != nullptr && fbx_texture_data->Media()->IsEmbedded()) {
// This is an embedded texture. Extract it.
Ref<Image> image;
- //image.instance(); // oooo double instance bug? why make Image::_png_blah call
+ //image.instantiate(); // oooo double instance bug? why make Image::_png_blah call
const String extension = texture_name.get_extension().to_upper();
if (extension == "PNG") {
@@ -256,7 +256,7 @@ Ref<StandardMaterial3D> FBXMaterial::import_material(ImportState &state) {
}
Ref<ImageTexture> image_texture;
- image_texture.instance();
+ image_texture.instantiate();
image_texture->create_from_image(image);
texture = image_texture;
@@ -324,7 +324,7 @@ Ref<StandardMaterial3D> FBXMaterial::import_material(ImportState &state) {
if (spatial_material.is_null()) {
// Done here so if no data no material is created.
- spatial_material.instance();
+ spatial_material.instantiate();
}
const FBXDocParser::TypedProperty<real_t> *real_value = dynamic_cast<const FBXDocParser::TypedProperty<real_t> *>(prop);
@@ -420,7 +420,7 @@ Ref<StandardMaterial3D> FBXMaterial::import_material(ImportState &state) {
} break;
case PROPERTY_DESC_COAT_ROUGHNESS: {
// meaning is that approx equal to zero is disabled not actually zero. ;)
- if (real_value && Math::is_equal_approx(real_value->Value(), 0.0f)) {
+ if (real_value && Math::is_zero_approx(real_value->Value())) {
print_verbose("clearcoat real value: " + rtos(real_value->Value()));
spatial_material->set_clearcoat_gloss(1.0 - real_value->Value());
} else {
@@ -428,7 +428,7 @@ Ref<StandardMaterial3D> FBXMaterial::import_material(ImportState &state) {
}
} break;
case PROPERTY_DESC_EMISSIVE: {
- if (real_value && Math::is_equal_approx(real_value->Value(), 0.0f)) {
+ if (real_value && Math::is_zero_approx(real_value->Value())) {
print_verbose("Emissive real value: " + rtos(real_value->Value()));
spatial_material->set_emission_energy(real_value->Value());
} else if (vector_value && !vector_value->Value().is_equal_approx(Vector3(0, 0, 0))) {
diff --git a/modules/fbx/data/fbx_material.h b/modules/fbx/data/fbx_material.h
index 23310b8e1d..5fd4d9212b 100644
--- a/modules/fbx/data/fbx_material.h
+++ b/modules/fbx/data/fbx_material.h
@@ -33,10 +33,10 @@
#include "tools/import_utils.h"
-#include "core/object/reference.h"
+#include "core/object/ref_counted.h"
#include "core/string/ustring.h"
-struct FBXMaterial : public Reference {
+struct FBXMaterial : public RefCounted {
String material_name = String();
bool warning_non_pbr_material = false;
FBXDocParser::Material *material = nullptr;
@@ -266,7 +266,7 @@ struct FBXMaterial : public Reference {
/* storing the texture properties like color */
template <class T>
- struct TexturePropertyMapping : Reference {
+ struct TexturePropertyMapping : RefCounted {
StandardMaterial3D::TextureParam map_mode = StandardMaterial3D::TextureParam::TEXTURE_ALBEDO;
const T property = T();
};
diff --git a/modules/fbx/data/fbx_mesh_data.cpp b/modules/fbx/data/fbx_mesh_data.cpp
index 8f32c523f9..0d33b8e7c6 100644
--- a/modules/fbx/data/fbx_mesh_data.cpp
+++ b/modules/fbx/data/fbx_mesh_data.cpp
@@ -211,7 +211,7 @@ EditorSceneImporterMeshNode3D *FBXMeshData::create_fbx_mesh(const ImportState &s
const int surface_id = polygon_surfaces[*polygon_id];
if (surfaces.has(surface_id) == false) {
SurfaceData sd;
- sd.surface_tool.instance();
+ sd.surface_tool.instantiate();
sd.surface_tool->begin(Mesh::PRIMITIVE_TRIANGLES);
if (surface_id < 0) {
@@ -316,7 +316,7 @@ EditorSceneImporterMeshNode3D *FBXMeshData::create_fbx_mesh(const ImportState &s
Vector3 *normals_ptr = morph_data->normals.ptrw();
Ref<SurfaceTool> morph_st;
- morph_st.instance();
+ morph_st.instantiate();
morph_st->begin(Mesh::PRIMITIVE_TRIANGLES);
for (unsigned int vi = 0; vi < surface->vertices_map.size(); vi += 1) {
@@ -345,7 +345,7 @@ EditorSceneImporterMeshNode3D *FBXMeshData::create_fbx_mesh(const ImportState &s
// Phase 6. Compose the mesh and return it.
Ref<EditorSceneImporterMesh> mesh;
- mesh.instance();
+ mesh.instantiate();
// Add blend shape info.
for (const String *morph_name = morphs.next(nullptr); morph_name != nullptr; morph_name = morphs.next(morph_name)) {
diff --git a/modules/fbx/data/fbx_mesh_data.h b/modules/fbx/data/fbx_mesh_data.h
index c4eaa7d170..7486c5c59c 100644
--- a/modules/fbx/data/fbx_mesh_data.h
+++ b/modules/fbx/data/fbx_mesh_data.h
@@ -78,7 +78,7 @@ struct VertexData {
};
// Caches mesh information and instantiates meshes for you using helper functions.
-struct FBXMeshData : Reference {
+struct FBXMeshData : RefCounted {
struct MorphVertexData {
// TODO we have only these??
/// Each element is a vertex. Not supposed to be void.
diff --git a/modules/fbx/data/fbx_node.h b/modules/fbx/data/fbx_node.h
index a6f62f3388..75461e397d 100644
--- a/modules/fbx/data/fbx_node.h
+++ b/modules/fbx/data/fbx_node.h
@@ -40,7 +40,7 @@
class Node3D;
struct PivotTransform;
-struct FBXNode : Reference, ModelAbstraction {
+struct FBXNode : RefCounted, ModelAbstraction {
uint64_t current_node_id = 0;
String node_name = String();
Node3D *godot_node = nullptr;
diff --git a/modules/fbx/data/fbx_skeleton.h b/modules/fbx/data/fbx_skeleton.h
index df937cde49..b6103df949 100644
--- a/modules/fbx/data/fbx_skeleton.h
+++ b/modules/fbx/data/fbx_skeleton.h
@@ -35,14 +35,14 @@
#include "fbx_node.h"
#include "model_abstraction.h"
-#include "core/object/reference.h"
+#include "core/object/ref_counted.h"
#include "scene/3d/skeleton_3d.h"
struct FBXNode;
struct ImportState;
struct FBXBone;
-struct FBXSkeleton : Reference {
+struct FBXSkeleton : RefCounted {
Ref<FBXNode> fbx_node = Ref<FBXNode>();
Vector<Ref<FBXBone>> skeleton_bones = Vector<Ref<FBXBone>>();
Skeleton3D *skeleton = nullptr;
diff --git a/modules/fbx/data/pivot_transform.h b/modules/fbx/data/pivot_transform.h
index 29cf7a3d0e..099b268075 100644
--- a/modules/fbx/data/pivot_transform.h
+++ b/modules/fbx/data/pivot_transform.h
@@ -32,7 +32,7 @@
#define PIVOT_TRANSFORM_H
#include "core/math/transform_3d.h"
-#include "core/object/reference.h"
+#include "core/object/ref_counted.h"
#include "model_abstraction.h"
@@ -55,7 +55,7 @@ enum TransformationComp {
TransformationComp_MAXIMUM
};
// Abstract away pivot data so its simpler to handle
-struct PivotTransform : Reference, ModelAbstraction {
+struct PivotTransform : RefCounted, ModelAbstraction {
// at the end we want to keep geometric_ everything, post and pre rotation
// these are used during animation data processing / keyframe ingestion the rest can be simplified down / out.
Quaternion pre_rotation = Quaternion();
diff --git a/modules/fbx/editor_scene_importer_fbx.cpp b/modules/fbx/editor_scene_importer_fbx.cpp
index 40deaae74d..e3f36ef3e3 100644
--- a/modules/fbx/editor_scene_importer_fbx.cpp
+++ b/modules/fbx/editor_scene_importer_fbx.cpp
@@ -373,7 +373,7 @@ Node3D *EditorSceneImporterFBX::_generate_scene(
scene_root->add_child(state.root);
state.root->set_owner(scene_root);
- state.fbx_root_node.instance();
+ state.fbx_root_node.instantiate();
state.fbx_root_node->godot_node = state.root;
// Size relative to cm.
@@ -389,11 +389,11 @@ Node3D *EditorSceneImporterFBX::_generate_scene(
// Enabled by default.
state.enable_animation_import = true;
Ref<FBXNode> root_node;
- root_node.instance();
+ root_node.instantiate();
// make sure fake noFBXDocParser::PropertyPtr ptrde always has a transform too ;)
Ref<PivotTransform> pivot_transform;
- pivot_transform.instance();
+ pivot_transform.instantiate();
root_node->pivot_transform = pivot_transform;
root_node->node_name = "root node";
root_node->current_node_id = 0;
@@ -479,7 +479,7 @@ Node3D *EditorSceneImporterFBX::_generate_scene(
if (state.renderer_mesh_data.has(mesh_id)) {
mesh_vertex_data = state.renderer_mesh_data[mesh_id];
} else {
- mesh_vertex_data.instance();
+ mesh_vertex_data.instantiate();
state.renderer_mesh_data.insert(mesh_id, mesh_vertex_data);
}
@@ -535,7 +535,7 @@ Node3D *EditorSceneImporterFBX::_generate_scene(
ERR_CONTINUE_MSG(!mat, "Could not convert fbx material by id: " + itos(material_id));
Ref<FBXMaterial> material;
- material.instance();
+ material.instantiate();
material->set_imported_material(mat);
Ref<StandardMaterial3D> godot_material = material->import_material(state);
@@ -575,7 +575,7 @@ Node3D *EditorSceneImporterFBX::_generate_scene(
if (state.skeleton_map.has(armature_id)) {
fbx_skeleton_inst = state.skeleton_map[armature_id];
} else {
- fbx_skeleton_inst.instance();
+ fbx_skeleton_inst.instantiate();
state.skeleton_map.insert(armature_id, fbx_skeleton_inst);
}
@@ -650,7 +650,7 @@ Node3D *EditorSceneImporterFBX::_generate_scene(
if (state.renderer_mesh_data.has(mesh_id)) {
mesh_data_precached = state.renderer_mesh_data[mesh_id];
} else {
- mesh_data_precached.instance();
+ mesh_data_precached.instantiate();
state.renderer_mesh_data.insert(mesh_id, mesh_data_precached);
}
@@ -735,7 +735,7 @@ Node3D *EditorSceneImporterFBX::_generate_scene(
Ref<Skin> skin;
if (!state.MeshSkins.has(mesh_id)) {
print_verbose("Created new skin");
- skin.instance();
+ skin.instantiate();
state.MeshSkins.insert(mesh_id, skin);
} else {
print_verbose("Grabbed skin");
@@ -848,7 +848,7 @@ Node3D *EditorSceneImporterFBX::_generate_scene(
}
Ref<Animation> animation;
- animation.instance();
+ animation.instantiate();
animation->set_name(animation_name);
animation->set_length(duration);
@@ -1312,7 +1312,7 @@ void EditorSceneImporterFBX::BuildDocumentBones(Ref<FBXBone> p_parent_bone,
// declare our bone element reference (invalid, unless we create a bone in this step)
// this lets us pass valid armature information into children objects and this is why we moved this up here
- // previously this was created .instanced() on the same line.
+ // previously this was created .instantiated() on the same line.
Ref<FBXBone> bone_element;
if (model != nullptr) {
@@ -1324,7 +1324,7 @@ void EditorSceneImporterFBX::BuildDocumentBones(Ref<FBXBone> p_parent_bone,
ERR_FAIL_COND_MSG(state.fbx_bone_map.has(limb_node->ID()), "[serious] duplicate LimbNode detected");
bool parent_is_bone = state.fbx_bone_map.find(p_id);
- bone_element.instance();
+ bone_element.instantiate();
// used to build the bone hierarchy in the skeleton
bone_element->parent_bone_id = parent_is_bone ? p_id : 0;
@@ -1404,12 +1404,12 @@ void EditorSceneImporterFBX::BuildDocumentNodes(
uint64_t current_node_id = model->ID();
Ref<FBXNode> new_node;
- new_node.instance();
+ new_node.instantiate();
new_node->current_node_id = current_node_id;
new_node->node_name = ImportUtils::FBXNodeToName(model->Name());
Ref<PivotTransform> fbx_transform;
- fbx_transform.instance();
+ fbx_transform.instantiate();
fbx_transform->set_parent(parent_transform);
fbx_transform->set_model(model);
fbx_transform->debug_pivot_xform("name: " + new_node->node_name);
diff --git a/modules/fbx/fbx_parser/FBXParser.cpp b/modules/fbx/fbx_parser/FBXParser.cpp
index 163518d18f..a92b23f4ee 100644
--- a/modules/fbx/fbx_parser/FBXParser.cpp
+++ b/modules/fbx/fbx_parser/FBXParser.cpp
@@ -1167,7 +1167,7 @@ Transform3D ReadMatrix(const ElementPtr element) {
// clean values to prevent any IBM damage on inverse() / affine_inverse()
for (float &value : values) {
- if (::Math::is_equal_approx(0, value)) {
+ if (::Math::is_zero_approx(value)) {
value = 0;
}
}
diff --git a/modules/fbx/register_types.cpp b/modules/fbx/register_types.cpp
index c0591dbc77..b615c91cd2 100644
--- a/modules/fbx/register_types.cpp
+++ b/modules/fbx/register_types.cpp
@@ -36,7 +36,7 @@
#ifdef TOOLS_ENABLED
static void _editor_init() {
Ref<EditorSceneImporterFBX> import_fbx;
- import_fbx.instance();
+ import_fbx.instantiate();
ResourceImporterScene::get_singleton()->add_importer(import_fbx);
}
#endif
diff --git a/modules/fbx/tools/import_utils.h b/modules/fbx/tools/import_utils.h
index 7625f67256..fbe7dbd82f 100644
--- a/modules/fbx/tools/import_utils.h
+++ b/modules/fbx/tools/import_utils.h
@@ -137,15 +137,15 @@ public:
static Vector3 safe_import_vector3(const Vector3 &p_vec) {
Vector3 vector = p_vec;
- if (Math::is_equal_approx(0, vector.x)) {
+ if (Math::is_zero_approx(vector.x)) {
vector.x = 0;
}
- if (Math::is_equal_approx(0, vector.y)) {
+ if (Math::is_zero_approx(vector.y)) {
vector.y = 0;
}
- if (Math::is_equal_approx(0, vector.z)) {
+ if (Math::is_zero_approx(vector.z)) {
vector.z = 0;
}
return vector;
@@ -317,7 +317,7 @@ public:
// }
// } else {
// Ref<Image> img;
- // img.instance();
+ // img.instantiate();
// PoolByteArray arr;
// uint32_t size = tex->mWidth * tex->mHeight;
// arr.resize(size);
@@ -362,7 +362,7 @@ public:
// if (found) {
// image_state.raw_image = AssimpUtils::load_image(state, state.assimp_scene, path);
// if (image_state.raw_image.is_valid()) {
- // image_state.texture.instance();
+ // image_state.texture.instantiate();
// image_state.texture->create_from_image(image_state.raw_image);
// image_state.texture->set_storage(ImageTexture::STORAGE_COMPRESS_LOSSY);
// return true;
diff --git a/modules/fbx/tools/validation_tools.h b/modules/fbx/tools/validation_tools.h
index fe0c92b22f..906a721045 100644
--- a/modules/fbx/tools/validation_tools.h
+++ b/modules/fbx/tools/validation_tools.h
@@ -33,9 +33,8 @@
#ifdef TOOLS_ENABLED
-#include "core/io/json.h"
-#include "core/os/file_access.h"
-#include "core/string/ustring.h"
+#include "core/io/file_access.h"
+#include "core/string/print_string.h"
#include "core/templates/local_vector.h"
#include "core/templates/map.h"
diff --git a/modules/gdnative/doc_classes/GDNative.xml b/modules/gdnative/doc_classes/GDNative.xml
index 44d9e32ed8..4f1530598c 100644
--- a/modules/gdnative/doc_classes/GDNative.xml
+++ b/modules/gdnative/doc_classes/GDNative.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="GDNative" inherits="Reference" version="4.0">
+<class name="GDNative" inherits="RefCounted" version="4.0">
<brief_description>
</brief_description>
<description>
diff --git a/modules/gdnative/gdnative.cpp b/modules/gdnative/gdnative.cpp
index 7c3b76e4d7..1ff591a87f 100644
--- a/modules/gdnative/gdnative.cpp
+++ b/modules/gdnative/gdnative.cpp
@@ -32,9 +32,9 @@
#include "core/config/project_settings.h"
#include "core/core_constants.h"
+#include "core/io/dir_access.h"
+#include "core/io/file_access.h"
#include "core/io/file_access_encrypted.h"
-#include "core/os/dir_access.h"
-#include "core/os/file_access.h"
#include "core/os/os.h"
#include "scene/main/scene_tree.h"
@@ -52,7 +52,7 @@ extern const godot_gdnative_core_api_struct api_struct;
Map<String, Vector<Ref<GDNative>>> GDNativeLibrary::loaded_libraries;
GDNativeLibrary::GDNativeLibrary() {
- config_file.instance();
+ config_file.instantiate();
symbol_prefix = default_symbol_prefix;
load_once = default_load_once;
@@ -112,7 +112,7 @@ bool GDNativeLibrary::_get(const StringName &p_name, Variant &r_property) const
}
void GDNativeLibrary::reset_state() {
- config_file.instance();
+ config_file.instantiate();
current_library_path = "";
current_dependencies.clear();
symbol_prefix = default_symbol_prefix;
@@ -252,7 +252,7 @@ void GDNativeLibrary::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_symbol_prefix", "symbol_prefix"), &GDNativeLibrary::set_symbol_prefix);
ClassDB::bind_method(D_METHOD("set_reloadable", "reloadable"), &GDNativeLibrary::set_reloadable);
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "config_file", PROPERTY_HINT_RESOURCE_TYPE, "ConfigFile", 0), "set_config_file", "get_config_file");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "config_file", PROPERTY_HINT_RESOURCE_TYPE, "ConfigFile", PROPERTY_USAGE_NONE), "set_config_file", "get_config_file");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "load_once"), "set_load_once", "should_load_once");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "singleton"), "set_singleton", "is_singleton");
@@ -532,7 +532,7 @@ Error GDNative::get_symbol(StringName p_procedure_name, void *&r_handle, bool p_
RES GDNativeLibraryResourceLoader::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, CacheMode p_cache_mode) {
Ref<GDNativeLibrary> lib;
- lib.instance();
+ lib.instantiate();
Ref<ConfigFile> config = lib->get_config_file();
diff --git a/modules/gdnative/gdnative.h b/modules/gdnative/gdnative.h
index a28c58ec0d..0cc6487ea4 100644
--- a/modules/gdnative/gdnative.h
+++ b/modules/gdnative/gdnative.h
@@ -138,8 +138,8 @@ struct GDNativeCallRegistry {
Vector<StringName> get_native_call_types();
};
-class GDNative : public Reference {
- GDCLASS(GDNative, Reference);
+class GDNative : public RefCounted {
+ GDCLASS(GDNative, RefCounted);
Ref<GDNativeLibrary> library;
diff --git a/modules/gdnative/gdnative/variant.cpp b/modules/gdnative/gdnative/variant.cpp
index 24f50a94f5..cfb57137bb 100644
--- a/modules/gdnative/gdnative/variant.cpp
+++ b/modules/gdnative/gdnative/variant.cpp
@@ -30,7 +30,7 @@
#include "gdnative/variant.h"
-#include "core/object/reference.h"
+#include "core/object/ref_counted.h"
#include "core/variant/variant.h"
#ifdef __cplusplus
@@ -200,17 +200,17 @@ void GDAPI godot_variant_new_signal(godot_variant *r_dest, const godot_signal *p
void GDAPI godot_variant_new_object(godot_variant *r_dest, const godot_object *p_obj) {
Variant *dest = (Variant *)r_dest;
const Object *obj = (const Object *)p_obj;
- const Reference *reference = Object::cast_to<Reference>(obj);
+ const RefCounted *ref_counted = Object::cast_to<RefCounted>(obj);
REF ref;
- if (reference) {
- ref = REF(reference);
+ if (ref_counted) {
+ ref = REF(ref_counted);
}
if (!ref.is_null()) {
memnew_placement_custom(dest, Variant, Variant(ref));
} else {
#if defined(DEBUG_METHODS_ENABLED)
- if (reference) {
- ERR_PRINT("Reference object has 0 refcount in godot_variant_new_object - you lost it somewhere.");
+ if (ref_counted) {
+ ERR_PRINT("RefCounted object has 0 refcount in godot_variant_new_object - you lost it somewhere.");
}
#endif
memnew_placement_custom(dest, Variant, Variant(obj));
diff --git a/modules/gdnative/gdnative_api.json b/modules/gdnative/gdnative_api.json
index 175a6a3c91..8c65447e5d 100644
--- a/modules/gdnative/gdnative_api.json
+++ b/modules/gdnative/gdnative_api.json
@@ -5068,7 +5068,7 @@
},
{
"name": "godot_xr_get_worldscale",
- "return_type": "godot_float",
+ "return_type": "godot_real_t",
"arguments": []
},
{
@@ -5189,7 +5189,7 @@
"p_exis"
],
[
- "godot_float",
+ "godot_real_t",
"p_value"
],
[
@@ -5200,7 +5200,7 @@
},
{
"name": "godot_xr_get_controller_rumble",
- "return_type": "godot_float",
+ "return_type": "godot_real_t",
"arguments": [
[
"godot_int",
diff --git a/modules/gdnative/gdnative_library_editor_plugin.cpp b/modules/gdnative/gdnative_library_editor_plugin.cpp
index b4ac0d886e..bdbf151393 100644
--- a/modules/gdnative/gdnative_library_editor_plugin.cpp
+++ b/modules/gdnative/gdnative_library_editor_plugin.cpp
@@ -356,12 +356,12 @@ GDNativeLibraryEditor::GDNativeLibraryEditor() {
tree->set_column_titles_visible(true);
tree->set_columns(4);
tree->set_column_expand(0, false);
- tree->set_column_min_width(0, int(200 * EDSCALE));
+ tree->set_column_custom_minimum_width(0, int(200 * EDSCALE));
tree->set_column_title(0, TTR("Platform"));
tree->set_column_title(1, TTR("Dynamic Library"));
tree->set_column_title(2, TTR("Dependencies"));
tree->set_column_expand(3, false);
- tree->set_column_min_width(3, int(110 * EDSCALE));
+ tree->set_column_custom_minimum_width(3, int(110 * EDSCALE));
tree->connect("button_pressed", callable_mp(this, &GDNativeLibraryEditor::_on_item_button));
tree->connect("item_collapsed", callable_mp(this, &GDNativeLibraryEditor::_on_item_collapsed));
tree->connect("item_activated", callable_mp(this, &GDNativeLibraryEditor::_on_item_activated));
diff --git a/modules/gdnative/include/gdnative/variant.h b/modules/gdnative/include/gdnative/variant.h
index dd4f76cf57..a88bd2878a 100644
--- a/modules/gdnative/include/gdnative/variant.h
+++ b/modules/gdnative/include/gdnative/variant.h
@@ -164,7 +164,7 @@ typedef void (*godot_validated_keyed_getter)(const godot_variant *p_base, const
typedef bool (*godot_validated_keyed_checker)(const godot_variant *p_base, const godot_variant *p_key, bool *r_valid);
typedef void (*godot_ptr_keyed_setter)(void *p_base, const void *p_key, const void *p_value);
typedef void (*godot_ptr_keyed_getter)(const void *p_base, const void *p_key, void *r_value);
-typedef bool (*godot_ptr_keyed_checker)(const godot_variant *p_base, const godot_variant *p_key);
+typedef uint32_t (*godot_ptr_keyed_checker)(const godot_variant *p_base, const godot_variant *p_key);
typedef void (*godot_validated_utility_function)(godot_variant *r_return, const godot_variant **p_arguments, int p_argument_count);
typedef void (*godot_ptr_utility_function)(void *r_return, const void **p_arguments, int p_argument_count);
diff --git a/modules/gdnative/include/pluginscript/godot_pluginscript.h b/modules/gdnative/include/pluginscript/godot_pluginscript.h
index 34ed4f097d..02ee4066d0 100644
--- a/modules/gdnative/include/pluginscript/godot_pluginscript.h
+++ b/modules/gdnative/include/pluginscript/godot_pluginscript.h
@@ -132,7 +132,7 @@ typedef struct {
godot_bool can_inherit_from_file;
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);
+ godot_bool (*validate)(godot_pluginscript_language_data *p_data, const godot_string *p_script, const godot_string *p_path, godot_packed_string_array *r_functions, godot_array *r_errors); // errors = Array of Dictionary with "line", "column", "message" keys
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);
diff --git a/modules/gdnative/include/xr/godot_xr.h b/modules/gdnative/include/xr/godot_xr.h
index e09244f3f9..53cb830cbb 100644
--- a/modules/gdnative/include/xr/godot_xr.h
+++ b/modules/gdnative/include/xr/godot_xr.h
@@ -41,8 +41,8 @@ extern "C" {
// version info to detect whether a call is available
// Use these to populate version in your plugin
-#define GODOTVR_API_MAJOR 1
-#define GODOTVR_API_MINOR 1
+#define GODOTVR_API_MAJOR 4
+#define GODOTVR_API_MINOR 0
typedef struct {
godot_gdnative_api_version version; /* version of our API */
@@ -52,24 +52,31 @@ typedef struct {
godot_int (*get_capabilities)(const void *);
godot_bool (*get_anchor_detection_is_enabled)(const void *);
void (*set_anchor_detection_is_enabled)(void *, godot_bool);
- godot_bool (*is_stereo)(const void *);
+ godot_int (*get_view_count)(const void *);
godot_bool (*is_initialized)(const void *);
godot_bool (*initialize)(void *);
void (*uninitialize)(void *);
godot_vector2 (*get_render_targetsize)(const void *);
- godot_transform3d (*get_transform_for_eye)(void *, godot_int, godot_transform3d *);
- void (*fill_projection_for_eye)(void *, godot_float *, godot_int, godot_float, godot_float, godot_float);
- void (*commit_for_eye)(void *, godot_int, godot_rid *, godot_rect2 *);
+
+ godot_transform3d (*get_camera_transform)(void *);
+ godot_transform3d (*get_transform_for_view)(void *, godot_int, godot_transform3d *);
+ void (*fill_projection_for_view)(void *, godot_real_t *, godot_int, godot_real_t, godot_real_t, godot_real_t);
+ void (*commit_views)(void *, godot_rid *, godot_rect2 *);
+
void (*process)(void *);
- godot_int (*get_external_texture_for_eye)(void *, godot_int);
void (*notification)(void *, godot_int);
godot_int (*get_camera_feed_id)(void *);
+
+ // possibly deprecate but adding/keeping as a reminder these are in Godot 3
+ void (*commit_for_eye)(void *, godot_int, godot_rid *, godot_rect2 *);
+ godot_int (*get_external_texture_for_eye)(void *, godot_int);
+ godot_int (*get_external_depth_for_eye)(void *, godot_int);
} godot_xr_interface_gdnative;
void GDAPI godot_xr_register_interface(const godot_xr_interface_gdnative *p_interface);
// helper functions to access XRServer data
-godot_float GDAPI godot_xr_get_worldscale();
+godot_real_t GDAPI godot_xr_get_worldscale();
godot_transform3d GDAPI godot_xr_get_reference_frame();
// helper functions for rendering
@@ -81,8 +88,8 @@ godot_int GDAPI godot_xr_add_controller(char *p_device_name, godot_int p_hand, g
void GDAPI godot_xr_remove_controller(godot_int p_controller_id);
void GDAPI godot_xr_set_controller_transform(godot_int p_controller_id, godot_transform3d *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_float p_value, godot_bool p_can_be_negative);
-godot_float GDAPI godot_xr_get_controller_rumble(godot_int p_controller_id);
+void GDAPI godot_xr_set_controller_axis(godot_int p_controller_id, godot_int p_axis, godot_real_t p_value, godot_bool p_can_be_negative);
+godot_real_t GDAPI godot_xr_get_controller_rumble(godot_int p_controller_id);
#ifdef __cplusplus
}
diff --git a/modules/gdnative/nativescript/api_generator.cpp b/modules/gdnative/nativescript/api_generator.cpp
index f184c84615..4f696f2a39 100644
--- a/modules/gdnative/nativescript/api_generator.cpp
+++ b/modules/gdnative/nativescript/api_generator.cpp
@@ -34,10 +34,11 @@
#include "core/config/engine.h"
#include "core/core_constants.h"
+#include "core/io/file_access.h"
#include "core/object/class_db.h"
-#include "core/os/file_access.h"
#include "core/string/string_builder.h"
#include "core/templates/pair.h"
+#include "core/variant/variant_parser.h"
// helper stuff
@@ -121,7 +122,7 @@ struct ClassAPI {
String singleton_name;
bool is_instantiable = false;
// @Unclear
- bool is_reference = false;
+ bool is_ref_counted = false;
bool has_indexing = false; // For builtin types.
String indexed_type; // For builtin types.
bool is_keyed = false; // For builtin types.
@@ -250,14 +251,14 @@ List<ClassAPI> generate_c_api_classes() {
class_api.singleton_name = name;
}
}
- class_api.is_instantiable = !class_api.is_singleton && ClassDB::can_instance(class_name);
+ class_api.is_instantiable = !class_api.is_singleton && ClassDB::can_instantiate(class_name);
{
List<StringName> inheriters;
- ClassDB::get_inheriters_from_class("Reference", &inheriters);
- bool is_reference = !!inheriters.find(class_name) || class_name == "Reference";
+ ClassDB::get_inheriters_from_class("RefCounted", &inheriters);
+ bool is_ref_counted = !!inheriters.find(class_name) || class_name == "RefCounted";
// @Unclear
- class_api.is_reference = !class_api.is_singleton && is_reference;
+ class_api.is_ref_counted = !class_api.is_singleton && is_ref_counted;
}
// constants
@@ -509,10 +510,10 @@ List<ClassAPI> generate_c_builtin_api_types() {
case Variant::PACKED_VECTOR2_ARRAY:
case Variant::PACKED_VECTOR3_ARRAY:
case Variant::PACKED_COLOR_ARRAY:
- class_api.is_reference = true;
+ class_api.is_ref_counted = true;
break;
default:
- class_api.is_reference = false;
+ class_api.is_ref_counted = false;
break;
}
@@ -638,6 +639,7 @@ static List<String> generate_c_api_json(const List<ClassAPI> &p_api) {
// I'm sorry for the \t mess
List<String> source;
+ VariantWriter writer;
source.push_back("[\n");
@@ -652,7 +654,7 @@ static List<String> generate_c_api_json(const List<ClassAPI> &p_api) {
source.push_back(String("\t\t\"singleton\": ") + (api.is_singleton ? "true" : "false") + ",\n");
source.push_back("\t\t\"singleton_name\": \"" + api.singleton_name + "\",\n");
source.push_back(String("\t\t\"instantiable\": ") + (api.is_instantiable ? "true" : "false") + ",\n");
- source.push_back(String("\t\t\"is_reference\": ") + (api.is_reference ? "true" : "false") + ",\n");
+ source.push_back(String("\t\t\"is_ref_counted\": ") + (api.is_ref_counted ? "true" : "false") + ",\n");
source.push_back("\t\t\"constants\": {\n");
for (List<ConstantAPI>::Element *e = api.constants.front(); e; e = e->next()) {
@@ -682,7 +684,12 @@ static List<String> generate_c_api_json(const List<ClassAPI> &p_api) {
source.push_back("\t\t\t\t\t\t\"name\": \"" + e->get().argument_names[i] + "\",\n");
source.push_back("\t\t\t\t\t\t\"type\": \"" + e->get().argument_types[i] + "\",\n");
source.push_back(String("\t\t\t\t\t\t\"has_default_value\": ") + (e->get().default_arguments.has(i) ? "true" : "false") + ",\n");
- source.push_back("\t\t\t\t\t\t\"default_value\": \"" + (e->get().default_arguments.has(i) ? (String)e->get().default_arguments[i] : "") + "\"\n");
+ String default_value;
+ if (e->get().default_arguments.has(i)) {
+ writer.write_to_string(e->get().default_arguments[i], default_value);
+ default_value = default_value.replace("\n", "").json_escape();
+ }
+ source.push_back("\t\t\t\t\t\t\"default_value\": \"" + default_value + "\"\n");
source.push_back(String("\t\t\t\t\t}") + ((i < e->get().argument_names.size() - 1) ? "," : "") + "\n");
}
source.push_back("\t\t\t\t]\n");
@@ -708,7 +715,12 @@ static List<String> generate_c_api_json(const List<ClassAPI> &p_api) {
source.push_back("\t\t\t\t\t\t\"name\": \"" + e->get().argument_names[i] + "\",\n");
source.push_back("\t\t\t\t\t\t\"type\": \"" + e->get().argument_types[i] + "\",\n");
source.push_back(String("\t\t\t\t\t\t\"has_default_value\": ") + (e->get().default_arguments.has(i) ? "true" : "false") + ",\n");
- source.push_back("\t\t\t\t\t\t\"default_value\": \"" + (e->get().default_arguments.has(i) ? (String)e->get().default_arguments[i] : "") + "\"\n");
+ String default_value;
+ if (e->get().default_arguments.has(i)) {
+ writer.write_to_string(e->get().default_arguments[i], default_value);
+ default_value = default_value.replace("\n", "").json_escape();
+ }
+ source.push_back("\t\t\t\t\t\t\"default_value\": \"" + default_value + "\"\n");
source.push_back(String("\t\t\t\t\t}") + ((i < e->get().argument_names.size() - 1) ? "," : "") + "\n");
}
source.push_back("\t\t\t\t]\n");
@@ -756,6 +768,8 @@ static void append_indented(StringBuilder &p_source, const char *p_text) {
}
static void write_builtin_method(StringBuilder &p_source, const MethodAPI &p_method) {
+ VariantWriter writer;
+
append_indented(p_source, vformat(R"("name": "%s",)", p_method.method_name));
append_indented(p_source, vformat(R"("return_type": "%s",)", p_method.return_type));
append_indented(p_source, vformat(R"("is_const": %s,)", p_method.is_const ? "true" : "false"));
@@ -771,7 +785,12 @@ static void write_builtin_method(StringBuilder &p_source, const MethodAPI &p_met
append_indented(p_source, vformat(R"("name": "%s",)", p_method.argument_names[i]));
append_indented(p_source, vformat(R"("type": "%s",)", p_method.argument_types[i]));
append_indented(p_source, vformat(R"("has_default_value": %s,)", p_method.default_arguments.has(i) ? "true" : "false"));
- append_indented(p_source, vformat(R"("default_value": "%s")", p_method.default_arguments.has(i) ? p_method.default_arguments[i].operator String() : ""));
+ String default_value;
+ if (p_method.default_arguments.has(i)) {
+ writer.write_to_string(p_method.default_arguments[i], default_value);
+ default_value = default_value.replace("\n", "").json_escape();
+ }
+ append_indented(p_source, vformat(R"("default_value": "%s")", default_value));
indent_level--;
append_indented(p_source, i < p_method.argument_count - 1 ? "}," : "}");
@@ -794,7 +813,7 @@ static List<String> generate_c_builtin_api_json(const List<ClassAPI> &p_api) {
append_indented(source, vformat(R"("name": "%s",)", class_api.class_name));
append_indented(source, vformat(R"("is_instantiable": %s,)", class_api.is_instantiable ? "true" : "false"));
- append_indented(source, vformat(R"("is_reference": %s,)", class_api.is_reference ? "true" : "false"));
+ append_indented(source, vformat(R"("is_ref_counted": %s,)", class_api.is_ref_counted ? "true" : "false"));
append_indented(source, vformat(R"("has_indexing": %s,)", class_api.has_indexing ? "true" : "false"));
append_indented(source, vformat(R"("indexed_type": "%s",)", class_api.has_indexing && class_api.indexed_type == "Nil" ? "Variant" : class_api.indexed_type));
append_indented(source, vformat(R"("is_keyed": %s,)", class_api.is_keyed ? "true" : "false"));
diff --git a/modules/gdnative/nativescript/nativescript.cpp b/modules/gdnative/nativescript/nativescript.cpp
index 03e25f49e6..3695f6b9a3 100644
--- a/modules/gdnative/nativescript/nativescript.cpp
+++ b/modules/gdnative/nativescript/nativescript.cpp
@@ -37,8 +37,8 @@
#include "core/config/project_settings.h"
#include "core/core_constants.h"
#include "core/core_string_names.h"
+#include "core/io/file_access.h"
#include "core/io/file_access_encrypted.h"
-#include "core/os/file_access.h"
#include "core/os/os.h"
#include "main/main.h"
@@ -170,7 +170,7 @@ String NativeScript::get_script_class_icon_path() const {
return script_class_icon_path;
}
-bool NativeScript::can_instance() const {
+bool NativeScript::can_instantiate() const {
NativeScriptDesc *script_data = get_script_desc();
#ifdef TOOLS_ENABLED
@@ -503,9 +503,9 @@ Variant NativeScript::_new(const Variant **p_args, int p_argcount, Callable::Cal
Object *owner = nullptr;
if (!(script_data->base_native_type == "")) {
- owner = ClassDB::instance(script_data->base_native_type);
+ owner = ClassDB::instantiate(script_data->base_native_type);
} else {
- owner = memnew(Reference);
+ owner = memnew(RefCounted);
}
if (!owner) {
@@ -513,7 +513,7 @@ Variant NativeScript::_new(const Variant **p_args, int p_argcount, Callable::Cal
return Variant();
}
- Reference *r = Object::cast_to<Reference>(owner);
+ RefCounted *r = Object::cast_to<RefCounted>(owner);
if (r) {
ref = REF(r);
}
@@ -1035,7 +1035,7 @@ Ref<Script> NativeScriptLanguage::get_template(const String &p_class_name, const
return Ref<NativeScript>(s);
}
-bool NativeScriptLanguage::validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path, List<String> *r_functions, List<ScriptLanguage::Warning> *r_warnings, Set<int> *r_safe_lines) const {
+bool NativeScriptLanguage::validate(const String &p_script, const String &p_path, List<String> *r_functions, List<ScriptLanguage::ScriptError> *r_errors, List<ScriptLanguage::Warning> *r_warnings, Set<int> *r_safe_lines) const {
return true;
}
@@ -1422,7 +1422,7 @@ void NativeScriptLanguage::init_library(const Ref<GDNativeLibrary> &lib) {
if (!E) {
Ref<GDNative> gdn;
- gdn.instance();
+ gdn.instantiate();
gdn->set_library(lib);
// TODO check the return value?
diff --git a/modules/gdnative/nativescript/nativescript.h b/modules/gdnative/nativescript/nativescript.h
index 1756321281..777a878660 100644
--- a/modules/gdnative/nativescript/nativescript.h
+++ b/modules/gdnative/nativescript/nativescript.h
@@ -137,7 +137,7 @@ public:
void set_script_class_icon_path(String p_icon_path);
String get_script_class_icon_path() const;
- virtual bool can_instance() const override;
+ virtual bool can_instantiate() const override;
virtual Ref<Script> get_base_script() const override; //for script inheritance
@@ -317,7 +317,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 = nullptr, Set<int> *r_safe_lines = nullptr) const;
+ virtual bool validate(const String &p_script, const String &p_path, List<String> *r_functions, List<ScriptLanguage::ScriptError> *r_errors = 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/nativescript/register_types.cpp b/modules/gdnative/nativescript/register_types.cpp
index 0353ab2092..0191cfd809 100644
--- a/modules/gdnative/nativescript/register_types.cpp
+++ b/modules/gdnative/nativescript/register_types.cpp
@@ -50,10 +50,10 @@ void register_nativescript_types() {
native_script_language->set_language_index(ScriptServer::get_language_count());
ScriptServer::register_language(native_script_language);
- resource_saver_gdns.instance();
+ resource_saver_gdns.instantiate();
ResourceSaver::add_resource_format_saver(resource_saver_gdns);
- resource_loader_gdns.instance();
+ resource_loader_gdns.instantiate();
ResourceLoader::add_resource_format_loader(resource_loader_gdns);
}
diff --git a/modules/gdnative/pluginscript/pluginscript_language.cpp b/modules/gdnative/pluginscript/pluginscript_language.cpp
index 1360cf0299..79aba342c9 100644
--- a/modules/gdnative/pluginscript/pluginscript_language.cpp
+++ b/modules/gdnative/pluginscript/pluginscript_language.cpp
@@ -30,7 +30,7 @@
// Godot imports
#include "core/config/project_settings.h"
-#include "core/os/file_access.h"
+#include "core/io/file_access.h"
#include "core/os/os.h"
// PluginScript imports
#include "pluginscript_language.h"
@@ -112,20 +112,29 @@ Ref<Script> PluginScriptLanguage::get_template(const String &p_class_name, const
return script;
}
-bool PluginScriptLanguage::validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path, List<String> *r_functions, List<ScriptLanguage::Warning> *r_warnings, Set<int> *r_safe_lines) const {
+bool PluginScriptLanguage::validate(const String &p_script, const String &p_path, List<String> *r_functions, List<ScriptLanguage::ScriptError> *r_errors, List<ScriptLanguage::Warning> *r_warnings, Set<int> *r_safe_lines) const {
PackedStringArray functions;
+ Array errors;
if (_desc.validate) {
bool ret = _desc.validate(
_data,
(godot_string *)&p_script,
- &r_line_error,
- &r_col_error,
- (godot_string *)&r_test_error,
(godot_string *)&p_path,
- (godot_packed_string_array *)&functions);
+ (godot_packed_string_array *)&functions,
+ (godot_array *)&errors);
for (int i = 0; i < functions.size(); i++) {
r_functions->push_back(functions[i]);
}
+ if (r_errors) {
+ for (int i = 0; i < errors.size(); i++) {
+ Dictionary error = errors[i];
+ ScriptLanguage::ScriptError e;
+ e.line = error["line"];
+ e.column = error["column"];
+ e.message = error["message"];
+ r_errors->push_back(e);
+ }
+ }
return ret;
}
return true;
diff --git a/modules/gdnative/pluginscript/pluginscript_language.h b/modules/gdnative/pluginscript/pluginscript_language.h
index 957bf355ca..26ab4a95e3 100644
--- a/modules/gdnative/pluginscript/pluginscript_language.h
+++ b/modules/gdnative/pluginscript/pluginscript_language.h
@@ -75,7 +75,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 = nullptr, List<ScriptLanguage::Warning> *r_warnings = nullptr, Set<int> *r_safe_lines = nullptr) const;
+ virtual bool validate(const String &p_script, const String &p_path = "", List<String> *r_functions = nullptr, List<ScriptLanguage::ScriptError> *r_errors = 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 f2165cd225..462452a897 100644
--- a/modules/gdnative/pluginscript/pluginscript_loader.cpp
+++ b/modules/gdnative/pluginscript/pluginscript_loader.cpp
@@ -29,7 +29,7 @@
/*************************************************************************/
// Godot imports
-#include "core/os/file_access.h"
+#include "core/io/file_access.h"
// Pythonscript imports
#include "pluginscript_language.h"
#include "pluginscript_loader.h"
diff --git a/modules/gdnative/pluginscript/pluginscript_script.cpp b/modules/gdnative/pluginscript/pluginscript_script.cpp
index 6bb11d3e8f..7fc8178e34 100644
--- a/modules/gdnative/pluginscript/pluginscript_script.cpp
+++ b/modules/gdnative/pluginscript/pluginscript_script.cpp
@@ -29,7 +29,7 @@
/*************************************************************************/
// Godot imports
-#include "core/os/file_access.h"
+#include "core/io/file_access.h"
// PluginScript imports
#include "pluginscript_instance.h"
#include "pluginscript_script.h"
@@ -38,13 +38,13 @@
#ifdef DEBUG_ENABLED
#define __ASSERT_SCRIPT_REASON "Cannot retrieve PluginScript class for this script, is your code correct?"
-#define ASSERT_SCRIPT_VALID() \
- { \
- ERR_FAIL_COND_MSG(!can_instance(), __ASSERT_SCRIPT_REASON); \
+#define ASSERT_SCRIPT_VALID() \
+ { \
+ ERR_FAIL_COND_MSG(!can_instantiate(), __ASSERT_SCRIPT_REASON); \
}
-#define ASSERT_SCRIPT_VALID_V(ret) \
- { \
- ERR_FAIL_COND_V_MSG(!can_instance(), ret, __ASSERT_SCRIPT_REASON); \
+#define ASSERT_SCRIPT_VALID_V(ret) \
+ { \
+ ERR_FAIL_COND_V_MSG(!can_instantiate(), ret, __ASSERT_SCRIPT_REASON); \
}
#else
#define ASSERT_SCRIPT_VALID()
@@ -94,9 +94,9 @@ Variant PluginScript::_new(const Variant **p_args, int p_argcount, Callable::Cal
Object *owner = nullptr;
if (get_instance_base_type() == "") {
- owner = memnew(Reference);
+ owner = memnew(RefCounted);
} else {
- owner = ClassDB::instance(get_instance_base_type());
+ owner = ClassDB::instantiate(get_instance_base_type());
}
if (!owner) {
@@ -104,7 +104,7 @@ Variant PluginScript::_new(const Variant **p_args, int p_argcount, Callable::Cal
return Variant();
}
- Reference *r = Object::cast_to<Reference>(owner);
+ RefCounted *r = Object::cast_to<RefCounted>(owner);
if (r) {
ref = REF(r);
}
@@ -133,7 +133,7 @@ void PluginScript::_placeholder_erased(PlaceHolderScriptInstance *p_placeholder)
#endif
-bool PluginScript::can_instance() const {
+bool PluginScript::can_instantiate() const {
bool can = _valid || (!_tool && !ScriptServer::is_scripting_enabled());
return can;
}
@@ -198,7 +198,7 @@ ScriptInstance *PluginScript::instance_create(Object *p_this) {
StringName base_type = get_instance_base_type();
if (base_type) {
if (!ClassDB::is_parent_class(p_this->get_class_name(), base_type)) {
- String msg = "Script inherits from native type '" + String(base_type) + "', so it can't be instanced in object of type: '" + p_this->get_class() + "'";
+ String msg = "Script inherits from native type '" + String(base_type) + "', so it can't be instantiated in object of type: '" + p_this->get_class() + "'";
// TODO: implement PluginscriptLanguage::debug_break_parse
// if (EngineDebugger::is_active()) {
// _language->debug_break_parse(get_path(), 0, msg);
diff --git a/modules/gdnative/pluginscript/pluginscript_script.h b/modules/gdnative/pluginscript/pluginscript_script.h
index 97989a19d8..838195147f 100644
--- a/modules/gdnative/pluginscript/pluginscript_script.h
+++ b/modules/gdnative/pluginscript/pluginscript_script.h
@@ -92,7 +92,7 @@ public:
return _icon_path;
}
- virtual bool can_instance() const override;
+ virtual bool can_instantiate() const override;
virtual Ref<Script> get_base_script() const override; //for script inheritance
diff --git a/modules/gdnative/pluginscript/register_types.cpp b/modules/gdnative/pluginscript/register_types.cpp
index b94538b2f7..433544178f 100644
--- a/modules/gdnative/pluginscript/register_types.cpp
+++ b/modules/gdnative/pluginscript/register_types.cpp
@@ -31,9 +31,9 @@
#include "register_types.h"
#include "core/config/project_settings.h"
+#include "core/io/dir_access.h"
#include "core/io/resource_loader.h"
#include "core/io/resource_saver.h"
-#include "core/os/dir_access.h"
#include "core/os/os.h"
#include "scene/main/scene_tree.h"
diff --git a/modules/gdnative/register_types.cpp b/modules/gdnative/register_types.cpp
index cf19c0c44c..8e20a2b90d 100644
--- a/modules/gdnative/register_types.cpp
+++ b/modules/gdnative/register_types.cpp
@@ -230,7 +230,7 @@ static void editor_init_callback() {
ProjectSettingsEditor::get_singleton()->get_tabs()->add_child(library_editor);
Ref<GDNativeExportPlugin> export_plugin;
- export_plugin.instance();
+ export_plugin.instantiate();
EditorExport::get_singleton()->add_export_plugin(export_plugin);
@@ -262,10 +262,10 @@ void register_gdnative_types() {
ClassDB::register_class<GDNativeLibrary>();
ClassDB::register_class<GDNative>();
- resource_loader_gdnlib.instance();
+ resource_loader_gdnlib.instantiate();
ResourceLoader::add_resource_format_loader(resource_loader_gdnlib);
- resource_saver_gdnlib.instance();
+ resource_saver_gdnlib.instantiate();
ResourceSaver::add_resource_format_saver(resource_saver_gdnlib);
GDNativeCallRegistry::singleton = memnew(GDNativeCallRegistry);
@@ -298,7 +298,7 @@ void register_gdnative_types() {
Ref<GDNativeLibrary> lib = ResourceLoader::load(path);
Ref<GDNative> singleton;
- singleton.instance();
+ singleton.instantiate();
singleton->set_library(lib);
if (!singleton->initialize()) {
diff --git a/modules/gdnative/videodecoder/register_types.cpp b/modules/gdnative/videodecoder/register_types.cpp
index 394831daeb..e822d42312 100644
--- a/modules/gdnative/videodecoder/register_types.cpp
+++ b/modules/gdnative/videodecoder/register_types.cpp
@@ -36,7 +36,7 @@
static Ref<ResourceFormatLoaderVideoStreamGDNative> resource_loader_vsgdnative;
void register_videodecoder_types() {
- resource_loader_vsgdnative.instance();
+ resource_loader_vsgdnative.instantiate();
ResourceLoader::add_resource_format_loader(resource_loader_vsgdnative, true);
ClassDB::register_class<VideoStreamGDNative>();
diff --git a/modules/gdnative/videodecoder/video_stream_gdnative.cpp b/modules/gdnative/videodecoder/video_stream_gdnative.cpp
index 8b0434c7dd..26b044c0ef 100644
--- a/modules/gdnative/videodecoder/video_stream_gdnative.cpp
+++ b/modules/gdnative/videodecoder/video_stream_gdnative.cpp
@@ -122,7 +122,7 @@ bool VideoStreamPlaybackGDNative::open_file(const String &p_file) {
samples_decoded = 0;
Ref<Image> img;
- img.instance();
+ img.instantiate();
img->create((int)texture_size.width, false, (int)texture_size.height, Image::FORMAT_RGBA8);
texture->create_from_image(img);
diff --git a/modules/gdnative/videodecoder/video_stream_gdnative.h b/modules/gdnative/videodecoder/video_stream_gdnative.h
index 140888cd4b..c605dbb433 100644
--- a/modules/gdnative/videodecoder/video_stream_gdnative.h
+++ b/modules/gdnative/videodecoder/video_stream_gdnative.h
@@ -32,7 +32,7 @@
#define VIDEO_STREAM_GDNATIVE_H
#include "../gdnative.h"
-#include "core/os/file_access.h"
+#include "core/io/file_access.h"
#include "scene/resources/texture.h"
#include "scene/resources/video_stream.h"
diff --git a/modules/gdnative/xr/xr_interface_gdnative.cpp b/modules/gdnative/xr/xr_interface_gdnative.cpp
index 258fb75000..e51542e23d 100644
--- a/modules/gdnative/xr/xr_interface_gdnative.cpp
+++ b/modules/gdnative/xr/xr_interface_gdnative.cpp
@@ -70,8 +70,13 @@ void XRInterfaceGDNative::set_interface(const godot_xr_interface_gdnative *p_int
// this should only be called once, just being paranoid..
if (interface) {
cleanup();
+ interface = NULL;
}
+ // validate
+ ERR_FAIL_NULL(p_interface);
+ ERR_FAIL_COND_MSG(p_interface->version.major < 4, "This is an incompatible GDNative XR plugin.");
+
// bind to our interface
interface = p_interface;
@@ -119,14 +124,14 @@ int XRInterfaceGDNative::get_camera_feed_id() {
return (unsigned int)interface->get_camera_feed_id(data);
}
-bool XRInterfaceGDNative::is_stereo() {
- bool stereo;
+uint32_t XRInterfaceGDNative::get_view_count() {
+ uint32_t view_count;
- ERR_FAIL_COND_V(interface == nullptr, false);
+ ERR_FAIL_COND_V(interface == nullptr, 1);
- stereo = interface->is_stereo(data);
+ view_count = interface->get_view_count(data);
- return stereo;
+ return view_count;
}
bool XRInterfaceGDNative::is_initialized() const {
@@ -173,28 +178,52 @@ Size2 XRInterfaceGDNative::get_render_targetsize() {
return *vec;
}
-Transform3D XRInterfaceGDNative::get_transform_for_eye(XRInterface::Eyes p_eye, const Transform3D &p_cam_transform) {
+Transform3D XRInterfaceGDNative::get_camera_transform() {
Transform3D *ret;
ERR_FAIL_COND_V(interface == nullptr, Transform3D());
- godot_transform3d t = interface->get_transform_for_eye(data, (int)p_eye, (godot_transform3d *)&p_cam_transform);
+ godot_transform3d t = interface->get_camera_transform(data);
ret = (Transform3D *)&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) {
+Transform3D XRInterfaceGDNative::get_transform_for_view(uint32_t p_view, const Transform3D &p_cam_transform) {
+ Transform3D *ret;
+
+ ERR_FAIL_COND_V(interface == nullptr, Transform3D());
+
+ godot_transform3d t = interface->get_transform_for_view(data, (int)p_view, (godot_transform3d *)&p_cam_transform);
+
+ ret = (Transform3D *)&t;
+
+ return *ret;
+}
+
+CameraMatrix XRInterfaceGDNative::get_projection_for_view(uint32_t p_view, 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_float *)cm.matrix, (godot_int)p_eye, p_aspect, p_z_near, p_z_far);
+ interface->fill_projection_for_view(data, (godot_real_t *)cm.matrix, (godot_int)p_view, p_aspect, p_z_near, p_z_far);
return cm;
}
+Vector<BlitToScreen> XRInterfaceGDNative::commit_views(RID p_render_target, const Rect2 &p_screen_rect) {
+ // possibly move this as a member variable and add a callback to populate?
+ Vector<BlitToScreen> blit_to_screen;
+
+ ERR_FAIL_COND_V(interface == nullptr, blit_to_screen);
+
+ // must implement
+ interface->commit_views(data, (godot_rid *)&p_render_target, (godot_rect2 *)&p_screen_rect);
+
+ return blit_to_screen;
+}
+
unsigned int XRInterfaceGDNative::get_external_texture_for_eye(XRInterface::Eyes p_eye) {
ERR_FAIL_COND_V(interface == nullptr, 0);
@@ -229,12 +258,12 @@ void GDAPI godot_xr_register_interface(const godot_xr_interface_gdnative *p_inte
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.instantiate();
new_interface->set_interface((const godot_xr_interface_gdnative *)p_interface);
XRServer::get_singleton()->add_interface(new_interface);
}
-godot_float GDAPI godot_xr_get_worldscale() {
+godot_real_t GDAPI godot_xr_get_worldscale() {
XRServer *xr_server = XRServer::get_singleton();
ERR_FAIL_NULL_V(xr_server, 1.0);
@@ -302,7 +331,7 @@ godot_int GDAPI godot_xr_add_controller(char *p_device_name, godot_int p_hand, g
ERR_FAIL_NULL_V(input, 0);
Ref<XRPositionalTracker> new_tracker;
- new_tracker.instance();
+ new_tracker.instantiate();
new_tracker->set_tracker_name(p_device_name);
new_tracker->set_tracker_type(XRServer::TRACKER_CONTROLLER);
if (p_hand == 1) {
@@ -383,12 +412,12 @@ void GDAPI godot_xr_set_controller_button(godot_int p_controller_id, godot_int p
if (tracker.is_valid()) {
int joyid = tracker->get_joy_id();
if (joyid != -1) {
- input->joy_button(joyid, p_button, p_is_pressed);
+ input->joy_button(joyid, (JoyButton)p_button, p_is_pressed);
}
}
}
-void GDAPI godot_xr_set_controller_axis(godot_int p_controller_id, godot_int p_axis, godot_float p_value, godot_bool p_can_be_negative) {
+void GDAPI godot_xr_set_controller_axis(godot_int p_controller_id, godot_int p_axis, godot_real_t p_value, godot_bool p_can_be_negative) {
XRServer *xr_server = XRServer::get_singleton();
ERR_FAIL_NULL(xr_server);
@@ -402,12 +431,12 @@ void GDAPI godot_xr_set_controller_axis(godot_int p_controller_id, godot_int p_a
Input::JoyAxisValue jx;
jx.min = p_can_be_negative ? -1 : 0;
jx.value = p_value;
- input->joy_axis(joyid, p_axis, jx);
+ input->joy_axis(joyid, (JoyAxis)p_axis, jx);
}
}
}
-godot_float GDAPI godot_xr_get_controller_rumble(godot_int p_controller_id) {
+godot_real_t 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);
diff --git a/modules/gdnative/xr/xr_interface_gdnative.h b/modules/gdnative/xr/xr_interface_gdnative.h
index 42098ebeff..42e9206c1f 100644
--- a/modules/gdnative/xr/xr_interface_gdnative.h
+++ b/modules/gdnative/xr/xr_interface_gdnative.h
@@ -72,20 +72,24 @@ public:
/** rendering and internal **/
virtual Size2 get_render_targetsize() override;
- virtual bool is_stereo() override;
- virtual Transform3D get_transform_for_eye(XRInterface::Eyes p_eye, const Transform3D &p_cam_transform) override;
+ virtual uint32_t get_view_count() override;
+ virtual Transform3D get_camera_transform() override;
+ virtual Transform3D get_transform_for_view(uint32_t p_view, const Transform3D &p_cam_transform) override;
// we expose a Vector<float> version of this function to GDNative
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 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) override;
+ virtual CameraMatrix get_projection_for_view(uint32_t p_view, real_t p_aspect, real_t p_z_near, real_t p_z_far) override;
- virtual unsigned int get_external_texture_for_eye(XRInterface::Eyes p_eye) override;
- virtual void commit_for_eye(XRInterface::Eyes p_eye, RID p_render_target, const Rect2 &p_screen_rect) override;
+ virtual Vector<BlitToScreen> commit_views(RID p_render_target, const Rect2 &p_screen_rect) override;
virtual void process() override;
virtual void notification(int p_what) override;
+
+ // deprecated
+ virtual void commit_for_eye(XRInterface::Eyes p_eye, RID p_render_target, const Rect2 &p_screen_rect) override;
+ virtual unsigned int get_external_texture_for_eye(XRInterface::Eyes p_eye) override;
};
#endif // XR_INTERFACE_GDNATIVE_H
diff --git a/modules/gdnavigation/navigation_mesh_generator.cpp b/modules/gdnavigation/navigation_mesh_generator.cpp
index d69c9114b9..0d8330c1da 100644
--- a/modules/gdnavigation/navigation_mesh_generator.cpp
+++ b/modules/gdnavigation/navigation_mesh_generator.cpp
@@ -177,7 +177,7 @@ void NavigationMeshGenerator::_parse_geometry(Transform3D p_accumulated_transfor
BoxShape3D *box = Object::cast_to<BoxShape3D>(*s);
if (box) {
Ref<BoxMesh> box_mesh;
- box_mesh.instance();
+ box_mesh.instantiate();
box_mesh->set_size(box->get_size());
mesh = box_mesh;
}
@@ -185,7 +185,7 @@ void NavigationMeshGenerator::_parse_geometry(Transform3D p_accumulated_transfor
CapsuleShape3D *capsule = Object::cast_to<CapsuleShape3D>(*s);
if (capsule) {
Ref<CapsuleMesh> capsule_mesh;
- capsule_mesh.instance();
+ capsule_mesh.instantiate();
capsule_mesh->set_radius(capsule->get_radius());
capsule_mesh->set_mid_height(capsule->get_height() / 2.0);
mesh = capsule_mesh;
@@ -194,7 +194,7 @@ void NavigationMeshGenerator::_parse_geometry(Transform3D p_accumulated_transfor
CylinderShape3D *cylinder = Object::cast_to<CylinderShape3D>(*s);
if (cylinder) {
Ref<CylinderMesh> cylinder_mesh;
- cylinder_mesh.instance();
+ cylinder_mesh.instantiate();
cylinder_mesh->set_height(cylinder->get_height());
cylinder_mesh->set_bottom_radius(cylinder->get_radius());
cylinder_mesh->set_top_radius(cylinder->get_radius());
@@ -204,7 +204,7 @@ void NavigationMeshGenerator::_parse_geometry(Transform3D p_accumulated_transfor
SphereShape3D *sphere = Object::cast_to<SphereShape3D>(*s);
if (sphere) {
Ref<SphereMesh> sphere_mesh;
- sphere_mesh.instance();
+ sphere_mesh.instantiate();
sphere_mesh->set_radius(sphere->get_radius());
sphere_mesh->set_height(sphere->get_radius() * 2.0);
mesh = sphere_mesh;
@@ -255,7 +255,7 @@ void NavigationMeshGenerator::_parse_geometry(Transform3D p_accumulated_transfor
for (int i = 0; i < meshes.size(); i += 2) {
Ref<Mesh> mesh = meshes[i + 1];
if (mesh.is_valid()) {
- _add_mesh(mesh, p_accumulated_transform * xform * meshes[i], p_verticies, p_indices);
+ _add_mesh(mesh, p_accumulated_transform * xform * (Transform3D)meshes[i], p_verticies, p_indices);
}
}
}
diff --git a/modules/gdscript/doc_classes/@GDScript.xml b/modules/gdscript/doc_classes/@GDScript.xml
index 9e974b6fdc..839aa6b3c6 100644
--- a/modules/gdscript/doc_classes/@GDScript.xml
+++ b/modules/gdscript/doc_classes/@GDScript.xml
@@ -177,7 +177,7 @@
[b]Note:[/b] Resource paths can be obtained by right clicking on a resource in the Assets Panel and choosing "Copy Path" or by dragging the file from the FileSystem dock into the script.
[codeblock]
# Instance a scene.
- var diamond = preload("res://diamond.tscn").instance()
+ var diamond = preload("res://diamond.tscn").instantiate()
[/codeblock]
</description>
</method>
@@ -240,10 +240,10 @@
</method>
</methods>
<constants>
- <constant name="PI" value="3.141593">
+ <constant name="PI" value="3.14159265358979">
Constant that represents how many times the diameter of a circle fits around its perimeter. This is equivalent to [code]TAU / 2[/code].
</constant>
- <constant name="TAU" value="6.283185">
+ <constant name="TAU" value="6.28318530717959">
The circle constant, the circumference of the unit circle in radians.
</constant>
<constant name="INF" value="inf">
diff --git a/modules/gdscript/editor/gdscript_highlighter.cpp b/modules/gdscript/editor/gdscript_highlighter.cpp
index b867b03903..79ec9eb65f 100644
--- a/modules/gdscript/editor/gdscript_highlighter.cpp
+++ b/modules/gdscript/editor/gdscript_highlighter.cpp
@@ -622,6 +622,6 @@ void GDScriptSyntaxHighlighter::add_color_region(const String &p_start_key, cons
Ref<EditorSyntaxHighlighter> GDScriptSyntaxHighlighter::_create() const {
Ref<GDScriptSyntaxHighlighter> syntax_highlighter;
- syntax_highlighter.instance();
+ syntax_highlighter.instantiate();
return syntax_highlighter;
}
diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp
index e99c3d6cca..397776ba1a 100644
--- a/modules/gdscript/gdscript.cpp
+++ b/modules/gdscript/gdscript.cpp
@@ -36,8 +36,8 @@
#include "core/config/project_settings.h"
#include "core/core_constants.h"
#include "core/core_string_names.h"
+#include "core/io/file_access.h"
#include "core/io/file_access_encrypted.h"
-#include "core/os/file_access.h"
#include "core/os/os.h"
#include "gdscript_analyzer.h"
#include "gdscript_cache.h"
@@ -72,19 +72,19 @@ void GDScriptNativeClass::_bind_methods() {
}
Variant GDScriptNativeClass::_new() {
- Object *o = instance();
+ Object *o = instantiate();
ERR_FAIL_COND_V_MSG(!o, Variant(), "Class type: '" + String(name) + "' is not instantiable.");
- Reference *ref = Object::cast_to<Reference>(o);
- if (ref) {
- return REF(ref);
+ RefCounted *rc = Object::cast_to<RefCounted>(o);
+ if (rc) {
+ return REF(rc);
} else {
return o;
}
}
-Object *GDScriptNativeClass::instance() {
- return ClassDB::instance(name);
+Object *GDScriptNativeClass::instantiate() {
+ return ClassDB::instantiate(name);
}
void GDScript::_super_implicit_constructor(GDScript *p_script, GDScriptInstance *p_instance, Callable::CallError &r_error) {
@@ -98,11 +98,11 @@ void GDScript::_super_implicit_constructor(GDScript *p_script, GDScriptInstance
p_script->implicit_initializer->call(p_instance, nullptr, 0, r_error);
}
-GDScriptInstance *GDScript::_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, bool p_isref, Callable::CallError &r_error) {
+GDScriptInstance *GDScript::_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, bool p_is_ref_counted, Callable::CallError &r_error) {
/* STEP 1, CREATE */
GDScriptInstance *instance = memnew(GDScriptInstance);
- instance->base_ref = p_isref;
+ instance->base_ref_counted = p_is_ref_counted;
instance->members.resize(member_indices.size());
instance->script = Ref<GDScript>(this);
instance->owner = p_owner;
@@ -170,13 +170,13 @@ Variant GDScript::_new(const Variant **p_args, int p_argcount, Callable::CallErr
ERR_FAIL_COND_V(_baseptr->native.is_null(), Variant());
if (_baseptr->native.ptr()) {
- owner = _baseptr->native->instance();
+ owner = _baseptr->native->instantiate();
} else {
- owner = memnew(Reference); //by default, no base means use reference
+ owner = memnew(RefCounted); //by default, no base means use reference
}
ERR_FAIL_COND_V_MSG(!owner, Variant(), "Can't inherit from a virtual class.");
- Reference *r = Object::cast_to<Reference>(owner);
+ RefCounted *r = Object::cast_to<RefCounted>(owner);
if (r) {
ref = REF(r);
}
@@ -196,7 +196,7 @@ Variant GDScript::_new(const Variant **p_args, int p_argcount, Callable::CallErr
}
}
-bool GDScript::can_instance() const {
+bool GDScript::can_instantiate() const {
#ifdef TOOLS_ENABLED
return valid && (tool || ScriptServer::is_scripting_enabled());
#else
@@ -346,21 +346,21 @@ ScriptInstance *GDScript::instance_create(Object *p_this) {
if (top->native.is_valid()) {
if (!ClassDB::is_parent_class(p_this->get_class_name(), top->native->get_name())) {
if (EngineDebugger::is_active()) {
- GDScriptLanguage::get_singleton()->debug_break_parse(get_path(), 1, "Script inherits from native type '" + String(top->native->get_name()) + "', so it can't be instanced in object of type: '" + p_this->get_class() + "'");
+ GDScriptLanguage::get_singleton()->debug_break_parse(get_path(), 1, "Script inherits from native type '" + String(top->native->get_name()) + "', so it can't be instantiated 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() + "'" + ".");
+ ERR_FAIL_V_MSG(nullptr, "Script inherits from native type '" + String(top->native->get_name()) + "', so it can't be instantiated in object of type '" + p_this->get_class() + "'" + ".");
}
}
Callable::CallError unchecked_error;
- return _create_instance(nullptr, 0, p_this, Object::cast_to<Reference>(p_this) != nullptr, unchecked_error);
+ return _create_instance(nullptr, 0, p_this, Object::cast_to<RefCounted>(p_this) != nullptr, unchecked_error);
}
PlaceHolderScriptInstance *GDScript::placeholder_instance_create(Object *p_this) {
#ifdef TOOLS_ENABLED
PlaceHolderScriptInstance *si = memnew(PlaceHolderScriptInstance(GDScriptLanguage::get_singleton(), Ref<Script>(this), p_this));
placeholders.insert(si);
- _update_exports();
+ _update_exports(nullptr, false, si);
return si;
#else
return nullptr;
@@ -584,7 +584,7 @@ void GDScript::_update_doc() {
}
#endif
-bool GDScript::_update_exports(bool *r_err, bool p_recursive_call) {
+bool GDScript::_update_exports(bool *r_err, bool p_recursive_call, PlaceHolderScriptInstance *p_instance_to_update) {
#ifdef TOOLS_ENABLED
static Vector<GDScript *> base_caches;
@@ -721,15 +721,19 @@ bool GDScript::_update_exports(bool *r_err, bool p_recursive_call) {
}
}
- if (placeholders.size()) { //hm :(
+ if ((changed || p_instance_to_update) && placeholders.size()) { //hm :(
// update placeholders if any
Map<StringName, Variant> values;
List<PropertyInfo> propnames;
_update_exports_values(values, propnames);
- for (Set<PlaceHolderScriptInstance *>::Element *E = placeholders.front(); E; E = E->next()) {
- E->get()->update(propnames, values);
+ if (changed) {
+ for (Set<PlaceHolderScriptInstance *>::Element *E = placeholders.front(); E; E = E->next()) {
+ E->get()->update(propnames, values);
+ }
+ } else {
+ p_instance_to_update->update(propnames, values);
}
}
@@ -1576,7 +1580,7 @@ void GDScriptInstance::reload_members() {
GDScriptInstance::GDScriptInstance() {
owner = nullptr;
- base_ref = false;
+ base_ref_counted = false;
}
GDScriptInstance::~GDScriptInstance() {
@@ -2064,7 +2068,7 @@ String GDScriptLanguage::get_global_class_name(const String &p_path, String *r_b
if (err == OK) {
const GDScriptParser::ClassNode *c = parser.get_tree();
if (r_icon_path) {
- if (c->icon_path.is_empty() || c->icon_path.is_abs_path()) {
+ if (c->icon_path.is_empty() || c->icon_path.is_absolute_path()) {
*r_icon_path = c->icon_path;
} else if (c->icon_path.is_rel_path()) {
*r_icon_path = p_path.get_base_dir().plus_file(c->icon_path).simplify_path();
@@ -2132,7 +2136,7 @@ String GDScriptLanguage::get_global_class_name(const String &p_path, String *r_b
break;
}
} else {
- *r_base_type = "Reference";
+ *r_base_type = "RefCounted";
subclass = nullptr;
}
}
@@ -2252,7 +2256,7 @@ RES ResourceFormatLoaderGDScript::load(const String &p_path, const String &p_ori
if (script.is_null()) {
// Don't fail loading because of parsing error.
- script.instance();
+ script.instantiate();
}
if (r_error) {
diff --git a/modules/gdscript/gdscript.h b/modules/gdscript/gdscript.h
index 8b1b859ca2..078b7a2fd0 100644
--- a/modules/gdscript/gdscript.h
+++ b/modules/gdscript/gdscript.h
@@ -39,8 +39,8 @@
#include "core/object/script_language.h"
#include "gdscript_function.h"
-class GDScriptNativeClass : public Reference {
- GDCLASS(GDScriptNativeClass, Reference);
+class GDScriptNativeClass : public RefCounted {
+ GDCLASS(GDScriptNativeClass, RefCounted);
StringName name;
@@ -51,7 +51,7 @@ protected:
public:
_FORCE_INLINE_ const StringName &get_name() const { return name; }
Variant _new();
- Object *instance();
+ Object *instantiate();
GDScriptNativeClass(const StringName &p_name);
};
@@ -80,10 +80,10 @@ class GDScript : public Script {
GDScript *_base = nullptr; //fast pointer access
GDScript *_owner = nullptr; //for subclasses
- Set<StringName> members; //members are just indices to the instanced script.
+ Set<StringName> members; //members are just indices to the instantiated script.
Map<StringName, Variant> constants;
Map<StringName, GDScriptFunction *> member_functions;
- Map<StringName, MemberInfo> member_indices; //members are just indices to the instanced script.
+ Map<StringName, MemberInfo> member_indices; //members are just indices to the instantiated script.
Map<StringName, Ref<GDScript>> subclasses;
Map<StringName, Vector<StringName>> _signals;
Vector<MultiplayerAPI::RPCConfig> rpc_functions;
@@ -132,7 +132,7 @@ class GDScript : public Script {
SelfList<GDScriptFunctionState>::List pending_func_states;
void _super_implicit_constructor(GDScript *p_script, GDScriptInstance *p_instance, Callable::CallError &r_error);
- GDScriptInstance *_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, bool p_isref, Callable::CallError &r_error);
+ GDScriptInstance *_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, bool p_is_ref_counted, Callable::CallError &r_error);
void _set_subclass_path(Ref<GDScript> &p_sc, const String &p_path);
@@ -148,7 +148,7 @@ class GDScript : public Script {
#endif
- bool _update_exports(bool *r_err = nullptr, bool p_recursive_call = false);
+ bool _update_exports(bool *r_err = nullptr, bool p_recursive_call = false, PlaceHolderScriptInstance *p_instance_to_update = nullptr);
void _save_orphaned_subclasses();
void _init_rpc_methods_properties();
@@ -157,7 +157,7 @@ class GDScript : public Script {
void _get_script_method_list(List<MethodInfo> *r_list, bool p_include_base) const;
void _get_script_signal_list(List<MethodInfo> *r_list, bool p_include_base) const;
- // This method will map the class name from "Reference" to "MyClass.InnerClass".
+ // This method will map the class name from "RefCounted" to "MyClass.InnerClass".
static String _get_gdscript_reference_class_name(const GDScript *p_gdscript);
protected:
@@ -196,7 +196,7 @@ public:
StringName debug_get_member_by_index(int p_idx) const;
Variant _new(const Variant **p_args, int p_argcount, Callable::CallError &r_error);
- virtual bool can_instance() const override;
+ virtual bool can_instantiate() const override;
virtual Ref<Script> get_base_script() const override;
@@ -270,7 +270,7 @@ class GDScriptInstance : public ScriptInstance {
Map<StringName, int> member_indices_cache; //used only for hot script reloading
#endif
Vector<Variant> members;
- bool base_ref;
+ bool base_ref_counted;
SelfList<GDScriptFunctionState>::List pending_func_states;
@@ -447,7 +447,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 = nullptr, List<ScriptLanguage::Warning> *r_warnings = nullptr, Set<int> *r_safe_lines = nullptr) const;
+ virtual bool validate(const String &p_script, const String &p_path = "", List<String> *r_functions = nullptr, List<ScriptLanguage::ScriptError> *r_errors = 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/gdscript/gdscript_analyzer.cpp b/modules/gdscript/gdscript_analyzer.cpp
index e92adee8e8..e7fb33a6a7 100644
--- a/modules/gdscript/gdscript_analyzer.cpp
+++ b/modules/gdscript/gdscript_analyzer.cpp
@@ -31,10 +31,10 @@
#include "gdscript_analyzer.h"
#include "core/config/project_settings.h"
+#include "core/io/file_access.h"
#include "core/io/resource_loader.h"
#include "core/object/class_db.h"
#include "core/object/script_language.h"
-#include "core/os/file_access.h"
#include "core/templates/hash_map.h"
#include "gdscript.h"
#include "gdscript_utility_functions.h"
@@ -163,7 +163,7 @@ Error GDScriptAnalyzer::resolve_inheritance(GDScriptParser::ClassNode *p_class,
if (!p_class->extends_used) {
result.type_source = GDScriptParser::DataType::ANNOTATED_INFERRED;
result.kind = GDScriptParser::DataType::NATIVE;
- result.native_type = "Reference";
+ result.native_type = "RefCounted";
} else {
result.type_source = GDScriptParser::DataType::ANNOTATED_EXPLICIT;
@@ -229,7 +229,7 @@ Error GDScriptAnalyzer::resolve_inheritance(GDScriptParser::ClassNode *p_class,
push_error(vformat(R"(Could not resolve super class inheritance from "%s".)", name), p_class);
return err;
}
- } else if (class_exists(name) && ClassDB::can_instance(GDScriptParser::get_real_class_name(name))) {
+ } else if (class_exists(name) && ClassDB::can_instantiate(GDScriptParser::get_real_class_name(name))) {
base.kind = GDScriptParser::DataType::NATIVE;
base.native_type = name;
} else {
@@ -1779,10 +1779,10 @@ void GDScriptAnalyzer::reduce_binary_op(GDScriptParser::BinaryOpNode *p_binary_o
} else {
if (p_binary_op->variant_op < Variant::OP_MAX) {
bool valid = false;
- result = get_operation_type(p_binary_op->variant_op, p_binary_op->left_operand->get_datatype(), right_type, valid, p_binary_op);
+ result = get_operation_type(p_binary_op->variant_op, left_type, right_type, valid, p_binary_op);
if (!valid) {
- push_error(vformat(R"(Invalid operands "%s" and "%s" for "%s" operator.)", p_binary_op->left_operand->get_datatype().to_string(), right_type.to_string(), Variant::get_operator_name(p_binary_op->variant_op)), p_binary_op);
+ push_error(vformat(R"(Invalid operands "%s" and "%s" for "%s" operator.)", left_type.to_string(), right_type.to_string(), Variant::get_operator_name(p_binary_op->variant_op)), p_binary_op);
}
} else {
if (p_binary_op->operation == GDScriptParser::BinaryOpNode::OP_TYPE_TEST) {
@@ -2349,6 +2349,7 @@ void GDScriptAnalyzer::reduce_identifier_from_base(GDScriptParser::IdentifierNod
GDScriptParser::DataType result;
result.type_source = GDScriptParser::DataType::ANNOTATED_EXPLICIT;
result.kind = GDScriptParser::DataType::ENUM_VALUE;
+ result.builtin_type = base.builtin_type;
result.native_type = base.native_type;
result.enum_type = name;
p_identifier->set_datatype(result);
@@ -3446,6 +3447,7 @@ GDScriptParser::DataType GDScriptAnalyzer::get_operation_type(Variant::Operator
}
r_valid = true;
+ result.type_source = GDScriptParser::DataType::ANNOTATED_INFERRED;
result.kind = GDScriptParser::DataType::BUILTIN;
result.builtin_type = Variant::get_operator_return_type(p_operation, a_type, b_type);
diff --git a/modules/gdscript/gdscript_analyzer.h b/modules/gdscript/gdscript_analyzer.h
index aabf407c76..8cd3fcf837 100644
--- a/modules/gdscript/gdscript_analyzer.h
+++ b/modules/gdscript/gdscript_analyzer.h
@@ -32,7 +32,7 @@
#define GDSCRIPT_ANALYZER_H
#include "core/object/object.h"
-#include "core/object/reference.h"
+#include "core/object/ref_counted.h"
#include "core/templates/set.h"
#include "gdscript_cache.h"
#include "gdscript_parser.h"
diff --git a/modules/gdscript/gdscript_byte_codegen.cpp b/modules/gdscript/gdscript_byte_codegen.cpp
index 6998cc5bb7..5a297cc50a 100644
--- a/modules/gdscript/gdscript_byte_codegen.cpp
+++ b/modules/gdscript/gdscript_byte_codegen.cpp
@@ -554,6 +554,14 @@ void GDScriptByteCodeGenerator::write_unary_operator(const Address &p_target, Va
void GDScriptByteCodeGenerator::write_binary_operator(const Address &p_target, Variant::Operator p_operator, const Address &p_left_operand, const Address &p_right_operand) {
if (HAS_BUILTIN_TYPE(p_left_operand) && HAS_BUILTIN_TYPE(p_right_operand)) {
+ if (p_target.mode == Address::TEMPORARY) {
+ Variant::Type result_type = Variant::get_operator_return_type(p_operator, p_left_operand.type.builtin_type, p_right_operand.type.builtin_type);
+ Variant::Type temp_type = temporaries[p_target.address].type;
+ if (result_type != temp_type) {
+ write_type_adjust(p_target, result_type);
+ }
+ }
+
// Gather specific operator.
Variant::ValidatedOperatorEvaluator op_func = Variant::get_validated_operator_evaluator(p_operator, p_left_operand.type.builtin_type, p_right_operand.type.builtin_type);
diff --git a/modules/gdscript/gdscript_cache.cpp b/modules/gdscript/gdscript_cache.cpp
index 601cdb4080..1a844bf241 100644
--- a/modules/gdscript/gdscript_cache.cpp
+++ b/modules/gdscript/gdscript_cache.cpp
@@ -30,7 +30,7 @@
#include "gdscript_cache.h"
-#include "core/os/file_access.h"
+#include "core/io/file_access.h"
#include "core/templates/vector.h"
#include "gdscript.h"
#include "gdscript_analyzer.h"
@@ -134,7 +134,7 @@ Ref<GDScriptParserRef> GDScriptCache::get_parser(const String &p_path, GDScriptP
return ref;
}
GDScriptParser *parser = memnew(GDScriptParser);
- ref.instance();
+ ref.instantiate();
ref->parser = parser;
ref->path = p_path;
singleton->parser_map[p_path] = ref.ptr();
@@ -180,7 +180,7 @@ Ref<GDScript> GDScriptCache::get_shallow_script(const String &p_path, const Stri
}
Ref<GDScript> script;
- script.instance();
+ script.instantiate();
script->set_path(p_path, true);
script->set_script_path(p_path);
script->load_source_code(p_path);
diff --git a/modules/gdscript/gdscript_cache.h b/modules/gdscript/gdscript_cache.h
index d1d2a2abbf..943638d29f 100644
--- a/modules/gdscript/gdscript_cache.h
+++ b/modules/gdscript/gdscript_cache.h
@@ -31,7 +31,7 @@
#ifndef GDSCRIPT_CACHE_H
#define GDSCRIPT_CACHE_H
-#include "core/object/reference.h"
+#include "core/object/ref_counted.h"
#include "core/os/mutex.h"
#include "core/templates/hash_map.h"
#include "core/templates/set.h"
@@ -40,7 +40,7 @@
class GDScriptAnalyzer;
class GDScriptParser;
-class GDScriptParserRef : public Reference {
+class GDScriptParserRef : public RefCounted {
public:
enum Status {
EMPTY,
diff --git a/modules/gdscript/gdscript_compiler.cpp b/modules/gdscript/gdscript_compiler.cpp
index c7ca9449c2..7fa8e9c067 100644
--- a/modules/gdscript/gdscript_compiler.cpp
+++ b/modules/gdscript/gdscript_compiler.cpp
@@ -2282,9 +2282,10 @@ Error GDScriptCompiler::_parse_class_level(GDScript *p_script, const GDScriptPar
}
prop_info.hint = export_info.hint;
prop_info.hint_string = export_info.hint_string;
- prop_info.usage = export_info.usage;
+ prop_info.usage = export_info.usage | PROPERTY_USAGE_SCRIPT_VARIABLE;
+ } else {
+ prop_info.usage = PROPERTY_USAGE_SCRIPT_VARIABLE;
}
- prop_info.usage |= PROPERTY_USAGE_SCRIPT_VARIABLE;
#ifdef TOOLS_ENABLED
p_script->doc_variables[name] = variable->doc_description;
#endif
@@ -2511,7 +2512,7 @@ Error GDScriptCompiler::_parse_class_blocks(GDScript *p_script, const GDScriptPa
p_script->placeholders.erase(psi); //remove placeholder
GDScriptInstance *instance = memnew(GDScriptInstance);
- instance->base_ref = Object::cast_to<Reference>(E->get());
+ instance->base_ref_counted = Object::cast_to<RefCounted>(E->get());
instance->members.resize(p_script->member_indices.size());
instance->script = Ref<GDScript>(p_script);
instance->owner = E->get();
@@ -2586,7 +2587,7 @@ void GDScriptCompiler::_make_scripts(GDScript *p_script, const GDScriptParser::C
if (orphan_subclass.is_valid()) {
subclass = orphan_subclass;
} else {
- subclass.instance();
+ subclass.instantiate();
}
}
diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp
index 504c7414f6..b149828a2f 100644
--- a/modules/gdscript/gdscript_editor.cpp
+++ b/modules/gdscript/gdscript_editor.cpp
@@ -32,7 +32,7 @@
#include "core/config/engine.h"
#include "core/core_constants.h"
-#include "core/os/file_access.h"
+#include "core/io/file_access.h"
#include "gdscript_analyzer.h"
#include "gdscript_compiler.h"
#include "gdscript_parser.h"
@@ -104,7 +104,7 @@ Ref<Script> GDScriptLanguage::get_template(const String &p_class_name, const Str
_template = _get_processed_template(_template, p_base_class_name);
Ref<GDScript> script;
- script.instance();
+ script.instantiate();
script->set_source_code(_template);
return script;
@@ -131,7 +131,7 @@ static void get_function_names_recursively(const GDScriptParser::ClassNode *p_cl
}
}
-bool GDScriptLanguage::validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path, List<String> *r_functions, List<ScriptLanguage::Warning> *r_warnings, Set<int> *r_safe_lines) const {
+bool GDScriptLanguage::validate(const String &p_script, const String &p_path, List<String> *r_functions, List<ScriptLanguage::ScriptError> *r_errors, List<ScriptLanguage::Warning> *r_warnings, Set<int> *r_safe_lines) const {
GDScriptParser parser;
GDScriptAnalyzer analyzer(&parser);
@@ -156,10 +156,16 @@ bool GDScriptLanguage::validate(const String &p_script, int &r_line_error, int &
}
#endif
if (err) {
- GDScriptParser::ParserError parse_error = parser.get_errors().front()->get();
- r_line_error = parse_error.line;
- r_col_error = parse_error.column;
- r_test_error = parse_error.message;
+ if (r_errors) {
+ for (const List<GDScriptParser::ParserError>::Element *E = parser.get_errors().front(); E; E = E->next()) {
+ const GDScriptParser::ParserError &pe = E->get();
+ ScriptLanguage::ScriptError e;
+ e.line = pe.line;
+ e.column = pe.column;
+ e.message = pe.message;
+ r_errors->push_back(e);
+ }
+ }
return false;
} else {
const GDScriptParser::ClassNode *cl = parser.get_tree();
@@ -1029,7 +1035,7 @@ static void _find_identifiers(GDScriptParser::CompletionContext &p_context, bool
}
static const char *_type_names[Variant::VARIANT_MAX] = {
- "null", "bool", "int", "float", "String", "StringName", "Vector2", "Vector2i", "Rect2", "Rect2i", "Vector3", "Vector3i", "Transform2D", "Plane", "Quat", "AABB", "Basis", "Transform",
+ "null", "bool", "int", "float", "String", "StringName", "Vector2", "Vector2i", "Rect2", "Rect2i", "Vector3", "Vector3i", "Transform2D", "Plane", "Quaternion", "AABB", "Basis", "Transform3D",
"Color", "NodePath", "RID", "Signal", "Callable", "Object", "Dictionary", "Array", "PackedByteArray", "PackedInt32Array", "PackedInt64Array", "PackedFloat32Array", "PackedFloat64Array", "PackedStringArray",
"PackedVector2Array", "PackedVector3Array", "PackedColorArray"
};
@@ -2378,7 +2384,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
r_forced = r_result.size() > 0;
}
-Error GDScriptLanguage::complete_code(const String &p_code, const String &p_path, Object *p_owner, List<ScriptCodeCompletionOption> *r_options, bool &r_forced, String &r_call_hint) {
+::Error GDScriptLanguage::complete_code(const String &p_code, const String &p_path, Object *p_owner, List<ScriptCodeCompletionOption> *r_options, bool &r_forced, String &r_call_hint) {
const String quote_style = EDITOR_DEF("text_editor/completion/use_single_quotes", false) ? "'" : "\"";
GDScriptParser parser;
@@ -2894,7 +2900,7 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co
Variant v;
REF v_ref;
if (base_type.builtin_type == Variant::OBJECT) {
- v_ref.instance();
+ v_ref.instantiate();
v = v_ref;
} else {
Callable::CallError err;
@@ -2929,7 +2935,7 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co
return ERR_CANT_RESOLVE;
}
-Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol, const String &p_path, Object *p_owner, LookupResult &r_result) {
+::Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol, const String &p_path, Object *p_owner, LookupResult &r_result) {
//before parsing, try the usual stuff
if (ClassDB::class_exists(p_symbol)) {
r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS;
diff --git a/modules/gdscript/gdscript_function.h b/modules/gdscript/gdscript_function.h
index cd1704cb03..553c2ecc01 100644
--- a/modules/gdscript/gdscript_function.h
+++ b/modules/gdscript/gdscript_function.h
@@ -31,7 +31,7 @@
#ifndef GDSCRIPT_FUNCTION_H
#define GDSCRIPT_FUNCTION_H
-#include "core/object/reference.h"
+#include "core/object/ref_counted.h"
#include "core/object/script_language.h"
#include "core/os/thread.h"
#include "core/string/string_name.h"
@@ -597,8 +597,8 @@ public:
~GDScriptFunction();
};
-class GDScriptFunctionState : public Reference {
- GDCLASS(GDScriptFunctionState, Reference);
+class GDScriptFunctionState : public RefCounted {
+ GDCLASS(GDScriptFunctionState, RefCounted);
friend class GDScriptFunction;
GDScriptFunction *function = nullptr;
GDScriptFunction::CallState state;
diff --git a/modules/gdscript/gdscript_lambda_callable.h b/modules/gdscript/gdscript_lambda_callable.h
index 357c845250..336778d549 100644
--- a/modules/gdscript/gdscript_lambda_callable.h
+++ b/modules/gdscript/gdscript_lambda_callable.h
@@ -31,7 +31,7 @@
#ifndef GDSCRIPT_LAMBDA_CALLABLE
#define GDSCRIPT_LAMBDA_CALLABLE
-#include "core/object/reference.h"
+#include "core/object/ref_counted.h"
#include "core/templates/vector.h"
#include "core/variant/callable.h"
#include "core/variant/variant.h"
diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp
index 1af54ea8df..ba208ebfe8 100644
--- a/modules/gdscript/gdscript_parser.cpp
+++ b/modules/gdscript/gdscript_parser.cpp
@@ -31,9 +31,9 @@
#include "gdscript_parser.h"
#include "core/config/project_settings.h"
+#include "core/io/file_access.h"
#include "core/io/resource_loader.h"
#include "core/math/math_defs.h"
-#include "core/os/file_access.h"
#include "gdscript.h"
#ifdef DEBUG_ENABLED
@@ -63,7 +63,7 @@ Variant::Type GDScriptParser::get_builtin_type(const StringName &p_type) {
builtin_types["Plane"] = Variant::PLANE;
builtin_types["Quaternion"] = Variant::QUATERNION;
builtin_types["Basis"] = Variant::BASIS;
- builtin_types["Transform"] = Variant::TRANSFORM3D;
+ builtin_types["Transform3D"] = Variant::TRANSFORM3D;
builtin_types["Color"] = Variant::COLOR;
builtin_types["RID"] = Variant::RID;
builtin_types["Object"] = Variant::OBJECT;
diff --git a/modules/gdscript/gdscript_parser.h b/modules/gdscript/gdscript_parser.h
index ee5e411cad..9e0b60a407 100644
--- a/modules/gdscript/gdscript_parser.h
+++ b/modules/gdscript/gdscript_parser.h
@@ -33,7 +33,7 @@
#include "core/io/multiplayer_api.h"
#include "core/io/resource.h"
-#include "core/object/reference.h"
+#include "core/object/ref_counted.h"
#include "core/object/script_language.h"
#include "core/string/string_name.h"
#include "core/string/ustring.h"
diff --git a/modules/gdscript/gdscript_vm.cpp b/modules/gdscript/gdscript_vm.cpp
index 318ec966ae..8a261a88e3 100644
--- a/modules/gdscript/gdscript_vm.cpp
+++ b/modules/gdscript/gdscript_vm.cpp
@@ -1989,7 +1989,10 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
ip += instr_arg_count;
- int self_fun = _code_ptr[ip + 1];
+ int argc = _code_ptr[ip + 1];
+ GD_ERR_BREAK(argc < 0);
+
+ int self_fun = _code_ptr[ip + 2];
#ifdef DEBUG_ENABLED
if (self_fun < 0 || self_fun >= _global_names_count) {
err_text = "compiler bug, function name not found";
@@ -1998,9 +2001,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
#endif
const StringName *methodname = &_global_names_ptr[self_fun];
- int argc = _code_ptr[ip + 2];
- GD_ERR_BREAK(argc < 0);
-
Variant **argptrs = instruction_args;
GET_INSTRUCTION_ARG(dst, argc);
diff --git a/modules/gdscript/language_server/gdscript_extend_parser.cpp b/modules/gdscript/language_server/gdscript_extend_parser.cpp
index 15236d900d..f817964a3c 100644
--- a/modules/gdscript/language_server/gdscript_extend_parser.cpp
+++ b/modules/gdscript/language_server/gdscript_extend_parser.cpp
@@ -32,7 +32,6 @@
#include "../gdscript.h"
#include "../gdscript_analyzer.h"
-#include "core/io/json.h"
#include "gdscript_language_protocol.h"
#include "gdscript_workspace.h"
@@ -183,7 +182,7 @@ void ExtendGDScriptParser::parse_class_symbol(const GDScriptParser::ClassNode *p
symbol.detail += ": " + m.get_datatype().to_string();
}
if (m.variable->initializer != nullptr && m.variable->initializer->is_constant) {
- symbol.detail += " = " + JSON::print(m.variable->initializer->reduced_value);
+ symbol.detail += " = " + m.variable->initializer->reduced_value.to_json_string();
}
symbol.documentation = parse_documentation(LINE_NUMBER_TO_INDEX(m.variable->start_line));
@@ -224,10 +223,10 @@ void ExtendGDScriptParser::parse_class_symbol(const GDScriptParser::ClassNode *p
}
}
} else {
- value_text = JSON::print(default_value);
+ value_text = default_value.to_json_string();
}
} else {
- value_text = JSON::print(default_value);
+ value_text = default_value.to_json_string();
}
if (!value_text.is_empty()) {
symbol.detail += " = " + value_text;
@@ -353,8 +352,7 @@ void ExtendGDScriptParser::parse_function_symbol(const GDScriptParser::FunctionN
parameters += ": " + parameter->get_datatype().to_string();
}
if (parameter->default_value != nullptr) {
- String value = JSON::print(parameter->default_value->reduced_value);
- parameters += " = " + value;
+ parameters += " = " + parameter->default_value->reduced_value.to_json_string();
}
}
r_symbol.detail += parameters + ")";
diff --git a/modules/gdscript/language_server/gdscript_language_protocol.cpp b/modules/gdscript/language_server/gdscript_language_protocol.cpp
index c16a7fa889..0d1f98778e 100644
--- a/modules/gdscript/language_server/gdscript_language_protocol.cpp
+++ b/modules/gdscript/language_server/gdscript_language_protocol.cpp
@@ -31,7 +31,6 @@
#include "gdscript_language_protocol.h"
#include "core/config/project_settings.h"
-#include "core/io/json.h"
#include "editor/doc_tools.h"
#include "editor/editor_log.h"
#include "editor/editor_node.h"
@@ -194,7 +193,7 @@ Dictionary GDScriptLanguageProtocol::initialize(const Dictionary &p_params) {
vformat("GDScriptLanguageProtocol: Can't initialize invalid peer '%d'.", latest_client_id));
Ref<LSPeer> peer = clients.get(latest_client_id);
if (peer != nullptr) {
- String msg = JSON::print(request);
+ String msg = Variant(request).to_json_string();
msg = format_output(msg);
(*peer)->res_queue.push_back(msg.utf8());
}
@@ -280,7 +279,7 @@ void GDScriptLanguageProtocol::notify_client(const String &p_method, const Varia
ERR_FAIL_COND(peer == nullptr);
Dictionary message = make_notification(p_method, p_params);
- String msg = JSON::print(message);
+ String msg = Variant(message).to_json_string();
msg = format_output(msg);
peer->res_queue.push_back(msg.utf8());
}
@@ -294,10 +293,10 @@ bool GDScriptLanguageProtocol::is_goto_native_symbols_enabled() const {
}
GDScriptLanguageProtocol::GDScriptLanguageProtocol() {
- server.instance();
+ server.instantiate();
singleton = this;
- workspace.instance();
- text_document.instance();
+ workspace.instantiate();
+ text_document.instantiate();
set_scope("textDocument", text_document.ptr());
set_scope("completionItem", text_document.ptr());
set_scope("workspace", workspace.ptr());
diff --git a/modules/gdscript/language_server/gdscript_language_protocol.h b/modules/gdscript/language_server/gdscript_language_protocol.h
index a5c5a233b1..969c38eab6 100644
--- a/modules/gdscript/language_server/gdscript_language_protocol.h
+++ b/modules/gdscript/language_server/gdscript_language_protocol.h
@@ -46,7 +46,7 @@ class GDScriptLanguageProtocol : public JSONRPC {
GDCLASS(GDScriptLanguageProtocol, JSONRPC)
private:
- struct LSPeer : Reference {
+ struct LSPeer : RefCounted {
Ref<StreamPeerTCP> connection;
uint8_t req_buf[LSP_MAX_BUFFER_SIZE];
diff --git a/modules/gdscript/language_server/gdscript_language_server.cpp b/modules/gdscript/language_server/gdscript_language_server.cpp
index 340a7b9343..33597c286f 100644
--- a/modules/gdscript/language_server/gdscript_language_server.cpp
+++ b/modules/gdscript/language_server/gdscript_language_server.cpp
@@ -30,7 +30,7 @@
#include "gdscript_language_server.h"
-#include "core/os/file_access.h"
+#include "core/io/file_access.h"
#include "core/os/os.h"
#include "editor/editor_log.h"
#include "editor/editor_node.h"
diff --git a/modules/gdscript/language_server/gdscript_text_document.h b/modules/gdscript/language_server/gdscript_text_document.h
index 792e601bc1..17f1d5d5e3 100644
--- a/modules/gdscript/language_server/gdscript_text_document.h
+++ b/modules/gdscript/language_server/gdscript_text_document.h
@@ -31,12 +31,12 @@
#ifndef GDSCRIPT_TEXT_DOCUMENT_H
#define GDSCRIPT_TEXT_DOCUMENT_H
-#include "core/object/reference.h"
-#include "core/os/file_access.h"
+#include "core/io/file_access.h"
+#include "core/object/ref_counted.h"
#include "lsp.hpp"
-class GDScriptTextDocument : public Reference {
- GDCLASS(GDScriptTextDocument, Reference)
+class GDScriptTextDocument : public RefCounted {
+ GDCLASS(GDScriptTextDocument, RefCounted)
protected:
static void _bind_methods();
diff --git a/modules/gdscript/language_server/gdscript_workspace.cpp b/modules/gdscript/language_server/gdscript_workspace.cpp
index 9b7b2b36b4..1915c92cbf 100644
--- a/modules/gdscript/language_server/gdscript_workspace.cpp
+++ b/modules/gdscript/language_server/gdscript_workspace.cpp
@@ -188,7 +188,9 @@ Array GDScriptWorkspace::symbol(const Dictionary &p_params) {
E->get()->get_symbols().symbol_tree_as_list(E->key(), script_symbols);
for (int i = 0; i < script_symbols.size(); ++i) {
if (query.is_subsequence_ofi(script_symbols[i].name)) {
- arr.push_back(script_symbols[i].to_json());
+ lsp::DocumentedSymbolInformation symbol = script_symbols[i];
+ symbol.location.uri = get_file_uri(symbol.location.uri);
+ arr.push_back(symbol.to_json());
}
}
}
@@ -424,7 +426,7 @@ Node *GDScriptWorkspace::_get_owner_scene_node(String p_path) {
RES owner_res = ResourceLoader::load(owner_path);
if (Object::cast_to<PackedScene>(owner_res.ptr())) {
Ref<PackedScene> owner_packed_scene = Ref<PackedScene>(Object::cast_to<PackedScene>(*owner_res));
- owner_scene_node = owner_packed_scene->instance();
+ owner_scene_node = owner_packed_scene->instantiate();
break;
}
}
diff --git a/modules/gdscript/language_server/gdscript_workspace.h b/modules/gdscript/language_server/gdscript_workspace.h
index 27616a2989..8b166a873c 100644
--- a/modules/gdscript/language_server/gdscript_workspace.h
+++ b/modules/gdscript/language_server/gdscript_workspace.h
@@ -37,8 +37,8 @@
#include "gdscript_extend_parser.h"
#include "lsp.hpp"
-class GDScriptWorkspace : public Reference {
- GDCLASS(GDScriptWorkspace, Reference);
+class GDScriptWorkspace : public RefCounted {
+ GDCLASS(GDScriptWorkspace, RefCounted);
private:
void _get_owners(EditorFileSystemDirectory *efsd, String p_path, List<String> &owners);
diff --git a/modules/gdscript/language_server/lsp.hpp b/modules/gdscript/language_server/lsp.hpp
index 47bcfeaefc..a7dcfdb22d 100644
--- a/modules/gdscript/language_server/lsp.hpp
+++ b/modules/gdscript/language_server/lsp.hpp
@@ -766,7 +766,7 @@ struct MarkupContent {
// Use namespace instead of enumeration to follow the LSP specifications
// lsp::EnumName::EnumValue is OK but lsp::EnumValue is not
-// And here C++ compilers are unhappy with our enumeration name like Color, File, Reference etc.
+// And here C++ compilers are unhappy with our enumeration name like Color, File, RefCounted etc.
/**
* The kind of a completion entry.
*/
@@ -788,7 +788,7 @@ static const int Keyword = 14;
static const int Snippet = 15;
static const int Color = 16;
static const int File = 17;
-static const int Reference = 18;
+static const int RefCounted = 18;
static const int Folder = 19;
static const int EnumMember = 20;
static const int Constant = 21;
diff --git a/modules/gdscript/register_types.cpp b/modules/gdscript/register_types.cpp
index 2d2f94f5e0..ad4ed8bf71 100644
--- a/modules/gdscript/register_types.cpp
+++ b/modules/gdscript/register_types.cpp
@@ -30,10 +30,10 @@
#include "register_types.h"
+#include "core/io/dir_access.h"
+#include "core/io/file_access.h"
#include "core/io/file_access_encrypted.h"
#include "core/io/resource_loader.h"
-#include "core/os/dir_access.h"
-#include "core/os/file_access.h"
#include "gdscript.h"
#include "gdscript_analyzer.h"
#include "gdscript_cache.h"
@@ -92,12 +92,12 @@ public:
static void _editor_init() {
Ref<EditorExportGDScript> gd_export;
- gd_export.instance();
+ gd_export.instantiate();
EditorExport::get_singleton()->add_export_plugin(gd_export);
#ifdef TOOLS_ENABLED
Ref<GDScriptSyntaxHighlighter> gdscript_syntax_highlighter;
- gdscript_syntax_highlighter.instance();
+ gdscript_syntax_highlighter.instantiate();
ScriptEditor::get_singleton()->register_syntax_highlighter(gdscript_syntax_highlighter);
#endif
@@ -117,10 +117,10 @@ void register_gdscript_types() {
script_language_gd = memnew(GDScriptLanguage);
ScriptServer::register_language(script_language_gd);
- resource_loader_gd.instance();
+ resource_loader_gd.instantiate();
ResourceLoader::add_resource_format_loader(resource_loader_gd);
- resource_saver_gd.instance();
+ resource_saver_gd.instantiate();
ResourceSaver::add_resource_format_saver(resource_saver_gd);
gdscript_cache = memnew(GDScriptCache);
@@ -128,7 +128,7 @@ void register_gdscript_types() {
#ifdef TOOLS_ENABLED
EditorNode::add_init_callback(_editor_init);
- gdscript_translation_parser_plugin.instance();
+ gdscript_translation_parser_plugin.instantiate();
EditorTranslationParser::get_singleton()->add_parser(gdscript_translation_parser_plugin, EditorTranslationParser::STANDARD);
#endif // TOOLS_ENABLED
diff --git a/modules/gdscript/tests/gdscript_test_runner.cpp b/modules/gdscript/tests/gdscript_test_runner.cpp
index e20e427597..b7faebb4ef 100644
--- a/modules/gdscript/tests/gdscript_test_runner.cpp
+++ b/modules/gdscript/tests/gdscript_test_runner.cpp
@@ -37,8 +37,8 @@
#include "core/config/project_settings.h"
#include "core/core_string_names.h"
+#include "core/io/dir_access.h"
#include "core/io/file_access_pack.h"
-#include "core/os/dir_access.h"
#include "core/os/os.h"
#include "core/string/string_builder.h"
#include "scene/resources/packed_scene.h"
@@ -75,14 +75,14 @@ void init_autoloads() {
Node *n = nullptr;
if (res->is_class("PackedScene")) {
Ref<PackedScene> ps = res;
- n = ps->instance();
+ n = ps->instantiate();
} else if (res->is_class("Script")) {
Ref<Script> script_res = res;
StringName ibt = script_res->get_instance_base_type();
bool valid_type = ClassDB::is_parent_class(ibt, "Node");
ERR_CONTINUE_MSG(!valid_type, "Script does not inherit a Node: " + info.path);
- Object *obj = ClassDB::instance(ibt);
+ Object *obj = ClassDB::instantiate(ibt);
ERR_CONTINUE_MSG(obj == nullptr,
"Cannot instance script for autoload, expected 'Node' inheritance, got: " +
@@ -420,7 +420,7 @@ GDScriptTest::TestResult GDScriptTest::execute_test_code(bool p_is_generating) {
// Create script.
Ref<GDScript> script;
- script.instance();
+ script.instantiate();
script->set_path(source_file);
script->set_script_path(source_file);
err = script->load_source_code(source_file);
@@ -510,10 +510,10 @@ GDScriptTest::TestResult GDScriptTest::execute_test_code(bool p_is_generating) {
script->reload();
// Create object instance for test.
- Object *obj = ClassDB::instance(script->get_native()->get_name());
- Ref<Reference> obj_ref;
- if (obj->is_reference()) {
- obj_ref = Ref<Reference>(Object::cast_to<Reference>(obj));
+ Object *obj = ClassDB::instantiate(script->get_native()->get_name());
+ Ref<RefCounted> obj_ref;
+ if (obj->is_ref_counted()) {
+ obj_ref = Ref<RefCounted>(Object::cast_to<RefCounted>(obj));
}
obj->set_script(script);
GDScriptInstance *instance = static_cast<GDScriptInstance *>(obj->get_script_instance());
diff --git a/modules/gdscript/tests/gdscript_test_runner_suite.h b/modules/gdscript/tests/gdscript_test_runner_suite.h
index 8fd77239cd..cf4e61f07d 100644
--- a/modules/gdscript/tests/gdscript_test_runner_suite.h
+++ b/modules/gdscript/tests/gdscript_test_runner_suite.h
@@ -51,7 +51,7 @@ TEST_SUITE("[Modules][GDScript]") {
TEST_CASE("[Modules][GDScript] Load source code dynamically and run it") {
Ref<GDScript> gdscript = memnew(GDScript);
gdscript->set_source_code(R"(
-extends Reference
+extends RefCounted
func _init():
set_meta("result", 42)
@@ -64,9 +64,9 @@ func _init():
CHECK_MESSAGE(error == OK, "The script should parse successfully.");
// Run the script by assigning it to a reference-counted object.
- Ref<Reference> reference = memnew(Reference);
- reference->set_script(gdscript);
- CHECK_MESSAGE(int(reference->get_meta("result")) == 42, "The script should assign object metadata successfully.");
+ Ref<RefCounted> ref_counted = memnew(RefCounted);
+ ref_counted->set_script(gdscript);
+ CHECK_MESSAGE(int(ref_counted->get_meta("result")) == 42, "The script should assign object metadata successfully.");
}
} // namespace GDScriptTests
diff --git a/modules/gdscript/tests/test_gdscript.cpp b/modules/gdscript/tests/test_gdscript.cpp
index fc73b5bb72..7aa5895981 100644
--- a/modules/gdscript/tests/test_gdscript.cpp
+++ b/modules/gdscript/tests/test_gdscript.cpp
@@ -31,8 +31,8 @@
#include "test_gdscript.h"
#include "core/config/project_settings.h"
+#include "core/io/file_access.h"
#include "core/io/file_access_pack.h"
-#include "core/os/file_access.h"
#include "core/os/main_loop.h"
#include "core/os/os.h"
#include "core/string/string_builder.h"
@@ -165,7 +165,7 @@ static void test_compiler(const String &p_code, const String &p_script_path, con
GDScriptCompiler compiler;
Ref<GDScript> script;
- script.instance();
+ script.instantiate();
script->set_path(p_script_path);
err = compiler.compile(&parser, script.ptr(), false);
diff --git a/modules/glslang/register_types.cpp b/modules/glslang/register_types.cpp
index 8979eabfc3..730c6b89f7 100644
--- a/modules/glslang/register_types.cpp
+++ b/modules/glslang/register_types.cpp
@@ -116,6 +116,10 @@ static Vector<uint8_t> _compile_shader_glsl(RenderingDevice::ShaderStage p_stage
}
}
+ if (p_capabilities->supports_multiview) {
+ preamble += "#define has_VK_KHR_multiview 1\n";
+ }
+
if (preamble != "") {
shader.setPreamble(preamble.c_str());
}
diff --git a/modules/gltf/doc_classes/GLTFAccessor.xml b/modules/gltf/doc_classes/GLTFAccessor.xml
index a1f596f7dd..41a318ce19 100644
--- a/modules/gltf/doc_classes/GLTFAccessor.xml
+++ b/modules/gltf/doc_classes/GLTFAccessor.xml
@@ -17,9 +17,9 @@
</member>
<member name="count" type="int" setter="set_count" getter="get_count" default="0">
</member>
- <member name="max" type="PackedFloat64Array" setter="set_max" getter="get_max" default="PackedFloat64Array( )">
+ <member name="max" type="PackedFloat64Array" setter="set_max" getter="get_max" default="PackedFloat64Array()">
</member>
- <member name="min" type="PackedFloat64Array" setter="set_min" getter="get_min" default="PackedFloat64Array( )">
+ <member name="min" type="PackedFloat64Array" setter="set_min" getter="get_min" default="PackedFloat64Array()">
</member>
<member name="normalized" type="bool" setter="set_normalized" getter="get_normalized" default="false">
</member>
diff --git a/modules/gltf/doc_classes/GLTFLight.xml b/modules/gltf/doc_classes/GLTFLight.xml
index bfeaf9a86e..f51d287685 100644
--- a/modules/gltf/doc_classes/GLTFLight.xml
+++ b/modules/gltf/doc_classes/GLTFLight.xml
@@ -9,7 +9,7 @@
<methods>
</methods>
<members>
- <member name="color" type="Color" setter="set_color" getter="get_color" default="Color( 0, 0, 0, 1 )">
+ <member name="color" type="Color" setter="set_color" getter="get_color" default="Color(0, 0, 0, 1)">
</member>
<member name="inner_cone_angle" type="float" setter="set_inner_cone_angle" getter="get_inner_cone_angle" default="0.0">
</member>
diff --git a/modules/gltf/doc_classes/GLTFMesh.xml b/modules/gltf/doc_classes/GLTFMesh.xml
index 55f79d2c55..fd7e4a169e 100644
--- a/modules/gltf/doc_classes/GLTFMesh.xml
+++ b/modules/gltf/doc_classes/GLTFMesh.xml
@@ -9,7 +9,7 @@
<methods>
</methods>
<members>
- <member name="blend_weights" type="PackedFloat32Array" setter="set_blend_weights" getter="get_blend_weights" default="PackedFloat32Array( )">
+ <member name="blend_weights" type="PackedFloat32Array" setter="set_blend_weights" getter="get_blend_weights" default="PackedFloat32Array()">
</member>
<member name="mesh" type="EditorSceneImporterMesh" setter="set_mesh" getter="get_mesh">
</member>
diff --git a/modules/gltf/doc_classes/GLTFNode.xml b/modules/gltf/doc_classes/GLTFNode.xml
index 5d84d7088b..bfbb12df4d 100644
--- a/modules/gltf/doc_classes/GLTFNode.xml
+++ b/modules/gltf/doc_classes/GLTFNode.xml
@@ -11,7 +11,7 @@
<members>
<member name="camera" type="int" setter="set_camera" getter="get_camera" default="-1">
</member>
- <member name="children" type="PackedInt32Array" setter="set_children" getter="get_children" default="PackedInt32Array( )">
+ <member name="children" type="PackedInt32Array" setter="set_children" getter="get_children" default="PackedInt32Array()">
</member>
<member name="height" type="int" setter="set_height" getter="get_height" default="-1">
</member>
@@ -23,17 +23,17 @@
</member>
<member name="parent" type="int" setter="set_parent" getter="get_parent" default="-1">
</member>
- <member name="rotation" type="Quaternion" setter="set_rotation" getter="get_rotation" default="Quaternion( 0, 0, 0, 1 )">
+ <member name="rotation" type="Quaternion" setter="set_rotation" getter="get_rotation" default="Quaternion(0, 0, 0, 1)">
</member>
- <member name="scale" type="Vector3" setter="set_scale" getter="get_scale" default="Vector3( 1, 1, 1 )">
+ <member name="scale" type="Vector3" setter="set_scale" getter="get_scale" default="Vector3(1, 1, 1)">
</member>
<member name="skeleton" type="int" setter="set_skeleton" getter="get_skeleton" default="-1">
</member>
<member name="skin" type="int" setter="set_skin" getter="get_skin" default="-1">
</member>
- <member name="translation" type="Vector3" setter="set_translation" getter="get_translation" default="Vector3( 0, 0, 0 )">
+ <member name="translation" type="Vector3" setter="set_translation" getter="get_translation" default="Vector3(0, 0, 0)">
</member>
- <member name="xform" type="Transform3D" setter="set_xform" getter="get_xform" default="Transform3D( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )">
+ <member name="xform" type="Transform3D" setter="set_xform" getter="get_xform" default="Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)">
</member>
</members>
<constants>
diff --git a/modules/gltf/doc_classes/GLTFSkeleton.xml b/modules/gltf/doc_classes/GLTFSkeleton.xml
index 9680c27705..40563c9ac6 100644
--- a/modules/gltf/doc_classes/GLTFSkeleton.xml
+++ b/modules/gltf/doc_classes/GLTFSkeleton.xml
@@ -57,9 +57,9 @@
</method>
</methods>
<members>
- <member name="joints" type="PackedInt32Array" setter="set_joints" getter="get_joints" default="PackedInt32Array( )">
+ <member name="joints" type="PackedInt32Array" setter="set_joints" getter="get_joints" default="PackedInt32Array()">
</member>
- <member name="roots" type="PackedInt32Array" setter="set_roots" getter="get_roots" default="PackedInt32Array( )">
+ <member name="roots" type="PackedInt32Array" setter="set_roots" getter="get_roots" default="PackedInt32Array()">
</member>
</members>
<constants>
diff --git a/modules/gltf/doc_classes/GLTFSkin.xml b/modules/gltf/doc_classes/GLTFSkin.xml
index 5a80c7097a..e20e127e52 100644
--- a/modules/gltf/doc_classes/GLTFSkin.xml
+++ b/modules/gltf/doc_classes/GLTFSkin.xml
@@ -53,13 +53,13 @@
<members>
<member name="godot_skin" type="Skin" setter="set_godot_skin" getter="get_godot_skin">
</member>
- <member name="joints" type="PackedInt32Array" setter="set_joints" getter="get_joints" default="PackedInt32Array( )">
+ <member name="joints" type="PackedInt32Array" setter="set_joints" getter="get_joints" default="PackedInt32Array()">
</member>
- <member name="joints_original" type="PackedInt32Array" setter="set_joints_original" getter="get_joints_original" default="PackedInt32Array( )">
+ <member name="joints_original" type="PackedInt32Array" setter="set_joints_original" getter="get_joints_original" default="PackedInt32Array()">
</member>
- <member name="non_joints" type="PackedInt32Array" setter="set_non_joints" getter="get_non_joints" default="PackedInt32Array( )">
+ <member name="non_joints" type="PackedInt32Array" setter="set_non_joints" getter="get_non_joints" default="PackedInt32Array()">
</member>
- <member name="roots" type="PackedInt32Array" setter="set_roots" getter="get_roots" default="PackedInt32Array( )">
+ <member name="roots" type="PackedInt32Array" setter="set_roots" getter="get_roots" default="PackedInt32Array()">
</member>
<member name="skeleton" type="int" setter="set_skeleton" getter="get_skeleton" default="-1">
</member>
diff --git a/modules/gltf/doc_classes/GLTFSpecGloss.xml b/modules/gltf/doc_classes/GLTFSpecGloss.xml
index 68cc7c845d..6e9c419649 100644
--- a/modules/gltf/doc_classes/GLTFSpecGloss.xml
+++ b/modules/gltf/doc_classes/GLTFSpecGloss.xml
@@ -9,7 +9,7 @@
<methods>
</methods>
<members>
- <member name="diffuse_factor" type="Color" setter="set_diffuse_factor" getter="get_diffuse_factor" default="Color( 1, 1, 1, 1 )">
+ <member name="diffuse_factor" type="Color" setter="set_diffuse_factor" getter="get_diffuse_factor" default="Color(1, 1, 1, 1)">
</member>
<member name="diffuse_img" type="Image" setter="set_diffuse_img" getter="get_diffuse_img">
</member>
@@ -17,7 +17,7 @@
</member>
<member name="spec_gloss_img" type="Image" setter="set_spec_gloss_img" getter="get_spec_gloss_img">
</member>
- <member name="specular_factor" type="Color" setter="set_specular_factor" getter="get_specular_factor" default="Color( 1, 1, 1, 1 )">
+ <member name="specular_factor" type="Color" setter="set_specular_factor" getter="get_specular_factor" default="Color(1, 1, 1, 1)">
</member>
</members>
<constants>
diff --git a/modules/gltf/doc_classes/GLTFState.xml b/modules/gltf/doc_classes/GLTFState.xml
index 8255cd73d0..a7b5b7b43e 100644
--- a/modules/gltf/doc_classes/GLTFState.xml
+++ b/modules/gltf/doc_classes/GLTFState.xml
@@ -243,9 +243,9 @@
</method>
</methods>
<members>
- <member name="buffers" type="Array" setter="set_buffers" getter="get_buffers" default="[ ]">
+ <member name="buffers" type="Array" setter="set_buffers" getter="get_buffers" default="[]">
</member>
- <member name="glb_data" type="PackedByteArray" setter="set_glb_data" getter="get_glb_data" default="PackedByteArray( )">
+ <member name="glb_data" type="PackedByteArray" setter="set_glb_data" getter="get_glb_data" default="PackedByteArray()">
</member>
<member name="json" type="Dictionary" setter="set_json" getter="get_json" default="{}">
</member>
@@ -253,7 +253,7 @@
</member>
<member name="minor_version" type="int" setter="set_minor_version" getter="get_minor_version" default="0">
</member>
- <member name="root_nodes" type="Array" setter="set_root_nodes" getter="get_root_nodes" default="[ ]">
+ <member name="root_nodes" type="Array" setter="set_root_nodes" getter="get_root_nodes" default="[]">
</member>
<member name="scene_name" type="String" setter="set_scene_name" getter="get_scene_name" default="&quot;&quot;">
</member>
diff --git a/modules/gltf/doc_classes/PackedSceneGLTF.xml b/modules/gltf/doc_classes/PackedSceneGLTF.xml
index a04c6ef0b6..a22111e9b7 100644
--- a/modules/gltf/doc_classes/PackedSceneGLTF.xml
+++ b/modules/gltf/doc_classes/PackedSceneGLTF.xml
@@ -51,7 +51,7 @@
</method>
</methods>
<members>
- <member name="_bundled" type="Dictionary" setter="_set_bundled_scene" getter="_get_bundled_scene" override="true" default="{&quot;conn_count&quot;: 0,&quot;conns&quot;: PackedInt32Array( ),&quot;editable_instances&quot;: [ ],&quot;names&quot;: PackedStringArray( ),&quot;node_count&quot;: 0,&quot;node_paths&quot;: [ ],&quot;nodes&quot;: PackedInt32Array( ),&quot;variants&quot;: [ ],&quot;version&quot;: 2}" />
+ <member name="_bundled" type="Dictionary" setter="_set_bundled_scene" getter="_get_bundled_scene" override="true" default="{&quot;conn_count&quot;: 0,&quot;conns&quot;: PackedInt32Array(),&quot;editable_instances&quot;: [],&quot;names&quot;: PackedStringArray(),&quot;node_count&quot;: 0,&quot;node_paths&quot;: [],&quot;nodes&quot;: PackedInt32Array(),&quot;variants&quot;: [],&quot;version&quot;: 2}" />
</members>
<constants>
</constants>
diff --git a/modules/gltf/editor_scene_exporter_gltf_plugin.cpp b/modules/gltf/editor_scene_exporter_gltf_plugin.cpp
index 4cdaccde6f..ae080bcc9a 100644
--- a/modules/gltf/editor_scene_exporter_gltf_plugin.cpp
+++ b/modules/gltf/editor_scene_exporter_gltf_plugin.cpp
@@ -49,7 +49,7 @@ bool SceneExporterGLTFPlugin::has_main_screen() const {
SceneExporterGLTFPlugin::SceneExporterGLTFPlugin(EditorNode *p_node) {
editor = p_node;
- convert_gltf2.instance();
+ convert_gltf2.instantiate();
file_export_lib = memnew(EditorFileDialog);
editor->get_gui_base()->add_child(file_export_lib);
file_export_lib->connect("file_selected", callable_mp(this, &SceneExporterGLTFPlugin::_gltf2_dialog_action));
diff --git a/modules/gltf/editor_scene_importer_gltf.cpp b/modules/gltf/editor_scene_importer_gltf.cpp
index 35f44ca122..cef5278f03 100644
--- a/modules/gltf/editor_scene_importer_gltf.cpp
+++ b/modules/gltf/editor_scene_importer_gltf.cpp
@@ -29,10 +29,9 @@
/*************************************************************************/
#include "core/crypto/crypto_core.h"
-#include "core/io/json.h"
+#include "core/io/file_access.h"
#include "core/math/disjoint_set.h"
#include "core/math/math_defs.h"
-#include "core/os/file_access.h"
#include "core/os/os.h"
#include "editor/import/resource_importer_scene.h"
#include "modules/gltf/gltf_state.h"
@@ -60,7 +59,7 @@ Node *EditorSceneImporterGLTF::import_scene(const String &p_path,
List<String> *r_missing_deps,
Error *r_err) {
Ref<PackedSceneGLTF> importer;
- importer.instance();
+ importer.instantiate();
return importer->import_scene(p_path, p_flags, p_bake_fps, r_missing_deps, r_err, Ref<GLTFState>());
}
@@ -91,13 +90,13 @@ Node *PackedSceneGLTF::import_scene(const String &p_path, uint32_t p_flags,
Error *r_err,
Ref<GLTFState> r_state) {
if (r_state == Ref<GLTFState>()) {
- r_state.instance();
+ r_state.instantiate();
}
r_state->use_named_skin_binds =
p_flags & EditorSceneImporter::IMPORT_USE_NAMED_SKIN_BINDS;
Ref<GLTFDocument> gltf_document;
- gltf_document.instance();
+ gltf_document.instantiate();
Error err = gltf_document->parse(r_state, p_path);
if (r_err) {
*r_err = err;
@@ -139,9 +138,9 @@ void PackedSceneGLTF::save_scene(Node *p_node, const String &p_path,
*r_err = err;
}
Ref<GLTFDocument> gltf_document;
- gltf_document.instance();
+ gltf_document.instantiate();
Ref<GLTFState> state;
- state.instance();
+ state.instantiate();
err = gltf_document->serialize(state, p_node, p_path);
if (r_err) {
*r_err = err;
@@ -172,7 +171,7 @@ Error PackedSceneGLTF::export_gltf(Node *p_root, String p_path,
int32_t flags = p_flags;
real_t baked_fps = p_bake_fps;
Ref<PackedSceneGLTF> exporter;
- exporter.instance();
+ exporter.instantiate();
exporter->save_scene(p_root, path, "", flags, baked_fps, &deps, &err);
int32_t error_code = err;
if (error_code != 0) {
diff --git a/modules/gltf/editor_scene_importer_gltf.h b/modules/gltf/editor_scene_importer_gltf.h
index af1a885f2b..566d5cfd34 100644
--- a/modules/gltf/editor_scene_importer_gltf.h
+++ b/modules/gltf/editor_scene_importer_gltf.h
@@ -32,7 +32,6 @@
#define EDITOR_SCENE_IMPORTER_GLTF_H
#include "core/config/project_settings.h"
-#include "core/io/json.h"
#include "core/object/object.h"
#include "core/templates/vector.h"
#include "editor/import/resource_importer_scene.h"
diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp
index fa93704fd9..a5080f9c41 100644
--- a/modules/gltf/gltf_document.cpp
+++ b/modules/gltf/gltf_document.cpp
@@ -49,9 +49,9 @@
#include "core/core_bind.h"
#include "core/crypto/crypto_core.h"
+#include "core/io/file_access.h"
#include "core/io/json.h"
#include "core/math/disjoint_set.h"
-#include "core/os/file_access.h"
#include "core/variant/typed_array.h"
#include "core/version.h"
#include "core/version_hash.gen.h"
@@ -238,15 +238,13 @@ Error GLTFDocument::_parse_json(const String &p_path, Ref<GLTFState> state) {
String text;
text.parse_utf8((const char *)array.ptr(), array.size());
- String err_txt;
- int err_line;
- Variant v;
- err = JSON::parse(text, v, err_txt, err_line);
+ JSON json;
+ err = json.parse(text);
if (err != OK) {
- _err_print_error("", p_path.utf8().get_data(), err_line, err_txt.utf8().get_data(), ERR_HANDLER_SCRIPT);
+ _err_print_error("", p_path.utf8().get_data(), json.get_error_line(), json.get_error_message().utf8().get_data(), ERR_HANDLER_SCRIPT);
return err;
}
- state->json = v;
+ state->json = json.get_data();
return OK;
}
@@ -299,16 +297,14 @@ Error GLTFDocument::_parse_glb(const String &p_path, Ref<GLTFState> state) {
String text;
text.parse_utf8((const char *)json_data.ptr(), json_data.size());
- String err_txt;
- int err_line;
- Variant v;
- err = JSON::parse(text, v, err_txt, err_line);
+ JSON json;
+ err = json.parse(text);
if (err != OK) {
- _err_print_error("", p_path.utf8().get_data(), err_line, err_txt.utf8().get_data(), ERR_HANDLER_SCRIPT);
+ _err_print_error("", p_path.utf8().get_data(), json.get_error_line(), json.get_error_message().utf8().get_data(), ERR_HANDLER_SCRIPT);
return err;
}
- state->json = v;
+ state->json = json.get_data();
//data?
@@ -569,7 +565,7 @@ Error GLTFDocument::_parse_nodes(Ref<GLTFState> state) {
const Array &nodes = state->json["nodes"];
for (int i = 0; i < nodes.size(); i++) {
Ref<GLTFNode> node;
- node.instance();
+ node.instantiate();
const Dictionary &n = nodes[i];
if (n.has("name")) {
@@ -830,7 +826,7 @@ Error GLTFDocument::_parse_buffer_views(Ref<GLTFState> state) {
const Dictionary &d = buffers[i];
Ref<GLTFBufferView> buffer_view;
- buffer_view.instance();
+ buffer_view.instantiate();
ERR_FAIL_COND_V(!d.has("buffer"), ERR_PARSE_ERROR);
buffer_view->buffer = d["buffer"];
@@ -976,7 +972,7 @@ Error GLTFDocument::_parse_accessors(Ref<GLTFState> state) {
const Dictionary &d = accessors[i];
Ref<GLTFAccessor> accessor;
- accessor.instance();
+ accessor.instantiate();
ERR_FAIL_COND_V(!d.has("componentType"), ERR_PARSE_ERROR);
accessor->component_type = d["componentType"];
@@ -1118,7 +1114,7 @@ Error GLTFDocument::_encode_buffer_view(Ref<GLTFState> state, const double *src,
}
Ref<GLTFBufferView> bv;
- bv.instance();
+ bv.instantiate();
const uint32_t offset = bv->byte_offset = byte_offset;
Vector<uint8_t> &gltf_buffer = state->buffers.write[0];
@@ -1512,7 +1508,7 @@ GLTFAccessorIndex GLTFDocument::_encode_accessor_as_ints(Ref<GLTFState> state, c
ERR_FAIL_COND_V(attribs.size() == 0, -1);
Ref<GLTFAccessor> accessor;
- accessor.instance();
+ accessor.instantiate();
GLTFBufferIndex buffer_view_i;
int64_t size = state->buffers[0].size();
const GLTFDocument::GLTFType type = GLTFDocument::TYPE_SCALAR;
@@ -1596,7 +1592,7 @@ GLTFAccessorIndex GLTFDocument::_encode_accessor_as_vec2(Ref<GLTFState> state, c
ERR_FAIL_COND_V(attribs.size() % element_count != 0, -1);
Ref<GLTFAccessor> accessor;
- accessor.instance();
+ accessor.instantiate();
GLTFBufferIndex buffer_view_i;
int64_t size = state->buffers[0].size();
const GLTFDocument::GLTFType type = GLTFDocument::TYPE_VEC2;
@@ -1645,7 +1641,7 @@ GLTFAccessorIndex GLTFDocument::_encode_accessor_as_color(Ref<GLTFState> state,
ERR_FAIL_COND_V(attribs.size() % element_count != 0, -1);
Ref<GLTFAccessor> accessor;
- accessor.instance();
+ accessor.instantiate();
GLTFBufferIndex buffer_view_i;
int64_t size = state->buffers[0].size();
const GLTFDocument::GLTFType type = GLTFDocument::TYPE_VEC4;
@@ -1710,7 +1706,7 @@ GLTFAccessorIndex GLTFDocument::_encode_accessor_as_weights(Ref<GLTFState> state
ERR_FAIL_COND_V(attribs.size() % element_count != 0, -1);
Ref<GLTFAccessor> accessor;
- accessor.instance();
+ accessor.instantiate();
GLTFBufferIndex buffer_view_i;
int64_t size = state->buffers[0].size();
const GLTFDocument::GLTFType type = GLTFDocument::TYPE_VEC4;
@@ -1757,7 +1753,7 @@ GLTFAccessorIndex GLTFDocument::_encode_accessor_as_joints(Ref<GLTFState> state,
ERR_FAIL_COND_V(attribs.size() % element_count != 0, -1);
Ref<GLTFAccessor> accessor;
- accessor.instance();
+ accessor.instantiate();
GLTFBufferIndex buffer_view_i;
int64_t size = state->buffers[0].size();
const GLTFDocument::GLTFType type = GLTFDocument::TYPE_VEC4;
@@ -1806,7 +1802,7 @@ GLTFAccessorIndex GLTFDocument::_encode_accessor_as_quaternions(Ref<GLTFState> s
ERR_FAIL_COND_V(attribs.size() % element_count != 0, -1);
Ref<GLTFAccessor> accessor;
- accessor.instance();
+ accessor.instantiate();
GLTFBufferIndex buffer_view_i;
int64_t size = state->buffers[0].size();
const GLTFDocument::GLTFType type = GLTFDocument::TYPE_VEC4;
@@ -1871,7 +1867,7 @@ GLTFAccessorIndex GLTFDocument::_encode_accessor_as_floats(Ref<GLTFState> state,
ERR_FAIL_COND_V(!attribs.size(), -1);
Ref<GLTFAccessor> accessor;
- accessor.instance();
+ accessor.instantiate();
GLTFBufferIndex buffer_view_i;
int64_t size = state->buffers[0].size();
const GLTFDocument::GLTFType type = GLTFDocument::TYPE_SCALAR;
@@ -1917,7 +1913,7 @@ GLTFAccessorIndex GLTFDocument::_encode_accessor_as_vec3(Ref<GLTFState> state, c
ERR_FAIL_COND_V(attribs.size() % element_count != 0, -1);
Ref<GLTFAccessor> accessor;
- accessor.instance();
+ accessor.instantiate();
GLTFBufferIndex buffer_view_i;
int64_t size = state->buffers[0].size();
const GLTFDocument::GLTFType type = GLTFDocument::TYPE_VEC3;
@@ -1985,7 +1981,7 @@ GLTFAccessorIndex GLTFDocument::_encode_accessor_as_xform(Ref<GLTFState> state,
ERR_FAIL_COND_V(attribs.size() % element_count != 0, -1);
Ref<GLTFAccessor> accessor;
- accessor.instance();
+ accessor.instantiate();
GLTFBufferIndex buffer_view_i;
int64_t size = state->buffers[0].size();
const GLTFDocument::GLTFType type = GLTFDocument::TYPE_MAT4;
@@ -2335,7 +2331,7 @@ Error GLTFDocument::_serialize_meshes(Ref<GLTFState> state) {
//generate indices because they need to be swapped for CW/CCW
const Vector<Vector3> &vertices = array[Mesh::ARRAY_VERTEX];
Ref<SurfaceTool> st;
- st.instance();
+ st.instantiate();
st->create_from_triangle_arrays(array);
st->index();
Vector<int32_t> generated_indices = st->commit_to_arrays()[Mesh::ARRAY_INDEX];
@@ -2459,7 +2455,7 @@ Error GLTFDocument::_parse_meshes(Ref<GLTFState> state) {
Dictionary d = meshes[i];
Ref<GLTFMesh> mesh;
- mesh.instance();
+ mesh.instantiate();
bool has_vertex_color = false;
ERR_FAIL_COND_V(!d.has("primitives"), ERR_PARSE_ERROR);
@@ -2467,7 +2463,7 @@ Error GLTFDocument::_parse_meshes(Ref<GLTFState> state) {
Array primitives = d["primitives"];
const Dictionary &extras = d.has("extras") ? (Dictionary)d["extras"] : Dictionary();
Ref<EditorSceneImporterMesh> import_mesh;
- import_mesh.instance();
+ import_mesh.instantiate();
String mesh_name = "mesh";
if (d.has("name") && !String(d["name"]).is_empty()) {
mesh_name = d["name"];
@@ -2652,11 +2648,11 @@ Error GLTFDocument::_parse_meshes(Ref<GLTFState> state) {
if (generate_tangents) {
//must generate mikktspace tangents.. ergh..
Ref<SurfaceTool> st;
- st.instance();
+ st.instantiate();
+ st->create_from_triangle_arrays(array);
if (a.has("JOINTS_0") && a.has("JOINTS_1")) {
st->set_skin_weight_count(SurfaceTool::SKIN_8_WEIGHTS);
}
- st->create_from_triangle_arrays(array);
st->generate_tangents();
array = st->commit_to_arrays();
}
@@ -2771,11 +2767,11 @@ Error GLTFDocument::_parse_meshes(Ref<GLTFState> state) {
if (generate_tangents) {
Ref<SurfaceTool> st;
- st.instance();
+ st.instantiate();
+ st->create_from_triangle_arrays(array_copy);
if (a.has("JOINTS_0") && a.has("JOINTS_1")) {
st->set_skin_weight_count(SurfaceTool::SKIN_8_WEIGHTS);
}
- st->create_from_triangle_arrays(array_copy);
st->deindex();
st->generate_tangents();
array_copy = st->commit_to_arrays();
@@ -2799,7 +2795,7 @@ Error GLTFDocument::_parse_meshes(Ref<GLTFState> state) {
} else if (has_vertex_color) {
Ref<StandardMaterial3D> mat3d;
- mat3d.instance();
+ mat3d.instantiate();
mat3d->set_flag(BaseMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
mat = mat3d;
}
@@ -2847,7 +2843,7 @@ Error GLTFDocument::_serialize_images(Ref<GLTFState> state, const String &p_path
GLTFBufferViewIndex bvi;
Ref<GLTFBufferView> bv;
- bv.instance();
+ bv.instantiate();
const GLTFBufferIndex bi = 0;
bv->buffer = bi;
@@ -2879,7 +2875,7 @@ Error GLTFDocument::_serialize_images(Ref<GLTFState> state, const String &p_path
name = _gen_unique_name(state, name);
name = name.pad_zeros(3);
Ref<_Directory> dir;
- dir.instance();
+ dir.instantiate();
String texture_dir = "textures";
String new_texture_dir = p_path.get_base_dir() + "/" + texture_dir;
dir->open(p_path.get_base_dir());
@@ -3038,7 +3034,7 @@ Error GLTFDocument::_parse_images(Ref<GLTFState> state, const String &p_base_pat
}
Ref<ImageTexture> t;
- t.instance();
+ t.instantiate();
t->create_from_image(img);
state->images.push_back(t);
@@ -3079,7 +3075,7 @@ Error GLTFDocument::_parse_textures(Ref<GLTFState> state) {
ERR_FAIL_COND_V(!d.has("source"), ERR_PARSE_ERROR);
Ref<GLTFTexture> t;
- t.instance();
+ t.instantiate();
t->set_src_image(d["source"]);
state->textures.push_back(t);
}
@@ -3090,7 +3086,7 @@ Error GLTFDocument::_parse_textures(Ref<GLTFState> state) {
GLTFTextureIndex GLTFDocument::_set_texture(Ref<GLTFState> state, Ref<Texture2D> p_texture) {
ERR_FAIL_COND_V(p_texture.is_null(), -1);
Ref<GLTFTexture> gltf_texture;
- gltf_texture.instance();
+ gltf_texture.instantiate();
ERR_FAIL_COND_V(p_texture->get_image().is_null(), -1);
GLTFImageIndex gltf_src_image_i = state->images.size();
state->images.push_back(p_texture);
@@ -3163,9 +3159,9 @@ Error GLTFDocument::_serialize_materials(Ref<GLTFState> state) {
Ref<Texture2D> ao_texture = material->get_texture(BaseMaterial3D::TEXTURE_AMBIENT_OCCLUSION);
BaseMaterial3D::TextureChannel ao_channel = material->get_ao_texture_channel();
Ref<ImageTexture> orm_texture;
- orm_texture.instance();
+ orm_texture.instantiate();
Ref<Image> orm_image;
- orm_image.instance();
+ orm_image.instantiate();
int32_t height = 0;
int32_t width = 0;
Ref<Image> ao_image;
@@ -3285,7 +3281,7 @@ Error GLTFDocument::_serialize_materials(Ref<GLTFState> state) {
if (material->get_feature(BaseMaterial3D::FEATURE_NORMAL_MAPPING)) {
Dictionary nt;
Ref<ImageTexture> tex;
- tex.instance();
+ tex.instantiate();
{
Ref<Texture2D> normal_texture = material->get_texture(BaseMaterial3D::TEXTURE_NORMAL);
// Code for uncompressing RG normal maps
@@ -3373,7 +3369,7 @@ Error GLTFDocument::_parse_materials(Ref<GLTFState> state) {
const Dictionary &d = materials[i];
Ref<StandardMaterial3D> material;
- material.instance();
+ material.instantiate();
if (d.has("name") && !String(d["name"]).is_empty()) {
material->set_name(d["name"]);
} else {
@@ -3389,7 +3385,7 @@ Error GLTFDocument::_parse_materials(Ref<GLTFState> state) {
Dictionary sgm = pbr_spec_gloss_extensions["KHR_materials_pbrSpecularGlossiness"];
Ref<GLTFSpecGloss> spec_gloss;
- spec_gloss.instance();
+ spec_gloss.instantiate();
if (sgm.has("diffuseTexture")) {
const Dictionary &diffuse_texture_dict = sgm["diffuseTexture"];
if (diffuse_texture_dict.has("index")) {
@@ -3572,7 +3568,7 @@ void GLTFDocument::spec_gloss_to_rough_metal(Ref<GLTFSpecGloss> r_spec_gloss, Re
return;
}
Ref<Image> rm_img;
- rm_img.instance();
+ rm_img.instantiate();
bool has_roughness = false;
bool has_metal = false;
p_material->set_roughness(1.0f);
@@ -3600,7 +3596,7 @@ void GLTFDocument::spec_gloss_to_rough_metal(Ref<GLTFSpecGloss> r_spec_gloss, Re
if (!Math::is_equal_approx(mr.g, 1.0f)) {
has_roughness = true;
}
- if (!Math::is_equal_approx(mr.b, 0.0f)) {
+ if (!Math::is_zero_approx(mr.b)) {
has_metal = true;
}
mr.g *= r_spec_gloss->gloss_factor;
@@ -3614,11 +3610,11 @@ void GLTFDocument::spec_gloss_to_rough_metal(Ref<GLTFSpecGloss> r_spec_gloss, Re
rm_img->generate_mipmaps();
r_spec_gloss->diffuse_img->generate_mipmaps();
Ref<ImageTexture> diffuse_image_texture;
- diffuse_image_texture.instance();
+ diffuse_image_texture.instantiate();
diffuse_image_texture->create_from_image(r_spec_gloss->diffuse_img);
p_material->set_texture(BaseMaterial3D::TEXTURE_ALBEDO, diffuse_image_texture);
Ref<ImageTexture> rm_image_texture;
- rm_image_texture.instance();
+ rm_image_texture.instantiate();
rm_image_texture->create_from_image(rm_img);
if (has_roughness) {
p_material->set_texture(BaseMaterial3D::TEXTURE_ROUGHNESS, rm_image_texture);
@@ -3894,7 +3890,7 @@ Error GLTFDocument::_parse_skins(Ref<GLTFState> state) {
const Dictionary &d = skins[i];
Ref<GLTFSkin> skin;
- skin.instance();
+ skin.instantiate();
ERR_FAIL_COND_V(!d.has("joints"), ERR_PARSE_ERROR);
@@ -4022,7 +4018,7 @@ Error GLTFDocument::_determine_skeletons(Ref<GLTFState> state) {
for (GLTFSkeletonIndex skel_i = 0; skel_i < skeleton_owners.size(); ++skel_i) {
const GLTFNodeIndex skeleton_owner = skeleton_owners[skel_i];
Ref<GLTFSkeleton> skeleton;
- skeleton.instance();
+ skeleton.instantiate();
Vector<GLTFNodeIndex> skeleton_nodes;
skeleton_sets.get_members(skeleton_nodes, skeleton_owner);
@@ -4270,7 +4266,7 @@ Error GLTFDocument::_create_skins(Ref<GLTFState> state) {
Ref<GLTFSkin> gltf_skin = state->skins.write[skin_i];
Ref<Skin> skin;
- skin.instance();
+ skin.instantiate();
// Some skins don't have IBM's! What absolute monsters!
const bool has_ibms = !gltf_skin->inverse_binds.is_empty();
@@ -4452,7 +4448,7 @@ Error GLTFDocument::_parse_lights(Ref<GLTFState> state) {
const Dictionary &d = lights[light_i];
Ref<GLTFLight> light;
- light.instance();
+ light.instantiate();
ERR_FAIL_COND_V(!d.has("type"), ERR_PARSE_ERROR);
const String &type = d["type"];
light->type = type;
@@ -4497,7 +4493,7 @@ Error GLTFDocument::_parse_cameras(Ref<GLTFState> state) {
const Dictionary &d = cameras[i];
Ref<GLTFCamera> camera;
- camera.instance();
+ camera.instantiate();
ERR_FAIL_COND_V(!d.has("type"), ERR_PARSE_ERROR);
const String &type = d["type"];
if (type == "orthographic") {
@@ -4700,7 +4696,7 @@ Error GLTFDocument::_parse_animations(Ref<GLTFState> state) {
const Dictionary &d = animations[i];
Ref<GLTFAnimation> animation;
- animation.instance();
+ animation.instantiate();
if (!d.has("channels") || !d.has("samplers")) {
continue;
@@ -4868,7 +4864,7 @@ GLTFMeshIndex GLTFDocument::_convert_mesh_instance(Ref<GLTFState> state, MeshIns
return -1;
}
Ref<EditorSceneImporterMesh> import_mesh;
- import_mesh.instance();
+ import_mesh.instantiate();
Ref<Mesh> godot_mesh = p_mesh_instance->get_mesh();
if (godot_mesh.is_null()) {
return -1;
@@ -4905,7 +4901,7 @@ GLTFMeshIndex GLTFDocument::_convert_mesh_instance(Ref<GLTFState> state, MeshIns
blend_weights.write[blend_i] = 0.0f;
}
Ref<GLTFMesh> gltf_mesh;
- gltf_mesh.instance();
+ gltf_mesh.instantiate();
gltf_mesh->set_mesh(import_mesh);
gltf_mesh->set_blend_weights(blend_weights);
GLTFMeshIndex mesh_i = state->meshes.size();
@@ -5010,7 +5006,7 @@ GLTFCameraIndex GLTFDocument::_convert_camera(Ref<GLTFState> state, Camera3D *p_
print_verbose("glTF: Converting camera: " + p_camera->get_name());
Ref<GLTFCamera> c;
- c.instance();
+ c.instantiate();
if (p_camera->get_projection() == Camera3D::Projection::PROJECTION_PERSPECTIVE) {
c->set_perspective(true);
@@ -5031,7 +5027,7 @@ GLTFLightIndex GLTFDocument::_convert_light(Ref<GLTFState> state, Light3D *p_lig
print_verbose("glTF: Converting light: " + p_light->get_name());
Ref<GLTFLight> l;
- l.instance();
+ l.instantiate();
l->color = p_light->get_color();
if (cast_to<DirectionalLight3D>(p_light)) {
l->type = "directional";
@@ -5066,7 +5062,7 @@ GLTFLightIndex GLTFDocument::_convert_light(Ref<GLTFState> state, Light3D *p_lig
GLTFSkeletonIndex GLTFDocument::_convert_skeleton(Ref<GLTFState> state, Skeleton3D *p_skeleton) {
print_verbose("glTF: Converting skeleton: " + p_skeleton->get_name());
Ref<GLTFSkeleton> gltf_skeleton;
- gltf_skeleton.instance();
+ gltf_skeleton.instantiate();
gltf_skeleton->set_name(_gen_unique_name(state, p_skeleton->get_name()));
gltf_skeleton->godot_skeleton = p_skeleton;
GLTFSkeletonIndex skeleton_i = state->skeletons.size();
@@ -5096,7 +5092,7 @@ void GLTFDocument::_convert_scene_node(Ref<GLTFState> state, Node *p_current, No
return;
}
Ref<GLTFNode> gltf_node;
- gltf_node.instance();
+ gltf_node.instantiate();
gltf_node->set_name(_gen_unique_name(state, p_current->get_name()));
if (cast_to<Node3D>(p_current)) {
Node3D *spatial = cast_to<Node3D>(p_current);
@@ -5162,9 +5158,9 @@ void GLTFDocument::_convert_csg_shape_to_gltf(Node *p_current, GLTFNodeIndex p_g
mat = csg->get_material_override();
}
Ref<GLTFMesh> gltf_mesh;
- gltf_mesh.instance();
+ gltf_mesh.instantiate();
Ref<EditorSceneImporterMesh> import_mesh;
- import_mesh.instance();
+ import_mesh.instantiate();
Ref<ArrayMesh> array_mesh = csg->get_meshes()[1];
for (int32_t surface_i = 0; surface_i < array_mesh->get_surface_count(); surface_i++) {
import_mesh->add_surface(Mesh::PrimitiveType::PRIMITIVE_TRIANGLES, array_mesh->surface_get_arrays(surface_i), Array(), Dictionary(), mat, array_mesh->surface_get_name(surface_i));
@@ -5250,7 +5246,7 @@ void GLTFDocument::_convert_grid_map_to_gltf(Node *p_scene_parent, const GLTFNod
cell_xform.set_origin(grid_map->map_to_world(
Vector3(cell_location.x, cell_location.y, cell_location.z)));
Ref<GLTFMesh> gltf_mesh;
- gltf_mesh.instance();
+ gltf_mesh.instantiate();
gltf_mesh = import_mesh_node;
new_gltf_node->mesh = state->meshes.size();
state->meshes.push_back(gltf_mesh);
@@ -5287,14 +5283,14 @@ void GLTFDocument::_convert_mult_mesh_instance_to_gltf(Node *p_scene_parent, con
Ref<ArrayMesh> mm = multi_mesh->get_mesh();
if (mm.is_valid()) {
Ref<EditorSceneImporterMesh> mesh;
- mesh.instance();
+ mesh.instantiate();
for (int32_t surface_i = 0; surface_i < mm->get_surface_count(); surface_i++) {
Array surface = mm->surface_get_arrays(surface_i);
mesh->add_surface(mm->surface_get_primitive_type(surface_i), surface, Array(), Dictionary(),
mm->surface_get_material(surface_i), mm->get_name());
}
Ref<GLTFMesh> gltf_mesh;
- gltf_mesh.instance();
+ gltf_mesh.instantiate();
gltf_mesh->set_name(multi_mesh->get_name());
gltf_mesh->set_mesh(mesh);
new_gltf_node->mesh = state->meshes.size();
@@ -5541,6 +5537,8 @@ struct EditorSceneImporterGLTFInterpolate<Quaternion> {
template <class T>
T GLTFDocument::_interpolate_track(const Vector<float> &p_times, const Vector<T> &p_values, const float p_time, const GLTFAnimation::Interpolation p_interp) {
+ ERR_FAIL_COND_V(!p_values.size(), T());
+ ERR_FAIL_COND_V(p_times.size() != p_values.size(), p_values[0]);
//could use binary search, worth it?
int idx = -1;
for (int i = 0; i < p_times.size(); i++) {
@@ -5615,7 +5613,7 @@ void GLTFDocument::_import_animation(Ref<GLTFState> state, AnimationPlayer *ap,
}
Ref<Animation> animation;
- animation.instance();
+ animation.instantiate();
animation->set_name(name);
if (anim->get_loop()) {
@@ -5826,7 +5824,7 @@ void GLTFDocument::_convert_mesh_instances(Ref<GLTFState> state) {
skin = skeleton->register_skin(nullptr)->get_skin();
}
Ref<GLTFSkin> gltf_skin;
- gltf_skin.instance();
+ gltf_skin.instantiate();
Array json_joints;
GLTFSkeletonIndex skeleton_gltf_i = -1;
@@ -5868,7 +5866,7 @@ void GLTFDocument::_convert_mesh_instances(Ref<GLTFState> state) {
BoneId bone_index = skeleton->find_bone(godot_bone_name);
ERR_CONTINUE(bone_index == -1);
Ref<GLTFNode> joint_node;
- joint_node.instance();
+ joint_node.instantiate();
String gltf_bone_name = _gen_unique_bone_name(state, skeleton_gltf_i, godot_bone_name);
joint_node->set_name(gltf_bone_name);
@@ -6190,7 +6188,7 @@ GLTFAnimation::Track GLTFDocument::_convert_animation_track(Ref<GLTFState> state
void GLTFDocument::_convert_animation(Ref<GLTFState> state, AnimationPlayer *ap, String p_animation_track_name) {
Ref<Animation> animation = ap->get_animation(p_animation_track_name);
Ref<GLTFAnimation> gltf_animation;
- gltf_animation.instance();
+ gltf_animation.instantiate();
gltf_animation->set_name(_gen_unique_name(state, p_animation_track_name));
for (int32_t track_i = 0; track_i < animation->get_track_count(); track_i++) {
@@ -6584,7 +6582,7 @@ Error GLTFDocument::_serialize_file(Ref<GLTFState> state, const String p_path) {
FileAccessRef f = FileAccess::open(p_path, FileAccess::WRITE, &err);
ERR_FAIL_COND_V(!f, FAILED);
- String json = JSON::print(state->json);
+ String json = Variant(state->json).to_json_string();
const uint32_t magic = 0x46546C67; // GLTF
const int32_t header_size = 12;
@@ -6625,7 +6623,7 @@ Error GLTFDocument::_serialize_file(Ref<GLTFState> state, const String p_path) {
ERR_FAIL_COND_V(!f, FAILED);
f->create(FileAccess::ACCESS_RESOURCES);
- String json = JSON::print(state->json);
+ String json = Variant(state->json).to_json_string();
f->store_string(json);
f->close();
}
diff --git a/modules/gltf/register_types.cpp b/modules/gltf/register_types.cpp
index dc995c9249..d11c7cb9cd 100644
--- a/modules/gltf/register_types.cpp
+++ b/modules/gltf/register_types.cpp
@@ -51,7 +51,7 @@
#ifdef TOOLS_ENABLED
static void _editor_init() {
Ref<EditorSceneImporterGLTF> import_gltf;
- import_gltf.instance();
+ import_gltf.instantiate();
ResourceImporterScene::get_singleton()->add_importer(import_gltf);
}
#endif
diff --git a/modules/gridmap/doc_classes/GridMap.xml b/modules/gridmap/doc_classes/GridMap.xml
index fb0a2c9953..a2c8e8eabf 100644
--- a/modules/gridmap/doc_classes/GridMap.xml
+++ b/modules/gridmap/doc_classes/GridMap.xml
@@ -203,7 +203,7 @@
The scale of the cell items.
This does not affect the size of the grid cells themselves, only the items in them. This can be used to make cell items overlap their neighbors.
</member>
- <member name="cell_size" type="Vector3" setter="set_cell_size" getter="get_cell_size" default="Vector3( 2, 2, 2 )">
+ <member name="cell_size" type="Vector3" setter="set_cell_size" getter="get_cell_size" default="Vector3(2, 2, 2)">
The dimensions of the grid's cells.
This does not affect the size of the meshes. See [member cell_scale].
</member>
diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cpp
index 45af59622f..c62e7acd62 100644
--- a/modules/gridmap/grid_map.cpp
+++ b/modules/gridmap/grid_map.cpp
@@ -1012,7 +1012,7 @@ void GridMap::make_baked_meshes(bool p_gen_lightmap_uv, float p_lightmap_uv_texe
Ref<Material> surf_mat = mesh->surface_get_material(i);
if (!mat_map.has(surf_mat)) {
Ref<SurfaceTool> st;
- st.instance();
+ st.instantiate();
st->begin(Mesh::PRIMITIVE_TRIANGLES);
st->set_material(surf_mat);
mat_map[surf_mat] = st;
@@ -1024,7 +1024,7 @@ void GridMap::make_baked_meshes(bool p_gen_lightmap_uv, float p_lightmap_uv_texe
for (Map<OctantKey, Map<Ref<Material>, Ref<SurfaceTool>>>::Element *E = surface_map.front(); E; E = E->next()) {
Ref<ArrayMesh> mesh;
- mesh.instance();
+ mesh.instantiate();
for (Map<Ref<Material>, Ref<SurfaceTool>>::Element *F = E->get().front(); F; F = F->next()) {
F->get()->commit(mesh);
}
diff --git a/modules/gridmap/grid_map_editor_plugin.cpp b/modules/gridmap/grid_map_editor_plugin.cpp
index a47ed6652d..a2f570e6a5 100644
--- a/modules/gridmap/grid_map_editor_plugin.cpp
+++ b/modules/gridmap/grid_map_editor_plugin.cpp
@@ -62,12 +62,6 @@ void GridMapEditor::_menu_option(int p_option) {
floor->set_value(floor->get_value() + 1);
} break;
- case MENU_OPTION_LOCK_VIEW: {
- int index = options->get_popup()->get_item_index(MENU_OPTION_LOCK_VIEW);
- lock_view = !options->get_popup()->is_item_checked(index);
-
- options->get_popup()->set_item_checked(index, lock_view);
- } break;
case MENU_OPTION_CLIP_DISABLED:
case MENU_OPTION_CLIP_ABOVE:
case MENU_OPTION_CLIP_BELOW: {
@@ -1080,26 +1074,22 @@ void GridMapEditor::_notification(int p_what) {
if (cgmt.operator->() != last_mesh_library) {
update_palette();
}
-
- if (lock_view) {
- EditorNode *editor = Object::cast_to<EditorNode>(get_tree()->get_root()->get_child(0));
-
- Plane p;
- p.normal[edit_axis] = 1.0;
- p.d = edit_floor[edit_axis] * node->get_cell_size()[edit_axis];
- p = node->get_transform().xform(p); // plane to snap
-
- 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_theme_icon("GridMap", "EditorIcons"));
search_box->set_right_icon(get_theme_icon("Search", "EditorIcons"));
} break;
+
+ case NOTIFICATION_APPLICATION_FOCUS_OUT: {
+ if (input_action == INPUT_PAINT) {
+ // Simulate mouse released event to stop drawing when editor focus exists.
+ Ref<InputEventMouseButton> release;
+ release.instantiate();
+ release->set_button_index(MOUSE_BUTTON_LEFT);
+ forward_spatial_input_event(nullptr, release);
+ }
+ } break;
}
}
@@ -1187,8 +1177,6 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
spatial_editor_hb->hide();
options->set_text(TTR("Grid Map"));
- options->get_popup()->add_check_item(TTR("Snap View"), MENU_OPTION_LOCK_VIEW);
- options->get_popup()->add_separator();
options->get_popup()->add_item(TTR("Previous Floor"), MENU_OPTION_PREV_LEVEL, KEY_Q);
options->get_popup()->add_item(TTR("Next Floor"), MENU_OPTION_NEXT_LEVEL, KEY_E);
options->get_popup()->add_separator();
@@ -1368,7 +1356,7 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
Array d;
d.resize(RS::ARRAY_MAX);
- inner_mat.instance();
+ inner_mat.instantiate();
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);
@@ -1377,14 +1365,14 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
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.instantiate();
outer_mat->set_albedo(Color(0.7, 0.7, 1.0, 0.8));
outer_mat->set_on_top_of_alpha();
outer_mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
outer_mat->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
- selection_floor_mat.instance();
+ selection_floor_mat.instantiate();
selection_floor_mat->set_albedo(Color(0.80, 0.80, 1.0, 1));
selection_floor_mat->set_on_top_of_alpha();
selection_floor_mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
@@ -1411,7 +1399,7 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
_set_selection(false);
- indicator_mat.instance();
+ indicator_mat.instantiate();
indicator_mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
indicator_mat->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
indicator_mat->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true);
diff --git a/modules/gridmap/grid_map_editor_plugin.h b/modules/gridmap/grid_map_editor_plugin.h
index 0e29c88d26..4bc849e071 100644
--- a/modules/gridmap/grid_map_editor_plugin.h
+++ b/modules/gridmap/grid_map_editor_plugin.h
@@ -94,7 +94,6 @@ class GridMapEditor : public VBoxContainer {
MeshLibrary *last_mesh_library;
ClipMode clip_mode = CLIP_DISABLED;
- bool lock_view = false;
Transform3D grid_xform;
Transform3D edit_grid_xform;
Vector3::Axis edit_axis;
diff --git a/modules/jpg/image_loader_jpegd.cpp b/modules/jpg/image_loader_jpegd.cpp
index d237544d66..b5e4753e8d 100644
--- a/modules/jpg/image_loader_jpegd.cpp
+++ b/modules/jpg/image_loader_jpegd.cpp
@@ -127,7 +127,7 @@ void ImageLoaderJPG::get_recognized_extensions(List<String> *p_extensions) const
static Ref<Image> _jpegd_mem_loader_func(const uint8_t *p_png, int p_size) {
Ref<Image> img;
- img.instance();
+ img.instantiate();
Error err = jpeg_load_image_from_buffer(img.ptr(), p_png, p_size);
ERR_FAIL_COND_V(err, Ref<Image>());
return img;
diff --git a/modules/jsonrpc/jsonrpc.cpp b/modules/jsonrpc/jsonrpc.cpp
index 306c0ff087..3d0759d83e 100644
--- a/modules/jsonrpc/jsonrpc.cpp
+++ b/modules/jsonrpc/jsonrpc.cpp
@@ -29,6 +29,7 @@
/*************************************************************************/
#include "jsonrpc.h"
+
#include "core/io/json.h"
JSONRPC::JSONRPC() {
@@ -156,19 +157,17 @@ String JSONRPC::process_string(const String &p_input) {
}
Variant ret;
- Variant input;
- String err_message;
- int err_line;
- if (OK != JSON::parse(p_input, input, err_message, err_line)) {
- ret = make_response_error(JSONRPC::PARSE_ERROR, "Parse error");
+ JSON json;
+ if (json.parse(p_input) == OK) {
+ ret = process_action(json.get_data(), true);
} else {
- ret = process_action(input, true);
+ ret = make_response_error(JSONRPC::PARSE_ERROR, "Parse error");
}
if (ret.get_type() == Variant::NIL) {
return "";
}
- return JSON::print(ret);
+ return ret.to_json_string();
}
void JSONRPC::set_scope(const String &p_scope, Object *p_obj) {
diff --git a/modules/lightmapper_rd/lightmapper_rd.cpp b/modules/lightmapper_rd/lightmapper_rd.cpp
index 3b0fbb1c47..b75cf6502e 100644
--- a/modules/lightmapper_rd/lightmapper_rd.cpp
+++ b/modules/lightmapper_rd/lightmapper_rd.cpp
@@ -248,13 +248,13 @@ Lightmapper::BakeError LightmapperRD::_blit_meshes_into_atlas(int p_max_texture_
for (int i = 0; i < atlas_slices; i++) {
Ref<Image> albedo;
- albedo.instance();
+ albedo.instantiate();
albedo->create(atlas_size.width, atlas_size.height, false, Image::FORMAT_RGBA8);
albedo->set_as_black();
albedo_images.write[i] = albedo;
Ref<Image> emission;
- emission.instance();
+ emission.instantiate();
emission->create(atlas_size.width, atlas_size.height, false, Image::FORMAT_RGBAH);
emission->set_as_black();
emission_images.write[i] = emission;
@@ -479,7 +479,7 @@ void LightmapperRD::_create_acceleration_structures(RenderingDevice *rd, Size2i
}
Ref<Image> img;
- img.instance();
+ img.instantiate();
img->create(grid_size, grid_size, false, Image::FORMAT_L8, grid_usage);
img->save_png("res://grid_layer_" + itos(1000 + i).substr(1, 3) + ".png");
}
@@ -725,7 +725,7 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d
panorama_tex = p_environment_panorama;
panorama_tex->convert(Image::FORMAT_RGBAF);
} else {
- panorama_tex.instance();
+ panorama_tex.instantiate();
panorama_tex->create(8, 8, false, Image::FORMAT_RGBAF);
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
@@ -782,7 +782,7 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d
//shaders
Ref<RDShaderFile> raster_shader;
- raster_shader.instance();
+ raster_shader.instantiate();
Error err = raster_shader->parse_versions_from_text(lm_raster_shader_glsl);
if (err != OK) {
raster_shader->print_errors("raster_shader");
@@ -915,7 +915,7 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d
for (int i = 0; i < atlas_slices; i++) {
Vector<uint8_t> s = rd->texture_get_data(position_tex, i);
Ref<Image> img;
- img.instance();
+ img.instantiate();
img->create(atlas_size.width, atlas_size.height, false, Image::FORMAT_RGBAF, s);
img->save_exr("res://1_position_" + itos(i) + ".exr", false);
@@ -933,7 +933,7 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d
/* Plot direct light */
Ref<RDShaderFile> compute_shader;
- compute_shader.instance();
+ compute_shader.instantiate();
err = compute_shader->parse_versions_from_text(lm_compute_shader_glsl, p_bake_sh ? "\n#define USE_SH_LIGHTMAPS\n" : "");
if (err != OK) {
FREE_TEXTURES
@@ -1129,7 +1129,7 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d
for (int i = 0; i < atlas_slices; i++) {
Vector<uint8_t> s = rd->texture_get_data(light_source_tex, i);
Ref<Image> img;
- img.instance();
+ img.instantiate();
img->create(atlas_size.width, atlas_size.height, false, Image::FORMAT_RGBAH, s);
img->save_exr("res://2_light_primary_" + itos(i) + ".exr", false);
}
@@ -1379,12 +1379,12 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d
#if 0
for (int i = 0; i < probe_positions.size(); i++) {
Ref<Image> img;
- img.instance();
+ img.instantiate();
img->create(6, 4, false, Image::FORMAT_RGB8);
for (int j = 0; j < 6; j++) {
Vector<uint8_t> s = rd->texture_get_data(lightprobe_tex, i * 6 + j);
Ref<Image> img2;
- img2.instance();
+ img2.instantiate();
img2->create(2, 2, false, Image::FORMAT_RGBAF, s);
img2->convert(Image::FORMAT_RGB8);
img->blit_rect(img2, Rect2(0, 0, 2, 2), Point2((j % 3) * 2, (j / 3) * 2));
@@ -1405,7 +1405,7 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d
for (int i = 0; i < atlas_slices * (p_bake_sh ? 4 : 1); i++) {
Vector<uint8_t> s = rd->texture_get_data(light_accum_tex, i);
Ref<Image> img;
- img.instance();
+ img.instantiate();
img->create(atlas_size.width, atlas_size.height, false, Image::FORMAT_RGBAH, s);
Ref<Image> denoised = denoiser->denoise_image(img);
@@ -1432,7 +1432,7 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d
for (int i = 0; i < atlas_slices * (p_bake_sh ? 4 : 1); i++) {
Vector<uint8_t> s = rd->texture_get_data(light_accum_tex, i);
Ref<Image> img;
- img.instance();
+ img.instantiate();
img->create(atlas_size.width, atlas_size.height, false, Image::FORMAT_RGBAH, s);
img->save_exr("res://4_light_secondary_" + itos(i) + ".exr", false);
}
@@ -1484,7 +1484,7 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d
for (int i = 0; i < atlas_slices * (p_bake_sh ? 4 : 1); i++) {
Vector<uint8_t> s = rd->texture_get_data(light_accum_tex, i);
Ref<Image> img;
- img.instance();
+ img.instantiate();
img->create(atlas_size.width, atlas_size.height, false, Image::FORMAT_RGBAH, s);
img->convert(Image::FORMAT_RGBA8);
img->save_png("res://5_dilated_" + itos(i) + ".png");
@@ -1494,7 +1494,7 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d
/* BLEND SEAMS */
//shaders
Ref<RDShaderFile> blendseams_shader;
- blendseams_shader.instance();
+ blendseams_shader.instantiate();
err = blendseams_shader->parse_versions_from_text(lm_blendseams_shader_glsl);
if (err != OK) {
FREE_TEXTURES
@@ -1641,7 +1641,7 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d
for (int i = 0; i < atlas_slices * (p_bake_sh ? 4 : 1); i++) {
Vector<uint8_t> s = rd->texture_get_data(light_accum_tex, i);
Ref<Image> img;
- img.instance();
+ img.instantiate();
img->create(atlas_size.width, atlas_size.height, false, Image::FORMAT_RGBAH, s);
img->save_exr("res://5_blendseams" + itos(i) + ".exr", false);
}
@@ -1653,7 +1653,7 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d
for (int i = 0; i < atlas_slices * (p_bake_sh ? 4 : 1); i++) {
Vector<uint8_t> s = rd->texture_get_data(light_accum_tex, i);
Ref<Image> img;
- img.instance();
+ img.instantiate();
img->create(atlas_size.width, atlas_size.height, false, Image::FORMAT_RGBAH, s);
img->convert(Image::FORMAT_RGBH); //remove alpha
bake_textures.push_back(img);
@@ -1668,7 +1668,7 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d
#ifdef DEBUG_TEXTURES
{
Ref<Image> img2;
- img2.instance();
+ img2.instantiate();
img2->create(probe_values.size(), 1, false, Image::FORMAT_RGBAF, probe_data);
img2->save_exr("res://6_lightprobes.exr", false);
}
diff --git a/modules/mbedtls/crypto_mbedtls.cpp b/modules/mbedtls/crypto_mbedtls.cpp
index c389609984..774da5a324 100644
--- a/modules/mbedtls/crypto_mbedtls.cpp
+++ b/modules/mbedtls/crypto_mbedtls.cpp
@@ -30,7 +30,7 @@
#include "crypto_mbedtls.h"
-#include "core/os/file_access.h"
+#include "core/io/file_access.h"
#include "core/config/engine.h"
#include "core/config/project_settings.h"
@@ -324,7 +324,7 @@ void CryptoMbedTLS::load_default_certificates(String p_path) {
Ref<CryptoKey> CryptoMbedTLS::generate_rsa(int p_bytes) {
Ref<CryptoKeyMbedTLS> out;
- out.instance();
+ out.instantiate();
int ret = mbedtls_pk_setup(&(out->pkey), mbedtls_pk_info_from_type(MBEDTLS_PK_RSA));
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);
@@ -366,7 +366,7 @@ Ref<X509Certificate> CryptoMbedTLS::generate_self_signed_certificate(Ref<CryptoK
buf[4095] = '\0'; // Make sure strlen can't fail.
Ref<X509CertificateMbedTLS> out;
- out.instance();
+ out.instantiate();
out->load_from_memory(buf, strlen((char *)buf) + 1); // Use strlen to find correct output size.
return out;
}
diff --git a/modules/mbedtls/dtls_server_mbedtls.cpp b/modules/mbedtls/dtls_server_mbedtls.cpp
index 5d895d8579..b1b6b3844b 100644
--- a/modules/mbedtls/dtls_server_mbedtls.cpp
+++ b/modules/mbedtls/dtls_server_mbedtls.cpp
@@ -45,7 +45,7 @@ void DTLSServerMbedTLS::stop() {
Ref<PacketPeerDTLS> DTLSServerMbedTLS::take_connection(Ref<PacketPeerUDP> p_udp_peer) {
Ref<PacketPeerMbedDTLS> out;
- out.instance();
+ out.instantiate();
ERR_FAIL_COND_V(!out.is_valid(), out);
ERR_FAIL_COND_V(!p_udp_peer.is_valid(), out);
@@ -68,7 +68,7 @@ void DTLSServerMbedTLS::finalize() {
}
DTLSServerMbedTLS::DTLSServerMbedTLS() {
- _cookies.instance();
+ _cookies.instantiate();
}
DTLSServerMbedTLS::~DTLSServerMbedTLS() {
diff --git a/modules/mbedtls/packet_peer_mbed_dtls.cpp b/modules/mbedtls/packet_peer_mbed_dtls.cpp
index d77d946a77..114bf49e9e 100644
--- a/modules/mbedtls/packet_peer_mbed_dtls.cpp
+++ b/modules/mbedtls/packet_peer_mbed_dtls.cpp
@@ -31,8 +31,8 @@
#include "packet_peer_mbed_dtls.h"
#include "mbedtls/platform_util.h"
+#include "core/io/file_access.h"
#include "core/io/stream_peer_ssl.h"
-#include "core/os/file_access.h"
int PacketPeerMbedDTLS::bio_send(void *ctx, const unsigned char *buf, size_t len) {
if (buf == nullptr || len <= 0) {
@@ -245,7 +245,7 @@ int PacketPeerMbedDTLS::get_max_packet_size() const {
}
PacketPeerMbedDTLS::PacketPeerMbedDTLS() {
- ssl_ctx.instance();
+ ssl_ctx.instantiate();
}
PacketPeerMbedDTLS::~PacketPeerMbedDTLS() {
diff --git a/modules/mbedtls/ssl_context_mbedtls.h b/modules/mbedtls/ssl_context_mbedtls.h
index 30632018a8..1b55a54a10 100644
--- a/modules/mbedtls/ssl_context_mbedtls.h
+++ b/modules/mbedtls/ssl_context_mbedtls.h
@@ -33,9 +33,9 @@
#include "crypto_mbedtls.h"
-#include "core/os/file_access.h"
+#include "core/io/file_access.h"
-#include "core/object/reference.h"
+#include "core/object/ref_counted.h"
#include <mbedtls/config.h>
#include <mbedtls/ctr_drbg.h>
@@ -46,7 +46,7 @@
class SSLContextMbedTLS;
-class CookieContextMbedTLS : public Reference {
+class CookieContextMbedTLS : public RefCounted {
friend class SSLContextMbedTLS;
protected:
@@ -63,7 +63,7 @@ public:
~CookieContextMbedTLS();
};
-class SSLContextMbedTLS : public Reference {
+class SSLContextMbedTLS : public RefCounted {
protected:
bool inited = false;
diff --git a/modules/mbedtls/stream_peer_mbedtls.cpp b/modules/mbedtls/stream_peer_mbedtls.cpp
index 8e40451806..5727f5f82f 100644
--- a/modules/mbedtls/stream_peer_mbedtls.cpp
+++ b/modules/mbedtls/stream_peer_mbedtls.cpp
@@ -30,8 +30,8 @@
#include "stream_peer_mbedtls.h"
+#include "core/io/file_access.h"
#include "core/io/stream_peer_tcp.h"
-#include "core/os/file_access.h"
int StreamPeerMbedTLS::bio_send(void *ctx, const unsigned char *buf, size_t len) {
if (buf == nullptr || len <= 0) {
@@ -273,7 +273,7 @@ int StreamPeerMbedTLS::get_available_bytes() const {
}
StreamPeerMbedTLS::StreamPeerMbedTLS() {
- ssl_ctx.instance();
+ ssl_ctx.instantiate();
}
StreamPeerMbedTLS::~StreamPeerMbedTLS() {
diff --git a/modules/minimp3/audio_stream_mp3.cpp b/modules/minimp3/audio_stream_mp3.cpp
index 24ec206191..2cc974322d 100644
--- a/modules/minimp3/audio_stream_mp3.cpp
+++ b/modules/minimp3/audio_stream_mp3.cpp
@@ -35,7 +35,7 @@
#include "audio_stream_mp3.h"
-#include "core/os/file_access.h"
+#include "core/io/file_access.h"
void AudioStreamPlaybackMP3::_mix_internal(AudioFrame *p_buffer, int p_frames) {
ERR_FAIL_COND(!active);
@@ -126,7 +126,7 @@ Ref<AudioStreamPlayback> AudioStreamMP3::instance_playback() {
"to it. AudioStreamMP3 should not be created from the "
"inspector or with `.new()`. Instead, load an audio file.");
- mp3s.instance();
+ mp3s.instantiate();
mp3s->mp3_stream = Ref<AudioStreamMP3>(this);
mp3s->mp3d = (mp3dec_ex_t *)memalloc(sizeof(mp3dec_ex_t));
diff --git a/modules/minimp3/doc_classes/AudioStreamMP3.xml b/modules/minimp3/doc_classes/AudioStreamMP3.xml
index 92e777ca0f..5507329a18 100644
--- a/modules/minimp3/doc_classes/AudioStreamMP3.xml
+++ b/modules/minimp3/doc_classes/AudioStreamMP3.xml
@@ -11,7 +11,7 @@
<methods>
</methods>
<members>
- <member name="data" type="PackedByteArray" setter="set_data" getter="get_data" default="PackedByteArray( )">
+ <member name="data" type="PackedByteArray" setter="set_data" getter="get_data" default="PackedByteArray()">
Contains the audio data in bytes.
</member>
<member name="loop" type="bool" setter="set_loop" getter="has_loop" default="false">
diff --git a/modules/minimp3/register_types.cpp b/modules/minimp3/register_types.cpp
index 4ab4c743d6..27ea512b69 100644
--- a/modules/minimp3/register_types.cpp
+++ b/modules/minimp3/register_types.cpp
@@ -41,7 +41,7 @@ void register_minimp3_types() {
#ifdef TOOLS_ENABLED
if (Engine::get_singleton()->is_editor_hint()) {
Ref<ResourceImporterMP3> mp3_import;
- mp3_import.instance();
+ mp3_import.instantiate();
ResourceFormatImporter::get_singleton()->add_importer(mp3_import);
}
#endif
diff --git a/modules/minimp3/resource_importer_mp3.cpp b/modules/minimp3/resource_importer_mp3.cpp
index f5137965da..dc360c12ba 100644
--- a/modules/minimp3/resource_importer_mp3.cpp
+++ b/modules/minimp3/resource_importer_mp3.cpp
@@ -30,8 +30,8 @@
#include "resource_importer_mp3.h"
+#include "core/io/file_access.h"
#include "core/io/resource_saver.h"
-#include "core/os/file_access.h"
#include "scene/resources/texture.h"
String ResourceImporterMP3::get_importer_name() const {
@@ -90,7 +90,7 @@ Error ResourceImporterMP3::import(const String &p_source_file, const String &p_s
memdelete(f);
Ref<AudioStreamMP3> mp3_stream;
- mp3_stream.instance();
+ mp3_stream.instantiate();
mp3_stream->set_data(data);
ERR_FAIL_COND_V(!mp3_stream->get_data().size(), ERR_FILE_CORRUPT);
diff --git a/modules/mobile_vr/mobile_vr_interface.cpp b/modules/mobile_vr/mobile_vr_interface.cpp
index 40b1745c35..590b95ab79 100644
--- a/modules/mobile_vr/mobile_vr_interface.cpp
+++ b/modules/mobile_vr/mobile_vr_interface.cpp
@@ -300,9 +300,9 @@ real_t MobileVRInterface::get_k2() const {
return k2;
};
-bool MobileVRInterface::is_stereo() {
+uint32_t MobileVRInterface::get_view_count() {
// needs stereo...
- return true;
+ return 2;
};
bool MobileVRInterface::is_initialized() const {
@@ -361,7 +361,29 @@ Size2 MobileVRInterface::get_render_targetsize() {
return target_size;
};
-Transform3D MobileVRInterface::get_transform_for_eye(XRInterface::Eyes p_eye, const Transform3D &p_cam_transform) {
+Transform3D MobileVRInterface::get_camera_transform() {
+ _THREAD_SAFE_METHOD_
+
+ Transform3D transform_for_eye;
+
+ XRServer *xr_server = XRServer::get_singleton();
+ ERR_FAIL_NULL_V(xr_server, transform_for_eye);
+
+ if (initialized) {
+ float world_scale = xr_server->get_world_scale();
+
+ // just scale our origin point of our transform
+ Transform3D hmd_transform;
+ hmd_transform.basis = orientation;
+ hmd_transform.origin = Vector3(0.0, eye_height * world_scale, 0.0);
+
+ transform_for_eye = (xr_server->get_reference_frame()) * hmd_transform;
+ }
+
+ return transform_for_eye;
+};
+
+Transform3D MobileVRInterface::get_transform_for_view(uint32_t p_view, const Transform3D &p_cam_transform) {
_THREAD_SAFE_METHOD_
Transform3D transform_for_eye;
@@ -374,12 +396,12 @@ Transform3D MobileVRInterface::get_transform_for_eye(XRInterface::Eyes p_eye, co
// we don't need to check for the existence of our HMD, doesn't affect our values...
// note * 0.01 to convert cm to m and * 0.5 as we're moving half in each direction...
- if (p_eye == XRInterface::EYE_LEFT) {
+ if (p_view == 0) {
transform_for_eye.origin.x = -(intraocular_dist * 0.01 * 0.5 * world_scale);
- } else if (p_eye == XRInterface::EYE_RIGHT) {
+ } else if (p_view == 1) {
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.
+ // should not have any other values..
};
// just scale our origin point of our transform
@@ -396,21 +418,13 @@ Transform3D MobileVRInterface::get_transform_for_eye(XRInterface::Eyes p_eye, co
return transform_for_eye;
};
-CameraMatrix MobileVRInterface::get_projection_for_eye(XRInterface::Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far) {
+CameraMatrix MobileVRInterface::get_projection_for_view(uint32_t p_view, real_t p_aspect, real_t p_z_near, real_t p_z_far) {
_THREAD_SAFE_METHOD_
CameraMatrix eye;
- 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 camera's 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
- // to position a stock standard Godot camera and have control over this.
- // 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 == XRInterface::EYE_LEFT ? 1 : 2, p_aspect, intraocular_dist, display_width, display_to_lens, oversample, p_z_near, p_z_far);
- };
+ aspect = p_aspect;
+ eye.set_for_hmd(p_view + 1, p_aspect, intraocular_dist, display_width, display_to_lens, oversample, p_z_near, p_z_far);
return eye;
};
@@ -440,6 +454,45 @@ void MobileVRInterface::commit_for_eye(XRInterface::Eyes p_eye, RID p_render_tar
eye_center.y = 0.0;
}
+Vector<BlitToScreen> MobileVRInterface::commit_views(RID p_render_target, const Rect2 &p_screen_rect) {
+ _THREAD_SAFE_METHOD_
+
+ Vector<BlitToScreen> blit_to_screen;
+
+ // We must have a valid render target
+ ERR_FAIL_COND_V(!p_render_target.is_valid(), blit_to_screen);
+
+ // Because we are rendering to our device we must use our main viewport!
+ ERR_FAIL_COND_V(p_screen_rect == Rect2(), blit_to_screen);
+
+ // and add our blits
+ BlitToScreen blit;
+ blit.render_target = p_render_target;
+ blit.multi_view.use_layer = true;
+ blit.lens_distortion.apply = true;
+ blit.lens_distortion.k1 = k1;
+ blit.lens_distortion.k2 = k2;
+ blit.lens_distortion.upscale = oversample;
+ blit.lens_distortion.aspect_ratio = aspect;
+
+ // left eye
+ blit.rect = p_screen_rect;
+ blit.rect.size.width *= 0.5;
+ blit.multi_view.layer = 0;
+ blit.lens_distortion.eye_center.x = ((-intraocular_dist / 2.0) + (display_width / 4.0)) / (display_width / 2.0);
+ blit_to_screen.push_back(blit);
+
+ // right eye
+ blit.rect = p_screen_rect;
+ blit.rect.size.width *= 0.5;
+ blit.rect.position.x = blit.rect.size.width;
+ blit.multi_view.layer = 1;
+ blit.lens_distortion.eye_center.x = ((intraocular_dist / 2.0) - (display_width / 4.0)) / (display_width / 2.0);
+ blit_to_screen.push_back(blit);
+
+ return blit_to_screen;
+}
+
void MobileVRInterface::process() {
_THREAD_SAFE_METHOD_
diff --git a/modules/mobile_vr/mobile_vr_interface.h b/modules/mobile_vr/mobile_vr_interface.h
index aad40ebb5b..29ce0f92c8 100644
--- a/modules/mobile_vr/mobile_vr_interface.h
+++ b/modules/mobile_vr/mobile_vr_interface.h
@@ -63,9 +63,9 @@ private:
real_t display_to_lens = 4.0;
real_t oversample = 1.5;
- //@TODO not yet used, these are needed in our distortion shader...
real_t k1 = 0.215;
real_t k2 = 0.215;
+ real_t aspect = 1.0;
/*
logic for processing our sensor data, this was originally in our positional tracker logic but I think
@@ -138,16 +138,20 @@ public:
virtual void uninitialize() override;
virtual Size2 get_render_targetsize() override;
- virtual bool is_stereo() override;
- virtual Transform3D get_transform_for_eye(XRInterface::Eyes p_eye, const Transform3D &p_cam_transform) override;
- virtual CameraMatrix get_projection_for_eye(XRInterface::Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far) override;
- virtual void commit_for_eye(XRInterface::Eyes p_eye, RID p_render_target, const Rect2 &p_screen_rect) override;
+ virtual uint32_t get_view_count() override;
+ virtual Transform3D get_camera_transform() override;
+ virtual Transform3D get_transform_for_view(uint32_t p_view, const Transform3D &p_cam_transform) override;
+ virtual CameraMatrix get_projection_for_view(uint32_t p_view, real_t p_aspect, real_t p_z_near, real_t p_z_far) override;
+ virtual Vector<BlitToScreen> commit_views(RID p_render_target, const Rect2 &p_screen_rect) override;
virtual void process() override;
virtual void notification(int p_what) override {}
MobileVRInterface();
~MobileVRInterface();
+
+ // deprecated
+ virtual void commit_for_eye(XRInterface::Eyes p_eye, RID p_render_target, const Rect2 &p_screen_rect) override;
};
#endif // !MOBILE_VR_INTERFACE_H
diff --git a/modules/mobile_vr/register_types.cpp b/modules/mobile_vr/register_types.cpp
index e7d33ba8a7..7d138aa4c9 100644
--- a/modules/mobile_vr/register_types.cpp
+++ b/modules/mobile_vr/register_types.cpp
@@ -37,7 +37,7 @@ void register_mobile_vr_types() {
if (XRServer::get_singleton()) {
Ref<MobileVRInterface> mobile_vr;
- mobile_vr.instance();
+ mobile_vr.instantiate();
XRServer::get_singleton()->add_interface(mobile_vr);
}
}
diff --git a/modules/mono/class_db_api_json.cpp b/modules/mono/class_db_api_json.cpp
index 553c6eca53..25193a1352 100644
--- a/modules/mono/class_db_api_json.cpp
+++ b/modules/mono/class_db_api_json.cpp
@@ -33,8 +33,8 @@
#ifdef DEBUG_METHODS_ENABLED
#include "core/config/project_settings.h"
+#include "core/io/file_access.h"
#include "core/io/json.h"
-#include "core/os/file_access.h"
#include "core/version.h"
void class_db_api_to_json(const String &p_output_file, ClassDB::APIType p_api) {
@@ -240,7 +240,8 @@ void class_db_api_to_json(const String &p_output_file, ClassDB::APIType p_api) {
FileAccessRef f = FileAccess::open(p_output_file, FileAccess::WRITE);
ERR_FAIL_COND_MSG(!f, "Cannot open file '" + p_output_file + "'.");
- f->store_string(JSON::print(classes_dict, /*indent: */ "\t"));
+ JSON json;
+ f->store_string(json.stringify(classes_dict, "\t"));
f->close();
print_line(String() + "ClassDB API JSON written to: " + ProjectSettings::get_singleton()->globalize_path(p_output_file));
diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp
index ac248bcff8..c48230f524 100644
--- a/modules/mono/csharp_script.cpp
+++ b/modules/mono/csharp_script.cpp
@@ -37,8 +37,7 @@
#include "core/config/project_settings.h"
#include "core/debugger/engine_debugger.h"
#include "core/debugger/script_debugger.h"
-#include "core/io/json.h"
-#include "core/os/file_access.h"
+#include "core/io/file_access.h"
#include "core/os/mutex.h"
#include "core/os/os.h"
#include "core/os/thread.h"
@@ -376,7 +375,7 @@ Ref<Script> CSharpLanguage::get_template(const String &p_class_name, const Strin
.replace("%CLASS%", class_name_no_spaces);
Ref<CSharpScript> script;
- script.instance();
+ script.instantiate();
script->set_source_code(script_template);
script->set_name(class_name_no_spaces);
@@ -863,13 +862,13 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) {
List<Ref<CSharpScript>> to_reload;
// We need to keep reference instances alive during reloading
- List<Ref<Reference>> ref_instances;
+ List<Ref<RefCounted>> rc_instances;
for (Map<Object *, CSharpScriptBinding>::Element *E = script_bindings.front(); E; E = E->next()) {
CSharpScriptBinding &script_binding = E->value();
- Reference *ref = Object::cast_to<Reference>(script_binding.owner);
- if (ref) {
- ref_instances.push_back(Ref<Reference>(ref));
+ RefCounted *rc = Object::cast_to<RefCounted>(script_binding.owner);
+ if (rc) {
+ rc_instances.push_back(Ref<RefCounted>(rc));
}
}
@@ -892,9 +891,9 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) {
Object *obj = F->get();
script->pending_reload_instances.insert(obj->get_instance_id());
- Reference *ref = Object::cast_to<Reference>(obj);
- if (ref) {
- ref_instances.push_back(Ref<Reference>(ref));
+ RefCounted *rc = Object::cast_to<RefCounted>(obj);
+ if (rc) {
+ rc_instances.push_back(Ref<RefCounted>(rc));
}
}
@@ -903,9 +902,9 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) {
Object *obj = F->get()->get_owner();
script->pending_reload_instances.insert(obj->get_instance_id());
- Reference *ref = Object::cast_to<Reference>(obj);
- if (ref) {
- ref_instances.push_back(Ref<Reference>(ref));
+ RefCounted *rc = Object::cast_to<RefCounted>(obj);
+ if (rc) {
+ rc_instances.push_back(Ref<RefCounted>(rc));
}
}
#endif
@@ -1438,16 +1437,16 @@ bool CSharpLanguage::setup_csharp_script_binding(CSharpScriptBinding &r_script_b
r_script_binding.owner = p_object;
// Tie managed to unmanaged
- Reference *ref = Object::cast_to<Reference>(p_object);
+ RefCounted *rc = Object::cast_to<RefCounted>(p_object);
- if (ref) {
+ if (rc) {
// Unsafe refcount increment. The managed instance also counts as a reference.
// This way if the unmanaged world has no references to our owner
// but the managed instance is alive, the refcount will be 1 instead of 0.
- // See: godot_icall_Reference_Dtor(MonoObject *p_obj, Object *p_ptr)
+ // See: godot_icall_RefCounted_Dtor(MonoObject *p_obj, Object *p_ptr)
- ref->reference();
- CSharpLanguage::get_singleton()->post_unsafe_reference(ref);
+ rc->reference();
+ CSharpLanguage::get_singleton()->post_unsafe_reference(rc);
}
return true;
@@ -1511,10 +1510,10 @@ void CSharpLanguage::free_instance_binding_data(void *p_data) {
}
void CSharpLanguage::refcount_incremented_instance_binding(Object *p_object) {
- Reference *ref_owner = Object::cast_to<Reference>(p_object);
+ RefCounted *rc_owner = Object::cast_to<RefCounted>(p_object);
#ifdef DEBUG_ENABLED
- CRASH_COND(!ref_owner);
+ CRASH_COND(!rc_owner);
CRASH_COND(!p_object->has_script_instance_binding(get_language_index()));
#endif
@@ -1528,7 +1527,7 @@ void CSharpLanguage::refcount_incremented_instance_binding(Object *p_object) {
return;
}
- if (ref_owner->reference_get_count() > 1 && gchandle.is_weak()) { // The managed side also holds a reference, hence 1 instead of 0
+ if (rc_owner->reference_get_count() > 1 && gchandle.is_weak()) { // The managed side also holds a reference, hence 1 instead of 0
GD_MONO_SCOPE_THREAD_ATTACH;
// The reference count was increased after the managed side was the only one referencing our owner.
@@ -1548,10 +1547,10 @@ void CSharpLanguage::refcount_incremented_instance_binding(Object *p_object) {
}
bool CSharpLanguage::refcount_decremented_instance_binding(Object *p_object) {
- Reference *ref_owner = Object::cast_to<Reference>(p_object);
+ RefCounted *rc_owner = Object::cast_to<RefCounted>(p_object);
#ifdef DEBUG_ENABLED
- CRASH_COND(!ref_owner);
+ CRASH_COND(!rc_owner);
CRASH_COND(!p_object->has_script_instance_binding(get_language_index()));
#endif
@@ -1561,7 +1560,7 @@ bool CSharpLanguage::refcount_decremented_instance_binding(Object *p_object) {
CSharpScriptBinding &script_binding = ((Map<Object *, CSharpScriptBinding>::Element *)data)->get();
MonoGCHandleData &gchandle = script_binding.gchandle;
- int refcount = ref_owner->reference_get_count();
+ int refcount = rc_owner->reference_get_count();
if (!script_binding.inited) {
return refcount == 0;
@@ -1592,13 +1591,13 @@ bool CSharpLanguage::refcount_decremented_instance_binding(Object *p_object) {
CSharpInstance *CSharpInstance::create_for_managed_type(Object *p_owner, CSharpScript *p_script, const MonoGCHandleData &p_gchandle) {
CSharpInstance *instance = memnew(CSharpInstance(Ref<CSharpScript>(p_script)));
- Reference *ref = Object::cast_to<Reference>(p_owner);
+ RefCounted *rc = Object::cast_to<RefCounted>(p_owner);
- instance->base_ref = ref != nullptr;
+ instance->base_ref_counted = rc != nullptr;
instance->owner = p_owner;
instance->gchandle = p_gchandle;
- if (instance->base_ref) {
+ if (instance->base_ref_counted) {
instance->_reference_owner_unsafe();
}
@@ -1900,7 +1899,7 @@ Variant CSharpInstance::call(const StringName &p_method, const Variant **p_args,
bool CSharpInstance::_reference_owner_unsafe() {
#ifdef DEBUG_ENABLED
- CRASH_COND(!base_ref);
+ CRASH_COND(!base_ref_counted);
CRASH_COND(owner == nullptr);
CRASH_COND(unsafe_referenced); // already referenced
#endif
@@ -1911,7 +1910,7 @@ bool CSharpInstance::_reference_owner_unsafe() {
// See: _unreference_owner_unsafe()
// May not me referenced yet, so we must use init_ref() instead of reference()
- if (static_cast<Reference *>(owner)->init_ref()) {
+ if (static_cast<RefCounted *>(owner)->init_ref()) {
CSharpLanguage::get_singleton()->post_unsafe_reference(owner);
unsafe_referenced = true;
}
@@ -1921,7 +1920,7 @@ bool CSharpInstance::_reference_owner_unsafe() {
bool CSharpInstance::_unreference_owner_unsafe() {
#ifdef DEBUG_ENABLED
- CRASH_COND(!base_ref);
+ CRASH_COND(!base_ref_counted);
CRASH_COND(owner == nullptr);
#endif
@@ -1938,7 +1937,7 @@ bool CSharpInstance::_unreference_owner_unsafe() {
// Destroying the owner here means self destructing, so we defer the owner destruction to the caller.
CSharpLanguage::get_singleton()->pre_unsafe_unreference(owner);
- return static_cast<Reference *>(owner)->unreference();
+ return static_cast<RefCounted *>(owner)->unreference();
}
MonoObject *CSharpInstance::_internal_new_managed() {
@@ -1970,7 +1969,7 @@ MonoObject *CSharpInstance::_internal_new_managed() {
// Tie managed to unmanaged
gchandle = MonoGCHandleData::new_strong_handle(mono_object);
- if (base_ref) {
+ if (base_ref_counted) {
_reference_owner_unsafe(); // Here, after assigning the gchandle (for the refcount_incremented callback)
}
@@ -1987,7 +1986,7 @@ void CSharpInstance::mono_object_disposed(MonoObject *p_obj) {
disconnect_event_signals();
#ifdef DEBUG_ENABLED
- CRASH_COND(base_ref);
+ CRASH_COND(base_ref_counted);
CRASH_COND(gchandle.is_released());
#endif
CSharpLanguage::get_singleton()->release_script_gchandle(p_obj, gchandle);
@@ -1995,7 +1994,7 @@ void CSharpInstance::mono_object_disposed(MonoObject *p_obj) {
void CSharpInstance::mono_object_disposed_baseref(MonoObject *p_obj, bool p_is_finalizer, bool &r_delete_owner, bool &r_remove_script_instance) {
#ifdef DEBUG_ENABLED
- CRASH_COND(!base_ref);
+ CRASH_COND(!base_ref_counted);
CRASH_COND(gchandle.is_released());
#endif
@@ -2056,13 +2055,13 @@ void CSharpInstance::disconnect_event_signals() {
void CSharpInstance::refcount_incremented() {
#ifdef DEBUG_ENABLED
- CRASH_COND(!base_ref);
+ CRASH_COND(!base_ref_counted);
CRASH_COND(owner == nullptr);
#endif
- Reference *ref_owner = Object::cast_to<Reference>(owner);
+ RefCounted *rc_owner = Object::cast_to<RefCounted>(owner);
- if (ref_owner->reference_get_count() > 1 && gchandle.is_weak()) { // The managed side also holds a reference, hence 1 instead of 0
+ if (rc_owner->reference_get_count() > 1 && gchandle.is_weak()) { // The managed side also holds a reference, hence 1 instead of 0
GD_MONO_SCOPE_THREAD_ATTACH;
// The reference count was increased after the managed side was the only one referencing our owner.
@@ -2078,13 +2077,13 @@ void CSharpInstance::refcount_incremented() {
bool CSharpInstance::refcount_decremented() {
#ifdef DEBUG_ENABLED
- CRASH_COND(!base_ref);
+ CRASH_COND(!base_ref_counted);
CRASH_COND(owner == nullptr);
#endif
- Reference *ref_owner = Object::cast_to<Reference>(owner);
+ RefCounted *rc_owner = Object::cast_to<RefCounted>(owner);
- int refcount = ref_owner->reference_get_count();
+ int refcount = rc_owner->reference_get_count();
if (refcount == 1 && !gchandle.is_weak()) { // The managed side also holds a reference, hence 1 instead of 0
GD_MONO_SCOPE_THREAD_ATTACH;
@@ -2119,12 +2118,12 @@ void CSharpInstance::notification(int p_notification) {
predelete_notified = true;
- if (base_ref) {
- // It's not safe to proceed if the owner derives Reference and the refcount reached 0.
+ if (base_ref_counted) {
+ // It's not safe to proceed if the owner derives RefCounted and the refcount reached 0.
// At this point, Dispose() was already called (manually or from the finalizer) so
// that's not a problem. The refcount wouldn't have reached 0 otherwise, since the
// managed side references it and Dispose() needs to be called to release it.
- // However, this means C# Reference scripts can't receive NOTIFICATION_PREDELETE, but
+ // However, this means C# RefCounted scripts can't receive NOTIFICATION_PREDELETE, but
// this is likely the case with GDScript as well: https://github.com/godotengine/godot/issues/6784
return;
}
@@ -2250,15 +2249,15 @@ CSharpInstance::~CSharpInstance() {
}
// If not being called from the owner's destructor, and we still hold a reference to the owner
- if (base_ref && !ref_dying && owner && unsafe_referenced) {
+ if (base_ref_counted && !ref_dying && owner && unsafe_referenced) {
// The owner's script or script instance is being replaced (or removed)
// Transfer ownership to an "instance binding"
- Reference *ref_owner = static_cast<Reference *>(owner);
+ RefCounted *rc_owner = static_cast<RefCounted *>(owner);
// We will unreference the owner before referencing it again, so we need to keep it alive
- Ref<Reference> scope_keep_owner_alive(ref_owner);
+ Ref<RefCounted> scope_keep_owner_alive(rc_owner);
(void)scope_keep_owner_alive;
// Unreference the owner here, before the new "instance binding" references it.
@@ -2283,7 +2282,7 @@ CSharpInstance::~CSharpInstance() {
#ifdef DEBUG_ENABLED
// The "instance binding" holds a reference so the refcount should be at least 2 before `scope_keep_owner_alive` goes out of scope
- CRASH_COND(ref_owner->reference_get_count() <= 1);
+ CRASH_COND(rc_owner->reference_get_count() <= 1);
#endif
}
@@ -2370,7 +2369,7 @@ void CSharpScript::_update_member_info_no_exports() {
}
#endif
-bool CSharpScript::_update_exports() {
+bool CSharpScript::_update_exports(PlaceHolderScriptInstance *p_instance_to_update) {
#ifdef TOOLS_ENABLED
bool is_editor = Engine::get_singleton()->is_editor_hint();
if (is_editor) {
@@ -2511,7 +2510,7 @@ bool CSharpScript::_update_exports() {
#ifdef TOOLS_ENABLED
if (is_editor) {
// Need to check this here, before disposal
- bool base_ref = Object::cast_to<Reference>(tmp_native) != nullptr;
+ bool base_ref_counted = Object::cast_to<RefCounted>(tmp_native) != nullptr;
// Dispose the temporary managed instance
@@ -2526,7 +2525,7 @@ bool CSharpScript::_update_exports() {
GDMonoUtils::free_gchandle(tmp_pinned_gchandle);
tmp_object = nullptr;
- if (tmp_native && !base_ref) {
+ if (tmp_native && !base_ref_counted) {
Node *node = Object::cast_to<Node>(tmp_native);
if (node && node->is_inside_tree()) {
ERR_PRINT("Temporary instance was added to the scene tree.");
@@ -2542,14 +2541,18 @@ bool CSharpScript::_update_exports() {
if (is_editor) {
placeholder_fallback_enabled = false;
- if (placeholders.size()) {
+ if ((changed || p_instance_to_update) && placeholders.size()) {
// Update placeholders if any
Map<StringName, Variant> values;
List<PropertyInfo> propnames;
_update_exports_values(values, propnames);
- for (Set<PlaceHolderScriptInstance *>::Element *E = placeholders.front(); E; E = E->next()) {
- E->get()->update(propnames, values);
+ if (changed) {
+ for (Set<PlaceHolderScriptInstance *>::Element *E = placeholders.front(); E; E = E->next()) {
+ E->get()->update(propnames, values);
+ }
+ } else {
+ p_instance_to_update->update(propnames, values);
}
}
}
@@ -3046,7 +3049,7 @@ void CSharpScript::update_script_class_info(Ref<CSharpScript> p_script) {
p_script->load_script_signals(p_script->script_class, p_script->native);
}
-bool CSharpScript::can_instance() const {
+bool CSharpScript::can_instantiate() const {
#ifdef TOOLS_ENABLED
bool extra_cond = tool || ScriptServer::is_scripting_enabled();
#else
@@ -3077,7 +3080,7 @@ StringName CSharpScript::get_instance_base_type() const {
}
}
-CSharpInstance *CSharpScript::_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, bool p_isref, Callable::CallError &r_error) {
+CSharpInstance *CSharpScript::_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, bool p_is_ref_counted, Callable::CallError &r_error) {
GD_MONO_ASSERT_THREAD_ATTACHED;
/* STEP 1, CREATE */
@@ -3093,10 +3096,10 @@ CSharpInstance *CSharpScript::_create_instance(const Variant **p_args, int p_arg
ERR_FAIL_V_MSG(nullptr, "Constructor not found.");
}
- Ref<Reference> ref;
- if (p_isref) {
+ Ref<RefCounted> ref;
+ if (p_is_ref_counted) {
// Hold it alive. Important if we have to dispose a script instance binding before creating the CSharpInstance.
- ref = Ref<Reference>(static_cast<Reference *>(p_owner));
+ ref = Ref<RefCounted>(static_cast<RefCounted *>(p_owner));
}
// If the object had a script instance binding, dispose it before adding the CSharpInstance
@@ -3122,7 +3125,7 @@ CSharpInstance *CSharpScript::_create_instance(const Variant **p_args, int p_arg
}
CSharpInstance *instance = memnew(CSharpInstance(Ref<CSharpScript>(this)));
- instance->base_ref = p_isref;
+ instance->base_ref_counted = p_is_ref_counted;
instance->owner = p_owner;
instance->owner->set_script_instance(instance);
@@ -3147,7 +3150,7 @@ CSharpInstance *CSharpScript::_create_instance(const Variant **p_args, int p_arg
// Tie managed to unmanaged
instance->gchandle = MonoGCHandleData::new_strong_handle(mono_object);
- if (instance->base_ref) {
+ if (instance->base_ref_counted) {
instance->_reference_owner_unsafe(); // Here, after assigning the gchandle (for the refcount_incremented callback)
}
@@ -3179,10 +3182,10 @@ Variant CSharpScript::_new(const Variant **p_args, int p_argcount, Callable::Cal
GD_MONO_SCOPE_THREAD_ATTACH;
- Object *owner = ClassDB::instance(NATIVE_GDMONOCLASS_NAME(native));
+ Object *owner = ClassDB::instantiate(NATIVE_GDMONOCLASS_NAME(native));
REF ref;
- Reference *r = Object::cast_to<Reference>(owner);
+ RefCounted *r = Object::cast_to<RefCounted>(owner);
if (r) {
ref = REF(r);
}
@@ -3213,24 +3216,24 @@ ScriptInstance *CSharpScript::instance_create(Object *p_this) {
if (EngineDebugger::is_active()) {
CSharpLanguage::get_singleton()->debug_break_parse(get_path(), 0,
"Script inherits from native type '" + String(native_name) +
- "', so it can't be instanced in object of type: '" + p_this->get_class() + "'");
+ "', so it can't be instantiated 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() + "'.");
+ "', so it can't be instantiated in object of type: '" + p_this->get_class() + "'.");
}
}
GD_MONO_SCOPE_THREAD_ATTACH;
Callable::CallError unchecked_error;
- return _create_instance(nullptr, 0, p_this, Object::cast_to<Reference>(p_this) != nullptr, unchecked_error);
+ return _create_instance(nullptr, 0, p_this, Object::cast_to<RefCounted>(p_this) != nullptr, unchecked_error);
}
PlaceHolderScriptInstance *CSharpScript::placeholder_instance_create(Object *p_this) {
#ifdef TOOLS_ENABLED
PlaceHolderScriptInstance *si = memnew(PlaceHolderScriptInstance(CSharpLanguage::get_singleton(), Ref<Script>(this), p_this));
placeholders.insert(si);
- _update_exports();
+ _update_exports(si);
return si;
#else
return nullptr;
diff --git a/modules/mono/csharp_script.h b/modules/mono/csharp_script.h
index b389e900f4..da6b60aee2 100644
--- a/modules/mono/csharp_script.h
+++ b/modules/mono/csharp_script.h
@@ -163,14 +163,14 @@ private:
void load_script_signals(GDMonoClass *p_class, GDMonoClass *p_native_class);
bool _get_signal(GDMonoClass *p_class, GDMonoMethod *p_delegate_invoke, Vector<SignalParameter> &params);
- bool _update_exports();
+ bool _update_exports(PlaceHolderScriptInstance *p_instance_to_update = nullptr);
bool _get_member_export(IMonoClassMember *p_member, bool p_inspect_export, PropertyInfo &r_prop_info, bool &r_exported);
#ifdef TOOLS_ENABLED
static int _try_get_member_export_hint(IMonoClassMember *p_member, ManagedType p_type, Variant::Type p_variant_type, bool p_allow_generics, PropertyHint &r_hint, String &r_hint_string);
#endif
- CSharpInstance *_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, bool p_isref, Callable::CallError &r_error);
+ CSharpInstance *_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, bool p_is_ref_counted, Callable::CallError &r_error);
Variant _new(const Variant **p_args, int p_argcount, Callable::CallError &r_error);
// Do not use unless you know what you are doing
@@ -191,7 +191,7 @@ protected:
void _get_property_list(List<PropertyInfo> *p_properties) const;
public:
- bool can_instance() const override;
+ bool can_instantiate() const override;
StringName get_instance_base_type() const override;
ScriptInstance *instance_create(Object *p_this) override;
PlaceHolderScriptInstance *placeholder_instance_create(Object *p_this) override;
@@ -251,7 +251,7 @@ class CSharpInstance : public ScriptInstance {
friend class CSharpLanguage;
Object *owner = nullptr;
- bool base_ref = false;
+ bool base_ref_counted = false;
bool ref_dying = false;
bool unsafe_referenced = false;
bool predelete_notified = false;
@@ -455,9 +455,8 @@ public:
Ref<Script> get_template(const String &p_class_name, const String &p_base_class_name) const override;
bool is_using_templates() override;
void make_template(const String &p_class_name, const String &p_base_class_name, Ref<Script> &p_script) override;
- /* TODO */ 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 override {
+ /* TODO */ bool validate(const String &p_script, const String &p_path, List<String> *r_functions,
+ List<ScriptLanguage::ScriptError> *r_errors = nullptr, List<ScriptLanguage::Warning> *r_warnings = nullptr, Set<int> *r_safe_lines = nullptr) const override {
return true;
}
String validate_path(const String &p_path) const override;
diff --git a/modules/mono/editor/GodotTools/GodotTools/Build/BuildInfo.cs b/modules/mono/editor/GodotTools/GodotTools/Build/BuildInfo.cs
index 51055dc9b9..27737c3da0 100644
--- a/modules/mono/editor/GodotTools/GodotTools/Build/BuildInfo.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/Build/BuildInfo.cs
@@ -7,7 +7,7 @@ using Path = System.IO.Path;
namespace GodotTools.Build
{
[Serializable]
- public sealed class BuildInfo : Reference // TODO Remove Reference once we have proper serialization
+ public sealed class BuildInfo : RefCounted // TODO Remove RefCounted once we have proper serialization
{
public string Solution { get; }
public string[] Targets { get; }
diff --git a/modules/mono/editor/GodotTools/GodotTools/Build/BuildOutputView.cs b/modules/mono/editor/GodotTools/GodotTools/Build/BuildOutputView.cs
index 1a1639aac7..c380707587 100644
--- a/modules/mono/editor/GodotTools/GodotTools/Build/BuildOutputView.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/Build/BuildOutputView.cs
@@ -11,7 +11,7 @@ namespace GodotTools.Build
public class BuildOutputView : VBoxContainer, ISerializationListener
{
[Serializable]
- private class BuildIssue : Reference // TODO Remove Reference once we have proper serialization
+ private class BuildIssue : RefCounted // TODO Remove RefCounted once we have proper serialization
{
public bool Warning { get; set; }
public string File { get; set; }
diff --git a/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs b/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs
index 58561c5097..c71c44d79d 100644
--- a/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs
@@ -371,7 +371,7 @@ namespace GodotTools
return (ExternalEditorId)editorSettings.GetSetting("mono/editor/external_editor") != ExternalEditorId.None;
}
- public override bool Build()
+ public override bool _Build()
{
return BuildManager.EditorBuildCallback();
}
@@ -413,9 +413,9 @@ namespace GodotTools
bottomPanelBtn.Icon = MSBuildPanel.BuildOutputView.BuildStateIcon;
}
- public override void EnablePlugin()
+ public override void _EnablePlugin()
{
- base.EnablePlugin();
+ base._EnablePlugin();
if (Instance != null)
throw new InvalidOperationException();
diff --git a/modules/mono/editor/bindings_generator.cpp b/modules/mono/editor/bindings_generator.cpp
index 94c5195b83..620b031ddb 100644
--- a/modules/mono/editor/bindings_generator.cpp
+++ b/modules/mono/editor/bindings_generator.cpp
@@ -35,8 +35,8 @@
#include "core/config/engine.h"
#include "core/core_constants.h"
#include "core/io/compression.h"
-#include "core/os/dir_access.h"
-#include "core/os/file_access.h"
+#include "core/io/dir_access.h"
+#include "core/io/file_access.h"
#include "core/os/os.h"
#include "core/string/ucaps.h"
#include "main/main.h"
@@ -1260,7 +1260,7 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str
CRASH_COND(itype.cname != name_cache.type_Object);
CRASH_COND(!itype.is_instantiable);
CRASH_COND(itype.api_type != ClassDB::API_CORE);
- CRASH_COND(itype.is_reference);
+ CRASH_COND(itype.is_ref_counted);
CRASH_COND(itype.is_singleton);
}
@@ -2284,8 +2284,8 @@ 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 ? "" : " = nullptr";
+ ptrcall_return_type = return_type->is_ref_counted ? "Ref<RefCounted>" : return_type->c_type;
+ initialization = return_type->is_ref_counted ? "" : " = nullptr";
} else {
ptrcall_return_type = return_type->c_type;
}
@@ -2600,12 +2600,12 @@ bool BindingsGenerator::_populate_object_type_interfaces() {
itype.base_name = ClassDB::get_parent_class(type_cname);
itype.is_singleton = Engine::get_singleton()->has_singleton(itype.proxy_name);
itype.is_instantiable = class_info->creation_func && !itype.is_singleton;
- itype.is_reference = ClassDB::is_parent_class(type_cname, name_cache.type_Reference);
- itype.memory_own = itype.is_reference;
+ itype.is_ref_counted = ClassDB::is_parent_class(type_cname, name_cache.type_RefCounted);
+ itype.memory_own = itype.is_ref_counted;
itype.c_out = "\treturn ";
itype.c_out += C_METHOD_UNMANAGED_GET_MANAGED;
- itype.c_out += itype.is_reference ? "(%1.ptr());\n" : "(%1);\n";
+ itype.c_out += itype.is_ref_counted ? "(%1.ptr());\n" : "(%1);\n";
itype.cs_in = itype.is_singleton ? BINDINGS_PTR_FIELD : "Object." CS_SMETHOD_GETINSTANCE "(%0)";
@@ -2741,7 +2741,7 @@ bool BindingsGenerator::_populate_object_type_interfaces() {
imethod.return_type.cname = return_info.class_name;
bool bad_reference_hint = !imethod.is_virtual && return_info.hint != PROPERTY_HINT_RESOURCE_TYPE &&
- ClassDB::is_parent_class(return_info.class_name, name_cache.type_Reference);
+ ClassDB::is_parent_class(return_info.class_name, name_cache.type_RefCounted);
ERR_FAIL_COND_V_MSG(bad_reference_hint, false,
String() + "Return type is reference but hint is not '" _STR(PROPERTY_HINT_RESOURCE_TYPE) "'." +
" Are you returning a reference type by pointer? Method: '" + itype.name + "." + imethod.name + "'.");
@@ -3053,28 +3053,25 @@ bool BindingsGenerator::_arg_default_value_from_variant(const Variant &p_val, Ar
break;
case Variant::PLANE: {
Plane plane = p_val.operator Plane();
- r_iarg.default_argument = "new Plane(new Vector3(" + plane.normal.operator String() + "), " + rtos(plane.d) + ")";
+ r_iarg.default_argument = "new Plane(new Vector3" + plane.normal.operator String() + ", " + rtos(plane.d) + ")";
r_iarg.def_param_mode = ArgumentInterface::NULLABLE_VAL;
} break;
case Variant::AABB: {
AABB aabb = p_val.operator ::AABB();
- r_iarg.default_argument = "new AABB(new Vector3(" + aabb.position.operator String() + "), new Vector3(" + aabb.position.operator String() + "))";
+ r_iarg.default_argument = "new AABB(new Vector3" + aabb.position.operator String() + ", new Vector3" + aabb.size.operator String() + ")";
r_iarg.def_param_mode = ArgumentInterface::NULLABLE_VAL;
} break;
case Variant::RECT2: {
Rect2 rect = p_val.operator Rect2();
- r_iarg.default_argument = "new Rect2(new Vector2(" + rect.position.operator String() + "), new Vector2(" + rect.position.operator String() + "))";
+ r_iarg.default_argument = "new Rect2(new Vector2" + rect.position.operator String() + ", new Vector2" + rect.size.operator String() + ")";
r_iarg.def_param_mode = ArgumentInterface::NULLABLE_VAL;
} break;
case Variant::RECT2I: {
Rect2i rect = p_val.operator Rect2i();
- r_iarg.default_argument = "new Rect2i(new Vector2i(" + rect.position.operator String() + "), new Vector2i(" + rect.position.operator String() + "))";
+ r_iarg.default_argument = "new Rect2i(new Vector2i" + rect.position.operator String() + ", new Vector2i" + rect.size.operator String() + ")";
r_iarg.def_param_mode = ArgumentInterface::NULLABLE_VAL;
} break;
case Variant::COLOR:
- r_iarg.default_argument = "new %s(" + r_iarg.default_argument + ")";
- r_iarg.def_param_mode = ArgumentInterface::NULLABLE_VAL;
- break;
case Variant::VECTOR2:
case Variant::VECTOR2I:
case Variant::VECTOR3:
diff --git a/modules/mono/editor/bindings_generator.h b/modules/mono/editor/bindings_generator.h
index 876046176b..48c0e02723 100644
--- a/modules/mono/editor/bindings_generator.h
+++ b/modules/mono/editor/bindings_generator.h
@@ -216,7 +216,7 @@ class BindingsGenerator {
bool is_enum = false;
bool is_object_type = false;
bool is_singleton = false;
- bool is_reference = false;
+ bool is_ref_counted = false;
/**
* Used only by Object-derived types.
@@ -228,7 +228,7 @@ class BindingsGenerator {
/**
* Used only by Object-derived types.
* Determines if the C# class owns the native handle and must free it somehow when disposed.
- * e.g.: Reference types must notify when the C# instance is disposed, for proper refcounting.
+ * e.g.: RefCounted types must notify when the C# instance is disposed, for proper refcounting.
*/
bool memory_own = false;
@@ -295,7 +295,7 @@ class BindingsGenerator {
* VarArg (fictitious type to represent variable arguments): Array
* float: double (because ptrcall only supports double)
* int: int64_t (because ptrcall only supports int64_t and uint64_t)
- * Reference types override this for the type of the return variable: Ref<Reference>
+ * RefCounted types override this for the type of the return variable: Ref<RefCounted>
*/
String c_type;
@@ -534,7 +534,7 @@ class BindingsGenerator {
StringName type_Variant = StaticCString::create("Variant");
StringName type_VarArg = StaticCString::create("VarArg");
StringName type_Object = StaticCString::create("Object");
- StringName type_Reference = StaticCString::create("Reference");
+ StringName type_RefCounted = StaticCString::create("RefCounted");
StringName type_RID = StaticCString::create("RID");
StringName type_String = StaticCString::create("String");
StringName type_StringName = StaticCString::create("StringName");
@@ -623,7 +623,7 @@ class BindingsGenerator {
}
inline String get_unique_sig(const TypeInterface &p_type) {
- if (p_type.is_reference) {
+ if (p_type.is_ref_counted) {
return "Ref";
} else if (p_type.is_object_type) {
return "Obj";
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/AABB.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/AABB.cs
index 3aecce50f5..2b641a8937 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/AABB.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/AABB.cs
@@ -676,7 +676,7 @@ namespace Godot
public override string ToString()
{
- return String.Format("{0} - {1}", new object[]
+ return String.Format("{0}, {1}", new object[]
{
_position.ToString(),
_size.ToString()
@@ -685,7 +685,7 @@ namespace Godot
public string ToString(string format)
{
- return String.Format("{0} - {1}", new object[]
+ return String.Format("{0}, {1}", new object[]
{
_position.ToString(format),
_size.ToString(format)
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Basis.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Basis.cs
index 01525e593f..5dbf5d5657 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Basis.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Basis.cs
@@ -863,22 +863,16 @@ namespace Godot
public override string ToString()
{
- return String.Format("({0}, {1}, {2})", new object[]
- {
- Row0.ToString(),
- Row1.ToString(),
- Row2.ToString()
- });
+ return "[X: " + x.ToString() +
+ ", Y: " + y.ToString() +
+ ", Z: " + z.ToString() + "]";
}
public string ToString(string format)
{
- return String.Format("({0}, {1}, {2})", new object[]
- {
- Row0.ToString(format),
- Row1.ToString(format),
- Row2.ToString(format)
- });
+ return "[X: " + x.ToString(format) +
+ ", Y: " + y.ToString(format) +
+ ", Z: " + z.ToString(format) + "]";
}
}
}
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Color.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Color.cs
index 24b9218197..155ffcff32 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Color.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Color.cs
@@ -1010,12 +1010,12 @@ namespace Godot
public override string ToString()
{
- return String.Format("{0},{1},{2},{3}", r.ToString(), g.ToString(), b.ToString(), a.ToString());
+ return String.Format("({0}, {1}, {2}, {3})", r.ToString(), g.ToString(), b.ToString(), a.ToString());
}
public string ToString(string format)
{
- return String.Format("{0},{1},{2},{3}", r.ToString(format), g.ToString(format), b.ToString(format), a.ToString(format));
+ return String.Format("({0}, {1}, {2}, {3})", r.ToString(format), g.ToString(format), b.ToString(format), a.ToString(format));
}
}
}
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Extensions/PackedSceneExtensions.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Extensions/PackedSceneExtensions.cs
index 763f470504..214bbf5179 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Extensions/PackedSceneExtensions.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Extensions/PackedSceneExtensions.cs
@@ -8,9 +8,9 @@ namespace Godot
/// `Node.NotificationInstanced` notification on the root node.
/// </summary>
/// <typeparam name="T">The type to cast to. Should be a descendant of Node.</typeparam>
- public T Instance<T>(PackedScene.GenEditState editState = (PackedScene.GenEditState)0) where T : class
+ public T Instantiate<T>(PackedScene.GenEditState editState = (PackedScene.GenEditState)0) where T : class
{
- return (T)(object)Instance(editState);
+ return (T)(object)Instantiate(editState);
}
/// <summary>
@@ -19,9 +19,9 @@ namespace Godot
/// `Node.NotificationInstanced` notification on the root node.
/// </summary>
/// <typeparam name="T">The type to cast to. Should be a descendant of Node.</typeparam>
- public T InstanceOrNull<T>(PackedScene.GenEditState editState = (PackedScene.GenEditState)0) where T : class
+ public T InstantiateOrNull<T>(PackedScene.GenEditState editState = (PackedScene.GenEditState)0) where T : class
{
- return Instance(editState) as T;
+ return Instantiate(editState) as T;
}
}
}
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Object.base.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Object.base.cs
index 48582d5ad8..d486d79557 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Object.base.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Object.base.cs
@@ -66,7 +66,7 @@ namespace Godot
if (memoryOwn)
{
memoryOwn = false;
- godot_icall_Reference_Disposed(this, ptr, !disposing);
+ godot_icall_RefCounted_Disposed(this, ptr, !disposing);
}
else
{
@@ -129,7 +129,7 @@ namespace Godot
internal static extern void godot_icall_Object_Disposed(Object obj, IntPtr ptr);
[MethodImpl(MethodImplOptions.InternalCall)]
- internal static extern void godot_icall_Reference_Disposed(Object obj, IntPtr ptr, bool isFinalizer);
+ internal static extern void godot_icall_RefCounted_Disposed(Object obj, IntPtr ptr, bool isFinalizer);
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern void godot_icall_Object_ConnectEventSignals(IntPtr obj);
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Plane.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Plane.cs
index 2f8b5f297c..ad6ca51e8b 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Plane.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Plane.cs
@@ -355,7 +355,7 @@ namespace Godot
public override string ToString()
{
- return String.Format("({0}, {1})", new object[]
+ return String.Format("{0}, {1}", new object[]
{
_normal.ToString(),
D.ToString()
@@ -364,7 +364,7 @@ namespace Godot
public string ToString(string format)
{
- return String.Format("({0}, {1})", new object[]
+ return String.Format("{0}, {1}", new object[]
{
_normal.ToString(format),
D.ToString(format)
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Quaternion.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Quaternion.cs
index b087b4c200..817103994a 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Quaternion.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Quaternion.cs
@@ -114,6 +114,23 @@ namespace Godot
}
/// <summary>
+ /// Returns the angle between this quaternion and `to`.
+ /// This is the magnitude of the angle you would need to rotate
+ /// by to get from one to the other.
+ ///
+ /// Note: This method has an abnormally high amount
+ /// of floating-point error, so methods such as
+ /// <see cref="Mathf.IsZeroApprox"/> will not work reliably.
+ /// </summary>
+ /// <param name="to">The other quaternion.</param>
+ /// <returns>The angle between the quaternions.</returns>
+ public real_t AngleTo(Quaternion to)
+ {
+ real_t dot = Dot(to);
+ return Mathf.Acos(Mathf.Clamp(dot * dot * 2 - 1, -1, 1));
+ }
+
+ /// <summary>
/// Performs a cubic spherical interpolation between quaternions `preA`,
/// this vector, `b`, and `postB`, by the given amount `t`.
/// </summary>
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2.cs
index 868c3536fe..612fb64a3d 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2.cs
@@ -405,7 +405,7 @@ namespace Godot
public override string ToString()
{
- return String.Format("({0}, {1})", new object[]
+ return String.Format("{0}, {1}", new object[]
{
_position.ToString(),
_size.ToString()
@@ -414,7 +414,7 @@ namespace Godot
public string ToString(string format)
{
- return String.Format("({0}, {1})", new object[]
+ return String.Format("{0}, {1}", new object[]
{
_position.ToString(format),
_size.ToString(format)
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform2D.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform2D.cs
index bc0f81b2a7..fe93592667 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform2D.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform2D.cs
@@ -492,22 +492,16 @@ namespace Godot
public override string ToString()
{
- return String.Format("({0}, {1}, {2})", new object[]
- {
- x.ToString(),
- y.ToString(),
- origin.ToString()
- });
+ return "[X: " + x.ToString() +
+ ", Y: " + y.ToString() +
+ ", O: " + origin.ToString() + "]";
}
public string ToString(string format)
{
- return String.Format("({0}, {1}, {2})", new object[]
- {
- x.ToString(format),
- y.ToString(format),
- origin.ToString(format)
- });
+ return "[X: " + x.ToString(format) +
+ ", Y: " + y.ToString(format) +
+ ", O: " + origin.ToString(format) + "]";
}
}
}
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform3D.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform3D.cs
index 50cc95fb95..26b1a9e8b2 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform3D.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform3D.cs
@@ -393,20 +393,18 @@ namespace Godot
public override string ToString()
{
- return String.Format("{0} - {1}", new object[]
- {
- basis.ToString(),
- origin.ToString()
- });
+ return "[X: " + basis.x.ToString() +
+ ", Y: " + basis.y.ToString() +
+ ", Z: " + basis.z.ToString() +
+ ", O: " + origin.ToString() + "]";
}
public string ToString(string format)
{
- return String.Format("{0} - {1}", new object[]
- {
- basis.ToString(format),
- origin.ToString(format)
- });
+ return "[X: " + basis.x.ToString(format) +
+ ", Y: " + basis.y.ToString(format) +
+ ", Z: " + basis.z.ToString(format) +
+ ", O: " + origin.ToString(format) + "]";
}
}
}
diff --git a/modules/mono/glue/base_object_glue.cpp b/modules/mono/glue/base_object_glue.cpp
index 34a96eba17..2b87c2d9a4 100644
--- a/modules/mono/glue/base_object_glue.cpp
+++ b/modules/mono/glue/base_object_glue.cpp
@@ -31,7 +31,7 @@
#ifdef MONO_GLUE_ENABLED
#include "core/object/class_db.h"
-#include "core/object/reference.h"
+#include "core/object/ref_counted.h"
#include "core/string/string_name.h"
#include "../csharp_script.h"
@@ -78,17 +78,17 @@ 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) {
+void godot_icall_RefCounted_Disposed(MonoObject *p_obj, Object *p_ptr, MonoBoolean p_is_finalizer) {
#ifdef DEBUG_ENABLED
CRASH_COND(p_ptr == nullptr);
- // This is only called with Reference derived classes
- CRASH_COND(!Object::cast_to<Reference>(p_ptr));
+ // This is only called with RefCounted derived classes
+ CRASH_COND(!Object::cast_to<RefCounted>(p_ptr));
#endif
- Reference *ref = static_cast<Reference *>(p_ptr);
+ RefCounted *rc = static_cast<RefCounted *>(p_ptr);
- if (ref->get_script_instance()) {
- CSharpInstance *cs_instance = CAST_CSHARP_INSTANCE(ref->get_script_instance());
+ if (rc->get_script_instance()) {
+ CSharpInstance *cs_instance = CAST_CSHARP_INSTANCE(rc->get_script_instance());
if (cs_instance) {
if (!cs_instance->is_destructing_script_instance()) {
bool delete_owner;
@@ -97,9 +97,9 @@ void godot_icall_Reference_Disposed(MonoObject *p_obj, Object *p_ptr, MonoBoolea
cs_instance->mono_object_disposed_baseref(p_obj, p_is_finalizer, delete_owner, remove_script_instance);
if (delete_owner) {
- memdelete(ref);
+ memdelete(rc);
} else if (remove_script_instance) {
- ref->set_script_instance(nullptr);
+ rc->set_script_instance(nullptr);
}
}
return;
@@ -108,11 +108,11 @@ void godot_icall_Reference_Disposed(MonoObject *p_obj, Object *p_ptr, MonoBoolea
// Unsafe refcount decrement. The managed instance also counts as a reference.
// See: CSharpLanguage::alloc_instance_binding_data(Object *p_object)
- CSharpLanguage::get_singleton()->pre_unsafe_unreference(ref);
- if (ref->unreference()) {
- memdelete(ref);
+ CSharpLanguage::get_singleton()->pre_unsafe_unreference(rc);
+ if (rc->unreference()) {
+ memdelete(rc);
} else {
- void *data = ref->get_script_instance_binding(CSharpLanguage::get_singleton()->get_language_index());
+ void *data = rc->get_script_instance_binding(CSharpLanguage::get_singleton()->get_language_index());
if (data) {
CSharpScriptBinding &script_binding = ((Map<Object *, CSharpScriptBinding>::Element *)data)->get();
@@ -145,18 +145,18 @@ MonoObject *godot_icall_Object_weakref(Object *p_ptr) {
}
Ref<WeakRef> wref;
- Reference *ref = Object::cast_to<Reference>(p_ptr);
+ RefCounted *rc = Object::cast_to<RefCounted>(p_ptr);
- if (ref) {
- REF r = ref;
+ if (rc) {
+ REF r = rc;
if (!r.is_valid()) {
return nullptr;
}
- wref.instance();
+ wref.instantiate();
wref->set_ref(r);
} else {
- wref.instance();
+ wref.instantiate();
wref->set_obj(p_ptr);
}
@@ -242,7 +242,7 @@ MonoString *godot_icall_Object_ToString(Object *p_ptr) {
void godot_register_object_icalls() {
GDMonoUtils::add_internal_call("Godot.Object::godot_icall_Object_Ctor", godot_icall_Object_Ctor);
GDMonoUtils::add_internal_call("Godot.Object::godot_icall_Object_Disposed", godot_icall_Object_Disposed);
- GDMonoUtils::add_internal_call("Godot.Object::godot_icall_Reference_Disposed", godot_icall_Reference_Disposed);
+ GDMonoUtils::add_internal_call("Godot.Object::godot_icall_RefCounted_Disposed", godot_icall_RefCounted_Disposed);
GDMonoUtils::add_internal_call("Godot.Object::godot_icall_Object_ConnectEventSignals", godot_icall_Object_ConnectEventSignals);
GDMonoUtils::add_internal_call("Godot.Object::godot_icall_Object_ClassDB_get_method", godot_icall_Object_ClassDB_get_method);
GDMonoUtils::add_internal_call("Godot.Object::godot_icall_Object_ToString", godot_icall_Object_ToString);
diff --git a/modules/mono/glue/glue_header.h b/modules/mono/glue/glue_header.h
index 3db52d7c30..eed3bd2167 100644
--- a/modules/mono/glue/glue_header.h
+++ b/modules/mono/glue/glue_header.h
@@ -61,7 +61,7 @@ void godot_register_glue_header_icalls() {
#include "core/config/engine.h"
#include "core/object/class_db.h"
#include "core/object/method_bind.h"
-#include "core/object/reference.h"
+#include "core/object/ref_counted.h"
#include "core/string/node_path.h"
#include "core/string/ustring.h"
#include "core/typedefs.h"
diff --git a/modules/mono/godotsharp_dirs.cpp b/modules/mono/godotsharp_dirs.cpp
index 68134b9b20..375ad413c4 100644
--- a/modules/mono/godotsharp_dirs.cpp
+++ b/modules/mono/godotsharp_dirs.cpp
@@ -31,7 +31,7 @@
#include "godotsharp_dirs.h"
#include "core/config/project_settings.h"
-#include "core/os/dir_access.h"
+#include "core/io/dir_access.h"
#include "core/os/os.h"
#ifdef TOOLS_ENABLED
diff --git a/modules/mono/mono_gc_handle.h b/modules/mono/mono_gc_handle.h
index f435aab3dd..d0e51d159f 100644
--- a/modules/mono/mono_gc_handle.h
+++ b/modules/mono/mono_gc_handle.h
@@ -33,7 +33,7 @@
#include <mono/jit/jit.h>
-#include "core/object/reference.h"
+#include "core/object/ref_counted.h"
namespace gdmono {
@@ -79,8 +79,8 @@ struct MonoGCHandleData {
static MonoGCHandleData new_weak_handle(MonoObject *p_object);
};
-class MonoGCHandleRef : public Reference {
- GDCLASS(MonoGCHandleRef, Reference);
+class MonoGCHandleRef : public RefCounted {
+ GDCLASS(MonoGCHandleRef, RefCounted);
MonoGCHandleData data;
diff --git a/modules/mono/mono_gd/gd_mono.cpp b/modules/mono/mono_gd/gd_mono.cpp
index c523d381f6..02d875f669 100644
--- a/modules/mono/mono_gd/gd_mono.cpp
+++ b/modules/mono/mono_gd/gd_mono.cpp
@@ -39,8 +39,8 @@
#include "core/config/project_settings.h"
#include "core/debugger/engine_debugger.h"
-#include "core/os/dir_access.h"
-#include "core/os/file_access.h"
+#include "core/io/dir_access.h"
+#include "core/io/file_access.h"
#include "core/os/os.h"
#include "core/os/thread.h"
@@ -691,7 +691,7 @@ static bool try_get_cached_api_hash_for(const String &p_api_assemblies_dir, bool
}
Ref<ConfigFile> cfg;
- cfg.instance();
+ cfg.instantiate();
Error cfg_err = cfg->load(cached_api_hash_path);
ERR_FAIL_COND_V(cfg_err != OK, false);
@@ -717,7 +717,7 @@ static void create_cached_api_hash_for(const String &p_api_assemblies_dir) {
String cached_api_hash_path = p_api_assemblies_dir.plus_file("api_hash_cache.cfg");
Ref<ConfigFile> cfg;
- cfg.instance();
+ cfg.instantiate();
cfg->set_value("core", "modified_time", FileAccess::get_modified_time(core_api_assembly_path));
cfg->set_value("editor", "modified_time", FileAccess::get_modified_time(editor_api_assembly_path));
diff --git a/modules/mono/mono_gd/gd_mono_assembly.cpp b/modules/mono/mono_gd/gd_mono_assembly.cpp
index a1556bace5..67d6f3ef29 100644
--- a/modules/mono/mono_gd/gd_mono_assembly.cpp
+++ b/modules/mono/mono_gd/gd_mono_assembly.cpp
@@ -34,8 +34,8 @@
#include <mono/metadata/tokentype.h>
#include "core/config/project_settings.h"
+#include "core/io/file_access.h"
#include "core/io/file_access_pack.h"
-#include "core/os/file_access.h"
#include "core/os/os.h"
#include "core/templates/list.h"
diff --git a/modules/mono/mono_gd/gd_mono_internals.cpp b/modules/mono/mono_gd/gd_mono_internals.cpp
index fa93c6533a..d7df18d5da 100644
--- a/modules/mono/mono_gd/gd_mono_internals.cpp
+++ b/modules/mono/mono_gd/gd_mono_internals.cpp
@@ -51,7 +51,7 @@ void tie_managed_to_unmanaged(MonoObject *managed, Object *unmanaged) {
// All mono objects created from the managed world (e.g.: 'new Player()')
// need to have a CSharpScript in order for their methods to be callable from the unmanaged side
- Reference *ref = Object::cast_to<Reference>(unmanaged);
+ RefCounted *rc = Object::cast_to<RefCounted>(unmanaged);
GDMonoClass *klass = GDMonoUtils::get_object_class(managed);
@@ -73,18 +73,18 @@ void tie_managed_to_unmanaged(MonoObject *managed, Object *unmanaged) {
script_binding.inited = true;
script_binding.type_name = NATIVE_GDMONOCLASS_NAME(klass);
script_binding.wrapper_class = klass;
- script_binding.gchandle = ref ? MonoGCHandleData::new_weak_handle(managed) : MonoGCHandleData::new_strong_handle(managed);
+ script_binding.gchandle = rc ? MonoGCHandleData::new_weak_handle(managed) : MonoGCHandleData::new_strong_handle(managed);
script_binding.owner = unmanaged;
- if (ref) {
+ if (rc) {
// Unsafe refcount increment. The managed instance also counts as a reference.
// This way if the unmanaged world has no references to our owner
// but the managed instance is alive, the refcount will be 1 instead of 0.
- // See: godot_icall_Reference_Dtor(MonoObject *p_obj, Object *p_ptr)
+ // See: godot_icall_RefCounted_Dtor(MonoObject *p_obj, Object *p_ptr)
// May not me referenced yet, so we must use init_ref() instead of reference()
- if (ref->init_ref()) {
- CSharpLanguage::get_singleton()->post_unsafe_reference(ref);
+ if (rc->init_ref()) {
+ CSharpLanguage::get_singleton()->post_unsafe_reference(rc);
}
}
@@ -99,7 +99,7 @@ void tie_managed_to_unmanaged(MonoObject *managed, Object *unmanaged) {
return;
}
- MonoGCHandleData gchandle = ref ? MonoGCHandleData::new_weak_handle(managed) : MonoGCHandleData::new_strong_handle(managed);
+ MonoGCHandleData gchandle = rc ? MonoGCHandleData::new_weak_handle(managed) : MonoGCHandleData::new_strong_handle(managed);
Ref<CSharpScript> script = CSharpScript::create_for_managed_type(klass, native);
diff --git a/modules/mono/mono_gd/gd_mono_log.cpp b/modules/mono/mono_gd/gd_mono_log.cpp
index dafd36c36b..179bbfb40c 100644
--- a/modules/mono/mono_gd/gd_mono_log.cpp
+++ b/modules/mono/mono_gd/gd_mono_log.cpp
@@ -32,7 +32,7 @@
#include <stdlib.h> // abort
-#include "core/os/dir_access.h"
+#include "core/io/dir_access.h"
#include "core/os/os.h"
#include "../godotsharp_dirs.h"
@@ -161,8 +161,8 @@ void GDMonoLog::initialize() {
OS::Time time_now = OS::get_singleton()->get_time();
String log_file_name = str_format("%04d-%02d-%02d_%02d.%02d.%02d",
- date_now.year, date_now.month, date_now.day,
- time_now.hour, time_now.min, time_now.sec);
+ (int)date_now.year, (int)date_now.month, (int)date_now.day,
+ (int)time_now.hour, (int)time_now.minute, (int)time_now.second);
log_file_name += str_format("_%d", OS::get_singleton()->get_process_id());
diff --git a/modules/mono/mono_gd/gd_mono_log.h b/modules/mono/mono_gd/gd_mono_log.h
index f7a53156ab..9ddbd251ac 100644
--- a/modules/mono/mono_gd/gd_mono_log.h
+++ b/modules/mono/mono_gd/gd_mono_log.h
@@ -41,7 +41,7 @@
#endif
#ifdef GD_MONO_LOG_ENABLED
-#include "core/os/file_access.h"
+#include "core/io/file_access.h"
#endif
class GDMonoLog {
diff --git a/modules/mono/mono_gd/gd_mono_marshal.cpp b/modules/mono/mono_gd/gd_mono_marshal.cpp
index c8f80e7777..9f2977bfa2 100644
--- a/modules/mono/mono_gd/gd_mono_marshal.cpp
+++ b/modules/mono/mono_gd/gd_mono_marshal.cpp
@@ -1136,8 +1136,8 @@ Variant mono_object_to_variant_impl(MonoObject *p_obj, const ManagedType &p_type
if (CACHED_CLASS(GodotObject)->is_assignable_from(type_class)) {
Object *ptr = unbox<Object *>(CACHED_FIELD(GodotObject, ptr)->get_value(p_obj));
if (ptr != nullptr) {
- Reference *ref = Object::cast_to<Reference>(ptr);
- return ref ? Variant(Ref<Reference>(ref)) : Variant(ptr);
+ RefCounted *rc = Object::cast_to<RefCounted>(ptr);
+ return rc ? Variant(Ref<RefCounted>(rc)) : Variant(ptr);
}
return Variant();
}
diff --git a/modules/mono/mono_gd/gd_mono_utils.cpp b/modules/mono/mono_gd/gd_mono_utils.cpp
index 6e0a263c7f..0b9a577e01 100644
--- a/modules/mono/mono_gd/gd_mono_utils.cpp
+++ b/modules/mono/mono_gd/gd_mono_utils.cpp
@@ -35,8 +35,8 @@
#include "core/debugger/engine_debugger.h"
#include "core/debugger/script_debugger.h"
-#include "core/object/reference.h"
-#include "core/os/dir_access.h"
+#include "core/io/dir_access.h"
+#include "core/object/ref_counted.h"
#include "core/os/mutex.h"
#include "core/os/os.h"
@@ -108,15 +108,15 @@ MonoObject *unmanaged_get_managed(Object *unmanaged) {
gchandle = MonoGCHandleData::new_strong_handle(mono_object);
// Tie managed to unmanaged
- Reference *ref = Object::cast_to<Reference>(unmanaged);
+ RefCounted *rc = Object::cast_to<RefCounted>(unmanaged);
- if (ref) {
+ if (rc) {
// Unsafe refcount increment. The managed instance also counts as a reference.
// This way if the unmanaged world has no references to our owner
// but the managed instance is alive, the refcount will be 1 instead of 0.
- // See: godot_icall_Reference_Dtor(MonoObject *p_obj, Object *p_ptr)
- ref->reference();
- CSharpLanguage::get_singleton()->post_unsafe_reference(ref);
+ // See: godot_icall_RefCounted_Dtor(MonoObject *p_obj, Object *p_ptr)
+ rc->reference();
+ CSharpLanguage::get_singleton()->post_unsafe_reference(rc);
}
return mono_object;
@@ -238,7 +238,7 @@ GDMonoClass *get_class_native_base(GDMonoClass *p_class) {
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, nullptr,
- "Type inherits from native type '" + p_native + "', so it can't be instanced in object of type: '" + p_object->get_class() + "'.");
+ "Type inherits from native type '" + p_native + "', so it can't be instantiated 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, nullptr);
diff --git a/modules/mono/mono_gd/gd_mono_utils.h b/modules/mono/mono_gd/gd_mono_utils.h
index 9e024418e1..773501e93d 100644
--- a/modules/mono/mono_gd/gd_mono_utils.h
+++ b/modules/mono/mono_gd/gd_mono_utils.h
@@ -41,7 +41,7 @@
#endif
#include "core/object/class_db.h"
-#include "core/object/reference.h"
+#include "core/object/ref_counted.h"
#define UNHANDLED_EXCEPTION(m_exc) \
if (unlikely(m_exc != nullptr)) { \
diff --git a/modules/mono/register_types.cpp b/modules/mono/register_types.cpp
index 80eb47bfd4..b4a6bfdcd4 100644
--- a/modules/mono/register_types.cpp
+++ b/modules/mono/register_types.cpp
@@ -52,10 +52,10 @@ void register_mono_types() {
script_language_cs->set_language_index(ScriptServer::get_language_count());
ScriptServer::register_language(script_language_cs);
- resource_loader_cs.instance();
+ resource_loader_cs.instantiate();
ResourceLoader::add_resource_format_loader(resource_loader_cs);
- resource_saver_cs.instance();
+ resource_saver_cs.instantiate();
ResourceSaver::add_resource_format_saver(resource_saver_cs);
}
diff --git a/modules/mono/signal_awaiter_utils.h b/modules/mono/signal_awaiter_utils.h
index 4c77f8cfed..e12ea45b3f 100644
--- a/modules/mono/signal_awaiter_utils.h
+++ b/modules/mono/signal_awaiter_utils.h
@@ -31,7 +31,7 @@
#ifndef SIGNAL_AWAITER_UTILS_H
#define SIGNAL_AWAITER_UTILS_H
-#include "core/object/reference.h"
+#include "core/object/ref_counted.h"
#include "csharp_script.h"
#include "mono_gc_handle.h"
diff --git a/modules/mono/utils/mono_reg_utils.cpp b/modules/mono/utils/mono_reg_utils.cpp
index bb1265e959..6b616dd52d 100644
--- a/modules/mono/utils/mono_reg_utils.cpp
+++ b/modules/mono/utils/mono_reg_utils.cpp
@@ -29,7 +29,7 @@
/*************************************************************************/
#include "mono_reg_utils.h"
-#include "core/os/dir_access.h"
+#include "core/io/dir_access.h"
#ifdef WINDOWS_ENABLED
diff --git a/modules/mono/utils/path_utils.cpp b/modules/mono/utils/path_utils.cpp
index 93d44628ac..ec04d50704 100644
--- a/modules/mono/utils/path_utils.cpp
+++ b/modules/mono/utils/path_utils.cpp
@@ -31,8 +31,8 @@
#include "path_utils.h"
#include "core/config/project_settings.h"
-#include "core/os/dir_access.h"
-#include "core/os/file_access.h"
+#include "core/io/dir_access.h"
+#include "core/io/file_access.h"
#include "core/os/os.h"
#ifdef WINDOWS_ENABLED
@@ -80,7 +80,7 @@ String cwd() {
}
String abspath(const String &p_path) {
- if (p_path.is_abs_path()) {
+ if (p_path.is_absolute_path()) {
return p_path.simplify_path();
} else {
return path::join(path::cwd(), p_path).simplify_path();
diff --git a/modules/mono/utils/string_utils.cpp b/modules/mono/utils/string_utils.cpp
index ee68458268..053618ebe4 100644
--- a/modules/mono/utils/string_utils.cpp
+++ b/modules/mono/utils/string_utils.cpp
@@ -30,7 +30,7 @@
#include "string_utils.h"
-#include "core/os/file_access.h"
+#include "core/io/file_access.h"
#include <stdio.h>
#include <stdlib.h>
diff --git a/modules/opensimplex/doc_classes/NoiseTexture.xml b/modules/opensimplex/doc_classes/NoiseTexture.xml
index a12412a9cd..2ae7f8cad9 100644
--- a/modules/opensimplex/doc_classes/NoiseTexture.xml
+++ b/modules/opensimplex/doc_classes/NoiseTexture.xml
@@ -31,7 +31,7 @@
<member name="noise" type="OpenSimplexNoise" setter="set_noise" getter="get_noise">
The [OpenSimplexNoise] instance used to generate the noise.
</member>
- <member name="noise_offset" type="Vector2" setter="set_noise_offset" getter="get_noise_offset" default="Vector2( 0, 0 )">
+ <member name="noise_offset" type="Vector2" setter="set_noise_offset" getter="get_noise_offset" default="Vector2(0, 0)">
An offset used to specify the noise space coordinate of the top left corner of the generated noise. This value is ignored if [member seamless] is enabled.
</member>
<member name="seamless" type="bool" setter="set_seamless" getter="get_seamless" default="false">
diff --git a/modules/opensimplex/doc_classes/OpenSimplexNoise.xml b/modules/opensimplex/doc_classes/OpenSimplexNoise.xml
index 2fdbd61ee7..4d45e41cc3 100644
--- a/modules/opensimplex/doc_classes/OpenSimplexNoise.xml
+++ b/modules/opensimplex/doc_classes/OpenSimplexNoise.xml
@@ -31,7 +31,7 @@
</argument>
<argument index="1" name="height" type="int">
</argument>
- <argument index="2" name="noise_offset" type="Vector2" default="Vector2( 0, 0 )">
+ <argument index="2" name="noise_offset" type="Vector2" default="Vector2(0, 0)">
</argument>
<description>
Generate a noise image in [constant Image.FORMAT_L8] format with the requested [code]width[/code] and [code]height[/code], based on the current noise parameters. If [code]noise_offset[/code] is specified, then the offset value is used as the coordinates of the top-left corner of the generated noise.
diff --git a/modules/opensimplex/noise_texture.cpp b/modules/opensimplex/noise_texture.cpp
index 9e0155da94..66c52ffbf9 100644
--- a/modules/opensimplex/noise_texture.cpp
+++ b/modules/opensimplex/noise_texture.cpp
@@ -187,6 +187,7 @@ Ref<OpenSimplexNoise> NoiseTexture::get_noise() {
}
void NoiseTexture::set_width(int p_width) {
+ ERR_FAIL_COND(p_width <= 0);
if (p_width == size.x) {
return;
}
@@ -195,6 +196,7 @@ void NoiseTexture::set_width(int p_width) {
}
void NoiseTexture::set_height(int p_height) {
+ ERR_FAIL_COND(p_height <= 0);
if (p_height == size.y) {
return;
}
diff --git a/modules/opensimplex/noise_texture.h b/modules/opensimplex/noise_texture.h
index 20a53bb58b..6237b6460d 100644
--- a/modules/opensimplex/noise_texture.h
+++ b/modules/opensimplex/noise_texture.h
@@ -34,7 +34,7 @@
#include "open_simplex_noise.h"
#include "core/io/image.h"
-#include "core/object/reference.h"
+#include "core/object/ref_counted.h"
#include "editor/editor_node.h"
#include "editor/editor_plugin.h"
#include "editor/property_editor.h"
diff --git a/modules/opensimplex/open_simplex_noise.h b/modules/opensimplex/open_simplex_noise.h
index bb50c523d2..dcf922a8bf 100644
--- a/modules/opensimplex/open_simplex_noise.h
+++ b/modules/opensimplex/open_simplex_noise.h
@@ -32,7 +32,7 @@
#define OPEN_SIMPLEX_NOISE_H
#include "core/io/image.h"
-#include "core/object/reference.h"
+#include "core/object/ref_counted.h"
#include "scene/resources/texture.h"
#include "thirdparty/misc/open-simplex-noise.h"
diff --git a/modules/pvr/image_compress_pvrtc.cpp b/modules/pvr/image_compress_pvrtc.cpp
index 6cb9837f49..980cac17d3 100644
--- a/modules/pvr/image_compress_pvrtc.cpp
+++ b/modules/pvr/image_compress_pvrtc.cpp
@@ -31,7 +31,7 @@
#include "image_compress_pvrtc.h"
#include "core/io/image.h"
-#include "core/object/reference.h"
+#include "core/object/ref_counted.h"
#include <PvrTcEncoder.h>
#include <RgbaBitmap.h>
@@ -43,6 +43,10 @@ static void _compress_pvrtc1_4bpp(Image *p_img) {
if (!img->is_size_po2() || img->get_width() != img->get_height()) {
make_mipmaps = img->has_mipmaps();
img->resize_to_po2(true);
+ // Resizing can fail for some formats
+ if (!img->is_size_po2() || img->get_width() != img->get_height()) {
+ ERR_FAIL_MSG("Failed to resize the image for compression.");
+ }
}
img->convert(Image::FORMAT_RGBA8);
if (!img->has_mipmaps() && make_mipmaps) {
@@ -52,7 +56,7 @@ static void _compress_pvrtc1_4bpp(Image *p_img) {
bool use_alpha = img->detect_alpha();
Ref<Image> new_img;
- new_img.instance();
+ new_img.instantiate();
new_img->create(img->get_width(), img->get_height(), img->has_mipmaps(), use_alpha ? Image::FORMAT_PVRTC1_4A : Image::FORMAT_PVRTC1_4);
Vector<uint8_t> data = new_img->get_data();
diff --git a/modules/pvr/register_types.cpp b/modules/pvr/register_types.cpp
index aeac564c93..ef72087d25 100644
--- a/modules/pvr/register_types.cpp
+++ b/modules/pvr/register_types.cpp
@@ -36,7 +36,7 @@
static Ref<ResourceFormatPVR> resource_loader_pvr;
void register_pvr_types() {
- resource_loader_pvr.instance();
+ resource_loader_pvr.instantiate();
ResourceLoader::add_resource_format_loader(resource_loader_pvr);
_register_pvrtc_compress_func();
diff --git a/modules/pvr/texture_loader_pvr.cpp b/modules/pvr/texture_loader_pvr.cpp
index 83f032ca2b..cb12976090 100644
--- a/modules/pvr/texture_loader_pvr.cpp
+++ b/modules/pvr/texture_loader_pvr.cpp
@@ -30,7 +30,7 @@
#include "texture_loader_pvr.h"
-#include "core/os/file_access.h"
+#include "core/io/file_access.h"
static void _pvrtc_decompress(Image *p_img);
diff --git a/modules/raycast/raycast_occlusion_cull.h b/modules/raycast/raycast_occlusion_cull.h
index d9ca57cf24..85710a790c 100644
--- a/modules/raycast/raycast_occlusion_cull.h
+++ b/modules/raycast/raycast_occlusion_cull.h
@@ -34,7 +34,7 @@
#include "core/io/image.h"
#include "core/math/camera_matrix.h"
#include "core/object/object.h"
-#include "core/object/reference.h"
+#include "core/object/ref_counted.h"
#include "core/templates/local_vector.h"
#include "core/templates/rid_owner.h"
#include "scene/resources/mesh.h"
diff --git a/modules/regex/doc_classes/RegEx.xml b/modules/regex/doc_classes/RegEx.xml
index b21f5d1e7a..7f5a0dfecb 100644
--- a/modules/regex/doc_classes/RegEx.xml
+++ b/modules/regex/doc_classes/RegEx.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="RegEx" inherits="Reference" version="4.0">
+<class name="RegEx" inherits="RefCounted" version="4.0">
<brief_description>
Class for searching text for patterns using regular expressions.
</brief_description>
diff --git a/modules/regex/doc_classes/RegExMatch.xml b/modules/regex/doc_classes/RegExMatch.xml
index a45de60aef..492519d3d9 100644
--- a/modules/regex/doc_classes/RegExMatch.xml
+++ b/modules/regex/doc_classes/RegExMatch.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="RegExMatch" inherits="Reference" version="4.0">
+<class name="RegExMatch" inherits="RefCounted" version="4.0">
<brief_description>
Contains the results of a [RegEx] search.
</brief_description>
@@ -51,7 +51,7 @@
<member name="names" type="Dictionary" setter="" getter="get_names" default="{}">
A dictionary of named groups and its corresponding group number. Only groups that were matched are included. If multiple groups have the same name, that name would refer to the first matching one.
</member>
- <member name="strings" type="Array" setter="" getter="get_strings" default="[ ]">
+ <member name="strings" type="Array" setter="" getter="get_strings" default="[]">
An [Array] of the match and its capturing groups.
</member>
<member name="subject" type="String" setter="" getter="get_subject" default="&quot;&quot;">
diff --git a/modules/regex/regex.h b/modules/regex/regex.h
index f5773042fb..68fe2bc6e0 100644
--- a/modules/regex/regex.h
+++ b/modules/regex/regex.h
@@ -31,15 +31,15 @@
#ifndef REGEX_H
#define REGEX_H
-#include "core/object/reference.h"
+#include "core/object/ref_counted.h"
#include "core/string/ustring.h"
#include "core/templates/map.h"
#include "core/templates/vector.h"
#include "core/variant/array.h"
#include "core/variant/dictionary.h"
-class RegExMatch : public Reference {
- GDCLASS(RegExMatch, Reference);
+class RegExMatch : public RefCounted {
+ GDCLASS(RegExMatch, RefCounted);
struct Range {
int start = 0;
@@ -68,8 +68,8 @@ public:
int get_end(const Variant &p_name) const;
};
-class RegEx : public Reference {
- GDCLASS(RegEx, Reference);
+class RegEx : public RefCounted {
+ GDCLASS(RegEx, RefCounted);
void *general_ctx;
void *code = nullptr;
diff --git a/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp b/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp
index e8e481de2d..768b419348 100644
--- a/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp
+++ b/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp
@@ -30,7 +30,7 @@
#include "audio_stream_ogg_vorbis.h"
-#include "core/os/file_access.h"
+#include "core/io/file_access.h"
void AudioStreamPlaybackOGGVorbis::_mix_internal(AudioFrame *p_buffer, int p_frames) {
ERR_FAIL_COND(!active);
@@ -129,7 +129,7 @@ Ref<AudioStreamPlayback> AudioStreamOGGVorbis::instance_playback() {
"to it. AudioStreamOGGVorbis should not be created from the "
"inspector or with `.new()`. Instead, load an audio file.");
- ovs.instance();
+ ovs.instantiate();
ovs->vorbis_stream = Ref<AudioStreamOGGVorbis>(this);
ovs->ogg_alloc.alloc_buffer = (char *)memalloc(decode_mem_size);
ovs->ogg_alloc.alloc_buffer_length_in_bytes = decode_mem_size;
diff --git a/modules/stb_vorbis/doc_classes/AudioStreamOGGVorbis.xml b/modules/stb_vorbis/doc_classes/AudioStreamOGGVorbis.xml
index 8a1bb62e24..94fdff5d43 100644
--- a/modules/stb_vorbis/doc_classes/AudioStreamOGGVorbis.xml
+++ b/modules/stb_vorbis/doc_classes/AudioStreamOGGVorbis.xml
@@ -11,7 +11,7 @@
<methods>
</methods>
<members>
- <member name="data" type="PackedByteArray" setter="set_data" getter="get_data" default="PackedByteArray( )">
+ <member name="data" type="PackedByteArray" setter="set_data" getter="get_data" default="PackedByteArray()">
Contains the audio data in bytes.
</member>
<member name="loop" type="bool" setter="set_loop" getter="has_loop" default="false">
diff --git a/modules/stb_vorbis/register_types.cpp b/modules/stb_vorbis/register_types.cpp
index 6f7eb53bc8..d9c6c06d65 100644
--- a/modules/stb_vorbis/register_types.cpp
+++ b/modules/stb_vorbis/register_types.cpp
@@ -41,7 +41,7 @@ void register_stb_vorbis_types() {
#ifdef TOOLS_ENABLED
if (Engine::get_singleton()->is_editor_hint()) {
Ref<ResourceImporterOGGVorbis> ogg_import;
- ogg_import.instance();
+ ogg_import.instantiate();
ResourceFormatImporter::get_singleton()->add_importer(ogg_import);
}
#endif
diff --git a/modules/stb_vorbis/resource_importer_ogg_vorbis.cpp b/modules/stb_vorbis/resource_importer_ogg_vorbis.cpp
index e3aa630cef..85de698efd 100644
--- a/modules/stb_vorbis/resource_importer_ogg_vorbis.cpp
+++ b/modules/stb_vorbis/resource_importer_ogg_vorbis.cpp
@@ -30,8 +30,8 @@
#include "resource_importer_ogg_vorbis.h"
+#include "core/io/file_access.h"
#include "core/io/resource_saver.h"
-#include "core/os/file_access.h"
#include "scene/resources/texture.h"
String ResourceImporterOGGVorbis::get_importer_name() const {
@@ -90,7 +90,7 @@ Error ResourceImporterOGGVorbis::import(const String &p_source_file, const Strin
memdelete(f);
Ref<AudioStreamOGGVorbis> ogg_stream;
- ogg_stream.instance();
+ ogg_stream.instantiate();
ogg_stream->set_data(data);
ERR_FAIL_COND_V(!ogg_stream->get_data().size(), ERR_FILE_CORRUPT);
diff --git a/modules/text_server_adv/dynamic_font_adv.cpp b/modules/text_server_adv/dynamic_font_adv.cpp
index c29aac05bb..62eedebb59 100644
--- a/modules/text_server_adv/dynamic_font_adv.cpp
+++ b/modules/text_server_adv/dynamic_font_adv.cpp
@@ -420,7 +420,7 @@ DynamicFontDataAdvanced::Character DynamicFontDataAdvanced::bitmap_to_character(
Ref<Image> img = memnew(Image(tex.texture_size, tex.texture_size, 0, require_format, tex.imgdata));
if (tex.texture.is_null()) {
- tex.texture.instance();
+ tex.texture.instantiate();
tex.texture->create_from_image(img);
} else {
tex.texture->update(img); //update
diff --git a/modules/text_server_adv/text_server_adv.cpp b/modules/text_server_adv/text_server_adv.cpp
index 7eff3f8dee..906ebe4993 100644
--- a/modules/text_server_adv/text_server_adv.cpp
+++ b/modules/text_server_adv/text_server_adv.cpp
@@ -2352,24 +2352,22 @@ bool TextServerAdvanced::shaped_text_shape(RID p_shaped) {
sd->glyphs.push_back(gl);
} else {
Vector<RID> fonts;
- // Push fonts with the language and script support first.
- for (int l = 0; l < span.fonts.size(); l++) {
- if ((font_is_language_supported(span.fonts[l], span.language)) && (font_is_script_supported(span.fonts[l], script))) {
- fonts.push_back(sd->spans[k].fonts[l]);
- }
- }
- // Push fonts with the script support.
- for (int l = 0; l < sd->spans[k].fonts.size(); l++) {
- if (!(font_is_language_supported(span.fonts[l], span.language)) && (font_is_script_supported(span.fonts[l], script))) {
- fonts.push_back(sd->spans[k].fonts[l]);
- }
- }
- // Push the rest valid fonts.
- for (int l = 0; l < sd->spans[k].fonts.size(); l++) {
- if (!(font_is_language_supported(span.fonts[l], span.language)) && !(font_is_script_supported(span.fonts[l], script))) {
- fonts.push_back(sd->spans[k].fonts[l]);
+ Vector<RID> fonts_scr_only;
+ Vector<RID> fonts_no_match;
+ int font_count = span.fonts.size();
+ for (int l = 0; l < font_count; l++) {
+ if (font_is_script_supported(span.fonts[l], script)) {
+ if (font_is_language_supported(span.fonts[l], span.language)) {
+ fonts.push_back(sd->spans[k].fonts[l]);
+ } else {
+ fonts_scr_only.push_back(sd->spans[k].fonts[l]);
+ }
+ } else {
+ fonts_no_match.push_back(sd->spans[k].fonts[l]);
}
}
+ fonts.append_array(fonts_scr_only);
+ fonts.append_array(fonts_no_match);
_shape_run(sd, MAX(sd->spans[k].start, script_run_start), MIN(sd->spans[k].end, script_run_end), sd->script_iter->script_ranges[j].script, bidi_run_direction, fonts, k, 0);
}
}
diff --git a/modules/text_server_fb/dynamic_font_fb.cpp b/modules/text_server_fb/dynamic_font_fb.cpp
index a261ba8f37..7e77987074 100644
--- a/modules/text_server_fb/dynamic_font_fb.cpp
+++ b/modules/text_server_fb/dynamic_font_fb.cpp
@@ -306,7 +306,7 @@ DynamicFontDataFallback::Character DynamicFontDataFallback::bitmap_to_character(
Ref<Image> img = memnew(Image(tex.texture_size, tex.texture_size, 0, require_format, tex.imgdata));
if (tex.texture.is_null()) {
- tex.texture.instance();
+ tex.texture.instantiate();
tex.texture->create_from_image(img);
} else {
tex.texture->update(img); //update
diff --git a/modules/text_server_fb/text_server_fb.cpp b/modules/text_server_fb/text_server_fb.cpp
index 98a67ef309..a22559efdd 100644
--- a/modules/text_server_fb/text_server_fb.cpp
+++ b/modules/text_server_fb/text_server_fb.cpp
@@ -634,17 +634,17 @@ bool TextServerFallback::shaped_text_add_string(RID p_shaped, const String &p_te
span.start = sd->text.length();
span.end = span.start + p_text.length();
// Pre-sort fonts, push fonts with the language support first.
- for (int i = 0; i < p_fonts.size(); i++) {
+ Vector<RID> fonts_no_match;
+ int font_count = p_fonts.size();
+ for (int i = 0; i < font_count; i++) {
if (font_is_language_supported(p_fonts[i], p_language)) {
span.fonts.push_back(p_fonts[i]);
+ } else {
+ fonts_no_match.push_back(p_fonts[i]);
}
}
- // Push the rest valid fonts.
- for (int i = 0; i < p_fonts.size(); i++) {
- if (!font_is_language_supported(p_fonts[i], p_language)) {
- span.fonts.push_back(p_fonts[i]);
- }
- }
+ span.fonts.append_array(fonts_no_match);
+
ERR_FAIL_COND_V(span.fonts.is_empty(), false);
span.font_size = p_size;
span.language = p_language;
diff --git a/modules/tga/image_loader_tga.cpp b/modules/tga/image_loader_tga.cpp
index 3cfd4ff36a..f0d7c335bd 100644
--- a/modules/tga/image_loader_tga.cpp
+++ b/modules/tga/image_loader_tga.cpp
@@ -35,7 +35,7 @@
#include "core/os/os.h"
#include "core/string/print_string.h"
-Error ImageLoaderTGA::decode_tga_rle(const uint8_t *p_compressed_buffer, size_t p_pixel_size, uint8_t *p_uncompressed_buffer, size_t p_output_size) {
+Error ImageLoaderTGA::decode_tga_rle(const uint8_t *p_compressed_buffer, size_t p_pixel_size, uint8_t *p_uncompressed_buffer, size_t p_output_size, size_t p_input_size) {
Error error;
Vector<uint8_t> pixels;
@@ -56,11 +56,14 @@ Error ImageLoaderTGA::decode_tga_rle(const uint8_t *p_compressed_buffer, size_t
compressed_pos += 1;
count = (c & 0x7f) + 1;
- if (output_pos + count * p_pixel_size > output_pos) {
+ if (output_pos + count * p_pixel_size > p_output_size) {
return ERR_PARSE_ERROR;
}
if (c & 0x80) {
+ if (compressed_pos + p_pixel_size > p_input_size) {
+ return ERR_PARSE_ERROR;
+ }
for (size_t i = 0; i < p_pixel_size; i++) {
pixels_w[i] = p_compressed_buffer[compressed_pos];
compressed_pos += 1;
@@ -72,6 +75,9 @@ Error ImageLoaderTGA::decode_tga_rle(const uint8_t *p_compressed_buffer, size_t
output_pos += p_pixel_size;
}
} else {
+ if (compressed_pos + count * p_pixel_size > p_input_size) {
+ return ERR_PARSE_ERROR;
+ }
count *= p_pixel_size;
for (size_t i = 0; i < count; i++) {
p_uncompressed_buffer[output_pos] = p_compressed_buffer[compressed_pos];
@@ -83,7 +89,7 @@ Error ImageLoaderTGA::decode_tga_rle(const uint8_t *p_compressed_buffer, size_t
return OK;
}
-Error ImageLoaderTGA::convert_to_image(Ref<Image> p_image, const uint8_t *p_buffer, const tga_header_s &p_header, const uint8_t *p_palette, const bool p_is_monochrome, size_t p_output_size) {
+Error ImageLoaderTGA::convert_to_image(Ref<Image> p_image, const uint8_t *p_buffer, const tga_header_s &p_header, const uint8_t *p_palette, const bool p_is_monochrome, size_t p_input_size) {
#define TGA_PUT_PIXEL(r, g, b, a) \
int image_data_ofs = ((y * width) + x); \
image_data_w[image_data_ofs * 4 + 0] = r; \
@@ -134,7 +140,7 @@ Error ImageLoaderTGA::convert_to_image(Ref<Image> p_image, const uint8_t *p_buff
if (p_is_monochrome) {
while (y != y_end) {
while (x != x_end) {
- if (i > p_output_size) {
+ if (i >= p_input_size) {
return ERR_PARSE_ERROR;
}
uint8_t shade = p_buffer[i];
@@ -150,7 +156,7 @@ Error ImageLoaderTGA::convert_to_image(Ref<Image> p_image, const uint8_t *p_buff
} else {
while (y != y_end) {
while (x != x_end) {
- if (i > p_output_size) {
+ if (i >= p_input_size) {
return ERR_PARSE_ERROR;
}
uint8_t index = p_buffer[i];
@@ -181,7 +187,7 @@ Error ImageLoaderTGA::convert_to_image(Ref<Image> p_image, const uint8_t *p_buff
} else if (p_header.pixel_depth == 24) {
while (y != y_end) {
while (x != x_end) {
- if (i + 2 > p_output_size) {
+ if (i + 2 >= p_input_size) {
return ERR_PARSE_ERROR;
}
@@ -200,7 +206,7 @@ Error ImageLoaderTGA::convert_to_image(Ref<Image> p_image, const uint8_t *p_buff
} else if (p_header.pixel_depth == 32) {
while (y != y_end) {
while (x != x_end) {
- if (i + 3 > p_output_size) {
+ if (i + 3 >= p_input_size) {
return ERR_PARSE_ERROR;
}
@@ -307,7 +313,7 @@ Error ImageLoaderTGA::load_image(Ref<Image> p_image, FileAccess *f, bool p_force
const uint8_t *buffer = nullptr;
if (is_encoded) {
- err = decode_tga_rle(src_image_r, pixel_size, uncompressed_buffer_w, buffer_size);
+ err = decode_tga_rle(src_image_r, pixel_size, uncompressed_buffer_w, buffer_size, src_image_len);
if (err == OK) {
uncompressed_buffer_r = uncompressed_buffer.ptr();
@@ -337,7 +343,7 @@ static Ref<Image> _tga_mem_loader_func(const uint8_t *p_tga, int p_size) {
Error open_memfile_error = memfile.open_custom(p_tga, p_size);
ERR_FAIL_COND_V_MSG(open_memfile_error, Ref<Image>(), "Could not create memfile for TGA image buffer.");
Ref<Image> img;
- img.instance();
+ img.instantiate();
Error load_error = ImageLoaderTGA().load_image(img, &memfile, false, 1.0f);
ERR_FAIL_COND_V_MSG(load_error, Ref<Image>(), "Failed to load TGA image.");
return img;
diff --git a/modules/tga/image_loader_tga.h b/modules/tga/image_loader_tga.h
index cb2ce07edd..e4463a322f 100644
--- a/modules/tga/image_loader_tga.h
+++ b/modules/tga/image_loader_tga.h
@@ -72,8 +72,8 @@ class ImageLoaderTGA : public ImageFormatLoader {
uint8_t pixel_depth = 0;
uint8_t image_descriptor = 0;
};
- static Error decode_tga_rle(const uint8_t *p_compressed_buffer, size_t p_pixel_size, uint8_t *p_uncompressed_buffer, size_t p_output_size);
- static Error convert_to_image(Ref<Image> p_image, const uint8_t *p_buffer, const tga_header_s &p_header, const uint8_t *p_palette, const bool p_is_monochrome, size_t p_output_size);
+ static Error decode_tga_rle(const uint8_t *p_compressed_buffer, size_t p_pixel_size, uint8_t *p_uncompressed_buffer, size_t p_output_size, size_t p_input_size);
+ static Error convert_to_image(Ref<Image> p_image, const uint8_t *p_buffer, const tga_header_s &p_header, const uint8_t *p_palette, const bool p_is_monochrome, size_t p_input_size);
public:
virtual Error load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear, float p_scale);
diff --git a/modules/theora/register_types.cpp b/modules/theora/register_types.cpp
index 0218b8c7a4..fd6c9dcd3c 100644
--- a/modules/theora/register_types.cpp
+++ b/modules/theora/register_types.cpp
@@ -35,7 +35,7 @@
static Ref<ResourceFormatLoaderTheora> resource_loader_theora;
void register_theora_types() {
- resource_loader_theora.instance();
+ resource_loader_theora.instantiate();
ResourceLoader::add_resource_format_loader(resource_loader_theora, true);
ClassDB::register_class<VideoStreamTheora>();
diff --git a/modules/theora/video_stream_theora.cpp b/modules/theora/video_stream_theora.cpp
index 4400445f30..40be067a91 100644
--- a/modules/theora/video_stream_theora.cpp
+++ b/modules/theora/video_stream_theora.cpp
@@ -335,7 +335,7 @@ void VideoStreamPlaybackTheora::set_file(const String &p_file) {
size.y = h;
Ref<Image> img;
- img.instance();
+ img.instantiate();
img->create(w, h, false, Image::FORMAT_RGBA8);
} else {
diff --git a/modules/theora/video_stream_theora.h b/modules/theora/video_stream_theora.h
index 2685a8a013..760173d0df 100644
--- a/modules/theora/video_stream_theora.h
+++ b/modules/theora/video_stream_theora.h
@@ -31,8 +31,8 @@
#ifndef VIDEO_STREAM_THEORA_H
#define VIDEO_STREAM_THEORA_H
+#include "core/io/file_access.h"
#include "core/io/resource_loader.h"
-#include "core/os/file_access.h"
#include "core/os/semaphore.h"
#include "core/os/thread.h"
#include "core/templates/ring_buffer.h"
diff --git a/modules/upnp/doc_classes/UPNP.xml b/modules/upnp/doc_classes/UPNP.xml
index 785c8dad50..09a2c8a88c 100644
--- a/modules/upnp/doc_classes/UPNP.xml
+++ b/modules/upnp/doc_classes/UPNP.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="UPNP" inherits="Reference" version="4.0">
+<class name="UPNP" inherits="RefCounted" version="4.0">
<brief_description>
UPNP network functions.
</brief_description>
diff --git a/modules/upnp/doc_classes/UPNPDevice.xml b/modules/upnp/doc_classes/UPNPDevice.xml
index f3b96bb89d..f7b5386d86 100644
--- a/modules/upnp/doc_classes/UPNPDevice.xml
+++ b/modules/upnp/doc_classes/UPNPDevice.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="UPNPDevice" inherits="Reference" version="4.0">
+<class name="UPNPDevice" inherits="RefCounted" version="4.0">
<brief_description>
UPNP device.
</brief_description>
diff --git a/modules/upnp/upnp.cpp b/modules/upnp/upnp.cpp
index 8e4e833d45..efe618012a 100644
--- a/modules/upnp/upnp.cpp
+++ b/modules/upnp/upnp.cpp
@@ -92,7 +92,7 @@ int UPNP::discover(int timeout, int ttl, const String &device_filter) {
void UPNP::add_device_to_list(UPNPDev *dev, UPNPDev *devlist) {
Ref<UPNPDevice> new_device;
- new_device.instance();
+ new_device.instantiate();
new_device->set_description_url(dev->descURL);
new_device->set_service_type(dev->st);
diff --git a/modules/upnp/upnp.h b/modules/upnp/upnp.h
index a0cca96bc8..b961a9667f 100644
--- a/modules/upnp/upnp.h
+++ b/modules/upnp/upnp.h
@@ -31,14 +31,14 @@
#ifndef GODOT_UPNP_H
#define GODOT_UPNP_H
-#include "core/object/reference.h"
+#include "core/object/ref_counted.h"
#include "upnp_device.h"
#include <miniupnpc/miniupnpc.h>
-class UPNP : public Reference {
- GDCLASS(UPNP, Reference);
+class UPNP : public RefCounted {
+ GDCLASS(UPNP, RefCounted);
private:
String discover_multicast_if = "";
diff --git a/modules/upnp/upnp_device.h b/modules/upnp/upnp_device.h
index 126e761a56..0a66c36ab9 100644
--- a/modules/upnp/upnp_device.h
+++ b/modules/upnp/upnp_device.h
@@ -31,10 +31,10 @@
#ifndef GODOT_UPNP_DEVICE_H
#define GODOT_UPNP_DEVICE_H
-#include "core/object/reference.h"
+#include "core/object/ref_counted.h"
-class UPNPDevice : public Reference {
- GDCLASS(UPNPDevice, Reference);
+class UPNPDevice : public RefCounted {
+ GDCLASS(UPNPDevice, RefCounted);
public:
enum IGDStatus {
diff --git a/modules/visual_script/doc_classes/VisualScript.xml b/modules/visual_script/doc_classes/VisualScript.xml
index 0798375a96..9d51bd86a2 100644
--- a/modules/visual_script/doc_classes/VisualScript.xml
+++ b/modules/visual_script/doc_classes/VisualScript.xml
@@ -39,7 +39,7 @@
</argument>
<argument index="1" name="node" type="VisualScriptNode">
</argument>
- <argument index="2" name="position" type="Vector2" default="Vector2( 0, 0 )">
+ <argument index="2" name="position" type="Vector2" default="Vector2(0, 0)">
</argument>
<description>
Add a node to the VisualScript.
diff --git a/modules/visual_script/doc_classes/VisualScriptClassConstant.xml b/modules/visual_script/doc_classes/VisualScriptClassConstant.xml
index de5d731cc0..d6b96957f5 100644
--- a/modules/visual_script/doc_classes/VisualScriptClassConstant.xml
+++ b/modules/visual_script/doc_classes/VisualScriptClassConstant.xml
@@ -15,10 +15,10 @@
<methods>
</methods>
<members>
- <member name="base_type" type="StringName" setter="set_base_type" getter="get_base_type" default="@&quot;Object&quot;">
+ <member name="base_type" type="StringName" setter="set_base_type" getter="get_base_type" default="&amp;&quot;Object&quot;">
The constant's parent class.
</member>
- <member name="constant" type="StringName" setter="set_class_constant" getter="get_class_constant" default="@&quot;&quot;">
+ <member name="constant" type="StringName" setter="set_class_constant" getter="get_class_constant" default="&amp;&quot;&quot;">
The constant to return. See the given class for its available constants.
</member>
</members>
diff --git a/modules/visual_script/doc_classes/VisualScriptComment.xml b/modules/visual_script/doc_classes/VisualScriptComment.xml
index 243338ea52..02cec97b27 100644
--- a/modules/visual_script/doc_classes/VisualScriptComment.xml
+++ b/modules/visual_script/doc_classes/VisualScriptComment.xml
@@ -15,7 +15,7 @@
<member name="description" type="String" setter="set_description" getter="get_description" default="&quot;&quot;">
The text inside the comment node.
</member>
- <member name="size" type="Vector2" setter="set_size" getter="get_size" default="Vector2( 150, 150 )">
+ <member name="size" type="Vector2" setter="set_size" getter="get_size" default="Vector2(150, 150)">
The comment node's size (in pixels).
</member>
<member name="title" type="String" setter="set_title" getter="get_title" default="&quot;Comment&quot;">
diff --git a/modules/visual_script/doc_classes/VisualScriptEmitSignal.xml b/modules/visual_script/doc_classes/VisualScriptEmitSignal.xml
index 5c9c8d3eca..df3121d093 100644
--- a/modules/visual_script/doc_classes/VisualScriptEmitSignal.xml
+++ b/modules/visual_script/doc_classes/VisualScriptEmitSignal.xml
@@ -15,7 +15,7 @@
<methods>
</methods>
<members>
- <member name="signal" type="StringName" setter="set_signal" getter="get_signal" default="@&quot;&quot;">
+ <member name="signal" type="StringName" setter="set_signal" getter="get_signal" default="&amp;&quot;&quot;">
The signal to emit.
</member>
</members>
diff --git a/modules/visual_script/doc_classes/VisualScriptFunctionCall.xml b/modules/visual_script/doc_classes/VisualScriptFunctionCall.xml
index 2d0fac1fa0..48104afcf7 100644
--- a/modules/visual_script/doc_classes/VisualScriptFunctionCall.xml
+++ b/modules/visual_script/doc_classes/VisualScriptFunctionCall.xml
@@ -11,13 +11,13 @@
<members>
<member name="base_script" type="String" setter="set_base_script" getter="get_base_script">
</member>
- <member name="base_type" type="StringName" setter="set_base_type" getter="get_base_type" default="@&quot;Object&quot;">
+ <member name="base_type" type="StringName" setter="set_base_type" getter="get_base_type" default="&amp;&quot;Object&quot;">
</member>
<member name="basic_type" type="int" setter="set_basic_type" getter="get_basic_type" enum="Variant.Type">
</member>
<member name="call_mode" type="int" setter="set_call_mode" getter="get_call_mode" enum="VisualScriptFunctionCall.CallMode" default="0">
</member>
- <member name="function" type="StringName" setter="set_function" getter="get_function" default="@&quot;&quot;">
+ <member name="function" type="StringName" setter="set_function" getter="get_function" default="&amp;&quot;&quot;">
</member>
<member name="node_path" type="NodePath" setter="set_base_path" getter="get_base_path">
</member>
diff --git a/modules/visual_script/doc_classes/VisualScriptFunctionState.xml b/modules/visual_script/doc_classes/VisualScriptFunctionState.xml
index 68083614a6..16c1629fe4 100644
--- a/modules/visual_script/doc_classes/VisualScriptFunctionState.xml
+++ b/modules/visual_script/doc_classes/VisualScriptFunctionState.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="VisualScriptFunctionState" inherits="Reference" version="4.0">
+<class name="VisualScriptFunctionState" inherits="RefCounted" version="4.0">
<brief_description>
</brief_description>
<description>
@@ -28,7 +28,7 @@
<method name="resume">
<return type="Variant">
</return>
- <argument index="0" name="args" type="Array" default="null">
+ <argument index="0" name="args" type="Array" default="[]">
</argument>
<description>
</description>
diff --git a/modules/visual_script/doc_classes/VisualScriptInputAction.xml b/modules/visual_script/doc_classes/VisualScriptInputAction.xml
index 6c296fdb4b..9ca67feacb 100644
--- a/modules/visual_script/doc_classes/VisualScriptInputAction.xml
+++ b/modules/visual_script/doc_classes/VisualScriptInputAction.xml
@@ -9,7 +9,7 @@
<methods>
</methods>
<members>
- <member name="action" type="StringName" setter="set_action_name" getter="get_action_name" default="@&quot;&quot;">
+ <member name="action" type="StringName" setter="set_action_name" getter="get_action_name" default="&amp;&quot;&quot;">
</member>
<member name="mode" type="int" setter="set_action_mode" getter="get_action_mode" enum="VisualScriptInputAction.Mode" default="0">
</member>
diff --git a/modules/visual_script/doc_classes/VisualScriptLocalVar.xml b/modules/visual_script/doc_classes/VisualScriptLocalVar.xml
index c3741eea89..185f0f1ffb 100644
--- a/modules/visual_script/doc_classes/VisualScriptLocalVar.xml
+++ b/modules/visual_script/doc_classes/VisualScriptLocalVar.xml
@@ -18,7 +18,7 @@
<member name="type" type="int" setter="set_var_type" getter="get_var_type" enum="Variant.Type" default="0">
The local variable's type.
</member>
- <member name="var_name" type="StringName" setter="set_var_name" getter="get_var_name" default="@&quot;new_local&quot;">
+ <member name="var_name" type="StringName" setter="set_var_name" getter="get_var_name" default="&amp;&quot;new_local&quot;">
The local variable's name.
</member>
</members>
diff --git a/modules/visual_script/doc_classes/VisualScriptLocalVarSet.xml b/modules/visual_script/doc_classes/VisualScriptLocalVarSet.xml
index 619bbb90ca..865f0153c9 100644
--- a/modules/visual_script/doc_classes/VisualScriptLocalVarSet.xml
+++ b/modules/visual_script/doc_classes/VisualScriptLocalVarSet.xml
@@ -20,7 +20,7 @@
<member name="type" type="int" setter="set_var_type" getter="get_var_type" enum="Variant.Type" default="0">
The local variable's type.
</member>
- <member name="var_name" type="StringName" setter="set_var_name" getter="get_var_name" default="@&quot;new_local&quot;">
+ <member name="var_name" type="StringName" setter="set_var_name" getter="get_var_name" default="&amp;&quot;new_local&quot;">
The local variable's name.
</member>
</members>
diff --git a/modules/visual_script/doc_classes/VisualScriptPropertyGet.xml b/modules/visual_script/doc_classes/VisualScriptPropertyGet.xml
index 1c22070ab1..ff6c723a3e 100644
--- a/modules/visual_script/doc_classes/VisualScriptPropertyGet.xml
+++ b/modules/visual_script/doc_classes/VisualScriptPropertyGet.xml
@@ -11,7 +11,7 @@
<members>
<member name="base_script" type="String" setter="set_base_script" getter="get_base_script">
</member>
- <member name="base_type" type="StringName" setter="set_base_type" getter="get_base_type" default="@&quot;Object&quot;">
+ <member name="base_type" type="StringName" setter="set_base_type" getter="get_base_type" default="&amp;&quot;Object&quot;">
</member>
<member name="basic_type" type="int" setter="set_basic_type" getter="get_basic_type" enum="Variant.Type">
</member>
@@ -19,7 +19,7 @@
</member>
<member name="node_path" type="NodePath" setter="set_base_path" getter="get_base_path">
</member>
- <member name="property" type="StringName" setter="set_property" getter="get_property" default="@&quot;&quot;">
+ <member name="property" type="StringName" setter="set_property" getter="get_property" default="&amp;&quot;&quot;">
</member>
<member name="set_mode" type="int" setter="set_call_mode" getter="get_call_mode" enum="VisualScriptPropertyGet.CallMode" default="0">
</member>
diff --git a/modules/visual_script/doc_classes/VisualScriptPropertySet.xml b/modules/visual_script/doc_classes/VisualScriptPropertySet.xml
index 629576e261..71bfc4c8a5 100644
--- a/modules/visual_script/doc_classes/VisualScriptPropertySet.xml
+++ b/modules/visual_script/doc_classes/VisualScriptPropertySet.xml
@@ -13,7 +13,7 @@
</member>
<member name="base_script" type="String" setter="set_base_script" getter="get_base_script">
</member>
- <member name="base_type" type="StringName" setter="set_base_type" getter="get_base_type" default="@&quot;Object&quot;">
+ <member name="base_type" type="StringName" setter="set_base_type" getter="get_base_type" default="&amp;&quot;Object&quot;">
</member>
<member name="basic_type" type="int" setter="set_basic_type" getter="get_basic_type" enum="Variant.Type">
</member>
@@ -21,7 +21,7 @@
</member>
<member name="node_path" type="NodePath" setter="set_base_path" getter="get_base_path">
</member>
- <member name="property" type="StringName" setter="set_property" getter="get_property" default="@&quot;&quot;">
+ <member name="property" type="StringName" setter="set_property" getter="get_property" default="&amp;&quot;&quot;">
</member>
<member name="set_mode" type="int" setter="set_call_mode" getter="get_call_mode" enum="VisualScriptPropertySet.CallMode" default="0">
</member>
diff --git a/modules/visual_script/doc_classes/VisualScriptTypeCast.xml b/modules/visual_script/doc_classes/VisualScriptTypeCast.xml
index 80a8d31041..9e3e020f2d 100644
--- a/modules/visual_script/doc_classes/VisualScriptTypeCast.xml
+++ b/modules/visual_script/doc_classes/VisualScriptTypeCast.xml
@@ -11,7 +11,7 @@
<members>
<member name="base_script" type="String" setter="set_base_script" getter="get_base_script" default="&quot;&quot;">
</member>
- <member name="base_type" type="StringName" setter="set_base_type" getter="get_base_type" default="@&quot;Object&quot;">
+ <member name="base_type" type="StringName" setter="set_base_type" getter="get_base_type" default="&amp;&quot;Object&quot;">
</member>
</members>
<constants>
diff --git a/modules/visual_script/doc_classes/VisualScriptVariableGet.xml b/modules/visual_script/doc_classes/VisualScriptVariableGet.xml
index d182e14e4d..df20ac53f2 100644
--- a/modules/visual_script/doc_classes/VisualScriptVariableGet.xml
+++ b/modules/visual_script/doc_classes/VisualScriptVariableGet.xml
@@ -15,7 +15,7 @@
<methods>
</methods>
<members>
- <member name="var_name" type="StringName" setter="set_variable" getter="get_variable" default="@&quot;&quot;">
+ <member name="var_name" type="StringName" setter="set_variable" getter="get_variable" default="&amp;&quot;&quot;">
The variable's name.
</member>
</members>
diff --git a/modules/visual_script/doc_classes/VisualScriptVariableSet.xml b/modules/visual_script/doc_classes/VisualScriptVariableSet.xml
index 3bd392dd85..eb8ebbe338 100644
--- a/modules/visual_script/doc_classes/VisualScriptVariableSet.xml
+++ b/modules/visual_script/doc_classes/VisualScriptVariableSet.xml
@@ -16,7 +16,7 @@
<methods>
</methods>
<members>
- <member name="var_name" type="StringName" setter="set_variable" getter="get_variable" default="@&quot;&quot;">
+ <member name="var_name" type="StringName" setter="set_variable" getter="get_variable" default="&amp;&quot;&quot;">
The variable's name.
</member>
</members>
diff --git a/modules/visual_script/doc_classes/VisualScriptYieldSignal.xml b/modules/visual_script/doc_classes/VisualScriptYieldSignal.xml
index 483cdfeaf8..c59234433f 100644
--- a/modules/visual_script/doc_classes/VisualScriptYieldSignal.xml
+++ b/modules/visual_script/doc_classes/VisualScriptYieldSignal.xml
@@ -9,13 +9,13 @@
<methods>
</methods>
<members>
- <member name="base_type" type="StringName" setter="set_base_type" getter="get_base_type" default="@&quot;Object&quot;">
+ <member name="base_type" type="StringName" setter="set_base_type" getter="get_base_type" default="&amp;&quot;Object&quot;">
</member>
<member name="call_mode" type="int" setter="set_call_mode" getter="get_call_mode" enum="VisualScriptYieldSignal.CallMode" default="0">
</member>
<member name="node_path" type="NodePath" setter="set_base_path" getter="get_base_path">
</member>
- <member name="signal" type="StringName" setter="set_signal" getter="get_signal" default="@&quot;&quot;">
+ <member name="signal" type="StringName" setter="set_signal" getter="get_signal" default="&amp;&quot;&quot;">
</member>
</members>
<constants>
diff --git a/modules/visual_script/visual_script.cpp b/modules/visual_script/visual_script.cpp
index c9ed912ac1..d49060bea8 100644
--- a/modules/visual_script/visual_script.cpp
+++ b/modules/visual_script/visual_script.cpp
@@ -725,7 +725,7 @@ int VisualScript::get_available_id() const {
/////////////////////////////////
-bool VisualScript::can_instance() const {
+bool VisualScript::can_instantiate() const {
return true; // ScriptServer::is_scripting_enabled();
}
@@ -1958,7 +1958,7 @@ void VisualScriptInstance::create(const Ref<VisualScript> &p_script, Object *p_o
for (const Set<int>::Element *F = node_ids.front(); F; F = F->next()) {
Ref<VisualScriptNode> node = script->nodes[F->get()].node;
- VisualScriptNodeInstance *instance = node->instance(this); // Create instance.
+ VisualScriptNodeInstance *instance = node->instantiate(this); // Create instance.
ERR_FAIL_COND(!instance);
instance->base = node.ptr();
@@ -2204,7 +2204,7 @@ Variant VisualScriptFunctionState::resume(Array p_args) {
void VisualScriptFunctionState::_bind_methods() {
ClassDB::bind_method(D_METHOD("connect_to_signal", "obj", "signals", "args"), &VisualScriptFunctionState::connect_to_signal);
- ClassDB::bind_method(D_METHOD("resume", "args"), &VisualScriptFunctionState::resume, DEFVAL(Variant()));
+ ClassDB::bind_method(D_METHOD("resume", "args"), &VisualScriptFunctionState::resume, DEFVAL(Array()));
ClassDB::bind_method(D_METHOD("is_valid"), &VisualScriptFunctionState::is_valid);
ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "_signal_callback", &VisualScriptFunctionState::_signal_callback, MethodInfo("_signal_callback"));
}
@@ -2262,7 +2262,7 @@ void VisualScriptLanguage::get_string_delimiters(List<String> *p_delimiters) con
Ref<Script> VisualScriptLanguage::get_template(const String &p_class_name, const String &p_base_class_name) const {
Ref<VisualScript> script;
- script.instance();
+ script.instantiate();
script->set_instance_base_type(p_base_class_name);
return script;
}
@@ -2276,7 +2276,7 @@ void VisualScriptLanguage::make_template(const String &p_class_name, const Strin
script->set_instance_base_type(p_base_class_name);
}
-bool VisualScriptLanguage::validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path, List<String> *r_functions, List<ScriptLanguage::Warning> *r_warnings, Set<int> *r_safe_lines) const {
+bool VisualScriptLanguage::validate(const String &p_script, const String &p_path, List<String> *r_functions, List<ScriptLanguage::ScriptError> *r_errors, List<ScriptLanguage::Warning> *r_warnings, Set<int> *r_safe_lines) const {
return false;
}
diff --git a/modules/visual_script/visual_script.h b/modules/visual_script/visual_script.h
index 3c4a26a2a3..932ebeb27f 100644
--- a/modules/visual_script/visual_script.h
+++ b/modules/visual_script/visual_script.h
@@ -87,7 +87,7 @@ public:
void set_breakpoint(bool p_breakpoint);
bool is_breakpoint() const;
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) = 0;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) = 0;
struct TypeGuess {
Variant::Type type = Variant::NIL;
@@ -325,7 +325,7 @@ public:
void set_instance_base_type(const StringName &p_type);
- virtual bool can_instance() const override;
+ virtual bool can_instantiate() const override;
virtual Ref<Script> get_base_script() const override;
virtual StringName get_instance_base_type() const override;
@@ -449,8 +449,8 @@ public:
~VisualScriptInstance();
};
-class VisualScriptFunctionState : public Reference {
- GDCLASS(VisualScriptFunctionState, Reference);
+class VisualScriptFunctionState : public RefCounted {
+ GDCLASS(VisualScriptFunctionState, RefCounted);
friend class VisualScriptInstance;
ObjectID instance_id;
@@ -571,7 +571,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 = nullptr, List<ScriptLanguage::Warning> *r_warnings = nullptr, Set<int> *r_safe_lines = nullptr) const;
+ virtual bool validate(const String &p_script, const String &p_path = "", List<String> *r_functions = nullptr, List<ScriptLanguage::ScriptError> *r_errors = 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;
@@ -619,7 +619,7 @@ public:
template <class T>
static Ref<VisualScriptNode> create_node_generic(const String &p_name) {
Ref<T> node;
- node.instance();
+ node.instantiate();
return node;
}
diff --git a/modules/visual_script/visual_script_builtin_funcs.cpp b/modules/visual_script/visual_script_builtin_funcs.cpp
index df34ec22ce..f17ad62531 100644
--- a/modules/visual_script/visual_script_builtin_funcs.cpp
+++ b/modules/visual_script/visual_script_builtin_funcs.cpp
@@ -33,7 +33,7 @@
#include "core/io/marshalls.h"
#include "core/math/math_funcs.h"
#include "core/object/class_db.h"
-#include "core/object/reference.h"
+#include "core/object/ref_counted.h"
#include "core/os/os.h"
#include "core/variant/variant_parser.h"
@@ -1187,7 +1187,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptBuiltinFunc::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptBuiltinFunc::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceBuiltinFunc *instance = memnew(VisualScriptNodeInstanceBuiltinFunc);
instance->node = this;
instance->instance = p_instance;
diff --git a/modules/visual_script/visual_script_builtin_funcs.h b/modules/visual_script/visual_script_builtin_funcs.h
index 1fafaf1d98..7196d4b46a 100644
--- a/modules/visual_script/visual_script_builtin_funcs.h
+++ b/modules/visual_script/visual_script_builtin_funcs.h
@@ -139,7 +139,7 @@ public:
void set_func(BuiltinFunc p_which);
BuiltinFunc get_func();
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptBuiltinFunc(VisualScriptBuiltinFunc::BuiltinFunc func);
VisualScriptBuiltinFunc();
diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp
index 5cfc228fae..69920a81b6 100644
--- a/modules/visual_script/visual_script_editor.cpp
+++ b/modules/visual_script/visual_script_editor.cpp
@@ -627,7 +627,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
Control::get_theme_icon("Quaternion", "EditorIcons"),
Control::get_theme_icon("AABB", "EditorIcons"),
Control::get_theme_icon("Basis", "EditorIcons"),
- Control::get_theme_icon("Transform", "EditorIcons"),
+ Control::get_theme_icon("Transform3D", "EditorIcons"),
Control::get_theme_icon("Color", "EditorIcons"),
Control::get_theme_icon("NodePath", "EditorIcons"),
Control::get_theme_icon("RID", "EditorIcons"),
@@ -1078,7 +1078,7 @@ void VisualScriptEditor::_update_members() {
Control::get_theme_icon("Quaternion", "EditorIcons"),
Control::get_theme_icon("AABB", "EditorIcons"),
Control::get_theme_icon("Basis", "EditorIcons"),
- Control::get_theme_icon("Transform", "EditorIcons"),
+ Control::get_theme_icon("Transform3D", "EditorIcons"),
Control::get_theme_icon("Color", "EditorIcons"),
Control::get_theme_icon("NodePath", "EditorIcons"),
Control::get_theme_icon("RID", "EditorIcons"),
@@ -1300,10 +1300,10 @@ void VisualScriptEditor::_create_function_dialog() {
void VisualScriptEditor::_create_function() {
String name = _validate_name((func_name_box->get_text() == "") ? "new_func" : func_name_box->get_text());
selected = name;
- Vector2 ofs = _get_available_pos();
+ Vector2 pos = _get_available_pos();
Ref<VisualScriptFunction> func_node;
- func_node.instance();
+ func_node.instantiate();
func_node->set_name(name);
for (int i = 0; i < func_input_vbox->get_child_count(); i++) {
@@ -1322,7 +1322,7 @@ void VisualScriptEditor::_create_function() {
undo_redo->create_action(TTR("Add Function"));
undo_redo->add_do_method(script.ptr(), "add_function", name, func_node_id);
undo_redo->add_undo_method(script.ptr(), "remove_function", name);
- undo_redo->add_do_method(script.ptr(), "add_node", func_node_id, func_node, ofs);
+ undo_redo->add_do_method(script.ptr(), "add_node", func_node_id, func_node, pos);
undo_redo->add_undo_method(script.ptr(), "remove_node", func_node_id);
undo_redo->add_do_method(this, "_update_members");
undo_redo->add_undo_method(this, "_update_members");
@@ -1417,16 +1417,16 @@ void VisualScriptEditor::_member_button(Object *p_item, int p_column, int p_butt
} else if (p_button == 0) {
String name = _validate_name("new_function");
selected = name;
- Vector2 ofs = _get_available_pos();
+ Vector2 pos = _get_available_pos();
Ref<VisualScriptFunction> func_node;
- func_node.instance();
+ func_node.instantiate();
func_node->set_name(name);
int fn_id = script->get_available_id();
undo_redo->create_action(TTR("Add Function"));
undo_redo->add_do_method(script.ptr(), "add_function", name, fn_id);
- undo_redo->add_do_method(script.ptr(), "add_node", fn_id, func_node, ofs);
+ undo_redo->add_do_method(script.ptr(), "add_node", fn_id, func_node, pos);
undo_redo->add_undo_method(script.ptr(), "remove_function", name);
undo_redo->add_do_method(script.ptr(), "remove_node", fn_id);
undo_redo->add_do_method(this, "_update_members");
@@ -1621,17 +1621,19 @@ void VisualScriptEditor::_expression_text_changed(const String &p_text, int p_id
updating_graph = false;
}
-Vector2 VisualScriptEditor::_get_available_pos(bool centered, Vector2 ofs) const {
- if (centered) {
- ofs = graph->get_scroll_ofs() + graph->get_size() * 0.5;
- }
-
+Vector2 VisualScriptEditor::_get_pos_in_graph(Vector2 p_point) const {
+ Vector2 pos = (graph->get_scroll_ofs() + p_point) / (graph->get_zoom() * EDSCALE);
if (graph->is_using_snap()) {
int snap = graph->get_snap();
- ofs = ofs.snapped(Vector2(snap, snap));
+ pos = pos.snapped(Vector2(snap, snap));
}
+ return pos;
+}
- ofs /= EDSCALE;
+Vector2 VisualScriptEditor::_get_available_pos(bool p_centered, Vector2 p_pos) const {
+ if (p_centered) {
+ p_pos = _get_pos_in_graph(graph->get_size() * 0.5);
+ }
while (true) {
bool exists = false;
@@ -1639,8 +1641,8 @@ Vector2 VisualScriptEditor::_get_available_pos(bool centered, Vector2 ofs) const
script->get_node_list(&existing);
for (List<int>::Element *E = existing.front(); E; E = E->next()) {
Point2 pos = script->get_node_position(E->get());
- if (pos.distance_to(ofs) < 50) {
- ofs += Vector2(graph->get_snap(), graph->get_snap());
+ if (pos.distance_to(p_pos) < 50) {
+ p_pos += Vector2(graph->get_snap(), graph->get_snap());
exists = true;
break;
}
@@ -1651,7 +1653,7 @@ Vector2 VisualScriptEditor::_get_available_pos(bool centered, Vector2 ofs) const
break;
}
- return ofs;
+ return p_pos;
}
String VisualScriptEditor::_validate_name(const String &p_name) const {
@@ -2049,16 +2051,9 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
return;
}
- Vector2 ofs = graph->get_scroll_ofs() + p_point;
-
- if (graph->is_using_snap()) {
- int snap = graph->get_snap();
- ofs = ofs.snapped(Vector2(snap, snap));
- }
-
- ofs /= EDSCALE;
+ Vector2 pos = _get_pos_in_graph(p_point);
- int new_id = _create_new_node_from_name(d["node_type"], ofs);
+ int new_id = _create_new_node_from_name(d["node_type"], pos);
Node *node = graph->get_node(itos(new_id));
if (node) {
@@ -2073,23 +2068,17 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
#else
bool use_set = Input::get_singleton()->is_key_pressed(KEY_CTRL);
#endif
- Vector2 ofs = graph->get_scroll_ofs() + p_point;
- if (graph->is_using_snap()) {
- int snap = graph->get_snap();
- ofs = ofs.snapped(Vector2(snap, snap));
- }
-
- ofs /= EDSCALE;
+ Vector2 pos = _get_pos_in_graph(p_point);
Ref<VisualScriptNode> vnode;
if (use_set) {
Ref<VisualScriptVariableSet> vnodes;
- vnodes.instance();
+ vnodes.instantiate();
vnodes->set_variable(d["variable"]);
vnode = vnodes;
} else {
Ref<VisualScriptVariableGet> vnodeg;
- vnodeg.instance();
+ vnodeg.instantiate();
vnodeg->set_variable(d["variable"]);
vnode = vnodeg;
}
@@ -2097,7 +2086,7 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
int new_id = script->get_available_id();
undo_redo->create_action(TTR("Add Node"));
- undo_redo->add_do_method(script.ptr(), "add_node", new_id, vnode, ofs);
+ undo_redo->add_do_method(script.ptr(), "add_node", new_id, vnode, pos);
undo_redo->add_undo_method(script.ptr(), "remove_node", new_id);
undo_redo->add_do_method(this, "_update_graph");
undo_redo->add_undo_method(this, "_update_graph");
@@ -2111,22 +2100,16 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
}
if (String(d["type"]) == "visual_script_function_drag") {
- Vector2 ofs = graph->get_scroll_ofs() + p_point;
- if (graph->is_using_snap()) {
- int snap = graph->get_snap();
- ofs = ofs.snapped(Vector2(snap, snap));
- }
-
- ofs /= EDSCALE;
+ Vector2 pos = _get_pos_in_graph(p_point);
Ref<VisualScriptFunctionCall> vnode;
- vnode.instance();
+ vnode.instantiate();
vnode->set_call_mode(VisualScriptFunctionCall::CALL_MODE_SELF);
int new_id = script->get_available_id();
undo_redo->create_action(TTR("Add Node"));
- undo_redo->add_do_method(script.ptr(), "add_node", new_id, vnode, ofs);
+ undo_redo->add_do_method(script.ptr(), "add_node", new_id, vnode, pos);
undo_redo->add_do_method(vnode.ptr(), "set_base_type", script->get_instance_base_type());
undo_redo->add_do_method(vnode.ptr(), "set_function", d["function"]);
@@ -2143,22 +2126,16 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
}
if (String(d["type"]) == "visual_script_signal_drag") {
- Vector2 ofs = graph->get_scroll_ofs() + p_point;
- if (graph->is_using_snap()) {
- int snap = graph->get_snap();
- ofs = ofs.snapped(Vector2(snap, snap));
- }
-
- ofs /= EDSCALE;
+ Vector2 pos = _get_pos_in_graph(p_point);
Ref<VisualScriptEmitSignal> vnode;
- vnode.instance();
+ vnode.instantiate();
vnode->set_signal(d["signal"]);
int new_id = script->get_available_id();
undo_redo->create_action(TTR("Add Node"));
- undo_redo->add_do_method(script.ptr(), "add_node", new_id, vnode, ofs);
+ undo_redo->add_do_method(script.ptr(), "add_node", new_id, vnode, pos);
undo_redo->add_undo_method(script.ptr(), "remove_node", new_id);
undo_redo->add_do_method(this, "_update_graph");
undo_redo->add_undo_method(this, "_update_graph");
@@ -2172,22 +2149,16 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
}
if (String(d["type"]) == "resource") {
- Vector2 ofs = graph->get_scroll_ofs() + p_point;
- if (graph->is_using_snap()) {
- int snap = graph->get_snap();
- ofs = ofs.snapped(Vector2(snap, snap));
- }
-
- ofs /= EDSCALE;
+ Vector2 pos = _get_pos_in_graph(p_point);
Ref<VisualScriptPreload> prnode;
- prnode.instance();
+ prnode.instantiate();
prnode->set_preload(d["resource"]);
int new_id = script->get_available_id();
undo_redo->create_action(TTR("Add Preload Node"));
- undo_redo->add_do_method(script.ptr(), "add_node", new_id, prnode, ofs);
+ undo_redo->add_do_method(script.ptr(), "add_node", new_id, prnode, pos);
undo_redo->add_undo_method(script.ptr(), "remove_node", new_id);
undo_redo->add_do_method(this, "_update_graph");
undo_redo->add_undo_method(this, "_update_graph");
@@ -2201,13 +2172,7 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
}
if (String(d["type"]) == "files") {
- Vector2 ofs = graph->get_scroll_ofs() + p_point;
- if (graph->is_using_snap()) {
- int snap = graph->get_snap();
- ofs = ofs.snapped(Vector2(snap, snap));
- }
-
- ofs /= EDSCALE;
+ Vector2 pos = _get_pos_in_graph(p_point);
Array files = d["files"];
@@ -2224,14 +2189,14 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
}
Ref<VisualScriptPreload> prnode;
- prnode.instance();
+ prnode.instantiate();
prnode->set_preload(res);
- undo_redo->add_do_method(script.ptr(), "add_node", new_id, prnode, ofs);
+ undo_redo->add_do_method(script.ptr(), "add_node", new_id, prnode, pos);
undo_redo->add_undo_method(script.ptr(), "remove_node", new_id);
new_ids.push_back(new_id);
new_id++;
- ofs += Vector2(20, 20) * EDSCALE;
+ pos += Vector2(20, 20);
}
undo_redo->add_do_method(this, "_update_graph");
@@ -2264,13 +2229,7 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
Array nodes = d["nodes"];
- Vector2 ofs = graph->get_scroll_ofs() + p_point;
-
- if (graph->is_using_snap()) {
- int snap = graph->get_snap();
- ofs = ofs.snapped(Vector2(snap, snap));
- }
- ofs /= EDSCALE;
+ Vector2 pos = _get_pos_in_graph(p_point);
undo_redo->create_action(TTR("Add Node(s) From Tree"));
int base_id = script->get_available_id();
@@ -2290,13 +2249,13 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
if (use_node) {
Ref<VisualScriptSceneNode> scene_node;
- scene_node.instance();
+ scene_node.instantiate();
scene_node->set_node_path(sn->get_path_to(node));
n = scene_node;
} else {
// ! Doesn't work properly.
Ref<VisualScriptFunctionCall> call;
- call.instance();
+ call.instantiate();
call->set_call_mode(VisualScriptFunctionCall::CALL_MODE_NODE_PATH);
call->set_base_path(sn->get_path_to(node));
call->set_base_type(node->get_class());
@@ -2305,11 +2264,11 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
selecting_method_id = base_id;
}
- undo_redo->add_do_method(script.ptr(), "add_node", base_id, n, ofs);
+ undo_redo->add_do_method(script.ptr(), "add_node", base_id, n, pos);
undo_redo->add_undo_method(script.ptr(), "remove_node", base_id);
base_id++;
- ofs += Vector2(25, 25);
+ pos += Vector2(25, 25);
}
undo_redo->add_do_method(this, "_update_graph");
undo_redo->add_undo_method(this, "_update_graph");
@@ -2331,14 +2290,8 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
}
Node *node = Object::cast_to<Node>(obj);
- Vector2 ofs = graph->get_scroll_ofs() + p_point;
-
- if (graph->is_using_snap()) {
- int snap = graph->get_snap();
- ofs = ofs.snapped(Vector2(snap, snap));
- }
+ Vector2 pos = _get_pos_in_graph(p_point);
- ofs /= EDSCALE;
#ifdef OSX_ENABLED
bool use_get = Input::get_singleton()->is_key_pressed(KEY_META);
#else
@@ -2358,7 +2311,7 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
if (!use_get) {
Ref<VisualScriptPropertySet> pset;
- pset.instance();
+ pset.instantiate();
pset->set_call_mode(VisualScriptPropertySet::CALL_MODE_INSTANCE);
pset->set_base_type(obj->get_class());
/*if (use_value) {
@@ -2368,14 +2321,14 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
vnode = pset;
} else {
Ref<VisualScriptPropertyGet> pget;
- pget.instance();
+ pget.instantiate();
pget->set_call_mode(VisualScriptPropertyGet::CALL_MODE_INSTANCE);
pget->set_base_type(obj->get_class());
vnode = pget;
}
- undo_redo->add_do_method(script.ptr(), "add_node", base_id, vnode, ofs);
+ undo_redo->add_do_method(script.ptr(), "add_node", base_id, vnode, pos);
undo_redo->add_do_method(vnode.ptr(), "set_property", d["property"]);
if (!use_get) {
undo_redo->add_do_method(vnode.ptr(), "set_default_input_value", 0, d["value"]);
@@ -2400,7 +2353,7 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
if (!use_get) {
Ref<VisualScriptPropertySet> pset;
- pset.instance();
+ pset.instantiate();
if (sn == node) {
pset->set_call_mode(VisualScriptPropertySet::CALL_MODE_SELF);
} else {
@@ -2411,7 +2364,7 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
vnode = pset;
} else {
Ref<VisualScriptPropertyGet> pget;
- pget.instance();
+ pget.instantiate();
if (sn == node) {
pget->set_call_mode(VisualScriptPropertyGet::CALL_MODE_SELF);
} else {
@@ -2420,7 +2373,7 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
}
vnode = pget;
}
- undo_redo->add_do_method(script.ptr(), "add_node", base_id, vnode, ofs);
+ undo_redo->add_do_method(script.ptr(), "add_node", base_id, vnode, pos);
undo_redo->add_do_method(vnode.ptr(), "set_property", d["property"]);
if (!use_get) {
undo_redo->add_do_method(vnode.ptr(), "set_default_input_value", 0, d["value"]);
@@ -2666,7 +2619,7 @@ void VisualScriptEditor::add_callback(const String &p_function, PackedStringArra
}
Ref<VisualScriptFunction> func;
- func.instance();
+ func.instantiate();
for (int i = 0; i < p_args.size(); i++) {
String name = p_args[i];
Variant::Type type = Variant::NIL;
@@ -3009,7 +2962,7 @@ void VisualScriptEditor::_graph_connect_to_empty(const String &p_from, int p_fro
if (!vsn.is_valid()) {
return;
}
- if (vsn->get_output_value_port_count()) {
+ if (vsn->get_output_value_port_count() || vsn->get_output_sequence_port_count()) {
port_action_pos = p_release_pos;
}
@@ -3075,19 +3028,12 @@ VisualScriptNode::TypeGuess VisualScriptEditor::_guess_output_type(int p_port_ac
}
void VisualScriptEditor::_port_action_menu(int p_option) {
- Vector2 ofs = graph->get_scroll_ofs() + port_action_pos;
- if (graph->is_using_snap()) {
- int snap = graph->get_snap();
- ofs = ofs.snapped(Vector2(snap, snap));
- }
- ofs /= EDSCALE;
-
Set<int> vn;
switch (p_option) {
case CREATE_CALL_SET_GET: {
Ref<VisualScriptFunctionCall> n;
- n.instance();
+ n.instantiate();
VisualScriptNode::TypeGuess tg = _guess_output_type(port_action_node, port_action_output, vn);
@@ -3172,13 +3118,7 @@ void VisualScriptEditor::connect_data(Ref<VisualScriptNode> vnode_old, Ref<Visua
}
void VisualScriptEditor::_selected_connect_node(const String &p_text, const String &p_category, const bool p_connecting) {
- Vector2 ofs = graph->get_scroll_ofs() + port_action_pos;
- if (graph->is_using_snap()) {
- int snap = graph->get_snap();
- ofs = ofs.snapped(Vector2(snap, snap));
- }
- ofs /= EDSCALE;
- ofs /= graph->get_zoom();
+ Vector2 pos = _get_pos_in_graph(port_action_pos);
Set<int> vn;
@@ -3216,7 +3156,7 @@ void VisualScriptEditor::_selected_connect_node(const String &p_text, const Stri
}
undo_redo->create_action(TTR("Add Node"));
- undo_redo->add_do_method(script.ptr(), "add_node", new_id, vnode_new, ofs);
+ undo_redo->add_do_method(script.ptr(), "add_node", new_id, vnode_new, pos);
if (vnode_old.is_valid() && p_connecting) {
connect_seq(vnode_old, vnode_new, new_id);
connect_data(vnode_old, vnode_new, new_id);
@@ -3234,16 +3174,16 @@ void VisualScriptEditor::_selected_connect_node(const String &p_text, const Stri
if (p_category == String("method")) {
Ref<VisualScriptFunctionCall> n;
- n.instance();
+ n.instantiate();
vnode = n;
} else if (p_category == String("set")) {
Ref<VisualScriptPropertySet> n;
- n.instance();
+ n.instantiate();
vnode = n;
script_prop_set = n;
} else if (p_category == String("get")) {
Ref<VisualScriptPropertyGet> n;
- n.instance();
+ n.instantiate();
n->set_property(p_text);
vnode = n;
}
@@ -3251,35 +3191,35 @@ void VisualScriptEditor::_selected_connect_node(const String &p_text, const Stri
if (p_category == String("action")) {
if (p_text == "VisualScriptCondition") {
Ref<VisualScriptCondition> n;
- n.instance();
+ n.instantiate();
vnode = n;
}
if (p_text == "VisualScriptSwitch") {
Ref<VisualScriptSwitch> n;
- n.instance();
+ n.instantiate();
vnode = n;
} else if (p_text == "VisualScriptSequence") {
Ref<VisualScriptSequence> n;
- n.instance();
+ n.instantiate();
vnode = n;
} else if (p_text == "VisualScriptIterator") {
Ref<VisualScriptIterator> n;
- n.instance();
+ n.instantiate();
vnode = n;
} else if (p_text == "VisualScriptWhile") {
Ref<VisualScriptWhile> n;
- n.instance();
+ n.instantiate();
vnode = n;
} else if (p_text == "VisualScriptReturn") {
Ref<VisualScriptReturn> n;
- n.instance();
+ n.instantiate();
vnode = n;
}
}
int new_id = script->get_available_id();
undo_redo->create_action(TTR("Add Node"));
- undo_redo->add_do_method(script.ptr(), "add_node", new_id, vnode, ofs);
+ undo_redo->add_do_method(script.ptr(), "add_node", new_id, vnode, pos);
undo_redo->add_undo_method(script.ptr(), "remove_node", new_id);
undo_redo->add_do_method(this, "_update_graph", new_id);
undo_redo->add_undo_method(this, "_update_graph", new_id);
@@ -3468,7 +3408,7 @@ void VisualScriptEditor::_selected_new_virtual_method(const String &p_text, cons
selected = name;
Ref<VisualScriptFunction> func_node;
- func_node.instance();
+ func_node.instantiate();
func_node->set_name(name);
int fn_id = script->get_available_id();
undo_redo->create_action(TTR("Add Function"));
@@ -3478,18 +3418,18 @@ void VisualScriptEditor::_selected_new_virtual_method(const String &p_text, cons
func_node->add_argument(minfo.arguments[i].type, minfo.arguments[i].name, -1, minfo.arguments[i].hint, minfo.arguments[i].hint_string);
}
- Vector2 ofs = _get_available_pos();
+ Vector2 pos = _get_available_pos();
- undo_redo->add_do_method(script.ptr(), "add_node", fn_id, func_node, ofs);
+ undo_redo->add_do_method(script.ptr(), "add_node", fn_id, func_node, pos);
undo_redo->add_undo_method(script.ptr(), "remove_node", fn_id);
if (minfo.return_val.type != Variant::NIL || minfo.return_val.usage & PROPERTY_USAGE_NIL_IS_VARIANT) {
Ref<VisualScriptReturn> ret_node;
- ret_node.instance();
+ ret_node.instantiate();
ret_node->set_return_type(minfo.return_val.type);
ret_node->set_enable_return_value(true);
ret_node->set_name(name);
int nid = script->get_available_id() + 1;
- undo_redo->add_do_method(script.ptr(), "add_node", nid, ret_node, _get_available_pos(false, ofs + Vector2(500, 0)));
+ undo_redo->add_do_method(script.ptr(), "add_node", nid, ret_node, _get_available_pos(false, pos + Vector2(500, 0)));
undo_redo->add_undo_method(script.ptr(), "remove_node", nid);
}
@@ -3993,16 +3933,16 @@ void VisualScriptEditor::_menu_option(int p_what) {
{
String new_fn = _validate_name("new_function");
- Vector2 ofs = _get_available_pos(false, script->get_node_position(start_node) - Vector2(80, 150));
+ Vector2 pos = _get_available_pos(false, script->get_node_position(start_node) - Vector2(80, 150));
Ref<VisualScriptFunction> func_node;
- func_node.instance();
+ func_node.instantiate();
func_node->set_name(new_fn);
undo_redo->create_action(TTR("Create Function"));
undo_redo->add_do_method(script.ptr(), "add_function", new_fn, fn_id);
- undo_redo->add_do_method(script.ptr(), "add_node", fn_id, func_node, ofs);
+ undo_redo->add_do_method(script.ptr(), "add_node", fn_id, func_node, pos);
undo_redo->add_undo_method(script.ptr(), "remove_function", new_fn);
undo_redo->add_undo_method(script.ptr(), "remove_node", fn_id);
undo_redo->add_do_method(this, "_update_members");
@@ -4041,12 +3981,12 @@ void VisualScriptEditor::_menu_option(int p_what) {
int m = 1;
for (Set<int>::Element *G = end_nodes.front(); G; G = G->next()) {
Ref<VisualScriptReturn> ret_node;
- ret_node.instance();
+ ret_node.instantiate();
int ret_id = fn_id + (m++);
selections.insert(ret_id);
- Vector2 ofsi = _get_available_pos(false, script->get_node_position(G->get()) + Vector2(80, -100));
- undo_redo->add_do_method(script.ptr(), "add_node", ret_id, ret_node, ofsi);
+ Vector2 posi = _get_available_pos(false, script->get_node_position(G->get()) + Vector2(80, -100));
+ undo_redo->add_do_method(script.ptr(), "add_node", ret_id, ret_node, posi);
undo_redo->add_undo_method(script.ptr(), "remove_node", ret_id);
undo_redo->add_do_method(script.ptr(), "sequence_connect", G->get(), 0, ret_id);
@@ -4243,9 +4183,9 @@ void VisualScriptEditor::_bind_methods() {
ClassDB::bind_method("_create_new_node_from_name", &VisualScriptEditor::_create_new_node_from_name);
- ClassDB::bind_method("get_drag_data_fw", &VisualScriptEditor::get_drag_data_fw);
- ClassDB::bind_method("can_drop_data_fw", &VisualScriptEditor::can_drop_data_fw);
- ClassDB::bind_method("drop_data_fw", &VisualScriptEditor::drop_data_fw);
+ ClassDB::bind_method("_get_drag_data_fw", &VisualScriptEditor::get_drag_data_fw);
+ ClassDB::bind_method("_can_drop_data_fw", &VisualScriptEditor::can_drop_data_fw);
+ ClassDB::bind_method("_drop_data_fw", &VisualScriptEditor::drop_data_fw);
ClassDB::bind_method("_input", &VisualScriptEditor::_input);
@@ -4529,7 +4469,7 @@ void VisualScriptEditor::register_editor() {
Ref<VisualScriptNode> _VisualScriptEditor::create_node_custom(const String &p_name) {
Ref<VisualScriptCustomNode> node;
- node.instance();
+ node.instantiate();
node->set_script(singleton->custom_nodes[p_name]);
return node;
}
diff --git a/modules/visual_script/visual_script_editor.h b/modules/visual_script/visual_script_editor.h
index ca06b807cc..1f0f087be7 100644
--- a/modules/visual_script/visual_script_editor.h
+++ b/modules/visual_script/visual_script_editor.h
@@ -226,7 +226,8 @@ class VisualScriptEditor : public ScriptEditorBase {
void _update_node_size(int p_id);
void _port_name_focus_out(const Node *p_name_box, int p_id, int p_port, bool is_input);
- Vector2 _get_available_pos(bool centered = true, Vector2 ofs = Vector2()) const;
+ Vector2 _get_pos_in_graph(Vector2 p_point) const;
+ Vector2 _get_available_pos(bool p_centered = true, Vector2 p_pos = Vector2()) const;
bool node_has_sequence_connections(int p_id);
diff --git a/modules/visual_script/visual_script_expression.cpp b/modules/visual_script/visual_script_expression.cpp
index cb4230bea9..d63fbeb726 100644
--- a/modules/visual_script/visual_script_expression.cpp
+++ b/modules/visual_script/visual_script_expression.cpp
@@ -1498,7 +1498,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptExpression::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptExpression::instantiate(VisualScriptInstance *p_instance) {
_compile_expression();
VisualScriptNodeInstanceExpression *instance = memnew(VisualScriptNodeInstanceExpression);
instance->instance = p_instance;
diff --git a/modules/visual_script/visual_script_expression.h b/modules/visual_script/visual_script_expression.h
index c35075ea53..ef16222b42 100644
--- a/modules/visual_script/visual_script_expression.h
+++ b/modules/visual_script/visual_script_expression.h
@@ -273,7 +273,7 @@ public:
virtual String get_text() const override;
virtual String get_category() const override { return "operators"; }
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptExpression();
~VisualScriptExpression();
diff --git a/modules/visual_script/visual_script_flow_control.cpp b/modules/visual_script/visual_script_flow_control.cpp
index e977f9c96b..af86f90b25 100644
--- a/modules/visual_script/visual_script_flow_control.cpp
+++ b/modules/visual_script/visual_script_flow_control.cpp
@@ -138,7 +138,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptReturn::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptReturn::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceReturn *instance = memnew(VisualScriptNodeInstanceReturn);
instance->node = this;
instance->instance = p_instance;
@@ -154,7 +154,7 @@ VisualScriptReturn::VisualScriptReturn() {
template <bool with_value>
static Ref<VisualScriptNode> create_return_node(const String &p_name) {
Ref<VisualScriptReturn> node;
- node.instance();
+ node.instantiate();
node->set_enable_return_value(with_value);
return node;
}
@@ -231,7 +231,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptCondition::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptCondition::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceCondition *instance = memnew(VisualScriptNodeInstanceCondition);
instance->node = this;
instance->instance = p_instance;
@@ -311,7 +311,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptWhile::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptWhile::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceWhile *instance = memnew(VisualScriptNodeInstanceWhile);
instance->node = this;
instance->instance = p_instance;
@@ -435,7 +435,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptIterator::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptIterator::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceIterator *instance = memnew(VisualScriptNodeInstanceIterator);
instance->node = this;
instance->instance = p_instance;
@@ -534,7 +534,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptSequence::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptSequence::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceSequence *instance = memnew(VisualScriptNodeInstanceSequence);
instance->node = this;
instance->instance = p_instance;
@@ -618,7 +618,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptSwitch::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptSwitch::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceSwitch *instance = memnew(VisualScriptNodeInstanceSwitch);
instance->instance = p_instance;
instance->case_count = case_values.size();
@@ -831,7 +831,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptTypeCast::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptTypeCast::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceTypeCast *instance = memnew(VisualScriptNodeInstanceTypeCast);
instance->instance = p_instance;
instance->base_type = base_type;
diff --git a/modules/visual_script/visual_script_flow_control.h b/modules/visual_script/visual_script_flow_control.h
index d9c4dedafd..73822fcc37 100644
--- a/modules/visual_script/visual_script_flow_control.h
+++ b/modules/visual_script/visual_script_flow_control.h
@@ -64,7 +64,7 @@ public:
void set_enable_return_value(bool p_enable);
bool is_return_value_enabled() const;
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptReturn();
};
@@ -91,7 +91,7 @@ public:
virtual String get_text() const override;
virtual String get_category() const override { return "flow_control"; }
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptCondition();
};
@@ -118,7 +118,7 @@ public:
virtual String get_text() const override;
virtual String get_category() const override { return "flow_control"; }
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptWhile();
};
@@ -145,7 +145,7 @@ public:
virtual String get_text() const override;
virtual String get_category() const override { return "flow_control"; }
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptIterator();
};
@@ -177,7 +177,7 @@ public:
void set_steps(int p_steps);
int get_steps() const;
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptSequence();
};
@@ -220,7 +220,7 @@ public:
virtual String get_text() const override;
virtual String get_category() const override { return "flow_control"; }
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptSwitch();
};
@@ -258,7 +258,7 @@ public:
virtual TypeGuess guess_output_type(TypeGuess *p_inputs, int p_output) const override;
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptTypeCast();
};
diff --git a/modules/visual_script/visual_script_func_nodes.cpp b/modules/visual_script/visual_script_func_nodes.cpp
index a0ba7b1962..43e1d38a16 100644
--- a/modules/visual_script/visual_script_func_nodes.cpp
+++ b/modules/visual_script/visual_script_func_nodes.cpp
@@ -856,7 +856,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptFunctionCall::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptFunctionCall::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceFunctionCall *instance = memnew(VisualScriptNodeInstanceFunctionCall);
instance->node = this;
instance->instance = p_instance;
@@ -891,7 +891,7 @@ VisualScriptFunctionCall::VisualScriptFunctionCall() {
template <VisualScriptFunctionCall::CallMode cmode>
static Ref<VisualScriptNode> create_function_call_node(const String &p_name) {
Ref<VisualScriptFunctionCall> node;
- node.instance();
+ node.instantiate();
node->set_call_mode(cmode);
return node;
}
@@ -1587,7 +1587,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptPropertySet::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptPropertySet::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstancePropertySet *instance = memnew(VisualScriptNodeInstancePropertySet);
instance->node = this;
instance->instance = p_instance;
@@ -1618,7 +1618,7 @@ VisualScriptPropertySet::VisualScriptPropertySet() {
template <VisualScriptPropertySet::CallMode cmode>
static Ref<VisualScriptNode> create_property_set_node(const String &p_name) {
Ref<VisualScriptPropertySet> node;
- node.instance();
+ node.instantiate();
node->set_call_mode(cmode);
return node;
}
@@ -2175,7 +2175,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptPropertyGet::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptPropertyGet::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstancePropertyGet *instance = memnew(VisualScriptNodeInstancePropertyGet);
instance->node = this;
instance->instance = p_instance;
@@ -2197,7 +2197,7 @@ VisualScriptPropertyGet::VisualScriptPropertyGet() {
template <VisualScriptPropertyGet::CallMode cmode>
static Ref<VisualScriptNode> create_property_get_node(const String &p_name) {
Ref<VisualScriptPropertyGet> node;
- node.instance();
+ node.instantiate();
node->set_call_mode(cmode);
return node;
}
@@ -2321,7 +2321,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptEmitSignal::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptEmitSignal::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceEmitSignal *instance = memnew(VisualScriptNodeInstanceEmitSignal);
instance->node = this;
instance->instance = p_instance;
@@ -2340,7 +2340,7 @@ static Ref<VisualScriptNode> create_basic_type_call_node(const String &p_name) {
String method = path[3];
Ref<VisualScriptFunctionCall> node;
- node.instance();
+ node.instantiate();
Variant::Type type = Variant::VARIANT_MAX;
diff --git a/modules/visual_script/visual_script_func_nodes.h b/modules/visual_script/visual_script_func_nodes.h
index 2ff9b7a981..eb17be1fbe 100644
--- a/modules/visual_script/visual_script_func_nodes.h
+++ b/modules/visual_script/visual_script_func_nodes.h
@@ -125,7 +125,7 @@ public:
void set_rpc_call_mode(RPCCallMode p_mode);
RPCCallMode get_rpc_call_mode() const;
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
virtual TypeGuess guess_output_type(TypeGuess *p_inputs, int p_output) const override;
@@ -231,7 +231,7 @@ public:
void set_assign_op(AssignOp p_op);
AssignOp get_assign_op() const;
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
virtual TypeGuess guess_output_type(TypeGuess *p_inputs, int p_output) const override;
VisualScriptPropertySet();
@@ -314,7 +314,7 @@ public:
void set_index(const StringName &p_type);
StringName get_index() const;
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptPropertyGet();
};
@@ -351,7 +351,7 @@ public:
void set_signal(const StringName &p_type);
StringName get_signal() const;
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptEmitSignal();
};
diff --git a/modules/visual_script/visual_script_nodes.cpp b/modules/visual_script/visual_script_nodes.cpp
index 07dc3dfaf6..f168a5942e 100644
--- a/modules/visual_script/visual_script_nodes.cpp
+++ b/modules/visual_script/visual_script_nodes.cpp
@@ -296,7 +296,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptFunction::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptFunction::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceFunction *instance = memnew(VisualScriptNodeInstanceFunction);
instance->node = this;
instance->instance = p_instance;
@@ -791,7 +791,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptComposeArray::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptComposeArray::instantiate(VisualScriptInstance *p_instance) {
VisualScriptComposeArrayNode *instance = memnew(VisualScriptComposeArrayNode);
instance->input_count = inputports.size();
return instance;
@@ -912,73 +912,135 @@ PropertyInfo VisualScriptOperator::get_output_value_port_info(int p_idx) const {
return pinfo;
}
-static const char *op_names[] = {
- //comparison
- "Are Equal", //OP_EQUAL,
- "Are Not Equal", //OP_NOT_EQUAL,
- "Less Than", //OP_LESS,
- "Less Than or Equal", //OP_LESS_EQUAL,
- "Greater Than", //OP_GREATER,
- "Greater Than or Equal", //OP_GREATER_EQUAL,
- //mathematic
- "Add", //OP_ADD,
- "Subtract", //OP_SUBTRACT,
- "Multiply", //OP_MULTIPLY,
- "Divide", //OP_DIVIDE,
- "Negate", //OP_NEGATE,
- "Positive", //OP_POSITIVE,
- "Remainder", //OP_MODULE,
- "Concatenate", //OP_STRING_CONCAT,
- //bitwise
- "Bit Shift Left", //OP_SHIFT_LEFT,
- "Bit Shift Right", //OP_SHIFT_RIGHT,
- "Bit And", //OP_BIT_AND,
- "Bit Or", //OP_BIT_OR,
- "Bit Xor", //OP_BIT_XOR,
- "Bit Negate", //OP_BIT_NEGATE,
- //logic
- "And", //OP_AND,
- "Or", //OP_OR,
- "Xor", //OP_XOR,
- "Not", //OP_NOT,
- //containment
- "In", //OP_IN,
-};
-
String VisualScriptOperator::get_caption() const {
- static const char32_t *op_names[] = {
- //comparison
- U"A = B", //OP_EQUAL,
- U"A \u2260 B", //OP_NOT_EQUAL,
- U"A < B", //OP_LESS,
- U"A \u2264 B", //OP_LESS_EQUAL,
- U"A > B", //OP_GREATER,
- U"A \u2265 B", //OP_GREATER_EQUAL,
- //mathematic
- U"A + B", //OP_ADD,
- U"A - B", //OP_SUBTRACT,
- U"A \u00D7 B", //OP_MULTIPLY,
- U"A \u00F7 B", //OP_DIVIDE,
- U"\u00AC A", //OP_NEGATE,
- U"+ A", //OP_POSITIVE,
- U"A mod B", //OP_MODULE,
- U"A .. B", //OP_STRING_CONCAT,
- //bitwise
- U"A << B", //OP_SHIFT_LEFT,
- U"A >> B", //OP_SHIFT_RIGHT,
- U"A & B", //OP_BIT_AND,
- U"A | B", //OP_BIT_OR,
- U"A ^ B", //OP_BIT_XOR,
- U"~A", //OP_BIT_NEGATE,
- //logic
- U"A and B", //OP_AND,
- U"A or B", //OP_OR,
- U"A xor B", //OP_XOR,
- U"not A", //OP_NOT,
- U"A in B", //OP_IN,
-
- };
- return op_names[op];
+ switch (op) {
+ // comparison
+ case Variant::OP_EQUAL:
+ return U"A = B";
+ case Variant::OP_NOT_EQUAL:
+ return U"A \u2260 B";
+ case Variant::OP_LESS:
+ return U"A < B";
+ case Variant::OP_LESS_EQUAL:
+ return U"A \u2264 B";
+ case Variant::OP_GREATER:
+ return U"A > B";
+ case Variant::OP_GREATER_EQUAL:
+ return U"A \u2265 B";
+
+ // mathematic
+ case Variant::OP_ADD:
+ return U"A + B";
+ case Variant::OP_SUBTRACT:
+ return U"A - B";
+ case Variant::OP_MULTIPLY:
+ return U"A \u00D7 B";
+ case Variant::OP_DIVIDE:
+ return U"A \u00F7 B";
+ case Variant::OP_NEGATE:
+ return U"\u00AC A";
+ case Variant::OP_POSITIVE:
+ return U"+ A";
+ case Variant::OP_MODULE:
+ return U"A mod B";
+
+ // bitwise
+ case Variant::OP_SHIFT_LEFT:
+ return U"A << B";
+ case Variant::OP_SHIFT_RIGHT:
+ return U"A >> B";
+ case Variant::OP_BIT_AND:
+ return U"A & B";
+ case Variant::OP_BIT_OR:
+ return U"A | B";
+ case Variant::OP_BIT_XOR:
+ return U"A ^ B";
+ case Variant::OP_BIT_NEGATE:
+ return U"~A";
+
+ // logic
+ case Variant::OP_AND:
+ return U"A and B";
+ case Variant::OP_OR:
+ return U"A or B";
+ case Variant::OP_XOR:
+ return U"A xor B";
+ case Variant::OP_NOT:
+ return U"not A";
+ case Variant::OP_IN:
+ return U"A in B";
+
+ default: {
+ ERR_FAIL_V_MSG(
+ U"Unknown node",
+ U"Unknown node type encountered, caption not available.");
+ }
+ }
+}
+
+String VisualScriptOperator::get_operator_name(Variant::Operator p_op) {
+ switch (p_op) {
+ // comparison
+ case Variant::OP_EQUAL:
+ return "Are Equal";
+ case Variant::OP_NOT_EQUAL:
+ return "Are Not Equal";
+ case Variant::OP_LESS:
+ return "Less Than";
+ case Variant::OP_LESS_EQUAL:
+ return "Less Than or Equal";
+ case Variant::OP_GREATER:
+ return "Greater Than";
+ case Variant::OP_GREATER_EQUAL:
+ return "Greater Than or Equal";
+
+ // mathematic
+ case Variant::OP_ADD:
+ return "Add";
+ case Variant::OP_SUBTRACT:
+ return "Subtract";
+ case Variant::OP_MULTIPLY:
+ return "Multiply";
+ case Variant::OP_DIVIDE:
+ return "Divide";
+ case Variant::OP_NEGATE:
+ return "Negate";
+ case Variant::OP_POSITIVE:
+ return "Positive";
+ case Variant::OP_MODULE:
+ return "Remainder";
+
+ // bitwise
+ case Variant::OP_SHIFT_LEFT:
+ return "Bit Shift Left";
+ case Variant::OP_SHIFT_RIGHT:
+ return "Bit Shift Right";
+ case Variant::OP_BIT_AND:
+ return "Bit And";
+ case Variant::OP_BIT_OR:
+ return "Bit Or";
+ case Variant::OP_BIT_XOR:
+ return "Bit Xor";
+ case Variant::OP_BIT_NEGATE:
+ return "Bit Negate";
+
+ // logic
+ case Variant::OP_AND:
+ return "And";
+ case Variant::OP_OR:
+ return "Or";
+ case Variant::OP_XOR:
+ return "Xor";
+ case Variant::OP_NOT:
+ return "Not";
+ case Variant::OP_IN:
+ return "In";
+
+ default: {
+ ERR_FAIL_INDEX_V(p_op, Variant::OP_MAX, "");
+ return "Unknown Operator";
+ }
+ }
}
void VisualScriptOperator::set_operator(Variant::Operator p_op) {
@@ -1018,7 +1080,7 @@ void VisualScriptOperator::_bind_methods() {
if (i > 0) {
types += ",";
}
- types += op_names[i];
+ types += get_operator_name(static_cast<Variant::Operator>(i));
}
String argt = "Any";
@@ -1051,9 +1113,9 @@ public:
r_error_str = *p_outputs[0];
} else {
if (unary) {
- r_error_str = String(op_names[op]) + RTR(": Invalid argument of type: ") + Variant::get_type_name(p_inputs[0]->get_type());
+ r_error_str = String(Variant::get_operator_name(op)) + RTR(": Invalid argument of type: ") + Variant::get_type_name(p_inputs[0]->get_type());
} else {
- r_error_str = String(op_names[op]) + RTR(": Invalid arguments: ") + "A: " + Variant::get_type_name(p_inputs[0]->get_type()) + " B: " + Variant::get_type_name(p_inputs[1]->get_type());
+ r_error_str = String(Variant::get_operator_name(op)) + RTR(": Invalid arguments: ") + "A: " + Variant::get_type_name(p_inputs[0]->get_type()) + " B: " + Variant::get_type_name(p_inputs[1]->get_type());
}
}
}
@@ -1062,7 +1124,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptOperator::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptOperator::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceOperator *instance = memnew(VisualScriptNodeInstanceOperator);
instance->unary = get_input_value_port_count() == 1;
instance->op = op;
@@ -1077,7 +1139,7 @@ VisualScriptOperator::VisualScriptOperator() {
template <Variant::Operator OP>
static Ref<VisualScriptNode> create_op_node(const String &p_name) {
Ref<VisualScriptOperator> node;
- node.instance();
+ node.instantiate();
node->set_operator(OP);
return node;
}
@@ -1169,7 +1231,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptSelect::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptSelect::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceSelect *instance = memnew(VisualScriptNodeInstanceSelect);
return instance;
}
@@ -1277,7 +1339,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptVariableGet::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptVariableGet::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceVariableGet *instance = memnew(VisualScriptNodeInstanceVariableGet);
instance->node = this;
instance->instance = p_instance;
@@ -1389,7 +1451,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptVariableSet::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptVariableSet::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceVariableSet *instance = memnew(VisualScriptNodeInstanceVariableSet);
instance->node = this;
instance->instance = p_instance;
@@ -1504,7 +1566,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptConstant::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptConstant::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceConstant *instance = memnew(VisualScriptNodeInstanceConstant);
instance->constant = value;
return instance;
@@ -1597,7 +1659,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptPreload::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptPreload::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstancePreload *instance = memnew(VisualScriptNodeInstancePreload);
instance->preload = preload;
return instance;
@@ -1662,7 +1724,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptIndexGet::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptIndexGet::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceIndexGet *instance = memnew(VisualScriptNodeInstanceIndexGet);
return instance;
}
@@ -1732,7 +1794,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptIndexSet::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptIndexSet::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceIndexSet *instance = memnew(VisualScriptNodeInstanceIndexSet);
return instance;
}
@@ -1798,7 +1860,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptGlobalConstant::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptGlobalConstant::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceGlobalConstant *instance = memnew(VisualScriptNodeInstanceGlobalConstant);
instance->index = index;
return instance;
@@ -1916,7 +1978,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptClassConstant::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptClassConstant::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceClassConstant *instance = memnew(VisualScriptNodeInstanceClassConstant);
instance->value = ClassDB::get_integer_constant(base_type, name, &instance->valid);
return instance;
@@ -2050,7 +2112,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptBasicTypeConstant::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptBasicTypeConstant::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceBasicTypeConstant *instance = memnew(VisualScriptNodeInstanceBasicTypeConstant);
instance->value = Variant::get_constant_value(type, name, &instance->valid);
return instance;
@@ -2174,7 +2236,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptMathConstant::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptMathConstant::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceMathConstant *instance = memnew(VisualScriptNodeInstanceMathConstant);
instance->value = const_value[constant];
return instance;
@@ -2268,7 +2330,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptEngineSingleton::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptEngineSingleton::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceEngineSingleton *instance = memnew(VisualScriptNodeInstanceEngineSingleton);
instance->singleton = Engine::get_singleton()->get_singleton_object(singleton);
return instance;
@@ -2394,7 +2456,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptSceneNode::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptSceneNode::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceSceneNode *instance = memnew(VisualScriptNodeInstanceSceneNode);
instance->node = this;
instance->instance = p_instance;
@@ -2574,7 +2636,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptSceneTree::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptSceneTree::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceSceneTree *instance = memnew(VisualScriptNodeInstanceSceneTree);
instance->node = this;
instance->instance = p_instance;
@@ -2655,7 +2717,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptResourcePath::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptResourcePath::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceResourcePath *instance = memnew(VisualScriptNodeInstanceResourcePath);
instance->path = path;
return instance;
@@ -2727,7 +2789,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptSelf::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptSelf::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceSelf *instance = memnew(VisualScriptNodeInstanceSelf);
instance->instance = p_instance;
return instance;
@@ -2908,7 +2970,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptCustomNode::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptCustomNode::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceCustomNode *instance = memnew(VisualScriptNodeInstanceCustomNode);
instance->instance = p_instance;
instance->node = this;
@@ -3059,7 +3121,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptSubCall::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptSubCall::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceSubCall *instance = memnew(VisualScriptNodeInstanceSubCall);
instance->instance = p_instance;
Ref<Script> script = get_script();
@@ -3172,7 +3234,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptComment::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptComment::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceComment *instance = memnew(VisualScriptNodeInstanceComment);
instance->instance = p_instance;
return instance;
@@ -3279,7 +3341,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptConstructor::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptConstructor::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceConstructor *instance = memnew(VisualScriptNodeInstanceConstructor);
instance->instance = p_instance;
instance->type = type;
@@ -3308,7 +3370,7 @@ static Ref<VisualScriptNode> create_constructor_node(const String &p_name) {
ERR_FAIL_COND_V(!constructor_map.has(p_name), Ref<VisualScriptNode>());
Ref<VisualScriptConstructor> vsc;
- vsc.instance();
+ vsc.instantiate();
vsc->set_constructor_type(constructor_map[p_name].first);
vsc->set_constructor(constructor_map[p_name].second);
@@ -3389,7 +3451,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptLocalVar::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptLocalVar::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceLocalVar *instance = memnew(VisualScriptNodeInstanceLocalVar);
instance->instance = p_instance;
instance->name = name;
@@ -3497,7 +3559,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptLocalVarSet::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptLocalVarSet::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceLocalVarSet *instance = memnew(VisualScriptNodeInstanceLocalVarSet);
instance->instance = p_instance;
instance->name = name;
@@ -3634,7 +3696,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptInputAction::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptInputAction::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceInputAction *instance = memnew(VisualScriptNodeInstanceInputAction);
instance->instance = p_instance;
instance->action = name;
@@ -3812,7 +3874,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptDeconstruct::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptDeconstruct::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceDeconstruct *instance = memnew(VisualScriptNodeInstanceDeconstruct);
instance->instance = p_instance;
instance->outputs.resize(elements.size());
@@ -3849,7 +3911,7 @@ VisualScriptDeconstruct::VisualScriptDeconstruct() {
template <Variant::Type T>
static Ref<VisualScriptNode> create_node_deconst_typed(const String &p_name) {
Ref<VisualScriptDeconstruct> node;
- node.instance();
+ node.instantiate();
node->set_deconstruct_type(T);
return node;
}
diff --git a/modules/visual_script/visual_script_nodes.h b/modules/visual_script/visual_script_nodes.h
index 7392443e4e..b599b92b3a 100644
--- a/modules/visual_script/visual_script_nodes.h
+++ b/modules/visual_script/visual_script_nodes.h
@@ -97,7 +97,7 @@ public:
void set_rpc_mode(MultiplayerAPI::RPCMode p_mode);
MultiplayerAPI::RPCMode get_rpc_mode() const;
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
virtual void reset_state() override;
@@ -192,7 +192,7 @@ public:
virtual String get_text() const override;
virtual String get_category() const override { return "functions"; }
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptComposeArray();
};
@@ -227,7 +227,9 @@ public:
void set_typed(Variant::Type p_op);
Variant::Type get_typed() const;
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ static String get_operator_name(Variant::Operator p_op);
+
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptOperator();
};
@@ -259,7 +261,7 @@ public:
void set_typed(Variant::Type p_op);
Variant::Type get_typed() const;
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptSelect();
};
@@ -291,7 +293,7 @@ public:
void set_variable(StringName p_variable);
StringName get_variable() const;
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptVariableGet();
};
@@ -323,7 +325,7 @@ public:
void set_variable(StringName p_variable);
StringName get_variable() const;
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptVariableSet();
};
@@ -359,7 +361,7 @@ public:
void set_constant_value(Variant p_value);
Variant get_constant_value() const;
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptConstant();
};
@@ -390,7 +392,7 @@ public:
void set_preload(const Ref<Resource> &p_preload);
Ref<Resource> get_preload() const;
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptPreload();
};
@@ -413,7 +415,7 @@ public:
virtual String get_caption() const override;
virtual String get_category() const override { return "operators"; }
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptIndexGet();
};
@@ -436,7 +438,7 @@ public:
virtual String get_caption() const override;
virtual String get_category() const override { return "operators"; }
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptIndexSet();
};
@@ -466,7 +468,7 @@ public:
void set_global_constant(int p_which);
int get_global_constant();
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptGlobalConstant();
};
@@ -502,7 +504,7 @@ public:
void set_base_type(const StringName &p_which);
StringName get_base_type();
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptClassConstant();
};
@@ -539,7 +541,7 @@ public:
void set_basic_type(Variant::Type p_which);
Variant::Type get_basic_type() const;
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptBasicTypeConstant();
};
@@ -586,7 +588,7 @@ public:
void set_math_constant(MathConstant p_which);
MathConstant get_math_constant();
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptMathConstant();
};
@@ -621,7 +623,7 @@ public:
void set_singleton(const String &p_string);
String get_singleton();
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
virtual TypeGuess guess_output_type(TypeGuess *p_inputs, int p_output) const override;
@@ -655,7 +657,7 @@ public:
void set_node_path(const NodePath &p_path);
NodePath get_node_path();
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
virtual TypeGuess guess_output_type(TypeGuess *p_inputs, int p_output) const override;
@@ -684,7 +686,7 @@ public:
virtual String get_caption() const override;
virtual String get_category() const override { return "data"; }
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
virtual TypeGuess guess_output_type(TypeGuess *p_inputs, int p_output) const override;
@@ -717,7 +719,7 @@ public:
void set_resource_path(const String &p_path);
String get_resource_path();
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptResourcePath();
};
@@ -743,7 +745,7 @@ public:
virtual String get_caption() const override;
virtual String get_category() const override { return "data"; }
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
virtual TypeGuess guess_output_type(TypeGuess *p_inputs, int p_output) const override;
@@ -788,7 +790,7 @@ public:
virtual String get_text() const override;
virtual String get_category() const override;
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
void _script_changed();
@@ -819,7 +821,7 @@ public:
virtual String get_text() const override;
virtual String get_category() const override;
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptSubCall();
};
@@ -859,7 +861,7 @@ public:
void set_size(const Size2 &p_size);
Size2 get_size() const;
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptComment();
};
@@ -894,7 +896,7 @@ public:
void set_constructor(const Dictionary &p_info);
Dictionary get_constructor() const;
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptConstructor();
};
@@ -929,7 +931,7 @@ public:
void set_var_type(Variant::Type p_type);
Variant::Type get_var_type() const;
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptLocalVar();
};
@@ -965,7 +967,7 @@ public:
void set_var_type(Variant::Type p_type);
Variant::Type get_var_type() const;
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptLocalVarSet();
};
@@ -1010,7 +1012,7 @@ public:
void set_action_mode(Mode p_mode);
Mode get_action_mode() const;
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptInputAction();
};
@@ -1056,7 +1058,7 @@ public:
void set_deconstruct_type(Variant::Type p_type);
Variant::Type get_deconstruct_type() const;
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptDeconstruct();
};
diff --git a/modules/visual_script/visual_script_property_selector.cpp b/modules/visual_script/visual_script_property_selector.cpp
index 7a3cd5c0d1..79addc5828 100644
--- a/modules/visual_script/visual_script_property_selector.cpp
+++ b/modules/visual_script/visual_script_property_selector.cpp
@@ -111,7 +111,7 @@ void VisualScriptPropertySelector::_update_search() {
vbc->get_theme_icon("Quaternion", "EditorIcons"),
vbc->get_theme_icon("AABB", "EditorIcons"),
vbc->get_theme_icon("Basis", "EditorIcons"),
- vbc->get_theme_icon("Transform", "EditorIcons"),
+ vbc->get_theme_icon("Transform3D", "EditorIcons"),
vbc->get_theme_icon("Color", "EditorIcons"),
vbc->get_theme_icon("Path", "EditorIcons"),
vbc->get_theme_icon("RID", "EditorIcons"),
@@ -469,10 +469,11 @@ void VisualScriptPropertySelector::_item_selected() {
at_class = ClassDB::get_parent_class_nocheck(at_class);
}
- Map<String, DocData::ClassDoc>::Element *T = dd->class_list.find(class_type);
+ Vector<String> functions = name.rsplit("/", false);
+ at_class = functions.size() > 3 ? functions[functions.size() - 2] : class_type;
+ Map<String, DocData::ClassDoc>::Element *T = dd->class_list.find(at_class);
if (T) {
for (int i = 0; i < T->get().methods.size(); i++) {
- Vector<String> functions = name.rsplit("/", false, 1);
if (T->get().methods[i].name == functions[functions.size() - 1]) {
text = DTR(T->get().methods[i].description);
}
diff --git a/modules/visual_script/visual_script_yield_nodes.cpp b/modules/visual_script/visual_script_yield_nodes.cpp
index 52fe659983..2e1b0a3e99 100644
--- a/modules/visual_script/visual_script_yield_nodes.cpp
+++ b/modules/visual_script/visual_script_yield_nodes.cpp
@@ -113,7 +113,7 @@ public:
}
Ref<VisualScriptFunctionState> state;
- state.instance();
+ state.instantiate();
int ret = STEP_YIELD_BIT;
switch (mode) {
@@ -138,7 +138,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptYield::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptYield::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceYield *instance = memnew(VisualScriptNodeInstanceYield);
//instance->instance=p_instance;
instance->mode = yield_mode;
@@ -202,7 +202,7 @@ VisualScriptYield::VisualScriptYield() {
template <VisualScriptYield::YieldMode MODE>
static Ref<VisualScriptNode> create_yield_node(const String &p_name) {
Ref<VisualScriptYield> node;
- node.instance();
+ node.instantiate();
node->set_yield_mode(MODE);
return node;
}
@@ -548,7 +548,7 @@ public:
}
Ref<VisualScriptFunctionState> state;
- state.instance();
+ state.instantiate();
state->connect_to_signal(object, signal, Array());
@@ -559,7 +559,7 @@ public:
}
};
-VisualScriptNodeInstance *VisualScriptYieldSignal::instance(VisualScriptInstance *p_instance) {
+VisualScriptNodeInstance *VisualScriptYieldSignal::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceYieldSignal *instance = memnew(VisualScriptNodeInstanceYieldSignal);
instance->node = this;
instance->instance = p_instance;
@@ -578,7 +578,7 @@ VisualScriptYieldSignal::VisualScriptYieldSignal() {
template <VisualScriptYieldSignal::CallMode cmode>
static Ref<VisualScriptNode> create_yield_signal_node(const String &p_name) {
Ref<VisualScriptYieldSignal> node;
- node.instance();
+ node.instantiate();
node->set_call_mode(cmode);
return node;
}
diff --git a/modules/visual_script/visual_script_yield_nodes.h b/modules/visual_script/visual_script_yield_nodes.h
index cc7ce0a1c6..fa596173a6 100644
--- a/modules/visual_script/visual_script_yield_nodes.h
+++ b/modules/visual_script/visual_script_yield_nodes.h
@@ -76,7 +76,7 @@ public:
void set_wait_time(float p_time);
float get_wait_time();
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptYield();
};
@@ -135,7 +135,7 @@ public:
void set_call_mode(CallMode p_mode);
CallMode get_call_mode() const;
- virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override;
+ virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptYieldSignal();
};
diff --git a/modules/webm/register_types.cpp b/modules/webm/register_types.cpp
index 82157a71c9..9cfaba83c1 100644
--- a/modules/webm/register_types.cpp
+++ b/modules/webm/register_types.cpp
@@ -35,7 +35,7 @@
static Ref<ResourceFormatLoaderWebm> resource_loader_webm;
void register_webm_types() {
- resource_loader_webm.instance();
+ resource_loader_webm.instantiate();
ResourceLoader::add_resource_format_loader(resource_loader_webm, true);
ClassDB::register_class<VideoStreamWebm>();
diff --git a/modules/webm/video_stream_webm.cpp b/modules/webm/video_stream_webm.cpp
index 34addb5c9f..12e0f5bd25 100644
--- a/modules/webm/video_stream_webm.cpp
+++ b/modules/webm/video_stream_webm.cpp
@@ -31,7 +31,7 @@
#include "video_stream_webm.h"
#include "core/config/project_settings.h"
-#include "core/os/file_access.h"
+#include "core/io/file_access.h"
#include "core/os/os.h"
#include "servers/audio_server.h"
@@ -116,7 +116,7 @@ bool VideoStreamPlaybackWebm::open_file(const String &p_file) {
frame_data.resize((webm->getWidth() * webm->getHeight()) << 2);
Ref<Image> img;
- img.instance();
+ img.instantiate();
img->create(webm->getWidth(), webm->getHeight(), false, Image::FORMAT_RGBA8);
texture->create_from_image(img);
diff --git a/modules/webp/image_loader_webp.cpp b/modules/webp/image_loader_webp.cpp
index 1f2a456619..5bebad2b53 100644
--- a/modules/webp/image_loader_webp.cpp
+++ b/modules/webp/image_loader_webp.cpp
@@ -30,6 +30,7 @@
#include "image_loader_webp.h"
+#include "core/config/project_settings.h"
#include "core/io/marshalls.h"
#include "core/os/os.h"
#include "core/string/print_string.h"
@@ -69,12 +70,77 @@ static Vector<uint8_t> _webp_lossy_pack(const Ref<Image> &p_image, float p_quali
w[2] = 'B';
w[3] = 'P';
memcpy(&w[4], dst_buff, dst_size);
- free(dst_buff);
+ WebPFree(dst_buff);
return dst;
}
-static Ref<Image> _webp_lossy_unpack(const Vector<uint8_t> &p_buffer) {
+static Vector<uint8_t> _webp_lossless_pack(const Ref<Image> &p_image) {
+ ERR_FAIL_COND_V(p_image.is_null() || p_image->is_empty(), Vector<uint8_t>());
+
+ int compression_level = ProjectSettings::get_singleton()->get("rendering/textures/lossless_compression/webp_compression_level");
+ compression_level = CLAMP(compression_level, 0, 9);
+
+ Ref<Image> img = p_image->duplicate();
+ if (img->detect_alpha()) {
+ img->convert(Image::FORMAT_RGBA8);
+ } else {
+ img->convert(Image::FORMAT_RGB8);
+ }
+
+ Size2 s(img->get_width(), img->get_height());
+ Vector<uint8_t> data = img->get_data();
+ const uint8_t *r = data.ptr();
+
+ // we need to use the more complex API in order to access the 'exact' flag...
+
+ WebPConfig config;
+ WebPPicture pic;
+ if (!WebPConfigInit(&config) || !WebPConfigLosslessPreset(&config, compression_level) || !WebPPictureInit(&pic)) {
+ ERR_FAIL_V(Vector<uint8_t>());
+ }
+
+ WebPMemoryWriter wrt;
+ config.exact = 1;
+ pic.use_argb = 1;
+ pic.width = s.width;
+ pic.height = s.height;
+ pic.writer = WebPMemoryWrite;
+ pic.custom_ptr = &wrt;
+ WebPMemoryWriterInit(&wrt);
+
+ bool success_import = false;
+ if (img->get_format() == Image::FORMAT_RGB8) {
+ success_import = WebPPictureImportRGB(&pic, r, 3 * s.width);
+ } else {
+ success_import = WebPPictureImportRGBA(&pic, r, 4 * s.width);
+ }
+ bool success_encode = false;
+ if (success_import) {
+ success_encode = WebPEncode(&config, &pic);
+ }
+ WebPPictureFree(&pic);
+
+ if (!success_encode) {
+ WebPMemoryWriterClear(&wrt);
+ ERR_FAIL_V_MSG(Vector<uint8_t>(), "WebP packing failed.");
+ }
+
+ // copy from wrt
+ Vector<uint8_t> dst;
+ dst.resize(4 + wrt.size);
+ uint8_t *w = dst.ptrw();
+ w[0] = 'W';
+ w[1] = 'E';
+ w[2] = 'B';
+ w[3] = 'P';
+ memcpy(&w[4], wrt.mem, wrt.size);
+ WebPMemoryWriterClear(&wrt);
+
+ return dst;
+}
+
+static Ref<Image> _webp_unpack(const Vector<uint8_t> &p_buffer) {
int size = p_buffer.size() - 4;
ERR_FAIL_COND_V(size <= 0, Ref<Image>());
const uint8_t *r = p_buffer.ptr();
@@ -139,7 +205,7 @@ Error webp_load_image_from_buffer(Image *p_image, const uint8_t *p_buffer, int p
static Ref<Image> _webp_mem_loader_func(const uint8_t *p_png, int p_size) {
Ref<Image> img;
- img.instance();
+ img.instantiate();
Error err = webp_load_image_from_buffer(img.ptr(), p_png, p_size);
ERR_FAIL_COND_V(err, Ref<Image>());
return img;
@@ -168,6 +234,7 @@ void ImageLoaderWEBP::get_recognized_extensions(List<String> *p_extensions) cons
ImageLoaderWEBP::ImageLoaderWEBP() {
Image::_webp_mem_loader_func = _webp_mem_loader_func;
- Image::lossy_packer = _webp_lossy_pack;
- Image::lossy_unpacker = _webp_lossy_unpack;
+ Image::webp_lossy_packer = _webp_lossy_pack;
+ Image::webp_lossless_packer = _webp_lossless_pack;
+ Image::webp_unpacker = _webp_unpack;
}
diff --git a/modules/webrtc/doc_classes/WebRTCPeerConnection.xml b/modules/webrtc/doc_classes/WebRTCPeerConnection.xml
index 3b53892a3d..62e524825d 100644
--- a/modules/webrtc/doc_classes/WebRTCPeerConnection.xml
+++ b/modules/webrtc/doc_classes/WebRTCPeerConnection.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="WebRTCPeerConnection" inherits="Reference" version="4.0">
+<class name="WebRTCPeerConnection" inherits="RefCounted" version="4.0">
<brief_description>
Interface to a WebRTC peer connection.
</brief_description>
diff --git a/modules/webrtc/webrtc_multiplayer.h b/modules/webrtc/webrtc_multiplayer.h
index 6b4ae6fcc8..2ddb98f656 100644
--- a/modules/webrtc/webrtc_multiplayer.h
+++ b/modules/webrtc/webrtc_multiplayer.h
@@ -48,7 +48,7 @@ private:
CH_RESERVED_MAX = 3
};
- class ConnectedPeer : public Reference {
+ class ConnectedPeer : public RefCounted {
public:
Ref<WebRTCPeerConnection> connection;
List<Ref<WebRTCDataChannel>> channels;
diff --git a/modules/webrtc/webrtc_peer_connection.h b/modules/webrtc/webrtc_peer_connection.h
index ae75864489..fcfb9ae9ae 100644
--- a/modules/webrtc/webrtc_peer_connection.h
+++ b/modules/webrtc/webrtc_peer_connection.h
@@ -34,8 +34,8 @@
#include "core/io/packet_peer.h"
#include "modules/webrtc/webrtc_data_channel.h"
-class WebRTCPeerConnection : public Reference {
- GDCLASS(WebRTCPeerConnection, Reference);
+class WebRTCPeerConnection : public RefCounted {
+ GDCLASS(WebRTCPeerConnection, RefCounted);
public:
enum ConnectionState {
diff --git a/modules/websocket/doc_classes/WebSocketClient.xml b/modules/websocket/doc_classes/WebSocketClient.xml
index d362bcc10f..6af610c689 100644
--- a/modules/websocket/doc_classes/WebSocketClient.xml
+++ b/modules/websocket/doc_classes/WebSocketClient.xml
@@ -17,11 +17,11 @@
</return>
<argument index="0" name="url" type="String">
</argument>
- <argument index="1" name="protocols" type="PackedStringArray" default="PackedStringArray( )">
+ <argument index="1" name="protocols" type="PackedStringArray" default="PackedStringArray()">
</argument>
<argument index="2" name="gd_mp_api" type="bool" default="false">
</argument>
- <argument index="3" name="custom_headers" type="PackedStringArray" default="PackedStringArray( )">
+ <argument index="3" name="custom_headers" type="PackedStringArray" default="PackedStringArray()">
</argument>
<description>
Connects to the given URL requesting one of the given [code]protocols[/code] as sub-protocol. If the list empty (default), no sub-protocol will be requested.
diff --git a/modules/websocket/doc_classes/WebSocketServer.xml b/modules/websocket/doc_classes/WebSocketServer.xml
index f7805209e2..7bc0d64718 100644
--- a/modules/websocket/doc_classes/WebSocketServer.xml
+++ b/modules/websocket/doc_classes/WebSocketServer.xml
@@ -63,7 +63,7 @@
</return>
<argument index="0" name="port" type="int">
</argument>
- <argument index="1" name="protocols" type="PackedStringArray" default="PackedStringArray( )">
+ <argument index="1" name="protocols" type="PackedStringArray" default="PackedStringArray()">
</argument>
<argument index="2" name="gd_mp_api" type="bool" default="false">
</argument>
@@ -89,6 +89,9 @@
<member name="ca_chain" type="X509Certificate" setter="set_ca_chain" getter="get_ca_chain">
When using SSL (see [member private_key] and [member ssl_certificate]), you can set this to a valid [X509Certificate] to be provided as additional CA chain information during the SSL handshake.
</member>
+ <member name="handshake_timeout" type="float" setter="set_handshake_timeout" getter="get_handshake_timeout" default="3.0">
+ The time in seconds before a pending client (i.e. a client that has not yet finished the HTTP handshake) is considered stale and forcefully disconnected.
+ </member>
<member name="private_key" type="CryptoKey" setter="set_private_key" getter="get_private_key">
When set to a valid [CryptoKey] (along with [member ssl_certificate]) will cause the server to require SSL instead of regular TCP (i.e. the [code]wss://[/code] protocol).
</member>
diff --git a/modules/websocket/emws_server.h b/modules/websocket/emws_server.h
index e7285ccb86..d36e3a3557 100644
--- a/modules/websocket/emws_server.h
+++ b/modules/websocket/emws_server.h
@@ -33,7 +33,7 @@
#ifdef JAVASCRIPT_ENABLED
-#include "core/object/reference.h"
+#include "core/object/ref_counted.h"
#include "emws_peer.h"
#include "websocket_server.h"
diff --git a/modules/websocket/websocket_client.cpp b/modules/websocket/websocket_client.cpp
index 1e9183ebfa..af1dc8ff54 100644
--- a/modules/websocket/websocket_client.cpp
+++ b/modules/websocket/websocket_client.cpp
@@ -42,9 +42,9 @@ Error WebSocketClient::connect_to_url(String p_url, const Vector<String> p_proto
_is_multiplayer = gd_mp_api;
String host = p_url;
- String path = "/";
- String scheme = "";
- int port = 80;
+ String path;
+ String scheme;
+ int port = 0;
Error err = p_url.parse_url(scheme, host, port, path);
ERR_FAIL_COND_V_MSG(err != OK, err, "Invalid URL: " + p_url);
@@ -55,6 +55,9 @@ Error WebSocketClient::connect_to_url(String p_url, const Vector<String> p_proto
if (port == 0) {
port = ssl ? 443 : 80;
}
+ if (path.is_empty()) {
+ path = "/";
+ }
return connect_to_host(host, path, port, ssl, p_protocols, p_custom_headers);
}
@@ -123,12 +126,12 @@ void WebSocketClient::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_verify_ssl_enabled", "enabled"), &WebSocketClient::set_verify_ssl_enabled);
ClassDB::bind_method(D_METHOD("is_verify_ssl_enabled"), &WebSocketClient::is_verify_ssl_enabled);
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "verify_ssl", PROPERTY_HINT_NONE, "", 0), "set_verify_ssl_enabled", "is_verify_ssl_enabled");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "verify_ssl", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_verify_ssl_enabled", "is_verify_ssl_enabled");
ClassDB::bind_method(D_METHOD("get_trusted_ssl_certificate"), &WebSocketClient::get_trusted_ssl_certificate);
ClassDB::bind_method(D_METHOD("set_trusted_ssl_certificate"), &WebSocketClient::set_trusted_ssl_certificate);
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "trusted_ssl_certificate", PROPERTY_HINT_RESOURCE_TYPE, "X509Certificate", 0), "set_trusted_ssl_certificate", "get_trusted_ssl_certificate");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "trusted_ssl_certificate", PROPERTY_HINT_RESOURCE_TYPE, "X509Certificate", PROPERTY_USAGE_NONE), "set_trusted_ssl_certificate", "get_trusted_ssl_certificate");
ADD_SIGNAL(MethodInfo("data_received"));
ADD_SIGNAL(MethodInfo("connection_established", PropertyInfo(Variant::STRING, "protocol")));
diff --git a/modules/websocket/websocket_server.cpp b/modules/websocket/websocket_server.cpp
index 7cf68b835c..9b2d04f14f 100644
--- a/modules/websocket/websocket_server.cpp
+++ b/modules/websocket/websocket_server.cpp
@@ -55,15 +55,19 @@ void WebSocketServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_private_key"), &WebSocketServer::get_private_key);
ClassDB::bind_method(D_METHOD("set_private_key"), &WebSocketServer::set_private_key);
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "private_key", PROPERTY_HINT_RESOURCE_TYPE, "CryptoKey", 0), "set_private_key", "get_private_key");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "private_key", PROPERTY_HINT_RESOURCE_TYPE, "CryptoKey", PROPERTY_USAGE_NONE), "set_private_key", "get_private_key");
ClassDB::bind_method(D_METHOD("get_ssl_certificate"), &WebSocketServer::get_ssl_certificate);
ClassDB::bind_method(D_METHOD("set_ssl_certificate"), &WebSocketServer::set_ssl_certificate);
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "ssl_certificate", PROPERTY_HINT_RESOURCE_TYPE, "X509Certificate", 0), "set_ssl_certificate", "get_ssl_certificate");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "ssl_certificate", PROPERTY_HINT_RESOURCE_TYPE, "X509Certificate", PROPERTY_USAGE_NONE), "set_ssl_certificate", "get_ssl_certificate");
ClassDB::bind_method(D_METHOD("get_ca_chain"), &WebSocketServer::get_ca_chain);
ClassDB::bind_method(D_METHOD("set_ca_chain"), &WebSocketServer::set_ca_chain);
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "ca_chain", PROPERTY_HINT_RESOURCE_TYPE, "X509Certificate", 0), "set_ca_chain", "get_ca_chain");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "ca_chain", PROPERTY_HINT_RESOURCE_TYPE, "X509Certificate", PROPERTY_USAGE_NONE), "set_ca_chain", "get_ca_chain");
+
+ ClassDB::bind_method(D_METHOD("get_handshake_timeout"), &WebSocketServer::get_handshake_timeout);
+ ClassDB::bind_method(D_METHOD("set_handshake_timeout", "timeout"), &WebSocketServer::set_handshake_timeout);
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "handshake_timeout"), "set_handshake_timeout", "get_handshake_timeout");
ADD_SIGNAL(MethodInfo("client_close_request", PropertyInfo(Variant::INT, "id"), PropertyInfo(Variant::INT, "code"), PropertyInfo(Variant::STRING, "reason")));
ADD_SIGNAL(MethodInfo("client_disconnected", PropertyInfo(Variant::INT, "id"), PropertyInfo(Variant::BOOL, "was_clean_close")));
@@ -108,6 +112,15 @@ void WebSocketServer::set_ca_chain(Ref<X509Certificate> p_ca_chain) {
ca_chain = p_ca_chain;
}
+float WebSocketServer::get_handshake_timeout() const {
+ return handshake_timeout / 1000.0;
+}
+
+void WebSocketServer::set_handshake_timeout(float p_timeout) {
+ ERR_FAIL_COND(p_timeout <= 0.0);
+ handshake_timeout = p_timeout * 1000;
+}
+
NetworkedMultiplayerPeer::ConnectionStatus WebSocketServer::get_connection_status() const {
if (is_listening()) {
return CONNECTION_CONNECTED;
diff --git a/modules/websocket/websocket_server.h b/modules/websocket/websocket_server.h
index 10da51fce5..26864f3085 100644
--- a/modules/websocket/websocket_server.h
+++ b/modules/websocket/websocket_server.h
@@ -32,7 +32,7 @@
#define WEBSOCKET_H
#include "core/crypto/crypto.h"
-#include "core/object/reference.h"
+#include "core/object/ref_counted.h"
#include "websocket_multiplayer_peer.h"
#include "websocket_peer.h"
@@ -48,6 +48,7 @@ protected:
Ref<CryptoKey> private_key;
Ref<X509Certificate> ssl_cert;
Ref<X509Certificate> ca_chain;
+ uint32_t handshake_timeout = 3000;
public:
virtual Error listen(int p_port, const Vector<String> p_protocols = Vector<String>(), bool gd_mp_api = false) = 0;
@@ -78,6 +79,9 @@ public:
Ref<X509Certificate> get_ca_chain() const;
void set_ca_chain(Ref<X509Certificate> p_ca_chain);
+ float get_handshake_timeout() const;
+ void set_handshake_timeout(float p_timeout);
+
WebSocketServer();
~WebSocketServer();
};
diff --git a/modules/websocket/wsl_client.cpp b/modules/websocket/wsl_client.cpp
index 111d2178d6..74017fedd7 100644
--- a/modules/websocket/wsl_client.cpp
+++ b/modules/websocket/wsl_client.cpp
@@ -158,6 +158,7 @@ bool WSLClient::_verify_headers(String &r_protocol) {
Error WSLClient::connect_to_host(String p_host, String p_path, uint16_t p_port, bool p_ssl, const Vector<String> p_protocols, const Vector<String> p_custom_headers) {
ERR_FAIL_COND_V(_connection.is_valid(), ERR_ALREADY_IN_USE);
+ ERR_FAIL_COND_V(p_path.is_empty(), ERR_INVALID_PARAMETER);
_peer = Ref<WSLPeer>(memnew(WSLPeer));
IPAddress addr;
@@ -337,8 +338,8 @@ Error WSLClient::set_buffers(int p_in_buffer, int p_in_packets, int p_out_buffer
}
WSLClient::WSLClient() {
- _peer.instance();
- _tcp.instance();
+ _peer.instantiate();
+ _tcp.instantiate();
disconnect_from_host();
}
diff --git a/modules/websocket/wsl_server.cpp b/modules/websocket/wsl_server.cpp
index dc5b23c31e..ccdb6e9292 100644
--- a/modules/websocket/wsl_server.cpp
+++ b/modules/websocket/wsl_server.cpp
@@ -95,8 +95,8 @@ bool WSLServer::PendingPeer::_parse_request(const Vector<String> p_protocols) {
return true;
}
-Error WSLServer::PendingPeer::do_handshake(const Vector<String> p_protocols) {
- if (OS::get_singleton()->get_ticks_msec() - time > WSL_SERVER_TIMEOUT) {
+Error WSLServer::PendingPeer::do_handshake(const Vector<String> p_protocols, uint64_t p_timeout) {
+ if (OS::get_singleton()->get_ticks_msec() - time > p_timeout) {
return ERR_TIMEOUT;
}
if (use_ssl) {
@@ -188,7 +188,7 @@ void WSLServer::poll() {
List<Ref<PendingPeer>> remove_peers;
for (List<Ref<PendingPeer>>::Element *E = _pending.front(); E; E = E->next()) {
Ref<PendingPeer> ppeer = E->get();
- Error err = ppeer->do_handshake(_protocols);
+ Error err = ppeer->do_handshake(_protocols, handshake_timeout);
if (err == ERR_BUSY) {
continue;
} else if (err != OK) {
@@ -301,7 +301,7 @@ Error WSLServer::set_buffers(int p_in_buffer, int p_in_packets, int p_out_buffer
}
WSLServer::WSLServer() {
- _server.instance();
+ _server.instantiate();
}
WSLServer::~WSLServer() {
diff --git a/modules/websocket/wsl_server.h b/modules/websocket/wsl_server.h
index c2cf9df58b..a428c89f4f 100644
--- a/modules/websocket/wsl_server.h
+++ b/modules/websocket/wsl_server.h
@@ -40,13 +40,11 @@
#include "core/io/stream_peer_tcp.h"
#include "core/io/tcp_server.h"
-#define WSL_SERVER_TIMEOUT 1000
-
class WSLServer : public WebSocketServer {
GDCIIMPL(WSLServer, WebSocketServer);
private:
- class PendingPeer : public Reference {
+ class PendingPeer : public RefCounted {
private:
bool _parse_request(const Vector<String> p_protocols);
@@ -64,7 +62,7 @@ private:
CharString response;
int response_sent = 0;
- Error do_handshake(const Vector<String> p_protocols);
+ Error do_handshake(const Vector<String> p_protocols, uint64_t p_timeout);
};
int _in_buf_size = DEF_BUF_SHIFT;
diff --git a/modules/webxr/register_types.cpp b/modules/webxr/register_types.cpp
index 8baf7e05b8..6df0234811 100644
--- a/modules/webxr/register_types.cpp
+++ b/modules/webxr/register_types.cpp
@@ -38,7 +38,7 @@ void register_webxr_types() {
#ifdef JAVASCRIPT_ENABLED
Ref<WebXRInterfaceJS> webxr;
- webxr.instance();
+ webxr.instantiate();
XRServer::get_singleton()->add_interface(webxr);
#endif
}
diff --git a/modules/webxr/webxr_interface_js.cpp b/modules/webxr/webxr_interface_js.cpp
index a628cb0549..2eab0cdb07 100644
--- a/modules/webxr/webxr_interface_js.cpp
+++ b/modules/webxr/webxr_interface_js.cpp
@@ -265,7 +265,7 @@ void WebXRInterfaceJS::uninitialize() {
};
};
-Transform WebXRInterfaceJS::_js_matrix_to_transform(float *p_js_matrix) {
+Transform3D WebXRInterfaceJS::_js_matrix_to_transform(float *p_js_matrix) {
Transform3D transform;
transform.basis.elements[0].x = p_js_matrix[0];
@@ -305,13 +305,30 @@ Size2 WebXRInterfaceJS::get_render_targetsize() {
return render_targetsize;
};
-Transform WebXRInterfaceJS::get_transform_for_eye(XRInterface::Eyes p_eye, const Transform3D &p_cam_transform) {
+Transform3D WebXRInterfaceJS::get_camera_transform() {
Transform3D transform_for_eye;
XRServer *xr_server = XRServer::get_singleton();
ERR_FAIL_NULL_V(xr_server, transform_for_eye);
- float *js_matrix = godot_webxr_get_transform_for_eye(p_eye);
+ float *js_matrix = godot_webxr_get_transform_for_eye(0);
+ if (!initialized || js_matrix == nullptr) {
+ return transform_for_eye;
+ }
+
+ transform_for_eye = _js_matrix_to_transform(js_matrix);
+ free(js_matrix);
+
+ return xr_server->get_reference_frame() * transform_for_eye;
+};
+
+Transform3D WebXRInterfaceJS::get_transform_for_view(uint32_t p_view, const Transform3D &p_cam_transform) {
+ Transform3D transform_for_eye;
+
+ XRServer *xr_server = XRServer::get_singleton();
+ ERR_FAIL_NULL_V(xr_server, transform_for_eye);
+
+ float *js_matrix = godot_webxr_get_transform_for_eye(p_view + 1);
if (!initialized || js_matrix == nullptr) {
transform_for_eye = p_cam_transform;
return transform_for_eye;
@@ -323,10 +340,10 @@ Transform WebXRInterfaceJS::get_transform_for_eye(XRInterface::Eyes p_eye, const
return p_cam_transform * xr_server->get_reference_frame() * transform_for_eye;
};
-CameraMatrix WebXRInterfaceJS::get_projection_for_eye(XRInterface::Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far) {
+CameraMatrix WebXRInterfaceJS::get_projection_for_view(uint32_t p_view, real_t p_aspect, real_t p_z_near, real_t p_z_far) {
CameraMatrix eye;
- float *js_matrix = godot_webxr_get_projection_for_eye(p_eye);
+ float *js_matrix = godot_webxr_get_projection_for_eye(p_view + 1);
if (!initialized || js_matrix == nullptr) {
return eye;
}
@@ -383,7 +400,7 @@ void WebXRInterfaceJS::_update_tracker(int p_controller_id) {
Ref<XRPositionalTracker> tracker = xr_server->find_by_type_and_id(XRServer::TRACKER_CONTROLLER, p_controller_id + 1);
if (godot_webxr_is_controller_connected(p_controller_id)) {
if (tracker.is_null()) {
- tracker.instance();
+ tracker.instantiate();
tracker->set_tracker_type(XRServer::TRACKER_CONTROLLER);
// Controller id's 0 and 1 are always the left and right hands.
if (p_controller_id < 2) {
diff --git a/modules/webxr/webxr_interface_js.h b/modules/webxr/webxr_interface_js.h
index e9274a06e4..723ab952cd 100644
--- a/modules/webxr/webxr_interface_js.h
+++ b/modules/webxr/webxr_interface_js.h
@@ -84,8 +84,9 @@ public:
virtual Size2 get_render_targetsize() override;
virtual bool is_stereo() override;
- virtual Transform get_transform_for_eye(XRInterface::Eyes p_eye, const Transform3D &p_cam_transform) override;
- virtual CameraMatrix get_projection_for_eye(XRInterface::Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far) override;
+ virtual Transform3D get_camera_transform() override;
+ virtual Transform3D get_transform_for_view(uint32_t p_view, const Transform3D &p_cam_transform) override;
+ virtual CameraMatrix get_projection_for_view(uint32_t p_view, real_t p_aspect, real_t p_z_near, real_t p_z_far) override;
virtual unsigned int get_external_texture_for_eye(XRInterface::Eyes p_eye) override;
virtual void commit_for_eye(XRInterface::Eyes p_eye, RID p_render_target, const Rect2 &p_screen_rect) override;