summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/arkit/arkit_interface.h2
-rw-r--r--modules/arkit/arkit_interface.mm4
-rw-r--r--modules/assimp/editor_scene_importer_assimp.cpp105
-rw-r--r--modules/assimp/import_utils.h30
-rw-r--r--modules/basis_universal/SCsub47
-rw-r--r--modules/basis_universal/config.py (renamed from modules/recast/config.py)2
-rw-r--r--modules/basis_universal/register_types.cpp287
-rw-r--r--modules/basis_universal/register_types.h (renamed from modules/recast/register_types.h)4
-rw-r--r--modules/basis_universal/texture_basisu.cpp233
-rw-r--r--modules/basis_universal/texture_basisu.h77
-rw-r--r--modules/bmp/image_loader_bmp.cpp38
-rw-r--r--modules/bullet/area_bullet.cpp8
-rw-r--r--modules/bullet/area_bullet.h3
-rw-r--r--modules/bullet/bullet_physics_server.cpp384
-rw-r--r--modules/bullet/bullet_physics_server.h30
-rw-r--r--modules/bullet/collision_object_bullet.cpp2
-rw-r--r--modules/bullet/cone_twist_joint_bullet.cpp10
-rw-r--r--modules/bullet/generic_6dof_joint_bullet.cpp22
-rw-r--r--modules/bullet/godot_result_callbacks.cpp4
-rw-r--r--modules/bullet/hinge_joint_bullet.cpp15
-rw-r--r--modules/bullet/pin_joint_bullet.cpp5
-rw-r--r--modules/bullet/rid_bullet.h2
-rw-r--r--modules/bullet/rigid_body_bullet.cpp6
-rw-r--r--modules/bullet/shape_bullet.cpp34
-rw-r--r--modules/bullet/shape_bullet.h12
-rw-r--r--modules/bullet/soft_body_bullet.cpp15
-rw-r--r--modules/bullet/soft_body_bullet.h2
-rw-r--r--modules/bullet/space_bullet.cpp37
-rw-r--r--modules/camera/camera_ios.mm6
-rw-r--r--modules/camera/camera_osx.mm10
-rw-r--r--modules/csg/csg.cpp12
-rw-r--r--modules/csg/csg.h4
-rw-r--r--modules/csg/csg_gizmos.cpp4
-rw-r--r--modules/csg/csg_shape.cpp238
-rw-r--r--modules/csg/csg_shape.h22
-rw-r--r--modules/csg/doc_classes/CSGPolygon.xml2
-rw-r--r--modules/cvtt/image_compress_cvtt.cpp29
-rw-r--r--modules/cvtt/image_compress_cvtt.h2
-rw-r--r--modules/dds/texture_loader_dds.cpp16
-rw-r--r--modules/enet/doc_classes/NetworkedMultiplayerENet.xml25
-rw-r--r--modules/enet/networked_multiplayer_enet.cpp136
-rw-r--r--modules/enet/networked_multiplayer_enet.h12
-rw-r--r--modules/etc/image_etc.cpp74
-rw-r--r--modules/etc/texture_loader_pkm.cpp9
-rw-r--r--modules/gdnative/arvr/arvr_interface_gdnative.cpp17
-rw-r--r--modules/gdnative/arvr/arvr_interface_gdnative.h4
-rw-r--r--modules/gdnative/doc_classes/GDNative.xml4
-rw-r--r--modules/gdnative/doc_classes/GDNativeLibrary.xml2
-rw-r--r--modules/gdnative/doc_classes/NativeScript.xml6
-rw-r--r--modules/gdnative/gdnative/array.cpp29
-rw-r--r--modules/gdnative/gdnative/color.cpp5
-rw-r--r--modules/gdnative/gdnative/gdnative.cpp8
-rw-r--r--modules/gdnative/gdnative/pool_arrays.cpp822
-rw-r--r--modules/gdnative/gdnative/string.cpp37
-rw-r--r--modules/gdnative/gdnative/variant.cpp88
-rw-r--r--modules/gdnative/gdnative_api.json1058
-rw-r--r--modules/gdnative/gdnative_library_editor_plugin.cpp16
-rw-r--r--modules/gdnative/gdnative_library_editor_plugin.h2
-rw-r--r--modules/gdnative/gdnative_library_singleton_editor.cpp4
-rw-r--r--modules/gdnative/include/gdnative/array.h14
-rw-r--r--modules/gdnative/include/gdnative/color.h2
-rw-r--r--modules/gdnative/include/gdnative/gdnative.h6
-rw-r--r--modules/gdnative/include/gdnative/pool_arrays.h432
-rw-r--r--modules/gdnative/include/gdnative/string.h6
-rw-r--r--modules/gdnative/include/gdnative/variant.h54
-rw-r--r--modules/gdnative/include/nativescript/godot_nativescript.h2
-rw-r--r--modules/gdnative/include/pluginscript/godot_pluginscript.h17
-rw-r--r--modules/gdnative/include/videodecoder/godot_videodecoder.h2
-rw-r--r--modules/gdnative/nativescript/godot_nativescript.cpp28
-rw-r--r--modules/gdnative/nativescript/nativescript.cpp374
-rw-r--r--modules/gdnative/nativescript/nativescript.h35
-rw-r--r--modules/gdnative/pluginscript/pluginscript_instance.cpp40
-rw-r--r--modules/gdnative/pluginscript/pluginscript_instance.h11
-rw-r--r--modules/gdnative/pluginscript/pluginscript_language.cpp23
-rw-r--r--modules/gdnative/pluginscript/pluginscript_language.h2
-rw-r--r--modules/gdnative/pluginscript/pluginscript_script.cpp129
-rw-r--r--modules/gdnative/pluginscript/pluginscript_script.h21
-rw-r--r--modules/gdnative/register_types.cpp2
-rw-r--r--modules/gdnative/videodecoder/video_stream_gdnative.cpp12
-rw-r--r--modules/gdnative/videodecoder/video_stream_gdnative.h2
-rw-r--r--modules/gdnavigation/SCsub50
-rw-r--r--modules/gdnavigation/config.py5
-rw-r--r--modules/gdnavigation/gd_navigation_server.cpp512
-rw-r--r--modules/gdnavigation/gd_navigation_server.h143
-rw-r--r--modules/gdnavigation/nav_map.cpp806
-rw-r--r--modules/gdnavigation/nav_map.h141
-rw-r--r--modules/gdnavigation/nav_region.cpp136
-rw-r--r--modules/gdnavigation/nav_region.h89
-rw-r--r--modules/gdnavigation/nav_rid.h48
-rw-r--r--modules/gdnavigation/nav_utils.h169
-rw-r--r--modules/gdnavigation/navigation_mesh_editor_plugin.cpp (renamed from modules/recast/navigation_mesh_editor_plugin.cpp)19
-rw-r--r--modules/gdnavigation/navigation_mesh_editor_plugin.h (renamed from modules/recast/navigation_mesh_editor_plugin.h)13
-rw-r--r--modules/gdnavigation/navigation_mesh_generator.cpp (renamed from modules/recast/navigation_mesh_generator.cpp)155
-rw-r--r--modules/gdnavigation/navigation_mesh_generator.h (renamed from modules/recast/navigation_mesh_generator.h)40
-rw-r--r--modules/gdnavigation/register_types.cpp (renamed from modules/recast/register_types.cpp)45
-rw-r--r--modules/gdnavigation/register_types.h36
-rw-r--r--modules/gdnavigation/rvo_agent.cpp84
-rw-r--r--modules/gdnavigation/rvo_agent.h77
-rw-r--r--modules/gdscript/doc_classes/@GDScript.xml13
-rw-r--r--modules/gdscript/doc_classes/GDScript.xml2
-rw-r--r--modules/gdscript/gdscript.cpp233
-rw-r--r--modules/gdscript/gdscript.h35
-rw-r--r--modules/gdscript/gdscript_compiler.cpp4
-rw-r--r--modules/gdscript/gdscript_editor.cpp46
-rw-r--r--modules/gdscript/gdscript_function.cpp155
-rw-r--r--modules/gdscript/gdscript_function.h16
-rw-r--r--modules/gdscript/gdscript_functions.cpp399
-rw-r--r--modules/gdscript/gdscript_functions.h3
-rw-r--r--modules/gdscript/gdscript_parser.cpp144
-rw-r--r--modules/gdscript/gdscript_tokenizer.cpp47
-rw-r--r--modules/gdscript/gdscript_tokenizer.h2
-rw-r--r--modules/gdscript/language_server/gdscript_language_protocol.cpp201
-rw-r--r--modules/gdscript/language_server/gdscript_language_protocol.h40
-rw-r--r--modules/gdscript/language_server/gdscript_text_document.cpp2
-rw-r--r--modules/gdscript/language_server/gdscript_workspace.cpp49
-rw-r--r--modules/gdscript/language_server/gdscript_workspace.h5
-rw-r--r--modules/glslang/SCsub72
-rw-r--r--modules/glslang/config.py5
-rw-r--r--modules/glslang/register_types.cpp246
-rw-r--r--modules/glslang/register_types.h34
-rw-r--r--modules/gridmap/grid_map.cpp55
-rw-r--r--modules/gridmap/grid_map.h2
-rw-r--r--modules/gridmap/grid_map_editor_plugin.cpp84
-rw-r--r--modules/gridmap/grid_map_editor_plugin.h9
-rw-r--r--modules/hdr/image_loader_hdr.cpp6
-rw-r--r--modules/jpg/image_loader_jpegd.cpp13
-rw-r--r--modules/mbedtls/crypto_mbedtls.cpp32
-rw-r--r--modules/mbedtls/crypto_mbedtls.h2
-rw-r--r--modules/mbedtls/dtls_server_mbedtls.cpp78
-rw-r--r--modules/mbedtls/dtls_server_mbedtls.h58
-rwxr-xr-xmodules/mbedtls/packet_peer_mbed_dtls.cpp297
-rwxr-xr-xmodules/mbedtls/packet_peer_mbed_dtls.h88
-rwxr-xr-xmodules/mbedtls/register_types.cpp6
-rw-r--r--modules/mbedtls/ssl_context_mbedtls.cpp61
-rw-r--r--modules/mbedtls/ssl_context_mbedtls.h30
-rwxr-xr-xmodules/mbedtls/stream_peer_mbedtls.cpp13
-rw-r--r--modules/mobile_vr/mobile_vr_interface.cpp22
-rw-r--r--modules/mono/build_scripts/make_android_mono_config.py6
-rw-r--r--modules/mono/csharp_script.cpp265
-rw-r--r--modules/mono/csharp_script.h38
-rw-r--r--modules/mono/doc_classes/@C#.xml2
-rw-r--r--modules/mono/doc_classes/CSharpScript.xml4
-rw-r--r--modules/mono/doc_classes/GodotSharp.xml2
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/BottomPanel.cs2
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/BuildTab.cs2
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/Internals/Internal.cs4
-rw-r--r--modules/mono/editor/bindings_generator.cpp54
-rw-r--r--modules/mono/editor/editor_internal_calls.cpp14
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/RPCAttributes.cs6
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Basis.cs64
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Mathf.cs6
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Quat.cs27
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs7
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Transform.cs70
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Transform2D.cs46
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs13
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs15
-rw-r--r--modules/mono/glue/base_object_glue.cpp11
-rw-r--r--modules/mono/glue/gd_glue.cpp20
-rw-r--r--modules/mono/mono_gd/gd_mono_cache.cpp4
-rw-r--r--modules/mono/mono_gd/gd_mono_cache.h6
-rw-r--r--modules/mono/mono_gd/gd_mono_field.cpp44
-rw-r--r--modules/mono/mono_gd/gd_mono_internals.cpp2
-rw-r--r--modules/mono/mono_gd/gd_mono_marshal.cpp146
-rw-r--r--modules/mono/mono_gd/gd_mono_marshal.h42
-rw-r--r--modules/mono/mono_gd/gd_mono_utils.cpp2
-rw-r--r--modules/mono/signal_awaiter_utils.cpp17
-rw-r--r--modules/mono/signal_awaiter_utils.h2
-rw-r--r--modules/mono/utils/string_utils.cpp8
-rw-r--r--modules/opensimplex/doc_classes/NoiseTexture.xml5
-rw-r--r--modules/opensimplex/noise_texture.cpp32
-rw-r--r--modules/opensimplex/noise_texture.h11
-rw-r--r--modules/opensimplex/open_simplex_noise.cpp14
-rw-r--r--modules/pvr/texture_loader_pvr.cpp36
-rw-r--r--modules/recast/SCsub33
-rw-r--r--modules/register_module_types.h1
-rw-r--r--modules/squish/image_compress_squish.cpp77
-rw-r--r--modules/squish/image_compress_squish.h2
-rw-r--r--modules/stb_vorbis/audio_stream_ogg_vorbis.cpp30
-rw-r--r--modules/stb_vorbis/audio_stream_ogg_vorbis.h4
-rw-r--r--modules/stb_vorbis/doc_classes/AudioStreamOGGVorbis.xml2
-rw-r--r--modules/stb_vorbis/resource_importer_ogg_vorbis.cpp8
-rw-r--r--modules/svg/image_loader_svg.cpp27
-rw-r--r--modules/svg/image_loader_svg.h2
-rw-r--r--modules/tga/image_loader_tga.cpp42
-rw-r--r--modules/theora/video_stream_theora.cpp12
-rw-r--r--modules/theora/video_stream_theora.h4
-rw-r--r--modules/tinyexr/image_loader_tinyexr.cpp18
-rw-r--r--modules/tinyexr/image_saver_tinyexr.cpp39
-rw-r--r--modules/visual_script/doc_classes/VisualScript.xml90
-rw-r--r--modules/visual_script/doc_classes/VisualScriptBasicTypeConstant.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptBuiltinFunc.xml6
-rw-r--r--modules/visual_script/doc_classes/VisualScriptClassConstant.xml4
-rw-r--r--modules/visual_script/doc_classes/VisualScriptEmitSignal.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptFunctionCall.xml6
-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.xml6
-rw-r--r--modules/visual_script/doc_classes/VisualScriptPropertySet.xml6
-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.cpp219
-rw-r--r--modules/visual_script/visual_script.h35
-rw-r--r--modules/visual_script/visual_script_builtin_funcs.cpp182
-rw-r--r--modules/visual_script/visual_script_builtin_funcs.h4
-rw-r--r--modules/visual_script/visual_script_editor.cpp218
-rw-r--r--modules/visual_script/visual_script_editor.h8
-rw-r--r--modules/visual_script/visual_script_expression.cpp28
-rw-r--r--modules/visual_script/visual_script_flow_control.cpp26
-rw-r--r--modules/visual_script/visual_script_func_nodes.cpp50
-rw-r--r--modules/visual_script/visual_script_nodes.cpp123
-rw-r--r--modules/visual_script/visual_script_property_selector.cpp44
-rw-r--r--modules/visual_script/visual_script_yield_nodes.cpp14
-rw-r--r--modules/webm/video_stream_webm.cpp19
-rw-r--r--modules/webm/video_stream_webm.h4
-rw-r--r--modules/webp/image_loader_webp.cpp49
-rw-r--r--modules/websocket/doc_classes/WebSocketClient.xml4
-rw-r--r--modules/websocket/doc_classes/WebSocketServer.xml2
-rw-r--r--modules/websocket/emws_client.cpp22
-rw-r--r--modules/websocket/emws_peer.cpp17
-rw-r--r--modules/websocket/emws_peer.h2
-rw-r--r--modules/websocket/emws_server.cpp4
-rw-r--r--modules/websocket/emws_server.h2
-rw-r--r--modules/websocket/websocket_multiplayer_peer.cpp16
-rw-r--r--modules/websocket/websocket_multiplayer_peer.h2
-rw-r--r--modules/websocket/wsl_peer.cpp10
-rw-r--r--modules/websocket/wsl_peer.h2
230 files changed, 8524 insertions, 4584 deletions
diff --git a/modules/arkit/arkit_interface.h b/modules/arkit/arkit_interface.h
index cb18350409..4f8f726816 100644
--- a/modules/arkit/arkit_interface.h
+++ b/modules/arkit/arkit_interface.h
@@ -62,7 +62,7 @@ private:
Ref<CameraFeed> feed;
int image_width[2];
int image_height[2];
- PoolVector<uint8_t> img_data[2];
+ Vector<uint8_t> img_data[2];
struct anchor_map {
ARVRPositionalTracker *tracker;
diff --git a/modules/arkit/arkit_interface.mm b/modules/arkit/arkit_interface.mm
index 1896a34e46..39447e8dab 100644
--- a/modules/arkit/arkit_interface.mm
+++ b/modules/arkit/arkit_interface.mm
@@ -488,7 +488,7 @@ void ARKitInterface::process() {
img_data[0].resize(new_width * new_height);
}
- PoolVector<uint8_t>::Write w = img_data[0].write();
+ uint8_t *w = img_data[0].write();
if (new_width == bytes_per_row) {
memcpy(w.ptr(), dataY, new_width * new_height);
} else {
@@ -519,7 +519,7 @@ void ARKitInterface::process() {
img_data[1].resize(2 * new_width * new_height);
}
- PoolVector<uint8_t>::Write w = img_data[1].write();
+ uint8_t *w = img_data[1].write();
if ((2 * new_width) == bytes_per_row) {
memcpy(w.ptr(), dataCbCr, 2 * new_width * new_height);
} else {
diff --git a/modules/assimp/editor_scene_importer_assimp.cpp b/modules/assimp/editor_scene_importer_assimp.cpp
index 69ab068648..1881d0db33 100644
--- a/modules/assimp/editor_scene_importer_assimp.cpp
+++ b/modules/assimp/editor_scene_importer_assimp.cpp
@@ -167,8 +167,7 @@ struct EditorSceneImporterAssetImportInterpolate {
float t2 = t * t;
float t3 = t2 * t;
- return 0.5f * ((2.0f * p1) + (-p0 + p2) * t + (2.0f * p0 - 5.0f * p1 + 4 * p2 - p3) * t2 +
- (-p0 + 3.0f * p1 - 3.0f * p2 + p3) * t3);
+ return 0.5f * ((2.0f * p1) + (-p0 + p2) * t + (2.0f * p0 - 5.0f * p1 + 4.0f * p2 - p3) * t2 + (-p0 + 3.0f * p1 - 3.0f * p2 + p3) * t3);
}
T bezier(T start, T control_1, T control_2, T end, float t) {
@@ -995,15 +994,15 @@ EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &stat
}
aiMaterial *ai_material = state.assimp_scene->mMaterials[ai_mesh->mMaterialIndex];
- Ref<SpatialMaterial> mat;
+ Ref<StandardMaterial3D> mat;
mat.instance();
int32_t mat_two_sided = 0;
if (AI_SUCCESS == ai_material->Get(AI_MATKEY_TWOSIDED, mat_two_sided)) {
if (mat_two_sided > 0) {
- mat->set_cull_mode(SpatialMaterial::CULL_DISABLED);
+ mat->set_cull_mode(StandardMaterial3D::CULL_DISABLED);
} else {
- mat->set_cull_mode(SpatialMaterial::CULL_BACK);
+ mat->set_cull_mode(StandardMaterial3D::CULL_BACK);
}
}
@@ -1015,7 +1014,7 @@ EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &stat
// Culling handling for meshes
// cull all back faces
- mat->set_cull_mode(SpatialMaterial::CULL_DISABLED);
+ mat->set_cull_mode(StandardMaterial3D::CULL_DISABLED);
// Now process materials
aiTextureType base_color = aiTextureType_BASE_COLOR;
@@ -1028,13 +1027,11 @@ EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &stat
// anything transparent must be culled
if (image_data.raw_image->detect_alpha() != Image::ALPHA_NONE) {
- mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
- mat->set_depth_draw_mode(SpatialMaterial::DepthDrawMode::DEPTH_DRAW_ALPHA_OPAQUE_PREPASS);
- mat->set_cull_mode(
- SpatialMaterial::CULL_DISABLED); // since you can see both sides in transparent mode
+ mat->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA_DEPTH_PRE_PASS);
+ mat->set_cull_mode(StandardMaterial3D::CULL_DISABLED); // since you can see both sides in transparent mode
}
- mat->set_texture(SpatialMaterial::TEXTURE_ALBEDO, image_data.texture);
+ mat->set_texture(StandardMaterial3D::TEXTURE_ALBEDO, image_data.texture);
}
}
@@ -1048,22 +1045,18 @@ EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &stat
// anything transparent must be culled
if (image_data.raw_image->detect_alpha() != Image::ALPHA_NONE) {
- mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
- mat->set_depth_draw_mode(SpatialMaterial::DepthDrawMode::DEPTH_DRAW_ALPHA_OPAQUE_PREPASS);
- mat->set_cull_mode(
- SpatialMaterial::CULL_DISABLED); // since you can see both sides in transparent mode
+ mat->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA_DEPTH_PRE_PASS);
+ mat->set_cull_mode(StandardMaterial3D::CULL_DISABLED); // since you can see both sides in transparent mode
}
- mat->set_texture(SpatialMaterial::TEXTURE_ALBEDO, image_data.texture);
+ mat->set_texture(StandardMaterial3D::TEXTURE_ALBEDO, image_data.texture);
}
aiColor4D clr_diffuse;
if (AI_SUCCESS == ai_material->Get(AI_MATKEY_COLOR_DIFFUSE, clr_diffuse)) {
if (Math::is_equal_approx(clr_diffuse.a, 1.0f) == false) {
- mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
- mat->set_depth_draw_mode(SpatialMaterial::DepthDrawMode::DEPTH_DRAW_ALPHA_OPAQUE_PREPASS);
- mat->set_cull_mode(
- SpatialMaterial::CULL_DISABLED); // since you can see both sides in transparent mode
+ mat->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA_DEPTH_PRE_PASS);
+ mat->set_cull_mode(StandardMaterial3D::CULL_DISABLED); // since you can see both sides in transparent mode
}
mat->set_albedo(Color(clr_diffuse.r, clr_diffuse.g, clr_diffuse.b, clr_diffuse.a));
}
@@ -1078,14 +1071,14 @@ EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &stat
// Process texture normal map
if (AssimpUtils::GetAssimpTexture(state, ai_material, tex_normal, filename, path, image_data)) {
AssimpUtils::set_texture_mapping_mode(image_data.map_mode, image_data.texture);
- mat->set_feature(SpatialMaterial::Feature::FEATURE_NORMAL_MAPPING, true);
- mat->set_texture(SpatialMaterial::TEXTURE_NORMAL, image_data.texture);
+ mat->set_feature(StandardMaterial3D::Feature::FEATURE_NORMAL_MAPPING, true);
+ mat->set_texture(StandardMaterial3D::TEXTURE_NORMAL, image_data.texture);
} else {
aiString texture_path;
if (AI_SUCCESS == ai_material->Get(AI_MATKEY_FBX_NORMAL_TEXTURE, AI_PROPERTIES, texture_path)) {
if (AssimpUtils::CreateAssimpTexture(state, texture_path, filename, path, image_data)) {
- mat->set_feature(SpatialMaterial::Feature::FEATURE_NORMAL_MAPPING, true);
- mat->set_texture(SpatialMaterial::TEXTURE_NORMAL, image_data.texture);
+ mat->set_feature(StandardMaterial3D::Feature::FEATURE_NORMAL_MAPPING, true);
+ mat->set_texture(StandardMaterial3D::TEXTURE_NORMAL, image_data.texture);
}
}
}
@@ -1100,8 +1093,8 @@ EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &stat
// Process texture normal map
if (AssimpUtils::GetAssimpTexture(state, ai_material, tex_normal_camera, filename, path, image_data)) {
AssimpUtils::set_texture_mapping_mode(image_data.map_mode, image_data.texture);
- mat->set_feature(SpatialMaterial::Feature::FEATURE_NORMAL_MAPPING, true);
- mat->set_texture(SpatialMaterial::TEXTURE_NORMAL, image_data.texture);
+ mat->set_feature(StandardMaterial3D::Feature::FEATURE_NORMAL_MAPPING, true);
+ mat->set_texture(StandardMaterial3D::TEXTURE_NORMAL, image_data.texture);
}
}
@@ -1114,8 +1107,8 @@ EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &stat
// Process texture normal map
if (AssimpUtils::GetAssimpTexture(state, ai_material, tex_emission_color, filename, path, image_data)) {
AssimpUtils::set_texture_mapping_mode(image_data.map_mode, image_data.texture);
- mat->set_feature(SpatialMaterial::Feature::FEATURE_NORMAL_MAPPING, true);
- mat->set_texture(SpatialMaterial::TEXTURE_NORMAL, image_data.texture);
+ mat->set_feature(StandardMaterial3D::Feature::FEATURE_NORMAL_MAPPING, true);
+ mat->set_texture(StandardMaterial3D::TEXTURE_NORMAL, image_data.texture);
}
}
@@ -1128,7 +1121,7 @@ EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &stat
// Process texture normal map
if (AssimpUtils::GetAssimpTexture(state, ai_material, tex_metalness, filename, path, image_data)) {
AssimpUtils::set_texture_mapping_mode(image_data.map_mode, image_data.texture);
- mat->set_texture(SpatialMaterial::TEXTURE_METALLIC, image_data.texture);
+ mat->set_texture(StandardMaterial3D::TEXTURE_METALLIC, image_data.texture);
}
}
@@ -1141,7 +1134,7 @@ EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &stat
// Process texture normal map
if (AssimpUtils::GetAssimpTexture(state, ai_material, tex_roughness, filename, path, image_data)) {
AssimpUtils::set_texture_mapping_mode(image_data.map_mode, image_data.texture);
- mat->set_texture(SpatialMaterial::TEXTURE_ROUGHNESS, image_data.texture);
+ mat->set_texture(StandardMaterial3D::TEXTURE_ROUGHNESS, image_data.texture);
}
}
@@ -1154,16 +1147,16 @@ EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &stat
if (AssimpUtils::GetAssimpTexture(state, ai_material, tex_emissive, filename, path, image_data)) {
AssimpUtils::set_texture_mapping_mode(image_data.map_mode, image_data.texture);
- mat->set_feature(SpatialMaterial::FEATURE_EMISSION, true);
- mat->set_texture(SpatialMaterial::TEXTURE_EMISSION, image_data.texture);
+ mat->set_feature(StandardMaterial3D::FEATURE_EMISSION, true);
+ mat->set_texture(StandardMaterial3D::TEXTURE_EMISSION, image_data.texture);
} else {
// Process emission textures
aiString texture_emissive_path;
if (AI_SUCCESS ==
ai_material->Get(AI_MATKEY_FBX_MAYA_EMISSION_TEXTURE, AI_PROPERTIES, texture_emissive_path)) {
if (AssimpUtils::CreateAssimpTexture(state, texture_emissive_path, filename, path, image_data)) {
- mat->set_feature(SpatialMaterial::FEATURE_EMISSION, true);
- mat->set_texture(SpatialMaterial::TEXTURE_EMISSION, image_data.texture);
+ mat->set_feature(StandardMaterial3D::FEATURE_EMISSION, true);
+ mat->set_texture(StandardMaterial3D::TEXTURE_EMISSION, image_data.texture);
}
} else {
float pbr_emission = 0.0f;
@@ -1183,7 +1176,7 @@ EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &stat
// Process texture normal map
if (AssimpUtils::GetAssimpTexture(state, ai_material, tex_specular, filename, path, image_data)) {
AssimpUtils::set_texture_mapping_mode(image_data.map_mode, image_data.texture);
- mat->set_texture(SpatialMaterial::TEXTURE_METALLIC, image_data.texture);
+ mat->set_texture(StandardMaterial3D::TEXTURE_METALLIC, image_data.texture);
}
}
@@ -1196,8 +1189,8 @@ EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &stat
// Process texture normal map
if (AssimpUtils::GetAssimpTexture(state, ai_material, tex_ao_map, filename, path, image_data)) {
AssimpUtils::set_texture_mapping_mode(image_data.map_mode, image_data.texture);
- mat->set_feature(SpatialMaterial::FEATURE_AMBIENT_OCCLUSION, true);
- mat->set_texture(SpatialMaterial::TEXTURE_AMBIENT_OCCLUSION, image_data.texture);
+ mat->set_feature(StandardMaterial3D::FEATURE_AMBIENT_OCCLUSION, true);
+ mat->set_texture(StandardMaterial3D::TEXTURE_AMBIENT_OCCLUSION, image_data.texture);
}
}
@@ -1224,17 +1217,17 @@ EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &stat
const size_t num_vertices = ai_mesh->mAnimMeshes[j]->mNumVertices;
array_copy[Mesh::ARRAY_INDEX] = Variant();
if (ai_mesh->mAnimMeshes[j]->HasPositions()) {
- PoolVector3Array vertices;
+ PackedVector3Array vertices;
vertices.resize(num_vertices);
for (size_t l = 0; l < num_vertices; l++) {
const aiVector3D ai_pos = ai_mesh->mAnimMeshes[j]->mVertices[l];
Vector3 position = Vector3(ai_pos.x, ai_pos.y, ai_pos.z);
- vertices.write()[l] = position;
+ vertices.ptrw()[l] = position;
}
- PoolVector3Array new_vertices = array_copy[VisualServer::ARRAY_VERTEX].duplicate(true);
+ PackedVector3Array new_vertices = array_copy[VisualServer::ARRAY_VERTEX].duplicate(true);
ERR_CONTINUE(vertices.size() != new_vertices.size());
for (int32_t l = 0; l < new_vertices.size(); l++) {
- PoolVector3Array::Write w = new_vertices.write();
+ Vector3 *w = new_vertices.ptrw();
w[l] = vertices[l];
}
array_copy[VisualServer::ARRAY_VERTEX] = new_vertices;
@@ -1242,53 +1235,53 @@ EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &stat
int32_t color_set = 0;
if (ai_mesh->mAnimMeshes[j]->HasVertexColors(color_set)) {
- PoolColorArray colors;
+ PackedColorArray colors;
colors.resize(num_vertices);
for (size_t l = 0; l < num_vertices; l++) {
const aiColor4D ai_color = ai_mesh->mAnimMeshes[j]->mColors[color_set][l];
Color color = Color(ai_color.r, ai_color.g, ai_color.b, ai_color.a);
- colors.write()[l] = color;
+ colors.ptrw()[l] = color;
}
- PoolColorArray new_colors = array_copy[VisualServer::ARRAY_COLOR].duplicate(true);
+ PackedColorArray new_colors = array_copy[VisualServer::ARRAY_COLOR].duplicate(true);
ERR_CONTINUE(colors.size() != new_colors.size());
for (int32_t l = 0; l < colors.size(); l++) {
- PoolColorArray::Write w = new_colors.write();
+ Color *w = new_colors.ptrw();
w[l] = colors[l];
}
array_copy[VisualServer::ARRAY_COLOR] = new_colors;
}
if (ai_mesh->mAnimMeshes[j]->HasNormals()) {
- PoolVector3Array normals;
+ PackedVector3Array normals;
normals.resize(num_vertices);
for (size_t l = 0; l < num_vertices; l++) {
const aiVector3D ai_normal = ai_mesh->mAnimMeshes[j]->mNormals[l];
Vector3 normal = Vector3(ai_normal.x, ai_normal.y, ai_normal.z);
- normals.write()[l] = normal;
+ normals.ptrw()[l] = normal;
}
- PoolVector3Array new_normals = array_copy[VisualServer::ARRAY_NORMAL].duplicate(true);
+ PackedVector3Array new_normals = array_copy[VisualServer::ARRAY_NORMAL].duplicate(true);
ERR_CONTINUE(normals.size() != new_normals.size());
for (int l = 0; l < normals.size(); l++) {
- PoolVector3Array::Write w = new_normals.write();
+ Vector3 *w = new_normals.ptrw();
w[l] = normals[l];
}
array_copy[VisualServer::ARRAY_NORMAL] = new_normals;
}
if (ai_mesh->mAnimMeshes[j]->HasTangentsAndBitangents()) {
- PoolColorArray tangents;
+ PackedColorArray tangents;
tangents.resize(num_vertices);
- PoolColorArray::Write w = tangents.write();
+ Color *w = tangents.ptrw();
for (size_t l = 0; l < num_vertices; l++) {
AssimpUtils::calc_tangent_from_mesh(ai_mesh, j, l, l, w);
}
- PoolRealArray new_tangents = array_copy[VisualServer::ARRAY_TANGENT].duplicate(true);
+ PackedFloat32Array new_tangents = array_copy[VisualServer::ARRAY_TANGENT].duplicate(true);
ERR_CONTINUE(new_tangents.size() != tangents.size() * 4);
for (int32_t l = 0; l < tangents.size(); l++) {
- new_tangents.write()[l + 0] = tangents[l].r;
- new_tangents.write()[l + 1] = tangents[l].g;
- new_tangents.write()[l + 2] = tangents[l].b;
- new_tangents.write()[l + 3] = tangents[l].a;
+ new_tangents.ptrw()[l + 0] = tangents[l].r;
+ new_tangents.ptrw()[l + 1] = tangents[l].g;
+ new_tangents.ptrw()[l + 2] = tangents[l].b;
+ new_tangents.ptrw()[l + 3] = tangents[l].a;
}
array_copy[VisualServer::ARRAY_TANGENT] = new_tangents;
}
diff --git a/modules/assimp/import_utils.h b/modules/assimp/import_utils.h
index c522b01727..80b67b5453 100644
--- a/modules/assimp/import_utils.h
+++ b/modules/assimp/import_utils.h
@@ -98,7 +98,7 @@ public:
/**
* calculate tangents for mesh data from assimp data
*/
- static void calc_tangent_from_mesh(const aiMesh *ai_mesh, int i, int tri_index, int index, PoolColorArray::Write &w) {
+ static void calc_tangent_from_mesh(const aiMesh *ai_mesh, int i, int tri_index, int index, Color *w) {
const aiVector3D normals = ai_mesh->mAnimMeshes[i]->mNormals[tri_index];
const Vector3 godot_normal = Vector3(normals.x, normals.y, normals.z);
const aiVector3D tangent = ai_mesh->mAnimMeshes[i]->mTangents[tri_index];
@@ -189,7 +189,7 @@ public:
}
/**
- * Converts aiMatrix4x4 to godot Transform
+ * Converts aiMatrix4x4 to godot Transform
*/
static const Transform assimp_matrix_transform(const aiMatrix4x4 p_matrix) {
aiMatrix4x4 matrix = p_matrix;
@@ -320,17 +320,20 @@ public:
static void set_texture_mapping_mode(aiTextureMapMode *map_mode, Ref<ImageTexture> texture) {
ERR_FAIL_COND(texture.is_null());
ERR_FAIL_COND(map_mode == NULL);
+ // FIXME: Commented out during Vulkan port.
+ /*
aiTextureMapMode tex_mode = map_mode[0];
- int32_t flags = Texture::FLAGS_DEFAULT;
+ int32_t flags = Texture2D::FLAGS_DEFAULT;
if (tex_mode == aiTextureMapMode_Wrap) {
//Default
} else if (tex_mode == aiTextureMapMode_Clamp) {
- flags = flags & ~Texture::FLAG_REPEAT;
+ flags = flags & ~Texture2D::FLAG_REPEAT;
} else if (tex_mode == aiTextureMapMode_Mirror) {
- flags = flags | Texture::FLAG_MIRRORED_REPEAT;
+ flags = flags | Texture2D::FLAG_MIRRORED_REPEAT;
}
texture->set_flags(flags);
+ */
}
/**
@@ -372,17 +375,17 @@ public:
} else {
Ref<Image> img;
img.instance();
- PoolByteArray arr;
+ PackedByteArray arr;
uint32_t size = tex->mWidth * tex->mHeight;
arr.resize(size);
- memcpy(arr.write().ptr(), tex->pcData, size);
+ memcpy(arr.ptrw(), tex->pcData, size);
ERR_FAIL_COND_V(arr.size() % 4 != 0, Ref<Image>());
//ARGB8888 to RGBA8888
for (int32_t i = 0; i < arr.size() / 4; i++) {
- arr.write().ptr()[(4 * i) + 3] = arr[(4 * i) + 0];
- arr.write().ptr()[(4 * i) + 0] = arr[(4 * i) + 1];
- arr.write().ptr()[(4 * i) + 1] = arr[(4 * i) + 2];
- arr.write().ptr()[(4 * i) + 2] = arr[(4 * i) + 3];
+ arr.ptrw()[(4 * i) + 3] = arr[(4 * i) + 0];
+ arr.ptrw()[(4 * i) + 0] = arr[(4 * i) + 1];
+ arr.ptrw()[(4 * i) + 1] = arr[(4 * i) + 2];
+ arr.ptrw()[(4 * i) + 2] = arr[(4 * i) + 3];
}
img->create(tex->mWidth, tex->mHeight, true, Image::FORMAT_RGBA8, arr);
ERR_FAIL_COND_V(img.is_null(), Ref<Image>());
@@ -391,7 +394,7 @@ public:
}
return Ref<Image>();
} else {
- Ref<Texture> texture = ResourceLoader::load(p_path);
+ Ref<Texture2D> texture = ResourceLoader::load(p_path);
ERR_FAIL_COND_V(texture.is_null(), Ref<Image>());
Ref<Image> image = texture->get_data();
ERR_FAIL_COND_V(image.is_null(), Ref<Image>());
@@ -418,7 +421,8 @@ public:
if (image_state.raw_image.is_valid()) {
image_state.texture.instance();
image_state.texture->create_from_image(image_state.raw_image);
- image_state.texture->set_storage(ImageTexture::STORAGE_COMPRESS_LOSSY);
+ // FIXME: Commented out during Vulkan port.
+ //image_state.texture->set_storage(ImageTexture::STORAGE_COMPRESS_LOSSY);
return true;
}
}
diff --git a/modules/basis_universal/SCsub b/modules/basis_universal/SCsub
new file mode 100644
index 0000000000..d7342358d7
--- /dev/null
+++ b/modules/basis_universal/SCsub
@@ -0,0 +1,47 @@
+#!/usr/bin/env python
+
+Import('env')
+Import('env_modules')
+
+env_basisu = env_modules.Clone()
+
+# Thirdparty source files
+# Not unbundled so far since not widespread as shared library
+thirdparty_dir = "#thirdparty/basis_universal/"
+tool_sources = [
+ "basisu_astc_decomp.cpp",
+ "basisu_backend.cpp",
+ "basisu_basis_file.cpp",
+ "basisu_comp.cpp",
+ "basisu_enc.cpp",
+ "basisu_etc.cpp",
+ "basisu_frontend.cpp",
+ "basisu_global_selector_palette_helpers.cpp",
+ "basisu_gpu_texture.cpp",
+ "basisu_pvrtc1_4.cpp",
+ "basisu_resample_filters.cpp",
+ "basisu_resampler.cpp",
+ "basisu_ssim.cpp",
+ "basisu_tool.cpp",
+ "lodepng.cpp",
+]
+tool_sources = [thirdparty_dir + file for file in tool_sources]
+transcoder_sources = [thirdparty_dir + "transcoder/basisu_transcoder.cpp"]
+
+# Treat Basis headers as system headers to avoid raising warnings. Not supported on MSVC.
+if not env.msvc:
+ env_basisu.Append(CPPFLAGS=['-isystem', Dir(thirdparty_dir).path, '-isystem', Dir(thirdparty_dir + "transcoder").path])
+else:
+ env_basisu.Prepend(CPPPATH=[thirdparty_dir, thirdparty_dir + "transcoder"])
+
+if env['target'] == "debug":
+ env_basisu.Append(CPPFLAGS=["-DBASISU_DEVEL_MESSAGES=1", "-DBASISD_ENABLE_DEBUG_FLAGS=1"])
+
+env_thirdparty = env_basisu.Clone()
+env_thirdparty.disable_warnings()
+if env['tools']:
+ env_thirdparty.add_source_files(env.modules_sources, tool_sources)
+env_thirdparty.add_source_files(env.modules_sources, transcoder_sources)
+
+# Godot source files
+env_basisu.add_source_files(env.modules_sources, "*.cpp")
diff --git a/modules/recast/config.py b/modules/basis_universal/config.py
index 098f1eafa9..1c8cd12a2d 100644
--- a/modules/recast/config.py
+++ b/modules/basis_universal/config.py
@@ -1,5 +1,5 @@
def can_build(env, platform):
- return env['tools']
+ return True
def configure(env):
pass
diff --git a/modules/basis_universal/register_types.cpp b/modules/basis_universal/register_types.cpp
new file mode 100644
index 0000000000..062b5b59f8
--- /dev/null
+++ b/modules/basis_universal/register_types.cpp
@@ -0,0 +1,287 @@
+/*************************************************************************/
+/* register_types.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#include "register_types.h"
+
+#include "core/os/os.h"
+#include "servers/visual_server.h"
+#include "texture_basisu.h"
+
+#ifdef TOOLS_ENABLED
+#include <basisu_comp.h>
+#endif
+
+#include <transcoder/basisu_transcoder.h>
+
+enum BasisDecompressFormat {
+ BASIS_DECOMPRESS_RG,
+ BASIS_DECOMPRESS_RGB,
+ BASIS_DECOMPRESS_RGBA,
+ BASIS_DECOMPRESS_RG_AS_RA
+};
+
+//workaround for lack of ETC2 RG
+#define USE_RG_AS_RGBA
+
+basist::etc1_global_selector_codebook *sel_codebook = nullptr;
+
+#ifdef TOOLS_ENABLED
+static Vector<uint8_t> basis_universal_packer(const Ref<Image> &p_image, Image::UsedChannels p_channels) {
+
+ Vector<uint8_t> budata;
+
+ {
+ Ref<Image> image = p_image->duplicate();
+
+ // unfortunately, basis universal does not support compressing supplied mipmaps,
+ // so for the time being, only compressing individual images will have to do.
+
+ if (image->has_mipmaps()) {
+ image->clear_mipmaps();
+ }
+ if (image->get_format() != Image::FORMAT_RGBA8) {
+ image->convert(Image::FORMAT_RGBA8);
+ }
+
+ basisu::image buimg(image->get_width(), image->get_height());
+
+ {
+ Vector<uint8_t> vec = image->get_data();
+ const uint8_t *r = vec.ptr();
+
+ memcpy(buimg.get_ptr(), r, vec.size());
+ }
+
+ //image->save_png("pepeche.png");
+
+ basisu::basis_compressor_params params;
+ params.m_max_endpoint_clusters = 512;
+ params.m_max_selector_clusters = 512;
+ params.m_multithreading = true;
+ //params.m_no_hybrid_sel_cb = true; //fixme, default on this causes crashes //seems fixed?
+ params.m_pSel_codebook = sel_codebook;
+ //params.m_quality_level = 0;
+ //params.m_disable_hierarchical_endpoint_codebooks = true;
+ //params.m_no_selector_rdo = true;
+ params.m_auto_global_sel_pal = false;
+
+ basisu::job_pool jpool(OS::get_singleton()->get_processor_count());
+ params.m_pJob_pool = &jpool;
+
+ params.m_mip_gen = false; //sorry, please some day support provided mipmaps.
+ params.m_source_images.push_back(buimg);
+
+ BasisDecompressFormat decompress_format;
+ params.m_check_for_alpha = false;
+
+ switch (p_channels) {
+ case Image::USED_CHANNELS_L: {
+ decompress_format = BASIS_DECOMPRESS_RGB;
+ } break;
+ case Image::USED_CHANNELS_LA: {
+ params.m_force_alpha = true;
+ decompress_format = BASIS_DECOMPRESS_RGBA;
+ } break;
+ case Image::USED_CHANNELS_R: {
+ decompress_format = BASIS_DECOMPRESS_RGB;
+ } break;
+ case Image::USED_CHANNELS_RG: {
+#ifdef USE_RG_AS_RGBA
+ image->convert_rg_to_ra_rgba8();
+ decompress_format = BASIS_DECOMPRESS_RG_AS_RA;
+#else
+ params.m_seperate_rg_to_color_alpha = true;
+ decompress_format = BASIS_DECOMPRESS_RG;
+#endif
+ } break;
+ case Image::USED_CHANNELS_RGB: {
+ decompress_format = BASIS_DECOMPRESS_RGB;
+ } break;
+ case Image::USED_CHANNELS_RGBA: {
+ params.m_force_alpha = true;
+ decompress_format = BASIS_DECOMPRESS_RGBA;
+ } break;
+ }
+
+ basisu::basis_compressor c;
+ c.init(params);
+
+ int buerr = c.process();
+ ERR_FAIL_COND_V(buerr != basisu::basis_compressor::cECSuccess, budata);
+
+ const basisu::uint8_vec &buvec = c.get_output_basis_file();
+ budata.resize(buvec.size() + 4);
+
+ {
+ uint8_t *w = budata.ptrw();
+ uint32_t *decf = (uint32_t *)w;
+ *decf = decompress_format;
+ memcpy(w + 4, &buvec[0], buvec.size());
+ }
+ }
+
+ return budata;
+}
+#endif // TOOLS_ENABLED
+
+static Ref<Image> basis_universal_unpacker(const Vector<uint8_t> &p_buffer) {
+ Ref<Image> image;
+
+ const uint8_t *r = p_buffer.ptr();
+ const uint8_t *ptr = r;
+ int size = p_buffer.size();
+
+ basist::transcoder_texture_format format;
+ Image::Format imgfmt;
+
+ switch (*(uint32_t *)(ptr)) {
+ case BASIS_DECOMPRESS_RG: {
+
+ if (VS::get_singleton()->has_os_feature("rgtc")) {
+ format = basist::transcoder_texture_format::cTFBC5; // get this from renderer
+ imgfmt = Image::FORMAT_RGTC_RG;
+ } else if (VS::get_singleton()->has_os_feature("etc2")) {
+ //unfortunately, basis universal does not support
+ //
+ ERR_FAIL_V(image); //unimplemented here
+ //format = basist::transcoder_texture_format::cTFETC1; // get this from renderer
+ //imgfmt = Image::FORMAT_RGTC_RG;
+ } else {
+ //decompress
+ }
+ } break;
+ case BASIS_DECOMPRESS_RGB: {
+ if (VS::get_singleton()->has_os_feature("bptc")) {
+ format = basist::transcoder_texture_format::cTFBC7_M6_OPAQUE_ONLY; // get this from renderer
+ imgfmt = Image::FORMAT_BPTC_RGBA;
+ } else if (VS::get_singleton()->has_os_feature("s3tc")) {
+ format = basist::transcoder_texture_format::cTFBC1; // get this from renderer
+ imgfmt = Image::FORMAT_DXT1;
+ } else if (VS::get_singleton()->has_os_feature("etc")) {
+
+ format = basist::transcoder_texture_format::cTFETC1; // get this from renderer
+ imgfmt = Image::FORMAT_ETC;
+ } else {
+ format = basist::transcoder_texture_format::cTFBGR565; // get this from renderer
+ imgfmt = Image::FORMAT_RGB565;
+ }
+
+ } break;
+ case BASIS_DECOMPRESS_RGBA: {
+ if (VS::get_singleton()->has_os_feature("bptc")) {
+ format = basist::transcoder_texture_format::cTFBC7_M5; // get this from renderer
+ imgfmt = Image::FORMAT_BPTC_RGBA;
+ } else if (VS::get_singleton()->has_os_feature("s3tc")) {
+ format = basist::transcoder_texture_format::cTFBC3; // get this from renderer
+ imgfmt = Image::FORMAT_DXT5;
+ } else if (VS::get_singleton()->has_os_feature("etc2")) {
+ format = basist::transcoder_texture_format::cTFETC2; // get this from renderer
+ imgfmt = Image::FORMAT_ETC2_RGBA8;
+ } else {
+ //gles2 most likely
+ format = basist::transcoder_texture_format::cTFRGBA4444; // get this from renderer
+ imgfmt = Image::FORMAT_RGBA4444;
+ }
+ } break;
+ case BASIS_DECOMPRESS_RG_AS_RA: {
+ if (VS::get_singleton()->has_os_feature("s3tc")) {
+ format = basist::transcoder_texture_format::cTFBC3; // get this from renderer
+ imgfmt = Image::FORMAT_DXT5_RA_AS_RG;
+ } else if (VS::get_singleton()->has_os_feature("etc2")) {
+ format = basist::transcoder_texture_format::cTFETC2; // get this from renderer
+ imgfmt = Image::FORMAT_ETC2_RGBA8;
+ } else {
+ //gles2 most likely, bad for normalmaps, nothing to do about this.
+ format = basist::transcoder_texture_format::cTFRGBA32;
+ imgfmt = Image::FORMAT_RGBA8;
+ }
+ } break;
+ }
+
+ ptr += 4;
+ size -= 4;
+
+ basist::basisu_transcoder tr(NULL);
+
+ ERR_FAIL_COND_V(!tr.validate_header(ptr, size), image);
+
+ basist::basisu_image_info info;
+ tr.get_image_info(ptr, size, info, 0);
+
+ int block_size = basist::basis_get_bytes_per_block(format);
+ Vector<uint8_t> gpudata;
+ gpudata.resize(info.m_total_blocks * block_size);
+
+ {
+ uint8_t *w = gpudata.ptrw();
+ uint8_t *dst = w;
+ for (int i = 0; i < gpudata.size(); i++)
+ dst[i] = 0x00;
+
+ int ofs = 0;
+ tr.start_transcoding(ptr, size);
+ for (uint32_t i = 0; i < info.m_total_levels; i++) {
+
+ basist::basisu_image_level_info level;
+ tr.get_image_level_info(ptr, size, level, 0, i);
+
+ bool ret = tr.transcode_image_level(ptr, size, 0, i, dst + ofs, level.m_total_blocks - i, format);
+ if (!ret) {
+ printf("failed! on level %i\n", i);
+ break;
+ };
+
+ ofs += level.m_total_blocks * block_size;
+ };
+ };
+
+ image.instance();
+ image->create(info.m_width, info.m_height, info.m_total_levels > 1, imgfmt, gpudata);
+
+ return image;
+}
+
+void register_basis_universal_types() {
+#ifdef TOOLS_ENABLED
+ sel_codebook = new basist::etc1_global_selector_codebook(basist::g_global_selector_cb_size, basist::g_global_selector_cb);
+ Image::basis_universal_packer = basis_universal_packer;
+#endif
+ Image::basis_universal_unpacker = basis_universal_unpacker;
+ //ClassDB::register_class<TextureBasisU>();
+}
+
+void unregister_basis_universal_types() {
+
+#ifdef TOOLS_ENABLED
+ delete sel_codebook;
+ Image::basis_universal_packer = NULL;
+#endif
+ Image::basis_universal_unpacker = NULL;
+}
diff --git a/modules/recast/register_types.h b/modules/basis_universal/register_types.h
index d16ba37f5e..977374fbfc 100644
--- a/modules/recast/register_types.h
+++ b/modules/basis_universal/register_types.h
@@ -28,5 +28,5 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-void register_recast_types();
-void unregister_recast_types();
+void register_basis_universal_types();
+void unregister_basis_universal_types();
diff --git a/modules/basis_universal/texture_basisu.cpp b/modules/basis_universal/texture_basisu.cpp
new file mode 100644
index 0000000000..12f3241c98
--- /dev/null
+++ b/modules/basis_universal/texture_basisu.cpp
@@ -0,0 +1,233 @@
+/*************************************************************************/
+/* texture_basisu.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#include "texture_basisu.h"
+#if 0
+#include "core/os/os.h"
+
+#ifdef TOOLS_ENABLED
+#include <basisu_comp.h>
+#endif
+
+#include <transcoder/basisu_transcoder.h>
+
+void TextureBasisU::_bind_methods() {
+
+ ClassDB::bind_method(D_METHOD("set_basisu_data", "data"), &TextureBasisU::set_basisu_data);
+ ClassDB::bind_method(D_METHOD("get_basisu_data"), &TextureBasisU::get_data);
+ ClassDB::bind_method(D_METHOD("import"), &TextureBasisU::import);
+
+ ADD_PROPERTY(PropertyInfo(Variant::PACKED_BYTE_ARRAY, "basisu_data"), "set_basisu_data", "get_basisu_data");
+
+};
+
+int TextureBasisU::get_width() const {
+
+ return tex_size.x;
+};
+
+int TextureBasisU::get_height() const {
+
+ return tex_size.y;
+};
+
+RID TextureBasisU::get_rid() const {
+
+ return texture;
+};
+
+
+bool TextureBasisU::has_alpha() const {
+
+ return false;
+};
+
+void TextureBasisU::set_flags(uint32_t p_flags) {
+
+ flags = p_flags;
+ VisualServer::get_singleton()->texture_set_flags(texture, p_flags);
+};
+
+uint32_t TextureBasisU::get_flags() const {
+
+ return flags;
+};
+
+
+void TextureBasisU::set_basisu_data(const Vector<uint8_t>& p_data) {
+
+#ifdef TOOLS_ENABLED
+ data = p_data;
+#endif
+
+ const uint8_t* r = p_data.ptr();
+ const void* ptr = r.ptr();
+ int size = p_data.size();
+
+ basist::transcoder_texture_format format;
+ Image::Format imgfmt;
+
+ if (OS::get_singleton()->has_feature("s3tc")) {
+
+ format = basist::cTFBC3; // get this from renderer
+ imgfmt = Image::FORMAT_DXT5;
+
+ } else if (OS::get_singleton()->has_feature("etc2")) {
+
+ format = basist::cTFETC2;
+ imgfmt = Image::FORMAT_ETC2_RGBA8;
+ };
+
+ basist::basisu_transcoder tr(NULL);
+
+ ERR_FAIL_COND(!tr.validate_header(ptr, size));
+
+ basist::basisu_image_info info;
+ tr.get_image_info(ptr, size, info, 0);
+ tex_size = Size2(info.m_width, info.m_height);
+
+ int block_size = basist::basis_get_bytes_per_block(format);
+ Vector<uint8_t> gpudata;
+ gpudata.resize(info.m_total_blocks * block_size);
+
+ {
+ uint8_t* w = gpudata.ptrw();
+ uint8_t* dst = w.ptr();
+ for (int i=0; i<gpudata.size(); i++)
+ dst[i] = 0x00;
+
+ int ofs = 0;
+ tr.start_transcoding(ptr, size);
+ for (int i=0; i<info.m_total_levels; i++) {
+
+ basist::basisu_image_level_info level;
+ tr.get_image_level_info(ptr, size, level, 0, i);
+
+ bool ret = tr.transcode_image_level(ptr, size, 0, i, dst + ofs, level.m_total_blocks - i, format);
+ if (!ret) {
+ printf("failed! on level %i\n", i);
+ break;
+ };
+
+ ofs += level.m_total_blocks * block_size;
+ };
+ };
+
+ Ref<Image> img;
+ img.instance();
+ img->create(info.m_width, info.m_height, info.m_total_levels > 1, imgfmt, gpudata);
+
+ VisualServer::get_singleton()->texture_allocate(texture, tex_size.x, tex_size.y, 0, img->get_format(), VS::TEXTURE_TYPE_2D, flags);
+ VisualServer::get_singleton()->texture_set_data(texture, img);
+};
+
+Error TextureBasisU::import(const Ref<Image>& p_img) {
+
+#ifdef TOOLS_ENABLED
+
+ Vector<uint8_t> budata;
+
+ {
+ Image::Format format = p_img->get_format();
+ if (format != Image::FORMAT_RGB8 && format != Image::FORMAT_RGBA8) {
+ ERR_FAIL_V(ERR_INVALID_PARAMETER);
+ return ERR_INVALID_PARAMETER;
+ };
+
+ Ref<Image> copy = p_img->duplicate();
+ if (format == Image::FORMAT_RGB8)
+ copy->convert(Image::FORMAT_RGBA8);
+
+ basisu::image buimg(p_img->get_width(), p_img->get_height());
+ int size = p_img->get_width() * p_img->get_height() * 4;
+
+ Vector<uint8_t> vec = copy->get_data();
+ {
+ const uint8_t* r = vec.ptr();
+ memcpy(buimg.get_ptr(), r.ptr(), size);
+ };
+
+ basisu::basis_compressor_params params;
+ params.m_max_endpoint_clusters = 512;
+ params.m_max_selector_clusters = 512;
+ params.m_multithreading = true;
+
+ basisu::job_pool jpool(1);
+ params.m_pJob_pool = &jpool;
+
+ params.m_mip_gen = p_img->get_mipmap_count() > 0;
+ params.m_source_images.push_back(buimg);
+
+ basisu::basis_compressor c;
+ c.init(params);
+
+ int buerr = c.process();
+ if (buerr != basisu::basis_compressor::cECSuccess) {
+ ERR_FAIL_V(ERR_INVALID_PARAMETER);
+ return ERR_INVALID_PARAMETER;
+ };
+
+ const basisu::uint8_vec& buvec = c.get_output_basis_file();
+ budata.resize(buvec.size());
+
+ {
+ uint8_t* w = budata.ptrw();
+ memcpy(w.ptr(), &buvec[0], budata.size());
+ };
+ };
+
+ set_basisu_data(budata);
+
+ return OK;
+#else
+
+ return ERR_UNAVAILABLE;
+#endif
+};
+
+
+Vector<uint8_t> TextureBasisU::get_basisu_data() const {
+
+ return data;
+};
+
+TextureBasisU::TextureBasisU() {
+
+ flags = FLAGS_DEFAULT;
+ texture = VisualServer::get_singleton()->texture_create();
+};
+
+
+TextureBasisU::~TextureBasisU() {
+
+ VisualServer::get_singleton()->free(texture);
+};
+
+#endif
diff --git a/modules/basis_universal/texture_basisu.h b/modules/basis_universal/texture_basisu.h
new file mode 100644
index 0000000000..8de151ede0
--- /dev/null
+++ b/modules/basis_universal/texture_basisu.h
@@ -0,0 +1,77 @@
+/*************************************************************************/
+/* texture_basisu.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#include "scene/resources/texture.h"
+
+#ifdef TOOLS_ENABLED
+#include <basisu_comp.h>
+#endif
+
+#include <transcoder/basisu_transcoder.h>
+
+#if 0
+class TextureBasisU : public Texture {
+
+ GDCLASS(TextureBasisU, Texture);
+ RES_BASE_EXTENSION("butex");
+
+ RID texture;
+ Size2 tex_size;
+
+ uint32_t flags;
+
+ Vector<uint8_t> data;
+
+ static void _bind_methods();
+
+public:
+
+ virtual int get_width() const;
+ virtual int get_height() const;
+ virtual RID get_rid() const;
+ virtual bool has_alpha() const;
+
+ virtual void set_flags(uint32_t p_flags);
+ virtual uint32_t get_flags() const;
+
+
+ Error import(const Ref<Image> &p_img);
+
+ void set_basisu_data(const Vector<uint8_t>& p_data);
+
+ Vector<uint8_t> get_basisu_data() const;
+ String get_img_path() const;
+
+ TextureBasisU();
+ ~TextureBasisU();
+
+};
+
+#endif
diff --git a/modules/bmp/image_loader_bmp.cpp b/modules/bmp/image_loader_bmp.cpp
index 5ce6d59daa..71e5076e78 100644
--- a/modules/bmp/image_loader_bmp.cpp
+++ b/modules/bmp/image_loader_bmp.cpp
@@ -65,7 +65,7 @@ Error ImageLoaderBMP::convert_to_image(Ref<Image> p_image,
}
// Image data (might be indexed)
- PoolVector<uint8_t> data;
+ Vector<uint8_t> data;
int data_len = 0;
if (bits_per_pixel <= 8) { // indexed
@@ -76,8 +76,8 @@ Error ImageLoaderBMP::convert_to_image(Ref<Image> p_image,
ERR_FAIL_COND_V(data_len == 0, ERR_BUG);
err = data.resize(data_len);
- PoolVector<uint8_t>::Write data_w = data.write();
- uint8_t *write_buffer = data_w.ptr();
+ uint8_t *data_w = data.ptrw();
+ uint8_t *write_buffer = data_w;
const uint32_t width_bytes = width * bits_per_pixel / 8;
const uint32_t line_width = (width_bytes + 3) & ~3;
@@ -158,11 +158,11 @@ Error ImageLoaderBMP::convert_to_image(Ref<Image> p_image,
} else { // data is in indexed format, extend it
// Palette data
- PoolVector<uint8_t> palette_data;
+ Vector<uint8_t> palette_data;
palette_data.resize(color_table_size * 4);
- PoolVector<uint8_t>::Write palette_data_w = palette_data.write();
- uint8_t *pal = palette_data_w.ptr();
+ uint8_t *palette_data_w = palette_data.ptrw();
+ uint8_t *pal = palette_data_w;
const uint8_t *cb = p_color_buffer;
@@ -177,11 +177,11 @@ Error ImageLoaderBMP::convert_to_image(Ref<Image> p_image,
cb += 4;
}
// Extend palette to image
- PoolVector<uint8_t> extended_data;
+ Vector<uint8_t> extended_data;
extended_data.resize(data.size() * 4);
- PoolVector<uint8_t>::Write ex_w = extended_data.write();
- uint8_t *dest = ex_w.ptr();
+ uint8_t *ex_w = extended_data.ptrw();
+ uint8_t *dest = ex_w;
const int num_pixels = width * height;
@@ -260,27 +260,27 @@ Error ImageLoaderBMP::load_image(Ref<Image> p_image, FileAccess *f,
ERR_FAIL_COND_V(color_table_size == 0, ERR_BUG);
}
- PoolVector<uint8_t> bmp_color_table;
+ Vector<uint8_t> bmp_color_table;
// Color table is usually 4 bytes per color -> [B][G][R][0]
bmp_color_table.resize(color_table_size * 4);
- PoolVector<uint8_t>::Write bmp_color_table_w = bmp_color_table.write();
- f->get_buffer(bmp_color_table_w.ptr(), color_table_size * 4);
+ uint8_t *bmp_color_table_w = bmp_color_table.ptrw();
+ f->get_buffer(bmp_color_table_w, color_table_size * 4);
f->seek(bmp_header.bmp_file_header.bmp_file_offset);
uint32_t bmp_buffer_size = (bmp_header.bmp_file_header.bmp_file_size -
bmp_header.bmp_file_header.bmp_file_offset);
- PoolVector<uint8_t> bmp_buffer;
+ Vector<uint8_t> bmp_buffer;
err = bmp_buffer.resize(bmp_buffer_size);
if (err == OK) {
- PoolVector<uint8_t>::Write bmp_buffer_w = bmp_buffer.write();
- f->get_buffer(bmp_buffer_w.ptr(), bmp_buffer_size);
+ uint8_t *bmp_buffer_w = bmp_buffer.ptrw();
+ f->get_buffer(bmp_buffer_w, bmp_buffer_size);
- PoolVector<uint8_t>::Read bmp_buffer_r = bmp_buffer.read();
- PoolVector<uint8_t>::Read bmp_color_table_r = bmp_color_table.read();
- err = convert_to_image(p_image, bmp_buffer_r.ptr(),
- bmp_color_table_r.ptr(), color_table_size, bmp_header);
+ const uint8_t *bmp_buffer_r = bmp_buffer.ptr();
+ const uint8_t *bmp_color_table_r = bmp_color_table.ptr();
+ err = convert_to_image(p_image, bmp_buffer_r,
+ bmp_color_table_r, color_table_size, bmp_header);
}
f->close();
}
diff --git a/modules/bullet/area_bullet.cpp b/modules/bullet/area_bullet.cpp
index 8d03a99556..e8a5c1475a 100644
--- a/modules/bullet/area_bullet.cpp
+++ b/modules/bullet/area_bullet.cpp
@@ -107,7 +107,7 @@ void AreaBullet::call_event(CollisionObjectBullet *p_otherObject, PhysicsServer:
Object *areaGodoObject = ObjectDB::get_instance(event.event_callback_id);
if (!areaGodoObject) {
- event.event_callback_id = 0;
+ event.event_callback_id = ObjectID();
return;
}
@@ -117,7 +117,7 @@ void AreaBullet::call_event(CollisionObjectBullet *p_otherObject, PhysicsServer:
call_event_res[3] = 0; // other_body_shape ID
call_event_res[4] = 0; // self_shape ID
- Variant::CallError outResp;
+ Callable::CallError outResp;
areaGodoObject->call(event.event_callback_method, (const Variant **)call_event_res_ptr, 5, outResp);
}
@@ -279,7 +279,7 @@ void AreaBullet::set_event_callback(Type p_callbackObjectType, ObjectID p_id, co
ev.event_callback_method = p_method;
/// Set if monitoring
- if (eventsCallbacks[0].event_callback_id || eventsCallbacks[1].event_callback_id) {
+ if (eventsCallbacks[0].event_callback_id.is_valid() || eventsCallbacks[1].event_callback_id.is_valid()) {
set_godot_object_flags(get_godot_object_flags() | GOF_IS_MONITORING_AREA);
} else {
set_godot_object_flags(get_godot_object_flags() & (~GOF_IS_MONITORING_AREA));
@@ -287,7 +287,7 @@ void AreaBullet::set_event_callback(Type p_callbackObjectType, ObjectID p_id, co
}
bool AreaBullet::has_event_callback(Type p_callbackObjectType) {
- return eventsCallbacks[static_cast<int>(p_callbackObjectType)].event_callback_id;
+ return eventsCallbacks[static_cast<int>(p_callbackObjectType)].event_callback_id.is_valid();
}
void AreaBullet::on_enter_area(AreaBullet *p_area) {
diff --git a/modules/bullet/area_bullet.h b/modules/bullet/area_bullet.h
index f770c63bcc..18888c6725 100644
--- a/modules/bullet/area_bullet.h
+++ b/modules/bullet/area_bullet.h
@@ -50,8 +50,7 @@ public:
ObjectID event_callback_id;
StringName event_callback_method;
- InOutEventCallback() :
- event_callback_id(0) {}
+ InOutEventCallback() {}
};
enum OverlapState {
diff --git a/modules/bullet/bullet_physics_server.cpp b/modules/bullet/bullet_physics_server.cpp
index e507987297..89868babc6 100644
--- a/modules/bullet/bullet_physics_server.cpp
+++ b/modules/bullet/bullet_physics_server.cpp
@@ -134,7 +134,7 @@ RID BulletPhysicsServer::shape_create(ShapeType p_shape) {
}
void BulletPhysicsServer::shape_set_data(RID p_shape, const Variant &p_data) {
- ShapeBullet *shape = shape_owner.get(p_shape);
+ ShapeBullet *shape = shape_owner.getornull(p_shape);
ERR_FAIL_COND(!shape);
shape->set_data(p_data);
}
@@ -144,25 +144,25 @@ void BulletPhysicsServer::shape_set_custom_solver_bias(RID p_shape, real_t p_bia
}
PhysicsServer::ShapeType BulletPhysicsServer::shape_get_type(RID p_shape) const {
- ShapeBullet *shape = shape_owner.get(p_shape);
+ ShapeBullet *shape = shape_owner.getornull(p_shape);
ERR_FAIL_COND_V(!shape, PhysicsServer::SHAPE_CUSTOM);
return shape->get_type();
}
Variant BulletPhysicsServer::shape_get_data(RID p_shape) const {
- ShapeBullet *shape = shape_owner.get(p_shape);
+ ShapeBullet *shape = shape_owner.getornull(p_shape);
ERR_FAIL_COND_V(!shape, Variant());
return shape->get_data();
}
void BulletPhysicsServer::shape_set_margin(RID p_shape, real_t p_margin) {
- ShapeBullet *shape = shape_owner.get(p_shape);
+ ShapeBullet *shape = shape_owner.getornull(p_shape);
ERR_FAIL_COND(!shape);
shape->set_margin(p_margin);
}
real_t BulletPhysicsServer::shape_get_margin(RID p_shape) const {
- ShapeBullet *shape = shape_owner.get(p_shape);
+ ShapeBullet *shape = shape_owner.getornull(p_shape);
ERR_FAIL_COND_V(!shape, 0.0);
return shape->get_margin();
}
@@ -179,7 +179,7 @@ RID BulletPhysicsServer::space_create() {
void BulletPhysicsServer::space_set_active(RID p_space, bool p_active) {
- SpaceBullet *space = space_owner.get(p_space);
+ SpaceBullet *space = space_owner.getornull(p_space);
ERR_FAIL_COND(!space);
if (space_is_active(p_space) == p_active) {
@@ -196,47 +196,47 @@ void BulletPhysicsServer::space_set_active(RID p_space, bool p_active) {
}
bool BulletPhysicsServer::space_is_active(RID p_space) const {
- SpaceBullet *space = space_owner.get(p_space);
+ SpaceBullet *space = space_owner.getornull(p_space);
ERR_FAIL_COND_V(!space, false);
return -1 != active_spaces.find(space);
}
void BulletPhysicsServer::space_set_param(RID p_space, SpaceParameter p_param, real_t p_value) {
- SpaceBullet *space = space_owner.get(p_space);
+ SpaceBullet *space = space_owner.getornull(p_space);
ERR_FAIL_COND(!space);
space->set_param(p_param, p_value);
}
real_t BulletPhysicsServer::space_get_param(RID p_space, SpaceParameter p_param) const {
- SpaceBullet *space = space_owner.get(p_space);
+ SpaceBullet *space = space_owner.getornull(p_space);
ERR_FAIL_COND_V(!space, 0);
return space->get_param(p_param);
}
PhysicsDirectSpaceState *BulletPhysicsServer::space_get_direct_state(RID p_space) {
- SpaceBullet *space = space_owner.get(p_space);
+ SpaceBullet *space = space_owner.getornull(p_space);
ERR_FAIL_COND_V(!space, NULL);
return space->get_direct_state();
}
void BulletPhysicsServer::space_set_debug_contacts(RID p_space, int p_max_contacts) {
- SpaceBullet *space = space_owner.get(p_space);
+ SpaceBullet *space = space_owner.getornull(p_space);
ERR_FAIL_COND(!space);
space->set_debug_contacts(p_max_contacts);
}
Vector<Vector3> BulletPhysicsServer::space_get_contacts(RID p_space) const {
- SpaceBullet *space = space_owner.get(p_space);
+ SpaceBullet *space = space_owner.getornull(p_space);
ERR_FAIL_COND_V(!space, Vector<Vector3>());
return space->get_debug_contacts();
}
int BulletPhysicsServer::space_get_contact_count(RID p_space) const {
- SpaceBullet *space = space_owner.get(p_space);
+ SpaceBullet *space = space_owner.getornull(p_space);
ERR_FAIL_COND_V(!space, 0);
return space->get_debug_contact_count();
@@ -250,91 +250,91 @@ RID BulletPhysicsServer::area_create() {
}
void BulletPhysicsServer::area_set_space(RID p_area, RID p_space) {
- AreaBullet *area = area_owner.get(p_area);
+ AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
SpaceBullet *space = NULL;
if (p_space.is_valid()) {
- space = space_owner.get(p_space);
+ space = space_owner.getornull(p_space);
ERR_FAIL_COND(!space);
}
area->set_space(space);
}
RID BulletPhysicsServer::area_get_space(RID p_area) const {
- AreaBullet *area = area_owner.get(p_area);
+ AreaBullet *area = area_owner.getornull(p_area);
return area->get_space()->get_self();
}
void BulletPhysicsServer::area_set_space_override_mode(RID p_area, AreaSpaceOverrideMode p_mode) {
- AreaBullet *area = area_owner.get(p_area);
+ AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
area->set_spOv_mode(p_mode);
}
PhysicsServer::AreaSpaceOverrideMode BulletPhysicsServer::area_get_space_override_mode(RID p_area) const {
- AreaBullet *area = area_owner.get(p_area);
+ AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND_V(!area, PhysicsServer::AREA_SPACE_OVERRIDE_DISABLED);
return area->get_spOv_mode();
}
void BulletPhysicsServer::area_add_shape(RID p_area, RID p_shape, const Transform &p_transform, bool p_disabled) {
- AreaBullet *area = area_owner.get(p_area);
+ AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
- ShapeBullet *shape = shape_owner.get(p_shape);
+ ShapeBullet *shape = shape_owner.getornull(p_shape);
ERR_FAIL_COND(!shape);
area->add_shape(shape, p_transform, p_disabled);
}
void BulletPhysicsServer::area_set_shape(RID p_area, int p_shape_idx, RID p_shape) {
- AreaBullet *area = area_owner.get(p_area);
+ AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
- ShapeBullet *shape = shape_owner.get(p_shape);
+ ShapeBullet *shape = shape_owner.getornull(p_shape);
ERR_FAIL_COND(!shape);
area->set_shape(p_shape_idx, shape);
}
void BulletPhysicsServer::area_set_shape_transform(RID p_area, int p_shape_idx, const Transform &p_transform) {
- AreaBullet *area = area_owner.get(p_area);
+ AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
area->set_shape_transform(p_shape_idx, p_transform);
}
int BulletPhysicsServer::area_get_shape_count(RID p_area) const {
- AreaBullet *area = area_owner.get(p_area);
+ AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND_V(!area, 0);
return area->get_shape_count();
}
RID BulletPhysicsServer::area_get_shape(RID p_area, int p_shape_idx) const {
- AreaBullet *area = area_owner.get(p_area);
+ AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND_V(!area, RID());
return area->get_shape(p_shape_idx)->get_self();
}
Transform BulletPhysicsServer::area_get_shape_transform(RID p_area, int p_shape_idx) const {
- AreaBullet *area = area_owner.get(p_area);
+ AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND_V(!area, Transform());
return area->get_shape_transform(p_shape_idx);
}
void BulletPhysicsServer::area_remove_shape(RID p_area, int p_shape_idx) {
- AreaBullet *area = area_owner.get(p_area);
+ AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
return area->remove_shape_full(p_shape_idx);
}
void BulletPhysicsServer::area_clear_shapes(RID p_area) {
- AreaBullet *area = area_owner.get(p_area);
+ AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
for (int i = area->get_shape_count(); 0 < i; --i)
@@ -342,7 +342,7 @@ void BulletPhysicsServer::area_clear_shapes(RID p_area) {
}
void BulletPhysicsServer::area_set_shape_disabled(RID p_area, int p_shape_idx, bool p_disabled) {
- AreaBullet *area = area_owner.get(p_area);
+ AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
area->set_shape_disabled(p_shape_idx, p_disabled);
@@ -352,29 +352,29 @@ void BulletPhysicsServer::area_attach_object_instance_id(RID p_area, ObjectID p_
if (space_owner.owns(p_area)) {
return;
}
- AreaBullet *area = area_owner.get(p_area);
+ AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
area->set_instance_id(p_id);
}
ObjectID BulletPhysicsServer::area_get_object_instance_id(RID p_area) const {
if (space_owner.owns(p_area)) {
- return 0;
+ return ObjectID();
}
- AreaBullet *area = area_owner.get(p_area);
+ AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND_V(!area, ObjectID());
return area->get_instance_id();
}
void BulletPhysicsServer::area_set_param(RID p_area, AreaParameter p_param, const Variant &p_value) {
if (space_owner.owns(p_area)) {
- SpaceBullet *space = space_owner.get(p_area);
+ SpaceBullet *space = space_owner.getornull(p_area);
if (space) {
space->set_param(p_param, p_value);
}
} else {
- AreaBullet *area = area_owner.get(p_area);
+ AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
area->set_param(p_param, p_value);
@@ -383,10 +383,10 @@ void BulletPhysicsServer::area_set_param(RID p_area, AreaParameter p_param, cons
Variant BulletPhysicsServer::area_get_param(RID p_area, AreaParameter p_param) const {
if (space_owner.owns(p_area)) {
- SpaceBullet *space = space_owner.get(p_area);
+ SpaceBullet *space = space_owner.getornull(p_area);
return space->get_param(p_param);
} else {
- AreaBullet *area = area_owner.get(p_area);
+ AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND_V(!area, Variant());
return area->get_param(p_param);
@@ -394,58 +394,58 @@ Variant BulletPhysicsServer::area_get_param(RID p_area, AreaParameter p_param) c
}
void BulletPhysicsServer::area_set_transform(RID p_area, const Transform &p_transform) {
- AreaBullet *area = area_owner.get(p_area);
+ AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
area->set_transform(p_transform);
}
Transform BulletPhysicsServer::area_get_transform(RID p_area) const {
- AreaBullet *area = area_owner.get(p_area);
+ AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND_V(!area, Transform());
return area->get_transform();
}
void BulletPhysicsServer::area_set_collision_mask(RID p_area, uint32_t p_mask) {
- AreaBullet *area = area_owner.get(p_area);
+ AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
area->set_collision_mask(p_mask);
}
void BulletPhysicsServer::area_set_collision_layer(RID p_area, uint32_t p_layer) {
- AreaBullet *area = area_owner.get(p_area);
+ AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
area->set_collision_layer(p_layer);
}
void BulletPhysicsServer::area_set_monitorable(RID p_area, bool p_monitorable) {
- AreaBullet *area = area_owner.get(p_area);
+ AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
area->set_monitorable(p_monitorable);
}
void BulletPhysicsServer::area_set_monitor_callback(RID p_area, Object *p_receiver, const StringName &p_method) {
- AreaBullet *area = area_owner.get(p_area);
+ AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
- area->set_event_callback(CollisionObjectBullet::TYPE_RIGID_BODY, p_receiver ? p_receiver->get_instance_id() : 0, p_method);
+ area->set_event_callback(CollisionObjectBullet::TYPE_RIGID_BODY, p_receiver ? p_receiver->get_instance_id() : ObjectID(), p_method);
}
void BulletPhysicsServer::area_set_area_monitor_callback(RID p_area, Object *p_receiver, const StringName &p_method) {
- AreaBullet *area = area_owner.get(p_area);
+ AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
- area->set_event_callback(CollisionObjectBullet::TYPE_AREA, p_receiver ? p_receiver->get_instance_id() : 0, p_method);
+ area->set_event_callback(CollisionObjectBullet::TYPE_AREA, p_receiver ? p_receiver->get_instance_id() : ObjectID(), p_method);
}
void BulletPhysicsServer::area_set_ray_pickable(RID p_area, bool p_enable) {
- AreaBullet *area = area_owner.get(p_area);
+ AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
area->set_ray_pickable(p_enable);
}
bool BulletPhysicsServer::area_is_ray_pickable(RID p_area) const {
- AreaBullet *area = area_owner.get(p_area);
+ AreaBullet *area = area_owner.getornull(p_area);
ERR_FAIL_COND_V(!area, false);
return area->is_ray_pickable();
}
@@ -461,12 +461,12 @@ RID BulletPhysicsServer::body_create(BodyMode p_mode, bool p_init_sleeping) {
}
void BulletPhysicsServer::body_set_space(RID p_body, RID p_space) {
- RigidBodyBullet *body = rigid_body_owner.get(p_body);
+ RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
SpaceBullet *space = NULL;
if (p_space.is_valid()) {
- space = space_owner.get(p_space);
+ space = space_owner.getornull(p_space);
ERR_FAIL_COND(!space);
}
@@ -477,7 +477,7 @@ void BulletPhysicsServer::body_set_space(RID p_body, RID p_space) {
}
RID BulletPhysicsServer::body_get_space(RID p_body) const {
- RigidBodyBullet *body = rigid_body_owner.get(p_body);
+ RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, RID());
SpaceBullet *space = body->get_space();
@@ -487,53 +487,53 @@ RID BulletPhysicsServer::body_get_space(RID p_body) const {
}
void BulletPhysicsServer::body_set_mode(RID p_body, PhysicsServer::BodyMode p_mode) {
- RigidBodyBullet *body = rigid_body_owner.get(p_body);
+ RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_mode(p_mode);
}
PhysicsServer::BodyMode BulletPhysicsServer::body_get_mode(RID p_body) const {
- RigidBodyBullet *body = rigid_body_owner.get(p_body);
+ RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, BODY_MODE_STATIC);
return body->get_mode();
}
void BulletPhysicsServer::body_add_shape(RID p_body, RID p_shape, const Transform &p_transform, bool p_disabled) {
- RigidBodyBullet *body = rigid_body_owner.get(p_body);
+ RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
- ShapeBullet *shape = shape_owner.get(p_shape);
+ ShapeBullet *shape = shape_owner.getornull(p_shape);
ERR_FAIL_COND(!shape);
body->add_shape(shape, p_transform, p_disabled);
}
void BulletPhysicsServer::body_set_shape(RID p_body, int p_shape_idx, RID p_shape) {
- RigidBodyBullet *body = rigid_body_owner.get(p_body);
+ RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
- ShapeBullet *shape = shape_owner.get(p_shape);
+ ShapeBullet *shape = shape_owner.getornull(p_shape);
ERR_FAIL_COND(!shape);
body->set_shape(p_shape_idx, shape);
}
void BulletPhysicsServer::body_set_shape_transform(RID p_body, int p_shape_idx, const Transform &p_transform) {
- RigidBodyBullet *body = rigid_body_owner.get(p_body);
+ RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_shape_transform(p_shape_idx, p_transform);
}
int BulletPhysicsServer::body_get_shape_count(RID p_body) const {
- RigidBodyBullet *body = rigid_body_owner.get(p_body);
+ RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0);
return body->get_shape_count();
}
RID BulletPhysicsServer::body_get_shape(RID p_body, int p_shape_idx) const {
- RigidBodyBullet *body = rigid_body_owner.get(p_body);
+ RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, RID());
ShapeBullet *shape = body->get_shape(p_shape_idx);
@@ -543,83 +543,83 @@ RID BulletPhysicsServer::body_get_shape(RID p_body, int p_shape_idx) const {
}
Transform BulletPhysicsServer::body_get_shape_transform(RID p_body, int p_shape_idx) const {
- RigidBodyBullet *body = rigid_body_owner.get(p_body);
+ RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, Transform());
return body->get_shape_transform(p_shape_idx);
}
void BulletPhysicsServer::body_set_shape_disabled(RID p_body, int p_shape_idx, bool p_disabled) {
- RigidBodyBullet *body = rigid_body_owner.get(p_body);
+ RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_shape_disabled(p_shape_idx, p_disabled);
}
void BulletPhysicsServer::body_remove_shape(RID p_body, int p_shape_idx) {
- RigidBodyBullet *body = rigid_body_owner.get(p_body);
+ RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->remove_shape_full(p_shape_idx);
}
void BulletPhysicsServer::body_clear_shapes(RID p_body) {
- RigidBodyBullet *body = rigid_body_owner.get(p_body);
+ RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->remove_all_shapes();
}
-void BulletPhysicsServer::body_attach_object_instance_id(RID p_body, uint32_t p_id) {
+void BulletPhysicsServer::body_attach_object_instance_id(RID p_body, ObjectID p_id) {
CollisionObjectBullet *body = get_collisin_object(p_body);
ERR_FAIL_COND(!body);
body->set_instance_id(p_id);
}
-uint32_t BulletPhysicsServer::body_get_object_instance_id(RID p_body) const {
+ObjectID BulletPhysicsServer::body_get_object_instance_id(RID p_body) const {
CollisionObjectBullet *body = get_collisin_object(p_body);
- ERR_FAIL_COND_V(!body, 0);
+ ERR_FAIL_COND_V(!body, ObjectID());
return body->get_instance_id();
}
void BulletPhysicsServer::body_set_enable_continuous_collision_detection(RID p_body, bool p_enable) {
- RigidBodyBullet *body = rigid_body_owner.get(p_body);
+ RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_continuous_collision_detection(p_enable);
}
bool BulletPhysicsServer::body_is_continuous_collision_detection_enabled(RID p_body) const {
- RigidBodyBullet *body = rigid_body_owner.get(p_body);
+ RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, false);
return body->is_continuous_collision_detection_enabled();
}
void BulletPhysicsServer::body_set_collision_layer(RID p_body, uint32_t p_layer) {
- RigidBodyBullet *body = rigid_body_owner.get(p_body);
+ RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_collision_layer(p_layer);
}
uint32_t BulletPhysicsServer::body_get_collision_layer(RID p_body) const {
- const RigidBodyBullet *body = rigid_body_owner.get(p_body);
+ const RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0);
return body->get_collision_layer();
}
void BulletPhysicsServer::body_set_collision_mask(RID p_body, uint32_t p_mask) {
- RigidBodyBullet *body = rigid_body_owner.get(p_body);
+ RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_collision_mask(p_mask);
}
uint32_t BulletPhysicsServer::body_get_collision_mask(RID p_body) const {
- RigidBodyBullet *body = rigid_body_owner.get(p_body);
+ RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0);
return body->get_collision_mask();
@@ -635,21 +635,21 @@ uint32_t BulletPhysicsServer::body_get_user_flags(RID p_body) const {
}
void BulletPhysicsServer::body_set_param(RID p_body, BodyParameter p_param, float p_value) {
- RigidBodyBullet *body = rigid_body_owner.get(p_body);
+ RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_param(p_param, p_value);
}
float BulletPhysicsServer::body_get_param(RID p_body, BodyParameter p_param) const {
- RigidBodyBullet *body = rigid_body_owner.get(p_body);
+ RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0);
return body->get_param(p_param);
}
void BulletPhysicsServer::body_set_kinematic_safe_margin(RID p_body, real_t p_margin) {
- RigidBodyBullet *body = rigid_body_owner.get(p_body);
+ RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
if (body->get_kinematic_utilities()) {
@@ -659,7 +659,7 @@ void BulletPhysicsServer::body_set_kinematic_safe_margin(RID p_body, real_t p_ma
}
real_t BulletPhysicsServer::body_get_kinematic_safe_margin(RID p_body) const {
- RigidBodyBullet *body = rigid_body_owner.get(p_body);
+ RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0);
if (body->get_kinematic_utilities()) {
@@ -671,90 +671,90 @@ real_t BulletPhysicsServer::body_get_kinematic_safe_margin(RID p_body) const {
}
void BulletPhysicsServer::body_set_state(RID p_body, BodyState p_state, const Variant &p_variant) {
- RigidBodyBullet *body = rigid_body_owner.get(p_body);
+ RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_state(p_state, p_variant);
}
Variant BulletPhysicsServer::body_get_state(RID p_body, BodyState p_state) const {
- RigidBodyBullet *body = rigid_body_owner.get(p_body);
+ RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, Variant());
return body->get_state(p_state);
}
void BulletPhysicsServer::body_set_applied_force(RID p_body, const Vector3 &p_force) {
- RigidBodyBullet *body = rigid_body_owner.get(p_body);
+ RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_applied_force(p_force);
}
Vector3 BulletPhysicsServer::body_get_applied_force(RID p_body) const {
- RigidBodyBullet *body = rigid_body_owner.get(p_body);
+ RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, Vector3());
return body->get_applied_force();
}
void BulletPhysicsServer::body_set_applied_torque(RID p_body, const Vector3 &p_torque) {
- RigidBodyBullet *body = rigid_body_owner.get(p_body);
+ RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_applied_torque(p_torque);
}
Vector3 BulletPhysicsServer::body_get_applied_torque(RID p_body) const {
- RigidBodyBullet *body = rigid_body_owner.get(p_body);
+ RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, Vector3());
return body->get_applied_torque();
}
void BulletPhysicsServer::body_add_central_force(RID p_body, const Vector3 &p_force) {
- RigidBodyBullet *body = rigid_body_owner.get(p_body);
+ RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->apply_central_force(p_force);
}
void BulletPhysicsServer::body_add_force(RID p_body, const Vector3 &p_force, const Vector3 &p_pos) {
- RigidBodyBullet *body = rigid_body_owner.get(p_body);
+ RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->apply_force(p_force, p_pos);
}
void BulletPhysicsServer::body_add_torque(RID p_body, const Vector3 &p_torque) {
- RigidBodyBullet *body = rigid_body_owner.get(p_body);
+ RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->apply_torque(p_torque);
}
void BulletPhysicsServer::body_apply_central_impulse(RID p_body, const Vector3 &p_impulse) {
- RigidBodyBullet *body = rigid_body_owner.get(p_body);
+ RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->apply_central_impulse(p_impulse);
}
void BulletPhysicsServer::body_apply_impulse(RID p_body, const Vector3 &p_pos, const Vector3 &p_impulse) {
- RigidBodyBullet *body = rigid_body_owner.get(p_body);
+ RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->apply_impulse(p_pos, p_impulse);
}
void BulletPhysicsServer::body_apply_torque_impulse(RID p_body, const Vector3 &p_impulse) {
- RigidBodyBullet *body = rigid_body_owner.get(p_body);
+ RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->apply_torque_impulse(p_impulse);
}
void BulletPhysicsServer::body_set_axis_velocity(RID p_body, const Vector3 &p_axis_velocity) {
- RigidBodyBullet *body = rigid_body_owner.get(p_body);
+ RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
Vector3 v = body->get_linear_velocity();
@@ -765,39 +765,39 @@ void BulletPhysicsServer::body_set_axis_velocity(RID p_body, const Vector3 &p_ax
}
void BulletPhysicsServer::body_set_axis_lock(RID p_body, BodyAxis p_axis, bool p_lock) {
- RigidBodyBullet *body = rigid_body_owner.get(p_body);
+ RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_axis_lock(p_axis, p_lock);
}
bool BulletPhysicsServer::body_is_axis_locked(RID p_body, BodyAxis p_axis) const {
- const RigidBodyBullet *body = rigid_body_owner.get(p_body);
+ const RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0);
return body->is_axis_locked(p_axis);
}
void BulletPhysicsServer::body_add_collision_exception(RID p_body, RID p_body_b) {
- RigidBodyBullet *body = rigid_body_owner.get(p_body);
+ RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
- RigidBodyBullet *other_body = rigid_body_owner.get(p_body_b);
+ RigidBodyBullet *other_body = rigid_body_owner.getornull(p_body_b);
ERR_FAIL_COND(!other_body);
body->add_collision_exception(other_body);
}
void BulletPhysicsServer::body_remove_collision_exception(RID p_body, RID p_body_b) {
- RigidBodyBullet *body = rigid_body_owner.get(p_body);
+ RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
- RigidBodyBullet *other_body = rigid_body_owner.get(p_body_b);
+ RigidBodyBullet *other_body = rigid_body_owner.getornull(p_body_b);
ERR_FAIL_COND(!other_body);
body->remove_collision_exception(other_body);
}
void BulletPhysicsServer::body_get_collision_exceptions(RID p_body, List<RID> *p_exceptions) {
- RigidBodyBullet *body = rigid_body_owner.get(p_body);
+ RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
for (int i = 0; i < body->get_exceptions().size(); i++) {
p_exceptions->push_back(body->get_exceptions()[i]);
@@ -805,14 +805,14 @@ void BulletPhysicsServer::body_get_collision_exceptions(RID p_body, List<RID> *p
}
void BulletPhysicsServer::body_set_max_contacts_reported(RID p_body, int p_contacts) {
- RigidBodyBullet *body = rigid_body_owner.get(p_body);
+ RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_max_collisions_detection(p_contacts);
}
int BulletPhysicsServer::body_get_max_contacts_reported(RID p_body) const {
- RigidBodyBullet *body = rigid_body_owner.get(p_body);
+ RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0);
return body->get_max_collisions_detection();
@@ -828,45 +828,45 @@ float BulletPhysicsServer::body_get_contacts_reported_depth_threshold(RID p_body
}
void BulletPhysicsServer::body_set_omit_force_integration(RID p_body, bool p_omit) {
- RigidBodyBullet *body = rigid_body_owner.get(p_body);
+ RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_omit_forces_integration(p_omit);
}
bool BulletPhysicsServer::body_is_omitting_force_integration(RID p_body) const {
- RigidBodyBullet *body = rigid_body_owner.get(p_body);
+ RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, false);
return body->get_omit_forces_integration();
}
void BulletPhysicsServer::body_set_force_integration_callback(RID p_body, Object *p_receiver, const StringName &p_method, const Variant &p_udata) {
- RigidBodyBullet *body = rigid_body_owner.get(p_body);
+ RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
- body->set_force_integration_callback(p_receiver ? p_receiver->get_instance_id() : ObjectID(0), p_method, p_udata);
+ body->set_force_integration_callback(p_receiver ? p_receiver->get_instance_id() : ObjectID(), p_method, p_udata);
}
void BulletPhysicsServer::body_set_ray_pickable(RID p_body, bool p_enable) {
- RigidBodyBullet *body = rigid_body_owner.get(p_body);
+ RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_ray_pickable(p_enable);
}
bool BulletPhysicsServer::body_is_ray_pickable(RID p_body) const {
- RigidBodyBullet *body = rigid_body_owner.get(p_body);
+ RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, false);
return body->is_ray_pickable();
}
PhysicsDirectBodyState *BulletPhysicsServer::body_get_direct_state(RID p_body) {
- RigidBodyBullet *body = rigid_body_owner.get(p_body);
+ RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, NULL);
return BulletPhysicsDirectBodyState::get_singleton(body);
}
bool BulletPhysicsServer::body_test_motion(RID p_body, const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia, MotionResult *r_result, bool p_exclude_raycast_shapes) {
- RigidBodyBullet *body = rigid_body_owner.get(p_body);
+ RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, false);
ERR_FAIL_COND_V(!body->get_space(), false);
@@ -874,7 +874,7 @@ bool BulletPhysicsServer::body_test_motion(RID p_body, const Transform &p_from,
}
int BulletPhysicsServer::body_test_ray_separation(RID p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, SeparationResult *r_results, int p_result_max, float p_margin) {
- RigidBodyBullet *body = rigid_body_owner.get(p_body);
+ RigidBodyBullet *body = rigid_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0);
ERR_FAIL_COND_V(!body->get_space(), 0);
@@ -891,19 +891,19 @@ RID BulletPhysicsServer::soft_body_create(bool p_init_sleeping) {
}
void BulletPhysicsServer::soft_body_update_visual_server(RID p_body, class SoftBodyVisualServerHandler *p_visual_server_handler) {
- SoftBodyBullet *body = soft_body_owner.get(p_body);
+ SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->update_visual_server(p_visual_server_handler);
}
void BulletPhysicsServer::soft_body_set_space(RID p_body, RID p_space) {
- SoftBodyBullet *body = soft_body_owner.get(p_body);
+ SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
SpaceBullet *space = NULL;
if (p_space.is_valid()) {
- space = space_owner.get(p_space);
+ space = space_owner.getornull(p_space);
ERR_FAIL_COND(!space);
}
@@ -914,7 +914,7 @@ void BulletPhysicsServer::soft_body_set_space(RID p_body, RID p_space) {
}
RID BulletPhysicsServer::soft_body_get_space(RID p_body) const {
- SoftBodyBullet *body = soft_body_owner.get(p_body);
+ SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, RID());
SpaceBullet *space = body->get_space();
@@ -924,47 +924,47 @@ RID BulletPhysicsServer::soft_body_get_space(RID p_body) const {
}
void BulletPhysicsServer::soft_body_set_mesh(RID p_body, const REF &p_mesh) {
- SoftBodyBullet *body = soft_body_owner.get(p_body);
+ SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_soft_mesh(p_mesh);
}
void BulletPhysicsServer::soft_body_set_collision_layer(RID p_body, uint32_t p_layer) {
- SoftBodyBullet *body = soft_body_owner.get(p_body);
+ SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_collision_layer(p_layer);
}
uint32_t BulletPhysicsServer::soft_body_get_collision_layer(RID p_body) const {
- const SoftBodyBullet *body = soft_body_owner.get(p_body);
+ const SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0);
return body->get_collision_layer();
}
void BulletPhysicsServer::soft_body_set_collision_mask(RID p_body, uint32_t p_mask) {
- SoftBodyBullet *body = soft_body_owner.get(p_body);
+ SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_collision_mask(p_mask);
}
uint32_t BulletPhysicsServer::soft_body_get_collision_mask(RID p_body) const {
- const SoftBodyBullet *body = soft_body_owner.get(p_body);
+ const SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0);
return body->get_collision_mask();
}
void BulletPhysicsServer::soft_body_add_collision_exception(RID p_body, RID p_body_b) {
- SoftBodyBullet *body = soft_body_owner.get(p_body);
+ SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
- CollisionObjectBullet *other_body = rigid_body_owner.get(p_body_b);
+ CollisionObjectBullet *other_body = rigid_body_owner.getornull(p_body_b);
if (!other_body) {
- other_body = soft_body_owner.get(p_body_b);
+ other_body = soft_body_owner.getornull(p_body_b);
}
ERR_FAIL_COND(!other_body);
@@ -972,12 +972,12 @@ void BulletPhysicsServer::soft_body_add_collision_exception(RID p_body, RID p_bo
}
void BulletPhysicsServer::soft_body_remove_collision_exception(RID p_body, RID p_body_b) {
- SoftBodyBullet *body = soft_body_owner.get(p_body);
+ SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
- CollisionObjectBullet *other_body = rigid_body_owner.get(p_body_b);
+ CollisionObjectBullet *other_body = rigid_body_owner.getornull(p_body_b);
if (!other_body) {
- other_body = soft_body_owner.get(p_body_b);
+ other_body = soft_body_owner.getornull(p_body_b);
}
ERR_FAIL_COND(!other_body);
@@ -985,7 +985,7 @@ void BulletPhysicsServer::soft_body_remove_collision_exception(RID p_body, RID p
}
void BulletPhysicsServer::soft_body_get_collision_exceptions(RID p_body, List<RID> *p_exceptions) {
- SoftBodyBullet *body = soft_body_owner.get(p_body);
+ SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
for (int i = 0; i < body->get_exceptions().size(); i++) {
p_exceptions->push_back(body->get_exceptions()[i]);
@@ -1004,14 +1004,14 @@ Variant BulletPhysicsServer::soft_body_get_state(RID p_body, BodyState p_state)
}
void BulletPhysicsServer::soft_body_set_transform(RID p_body, const Transform &p_transform) {
- SoftBodyBullet *body = soft_body_owner.get(p_body);
+ SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_soft_transform(p_transform);
}
Vector3 BulletPhysicsServer::soft_body_get_vertex_position(RID p_body, int vertex_index) const {
- const SoftBodyBullet *body = soft_body_owner.get(p_body);
+ const SoftBodyBullet *body = soft_body_owner.getornull(p_body);
Vector3 pos;
ERR_FAIL_COND_V(!body, pos);
@@ -1020,133 +1020,133 @@ Vector3 BulletPhysicsServer::soft_body_get_vertex_position(RID p_body, int verte
}
void BulletPhysicsServer::soft_body_set_ray_pickable(RID p_body, bool p_enable) {
- SoftBodyBullet *body = soft_body_owner.get(p_body);
+ SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_ray_pickable(p_enable);
}
bool BulletPhysicsServer::soft_body_is_ray_pickable(RID p_body) const {
- SoftBodyBullet *body = soft_body_owner.get(p_body);
+ SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, false);
return body->is_ray_pickable();
}
void BulletPhysicsServer::soft_body_set_simulation_precision(RID p_body, int p_simulation_precision) {
- SoftBodyBullet *body = soft_body_owner.get(p_body);
+ SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_simulation_precision(p_simulation_precision);
}
int BulletPhysicsServer::soft_body_get_simulation_precision(RID p_body) {
- SoftBodyBullet *body = soft_body_owner.get(p_body);
+ SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0.f);
return body->get_simulation_precision();
}
void BulletPhysicsServer::soft_body_set_total_mass(RID p_body, real_t p_total_mass) {
- SoftBodyBullet *body = soft_body_owner.get(p_body);
+ SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_total_mass(p_total_mass);
}
real_t BulletPhysicsServer::soft_body_get_total_mass(RID p_body) {
- SoftBodyBullet *body = soft_body_owner.get(p_body);
+ SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0.f);
return body->get_total_mass();
}
void BulletPhysicsServer::soft_body_set_linear_stiffness(RID p_body, real_t p_stiffness) {
- SoftBodyBullet *body = soft_body_owner.get(p_body);
+ SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_linear_stiffness(p_stiffness);
}
real_t BulletPhysicsServer::soft_body_get_linear_stiffness(RID p_body) {
- SoftBodyBullet *body = soft_body_owner.get(p_body);
+ SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0.f);
return body->get_linear_stiffness();
}
void BulletPhysicsServer::soft_body_set_areaAngular_stiffness(RID p_body, real_t p_stiffness) {
- SoftBodyBullet *body = soft_body_owner.get(p_body);
+ SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_areaAngular_stiffness(p_stiffness);
}
real_t BulletPhysicsServer::soft_body_get_areaAngular_stiffness(RID p_body) {
- SoftBodyBullet *body = soft_body_owner.get(p_body);
+ SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0.f);
return body->get_areaAngular_stiffness();
}
void BulletPhysicsServer::soft_body_set_volume_stiffness(RID p_body, real_t p_stiffness) {
- SoftBodyBullet *body = soft_body_owner.get(p_body);
+ SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_volume_stiffness(p_stiffness);
}
real_t BulletPhysicsServer::soft_body_get_volume_stiffness(RID p_body) {
- SoftBodyBullet *body = soft_body_owner.get(p_body);
+ SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0.f);
return body->get_volume_stiffness();
}
void BulletPhysicsServer::soft_body_set_pressure_coefficient(RID p_body, real_t p_pressure_coefficient) {
- SoftBodyBullet *body = soft_body_owner.get(p_body);
+ SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_pressure_coefficient(p_pressure_coefficient);
}
real_t BulletPhysicsServer::soft_body_get_pressure_coefficient(RID p_body) {
- SoftBodyBullet *body = soft_body_owner.get(p_body);
+ SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0.f);
return body->get_pressure_coefficient();
}
void BulletPhysicsServer::soft_body_set_pose_matching_coefficient(RID p_body, real_t p_pose_matching_coefficient) {
- SoftBodyBullet *body = soft_body_owner.get(p_body);
+ SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
return body->set_pose_matching_coefficient(p_pose_matching_coefficient);
}
real_t BulletPhysicsServer::soft_body_get_pose_matching_coefficient(RID p_body) {
- SoftBodyBullet *body = soft_body_owner.get(p_body);
+ SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0.f);
return body->get_pose_matching_coefficient();
}
void BulletPhysicsServer::soft_body_set_damping_coefficient(RID p_body, real_t p_damping_coefficient) {
- SoftBodyBullet *body = soft_body_owner.get(p_body);
+ SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_damping_coefficient(p_damping_coefficient);
}
real_t BulletPhysicsServer::soft_body_get_damping_coefficient(RID p_body) {
- SoftBodyBullet *body = soft_body_owner.get(p_body);
+ SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0.f);
return body->get_damping_coefficient();
}
void BulletPhysicsServer::soft_body_set_drag_coefficient(RID p_body, real_t p_drag_coefficient) {
- SoftBodyBullet *body = soft_body_owner.get(p_body);
+ SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_drag_coefficient(p_drag_coefficient);
}
real_t BulletPhysicsServer::soft_body_get_drag_coefficient(RID p_body) {
- SoftBodyBullet *body = soft_body_owner.get(p_body);
+ SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0.f);
return body->get_drag_coefficient();
}
void BulletPhysicsServer::soft_body_move_point(RID p_body, int p_point_index, const Vector3 &p_global_position) {
- SoftBodyBullet *body = soft_body_owner.get(p_body);
+ SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_node_position(p_point_index, p_global_position);
}
Vector3 BulletPhysicsServer::soft_body_get_point_global_position(RID p_body, int p_point_index) {
- SoftBodyBullet *body = soft_body_owner.get(p_body);
+ SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, Vector3(0., 0., 0.));
Vector3 pos;
body->get_node_position(p_point_index, pos);
@@ -1154,7 +1154,7 @@ Vector3 BulletPhysicsServer::soft_body_get_point_global_position(RID p_body, int
}
Vector3 BulletPhysicsServer::soft_body_get_point_offset(RID p_body, int p_point_index) const {
- SoftBodyBullet *body = soft_body_owner.get(p_body);
+ SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, Vector3());
Vector3 res;
body->get_node_offset(p_point_index, res);
@@ -1162,25 +1162,25 @@ Vector3 BulletPhysicsServer::soft_body_get_point_offset(RID p_body, int p_point_
}
void BulletPhysicsServer::soft_body_remove_all_pinned_points(RID p_body) {
- SoftBodyBullet *body = soft_body_owner.get(p_body);
+ SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->reset_all_node_mass();
}
void BulletPhysicsServer::soft_body_pin_point(RID p_body, int p_point_index, bool p_pin) {
- SoftBodyBullet *body = soft_body_owner.get(p_body);
+ SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_node_mass(p_point_index, p_pin ? 0 : 1);
}
bool BulletPhysicsServer::soft_body_is_point_pinned(RID p_body, int p_point_index) {
- SoftBodyBullet *body = soft_body_owner.get(p_body);
+ SoftBodyBullet *body = soft_body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0.f);
return body->get_node_mass(p_point_index);
}
PhysicsServer::JointType BulletPhysicsServer::joint_get_type(RID p_joint) const {
- JointBullet *joint = joint_owner.get(p_joint);
+ JointBullet *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND_V(!joint, JOINT_PIN);
return joint->get_type();
}
@@ -1195,28 +1195,28 @@ int BulletPhysicsServer::joint_get_solver_priority(RID p_joint) const {
}
void BulletPhysicsServer::joint_disable_collisions_between_bodies(RID p_joint, const bool p_disable) {
- JointBullet *joint = joint_owner.get(p_joint);
+ JointBullet *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND(!joint);
joint->disable_collisions_between_bodies(p_disable);
}
bool BulletPhysicsServer::joint_is_disabled_collisions_between_bodies(RID p_joint) const {
- JointBullet *joint(joint_owner.get(p_joint));
+ JointBullet *joint(joint_owner.getornull(p_joint));
ERR_FAIL_COND_V(!joint, false);
return joint->is_disabled_collisions_between_bodies();
}
RID BulletPhysicsServer::joint_create_pin(RID p_body_A, const Vector3 &p_local_A, RID p_body_B, const Vector3 &p_local_B) {
- RigidBodyBullet *body_A = rigid_body_owner.get(p_body_A);
+ RigidBodyBullet *body_A = rigid_body_owner.getornull(p_body_A);
ERR_FAIL_COND_V(!body_A, RID());
JointAssertSpace(body_A, "A", RID());
RigidBodyBullet *body_B = NULL;
if (p_body_B.is_valid()) {
- body_B = rigid_body_owner.get(p_body_B);
+ body_B = rigid_body_owner.getornull(p_body_B);
JointAssertSpace(body_B, "B", RID());
JointAssertSameSpace(body_A, body_B, RID());
}
@@ -1230,7 +1230,7 @@ RID BulletPhysicsServer::joint_create_pin(RID p_body_A, const Vector3 &p_local_A
}
void BulletPhysicsServer::pin_joint_set_param(RID p_joint, PinJointParam p_param, float p_value) {
- JointBullet *joint = joint_owner.get(p_joint);
+ JointBullet *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_PIN);
PinJointBullet *pin_joint = static_cast<PinJointBullet *>(joint);
@@ -1238,7 +1238,7 @@ void BulletPhysicsServer::pin_joint_set_param(RID p_joint, PinJointParam p_param
}
float BulletPhysicsServer::pin_joint_get_param(RID p_joint, PinJointParam p_param) const {
- JointBullet *joint = joint_owner.get(p_joint);
+ JointBullet *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND_V(!joint, 0);
ERR_FAIL_COND_V(joint->get_type() != JOINT_PIN, 0);
PinJointBullet *pin_joint = static_cast<PinJointBullet *>(joint);
@@ -1246,7 +1246,7 @@ float BulletPhysicsServer::pin_joint_get_param(RID p_joint, PinJointParam p_para
}
void BulletPhysicsServer::pin_joint_set_local_a(RID p_joint, const Vector3 &p_A) {
- JointBullet *joint = joint_owner.get(p_joint);
+ JointBullet *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_PIN);
PinJointBullet *pin_joint = static_cast<PinJointBullet *>(joint);
@@ -1254,7 +1254,7 @@ void BulletPhysicsServer::pin_joint_set_local_a(RID p_joint, const Vector3 &p_A)
}
Vector3 BulletPhysicsServer::pin_joint_get_local_a(RID p_joint) const {
- JointBullet *joint = joint_owner.get(p_joint);
+ JointBullet *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND_V(!joint, Vector3());
ERR_FAIL_COND_V(joint->get_type() != JOINT_PIN, Vector3());
PinJointBullet *pin_joint = static_cast<PinJointBullet *>(joint);
@@ -1262,7 +1262,7 @@ Vector3 BulletPhysicsServer::pin_joint_get_local_a(RID p_joint) const {
}
void BulletPhysicsServer::pin_joint_set_local_b(RID p_joint, const Vector3 &p_B) {
- JointBullet *joint = joint_owner.get(p_joint);
+ JointBullet *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_PIN);
PinJointBullet *pin_joint = static_cast<PinJointBullet *>(joint);
@@ -1270,7 +1270,7 @@ void BulletPhysicsServer::pin_joint_set_local_b(RID p_joint, const Vector3 &p_B)
}
Vector3 BulletPhysicsServer::pin_joint_get_local_b(RID p_joint) const {
- JointBullet *joint = joint_owner.get(p_joint);
+ JointBullet *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND_V(!joint, Vector3());
ERR_FAIL_COND_V(joint->get_type() != JOINT_PIN, Vector3());
PinJointBullet *pin_joint = static_cast<PinJointBullet *>(joint);
@@ -1278,13 +1278,13 @@ Vector3 BulletPhysicsServer::pin_joint_get_local_b(RID p_joint) const {
}
RID BulletPhysicsServer::joint_create_hinge(RID p_body_A, const Transform &p_hinge_A, RID p_body_B, const Transform &p_hinge_B) {
- RigidBodyBullet *body_A = rigid_body_owner.get(p_body_A);
+ RigidBodyBullet *body_A = rigid_body_owner.getornull(p_body_A);
ERR_FAIL_COND_V(!body_A, RID());
JointAssertSpace(body_A, "A", RID());
RigidBodyBullet *body_B = NULL;
if (p_body_B.is_valid()) {
- body_B = rigid_body_owner.get(p_body_B);
+ body_B = rigid_body_owner.getornull(p_body_B);
JointAssertSpace(body_B, "B", RID());
JointAssertSameSpace(body_A, body_B, RID());
}
@@ -1298,13 +1298,13 @@ RID BulletPhysicsServer::joint_create_hinge(RID p_body_A, const Transform &p_hin
}
RID BulletPhysicsServer::joint_create_hinge_simple(RID p_body_A, const Vector3 &p_pivot_A, const Vector3 &p_axis_A, RID p_body_B, const Vector3 &p_pivot_B, const Vector3 &p_axis_B) {
- RigidBodyBullet *body_A = rigid_body_owner.get(p_body_A);
+ RigidBodyBullet *body_A = rigid_body_owner.getornull(p_body_A);
ERR_FAIL_COND_V(!body_A, RID());
JointAssertSpace(body_A, "A", RID());
RigidBodyBullet *body_B = NULL;
if (p_body_B.is_valid()) {
- body_B = rigid_body_owner.get(p_body_B);
+ body_B = rigid_body_owner.getornull(p_body_B);
JointAssertSpace(body_B, "B", RID());
JointAssertSameSpace(body_A, body_B, RID());
}
@@ -1318,7 +1318,7 @@ RID BulletPhysicsServer::joint_create_hinge_simple(RID p_body_A, const Vector3 &
}
void BulletPhysicsServer::hinge_joint_set_param(RID p_joint, HingeJointParam p_param, float p_value) {
- JointBullet *joint = joint_owner.get(p_joint);
+ JointBullet *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_HINGE);
HingeJointBullet *hinge_joint = static_cast<HingeJointBullet *>(joint);
@@ -1326,7 +1326,7 @@ void BulletPhysicsServer::hinge_joint_set_param(RID p_joint, HingeJointParam p_p
}
float BulletPhysicsServer::hinge_joint_get_param(RID p_joint, HingeJointParam p_param) const {
- JointBullet *joint = joint_owner.get(p_joint);
+ JointBullet *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND_V(!joint, 0);
ERR_FAIL_COND_V(joint->get_type() != JOINT_HINGE, 0);
HingeJointBullet *hinge_joint = static_cast<HingeJointBullet *>(joint);
@@ -1334,7 +1334,7 @@ float BulletPhysicsServer::hinge_joint_get_param(RID p_joint, HingeJointParam p_
}
void BulletPhysicsServer::hinge_joint_set_flag(RID p_joint, HingeJointFlag p_flag, bool p_value) {
- JointBullet *joint = joint_owner.get(p_joint);
+ JointBullet *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_HINGE);
HingeJointBullet *hinge_joint = static_cast<HingeJointBullet *>(joint);
@@ -1342,7 +1342,7 @@ void BulletPhysicsServer::hinge_joint_set_flag(RID p_joint, HingeJointFlag p_fla
}
bool BulletPhysicsServer::hinge_joint_get_flag(RID p_joint, HingeJointFlag p_flag) const {
- JointBullet *joint = joint_owner.get(p_joint);
+ JointBullet *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND_V(!joint, false);
ERR_FAIL_COND_V(joint->get_type() != JOINT_HINGE, false);
HingeJointBullet *hinge_joint = static_cast<HingeJointBullet *>(joint);
@@ -1350,13 +1350,13 @@ bool BulletPhysicsServer::hinge_joint_get_flag(RID p_joint, HingeJointFlag p_fla
}
RID BulletPhysicsServer::joint_create_slider(RID p_body_A, const Transform &p_local_frame_A, RID p_body_B, const Transform &p_local_frame_B) {
- RigidBodyBullet *body_A = rigid_body_owner.get(p_body_A);
+ RigidBodyBullet *body_A = rigid_body_owner.getornull(p_body_A);
ERR_FAIL_COND_V(!body_A, RID());
JointAssertSpace(body_A, "A", RID());
RigidBodyBullet *body_B = NULL;
if (p_body_B.is_valid()) {
- body_B = rigid_body_owner.get(p_body_B);
+ body_B = rigid_body_owner.getornull(p_body_B);
JointAssertSpace(body_B, "B", RID());
JointAssertSameSpace(body_A, body_B, RID());
}
@@ -1370,7 +1370,7 @@ RID BulletPhysicsServer::joint_create_slider(RID p_body_A, const Transform &p_lo
}
void BulletPhysicsServer::slider_joint_set_param(RID p_joint, SliderJointParam p_param, float p_value) {
- JointBullet *joint = joint_owner.get(p_joint);
+ JointBullet *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_SLIDER);
SliderJointBullet *slider_joint = static_cast<SliderJointBullet *>(joint);
@@ -1378,7 +1378,7 @@ void BulletPhysicsServer::slider_joint_set_param(RID p_joint, SliderJointParam p
}
float BulletPhysicsServer::slider_joint_get_param(RID p_joint, SliderJointParam p_param) const {
- JointBullet *joint = joint_owner.get(p_joint);
+ JointBullet *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND_V(!joint, 0);
ERR_FAIL_COND_V(joint->get_type() != JOINT_SLIDER, 0);
SliderJointBullet *slider_joint = static_cast<SliderJointBullet *>(joint);
@@ -1386,13 +1386,13 @@ float BulletPhysicsServer::slider_joint_get_param(RID p_joint, SliderJointParam
}
RID BulletPhysicsServer::joint_create_cone_twist(RID p_body_A, const Transform &p_local_frame_A, RID p_body_B, const Transform &p_local_frame_B) {
- RigidBodyBullet *body_A = rigid_body_owner.get(p_body_A);
+ RigidBodyBullet *body_A = rigid_body_owner.getornull(p_body_A);
ERR_FAIL_COND_V(!body_A, RID());
JointAssertSpace(body_A, "A", RID());
RigidBodyBullet *body_B = NULL;
if (p_body_B.is_valid()) {
- body_B = rigid_body_owner.get(p_body_B);
+ body_B = rigid_body_owner.getornull(p_body_B);
JointAssertSpace(body_B, "B", RID());
JointAssertSameSpace(body_A, body_B, RID());
}
@@ -1404,7 +1404,7 @@ RID BulletPhysicsServer::joint_create_cone_twist(RID p_body_A, const Transform &
}
void BulletPhysicsServer::cone_twist_joint_set_param(RID p_joint, ConeTwistJointParam p_param, float p_value) {
- JointBullet *joint = joint_owner.get(p_joint);
+ JointBullet *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_CONE_TWIST);
ConeTwistJointBullet *coneTwist_joint = static_cast<ConeTwistJointBullet *>(joint);
@@ -1412,7 +1412,7 @@ void BulletPhysicsServer::cone_twist_joint_set_param(RID p_joint, ConeTwistJoint
}
float BulletPhysicsServer::cone_twist_joint_get_param(RID p_joint, ConeTwistJointParam p_param) const {
- JointBullet *joint = joint_owner.get(p_joint);
+ JointBullet *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND_V(!joint, 0.);
ERR_FAIL_COND_V(joint->get_type() != JOINT_CONE_TWIST, 0.);
ConeTwistJointBullet *coneTwist_joint = static_cast<ConeTwistJointBullet *>(joint);
@@ -1420,13 +1420,13 @@ float BulletPhysicsServer::cone_twist_joint_get_param(RID p_joint, ConeTwistJoin
}
RID BulletPhysicsServer::joint_create_generic_6dof(RID p_body_A, const Transform &p_local_frame_A, RID p_body_B, const Transform &p_local_frame_B) {
- RigidBodyBullet *body_A = rigid_body_owner.get(p_body_A);
+ RigidBodyBullet *body_A = rigid_body_owner.getornull(p_body_A);
ERR_FAIL_COND_V(!body_A, RID());
JointAssertSpace(body_A, "A", RID());
RigidBodyBullet *body_B = NULL;
if (p_body_B.is_valid()) {
- body_B = rigid_body_owner.get(p_body_B);
+ body_B = rigid_body_owner.getornull(p_body_B);
JointAssertSpace(body_B, "B", RID());
JointAssertSameSpace(body_A, body_B, RID());
}
@@ -1440,7 +1440,7 @@ RID BulletPhysicsServer::joint_create_generic_6dof(RID p_body_A, const Transform
}
void BulletPhysicsServer::generic_6dof_joint_set_param(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisParam p_param, float p_value) {
- JointBullet *joint = joint_owner.get(p_joint);
+ JointBullet *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_6DOF);
Generic6DOFJointBullet *generic_6dof_joint = static_cast<Generic6DOFJointBullet *>(joint);
@@ -1448,7 +1448,7 @@ void BulletPhysicsServer::generic_6dof_joint_set_param(RID p_joint, Vector3::Axi
}
float BulletPhysicsServer::generic_6dof_joint_get_param(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisParam p_param) {
- JointBullet *joint = joint_owner.get(p_joint);
+ JointBullet *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND_V(!joint, 0);
ERR_FAIL_COND_V(joint->get_type() != JOINT_6DOF, 0);
Generic6DOFJointBullet *generic_6dof_joint = static_cast<Generic6DOFJointBullet *>(joint);
@@ -1456,7 +1456,7 @@ float BulletPhysicsServer::generic_6dof_joint_get_param(RID p_joint, Vector3::Ax
}
void BulletPhysicsServer::generic_6dof_joint_set_flag(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisFlag p_flag, bool p_enable) {
- JointBullet *joint = joint_owner.get(p_joint);
+ JointBullet *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_6DOF);
Generic6DOFJointBullet *generic_6dof_joint = static_cast<Generic6DOFJointBullet *>(joint);
@@ -1464,7 +1464,7 @@ void BulletPhysicsServer::generic_6dof_joint_set_flag(RID p_joint, Vector3::Axis
}
bool BulletPhysicsServer::generic_6dof_joint_get_flag(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisFlag p_flag) {
- JointBullet *joint = joint_owner.get(p_joint);
+ JointBullet *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND_V(!joint, false);
ERR_FAIL_COND_V(joint->get_type() != JOINT_6DOF, false);
Generic6DOFJointBullet *generic_6dof_joint = static_cast<Generic6DOFJointBullet *>(joint);
@@ -1472,7 +1472,7 @@ bool BulletPhysicsServer::generic_6dof_joint_get_flag(RID p_joint, Vector3::Axis
}
void BulletPhysicsServer::generic_6dof_joint_set_precision(RID p_joint, int p_precision) {
- JointBullet *joint = joint_owner.get(p_joint);
+ JointBullet *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_6DOF);
Generic6DOFJointBullet *generic_6dof_joint = static_cast<Generic6DOFJointBullet *>(joint);
@@ -1480,7 +1480,7 @@ void BulletPhysicsServer::generic_6dof_joint_set_precision(RID p_joint, int p_pr
}
int BulletPhysicsServer::generic_6dof_joint_get_precision(RID p_joint) {
- JointBullet *joint = joint_owner.get(p_joint);
+ JointBullet *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND_V(!joint, 0);
ERR_FAIL_COND_V(joint->get_type() != JOINT_6DOF, 0);
Generic6DOFJointBullet *generic_6dof_joint = static_cast<Generic6DOFJointBullet *>(joint);
@@ -1490,7 +1490,7 @@ int BulletPhysicsServer::generic_6dof_joint_get_precision(RID p_joint) {
void BulletPhysicsServer::free(RID p_rid) {
if (shape_owner.owns(p_rid)) {
- ShapeBullet *shape = shape_owner.get(p_rid);
+ ShapeBullet *shape = shape_owner.getornull(p_rid);
// Notify the shape is configured
for (Map<ShapeOwnerBullet *, int>::Element *element = shape->get_owners().front(); element; element = element->next()) {
@@ -1501,7 +1501,7 @@ void BulletPhysicsServer::free(RID p_rid) {
bulletdelete(shape);
} else if (rigid_body_owner.owns(p_rid)) {
- RigidBodyBullet *body = rigid_body_owner.get(p_rid);
+ RigidBodyBullet *body = rigid_body_owner.getornull(p_rid);
body->set_space(NULL);
@@ -1512,7 +1512,7 @@ void BulletPhysicsServer::free(RID p_rid) {
} else if (soft_body_owner.owns(p_rid)) {
- SoftBodyBullet *body = soft_body_owner.get(p_rid);
+ SoftBodyBullet *body = soft_body_owner.getornull(p_rid);
body->set_space(NULL);
@@ -1521,7 +1521,7 @@ void BulletPhysicsServer::free(RID p_rid) {
} else if (area_owner.owns(p_rid)) {
- AreaBullet *area = area_owner.get(p_rid);
+ AreaBullet *area = area_owner.getornull(p_rid);
area->set_space(NULL);
@@ -1532,14 +1532,14 @@ void BulletPhysicsServer::free(RID p_rid) {
} else if (joint_owner.owns(p_rid)) {
- JointBullet *joint = joint_owner.get(p_rid);
+ JointBullet *joint = joint_owner.getornull(p_rid);
joint->destroy_internal_constraint();
joint_owner.free(p_rid);
bulletdelete(joint);
} else if (space_owner.owns(p_rid)) {
- SpaceBullet *space = space_owner.get(p_rid);
+ SpaceBullet *space = space_owner.getornull(p_rid);
space->remove_all_collision_objects();
diff --git a/modules/bullet/bullet_physics_server.h b/modules/bullet/bullet_physics_server.h
index 4a3b4a2edc..6ea9a7a974 100644
--- a/modules/bullet/bullet_physics_server.h
+++ b/modules/bullet/bullet_physics_server.h
@@ -33,13 +33,13 @@
#include "area_bullet.h"
#include "core/rid.h"
+#include "core/rid_owner.h"
#include "joint_bullet.h"
#include "rigid_body_bullet.h"
#include "servers/physics_server.h"
#include "shape_bullet.h"
#include "soft_body_bullet.h"
#include "space_bullet.h"
-
/**
@author AndreaCatania
*/
@@ -53,12 +53,12 @@ class BulletPhysicsServer : public PhysicsServer {
char active_spaces_count;
Vector<SpaceBullet *> active_spaces;
- mutable RID_Owner<SpaceBullet> space_owner;
- mutable RID_Owner<ShapeBullet> shape_owner;
- mutable RID_Owner<AreaBullet> area_owner;
- mutable RID_Owner<RigidBodyBullet> rigid_body_owner;
- mutable RID_Owner<SoftBodyBullet> soft_body_owner;
- mutable RID_Owner<JointBullet> joint_owner;
+ mutable RID_PtrOwner<SpaceBullet> space_owner;
+ mutable RID_PtrOwner<ShapeBullet> shape_owner;
+ mutable RID_PtrOwner<AreaBullet> area_owner;
+ mutable RID_PtrOwner<RigidBodyBullet> rigid_body_owner;
+ mutable RID_PtrOwner<SoftBodyBullet> soft_body_owner;
+ mutable RID_PtrOwner<JointBullet> joint_owner;
protected:
static void _bind_methods();
@@ -67,22 +67,22 @@ public:
BulletPhysicsServer();
~BulletPhysicsServer();
- _FORCE_INLINE_ RID_Owner<SpaceBullet> *get_space_owner() {
+ _FORCE_INLINE_ RID_PtrOwner<SpaceBullet> *get_space_owner() {
return &space_owner;
}
- _FORCE_INLINE_ RID_Owner<ShapeBullet> *get_shape_owner() {
+ _FORCE_INLINE_ RID_PtrOwner<ShapeBullet> *get_shape_owner() {
return &shape_owner;
}
- _FORCE_INLINE_ RID_Owner<AreaBullet> *get_area_owner() {
+ _FORCE_INLINE_ RID_PtrOwner<AreaBullet> *get_area_owner() {
return &area_owner;
}
- _FORCE_INLINE_ RID_Owner<RigidBodyBullet> *get_rigid_body_owner() {
+ _FORCE_INLINE_ RID_PtrOwner<RigidBodyBullet> *get_rigid_body_owner() {
return &rigid_body_owner;
}
- _FORCE_INLINE_ RID_Owner<SoftBodyBullet> *get_soft_body_owner() {
+ _FORCE_INLINE_ RID_PtrOwner<SoftBodyBullet> *get_soft_body_owner() {
return &soft_body_owner;
}
- _FORCE_INLINE_ RID_Owner<JointBullet> *get_joint_owner() {
+ _FORCE_INLINE_ RID_PtrOwner<JointBullet> *get_joint_owner() {
return &joint_owner;
}
@@ -189,8 +189,8 @@ public:
virtual void body_clear_shapes(RID p_body);
// Used for Rigid and Soft Bodies
- virtual void body_attach_object_instance_id(RID p_body, uint32_t p_id);
- virtual uint32_t body_get_object_instance_id(RID p_body) const;
+ virtual void body_attach_object_instance_id(RID p_body, ObjectID p_id);
+ virtual ObjectID body_get_object_instance_id(RID p_body) const;
virtual void body_set_enable_continuous_collision_detection(RID p_body, bool p_enable);
virtual bool body_is_continuous_collision_detection_enabled(RID p_body) const;
diff --git a/modules/bullet/collision_object_bullet.cpp b/modules/bullet/collision_object_bullet.cpp
index c916c65d2b..5b7e7281e4 100644
--- a/modules/bullet/collision_object_bullet.cpp
+++ b/modules/bullet/collision_object_bullet.cpp
@@ -90,7 +90,7 @@ void CollisionObjectBullet::ShapeWrapper::claim_bt_shape(const btVector3 &body_s
CollisionObjectBullet::CollisionObjectBullet(Type p_type) :
RIDBullet(),
type(p_type),
- instance_id(0),
+ instance_id(ObjectID()),
collisionLayer(0),
collisionMask(0),
collisionsEnabled(true),
diff --git a/modules/bullet/cone_twist_joint_bullet.cpp b/modules/bullet/cone_twist_joint_bullet.cpp
index afeafcc356..23eb39fe7e 100644
--- a/modules/bullet/cone_twist_joint_bullet.cpp
+++ b/modules/bullet/cone_twist_joint_bullet.cpp
@@ -82,8 +82,8 @@ void ConeTwistJointBullet::set_param(PhysicsServer::ConeTwistJointParam p_param,
case PhysicsServer::CONE_TWIST_JOINT_RELAXATION:
coneConstraint->setLimit(coneConstraint->getSwingSpan1(), coneConstraint->getSwingSpan2(), coneConstraint->getTwistSpan(), coneConstraint->getLimitSoftness(), coneConstraint->getBiasFactor(), p_value);
break;
- default:
- WARN_DEPRECATED_MSG("The parameter " + itos(p_param) + " is deprecated.");
+ case PhysicsServer::CONE_TWIST_MAX:
+ // Internal size value, nothing to do.
break;
}
}
@@ -100,8 +100,10 @@ real_t ConeTwistJointBullet::get_param(PhysicsServer::ConeTwistJointParam p_para
return coneConstraint->getLimitSoftness();
case PhysicsServer::CONE_TWIST_JOINT_RELAXATION:
return coneConstraint->getRelaxationFactor();
- default:
- WARN_DEPRECATED_MSG("The parameter " + itos(p_param) + " is deprecated.");
+ case PhysicsServer::CONE_TWIST_MAX:
+ // Internal size value, nothing to do.
return 0;
}
+ // Compiler doesn't seem to notice that all code paths are fulfilled...
+ return 0;
}
diff --git a/modules/bullet/generic_6dof_joint_bullet.cpp b/modules/bullet/generic_6dof_joint_bullet.cpp
index 86bedd6c45..45ab3d3bb2 100644
--- a/modules/bullet/generic_6dof_joint_bullet.cpp
+++ b/modules/bullet/generic_6dof_joint_bullet.cpp
@@ -173,6 +173,9 @@ void Generic6DOFJointBullet::set_param(Vector3::Axis p_axis, PhysicsServer::G6DO
case PhysicsServer::G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT:
sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_equilibriumPoint = p_value;
break;
+ case PhysicsServer::G6DOF_JOINT_MAX:
+ // Internal size value, nothing to do.
+ break;
default:
WARN_DEPRECATED_MSG("The parameter " + itos(p_param) + " is deprecated.");
break;
@@ -214,6 +217,9 @@ real_t Generic6DOFJointBullet::get_param(Vector3::Axis p_axis, PhysicsServer::G6
return sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_springDamping;
case PhysicsServer::G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT:
return sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_equilibriumPoint;
+ case PhysicsServer::G6DOF_JOINT_MAX:
+ // Internal size value, nothing to do.
+ return 0;
default:
WARN_DEPRECATED_MSG("The parameter " + itos(p_param) + " is deprecated.");
return 0;
@@ -240,20 +246,20 @@ void Generic6DOFJointBullet::set_flag(Vector3::Axis p_axis, PhysicsServer::G6DOF
sixDOFConstraint->setLimit(p_axis + 3, 0, -1); // Free
}
break;
+ case PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_SPRING:
+ sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_enableSpring = p_value;
+ break;
+ case PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_LINEAR_SPRING:
+ sixDOFConstraint->getTranslationalLimitMotor()->m_enableSpring[p_axis] = p_value;
+ break;
case PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_MOTOR:
sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_enableMotor = flags[p_axis][p_flag];
break;
case PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_LINEAR_MOTOR:
sixDOFConstraint->getTranslationalLimitMotor()->m_enableMotor[p_axis] = flags[p_axis][p_flag];
break;
- case PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_LINEAR_SPRING:
- sixDOFConstraint->getTranslationalLimitMotor()->m_enableSpring[p_axis] = p_value;
- break;
- case PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_SPRING:
- sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_enableSpring = p_value;
- break;
- default:
- WARN_DEPRECATED_MSG("The flag " + itos(p_flag) + " is deprecated.");
+ case PhysicsServer::G6DOF_JOINT_FLAG_MAX:
+ // Internal size value, nothing to do.
break;
}
}
diff --git a/modules/bullet/godot_result_callbacks.cpp b/modules/bullet/godot_result_callbacks.cpp
index 6e54d10abf..20467e3ef3 100644
--- a/modules/bullet/godot_result_callbacks.cpp
+++ b/modules/bullet/godot_result_callbacks.cpp
@@ -112,7 +112,7 @@ btScalar GodotAllConvexResultCallback::addSingleResult(btCollisionWorld::LocalCo
result.shape = convexResult.m_localShapeInfo->m_triangleIndex; // "m_triangleIndex" Is a odd name but contains the compound shape ID
result.rid = gObj->get_self();
result.collider_id = gObj->get_instance_id();
- result.collider = 0 == result.collider_id ? NULL : ObjectDB::get_instance(result.collider_id);
+ result.collider = result.collider_id.is_null() ? NULL : ObjectDB::get_instance(result.collider_id);
++count;
return 1; // not used by bullet
@@ -220,7 +220,7 @@ btScalar GodotAllContactResultCallback::addSingleResult(btManifoldPoint &cp, con
}
result.collider_id = colObj->get_instance_id();
- result.collider = 0 == result.collider_id ? NULL : ObjectDB::get_instance(result.collider_id);
+ result.collider = result.collider_id.is_null() ? NULL : ObjectDB::get_instance(result.collider_id);
result.rid = colObj->get_self();
++m_count;
}
diff --git a/modules/bullet/hinge_joint_bullet.cpp b/modules/bullet/hinge_joint_bullet.cpp
index 49e67bfbc1..970732688a 100644
--- a/modules/bullet/hinge_joint_bullet.cpp
+++ b/modules/bullet/hinge_joint_bullet.cpp
@@ -95,6 +95,9 @@ real_t HingeJointBullet::get_hinge_angle() {
void HingeJointBullet::set_param(PhysicsServer::HingeJointParam p_param, real_t p_value) {
switch (p_param) {
+ case PhysicsServer::HINGE_JOINT_BIAS:
+ WARN_DEPRECATED_MSG("The HingeJoint parameter \"bias\" is deprecated.");
+ break;
case PhysicsServer::HINGE_JOINT_LIMIT_UPPER:
hingeConstraint->setLimit(hingeConstraint->getLowerLimit(), p_value, hingeConstraint->getLimitSoftness(), hingeConstraint->getLimitBiasFactor(), hingeConstraint->getLimitRelaxationFactor());
break;
@@ -116,8 +119,8 @@ void HingeJointBullet::set_param(PhysicsServer::HingeJointParam p_param, real_t
case PhysicsServer::HINGE_JOINT_MOTOR_MAX_IMPULSE:
hingeConstraint->setMaxMotorImpulse(p_value);
break;
- default:
- WARN_DEPRECATED_MSG("The HingeJoint parameter " + itos(p_param) + " is deprecated.");
+ case PhysicsServer::HINGE_JOINT_MAX:
+ // Internal size value, nothing to do.
break;
}
}
@@ -125,8 +128,8 @@ void HingeJointBullet::set_param(PhysicsServer::HingeJointParam p_param, real_t
real_t HingeJointBullet::get_param(PhysicsServer::HingeJointParam p_param) const {
switch (p_param) {
case PhysicsServer::HINGE_JOINT_BIAS:
+ WARN_DEPRECATED_MSG("The HingeJoint parameter \"bias\" is deprecated.");
return 0;
- break;
case PhysicsServer::HINGE_JOINT_LIMIT_UPPER:
return hingeConstraint->getUpperLimit();
case PhysicsServer::HINGE_JOINT_LIMIT_LOWER:
@@ -141,10 +144,12 @@ real_t HingeJointBullet::get_param(PhysicsServer::HingeJointParam p_param) const
return hingeConstraint->getMotorTargetVelocity();
case PhysicsServer::HINGE_JOINT_MOTOR_MAX_IMPULSE:
return hingeConstraint->getMaxMotorImpulse();
- default:
- WARN_DEPRECATED_MSG("The HingeJoint parameter " + itos(p_param) + " is deprecated.");
+ case PhysicsServer::HINGE_JOINT_MAX:
+ // Internal size value, nothing to do.
return 0;
}
+ // Compiler doesn't seem to notice that all code paths are fulfilled...
+ return 0;
}
void HingeJointBullet::set_flag(PhysicsServer::HingeJointFlag p_flag, bool p_value) {
diff --git a/modules/bullet/pin_joint_bullet.cpp b/modules/bullet/pin_joint_bullet.cpp
index 1c2e5e65cc..8d109f1866 100644
--- a/modules/bullet/pin_joint_bullet.cpp
+++ b/modules/bullet/pin_joint_bullet.cpp
@@ -84,10 +84,9 @@ real_t PinJointBullet::get_param(PhysicsServer::PinJointParam p_param) const {
return p2pConstraint->m_setting.m_damping;
case PhysicsServer::PIN_JOINT_IMPULSE_CLAMP:
return p2pConstraint->m_setting.m_impulseClamp;
- default:
- WARN_DEPRECATED_MSG("The parameter " + itos(p_param) + " is deprecated.");
- return 0;
}
+ // Compiler doesn't seem to notice that all code paths are fulfilled...
+ return 0;
}
void PinJointBullet::setPivotInA(const Vector3 &p_pos) {
diff --git a/modules/bullet/rid_bullet.h b/modules/bullet/rid_bullet.h
index 28bcedb01a..b76641ca54 100644
--- a/modules/bullet/rid_bullet.h
+++ b/modules/bullet/rid_bullet.h
@@ -39,7 +39,7 @@
class BulletPhysicsServer;
-class RIDBullet : public RID_Data {
+class RIDBullet {
RID self;
BulletPhysicsServer *physicsServer;
diff --git a/modules/bullet/rigid_body_bullet.cpp b/modules/bullet/rigid_body_bullet.cpp
index dfc9647813..d33c3a748c 100644
--- a/modules/bullet/rigid_body_bullet.cpp
+++ b/modules/bullet/rigid_body_bullet.cpp
@@ -366,11 +366,11 @@ void RigidBodyBullet::dispatch_callbacks() {
Object *obj = ObjectDB::get_instance(force_integration_callback->id);
if (!obj) {
// Remove integration callback
- set_force_integration_callback(0, StringName());
+ set_force_integration_callback(ObjectID(), StringName());
} else {
const Variant *vp[2] = { &variantBodyDirect, &force_integration_callback->udata };
- Variant::CallError responseCallError;
+ Callable::CallError responseCallError;
int argc = (force_integration_callback->udata.get_type() == Variant::NIL) ? 1 : 2;
obj->call(force_integration_callback->method, vp, argc, responseCallError);
}
@@ -395,7 +395,7 @@ void RigidBodyBullet::set_force_integration_callback(ObjectID p_id, const String
force_integration_callback = NULL;
}
- if (p_id != 0) {
+ if (p_id.is_valid()) {
force_integration_callback = memnew(ForceIntegrationCallback);
force_integration_callback->id = p_id;
force_integration_callback->method = p_method;
diff --git a/modules/bullet/shape_bullet.cpp b/modules/bullet/shape_bullet.cpp
index f46db09e4a..6780f89d9e 100644
--- a/modules/bullet/shape_bullet.cpp
+++ b/modules/bullet/shape_bullet.cpp
@@ -122,8 +122,8 @@ btBoxShape *ShapeBullet::create_shape_box(const btVector3 &boxHalfExtents) {
return bulletnew(btBoxShape(boxHalfExtents));
}
-btCapsuleShapeZ *ShapeBullet::create_shape_capsule(btScalar radius, btScalar height) {
- return bulletnew(btCapsuleShapeZ(radius, height));
+btCapsuleShape *ShapeBullet::create_shape_capsule(btScalar radius, btScalar height) {
+ return bulletnew(btCapsuleShape(radius, height));
}
btCylinderShape *ShapeBullet::create_shape_cylinder(btScalar radius, btScalar height) {
@@ -142,11 +142,11 @@ btScaledBvhTriangleMeshShape *ShapeBullet::create_shape_concave(btBvhTriangleMes
}
}
-btHeightfieldTerrainShape *ShapeBullet::create_shape_height_field(PoolVector<real_t> &p_heights, int p_width, int p_depth, real_t p_min_height, real_t p_max_height) {
+btHeightfieldTerrainShape *ShapeBullet::create_shape_height_field(Vector<real_t> &p_heights, int p_width, int p_depth, real_t p_min_height, real_t p_max_height) {
const btScalar ignoredHeightScale(1);
const int YAxis = 1; // 0=X, 1=Y, 2=Z
const bool flipQuadEdges = false;
- const void *heightsPtr = p_heights.read().ptr();
+ const void *heightsPtr = p_heights.ptr();
btHeightfieldTerrainShape *heightfield = bulletnew(btHeightfieldTerrainShape(p_width, p_depth, heightsPtr, ignoredHeightScale, p_min_height, p_max_height, YAxis, PHY_FLOAT, flipQuadEdges));
@@ -370,7 +370,7 @@ ConcavePolygonShapeBullet::~ConcavePolygonShapeBullet() {
delete meshShape->getTriangleInfoMap();
bulletdelete(meshShape);
}
- faces = PoolVector<Vector3>();
+ faces = Vector<Vector3>();
}
void ConcavePolygonShapeBullet::set_data(const Variant &p_data) {
@@ -385,7 +385,7 @@ PhysicsServer::ShapeType ConcavePolygonShapeBullet::get_type() const {
return PhysicsServer::SHAPE_CONCAVE_POLYGON;
}
-void ConcavePolygonShapeBullet::setup(PoolVector<Vector3> p_faces) {
+void ConcavePolygonShapeBullet::setup(Vector<Vector3> p_faces) {
faces = p_faces;
if (meshShape) {
/// Clear previous created shape
@@ -401,8 +401,8 @@ void ConcavePolygonShapeBullet::setup(PoolVector<Vector3> p_faces) {
btTriangleMesh *shapeInterface = bulletnew(btTriangleMesh);
src_face_count /= 3;
- PoolVector<Vector3>::Read r = p_faces.read();
- const Vector3 *facesr = r.ptr();
+ const Vector3 *r = p_faces.ptr();
+ const Vector3 *facesr = r;
btVector3 supVec_0;
btVector3 supVec_1;
@@ -471,10 +471,10 @@ void HeightMapShapeBullet::set_data(const Variant &p_data) {
// TODO This code will need adjustments if real_t is set to `double`,
// because that precision is unnecessary for a heightmap and Bullet doesn't support it...
- PoolVector<real_t> l_heights;
+ Vector<real_t> l_heights;
Variant l_heights_v = d["heights"];
- if (l_heights_v.get_type() == Variant::POOL_REAL_ARRAY) {
+ if (l_heights_v.get_type() == Variant::PACKED_FLOAT32_ARRAY) {
// Ready-to-use heights can be passed
l_heights = l_heights_v;
@@ -491,13 +491,13 @@ void HeightMapShapeBullet::set_data(const Variant &p_data) {
// We could convert here automatically but it's better to not be intrusive and let the caller do it if necessary.
ERR_FAIL_COND(l_image->get_format() != Image::FORMAT_RF);
- PoolByteArray im_data = l_image->get_data();
+ PackedByteArray im_data = l_image->get_data();
l_heights.resize(l_image->get_width() * l_image->get_height());
- PoolRealArray::Write w = l_heights.write();
- PoolByteArray::Read r = im_data.read();
- float *rp = (float *)r.ptr();
+ real_t *w = l_heights.ptrw();
+ const uint8_t *r = im_data.ptr();
+ float *rp = (float *)r;
// At this point, `rp` could be used directly for Bullet, but I don't know how safe it would be.
for (int i = 0; i < l_heights.size(); ++i) {
@@ -505,7 +505,7 @@ void HeightMapShapeBullet::set_data(const Variant &p_data) {
}
} else {
- ERR_FAIL_MSG("Expected PoolRealArray or float Image.");
+ ERR_FAIL_MSG("Expected PackedFloat32Array or float Image.");
}
ERR_FAIL_COND(l_width <= 0);
@@ -515,7 +515,7 @@ void HeightMapShapeBullet::set_data(const Variant &p_data) {
// Compute min and max heights if not specified.
if (!d.has("min_height") && !d.has("max_height")) {
- PoolVector<real_t>::Read r = l_heights.read();
+ const real_t *r = l_heights.ptr();
int heights_size = l_heights.size();
for (int i = 0; i < heights_size; ++i) {
@@ -540,7 +540,7 @@ PhysicsServer::ShapeType HeightMapShapeBullet::get_type() const {
return PhysicsServer::SHAPE_HEIGHTMAP;
}
-void HeightMapShapeBullet::setup(PoolVector<real_t> &p_heights, int p_width, int p_depth, real_t p_min_height, real_t p_max_height) {
+void HeightMapShapeBullet::setup(Vector<real_t> &p_heights, int p_width, int p_depth, real_t p_min_height, real_t p_max_height) {
// TODO cell size must be tweaked using localScaling, which is a shared property for all Bullet shapes
// If this array is resized outside of here, it should be preserved due to CoW
diff --git a/modules/bullet/shape_bullet.h b/modules/bullet/shape_bullet.h
index 8d3512cab4..c8b5ca102a 100644
--- a/modules/bullet/shape_bullet.h
+++ b/modules/bullet/shape_bullet.h
@@ -85,12 +85,12 @@ public:
static class btStaticPlaneShape *create_shape_plane(const btVector3 &planeNormal, btScalar planeConstant);
static class btSphereShape *create_shape_sphere(btScalar radius);
static class btBoxShape *create_shape_box(const btVector3 &boxHalfExtents);
- static class btCapsuleShapeZ *create_shape_capsule(btScalar radius, btScalar height);
+ static class btCapsuleShape *create_shape_capsule(btScalar radius, btScalar height);
static class btCylinderShape *create_shape_cylinder(btScalar radius, btScalar height);
/// IMPORTANT: Remember to delete the shape interface by calling: delete my_shape->getMeshInterface();
static class btConvexPointCloudShape *create_shape_convex(btAlignedObjectArray<btVector3> &p_vertices, const btVector3 &p_local_scaling = btVector3(1, 1, 1));
static class btScaledBvhTriangleMeshShape *create_shape_concave(btBvhTriangleMeshShape *p_mesh_shape, const btVector3 &p_local_scaling = btVector3(1, 1, 1));
- static class btHeightfieldTerrainShape *create_shape_height_field(PoolVector<real_t> &p_heights, int p_width, int p_depth, real_t p_min_height, real_t p_max_height);
+ static class btHeightfieldTerrainShape *create_shape_height_field(Vector<real_t> &p_heights, int p_width, int p_depth, real_t p_min_height, real_t p_max_height);
static class btRayShape *create_shape_ray(real_t p_length, bool p_slips_on_slope);
};
@@ -203,7 +203,7 @@ class ConcavePolygonShapeBullet : public ShapeBullet {
class btBvhTriangleMeshShape *meshShape;
public:
- PoolVector<Vector3> faces;
+ Vector<Vector3> faces;
ConcavePolygonShapeBullet();
virtual ~ConcavePolygonShapeBullet();
@@ -214,13 +214,13 @@ public:
virtual btCollisionShape *create_bt_shape(const btVector3 &p_implicit_scale, real_t p_extra_edge = 0);
private:
- void setup(PoolVector<Vector3> p_faces);
+ void setup(Vector<Vector3> p_faces);
};
class HeightMapShapeBullet : public ShapeBullet {
public:
- PoolVector<real_t> heights;
+ Vector<real_t> heights;
int width;
int depth;
real_t min_height;
@@ -234,7 +234,7 @@ public:
virtual btCollisionShape *create_bt_shape(const btVector3 &p_implicit_scale, real_t p_extra_edge = 0);
private:
- void setup(PoolVector<real_t> &p_heights, int p_width, int p_depth, real_t p_min_height, real_t p_max_height);
+ void setup(Vector<real_t> &p_heights, int p_width, int p_depth, real_t p_min_height, real_t p_max_height);
};
class RayShapeBullet : public ShapeBullet {
diff --git a/modules/bullet/soft_body_bullet.cpp b/modules/bullet/soft_body_bullet.cpp
index f4c0ffa6eb..f21206dd0d 100644
--- a/modules/bullet/soft_body_bullet.cpp
+++ b/modules/bullet/soft_body_bullet.cpp
@@ -168,6 +168,7 @@ void SoftBodyBullet::set_node_position(int p_node_index, const Vector3 &p_global
void SoftBodyBullet::set_node_position(int p_node_index, const btVector3 &p_global_position) {
if (bt_soft_body) {
+ bt_soft_body->m_nodes[p_node_index].m_q = bt_soft_body->m_nodes[p_node_index].m_x;
bt_soft_body->m_nodes[p_node_index].m_x = p_global_position;
}
}
@@ -183,7 +184,7 @@ void SoftBodyBullet::get_node_offset(int p_node_index, Vector3 &r_offset) const
return;
Array arrays = soft_mesh->surface_get_arrays(0);
- PoolVector<Vector3> vertices(arrays[VS::ARRAY_VERTEX]);
+ Vector<Vector3> vertices(arrays[VS::ARRAY_VERTEX]);
if (0 <= p_node_index && vertices.size() > p_node_index) {
r_offset = vertices[p_node_index];
@@ -229,8 +230,8 @@ void SoftBodyBullet::reset_all_node_positions() {
return;
Array arrays = soft_mesh->surface_get_arrays(0);
- PoolVector<Vector3> vs_vertices(arrays[VS::ARRAY_VERTEX]);
- PoolVector<Vector3>::Read vs_vertices_read = vs_vertices.read();
+ Vector<Vector3> vs_vertices(arrays[VS::ARRAY_VERTEX]);
+ const Vector3 *vs_vertices_read = vs_vertices.ptr();
for (int vertex_index = bt_soft_body->m_nodes.size() - 1; 0 <= vertex_index; --vertex_index) {
@@ -319,7 +320,7 @@ void SoftBodyBullet::set_drag_coefficient(real_t p_val) {
}
}
-void SoftBodyBullet::set_trimesh_body_shape(PoolVector<int> p_indices, PoolVector<Vector3> p_vertices) {
+void SoftBodyBullet::set_trimesh_body_shape(Vector<int> p_indices, Vector<Vector3> p_vertices) {
/// Assert the current soft body is destroyed
destroy_soft_body();
@@ -338,7 +339,7 @@ void SoftBodyBullet::set_trimesh_body_shape(PoolVector<int> p_indices, PoolVecto
const int vs_vertices_size(p_vertices.size());
- PoolVector<Vector3>::Read p_vertices_read = p_vertices.read();
+ const Vector3 *p_vertices_read = p_vertices.ptr();
for (int vs_vertex_index = 0; vs_vertex_index < vs_vertices_size; ++vs_vertex_index) {
@@ -365,7 +366,7 @@ void SoftBodyBullet::set_trimesh_body_shape(PoolVector<int> p_indices, PoolVecto
{ // Parse vertices to bullet
bt_vertices.resize(indices_map_size * 3);
- PoolVector<Vector3>::Read p_vertices_read = p_vertices.read();
+ const Vector3 *p_vertices_read = p_vertices.ptr();
for (int i = 0; i < indices_map_size; ++i) {
bt_vertices.write[3 * i + 0] = p_vertices_read[indices_table[i][0]].x;
@@ -381,7 +382,7 @@ void SoftBodyBullet::set_trimesh_body_shape(PoolVector<int> p_indices, PoolVecto
bt_triangles.resize(triangles_size * 3);
- PoolVector<int>::Read p_indices_read = p_indices.read();
+ const int *p_indices_read = p_indices.ptr();
for (int i = 0; i < triangles_size; ++i) {
bt_triangles.write[3 * i + 0] = vs_indices_to_physics_table[p_indices_read[3 * i + 2]];
diff --git a/modules/bullet/soft_body_bullet.h b/modules/bullet/soft_body_bullet.h
index b98116b073..2df8ce074f 100644
--- a/modules/bullet/soft_body_bullet.h
+++ b/modules/bullet/soft_body_bullet.h
@@ -152,7 +152,7 @@ public:
_FORCE_INLINE_ real_t get_drag_coefficient() const { return drag_coefficient; }
private:
- void set_trimesh_body_shape(PoolVector<int> p_indices, PoolVector<Vector3> p_vertices);
+ void set_trimesh_body_shape(Vector<int> p_indices, Vector<Vector3> p_vertices);
void setup_soft_body();
void pin_node(int p_node_index);
diff --git a/modules/bullet/space_bullet.cpp b/modules/bullet/space_bullet.cpp
index 762637ce75..f6df97f11d 100644
--- a/modules/bullet/space_bullet.cpp
+++ b/modules/bullet/space_bullet.cpp
@@ -108,7 +108,7 @@ bool BulletPhysicsDirectSpaceState::intersect_ray(const Vector3 &p_from, const V
r_result.shape = btResult.m_shapeId;
r_result.rid = gObj->get_self();
r_result.collider_id = gObj->get_instance_id();
- r_result.collider = 0 == r_result.collider_id ? NULL : ObjectDB::get_instance(r_result.collider_id);
+ r_result.collider = r_result.collider_id.is_null() ? NULL : ObjectDB::get_instance(r_result.collider_id);
} else {
WARN_PRINT("The raycast performed has hit a collision object that is not part of Godot scene, please check it.");
}
@@ -122,7 +122,7 @@ int BulletPhysicsDirectSpaceState::intersect_shape(const RID &p_shape, const Tra
if (p_result_max <= 0)
return 0;
- ShapeBullet *shape = space->get_physics_server()->get_shape_owner()->get(p_shape);
+ ShapeBullet *shape = space->get_physics_server()->get_shape_owner()->getornull(p_shape);
btCollisionShape *btShape = shape->create_bt_shape(p_xform.basis.get_scale_abs(), p_margin);
if (!btShape->isConvex()) {
@@ -152,7 +152,7 @@ int BulletPhysicsDirectSpaceState::intersect_shape(const RID &p_shape, const Tra
}
bool BulletPhysicsDirectSpaceState::cast_motion(const RID &p_shape, const Transform &p_xform, const Vector3 &p_motion, float p_margin, float &r_closest_safe, float &r_closest_unsafe, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas, ShapeRestInfo *r_info) {
- ShapeBullet *shape = space->get_physics_server()->get_shape_owner()->get(p_shape);
+ ShapeBullet *shape = space->get_physics_server()->get_shape_owner()->getornull(p_shape);
btCollisionShape *btShape = shape->create_bt_shape(p_xform.basis.get_scale(), p_margin);
if (!btShape->isConvex()) {
@@ -207,7 +207,7 @@ bool BulletPhysicsDirectSpaceState::collide_shape(RID p_shape, const Transform &
if (p_result_max <= 0)
return 0;
- ShapeBullet *shape = space->get_physics_server()->get_shape_owner()->get(p_shape);
+ ShapeBullet *shape = space->get_physics_server()->get_shape_owner()->getornull(p_shape);
btCollisionShape *btShape = shape->create_bt_shape(p_shape_xform.basis.get_scale_abs(), p_margin);
if (!btShape->isConvex()) {
@@ -239,7 +239,7 @@ bool BulletPhysicsDirectSpaceState::collide_shape(RID p_shape, const Transform &
bool BulletPhysicsDirectSpaceState::rest_info(RID p_shape, const Transform &p_shape_xform, float p_margin, ShapeRestInfo *r_info, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {
- ShapeBullet *shape = space->get_physics_server()->get_shape_owner()->get(p_shape);
+ ShapeBullet *shape = space->get_physics_server()->get_shape_owner()->getornull(p_shape);
btCollisionShape *btShape = shape->create_bt_shape(p_shape_xform.basis.get_scale_abs(), p_margin);
if (!btShape->isConvex()) {
@@ -726,9 +726,6 @@ void SpaceBullet::check_ghost_overlaps() {
other_body_shape = static_cast<btCollisionShape *>(otherObject->get_bt_shape(z));
- if (other_body_shape->isConcave())
- continue;
-
btTransform other_shape_transform(otherObject->get_bt_shape_transform(z));
other_shape_transform.getOrigin() *= other_body_scale;
@@ -890,8 +887,8 @@ void SpaceBullet::update_gravity() {
static ImmediateGeometry *motionVec(NULL);
static ImmediateGeometry *normalLine(NULL);
-static Ref<SpatialMaterial> red_mat;
-static Ref<SpatialMaterial> blue_mat;
+static Ref<StandardMaterial3D> red_mat;
+static Ref<StandardMaterial3D> blue_mat;
#endif
bool SpaceBullet::test_body_motion(RigidBodyBullet *p_body, const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia, PhysicsServer::MotionResult *r_result, bool p_exclude_raycast_shapes) {
@@ -908,21 +905,21 @@ bool SpaceBullet::test_body_motion(RigidBodyBullet *p_body, const Transform &p_f
motionVec->set_as_toplevel(true);
normalLine->set_as_toplevel(true);
- red_mat = Ref<SpatialMaterial>(memnew(SpatialMaterial));
- red_mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
+ red_mat = Ref<StandardMaterial3D>(memnew(StandardMaterial3D));
+ red_mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
red_mat->set_line_width(20.0);
- red_mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
- red_mat->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
- red_mat->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true);
+ red_mat->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
+ red_mat->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
+ red_mat->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true);
red_mat->set_albedo(Color(1, 0, 0, 1));
motionVec->set_material_override(red_mat);
- blue_mat = Ref<SpatialMaterial>(memnew(SpatialMaterial));
- blue_mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
+ blue_mat = Ref<StandardMaterial3D>(memnew(StandardMaterial3D));
+ blue_mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
blue_mat->set_line_width(20.0);
- blue_mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
- blue_mat->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
- blue_mat->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true);
+ blue_mat->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
+ blue_mat->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
+ blue_mat->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true);
blue_mat->set_albedo(Color(0, 0, 1, 1));
normalLine->set_material_override(blue_mat);
}
diff --git a/modules/camera/camera_ios.mm b/modules/camera/camera_ios.mm
index 8059277503..f01135f251 100644
--- a/modules/camera/camera_ios.mm
+++ b/modules/camera/camera_ios.mm
@@ -44,7 +44,7 @@
Ref<CameraFeed> feed;
size_t width[2];
size_t height[2];
- PoolVector<uint8_t> img_data[2];
+ Vector<uint8_t> img_data[2];
AVCaptureDeviceInput *input;
AVCaptureVideoDataOutput *output;
@@ -175,7 +175,7 @@
img_data[0].resize(new_width * new_height);
}
- PoolVector<uint8_t>::Write w = img_data[0].write();
+ uint8_t *w = img_data[0].ptrw();
memcpy(w.ptr(), dataY, new_width * new_height);
img[0].instance();
@@ -196,7 +196,7 @@
img_data[1].resize(2 * new_width * new_height);
}
- PoolVector<uint8_t>::Write w = img_data[1].write();
+ uint8_t *w = img_data[1].ptrw();
memcpy(w.ptr(), dataCbCr, 2 * new_width * new_height);
///TODO GLES2 doesn't support FORMAT_RG8, need to do some form of conversion
diff --git a/modules/camera/camera_osx.mm b/modules/camera/camera_osx.mm
index 658ddb728b..9a72174723 100644
--- a/modules/camera/camera_osx.mm
+++ b/modules/camera/camera_osx.mm
@@ -42,7 +42,7 @@
Ref<CameraFeed> feed;
size_t width[2];
size_t height[2];
- PoolVector<uint8_t> img_data[2];
+ Vector<uint8_t> img_data[2];
AVCaptureDeviceInput *input;
AVCaptureVideoDataOutput *output;
@@ -159,8 +159,8 @@
img_data[0].resize(new_width * new_height);
}
- PoolVector<uint8_t>::Write w = img_data[0].write();
- memcpy(w.ptr(), dataY, new_width * new_height);
+ uint8_t *w = img_data[0].ptrw();
+ memcpy(w, dataY, new_width * new_height);
img[0].instance();
img[0]->create(new_width, new_height, 0, Image::FORMAT_R8, img_data[0]);
@@ -177,8 +177,8 @@
img_data[1].resize(2 * new_width * new_height);
}
- PoolVector<uint8_t>::Write w = img_data[1].write();
- memcpy(w.ptr(), dataCbCr, 2 * new_width * new_height);
+ uint8_t *w = img_data[1].ptrw();
+ 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();
diff --git a/modules/csg/csg.cpp b/modules/csg/csg.cpp
index cc3bbed27f..36055ce840 100644
--- a/modules/csg/csg.cpp
+++ b/modules/csg/csg.cpp
@@ -39,7 +39,7 @@ void CSGBrush::clear() {
faces.clear();
}
-void CSGBrush::build_from_faces(const PoolVector<Vector3> &p_vertices, const PoolVector<Vector2> &p_uvs, const PoolVector<bool> &p_smooth, const PoolVector<Ref<Material> > &p_materials, const PoolVector<bool> &p_invert_faces) {
+void CSGBrush::build_from_faces(const Vector<Vector3> &p_vertices, const Vector<Vector2> &p_uvs, const Vector<bool> &p_smooth, const Vector<Ref<Material> > &p_materials, const Vector<bool> &p_invert_faces) {
clear();
@@ -47,15 +47,15 @@ void CSGBrush::build_from_faces(const PoolVector<Vector3> &p_vertices, const Poo
ERR_FAIL_COND((vc % 3) != 0);
- PoolVector<Vector3>::Read rv = p_vertices.read();
+ const Vector3 *rv = p_vertices.ptr();
int uvc = p_uvs.size();
- PoolVector<Vector2>::Read ruv = p_uvs.read();
+ const Vector2 *ruv = p_uvs.ptr();
int sc = p_smooth.size();
- PoolVector<bool>::Read rs = p_smooth.read();
+ const bool *rs = p_smooth.ptr();
int mc = p_materials.size();
- PoolVector<Ref<Material> >::Read rm = p_materials.read();
+ const Ref<Material> *rm = p_materials.ptr();
int ic = p_invert_faces.size();
- PoolVector<bool>::Read ri = p_invert_faces.read();
+ const bool *ri = p_invert_faces.ptr();
Map<Ref<Material>, int> material_map;
diff --git a/modules/csg/csg.h b/modules/csg/csg.h
index a11e55c72a..472a96d5df 100644
--- a/modules/csg/csg.h
+++ b/modules/csg/csg.h
@@ -38,7 +38,7 @@
#include "core/math/transform.h"
#include "core/math/vector3.h"
#include "core/oa_hash_map.h"
-#include "core/pool_vector.h"
+
#include "scene/resources/material.h"
struct CSGBrush {
@@ -58,7 +58,7 @@ struct CSGBrush {
void _regen_face_aabbs();
//create a brush from faces
- void build_from_faces(const PoolVector<Vector3> &p_vertices, const PoolVector<Vector2> &p_uvs, const PoolVector<bool> &p_smooth, const PoolVector<Ref<Material> > &p_materials, const PoolVector<bool> &p_invert_faces);
+ void build_from_faces(const Vector<Vector3> &p_vertices, const Vector<Vector2> &p_uvs, const Vector<bool> &p_smooth, const Vector<Ref<Material> > &p_materials, const Vector<bool> &p_invert_faces);
void copy_from(const CSGBrush &p_brush, const Transform &p_xform);
void clear();
diff --git a/modules/csg/csg_gizmos.cpp b/modules/csg/csg_gizmos.cpp
index 49387606f3..1b63bccb06 100644
--- a/modules/csg/csg_gizmos.cpp
+++ b/modules/csg/csg_gizmos.cpp
@@ -336,12 +336,12 @@ void CSGShapeSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
Ref<Material> handles_material = get_material("handles");
- PoolVector<Vector3> faces = cs->get_brush_faces();
+ Vector<Vector3> faces = cs->get_brush_faces();
Vector<Vector3> lines;
lines.resize(faces.size() * 2);
{
- PoolVector<Vector3>::Read r = faces.read();
+ const Vector3 *r = faces.ptr();
for (int i = 0; i < lines.size(); i += 6) {
int f = i / 6;
diff --git a/modules/csg/csg_shape.cpp b/modules/csg/csg_shape.cpp
index c8a72ff813..d017afd792 100644
--- a/modules/csg/csg_shape.cpp
+++ b/modules/csg/csg_shape.cpp
@@ -334,16 +334,16 @@ void CSGShape::_update_shape() {
surfaces.write[i].material = n->materials[i];
}
- surfaces.write[i].verticesw = surfaces.write[i].vertices.write();
- surfaces.write[i].normalsw = surfaces.write[i].normals.write();
- surfaces.write[i].uvsw = surfaces.write[i].uvs.write();
+ surfaces.write[i].verticesw = surfaces.write[i].vertices.ptrw();
+ surfaces.write[i].normalsw = surfaces.write[i].normals.ptrw();
+ surfaces.write[i].uvsw = surfaces.write[i].uvs.ptrw();
if (calculate_tangents) {
- surfaces.write[i].tansw = surfaces.write[i].tans.write();
+ surfaces.write[i].tansw = surfaces.write[i].tans.ptrw();
}
}
//fill arrays
- PoolVector<Vector3> physics_faces;
+ Vector<Vector3> physics_faces;
bool fill_physics_faces = false;
if (root_collision_shape.is_valid()) {
physics_faces.resize(n->faces.size() * 3);
@@ -351,10 +351,10 @@ void CSGShape::_update_shape() {
}
{
- PoolVector<Vector3>::Write physicsw;
+ Vector3 *physicsw;
if (fill_physics_faces) {
- physicsw = physics_faces.write();
+ physicsw = physics_faces.ptrw();
}
for (int i = 0; i < n->faces.size(); i++) {
@@ -435,12 +435,6 @@ void CSGShape::_update_shape() {
have_tangents = genTangSpaceDefault(&msc);
}
- // unset write access
- surfaces.write[i].verticesw.release();
- surfaces.write[i].normalsw.release();
- surfaces.write[i].uvsw.release();
- surfaces.write[i].tansw.release();
-
if (surfaces[i].last_added == 0)
continue;
@@ -470,18 +464,18 @@ AABB CSGShape::get_aabb() const {
return node_aabb;
}
-PoolVector<Vector3> CSGShape::get_brush_faces() {
- ERR_FAIL_COND_V(!is_inside_tree(), PoolVector<Vector3>());
+Vector<Vector3> CSGShape::get_brush_faces() {
+ ERR_FAIL_COND_V(!is_inside_tree(), Vector<Vector3>());
CSGBrush *b = _get_brush();
if (!b) {
- return PoolVector<Vector3>();
+ return Vector<Vector3>();
}
- PoolVector<Vector3> faces;
+ Vector<Vector3> faces;
int fc = b->faces.size();
faces.resize(fc * 3);
{
- PoolVector<Vector3>::Write w = faces.write();
+ Vector3 *w = faces.ptrw();
for (int i = 0; i < fc; i++) {
w[i * 3 + 0] = b->faces[i].vertices[0];
w[i * 3 + 1] = b->faces[i].vertices[1];
@@ -492,9 +486,9 @@ PoolVector<Vector3> CSGShape::get_brush_faces() {
return faces;
}
-PoolVector<Face3> CSGShape::get_faces(uint32_t p_usage_flags) const {
+Vector<Face3> CSGShape::get_faces(uint32_t p_usage_flags) const {
- return PoolVector<Face3>();
+ return Vector<Face3>();
}
void CSGShape::_notification(int p_what) {
@@ -627,7 +621,7 @@ void CSGShape::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_meshes"), &CSGShape::get_meshes);
ADD_PROPERTY(PropertyInfo(Variant::INT, "operation", PROPERTY_HINT_ENUM, "Union,Intersection,Subtraction"), "set_operation", "get_operation");
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "snap", PROPERTY_HINT_RANGE, "0.0001,1,0.001"), "set_snap", "get_snap");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "snap", PROPERTY_HINT_RANGE, "0.0001,1,0.001"), "set_snap", "get_snap");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "calculate_tangents"), "set_calculate_tangents", "is_calculating_tangents");
ADD_GROUP("Collision", "collision_");
@@ -671,15 +665,15 @@ CSGCombiner::CSGCombiner() {
/////////////////////
-CSGBrush *CSGPrimitive::_create_brush_from_arrays(const PoolVector<Vector3> &p_vertices, const PoolVector<Vector2> &p_uv, const PoolVector<bool> &p_smooth, const PoolVector<Ref<Material> > &p_materials) {
+CSGBrush *CSGPrimitive::_create_brush_from_arrays(const Vector<Vector3> &p_vertices, const Vector<Vector2> &p_uv, const Vector<bool> &p_smooth, const Vector<Ref<Material> > &p_materials) {
CSGBrush *brush = memnew(CSGBrush);
- PoolVector<bool> invert;
+ Vector<bool> invert;
invert.resize(p_vertices.size() / 3);
{
int ic = invert.size();
- PoolVector<bool>::Write w = invert.write();
+ bool *w = invert.ptrw();
for (int i = 0; i < ic; i++) {
w[i] = invert_faces;
}
@@ -721,10 +715,10 @@ CSGBrush *CSGMesh::_build_brush() {
if (!mesh.is_valid())
return NULL;
- PoolVector<Vector3> vertices;
- PoolVector<bool> smooth;
- PoolVector<Ref<Material> > materials;
- PoolVector<Vector2> uvs;
+ Vector<Vector3> vertices;
+ Vector<bool> smooth;
+ Vector<Ref<Material> > materials;
+ Vector<Vector2> uvs;
Ref<Material> material = get_material();
for (int i = 0; i < mesh->get_surface_count(); i++) {
@@ -740,25 +734,25 @@ CSGBrush *CSGMesh::_build_brush() {
ERR_FAIL_COND_V(arrays.size() == 0, NULL);
}
- PoolVector<Vector3> avertices = arrays[Mesh::ARRAY_VERTEX];
+ Vector<Vector3> avertices = arrays[Mesh::ARRAY_VERTEX];
if (avertices.size() == 0)
continue;
- PoolVector<Vector3>::Read vr = avertices.read();
+ const Vector3 *vr = avertices.ptr();
- PoolVector<Vector3> anormals = arrays[Mesh::ARRAY_NORMAL];
- PoolVector<Vector3>::Read nr;
+ Vector<Vector3> anormals = arrays[Mesh::ARRAY_NORMAL];
+ const Vector3 *nr;
bool nr_used = false;
if (anormals.size()) {
- nr = anormals.read();
+ nr = anormals.ptr();
nr_used = true;
}
- PoolVector<Vector2> auvs = arrays[Mesh::ARRAY_TEX_UV];
- PoolVector<Vector2>::Read uvr;
+ Vector<Vector2> auvs = arrays[Mesh::ARRAY_TEX_UV];
+ const Vector2 *uvr;
bool uvr_used = false;
if (auvs.size()) {
- uvr = auvs.read();
+ uvr = auvs.ptr();
uvr_used = true;
}
@@ -769,7 +763,7 @@ CSGBrush *CSGMesh::_build_brush() {
mat = mesh->surface_get_material(i);
}
- PoolVector<int> aindices = arrays[Mesh::ARRAY_INDEX];
+ Vector<int> aindices = arrays[Mesh::ARRAY_INDEX];
if (aindices.size()) {
int as = vertices.size();
int is = aindices.size();
@@ -779,12 +773,12 @@ CSGBrush *CSGMesh::_build_brush() {
materials.resize((as + is) / 3);
uvs.resize(as + is);
- PoolVector<Vector3>::Write vw = vertices.write();
- PoolVector<bool>::Write sw = smooth.write();
- PoolVector<Vector2>::Write uvw = uvs.write();
- PoolVector<Ref<Material> >::Write mw = materials.write();
+ Vector3 *vw = vertices.ptrw();
+ bool *sw = smooth.ptrw();
+ Vector2 *uvw = uvs.ptrw();
+ Ref<Material> *mw = materials.ptrw();
- PoolVector<int>::Read ir = aindices.read();
+ const int *ir = aindices.ptr();
for (int j = 0; j < is; j += 3) {
@@ -825,10 +819,10 @@ CSGBrush *CSGMesh::_build_brush() {
uvs.resize(as + is);
materials.resize((as + is) / 3);
- PoolVector<Vector3>::Write vw = vertices.write();
- PoolVector<bool>::Write sw = smooth.write();
- PoolVector<Vector2>::Write uvw = uvs.write();
- PoolVector<Ref<Material> >::Write mw = materials.write();
+ Vector3 *vw = vertices.ptrw();
+ bool *sw = smooth.ptrw();
+ Vector2 *uvw = uvs.ptrw();
+ Ref<Material> *mw = materials.ptrw();
for (int j = 0; j < is; j += 3) {
@@ -896,7 +890,7 @@ void CSGMesh::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_material"), &CSGMesh::get_material);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "mesh", PROPERTY_HINT_RESOURCE_TYPE, "Mesh"), "set_mesh", "get_mesh");
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "SpatialMaterial,ShaderMaterial"), "set_material", "get_material");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "StandardMaterial3D,ShaderMaterial"), "set_material", "get_material");
}
void CSGMesh::set_mesh(const Ref<Mesh> &p_mesh) {
@@ -904,12 +898,12 @@ void CSGMesh::set_mesh(const Ref<Mesh> &p_mesh) {
if (mesh == p_mesh)
return;
if (mesh.is_valid()) {
- mesh->disconnect("changed", this, "_mesh_changed");
+ mesh->disconnect_compat("changed", this, "_mesh_changed");
}
mesh = p_mesh;
if (mesh.is_valid()) {
- mesh->connect("changed", this, "_mesh_changed");
+ mesh->connect_compat("changed", this, "_mesh_changed");
}
_make_dirty();
@@ -932,11 +926,11 @@ CSGBrush *CSGSphere::_build_brush() {
bool invert_val = is_inverting_faces();
Ref<Material> material = get_material();
- PoolVector<Vector3> faces;
- PoolVector<Vector2> uvs;
- PoolVector<bool> smooth;
- PoolVector<Ref<Material> > materials;
- PoolVector<bool> invert;
+ Vector<Vector3> faces;
+ Vector<Vector2> uvs;
+ Vector<bool> smooth;
+ Vector<Ref<Material> > materials;
+ Vector<bool> invert;
faces.resize(face_count * 3);
uvs.resize(face_count * 3);
@@ -947,11 +941,11 @@ CSGBrush *CSGSphere::_build_brush() {
{
- PoolVector<Vector3>::Write facesw = faces.write();
- PoolVector<Vector2>::Write uvsw = uvs.write();
- PoolVector<bool>::Write smoothw = smooth.write();
- PoolVector<Ref<Material> >::Write materialsw = materials.write();
- PoolVector<bool>::Write invertw = invert.write();
+ Vector3 *facesw = faces.ptrw();
+ Vector2 *uvsw = uvs.ptrw();
+ bool *smoothw = smooth.ptrw();
+ Ref<Material> *materialsw = materials.ptrw();
+ bool *invertw = invert.ptrw();
int face = 0;
@@ -1055,11 +1049,11 @@ void CSGSphere::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_material", "material"), &CSGSphere::set_material);
ClassDB::bind_method(D_METHOD("get_material"), &CSGSphere::get_material);
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "radius", PROPERTY_HINT_RANGE, "0.001,100.0,0.001"), "set_radius", "get_radius");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "radius", PROPERTY_HINT_RANGE, "0.001,100.0,0.001"), "set_radius", "get_radius");
ADD_PROPERTY(PropertyInfo(Variant::INT, "radial_segments", PROPERTY_HINT_RANGE, "1,100,1"), "set_radial_segments", "get_radial_segments");
ADD_PROPERTY(PropertyInfo(Variant::INT, "rings", PROPERTY_HINT_RANGE, "1,100,1"), "set_rings", "get_rings");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "smooth_faces"), "set_smooth_faces", "get_smooth_faces");
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "SpatialMaterial,ShaderMaterial"), "set_material", "get_material");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "StandardMaterial3D,ShaderMaterial"), "set_material", "get_material");
}
void CSGSphere::set_radius(const float p_radius) {
@@ -1135,11 +1129,11 @@ CSGBrush *CSGBox::_build_brush() {
bool invert_val = is_inverting_faces();
Ref<Material> material = get_material();
- PoolVector<Vector3> faces;
- PoolVector<Vector2> uvs;
- PoolVector<bool> smooth;
- PoolVector<Ref<Material> > materials;
- PoolVector<bool> invert;
+ Vector<Vector3> faces;
+ Vector<Vector2> uvs;
+ Vector<bool> smooth;
+ Vector<Ref<Material> > materials;
+ Vector<bool> invert;
faces.resize(face_count * 3);
uvs.resize(face_count * 3);
@@ -1150,11 +1144,11 @@ CSGBrush *CSGBox::_build_brush() {
{
- PoolVector<Vector3>::Write facesw = faces.write();
- PoolVector<Vector2>::Write uvsw = uvs.write();
- PoolVector<bool>::Write smoothw = smooth.write();
- PoolVector<Ref<Material> >::Write materialsw = materials.write();
- PoolVector<bool>::Write invertw = invert.write();
+ Vector3 *facesw = faces.ptrw();
+ Vector2 *uvsw = uvs.ptrw();
+ bool *smoothw = smooth.ptrw();
+ Ref<Material> *materialsw = materials.ptrw();
+ bool *invertw = invert.ptrw();
int face = 0;
@@ -1242,10 +1236,10 @@ void CSGBox::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_material", "material"), &CSGBox::set_material);
ClassDB::bind_method(D_METHOD("get_material"), &CSGBox::get_material);
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "width", PROPERTY_HINT_EXP_RANGE, "0.001,1000.0,0.001,or_greater"), "set_width", "get_width");
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "height", PROPERTY_HINT_EXP_RANGE, "0.001,1000.0,0.001,or_greater"), "set_height", "get_height");
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "depth", PROPERTY_HINT_EXP_RANGE, "0.001,1000.0,0.001,or_greater"), "set_depth", "get_depth");
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "SpatialMaterial,ShaderMaterial"), "set_material", "get_material");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "width", PROPERTY_HINT_EXP_RANGE, "0.001,1000.0,0.001,or_greater"), "set_width", "get_width");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "height", PROPERTY_HINT_EXP_RANGE, "0.001,1000.0,0.001,or_greater"), "set_height", "get_height");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "depth", PROPERTY_HINT_EXP_RANGE, "0.001,1000.0,0.001,or_greater"), "set_depth", "get_depth");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "StandardMaterial3D,ShaderMaterial"), "set_material", "get_material");
}
void CSGBox::set_width(const float p_width) {
@@ -1313,11 +1307,11 @@ CSGBrush *CSGCylinder::_build_brush() {
bool invert_val = is_inverting_faces();
Ref<Material> material = get_material();
- PoolVector<Vector3> faces;
- PoolVector<Vector2> uvs;
- PoolVector<bool> smooth;
- PoolVector<Ref<Material> > materials;
- PoolVector<bool> invert;
+ Vector<Vector3> faces;
+ Vector<Vector2> uvs;
+ Vector<bool> smooth;
+ Vector<Ref<Material> > materials;
+ Vector<bool> invert;
faces.resize(face_count * 3);
uvs.resize(face_count * 3);
@@ -1328,11 +1322,11 @@ CSGBrush *CSGCylinder::_build_brush() {
{
- PoolVector<Vector3>::Write facesw = faces.write();
- PoolVector<Vector2>::Write uvsw = uvs.write();
- PoolVector<bool>::Write smoothw = smooth.write();
- PoolVector<Ref<Material> >::Write materialsw = materials.write();
- PoolVector<bool>::Write invertw = invert.write();
+ Vector3 *facesw = faces.ptrw();
+ Vector2 *uvsw = uvs.ptrw();
+ bool *smoothw = smooth.ptrw();
+ Ref<Material> *materialsw = materials.ptrw();
+ bool *invertw = invert.ptrw();
int face = 0;
@@ -1457,12 +1451,12 @@ void CSGCylinder::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_smooth_faces", "smooth_faces"), &CSGCylinder::set_smooth_faces);
ClassDB::bind_method(D_METHOD("get_smooth_faces"), &CSGCylinder::get_smooth_faces);
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "radius", PROPERTY_HINT_EXP_RANGE, "0.001,1000.0,0.001,or_greater"), "set_radius", "get_radius");
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "height", PROPERTY_HINT_EXP_RANGE, "0.001,1000.0,0.001,or_greater"), "set_height", "get_height");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "radius", PROPERTY_HINT_EXP_RANGE, "0.001,1000.0,0.001,or_greater"), "set_radius", "get_radius");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "height", PROPERTY_HINT_EXP_RANGE, "0.001,1000.0,0.001,or_greater"), "set_height", "get_height");
ADD_PROPERTY(PropertyInfo(Variant::INT, "sides", PROPERTY_HINT_RANGE, "3,64,1"), "set_sides", "get_sides");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "cone"), "set_cone", "is_cone");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "smooth_faces"), "set_smooth_faces", "get_smooth_faces");
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "SpatialMaterial,ShaderMaterial"), "set_material", "get_material");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "StandardMaterial3D,ShaderMaterial"), "set_material", "get_material");
}
void CSGCylinder::set_radius(const float p_radius) {
@@ -1562,11 +1556,11 @@ CSGBrush *CSGTorus::_build_brush() {
bool invert_val = is_inverting_faces();
Ref<Material> material = get_material();
- PoolVector<Vector3> faces;
- PoolVector<Vector2> uvs;
- PoolVector<bool> smooth;
- PoolVector<Ref<Material> > materials;
- PoolVector<bool> invert;
+ Vector<Vector3> faces;
+ Vector<Vector2> uvs;
+ Vector<bool> smooth;
+ Vector<Ref<Material> > materials;
+ Vector<bool> invert;
faces.resize(face_count * 3);
uvs.resize(face_count * 3);
@@ -1577,11 +1571,11 @@ CSGBrush *CSGTorus::_build_brush() {
{
- PoolVector<Vector3>::Write facesw = faces.write();
- PoolVector<Vector2>::Write uvsw = uvs.write();
- PoolVector<bool>::Write smoothw = smooth.write();
- PoolVector<Ref<Material> >::Write materialsw = materials.write();
- PoolVector<bool>::Write invertw = invert.write();
+ Vector3 *facesw = faces.ptrw();
+ Vector2 *uvsw = uvs.ptrw();
+ bool *smoothw = smooth.ptrw();
+ Ref<Material> *materialsw = materials.ptrw();
+ bool *invertw = invert.ptrw();
int face = 0;
@@ -1684,12 +1678,12 @@ void CSGTorus::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_smooth_faces", "smooth_faces"), &CSGTorus::set_smooth_faces);
ClassDB::bind_method(D_METHOD("get_smooth_faces"), &CSGTorus::get_smooth_faces);
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "inner_radius", PROPERTY_HINT_EXP_RANGE, "0.001,1000.0,0.001,or_greater"), "set_inner_radius", "get_inner_radius");
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "outer_radius", PROPERTY_HINT_EXP_RANGE, "0.001,1000.0,0.001,or_greater"), "set_outer_radius", "get_outer_radius");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "inner_radius", PROPERTY_HINT_EXP_RANGE, "0.001,1000.0,0.001,or_greater"), "set_inner_radius", "get_inner_radius");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "outer_radius", PROPERTY_HINT_EXP_RANGE, "0.001,1000.0,0.001,or_greater"), "set_outer_radius", "get_outer_radius");
ADD_PROPERTY(PropertyInfo(Variant::INT, "sides", PROPERTY_HINT_RANGE, "3,64,1"), "set_sides", "get_sides");
ADD_PROPERTY(PropertyInfo(Variant::INT, "ring_sides", PROPERTY_HINT_RANGE, "3,64,1"), "set_ring_sides", "get_ring_sides");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "smooth_faces"), "set_smooth_faces", "get_smooth_faces");
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "SpatialMaterial,ShaderMaterial"), "set_material", "get_material");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "StandardMaterial3D,ShaderMaterial"), "set_material", "get_material");
}
void CSGTorus::set_inner_radius(const float p_inner_radius) {
@@ -1818,15 +1812,15 @@ CSGBrush *CSGPolygon::_build_brush() {
if (path != path_cache) {
if (path_cache) {
- path_cache->disconnect("tree_exited", this, "_path_exited");
- path_cache->disconnect("curve_changed", this, "_path_changed");
+ path_cache->disconnect_compat("tree_exited", this, "_path_exited");
+ path_cache->disconnect_compat("curve_changed", this, "_path_changed");
path_cache = NULL;
}
path_cache = path;
- path_cache->connect("tree_exited", this, "_path_exited");
- path_cache->connect("curve_changed", this, "_path_changed");
+ path_cache->connect_compat("tree_exited", this, "_path_exited");
+ path_cache->connect_compat("curve_changed", this, "_path_changed");
path_cache = NULL;
}
curve = path->get_curve();
@@ -1856,11 +1850,11 @@ CSGBrush *CSGPolygon::_build_brush() {
bool invert_val = is_inverting_faces();
Ref<Material> material = get_material();
- PoolVector<Vector3> faces;
- PoolVector<Vector2> uvs;
- PoolVector<bool> smooth;
- PoolVector<Ref<Material> > materials;
- PoolVector<bool> invert;
+ Vector<Vector3> faces;
+ Vector<Vector2> uvs;
+ Vector<bool> smooth;
+ Vector<Ref<Material> > materials;
+ Vector<bool> invert;
faces.resize(face_count * 3);
uvs.resize(face_count * 3);
@@ -1872,11 +1866,11 @@ CSGBrush *CSGPolygon::_build_brush() {
AABB aabb; //must be computed
{
- PoolVector<Vector3>::Write facesw = faces.write();
- PoolVector<Vector2>::Write uvsw = uvs.write();
- PoolVector<bool>::Write smoothw = smooth.write();
- PoolVector<Ref<Material> >::Write materialsw = materials.write();
- PoolVector<bool>::Write invertw = invert.write();
+ Vector3 *facesw = faces.ptrw();
+ Vector2 *uvsw = uvs.ptrw();
+ bool *smoothw = smooth.ptrw();
+ Ref<Material> *materialsw = materials.ptrw();
+ bool *invertw = invert.ptrw();
int face = 0;
@@ -2242,8 +2236,8 @@ CSGBrush *CSGPolygon::_build_brush() {
void CSGPolygon::_notification(int p_what) {
if (p_what == NOTIFICATION_EXIT_TREE) {
if (path_cache) {
- path_cache->disconnect("tree_exited", this, "_path_exited");
- path_cache->disconnect("curve_changed", this, "_path_changed");
+ path_cache->disconnect_compat("tree_exited", this, "_path_exited");
+ path_cache->disconnect_compat("curve_changed", this, "_path_changed");
path_cache = NULL;
}
}
@@ -2318,19 +2312,19 @@ void CSGPolygon::_bind_methods() {
ClassDB::bind_method(D_METHOD("_path_exited"), &CSGPolygon::_path_exited);
ClassDB::bind_method(D_METHOD("_path_changed"), &CSGPolygon::_path_changed);
- ADD_PROPERTY(PropertyInfo(Variant::POOL_VECTOR2_ARRAY, "polygon"), "set_polygon", "get_polygon");
+ ADD_PROPERTY(PropertyInfo(Variant::PACKED_VECTOR2_ARRAY, "polygon"), "set_polygon", "get_polygon");
ADD_PROPERTY(PropertyInfo(Variant::INT, "mode", PROPERTY_HINT_ENUM, "Depth,Spin,Path"), "set_mode", "get_mode");
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "depth", PROPERTY_HINT_EXP_RANGE, "0.001,1000.0,0.001,or_greater"), "set_depth", "get_depth");
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "spin_degrees", PROPERTY_HINT_RANGE, "1,360,0.1"), "set_spin_degrees", "get_spin_degrees");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "depth", PROPERTY_HINT_EXP_RANGE, "0.001,1000.0,0.001,or_greater"), "set_depth", "get_depth");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "spin_degrees", PROPERTY_HINT_RANGE, "1,360,0.1"), "set_spin_degrees", "get_spin_degrees");
ADD_PROPERTY(PropertyInfo(Variant::INT, "spin_sides", PROPERTY_HINT_RANGE, "3,64,1"), "set_spin_sides", "get_spin_sides");
ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "path_node", PROPERTY_HINT_NODE_PATH_VALID_TYPES, "Path"), "set_path_node", "get_path_node");
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "path_interval", PROPERTY_HINT_EXP_RANGE, "0.001,1000.0,0.001,or_greater"), "set_path_interval", "get_path_interval");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "path_interval", PROPERTY_HINT_EXP_RANGE, "0.001,1000.0,0.001,or_greater"), "set_path_interval", "get_path_interval");
ADD_PROPERTY(PropertyInfo(Variant::INT, "path_rotation", PROPERTY_HINT_ENUM, "Polygon,Path,PathFollow"), "set_path_rotation", "get_path_rotation");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "path_local"), "set_path_local", "is_path_local");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "path_continuous_u"), "set_path_continuous_u", "is_path_continuous_u");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "path_joined"), "set_path_joined", "is_path_joined");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "smooth_faces"), "set_smooth_faces", "get_smooth_faces");
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "SpatialMaterial,ShaderMaterial"), "set_material", "get_material");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "StandardMaterial3D,ShaderMaterial"), "set_material", "get_material");
BIND_ENUM_CONSTANT(MODE_DEPTH);
BIND_ENUM_CONSTANT(MODE_SPIN);
diff --git a/modules/csg/csg_shape.h b/modules/csg/csg_shape.h
index 1098feea51..909437e39b 100644
--- a/modules/csg/csg_shape.h
+++ b/modules/csg/csg_shape.h
@@ -80,17 +80,17 @@ private:
};
struct ShapeUpdateSurface {
- PoolVector<Vector3> vertices;
- PoolVector<Vector3> normals;
- PoolVector<Vector2> uvs;
- PoolVector<float> tans;
+ Vector<Vector3> vertices;
+ Vector<Vector3> normals;
+ Vector<Vector2> uvs;
+ Vector<float> tans;
Ref<Material> material;
int last_added;
- PoolVector<Vector3>::Write verticesw;
- PoolVector<Vector3>::Write normalsw;
- PoolVector<Vector2>::Write uvsw;
- PoolVector<float>::Write tansw;
+ Vector3 *verticesw;
+ Vector3 *normalsw;
+ Vector2 *uvsw;
+ float *tansw;
};
//mikktspace callbacks
@@ -122,10 +122,10 @@ public:
void set_operation(Operation p_operation);
Operation get_operation() const;
- virtual PoolVector<Vector3> get_brush_faces();
+ virtual Vector<Vector3> get_brush_faces();
virtual AABB get_aabb() const;
- virtual PoolVector<Face3> get_faces(uint32_t p_usage_flags) const;
+ virtual Vector<Face3> get_faces(uint32_t p_usage_flags) const;
void set_use_collision(bool p_enable);
bool is_using_collision() const;
@@ -172,7 +172,7 @@ private:
bool invert_faces;
protected:
- CSGBrush *_create_brush_from_arrays(const PoolVector<Vector3> &p_vertices, const PoolVector<Vector2> &p_uv, const PoolVector<bool> &p_smooth, const PoolVector<Ref<Material> > &p_materials);
+ CSGBrush *_create_brush_from_arrays(const Vector<Vector3> &p_vertices, const Vector<Vector2> &p_uv, const Vector<bool> &p_smooth, const Vector<Ref<Material> > &p_materials);
static void _bind_methods();
public:
diff --git a/modules/csg/doc_classes/CSGPolygon.xml b/modules/csg/doc_classes/CSGPolygon.xml
index 64ae46c69a..02b2e8b03f 100644
--- a/modules/csg/doc_classes/CSGPolygon.xml
+++ b/modules/csg/doc_classes/CSGPolygon.xml
@@ -38,7 +38,7 @@
<member name="path_rotation" type="int" setter="set_path_rotation" getter="get_path_rotation" enum="CSGPolygon.PathRotation">
The method by which each slice is rotated along the path when [member mode] is [constant MODE_PATH].
</member>
- <member name="polygon" type="PoolVector2Array" setter="set_polygon" getter="get_polygon" default="PoolVector2Array( 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/cvtt/image_compress_cvtt.cpp b/modules/cvtt/image_compress_cvtt.cpp
index c261350e89..9dbaa88202 100644
--- a/modules/cvtt/image_compress_cvtt.cpp
+++ b/modules/cvtt/image_compress_cvtt.cpp
@@ -136,7 +136,7 @@ static void _digest_job_queue(void *p_job_queue) {
}
}
-void image_compress_cvtt(Image *p_image, float p_lossy_quality, Image::CompressSource p_source) {
+void image_compress_cvtt(Image *p_image, float p_lossy_quality, Image::UsedChannels p_channels) {
if (p_image->get_format() >= Image::FORMAT_BPTC_RGBA)
return; //do not compress, already compressed
@@ -167,7 +167,7 @@ void image_compress_cvtt(Image *p_image, float p_lossy_quality, Image::CompressS
flags |= cvtt::Flags::BC7_RespectPunchThrough;
- if (p_source == Image::COMPRESS_SOURCE_NORMAL) {
+ if (p_channels == Image::USED_CHANNELS_RG) { //guessing this is a normalmap
flags |= cvtt::Flags::Uniform;
}
@@ -179,7 +179,7 @@ void image_compress_cvtt(Image *p_image, float p_lossy_quality, Image::CompressS
p_image->convert(Image::FORMAT_RGBH);
}
- PoolVector<uint8_t>::Read rb = p_image->get_data().read();
+ const uint8_t *rb = p_image->get_data().ptr();
const uint16_t *source_data = reinterpret_cast<const uint16_t *>(&rb[0]);
int pixel_element_count = w * h * 3;
@@ -195,15 +195,15 @@ void image_compress_cvtt(Image *p_image, float p_lossy_quality, Image::CompressS
p_image->convert(Image::FORMAT_RGBA8); //still uses RGBA to convert
}
- PoolVector<uint8_t>::Read rb = p_image->get_data().read();
+ const uint8_t *rb = p_image->get_data().ptr();
- PoolVector<uint8_t> data;
+ Vector<uint8_t> data;
int target_size = Image::get_image_data_size(w, h, target_format, p_image->has_mipmaps());
int mm_count = p_image->has_mipmaps() ? Image::get_image_required_mipmaps(w, h, target_format) : 0;
data.resize(target_size);
int shift = Image::get_format_pixel_rshift(target_format);
- PoolVector<uint8_t>::Write wb = data.write();
+ uint8_t *wb = data.ptrw();
int dst_ofs = 0;
@@ -219,7 +219,7 @@ void image_compress_cvtt(Image *p_image, float p_lossy_quality, Image::CompressS
int num_job_threads = OS::get_singleton()->can_use_threads() ? (OS::get_singleton()->get_processor_count() - 1) : 0;
#endif
- PoolVector<CVTTCompressionRowTask> tasks;
+ Vector<CVTTCompressionRowTask> tasks;
for (int i = 0; i <= mm_count; i++) {
@@ -254,12 +254,12 @@ void image_compress_cvtt(Image *p_image, float p_lossy_quality, Image::CompressS
}
if (num_job_threads > 0) {
- PoolVector<Thread *> threads;
+ Vector<Thread *> threads;
threads.resize(num_job_threads);
- PoolVector<Thread *>::Write threads_wb = threads.write();
+ Thread **threads_wb = threads.ptrw();
- PoolVector<CVTTCompressionRowTask>::Read tasks_rb = tasks.read();
+ const CVTTCompressionRowTask *tasks_rb = tasks.ptr();
job_queue.job_tasks = &tasks_rb[0];
job_queue.current_task = 0;
@@ -304,14 +304,14 @@ void image_decompress_cvtt(Image *p_image) {
int w = p_image->get_width();
int h = p_image->get_height();
- PoolVector<uint8_t>::Read rb = p_image->get_data().read();
+ const uint8_t *rb = p_image->get_data().ptr();
- PoolVector<uint8_t> data;
+ Vector<uint8_t> data;
int target_size = Image::get_image_data_size(w, h, target_format, p_image->has_mipmaps());
int mm_count = p_image->get_mipmap_count();
data.resize(target_size);
- PoolVector<uint8_t>::Write wb = data.write();
+ uint8_t *wb = data.ptrw();
int bytes_per_pixel = is_hdr ? 6 : 4;
@@ -388,8 +388,5 @@ void image_decompress_cvtt(Image *p_image) {
h >>= 1;
}
- rb.release();
- wb.release();
-
p_image->create(p_image->get_width(), p_image->get_height(), p_image->has_mipmaps(), target_format, data);
}
diff --git a/modules/cvtt/image_compress_cvtt.h b/modules/cvtt/image_compress_cvtt.h
index ecb876ecc6..c1772199af 100644
--- a/modules/cvtt/image_compress_cvtt.h
+++ b/modules/cvtt/image_compress_cvtt.h
@@ -33,7 +33,7 @@
#include "core/image.h"
-void image_compress_cvtt(Image *p_image, float p_lossy_quality, Image::CompressSource p_source);
+void image_compress_cvtt(Image *p_image, float p_lossy_quality, Image::UsedChannels p_channels);
void image_decompress_cvtt(Image *p_image);
#endif // IMAGE_COMPRESS_CVTT_H
diff --git a/modules/dds/texture_loader_dds.cpp b/modules/dds/texture_loader_dds.cpp
index a7701329d8..a04989449c 100644
--- a/modules/dds/texture_loader_dds.cpp
+++ b/modules/dds/texture_loader_dds.cpp
@@ -222,7 +222,7 @@ RES ResourceFormatDDS::load(const String &p_path, const String &p_original_path,
if (!(flags & DDSD_MIPMAPCOUNT))
mipmaps = 1;
- PoolVector<uint8_t> src_data;
+ Vector<uint8_t> src_data;
const DDSFormatInfo &info = dds_format_info[dds_format];
uint32_t w = width;
@@ -245,8 +245,8 @@ RES ResourceFormatDDS::load(const String &p_path, const String &p_original_path,
}
src_data.resize(size);
- PoolVector<uint8_t>::Write wb = src_data.write();
- f->get_buffer(wb.ptr(), size);
+ uint8_t *wb = src_data.ptrw();
+ f->get_buffer(wb, size);
} else if (info.palette) {
@@ -278,8 +278,8 @@ RES ResourceFormatDDS::load(const String &p_path, const String &p_original_path,
}
src_data.resize(size + 256 * colsize);
- PoolVector<uint8_t>::Write wb = src_data.write();
- f->get_buffer(wb.ptr(), size);
+ uint8_t *wb = src_data.ptrw();
+ f->get_buffer(wb, size);
for (int i = 0; i < 256; i++) {
@@ -309,8 +309,8 @@ RES ResourceFormatDDS::load(const String &p_path, const String &p_original_path,
size = size * 2;
src_data.resize(size);
- PoolVector<uint8_t>::Write wb = src_data.write();
- f->get_buffer(wb.ptr(), size);
+ uint8_t *wb = src_data.ptrw();
+ f->get_buffer(wb, size);
switch (dds_format) {
@@ -457,7 +457,7 @@ void ResourceFormatDDS::get_recognized_extensions(List<String> *p_extensions) co
bool ResourceFormatDDS::handles_type(const String &p_type) const {
- return ClassDB::is_parent_class(p_type, "Texture");
+ return ClassDB::is_parent_class(p_type, "Texture2D");
}
String ResourceFormatDDS::get_resource_type(const String &p_path) const {
diff --git a/modules/enet/doc_classes/NetworkedMultiplayerENet.xml b/modules/enet/doc_classes/NetworkedMultiplayerENet.xml
index 76b3710e96..456bf649d2 100644
--- a/modules/enet/doc_classes/NetworkedMultiplayerENet.xml
+++ b/modules/enet/doc_classes/NetworkedMultiplayerENet.xml
@@ -104,6 +104,24 @@
The IP used when creating a server. This is set to the wildcard [code]"*"[/code] by default, which binds to all available interfaces. The given IP needs to be in IPv4 or IPv6 address format, for example: [code]"192.168.1.1"[/code].
</description>
</method>
+ <method name="set_dtls_certificate">
+ <return type="void">
+ </return>
+ <argument index="0" name="certificate" type="X509Certificate">
+ </argument>
+ <description>
+ Configure the [X509Certificate] to use when [member use_dtls] is [code]true[/code]. For servers, you must also setup the [CryptoKey] via [method set_dtls_key].
+ </description>
+ </method>
+ <method name="set_dtls_key">
+ <return type="void">
+ </return>
+ <argument index="0" name="key" type="CryptoKey">
+ </argument>
+ <description>
+ Configure the [CryptoKey] to use when [member use_dtls] is [code]true[/code]. Remember to also call [method set_dtls_certificate] to setup your [X509Certificate].
+ </description>
+ </method>
</methods>
<members>
<member name="always_ordered" type="bool" setter="set_always_ordered" getter="is_always_ordered" default="false">
@@ -115,6 +133,9 @@
<member name="compression_mode" type="int" setter="set_compression_mode" getter="get_compression_mode" enum="NetworkedMultiplayerENet.CompressionMode" default="0">
The compression method used for network packets. These have different tradeoffs of compression speed versus bandwidth, you may need to test which one works best for your use case if you use compression at all.
</member>
+ <member name="dtls_verify" type="bool" setter="set_dtls_verify_enabled" getter="is_dtls_verify_enabled" default="true">
+ Enable or disable certiticate verification when [member use_dtls] [code]true[/code].
+ </member>
<member name="refuse_new_connections" type="bool" setter="set_refuse_new_connections" getter="is_refusing_new_connections" override="true" default="false" />
<member name="server_relay" type="bool" setter="set_server_relay_enabled" getter="is_server_relay_enabled" default="true">
Enable or disable the server feature that notifies clients of other peers' connection/disconnection, and relays messages between them. When this option is [code]false[/code], clients won't be automatically notified of other peers and won't be able to send them packets through the server.
@@ -123,6 +144,10 @@
Set the default channel to be used to transfer data. By default, this value is [code]-1[/code] which means that ENet will only use 2 channels, one for reliable and one for unreliable packets. Channel [code]0[/code] is reserved, and cannot be used. Setting this member to any value between [code]0[/code] and [member channel_count] (excluded) will force ENet to use that channel for sending data.
</member>
<member name="transfer_mode" type="int" setter="set_transfer_mode" getter="get_transfer_mode" override="true" enum="NetworkedMultiplayerPeer.TransferMode" default="2" />
+ <member name="use_dtls" type="bool" setter="set_dtls_enabled" getter="is_dtls_enabled" default="false">
+ When enabled, the client or server created by this peer, will use [PacketPeerDTLS] instead of raw UDP sockets for communicating with the remote peer. This will make the communication encrypted with DTLS at the cost of higher resource usage and potentially larger packet size.
+ Note: When creating a DTLS server, make sure you setup the key/certificate pair via [method set_dtls_key] and [method set_dtls_certificate]. For DTLS clients, have a look at the [member dtls_verify] option, and configure the certificate accordingly via [method set_dtls_certificate].
+ </member>
</members>
<constants>
<constant name="COMPRESS_NONE" value="0" enum="CompressionMode">
diff --git a/modules/enet/networked_multiplayer_enet.cpp b/modules/enet/networked_multiplayer_enet.cpp
index 21dd758391..406eb467f0 100644
--- a/modules/enet/networked_multiplayer_enet.cpp
+++ b/modules/enet/networked_multiplayer_enet.cpp
@@ -49,7 +49,7 @@ void NetworkedMultiplayerENet::set_target_peer(int p_peer) {
int NetworkedMultiplayerENet::get_packet_peer() const {
- ERR_FAIL_COND_V(!active, 1);
+ ERR_FAIL_COND_V_MSG(!active, 1, "The multiplayer instance isn't currently active.");
ERR_FAIL_COND_V(incoming_packets.size() == 0, 1);
return incoming_packets.front()->get().from;
@@ -57,7 +57,7 @@ int NetworkedMultiplayerENet::get_packet_peer() const {
int NetworkedMultiplayerENet::get_packet_channel() const {
- ERR_FAIL_COND_V(!active, -1);
+ ERR_FAIL_COND_V_MSG(!active, -1, "The multiplayer instance isn't currently active.");
ERR_FAIL_COND_V(incoming_packets.size() == 0, -1);
return incoming_packets.front()->get().channel;
@@ -65,7 +65,7 @@ int NetworkedMultiplayerENet::get_packet_channel() const {
int NetworkedMultiplayerENet::get_last_packet_channel() const {
- ERR_FAIL_COND_V(!active, -1);
+ ERR_FAIL_COND_V_MSG(!active, -1, "The multiplayer instance isn't currently active.");
ERR_FAIL_COND_V(!current_packet.packet, -1);
return current_packet.channel;
@@ -73,11 +73,12 @@ int NetworkedMultiplayerENet::get_last_packet_channel() const {
Error NetworkedMultiplayerENet::create_server(int p_port, int p_max_clients, int p_in_bandwidth, int p_out_bandwidth) {
- ERR_FAIL_COND_V(active, ERR_ALREADY_IN_USE);
- ERR_FAIL_COND_V(p_port < 0 || p_port > 65535, ERR_INVALID_PARAMETER);
- ERR_FAIL_COND_V(p_max_clients < 1 || p_max_clients > 4095, ERR_INVALID_PARAMETER);
- ERR_FAIL_COND_V(p_in_bandwidth < 0, ERR_INVALID_PARAMETER);
- ERR_FAIL_COND_V(p_out_bandwidth < 0, ERR_INVALID_PARAMETER);
+ ERR_FAIL_COND_V_MSG(active, ERR_ALREADY_IN_USE, "The multiplayer instance is already active.");
+ ERR_FAIL_COND_V_MSG(p_port < 0 || p_port > 65535, ERR_INVALID_PARAMETER, "The port number must be set between 0 and 65535 (inclusive).");
+ ERR_FAIL_COND_V_MSG(p_max_clients < 1 || p_max_clients > 4095, ERR_INVALID_PARAMETER, "The number of clients must be set between 1 and 4095 (inclusive).");
+ ERR_FAIL_COND_V_MSG(p_in_bandwidth < 0, ERR_INVALID_PARAMETER, "The incoming bandwidth limit must be greater than or equal to 0 (0 disables the limit).");
+ ERR_FAIL_COND_V_MSG(p_out_bandwidth < 0, ERR_INVALID_PARAMETER, "The outgoing bandwidth limit must be greater than or equal to 0 (0 disables the limit).");
+ ERR_FAIL_COND_V(dtls_enabled && (dtls_key.is_null() || dtls_cert.is_null()), ERR_INVALID_PARAMETER);
ENetAddress address;
memset(&address, 0, sizeof(address));
@@ -104,7 +105,12 @@ Error NetworkedMultiplayerENet::create_server(int p_port, int p_max_clients, int
p_in_bandwidth /* limit incoming bandwidth if > 0 */,
p_out_bandwidth /* limit outgoing bandwidth if > 0 */);
- ERR_FAIL_COND_V(!host, ERR_CANT_CREATE);
+ ERR_FAIL_COND_V_MSG(!host, ERR_CANT_CREATE, "Couldn't create an ENet multiplayer server.");
+#ifdef GODOT_ENET
+ if (dtls_enabled) {
+ enet_host_dtls_server_setup(host, dtls_key.ptr(), dtls_cert.ptr());
+ }
+#endif
_setup_compressor();
active = true;
@@ -116,11 +122,11 @@ Error NetworkedMultiplayerENet::create_server(int p_port, int p_max_clients, int
}
Error NetworkedMultiplayerENet::create_client(const String &p_address, int p_port, int p_in_bandwidth, int p_out_bandwidth, int p_client_port) {
- ERR_FAIL_COND_V(active, ERR_ALREADY_IN_USE);
- ERR_FAIL_COND_V(p_port < 0 || p_port > 65535, ERR_INVALID_PARAMETER);
- ERR_FAIL_COND_V(p_client_port < 0 || p_client_port > 65535, ERR_INVALID_PARAMETER);
- ERR_FAIL_COND_V(p_in_bandwidth < 0, ERR_INVALID_PARAMETER);
- ERR_FAIL_COND_V(p_out_bandwidth < 0, ERR_INVALID_PARAMETER);
+ ERR_FAIL_COND_V_MSG(active, ERR_ALREADY_IN_USE, "The multiplayer instance is already active.");
+ ERR_FAIL_COND_V_MSG(p_port < 0 || p_port > 65535, ERR_INVALID_PARAMETER, "The server port number must be set between 0 and 65535 (inclusive).");
+ ERR_FAIL_COND_V_MSG(p_client_port < 0 || p_client_port > 65535, ERR_INVALID_PARAMETER, "The client port number must be set between 0 and 65535 (inclusive).");
+ ERR_FAIL_COND_V_MSG(p_in_bandwidth < 0, ERR_INVALID_PARAMETER, "The incoming bandwidth limit must be greater than or equal to 0 (0 disables the limit).");
+ ERR_FAIL_COND_V_MSG(p_out_bandwidth < 0, ERR_INVALID_PARAMETER, "The outgoing bandwidth limit must be greater than or equal to 0 (0 disables the limit).");
if (p_client_port != 0) {
ENetAddress c_client;
@@ -135,7 +141,7 @@ Error NetworkedMultiplayerENet::create_client(const String &p_address, int p_por
if (bind_ip.is_wildcard()) {
c_client.host = 0;
} else {
- ERR_FAIL_COND_V(!bind_ip.is_ipv4(), ERR_INVALID_PARAMETER);
+ ERR_FAIL_COND_V_MSG(!bind_ip.is_ipv4(), ERR_INVALID_PARAMETER, "Wildcard IP addresses are only permitted in IPv4, not IPv6.");
c_client.host = *(uint32_t *)bind_ip.get_ipv4();
}
#endif
@@ -155,7 +161,12 @@ Error NetworkedMultiplayerENet::create_client(const String &p_address, int p_por
p_out_bandwidth /* limit outgoing bandwidth if > 0 */);
}
- ERR_FAIL_COND_V(!host, ERR_CANT_CREATE);
+ ERR_FAIL_COND_V_MSG(!host, ERR_CANT_CREATE, "Couldn't create the ENet client host.");
+#ifdef GODOT_ENET
+ if (dtls_enabled) {
+ enet_host_dtls_client_setup(host, dtls_cert.ptr(), dtls_verify, p_address.utf8().get_data());
+ }
+#endif
_setup_compressor();
@@ -169,14 +180,14 @@ Error NetworkedMultiplayerENet::create_client(const String &p_address, int p_por
ip = IP::get_singleton()->resolve_hostname(p_address, IP::TYPE_IPV4);
#endif
- ERR_FAIL_COND_V(!ip.is_valid(), ERR_CANT_RESOLVE);
+ ERR_FAIL_COND_V_MSG(!ip.is_valid(), ERR_CANT_RESOLVE, "Couldn't resolve the server IP address or domain name.");
}
ENetAddress address;
#ifdef GODOT_ENET
enet_address_set_ip(&address, ip.get_ipv6(), 16);
#else
- ERR_FAIL_COND_V(!ip.is_ipv4(), ERR_INVALID_PARAMETER);
+ ERR_FAIL_COND_V_MSG(!ip.is_ipv4(), ERR_INVALID_PARAMETER, "Connecting to an IPv6 server isn't supported when using vanilla ENet. Recompile Godot with the bundled ENet library.");
address.host = *(uint32_t *)ip.get_ipv4();
#endif
address.port = p_port;
@@ -188,7 +199,7 @@ Error NetworkedMultiplayerENet::create_client(const String &p_address, int p_por
if (peer == NULL) {
enet_host_destroy(host);
- ERR_FAIL_COND_V(!peer, ERR_CANT_CREATE);
+ ERR_FAIL_COND_V_MSG(!peer, ERR_CANT_CREATE, "Couldn't connect to the ENet multiplayer server.");
}
// Technically safe to ignore the peer or anything else.
@@ -203,7 +214,7 @@ Error NetworkedMultiplayerENet::create_client(const String &p_address, int p_por
void NetworkedMultiplayerENet::poll() {
- ERR_FAIL_COND(!active);
+ ERR_FAIL_COND_MSG(!active, "The multiplayer instance isn't currently active.");
_pop_current_packet();
@@ -435,14 +446,14 @@ void NetworkedMultiplayerENet::poll() {
}
bool NetworkedMultiplayerENet::is_server() const {
- ERR_FAIL_COND_V(!active, false);
+ ERR_FAIL_COND_V_MSG(!active, false, "The multiplayer instance isn't currently active.");
return server;
}
void NetworkedMultiplayerENet::close_connection(uint32_t wait_usec) {
- ERR_FAIL_COND(!active);
+ ERR_FAIL_COND_MSG(!active, "The multiplayer instance isn't currently active.");
_pop_current_packet();
@@ -474,9 +485,9 @@ void NetworkedMultiplayerENet::close_connection(uint32_t wait_usec) {
void NetworkedMultiplayerENet::disconnect_peer(int p_peer, bool now) {
- ERR_FAIL_COND(!active);
- ERR_FAIL_COND(!is_server());
- ERR_FAIL_COND(!peer_map.has(p_peer));
+ ERR_FAIL_COND_MSG(!active, "The multiplayer instance isn't currently active.");
+ ERR_FAIL_COND_MSG(!is_server(), "Can't disconnect a peer when not acting as a server.");
+ ERR_FAIL_COND_MSG(!peer_map.has(p_peer), vformat("Peer ID %d not found in the list of peers.", p_peer));
if (now) {
int *id = (int *)peer_map[p_peer]->data;
@@ -515,7 +526,7 @@ int NetworkedMultiplayerENet::get_available_packet_count() const {
Error NetworkedMultiplayerENet::get_packet(const uint8_t **r_buffer, int &r_buffer_size) {
- ERR_FAIL_COND_V(incoming_packets.size() == 0, ERR_UNAVAILABLE);
+ ERR_FAIL_COND_V_MSG(incoming_packets.size() == 0, ERR_UNAVAILABLE, "No incoming packets available.");
_pop_current_packet();
@@ -530,8 +541,8 @@ Error NetworkedMultiplayerENet::get_packet(const uint8_t **r_buffer, int &r_buff
Error NetworkedMultiplayerENet::put_packet(const uint8_t *p_buffer, int p_buffer_size) {
- ERR_FAIL_COND_V(!active, ERR_UNCONFIGURED);
- ERR_FAIL_COND_V(connection_status != CONNECTION_CONNECTED, ERR_UNCONFIGURED);
+ ERR_FAIL_COND_V_MSG(!active, ERR_UNCONFIGURED, "The multiplayer instance isn't currently active.");
+ ERR_FAIL_COND_V_MSG(connection_status != CONNECTION_CONNECTED, ERR_UNCONFIGURED, "The multiplayer instance isn't currently connected to any server or client.");
int packet_flags = 0;
int channel = SYSCH_RELIABLE;
@@ -562,7 +573,7 @@ Error NetworkedMultiplayerENet::put_packet(const uint8_t *p_buffer, int p_buffer
if (target_peer != 0) {
E = peer_map.find(ABS(target_peer));
- ERR_FAIL_COND_V_MSG(!E, ERR_INVALID_PARAMETER, "Invalid target peer '" + itos(target_peer) + "'.");
+ ERR_FAIL_COND_V_MSG(!E, ERR_INVALID_PARAMETER, vformat("Invalid target peer: %d", target_peer));
}
ENetPacket *packet = enet_packet_create(NULL, p_buffer_size + 8, packet_flags);
@@ -650,7 +661,7 @@ uint32_t NetworkedMultiplayerENet::_gen_unique_id() const {
int NetworkedMultiplayerENet::get_unique_id() const {
- ERR_FAIL_COND_V(!active, 0);
+ ERR_FAIL_COND_V_MSG(!active, 0, "The multiplayer instance isn't currently active.");
return unique_id;
}
@@ -706,7 +717,7 @@ size_t NetworkedMultiplayerENet::enet_compress(void *context, const ENetBuffer *
mode = Compression::MODE_ZSTD;
} break;
default: {
- ERR_FAIL_V(0);
+ ERR_FAIL_V_MSG(0, vformat("Invalid ENet compression mode: %d", enet->compression_mode));
}
}
@@ -781,9 +792,9 @@ void NetworkedMultiplayerENet::enet_compressor_destroy(void *context) {
IP_Address NetworkedMultiplayerENet::get_peer_address(int p_peer_id) const {
- ERR_FAIL_COND_V(!peer_map.has(p_peer_id), IP_Address());
- ERR_FAIL_COND_V(!is_server() && p_peer_id != 1, IP_Address());
- ERR_FAIL_COND_V(peer_map[p_peer_id] == NULL, IP_Address());
+ ERR_FAIL_COND_V_MSG(!peer_map.has(p_peer_id), IP_Address(), vformat("Peer ID %d not found in the list of peers.", p_peer_id));
+ ERR_FAIL_COND_V_MSG(!is_server() && p_peer_id != 1, IP_Address(), "Can't get the address of peers other than the server (ID -1) when acting as a client.");
+ ERR_FAIL_COND_V_MSG(peer_map[p_peer_id] == NULL, IP_Address(), vformat("Peer ID %d found in the list of peers, but is null.", p_peer_id));
IP_Address out;
#ifdef GODOT_ENET
@@ -797,9 +808,9 @@ IP_Address NetworkedMultiplayerENet::get_peer_address(int p_peer_id) const {
int NetworkedMultiplayerENet::get_peer_port(int p_peer_id) const {
- ERR_FAIL_COND_V(!peer_map.has(p_peer_id), 0);
- ERR_FAIL_COND_V(!is_server() && p_peer_id != 1, 0);
- ERR_FAIL_COND_V(peer_map[p_peer_id] == NULL, 0);
+ ERR_FAIL_COND_V_MSG(!peer_map.has(p_peer_id), 0, vformat("Peer ID %d not found in the list of peers.", p_peer_id));
+ ERR_FAIL_COND_V_MSG(!is_server() && p_peer_id != 1, 0, "Can't get the address of peers other than the server (ID -1) when acting as a client.");
+ ERR_FAIL_COND_V_MSG(peer_map[p_peer_id] == NULL, 0, vformat("Peer ID %d found in the list of peers, but is null.", p_peer_id));
#ifdef GODOT_ENET
return peer_map[p_peer_id]->address.port;
#else
@@ -809,8 +820,8 @@ int NetworkedMultiplayerENet::get_peer_port(int p_peer_id) const {
void NetworkedMultiplayerENet::set_transfer_channel(int p_channel) {
- ERR_FAIL_COND(p_channel < -1 || p_channel >= channel_count);
- ERR_FAIL_COND_MSG(p_channel == SYSCH_CONFIG, "Channel " + itos(SYSCH_CONFIG) + " is reserved.");
+ ERR_FAIL_COND_MSG(p_channel < -1 || p_channel >= channel_count, vformat("The transfer channel must be set between 0 and %d, inclusive (got %d).", channel_count - 1, p_channel));
+ ERR_FAIL_COND_MSG(p_channel == SYSCH_CONFIG, vformat("The channel %d is reserved.", SYSCH_CONFIG));
transfer_channel = p_channel;
}
@@ -820,8 +831,8 @@ int NetworkedMultiplayerENet::get_transfer_channel() const {
void NetworkedMultiplayerENet::set_channel_count(int p_channel) {
- ERR_FAIL_COND(active);
- ERR_FAIL_COND(p_channel < SYSCH_MAX);
+ ERR_FAIL_COND_MSG(active, "The channel count can't be set while the multiplayer instance is active.");
+ ERR_FAIL_COND_MSG(p_channel < SYSCH_MAX, vformat("The channel count must be greater than or equal to %d to account for reserved channels (got %d).", SYSCH_MAX, p_channel));
channel_count = p_channel;
}
@@ -838,7 +849,7 @@ bool NetworkedMultiplayerENet::is_always_ordered() const {
}
void NetworkedMultiplayerENet::set_server_relay_enabled(bool p_enabled) {
- ERR_FAIL_COND(active);
+ ERR_FAIL_COND_MSG(active, "Server relaying can't be toggled while the multiplayer instance is active.");
server_relay = p_enabled;
}
@@ -856,6 +867,12 @@ void NetworkedMultiplayerENet::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_compression_mode", "mode"), &NetworkedMultiplayerENet::set_compression_mode);
ClassDB::bind_method(D_METHOD("get_compression_mode"), &NetworkedMultiplayerENet::get_compression_mode);
ClassDB::bind_method(D_METHOD("set_bind_ip", "ip"), &NetworkedMultiplayerENet::set_bind_ip);
+ ClassDB::bind_method(D_METHOD("set_dtls_enabled", "enabled"), &NetworkedMultiplayerENet::set_dtls_enabled);
+ ClassDB::bind_method(D_METHOD("is_dtls_enabled"), &NetworkedMultiplayerENet::is_dtls_enabled);
+ ClassDB::bind_method(D_METHOD("set_dtls_key", "key"), &NetworkedMultiplayerENet::set_dtls_key);
+ ClassDB::bind_method(D_METHOD("set_dtls_certificate", "certificate"), &NetworkedMultiplayerENet::set_dtls_certificate);
+ ClassDB::bind_method(D_METHOD("set_dtls_verify_enabled", "enabled"), &NetworkedMultiplayerENet::set_dtls_verify_enabled);
+ ClassDB::bind_method(D_METHOD("is_dtls_verify_enabled"), &NetworkedMultiplayerENet::is_dtls_verify_enabled);
ClassDB::bind_method(D_METHOD("get_peer_address", "id"), &NetworkedMultiplayerENet::get_peer_address);
ClassDB::bind_method(D_METHOD("get_peer_port", "id"), &NetworkedMultiplayerENet::get_peer_port);
@@ -875,6 +892,8 @@ void NetworkedMultiplayerENet::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "channel_count"), "set_channel_count", "get_channel_count");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "always_ordered"), "set_always_ordered", "is_always_ordered");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "server_relay"), "set_server_relay_enabled", "is_server_relay_enabled");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "dtls_verify"), "set_dtls_verify_enabled", "is_dtls_verify_enabled");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_dtls"), "set_dtls_enabled", "is_dtls_enabled");
BIND_ENUM_CONSTANT(COMPRESS_NONE);
BIND_ENUM_CONSTANT(COMPRESS_RANGE_CODER);
@@ -904,6 +923,9 @@ NetworkedMultiplayerENet::NetworkedMultiplayerENet() {
enet_compressor.destroy = enet_compressor_destroy;
bind_ip = IP_Address("*");
+
+ dtls_enabled = false;
+ dtls_verify = true;
}
NetworkedMultiplayerENet::~NetworkedMultiplayerENet() {
@@ -916,7 +938,35 @@ NetworkedMultiplayerENet::~NetworkedMultiplayerENet() {
// Sets IP for ENet to bind when using create_server or create_client
// if no IP is set, then ENet bind to ENET_HOST_ANY
void NetworkedMultiplayerENet::set_bind_ip(const IP_Address &p_ip) {
- ERR_FAIL_COND(!p_ip.is_valid() && !p_ip.is_wildcard());
+ ERR_FAIL_COND_MSG(!p_ip.is_valid() && !p_ip.is_wildcard(), vformat("Invalid bind IP address: %s", String(p_ip)));
bind_ip = p_ip;
}
+
+void NetworkedMultiplayerENet::set_dtls_enabled(bool p_enabled) {
+ ERR_FAIL_COND(active);
+ dtls_enabled = p_enabled;
+}
+
+bool NetworkedMultiplayerENet::is_dtls_enabled() const {
+ return dtls_enabled;
+}
+
+void NetworkedMultiplayerENet::set_dtls_verify_enabled(bool p_enabled) {
+ ERR_FAIL_COND(active);
+ dtls_verify = p_enabled;
+}
+
+bool NetworkedMultiplayerENet::is_dtls_verify_enabled() const {
+ return dtls_verify;
+}
+
+void NetworkedMultiplayerENet::set_dtls_key(Ref<CryptoKey> p_key) {
+ ERR_FAIL_COND(active);
+ dtls_key = p_key;
+}
+
+void NetworkedMultiplayerENet::set_dtls_certificate(Ref<X509Certificate> p_cert) {
+ ERR_FAIL_COND(active);
+ dtls_cert = p_cert;
+}
diff --git a/modules/enet/networked_multiplayer_enet.h b/modules/enet/networked_multiplayer_enet.h
index 11487b99a5..ff436ce2c0 100644
--- a/modules/enet/networked_multiplayer_enet.h
+++ b/modules/enet/networked_multiplayer_enet.h
@@ -31,6 +31,7 @@
#ifndef NETWORKED_MULTIPLAYER_ENET_H
#define NETWORKED_MULTIPLAYER_ENET_H
+#include "core/crypto/crypto.h"
#include "core/io/compression.h"
#include "core/io/networked_multiplayer_peer.h"
@@ -111,6 +112,11 @@ private:
IP_Address bind_ip;
+ bool dtls_enabled;
+ Ref<CryptoKey> dtls_key;
+ Ref<X509Certificate> dtls_cert;
+ bool dtls_verify;
+
protected:
static void _bind_methods();
@@ -166,6 +172,12 @@ public:
~NetworkedMultiplayerENet();
void set_bind_ip(const IP_Address &p_ip);
+ void set_dtls_enabled(bool p_enabled);
+ bool is_dtls_enabled() const;
+ void set_dtls_verify_enabled(bool p_enabled);
+ bool is_dtls_verify_enabled() const;
+ void set_dtls_key(Ref<CryptoKey> p_key);
+ void set_dtls_certificate(Ref<X509Certificate> p_cert);
};
VARIANT_ENUM_CAST(NetworkedMultiplayerENet::CompressionMode);
diff --git a/modules/etc/image_etc.cpp b/modules/etc/image_etc.cpp
index b80138c99d..0dbd5ca905 100644
--- a/modules/etc/image_etc.cpp
+++ b/modules/etc/image_etc.cpp
@@ -36,18 +36,18 @@
#include "core/os/os.h"
#include "core/print_string.h"
-static Image::Format _get_etc2_mode(Image::DetectChannels format) {
+static Image::Format _get_etc2_mode(Image::UsedChannels format) {
switch (format) {
- case Image::DETECTED_R:
+ case Image::USED_CHANNELS_R:
return Image::FORMAT_ETC2_R11;
- case Image::DETECTED_RG:
+ case Image::USED_CHANNELS_RG:
return Image::FORMAT_ETC2_RG11;
- case Image::DETECTED_RGB:
+ case Image::USED_CHANNELS_RGB:
return Image::FORMAT_ETC2_RGB8;
- case Image::DETECTED_RGBA:
+ case Image::USED_CHANNELS_RGBA:
return Image::FORMAT_ETC2_RGBA8;
// TODO: would be nice if we could use FORMAT_ETC2_RGB8A1 for FORMAT_RGBA5551
@@ -88,47 +88,8 @@ static Etc::Image::Format _image_format_to_etc2comp_format(Image::Format format)
}
}
-static void _compress_etc(Image *p_img, float p_lossy_quality, bool force_etc1_format, Image::CompressSource p_source) {
+static void _compress_etc(Image *p_img, float p_lossy_quality, bool force_etc1_format, Image::UsedChannels p_channels) {
Image::Format img_format = p_img->get_format();
- Image::DetectChannels detected_channels = p_img->get_detected_channels();
-
- if (p_source == Image::COMPRESS_SOURCE_LAYERED) {
- //keep what comes in
- switch (p_img->get_format()) {
- case Image::FORMAT_L8: {
- detected_channels = Image::DETECTED_L;
- } break;
- case Image::FORMAT_LA8: {
- detected_channels = Image::DETECTED_LA;
- } break;
- case Image::FORMAT_R8: {
- detected_channels = Image::DETECTED_R;
- } break;
- case Image::FORMAT_RG8: {
- detected_channels = Image::DETECTED_RG;
- } break;
- case Image::FORMAT_RGB8: {
- detected_channels = Image::DETECTED_RGB;
- } break;
- case Image::FORMAT_RGBA8:
- case Image::FORMAT_RGBA4444:
- case Image::FORMAT_RGBA5551: {
- detected_channels = Image::DETECTED_RGBA;
- } break;
- default: {
- }
- }
- }
-
- if (p_source == Image::COMPRESS_SOURCE_SRGB && (detected_channels == Image::DETECTED_R || detected_channels == Image::DETECTED_RG)) {
- //R and RG do not support SRGB
- detected_channels = Image::DETECTED_RGB;
- }
-
- if (p_source == Image::COMPRESS_SOURCE_NORMAL) {
- //use RG channels only for normal
- detected_channels = Image::DETECTED_RG;
- }
if (img_format >= Image::FORMAT_DXT1) {
return; //do not compress, already compressed
@@ -139,21 +100,24 @@ static void _compress_etc(Image *p_img, float p_lossy_quality, bool force_etc1_f
return;
}
+ // FIXME: Commented out during Vulkan rebase.
+ /*
if (force_etc1_format) {
// If VRAM compression is using ETC, but image has alpha, convert to RGBA4444 or LA8
// This saves space while maintaining the alpha channel
- if (detected_channels == Image::DETECTED_RGBA) {
+ if (detected_channels == Image::USED_CHANNELS_RGBA) {
p_img->convert(Image::FORMAT_RGBA4444);
return;
- } else if (detected_channels == Image::DETECTED_LA) {
+ } else if (detected_channels == Image::USE_CHANNELS_LA) {
p_img->convert(Image::FORMAT_LA8);
return;
}
}
+ */
uint32_t imgw = p_img->get_width(), imgh = p_img->get_height();
- Image::Format etc_format = force_etc1_format ? Image::FORMAT_ETC : _get_etc2_mode(detected_channels);
+ Image::Format etc_format = force_etc1_format ? Image::FORMAT_ETC : _get_etc2_mode(p_channels);
Ref<Image> img = p_img->duplicate();
@@ -179,16 +143,16 @@ static void _compress_etc(Image *p_img, float p_lossy_quality, bool force_etc1_f
}
}
- PoolVector<uint8_t>::Read r = img->get_data().read();
- ERR_FAIL_COND(!r.ptr());
+ const uint8_t *r = img->get_data().ptr();
+ ERR_FAIL_COND(!r);
unsigned int target_size = Image::get_image_data_size(imgw, imgh, etc_format, p_img->has_mipmaps());
int mmc = 1 + (p_img->has_mipmaps() ? Image::get_image_required_mipmaps(imgw, imgh, etc_format) : 0);
- PoolVector<uint8_t> dst_data;
+ Vector<uint8_t> dst_data;
dst_data.resize(target_size);
- PoolVector<uint8_t>::Write w = dst_data.write();
+ uint8_t *w = dst_data.ptrw();
// prepare parameters to be passed to etc2comp
int num_cpus = OS::get_singleton()->get_processor_count();
@@ -241,11 +205,11 @@ static void _compress_etc(Image *p_img, float p_lossy_quality, bool force_etc1_f
}
static void _compress_etc1(Image *p_img, float p_lossy_quality) {
- _compress_etc(p_img, p_lossy_quality, true, Image::COMPRESS_SOURCE_GENERIC);
+ _compress_etc(p_img, p_lossy_quality, true, Image::USED_CHANNELS_RGB);
}
-static void _compress_etc2(Image *p_img, float p_lossy_quality, Image::CompressSource p_source) {
- _compress_etc(p_img, p_lossy_quality, false, p_source);
+static void _compress_etc2(Image *p_img, float p_lossy_quality, Image::UsedChannels p_channels) {
+ _compress_etc(p_img, p_lossy_quality, false, p_channels);
}
void _register_etc_compress_func() {
diff --git a/modules/etc/texture_loader_pkm.cpp b/modules/etc/texture_loader_pkm.cpp
index 27c2358306..e460c70cec 100644
--- a/modules/etc/texture_loader_pkm.cpp
+++ b/modules/etc/texture_loader_pkm.cpp
@@ -71,13 +71,12 @@ RES ResourceFormatPKM::load(const String &p_path, const String &p_original_path,
h.origWidth = f->get_16();
h.origHeight = f->get_16();
- PoolVector<uint8_t> src_data;
+ Vector<uint8_t> src_data;
uint32_t size = h.texWidth * h.texHeight / 2;
src_data.resize(size);
- PoolVector<uint8_t>::Write wb = src_data.write();
- f->get_buffer(wb.ptr(), size);
- wb.release();
+ uint8_t *wb = src_data.ptrw();
+ f->get_buffer(wb, size);
int mipmaps = h.format;
int width = h.origWidth;
@@ -103,7 +102,7 @@ void ResourceFormatPKM::get_recognized_extensions(List<String> *p_extensions) co
bool ResourceFormatPKM::handles_type(const String &p_type) const {
- return ClassDB::is_parent_class(p_type, "Texture");
+ return ClassDB::is_parent_class(p_type, "Texture2D");
}
String ResourceFormatPKM::get_resource_type(const String &p_path) const {
diff --git a/modules/gdnative/arvr/arvr_interface_gdnative.cpp b/modules/gdnative/arvr/arvr_interface_gdnative.cpp
index 5efa915f62..a033c2b7f9 100644
--- a/modules/gdnative/arvr/arvr_interface_gdnative.cpp
+++ b/modules/gdnative/arvr/arvr_interface_gdnative.cpp
@@ -277,7 +277,9 @@ godot_transform GDAPI godot_arvr_get_reference_frame() {
void GDAPI godot_arvr_blit(godot_int p_eye, godot_rid *p_render_target, godot_rect2 *p_rect) {
// blits out our texture as is, handy for preview display of one of the eyes that is already rendered with lens distortion on an external HMD
ARVRInterface::Eyes eye = (ARVRInterface::Eyes)p_eye;
+#if 0
RID *render_target = (RID *)p_render_target;
+#endif
Rect2 screen_rect = *(Rect2 *)p_rect;
if (eye == ARVRInterface::EYE_LEFT) {
@@ -286,18 +288,27 @@ void GDAPI godot_arvr_blit(godot_int p_eye, godot_rid *p_render_target, godot_re
screen_rect.size.x /= 2.0;
screen_rect.position.x += screen_rect.size.x;
}
-
- VSG::rasterizer->set_current_render_target(RID());
+#ifndef _MSC_VER
+#warning this needs to be redone
+#endif
+#if 0
VSG::rasterizer->blit_render_target_to_screen(*render_target, screen_rect, 0);
+#endif
}
godot_int GDAPI godot_arvr_get_texid(godot_rid *p_render_target) {
// In order to send off our textures to display on our hardware we need the opengl texture ID instead of the render target RID
// This is a handy function to expose that.
+#if 0
RID *render_target = (RID *)p_render_target;
RID eye_texture = VSG::storage->render_target_get_texture(*render_target);
- uint32_t texid = VS::get_singleton()->texture_get_texid(eye_texture);
+#endif
+
+#ifndef _MSC_VER
+#warning need to obtain this ID again
+#endif
+ uint32_t texid = 0; //VS::get_singleton()->texture_get_texid(eye_texture);
return texid;
}
diff --git a/modules/gdnative/arvr/arvr_interface_gdnative.h b/modules/gdnative/arvr/arvr_interface_gdnative.h
index 1077bef994..e38eb435c6 100644
--- a/modules/gdnative/arvr/arvr_interface_gdnative.h
+++ b/modules/gdnative/arvr/arvr_interface_gdnative.h
@@ -75,8 +75,8 @@ public:
virtual bool is_stereo();
virtual Transform get_transform_for_eye(ARVRInterface::Eyes p_eye, const Transform &p_cam_transform);
- // we expose a PoolVector<float> version of this function to GDNative
- PoolVector<float> _get_projection_for_eye(ARVRInterface::Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far);
+ // we expose a Vector<float> version of this function to GDNative
+ Vector<float> _get_projection_for_eye(ARVRInterface::Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far);
// and a CameraMatrix version to ARVRServer
virtual CameraMatrix get_projection_for_eye(ARVRInterface::Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far);
diff --git a/modules/gdnative/doc_classes/GDNative.xml b/modules/gdnative/doc_classes/GDNative.xml
index b4b63bf04a..44d9e32ed8 100644
--- a/modules/gdnative/doc_classes/GDNative.xml
+++ b/modules/gdnative/doc_classes/GDNative.xml
@@ -10,9 +10,9 @@
<method name="call_native">
<return type="Variant">
</return>
- <argument index="0" name="calling_type" type="String">
+ <argument index="0" name="calling_type" type="StringName">
</argument>
- <argument index="1" name="procedure_name" type="String">
+ <argument index="1" name="procedure_name" type="StringName">
</argument>
<argument index="2" name="arguments" type="Array">
</argument>
diff --git a/modules/gdnative/doc_classes/GDNativeLibrary.xml b/modules/gdnative/doc_classes/GDNativeLibrary.xml
index 820f126dd1..601e132d42 100644
--- a/modules/gdnative/doc_classes/GDNativeLibrary.xml
+++ b/modules/gdnative/doc_classes/GDNativeLibrary.xml
@@ -12,7 +12,7 @@
</tutorials>
<methods>
<method name="get_current_dependencies" qualifiers="const">
- <return type="PoolStringArray">
+ <return type="PackedStringArray">
</return>
<description>
Returns paths to all dependency libraries for the current platform and architecture.
diff --git a/modules/gdnative/doc_classes/NativeScript.xml b/modules/gdnative/doc_classes/NativeScript.xml
index b21d16a6fd..f2e9cac6dc 100644
--- a/modules/gdnative/doc_classes/NativeScript.xml
+++ b/modules/gdnative/doc_classes/NativeScript.xml
@@ -17,7 +17,7 @@
<method name="get_method_documentation" qualifiers="const">
<return type="String">
</return>
- <argument index="0" name="method" type="String">
+ <argument index="0" name="method" type="StringName">
</argument>
<description>
Returns the documentation string that was previously set with [code]godot_nativescript_set_method_documentation[/code].
@@ -26,7 +26,7 @@
<method name="get_property_documentation" qualifiers="const">
<return type="String">
</return>
- <argument index="0" name="path" type="String">
+ <argument index="0" name="path" type="StringName">
</argument>
<description>
Returns the documentation string that was previously set with [code]godot_nativescript_set_property_documentation[/code].
@@ -35,7 +35,7 @@
<method name="get_signal_documentation" qualifiers="const">
<return type="String">
</return>
- <argument index="0" name="signal_name" type="String">
+ <argument index="0" name="signal_name" type="StringName">
</argument>
<description>
Returns the documentation string that was previously set with [code]godot_nativescript_set_signal_documentation[/code].
diff --git a/modules/gdnative/gdnative/array.cpp b/modules/gdnative/gdnative/array.cpp
index 4a0308edec..0c764ab8fd 100644
--- a/modules/gdnative/gdnative/array.cpp
+++ b/modules/gdnative/gdnative/array.cpp
@@ -34,7 +34,6 @@
#include "core/os/memory.h"
#include "core/color.h"
-#include "core/pool_vector.h"
#include "core/variant.h"
@@ -53,9 +52,9 @@ void GDAPI godot_array_new_copy(godot_array *r_dest, const godot_array *p_src) {
memnew_placement(dest, Array(*src));
}
-void GDAPI godot_array_new_pool_color_array(godot_array *r_dest, const godot_pool_color_array *p_pca) {
+void GDAPI godot_array_new_packed_color_array(godot_array *r_dest, const godot_packed_color_array *p_pca) {
Array *dest = (Array *)r_dest;
- PoolVector<Color> *pca = (PoolVector<Color> *)p_pca;
+ Vector<Color> *pca = (Vector<Color> *)p_pca;
memnew_placement(dest, Array);
dest->resize(pca->size());
@@ -65,9 +64,9 @@ void GDAPI godot_array_new_pool_color_array(godot_array *r_dest, const godot_poo
}
}
-void GDAPI godot_array_new_pool_vector3_array(godot_array *r_dest, const godot_pool_vector3_array *p_pv3a) {
+void GDAPI godot_array_new_packed_vector3_array(godot_array *r_dest, const godot_packed_vector3_array *p_pv3a) {
Array *dest = (Array *)r_dest;
- PoolVector<Vector3> *pca = (PoolVector<Vector3> *)p_pv3a;
+ Vector<Vector3> *pca = (Vector<Vector3> *)p_pv3a;
memnew_placement(dest, Array);
dest->resize(pca->size());
@@ -77,9 +76,9 @@ void GDAPI godot_array_new_pool_vector3_array(godot_array *r_dest, const godot_p
}
}
-void GDAPI godot_array_new_pool_vector2_array(godot_array *r_dest, const godot_pool_vector2_array *p_pv2a) {
+void GDAPI godot_array_new_packed_vector2_array(godot_array *r_dest, const godot_packed_vector2_array *p_pv2a) {
Array *dest = (Array *)r_dest;
- PoolVector<Vector2> *pca = (PoolVector<Vector2> *)p_pv2a;
+ Vector<Vector2> *pca = (Vector<Vector2> *)p_pv2a;
memnew_placement(dest, Array);
dest->resize(pca->size());
@@ -89,9 +88,9 @@ void GDAPI godot_array_new_pool_vector2_array(godot_array *r_dest, const godot_p
}
}
-void GDAPI godot_array_new_pool_string_array(godot_array *r_dest, const godot_pool_string_array *p_psa) {
+void GDAPI godot_array_new_packed_string_array(godot_array *r_dest, const godot_packed_string_array *p_psa) {
Array *dest = (Array *)r_dest;
- PoolVector<String> *pca = (PoolVector<String> *)p_psa;
+ Vector<String> *pca = (Vector<String> *)p_psa;
memnew_placement(dest, Array);
dest->resize(pca->size());
@@ -101,9 +100,9 @@ void GDAPI godot_array_new_pool_string_array(godot_array *r_dest, const godot_po
}
}
-void GDAPI godot_array_new_pool_real_array(godot_array *r_dest, const godot_pool_real_array *p_pra) {
+void GDAPI godot_array_new_packed_real_array(godot_array *r_dest, const godot_packed_real_array *p_pra) {
Array *dest = (Array *)r_dest;
- PoolVector<godot_real> *pca = (PoolVector<godot_real> *)p_pra;
+ Vector<godot_real> *pca = (Vector<godot_real> *)p_pra;
memnew_placement(dest, Array);
dest->resize(pca->size());
@@ -113,9 +112,9 @@ void GDAPI godot_array_new_pool_real_array(godot_array *r_dest, const godot_pool
}
}
-void GDAPI godot_array_new_pool_int_array(godot_array *r_dest, const godot_pool_int_array *p_pia) {
+void GDAPI godot_array_new_packed_int_array(godot_array *r_dest, const godot_packed_int_array *p_pia) {
Array *dest = (Array *)r_dest;
- PoolVector<godot_int> *pca = (PoolVector<godot_int> *)p_pia;
+ Vector<godot_int> *pca = (Vector<godot_int> *)p_pia;
memnew_placement(dest, Array);
dest->resize(pca->size());
@@ -125,9 +124,9 @@ void GDAPI godot_array_new_pool_int_array(godot_array *r_dest, const godot_pool_
}
}
-void GDAPI godot_array_new_pool_byte_array(godot_array *r_dest, const godot_pool_byte_array *p_pba) {
+void GDAPI godot_array_new_packed_byte_array(godot_array *r_dest, const godot_packed_byte_array *p_pba) {
Array *dest = (Array *)r_dest;
- PoolVector<uint8_t> *pca = (PoolVector<uint8_t> *)p_pba;
+ Vector<uint8_t> *pca = (Vector<uint8_t> *)p_pba;
memnew_placement(dest, Array);
dest->resize(pca->size());
diff --git a/modules/gdnative/gdnative/color.cpp b/modules/gdnative/gdnative/color.cpp
index 24587ce4a1..914d5b03f4 100644
--- a/modules/gdnative/gdnative/color.cpp
+++ b/modules/gdnative/gdnative/color.cpp
@@ -141,11 +141,6 @@ godot_int GDAPI godot_color_to_argb32(const godot_color *p_self) {
return self->to_argb32();
}
-godot_real GDAPI godot_color_gray(const godot_color *p_self) {
- const Color *self = (const Color *)p_self;
- return self->gray();
-}
-
godot_color GDAPI godot_color_inverted(const godot_color *p_self) {
godot_color dest;
const Color *self = (const Color *)p_self;
diff --git a/modules/gdnative/gdnative/gdnative.cpp b/modules/gdnative/gdnative/gdnative.cpp
index 06334556d9..d996b006a5 100644
--- a/modules/gdnative/gdnative/gdnative.cpp
+++ b/modules/gdnative/gdnative/gdnative.cpp
@@ -79,7 +79,7 @@ godot_variant GDAPI godot_method_bind_call(godot_method_bind *p_method_bind, god
Variant *ret_val = (Variant *)&ret;
- Variant::CallError r_error;
+ Callable::CallError r_error;
*ret_val = mb->call(o, args, p_arg_count, r_error);
if (p_call_error) {
@@ -166,12 +166,8 @@ void _gdnative_report_loading_error(const godot_object *p_library, const char *p
_err_print_error("gdnative_init", library->get_current_library_path().utf8().ptr(), 0, message.utf8().ptr());
}
-bool GDAPI godot_is_instance_valid(const godot_object *p_object) {
- return ObjectDB::instance_validate((Object *)p_object);
-}
-
godot_object GDAPI *godot_instance_from_id(godot_int p_instance_id) {
- return (godot_object *)ObjectDB::get_instance((ObjectID)p_instance_id);
+ return (godot_object *)ObjectDB::get_instance(ObjectID(p_instance_id));
}
void *godot_get_class_tag(const godot_string_name *p_class) {
diff --git a/modules/gdnative/gdnative/pool_arrays.cpp b/modules/gdnative/gdnative/pool_arrays.cpp
index bae1290d59..589b4d4dfe 100644
--- a/modules/gdnative/gdnative/pool_arrays.cpp
+++ b/modules/gdnative/gdnative/pool_arrays.cpp
@@ -31,7 +31,7 @@
#include "gdnative/pool_arrays.h"
#include "core/array.h"
-#include "core/pool_vector.h"
+
#include "core/variant.h"
#include "core/color.h"
@@ -46,21 +46,21 @@ extern "C" {
// byte
-void GDAPI godot_pool_byte_array_new(godot_pool_byte_array *r_dest) {
- PoolVector<uint8_t> *dest = (PoolVector<uint8_t> *)r_dest;
- memnew_placement(dest, PoolVector<uint8_t>);
+void GDAPI godot_packed_byte_array_new(godot_packed_byte_array *r_dest) {
+ Vector<uint8_t> *dest = (Vector<uint8_t> *)r_dest;
+ memnew_placement(dest, Vector<uint8_t>);
}
-void GDAPI godot_pool_byte_array_new_copy(godot_pool_byte_array *r_dest, const godot_pool_byte_array *p_src) {
- PoolVector<uint8_t> *dest = (PoolVector<uint8_t> *)r_dest;
- const PoolVector<uint8_t> *src = (const PoolVector<uint8_t> *)p_src;
- memnew_placement(dest, PoolVector<uint8_t>(*src));
+void GDAPI godot_packed_byte_array_new_copy(godot_packed_byte_array *r_dest, const godot_packed_byte_array *p_src) {
+ Vector<uint8_t> *dest = (Vector<uint8_t> *)r_dest;
+ const Vector<uint8_t> *src = (const Vector<uint8_t> *)p_src;
+ memnew_placement(dest, Vector<uint8_t>(*src));
}
-void GDAPI godot_pool_byte_array_new_with_array(godot_pool_byte_array *r_dest, const godot_array *p_a) {
- PoolVector<uint8_t> *dest = (PoolVector<uint8_t> *)r_dest;
+void GDAPI godot_packed_byte_array_new_with_array(godot_packed_byte_array *r_dest, const godot_array *p_a) {
+ Vector<uint8_t> *dest = (Vector<uint8_t> *)r_dest;
Array *a = (Array *)p_a;
- memnew_placement(dest, PoolVector<uint8_t>);
+ memnew_placement(dest, Vector<uint8_t>);
dest->resize(a->size());
for (int i = 0; i < a->size(); i++) {
@@ -68,93 +68,83 @@ void GDAPI godot_pool_byte_array_new_with_array(godot_pool_byte_array *r_dest, c
}
}
-void GDAPI godot_pool_byte_array_append(godot_pool_byte_array *p_self, const uint8_t p_data) {
- PoolVector<uint8_t> *self = (PoolVector<uint8_t> *)p_self;
- self->append(p_data);
+void GDAPI godot_packed_byte_array_append(godot_packed_byte_array *p_self, const uint8_t p_data) {
+ Vector<uint8_t> *self = (Vector<uint8_t> *)p_self;
+ self->push_back(p_data);
}
-void GDAPI godot_pool_byte_array_append_array(godot_pool_byte_array *p_self, const godot_pool_byte_array *p_array) {
- PoolVector<uint8_t> *self = (PoolVector<uint8_t> *)p_self;
- PoolVector<uint8_t> *array = (PoolVector<uint8_t> *)p_array;
+void GDAPI godot_packed_byte_array_append_array(godot_packed_byte_array *p_self, const godot_packed_byte_array *p_array) {
+ Vector<uint8_t> *self = (Vector<uint8_t> *)p_self;
+ Vector<uint8_t> *array = (Vector<uint8_t> *)p_array;
self->append_array(*array);
}
-godot_error GDAPI godot_pool_byte_array_insert(godot_pool_byte_array *p_self, const godot_int p_idx, const uint8_t p_data) {
- PoolVector<uint8_t> *self = (PoolVector<uint8_t> *)p_self;
+godot_error GDAPI godot_packed_byte_array_insert(godot_packed_byte_array *p_self, const godot_int p_idx, const uint8_t p_data) {
+ Vector<uint8_t> *self = (Vector<uint8_t> *)p_self;
return (godot_error)self->insert(p_idx, p_data);
}
-void GDAPI godot_pool_byte_array_invert(godot_pool_byte_array *p_self) {
- PoolVector<uint8_t> *self = (PoolVector<uint8_t> *)p_self;
+void GDAPI godot_packed_byte_array_invert(godot_packed_byte_array *p_self) {
+ Vector<uint8_t> *self = (Vector<uint8_t> *)p_self;
self->invert();
}
-void GDAPI godot_pool_byte_array_push_back(godot_pool_byte_array *p_self, const uint8_t p_data) {
- PoolVector<uint8_t> *self = (PoolVector<uint8_t> *)p_self;
+void GDAPI godot_packed_byte_array_push_back(godot_packed_byte_array *p_self, const uint8_t p_data) {
+ Vector<uint8_t> *self = (Vector<uint8_t> *)p_self;
self->push_back(p_data);
}
-void GDAPI godot_pool_byte_array_remove(godot_pool_byte_array *p_self, const godot_int p_idx) {
- PoolVector<uint8_t> *self = (PoolVector<uint8_t> *)p_self;
+void GDAPI godot_packed_byte_array_remove(godot_packed_byte_array *p_self, const godot_int p_idx) {
+ Vector<uint8_t> *self = (Vector<uint8_t> *)p_self;
self->remove(p_idx);
}
-void GDAPI godot_pool_byte_array_resize(godot_pool_byte_array *p_self, const godot_int p_size) {
- PoolVector<uint8_t> *self = (PoolVector<uint8_t> *)p_self;
+void GDAPI godot_packed_byte_array_resize(godot_packed_byte_array *p_self, const godot_int p_size) {
+ Vector<uint8_t> *self = (Vector<uint8_t> *)p_self;
self->resize(p_size);
}
-godot_pool_byte_array_read_access GDAPI *godot_pool_byte_array_read(const godot_pool_byte_array *p_self) {
- const PoolVector<uint8_t> *self = (const PoolVector<uint8_t> *)p_self;
- return (godot_pool_byte_array_read_access *)memnew(PoolVector<uint8_t>::Read(self->read()));
-}
-
-godot_pool_byte_array_write_access GDAPI *godot_pool_byte_array_write(godot_pool_byte_array *p_self) {
- PoolVector<uint8_t> *self = (PoolVector<uint8_t> *)p_self;
- return (godot_pool_byte_array_write_access *)memnew(PoolVector<uint8_t>::Write(self->write()));
-}
-
-void GDAPI godot_pool_byte_array_set(godot_pool_byte_array *p_self, const godot_int p_idx, const uint8_t p_data) {
- PoolVector<uint8_t> *self = (PoolVector<uint8_t> *)p_self;
+void GDAPI godot_packed_byte_array_set(godot_packed_byte_array *p_self, const godot_int p_idx, const uint8_t p_data) {
+ Vector<uint8_t> *self = (Vector<uint8_t> *)p_self;
self->set(p_idx, p_data);
}
-uint8_t GDAPI godot_pool_byte_array_get(const godot_pool_byte_array *p_self, const godot_int p_idx) {
- const PoolVector<uint8_t> *self = (const PoolVector<uint8_t> *)p_self;
+uint8_t GDAPI godot_packed_byte_array_get(const godot_packed_byte_array *p_self, const godot_int p_idx) {
+ const Vector<uint8_t> *self = (const Vector<uint8_t> *)p_self;
return self->get(p_idx);
}
-godot_int GDAPI godot_pool_byte_array_size(const godot_pool_byte_array *p_self) {
- const PoolVector<uint8_t> *self = (const PoolVector<uint8_t> *)p_self;
+godot_int GDAPI godot_packed_byte_array_size(const godot_packed_byte_array *p_self) {
+ const Vector<uint8_t> *self = (const Vector<uint8_t> *)p_self;
return self->size();
}
-godot_bool GDAPI godot_pool_byte_array_empty(const godot_pool_byte_array *p_self) {
- const PoolVector<uint8_t> *self = (const PoolVector<uint8_t> *)p_self;
+godot_bool GDAPI godot_packed_byte_array_empty(const godot_packed_byte_array *p_self) {
+ const Vector<uint8_t> *self = (const Vector<uint8_t> *)p_self;
return self->empty();
}
-void GDAPI godot_pool_byte_array_destroy(godot_pool_byte_array *p_self) {
- ((PoolVector<uint8_t> *)p_self)->~PoolVector();
+void GDAPI godot_packed_byte_array_destroy(godot_packed_byte_array *p_self) {
+ ((Vector<uint8_t> *)p_self)->~Vector();
}
// int
-void GDAPI godot_pool_int_array_new(godot_pool_int_array *r_dest) {
- PoolVector<godot_int> *dest = (PoolVector<godot_int> *)r_dest;
- memnew_placement(dest, PoolVector<godot_int>);
+void GDAPI godot_packed_int_array_new(godot_packed_int_array *r_dest) {
+ Vector<godot_int> *dest = (Vector<godot_int> *)r_dest;
+ memnew_placement(dest, Vector<godot_int>);
}
-void GDAPI godot_pool_int_array_new_copy(godot_pool_int_array *r_dest, const godot_pool_int_array *p_src) {
- PoolVector<godot_int> *dest = (PoolVector<godot_int> *)r_dest;
- const PoolVector<godot_int> *src = (const PoolVector<godot_int> *)p_src;
- memnew_placement(dest, PoolVector<godot_int>(*src));
+void GDAPI godot_packed_int_array_new_copy(godot_packed_int_array *r_dest, const godot_packed_int_array *p_src) {
+ Vector<godot_int> *dest = (Vector<godot_int> *)r_dest;
+ const Vector<godot_int> *src = (const Vector<godot_int> *)p_src;
+ memnew_placement(dest, Vector<godot_int>(*src));
}
-void GDAPI godot_pool_int_array_new_with_array(godot_pool_int_array *r_dest, const godot_array *p_a) {
- PoolVector<godot_int> *dest = (PoolVector<godot_int> *)r_dest;
+void GDAPI godot_packed_int_array_new_with_array(godot_packed_int_array *r_dest, const godot_array *p_a) {
+ Vector<godot_int> *dest = (Vector<godot_int> *)r_dest;
Array *a = (Array *)p_a;
- memnew_placement(dest, PoolVector<godot_int>);
+ memnew_placement(dest, Vector<godot_int>);
dest->resize(a->size());
for (int i = 0; i < a->size(); i++) {
@@ -162,93 +152,83 @@ void GDAPI godot_pool_int_array_new_with_array(godot_pool_int_array *r_dest, con
}
}
-void GDAPI godot_pool_int_array_append(godot_pool_int_array *p_self, const godot_int p_data) {
- PoolVector<godot_int> *self = (PoolVector<godot_int> *)p_self;
- self->append(p_data);
+void GDAPI godot_packed_int_array_append(godot_packed_int_array *p_self, const godot_int p_data) {
+ Vector<godot_int> *self = (Vector<godot_int> *)p_self;
+ self->push_back(p_data);
}
-void GDAPI godot_pool_int_array_append_array(godot_pool_int_array *p_self, const godot_pool_int_array *p_array) {
- PoolVector<godot_int> *self = (PoolVector<godot_int> *)p_self;
- PoolVector<godot_int> *array = (PoolVector<godot_int> *)p_array;
+void GDAPI godot_packed_int_array_append_array(godot_packed_int_array *p_self, const godot_packed_int_array *p_array) {
+ Vector<godot_int> *self = (Vector<godot_int> *)p_self;
+ Vector<godot_int> *array = (Vector<godot_int> *)p_array;
self->append_array(*array);
}
-godot_error GDAPI godot_pool_int_array_insert(godot_pool_int_array *p_self, const godot_int p_idx, const godot_int p_data) {
- PoolVector<godot_int> *self = (PoolVector<godot_int> *)p_self;
+godot_error GDAPI godot_packed_int_array_insert(godot_packed_int_array *p_self, const godot_int p_idx, const godot_int p_data) {
+ Vector<godot_int> *self = (Vector<godot_int> *)p_self;
return (godot_error)self->insert(p_idx, p_data);
}
-void GDAPI godot_pool_int_array_invert(godot_pool_int_array *p_self) {
- PoolVector<godot_int> *self = (PoolVector<godot_int> *)p_self;
+void GDAPI godot_packed_int_array_invert(godot_packed_int_array *p_self) {
+ Vector<godot_int> *self = (Vector<godot_int> *)p_self;
self->invert();
}
-void GDAPI godot_pool_int_array_push_back(godot_pool_int_array *p_self, const godot_int p_data) {
- PoolVector<godot_int> *self = (PoolVector<godot_int> *)p_self;
+void GDAPI godot_packed_int_array_push_back(godot_packed_int_array *p_self, const godot_int p_data) {
+ Vector<godot_int> *self = (Vector<godot_int> *)p_self;
self->push_back(p_data);
}
-void GDAPI godot_pool_int_array_remove(godot_pool_int_array *p_self, const godot_int p_idx) {
- PoolVector<godot_int> *self = (PoolVector<godot_int> *)p_self;
+void GDAPI godot_packed_int_array_remove(godot_packed_int_array *p_self, const godot_int p_idx) {
+ Vector<godot_int> *self = (Vector<godot_int> *)p_self;
self->remove(p_idx);
}
-void GDAPI godot_pool_int_array_resize(godot_pool_int_array *p_self, const godot_int p_size) {
- PoolVector<godot_int> *self = (PoolVector<godot_int> *)p_self;
+void GDAPI godot_packed_int_array_resize(godot_packed_int_array *p_self, const godot_int p_size) {
+ Vector<godot_int> *self = (Vector<godot_int> *)p_self;
self->resize(p_size);
}
-godot_pool_int_array_read_access GDAPI *godot_pool_int_array_read(const godot_pool_int_array *p_self) {
- const PoolVector<godot_int> *self = (const PoolVector<godot_int> *)p_self;
- return (godot_pool_int_array_read_access *)memnew(PoolVector<godot_int>::Read(self->read()));
-}
-
-godot_pool_int_array_write_access GDAPI *godot_pool_int_array_write(godot_pool_int_array *p_self) {
- PoolVector<godot_int> *self = (PoolVector<godot_int> *)p_self;
- return (godot_pool_int_array_write_access *)memnew(PoolVector<godot_int>::Write(self->write()));
-}
-
-void GDAPI godot_pool_int_array_set(godot_pool_int_array *p_self, const godot_int p_idx, const godot_int p_data) {
- PoolVector<godot_int> *self = (PoolVector<godot_int> *)p_self;
+void GDAPI godot_packed_int_array_set(godot_packed_int_array *p_self, const godot_int p_idx, const godot_int p_data) {
+ Vector<godot_int> *self = (Vector<godot_int> *)p_self;
self->set(p_idx, p_data);
}
-godot_int GDAPI godot_pool_int_array_get(const godot_pool_int_array *p_self, const godot_int p_idx) {
- const PoolVector<godot_int> *self = (const PoolVector<godot_int> *)p_self;
+godot_int GDAPI godot_packed_int_array_get(const godot_packed_int_array *p_self, const godot_int p_idx) {
+ const Vector<godot_int> *self = (const Vector<godot_int> *)p_self;
return self->get(p_idx);
}
-godot_int GDAPI godot_pool_int_array_size(const godot_pool_int_array *p_self) {
- const PoolVector<godot_int> *self = (const PoolVector<godot_int> *)p_self;
+godot_int GDAPI godot_packed_int_array_size(const godot_packed_int_array *p_self) {
+ const Vector<godot_int> *self = (const Vector<godot_int> *)p_self;
return self->size();
}
-godot_bool GDAPI godot_pool_int_array_empty(const godot_pool_int_array *p_self) {
- const PoolVector<godot_int> *self = (const PoolVector<godot_int> *)p_self;
+godot_bool GDAPI godot_packed_int_array_empty(const godot_packed_int_array *p_self) {
+ const Vector<godot_int> *self = (const Vector<godot_int> *)p_self;
return self->empty();
}
-void GDAPI godot_pool_int_array_destroy(godot_pool_int_array *p_self) {
- ((PoolVector<godot_int> *)p_self)->~PoolVector();
+void GDAPI godot_packed_int_array_destroy(godot_packed_int_array *p_self) {
+ ((Vector<godot_int> *)p_self)->~Vector();
}
// real
-void GDAPI godot_pool_real_array_new(godot_pool_real_array *r_dest) {
- PoolVector<godot_real> *dest = (PoolVector<godot_real> *)r_dest;
- memnew_placement(dest, PoolVector<godot_real>);
+void GDAPI godot_packed_real_array_new(godot_packed_real_array *r_dest) {
+ Vector<godot_real> *dest = (Vector<godot_real> *)r_dest;
+ memnew_placement(dest, Vector<godot_real>);
}
-void GDAPI godot_pool_real_array_new_copy(godot_pool_real_array *r_dest, const godot_pool_real_array *p_src) {
- PoolVector<godot_real> *dest = (PoolVector<godot_real> *)r_dest;
- const PoolVector<godot_real> *src = (const PoolVector<godot_real> *)p_src;
- memnew_placement(dest, PoolVector<godot_real>(*src));
+void GDAPI godot_packed_real_array_new_copy(godot_packed_real_array *r_dest, const godot_packed_real_array *p_src) {
+ Vector<godot_real> *dest = (Vector<godot_real> *)r_dest;
+ const Vector<godot_real> *src = (const Vector<godot_real> *)p_src;
+ memnew_placement(dest, Vector<godot_real>(*src));
}
-void GDAPI godot_pool_real_array_new_with_array(godot_pool_real_array *r_dest, const godot_array *p_a) {
- PoolVector<godot_real> *dest = (PoolVector<godot_real> *)r_dest;
+void GDAPI godot_packed_real_array_new_with_array(godot_packed_real_array *r_dest, const godot_array *p_a) {
+ Vector<godot_real> *dest = (Vector<godot_real> *)r_dest;
Array *a = (Array *)p_a;
- memnew_placement(dest, PoolVector<godot_real>);
+ memnew_placement(dest, Vector<godot_real>);
dest->resize(a->size());
for (int i = 0; i < a->size(); i++) {
@@ -256,93 +236,83 @@ void GDAPI godot_pool_real_array_new_with_array(godot_pool_real_array *r_dest, c
}
}
-void GDAPI godot_pool_real_array_append(godot_pool_real_array *p_self, const godot_real p_data) {
- PoolVector<godot_real> *self = (PoolVector<godot_real> *)p_self;
- self->append(p_data);
+void GDAPI godot_packed_real_array_append(godot_packed_real_array *p_self, const godot_real p_data) {
+ Vector<godot_real> *self = (Vector<godot_real> *)p_self;
+ self->push_back(p_data);
}
-void GDAPI godot_pool_real_array_append_array(godot_pool_real_array *p_self, const godot_pool_real_array *p_array) {
- PoolVector<godot_real> *self = (PoolVector<godot_real> *)p_self;
- PoolVector<godot_real> *array = (PoolVector<godot_real> *)p_array;
+void GDAPI godot_packed_real_array_append_array(godot_packed_real_array *p_self, const godot_packed_real_array *p_array) {
+ Vector<godot_real> *self = (Vector<godot_real> *)p_self;
+ Vector<godot_real> *array = (Vector<godot_real> *)p_array;
self->append_array(*array);
}
-godot_error GDAPI godot_pool_real_array_insert(godot_pool_real_array *p_self, const godot_int p_idx, const godot_real p_data) {
- PoolVector<godot_real> *self = (PoolVector<godot_real> *)p_self;
+godot_error GDAPI godot_packed_real_array_insert(godot_packed_real_array *p_self, const godot_int p_idx, const godot_real p_data) {
+ Vector<godot_real> *self = (Vector<godot_real> *)p_self;
return (godot_error)self->insert(p_idx, p_data);
}
-void GDAPI godot_pool_real_array_invert(godot_pool_real_array *p_self) {
- PoolVector<godot_real> *self = (PoolVector<godot_real> *)p_self;
+void GDAPI godot_packed_real_array_invert(godot_packed_real_array *p_self) {
+ Vector<godot_real> *self = (Vector<godot_real> *)p_self;
self->invert();
}
-void GDAPI godot_pool_real_array_push_back(godot_pool_real_array *p_self, const godot_real p_data) {
- PoolVector<godot_real> *self = (PoolVector<godot_real> *)p_self;
+void GDAPI godot_packed_real_array_push_back(godot_packed_real_array *p_self, const godot_real p_data) {
+ Vector<godot_real> *self = (Vector<godot_real> *)p_self;
self->push_back(p_data);
}
-void GDAPI godot_pool_real_array_remove(godot_pool_real_array *p_self, const godot_int p_idx) {
- PoolVector<godot_real> *self = (PoolVector<godot_real> *)p_self;
+void GDAPI godot_packed_real_array_remove(godot_packed_real_array *p_self, const godot_int p_idx) {
+ Vector<godot_real> *self = (Vector<godot_real> *)p_self;
self->remove(p_idx);
}
-void GDAPI godot_pool_real_array_resize(godot_pool_real_array *p_self, const godot_int p_size) {
- PoolVector<godot_real> *self = (PoolVector<godot_real> *)p_self;
+void GDAPI godot_packed_real_array_resize(godot_packed_real_array *p_self, const godot_int p_size) {
+ Vector<godot_real> *self = (Vector<godot_real> *)p_self;
self->resize(p_size);
}
-godot_pool_real_array_read_access GDAPI *godot_pool_real_array_read(const godot_pool_real_array *p_self) {
- const PoolVector<godot_real> *self = (const PoolVector<godot_real> *)p_self;
- return (godot_pool_real_array_read_access *)memnew(PoolVector<godot_real>::Read(self->read()));
-}
-
-godot_pool_int_array_write_access GDAPI *godot_pool_real_array_write(godot_pool_real_array *p_self) {
- PoolVector<godot_real> *self = (PoolVector<godot_real> *)p_self;
- return (godot_pool_real_array_write_access *)memnew(PoolVector<godot_real>::Write(self->write()));
-}
-
-void GDAPI godot_pool_real_array_set(godot_pool_real_array *p_self, const godot_int p_idx, const godot_real p_data) {
- PoolVector<godot_real> *self = (PoolVector<godot_real> *)p_self;
+void GDAPI godot_packed_real_array_set(godot_packed_real_array *p_self, const godot_int p_idx, const godot_real p_data) {
+ Vector<godot_real> *self = (Vector<godot_real> *)p_self;
self->set(p_idx, p_data);
}
-godot_real GDAPI godot_pool_real_array_get(const godot_pool_real_array *p_self, const godot_int p_idx) {
- const PoolVector<godot_real> *self = (const PoolVector<godot_real> *)p_self;
+godot_real GDAPI godot_packed_real_array_get(const godot_packed_real_array *p_self, const godot_int p_idx) {
+ const Vector<godot_real> *self = (const Vector<godot_real> *)p_self;
return self->get(p_idx);
}
-godot_int GDAPI godot_pool_real_array_size(const godot_pool_real_array *p_self) {
- const PoolVector<godot_real> *self = (const PoolVector<godot_real> *)p_self;
+godot_int GDAPI godot_packed_real_array_size(const godot_packed_real_array *p_self) {
+ const Vector<godot_real> *self = (const Vector<godot_real> *)p_self;
return self->size();
}
-godot_bool GDAPI godot_pool_real_array_empty(const godot_pool_real_array *p_self) {
- const PoolVector<godot_real> *self = (const PoolVector<godot_real> *)p_self;
+godot_bool GDAPI godot_packed_real_array_empty(const godot_packed_real_array *p_self) {
+ const Vector<godot_real> *self = (const Vector<godot_real> *)p_self;
return self->empty();
}
-void GDAPI godot_pool_real_array_destroy(godot_pool_real_array *p_self) {
- ((PoolVector<godot_real> *)p_self)->~PoolVector();
+void GDAPI godot_packed_real_array_destroy(godot_packed_real_array *p_self) {
+ ((Vector<godot_real> *)p_self)->~Vector();
}
// string
-void GDAPI godot_pool_string_array_new(godot_pool_string_array *r_dest) {
- PoolVector<String> *dest = (PoolVector<String> *)r_dest;
- memnew_placement(dest, PoolVector<String>);
+void GDAPI godot_packed_string_array_new(godot_packed_string_array *r_dest) {
+ Vector<String> *dest = (Vector<String> *)r_dest;
+ memnew_placement(dest, Vector<String>);
}
-void GDAPI godot_pool_string_array_new_copy(godot_pool_string_array *r_dest, const godot_pool_string_array *p_src) {
- PoolVector<String> *dest = (PoolVector<String> *)r_dest;
- const PoolVector<String> *src = (const PoolVector<String> *)p_src;
- memnew_placement(dest, PoolVector<String>(*src));
+void GDAPI godot_packed_string_array_new_copy(godot_packed_string_array *r_dest, const godot_packed_string_array *p_src) {
+ Vector<String> *dest = (Vector<String> *)r_dest;
+ const Vector<String> *src = (const Vector<String> *)p_src;
+ memnew_placement(dest, Vector<String>(*src));
}
-void GDAPI godot_pool_string_array_new_with_array(godot_pool_string_array *r_dest, const godot_array *p_a) {
- PoolVector<String> *dest = (PoolVector<String> *)r_dest;
+void GDAPI godot_packed_string_array_new_with_array(godot_packed_string_array *r_dest, const godot_array *p_a) {
+ Vector<String> *dest = (Vector<String> *)r_dest;
Array *a = (Array *)p_a;
- memnew_placement(dest, PoolVector<String>);
+ memnew_placement(dest, Vector<String>);
dest->resize(a->size());
for (int i = 0; i < a->size(); i++) {
@@ -350,63 +320,53 @@ void GDAPI godot_pool_string_array_new_with_array(godot_pool_string_array *r_des
}
}
-void GDAPI godot_pool_string_array_append(godot_pool_string_array *p_self, const godot_string *p_data) {
- PoolVector<String> *self = (PoolVector<String> *)p_self;
+void GDAPI godot_packed_string_array_append(godot_packed_string_array *p_self, const godot_string *p_data) {
+ Vector<String> *self = (Vector<String> *)p_self;
String &s = *(String *)p_data;
- self->append(s);
+ self->push_back(s);
}
-void GDAPI godot_pool_string_array_append_array(godot_pool_string_array *p_self, const godot_pool_string_array *p_array) {
- PoolVector<String> *self = (PoolVector<String> *)p_self;
- PoolVector<String> *array = (PoolVector<String> *)p_array;
+void GDAPI godot_packed_string_array_append_array(godot_packed_string_array *p_self, const godot_packed_string_array *p_array) {
+ Vector<String> *self = (Vector<String> *)p_self;
+ Vector<String> *array = (Vector<String> *)p_array;
self->append_array(*array);
}
-godot_error GDAPI godot_pool_string_array_insert(godot_pool_string_array *p_self, const godot_int p_idx, const godot_string *p_data) {
- PoolVector<String> *self = (PoolVector<String> *)p_self;
+godot_error GDAPI godot_packed_string_array_insert(godot_packed_string_array *p_self, const godot_int p_idx, const godot_string *p_data) {
+ Vector<String> *self = (Vector<String> *)p_self;
String &s = *(String *)p_data;
return (godot_error)self->insert(p_idx, s);
}
-void GDAPI godot_pool_string_array_invert(godot_pool_string_array *p_self) {
- PoolVector<String> *self = (PoolVector<String> *)p_self;
+void GDAPI godot_packed_string_array_invert(godot_packed_string_array *p_self) {
+ Vector<String> *self = (Vector<String> *)p_self;
self->invert();
}
-void GDAPI godot_pool_string_array_push_back(godot_pool_string_array *p_self, const godot_string *p_data) {
- PoolVector<String> *self = (PoolVector<String> *)p_self;
+void GDAPI godot_packed_string_array_push_back(godot_packed_string_array *p_self, const godot_string *p_data) {
+ Vector<String> *self = (Vector<String> *)p_self;
String &s = *(String *)p_data;
self->push_back(s);
}
-void GDAPI godot_pool_string_array_remove(godot_pool_string_array *p_self, const godot_int p_idx) {
- PoolVector<String> *self = (PoolVector<String> *)p_self;
+void GDAPI godot_packed_string_array_remove(godot_packed_string_array *p_self, const godot_int p_idx) {
+ Vector<String> *self = (Vector<String> *)p_self;
self->remove(p_idx);
}
-void GDAPI godot_pool_string_array_resize(godot_pool_string_array *p_self, const godot_int p_size) {
- PoolVector<String> *self = (PoolVector<String> *)p_self;
+void GDAPI godot_packed_string_array_resize(godot_packed_string_array *p_self, const godot_int p_size) {
+ Vector<String> *self = (Vector<String> *)p_self;
self->resize(p_size);
}
-godot_pool_string_array_read_access GDAPI *godot_pool_string_array_read(const godot_pool_string_array *p_self) {
- const PoolVector<String> *self = (const PoolVector<String> *)p_self;
- return (godot_pool_string_array_read_access *)memnew(PoolVector<String>::Read(self->read()));
-}
-
-godot_pool_string_array_write_access GDAPI *godot_pool_string_array_write(godot_pool_string_array *p_self) {
- PoolVector<String> *self = (PoolVector<String> *)p_self;
- return (godot_pool_string_array_write_access *)memnew(PoolVector<String>::Write(self->write()));
-}
-
-void GDAPI godot_pool_string_array_set(godot_pool_string_array *p_self, const godot_int p_idx, const godot_string *p_data) {
- PoolVector<String> *self = (PoolVector<String> *)p_self;
+void GDAPI godot_packed_string_array_set(godot_packed_string_array *p_self, const godot_int p_idx, const godot_string *p_data) {
+ Vector<String> *self = (Vector<String> *)p_self;
String &s = *(String *)p_data;
self->set(p_idx, s);
}
-godot_string GDAPI godot_pool_string_array_get(const godot_pool_string_array *p_self, const godot_int p_idx) {
- const PoolVector<String> *self = (const PoolVector<String> *)p_self;
+godot_string GDAPI godot_packed_string_array_get(const godot_packed_string_array *p_self, const godot_int p_idx) {
+ const Vector<String> *self = (const Vector<String> *)p_self;
godot_string str;
String *s = (String *)&str;
memnew_placement(s, String);
@@ -414,37 +374,37 @@ godot_string GDAPI godot_pool_string_array_get(const godot_pool_string_array *p_
return str;
}
-godot_int GDAPI godot_pool_string_array_size(const godot_pool_string_array *p_self) {
- const PoolVector<String> *self = (const PoolVector<String> *)p_self;
+godot_int GDAPI godot_packed_string_array_size(const godot_packed_string_array *p_self) {
+ const Vector<String> *self = (const Vector<String> *)p_self;
return self->size();
}
-godot_bool GDAPI godot_pool_string_array_empty(const godot_pool_string_array *p_self) {
- const PoolVector<String> *self = (const PoolVector<String> *)p_self;
+godot_bool GDAPI godot_packed_string_array_empty(const godot_packed_string_array *p_self) {
+ const Vector<String> *self = (const Vector<String> *)p_self;
return self->empty();
}
-void GDAPI godot_pool_string_array_destroy(godot_pool_string_array *p_self) {
- ((PoolVector<String> *)p_self)->~PoolVector();
+void GDAPI godot_packed_string_array_destroy(godot_packed_string_array *p_self) {
+ ((Vector<String> *)p_self)->~Vector();
}
// vector2
-void GDAPI godot_pool_vector2_array_new(godot_pool_vector2_array *r_dest) {
- PoolVector<Vector2> *dest = (PoolVector<Vector2> *)r_dest;
- memnew_placement(dest, PoolVector<Vector2>);
+void GDAPI godot_packed_vector2_array_new(godot_packed_vector2_array *r_dest) {
+ Vector<Vector2> *dest = (Vector<Vector2> *)r_dest;
+ memnew_placement(dest, Vector<Vector2>);
}
-void GDAPI godot_pool_vector2_array_new_copy(godot_pool_vector2_array *r_dest, const godot_pool_vector2_array *p_src) {
- PoolVector<Vector2> *dest = (PoolVector<Vector2> *)r_dest;
- const PoolVector<Vector2> *src = (const PoolVector<Vector2> *)p_src;
- memnew_placement(dest, PoolVector<Vector2>(*src));
+void GDAPI godot_packed_vector2_array_new_copy(godot_packed_vector2_array *r_dest, const godot_packed_vector2_array *p_src) {
+ Vector<Vector2> *dest = (Vector<Vector2> *)r_dest;
+ const Vector<Vector2> *src = (const Vector<Vector2> *)p_src;
+ memnew_placement(dest, Vector<Vector2>(*src));
}
-void GDAPI godot_pool_vector2_array_new_with_array(godot_pool_vector2_array *r_dest, const godot_array *p_a) {
- PoolVector<Vector2> *dest = (PoolVector<Vector2> *)r_dest;
+void GDAPI godot_packed_vector2_array_new_with_array(godot_packed_vector2_array *r_dest, const godot_array *p_a) {
+ Vector<Vector2> *dest = (Vector<Vector2> *)r_dest;
Array *a = (Array *)p_a;
- memnew_placement(dest, PoolVector<Vector2>);
+ memnew_placement(dest, Vector<Vector2>);
dest->resize(a->size());
for (int i = 0; i < a->size(); i++) {
@@ -452,100 +412,90 @@ void GDAPI godot_pool_vector2_array_new_with_array(godot_pool_vector2_array *r_d
}
}
-void GDAPI godot_pool_vector2_array_append(godot_pool_vector2_array *p_self, const godot_vector2 *p_data) {
- PoolVector<Vector2> *self = (PoolVector<Vector2> *)p_self;
+void GDAPI godot_packed_vector2_array_append(godot_packed_vector2_array *p_self, const godot_vector2 *p_data) {
+ Vector<Vector2> *self = (Vector<Vector2> *)p_self;
Vector2 &s = *(Vector2 *)p_data;
- self->append(s);
+ self->push_back(s);
}
-void GDAPI godot_pool_vector2_array_append_array(godot_pool_vector2_array *p_self, const godot_pool_vector2_array *p_array) {
- PoolVector<Vector2> *self = (PoolVector<Vector2> *)p_self;
- PoolVector<Vector2> *array = (PoolVector<Vector2> *)p_array;
+void GDAPI godot_packed_vector2_array_append_array(godot_packed_vector2_array *p_self, const godot_packed_vector2_array *p_array) {
+ Vector<Vector2> *self = (Vector<Vector2> *)p_self;
+ Vector<Vector2> *array = (Vector<Vector2> *)p_array;
self->append_array(*array);
}
-godot_error GDAPI godot_pool_vector2_array_insert(godot_pool_vector2_array *p_self, const godot_int p_idx, const godot_vector2 *p_data) {
- PoolVector<Vector2> *self = (PoolVector<Vector2> *)p_self;
+godot_error GDAPI godot_packed_vector2_array_insert(godot_packed_vector2_array *p_self, const godot_int p_idx, const godot_vector2 *p_data) {
+ Vector<Vector2> *self = (Vector<Vector2> *)p_self;
Vector2 &s = *(Vector2 *)p_data;
return (godot_error)self->insert(p_idx, s);
}
-void GDAPI godot_pool_vector2_array_invert(godot_pool_vector2_array *p_self) {
- PoolVector<Vector2> *self = (PoolVector<Vector2> *)p_self;
+void GDAPI godot_packed_vector2_array_invert(godot_packed_vector2_array *p_self) {
+ Vector<Vector2> *self = (Vector<Vector2> *)p_self;
self->invert();
}
-void GDAPI godot_pool_vector2_array_push_back(godot_pool_vector2_array *p_self, const godot_vector2 *p_data) {
- PoolVector<Vector2> *self = (PoolVector<Vector2> *)p_self;
+void GDAPI godot_packed_vector2_array_push_back(godot_packed_vector2_array *p_self, const godot_vector2 *p_data) {
+ Vector<Vector2> *self = (Vector<Vector2> *)p_self;
Vector2 &s = *(Vector2 *)p_data;
self->push_back(s);
}
-void GDAPI godot_pool_vector2_array_remove(godot_pool_vector2_array *p_self, const godot_int p_idx) {
- PoolVector<Vector2> *self = (PoolVector<Vector2> *)p_self;
+void GDAPI godot_packed_vector2_array_remove(godot_packed_vector2_array *p_self, const godot_int p_idx) {
+ Vector<Vector2> *self = (Vector<Vector2> *)p_self;
self->remove(p_idx);
}
-void GDAPI godot_pool_vector2_array_resize(godot_pool_vector2_array *p_self, const godot_int p_size) {
- PoolVector<Vector2> *self = (PoolVector<Vector2> *)p_self;
+void GDAPI godot_packed_vector2_array_resize(godot_packed_vector2_array *p_self, const godot_int p_size) {
+ Vector<Vector2> *self = (Vector<Vector2> *)p_self;
self->resize(p_size);
}
-godot_pool_vector2_array_read_access GDAPI *godot_pool_vector2_array_read(const godot_pool_vector2_array *p_self) {
- const PoolVector<Vector2> *self = (const PoolVector<Vector2> *)p_self;
- return (godot_pool_vector2_array_read_access *)memnew(PoolVector<Vector2>::Read(self->read()));
-}
-
-godot_pool_vector2_array_write_access GDAPI *godot_pool_vector2_array_write(godot_pool_vector2_array *p_self) {
- PoolVector<Vector2> *self = (PoolVector<Vector2> *)p_self;
- return (godot_pool_vector2_array_write_access *)memnew(PoolVector<Vector2>::Write(self->write()));
-}
-
-void GDAPI godot_pool_vector2_array_set(godot_pool_vector2_array *p_self, const godot_int p_idx, const godot_vector2 *p_data) {
- PoolVector<Vector2> *self = (PoolVector<Vector2> *)p_self;
+void GDAPI godot_packed_vector2_array_set(godot_packed_vector2_array *p_self, const godot_int p_idx, const godot_vector2 *p_data) {
+ Vector<Vector2> *self = (Vector<Vector2> *)p_self;
Vector2 &s = *(Vector2 *)p_data;
self->set(p_idx, s);
}
-godot_vector2 GDAPI godot_pool_vector2_array_get(const godot_pool_vector2_array *p_self, const godot_int p_idx) {
- const PoolVector<Vector2> *self = (const PoolVector<Vector2> *)p_self;
+godot_vector2 GDAPI godot_packed_vector2_array_get(const godot_packed_vector2_array *p_self, const godot_int p_idx) {
+ const Vector<Vector2> *self = (const Vector<Vector2> *)p_self;
godot_vector2 v;
Vector2 *s = (Vector2 *)&v;
*s = self->get(p_idx);
return v;
}
-godot_int GDAPI godot_pool_vector2_array_size(const godot_pool_vector2_array *p_self) {
- const PoolVector<Vector2> *self = (const PoolVector<Vector2> *)p_self;
+godot_int GDAPI godot_packed_vector2_array_size(const godot_packed_vector2_array *p_self) {
+ const Vector<Vector2> *self = (const Vector<Vector2> *)p_self;
return self->size();
}
-godot_bool GDAPI godot_pool_vector2_array_empty(const godot_pool_vector2_array *p_self) {
- const PoolVector<Vector2> *self = (const PoolVector<Vector2> *)p_self;
+godot_bool GDAPI godot_packed_vector2_array_empty(const godot_packed_vector2_array *p_self) {
+ const Vector<Vector2> *self = (const Vector<Vector2> *)p_self;
return self->empty();
}
-void GDAPI godot_pool_vector2_array_destroy(godot_pool_vector2_array *p_self) {
- ((PoolVector<Vector2> *)p_self)->~PoolVector();
+void GDAPI godot_packed_vector2_array_destroy(godot_packed_vector2_array *p_self) {
+ ((Vector<Vector2> *)p_self)->~Vector();
}
// vector3
-void GDAPI godot_pool_vector3_array_new(godot_pool_vector3_array *r_dest) {
- PoolVector<Vector3> *dest = (PoolVector<Vector3> *)r_dest;
- memnew_placement(dest, PoolVector<Vector3>);
+void GDAPI godot_packed_vector3_array_new(godot_packed_vector3_array *r_dest) {
+ Vector<Vector3> *dest = (Vector<Vector3> *)r_dest;
+ memnew_placement(dest, Vector<Vector3>);
}
-void GDAPI godot_pool_vector3_array_new_copy(godot_pool_vector3_array *r_dest, const godot_pool_vector3_array *p_src) {
- PoolVector<Vector3> *dest = (PoolVector<Vector3> *)r_dest;
- const PoolVector<Vector3> *src = (const PoolVector<Vector3> *)p_src;
- memnew_placement(dest, PoolVector<Vector3>(*src));
+void GDAPI godot_packed_vector3_array_new_copy(godot_packed_vector3_array *r_dest, const godot_packed_vector3_array *p_src) {
+ Vector<Vector3> *dest = (Vector<Vector3> *)r_dest;
+ const Vector<Vector3> *src = (const Vector<Vector3> *)p_src;
+ memnew_placement(dest, Vector<Vector3>(*src));
}
-void GDAPI godot_pool_vector3_array_new_with_array(godot_pool_vector3_array *r_dest, const godot_array *p_a) {
- PoolVector<Vector3> *dest = (PoolVector<Vector3> *)r_dest;
+void GDAPI godot_packed_vector3_array_new_with_array(godot_packed_vector3_array *r_dest, const godot_array *p_a) {
+ Vector<Vector3> *dest = (Vector<Vector3> *)r_dest;
Array *a = (Array *)p_a;
- memnew_placement(dest, PoolVector<Vector3>);
+ memnew_placement(dest, Vector<Vector3>);
dest->resize(a->size());
for (int i = 0; i < a->size(); i++) {
@@ -553,100 +503,90 @@ void GDAPI godot_pool_vector3_array_new_with_array(godot_pool_vector3_array *r_d
}
}
-void GDAPI godot_pool_vector3_array_append(godot_pool_vector3_array *p_self, const godot_vector3 *p_data) {
- PoolVector<Vector3> *self = (PoolVector<Vector3> *)p_self;
+void GDAPI godot_packed_vector3_array_append(godot_packed_vector3_array *p_self, const godot_vector3 *p_data) {
+ Vector<Vector3> *self = (Vector<Vector3> *)p_self;
Vector3 &s = *(Vector3 *)p_data;
- self->append(s);
+ self->push_back(s);
}
-void GDAPI godot_pool_vector3_array_append_array(godot_pool_vector3_array *p_self, const godot_pool_vector3_array *p_array) {
- PoolVector<Vector3> *self = (PoolVector<Vector3> *)p_self;
- PoolVector<Vector3> *array = (PoolVector<Vector3> *)p_array;
+void GDAPI godot_packed_vector3_array_append_array(godot_packed_vector3_array *p_self, const godot_packed_vector3_array *p_array) {
+ Vector<Vector3> *self = (Vector<Vector3> *)p_self;
+ Vector<Vector3> *array = (Vector<Vector3> *)p_array;
self->append_array(*array);
}
-godot_error GDAPI godot_pool_vector3_array_insert(godot_pool_vector3_array *p_self, const godot_int p_idx, const godot_vector3 *p_data) {
- PoolVector<Vector3> *self = (PoolVector<Vector3> *)p_self;
+godot_error GDAPI godot_packed_vector3_array_insert(godot_packed_vector3_array *p_self, const godot_int p_idx, const godot_vector3 *p_data) {
+ Vector<Vector3> *self = (Vector<Vector3> *)p_self;
Vector3 &s = *(Vector3 *)p_data;
return (godot_error)self->insert(p_idx, s);
}
-void GDAPI godot_pool_vector3_array_invert(godot_pool_vector3_array *p_self) {
- PoolVector<Vector3> *self = (PoolVector<Vector3> *)p_self;
+void GDAPI godot_packed_vector3_array_invert(godot_packed_vector3_array *p_self) {
+ Vector<Vector3> *self = (Vector<Vector3> *)p_self;
self->invert();
}
-void GDAPI godot_pool_vector3_array_push_back(godot_pool_vector3_array *p_self, const godot_vector3 *p_data) {
- PoolVector<Vector3> *self = (PoolVector<Vector3> *)p_self;
+void GDAPI godot_packed_vector3_array_push_back(godot_packed_vector3_array *p_self, const godot_vector3 *p_data) {
+ Vector<Vector3> *self = (Vector<Vector3> *)p_self;
Vector3 &s = *(Vector3 *)p_data;
self->push_back(s);
}
-void GDAPI godot_pool_vector3_array_remove(godot_pool_vector3_array *p_self, const godot_int p_idx) {
- PoolVector<Vector3> *self = (PoolVector<Vector3> *)p_self;
+void GDAPI godot_packed_vector3_array_remove(godot_packed_vector3_array *p_self, const godot_int p_idx) {
+ Vector<Vector3> *self = (Vector<Vector3> *)p_self;
self->remove(p_idx);
}
-void GDAPI godot_pool_vector3_array_resize(godot_pool_vector3_array *p_self, const godot_int p_size) {
- PoolVector<Vector3> *self = (PoolVector<Vector3> *)p_self;
+void GDAPI godot_packed_vector3_array_resize(godot_packed_vector3_array *p_self, const godot_int p_size) {
+ Vector<Vector3> *self = (Vector<Vector3> *)p_self;
self->resize(p_size);
}
-godot_pool_vector3_array_read_access GDAPI *godot_pool_vector3_array_read(const godot_pool_vector3_array *p_self) {
- const PoolVector<Vector3> *self = (const PoolVector<Vector3> *)p_self;
- return (godot_pool_vector3_array_read_access *)memnew(PoolVector<Vector3>::Read(self->read()));
-}
-
-godot_pool_vector3_array_write_access GDAPI *godot_pool_vector3_array_write(godot_pool_vector3_array *p_self) {
- PoolVector<Vector3> *self = (PoolVector<Vector3> *)p_self;
- return (godot_pool_vector3_array_write_access *)memnew(PoolVector<Vector3>::Write(self->write()));
-}
-
-void GDAPI godot_pool_vector3_array_set(godot_pool_vector3_array *p_self, const godot_int p_idx, const godot_vector3 *p_data) {
- PoolVector<Vector3> *self = (PoolVector<Vector3> *)p_self;
+void GDAPI godot_packed_vector3_array_set(godot_packed_vector3_array *p_self, const godot_int p_idx, const godot_vector3 *p_data) {
+ Vector<Vector3> *self = (Vector<Vector3> *)p_self;
Vector3 &s = *(Vector3 *)p_data;
self->set(p_idx, s);
}
-godot_vector3 GDAPI godot_pool_vector3_array_get(const godot_pool_vector3_array *p_self, const godot_int p_idx) {
- const PoolVector<Vector3> *self = (const PoolVector<Vector3> *)p_self;
+godot_vector3 GDAPI godot_packed_vector3_array_get(const godot_packed_vector3_array *p_self, const godot_int p_idx) {
+ const Vector<Vector3> *self = (const Vector<Vector3> *)p_self;
godot_vector3 v;
Vector3 *s = (Vector3 *)&v;
*s = self->get(p_idx);
return v;
}
-godot_int GDAPI godot_pool_vector3_array_size(const godot_pool_vector3_array *p_self) {
- const PoolVector<Vector3> *self = (const PoolVector<Vector3> *)p_self;
+godot_int GDAPI godot_packed_vector3_array_size(const godot_packed_vector3_array *p_self) {
+ const Vector<Vector3> *self = (const Vector<Vector3> *)p_self;
return self->size();
}
-godot_bool GDAPI godot_pool_vector3_array_empty(const godot_pool_vector3_array *p_self) {
- const PoolVector<Vector3> *self = (const PoolVector<Vector3> *)p_self;
+godot_bool GDAPI godot_packed_vector3_array_empty(const godot_packed_vector3_array *p_self) {
+ const Vector<Vector3> *self = (const Vector<Vector3> *)p_self;
return self->empty();
}
-void GDAPI godot_pool_vector3_array_destroy(godot_pool_vector3_array *p_self) {
- ((PoolVector<Vector3> *)p_self)->~PoolVector();
+void GDAPI godot_packed_vector3_array_destroy(godot_packed_vector3_array *p_self) {
+ ((Vector<Vector3> *)p_self)->~Vector();
}
// color
-void GDAPI godot_pool_color_array_new(godot_pool_color_array *r_dest) {
- PoolVector<Color> *dest = (PoolVector<Color> *)r_dest;
- memnew_placement(dest, PoolVector<Color>);
+void GDAPI godot_packed_color_array_new(godot_packed_color_array *r_dest) {
+ Vector<Color> *dest = (Vector<Color> *)r_dest;
+ memnew_placement(dest, Vector<Color>);
}
-void GDAPI godot_pool_color_array_new_copy(godot_pool_color_array *r_dest, const godot_pool_color_array *p_src) {
- PoolVector<Color> *dest = (PoolVector<Color> *)r_dest;
- const PoolVector<Color> *src = (const PoolVector<Color> *)p_src;
- memnew_placement(dest, PoolVector<Color>(*src));
+void GDAPI godot_packed_color_array_new_copy(godot_packed_color_array *r_dest, const godot_packed_color_array *p_src) {
+ Vector<Color> *dest = (Vector<Color> *)r_dest;
+ const Vector<Color> *src = (const Vector<Color> *)p_src;
+ memnew_placement(dest, Vector<Color>(*src));
}
-void GDAPI godot_pool_color_array_new_with_array(godot_pool_color_array *r_dest, const godot_array *p_a) {
- PoolVector<Color> *dest = (PoolVector<Color> *)r_dest;
+void GDAPI godot_packed_color_array_new_with_array(godot_packed_color_array *r_dest, const godot_array *p_a) {
+ Vector<Color> *dest = (Vector<Color> *)r_dest;
Array *a = (Array *)p_a;
- memnew_placement(dest, PoolVector<Color>);
+ memnew_placement(dest, Vector<Color>);
dest->resize(a->size());
for (int i = 0; i < a->size(); i++) {
@@ -654,327 +594,71 @@ void GDAPI godot_pool_color_array_new_with_array(godot_pool_color_array *r_dest,
}
}
-void GDAPI godot_pool_color_array_append(godot_pool_color_array *p_self, const godot_color *p_data) {
- PoolVector<Color> *self = (PoolVector<Color> *)p_self;
+void GDAPI godot_packed_color_array_append(godot_packed_color_array *p_self, const godot_color *p_data) {
+ Vector<Color> *self = (Vector<Color> *)p_self;
Color &s = *(Color *)p_data;
- self->append(s);
+ self->push_back(s);
}
-void GDAPI godot_pool_color_array_append_array(godot_pool_color_array *p_self, const godot_pool_color_array *p_array) {
- PoolVector<Color> *self = (PoolVector<Color> *)p_self;
- PoolVector<Color> *array = (PoolVector<Color> *)p_array;
+void GDAPI godot_packed_color_array_append_array(godot_packed_color_array *p_self, const godot_packed_color_array *p_array) {
+ Vector<Color> *self = (Vector<Color> *)p_self;
+ Vector<Color> *array = (Vector<Color> *)p_array;
self->append_array(*array);
}
-godot_error GDAPI godot_pool_color_array_insert(godot_pool_color_array *p_self, const godot_int p_idx, const godot_color *p_data) {
- PoolVector<Color> *self = (PoolVector<Color> *)p_self;
+godot_error GDAPI godot_packed_color_array_insert(godot_packed_color_array *p_self, const godot_int p_idx, const godot_color *p_data) {
+ Vector<Color> *self = (Vector<Color> *)p_self;
Color &s = *(Color *)p_data;
return (godot_error)self->insert(p_idx, s);
}
-void GDAPI godot_pool_color_array_invert(godot_pool_color_array *p_self) {
- PoolVector<Color> *self = (PoolVector<Color> *)p_self;
+void GDAPI godot_packed_color_array_invert(godot_packed_color_array *p_self) {
+ Vector<Color> *self = (Vector<Color> *)p_self;
self->invert();
}
-void GDAPI godot_pool_color_array_push_back(godot_pool_color_array *p_self, const godot_color *p_data) {
- PoolVector<Color> *self = (PoolVector<Color> *)p_self;
+void GDAPI godot_packed_color_array_push_back(godot_packed_color_array *p_self, const godot_color *p_data) {
+ Vector<Color> *self = (Vector<Color> *)p_self;
Color &s = *(Color *)p_data;
self->push_back(s);
}
-void GDAPI godot_pool_color_array_remove(godot_pool_color_array *p_self, const godot_int p_idx) {
- PoolVector<Color> *self = (PoolVector<Color> *)p_self;
+void GDAPI godot_packed_color_array_remove(godot_packed_color_array *p_self, const godot_int p_idx) {
+ Vector<Color> *self = (Vector<Color> *)p_self;
self->remove(p_idx);
}
-void GDAPI godot_pool_color_array_resize(godot_pool_color_array *p_self, const godot_int p_size) {
- PoolVector<Color> *self = (PoolVector<Color> *)p_self;
+void GDAPI godot_packed_color_array_resize(godot_packed_color_array *p_self, const godot_int p_size) {
+ Vector<Color> *self = (Vector<Color> *)p_self;
self->resize(p_size);
}
-godot_pool_color_array_read_access GDAPI *godot_pool_color_array_read(const godot_pool_color_array *p_self) {
- const PoolVector<Color> *self = (const PoolVector<Color> *)p_self;
- return (godot_pool_color_array_read_access *)memnew(PoolVector<Color>::Read(self->read()));
-}
-
-godot_pool_color_array_write_access GDAPI *godot_pool_color_array_write(godot_pool_color_array *p_self) {
- PoolVector<Color> *self = (PoolVector<Color> *)p_self;
- return (godot_pool_color_array_write_access *)memnew(PoolVector<Color>::Write(self->write()));
-}
-
-void GDAPI godot_pool_color_array_set(godot_pool_color_array *p_self, const godot_int p_idx, const godot_color *p_data) {
- PoolVector<Color> *self = (PoolVector<Color> *)p_self;
+void GDAPI godot_packed_color_array_set(godot_packed_color_array *p_self, const godot_int p_idx, const godot_color *p_data) {
+ Vector<Color> *self = (Vector<Color> *)p_self;
Color &s = *(Color *)p_data;
self->set(p_idx, s);
}
-godot_color GDAPI godot_pool_color_array_get(const godot_pool_color_array *p_self, const godot_int p_idx) {
- const PoolVector<Color> *self = (const PoolVector<Color> *)p_self;
+godot_color GDAPI godot_packed_color_array_get(const godot_packed_color_array *p_self, const godot_int p_idx) {
+ const Vector<Color> *self = (const Vector<Color> *)p_self;
godot_color v;
Color *s = (Color *)&v;
*s = self->get(p_idx);
return v;
}
-godot_int GDAPI godot_pool_color_array_size(const godot_pool_color_array *p_self) {
- const PoolVector<Color> *self = (const PoolVector<Color> *)p_self;
+godot_int GDAPI godot_packed_color_array_size(const godot_packed_color_array *p_self) {
+ const Vector<Color> *self = (const Vector<Color> *)p_self;
return self->size();
}
-godot_bool GDAPI godot_pool_color_array_empty(const godot_pool_color_array *p_self) {
- const PoolVector<Color> *self = (const PoolVector<Color> *)p_self;
+godot_bool GDAPI godot_packed_color_array_empty(const godot_packed_color_array *p_self) {
+ const Vector<Color> *self = (const Vector<Color> *)p_self;
return self->empty();
}
-void GDAPI godot_pool_color_array_destroy(godot_pool_color_array *p_self) {
- ((PoolVector<Color> *)p_self)->~PoolVector();
-}
-
-//
-// read accessor functions
-//
-
-godot_pool_byte_array_read_access GDAPI *godot_pool_byte_array_read_access_copy(const godot_pool_byte_array_read_access *p_other) {
- PoolVector<uint8_t>::Read *other = (PoolVector<uint8_t>::Read *)p_other;
- return (godot_pool_byte_array_read_access *)memnew(PoolVector<uint8_t>::Read(*other));
-}
-const uint8_t GDAPI *godot_pool_byte_array_read_access_ptr(const godot_pool_byte_array_read_access *p_read) {
- const PoolVector<uint8_t>::Read *read = (const PoolVector<uint8_t>::Read *)p_read;
- return read->ptr();
-}
-void GDAPI godot_pool_byte_array_read_access_operator_assign(godot_pool_byte_array_read_access *p_read, godot_pool_byte_array_read_access *p_other) {
- PoolVector<uint8_t>::Read *read = (PoolVector<uint8_t>::Read *)p_read;
- PoolVector<uint8_t>::Read *other = (PoolVector<uint8_t>::Read *)p_other;
- read->operator=(*other);
-}
-void GDAPI godot_pool_byte_array_read_access_destroy(godot_pool_byte_array_read_access *p_read) {
- memdelete((PoolVector<uint8_t>::Read *)p_read);
-}
-
-godot_pool_int_array_read_access GDAPI *godot_pool_int_array_read_access_copy(const godot_pool_int_array_read_access *p_other) {
- PoolVector<godot_int>::Read *other = (PoolVector<godot_int>::Read *)p_other;
- return (godot_pool_int_array_read_access *)memnew(PoolVector<godot_int>::Read(*other));
-}
-const godot_int GDAPI *godot_pool_int_array_read_access_ptr(const godot_pool_int_array_read_access *p_read) {
- const PoolVector<godot_int>::Read *read = (const PoolVector<godot_int>::Read *)p_read;
- return read->ptr();
-}
-void GDAPI godot_pool_int_array_read_access_operator_assign(godot_pool_int_array_read_access *p_read, godot_pool_int_array_read_access *p_other) {
- PoolVector<godot_int>::Read *read = (PoolVector<godot_int>::Read *)p_read;
- PoolVector<godot_int>::Read *other = (PoolVector<godot_int>::Read *)p_other;
- read->operator=(*other);
-}
-void GDAPI godot_pool_int_array_read_access_destroy(godot_pool_int_array_read_access *p_read) {
- memdelete((PoolVector<godot_int>::Read *)p_read);
-}
-
-godot_pool_real_array_read_access GDAPI *godot_pool_real_array_read_access_copy(const godot_pool_real_array_read_access *p_other) {
- PoolVector<godot_real>::Read *other = (PoolVector<godot_real>::Read *)p_other;
- return (godot_pool_real_array_read_access *)memnew(PoolVector<godot_real>::Read(*other));
-}
-const godot_real GDAPI *godot_pool_real_array_read_access_ptr(const godot_pool_real_array_read_access *p_read) {
- const PoolVector<godot_real>::Read *read = (const PoolVector<godot_real>::Read *)p_read;
- return read->ptr();
-}
-void GDAPI godot_pool_real_array_read_access_operator_assign(godot_pool_real_array_read_access *p_read, godot_pool_real_array_read_access *p_other) {
- PoolVector<godot_real>::Read *read = (PoolVector<godot_real>::Read *)p_read;
- PoolVector<godot_real>::Read *other = (PoolVector<godot_real>::Read *)p_other;
- read->operator=(*other);
-}
-void GDAPI godot_pool_real_array_read_access_destroy(godot_pool_real_array_read_access *p_read) {
- memdelete((PoolVector<godot_real>::Read *)p_read);
-}
-
-godot_pool_string_array_read_access GDAPI *godot_pool_string_array_read_access_copy(const godot_pool_string_array_read_access *p_other) {
- PoolVector<String>::Read *other = (PoolVector<String>::Read *)p_other;
- return (godot_pool_string_array_read_access *)memnew(PoolVector<String>::Read(*other));
-}
-const godot_string GDAPI *godot_pool_string_array_read_access_ptr(const godot_pool_string_array_read_access *p_read) {
- const PoolVector<String>::Read *read = (const PoolVector<String>::Read *)p_read;
- return (const godot_string *)read->ptr();
-}
-void GDAPI godot_pool_string_array_read_access_operator_assign(godot_pool_string_array_read_access *p_read, godot_pool_string_array_read_access *p_other) {
- PoolVector<String>::Read *read = (PoolVector<String>::Read *)p_read;
- PoolVector<String>::Read *other = (PoolVector<String>::Read *)p_other;
- read->operator=(*other);
-}
-void GDAPI godot_pool_string_array_read_access_destroy(godot_pool_string_array_read_access *p_read) {
- memdelete((PoolVector<String>::Read *)p_read);
-}
-
-godot_pool_vector2_array_read_access GDAPI *godot_pool_vector2_array_read_access_copy(const godot_pool_vector2_array_read_access *p_other) {
- PoolVector<Vector2>::Read *other = (PoolVector<Vector2>::Read *)p_other;
- return (godot_pool_vector2_array_read_access *)memnew(PoolVector<Vector2>::Read(*other));
-}
-const godot_vector2 GDAPI *godot_pool_vector2_array_read_access_ptr(const godot_pool_vector2_array_read_access *p_read) {
- const PoolVector<Vector2>::Read *read = (const PoolVector<Vector2>::Read *)p_read;
- return (const godot_vector2 *)read->ptr();
-}
-void GDAPI godot_pool_vector2_array_read_access_operator_assign(godot_pool_vector2_array_read_access *p_read, godot_pool_vector2_array_read_access *p_other) {
- PoolVector<Vector2>::Read *read = (PoolVector<Vector2>::Read *)p_read;
- PoolVector<Vector2>::Read *other = (PoolVector<Vector2>::Read *)p_other;
- read->operator=(*other);
-}
-void GDAPI godot_pool_vector2_array_read_access_destroy(godot_pool_vector2_array_read_access *p_read) {
- memdelete((PoolVector<Vector2>::Read *)p_read);
-}
-
-godot_pool_vector3_array_read_access GDAPI *godot_pool_vector3_array_read_access_copy(const godot_pool_vector3_array_read_access *p_other) {
- PoolVector<Vector3>::Read *other = (PoolVector<Vector3>::Read *)p_other;
- return (godot_pool_vector3_array_read_access *)memnew(PoolVector<Vector3>::Read(*other));
-}
-const godot_vector3 GDAPI *godot_pool_vector3_array_read_access_ptr(const godot_pool_vector3_array_read_access *p_read) {
- const PoolVector<Vector3>::Read *read = (const PoolVector<Vector3>::Read *)p_read;
- return (const godot_vector3 *)read->ptr();
-}
-void GDAPI godot_pool_vector3_array_read_access_operator_assign(godot_pool_vector3_array_read_access *p_read, godot_pool_vector3_array_read_access *p_other) {
- PoolVector<Vector3>::Read *read = (PoolVector<Vector3>::Read *)p_read;
- PoolVector<Vector3>::Read *other = (PoolVector<Vector3>::Read *)p_other;
- read->operator=(*other);
-}
-void GDAPI godot_pool_vector3_array_read_access_destroy(godot_pool_vector3_array_read_access *p_read) {
- memdelete((PoolVector<Vector2>::Read *)p_read);
-}
-
-godot_pool_color_array_read_access GDAPI *godot_pool_color_array_read_access_copy(const godot_pool_color_array_read_access *p_other) {
- PoolVector<Color>::Read *other = (PoolVector<Color>::Read *)p_other;
- return (godot_pool_color_array_read_access *)memnew(PoolVector<Color>::Read(*other));
-}
-const godot_color GDAPI *godot_pool_color_array_read_access_ptr(const godot_pool_color_array_read_access *p_read) {
- const PoolVector<Color>::Read *read = (const PoolVector<Color>::Read *)p_read;
- return (const godot_color *)read->ptr();
-}
-void GDAPI godot_pool_color_array_read_access_operator_assign(godot_pool_color_array_read_access *p_read, godot_pool_color_array_read_access *p_other) {
- PoolVector<Color>::Read *read = (PoolVector<Color>::Read *)p_read;
- PoolVector<Color>::Read *other = (PoolVector<Color>::Read *)p_other;
- read->operator=(*other);
-}
-void GDAPI godot_pool_color_array_read_access_destroy(godot_pool_color_array_read_access *p_read) {
- memdelete((PoolVector<Color>::Read *)p_read);
-}
-
-//
-// write accessor functions
-//
-
-godot_pool_byte_array_write_access GDAPI *godot_pool_byte_array_write_access_copy(const godot_pool_byte_array_write_access *p_other) {
- PoolVector<uint8_t>::Write *other = (PoolVector<uint8_t>::Write *)p_other;
- return (godot_pool_byte_array_write_access *)memnew(PoolVector<uint8_t>::Write(*other));
-}
-uint8_t GDAPI *godot_pool_byte_array_write_access_ptr(const godot_pool_byte_array_write_access *p_write) {
- PoolVector<uint8_t>::Write *write = (PoolVector<uint8_t>::Write *)p_write;
- return write->ptr();
-}
-void GDAPI godot_pool_byte_array_write_access_operator_assign(godot_pool_byte_array_write_access *p_write, godot_pool_byte_array_write_access *p_other) {
- PoolVector<uint8_t>::Write *write = (PoolVector<uint8_t>::Write *)p_write;
- PoolVector<uint8_t>::Write *other = (PoolVector<uint8_t>::Write *)p_other;
- write->operator=(*other);
-}
-void GDAPI godot_pool_byte_array_write_access_destroy(godot_pool_byte_array_write_access *p_write) {
- memdelete((PoolVector<uint8_t>::Write *)p_write);
-}
-
-godot_pool_int_array_write_access GDAPI *godot_pool_int_array_write_access_copy(const godot_pool_int_array_write_access *p_other) {
- PoolVector<godot_int>::Write *other = (PoolVector<godot_int>::Write *)p_other;
- return (godot_pool_int_array_write_access *)memnew(PoolVector<godot_int>::Write(*other));
-}
-godot_int GDAPI *godot_pool_int_array_write_access_ptr(const godot_pool_int_array_write_access *p_write) {
- PoolVector<godot_int>::Write *write = (PoolVector<godot_int>::Write *)p_write;
- return write->ptr();
-}
-void GDAPI godot_pool_int_array_write_access_operator_assign(godot_pool_int_array_write_access *p_write, godot_pool_int_array_write_access *p_other) {
- PoolVector<godot_int>::Write *write = (PoolVector<godot_int>::Write *)p_write;
- PoolVector<godot_int>::Write *other = (PoolVector<godot_int>::Write *)p_other;
- write->operator=(*other);
-}
-void GDAPI godot_pool_int_array_write_access_destroy(godot_pool_int_array_write_access *p_write) {
- memdelete((PoolVector<godot_int>::Write *)p_write);
-}
-
-godot_pool_real_array_write_access GDAPI *godot_pool_real_array_write_access_copy(const godot_pool_real_array_write_access *p_other) {
- PoolVector<godot_real>::Write *other = (PoolVector<godot_real>::Write *)p_other;
- return (godot_pool_real_array_write_access *)memnew(PoolVector<godot_real>::Write(*other));
-}
-godot_real GDAPI *godot_pool_real_array_write_access_ptr(const godot_pool_real_array_write_access *p_write) {
- PoolVector<godot_real>::Write *write = (PoolVector<godot_real>::Write *)p_write;
- return write->ptr();
-}
-void GDAPI godot_pool_real_array_write_access_operator_assign(godot_pool_real_array_write_access *p_write, godot_pool_real_array_write_access *p_other) {
- PoolVector<godot_real>::Write *write = (PoolVector<godot_real>::Write *)p_write;
- PoolVector<godot_real>::Write *other = (PoolVector<godot_real>::Write *)p_other;
- write->operator=(*other);
-}
-void GDAPI godot_pool_real_array_write_access_destroy(godot_pool_real_array_write_access *p_write) {
- memdelete((PoolVector<godot_real>::Write *)p_write);
-}
-
-godot_pool_string_array_write_access GDAPI *godot_pool_string_array_write_access_copy(const godot_pool_string_array_write_access *p_other) {
- PoolVector<String>::Write *other = (PoolVector<String>::Write *)p_other;
- return (godot_pool_string_array_write_access *)memnew(PoolVector<String>::Write(*other));
-}
-godot_string GDAPI *godot_pool_string_array_write_access_ptr(const godot_pool_string_array_write_access *p_write) {
- PoolVector<String>::Write *write = (PoolVector<String>::Write *)p_write;
- return (godot_string *)write->ptr();
-}
-void GDAPI godot_pool_string_array_write_access_operator_assign(godot_pool_string_array_write_access *p_write, godot_pool_string_array_write_access *p_other) {
- PoolVector<String>::Write *write = (PoolVector<String>::Write *)p_write;
- PoolVector<String>::Write *other = (PoolVector<String>::Write *)p_other;
- write->operator=(*other);
-}
-void GDAPI godot_pool_string_array_write_access_destroy(godot_pool_string_array_write_access *p_write) {
- memdelete((PoolVector<String>::Write *)p_write);
-}
-
-godot_pool_vector2_array_write_access GDAPI *godot_pool_vector2_array_write_access_copy(const godot_pool_vector2_array_write_access *p_other) {
- PoolVector<Vector2>::Write *other = (PoolVector<Vector2>::Write *)p_other;
- return (godot_pool_vector2_array_write_access *)memnew(PoolVector<Vector2>::Write(*other));
-}
-godot_vector2 GDAPI *godot_pool_vector2_array_write_access_ptr(const godot_pool_vector2_array_write_access *p_write) {
- PoolVector<Vector2>::Write *write = (PoolVector<Vector2>::Write *)p_write;
- return (godot_vector2 *)write->ptr();
-}
-void GDAPI godot_pool_vector2_array_write_access_operator_assign(godot_pool_vector2_array_write_access *p_write, godot_pool_vector2_array_write_access *p_other) {
- PoolVector<Vector2>::Write *write = (PoolVector<Vector2>::Write *)p_write;
- PoolVector<Vector2>::Write *other = (PoolVector<Vector2>::Write *)p_other;
- write->operator=(*other);
-}
-void GDAPI godot_pool_vector2_array_write_access_destroy(godot_pool_vector2_array_write_access *p_write) {
- memdelete((PoolVector<Vector2>::Write *)p_write);
-}
-
-godot_pool_vector3_array_write_access GDAPI *godot_pool_vector3_array_write_access_copy(const godot_pool_vector3_array_write_access *p_other) {
- PoolVector<Vector3>::Write *other = (PoolVector<Vector3>::Write *)p_other;
- return (godot_pool_vector3_array_write_access *)memnew(PoolVector<Vector3>::Write(*other));
-}
-godot_vector3 GDAPI *godot_pool_vector3_array_write_access_ptr(const godot_pool_vector3_array_write_access *p_write) {
- PoolVector<Vector3>::Write *write = (PoolVector<Vector3>::Write *)p_write;
- return (godot_vector3 *)write->ptr();
-}
-void GDAPI godot_pool_vector3_array_write_access_operator_assign(godot_pool_vector3_array_write_access *p_write, godot_pool_vector3_array_write_access *p_other) {
- PoolVector<Vector3>::Write *write = (PoolVector<Vector3>::Write *)p_write;
- PoolVector<Vector3>::Write *other = (PoolVector<Vector3>::Write *)p_other;
- write->operator=(*other);
-}
-void GDAPI godot_pool_vector3_array_write_access_destroy(godot_pool_vector3_array_write_access *p_write) {
- memdelete((PoolVector<Vector3>::Write *)p_write);
-}
-
-godot_pool_color_array_write_access GDAPI *godot_pool_color_array_write_access_copy(const godot_pool_color_array_write_access *p_other) {
- PoolVector<Color>::Write *other = (PoolVector<Color>::Write *)p_other;
- return (godot_pool_color_array_write_access *)memnew(PoolVector<Color>::Write(*other));
-}
-godot_color GDAPI *godot_pool_color_array_write_access_ptr(const godot_pool_color_array_write_access *p_write) {
- PoolVector<Color>::Write *write = (PoolVector<Color>::Write *)p_write;
- return (godot_color *)write->ptr();
-}
-void GDAPI godot_pool_color_array_write_access_operator_assign(godot_pool_color_array_write_access *p_write, godot_pool_color_array_write_access *p_other) {
- PoolVector<Color>::Write *write = (PoolVector<Color>::Write *)p_write;
- PoolVector<Color>::Write *other = (PoolVector<Color>::Write *)p_other;
- write->operator=(*other);
-}
-void GDAPI godot_pool_color_array_write_access_destroy(godot_pool_color_array_write_access *p_write) {
- memdelete((PoolVector<Color>::Write *)p_write);
+void GDAPI godot_packed_color_array_destroy(godot_packed_color_array *p_self) {
+ ((Vector<Color> *)p_self)->~Vector();
}
#ifdef __cplusplus
diff --git a/modules/gdnative/gdnative/string.cpp b/modules/gdnative/gdnative/string.cpp
index 414b9b9eaf..4cb55900b0 100644
--- a/modules/gdnative/gdnative/string.cpp
+++ b/modules/gdnative/gdnative/string.cpp
@@ -250,7 +250,12 @@ godot_int GDAPI godot_string_findmk_from_in_place(const godot_string *p_self, co
keys.write[i] = (*keys_proxy)[i];
}
- return self->findmk(keys, p_from, r_key);
+ int key;
+ int ret = self->findmk(keys, p_from, &key);
+ if (r_key) {
+ *r_key = key;
+ }
+ return ret;
}
godot_int GDAPI godot_string_findn(const godot_string *p_self, godot_string p_what) {
@@ -1025,14 +1030,14 @@ uint32_t GDAPI godot_string_hash_utf8_chars_with_len(const wchar_t *p_str, godot
return String::hash(p_str, p_len);
}
-godot_pool_byte_array GDAPI godot_string_md5_buffer(const godot_string *p_self) {
+godot_packed_byte_array GDAPI godot_string_md5_buffer(const godot_string *p_self) {
const String *self = (const String *)p_self;
Vector<uint8_t> tmp_result = self->md5_buffer();
- godot_pool_byte_array result;
- memnew_placement(&result, PoolByteArray);
- PoolByteArray *proxy = (PoolByteArray *)&result;
- PoolByteArray::Write proxy_writer = proxy->write();
+ godot_packed_byte_array result;
+ memnew_placement(&result, PackedByteArray);
+ PackedByteArray *proxy = (PackedByteArray *)&result;
+ uint8_t *proxy_writer = proxy->ptrw();
proxy->resize(tmp_result.size());
for (int i = 0; i < tmp_result.size(); i++) {
@@ -1050,14 +1055,14 @@ godot_string GDAPI godot_string_md5_text(const godot_string *p_self) {
return result;
}
-godot_pool_byte_array GDAPI godot_string_sha256_buffer(const godot_string *p_self) {
+godot_packed_byte_array GDAPI godot_string_sha256_buffer(const godot_string *p_self) {
const String *self = (const String *)p_self;
Vector<uint8_t> tmp_result = self->sha256_buffer();
- godot_pool_byte_array result;
- memnew_placement(&result, PoolByteArray);
- PoolByteArray *proxy = (PoolByteArray *)&result;
- PoolByteArray::Write proxy_writer = proxy->write();
+ godot_packed_byte_array result;
+ memnew_placement(&result, PackedByteArray);
+ PackedByteArray *proxy = (PackedByteArray *)&result;
+ uint8_t *proxy_writer = proxy->ptrw();
proxy->resize(tmp_result.size());
for (int i = 0; i < tmp_result.size(); i++) {
@@ -1338,15 +1343,15 @@ godot_string GDAPI godot_string_rstrip(const godot_string *p_self, const godot_s
return result;
}
-godot_pool_string_array GDAPI godot_string_rsplit(const godot_string *p_self, const godot_string *p_divisor,
+godot_packed_string_array GDAPI godot_string_rsplit(const godot_string *p_self, const godot_string *p_divisor,
const godot_bool p_allow_empty, const godot_int p_maxsplit) {
const String *self = (const String *)p_self;
String *divisor = (String *)p_divisor;
- godot_pool_string_array result;
- memnew_placement(&result, PoolStringArray);
- PoolStringArray *proxy = (PoolStringArray *)&result;
- PoolStringArray::Write proxy_writer = proxy->write();
+ godot_packed_string_array result;
+ memnew_placement(&result, PackedStringArray);
+ PackedStringArray *proxy = (PackedStringArray *)&result;
+ String *proxy_writer = proxy->ptrw();
Vector<String> tmp_result = self->rsplit(*divisor, p_allow_empty, p_maxsplit);
proxy->resize(tmp_result.size());
diff --git a/modules/gdnative/gdnative/variant.cpp b/modules/gdnative/gdnative/variant.cpp
index 11b6448e34..f0fc44ae8a 100644
--- a/modules/gdnative/gdnative/variant.cpp
+++ b/modules/gdnative/gdnative/variant.cpp
@@ -178,7 +178,7 @@ void GDAPI godot_variant_new_object(godot_variant *r_dest, const godot_object *p
ref = REF(reference);
}
if (!ref.is_null()) {
- memnew_placement_custom(dest, Variant, Variant(ref.get_ref_ptr()));
+ memnew_placement_custom(dest, Variant, Variant(ref));
} else {
#if defined(DEBUG_METHODS_ENABLED)
if (reference) {
@@ -201,45 +201,45 @@ void GDAPI godot_variant_new_array(godot_variant *r_dest, const godot_array *p_a
memnew_placement_custom(dest, Variant, Variant(*arr));
}
-void GDAPI godot_variant_new_pool_byte_array(godot_variant *r_dest, const godot_pool_byte_array *p_pba) {
+void GDAPI godot_variant_new_packed_byte_array(godot_variant *r_dest, const godot_packed_byte_array *p_pba) {
Variant *dest = (Variant *)r_dest;
- PoolByteArray *pba = (PoolByteArray *)p_pba;
+ PackedByteArray *pba = (PackedByteArray *)p_pba;
memnew_placement_custom(dest, Variant, Variant(*pba));
}
-void GDAPI godot_variant_new_pool_int_array(godot_variant *r_dest, const godot_pool_int_array *p_pia) {
+void GDAPI godot_variant_new_packed_int_array(godot_variant *r_dest, const godot_packed_int_array *p_pia) {
Variant *dest = (Variant *)r_dest;
- PoolIntArray *pia = (PoolIntArray *)p_pia;
+ PackedInt32Array *pia = (PackedInt32Array *)p_pia;
memnew_placement_custom(dest, Variant, Variant(*pia));
}
-void GDAPI godot_variant_new_pool_real_array(godot_variant *r_dest, const godot_pool_real_array *p_pra) {
+void GDAPI godot_variant_new_packed_real_array(godot_variant *r_dest, const godot_packed_real_array *p_pra) {
Variant *dest = (Variant *)r_dest;
- PoolRealArray *pra = (PoolRealArray *)p_pra;
+ PackedFloat32Array *pra = (PackedFloat32Array *)p_pra;
memnew_placement_custom(dest, Variant, Variant(*pra));
}
-void GDAPI godot_variant_new_pool_string_array(godot_variant *r_dest, const godot_pool_string_array *p_psa) {
+void GDAPI godot_variant_new_packed_string_array(godot_variant *r_dest, const godot_packed_string_array *p_psa) {
Variant *dest = (Variant *)r_dest;
- PoolStringArray *psa = (PoolStringArray *)p_psa;
+ PackedStringArray *psa = (PackedStringArray *)p_psa;
memnew_placement_custom(dest, Variant, Variant(*psa));
}
-void GDAPI godot_variant_new_pool_vector2_array(godot_variant *r_dest, const godot_pool_vector2_array *p_pv2a) {
+void GDAPI godot_variant_new_packed_vector2_array(godot_variant *r_dest, const godot_packed_vector2_array *p_pv2a) {
Variant *dest = (Variant *)r_dest;
- PoolVector2Array *pv2a = (PoolVector2Array *)p_pv2a;
+ PackedVector2Array *pv2a = (PackedVector2Array *)p_pv2a;
memnew_placement_custom(dest, Variant, Variant(*pv2a));
}
-void GDAPI godot_variant_new_pool_vector3_array(godot_variant *r_dest, const godot_pool_vector3_array *p_pv3a) {
+void GDAPI godot_variant_new_packed_vector3_array(godot_variant *r_dest, const godot_packed_vector3_array *p_pv3a) {
Variant *dest = (Variant *)r_dest;
- PoolVector3Array *pv3a = (PoolVector3Array *)p_pv3a;
+ PackedVector3Array *pv3a = (PackedVector3Array *)p_pv3a;
memnew_placement_custom(dest, Variant, Variant(*pv3a));
}
-void GDAPI godot_variant_new_pool_color_array(godot_variant *r_dest, const godot_pool_color_array *p_pca) {
+void GDAPI godot_variant_new_packed_color_array(godot_variant *r_dest, const godot_packed_color_array *p_pca) {
Variant *dest = (Variant *)r_dest;
- PoolColorArray *pca = (PoolColorArray *)p_pca;
+ PackedColorArray *pca = (PackedColorArray *)p_pca;
memnew_placement_custom(dest, Variant, Variant(*pca));
}
@@ -390,65 +390,65 @@ godot_array GDAPI godot_variant_as_array(const godot_variant *p_self) {
return raw_dest;
}
-godot_pool_byte_array GDAPI godot_variant_as_pool_byte_array(const godot_variant *p_self) {
- godot_pool_byte_array raw_dest;
+godot_packed_byte_array GDAPI godot_variant_as_packed_byte_array(const godot_variant *p_self) {
+ godot_packed_byte_array raw_dest;
const Variant *self = (const Variant *)p_self;
- PoolByteArray *dest = (PoolByteArray *)&raw_dest;
- memnew_placement(dest, PoolByteArray(self->operator PoolByteArray())); // operator = is overloaded by PoolByteArray
+ PackedByteArray *dest = (PackedByteArray *)&raw_dest;
+ memnew_placement(dest, PackedByteArray(self->operator PackedByteArray())); // operator = is overloaded by PackedByteArray
*dest = *self;
return raw_dest;
}
-godot_pool_int_array GDAPI godot_variant_as_pool_int_array(const godot_variant *p_self) {
- godot_pool_int_array raw_dest;
+godot_packed_int_array GDAPI godot_variant_as_packed_int_array(const godot_variant *p_self) {
+ godot_packed_int_array raw_dest;
const Variant *self = (const Variant *)p_self;
- PoolIntArray *dest = (PoolIntArray *)&raw_dest;
- memnew_placement(dest, PoolIntArray(self->operator PoolIntArray())); // operator = is overloaded by PoolIntArray
+ PackedInt32Array *dest = (PackedInt32Array *)&raw_dest;
+ memnew_placement(dest, PackedInt32Array(self->operator PackedInt32Array())); // operator = is overloaded by PackedInt32Array
*dest = *self;
return raw_dest;
}
-godot_pool_real_array GDAPI godot_variant_as_pool_real_array(const godot_variant *p_self) {
- godot_pool_real_array raw_dest;
+godot_packed_real_array GDAPI godot_variant_as_packed_real_array(const godot_variant *p_self) {
+ godot_packed_real_array raw_dest;
const Variant *self = (const Variant *)p_self;
- PoolRealArray *dest = (PoolRealArray *)&raw_dest;
- memnew_placement(dest, PoolRealArray(self->operator PoolRealArray())); // operator = is overloaded by PoolRealArray
+ PackedFloat32Array *dest = (PackedFloat32Array *)&raw_dest;
+ memnew_placement(dest, PackedFloat32Array(self->operator PackedFloat32Array())); // operator = is overloaded by PackedFloat32Array
*dest = *self;
return raw_dest;
}
-godot_pool_string_array GDAPI godot_variant_as_pool_string_array(const godot_variant *p_self) {
- godot_pool_string_array raw_dest;
+godot_packed_string_array GDAPI godot_variant_as_packed_string_array(const godot_variant *p_self) {
+ godot_packed_string_array raw_dest;
const Variant *self = (const Variant *)p_self;
- PoolStringArray *dest = (PoolStringArray *)&raw_dest;
- memnew_placement(dest, PoolStringArray(self->operator PoolStringArray())); // operator = is overloaded by PoolStringArray
+ PackedStringArray *dest = (PackedStringArray *)&raw_dest;
+ memnew_placement(dest, PackedStringArray(self->operator PackedStringArray())); // operator = is overloaded by PackedStringArray
*dest = *self;
return raw_dest;
}
-godot_pool_vector2_array GDAPI godot_variant_as_pool_vector2_array(const godot_variant *p_self) {
- godot_pool_vector2_array raw_dest;
+godot_packed_vector2_array GDAPI godot_variant_as_packed_vector2_array(const godot_variant *p_self) {
+ godot_packed_vector2_array raw_dest;
const Variant *self = (const Variant *)p_self;
- PoolVector2Array *dest = (PoolVector2Array *)&raw_dest;
- memnew_placement(dest, PoolVector2Array(self->operator PoolVector2Array())); // operator = is overloaded by PoolVector2Array
+ PackedVector2Array *dest = (PackedVector2Array *)&raw_dest;
+ memnew_placement(dest, PackedVector2Array(self->operator PackedVector2Array())); // operator = is overloaded by PackedVector2Array
*dest = *self;
return raw_dest;
}
-godot_pool_vector3_array GDAPI godot_variant_as_pool_vector3_array(const godot_variant *p_self) {
- godot_pool_vector3_array raw_dest;
+godot_packed_vector3_array GDAPI godot_variant_as_packed_vector3_array(const godot_variant *p_self) {
+ godot_packed_vector3_array raw_dest;
const Variant *self = (const Variant *)p_self;
- PoolVector3Array *dest = (PoolVector3Array *)&raw_dest;
- memnew_placement(dest, PoolVector3Array(self->operator PoolVector3Array())); // operator = is overloaded by PoolVector3Array
+ PackedVector3Array *dest = (PackedVector3Array *)&raw_dest;
+ memnew_placement(dest, PackedVector3Array(self->operator PackedVector3Array())); // operator = is overloaded by PackedVector3Array
*dest = *self;
return raw_dest;
}
-godot_pool_color_array GDAPI godot_variant_as_pool_color_array(const godot_variant *p_self) {
- godot_pool_color_array raw_dest;
+godot_packed_color_array GDAPI godot_variant_as_packed_color_array(const godot_variant *p_self) {
+ godot_packed_color_array raw_dest;
const Variant *self = (const Variant *)p_self;
- PoolColorArray *dest = (PoolColorArray *)&raw_dest;
- memnew_placement(dest, PoolColorArray(self->operator PoolColorArray())); // operator = is overloaded by PoolColorArray
+ PackedColorArray *dest = (PackedColorArray *)&raw_dest;
+ memnew_placement(dest, PackedColorArray(self->operator PackedColorArray())); // operator = is overloaded by PackedColorArray
*dest = *self;
return raw_dest;
}
@@ -459,7 +459,7 @@ godot_variant GDAPI godot_variant_call(godot_variant *p_self, const godot_string
const Variant **args = (const Variant **)p_args;
godot_variant raw_dest;
Variant *dest = (Variant *)&raw_dest;
- Variant::CallError error;
+ Callable::CallError error;
memnew_placement_custom(dest, Variant, Variant(self->call(*method, args, p_argcount, error)));
if (r_error) {
r_error->error = (godot_variant_call_error_error)error.error;
diff --git a/modules/gdnative/gdnative_api.json b/modules/gdnative/gdnative_api.json
index 8ccb8d2286..e1d6c0c867 100644
--- a/modules/gdnative/gdnative_api.json
+++ b/modules/gdnative/gdnative_api.json
@@ -93,52 +93,52 @@
]
},
{
- "name": "godot_pool_byte_array_empty",
+ "name": "godot_packed_byte_array_empty",
"return_type": "godot_bool",
"arguments": [
- ["const godot_pool_byte_array *", "p_self"]
+ ["const godot_packed_byte_array *", "p_self"]
]
},
{
- "name": "godot_pool_int_array_empty",
+ "name": "godot_packed_int_array_empty",
"return_type": "godot_bool",
"arguments": [
- ["const godot_pool_int_array *", "p_self"]
+ ["const godot_packed_int_array *", "p_self"]
]
},
{
- "name": "godot_pool_real_array_empty",
+ "name": "godot_packed_real_array_empty",
"return_type": "godot_bool",
"arguments": [
- ["const godot_pool_real_array *", "p_self"]
+ ["const godot_packed_real_array *", "p_self"]
]
},
{
- "name": "godot_pool_string_array_empty",
+ "name": "godot_packed_string_array_empty",
"return_type": "godot_bool",
"arguments": [
- ["const godot_pool_string_array *", "p_self"]
+ ["const godot_packed_string_array *", "p_self"]
]
},
{
- "name": "godot_pool_vector2_array_empty",
+ "name": "godot_packed_vector2_array_empty",
"return_type": "godot_bool",
"arguments": [
- ["const godot_pool_vector2_array *", "p_self"]
+ ["const godot_packed_vector2_array *", "p_self"]
]
},
{
- "name": "godot_pool_vector3_array_empty",
+ "name": "godot_packed_vector3_array_empty",
"return_type": "godot_bool",
"arguments": [
- ["const godot_pool_vector3_array *", "p_self"]
+ ["const godot_packed_vector3_array *", "p_self"]
]
},
{
- "name": "godot_pool_color_array_empty",
+ "name": "godot_packed_color_array_empty",
"return_type": "godot_bool",
"arguments": [
- ["const godot_pool_color_array *", "p_self"]
+ ["const godot_packed_color_array *", "p_self"]
]
},
{
@@ -352,7 +352,7 @@
},
{
"name": "godot_string_rsplit",
- "return_type": "godot_pool_string_array",
+ "return_type": "godot_packed_string_array",
"arguments": [
["const godot_string *", "p_self"],
["const godot_string *", "p_divisor"],
@@ -404,13 +404,6 @@
]
},
{
- "name": "godot_is_instance_valid",
- "return_type": "bool",
- "arguments": [
- ["const godot_object *", "p_object"]
- ]
- },
- {
"name": "godot_quat_new_with_basis",
"return_type": "void",
"arguments": [
@@ -579,13 +572,6 @@
]
},
{
- "name": "godot_color_gray",
- "return_type": "godot_real",
- "arguments": [
- ["const godot_color *", "p_self"]
- ]
- },
- {
"name": "godot_color_inverted",
"return_type": "godot_color",
"arguments": [
@@ -1671,1277 +1657,773 @@
]
},
{
- "name": "godot_pool_byte_array_new",
+ "name": "godot_packed_byte_array_new",
"return_type": "void",
"arguments": [
- ["godot_pool_byte_array *", "r_dest"]
+ ["godot_packed_byte_array *", "r_dest"]
]
},
{
- "name": "godot_pool_byte_array_new_copy",
+ "name": "godot_packed_byte_array_new_copy",
"return_type": "void",
"arguments": [
- ["godot_pool_byte_array *", "r_dest"],
- ["const godot_pool_byte_array *", "p_src"]
+ ["godot_packed_byte_array *", "r_dest"],
+ ["const godot_packed_byte_array *", "p_src"]
]
},
{
- "name": "godot_pool_byte_array_new_with_array",
+ "name": "godot_packed_byte_array_new_with_array",
"return_type": "void",
"arguments": [
- ["godot_pool_byte_array *", "r_dest"],
+ ["godot_packed_byte_array *", "r_dest"],
["const godot_array *", "p_a"]
]
},
{
- "name": "godot_pool_byte_array_append",
+ "name": "godot_packed_byte_array_append",
"return_type": "void",
"arguments": [
- ["godot_pool_byte_array *", "p_self"],
+ ["godot_packed_byte_array *", "p_self"],
["const uint8_t", "p_data"]
]
},
{
- "name": "godot_pool_byte_array_append_array",
+ "name": "godot_packed_byte_array_append_array",
"return_type": "void",
"arguments": [
- ["godot_pool_byte_array *", "p_self"],
- ["const godot_pool_byte_array *", "p_array"]
+ ["godot_packed_byte_array *", "p_self"],
+ ["const godot_packed_byte_array *", "p_array"]
]
},
{
- "name": "godot_pool_byte_array_insert",
+ "name": "godot_packed_byte_array_insert",
"return_type": "godot_error",
"arguments": [
- ["godot_pool_byte_array *", "p_self"],
+ ["godot_packed_byte_array *", "p_self"],
["const godot_int", "p_idx"],
["const uint8_t", "p_data"]
]
},
{
- "name": "godot_pool_byte_array_invert",
+ "name": "godot_packed_byte_array_invert",
"return_type": "void",
"arguments": [
- ["godot_pool_byte_array *", "p_self"]
+ ["godot_packed_byte_array *", "p_self"]
]
},
{
- "name": "godot_pool_byte_array_push_back",
+ "name": "godot_packed_byte_array_push_back",
"return_type": "void",
"arguments": [
- ["godot_pool_byte_array *", "p_self"],
+ ["godot_packed_byte_array *", "p_self"],
["const uint8_t", "p_data"]
]
},
{
- "name": "godot_pool_byte_array_remove",
+ "name": "godot_packed_byte_array_remove",
"return_type": "void",
"arguments": [
- ["godot_pool_byte_array *", "p_self"],
+ ["godot_packed_byte_array *", "p_self"],
["const godot_int", "p_idx"]
]
},
{
- "name": "godot_pool_byte_array_resize",
+ "name": "godot_packed_byte_array_resize",
"return_type": "void",
"arguments": [
- ["godot_pool_byte_array *", "p_self"],
+ ["godot_packed_byte_array *", "p_self"],
["const godot_int", "p_size"]
]
},
{
- "name": "godot_pool_byte_array_read",
- "return_type": "godot_pool_byte_array_read_access *",
- "arguments": [
- ["const godot_pool_byte_array *", "p_self"]
- ]
- },
- {
- "name": "godot_pool_byte_array_write",
- "return_type": "godot_pool_byte_array_write_access *",
- "arguments": [
- ["godot_pool_byte_array *", "p_self"]
- ]
- },
- {
- "name": "godot_pool_byte_array_set",
+ "name": "godot_packed_byte_array_set",
"return_type": "void",
"arguments": [
- ["godot_pool_byte_array *", "p_self"],
+ ["godot_packed_byte_array *", "p_self"],
["const godot_int", "p_idx"],
["const uint8_t", "p_data"]
]
},
{
- "name": "godot_pool_byte_array_get",
+ "name": "godot_packed_byte_array_get",
"return_type": "uint8_t",
"arguments": [
- ["const godot_pool_byte_array *", "p_self"],
+ ["const godot_packed_byte_array *", "p_self"],
["const godot_int", "p_idx"]
]
},
{
- "name": "godot_pool_byte_array_size",
+ "name": "godot_packed_byte_array_size",
"return_type": "godot_int",
"arguments": [
- ["const godot_pool_byte_array *", "p_self"]
+ ["const godot_packed_byte_array *", "p_self"]
]
},
{
- "name": "godot_pool_byte_array_destroy",
+ "name": "godot_packed_byte_array_destroy",
"return_type": "void",
"arguments": [
- ["godot_pool_byte_array *", "p_self"]
+ ["godot_packed_byte_array *", "p_self"]
]
},
{
- "name": "godot_pool_int_array_new",
+ "name": "godot_packed_int_array_new",
"return_type": "void",
"arguments": [
- ["godot_pool_int_array *", "r_dest"]
+ ["godot_packed_int_array *", "r_dest"]
]
},
{
- "name": "godot_pool_int_array_new_copy",
+ "name": "godot_packed_int_array_new_copy",
"return_type": "void",
"arguments": [
- ["godot_pool_int_array *", "r_dest"],
- ["const godot_pool_int_array *", "p_src"]
+ ["godot_packed_int_array *", "r_dest"],
+ ["const godot_packed_int_array *", "p_src"]
]
},
{
- "name": "godot_pool_int_array_new_with_array",
+ "name": "godot_packed_int_array_new_with_array",
"return_type": "void",
"arguments": [
- ["godot_pool_int_array *", "r_dest"],
+ ["godot_packed_int_array *", "r_dest"],
["const godot_array *", "p_a"]
]
},
{
- "name": "godot_pool_int_array_append",
+ "name": "godot_packed_int_array_append",
"return_type": "void",
"arguments": [
- ["godot_pool_int_array *", "p_self"],
+ ["godot_packed_int_array *", "p_self"],
["const godot_int", "p_data"]
]
},
{
- "name": "godot_pool_int_array_append_array",
+ "name": "godot_packed_int_array_append_array",
"return_type": "void",
"arguments": [
- ["godot_pool_int_array *", "p_self"],
- ["const godot_pool_int_array *", "p_array"]
+ ["godot_packed_int_array *", "p_self"],
+ ["const godot_packed_int_array *", "p_array"]
]
},
{
- "name": "godot_pool_int_array_insert",
+ "name": "godot_packed_int_array_insert",
"return_type": "godot_error",
"arguments": [
- ["godot_pool_int_array *", "p_self"],
+ ["godot_packed_int_array *", "p_self"],
["const godot_int", "p_idx"],
["const godot_int", "p_data"]
]
},
{
- "name": "godot_pool_int_array_invert",
+ "name": "godot_packed_int_array_invert",
"return_type": "void",
"arguments": [
- ["godot_pool_int_array *", "p_self"]
+ ["godot_packed_int_array *", "p_self"]
]
},
{
- "name": "godot_pool_int_array_push_back",
+ "name": "godot_packed_int_array_push_back",
"return_type": "void",
"arguments": [
- ["godot_pool_int_array *", "p_self"],
+ ["godot_packed_int_array *", "p_self"],
["const godot_int", "p_data"]
]
},
{
- "name": "godot_pool_int_array_remove",
+ "name": "godot_packed_int_array_remove",
"return_type": "void",
"arguments": [
- ["godot_pool_int_array *", "p_self"],
+ ["godot_packed_int_array *", "p_self"],
["const godot_int", "p_idx"]
]
},
{
- "name": "godot_pool_int_array_resize",
+ "name": "godot_packed_int_array_resize",
"return_type": "void",
"arguments": [
- ["godot_pool_int_array *", "p_self"],
+ ["godot_packed_int_array *", "p_self"],
["const godot_int", "p_size"]
]
},
{
- "name": "godot_pool_int_array_read",
- "return_type": "godot_pool_int_array_read_access *",
- "arguments": [
- ["const godot_pool_int_array *", "p_self"]
- ]
- },
- {
- "name": "godot_pool_int_array_write",
- "return_type": "godot_pool_int_array_write_access *",
- "arguments": [
- ["godot_pool_int_array *", "p_self"]
- ]
- },
- {
- "name": "godot_pool_int_array_set",
+ "name": "godot_packed_int_array_set",
"return_type": "void",
"arguments": [
- ["godot_pool_int_array *", "p_self"],
+ ["godot_packed_int_array *", "p_self"],
["const godot_int", "p_idx"],
["const godot_int", "p_data"]
]
},
{
- "name": "godot_pool_int_array_get",
+ "name": "godot_packed_int_array_get",
"return_type": "godot_int",
"arguments": [
- ["const godot_pool_int_array *", "p_self"],
+ ["const godot_packed_int_array *", "p_self"],
["const godot_int", "p_idx"]
]
},
{
- "name": "godot_pool_int_array_size",
+ "name": "godot_packed_int_array_size",
"return_type": "godot_int",
"arguments": [
- ["const godot_pool_int_array *", "p_self"]
+ ["const godot_packed_int_array *", "p_self"]
]
},
{
- "name": "godot_pool_int_array_destroy",
+ "name": "godot_packed_int_array_destroy",
"return_type": "void",
"arguments": [
- ["godot_pool_int_array *", "p_self"]
+ ["godot_packed_int_array *", "p_self"]
]
},
{
- "name": "godot_pool_real_array_new",
+ "name": "godot_packed_real_array_new",
"return_type": "void",
"arguments": [
- ["godot_pool_real_array *", "r_dest"]
+ ["godot_packed_real_array *", "r_dest"]
]
},
{
- "name": "godot_pool_real_array_new_copy",
+ "name": "godot_packed_real_array_new_copy",
"return_type": "void",
"arguments": [
- ["godot_pool_real_array *", "r_dest"],
- ["const godot_pool_real_array *", "p_src"]
+ ["godot_packed_real_array *", "r_dest"],
+ ["const godot_packed_real_array *", "p_src"]
]
},
{
- "name": "godot_pool_real_array_new_with_array",
+ "name": "godot_packed_real_array_new_with_array",
"return_type": "void",
"arguments": [
- ["godot_pool_real_array *", "r_dest"],
+ ["godot_packed_real_array *", "r_dest"],
["const godot_array *", "p_a"]
]
},
{
- "name": "godot_pool_real_array_append",
+ "name": "godot_packed_real_array_append",
"return_type": "void",
"arguments": [
- ["godot_pool_real_array *", "p_self"],
+ ["godot_packed_real_array *", "p_self"],
["const godot_real", "p_data"]
]
},
{
- "name": "godot_pool_real_array_append_array",
+ "name": "godot_packed_real_array_append_array",
"return_type": "void",
"arguments": [
- ["godot_pool_real_array *", "p_self"],
- ["const godot_pool_real_array *", "p_array"]
+ ["godot_packed_real_array *", "p_self"],
+ ["const godot_packed_real_array *", "p_array"]
]
},
{
- "name": "godot_pool_real_array_insert",
+ "name": "godot_packed_real_array_insert",
"return_type": "godot_error",
"arguments": [
- ["godot_pool_real_array *", "p_self"],
+ ["godot_packed_real_array *", "p_self"],
["const godot_int", "p_idx"],
["const godot_real", "p_data"]
]
},
{
- "name": "godot_pool_real_array_invert",
+ "name": "godot_packed_real_array_invert",
"return_type": "void",
"arguments": [
- ["godot_pool_real_array *", "p_self"]
+ ["godot_packed_real_array *", "p_self"]
]
},
{
- "name": "godot_pool_real_array_push_back",
+ "name": "godot_packed_real_array_push_back",
"return_type": "void",
"arguments": [
- ["godot_pool_real_array *", "p_self"],
+ ["godot_packed_real_array *", "p_self"],
["const godot_real", "p_data"]
]
},
{
- "name": "godot_pool_real_array_remove",
+ "name": "godot_packed_real_array_remove",
"return_type": "void",
"arguments": [
- ["godot_pool_real_array *", "p_self"],
+ ["godot_packed_real_array *", "p_self"],
["const godot_int", "p_idx"]
]
},
{
- "name": "godot_pool_real_array_resize",
+ "name": "godot_packed_real_array_resize",
"return_type": "void",
"arguments": [
- ["godot_pool_real_array *", "p_self"],
+ ["godot_packed_real_array *", "p_self"],
["const godot_int", "p_size"]
]
},
{
- "name": "godot_pool_real_array_read",
- "return_type": "godot_pool_real_array_read_access *",
- "arguments": [
- ["const godot_pool_real_array *", "p_self"]
- ]
- },
- {
- "name": "godot_pool_real_array_write",
- "return_type": "godot_pool_real_array_write_access *",
- "arguments": [
- ["godot_pool_real_array *", "p_self"]
- ]
- },
- {
- "name": "godot_pool_real_array_set",
+ "name": "godot_packed_real_array_set",
"return_type": "void",
"arguments": [
- ["godot_pool_real_array *", "p_self"],
+ ["godot_packed_real_array *", "p_self"],
["const godot_int", "p_idx"],
["const godot_real", "p_data"]
]
},
{
- "name": "godot_pool_real_array_get",
+ "name": "godot_packed_real_array_get",
"return_type": "godot_real",
"arguments": [
- ["const godot_pool_real_array *", "p_self"],
+ ["const godot_packed_real_array *", "p_self"],
["const godot_int", "p_idx"]
]
},
{
- "name": "godot_pool_real_array_size",
+ "name": "godot_packed_real_array_size",
"return_type": "godot_int",
"arguments": [
- ["const godot_pool_real_array *", "p_self"]
+ ["const godot_packed_real_array *", "p_self"]
]
},
{
- "name": "godot_pool_real_array_destroy",
+ "name": "godot_packed_real_array_destroy",
"return_type": "void",
"arguments": [
- ["godot_pool_real_array *", "p_self"]
+ ["godot_packed_real_array *", "p_self"]
]
},
{
- "name": "godot_pool_string_array_new",
+ "name": "godot_packed_string_array_new",
"return_type": "void",
"arguments": [
- ["godot_pool_string_array *", "r_dest"]
+ ["godot_packed_string_array *", "r_dest"]
]
},
{
- "name": "godot_pool_string_array_new_copy",
+ "name": "godot_packed_string_array_new_copy",
"return_type": "void",
"arguments": [
- ["godot_pool_string_array *", "r_dest"],
- ["const godot_pool_string_array *", "p_src"]
+ ["godot_packed_string_array *", "r_dest"],
+ ["const godot_packed_string_array *", "p_src"]
]
},
{
- "name": "godot_pool_string_array_new_with_array",
+ "name": "godot_packed_string_array_new_with_array",
"return_type": "void",
"arguments": [
- ["godot_pool_string_array *", "r_dest"],
+ ["godot_packed_string_array *", "r_dest"],
["const godot_array *", "p_a"]
]
},
{
- "name": "godot_pool_string_array_append",
+ "name": "godot_packed_string_array_append",
"return_type": "void",
"arguments": [
- ["godot_pool_string_array *", "p_self"],
+ ["godot_packed_string_array *", "p_self"],
["const godot_string *", "p_data"]
]
},
{
- "name": "godot_pool_string_array_append_array",
+ "name": "godot_packed_string_array_append_array",
"return_type": "void",
"arguments": [
- ["godot_pool_string_array *", "p_self"],
- ["const godot_pool_string_array *", "p_array"]
+ ["godot_packed_string_array *", "p_self"],
+ ["const godot_packed_string_array *", "p_array"]
]
},
{
- "name": "godot_pool_string_array_insert",
+ "name": "godot_packed_string_array_insert",
"return_type": "godot_error",
"arguments": [
- ["godot_pool_string_array *", "p_self"],
+ ["godot_packed_string_array *", "p_self"],
["const godot_int", "p_idx"],
["const godot_string *", "p_data"]
]
},
{
- "name": "godot_pool_string_array_invert",
+ "name": "godot_packed_string_array_invert",
"return_type": "void",
"arguments": [
- ["godot_pool_string_array *", "p_self"]
+ ["godot_packed_string_array *", "p_self"]
]
},
{
- "name": "godot_pool_string_array_push_back",
+ "name": "godot_packed_string_array_push_back",
"return_type": "void",
"arguments": [
- ["godot_pool_string_array *", "p_self"],
+ ["godot_packed_string_array *", "p_self"],
["const godot_string *", "p_data"]
]
},
{
- "name": "godot_pool_string_array_remove",
+ "name": "godot_packed_string_array_remove",
"return_type": "void",
"arguments": [
- ["godot_pool_string_array *", "p_self"],
+ ["godot_packed_string_array *", "p_self"],
["const godot_int", "p_idx"]
]
},
{
- "name": "godot_pool_string_array_resize",
+ "name": "godot_packed_string_array_resize",
"return_type": "void",
"arguments": [
- ["godot_pool_string_array *", "p_self"],
+ ["godot_packed_string_array *", "p_self"],
["const godot_int", "p_size"]
]
},
{
- "name": "godot_pool_string_array_read",
- "return_type": "godot_pool_string_array_read_access *",
- "arguments": [
- ["const godot_pool_string_array *", "p_self"]
- ]
- },
- {
- "name": "godot_pool_string_array_write",
- "return_type": "godot_pool_string_array_write_access *",
- "arguments": [
- ["godot_pool_string_array *", "p_self"]
- ]
- },
- {
- "name": "godot_pool_string_array_set",
+ "name": "godot_packed_string_array_set",
"return_type": "void",
"arguments": [
- ["godot_pool_string_array *", "p_self"],
+ ["godot_packed_string_array *", "p_self"],
["const godot_int", "p_idx"],
["const godot_string *", "p_data"]
]
},
{
- "name": "godot_pool_string_array_get",
+ "name": "godot_packed_string_array_get",
"return_type": "godot_string",
"arguments": [
- ["const godot_pool_string_array *", "p_self"],
+ ["const godot_packed_string_array *", "p_self"],
["const godot_int", "p_idx"]
]
},
{
- "name": "godot_pool_string_array_size",
+ "name": "godot_packed_string_array_size",
"return_type": "godot_int",
"arguments": [
- ["const godot_pool_string_array *", "p_self"]
+ ["const godot_packed_string_array *", "p_self"]
]
},
{
- "name": "godot_pool_string_array_destroy",
+ "name": "godot_packed_string_array_destroy",
"return_type": "void",
"arguments": [
- ["godot_pool_string_array *", "p_self"]
+ ["godot_packed_string_array *", "p_self"]
]
},
{
- "name": "godot_pool_vector2_array_new",
+ "name": "godot_packed_vector2_array_new",
"return_type": "void",
"arguments": [
- ["godot_pool_vector2_array *", "r_dest"]
+ ["godot_packed_vector2_array *", "r_dest"]
]
},
{
- "name": "godot_pool_vector2_array_new_copy",
+ "name": "godot_packed_vector2_array_new_copy",
"return_type": "void",
"arguments": [
- ["godot_pool_vector2_array *", "r_dest"],
- ["const godot_pool_vector2_array *", "p_src"]
+ ["godot_packed_vector2_array *", "r_dest"],
+ ["const godot_packed_vector2_array *", "p_src"]
]
},
{
- "name": "godot_pool_vector2_array_new_with_array",
+ "name": "godot_packed_vector2_array_new_with_array",
"return_type": "void",
"arguments": [
- ["godot_pool_vector2_array *", "r_dest"],
+ ["godot_packed_vector2_array *", "r_dest"],
["const godot_array *", "p_a"]
]
},
{
- "name": "godot_pool_vector2_array_append",
+ "name": "godot_packed_vector2_array_append",
"return_type": "void",
"arguments": [
- ["godot_pool_vector2_array *", "p_self"],
+ ["godot_packed_vector2_array *", "p_self"],
["const godot_vector2 *", "p_data"]
]
},
{
- "name": "godot_pool_vector2_array_append_array",
+ "name": "godot_packed_vector2_array_append_array",
"return_type": "void",
"arguments": [
- ["godot_pool_vector2_array *", "p_self"],
- ["const godot_pool_vector2_array *", "p_array"]
+ ["godot_packed_vector2_array *", "p_self"],
+ ["const godot_packed_vector2_array *", "p_array"]
]
},
{
- "name": "godot_pool_vector2_array_insert",
+ "name": "godot_packed_vector2_array_insert",
"return_type": "godot_error",
"arguments": [
- ["godot_pool_vector2_array *", "p_self"],
+ ["godot_packed_vector2_array *", "p_self"],
["const godot_int", "p_idx"],
["const godot_vector2 *", "p_data"]
]
},
{
- "name": "godot_pool_vector2_array_invert",
+ "name": "godot_packed_vector2_array_invert",
"return_type": "void",
"arguments": [
- ["godot_pool_vector2_array *", "p_self"]
+ ["godot_packed_vector2_array *", "p_self"]
]
},
{
- "name": "godot_pool_vector2_array_push_back",
+ "name": "godot_packed_vector2_array_push_back",
"return_type": "void",
"arguments": [
- ["godot_pool_vector2_array *", "p_self"],
+ ["godot_packed_vector2_array *", "p_self"],
["const godot_vector2 *", "p_data"]
]
},
{
- "name": "godot_pool_vector2_array_remove",
+ "name": "godot_packed_vector2_array_remove",
"return_type": "void",
"arguments": [
- ["godot_pool_vector2_array *", "p_self"],
+ ["godot_packed_vector2_array *", "p_self"],
["const godot_int", "p_idx"]
]
},
{
- "name": "godot_pool_vector2_array_resize",
+ "name": "godot_packed_vector2_array_resize",
"return_type": "void",
"arguments": [
- ["godot_pool_vector2_array *", "p_self"],
+ ["godot_packed_vector2_array *", "p_self"],
["const godot_int", "p_size"]
]
},
{
- "name": "godot_pool_vector2_array_read",
- "return_type": "godot_pool_vector2_array_read_access *",
- "arguments": [
- ["const godot_pool_vector2_array *", "p_self"]
- ]
- },
- {
- "name": "godot_pool_vector2_array_write",
- "return_type": "godot_pool_vector2_array_write_access *",
- "arguments": [
- ["godot_pool_vector2_array *", "p_self"]
- ]
- },
- {
- "name": "godot_pool_vector2_array_set",
+ "name": "godot_packed_vector2_array_set",
"return_type": "void",
"arguments": [
- ["godot_pool_vector2_array *", "p_self"],
+ ["godot_packed_vector2_array *", "p_self"],
["const godot_int", "p_idx"],
["const godot_vector2 *", "p_data"]
]
},
{
- "name": "godot_pool_vector2_array_get",
+ "name": "godot_packed_vector2_array_get",
"return_type": "godot_vector2",
"arguments": [
- ["const godot_pool_vector2_array *", "p_self"],
+ ["const godot_packed_vector2_array *", "p_self"],
["const godot_int", "p_idx"]
]
},
{
- "name": "godot_pool_vector2_array_size",
+ "name": "godot_packed_vector2_array_size",
"return_type": "godot_int",
"arguments": [
- ["const godot_pool_vector2_array *", "p_self"]
+ ["const godot_packed_vector2_array *", "p_self"]
]
},
{
- "name": "godot_pool_vector2_array_destroy",
+ "name": "godot_packed_vector2_array_destroy",
"return_type": "void",
"arguments": [
- ["godot_pool_vector2_array *", "p_self"]
+ ["godot_packed_vector2_array *", "p_self"]
]
},
{
- "name": "godot_pool_vector3_array_new",
+ "name": "godot_packed_vector3_array_new",
"return_type": "void",
"arguments": [
- ["godot_pool_vector3_array *", "r_dest"]
+ ["godot_packed_vector3_array *", "r_dest"]
]
},
{
- "name": "godot_pool_vector3_array_new_copy",
+ "name": "godot_packed_vector3_array_new_copy",
"return_type": "void",
"arguments": [
- ["godot_pool_vector3_array *", "r_dest"],
- ["const godot_pool_vector3_array *", "p_src"]
+ ["godot_packed_vector3_array *", "r_dest"],
+ ["const godot_packed_vector3_array *", "p_src"]
]
},
{
- "name": "godot_pool_vector3_array_new_with_array",
+ "name": "godot_packed_vector3_array_new_with_array",
"return_type": "void",
"arguments": [
- ["godot_pool_vector3_array *", "r_dest"],
+ ["godot_packed_vector3_array *", "r_dest"],
["const godot_array *", "p_a"]
]
},
{
- "name": "godot_pool_vector3_array_append",
+ "name": "godot_packed_vector3_array_append",
"return_type": "void",
"arguments": [
- ["godot_pool_vector3_array *", "p_self"],
+ ["godot_packed_vector3_array *", "p_self"],
["const godot_vector3 *", "p_data"]
]
},
{
- "name": "godot_pool_vector3_array_append_array",
+ "name": "godot_packed_vector3_array_append_array",
"return_type": "void",
"arguments": [
- ["godot_pool_vector3_array *", "p_self"],
- ["const godot_pool_vector3_array *", "p_array"]
+ ["godot_packed_vector3_array *", "p_self"],
+ ["const godot_packed_vector3_array *", "p_array"]
]
},
{
- "name": "godot_pool_vector3_array_insert",
+ "name": "godot_packed_vector3_array_insert",
"return_type": "godot_error",
"arguments": [
- ["godot_pool_vector3_array *", "p_self"],
+ ["godot_packed_vector3_array *", "p_self"],
["const godot_int", "p_idx"],
["const godot_vector3 *", "p_data"]
]
},
{
- "name": "godot_pool_vector3_array_invert",
+ "name": "godot_packed_vector3_array_invert",
"return_type": "void",
"arguments": [
- ["godot_pool_vector3_array *", "p_self"]
+ ["godot_packed_vector3_array *", "p_self"]
]
},
{
- "name": "godot_pool_vector3_array_push_back",
+ "name": "godot_packed_vector3_array_push_back",
"return_type": "void",
"arguments": [
- ["godot_pool_vector3_array *", "p_self"],
+ ["godot_packed_vector3_array *", "p_self"],
["const godot_vector3 *", "p_data"]
]
},
{
- "name": "godot_pool_vector3_array_remove",
+ "name": "godot_packed_vector3_array_remove",
"return_type": "void",
"arguments": [
- ["godot_pool_vector3_array *", "p_self"],
+ ["godot_packed_vector3_array *", "p_self"],
["const godot_int", "p_idx"]
]
},
{
- "name": "godot_pool_vector3_array_resize",
+ "name": "godot_packed_vector3_array_resize",
"return_type": "void",
"arguments": [
- ["godot_pool_vector3_array *", "p_self"],
+ ["godot_packed_vector3_array *", "p_self"],
["const godot_int", "p_size"]
]
},
{
- "name": "godot_pool_vector3_array_read",
- "return_type": "godot_pool_vector3_array_read_access *",
- "arguments": [
- ["const godot_pool_vector3_array *", "p_self"]
- ]
- },
- {
- "name": "godot_pool_vector3_array_write",
- "return_type": "godot_pool_vector3_array_write_access *",
- "arguments": [
- ["godot_pool_vector3_array *", "p_self"]
- ]
- },
- {
- "name": "godot_pool_vector3_array_set",
+ "name": "godot_packed_vector3_array_set",
"return_type": "void",
"arguments": [
- ["godot_pool_vector3_array *", "p_self"],
+ ["godot_packed_vector3_array *", "p_self"],
["const godot_int", "p_idx"],
["const godot_vector3 *", "p_data"]
]
},
{
- "name": "godot_pool_vector3_array_get",
+ "name": "godot_packed_vector3_array_get",
"return_type": "godot_vector3",
"arguments": [
- ["const godot_pool_vector3_array *", "p_self"],
+ ["const godot_packed_vector3_array *", "p_self"],
["const godot_int", "p_idx"]
]
},
{
- "name": "godot_pool_vector3_array_size",
+ "name": "godot_packed_vector3_array_size",
"return_type": "godot_int",
"arguments": [
- ["const godot_pool_vector3_array *", "p_self"]
+ ["const godot_packed_vector3_array *", "p_self"]
]
},
{
- "name": "godot_pool_vector3_array_destroy",
+ "name": "godot_packed_vector3_array_destroy",
"return_type": "void",
"arguments": [
- ["godot_pool_vector3_array *", "p_self"]
+ ["godot_packed_vector3_array *", "p_self"]
]
},
{
- "name": "godot_pool_color_array_new",
+ "name": "godot_packed_color_array_new",
"return_type": "void",
"arguments": [
- ["godot_pool_color_array *", "r_dest"]
+ ["godot_packed_color_array *", "r_dest"]
]
},
{
- "name": "godot_pool_color_array_new_copy",
+ "name": "godot_packed_color_array_new_copy",
"return_type": "void",
"arguments": [
- ["godot_pool_color_array *", "r_dest"],
- ["const godot_pool_color_array *", "p_src"]
+ ["godot_packed_color_array *", "r_dest"],
+ ["const godot_packed_color_array *", "p_src"]
]
},
{
- "name": "godot_pool_color_array_new_with_array",
+ "name": "godot_packed_color_array_new_with_array",
"return_type": "void",
"arguments": [
- ["godot_pool_color_array *", "r_dest"],
+ ["godot_packed_color_array *", "r_dest"],
["const godot_array *", "p_a"]
]
},
{
- "name": "godot_pool_color_array_append",
+ "name": "godot_packed_color_array_append",
"return_type": "void",
"arguments": [
- ["godot_pool_color_array *", "p_self"],
+ ["godot_packed_color_array *", "p_self"],
["const godot_color *", "p_data"]
]
},
{
- "name": "godot_pool_color_array_append_array",
+ "name": "godot_packed_color_array_append_array",
"return_type": "void",
"arguments": [
- ["godot_pool_color_array *", "p_self"],
- ["const godot_pool_color_array *", "p_array"]
+ ["godot_packed_color_array *", "p_self"],
+ ["const godot_packed_color_array *", "p_array"]
]
},
{
- "name": "godot_pool_color_array_insert",
+ "name": "godot_packed_color_array_insert",
"return_type": "godot_error",
"arguments": [
- ["godot_pool_color_array *", "p_self"],
+ ["godot_packed_color_array *", "p_self"],
["const godot_int", "p_idx"],
["const godot_color *", "p_data"]
]
},
{
- "name": "godot_pool_color_array_invert",
+ "name": "godot_packed_color_array_invert",
"return_type": "void",
"arguments": [
- ["godot_pool_color_array *", "p_self"]
+ ["godot_packed_color_array *", "p_self"]
]
},
{
- "name": "godot_pool_color_array_push_back",
+ "name": "godot_packed_color_array_push_back",
"return_type": "void",
"arguments": [
- ["godot_pool_color_array *", "p_self"],
+ ["godot_packed_color_array *", "p_self"],
["const godot_color *", "p_data"]
]
},
{
- "name": "godot_pool_color_array_remove",
+ "name": "godot_packed_color_array_remove",
"return_type": "void",
"arguments": [
- ["godot_pool_color_array *", "p_self"],
+ ["godot_packed_color_array *", "p_self"],
["const godot_int", "p_idx"]
]
},
{
- "name": "godot_pool_color_array_resize",
+ "name": "godot_packed_color_array_resize",
"return_type": "void",
"arguments": [
- ["godot_pool_color_array *", "p_self"],
+ ["godot_packed_color_array *", "p_self"],
["const godot_int", "p_size"]
]
},
{
- "name": "godot_pool_color_array_read",
- "return_type": "godot_pool_color_array_read_access *",
- "arguments": [
- ["const godot_pool_color_array *", "p_self"]
- ]
- },
- {
- "name": "godot_pool_color_array_write",
- "return_type": "godot_pool_color_array_write_access *",
- "arguments": [
- ["godot_pool_color_array *", "p_self"]
- ]
- },
- {
- "name": "godot_pool_color_array_set",
+ "name": "godot_packed_color_array_set",
"return_type": "void",
"arguments": [
- ["godot_pool_color_array *", "p_self"],
+ ["godot_packed_color_array *", "p_self"],
["const godot_int", "p_idx"],
["const godot_color *", "p_data"]
]
},
{
- "name": "godot_pool_color_array_get",
+ "name": "godot_packed_color_array_get",
"return_type": "godot_color",
"arguments": [
- ["const godot_pool_color_array *", "p_self"],
+ ["const godot_packed_color_array *", "p_self"],
["const godot_int", "p_idx"]
]
},
{
- "name": "godot_pool_color_array_size",
+ "name": "godot_packed_color_array_size",
"return_type": "godot_int",
"arguments": [
- ["const godot_pool_color_array *", "p_self"]
- ]
- },
- {
- "name": "godot_pool_color_array_destroy",
- "return_type": "void",
- "arguments": [
- ["godot_pool_color_array *", "p_self"]
- ]
- },
- {
- "name": "godot_pool_byte_array_read_access_copy",
- "return_type": "godot_pool_byte_array_read_access *",
- "arguments": [
- ["const godot_pool_byte_array_read_access *", "p_read"]
- ]
- },
- {
- "name": "godot_pool_byte_array_read_access_ptr",
- "return_type": "const uint8_t *",
- "arguments": [
- ["const godot_pool_byte_array_read_access *", "p_read"]
- ]
- },
- {
- "name": "godot_pool_byte_array_read_access_operator_assign",
- "return_type": "void",
- "arguments": [
- ["godot_pool_byte_array_read_access *", "p_read"],
- ["godot_pool_byte_array_read_access *", "p_other"]
- ]
- },
- {
- "name": "godot_pool_byte_array_read_access_destroy",
- "return_type": "void",
- "arguments": [
- ["godot_pool_byte_array_read_access *", "p_read"]
- ]
- },
- {
- "name": "godot_pool_int_array_read_access_copy",
- "return_type": "godot_pool_int_array_read_access *",
- "arguments": [
- ["const godot_pool_int_array_read_access *", "p_read"]
- ]
- },
- {
- "name": "godot_pool_int_array_read_access_ptr",
- "return_type": "const godot_int *",
- "arguments": [
- ["const godot_pool_int_array_read_access *", "p_read"]
- ]
- },
- {
- "name": "godot_pool_int_array_read_access_operator_assign",
- "return_type": "void",
- "arguments": [
- ["godot_pool_int_array_read_access *", "p_read"],
- ["godot_pool_int_array_read_access *", "p_other"]
- ]
- },
- {
- "name": "godot_pool_int_array_read_access_destroy",
- "return_type": "void",
- "arguments": [
- ["godot_pool_int_array_read_access *", "p_read"]
- ]
- },
- {
- "name": "godot_pool_real_array_read_access_copy",
- "return_type": "godot_pool_real_array_read_access *",
- "arguments": [
- ["const godot_pool_real_array_read_access *", "p_read"]
- ]
- },
- {
- "name": "godot_pool_real_array_read_access_ptr",
- "return_type": "const godot_real *",
- "arguments": [
- ["const godot_pool_real_array_read_access *", "p_read"]
- ]
- },
- {
- "name": "godot_pool_real_array_read_access_operator_assign",
- "return_type": "void",
- "arguments": [
- ["godot_pool_real_array_read_access *", "p_read"],
- ["godot_pool_real_array_read_access *", "p_other"]
- ]
- },
- {
- "name": "godot_pool_real_array_read_access_destroy",
- "return_type": "void",
- "arguments": [
- ["godot_pool_real_array_read_access *", "p_read"]
- ]
- },
- {
- "name": "godot_pool_string_array_read_access_copy",
- "return_type": "godot_pool_string_array_read_access *",
- "arguments": [
- ["const godot_pool_string_array_read_access *", "p_read"]
- ]
- },
- {
- "name": "godot_pool_string_array_read_access_ptr",
- "return_type": "const godot_string *",
- "arguments": [
- ["const godot_pool_string_array_read_access *", "p_read"]
- ]
- },
- {
- "name": "godot_pool_string_array_read_access_operator_assign",
- "return_type": "void",
- "arguments": [
- ["godot_pool_string_array_read_access *", "p_read"],
- ["godot_pool_string_array_read_access *", "p_other"]
- ]
- },
- {
- "name": "godot_pool_string_array_read_access_destroy",
- "return_type": "void",
- "arguments": [
- ["godot_pool_string_array_read_access *", "p_read"]
- ]
- },
- {
- "name": "godot_pool_vector2_array_read_access_copy",
- "return_type": "godot_pool_vector2_array_read_access *",
- "arguments": [
- ["const godot_pool_vector2_array_read_access *", "p_read"]
- ]
- },
- {
- "name": "godot_pool_vector2_array_read_access_ptr",
- "return_type": "const godot_vector2 *",
- "arguments": [
- ["const godot_pool_vector2_array_read_access *", "p_read"]
- ]
- },
- {
- "name": "godot_pool_vector2_array_read_access_operator_assign",
- "return_type": "void",
- "arguments": [
- ["godot_pool_vector2_array_read_access *", "p_read"],
- ["godot_pool_vector2_array_read_access *", "p_other"]
- ]
- },
- {
- "name": "godot_pool_vector2_array_read_access_destroy",
- "return_type": "void",
- "arguments": [
- ["godot_pool_vector2_array_read_access *", "p_read"]
- ]
- },
- {
- "name": "godot_pool_vector3_array_read_access_copy",
- "return_type": "godot_pool_vector3_array_read_access *",
- "arguments": [
- ["const godot_pool_vector3_array_read_access *", "p_read"]
- ]
- },
- {
- "name": "godot_pool_vector3_array_read_access_ptr",
- "return_type": "const godot_vector3 *",
- "arguments": [
- ["const godot_pool_vector3_array_read_access *", "p_read"]
- ]
- },
- {
- "name": "godot_pool_vector3_array_read_access_operator_assign",
- "return_type": "void",
- "arguments": [
- ["godot_pool_vector3_array_read_access *", "p_read"],
- ["godot_pool_vector3_array_read_access *", "p_other"]
- ]
- },
- {
- "name": "godot_pool_vector3_array_read_access_destroy",
- "return_type": "void",
- "arguments": [
- ["godot_pool_vector3_array_read_access *", "p_read"]
- ]
- },
- {
- "name": "godot_pool_color_array_read_access_copy",
- "return_type": "godot_pool_color_array_read_access *",
- "arguments": [
- ["const godot_pool_color_array_read_access *", "p_read"]
- ]
- },
- {
- "name": "godot_pool_color_array_read_access_ptr",
- "return_type": "const godot_color *",
- "arguments": [
- ["const godot_pool_color_array_read_access *", "p_read"]
- ]
- },
- {
- "name": "godot_pool_color_array_read_access_operator_assign",
- "return_type": "void",
- "arguments": [
- ["godot_pool_color_array_read_access *", "p_read"],
- ["godot_pool_color_array_read_access *", "p_other"]
- ]
- },
- {
- "name": "godot_pool_color_array_read_access_destroy",
- "return_type": "void",
- "arguments": [
- ["godot_pool_color_array_read_access *", "p_read"]
- ]
- },
- {
- "name": "godot_pool_byte_array_write_access_copy",
- "return_type": "godot_pool_byte_array_write_access *",
- "arguments": [
- ["const godot_pool_byte_array_write_access *", "p_write"]
- ]
- },
- {
- "name": "godot_pool_byte_array_write_access_ptr",
- "return_type": "uint8_t *",
- "arguments": [
- ["const godot_pool_byte_array_write_access *", "p_write"]
- ]
- },
- {
- "name": "godot_pool_byte_array_write_access_operator_assign",
- "return_type": "void",
- "arguments": [
- ["godot_pool_byte_array_write_access *", "p_write"],
- ["godot_pool_byte_array_write_access *", "p_other"]
- ]
- },
- {
- "name": "godot_pool_byte_array_write_access_destroy",
- "return_type": "void",
- "arguments": [
- ["godot_pool_byte_array_write_access *", "p_write"]
- ]
- },
- {
- "name": "godot_pool_int_array_write_access_copy",
- "return_type": "godot_pool_int_array_write_access *",
- "arguments": [
- ["const godot_pool_int_array_write_access *", "p_write"]
- ]
- },
- {
- "name": "godot_pool_int_array_write_access_ptr",
- "return_type": "godot_int *",
- "arguments": [
- ["const godot_pool_int_array_write_access *", "p_write"]
- ]
- },
- {
- "name": "godot_pool_int_array_write_access_operator_assign",
- "return_type": "void",
- "arguments": [
- ["godot_pool_int_array_write_access *", "p_write"],
- ["godot_pool_int_array_write_access *", "p_other"]
- ]
- },
- {
- "name": "godot_pool_int_array_write_access_destroy",
- "return_type": "void",
- "arguments": [
- ["godot_pool_int_array_write_access *", "p_write"]
- ]
- },
- {
- "name": "godot_pool_real_array_write_access_copy",
- "return_type": "godot_pool_real_array_write_access *",
- "arguments": [
- ["const godot_pool_real_array_write_access *", "p_write"]
- ]
- },
- {
- "name": "godot_pool_real_array_write_access_ptr",
- "return_type": "godot_real *",
- "arguments": [
- ["const godot_pool_real_array_write_access *", "p_write"]
- ]
- },
- {
- "name": "godot_pool_real_array_write_access_operator_assign",
- "return_type": "void",
- "arguments": [
- ["godot_pool_real_array_write_access *", "p_write"],
- ["godot_pool_real_array_write_access *", "p_other"]
- ]
- },
- {
- "name": "godot_pool_real_array_write_access_destroy",
- "return_type": "void",
- "arguments": [
- ["godot_pool_real_array_write_access *", "p_write"]
- ]
- },
- {
- "name": "godot_pool_string_array_write_access_copy",
- "return_type": "godot_pool_string_array_write_access *",
- "arguments": [
- ["const godot_pool_string_array_write_access *", "p_write"]
- ]
- },
- {
- "name": "godot_pool_string_array_write_access_ptr",
- "return_type": "godot_string *",
- "arguments": [
- ["const godot_pool_string_array_write_access *", "p_write"]
- ]
- },
- {
- "name": "godot_pool_string_array_write_access_operator_assign",
- "return_type": "void",
- "arguments": [
- ["godot_pool_string_array_write_access *", "p_write"],
- ["godot_pool_string_array_write_access *", "p_other"]
- ]
- },
- {
- "name": "godot_pool_string_array_write_access_destroy",
- "return_type": "void",
- "arguments": [
- ["godot_pool_string_array_write_access *", "p_write"]
- ]
- },
- {
- "name": "godot_pool_vector2_array_write_access_copy",
- "return_type": "godot_pool_vector2_array_write_access *",
- "arguments": [
- ["const godot_pool_vector2_array_write_access *", "p_write"]
- ]
- },
- {
- "name": "godot_pool_vector2_array_write_access_ptr",
- "return_type": "godot_vector2 *",
- "arguments": [
- ["const godot_pool_vector2_array_write_access *", "p_write"]
- ]
- },
- {
- "name": "godot_pool_vector2_array_write_access_operator_assign",
- "return_type": "void",
- "arguments": [
- ["godot_pool_vector2_array_write_access *", "p_write"],
- ["godot_pool_vector2_array_write_access *", "p_other"]
- ]
- },
- {
- "name": "godot_pool_vector2_array_write_access_destroy",
- "return_type": "void",
- "arguments": [
- ["godot_pool_vector2_array_write_access *", "p_write"]
- ]
- },
- {
- "name": "godot_pool_vector3_array_write_access_copy",
- "return_type": "godot_pool_vector3_array_write_access *",
- "arguments": [
- ["const godot_pool_vector3_array_write_access *", "p_write"]
- ]
- },
- {
- "name": "godot_pool_vector3_array_write_access_ptr",
- "return_type": "godot_vector3 *",
- "arguments": [
- ["const godot_pool_vector3_array_write_access *", "p_write"]
- ]
- },
- {
- "name": "godot_pool_vector3_array_write_access_operator_assign",
- "return_type": "void",
- "arguments": [
- ["godot_pool_vector3_array_write_access *", "p_write"],
- ["godot_pool_vector3_array_write_access *", "p_other"]
- ]
- },
- {
- "name": "godot_pool_vector3_array_write_access_destroy",
- "return_type": "void",
- "arguments": [
- ["godot_pool_vector3_array_write_access *", "p_write"]
- ]
- },
- {
- "name": "godot_pool_color_array_write_access_copy",
- "return_type": "godot_pool_color_array_write_access *",
- "arguments": [
- ["const godot_pool_color_array_write_access *", "p_write"]
- ]
- },
- {
- "name": "godot_pool_color_array_write_access_ptr",
- "return_type": "godot_color *",
- "arguments": [
- ["const godot_pool_color_array_write_access *", "p_write"]
- ]
- },
- {
- "name": "godot_pool_color_array_write_access_operator_assign",
- "return_type": "void",
- "arguments": [
- ["godot_pool_color_array_write_access *", "p_write"],
- ["godot_pool_color_array_write_access *", "p_other"]
+ ["const godot_packed_color_array *", "p_self"]
]
},
{
- "name": "godot_pool_color_array_write_access_destroy",
+ "name": "godot_packed_color_array_destroy",
"return_type": "void",
"arguments": [
- ["godot_pool_color_array_write_access *", "p_write"]
+ ["godot_packed_color_array *", "p_self"]
]
},
{
@@ -2960,59 +2442,59 @@
]
},
{
- "name": "godot_array_new_pool_color_array",
+ "name": "godot_array_new_packed_color_array",
"return_type": "void",
"arguments": [
["godot_array *", "r_dest"],
- ["const godot_pool_color_array *", "p_pca"]
+ ["const godot_packed_color_array *", "p_pca"]
]
},
{
- "name": "godot_array_new_pool_vector3_array",
+ "name": "godot_array_new_packed_vector3_array",
"return_type": "void",
"arguments": [
["godot_array *", "r_dest"],
- ["const godot_pool_vector3_array *", "p_pv3a"]
+ ["const godot_packed_vector3_array *", "p_pv3a"]
]
},
{
- "name": "godot_array_new_pool_vector2_array",
+ "name": "godot_array_new_packed_vector2_array",
"return_type": "void",
"arguments": [
["godot_array *", "r_dest"],
- ["const godot_pool_vector2_array *", "p_pv2a"]
+ ["const godot_packed_vector2_array *", "p_pv2a"]
]
},
{
- "name": "godot_array_new_pool_string_array",
+ "name": "godot_array_new_packed_string_array",
"return_type": "void",
"arguments": [
["godot_array *", "r_dest"],
- ["const godot_pool_string_array *", "p_psa"]
+ ["const godot_packed_string_array *", "p_psa"]
]
},
{
- "name": "godot_array_new_pool_real_array",
+ "name": "godot_array_new_packed_real_array",
"return_type": "void",
"arguments": [
["godot_array *", "r_dest"],
- ["const godot_pool_real_array *", "p_pra"]
+ ["const godot_packed_real_array *", "p_pra"]
]
},
{
- "name": "godot_array_new_pool_int_array",
+ "name": "godot_array_new_packed_int_array",
"return_type": "void",
"arguments": [
["godot_array *", "r_dest"],
- ["const godot_pool_int_array *", "p_pia"]
+ ["const godot_packed_int_array *", "p_pia"]
]
},
{
- "name": "godot_array_new_pool_byte_array",
+ "name": "godot_array_new_packed_byte_array",
"return_type": "void",
"arguments": [
["godot_array *", "r_dest"],
- ["const godot_pool_byte_array *", "p_pba"]
+ ["const godot_packed_byte_array *", "p_pba"]
]
},
{
@@ -4569,59 +4051,59 @@
]
},
{
- "name": "godot_variant_new_pool_byte_array",
+ "name": "godot_variant_new_packed_byte_array",
"return_type": "void",
"arguments": [
["godot_variant *", "r_dest"],
- ["const godot_pool_byte_array *", "p_pba"]
+ ["const godot_packed_byte_array *", "p_pba"]
]
},
{
- "name": "godot_variant_new_pool_int_array",
+ "name": "godot_variant_new_packed_int_array",
"return_type": "void",
"arguments": [
["godot_variant *", "r_dest"],
- ["const godot_pool_int_array *", "p_pia"]
+ ["const godot_packed_int_array *", "p_pia"]
]
},
{
- "name": "godot_variant_new_pool_real_array",
+ "name": "godot_variant_new_packed_real_array",
"return_type": "void",
"arguments": [
["godot_variant *", "r_dest"],
- ["const godot_pool_real_array *", "p_pra"]
+ ["const godot_packed_real_array *", "p_pra"]
]
},
{
- "name": "godot_variant_new_pool_string_array",
+ "name": "godot_variant_new_packed_string_array",
"return_type": "void",
"arguments": [
["godot_variant *", "r_dest"],
- ["const godot_pool_string_array *", "p_psa"]
+ ["const godot_packed_string_array *", "p_psa"]
]
},
{
- "name": "godot_variant_new_pool_vector2_array",
+ "name": "godot_variant_new_packed_vector2_array",
"return_type": "void",
"arguments": [
["godot_variant *", "r_dest"],
- ["const godot_pool_vector2_array *", "p_pv2a"]
+ ["const godot_packed_vector2_array *", "p_pv2a"]
]
},
{
- "name": "godot_variant_new_pool_vector3_array",
+ "name": "godot_variant_new_packed_vector3_array",
"return_type": "void",
"arguments": [
["godot_variant *", "r_dest"],
- ["const godot_pool_vector3_array *", "p_pv3a"]
+ ["const godot_packed_vector3_array *", "p_pv3a"]
]
},
{
- "name": "godot_variant_new_pool_color_array",
+ "name": "godot_variant_new_packed_color_array",
"return_type": "void",
"arguments": [
["godot_variant *", "r_dest"],
- ["const godot_pool_color_array *", "p_pca"]
+ ["const godot_packed_color_array *", "p_pca"]
]
},
{
@@ -4765,50 +4247,50 @@
]
},
{
- "name": "godot_variant_as_pool_byte_array",
- "return_type": "godot_pool_byte_array",
+ "name": "godot_variant_as_packed_byte_array",
+ "return_type": "godot_packed_byte_array",
"arguments": [
["const godot_variant *", "p_self"]
]
},
{
- "name": "godot_variant_as_pool_int_array",
- "return_type": "godot_pool_int_array",
+ "name": "godot_variant_as_packed_int_array",
+ "return_type": "godot_packed_int_array",
"arguments": [
["const godot_variant *", "p_self"]
]
},
{
- "name": "godot_variant_as_pool_real_array",
- "return_type": "godot_pool_real_array",
+ "name": "godot_variant_as_packed_real_array",
+ "return_type": "godot_packed_real_array",
"arguments": [
["const godot_variant *", "p_self"]
]
},
{
- "name": "godot_variant_as_pool_string_array",
- "return_type": "godot_pool_string_array",
+ "name": "godot_variant_as_packed_string_array",
+ "return_type": "godot_packed_string_array",
"arguments": [
["const godot_variant *", "p_self"]
]
},
{
- "name": "godot_variant_as_pool_vector2_array",
- "return_type": "godot_pool_vector2_array",
+ "name": "godot_variant_as_packed_vector2_array",
+ "return_type": "godot_packed_vector2_array",
"arguments": [
["const godot_variant *", "p_self"]
]
},
{
- "name": "godot_variant_as_pool_vector3_array",
- "return_type": "godot_pool_vector3_array",
+ "name": "godot_variant_as_packed_vector3_array",
+ "return_type": "godot_packed_vector3_array",
"arguments": [
["const godot_variant *", "p_self"]
]
},
{
- "name": "godot_variant_as_pool_color_array",
- "return_type": "godot_pool_color_array",
+ "name": "godot_variant_as_packed_color_array",
+ "return_type": "godot_packed_color_array",
"arguments": [
["const godot_variant *", "p_self"]
]
@@ -5796,7 +5278,7 @@
},
{
"name": "godot_string_md5_buffer",
- "return_type": "godot_pool_byte_array",
+ "return_type": "godot_packed_byte_array",
"arguments": [
["const godot_string *", "p_self"]
]
@@ -5810,7 +5292,7 @@
},
{
"name": "godot_string_sha256_buffer",
- "return_type": "godot_pool_byte_array",
+ "return_type": "godot_packed_byte_array",
"arguments": [
["const godot_string *", "p_self"]
]
@@ -6482,7 +5964,7 @@
"name": "godot_arvr_blit",
"return_type": "void",
"arguments": [
- ["int", "p_eye"],
+ ["godot_int", "p_eye"],
["godot_rid *", "p_render_target"],
["godot_rect2 *", "p_screen_rect"]
]
diff --git a/modules/gdnative/gdnative_library_editor_plugin.cpp b/modules/gdnative/gdnative_library_editor_plugin.cpp
index 5ffab0f80e..b434bc8385 100644
--- a/modules/gdnative/gdnative_library_editor_plugin.cpp
+++ b/modules/gdnative/gdnative_library_editor_plugin.cpp
@@ -168,7 +168,7 @@ void GDNativeLibraryEditor::_on_library_selected(const String &file) {
_set_target_value(file_dialog->get_meta("section"), file_dialog->get_meta("target"), file);
}
-void GDNativeLibraryEditor::_on_dependencies_selected(const PoolStringArray &files) {
+void GDNativeLibraryEditor::_on_dependencies_selected(const PackedStringArray &files) {
_set_target_value(file_dialog->get_meta("section"), file_dialog->get_meta("target"), files);
}
@@ -359,7 +359,7 @@ GDNativeLibraryEditor::GDNativeLibraryEditor() {
filter_list->set_item_checked(idx, true);
idx += 1;
}
- filter_list->connect("index_pressed", this, "_on_filter_selected");
+ filter_list->connect_compat("index_pressed", this, "_on_filter_selected");
tree = memnew(Tree);
container->add_child(tree);
@@ -374,16 +374,16 @@ GDNativeLibraryEditor::GDNativeLibraryEditor() {
tree->set_column_title(2, TTR("Dependencies"));
tree->set_column_expand(3, false);
tree->set_column_min_width(3, int(110 * EDSCALE));
- tree->connect("button_pressed", this, "_on_item_button");
- tree->connect("item_collapsed", this, "_on_item_collapsed");
- tree->connect("item_activated", this, "_on_item_activated");
+ tree->connect_compat("button_pressed", this, "_on_item_button");
+ tree->connect_compat("item_collapsed", this, "_on_item_collapsed");
+ tree->connect_compat("item_activated", this, "_on_item_activated");
file_dialog = memnew(EditorFileDialog);
file_dialog->set_access(EditorFileDialog::ACCESS_RESOURCES);
file_dialog->set_resizable(true);
add_child(file_dialog);
- file_dialog->connect("file_selected", this, "_on_library_selected");
- file_dialog->connect("files_selected", this, "_on_dependencies_selected");
+ file_dialog->connect_compat("file_selected", this, "_on_library_selected");
+ file_dialog->connect_compat("files_selected", this, "_on_dependencies_selected");
new_architecture_dialog = memnew(ConfirmationDialog);
add_child(new_architecture_dialog);
@@ -392,7 +392,7 @@ GDNativeLibraryEditor::GDNativeLibraryEditor() {
new_architecture_dialog->add_child(new_architecture_input);
new_architecture_dialog->set_custom_minimum_size(Vector2(300, 80) * EDSCALE);
new_architecture_input->set_anchors_and_margins_preset(PRESET_HCENTER_WIDE, PRESET_MODE_MINSIZE, 5 * EDSCALE);
- new_architecture_dialog->get_ok()->connect("pressed", this, "_on_create_new_entry");
+ new_architecture_dialog->get_ok()->connect_compat("pressed", this, "_on_create_new_entry");
}
void GDNativeLibraryEditorPlugin::edit(Object *p_node) {
diff --git a/modules/gdnative/gdnative_library_editor_plugin.h b/modules/gdnative/gdnative_library_editor_plugin.h
index 7b59aaac38..b1274d08b3 100644
--- a/modules/gdnative/gdnative_library_editor_plugin.h
+++ b/modules/gdnative/gdnative_library_editor_plugin.h
@@ -77,7 +77,7 @@ protected:
void _update_tree();
void _on_item_button(Object *item, int column, int id);
void _on_library_selected(const String &file);
- void _on_dependencies_selected(const PoolStringArray &files);
+ void _on_dependencies_selected(const PackedStringArray &files);
void _on_filter_selected(int id);
void _on_item_collapsed(Object *p_item);
void _on_item_activated();
diff --git a/modules/gdnative/gdnative_library_singleton_editor.cpp b/modules/gdnative/gdnative_library_singleton_editor.cpp
index 17a7d5492a..e5eb3c44d0 100644
--- a/modules/gdnative/gdnative_library_singleton_editor.cpp
+++ b/modules/gdnative/gdnative_library_singleton_editor.cpp
@@ -207,8 +207,8 @@ GDNativeLibrarySingletonEditor::GDNativeLibrarySingletonEditor() {
libraries->set_hide_root(true);
add_margin_child(TTR("Libraries: "), libraries, true);
updating = false;
- libraries->connect("item_edited", this, "_item_edited");
- EditorFileSystem::get_singleton()->connect("filesystem_changed", this, "_discover_singletons");
+ libraries->connect_compat("item_edited", this, "_item_edited");
+ EditorFileSystem::get_singleton()->connect_compat("filesystem_changed", this, "_discover_singletons");
}
#endif // TOOLS_ENABLED
diff --git a/modules/gdnative/include/gdnative/array.h b/modules/gdnative/include/gdnative/array.h
index 36b5c77875..e3114e9348 100644
--- a/modules/gdnative/include/gdnative/array.h
+++ b/modules/gdnative/include/gdnative/array.h
@@ -62,13 +62,13 @@ extern "C" {
void GDAPI godot_array_new(godot_array *r_dest);
void GDAPI godot_array_new_copy(godot_array *r_dest, const godot_array *p_src);
-void GDAPI godot_array_new_pool_color_array(godot_array *r_dest, const godot_pool_color_array *p_pca);
-void GDAPI godot_array_new_pool_vector3_array(godot_array *r_dest, const godot_pool_vector3_array *p_pv3a);
-void GDAPI godot_array_new_pool_vector2_array(godot_array *r_dest, const godot_pool_vector2_array *p_pv2a);
-void GDAPI godot_array_new_pool_string_array(godot_array *r_dest, const godot_pool_string_array *p_psa);
-void GDAPI godot_array_new_pool_real_array(godot_array *r_dest, const godot_pool_real_array *p_pra);
-void GDAPI godot_array_new_pool_int_array(godot_array *r_dest, const godot_pool_int_array *p_pia);
-void GDAPI godot_array_new_pool_byte_array(godot_array *r_dest, const godot_pool_byte_array *p_pba);
+void GDAPI godot_array_new_packed_color_array(godot_array *r_dest, const godot_packed_color_array *p_pca);
+void GDAPI godot_array_new_packed_vector3_array(godot_array *r_dest, const godot_packed_vector3_array *p_pv3a);
+void GDAPI godot_array_new_packed_vector2_array(godot_array *r_dest, const godot_packed_vector2_array *p_pv2a);
+void GDAPI godot_array_new_packed_string_array(godot_array *r_dest, const godot_packed_string_array *p_psa);
+void GDAPI godot_array_new_packed_real_array(godot_array *r_dest, const godot_packed_real_array *p_pra);
+void GDAPI godot_array_new_packed_int_array(godot_array *r_dest, const godot_packed_int_array *p_pia);
+void GDAPI godot_array_new_packed_byte_array(godot_array *r_dest, const godot_packed_byte_array *p_pba);
void GDAPI godot_array_set(godot_array *p_self, const godot_int p_idx, const godot_variant *p_value);
diff --git a/modules/gdnative/include/gdnative/color.h b/modules/gdnative/include/gdnative/color.h
index 3f046b7f08..47c01dbb20 100644
--- a/modules/gdnative/include/gdnative/color.h
+++ b/modules/gdnative/include/gdnative/color.h
@@ -91,8 +91,6 @@ godot_int GDAPI godot_color_to_rgba64(const godot_color *p_self);
godot_int GDAPI godot_color_to_argb32(const godot_color *p_self);
-godot_real GDAPI godot_color_gray(const godot_color *p_self);
-
godot_color GDAPI godot_color_inverted(const godot_color *p_self);
godot_color GDAPI godot_color_contrasted(const godot_color *p_self);
diff --git a/modules/gdnative/include/gdnative/gdnative.h b/modules/gdnative/include/gdnative/gdnative.h
index e19a2ec149..6fdca30122 100644
--- a/modules/gdnative/include/gdnative/gdnative.h
+++ b/modules/gdnative/include/gdnative/gdnative.h
@@ -127,7 +127,7 @@ typedef bool godot_bool;
/////// int
-typedef int godot_int;
+typedef int64_t godot_int;
/////// real
@@ -282,9 +282,7 @@ void GDAPI godot_print_error(const char *p_description, const char *p_function,
void GDAPI godot_print_warning(const char *p_description, const char *p_function, const char *p_file, int p_line);
void GDAPI godot_print(const godot_string *p_message);
-// GDNATIVE CORE 1.0.1
-
-bool GDAPI godot_is_instance_valid(const godot_object *p_object);
+// GDNATIVE CORE 1.0.2?
//tags used for safe dynamic casting
void GDAPI *godot_get_class_tag(const godot_string_name *p_class);
diff --git a/modules/gdnative/include/gdnative/pool_arrays.h b/modules/gdnative/include/gdnative/pool_arrays.h
index 7d51b3cd5c..c610377f54 100644
--- a/modules/gdnative/include/gdnative/pool_arrays.h
+++ b/modules/gdnative/include/gdnative/pool_arrays.h
@@ -37,113 +37,81 @@ extern "C" {
#include <stdint.h>
-/////// Read Access
+/////// PackedByteArray
-#define GODOT_POOL_ARRAY_READ_ACCESS_SIZE 1
+#define GODOT_PACKED_BYTE_ARRAY_SIZE sizeof(void *)
+#ifndef GODOT_CORE_API_GODOT_PACKED_BYTE_ARRAY_TYPE_DEFINED
+#define GODOT_CORE_API_GODOT_PACKED_BYTE_ARRAY_TYPE_DEFINED
typedef struct {
- uint8_t _dont_touch_that[GODOT_POOL_ARRAY_READ_ACCESS_SIZE];
-} godot_pool_array_read_access;
-
-typedef godot_pool_array_read_access godot_pool_byte_array_read_access;
-typedef godot_pool_array_read_access godot_pool_int_array_read_access;
-typedef godot_pool_array_read_access godot_pool_real_array_read_access;
-typedef godot_pool_array_read_access godot_pool_string_array_read_access;
-typedef godot_pool_array_read_access godot_pool_vector2_array_read_access;
-typedef godot_pool_array_read_access godot_pool_vector3_array_read_access;
-typedef godot_pool_array_read_access godot_pool_color_array_read_access;
-
-/////// Write Access
-
-#define GODOT_POOL_ARRAY_WRITE_ACCESS_SIZE 1
-
-typedef struct {
- uint8_t _dont_touch_that[GODOT_POOL_ARRAY_WRITE_ACCESS_SIZE];
-} godot_pool_array_write_access;
-
-typedef godot_pool_array_write_access godot_pool_byte_array_write_access;
-typedef godot_pool_array_write_access godot_pool_int_array_write_access;
-typedef godot_pool_array_write_access godot_pool_real_array_write_access;
-typedef godot_pool_array_write_access godot_pool_string_array_write_access;
-typedef godot_pool_array_write_access godot_pool_vector2_array_write_access;
-typedef godot_pool_array_write_access godot_pool_vector3_array_write_access;
-typedef godot_pool_array_write_access godot_pool_color_array_write_access;
-
-/////// PoolByteArray
-
-#define GODOT_POOL_BYTE_ARRAY_SIZE sizeof(void *)
-
-#ifndef GODOT_CORE_API_GODOT_POOL_BYTE_ARRAY_TYPE_DEFINED
-#define GODOT_CORE_API_GODOT_POOL_BYTE_ARRAY_TYPE_DEFINED
-typedef struct {
- uint8_t _dont_touch_that[GODOT_POOL_BYTE_ARRAY_SIZE];
-} godot_pool_byte_array;
+ uint8_t _dont_touch_that[GODOT_PACKED_BYTE_ARRAY_SIZE];
+} godot_packed_byte_array;
#endif
-/////// PoolIntArray
+/////// PackedInt32Array
-#define GODOT_POOL_INT_ARRAY_SIZE sizeof(void *)
+#define GODOT_PACKED_INT_ARRAY_SIZE sizeof(void *)
-#ifndef GODOT_CORE_API_GODOT_POOL_INT_ARRAY_TYPE_DEFINED
-#define GODOT_CORE_API_GODOT_POOL_INT_ARRAY_TYPE_DEFINED
+#ifndef GODOT_CORE_API_GODOT_PACKED_INT_ARRAY_TYPE_DEFINED
+#define GODOT_CORE_API_GODOT_PACKED_INT_ARRAY_TYPE_DEFINED
typedef struct {
- uint8_t _dont_touch_that[GODOT_POOL_INT_ARRAY_SIZE];
-} godot_pool_int_array;
+ uint8_t _dont_touch_that[GODOT_PACKED_INT_ARRAY_SIZE];
+} godot_packed_int_array;
#endif
-/////// PoolRealArray
+/////// PackedFloat32Array
-#define GODOT_POOL_REAL_ARRAY_SIZE sizeof(void *)
+#define GODOT_PACKED_REAL_ARRAY_SIZE sizeof(void *)
-#ifndef GODOT_CORE_API_GODOT_POOL_REAL_ARRAY_TYPE_DEFINED
-#define GODOT_CORE_API_GODOT_POOL_REAL_ARRAY_TYPE_DEFINED
+#ifndef GODOT_CORE_API_GODOT_PACKED_REAL_ARRAY_TYPE_DEFINED
+#define GODOT_CORE_API_GODOT_PACKED_REAL_ARRAY_TYPE_DEFINED
typedef struct {
- uint8_t _dont_touch_that[GODOT_POOL_REAL_ARRAY_SIZE];
-} godot_pool_real_array;
+ uint8_t _dont_touch_that[GODOT_PACKED_REAL_ARRAY_SIZE];
+} godot_packed_real_array;
#endif
-/////// PoolStringArray
+/////// PackedStringArray
-#define GODOT_POOL_STRING_ARRAY_SIZE sizeof(void *)
+#define GODOT_PACKED_STRING_ARRAY_SIZE sizeof(void *)
-#ifndef GODOT_CORE_API_GODOT_POOL_STRING_ARRAY_TYPE_DEFINED
-#define GODOT_CORE_API_GODOT_POOL_STRING_ARRAY_TYPE_DEFINED
+#ifndef GODOT_CORE_API_GODOT_PACKED_STRING_ARRAY_TYPE_DEFINED
+#define GODOT_CORE_API_GODOT_PACKED_STRING_ARRAY_TYPE_DEFINED
typedef struct {
- uint8_t _dont_touch_that[GODOT_POOL_STRING_ARRAY_SIZE];
-} godot_pool_string_array;
+ uint8_t _dont_touch_that[GODOT_PACKED_STRING_ARRAY_SIZE];
+} godot_packed_string_array;
#endif
-/////// PoolVector2Array
+/////// PackedVector2Array
-#define GODOT_POOL_VECTOR2_ARRAY_SIZE sizeof(void *)
+#define GODOT_PACKED_VECTOR2_ARRAY_SIZE sizeof(void *)
-#ifndef GODOT_CORE_API_GODOT_POOL_VECTOR2_ARRAY_TYPE_DEFINED
-#define GODOT_CORE_API_GODOT_POOL_VECTOR2_ARRAY_TYPE_DEFINED
+#ifndef GODOT_CORE_API_GODOT_PACKED_VECTOR2_ARRAY_TYPE_DEFINED
+#define GODOT_CORE_API_GODOT_PACKED_VECTOR2_ARRAY_TYPE_DEFINED
typedef struct {
- uint8_t _dont_touch_that[GODOT_POOL_VECTOR2_ARRAY_SIZE];
-} godot_pool_vector2_array;
+ uint8_t _dont_touch_that[GODOT_PACKED_VECTOR2_ARRAY_SIZE];
+} godot_packed_vector2_array;
#endif
-/////// PoolVector3Array
+/////// PackedVector3Array
-#define GODOT_POOL_VECTOR3_ARRAY_SIZE sizeof(void *)
+#define GODOT_PACKED_VECTOR3_ARRAY_SIZE sizeof(void *)
-#ifndef GODOT_CORE_API_GODOT_POOL_VECTOR3_ARRAY_TYPE_DEFINED
-#define GODOT_CORE_API_GODOT_POOL_VECTOR3_ARRAY_TYPE_DEFINED
+#ifndef GODOT_CORE_API_GODOT_PACKED_VECTOR3_ARRAY_TYPE_DEFINED
+#define GODOT_CORE_API_GODOT_PACKED_VECTOR3_ARRAY_TYPE_DEFINED
typedef struct {
- uint8_t _dont_touch_that[GODOT_POOL_VECTOR3_ARRAY_SIZE];
-} godot_pool_vector3_array;
+ uint8_t _dont_touch_that[GODOT_PACKED_VECTOR3_ARRAY_SIZE];
+} godot_packed_vector3_array;
#endif
-/////// PoolColorArray
+/////// PackedColorArray
-#define GODOT_POOL_COLOR_ARRAY_SIZE sizeof(void *)
+#define GODOT_PACKED_COLOR_ARRAY_SIZE sizeof(void *)
-#ifndef GODOT_CORE_API_GODOT_POOL_COLOR_ARRAY_TYPE_DEFINED
-#define GODOT_CORE_API_GODOT_POOL_COLOR_ARRAY_TYPE_DEFINED
+#ifndef GODOT_CORE_API_GODOT_PACKED_COLOR_ARRAY_TYPE_DEFINED
+#define GODOT_CORE_API_GODOT_PACKED_COLOR_ARRAY_TYPE_DEFINED
typedef struct {
- uint8_t _dont_touch_that[GODOT_POOL_COLOR_ARRAY_SIZE];
-} godot_pool_color_array;
+ uint8_t _dont_touch_that[GODOT_PACKED_COLOR_ARRAY_SIZE];
+} godot_packed_color_array;
#endif
// reduce extern "C" nesting for VS2013
@@ -164,312 +132,206 @@ extern "C" {
// byte
-void GDAPI godot_pool_byte_array_new(godot_pool_byte_array *r_dest);
-void GDAPI godot_pool_byte_array_new_copy(godot_pool_byte_array *r_dest, const godot_pool_byte_array *p_src);
-void GDAPI godot_pool_byte_array_new_with_array(godot_pool_byte_array *r_dest, const godot_array *p_a);
+void GDAPI godot_packed_byte_array_new(godot_packed_byte_array *r_dest);
+void GDAPI godot_packed_byte_array_new_copy(godot_packed_byte_array *r_dest, const godot_packed_byte_array *p_src);
+void GDAPI godot_packed_byte_array_new_with_array(godot_packed_byte_array *r_dest, const godot_array *p_a);
-void GDAPI godot_pool_byte_array_append(godot_pool_byte_array *p_self, const uint8_t p_data);
+void GDAPI godot_packed_byte_array_append(godot_packed_byte_array *p_self, const uint8_t p_data);
-void GDAPI godot_pool_byte_array_append_array(godot_pool_byte_array *p_self, const godot_pool_byte_array *p_array);
+void GDAPI godot_packed_byte_array_append_array(godot_packed_byte_array *p_self, const godot_packed_byte_array *p_array);
-godot_error GDAPI godot_pool_byte_array_insert(godot_pool_byte_array *p_self, const godot_int p_idx, const uint8_t p_data);
+godot_error GDAPI godot_packed_byte_array_insert(godot_packed_byte_array *p_self, const godot_int p_idx, const uint8_t p_data);
-void GDAPI godot_pool_byte_array_invert(godot_pool_byte_array *p_self);
+void GDAPI godot_packed_byte_array_invert(godot_packed_byte_array *p_self);
-void GDAPI godot_pool_byte_array_push_back(godot_pool_byte_array *p_self, const uint8_t p_data);
+void GDAPI godot_packed_byte_array_push_back(godot_packed_byte_array *p_self, const uint8_t p_data);
-void GDAPI godot_pool_byte_array_remove(godot_pool_byte_array *p_self, const godot_int p_idx);
+void GDAPI godot_packed_byte_array_remove(godot_packed_byte_array *p_self, const godot_int p_idx);
-void GDAPI godot_pool_byte_array_resize(godot_pool_byte_array *p_self, const godot_int p_size);
+void GDAPI godot_packed_byte_array_resize(godot_packed_byte_array *p_self, const godot_int p_size);
-godot_pool_byte_array_read_access GDAPI *godot_pool_byte_array_read(const godot_pool_byte_array *p_self);
+void GDAPI godot_packed_byte_array_set(godot_packed_byte_array *p_self, const godot_int p_idx, const uint8_t p_data);
+uint8_t GDAPI godot_packed_byte_array_get(const godot_packed_byte_array *p_self, const godot_int p_idx);
-godot_pool_byte_array_write_access GDAPI *godot_pool_byte_array_write(godot_pool_byte_array *p_self);
+godot_int GDAPI godot_packed_byte_array_size(const godot_packed_byte_array *p_self);
-void GDAPI godot_pool_byte_array_set(godot_pool_byte_array *p_self, const godot_int p_idx, const uint8_t p_data);
-uint8_t GDAPI godot_pool_byte_array_get(const godot_pool_byte_array *p_self, const godot_int p_idx);
+godot_bool GDAPI godot_packed_byte_array_empty(const godot_packed_byte_array *p_self);
-godot_int GDAPI godot_pool_byte_array_size(const godot_pool_byte_array *p_self);
-
-godot_bool GDAPI godot_pool_byte_array_empty(const godot_pool_byte_array *p_self);
-
-void GDAPI godot_pool_byte_array_destroy(godot_pool_byte_array *p_self);
+void GDAPI godot_packed_byte_array_destroy(godot_packed_byte_array *p_self);
// int
-void GDAPI godot_pool_int_array_new(godot_pool_int_array *r_dest);
-void GDAPI godot_pool_int_array_new_copy(godot_pool_int_array *r_dest, const godot_pool_int_array *p_src);
-void GDAPI godot_pool_int_array_new_with_array(godot_pool_int_array *r_dest, const godot_array *p_a);
-
-void GDAPI godot_pool_int_array_append(godot_pool_int_array *p_self, const godot_int p_data);
+void GDAPI godot_packed_int_array_new(godot_packed_int_array *r_dest);
+void GDAPI godot_packed_int_array_new_copy(godot_packed_int_array *r_dest, const godot_packed_int_array *p_src);
+void GDAPI godot_packed_int_array_new_with_array(godot_packed_int_array *r_dest, const godot_array *p_a);
-void GDAPI godot_pool_int_array_append_array(godot_pool_int_array *p_self, const godot_pool_int_array *p_array);
+void GDAPI godot_packed_int_array_append(godot_packed_int_array *p_self, const godot_int p_data);
-godot_error GDAPI godot_pool_int_array_insert(godot_pool_int_array *p_self, const godot_int p_idx, const godot_int p_data);
+void GDAPI godot_packed_int_array_append_array(godot_packed_int_array *p_self, const godot_packed_int_array *p_array);
-void GDAPI godot_pool_int_array_invert(godot_pool_int_array *p_self);
+godot_error GDAPI godot_packed_int_array_insert(godot_packed_int_array *p_self, const godot_int p_idx, const godot_int p_data);
-void GDAPI godot_pool_int_array_push_back(godot_pool_int_array *p_self, const godot_int p_data);
+void GDAPI godot_packed_int_array_invert(godot_packed_int_array *p_self);
-void GDAPI godot_pool_int_array_remove(godot_pool_int_array *p_self, const godot_int p_idx);
+void GDAPI godot_packed_int_array_push_back(godot_packed_int_array *p_self, const godot_int p_data);
-void GDAPI godot_pool_int_array_resize(godot_pool_int_array *p_self, const godot_int p_size);
+void GDAPI godot_packed_int_array_remove(godot_packed_int_array *p_self, const godot_int p_idx);
-godot_pool_int_array_read_access GDAPI *godot_pool_int_array_read(const godot_pool_int_array *p_self);
+void GDAPI godot_packed_int_array_resize(godot_packed_int_array *p_self, const godot_int p_size);
-godot_pool_int_array_write_access GDAPI *godot_pool_int_array_write(godot_pool_int_array *p_self);
+void GDAPI godot_packed_int_array_set(godot_packed_int_array *p_self, const godot_int p_idx, const godot_int p_data);
+godot_int GDAPI godot_packed_int_array_get(const godot_packed_int_array *p_self, const godot_int p_idx);
-void GDAPI godot_pool_int_array_set(godot_pool_int_array *p_self, const godot_int p_idx, const godot_int p_data);
-godot_int GDAPI godot_pool_int_array_get(const godot_pool_int_array *p_self, const godot_int p_idx);
+godot_int GDAPI godot_packed_int_array_size(const godot_packed_int_array *p_self);
-godot_int GDAPI godot_pool_int_array_size(const godot_pool_int_array *p_self);
+godot_bool GDAPI godot_packed_int_array_empty(const godot_packed_int_array *p_self);
-godot_bool GDAPI godot_pool_int_array_empty(const godot_pool_int_array *p_self);
-
-void GDAPI godot_pool_int_array_destroy(godot_pool_int_array *p_self);
+void GDAPI godot_packed_int_array_destroy(godot_packed_int_array *p_self);
// real
-void GDAPI godot_pool_real_array_new(godot_pool_real_array *r_dest);
-void GDAPI godot_pool_real_array_new_copy(godot_pool_real_array *r_dest, const godot_pool_real_array *p_src);
-void GDAPI godot_pool_real_array_new_with_array(godot_pool_real_array *r_dest, const godot_array *p_a);
-
-void GDAPI godot_pool_real_array_append(godot_pool_real_array *p_self, const godot_real p_data);
+void GDAPI godot_packed_real_array_new(godot_packed_real_array *r_dest);
+void GDAPI godot_packed_real_array_new_copy(godot_packed_real_array *r_dest, const godot_packed_real_array *p_src);
+void GDAPI godot_packed_real_array_new_with_array(godot_packed_real_array *r_dest, const godot_array *p_a);
-void GDAPI godot_pool_real_array_append_array(godot_pool_real_array *p_self, const godot_pool_real_array *p_array);
+void GDAPI godot_packed_real_array_append(godot_packed_real_array *p_self, const godot_real p_data);
-godot_error GDAPI godot_pool_real_array_insert(godot_pool_real_array *p_self, const godot_int p_idx, const godot_real p_data);
+void GDAPI godot_packed_real_array_append_array(godot_packed_real_array *p_self, const godot_packed_real_array *p_array);
-void GDAPI godot_pool_real_array_invert(godot_pool_real_array *p_self);
+godot_error GDAPI godot_packed_real_array_insert(godot_packed_real_array *p_self, const godot_int p_idx, const godot_real p_data);
-void GDAPI godot_pool_real_array_push_back(godot_pool_real_array *p_self, const godot_real p_data);
+void GDAPI godot_packed_real_array_invert(godot_packed_real_array *p_self);
-void GDAPI godot_pool_real_array_remove(godot_pool_real_array *p_self, const godot_int p_idx);
+void GDAPI godot_packed_real_array_push_back(godot_packed_real_array *p_self, const godot_real p_data);
-void GDAPI godot_pool_real_array_resize(godot_pool_real_array *p_self, const godot_int p_size);
+void GDAPI godot_packed_real_array_remove(godot_packed_real_array *p_self, const godot_int p_idx);
-godot_pool_real_array_read_access GDAPI *godot_pool_real_array_read(const godot_pool_real_array *p_self);
+void GDAPI godot_packed_real_array_resize(godot_packed_real_array *p_self, const godot_int p_size);
-godot_pool_real_array_write_access GDAPI *godot_pool_real_array_write(godot_pool_real_array *p_self);
+void GDAPI godot_packed_real_array_set(godot_packed_real_array *p_self, const godot_int p_idx, const godot_real p_data);
+godot_real GDAPI godot_packed_real_array_get(const godot_packed_real_array *p_self, const godot_int p_idx);
-void GDAPI godot_pool_real_array_set(godot_pool_real_array *p_self, const godot_int p_idx, const godot_real p_data);
-godot_real GDAPI godot_pool_real_array_get(const godot_pool_real_array *p_self, const godot_int p_idx);
+godot_int GDAPI godot_packed_real_array_size(const godot_packed_real_array *p_self);
-godot_int GDAPI godot_pool_real_array_size(const godot_pool_real_array *p_self);
+godot_bool GDAPI godot_packed_real_array_empty(const godot_packed_real_array *p_self);
-godot_bool GDAPI godot_pool_real_array_empty(const godot_pool_real_array *p_self);
-
-void GDAPI godot_pool_real_array_destroy(godot_pool_real_array *p_self);
+void GDAPI godot_packed_real_array_destroy(godot_packed_real_array *p_self);
// string
-void GDAPI godot_pool_string_array_new(godot_pool_string_array *r_dest);
-void GDAPI godot_pool_string_array_new_copy(godot_pool_string_array *r_dest, const godot_pool_string_array *p_src);
-void GDAPI godot_pool_string_array_new_with_array(godot_pool_string_array *r_dest, const godot_array *p_a);
-
-void GDAPI godot_pool_string_array_append(godot_pool_string_array *p_self, const godot_string *p_data);
-
-void GDAPI godot_pool_string_array_append_array(godot_pool_string_array *p_self, const godot_pool_string_array *p_array);
+void GDAPI godot_packed_string_array_new(godot_packed_string_array *r_dest);
+void GDAPI godot_packed_string_array_new_copy(godot_packed_string_array *r_dest, const godot_packed_string_array *p_src);
+void GDAPI godot_packed_string_array_new_with_array(godot_packed_string_array *r_dest, const godot_array *p_a);
-godot_error GDAPI godot_pool_string_array_insert(godot_pool_string_array *p_self, const godot_int p_idx, const godot_string *p_data);
+void GDAPI godot_packed_string_array_append(godot_packed_string_array *p_self, const godot_string *p_data);
-void GDAPI godot_pool_string_array_invert(godot_pool_string_array *p_self);
+void GDAPI godot_packed_string_array_append_array(godot_packed_string_array *p_self, const godot_packed_string_array *p_array);
-void GDAPI godot_pool_string_array_push_back(godot_pool_string_array *p_self, const godot_string *p_data);
+godot_error GDAPI godot_packed_string_array_insert(godot_packed_string_array *p_self, const godot_int p_idx, const godot_string *p_data);
-void GDAPI godot_pool_string_array_remove(godot_pool_string_array *p_self, const godot_int p_idx);
+void GDAPI godot_packed_string_array_invert(godot_packed_string_array *p_self);
-void GDAPI godot_pool_string_array_resize(godot_pool_string_array *p_self, const godot_int p_size);
+void GDAPI godot_packed_string_array_push_back(godot_packed_string_array *p_self, const godot_string *p_data);
-godot_pool_string_array_read_access GDAPI *godot_pool_string_array_read(const godot_pool_string_array *p_self);
+void GDAPI godot_packed_string_array_remove(godot_packed_string_array *p_self, const godot_int p_idx);
-godot_pool_string_array_write_access GDAPI *godot_pool_string_array_write(godot_pool_string_array *p_self);
+void GDAPI godot_packed_string_array_resize(godot_packed_string_array *p_self, const godot_int p_size);
-void GDAPI godot_pool_string_array_set(godot_pool_string_array *p_self, const godot_int p_idx, const godot_string *p_data);
-godot_string GDAPI godot_pool_string_array_get(const godot_pool_string_array *p_self, const godot_int p_idx);
+void GDAPI godot_packed_string_array_set(godot_packed_string_array *p_self, const godot_int p_idx, const godot_string *p_data);
+godot_string GDAPI godot_packed_string_array_get(const godot_packed_string_array *p_self, const godot_int p_idx);
-godot_int GDAPI godot_pool_string_array_size(const godot_pool_string_array *p_self);
+godot_int GDAPI godot_packed_string_array_size(const godot_packed_string_array *p_self);
-godot_bool GDAPI godot_pool_string_array_empty(const godot_pool_string_array *p_self);
+godot_bool GDAPI godot_packed_string_array_empty(const godot_packed_string_array *p_self);
-void GDAPI godot_pool_string_array_destroy(godot_pool_string_array *p_self);
+void GDAPI godot_packed_string_array_destroy(godot_packed_string_array *p_self);
// vector2
-void GDAPI godot_pool_vector2_array_new(godot_pool_vector2_array *r_dest);
-void GDAPI godot_pool_vector2_array_new_copy(godot_pool_vector2_array *r_dest, const godot_pool_vector2_array *p_src);
-void GDAPI godot_pool_vector2_array_new_with_array(godot_pool_vector2_array *r_dest, const godot_array *p_a);
-
-void GDAPI godot_pool_vector2_array_append(godot_pool_vector2_array *p_self, const godot_vector2 *p_data);
-
-void GDAPI godot_pool_vector2_array_append_array(godot_pool_vector2_array *p_self, const godot_pool_vector2_array *p_array);
+void GDAPI godot_packed_vector2_array_new(godot_packed_vector2_array *r_dest);
+void GDAPI godot_packed_vector2_array_new_copy(godot_packed_vector2_array *r_dest, const godot_packed_vector2_array *p_src);
+void GDAPI godot_packed_vector2_array_new_with_array(godot_packed_vector2_array *r_dest, const godot_array *p_a);
-godot_error GDAPI godot_pool_vector2_array_insert(godot_pool_vector2_array *p_self, const godot_int p_idx, const godot_vector2 *p_data);
+void GDAPI godot_packed_vector2_array_append(godot_packed_vector2_array *p_self, const godot_vector2 *p_data);
-void GDAPI godot_pool_vector2_array_invert(godot_pool_vector2_array *p_self);
+void GDAPI godot_packed_vector2_array_append_array(godot_packed_vector2_array *p_self, const godot_packed_vector2_array *p_array);
-void GDAPI godot_pool_vector2_array_push_back(godot_pool_vector2_array *p_self, const godot_vector2 *p_data);
+godot_error GDAPI godot_packed_vector2_array_insert(godot_packed_vector2_array *p_self, const godot_int p_idx, const godot_vector2 *p_data);
-void GDAPI godot_pool_vector2_array_remove(godot_pool_vector2_array *p_self, const godot_int p_idx);
+void GDAPI godot_packed_vector2_array_invert(godot_packed_vector2_array *p_self);
-void GDAPI godot_pool_vector2_array_resize(godot_pool_vector2_array *p_self, const godot_int p_size);
+void GDAPI godot_packed_vector2_array_push_back(godot_packed_vector2_array *p_self, const godot_vector2 *p_data);
-godot_pool_vector2_array_read_access GDAPI *godot_pool_vector2_array_read(const godot_pool_vector2_array *p_self);
+void GDAPI godot_packed_vector2_array_remove(godot_packed_vector2_array *p_self, const godot_int p_idx);
-godot_pool_vector2_array_write_access GDAPI *godot_pool_vector2_array_write(godot_pool_vector2_array *p_self);
+void GDAPI godot_packed_vector2_array_resize(godot_packed_vector2_array *p_self, const godot_int p_size);
-void GDAPI godot_pool_vector2_array_set(godot_pool_vector2_array *p_self, const godot_int p_idx, const godot_vector2 *p_data);
-godot_vector2 GDAPI godot_pool_vector2_array_get(const godot_pool_vector2_array *p_self, const godot_int p_idx);
+void GDAPI godot_packed_vector2_array_set(godot_packed_vector2_array *p_self, const godot_int p_idx, const godot_vector2 *p_data);
+godot_vector2 GDAPI godot_packed_vector2_array_get(const godot_packed_vector2_array *p_self, const godot_int p_idx);
-godot_int GDAPI godot_pool_vector2_array_size(const godot_pool_vector2_array *p_self);
+godot_int GDAPI godot_packed_vector2_array_size(const godot_packed_vector2_array *p_self);
-godot_bool GDAPI godot_pool_vector2_array_empty(const godot_pool_vector2_array *p_self);
+godot_bool GDAPI godot_packed_vector2_array_empty(const godot_packed_vector2_array *p_self);
-void GDAPI godot_pool_vector2_array_destroy(godot_pool_vector2_array *p_self);
+void GDAPI godot_packed_vector2_array_destroy(godot_packed_vector2_array *p_self);
// vector3
-void GDAPI godot_pool_vector3_array_new(godot_pool_vector3_array *r_dest);
-void GDAPI godot_pool_vector3_array_new_copy(godot_pool_vector3_array *r_dest, const godot_pool_vector3_array *p_src);
-void GDAPI godot_pool_vector3_array_new_with_array(godot_pool_vector3_array *r_dest, const godot_array *p_a);
+void GDAPI godot_packed_vector3_array_new(godot_packed_vector3_array *r_dest);
+void GDAPI godot_packed_vector3_array_new_copy(godot_packed_vector3_array *r_dest, const godot_packed_vector3_array *p_src);
+void GDAPI godot_packed_vector3_array_new_with_array(godot_packed_vector3_array *r_dest, const godot_array *p_a);
-void GDAPI godot_pool_vector3_array_append(godot_pool_vector3_array *p_self, const godot_vector3 *p_data);
+void GDAPI godot_packed_vector3_array_append(godot_packed_vector3_array *p_self, const godot_vector3 *p_data);
-void GDAPI godot_pool_vector3_array_append_array(godot_pool_vector3_array *p_self, const godot_pool_vector3_array *p_array);
+void GDAPI godot_packed_vector3_array_append_array(godot_packed_vector3_array *p_self, const godot_packed_vector3_array *p_array);
-godot_error GDAPI godot_pool_vector3_array_insert(godot_pool_vector3_array *p_self, const godot_int p_idx, const godot_vector3 *p_data);
+godot_error GDAPI godot_packed_vector3_array_insert(godot_packed_vector3_array *p_self, const godot_int p_idx, const godot_vector3 *p_data);
-void GDAPI godot_pool_vector3_array_invert(godot_pool_vector3_array *p_self);
+void GDAPI godot_packed_vector3_array_invert(godot_packed_vector3_array *p_self);
-void GDAPI godot_pool_vector3_array_push_back(godot_pool_vector3_array *p_self, const godot_vector3 *p_data);
+void GDAPI godot_packed_vector3_array_push_back(godot_packed_vector3_array *p_self, const godot_vector3 *p_data);
-void GDAPI godot_pool_vector3_array_remove(godot_pool_vector3_array *p_self, const godot_int p_idx);
+void GDAPI godot_packed_vector3_array_remove(godot_packed_vector3_array *p_self, const godot_int p_idx);
-void GDAPI godot_pool_vector3_array_resize(godot_pool_vector3_array *p_self, const godot_int p_size);
+void GDAPI godot_packed_vector3_array_resize(godot_packed_vector3_array *p_self, const godot_int p_size);
-godot_pool_vector3_array_read_access GDAPI *godot_pool_vector3_array_read(const godot_pool_vector3_array *p_self);
+void GDAPI godot_packed_vector3_array_set(godot_packed_vector3_array *p_self, const godot_int p_idx, const godot_vector3 *p_data);
+godot_vector3 GDAPI godot_packed_vector3_array_get(const godot_packed_vector3_array *p_self, const godot_int p_idx);
-godot_pool_vector3_array_write_access GDAPI *godot_pool_vector3_array_write(godot_pool_vector3_array *p_self);
+godot_int GDAPI godot_packed_vector3_array_size(const godot_packed_vector3_array *p_self);
-void GDAPI godot_pool_vector3_array_set(godot_pool_vector3_array *p_self, const godot_int p_idx, const godot_vector3 *p_data);
-godot_vector3 GDAPI godot_pool_vector3_array_get(const godot_pool_vector3_array *p_self, const godot_int p_idx);
+godot_bool GDAPI godot_packed_vector3_array_empty(const godot_packed_vector3_array *p_self);
-godot_int GDAPI godot_pool_vector3_array_size(const godot_pool_vector3_array *p_self);
-
-godot_bool GDAPI godot_pool_vector3_array_empty(const godot_pool_vector3_array *p_self);
-
-void GDAPI godot_pool_vector3_array_destroy(godot_pool_vector3_array *p_self);
+void GDAPI godot_packed_vector3_array_destroy(godot_packed_vector3_array *p_self);
// color
-void GDAPI godot_pool_color_array_new(godot_pool_color_array *r_dest);
-void GDAPI godot_pool_color_array_new_copy(godot_pool_color_array *r_dest, const godot_pool_color_array *p_src);
-void GDAPI godot_pool_color_array_new_with_array(godot_pool_color_array *r_dest, const godot_array *p_a);
-
-void GDAPI godot_pool_color_array_append(godot_pool_color_array *p_self, const godot_color *p_data);
-
-void GDAPI godot_pool_color_array_append_array(godot_pool_color_array *p_self, const godot_pool_color_array *p_array);
-
-godot_error GDAPI godot_pool_color_array_insert(godot_pool_color_array *p_self, const godot_int p_idx, const godot_color *p_data);
-
-void GDAPI godot_pool_color_array_invert(godot_pool_color_array *p_self);
-
-void GDAPI godot_pool_color_array_push_back(godot_pool_color_array *p_self, const godot_color *p_data);
-
-void GDAPI godot_pool_color_array_remove(godot_pool_color_array *p_self, const godot_int p_idx);
-
-void GDAPI godot_pool_color_array_resize(godot_pool_color_array *p_self, const godot_int p_size);
-
-godot_pool_color_array_read_access GDAPI *godot_pool_color_array_read(const godot_pool_color_array *p_self);
-
-godot_pool_color_array_write_access GDAPI *godot_pool_color_array_write(godot_pool_color_array *p_self);
-
-void GDAPI godot_pool_color_array_set(godot_pool_color_array *p_self, const godot_int p_idx, const godot_color *p_data);
-godot_color GDAPI godot_pool_color_array_get(const godot_pool_color_array *p_self, const godot_int p_idx);
-
-godot_int GDAPI godot_pool_color_array_size(const godot_pool_color_array *p_self);
-
-godot_bool GDAPI godot_pool_color_array_empty(const godot_pool_color_array *p_self);
-
-void GDAPI godot_pool_color_array_destroy(godot_pool_color_array *p_self);
-
-//
-// read accessor functions
-//
-
-godot_pool_byte_array_read_access GDAPI *godot_pool_byte_array_read_access_copy(const godot_pool_byte_array_read_access *p_other);
-const uint8_t GDAPI *godot_pool_byte_array_read_access_ptr(const godot_pool_byte_array_read_access *p_read);
-void GDAPI godot_pool_byte_array_read_access_operator_assign(godot_pool_byte_array_read_access *p_read, godot_pool_byte_array_read_access *p_other);
-void GDAPI godot_pool_byte_array_read_access_destroy(godot_pool_byte_array_read_access *p_read);
-
-godot_pool_int_array_read_access GDAPI *godot_pool_int_array_read_access_copy(const godot_pool_int_array_read_access *p_other);
-const godot_int GDAPI *godot_pool_int_array_read_access_ptr(const godot_pool_int_array_read_access *p_read);
-void GDAPI godot_pool_int_array_read_access_operator_assign(godot_pool_int_array_read_access *p_read, godot_pool_int_array_read_access *p_other);
-void GDAPI godot_pool_int_array_read_access_destroy(godot_pool_int_array_read_access *p_read);
-
-godot_pool_real_array_read_access GDAPI *godot_pool_real_array_read_access_copy(const godot_pool_real_array_read_access *p_other);
-const godot_real GDAPI *godot_pool_real_array_read_access_ptr(const godot_pool_real_array_read_access *p_read);
-void GDAPI godot_pool_real_array_read_access_operator_assign(godot_pool_real_array_read_access *p_read, godot_pool_real_array_read_access *p_other);
-void GDAPI godot_pool_real_array_read_access_destroy(godot_pool_real_array_read_access *p_read);
-
-godot_pool_string_array_read_access GDAPI *godot_pool_string_array_read_access_copy(const godot_pool_string_array_read_access *p_other);
-const godot_string GDAPI *godot_pool_string_array_read_access_ptr(const godot_pool_string_array_read_access *p_read);
-void GDAPI godot_pool_string_array_read_access_operator_assign(godot_pool_string_array_read_access *p_read, godot_pool_string_array_read_access *p_other);
-void GDAPI godot_pool_string_array_read_access_destroy(godot_pool_string_array_read_access *p_read);
+void GDAPI godot_packed_color_array_new(godot_packed_color_array *r_dest);
+void GDAPI godot_packed_color_array_new_copy(godot_packed_color_array *r_dest, const godot_packed_color_array *p_src);
+void GDAPI godot_packed_color_array_new_with_array(godot_packed_color_array *r_dest, const godot_array *p_a);
-godot_pool_vector2_array_read_access GDAPI *godot_pool_vector2_array_read_access_copy(const godot_pool_vector2_array_read_access *p_other);
-const godot_vector2 GDAPI *godot_pool_vector2_array_read_access_ptr(const godot_pool_vector2_array_read_access *p_read);
-void GDAPI godot_pool_vector2_array_read_access_operator_assign(godot_pool_vector2_array_read_access *p_read, godot_pool_vector2_array_read_access *p_other);
-void GDAPI godot_pool_vector2_array_read_access_destroy(godot_pool_vector2_array_read_access *p_read);
+void GDAPI godot_packed_color_array_append(godot_packed_color_array *p_self, const godot_color *p_data);
-godot_pool_vector3_array_read_access GDAPI *godot_pool_vector3_array_read_access_copy(const godot_pool_vector3_array_read_access *p_other);
-const godot_vector3 GDAPI *godot_pool_vector3_array_read_access_ptr(const godot_pool_vector3_array_read_access *p_read);
-void GDAPI godot_pool_vector3_array_read_access_operator_assign(godot_pool_vector3_array_read_access *p_read, godot_pool_vector3_array_read_access *p_other);
-void GDAPI godot_pool_vector3_array_read_access_destroy(godot_pool_vector3_array_read_access *p_read);
+void GDAPI godot_packed_color_array_append_array(godot_packed_color_array *p_self, const godot_packed_color_array *p_array);
-godot_pool_color_array_read_access GDAPI *godot_pool_color_array_read_access_copy(const godot_pool_color_array_read_access *p_other);
-const godot_color GDAPI *godot_pool_color_array_read_access_ptr(const godot_pool_color_array_read_access *p_read);
-void GDAPI godot_pool_color_array_read_access_operator_assign(godot_pool_color_array_read_access *p_read, godot_pool_color_array_read_access *p_other);
-void GDAPI godot_pool_color_array_read_access_destroy(godot_pool_color_array_read_access *p_read);
+godot_error GDAPI godot_packed_color_array_insert(godot_packed_color_array *p_self, const godot_int p_idx, const godot_color *p_data);
-//
-// write accessor functions
-//
+void GDAPI godot_packed_color_array_invert(godot_packed_color_array *p_self);
-godot_pool_byte_array_write_access GDAPI *godot_pool_byte_array_write_access_copy(const godot_pool_byte_array_write_access *p_other);
-uint8_t GDAPI *godot_pool_byte_array_write_access_ptr(const godot_pool_byte_array_write_access *p_write);
-void GDAPI godot_pool_byte_array_write_access_operator_assign(godot_pool_byte_array_write_access *p_write, godot_pool_byte_array_write_access *p_other);
-void GDAPI godot_pool_byte_array_write_access_destroy(godot_pool_byte_array_write_access *p_write);
+void GDAPI godot_packed_color_array_push_back(godot_packed_color_array *p_self, const godot_color *p_data);
-godot_pool_int_array_write_access GDAPI *godot_pool_int_array_write_access_copy(const godot_pool_int_array_write_access *p_other);
-godot_int GDAPI *godot_pool_int_array_write_access_ptr(const godot_pool_int_array_write_access *p_write);
-void GDAPI godot_pool_int_array_write_access_operator_assign(godot_pool_int_array_write_access *p_write, godot_pool_int_array_write_access *p_other);
-void GDAPI godot_pool_int_array_write_access_destroy(godot_pool_int_array_write_access *p_write);
+void GDAPI godot_packed_color_array_remove(godot_packed_color_array *p_self, const godot_int p_idx);
-godot_pool_real_array_write_access GDAPI *godot_pool_real_array_write_access_copy(const godot_pool_real_array_write_access *p_other);
-godot_real GDAPI *godot_pool_real_array_write_access_ptr(const godot_pool_real_array_write_access *p_write);
-void GDAPI godot_pool_real_array_write_access_operator_assign(godot_pool_real_array_write_access *p_write, godot_pool_real_array_write_access *p_other);
-void GDAPI godot_pool_real_array_write_access_destroy(godot_pool_real_array_write_access *p_write);
+void GDAPI godot_packed_color_array_resize(godot_packed_color_array *p_self, const godot_int p_size);
-godot_pool_string_array_write_access GDAPI *godot_pool_string_array_write_access_copy(const godot_pool_string_array_write_access *p_other);
-godot_string GDAPI *godot_pool_string_array_write_access_ptr(const godot_pool_string_array_write_access *p_write);
-void GDAPI godot_pool_string_array_write_access_operator_assign(godot_pool_string_array_write_access *p_write, godot_pool_string_array_write_access *p_other);
-void GDAPI godot_pool_string_array_write_access_destroy(godot_pool_string_array_write_access *p_write);
+void GDAPI godot_packed_color_array_set(godot_packed_color_array *p_self, const godot_int p_idx, const godot_color *p_data);
+godot_color GDAPI godot_packed_color_array_get(const godot_packed_color_array *p_self, const godot_int p_idx);
-godot_pool_vector2_array_write_access GDAPI *godot_pool_vector2_array_write_access_copy(const godot_pool_vector2_array_write_access *p_other);
-godot_vector2 GDAPI *godot_pool_vector2_array_write_access_ptr(const godot_pool_vector2_array_write_access *p_write);
-void GDAPI godot_pool_vector2_array_write_access_operator_assign(godot_pool_vector2_array_write_access *p_write, godot_pool_vector2_array_write_access *p_other);
-void GDAPI godot_pool_vector2_array_write_access_destroy(godot_pool_vector2_array_write_access *p_write);
+godot_int GDAPI godot_packed_color_array_size(const godot_packed_color_array *p_self);
-godot_pool_vector3_array_write_access GDAPI *godot_pool_vector3_array_write_access_copy(const godot_pool_vector3_array_write_access *p_other);
-godot_vector3 GDAPI *godot_pool_vector3_array_write_access_ptr(const godot_pool_vector3_array_write_access *p_write);
-void GDAPI godot_pool_vector3_array_write_access_operator_assign(godot_pool_vector3_array_write_access *p_write, godot_pool_vector3_array_write_access *p_other);
-void GDAPI godot_pool_vector3_array_write_access_destroy(godot_pool_vector3_array_write_access *p_write);
+godot_bool GDAPI godot_packed_color_array_empty(const godot_packed_color_array *p_self);
-godot_pool_color_array_write_access GDAPI *godot_pool_color_array_write_access_copy(const godot_pool_color_array_write_access *p_other);
-godot_color GDAPI *godot_pool_color_array_write_access_ptr(const godot_pool_color_array_write_access *p_write);
-void GDAPI godot_pool_color_array_write_access_operator_assign(godot_pool_color_array_write_access *p_write, godot_pool_color_array_write_access *p_other);
-void GDAPI godot_pool_color_array_write_access_destroy(godot_pool_color_array_write_access *p_write);
+void GDAPI godot_packed_color_array_destroy(godot_packed_color_array *p_self);
#ifdef __cplusplus
}
diff --git a/modules/gdnative/include/gdnative/string.h b/modules/gdnative/include/gdnative/string.h
index b676d21fb2..608978db76 100644
--- a/modules/gdnative/include/gdnative/string.h
+++ b/modules/gdnative/include/gdnative/string.h
@@ -209,9 +209,9 @@ uint32_t GDAPI godot_string_hash_chars(const char *p_cstr);
uint32_t GDAPI godot_string_hash_chars_with_len(const char *p_cstr, godot_int p_len);
uint32_t GDAPI godot_string_hash_utf8_chars(const wchar_t *p_str);
uint32_t GDAPI godot_string_hash_utf8_chars_with_len(const wchar_t *p_str, godot_int p_len);
-godot_pool_byte_array GDAPI godot_string_md5_buffer(const godot_string *p_self);
+godot_packed_byte_array GDAPI godot_string_md5_buffer(const godot_string *p_self);
godot_string GDAPI godot_string_md5_text(const godot_string *p_self);
-godot_pool_byte_array GDAPI godot_string_sha256_buffer(const godot_string *p_self);
+godot_packed_byte_array GDAPI godot_string_sha256_buffer(const godot_string *p_self);
godot_string GDAPI godot_string_sha256_text(const godot_string *p_self);
godot_bool godot_string_empty(const godot_string *p_self);
@@ -252,7 +252,7 @@ godot_string GDAPI godot_string_dedent(const godot_string *p_self);
godot_string GDAPI godot_string_trim_prefix(const godot_string *p_self, const godot_string *p_prefix);
godot_string GDAPI godot_string_trim_suffix(const godot_string *p_self, const godot_string *p_suffix);
godot_string GDAPI godot_string_rstrip(const godot_string *p_self, const godot_string *p_chars);
-godot_pool_string_array GDAPI godot_string_rsplit(const godot_string *p_self, const godot_string *p_divisor, const godot_bool p_allow_empty, const godot_int p_maxsplit);
+godot_packed_string_array GDAPI godot_string_rsplit(const godot_string *p_self, const godot_string *p_divisor, const godot_bool p_allow_empty, const godot_int p_maxsplit);
void GDAPI godot_string_destroy(godot_string *p_self);
diff --git a/modules/gdnative/include/gdnative/variant.h b/modules/gdnative/include/gdnative/variant.h
index c65f7a28d2..934e856fbf 100644
--- a/modules/gdnative/include/gdnative/variant.h
+++ b/modules/gdnative/include/gdnative/variant.h
@@ -56,33 +56,35 @@ typedef enum godot_variant_type {
GODOT_VARIANT_TYPE_STRING,
// math types
-
- GODOT_VARIANT_TYPE_VECTOR2, // 5
+ GODOT_VARIANT_TYPE_VECTOR2,
+ GODOT_VARIANT_TYPE_VECTOR2I,
GODOT_VARIANT_TYPE_RECT2,
+ GODOT_VARIANT_TYPE_RECT2I,
GODOT_VARIANT_TYPE_VECTOR3,
+ GODOT_VARIANT_TYPE_VECTOR3I,
GODOT_VARIANT_TYPE_TRANSFORM2D,
GODOT_VARIANT_TYPE_PLANE,
- GODOT_VARIANT_TYPE_QUAT, // 10
+ GODOT_VARIANT_TYPE_QUAT,
GODOT_VARIANT_TYPE_AABB,
GODOT_VARIANT_TYPE_BASIS,
GODOT_VARIANT_TYPE_TRANSFORM,
// misc types
GODOT_VARIANT_TYPE_COLOR,
- GODOT_VARIANT_TYPE_NODE_PATH, // 15
+ GODOT_VARIANT_TYPE_NODE_PATH,
GODOT_VARIANT_TYPE_RID,
GODOT_VARIANT_TYPE_OBJECT,
GODOT_VARIANT_TYPE_DICTIONARY,
- GODOT_VARIANT_TYPE_ARRAY, // 20
+ GODOT_VARIANT_TYPE_ARRAY,
// arrays
- GODOT_VARIANT_TYPE_POOL_BYTE_ARRAY,
- GODOT_VARIANT_TYPE_POOL_INT_ARRAY,
- GODOT_VARIANT_TYPE_POOL_REAL_ARRAY,
- GODOT_VARIANT_TYPE_POOL_STRING_ARRAY,
- GODOT_VARIANT_TYPE_POOL_VECTOR2_ARRAY, // 25
- GODOT_VARIANT_TYPE_POOL_VECTOR3_ARRAY,
- GODOT_VARIANT_TYPE_POOL_COLOR_ARRAY,
+ GODOT_VARIANT_TYPE_PACKED_BYTE_ARRAY,
+ GODOT_VARIANT_TYPE_PACKED_INT_ARRAY,
+ GODOT_VARIANT_TYPE_PACKED_REAL_ARRAY,
+ GODOT_VARIANT_TYPE_PACKED_STRING_ARRAY,
+ GODOT_VARIANT_TYPE_PACKED_VECTOR2_ARRAY,
+ GODOT_VARIANT_TYPE_PACKED_VECTOR3_ARRAY,
+ GODOT_VARIANT_TYPE_PACKED_COLOR_ARRAY,
} godot_variant_type;
typedef enum godot_variant_call_error_error {
@@ -194,13 +196,13 @@ void GDAPI godot_variant_new_rid(godot_variant *r_dest, const godot_rid *p_rid);
void GDAPI godot_variant_new_object(godot_variant *r_dest, const godot_object *p_obj);
void GDAPI godot_variant_new_dictionary(godot_variant *r_dest, const godot_dictionary *p_dict);
void GDAPI godot_variant_new_array(godot_variant *r_dest, const godot_array *p_arr);
-void GDAPI godot_variant_new_pool_byte_array(godot_variant *r_dest, const godot_pool_byte_array *p_pba);
-void GDAPI godot_variant_new_pool_int_array(godot_variant *r_dest, const godot_pool_int_array *p_pia);
-void GDAPI godot_variant_new_pool_real_array(godot_variant *r_dest, const godot_pool_real_array *p_pra);
-void GDAPI godot_variant_new_pool_string_array(godot_variant *r_dest, const godot_pool_string_array *p_psa);
-void GDAPI godot_variant_new_pool_vector2_array(godot_variant *r_dest, const godot_pool_vector2_array *p_pv2a);
-void GDAPI godot_variant_new_pool_vector3_array(godot_variant *r_dest, const godot_pool_vector3_array *p_pv3a);
-void GDAPI godot_variant_new_pool_color_array(godot_variant *r_dest, const godot_pool_color_array *p_pca);
+void GDAPI godot_variant_new_packed_byte_array(godot_variant *r_dest, const godot_packed_byte_array *p_pba);
+void GDAPI godot_variant_new_packed_int_array(godot_variant *r_dest, const godot_packed_int_array *p_pia);
+void GDAPI godot_variant_new_packed_real_array(godot_variant *r_dest, const godot_packed_real_array *p_pra);
+void GDAPI godot_variant_new_packed_string_array(godot_variant *r_dest, const godot_packed_string_array *p_psa);
+void GDAPI godot_variant_new_packed_vector2_array(godot_variant *r_dest, const godot_packed_vector2_array *p_pv2a);
+void GDAPI godot_variant_new_packed_vector3_array(godot_variant *r_dest, const godot_packed_vector3_array *p_pv3a);
+void GDAPI godot_variant_new_packed_color_array(godot_variant *r_dest, const godot_packed_color_array *p_pca);
godot_bool GDAPI godot_variant_as_bool(const godot_variant *p_self);
uint64_t GDAPI godot_variant_as_uint(const godot_variant *p_self);
@@ -222,13 +224,13 @@ godot_rid GDAPI godot_variant_as_rid(const godot_variant *p_self);
godot_object GDAPI *godot_variant_as_object(const godot_variant *p_self);
godot_dictionary GDAPI godot_variant_as_dictionary(const godot_variant *p_self);
godot_array GDAPI godot_variant_as_array(const godot_variant *p_self);
-godot_pool_byte_array GDAPI godot_variant_as_pool_byte_array(const godot_variant *p_self);
-godot_pool_int_array GDAPI godot_variant_as_pool_int_array(const godot_variant *p_self);
-godot_pool_real_array GDAPI godot_variant_as_pool_real_array(const godot_variant *p_self);
-godot_pool_string_array GDAPI godot_variant_as_pool_string_array(const godot_variant *p_self);
-godot_pool_vector2_array GDAPI godot_variant_as_pool_vector2_array(const godot_variant *p_self);
-godot_pool_vector3_array GDAPI godot_variant_as_pool_vector3_array(const godot_variant *p_self);
-godot_pool_color_array GDAPI godot_variant_as_pool_color_array(const godot_variant *p_self);
+godot_packed_byte_array GDAPI godot_variant_as_packed_byte_array(const godot_variant *p_self);
+godot_packed_int_array GDAPI godot_variant_as_packed_int_array(const godot_variant *p_self);
+godot_packed_real_array GDAPI godot_variant_as_packed_real_array(const godot_variant *p_self);
+godot_packed_string_array GDAPI godot_variant_as_packed_string_array(const godot_variant *p_self);
+godot_packed_vector2_array GDAPI godot_variant_as_packed_vector2_array(const godot_variant *p_self);
+godot_packed_vector3_array GDAPI godot_variant_as_packed_vector3_array(const godot_variant *p_self);
+godot_packed_color_array GDAPI godot_variant_as_packed_color_array(const godot_variant *p_self);
godot_variant GDAPI godot_variant_call(godot_variant *p_self, const godot_string *p_method, const godot_variant **p_args, const godot_int p_argcount, godot_variant_call_error *r_error);
diff --git a/modules/gdnative/include/nativescript/godot_nativescript.h b/modules/gdnative/include/nativescript/godot_nativescript.h
index d2ed4fb3e5..1b131c8cf0 100644
--- a/modules/gdnative/include/nativescript/godot_nativescript.h
+++ b/modules/gdnative/include/nativescript/godot_nativescript.h
@@ -42,9 +42,7 @@ typedef enum {
GODOT_METHOD_RPC_MODE_REMOTE,
GODOT_METHOD_RPC_MODE_MASTER,
GODOT_METHOD_RPC_MODE_PUPPET,
- GODOT_METHOD_RPC_MODE_SLAVE = GODOT_METHOD_RPC_MODE_PUPPET,
GODOT_METHOD_RPC_MODE_REMOTESYNC,
- GODOT_METHOD_RPC_MODE_SYNC = GODOT_METHOD_RPC_MODE_REMOTESYNC,
GODOT_METHOD_RPC_MODE_MASTERSYNC,
GODOT_METHOD_RPC_MODE_PUPPETSYNC,
} godot_method_rpc_mode;
diff --git a/modules/gdnative/include/pluginscript/godot_pluginscript.h b/modules/gdnative/include/pluginscript/godot_pluginscript.h
index e8822fc1ec..341e7f9e2b 100644
--- a/modules/gdnative/include/pluginscript/godot_pluginscript.h
+++ b/modules/gdnative/include/pluginscript/godot_pluginscript.h
@@ -44,13 +44,12 @@ typedef void godot_pluginscript_language_data;
// --- Instance ---
-// TODO: use godot_string_name for faster lookup ?
typedef struct {
godot_pluginscript_instance_data *(*init)(godot_pluginscript_script_data *p_data, godot_object *p_owner);
void (*finish)(godot_pluginscript_instance_data *p_data);
- godot_bool (*set_prop)(godot_pluginscript_instance_data *p_data, const godot_string *p_name, const godot_variant *p_value);
- godot_bool (*get_prop)(godot_pluginscript_instance_data *p_data, const godot_string *p_name, godot_variant *r_ret);
+ godot_bool (*set_prop)(godot_pluginscript_instance_data *p_data, const godot_string_name *p_name, const godot_variant *p_value);
+ godot_bool (*get_prop)(godot_pluginscript_instance_data *p_data, const godot_string_name *p_name, godot_variant *r_ret);
godot_variant (*call_method)(godot_pluginscript_instance_data *p_data,
const godot_string_name *p_method, const godot_variant **p_args,
@@ -130,21 +129,21 @@ typedef struct {
godot_bool supports_builtin_mode;
godot_string (*get_template_source_code)(godot_pluginscript_language_data *p_data, const godot_string *p_class_name, const godot_string *p_base_class_name);
- godot_bool (*validate)(godot_pluginscript_language_data *p_data, const godot_string *p_script, int *r_line_error, int *r_col_error, godot_string *r_test_error, const godot_string *p_path, godot_pool_string_array *r_functions);
+ godot_bool (*validate)(godot_pluginscript_language_data *p_data, const godot_string *p_script, int *r_line_error, int *r_col_error, godot_string *r_test_error, const godot_string *p_path, godot_packed_string_array *r_functions);
int (*find_function)(godot_pluginscript_language_data *p_data, const godot_string *p_function, const godot_string *p_code); // Can be NULL
- godot_string (*make_function)(godot_pluginscript_language_data *p_data, const godot_string *p_class, const godot_string *p_name, const godot_pool_string_array *p_args);
+ godot_string (*make_function)(godot_pluginscript_language_data *p_data, const godot_string *p_class, const godot_string *p_name, const godot_packed_string_array *p_args);
godot_error (*complete_code)(godot_pluginscript_language_data *p_data, const godot_string *p_code, const godot_string *p_path, godot_object *p_owner, godot_array *r_options, godot_bool *r_force, godot_string *r_call_hint);
void (*auto_indent_code)(godot_pluginscript_language_data *p_data, godot_string *p_code, int p_from_line, int p_to_line);
- void (*add_global_constant)(godot_pluginscript_language_data *p_data, const godot_string *p_variable, const godot_variant *p_value);
+ void (*add_global_constant)(godot_pluginscript_language_data *p_data, const godot_string_name *p_variable, const godot_variant *p_value);
godot_string (*debug_get_error)(godot_pluginscript_language_data *p_data);
int (*debug_get_stack_level_count)(godot_pluginscript_language_data *p_data);
int (*debug_get_stack_level_line)(godot_pluginscript_language_data *p_data, int p_level);
godot_string (*debug_get_stack_level_function)(godot_pluginscript_language_data *p_data, int p_level);
godot_string (*debug_get_stack_level_source)(godot_pluginscript_language_data *p_data, int p_level);
- void (*debug_get_stack_level_locals)(godot_pluginscript_language_data *p_data, int p_level, godot_pool_string_array *p_locals, godot_array *p_values, int p_max_subitems, int p_max_depth);
- void (*debug_get_stack_level_members)(godot_pluginscript_language_data *p_data, int p_level, godot_pool_string_array *p_members, godot_array *p_values, int p_max_subitems, int p_max_depth);
- void (*debug_get_globals)(godot_pluginscript_language_data *p_data, godot_pool_string_array *p_locals, godot_array *p_values, int p_max_subitems, int p_max_depth);
+ void (*debug_get_stack_level_locals)(godot_pluginscript_language_data *p_data, int p_level, godot_packed_string_array *p_locals, godot_array *p_values, int p_max_subitems, int p_max_depth);
+ void (*debug_get_stack_level_members)(godot_pluginscript_language_data *p_data, int p_level, godot_packed_string_array *p_members, godot_array *p_values, int p_max_subitems, int p_max_depth);
+ void (*debug_get_globals)(godot_pluginscript_language_data *p_data, godot_packed_string_array *p_locals, godot_array *p_values, int p_max_subitems, int p_max_depth);
godot_string (*debug_parse_stack_level_expression)(godot_pluginscript_language_data *p_data, int p_level, const godot_string *p_expression, int p_max_subitems, int p_max_depth);
// TODO: could this stuff be moved to the godot_pluginscript_language_desc ?
diff --git a/modules/gdnative/include/videodecoder/godot_videodecoder.h b/modules/gdnative/include/videodecoder/godot_videodecoder.h
index 714991ca72..3e91a2e9ac 100644
--- a/modules/gdnative/include/videodecoder/godot_videodecoder.h
+++ b/modules/gdnative/include/videodecoder/godot_videodecoder.h
@@ -54,7 +54,7 @@ typedef struct
void (*seek)(void *, godot_real);
void (*set_audio_track)(void *, godot_int);
void (*update)(void *, godot_real);
- godot_pool_byte_array *(*get_videoframe)(void *);
+ godot_packed_byte_array *(*get_videoframe)(void *);
godot_int (*get_audioframe)(void *, float *, int);
godot_int (*get_channels)(const void *);
godot_int (*get_mix_rate)(const void *);
diff --git a/modules/gdnative/nativescript/godot_nativescript.cpp b/modules/gdnative/nativescript/godot_nativescript.cpp
index e19e675344..f953206a34 100644
--- a/modules/gdnative/nativescript/godot_nativescript.cpp
+++ b/modules/gdnative/nativescript/godot_nativescript.cpp
@@ -36,6 +36,7 @@
#include "core/project_settings.h"
#include "core/variant.h"
#include "gdnative/gdnative.h"
+#include <stdint.h>
#include "nativescript.h"
@@ -67,6 +68,14 @@ void GDAPI godot_nativescript_register_class(void *p_gdnative_handle, const char
if (classes->has(p_base)) {
desc.base_data = &(*classes)[p_base];
desc.base_native_type = desc.base_data->base_native_type;
+
+ const NativeScriptDesc *b = desc.base_data;
+ while (b) {
+ desc.rpc_count += b->rpc_count;
+ desc.rset_count += b->rset_count;
+ b = b->base_data;
+ }
+
} else {
desc.base_data = NULL;
desc.base_native_type = p_base;
@@ -87,10 +96,20 @@ void GDAPI godot_nativescript_register_tool_class(void *p_gdnative_handle, const
desc.destroy_func = p_destroy_func;
desc.is_tool = true;
desc.base = p_base;
+ desc.rpc_count = 0;
+ desc.rset_count = 0;
if (classes->has(p_base)) {
desc.base_data = &(*classes)[p_base];
desc.base_native_type = desc.base_data->base_native_type;
+
+ const NativeScriptDesc *b = desc.base_data;
+ while (b) {
+ desc.rpc_count += b->rpc_count;
+ desc.rset_count += b->rset_count;
+ b = b->base_data;
+ }
+
} else {
desc.base_data = NULL;
desc.base_native_type = p_base;
@@ -109,6 +128,11 @@ void GDAPI godot_nativescript_register_method(void *p_gdnative_handle, const cha
NativeScriptDesc::Method method;
method.method = p_method;
method.rpc_mode = p_attr.rpc_type;
+ method.rpc_method_id = UINT16_MAX;
+ if (p_attr.rpc_type != GODOT_METHOD_RPC_MODE_DISABLED) {
+ method.rpc_method_id = E->get().rpc_count;
+ E->get().rpc_count += 1;
+ }
method.info = MethodInfo(p_function_name);
E->get().methods.insert(p_function_name, method);
@@ -125,6 +149,10 @@ void GDAPI godot_nativescript_register_property(void *p_gdnative_handle, const c
property.default_value = *(Variant *)&p_attr->default_value;
property.getter = p_get_func;
property.rset_mode = p_attr->rset_type;
+ if (p_attr->rset_type != GODOT_METHOD_RPC_MODE_DISABLED) {
+ property.rset_property_id = E->get().rset_count;
+ E->get().rset_count += 1;
+ }
property.setter = p_set_func;
property.info = PropertyInfo((Variant::Type)p_attr->type,
p_path,
diff --git a/modules/gdnative/nativescript/nativescript.cpp b/modules/gdnative/nativescript/nativescript.cpp
index 8b06af6c7b..8240ae2f83 100644
--- a/modules/gdnative/nativescript/nativescript.cpp
+++ b/modules/gdnative/nativescript/nativescript.cpp
@@ -30,6 +30,8 @@
#include "nativescript.h"
+#include <stdint.h>
+
#include "gdnative/gdnative.h"
#include "core/core_string_names.h"
@@ -402,6 +404,262 @@ void NativeScript::get_script_property_list(List<PropertyInfo> *p_list) const {
}
}
+Vector<ScriptNetData> NativeScript::get_rpc_methods() const {
+
+ Vector<ScriptNetData> v;
+
+ NativeScriptDesc *script_data = get_script_desc();
+
+ while (script_data) {
+
+ for (Map<StringName, NativeScriptDesc::Method>::Element *E = script_data->methods.front(); E; E = E->next()) {
+ if (E->get().rpc_mode != GODOT_METHOD_RPC_MODE_DISABLED) {
+ ScriptNetData nd;
+ nd.name = E->key();
+ nd.mode = MultiplayerAPI::RPCMode(E->get().rpc_mode);
+ v.push_back(nd);
+ }
+ }
+
+ script_data = script_data->base_data;
+ }
+
+ return v;
+}
+
+uint16_t NativeScript::get_rpc_method_id(const StringName &p_method) const {
+ NativeScriptDesc *script_data = get_script_desc();
+
+ while (script_data) {
+
+ Map<StringName, NativeScriptDesc::Method>::Element *E = script_data->methods.find(p_method);
+ if (E) {
+ return E->get().rpc_method_id;
+ }
+
+ script_data = script_data->base_data;
+ }
+
+ return UINT16_MAX;
+}
+
+StringName NativeScript::get_rpc_method(uint16_t p_id) const {
+ ERR_FAIL_COND_V(p_id == UINT16_MAX, StringName());
+
+ NativeScriptDesc *script_data = get_script_desc();
+
+ while (script_data) {
+
+ for (Map<StringName, NativeScriptDesc::Method>::Element *E = script_data->methods.front(); E; E = E->next()) {
+ if (E->get().rpc_method_id == p_id) {
+ return E->key();
+ }
+ }
+
+ script_data = script_data->base_data;
+ }
+
+ return StringName();
+}
+
+MultiplayerAPI::RPCMode NativeScript::get_rpc_mode_by_id(uint16_t p_id) const {
+
+ ERR_FAIL_COND_V(p_id == UINT16_MAX, MultiplayerAPI::RPC_MODE_DISABLED);
+
+ NativeScriptDesc *script_data = get_script_desc();
+
+ while (script_data) {
+
+ for (Map<StringName, NativeScriptDesc::Method>::Element *E = script_data->methods.front(); E; E = E->next()) {
+ if (E->get().rpc_method_id == p_id) {
+ switch (E->get().rpc_mode) {
+ case GODOT_METHOD_RPC_MODE_DISABLED:
+ return MultiplayerAPI::RPC_MODE_DISABLED;
+ case GODOT_METHOD_RPC_MODE_REMOTE:
+ return MultiplayerAPI::RPC_MODE_REMOTE;
+ case GODOT_METHOD_RPC_MODE_MASTER:
+ return MultiplayerAPI::RPC_MODE_MASTER;
+ case GODOT_METHOD_RPC_MODE_PUPPET:
+ return MultiplayerAPI::RPC_MODE_PUPPET;
+ case GODOT_METHOD_RPC_MODE_REMOTESYNC:
+ return MultiplayerAPI::RPC_MODE_REMOTESYNC;
+ case GODOT_METHOD_RPC_MODE_MASTERSYNC:
+ return MultiplayerAPI::RPC_MODE_MASTERSYNC;
+ case GODOT_METHOD_RPC_MODE_PUPPETSYNC:
+ return MultiplayerAPI::RPC_MODE_PUPPETSYNC;
+ default:
+ return MultiplayerAPI::RPC_MODE_DISABLED;
+ }
+ }
+ }
+
+ script_data = script_data->base_data;
+ }
+
+ return MultiplayerAPI::RPC_MODE_DISABLED;
+}
+
+MultiplayerAPI::RPCMode NativeScript::get_rpc_mode(const StringName &p_method) const {
+
+ NativeScriptDesc *script_data = get_script_desc();
+
+ while (script_data) {
+
+ Map<StringName, NativeScriptDesc::Method>::Element *E = script_data->methods.find(p_method);
+ if (E) {
+ switch (E->get().rpc_mode) {
+ case GODOT_METHOD_RPC_MODE_DISABLED:
+ return MultiplayerAPI::RPC_MODE_DISABLED;
+ case GODOT_METHOD_RPC_MODE_REMOTE:
+ return MultiplayerAPI::RPC_MODE_REMOTE;
+ case GODOT_METHOD_RPC_MODE_MASTER:
+ return MultiplayerAPI::RPC_MODE_MASTER;
+ case GODOT_METHOD_RPC_MODE_PUPPET:
+ return MultiplayerAPI::RPC_MODE_PUPPET;
+ case GODOT_METHOD_RPC_MODE_REMOTESYNC:
+ return MultiplayerAPI::RPC_MODE_REMOTESYNC;
+ case GODOT_METHOD_RPC_MODE_MASTERSYNC:
+ return MultiplayerAPI::RPC_MODE_MASTERSYNC;
+ case GODOT_METHOD_RPC_MODE_PUPPETSYNC:
+ return MultiplayerAPI::RPC_MODE_PUPPETSYNC;
+ default:
+ return MultiplayerAPI::RPC_MODE_DISABLED;
+ }
+ }
+
+ script_data = script_data->base_data;
+ }
+
+ return MultiplayerAPI::RPC_MODE_DISABLED;
+}
+
+Vector<ScriptNetData> NativeScript::get_rset_properties() const {
+ Vector<ScriptNetData> v;
+
+ NativeScriptDesc *script_data = get_script_desc();
+
+ while (script_data) {
+
+ for (OrderedHashMap<StringName, NativeScriptDesc::Property>::Element E = script_data->properties.front(); E; E = E.next()) {
+ if (E.get().rset_mode != GODOT_METHOD_RPC_MODE_DISABLED) {
+ ScriptNetData nd;
+ nd.name = E.key();
+ nd.mode = MultiplayerAPI::RPCMode(E.get().rset_mode);
+ v.push_back(nd);
+ }
+ }
+ script_data = script_data->base_data;
+ }
+
+ return v;
+}
+
+uint16_t NativeScript::get_rset_property_id(const StringName &p_variable) const {
+ NativeScriptDesc *script_data = get_script_desc();
+
+ while (script_data) {
+
+ OrderedHashMap<StringName, NativeScriptDesc::Property>::Element E = script_data->properties.find(p_variable);
+ if (E) {
+ return E.get().rset_property_id;
+ }
+
+ script_data = script_data->base_data;
+ }
+
+ return UINT16_MAX;
+}
+
+StringName NativeScript::get_rset_property(uint16_t p_id) const {
+ ERR_FAIL_COND_V(p_id == UINT16_MAX, StringName());
+
+ NativeScriptDesc *script_data = get_script_desc();
+
+ while (script_data) {
+
+ for (OrderedHashMap<StringName, NativeScriptDesc::Property>::Element E = script_data->properties.front(); E; E = E.next()) {
+ if (E.get().rset_property_id == p_id) {
+ return E.key();
+ }
+ }
+
+ script_data = script_data->base_data;
+ }
+
+ return StringName();
+}
+
+MultiplayerAPI::RPCMode NativeScript::get_rset_mode_by_id(uint16_t p_id) const {
+
+ ERR_FAIL_COND_V(p_id == UINT16_MAX, MultiplayerAPI::RPC_MODE_DISABLED);
+
+ NativeScriptDesc *script_data = get_script_desc();
+
+ while (script_data) {
+
+ for (OrderedHashMap<StringName, NativeScriptDesc::Property>::Element E = script_data->properties.front(); E; E = E.next()) {
+ if (E.get().rset_property_id == p_id) {
+ switch (E.get().rset_mode) {
+ case GODOT_METHOD_RPC_MODE_DISABLED:
+ return MultiplayerAPI::RPC_MODE_DISABLED;
+ case GODOT_METHOD_RPC_MODE_REMOTE:
+ return MultiplayerAPI::RPC_MODE_REMOTE;
+ case GODOT_METHOD_RPC_MODE_MASTER:
+ return MultiplayerAPI::RPC_MODE_MASTER;
+ case GODOT_METHOD_RPC_MODE_PUPPET:
+ return MultiplayerAPI::RPC_MODE_PUPPET;
+ case GODOT_METHOD_RPC_MODE_REMOTESYNC:
+ return MultiplayerAPI::RPC_MODE_REMOTESYNC;
+ case GODOT_METHOD_RPC_MODE_MASTERSYNC:
+ return MultiplayerAPI::RPC_MODE_MASTERSYNC;
+ case GODOT_METHOD_RPC_MODE_PUPPETSYNC:
+ return MultiplayerAPI::RPC_MODE_PUPPETSYNC;
+ default:
+ return MultiplayerAPI::RPC_MODE_DISABLED;
+ }
+ }
+ }
+
+ script_data = script_data->base_data;
+ }
+
+ return MultiplayerAPI::RPC_MODE_DISABLED;
+}
+
+MultiplayerAPI::RPCMode NativeScript::get_rset_mode(const StringName &p_variable) const {
+
+ NativeScriptDesc *script_data = get_script_desc();
+
+ while (script_data) {
+
+ OrderedHashMap<StringName, NativeScriptDesc::Property>::Element E = script_data->properties.find(p_variable);
+ if (E) {
+ switch (E.get().rset_mode) {
+ case GODOT_METHOD_RPC_MODE_DISABLED:
+ return MultiplayerAPI::RPC_MODE_DISABLED;
+ case GODOT_METHOD_RPC_MODE_REMOTE:
+ return MultiplayerAPI::RPC_MODE_REMOTE;
+ case GODOT_METHOD_RPC_MODE_MASTER:
+ return MultiplayerAPI::RPC_MODE_MASTER;
+ case GODOT_METHOD_RPC_MODE_PUPPET:
+ return MultiplayerAPI::RPC_MODE_PUPPET;
+ case GODOT_METHOD_RPC_MODE_REMOTESYNC:
+ return MultiplayerAPI::RPC_MODE_REMOTESYNC;
+ case GODOT_METHOD_RPC_MODE_MASTERSYNC:
+ return MultiplayerAPI::RPC_MODE_MASTERSYNC;
+ case GODOT_METHOD_RPC_MODE_PUPPETSYNC:
+ return MultiplayerAPI::RPC_MODE_PUPPETSYNC;
+ default:
+ return MultiplayerAPI::RPC_MODE_DISABLED;
+ }
+ }
+
+ script_data = script_data->base_data;
+ }
+
+ return MultiplayerAPI::RPC_MODE_DISABLED;
+}
+
String NativeScript::get_class_documentation() const {
NativeScriptDesc *script_data = get_script_desc();
@@ -467,21 +725,21 @@ String NativeScript::get_property_documentation(const StringName &p_path) const
ERR_FAIL_V_MSG("", "Attempt to get property documentation for non-existent signal.");
}
-Variant NativeScript::_new(const Variant **p_args, int p_argcount, Variant::CallError &r_error) {
+Variant NativeScript::_new(const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
if (lib_path.empty() || class_name.empty() || library.is_null()) {
- r_error.error = Variant::CallError::CALL_ERROR_INSTANCE_IS_NULL;
+ r_error.error = Callable::CallError::CALL_ERROR_INSTANCE_IS_NULL;
return Variant();
}
NativeScriptDesc *script_data = get_script_desc();
if (!script_data) {
- r_error.error = Variant::CallError::CALL_ERROR_INSTANCE_IS_NULL;
+ r_error.error = Callable::CallError::CALL_ERROR_INSTANCE_IS_NULL;
return Variant();
}
- r_error.error = Variant::CallError::CALL_OK;
+ r_error.error = Callable::CallError::CALL_OK;
REF ref;
Object *owner = NULL;
@@ -493,7 +751,7 @@ Variant NativeScript::_new(const Variant **p_args, int p_argcount, Variant::Call
}
if (!owner) {
- r_error.error = Variant::CallError::CALL_ERROR_INSTANCE_IS_NULL;
+ r_error.error = Callable::CallError::CALL_ERROR_INSTANCE_IS_NULL;
return Variant();
}
@@ -706,7 +964,7 @@ bool NativeScriptInstance::has_method(const StringName &p_method) const {
return script->has_method(p_method);
}
-Variant NativeScriptInstance::call(const StringName &p_method, const Variant **p_args, int p_argcount, Variant::CallError &r_error) {
+Variant NativeScriptInstance::call(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
NativeScriptDesc *script_data = GET_SCRIPT_DESC();
@@ -731,14 +989,14 @@ Variant NativeScriptInstance::call(const StringName &p_method, const Variant **p
Variant res = *(Variant *)&result;
godot_variant_destroy(&result);
- r_error.error = Variant::CallError::CALL_OK;
+ r_error.error = Callable::CallError::CALL_OK;
return res;
}
script_data = script_data->base_data;
}
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
return Variant();
}
@@ -759,9 +1017,9 @@ void NativeScriptInstance::notification(int p_notification) {
String NativeScriptInstance::to_string(bool *r_valid) {
if (has_method(CoreStringNames::get_singleton()->_to_string)) {
- Variant::CallError ce;
+ Callable::CallError ce;
Variant ret = call(CoreStringNames::get_singleton()->_to_string, NULL, 0, ce);
- if (ce.error == Variant::CallError::CALL_OK) {
+ if (ce.error == Callable::CallError::CALL_OK) {
if (ret.get_type() != Variant::STRING) {
if (r_valid)
*r_valid = false;
@@ -778,21 +1036,21 @@ String NativeScriptInstance::to_string(bool *r_valid) {
}
void NativeScriptInstance::refcount_incremented() {
- Variant::CallError err;
+ Callable::CallError err;
call("_refcount_incremented", NULL, 0, err);
- if (err.error != Variant::CallError::CALL_OK && err.error != Variant::CallError::CALL_ERROR_INVALID_METHOD) {
+ if (err.error != Callable::CallError::CALL_OK && err.error != Callable::CallError::CALL_ERROR_INVALID_METHOD) {
ERR_PRINT("Failed to invoke _refcount_incremented - should not happen");
}
}
bool NativeScriptInstance::refcount_decremented() {
- Variant::CallError err;
+ Callable::CallError err;
Variant ret = call("_refcount_decremented", NULL, 0, err);
- if (err.error != Variant::CallError::CALL_OK && err.error != Variant::CallError::CALL_ERROR_INVALID_METHOD) {
+ if (err.error != Callable::CallError::CALL_OK && err.error != Callable::CallError::CALL_ERROR_INVALID_METHOD) {
ERR_PRINT("Failed to invoke _refcount_decremented - should not happen");
return true; // assume we can destroy the object
}
- if (err.error == Variant::CallError::CALL_ERROR_INVALID_METHOD) {
+ if (err.error == Callable::CallError::CALL_ERROR_INVALID_METHOD) {
// the method does not exist, default is true
return true;
}
@@ -803,72 +1061,44 @@ Ref<Script> NativeScriptInstance::get_script() const {
return script;
}
-MultiplayerAPI::RPCMode NativeScriptInstance::get_rpc_mode(const StringName &p_method) const {
-
- NativeScriptDesc *script_data = GET_SCRIPT_DESC();
-
- while (script_data) {
+Vector<ScriptNetData> NativeScriptInstance::get_rpc_methods() const {
+ return script->get_rpc_methods();
+}
- Map<StringName, NativeScriptDesc::Method>::Element *E = script_data->methods.find(p_method);
- if (E) {
- switch (E->get().rpc_mode) {
- case GODOT_METHOD_RPC_MODE_DISABLED:
- return MultiplayerAPI::RPC_MODE_DISABLED;
- case GODOT_METHOD_RPC_MODE_REMOTE:
- return MultiplayerAPI::RPC_MODE_REMOTE;
- case GODOT_METHOD_RPC_MODE_MASTER:
- return MultiplayerAPI::RPC_MODE_MASTER;
- case GODOT_METHOD_RPC_MODE_PUPPET:
- return MultiplayerAPI::RPC_MODE_PUPPET;
- case GODOT_METHOD_RPC_MODE_REMOTESYNC:
- return MultiplayerAPI::RPC_MODE_REMOTESYNC;
- case GODOT_METHOD_RPC_MODE_MASTERSYNC:
- return MultiplayerAPI::RPC_MODE_MASTERSYNC;
- case GODOT_METHOD_RPC_MODE_PUPPETSYNC:
- return MultiplayerAPI::RPC_MODE_PUPPETSYNC;
- default:
- return MultiplayerAPI::RPC_MODE_DISABLED;
- }
- }
+uint16_t NativeScriptInstance::get_rpc_method_id(const StringName &p_method) const {
+ return script->get_rpc_method_id(p_method);
+}
- script_data = script_data->base_data;
- }
+StringName NativeScriptInstance::get_rpc_method(uint16_t p_id) const {
+ return script->get_rpc_method(p_id);
+}
- return MultiplayerAPI::RPC_MODE_DISABLED;
+MultiplayerAPI::RPCMode NativeScriptInstance::get_rpc_mode_by_id(uint16_t p_id) const {
+ return script->get_rpc_mode_by_id(p_id);
}
-MultiplayerAPI::RPCMode NativeScriptInstance::get_rset_mode(const StringName &p_variable) const {
+MultiplayerAPI::RPCMode NativeScriptInstance::get_rpc_mode(const StringName &p_method) const {
+ return script->get_rpc_mode(p_method);
+}
- NativeScriptDesc *script_data = GET_SCRIPT_DESC();
+Vector<ScriptNetData> NativeScriptInstance::get_rset_properties() const {
+ return script->get_rset_properties();
+}
- while (script_data) {
+uint16_t NativeScriptInstance::get_rset_property_id(const StringName &p_variable) const {
+ return script->get_rset_property_id(p_variable);
+}
- OrderedHashMap<StringName, NativeScriptDesc::Property>::Element E = script_data->properties.find(p_variable);
- if (E) {
- switch (E.get().rset_mode) {
- case GODOT_METHOD_RPC_MODE_DISABLED:
- return MultiplayerAPI::RPC_MODE_DISABLED;
- case GODOT_METHOD_RPC_MODE_REMOTE:
- return MultiplayerAPI::RPC_MODE_REMOTE;
- case GODOT_METHOD_RPC_MODE_MASTER:
- return MultiplayerAPI::RPC_MODE_MASTER;
- case GODOT_METHOD_RPC_MODE_PUPPET:
- return MultiplayerAPI::RPC_MODE_PUPPET;
- case GODOT_METHOD_RPC_MODE_REMOTESYNC:
- return MultiplayerAPI::RPC_MODE_REMOTESYNC;
- case GODOT_METHOD_RPC_MODE_MASTERSYNC:
- return MultiplayerAPI::RPC_MODE_MASTERSYNC;
- case GODOT_METHOD_RPC_MODE_PUPPETSYNC:
- return MultiplayerAPI::RPC_MODE_PUPPETSYNC;
- default:
- return MultiplayerAPI::RPC_MODE_DISABLED;
- }
- }
+StringName NativeScriptInstance::get_rset_property(uint16_t p_id) const {
+ return script->get_rset_property(p_id);
+}
- script_data = script_data->base_data;
- }
+MultiplayerAPI::RPCMode NativeScriptInstance::get_rset_mode_by_id(uint16_t p_id) const {
+ return script->get_rset_mode_by_id(p_id);
+}
- return MultiplayerAPI::RPC_MODE_DISABLED;
+MultiplayerAPI::RPCMode NativeScriptInstance::get_rset_mode(const StringName &p_variable) const {
+ return script->get_rset_mode(p_variable);
}
ScriptLanguage *NativeScriptInstance::get_language() {
@@ -1131,7 +1361,7 @@ bool NativeScriptLanguage::supports_builtin_mode() const {
int NativeScriptLanguage::find_function(const String &p_function, const String &p_code) const {
return -1;
}
-String NativeScriptLanguage::make_function(const String &p_class, const String &p_name, const PoolStringArray &p_args) const {
+String NativeScriptLanguage::make_function(const String &p_class, const String &p_name, const PackedStringArray &p_args) const {
return "";
}
void NativeScriptLanguage::auto_indent_code(String &p_code, int p_from_line, int p_to_line) const {
diff --git a/modules/gdnative/nativescript/nativescript.h b/modules/gdnative/nativescript/nativescript.h
index cf787e1f6a..609ffa2bd4 100644
--- a/modules/gdnative/nativescript/nativescript.h
+++ b/modules/gdnative/nativescript/nativescript.h
@@ -54,6 +54,7 @@ struct NativeScriptDesc {
godot_instance_method method;
MethodInfo info;
int rpc_mode;
+ uint16_t rpc_method_id;
String documentation;
};
struct Property {
@@ -62,6 +63,7 @@ struct NativeScriptDesc {
PropertyInfo info;
Variant default_value;
int rset_mode;
+ uint16_t rset_property_id;
String documentation;
};
@@ -70,7 +72,9 @@ struct NativeScriptDesc {
String documentation;
};
+ uint16_t rpc_count;
Map<StringName, Method> methods;
+ uint16_t rset_count;
OrderedHashMap<StringName, Property> properties;
Map<StringName, Signal> signals_; // QtCreator doesn't like the name signals
StringName base;
@@ -86,7 +90,9 @@ struct NativeScriptDesc {
bool is_tool;
inline NativeScriptDesc() :
+ rpc_count(0),
methods(),
+ rset_count(0),
properties(),
signals_(),
base(),
@@ -174,12 +180,24 @@ public:
virtual void get_script_method_list(List<MethodInfo> *p_list) const;
virtual void get_script_property_list(List<PropertyInfo> *p_list) const;
+ virtual Vector<ScriptNetData> get_rpc_methods() const;
+ virtual uint16_t get_rpc_method_id(const StringName &p_method) const;
+ virtual StringName get_rpc_method(uint16_t p_id) const;
+ virtual MultiplayerAPI::RPCMode get_rpc_mode_by_id(uint16_t p_id) const;
+ virtual MultiplayerAPI::RPCMode get_rpc_mode(const StringName &p_method) const;
+
+ virtual Vector<ScriptNetData> get_rset_properties() const;
+ virtual uint16_t get_rset_property_id(const StringName &p_variable) const;
+ virtual StringName get_rset_property(uint16_t p_id) const;
+ virtual MultiplayerAPI::RPCMode get_rset_mode_by_id(uint16_t p_id) const;
+ virtual MultiplayerAPI::RPCMode get_rset_mode(const StringName &p_variable) const;
+
String get_class_documentation() const;
String get_method_documentation(const StringName &p_method) const;
String get_signal_documentation(const StringName &p_signal_name) const;
String get_property_documentation(const StringName &p_path) const;
- Variant _new(const Variant **p_args, int p_argcount, Variant::CallError &r_error);
+ Variant _new(const Variant **p_args, int p_argcount, Callable::CallError &r_error);
NativeScript();
~NativeScript();
@@ -206,12 +224,23 @@ public:
virtual Variant::Type get_property_type(const StringName &p_name, bool *r_is_valid) const;
virtual void get_method_list(List<MethodInfo> *p_list) const;
virtual bool has_method(const StringName &p_method) const;
- virtual Variant call(const StringName &p_method, const Variant **p_args, int p_argcount, Variant::CallError &r_error);
+ virtual Variant call(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error);
virtual void notification(int p_notification);
String to_string(bool *r_valid);
virtual Ref<Script> get_script() const;
+
+ virtual Vector<ScriptNetData> get_rpc_methods() const;
+ virtual uint16_t get_rpc_method_id(const StringName &p_method) const;
+ virtual StringName get_rpc_method(uint16_t p_id) const;
+ virtual MultiplayerAPI::RPCMode get_rpc_mode_by_id(uint16_t p_id) const;
virtual MultiplayerAPI::RPCMode get_rpc_mode(const StringName &p_method) const;
+
+ virtual Vector<ScriptNetData> get_rset_properties() const;
+ virtual uint16_t get_rset_property_id(const StringName &p_variable) const;
+ virtual StringName get_rset_property(uint16_t p_id) const;
+ virtual MultiplayerAPI::RPCMode get_rset_mode_by_id(uint16_t p_id) const;
virtual MultiplayerAPI::RPCMode get_rset_mode(const StringName &p_variable) const;
+
virtual ScriptLanguage *get_language();
virtual void call_multilevel(const StringName &p_method, const Variant **p_args, int p_argcount);
@@ -323,7 +352,7 @@ public:
virtual bool has_named_classes() const;
virtual bool supports_builtin_mode() const;
virtual int find_function(const String &p_function, const String &p_code) const;
- virtual String make_function(const String &p_class, const String &p_name, const PoolStringArray &p_args) const;
+ virtual String make_function(const String &p_class, const String &p_name, const PackedStringArray &p_args) const;
virtual void auto_indent_code(String &p_code, int p_from_line, int p_to_line) const;
virtual void add_global_constant(const StringName &p_variable, const Variant &p_value);
virtual String debug_get_error() const;
diff --git a/modules/gdnative/pluginscript/pluginscript_instance.cpp b/modules/gdnative/pluginscript/pluginscript_instance.cpp
index c64a00a4d9..22e8372130 100644
--- a/modules/gdnative/pluginscript/pluginscript_instance.cpp
+++ b/modules/gdnative/pluginscript/pluginscript_instance.cpp
@@ -39,13 +39,11 @@
#include "pluginscript_script.h"
bool PluginScriptInstance::set(const StringName &p_name, const Variant &p_value) {
- String name = String(p_name);
- return _desc->set_prop(_data, (const godot_string *)&name, (const godot_variant *)&p_value);
+ return _desc->set_prop(_data, (const godot_string_name *)&p_name, (const godot_variant *)&p_value);
}
bool PluginScriptInstance::get(const StringName &p_name, Variant &r_ret) const {
- String name = String(p_name);
- return _desc->get_prop(_data, (const godot_string *)&name, (godot_variant *)&r_ret);
+ return _desc->get_prop(_data, (const godot_string_name *)&p_name, (godot_variant *)&r_ret);
}
Ref<Script> PluginScriptInstance::get_script() const {
@@ -81,7 +79,7 @@ bool PluginScriptInstance::has_method(const StringName &p_method) const {
return _script->has_method(p_method);
}
-Variant PluginScriptInstance::call(const StringName &p_method, const Variant **p_args, int p_argcount, Variant::CallError &r_error) {
+Variant PluginScriptInstance::call(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
// TODO: optimize when calling a Godot method from Godot to avoid param conversion ?
godot_variant ret = _desc->call_method(
_data, (godot_string_name *)&p_method, (const godot_variant **)p_args,
@@ -95,10 +93,42 @@ void PluginScriptInstance::notification(int p_notification) {
_desc->notification(_data, p_notification);
}
+Vector<ScriptNetData> PluginScriptInstance::get_rpc_methods() const {
+ return _script->get_rpc_methods();
+}
+
+uint16_t PluginScriptInstance::get_rpc_method_id(const StringName &p_variable) const {
+ return _script->get_rpc_method_id(p_variable);
+}
+
+StringName PluginScriptInstance::get_rpc_method(uint16_t p_id) const {
+ return _script->get_rpc_method(p_id);
+}
+
+MultiplayerAPI::RPCMode PluginScriptInstance::get_rpc_mode_by_id(uint16_t p_id) const {
+ return _script->get_rpc_mode_by_id(p_id);
+}
+
MultiplayerAPI::RPCMode PluginScriptInstance::get_rpc_mode(const StringName &p_method) const {
return _script->get_rpc_mode(p_method);
}
+Vector<ScriptNetData> PluginScriptInstance::get_rset_properties() const {
+ return _script->get_rset_properties();
+}
+
+uint16_t PluginScriptInstance::get_rset_property_id(const StringName &p_variable) const {
+ return _script->get_rset_property_id(p_variable);
+}
+
+StringName PluginScriptInstance::get_rset_property(uint16_t p_id) const {
+ return _script->get_rset_property(p_id);
+}
+
+MultiplayerAPI::RPCMode PluginScriptInstance::get_rset_mode_by_id(uint16_t p_id) const {
+ return _script->get_rset_mode_by_id(p_id);
+}
+
MultiplayerAPI::RPCMode PluginScriptInstance::get_rset_mode(const StringName &p_variable) const {
return _script->get_rset_mode(p_variable);
}
diff --git a/modules/gdnative/pluginscript/pluginscript_instance.h b/modules/gdnative/pluginscript/pluginscript_instance.h
index dc1229a44d..c91ad643a7 100644
--- a/modules/gdnative/pluginscript/pluginscript_instance.h
+++ b/modules/gdnative/pluginscript/pluginscript_instance.h
@@ -60,7 +60,7 @@ public:
virtual void get_method_list(List<MethodInfo> *p_list) const;
virtual bool has_method(const StringName &p_method) const;
- virtual Variant call(const StringName &p_method, const Variant **p_args, int p_argcount, Variant::CallError &r_error);
+ virtual Variant call(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error);
// Rely on default implementations provided by ScriptInstance for the moment.
// Note that multilevel call could be removed in 3.0 release, so stay tuned
@@ -76,7 +76,16 @@ public:
void set_path(const String &p_path);
+ virtual Vector<ScriptNetData> get_rpc_methods() const;
+ virtual uint16_t get_rpc_method_id(const StringName &p_method) const;
+ virtual StringName get_rpc_method(uint16_t p_id) const;
+ virtual MultiplayerAPI::RPCMode get_rpc_mode_by_id(uint16_t p_id) const;
virtual MultiplayerAPI::RPCMode get_rpc_mode(const StringName &p_method) const;
+
+ virtual Vector<ScriptNetData> get_rset_properties() const;
+ virtual uint16_t get_rset_property_id(const StringName &p_variable) const;
+ virtual StringName get_rset_property(uint16_t p_id) const;
+ virtual MultiplayerAPI::RPCMode get_rset_mode_by_id(uint16_t p_id) const;
virtual MultiplayerAPI::RPCMode get_rset_mode(const StringName &p_variable) const;
virtual void refcount_incremented();
diff --git a/modules/gdnative/pluginscript/pluginscript_language.cpp b/modules/gdnative/pluginscript/pluginscript_language.cpp
index 41f0e34243..4e39f4b0a8 100644
--- a/modules/gdnative/pluginscript/pluginscript_language.cpp
+++ b/modules/gdnative/pluginscript/pluginscript_language.cpp
@@ -109,7 +109,7 @@ Ref<Script> PluginScriptLanguage::get_template(const String &p_class_name, const
}
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 {
- PoolStringArray functions;
+ PackedStringArray functions;
if (_desc.validate) {
bool ret = _desc.validate(
_data,
@@ -118,7 +118,7 @@ bool PluginScriptLanguage::validate(const String &p_script, int &r_line_error, i
&r_col_error,
(godot_string *)&r_test_error,
(godot_string *)&p_path,
- (godot_pool_string_array *)&functions);
+ (godot_packed_string_array *)&functions);
for (int i = 0; i < functions.size(); i++) {
r_functions->push_back(functions[i]);
}
@@ -149,9 +149,9 @@ int PluginScriptLanguage::find_function(const String &p_function, const String &
return -1;
}
-String PluginScriptLanguage::make_function(const String &p_class, const String &p_name, const PoolStringArray &p_args) const {
+String PluginScriptLanguage::make_function(const String &p_class, const String &p_name, const PackedStringArray &p_args) const {
if (_desc.make_function) {
- godot_string tmp = _desc.make_function(_data, (godot_string *)&p_class, (godot_string *)&p_name, (godot_pool_string_array *)&p_args);
+ godot_string tmp = _desc.make_function(_data, (godot_string *)&p_class, (godot_string *)&p_name, (godot_packed_string_array *)&p_args);
String ret = *(String *)&tmp;
godot_string_destroy(&tmp);
return ret;
@@ -187,8 +187,7 @@ void PluginScriptLanguage::auto_indent_code(String &p_code, int p_from_line, int
}
void PluginScriptLanguage::add_global_constant(const StringName &p_variable, const Variant &p_value) {
- const String variable = String(p_variable);
- _desc.add_global_constant(_data, (godot_string *)&variable, (godot_variant *)&p_value);
+ _desc.add_global_constant(_data, (godot_string_name *)&p_variable, (godot_variant *)&p_value);
}
/* LOADER FUNCTIONS */
@@ -337,9 +336,9 @@ String PluginScriptLanguage::debug_get_stack_level_source(int p_level) const {
void PluginScriptLanguage::debug_get_stack_level_locals(int p_level, List<String> *p_locals, List<Variant> *p_values, int p_max_subitems, int p_max_depth) {
if (_desc.debug_get_stack_level_locals) {
- PoolStringArray locals;
+ PackedStringArray locals;
Array values;
- _desc.debug_get_stack_level_locals(_data, p_level, (godot_pool_string_array *)&locals, (godot_array *)&values, p_max_subitems, p_max_depth);
+ _desc.debug_get_stack_level_locals(_data, p_level, (godot_packed_string_array *)&locals, (godot_array *)&values, p_max_subitems, p_max_depth);
for (int i = 0; i < locals.size(); i++) {
p_locals->push_back(locals[i]);
}
@@ -351,9 +350,9 @@ void PluginScriptLanguage::debug_get_stack_level_locals(int p_level, List<String
void PluginScriptLanguage::debug_get_stack_level_members(int p_level, List<String> *p_members, List<Variant> *p_values, int p_max_subitems, int p_max_depth) {
if (_desc.debug_get_stack_level_members) {
- PoolStringArray members;
+ PackedStringArray members;
Array values;
- _desc.debug_get_stack_level_members(_data, p_level, (godot_pool_string_array *)&members, (godot_array *)&values, p_max_subitems, p_max_depth);
+ _desc.debug_get_stack_level_members(_data, p_level, (godot_packed_string_array *)&members, (godot_array *)&values, p_max_subitems, p_max_depth);
for (int i = 0; i < members.size(); i++) {
p_members->push_back(members[i]);
}
@@ -365,9 +364,9 @@ void PluginScriptLanguage::debug_get_stack_level_members(int p_level, List<Strin
void PluginScriptLanguage::debug_get_globals(List<String> *p_locals, List<Variant> *p_values, int p_max_subitems, int p_max_depth) {
if (_desc.debug_get_globals) {
- PoolStringArray locals;
+ PackedStringArray locals;
Array values;
- _desc.debug_get_globals(_data, (godot_pool_string_array *)&locals, (godot_array *)&values, p_max_subitems, p_max_depth);
+ _desc.debug_get_globals(_data, (godot_packed_string_array *)&locals, (godot_array *)&values, p_max_subitems, p_max_depth);
for (int i = 0; i < locals.size(); i++) {
p_locals->push_back(locals[i]);
}
diff --git a/modules/gdnative/pluginscript/pluginscript_language.h b/modules/gdnative/pluginscript/pluginscript_language.h
index 145ab5599c..037d7a4948 100644
--- a/modules/gdnative/pluginscript/pluginscript_language.h
+++ b/modules/gdnative/pluginscript/pluginscript_language.h
@@ -80,7 +80,7 @@ public:
virtual bool supports_builtin_mode() const;
virtual bool can_inherit_from_file() { return true; }
virtual int find_function(const String &p_function, const String &p_code) const;
- virtual String make_function(const String &p_class, const String &p_name, const PoolStringArray &p_args) const;
+ virtual String make_function(const String &p_class, const String &p_name, const PackedStringArray &p_args) const;
virtual Error complete_code(const String &p_code, const String &p_path, Object *p_owner, List<ScriptCodeCompletionOption> *r_options, bool &r_force, String &r_call_hint);
virtual void auto_indent_code(String &p_code, int p_from_line, int p_to_line) const;
virtual void add_global_constant(const StringName &p_variable, const Variant &p_value);
diff --git a/modules/gdnative/pluginscript/pluginscript_script.cpp b/modules/gdnative/pluginscript/pluginscript_script.cpp
index cc5bdee0a1..fe1f63f6da 100644
--- a/modules/gdnative/pluginscript/pluginscript_script.cpp
+++ b/modules/gdnative/pluginscript/pluginscript_script.cpp
@@ -34,6 +34,8 @@
#include "pluginscript_instance.h"
#include "pluginscript_script.h"
+#include <stdint.h>
+
#ifdef DEBUG_ENABLED
#define __ASSERT_SCRIPT_REASON "Cannot retrieve PluginScript class for this script, is your code correct?"
#define ASSERT_SCRIPT_VALID() \
@@ -53,9 +55,9 @@ void PluginScript::_bind_methods() {
ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "new", &PluginScript::_new, MethodInfo("new"));
}
-PluginScriptInstance *PluginScript::_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, Variant::CallError &r_error) {
+PluginScriptInstance *PluginScript::_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, Callable::CallError &r_error) {
- r_error.error = Variant::CallError::CALL_OK;
+ r_error.error = Callable::CallError::CALL_OK;
// Create instance
PluginScriptInstance *instance = memnew(PluginScriptInstance());
@@ -65,7 +67,7 @@ PluginScriptInstance *PluginScript::_create_instance(const Variant **p_args, int
_instances.insert(instance->get_owner());
_language->unlock();
} else {
- r_error.error = Variant::CallError::CALL_ERROR_INSTANCE_IS_NULL;
+ r_error.error = Callable::CallError::CALL_ERROR_INSTANCE_IS_NULL;
memdelete(instance);
ERR_FAIL_V(NULL);
}
@@ -81,12 +83,12 @@ PluginScriptInstance *PluginScript::_create_instance(const Variant **p_args, int
return instance;
}
-Variant PluginScript::_new(const Variant **p_args, int p_argcount, Variant::CallError &r_error) {
+Variant PluginScript::_new(const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
- r_error.error = Variant::CallError::CALL_OK;
+ r_error.error = Callable::CallError::CALL_OK;
if (!_valid) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
return Variant();
}
@@ -100,7 +102,7 @@ Variant PluginScript::_new(const Variant **p_args, int p_argcount, Variant::Call
}
if (!owner) {
- r_error.error = Variant::CallError::CALL_ERROR_INSTANCE_IS_NULL;
+ r_error.error = Callable::CallError::CALL_ERROR_INSTANCE_IS_NULL;
return Variant();
}
@@ -199,7 +201,7 @@ ScriptInstance *PluginScript::instance_create(Object *p_this) {
}
}
- Variant::CallError unchecked_error;
+ Callable::CallError unchecked_error;
return _create_instance(NULL, 0, p_this, unchecked_error);
}
@@ -298,18 +300,31 @@ Error PluginScript::reload(bool p_keep_state) {
_member_lines[*key] = (*members)[*key];
}
Array *methods = (Array *)&manifest.methods;
+ _rpc_methods.clear();
+ _rpc_variables.clear();
+ if (_ref_base_parent.is_valid()) {
+ _rpc_methods = _ref_base_parent->get_rpc_methods();
+ _rpc_variables = _ref_base_parent->get_rset_properties();
+ }
for (int i = 0; i < methods->size(); ++i) {
Dictionary v = (*methods)[i];
MethodInfo mi = MethodInfo::from_dict(v);
_methods_info[mi.name] = mi;
// rpc_mode is passed as an optional field and is not part of MethodInfo
Variant var = v["rpc_mode"];
- if (var == Variant()) {
- _methods_rpc_mode[mi.name] = MultiplayerAPI::RPC_MODE_DISABLED;
- } else {
- _methods_rpc_mode[mi.name] = MultiplayerAPI::RPCMode(int(var));
+ if (var != Variant()) {
+ ScriptNetData nd;
+ nd.name = mi.name;
+ nd.mode = MultiplayerAPI::RPCMode(int(var));
+ if (_rpc_methods.find(nd) == -1) {
+ _rpc_methods.push_back(nd);
+ }
}
}
+
+ // Sort so we are 100% that they are always the same.
+ _rpc_methods.sort_custom<SortNetData>();
+
Array *signals = (Array *)&manifest.signals;
for (int i = 0; i < signals->size(); ++i) {
Variant v = (*signals)[i];
@@ -324,13 +339,19 @@ Error PluginScript::reload(bool p_keep_state) {
_properties_default_values[pi.name] = v["default_value"];
// rset_mode is passed as an optional field and is not part of PropertyInfo
Variant var = v["rset_mode"];
- if (var == Variant()) {
- _methods_rpc_mode[pi.name] = MultiplayerAPI::RPC_MODE_DISABLED;
- } else {
- _methods_rpc_mode[pi.name] = MultiplayerAPI::RPCMode(int(var));
+ if (var != Variant()) {
+ ScriptNetData nd;
+ nd.name = pi.name;
+ nd.mode = MultiplayerAPI::RPCMode(int(var));
+ if (_rpc_variables.find(nd) == -1) {
+ _rpc_variables.push_back(nd);
+ }
}
}
+ // Sort so we are 100% that they are always the same.
+ _rpc_variables.sort_custom<SortNetData>();
+
#ifdef TOOLS_ENABLED
/*for (Set<PlaceHolderScriptInstance*>::Element *E=placeholders.front();E;E=E->next()) {
@@ -407,22 +428,22 @@ ScriptLanguage *PluginScript::get_language() const {
Error PluginScript::load_source_code(const String &p_path) {
- PoolVector<uint8_t> sourcef;
+ Vector<uint8_t> sourcef;
Error err;
FileAccess *f = FileAccess::open(p_path, FileAccess::READ, &err);
ERR_FAIL_COND_V_MSG(err, err, "Cannot open file '" + p_path + "'.");
int len = f->get_len();
sourcef.resize(len + 1);
- PoolVector<uint8_t>::Write w = sourcef.write();
- int r = f->get_buffer(w.ptr(), len);
+ uint8_t *w = sourcef.ptrw();
+ int r = f->get_buffer(w, len);
f->close();
memdelete(f);
ERR_FAIL_COND_V(r != len, ERR_CANT_OPEN);
w[len] = 0;
String s;
- if (s.parse_utf8((const char *)w.ptr())) {
+ if (s.parse_utf8((const char *)w)) {
ERR_FAIL_V_MSG(ERR_INVALID_DATA, "Script '" + p_path + "' contains invalid unicode (UTF-8), so it was not loaded. Please ensure that scripts are saved in valid UTF-8 unicode.");
}
@@ -455,24 +476,70 @@ int PluginScript::get_member_line(const StringName &p_member) const {
return -1;
}
-MultiplayerAPI::RPCMode PluginScript::get_rpc_mode(const StringName &p_method) const {
+Vector<ScriptNetData> PluginScript::get_rpc_methods() const {
+ return _rpc_methods;
+}
+
+uint16_t PluginScript::get_rpc_method_id(const StringName &p_method) const {
+ ASSERT_SCRIPT_VALID_V(UINT16_MAX);
+ for (int i = 0; i < _rpc_methods.size(); i++) {
+ if (_rpc_methods[i].name == p_method) {
+ return i;
+ }
+ }
+ return UINT16_MAX;
+}
+
+StringName PluginScript::get_rpc_method(const uint16_t p_rpc_method_id) const {
+ ASSERT_SCRIPT_VALID_V(StringName());
+ if (p_rpc_method_id >= _rpc_methods.size())
+ return StringName();
+ return _rpc_methods[p_rpc_method_id].name;
+}
+
+MultiplayerAPI::RPCMode PluginScript::get_rpc_mode_by_id(const uint16_t p_rpc_method_id) const {
ASSERT_SCRIPT_VALID_V(MultiplayerAPI::RPC_MODE_DISABLED);
- const Map<StringName, MultiplayerAPI::RPCMode>::Element *e = _methods_rpc_mode.find(p_method);
- if (e != NULL) {
- return e->get();
- } else {
+ if (p_rpc_method_id >= _rpc_methods.size())
return MultiplayerAPI::RPC_MODE_DISABLED;
+ return _rpc_methods[p_rpc_method_id].mode;
+}
+
+MultiplayerAPI::RPCMode PluginScript::get_rpc_mode(const StringName &p_method) const {
+ ASSERT_SCRIPT_VALID_V(MultiplayerAPI::RPC_MODE_DISABLED);
+ return get_rpc_mode_by_id(get_rpc_method_id(p_method));
+}
+
+Vector<ScriptNetData> PluginScript::get_rset_properties() const {
+ return _rpc_variables;
+}
+
+uint16_t PluginScript::get_rset_property_id(const StringName &p_property) const {
+ ASSERT_SCRIPT_VALID_V(UINT16_MAX);
+ for (int i = 0; i < _rpc_variables.size(); i++) {
+ if (_rpc_variables[i].name == p_property) {
+ return i;
+ }
}
+ return UINT16_MAX;
}
-MultiplayerAPI::RPCMode PluginScript::get_rset_mode(const StringName &p_variable) const {
+StringName PluginScript::get_rset_property(const uint16_t p_rset_property_id) const {
+ ASSERT_SCRIPT_VALID_V(StringName());
+ if (p_rset_property_id >= _rpc_variables.size())
+ return StringName();
+ return _rpc_variables[p_rset_property_id].name;
+}
+
+MultiplayerAPI::RPCMode PluginScript::get_rset_mode_by_id(const uint16_t p_rset_property_id) const {
ASSERT_SCRIPT_VALID_V(MultiplayerAPI::RPC_MODE_DISABLED);
- const Map<StringName, MultiplayerAPI::RPCMode>::Element *e = _variables_rset_mode.find(p_variable);
- if (e != NULL) {
- return e->get();
- } else {
+ if (p_rset_property_id >= _rpc_variables.size())
return MultiplayerAPI::RPC_MODE_DISABLED;
- }
+ return _rpc_variables[p_rset_property_id].mode;
+}
+
+MultiplayerAPI::RPCMode PluginScript::get_rset_mode(const StringName &p_variable) const {
+ ASSERT_SCRIPT_VALID_V(MultiplayerAPI::RPC_MODE_DISABLED);
+ return get_rset_mode_by_id(get_rset_property_id(p_variable));
}
PluginScript::PluginScript() :
diff --git a/modules/gdnative/pluginscript/pluginscript_script.h b/modules/gdnative/pluginscript/pluginscript_script.h
index f67c88c794..5c93ae38f5 100644
--- a/modules/gdnative/pluginscript/pluginscript_script.h
+++ b/modules/gdnative/pluginscript/pluginscript_script.h
@@ -60,8 +60,8 @@ private:
Map<StringName, PropertyInfo> _properties_info;
Map<StringName, MethodInfo> _signals_info;
Map<StringName, MethodInfo> _methods_info;
- Map<StringName, MultiplayerAPI::RPCMode> _variables_rset_mode;
- Map<StringName, MultiplayerAPI::RPCMode> _methods_rpc_mode;
+ Vector<ScriptNetData> _rpc_methods;
+ Vector<ScriptNetData> _rpc_variables;
Set<Object *> _instances;
//exported members
@@ -72,8 +72,8 @@ private:
protected:
static void _bind_methods();
- PluginScriptInstance *_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, Variant::CallError &r_error);
- Variant _new(const Variant **p_args, int p_argcount, Variant::CallError &r_error);
+ PluginScriptInstance *_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, Callable::CallError &r_error);
+ Variant _new(const Variant **p_args, int p_argcount, Callable::CallError &r_error);
#ifdef TOOLS_ENABLED
Set<PlaceHolderScriptInstance *> placeholders;
@@ -118,8 +118,17 @@ public:
virtual int get_member_line(const StringName &p_member) const;
- MultiplayerAPI::RPCMode get_rpc_mode(const StringName &p_method) const;
- MultiplayerAPI::RPCMode get_rset_mode(const StringName &p_variable) const;
+ virtual Vector<ScriptNetData> get_rpc_methods() const;
+ virtual uint16_t get_rpc_method_id(const StringName &p_method) const;
+ virtual StringName get_rpc_method(const uint16_t p_rpc_method_id) const;
+ virtual MultiplayerAPI::RPCMode get_rpc_mode_by_id(const uint16_t p_rpc_method_id) const;
+ virtual MultiplayerAPI::RPCMode get_rpc_mode(const StringName &p_method) const;
+
+ virtual Vector<ScriptNetData> get_rset_properties() const;
+ virtual uint16_t get_rset_property_id(const StringName &p_property) const;
+ virtual StringName get_rset_property(const uint16_t p_rset_property_id) const;
+ virtual MultiplayerAPI::RPCMode get_rset_mode_by_id(const uint16_t p_rpc_method_id) const;
+ virtual MultiplayerAPI::RPCMode get_rset_mode(const StringName &p_variable) const;
PluginScript();
void init(PluginScriptLanguage *language);
diff --git a/modules/gdnative/register_types.cpp b/modules/gdnative/register_types.cpp
index 4142f60ba6..e5d688afd4 100644
--- a/modules/gdnative/register_types.cpp
+++ b/modules/gdnative/register_types.cpp
@@ -325,7 +325,7 @@ void unregister_gdnative_types() {
print_line(String("dict:\t" ) + itos(sizeof(Dictionary)));
print_line(String("node_path:\t") + itos(sizeof(NodePath)));
print_line(String("plane:\t") + itos(sizeof(Plane)));
- print_line(String("poolarray:\t") + itos(sizeof(PoolByteArray)));
+ print_line(String("poolarray:\t") + itos(sizeof(PackedByteArray)));
print_line(String("quat:\t") + itos(sizeof(Quat)));
print_line(String("rect2:\t") + itos(sizeof(Rect2)));
print_line(String("aabb:\t") + itos(sizeof(AABB)));
diff --git a/modules/gdnative/videodecoder/video_stream_gdnative.cpp b/modules/gdnative/videodecoder/video_stream_gdnative.cpp
index dbe00cdf71..bd16563ff0 100644
--- a/modules/gdnative/videodecoder/video_stream_gdnative.cpp
+++ b/modules/gdnative/videodecoder/video_stream_gdnative.cpp
@@ -132,7 +132,11 @@ bool VideoStreamPlaybackGDNative::open_file(const String &p_file) {
pcm_write_idx = -1;
samples_decoded = 0;
- texture->create((int)texture_size.width, (int)texture_size.height, Image::FORMAT_RGBA8, Texture::FLAG_FILTER | Texture::FLAG_VIDEO_SURFACE);
+ Ref<Image> img;
+ img.instance();
+ img->create((int)texture_size.width, false, (int)texture_size.height, Image::FORMAT_RGBA8);
+
+ texture->create_from_image(img);
}
return file_opened;
@@ -183,7 +187,7 @@ void VideoStreamPlaybackGDNative::update(float p_delta) {
}
void VideoStreamPlaybackGDNative::update_texture() {
- PoolByteArray *pba = (PoolByteArray *)interface->get_videoframe(data_struct);
+ PackedByteArray *pba = (PackedByteArray *)interface->get_videoframe(data_struct);
if (pba == NULL) {
playing = false;
@@ -192,7 +196,7 @@ void VideoStreamPlaybackGDNative::update_texture() {
Ref<Image> img = memnew(Image(texture_size.width, texture_size.height, 0, Image::FORMAT_RGBA8, *pba));
- texture->set_data(img);
+ texture->update(img, true);
}
// ctor and dtor
@@ -283,7 +287,7 @@ void VideoStreamPlaybackGDNative::set_paused(bool p_paused) {
paused = p_paused;
}
-Ref<Texture> VideoStreamPlaybackGDNative::get_texture() const {
+Ref<Texture2D> VideoStreamPlaybackGDNative::get_texture() const {
return texture;
}
diff --git a/modules/gdnative/videodecoder/video_stream_gdnative.h b/modules/gdnative/videodecoder/video_stream_gdnative.h
index bb0346efb4..024cdec196 100644
--- a/modules/gdnative/videodecoder/video_stream_gdnative.h
+++ b/modules/gdnative/videodecoder/video_stream_gdnative.h
@@ -168,7 +168,7 @@ public:
//virtual int mix(int16_t* p_buffer,int p_frames)=0;
- virtual Ref<Texture> get_texture() const;
+ virtual Ref<Texture2D> get_texture() const;
virtual void update(float p_delta);
virtual void set_mix_callback(AudioMixCallback p_callback, void *p_userdata);
diff --git a/modules/gdnavigation/SCsub b/modules/gdnavigation/SCsub
new file mode 100644
index 0000000000..9d462f92a7
--- /dev/null
+++ b/modules/gdnavigation/SCsub
@@ -0,0 +1,50 @@
+#!/usr/bin/env python
+
+Import('env')
+Import('env_modules')
+
+env_navigation = env_modules.Clone()
+
+# Recast Thirdparty source files
+if env['builtin_recast']:
+ thirdparty_dir = "#thirdparty/recastnavigation/Recast/"
+ thirdparty_sources = [
+ "Source/Recast.cpp",
+ "Source/RecastAlloc.cpp",
+ "Source/RecastArea.cpp",
+ "Source/RecastAssert.cpp",
+ "Source/RecastContour.cpp",
+ "Source/RecastFilter.cpp",
+ "Source/RecastLayers.cpp",
+ "Source/RecastMesh.cpp",
+ "Source/RecastMeshDetail.cpp",
+ "Source/RecastRasterization.cpp",
+ "Source/RecastRegion.cpp",
+ ]
+ thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
+
+ env_navigation.Prepend(CPPPATH=[thirdparty_dir + "/Include"])
+
+ env_thirdparty = env_navigation.Clone()
+ env_thirdparty.disable_warnings()
+ env_thirdparty.add_source_files(env.modules_sources, thirdparty_sources)
+
+
+# RVO Thirdparty source files
+if env['builtin_rvo2']:
+ thirdparty_dir = "#thirdparty/rvo2"
+ thirdparty_sources = [
+ "/src/Agent.cpp",
+ "/src/KdTree.cpp",
+ ]
+ thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
+
+ env_navigation.Prepend(CPPPATH=[thirdparty_dir + "/src"])
+
+ env_thirdparty = env_navigation.Clone()
+ env_thirdparty.disable_warnings()
+ env_thirdparty.add_source_files(env.modules_sources, thirdparty_sources)
+
+
+# Godot source files
+env_navigation.add_source_files(env.modules_sources, "*.cpp")
diff --git a/modules/gdnavigation/config.py b/modules/gdnavigation/config.py
new file mode 100644
index 0000000000..1c8cd12a2d
--- /dev/null
+++ b/modules/gdnavigation/config.py
@@ -0,0 +1,5 @@
+def can_build(env, platform):
+ return True
+
+def configure(env):
+ pass
diff --git a/modules/gdnavigation/gd_navigation_server.cpp b/modules/gdnavigation/gd_navigation_server.cpp
new file mode 100644
index 0000000000..4129d1f65a
--- /dev/null
+++ b/modules/gdnavigation/gd_navigation_server.cpp
@@ -0,0 +1,512 @@
+/*************************************************************************/
+/* gd_navigation_server.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#include "gd_navigation_server.h"
+
+#include "core/os/mutex.h"
+
+#ifndef _3D_DISABLED
+#include "navigation_mesh_generator.h"
+#endif
+
+/**
+ @author AndreaCatania
+*/
+
+/// Creates a struct for each function and a function that once called creates
+/// an instance of that struct with the submited parameters.
+/// Then, that struct is stored in an array; the `sync` function consume that array.
+
+#define COMMAND_1(F_NAME, T_0, D_0) \
+ struct MERGE(F_NAME, _command) : public SetCommand { \
+ T_0 d_0; \
+ MERGE(F_NAME, _command) \
+ (T_0 p_d_0) : \
+ d_0(p_d_0) {} \
+ virtual void exec(GdNavigationServer *server) { \
+ server->MERGE(_cmd_, F_NAME)(d_0); \
+ } \
+ }; \
+ void GdNavigationServer::F_NAME(T_0 D_0) const { \
+ auto cmd = memnew(MERGE(F_NAME, _command)( \
+ D_0)); \
+ add_command(cmd); \
+ } \
+ void GdNavigationServer::MERGE(_cmd_, F_NAME)(T_0 D_0)
+
+#define COMMAND_2(F_NAME, T_0, D_0, T_1, D_1) \
+ struct MERGE(F_NAME, _command) : public SetCommand { \
+ T_0 d_0; \
+ T_1 d_1; \
+ MERGE(F_NAME, _command) \
+ ( \
+ T_0 p_d_0, \
+ T_1 p_d_1) : \
+ d_0(p_d_0), \
+ d_1(p_d_1) {} \
+ virtual void exec(GdNavigationServer *server) { \
+ server->MERGE(_cmd_, F_NAME)(d_0, d_1); \
+ } \
+ }; \
+ void GdNavigationServer::F_NAME(T_0 D_0, T_1 D_1) const { \
+ auto cmd = memnew(MERGE(F_NAME, _command)( \
+ D_0, \
+ D_1)); \
+ add_command(cmd); \
+ } \
+ void GdNavigationServer::MERGE(_cmd_, F_NAME)(T_0 D_0, T_1 D_1)
+
+#define COMMAND_4(F_NAME, T_0, D_0, T_1, D_1, T_2, D_2, T_3, D_3) \
+ struct MERGE(F_NAME, _command) : public SetCommand { \
+ T_0 d_0; \
+ T_1 d_1; \
+ T_2 d_2; \
+ T_3 d_3; \
+ MERGE(F_NAME, _command) \
+ ( \
+ T_0 p_d_0, \
+ T_1 p_d_1, \
+ T_2 p_d_2, \
+ T_3 p_d_3) : \
+ d_0(p_d_0), \
+ d_1(p_d_1), \
+ d_2(p_d_2), \
+ d_3(p_d_3) {} \
+ virtual void exec(GdNavigationServer *server) { \
+ server->MERGE(_cmd_, F_NAME)(d_0, d_1, d_2, d_3); \
+ } \
+ }; \
+ void GdNavigationServer::F_NAME(T_0 D_0, T_1 D_1, T_2 D_2, T_3 D_3) const { \
+ auto cmd = memnew(MERGE(F_NAME, _command)( \
+ D_0, \
+ D_1, \
+ D_2, \
+ D_3)); \
+ add_command(cmd); \
+ } \
+ void GdNavigationServer::MERGE(_cmd_, F_NAME)(T_0 D_0, T_1 D_1, T_2 D_2, T_3 D_3)
+
+GdNavigationServer::GdNavigationServer() :
+ NavigationServer(),
+ commands_mutex(Mutex::create()),
+ operations_mutex(Mutex::create()),
+ active(true) {
+}
+
+GdNavigationServer::~GdNavigationServer() {
+ flush_queries();
+ memdelete(operations_mutex);
+ memdelete(commands_mutex);
+}
+
+void GdNavigationServer::add_command(SetCommand *command) const {
+ auto mut_this = const_cast<GdNavigationServer *>(this);
+ commands_mutex->lock();
+ mut_this->commands.push_back(command);
+ commands_mutex->unlock();
+}
+
+RID GdNavigationServer::map_create() const {
+ auto mut_this = const_cast<GdNavigationServer *>(this);
+ mut_this->operations_mutex->lock();
+ NavMap *space = memnew(NavMap);
+ RID rid = map_owner.make_rid(space);
+ space->set_self(rid);
+ mut_this->operations_mutex->unlock();
+ return rid;
+}
+
+COMMAND_2(map_set_active, RID, p_map, bool, p_active) {
+ NavMap *map = map_owner.getornull(p_map);
+ ERR_FAIL_COND(map == NULL);
+
+ if (p_active) {
+ if (!map_is_active(p_map)) {
+ active_maps.push_back(map);
+ }
+ } else {
+ active_maps.erase(map);
+ }
+}
+
+bool GdNavigationServer::map_is_active(RID p_map) const {
+ NavMap *map = map_owner.getornull(p_map);
+ ERR_FAIL_COND_V(map == NULL, false);
+
+ return active_maps.find(map) >= 0;
+}
+
+COMMAND_2(map_set_up, RID, p_map, Vector3, p_up) {
+ NavMap *map = map_owner.getornull(p_map);
+ ERR_FAIL_COND(map == NULL);
+
+ map->set_up(p_up);
+}
+
+Vector3 GdNavigationServer::map_get_up(RID p_map) const {
+ const NavMap *map = map_owner.getornull(p_map);
+ ERR_FAIL_COND_V(map == NULL, Vector3());
+
+ return map->get_up();
+}
+
+COMMAND_2(map_set_cell_size, RID, p_map, real_t, p_cell_size) {
+ NavMap *map = map_owner.getornull(p_map);
+ ERR_FAIL_COND(map == NULL);
+
+ map->set_cell_size(p_cell_size);
+}
+
+real_t GdNavigationServer::map_get_cell_size(RID p_map) const {
+ const NavMap *map = map_owner.getornull(p_map);
+ ERR_FAIL_COND_V(map == NULL, 0);
+
+ return map->get_cell_size();
+}
+
+COMMAND_2(map_set_edge_connection_margin, RID, p_map, real_t, p_connection_margin) {
+ NavMap *map = map_owner.getornull(p_map);
+ ERR_FAIL_COND(map == NULL);
+
+ map->set_edge_connection_margin(p_connection_margin);
+}
+
+real_t GdNavigationServer::map_get_edge_connection_margin(RID p_map) const {
+ const NavMap *map = map_owner.getornull(p_map);
+ ERR_FAIL_COND_V(map == NULL, 0);
+
+ return map->get_edge_connection_margin();
+}
+
+Vector<Vector3> GdNavigationServer::map_get_path(RID p_map, Vector3 p_origin, Vector3 p_destination, bool p_optimize) const {
+ const NavMap *map = map_owner.getornull(p_map);
+ ERR_FAIL_COND_V(map == NULL, Vector<Vector3>());
+
+ return map->get_path(p_origin, p_destination, p_optimize);
+}
+
+Vector3 GdNavigationServer::map_get_closest_point_to_segment(RID p_map, const Vector3 &p_from, const Vector3 &p_to, const bool p_use_collision) const {
+ const NavMap *map = map_owner.getornull(p_map);
+ ERR_FAIL_COND_V(map == NULL, Vector3());
+
+ return map->get_closest_point_to_segment(p_from, p_to, p_use_collision);
+}
+
+Vector3 GdNavigationServer::map_get_closest_point(RID p_map, const Vector3 &p_point) const {
+ const NavMap *map = map_owner.getornull(p_map);
+ ERR_FAIL_COND_V(map == NULL, Vector3());
+
+ return map->get_closest_point(p_point);
+}
+
+Vector3 GdNavigationServer::map_get_closest_point_normal(RID p_map, const Vector3 &p_point) const {
+ const NavMap *map = map_owner.getornull(p_map);
+ ERR_FAIL_COND_V(map == NULL, Vector3());
+
+ return map->get_closest_point_normal(p_point);
+}
+
+RID GdNavigationServer::map_get_closest_point_owner(RID p_map, const Vector3 &p_point) const {
+ const NavMap *map = map_owner.getornull(p_map);
+ ERR_FAIL_COND_V(map == NULL, RID());
+
+ return map->get_closest_point_owner(p_point);
+}
+
+RID GdNavigationServer::region_create() const {
+ auto mut_this = const_cast<GdNavigationServer *>(this);
+ mut_this->operations_mutex->lock();
+ NavRegion *reg = memnew(NavRegion);
+ RID rid = region_owner.make_rid(reg);
+ reg->set_self(rid);
+ mut_this->operations_mutex->unlock();
+ return rid;
+}
+
+COMMAND_2(region_set_map, RID, p_region, RID, p_map) {
+ NavRegion *region = region_owner.getornull(p_region);
+ ERR_FAIL_COND(region == NULL);
+
+ if (region->get_map() != NULL) {
+
+ if (region->get_map()->get_self() == p_map)
+ return; // Pointless
+
+ region->get_map()->remove_region(region);
+ region->set_map(NULL);
+ }
+
+ if (p_map.is_valid()) {
+ NavMap *map = map_owner.getornull(p_map);
+ ERR_FAIL_COND(map == NULL);
+
+ map->add_region(region);
+ region->set_map(map);
+ }
+}
+
+COMMAND_2(region_set_transform, RID, p_region, Transform, p_transform) {
+ NavRegion *region = region_owner.getornull(p_region);
+ ERR_FAIL_COND(region == NULL);
+
+ region->set_transform(p_transform);
+}
+
+COMMAND_2(region_set_navmesh, RID, p_region, Ref<NavigationMesh>, p_nav_mesh) {
+ NavRegion *region = region_owner.getornull(p_region);
+ ERR_FAIL_COND(region == NULL);
+
+ region->set_mesh(p_nav_mesh);
+}
+
+void GdNavigationServer::region_bake_navmesh(Ref<NavigationMesh> r_mesh, Node *p_node) const {
+ ERR_FAIL_COND(r_mesh.is_null());
+ ERR_FAIL_COND(p_node == NULL);
+
+#ifndef _3D_DISABLED
+ NavigationMeshGenerator::get_singleton()->clear(r_mesh);
+ NavigationMeshGenerator::get_singleton()->bake(r_mesh, p_node);
+#endif
+}
+
+RID GdNavigationServer::agent_create() const {
+ auto mut_this = const_cast<GdNavigationServer *>(this);
+ mut_this->operations_mutex->lock();
+ RvoAgent *agent = memnew(RvoAgent());
+ RID rid = agent_owner.make_rid(agent);
+ agent->set_self(rid);
+ mut_this->operations_mutex->unlock();
+ return rid;
+}
+
+COMMAND_2(agent_set_map, RID, p_agent, RID, p_map) {
+ RvoAgent *agent = agent_owner.getornull(p_agent);
+ ERR_FAIL_COND(agent == NULL);
+
+ if (agent->get_map()) {
+ if (agent->get_map()->get_self() == p_map)
+ return; // Pointless
+
+ agent->get_map()->remove_agent(agent);
+ }
+
+ agent->set_map(NULL);
+
+ if (p_map.is_valid()) {
+ NavMap *map = map_owner.getornull(p_map);
+ ERR_FAIL_COND(map == NULL);
+
+ agent->set_map(map);
+ map->add_agent(agent);
+
+ if (agent->has_callback()) {
+ map->set_agent_as_controlled(agent);
+ }
+ }
+}
+
+COMMAND_2(agent_set_neighbor_dist, RID, p_agent, real_t, p_dist) {
+ RvoAgent *agent = agent_owner.getornull(p_agent);
+ ERR_FAIL_COND(agent == NULL);
+
+ agent->get_agent()->neighborDist_ = p_dist;
+}
+
+COMMAND_2(agent_set_max_neighbors, RID, p_agent, int, p_count) {
+ RvoAgent *agent = agent_owner.getornull(p_agent);
+ ERR_FAIL_COND(agent == NULL);
+
+ agent->get_agent()->maxNeighbors_ = p_count;
+}
+
+COMMAND_2(agent_set_time_horizon, RID, p_agent, real_t, p_time) {
+ RvoAgent *agent = agent_owner.getornull(p_agent);
+ ERR_FAIL_COND(agent == NULL);
+
+ agent->get_agent()->timeHorizon_ = p_time;
+}
+
+COMMAND_2(agent_set_radius, RID, p_agent, real_t, p_radius) {
+ RvoAgent *agent = agent_owner.getornull(p_agent);
+ ERR_FAIL_COND(agent == NULL);
+
+ agent->get_agent()->radius_ = p_radius;
+}
+
+COMMAND_2(agent_set_max_speed, RID, p_agent, real_t, p_max_speed) {
+ RvoAgent *agent = agent_owner.getornull(p_agent);
+ ERR_FAIL_COND(agent == NULL);
+
+ agent->get_agent()->maxSpeed_ = p_max_speed;
+}
+
+COMMAND_2(agent_set_velocity, RID, p_agent, Vector3, p_velocity) {
+ RvoAgent *agent = agent_owner.getornull(p_agent);
+ ERR_FAIL_COND(agent == NULL);
+
+ agent->get_agent()->velocity_ = RVO::Vector3(p_velocity.x, p_velocity.y, p_velocity.z);
+}
+
+COMMAND_2(agent_set_target_velocity, RID, p_agent, Vector3, p_velocity) {
+ RvoAgent *agent = agent_owner.getornull(p_agent);
+ ERR_FAIL_COND(agent == NULL);
+
+ agent->get_agent()->prefVelocity_ = RVO::Vector3(p_velocity.x, p_velocity.y, p_velocity.z);
+}
+
+COMMAND_2(agent_set_position, RID, p_agent, Vector3, p_position) {
+ RvoAgent *agent = agent_owner.getornull(p_agent);
+ ERR_FAIL_COND(agent == NULL);
+
+ agent->get_agent()->position_ = RVO::Vector3(p_position.x, p_position.y, p_position.z);
+}
+
+COMMAND_2(agent_set_ignore_y, RID, p_agent, bool, p_ignore) {
+ RvoAgent *agent = agent_owner.getornull(p_agent);
+ ERR_FAIL_COND(agent == NULL);
+
+ agent->get_agent()->ignore_y_ = p_ignore;
+}
+
+bool GdNavigationServer::agent_is_map_changed(RID p_agent) const {
+ RvoAgent *agent = agent_owner.getornull(p_agent);
+ ERR_FAIL_COND_V(agent == NULL, false);
+
+ return agent->is_map_changed();
+}
+
+COMMAND_4(agent_set_callback, RID, p_agent, Object *, p_receiver, StringName, p_method, Variant, p_udata) {
+ RvoAgent *agent = agent_owner.getornull(p_agent);
+ ERR_FAIL_COND(agent == NULL);
+
+ agent->set_callback(p_receiver == NULL ? ObjectID() : p_receiver->get_instance_id(), p_method, p_udata);
+
+ if (agent->get_map()) {
+ if (p_receiver == NULL) {
+ agent->get_map()->remove_agent_as_controlled(agent);
+ } else {
+ agent->get_map()->set_agent_as_controlled(agent);
+ }
+ }
+}
+
+COMMAND_1(free, RID, p_object) {
+ if (map_owner.owns(p_object)) {
+ NavMap *map = map_owner.getornull(p_object);
+
+ // Removes any assigned region
+ std::vector<NavRegion *> regions = map->get_regions();
+ for (size_t i(0); i < regions.size(); i++) {
+ map->remove_region(regions[i]);
+ regions[i]->set_map(NULL);
+ }
+
+ // Remove any assigned agent
+ std::vector<RvoAgent *> agents = map->get_agents();
+ for (size_t i(0); i < agents.size(); i++) {
+ map->remove_agent(agents[i]);
+ agents[i]->set_map(NULL);
+ }
+
+ active_maps.erase(map);
+ map_owner.free(p_object);
+ memdelete(map);
+
+ } else if (region_owner.owns(p_object)) {
+ NavRegion *region = region_owner.getornull(p_object);
+
+ // Removes this region from the map if assigned
+ if (region->get_map() != NULL) {
+ region->get_map()->remove_region(region);
+ region->set_map(NULL);
+ }
+
+ region_owner.free(p_object);
+ memdelete(region);
+
+ } else if (agent_owner.owns(p_object)) {
+ RvoAgent *agent = agent_owner.getornull(p_object);
+
+ // Removes this agent from the map if assigned
+ if (agent->get_map() != NULL) {
+ agent->get_map()->remove_agent(agent);
+ agent->set_map(NULL);
+ }
+
+ agent_owner.free(p_object);
+ memdelete(agent);
+
+ } else {
+ ERR_FAIL_COND("Invalid ID.");
+ }
+}
+
+void GdNavigationServer::set_active(bool p_active) const {
+ auto mut_this = const_cast<GdNavigationServer *>(this);
+ mut_this->operations_mutex->lock();
+ mut_this->active = p_active;
+ mut_this->operations_mutex->unlock();
+}
+
+void GdNavigationServer::flush_queries() {
+ // In c++ we can't be sure that this is performed in the main thread
+ // even with mutable functions.
+ commands_mutex->lock();
+ operations_mutex->lock();
+ for (size_t i(0); i < commands.size(); i++) {
+ commands[i]->exec(this);
+ memdelete(commands[i]);
+ }
+ commands.clear();
+ operations_mutex->unlock();
+ commands_mutex->unlock();
+}
+
+void GdNavigationServer::process(real_t p_delta_time) {
+ flush_queries();
+
+ if (!active) {
+ return;
+ }
+
+ // In c++ we can't be sure that this is performed in the main thread
+ // even with mutable functions.
+ operations_mutex->lock();
+ for (int i(0); i < active_maps.size(); i++) {
+ active_maps[i]->sync();
+ active_maps[i]->step(p_delta_time);
+ active_maps[i]->dispatch_callbacks();
+ }
+ operations_mutex->unlock();
+}
+
+#undef COMMAND_1
+#undef COMMAND_2
+#undef COMMAND_4
diff --git a/modules/gdnavigation/gd_navigation_server.h b/modules/gdnavigation/gd_navigation_server.h
new file mode 100644
index 0000000000..0400acf1a3
--- /dev/null
+++ b/modules/gdnavigation/gd_navigation_server.h
@@ -0,0 +1,143 @@
+/*************************************************************************/
+/* gd_navigation_server.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifndef GD_NAVIGATION_SERVER_H
+#define GD_NAVIGATION_SERVER_H
+
+#include "core/rid.h"
+#include "core/rid_owner.h"
+#include "servers/navigation_server.h"
+
+#include "nav_map.h"
+#include "nav_region.h"
+#include "rvo_agent.h"
+
+/**
+ @author AndreaCatania
+*/
+
+/// The commands are functions executed during the `sync` phase.
+
+#define MERGE_INTERNAL(A, B) A##B
+#define MERGE(A, B) MERGE_INTERNAL(A, B)
+
+#define COMMAND_1(F_NAME, T_0, D_0) \
+ virtual void F_NAME(T_0 D_0) const; \
+ void MERGE(_cmd_, F_NAME)(T_0 D_0)
+
+#define COMMAND_2(F_NAME, T_0, D_0, T_1, D_1) \
+ virtual void F_NAME(T_0 D_0, T_1 D_1) const; \
+ void MERGE(_cmd_, F_NAME)(T_0 D_0, T_1 D_1)
+
+#define COMMAND_4_DEF(F_NAME, T_0, D_0, T_1, D_1, T_2, D_2, T_3, D_3, D_3_DEF) \
+ virtual void F_NAME(T_0 D_0, T_1 D_1, T_2 D_2, T_3 D_3 = D_3_DEF) const; \
+ void MERGE(_cmd_, F_NAME)(T_0 D_0, T_1 D_1, T_2 D_2, T_3 D_3)
+
+class GdNavigationServer;
+class Mutex;
+
+struct SetCommand {
+ virtual ~SetCommand() {}
+ virtual void exec(GdNavigationServer *server) = 0;
+};
+
+class GdNavigationServer : public NavigationServer {
+ Mutex *commands_mutex;
+ /// Mutex used to make any operation threadsafe.
+ Mutex *operations_mutex;
+
+ std::vector<SetCommand *> commands;
+
+ mutable RID_PtrOwner<NavMap> map_owner;
+ mutable RID_PtrOwner<NavRegion> region_owner;
+ mutable RID_PtrOwner<RvoAgent> agent_owner;
+
+ bool active;
+ Vector<NavMap *> active_maps;
+
+public:
+ GdNavigationServer();
+ virtual ~GdNavigationServer();
+
+ void add_command(SetCommand *command) const;
+
+ virtual RID map_create() const;
+ COMMAND_2(map_set_active, RID, p_map, bool, p_active);
+ virtual bool map_is_active(RID p_map) const;
+
+ COMMAND_2(map_set_up, RID, p_map, Vector3, p_up);
+ virtual Vector3 map_get_up(RID p_map) const;
+
+ COMMAND_2(map_set_cell_size, RID, p_map, real_t, p_cell_size);
+ virtual real_t map_get_cell_size(RID p_map) const;
+
+ COMMAND_2(map_set_edge_connection_margin, RID, p_map, real_t, p_connection_margin);
+ virtual real_t map_get_edge_connection_margin(RID p_map) const;
+
+ virtual Vector<Vector3> map_get_path(RID p_map, Vector3 p_origin, Vector3 p_destination, bool p_optimize) const;
+
+ virtual Vector3 map_get_closest_point_to_segment(RID p_map, const Vector3 &p_from, const Vector3 &p_to, const bool p_use_collision = false) const;
+ virtual Vector3 map_get_closest_point(RID p_map, const Vector3 &p_point) const;
+ virtual Vector3 map_get_closest_point_normal(RID p_map, const Vector3 &p_point) const;
+ virtual RID map_get_closest_point_owner(RID p_map, const Vector3 &p_point) const;
+
+ virtual RID region_create() const;
+ COMMAND_2(region_set_map, RID, p_region, RID, p_map);
+ COMMAND_2(region_set_transform, RID, p_region, Transform, p_transform);
+ COMMAND_2(region_set_navmesh, RID, p_region, Ref<NavigationMesh>, p_nav_mesh);
+ virtual void region_bake_navmesh(Ref<NavigationMesh> r_mesh, Node *p_node) const;
+
+ virtual RID agent_create() const;
+ COMMAND_2(agent_set_map, RID, p_agent, RID, p_map);
+ COMMAND_2(agent_set_neighbor_dist, RID, p_agent, real_t, p_dist);
+ COMMAND_2(agent_set_max_neighbors, RID, p_agent, int, p_count);
+ COMMAND_2(agent_set_time_horizon, RID, p_agent, real_t, p_time);
+ COMMAND_2(agent_set_radius, RID, p_agent, real_t, p_radius);
+ COMMAND_2(agent_set_max_speed, RID, p_agent, real_t, p_max_speed);
+ COMMAND_2(agent_set_velocity, RID, p_agent, Vector3, p_velocity);
+ COMMAND_2(agent_set_target_velocity, RID, p_agent, Vector3, p_velocity);
+ COMMAND_2(agent_set_position, RID, p_agent, Vector3, p_position);
+ COMMAND_2(agent_set_ignore_y, RID, p_agent, bool, p_ignore);
+ virtual bool agent_is_map_changed(RID p_agent) const;
+ COMMAND_4_DEF(agent_set_callback, RID, p_agent, Object *, p_receiver, StringName, p_method, Variant, p_udata, Variant());
+
+ COMMAND_1(free, RID, p_object);
+
+ virtual void set_active(bool p_active) const;
+
+ void flush_queries();
+ virtual void process(real_t p_delta_time);
+};
+
+#undef COMMAND_1
+#undef COMMAND_2
+#undef COMMAND_4_DEF
+
+#endif // GD_NAVIGATION_SERVER_H
diff --git a/modules/gdnavigation/nav_map.cpp b/modules/gdnavigation/nav_map.cpp
new file mode 100644
index 0000000000..c3880f89b6
--- /dev/null
+++ b/modules/gdnavigation/nav_map.cpp
@@ -0,0 +1,806 @@
+/*************************************************************************/
+/* nav_map.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#include "nav_map.h"
+
+#include "core/os/threaded_array_processor.h"
+#include "nav_region.h"
+#include "rvo_agent.h"
+#include <algorithm>
+
+/**
+ @author AndreaCatania
+*/
+
+#define USE_ENTRY_POINT
+
+NavMap::NavMap() :
+ up(0, 1, 0),
+ cell_size(0.3),
+ edge_connection_margin(5.0),
+ regenerate_polygons(true),
+ regenerate_links(true),
+ agents_dirty(false),
+ deltatime(0.0),
+ map_update_id(0) {}
+
+void NavMap::set_up(Vector3 p_up) {
+ up = p_up;
+ regenerate_polygons = true;
+}
+
+void NavMap::set_cell_size(float p_cell_size) {
+ cell_size = p_cell_size;
+ regenerate_polygons = true;
+}
+
+void NavMap::set_edge_connection_margin(float p_edge_connection_margin) {
+ edge_connection_margin = p_edge_connection_margin;
+ regenerate_links = true;
+}
+
+gd::PointKey NavMap::get_point_key(const Vector3 &p_pos) const {
+ const int x = int(Math::floor(p_pos.x / cell_size));
+ const int y = int(Math::floor(p_pos.y / cell_size));
+ const int z = int(Math::floor(p_pos.z / cell_size));
+
+ gd::PointKey p;
+ p.key = 0;
+ p.x = x;
+ p.y = y;
+ p.z = z;
+ return p;
+}
+
+Vector<Vector3> NavMap::get_path(Vector3 p_origin, Vector3 p_destination, bool p_optimize) const {
+
+ const gd::Polygon *begin_poly = NULL;
+ const gd::Polygon *end_poly = NULL;
+ Vector3 begin_point;
+ Vector3 end_point;
+ float begin_d = 1e20;
+ float end_d = 1e20;
+
+ // Find the initial poly and the end poly on this map.
+ for (size_t i(0); i < polygons.size(); i++) {
+ const gd::Polygon &p = polygons[i];
+
+ // For each point cast a face and check the distance between the origin/destination
+ for (size_t point_id = 2; point_id < p.points.size(); point_id++) {
+
+ Face3 f(p.points[point_id - 2].pos, p.points[point_id - 1].pos, p.points[point_id].pos);
+ Vector3 spoint = f.get_closest_point_to(p_origin);
+ float dpoint = spoint.distance_to(p_origin);
+ if (dpoint < begin_d) {
+ begin_d = dpoint;
+ begin_poly = &p;
+ begin_point = spoint;
+ }
+
+ spoint = f.get_closest_point_to(p_destination);
+ dpoint = spoint.distance_to(p_destination);
+ if (dpoint < end_d) {
+ end_d = dpoint;
+ end_poly = &p;
+ end_point = spoint;
+ }
+ }
+ }
+
+ if (!begin_poly || !end_poly) {
+ // No path
+ return Vector<Vector3>();
+ }
+
+ if (begin_poly == end_poly) {
+
+ Vector<Vector3> path;
+ path.resize(2);
+ path.write[0] = begin_point;
+ path.write[1] = end_point;
+ return path;
+ }
+
+ std::vector<gd::NavigationPoly> navigation_polys;
+ navigation_polys.reserve(polygons.size() * 0.75);
+
+ // The elements indices in the `navigation_polys`.
+ int least_cost_id(-1);
+ List<uint32_t> open_list;
+ bool found_route = false;
+
+ navigation_polys.push_back(gd::NavigationPoly(begin_poly));
+ {
+ least_cost_id = 0;
+ gd::NavigationPoly *least_cost_poly = &navigation_polys[least_cost_id];
+ least_cost_poly->self_id = least_cost_id;
+ least_cost_poly->entry = begin_point;
+ }
+
+ open_list.push_back(0);
+
+ const gd::Polygon *reachable_end = NULL;
+ float reachable_d = 1e30;
+ bool is_reachable = true;
+
+ while (found_route == false) {
+
+ {
+ // Takes the current least_cost_poly neighbors and compute the traveled_distance of each
+ for (size_t i = 0; i < navigation_polys[least_cost_id].poly->edges.size(); i++) {
+ gd::NavigationPoly *least_cost_poly = &navigation_polys[least_cost_id];
+
+ const gd::Edge &edge = least_cost_poly->poly->edges[i];
+ if (!edge.other_polygon)
+ continue;
+
+#ifdef USE_ENTRY_POINT
+ Vector3 edge_line[2] = {
+ least_cost_poly->poly->points[i].pos,
+ least_cost_poly->poly->points[(i + 1) % least_cost_poly->poly->points.size()].pos
+ };
+
+ const Vector3 new_entry = Geometry::get_closest_point_to_segment(least_cost_poly->entry, edge_line);
+ const float new_distance = least_cost_poly->entry.distance_to(new_entry) + least_cost_poly->traveled_distance;
+#else
+ const float new_distance = least_cost_poly->poly->center.distance_to(edge.other_polygon->center) + least_cost_poly->traveled_distance;
+#endif
+
+ auto it = std::find(
+ navigation_polys.begin(),
+ navigation_polys.end(),
+ gd::NavigationPoly(edge.other_polygon));
+
+ if (it != navigation_polys.end()) {
+ // Oh this was visited already, can we win the cost?
+ if (it->traveled_distance > new_distance) {
+
+ it->prev_navigation_poly_id = least_cost_id;
+ it->back_navigation_edge = edge.other_edge;
+ it->traveled_distance = new_distance;
+#ifdef USE_ENTRY_POINT
+ it->entry = new_entry;
+#endif
+ }
+ } else {
+ // Add to open neighbours
+
+ navigation_polys.push_back(gd::NavigationPoly(edge.other_polygon));
+ gd::NavigationPoly *np = &navigation_polys[navigation_polys.size() - 1];
+
+ np->self_id = navigation_polys.size() - 1;
+ np->prev_navigation_poly_id = least_cost_id;
+ np->back_navigation_edge = edge.other_edge;
+ np->traveled_distance = new_distance;
+#ifdef USE_ENTRY_POINT
+ np->entry = new_entry;
+#endif
+ open_list.push_back(navigation_polys.size() - 1);
+ }
+ }
+ }
+
+ // Removes the least cost polygon from the open list so we can advance.
+ open_list.erase(least_cost_id);
+
+ if (open_list.size() == 0) {
+ // When the open list is empty at this point the End Polygon is not reachable
+ // so use the further reachable polygon
+ ERR_BREAK_MSG(is_reachable == false, "It's not expect to not find the most reachable polygons");
+ is_reachable = false;
+ if (reachable_end == NULL) {
+ // The path is not found and there is not a way out.
+ break;
+ }
+
+ // Set as end point the furthest reachable point.
+ end_poly = reachable_end;
+ end_d = 1e20;
+ for (size_t point_id = 2; point_id < end_poly->points.size(); point_id++) {
+ Face3 f(end_poly->points[point_id - 2].pos, end_poly->points[point_id - 1].pos, end_poly->points[point_id].pos);
+ Vector3 spoint = f.get_closest_point_to(p_destination);
+ float dpoint = spoint.distance_to(p_destination);
+ if (dpoint < end_d) {
+ end_point = spoint;
+ end_d = dpoint;
+ }
+ }
+
+ // Reset open and navigation_polys
+ gd::NavigationPoly np = navigation_polys[0];
+ navigation_polys.clear();
+ navigation_polys.push_back(np);
+ open_list.clear();
+ open_list.push_back(0);
+
+ reachable_end = NULL;
+
+ continue;
+ }
+
+ // Now take the new least_cost_poly from the open list.
+ least_cost_id = -1;
+ float least_cost = 1e30;
+
+ for (auto element = open_list.front(); element != NULL; element = element->next()) {
+ gd::NavigationPoly *np = &navigation_polys[element->get()];
+ float cost = np->traveled_distance;
+#ifdef USE_ENTRY_POINT
+ cost += np->entry.distance_to(end_point);
+#else
+ cost += np->poly->center.distance_to(end_point);
+#endif
+ if (cost < least_cost) {
+ least_cost_id = np->self_id;
+ least_cost = cost;
+ }
+ }
+
+ // Stores the further reachable end polygon, in case our goal is not reachable.
+ if (is_reachable) {
+ float d = navigation_polys[least_cost_id].entry.distance_to(p_destination);
+ if (reachable_d > d) {
+ reachable_d = d;
+ reachable_end = navigation_polys[least_cost_id].poly;
+ }
+ }
+
+ ERR_BREAK(least_cost_id == -1);
+
+ // Check if we reached the end
+ if (navigation_polys[least_cost_id].poly == end_poly) {
+ // Yep, done!!
+ found_route = true;
+ break;
+ }
+ }
+
+ if (found_route) {
+
+ Vector<Vector3> path;
+ if (p_optimize) {
+
+ // String pulling
+
+ gd::NavigationPoly *apex_poly = &navigation_polys[least_cost_id];
+ Vector3 apex_point = end_point;
+ Vector3 portal_left = apex_point;
+ Vector3 portal_right = apex_point;
+ gd::NavigationPoly *left_poly = apex_poly;
+ gd::NavigationPoly *right_poly = apex_poly;
+ gd::NavigationPoly *p = apex_poly;
+
+ path.push_back(end_point);
+
+ while (p) {
+
+ Vector3 left;
+ Vector3 right;
+
+#define CLOCK_TANGENT(m_a, m_b, m_c) (((m_a) - (m_c)).cross((m_a) - (m_b)))
+
+ if (p->poly == begin_poly) {
+ left = begin_point;
+ right = begin_point;
+ } else {
+ int prev = p->back_navigation_edge;
+ int prev_n = (p->back_navigation_edge + 1) % p->poly->points.size();
+ left = p->poly->points[prev].pos;
+ right = p->poly->points[prev_n].pos;
+
+ //if (CLOCK_TANGENT(apex_point,left,(left+right)*0.5).dot(up) < 0){
+ if (p->poly->clockwise) {
+ SWAP(left, right);
+ }
+ }
+
+ bool skip = false;
+
+ if (CLOCK_TANGENT(apex_point, portal_left, left).dot(up) >= 0) {
+ //process
+ if (portal_left == apex_point || CLOCK_TANGENT(apex_point, left, portal_right).dot(up) > 0) {
+ left_poly = p;
+ portal_left = left;
+ } else {
+
+ clip_path(navigation_polys, path, apex_poly, portal_right, right_poly);
+
+ apex_point = portal_right;
+ p = right_poly;
+ left_poly = p;
+ apex_poly = p;
+ portal_left = apex_point;
+ portal_right = apex_point;
+ path.push_back(apex_point);
+ skip = true;
+ }
+ }
+
+ if (!skip && CLOCK_TANGENT(apex_point, portal_right, right).dot(up) <= 0) {
+ //process
+ if (portal_right == apex_point || CLOCK_TANGENT(apex_point, right, portal_left).dot(up) < 0) {
+ right_poly = p;
+ portal_right = right;
+ } else {
+
+ clip_path(navigation_polys, path, apex_poly, portal_left, left_poly);
+
+ apex_point = portal_left;
+ p = left_poly;
+ right_poly = p;
+ apex_poly = p;
+ portal_right = apex_point;
+ portal_left = apex_point;
+ path.push_back(apex_point);
+ }
+ }
+
+ if (p->prev_navigation_poly_id != -1)
+ p = &navigation_polys[p->prev_navigation_poly_id];
+ else
+ // The end
+ p = NULL;
+ }
+
+ if (path[path.size() - 1] != begin_point)
+ path.push_back(begin_point);
+
+ path.invert();
+
+ } else {
+ path.push_back(end_point);
+
+ // Add mid points
+ int np_id = least_cost_id;
+ while (np_id != -1) {
+
+#ifdef USE_ENTRY_POINT
+ Vector3 point = navigation_polys[np_id].entry;
+#else
+ int prev = navigation_polys[np_id].back_navigation_edge;
+ int prev_n = (navigation_polys[np_id].back_navigation_edge + 1) % navigation_polys[np_id].poly->points.size();
+ Vector3 point = (navigation_polys[np_id].poly->points[prev].pos + navigation_polys[np_id].poly->points[prev_n].pos) * 0.5;
+#endif
+
+ path.push_back(point);
+ np_id = navigation_polys[np_id].prev_navigation_poly_id;
+ }
+
+ path.invert();
+ }
+
+ return path;
+ }
+ return Vector<Vector3>();
+}
+
+Vector3 NavMap::get_closest_point_to_segment(const Vector3 &p_from, const Vector3 &p_to, const bool p_use_collision) const {
+
+ bool use_collision = p_use_collision;
+ Vector3 closest_point;
+ real_t closest_point_d = 1e20;
+
+ // Find the initial poly and the end poly on this map.
+ for (size_t i(0); i < polygons.size(); i++) {
+ const gd::Polygon &p = polygons[i];
+
+ // For each point cast a face and check the distance to the segment
+ for (size_t point_id = 2; point_id < p.points.size(); point_id += 1) {
+
+ const Face3 f(p.points[point_id - 2].pos, p.points[point_id - 1].pos, p.points[point_id].pos);
+ Vector3 inters;
+ if (f.intersects_segment(p_from, p_to, &inters)) {
+ const real_t d = closest_point_d = p_from.distance_to(inters);
+ if (use_collision == false) {
+ closest_point = inters;
+ use_collision = true;
+ closest_point_d = d;
+ } else if (closest_point_d > d) {
+
+ closest_point = inters;
+ closest_point_d = d;
+ }
+ }
+ }
+
+ if (use_collision == false) {
+
+ for (size_t point_id = 0; point_id < p.points.size(); point_id += 1) {
+
+ Vector3 a, b;
+
+ Geometry::get_closest_points_between_segments(
+ p_from,
+ p_to,
+ p.points[point_id].pos,
+ p.points[(point_id + 1) % p.points.size()].pos,
+ a,
+ b);
+
+ const real_t d = a.distance_to(b);
+ if (d < closest_point_d) {
+
+ closest_point_d = d;
+ closest_point = b;
+ }
+ }
+ }
+ }
+
+ return closest_point;
+}
+
+Vector3 NavMap::get_closest_point(const Vector3 &p_point) const {
+ // TODO this is really not optimal, please redesign the API to directly return all this data
+
+ Vector3 closest_point;
+ real_t closest_point_d = 1e20;
+
+ // Find the initial poly and the end poly on this map.
+ for (size_t i(0); i < polygons.size(); i++) {
+ const gd::Polygon &p = polygons[i];
+
+ // For each point cast a face and check the distance to the point
+ for (size_t point_id = 2; point_id < p.points.size(); point_id += 1) {
+
+ const Face3 f(p.points[point_id - 2].pos, p.points[point_id - 1].pos, p.points[point_id].pos);
+ const Vector3 inters = f.get_closest_point_to(p_point);
+ const real_t d = inters.distance_to(p_point);
+ if (d < closest_point_d) {
+ closest_point = inters;
+ closest_point_d = d;
+ }
+ }
+ }
+
+ return closest_point;
+}
+
+Vector3 NavMap::get_closest_point_normal(const Vector3 &p_point) const {
+ // TODO this is really not optimal, please redesign the API to directly return all this data
+
+ Vector3 closest_point;
+ Vector3 closest_point_normal;
+ real_t closest_point_d = 1e20;
+
+ // Find the initial poly and the end poly on this map.
+ for (size_t i(0); i < polygons.size(); i++) {
+ const gd::Polygon &p = polygons[i];
+
+ // For each point cast a face and check the distance to the point
+ for (size_t point_id = 2; point_id < p.points.size(); point_id += 1) {
+
+ const Face3 f(p.points[point_id - 2].pos, p.points[point_id - 1].pos, p.points[point_id].pos);
+ const Vector3 inters = f.get_closest_point_to(p_point);
+ const real_t d = inters.distance_to(p_point);
+ if (d < closest_point_d) {
+ closest_point = inters;
+ closest_point_normal = f.get_plane().normal;
+ closest_point_d = d;
+ }
+ }
+ }
+
+ return closest_point_normal;
+}
+
+RID NavMap::get_closest_point_owner(const Vector3 &p_point) const {
+ // TODO this is really not optimal, please redesign the API to directly return all this data
+
+ Vector3 closest_point;
+ RID closest_point_owner;
+ real_t closest_point_d = 1e20;
+
+ // Find the initial poly and the end poly on this map.
+ for (size_t i(0); i < polygons.size(); i++) {
+ const gd::Polygon &p = polygons[i];
+
+ // For each point cast a face and check the distance to the point
+ for (size_t point_id = 2; point_id < p.points.size(); point_id += 1) {
+
+ const Face3 f(p.points[point_id - 2].pos, p.points[point_id - 1].pos, p.points[point_id].pos);
+ const Vector3 inters = f.get_closest_point_to(p_point);
+ const real_t d = inters.distance_to(p_point);
+ if (d < closest_point_d) {
+ closest_point = inters;
+ closest_point_owner = p.owner->get_self();
+ closest_point_d = d;
+ }
+ }
+ }
+
+ return closest_point_owner;
+}
+
+void NavMap::add_region(NavRegion *p_region) {
+ regions.push_back(p_region);
+ regenerate_links = true;
+}
+
+void NavMap::remove_region(NavRegion *p_region) {
+ std::vector<NavRegion *>::iterator it = std::find(regions.begin(), regions.end(), p_region);
+ if (it != regions.end()) {
+ regions.erase(it);
+ regenerate_links = true;
+ }
+}
+
+bool NavMap::has_agent(RvoAgent *agent) const {
+ return std::find(agents.begin(), agents.end(), agent) != agents.end();
+}
+
+void NavMap::add_agent(RvoAgent *agent) {
+ if (!has_agent(agent)) {
+ agents.push_back(agent);
+ agents_dirty = true;
+ }
+}
+
+void NavMap::remove_agent(RvoAgent *agent) {
+ remove_agent_as_controlled(agent);
+ auto it = std::find(agents.begin(), agents.end(), agent);
+ if (it != agents.end()) {
+ agents.erase(it);
+ agents_dirty = true;
+ }
+}
+
+void NavMap::set_agent_as_controlled(RvoAgent *agent) {
+ const bool exist = std::find(controlled_agents.begin(), controlled_agents.end(), agent) != controlled_agents.end();
+ if (!exist) {
+ ERR_FAIL_COND(!has_agent(agent));
+ controlled_agents.push_back(agent);
+ }
+}
+
+void NavMap::remove_agent_as_controlled(RvoAgent *agent) {
+ auto it = std::find(controlled_agents.begin(), controlled_agents.end(), agent);
+ if (it != controlled_agents.end()) {
+ controlled_agents.erase(it);
+ }
+}
+
+void NavMap::sync() {
+
+ if (regenerate_polygons) {
+ for (size_t r(0); r < regions.size(); r++) {
+ regions[r]->scratch_polygons();
+ }
+ regenerate_links = true;
+ }
+
+ for (size_t r(0); r < regions.size(); r++) {
+ if (regions[r]->sync()) {
+ regenerate_links = true;
+ }
+ }
+
+ if (regenerate_links) {
+ // Copy all region polygons in the map.
+ int count = 0;
+ for (size_t r(0); r < regions.size(); r++) {
+ count += regions[r]->get_polygons().size();
+ }
+
+ polygons.resize(count);
+ count = 0;
+
+ for (size_t r(0); r < regions.size(); r++) {
+ std::copy(
+ regions[r]->get_polygons().data(),
+ regions[r]->get_polygons().data() + regions[r]->get_polygons().size(),
+ polygons.begin() + count);
+
+ count += regions[r]->get_polygons().size();
+ }
+
+ // Connects the `Edges` of all the `Polygons` of all `Regions` each other.
+ Map<gd::EdgeKey, gd::Connection> connections;
+
+ for (size_t poly_id(0); poly_id < polygons.size(); poly_id++) {
+ gd::Polygon &poly(polygons[poly_id]);
+
+ for (size_t p(0); p < poly.points.size(); p++) {
+ int next_point = (p + 1) % poly.points.size();
+ gd::EdgeKey ek(poly.points[p].key, poly.points[next_point].key);
+
+ Map<gd::EdgeKey, gd::Connection>::Element *connection = connections.find(ek);
+ if (!connection) {
+ // Nothing yet
+ gd::Connection c;
+ c.A = &poly;
+ c.A_edge = p;
+ c.B = NULL;
+ c.B_edge = -1;
+ connections[ek] = c;
+
+ } else if (connection->get().B == NULL) {
+ CRASH_COND(connection->get().A == NULL); // Unreachable
+
+ // Connect the two Polygons by this edge
+ connection->get().B = &poly;
+ connection->get().B_edge = p;
+
+ connection->get().A->edges[connection->get().A_edge].this_edge = connection->get().A_edge;
+ connection->get().A->edges[connection->get().A_edge].other_polygon = connection->get().B;
+ connection->get().A->edges[connection->get().A_edge].other_edge = connection->get().B_edge;
+
+ connection->get().B->edges[connection->get().B_edge].this_edge = connection->get().B_edge;
+ connection->get().B->edges[connection->get().B_edge].other_polygon = connection->get().A;
+ connection->get().B->edges[connection->get().B_edge].other_edge = connection->get().A_edge;
+ } else {
+ // The edge is already connected with another edge, skip.
+ }
+ }
+ }
+
+ // Takes all the free edges.
+ std::vector<gd::FreeEdge> free_edges;
+ free_edges.reserve(connections.size());
+
+ for (auto connection_element = connections.front(); connection_element; connection_element = connection_element->next()) {
+ if (connection_element->get().B == NULL) {
+ CRASH_COND(connection_element->get().A == NULL); // Unreachable
+ CRASH_COND(connection_element->get().A_edge < 0); // Unreachable
+
+ // This is a free edge
+ uint32_t id(free_edges.size());
+ free_edges.push_back(gd::FreeEdge());
+ free_edges[id].is_free = true;
+ free_edges[id].poly = connection_element->get().A;
+ free_edges[id].edge_id = connection_element->get().A_edge;
+ uint32_t point_0(free_edges[id].edge_id);
+ uint32_t point_1((free_edges[id].edge_id + 1) % free_edges[id].poly->points.size());
+ Vector3 pos_0 = free_edges[id].poly->points[point_0].pos;
+ Vector3 pos_1 = free_edges[id].poly->points[point_1].pos;
+ Vector3 relative = pos_1 - pos_0;
+ free_edges[id].edge_center = (pos_0 + pos_1) / 2.0;
+ free_edges[id].edge_dir = relative.normalized();
+ free_edges[id].edge_len_squared = relative.length_squared();
+ }
+ }
+
+ const float ecm_squared(edge_connection_margin * edge_connection_margin);
+#define LEN_TOLLERANCE 0.1
+#define DIR_TOLLERANCE 0.9
+ // In front of tollerance
+#define IFO_TOLLERANCE 0.5
+
+ // Find the compatible near edges.
+ //
+ // Note:
+ // Considering that the edges must be compatible (for obvious reasons)
+ // to be connected, create new polygons to remove that small gap is
+ // not really useful and would result in wasteful computation during
+ // connection, integration and path finding.
+ for (size_t i(0); i < free_edges.size(); i++) {
+ if (!free_edges[i].is_free) {
+ continue;
+ }
+ gd::FreeEdge &edge = free_edges[i];
+ for (size_t y(0); y < free_edges.size(); y++) {
+ gd::FreeEdge &other_edge = free_edges[y];
+ if (i == y || !other_edge.is_free || edge.poly->owner == other_edge.poly->owner) {
+ continue;
+ }
+
+ Vector3 rel_centers = other_edge.edge_center - edge.edge_center;
+ if (ecm_squared > rel_centers.length_squared() // Are enough closer?
+ && ABS(edge.edge_len_squared - other_edge.edge_len_squared) < LEN_TOLLERANCE // Are the same length?
+ && ABS(edge.edge_dir.dot(other_edge.edge_dir)) > DIR_TOLLERANCE // Are alligned?
+ && ABS(rel_centers.normalized().dot(edge.edge_dir)) < IFO_TOLLERANCE // Are one in front the other?
+ ) {
+ // The edges can be connected
+ edge.is_free = false;
+ other_edge.is_free = false;
+
+ edge.poly->edges[edge.edge_id].this_edge = edge.edge_id;
+ edge.poly->edges[edge.edge_id].other_edge = other_edge.edge_id;
+ edge.poly->edges[edge.edge_id].other_polygon = other_edge.poly;
+
+ other_edge.poly->edges[other_edge.edge_id].this_edge = other_edge.edge_id;
+ other_edge.poly->edges[other_edge.edge_id].other_edge = edge.edge_id;
+ other_edge.poly->edges[other_edge.edge_id].other_polygon = edge.poly;
+ }
+ }
+ }
+ }
+
+ if (regenerate_links) {
+ map_update_id = map_update_id + 1 % 9999999;
+ }
+
+ if (agents_dirty) {
+ std::vector<RVO::Agent *> raw_agents;
+ raw_agents.reserve(agents.size());
+ for (size_t i(0); i < agents.size(); i++)
+ raw_agents.push_back(agents[i]->get_agent());
+ rvo.buildAgentTree(raw_agents);
+ }
+
+ regenerate_polygons = false;
+ regenerate_links = false;
+ agents_dirty = false;
+}
+
+void NavMap::compute_single_step(uint32_t index, RvoAgent **agent) {
+ (*(agent + index))->get_agent()->computeNeighbors(&rvo);
+ (*(agent + index))->get_agent()->computeNewVelocity(deltatime);
+}
+
+void NavMap::step(real_t p_deltatime) {
+ deltatime = p_deltatime;
+ if (controlled_agents.size() > 0) {
+ thread_process_array(
+ controlled_agents.size(),
+ this,
+ &NavMap::compute_single_step,
+ controlled_agents.data());
+ }
+}
+
+void NavMap::dispatch_callbacks() {
+ for (int i(0); i < static_cast<int>(controlled_agents.size()); i++) {
+ controlled_agents[i]->dispatch_callback();
+ }
+}
+
+void NavMap::clip_path(const std::vector<gd::NavigationPoly> &p_navigation_polys, Vector<Vector3> &path, const gd::NavigationPoly *from_poly, const Vector3 &p_to_point, const gd::NavigationPoly *p_to_poly) const {
+ Vector3 from = path[path.size() - 1];
+
+ if (from.distance_to(p_to_point) < CMP_EPSILON)
+ return;
+ Plane cut_plane;
+ cut_plane.normal = (from - p_to_point).cross(up);
+ if (cut_plane.normal == Vector3())
+ return;
+ cut_plane.normal.normalize();
+ cut_plane.d = cut_plane.normal.dot(from);
+
+ while (from_poly != p_to_poly) {
+
+ int back_nav_edge = from_poly->back_navigation_edge;
+ Vector3 a = from_poly->poly->points[back_nav_edge].pos;
+ Vector3 b = from_poly->poly->points[(back_nav_edge + 1) % from_poly->poly->points.size()].pos;
+
+ ERR_FAIL_COND(from_poly->prev_navigation_poly_id == -1);
+ from_poly = &p_navigation_polys[from_poly->prev_navigation_poly_id];
+
+ if (a.distance_to(b) > CMP_EPSILON) {
+
+ Vector3 inters;
+ if (cut_plane.intersects_segment(a, b, &inters)) {
+ if (inters.distance_to(p_to_point) > CMP_EPSILON && inters.distance_to(path[path.size() - 1]) > CMP_EPSILON) {
+ path.push_back(inters);
+ }
+ }
+ }
+ }
+}
diff --git a/modules/gdnavigation/nav_map.h b/modules/gdnavigation/nav_map.h
new file mode 100644
index 0000000000..4543f00926
--- /dev/null
+++ b/modules/gdnavigation/nav_map.h
@@ -0,0 +1,141 @@
+/*************************************************************************/
+/* nav_map.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifndef RVO_SPACE_H
+#define RVO_SPACE_H
+
+#include "nav_rid.h"
+
+#include "core/math/math_defs.h"
+#include "nav_utils.h"
+#include <KdTree.h>
+
+/**
+ @author AndreaCatania
+*/
+
+class NavRegion;
+class RvoAgent;
+class NavRegion;
+
+class NavMap : public NavRid {
+
+ /// Map Up
+ Vector3 up;
+
+ /// To find the polygons edges the vertices are displaced in a grid where
+ /// each cell has the following cell_size.
+ real_t cell_size;
+
+ /// This value is used to detect the near edges to connect.
+ real_t edge_connection_margin;
+
+ bool regenerate_polygons;
+ bool regenerate_links;
+
+ std::vector<NavRegion *> regions;
+
+ /// Map polygons
+ std::vector<gd::Polygon> polygons;
+
+ /// Rvo world
+ RVO::KdTree rvo;
+
+ /// Is agent array modified?
+ bool agents_dirty;
+
+ /// All the Agents (even the controlled one)
+ std::vector<RvoAgent *> agents;
+
+ /// Controlled agents
+ std::vector<RvoAgent *> controlled_agents;
+
+ /// Physics delta time
+ real_t deltatime;
+
+ /// Change the id each time the map is updated.
+ uint32_t map_update_id;
+
+public:
+ NavMap();
+
+ void set_up(Vector3 p_up);
+ Vector3 get_up() const {
+ return up;
+ }
+
+ void set_cell_size(float p_cell_size);
+ float get_cell_size() const {
+ return cell_size;
+ }
+
+ void set_edge_connection_margin(float p_edge_connection_margin);
+ float get_edge_connection_margin() const {
+ return edge_connection_margin;
+ }
+
+ gd::PointKey get_point_key(const Vector3 &p_pos) const;
+
+ Vector<Vector3> get_path(Vector3 p_origin, Vector3 p_destination, bool p_optimize) const;
+ Vector3 get_closest_point_to_segment(const Vector3 &p_from, const Vector3 &p_to, const bool p_use_collision) const;
+ Vector3 get_closest_point(const Vector3 &p_point) const;
+ Vector3 get_closest_point_normal(const Vector3 &p_point) const;
+ RID get_closest_point_owner(const Vector3 &p_point) const;
+
+ void add_region(NavRegion *p_region);
+ void remove_region(NavRegion *p_region);
+ const std::vector<NavRegion *> &get_regions() const {
+ return regions;
+ }
+
+ bool has_agent(RvoAgent *agent) const;
+ void add_agent(RvoAgent *agent);
+ void remove_agent(RvoAgent *agent);
+ const std::vector<RvoAgent *> &get_agents() const {
+ return agents;
+ }
+
+ void set_agent_as_controlled(RvoAgent *agent);
+ void remove_agent_as_controlled(RvoAgent *agent);
+
+ uint32_t get_map_update_id() const {
+ return map_update_id;
+ }
+
+ void sync();
+ void step(real_t p_deltatime);
+ void dispatch_callbacks();
+
+private:
+ void compute_single_step(uint32_t index, RvoAgent **agent);
+ void clip_path(const std::vector<gd::NavigationPoly> &p_navigation_polys, Vector<Vector3> &path, const gd::NavigationPoly *from_poly, const Vector3 &p_to_point, const gd::NavigationPoly *p_to_poly) const;
+};
+
+#endif // RVO_SPACE_H
diff --git a/modules/gdnavigation/nav_region.cpp b/modules/gdnavigation/nav_region.cpp
new file mode 100644
index 0000000000..0215821305
--- /dev/null
+++ b/modules/gdnavigation/nav_region.cpp
@@ -0,0 +1,136 @@
+/*************************************************************************/
+/* nav_region.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#include "nav_region.h"
+
+#include "nav_map.h"
+
+/**
+ @author AndreaCatania
+*/
+
+NavRegion::NavRegion() :
+ map(NULL),
+ polygons_dirty(true) {
+}
+
+void NavRegion::set_map(NavMap *p_map) {
+ map = p_map;
+ polygons_dirty = true;
+}
+
+void NavRegion::set_transform(Transform p_transform) {
+ transform = p_transform;
+ polygons_dirty = true;
+}
+
+void NavRegion::set_mesh(Ref<NavigationMesh> p_mesh) {
+ mesh = p_mesh;
+ polygons_dirty = true;
+}
+
+bool NavRegion::sync() {
+ bool something_changed = polygons_dirty /* || something_dirty? */;
+
+ update_polygons();
+
+ return something_changed;
+}
+
+void NavRegion::update_polygons() {
+ if (!polygons_dirty) {
+ return;
+ }
+ polygons.clear();
+ polygons_dirty = false;
+
+ if (map == NULL) {
+ return;
+ }
+
+ if (mesh.is_null())
+ return;
+
+ Vector<Vector3> vertices = mesh->get_vertices();
+ int len = vertices.size();
+ if (len == 0)
+ return;
+
+ const Vector3 *vertices_r = vertices.ptr();
+
+ polygons.resize(mesh->get_polygon_count());
+
+ // Build
+ for (size_t i(0); i < polygons.size(); i++) {
+
+ gd::Polygon &p = polygons[i];
+ p.owner = this;
+
+ Vector<int> mesh_poly = mesh->get_polygon(i);
+ const int *indices = mesh_poly.ptr();
+ bool valid(true);
+ p.points.resize(mesh_poly.size());
+ p.edges.resize(mesh_poly.size());
+
+ Vector3 center;
+ float sum(0);
+
+ for (int j(0); j < mesh_poly.size(); j++) {
+
+ int idx = indices[j];
+ if (idx < 0 || idx >= len) {
+ valid = false;
+ break;
+ }
+
+ Vector3 point_position = transform.xform(vertices_r[idx]);
+ p.points[j].pos = point_position;
+ p.points[j].key = map->get_point_key(point_position);
+
+ center += point_position; // Composing the center of the polygon
+
+ if (j >= 2) {
+ Vector3 epa = transform.xform(vertices_r[indices[j - 2]]);
+ Vector3 epb = transform.xform(vertices_r[indices[j - 1]]);
+
+ sum += map->get_up().dot((epb - epa).cross(point_position - epa));
+ }
+ }
+
+ if (!valid) {
+ ERR_BREAK_MSG(!valid, "The navigation mesh set in this region is not valid!");
+ }
+
+ p.clockwise = sum > 0;
+ if (mesh_poly.size() != 0) {
+ p.center = center / float(mesh_poly.size());
+ }
+ }
+}
diff --git a/modules/gdnavigation/nav_region.h b/modules/gdnavigation/nav_region.h
new file mode 100644
index 0000000000..d99254d1ad
--- /dev/null
+++ b/modules/gdnavigation/nav_region.h
@@ -0,0 +1,89 @@
+/*************************************************************************/
+/* nav_region.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifndef NAV_REGION_H
+#define NAV_REGION_H
+
+#include "nav_rid.h"
+
+#include "nav_utils.h"
+#include "scene/3d/navigation.h"
+#include <vector>
+
+/**
+ @author AndreaCatania
+*/
+
+class NavMap;
+class NavRegion;
+
+class NavRegion : public NavRid {
+ NavMap *map;
+ Transform transform;
+ Ref<NavigationMesh> mesh;
+
+ bool polygons_dirty;
+
+ /// Cache
+ std::vector<gd::Polygon> polygons;
+
+public:
+ NavRegion();
+
+ void scratch_polygons() {
+ polygons_dirty = true;
+ }
+
+ void set_map(NavMap *p_map);
+ NavMap *get_map() const {
+ return map;
+ }
+
+ void set_transform(Transform transform);
+ const Transform &get_transform() const {
+ return transform;
+ }
+
+ void set_mesh(Ref<NavigationMesh> p_mesh);
+ const Ref<NavigationMesh> get_mesh() const {
+ return mesh;
+ }
+
+ std::vector<gd::Polygon> const &get_polygons() const {
+ return polygons;
+ }
+
+ bool sync();
+
+private:
+ void update_polygons();
+};
+
+#endif // NAV_REGION_H
diff --git a/modules/gdnavigation/nav_rid.h b/modules/gdnavigation/nav_rid.h
new file mode 100644
index 0000000000..c119ecc5e0
--- /dev/null
+++ b/modules/gdnavigation/nav_rid.h
@@ -0,0 +1,48 @@
+/*************************************************************************/
+/* nav_rid.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifndef NAV_RID_H
+#define NAV_RID_H
+
+#include "core/rid.h"
+
+/**
+ @author AndreaCatania
+*/
+
+class NavRid {
+ RID self;
+
+public:
+ _FORCE_INLINE_ void set_self(const RID &p_self) { self = p_self; }
+ _FORCE_INLINE_ RID get_self() const { return self; }
+};
+
+#endif // NAV_RID_H
diff --git a/modules/gdnavigation/nav_utils.h b/modules/gdnavigation/nav_utils.h
new file mode 100644
index 0000000000..bdf9eb34a8
--- /dev/null
+++ b/modules/gdnavigation/nav_utils.h
@@ -0,0 +1,169 @@
+/*************************************************************************/
+/* nav_utils.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifndef NAV_UTILS_H
+#define NAV_UTILS_H
+
+#include "core/math/vector3.h"
+#include <vector>
+
+/**
+ @author AndreaCatania
+*/
+
+class NavRegion;
+
+namespace gd {
+struct Polygon;
+
+union PointKey {
+
+ struct {
+ int64_t x : 21;
+ int64_t y : 22;
+ int64_t z : 21;
+ };
+
+ uint64_t key;
+ bool operator<(const PointKey &p_key) const { return key < p_key.key; }
+};
+
+struct EdgeKey {
+
+ PointKey a;
+ PointKey b;
+
+ bool operator<(const EdgeKey &p_key) const {
+ return (a.key == p_key.a.key) ? (b.key < p_key.b.key) : (a.key < p_key.a.key);
+ }
+
+ EdgeKey(const PointKey &p_a = PointKey(), const PointKey &p_b = PointKey()) :
+ a(p_a),
+ b(p_b) {
+ if (a.key > b.key) {
+ SWAP(a, b);
+ }
+ }
+};
+
+struct Point {
+ Vector3 pos;
+ PointKey key;
+};
+
+struct Edge {
+ /// This edge ID
+ int this_edge;
+
+ /// Other Polygon
+ Polygon *other_polygon;
+
+ /// The other `Polygon` at this edge id has this `Polygon`.
+ int other_edge;
+
+ Edge() {
+ this_edge = -1;
+ other_polygon = NULL;
+ other_edge = -1;
+ }
+};
+
+struct Polygon {
+ NavRegion *owner;
+
+ /// The points of this `Polygon`
+ std::vector<Point> points;
+
+ /// Are the points clockwise ?
+ bool clockwise;
+
+ /// The edges of this `Polygon`
+ std::vector<Edge> edges;
+
+ /// The center of this `Polygon`
+ Vector3 center;
+};
+
+struct Connection {
+
+ Polygon *A;
+ int A_edge;
+ Polygon *B;
+ int B_edge;
+
+ Connection() {
+ A = NULL;
+ B = NULL;
+ A_edge = -1;
+ B_edge = -1;
+ }
+};
+
+struct NavigationPoly {
+ uint32_t self_id;
+ /// This poly.
+ const Polygon *poly;
+ /// The previous navigation poly (id in the `navigation_poly` array).
+ int prev_navigation_poly_id;
+ /// The edge id in this `Poly` to reach the `prev_navigation_poly_id`.
+ uint32_t back_navigation_edge;
+ /// The entry location of this poly.
+ Vector3 entry;
+ /// The distance to the destination.
+ float traveled_distance;
+
+ NavigationPoly(const Polygon *p_poly) :
+ self_id(0),
+ poly(p_poly),
+ prev_navigation_poly_id(-1),
+ back_navigation_edge(0),
+ traveled_distance(0.0) {
+ }
+
+ bool operator==(const NavigationPoly &other) const {
+ return this->poly == other.poly;
+ }
+
+ bool operator!=(const NavigationPoly &other) const {
+ return !operator==(other);
+ }
+};
+
+struct FreeEdge {
+ bool is_free;
+ Polygon *poly;
+ uint32_t edge_id;
+ Vector3 edge_center;
+ Vector3 edge_dir;
+ float edge_len_squared;
+};
+} // namespace gd
+
+#endif // NAV_UTILS_H
diff --git a/modules/recast/navigation_mesh_editor_plugin.cpp b/modules/gdnavigation/navigation_mesh_editor_plugin.cpp
index 6e68dba8ee..28fe0bfd06 100644
--- a/modules/recast/navigation_mesh_editor_plugin.cpp
+++ b/modules/gdnavigation/navigation_mesh_editor_plugin.cpp
@@ -28,10 +28,12 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#ifdef TOOLS_ENABLED
#include "navigation_mesh_editor_plugin.h"
#include "core/io/marshalls.h"
#include "core/io/resource_saver.h"
+#include "navigation_mesh_generator.h"
#include "scene/3d/mesh_instance.h"
#include "scene/gui/box_container.h"
@@ -57,15 +59,14 @@ void NavigationMeshEditor::_bake_pressed() {
button_bake->set_pressed(false);
ERR_FAIL_COND(!node);
- const String conf_warning = node->get_configuration_warning();
- if (!conf_warning.empty()) {
- err_dialog->set_text(conf_warning);
+ if (!node->get_navigation_mesh().is_valid()) {
+ err_dialog->set_text(TTR("A NavigationMesh resource must be set or created for this node to work."));
err_dialog->popup_centered_minsize();
return;
}
- EditorNavigationMeshGenerator::get_singleton()->clear(node->get_navigation_mesh());
- EditorNavigationMeshGenerator::get_singleton()->bake(node->get_navigation_mesh(), node);
+ NavigationMeshGenerator::get_singleton()->clear(node->get_navigation_mesh());
+ NavigationMeshGenerator::get_singleton()->bake(node->get_navigation_mesh(), node);
node->update_gizmo();
}
@@ -73,7 +74,7 @@ void NavigationMeshEditor::_bake_pressed() {
void NavigationMeshEditor::_clear_pressed() {
if (node)
- EditorNavigationMeshGenerator::get_singleton()->clear(node->get_navigation_mesh());
+ NavigationMeshGenerator::get_singleton()->clear(node->get_navigation_mesh());
button_bake->set_pressed(false);
bake_info->set_text("");
@@ -106,13 +107,13 @@ NavigationMeshEditor::NavigationMeshEditor() {
bake_hbox->add_child(button_bake);
button_bake->set_toggle_mode(true);
button_bake->set_text(TTR("Bake NavMesh"));
- button_bake->connect("pressed", this, "_bake_pressed");
+ button_bake->connect_compat("pressed", this, "_bake_pressed");
button_reset = memnew(ToolButton);
bake_hbox->add_child(button_reset);
// No button text, we only use a revert icon which is set when entering the tree.
button_reset->set_tooltip(TTR("Clear the navigation mesh."));
- button_reset->connect("pressed", this, "_clear_pressed");
+ button_reset->connect_compat("pressed", this, "_clear_pressed");
bake_info = memnew(Label);
bake_hbox->add_child(bake_info);
@@ -160,3 +161,5 @@ NavigationMeshEditorPlugin::NavigationMeshEditorPlugin(EditorNode *p_node) {
NavigationMeshEditorPlugin::~NavigationMeshEditorPlugin() {
}
+
+#endif
diff --git a/modules/recast/navigation_mesh_editor_plugin.h b/modules/gdnavigation/navigation_mesh_editor_plugin.h
index 09c8673b43..f5833f3d7f 100644
--- a/modules/recast/navigation_mesh_editor_plugin.h
+++ b/modules/gdnavigation/navigation_mesh_editor_plugin.h
@@ -28,12 +28,15 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef NAVIGATION_MESH_GENERATOR_PLUGIN_H
-#define NAVIGATION_MESH_GENERATOR_PLUGIN_H
+#ifndef NAVIGATION_MESH_EDITOR_PLUGIN_H
+#define NAVIGATION_MESH_EDITOR_PLUGIN_H
+
+#ifdef TOOLS_ENABLED
#include "editor/editor_node.h"
#include "editor/editor_plugin.h"
-#include "navigation_mesh_generator.h"
+
+class NavigationMeshInstance;
class NavigationMeshEditor : public Control {
friend class NavigationMeshEditorPlugin;
@@ -81,4 +84,6 @@ public:
~NavigationMeshEditorPlugin();
};
-#endif // NAVIGATION_MESH_GENERATOR_PLUGIN_H
+#endif
+
+#endif
diff --git a/modules/recast/navigation_mesh_generator.cpp b/modules/gdnavigation/navigation_mesh_generator.cpp
index b6f5b38038..7f8761dac8 100644
--- a/modules/recast/navigation_mesh_generator.cpp
+++ b/modules/gdnavigation/navigation_mesh_generator.cpp
@@ -28,11 +28,12 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#ifndef _3D_DISABLED
+
#include "navigation_mesh_generator.h"
#include "core/math/quick_hull.h"
#include "core/os/thread.h"
-#include "editor/editor_settings.h"
#include "scene/3d/collision_shape.h"
#include "scene/3d/mesh_instance.h"
#include "scene/3d/physics_body.h"
@@ -47,6 +48,11 @@
#include "scene/resources/sphere_shape.h"
#include "modules/modules_enabled.gen.h"
+#ifdef TOOLS_ENABLED
+#include "editor/editor_node.h"
+#include "editor/editor_settings.h"
+#endif
+
#ifdef MODULE_CSG_ENABLED
#include "modules/csg/csg_shape.h"
#endif
@@ -54,15 +60,15 @@
#include "modules/gridmap/grid_map.h"
#endif
-EditorNavigationMeshGenerator *EditorNavigationMeshGenerator::singleton = NULL;
+NavigationMeshGenerator *NavigationMeshGenerator::singleton = NULL;
-void EditorNavigationMeshGenerator::_add_vertex(const Vector3 &p_vec3, Vector<float> &p_verticies) {
+void NavigationMeshGenerator::_add_vertex(const Vector3 &p_vec3, Vector<float> &p_verticies) {
p_verticies.push_back(p_vec3.x);
p_verticies.push_back(p_vec3.y);
p_verticies.push_back(p_vec3.z);
}
-void EditorNavigationMeshGenerator::_add_mesh(const Ref<Mesh> &p_mesh, const Transform &p_xform, Vector<float> &p_verticies, Vector<int> &p_indices) {
+void NavigationMeshGenerator::_add_mesh(const Ref<Mesh> &p_mesh, const Transform &p_xform, Vector<float> &p_verticies, Vector<int> &p_indices) {
int current_vertex_count;
for (int i = 0; i < p_mesh->get_surface_count(); i++) {
@@ -84,13 +90,13 @@ void EditorNavigationMeshGenerator::_add_mesh(const Ref<Mesh> &p_mesh, const Tra
Array a = p_mesh->surface_get_arrays(i);
- PoolVector<Vector3> mesh_vertices = a[Mesh::ARRAY_VERTEX];
- PoolVector<Vector3>::Read vr = mesh_vertices.read();
+ Vector<Vector3> mesh_vertices = a[Mesh::ARRAY_VERTEX];
+ const Vector3 *vr = mesh_vertices.ptr();
if (p_mesh->surface_get_format(i) & Mesh::ARRAY_FORMAT_INDEX) {
- PoolVector<int> mesh_indices = a[Mesh::ARRAY_INDEX];
- PoolVector<int>::Read ir = mesh_indices.read();
+ Vector<int> mesh_indices = a[Mesh::ARRAY_INDEX];
+ const int *ir = mesh_indices.ptr();
for (int j = 0; j < mesh_vertices.size(); j++) {
_add_vertex(p_xform.xform(vr[j]), p_verticies);
@@ -117,7 +123,7 @@ void EditorNavigationMeshGenerator::_add_mesh(const Ref<Mesh> &p_mesh, const Tra
}
}
-void EditorNavigationMeshGenerator::_add_faces(const PoolVector3Array &p_faces, const Transform &p_xform, Vector<float> &p_verticies, Vector<int> &p_indices) {
+void NavigationMeshGenerator::_add_faces(const PackedVector3Array &p_faces, const Transform &p_xform, Vector<float> &p_verticies, Vector<int> &p_indices) {
int face_count = p_faces.size() / 3;
int current_vertex_count = p_verticies.size() / 3;
@@ -132,7 +138,7 @@ void EditorNavigationMeshGenerator::_add_faces(const PoolVector3Array &p_faces,
}
}
-void EditorNavigationMeshGenerator::_parse_geometry(Transform p_accumulated_transform, Node *p_node, Vector<float> &p_verticies, Vector<int> &p_indices, int p_generate_from, uint32_t p_collision_mask, bool p_recurse_children) {
+void NavigationMeshGenerator::_parse_geometry(Transform p_accumulated_transform, Node *p_node, Vector<float> &p_verticies, Vector<int> &p_indices, int p_generate_from, uint32_t p_collision_mask, bool p_recurse_children) {
if (Object::cast_to<MeshInstance>(p_node) && p_generate_from != NavigationMesh::PARSED_GEOMETRY_STATIC_COLLIDERS) {
@@ -221,7 +227,7 @@ void EditorNavigationMeshGenerator::_parse_geometry(Transform p_accumulated_tran
Error err = QuickHull::build(varr, md);
if (err == OK) {
- PoolVector3Array faces;
+ PackedVector3Array faces;
for (int j = 0; j < md.faces.size(); ++j) {
Geometry::MeshData::Face face = md.faces[j];
@@ -271,13 +277,13 @@ void EditorNavigationMeshGenerator::_parse_geometry(Transform p_accumulated_tran
}
}
-void EditorNavigationMeshGenerator::_convert_detail_mesh_to_native_navigation_mesh(const rcPolyMeshDetail *p_detail_mesh, Ref<NavigationMesh> p_nav_mesh) {
+void NavigationMeshGenerator::_convert_detail_mesh_to_native_navigation_mesh(const rcPolyMeshDetail *p_detail_mesh, Ref<NavigationMesh> p_nav_mesh) {
- PoolVector<Vector3> nav_vertices;
+ Vector<Vector3> nav_vertices;
for (int i = 0; i < p_detail_mesh->nverts; i++) {
const float *v = &p_detail_mesh->verts[i * 3];
- nav_vertices.append(Vector3(v[0], v[1], v[2]));
+ nav_vertices.push_back(Vector3(v[0], v[1], v[2]));
}
p_nav_mesh->set_vertices(nav_vertices);
@@ -299,11 +305,24 @@ void EditorNavigationMeshGenerator::_convert_detail_mesh_to_native_navigation_me
}
}
-void EditorNavigationMeshGenerator::_build_recast_navigation_mesh(Ref<NavigationMesh> p_nav_mesh, EditorProgress *ep,
- rcHeightfield *hf, rcCompactHeightfield *chf, rcContourSet *cset, rcPolyMesh *poly_mesh, rcPolyMeshDetail *detail_mesh,
- Vector<float> &vertices, Vector<int> &indices) {
+void NavigationMeshGenerator::_build_recast_navigation_mesh(
+ Ref<NavigationMesh> p_nav_mesh,
+#ifdef TOOLS_ENABLED
+ EditorProgress *ep,
+#endif
+ rcHeightfield *hf,
+ rcCompactHeightfield *chf,
+ rcContourSet *cset,
+ rcPolyMesh *poly_mesh,
+ rcPolyMeshDetail *detail_mesh,
+ Vector<float> &vertices,
+ Vector<int> &indices) {
rcContext ctx;
- ep->step(TTR("Setting up Configuration..."), 1);
+
+#ifdef TOOLS_ENABLED
+ if (ep)
+ ep->step(TTR("Setting up Configuration..."), 1);
+#endif
const float *verts = vertices.ptr();
const int nverts = vertices.size() / 3;
@@ -337,16 +356,25 @@ void EditorNavigationMeshGenerator::_build_recast_navigation_mesh(Ref<Navigation
cfg.bmax[1] = bmax[1];
cfg.bmax[2] = bmax[2];
- ep->step(TTR("Calculating grid size..."), 2);
+#ifdef TOOLS_ENABLED
+ if (ep)
+ ep->step(TTR("Calculating grid size..."), 2);
+#endif
rcCalcGridSize(cfg.bmin, cfg.bmax, cfg.cs, &cfg.width, &cfg.height);
- ep->step(TTR("Creating heightfield..."), 3);
+#ifdef TOOLS_ENABLED
+ if (ep)
+ ep->step(TTR("Creating heightfield..."), 3);
+#endif
hf = rcAllocHeightfield();
ERR_FAIL_COND(!hf);
ERR_FAIL_COND(!rcCreateHeightfield(&ctx, *hf, cfg.width, cfg.height, cfg.bmin, cfg.bmax, cfg.cs, cfg.ch));
- ep->step(TTR("Marking walkable triangles..."), 4);
+#ifdef TOOLS_ENABLED
+ if (ep)
+ ep->step(TTR("Marking walkable triangles..."), 4);
+#endif
{
Vector<unsigned char> tri_areas;
tri_areas.resize(ntris);
@@ -366,7 +394,10 @@ void EditorNavigationMeshGenerator::_build_recast_navigation_mesh(Ref<Navigation
if (p_nav_mesh->get_filter_walkable_low_height_spans())
rcFilterWalkableLowHeightSpans(&ctx, cfg.walkableHeight, *hf);
- ep->step(TTR("Constructing compact heightfield..."), 5);
+#ifdef TOOLS_ENABLED
+ if (ep)
+ ep->step(TTR("Constructing compact heightfield..."), 5);
+#endif
chf = rcAllocCompactHeightfield();
@@ -376,10 +407,18 @@ void EditorNavigationMeshGenerator::_build_recast_navigation_mesh(Ref<Navigation
rcFreeHeightField(hf);
hf = 0;
- ep->step(TTR("Eroding walkable area..."), 6);
+#ifdef TOOLS_ENABLED
+ if (ep)
+ ep->step(TTR("Eroding walkable area..."), 6);
+#endif
+
ERR_FAIL_COND(!rcErodeWalkableArea(&ctx, cfg.walkableRadius, *chf));
- ep->step(TTR("Partitioning..."), 7);
+#ifdef TOOLS_ENABLED
+ if (ep)
+ ep->step(TTR("Partitioning..."), 7);
+#endif
+
if (p_nav_mesh->get_sample_partition_type() == NavigationMesh::SAMPLE_PARTITION_WATERSHED) {
ERR_FAIL_COND(!rcBuildDistanceField(&ctx, *chf));
ERR_FAIL_COND(!rcBuildRegions(&ctx, *chf, 0, cfg.minRegionArea, cfg.mergeRegionArea));
@@ -389,14 +428,20 @@ void EditorNavigationMeshGenerator::_build_recast_navigation_mesh(Ref<Navigation
ERR_FAIL_COND(!rcBuildLayerRegions(&ctx, *chf, 0, cfg.minRegionArea));
}
- ep->step(TTR("Creating contours..."), 8);
+#ifdef TOOLS_ENABLED
+ if (ep)
+ ep->step(TTR("Creating contours..."), 8);
+#endif
cset = rcAllocContourSet();
ERR_FAIL_COND(!cset);
ERR_FAIL_COND(!rcBuildContours(&ctx, *chf, cfg.maxSimplificationError, cfg.maxEdgeLen, *cset));
- ep->step(TTR("Creating polymesh..."), 9);
+#ifdef TOOLS_ENABLED
+ if (ep)
+ ep->step(TTR("Creating polymesh..."), 9);
+#endif
poly_mesh = rcAllocPolyMesh();
ERR_FAIL_COND(!poly_mesh);
@@ -411,7 +456,10 @@ void EditorNavigationMeshGenerator::_build_recast_navigation_mesh(Ref<Navigation
rcFreeContourSet(cset);
cset = 0;
- ep->step(TTR("Converting to native navigation mesh..."), 10);
+#ifdef TOOLS_ENABLED
+ if (ep)
+ ep->step(TTR("Converting to native navigation mesh..."), 10);
+#endif
_convert_detail_mesh_to_native_navigation_mesh(detail_mesh, p_nav_mesh);
@@ -421,23 +469,30 @@ void EditorNavigationMeshGenerator::_build_recast_navigation_mesh(Ref<Navigation
detail_mesh = 0;
}
-EditorNavigationMeshGenerator *EditorNavigationMeshGenerator::get_singleton() {
+NavigationMeshGenerator *NavigationMeshGenerator::get_singleton() {
return singleton;
}
-EditorNavigationMeshGenerator::EditorNavigationMeshGenerator() {
+NavigationMeshGenerator::NavigationMeshGenerator() {
singleton = this;
}
-EditorNavigationMeshGenerator::~EditorNavigationMeshGenerator() {
+NavigationMeshGenerator::~NavigationMeshGenerator() {
}
-void EditorNavigationMeshGenerator::bake(Ref<NavigationMesh> p_nav_mesh, Node *p_node) {
+void NavigationMeshGenerator::bake(Ref<NavigationMesh> p_nav_mesh, Node *p_node) {
ERR_FAIL_COND(!p_nav_mesh.is_valid());
- EditorProgress ep("bake", TTR("Navigation Mesh Generator Setup:"), 11);
- ep.step(TTR("Parsing Geometry..."), 0);
+#ifdef TOOLS_ENABLED
+ EditorProgress *ep(NULL);
+ if (Engine::get_singleton()->is_editor_hint()) {
+ ep = memnew(EditorProgress("bake", TTR("Navigation Mesh Generator Setup:"), 11));
+ }
+
+ if (ep)
+ ep->step(TTR("Parsing Geometry..."), 0);
+#endif
Vector<float> vertices;
Vector<int> indices;
@@ -466,7 +521,18 @@ void EditorNavigationMeshGenerator::bake(Ref<NavigationMesh> p_nav_mesh, Node *p
rcPolyMesh *poly_mesh = NULL;
rcPolyMeshDetail *detail_mesh = NULL;
- _build_recast_navigation_mesh(p_nav_mesh, &ep, hf, chf, cset, poly_mesh, detail_mesh, vertices, indices);
+ _build_recast_navigation_mesh(
+ p_nav_mesh,
+#ifdef TOOLS_ENABLED
+ ep,
+#endif
+ hf,
+ chf,
+ cset,
+ poly_mesh,
+ detail_mesh,
+ vertices,
+ indices);
rcFreeHeightField(hf);
hf = 0;
@@ -483,17 +549,26 @@ void EditorNavigationMeshGenerator::bake(Ref<NavigationMesh> p_nav_mesh, Node *p
rcFreePolyMeshDetail(detail_mesh);
detail_mesh = 0;
}
- ep.step(TTR("Done!"), 11);
+
+#ifdef TOOLS_ENABLED
+ if (ep)
+ ep->step(TTR("Done!"), 11);
+
+ if (ep)
+ memdelete(ep);
+#endif
}
-void EditorNavigationMeshGenerator::clear(Ref<NavigationMesh> p_nav_mesh) {
+void NavigationMeshGenerator::clear(Ref<NavigationMesh> p_nav_mesh) {
if (p_nav_mesh.is_valid()) {
p_nav_mesh->clear_polygons();
- p_nav_mesh->set_vertices(PoolVector<Vector3>());
+ p_nav_mesh->set_vertices(Vector<Vector3>());
}
}
-void EditorNavigationMeshGenerator::_bind_methods() {
- ClassDB::bind_method(D_METHOD("bake", "nav_mesh", "root_node"), &EditorNavigationMeshGenerator::bake);
- ClassDB::bind_method(D_METHOD("clear", "nav_mesh"), &EditorNavigationMeshGenerator::clear);
+void NavigationMeshGenerator::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("bake", "nav_mesh", "root_node"), &NavigationMeshGenerator::bake);
+ ClassDB::bind_method(D_METHOD("clear", "nav_mesh"), &NavigationMeshGenerator::clear);
}
+
+#endif
diff --git a/modules/recast/navigation_mesh_generator.h b/modules/gdnavigation/navigation_mesh_generator.h
index 8c7ca8b62c..27a56e1d7a 100644
--- a/modules/recast/navigation_mesh_generator.h
+++ b/modules/gdnavigation/navigation_mesh_generator.h
@@ -31,37 +31,53 @@
#ifndef NAVIGATION_MESH_GENERATOR_H
#define NAVIGATION_MESH_GENERATOR_H
-#include "editor/editor_node.h"
-#include "scene/3d/navigation_mesh.h"
+#ifndef _3D_DISABLED
+
+#include "scene/3d/navigation_mesh_instance.h"
#include <Recast.h>
-class EditorNavigationMeshGenerator : public Object {
- GDCLASS(EditorNavigationMeshGenerator, Object);
+#ifdef TOOLS_ENABLED
+struct EditorProgress;
+#endif
+
+class NavigationMeshGenerator : public Object {
+ GDCLASS(NavigationMeshGenerator, Object);
- static EditorNavigationMeshGenerator *singleton;
+ static NavigationMeshGenerator *singleton;
protected:
static void _bind_methods();
static void _add_vertex(const Vector3 &p_vec3, Vector<float> &p_verticies);
static void _add_mesh(const Ref<Mesh> &p_mesh, const Transform &p_xform, Vector<float> &p_verticies, Vector<int> &p_indices);
- static void _add_faces(const PoolVector3Array &p_faces, const Transform &p_xform, Vector<float> &p_verticies, Vector<int> &p_indices);
+ static void _add_faces(const PackedVector3Array &p_faces, const Transform &p_xform, Vector<float> &p_verticies, Vector<int> &p_indices);
static void _parse_geometry(Transform p_accumulated_transform, Node *p_node, Vector<float> &p_verticies, Vector<int> &p_indices, int p_generate_from, uint32_t p_collision_mask, bool p_recurse_children);
static void _convert_detail_mesh_to_native_navigation_mesh(const rcPolyMeshDetail *p_detail_mesh, Ref<NavigationMesh> p_nav_mesh);
- static void _build_recast_navigation_mesh(Ref<NavigationMesh> p_nav_mesh, EditorProgress *ep,
- rcHeightfield *hf, rcCompactHeightfield *chf, rcContourSet *cset, rcPolyMesh *poly_mesh,
- rcPolyMeshDetail *detail_mesh, Vector<float> &vertices, Vector<int> &indices);
+ static void _build_recast_navigation_mesh(
+ Ref<NavigationMesh> p_nav_mesh,
+#ifdef TOOLS_ENABLED
+ EditorProgress *ep,
+#endif
+ rcHeightfield *hf,
+ rcCompactHeightfield *chf,
+ rcContourSet *cset,
+ rcPolyMesh *poly_mesh,
+ rcPolyMeshDetail *detail_mesh,
+ Vector<float> &vertices,
+ Vector<int> &indices);
public:
- static EditorNavigationMeshGenerator *get_singleton();
+ static NavigationMeshGenerator *get_singleton();
- EditorNavigationMeshGenerator();
- ~EditorNavigationMeshGenerator();
+ NavigationMeshGenerator();
+ ~NavigationMeshGenerator();
void bake(Ref<NavigationMesh> p_nav_mesh, Node *p_node);
void clear(Ref<NavigationMesh> p_nav_mesh);
};
+#endif
+
#endif // NAVIGATION_MESH_GENERATOR_H
diff --git a/modules/recast/register_types.cpp b/modules/gdnavigation/register_types.cpp
index ea0ab00771..d717733787 100644
--- a/modules/recast/register_types.cpp
+++ b/modules/gdnavigation/register_types.cpp
@@ -30,30 +30,51 @@
#include "register_types.h"
-#include "navigation_mesh_editor_plugin.h"
+#include "core/engine.h"
+#include "gd_navigation_server.h"
+#include "servers/navigation_server.h"
-#ifdef TOOLS_ENABLED
-EditorNavigationMeshGenerator *_nav_mesh_generator = NULL;
+#ifndef _3D_DISABLED
+#include "navigation_mesh_generator.h"
#endif
-void register_recast_types() {
#ifdef TOOLS_ENABLED
- ClassDB::APIType prev_api = ClassDB::get_current_api();
- ClassDB::set_current_api(ClassDB::API_EDITOR);
+#include "navigation_mesh_editor_plugin.h"
+#endif
- EditorPlugins::add_by_type<NavigationMeshEditorPlugin>();
- _nav_mesh_generator = memnew(EditorNavigationMeshGenerator);
+/**
+ @author AndreaCatania
+*/
- ClassDB::register_class<EditorNavigationMeshGenerator>();
+#ifndef _3D_DISABLED
+NavigationMeshGenerator *_nav_mesh_generator = NULL;
+#endif
+
+NavigationServer *new_server() {
+ return memnew(GdNavigationServer);
+}
- Engine::get_singleton()->add_singleton(Engine::Singleton("NavigationMeshGenerator", EditorNavigationMeshGenerator::get_singleton()));
+void register_gdnavigation_types() {
+ NavigationServerManager::set_default_server(new_server);
+
+#ifndef _3D_DISABLED
+ _nav_mesh_generator = memnew(NavigationMeshGenerator);
+ ClassDB::register_class<NavigationMeshGenerator>();
+ Engine::get_singleton()->add_singleton(Engine::Singleton("NavigationMeshGenerator", NavigationMeshGenerator::get_singleton()));
+#endif
+
+#ifdef TOOLS_ENABLED
+ EditorPlugins::add_by_type<NavigationMeshEditorPlugin>();
+
+ ClassDB::APIType prev_api = ClassDB::get_current_api();
+ ClassDB::set_current_api(ClassDB::API_EDITOR);
ClassDB::set_current_api(prev_api);
#endif
}
-void unregister_recast_types() {
-#ifdef TOOLS_ENABLED
+void unregister_gdnavigation_types() {
+#ifndef _3D_DISABLED
if (_nav_mesh_generator) {
memdelete(_nav_mesh_generator);
}
diff --git a/modules/gdnavigation/register_types.h b/modules/gdnavigation/register_types.h
new file mode 100644
index 0000000000..bd15eaaada
--- /dev/null
+++ b/modules/gdnavigation/register_types.h
@@ -0,0 +1,36 @@
+/*************************************************************************/
+/* register_types.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+/**
+ @author AndreaCatania
+*/
+
+void register_gdnavigation_types();
+void unregister_gdnavigation_types();
diff --git a/modules/gdnavigation/rvo_agent.cpp b/modules/gdnavigation/rvo_agent.cpp
new file mode 100644
index 0000000000..677e525bbf
--- /dev/null
+++ b/modules/gdnavigation/rvo_agent.cpp
@@ -0,0 +1,84 @@
+/*************************************************************************/
+/* rvo_agent.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#include "rvo_agent.h"
+
+#include "nav_map.h"
+
+/**
+ @author AndreaCatania
+*/
+
+RvoAgent::RvoAgent() :
+ map(NULL) {
+ callback.id = ObjectID();
+}
+
+void RvoAgent::set_map(NavMap *p_map) {
+ map = p_map;
+}
+
+bool RvoAgent::is_map_changed() {
+ if (map) {
+ bool is_changed = map->get_map_update_id() != map_update_id;
+ map_update_id = map->get_map_update_id();
+ return is_changed;
+ } else {
+ return false;
+ }
+}
+
+void RvoAgent::set_callback(ObjectID p_id, const StringName p_method, const Variant p_udata) {
+ callback.id = p_id;
+ callback.method = p_method;
+ callback.udata = p_udata;
+}
+
+bool RvoAgent::has_callback() const {
+ return callback.id.is_valid();
+}
+
+void RvoAgent::dispatch_callback() {
+ if (callback.id.is_null()) {
+ return;
+ }
+ Object *obj = ObjectDB::get_instance(callback.id);
+ if (obj == NULL) {
+ callback.id = ObjectID();
+ }
+
+ Callable::CallError responseCallError;
+
+ callback.new_velocity = Vector3(agent.newVelocity_.x(), agent.newVelocity_.y(), agent.newVelocity_.z());
+
+ const Variant *vp[2] = { &callback.new_velocity, &callback.udata };
+ int argc = (callback.udata.get_type() == Variant::NIL) ? 1 : 2;
+ obj->call(callback.method, vp, argc, responseCallError);
+}
diff --git a/modules/gdnavigation/rvo_agent.h b/modules/gdnavigation/rvo_agent.h
new file mode 100644
index 0000000000..914cbaa7d9
--- /dev/null
+++ b/modules/gdnavigation/rvo_agent.h
@@ -0,0 +1,77 @@
+/*************************************************************************/
+/* rvo_agent.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifndef RVO_AGENT_H
+#define RVO_AGENT_H
+
+#include "core/object.h"
+#include "nav_rid.h"
+#include <Agent.h>
+
+/**
+ @author AndreaCatania
+*/
+
+class NavMap;
+
+class RvoAgent : public NavRid {
+ struct AvoidanceComputedCallback {
+ ObjectID id;
+ StringName method;
+ Variant udata;
+ Variant new_velocity;
+ };
+
+ NavMap *map;
+ RVO::Agent agent;
+ AvoidanceComputedCallback callback;
+ uint32_t map_update_id;
+
+public:
+ RvoAgent();
+
+ void set_map(NavMap *p_map);
+ NavMap *get_map() {
+ return map;
+ }
+
+ RVO::Agent *get_agent() {
+ return &agent;
+ }
+
+ bool is_map_changed();
+
+ void set_callback(ObjectID p_id, const StringName p_method, const Variant p_udata = Variant());
+ bool has_callback() const;
+
+ void dispatch_callback();
+};
+
+#endif // RVO_AGENT_H
diff --git a/modules/gdscript/doc_classes/@GDScript.xml b/modules/gdscript/doc_classes/@GDScript.xml
index b947d95fac..cf76c09294 100644
--- a/modules/gdscript/doc_classes/@GDScript.xml
+++ b/modules/gdscript/doc_classes/@GDScript.xml
@@ -131,7 +131,7 @@
<method name="bytes2var">
<return type="Variant">
</return>
- <argument index="0" name="bytes" type="PoolByteArray">
+ <argument index="0" name="bytes" type="PackedByteArray">
</argument>
<argument index="1" name="allow_objects" type="bool" default="false">
</argument>
@@ -256,15 +256,6 @@
Converts from decibels to linear energy (audio).
</description>
</method>
- <method name="decimals">
- <return type="int">
- </return>
- <argument index="0" name="step" type="float">
- </argument>
- <description>
- Deprecated alias for [method step_decimals].
- </description>
- </method>
<method name="dectime">
<return type="float">
</return>
@@ -1254,7 +1245,7 @@
</description>
</method>
<method name="var2bytes">
- <return type="PoolByteArray">
+ <return type="PackedByteArray">
</return>
<argument index="0" name="var" type="Variant">
</argument>
diff --git a/modules/gdscript/doc_classes/GDScript.xml b/modules/gdscript/doc_classes/GDScript.xml
index 5d0e93e117..62ccb93901 100644
--- a/modules/gdscript/doc_classes/GDScript.xml
+++ b/modules/gdscript/doc_classes/GDScript.xml
@@ -12,7 +12,7 @@
</tutorials>
<methods>
<method name="get_as_byte_code" qualifiers="const">
- <return type="PoolByteArray">
+ <return type="PackedByteArray">
</return>
<description>
Returns byte code for the script source code.
diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp
index a255b92257..a72bb7ba49 100644
--- a/modules/gdscript/gdscript.cpp
+++ b/modules/gdscript/gdscript.cpp
@@ -30,6 +30,8 @@
#include "gdscript.h"
+#include <stdint.h>
+
#include "core/core_string_names.h"
#include "core/engine.h"
#include "core/global_constants.h"
@@ -82,7 +84,7 @@ Object *GDScriptNativeClass::instance() {
return ClassDB::instance(name);
}
-GDScriptInstance *GDScript::_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, bool p_isref, Variant::CallError &r_error) {
+GDScriptInstance *GDScript::_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, bool p_isref, Callable::CallError &r_error) {
/* STEP 1, CREATE */
@@ -91,6 +93,7 @@ GDScriptInstance *GDScript::_create_instance(const Variant **p_args, int p_argco
instance->members.resize(member_indices.size());
instance->script = Ref<GDScript>(this);
instance->owner = p_owner;
+ instance->owner_id = p_owner->get_instance_id();
#ifdef DEBUG_ENABLED
//needed for hot reloading
for (Map<StringName, MemberInfo>::Element *E = member_indices.front(); E; E = E->next()) {
@@ -113,7 +116,7 @@ GDScriptInstance *GDScript::_create_instance(const Variant **p_args, int p_argco
initializer->call(instance, p_args, p_argcount, r_error);
- if (r_error.error != Variant::CallError::CALL_OK) {
+ if (r_error.error != Callable::CallError::CALL_OK) {
instance->script = Ref<GDScript>();
instance->owner->set_script_instance(NULL);
#ifndef NO_THREADS
@@ -124,23 +127,23 @@ GDScriptInstance *GDScript::_create_instance(const Variant **p_args, int p_argco
GDScriptLanguage::singleton->lock->unlock();
#endif
- ERR_FAIL_COND_V(r_error.error != Variant::CallError::CALL_OK, NULL); //error constructing
+ ERR_FAIL_COND_V(r_error.error != Callable::CallError::CALL_OK, NULL); //error constructing
}
//@TODO make thread safe
return instance;
}
-Variant GDScript::_new(const Variant **p_args, int p_argcount, Variant::CallError &r_error) {
+Variant GDScript::_new(const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
/* STEP 1, CREATE */
if (!valid) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
return Variant();
}
- r_error.error = Variant::CallError::CALL_OK;
+ r_error.error = Callable::CallError::CALL_OK;
REF ref;
Object *owner = NULL;
@@ -326,7 +329,7 @@ ScriptInstance *GDScript::instance_create(Object *p_this) {
}
}
- Variant::CallError unchecked_error;
+ Callable::CallError unchecked_error;
return _create_instance(NULL, 0, p_this, Object::cast_to<Reference>(p_this) != NULL, unchecked_error);
}
@@ -610,6 +613,53 @@ Error GDScript::reload(bool p_keep_state) {
_set_subclass_path(E->get(), path);
}
+ // Copy the base rpc methods so we don't mask their IDs.
+ rpc_functions.clear();
+ rpc_variables.clear();
+ if (base.is_valid()) {
+ rpc_functions = base->rpc_functions;
+ rpc_variables = base->rpc_variables;
+ }
+
+ GDScript *cscript = this;
+ Map<StringName, Ref<GDScript> >::Element *sub_E = subclasses.front();
+ while (cscript) {
+ // RPC Methods
+ for (Map<StringName, GDScriptFunction *>::Element *E = cscript->member_functions.front(); E; E = E->next()) {
+ if (E->get()->get_rpc_mode() != MultiplayerAPI::RPC_MODE_DISABLED) {
+ ScriptNetData nd;
+ nd.name = E->key();
+ nd.mode = E->get()->get_rpc_mode();
+ if (-1 == rpc_functions.find(nd)) {
+ rpc_functions.push_back(nd);
+ }
+ }
+ }
+ // RSet
+ for (Map<StringName, MemberInfo>::Element *E = cscript->member_indices.front(); E; E = E->next()) {
+ if (E->get().rpc_mode != MultiplayerAPI::RPC_MODE_DISABLED) {
+ ScriptNetData nd;
+ nd.name = E->key();
+ nd.mode = E->get().rpc_mode;
+ if (-1 == rpc_variables.find(nd)) {
+ rpc_variables.push_back(nd);
+ }
+ }
+ }
+
+ if (cscript != this)
+ sub_E = sub_E->next();
+
+ if (sub_E)
+ cscript = sub_E->get().ptr();
+ else
+ cscript = NULL;
+ }
+
+ // Sort so we are 100% that they are always the same.
+ rpc_functions.sort_custom<SortNetData>();
+ rpc_variables.sort_custom<SortNetData>();
+
return OK;
}
@@ -635,7 +685,61 @@ void GDScript::get_members(Set<StringName> *p_members) {
}
}
-Variant GDScript::call(const StringName &p_method, const Variant **p_args, int p_argcount, Variant::CallError &r_error) {
+Vector<ScriptNetData> GDScript::get_rpc_methods() const {
+ return rpc_functions;
+}
+
+uint16_t GDScript::get_rpc_method_id(const StringName &p_method) const {
+ for (int i = 0; i < rpc_functions.size(); i++) {
+ if (rpc_functions[i].name == p_method) {
+ return i;
+ }
+ }
+ return UINT16_MAX;
+}
+
+StringName GDScript::get_rpc_method(const uint16_t p_rpc_method_id) const {
+ ERR_FAIL_COND_V(p_rpc_method_id >= rpc_functions.size(), StringName());
+ return rpc_functions[p_rpc_method_id].name;
+}
+
+MultiplayerAPI::RPCMode GDScript::get_rpc_mode_by_id(const uint16_t p_rpc_method_id) const {
+ ERR_FAIL_COND_V(p_rpc_method_id >= rpc_functions.size(), MultiplayerAPI::RPC_MODE_DISABLED);
+ return rpc_functions[p_rpc_method_id].mode;
+}
+
+MultiplayerAPI::RPCMode GDScript::get_rpc_mode(const StringName &p_method) const {
+ return get_rpc_mode_by_id(get_rpc_method_id(p_method));
+}
+
+Vector<ScriptNetData> GDScript::get_rset_properties() const {
+ return rpc_variables;
+}
+
+uint16_t GDScript::get_rset_property_id(const StringName &p_variable) const {
+ for (int i = 0; i < rpc_variables.size(); i++) {
+ if (rpc_variables[i].name == p_variable) {
+ return i;
+ }
+ }
+ return UINT16_MAX;
+}
+
+StringName GDScript::get_rset_property(const uint16_t p_rset_member_id) const {
+ ERR_FAIL_COND_V(p_rset_member_id >= rpc_variables.size(), StringName());
+ return rpc_variables[p_rset_member_id].name;
+}
+
+MultiplayerAPI::RPCMode GDScript::get_rset_mode_by_id(const uint16_t p_rset_member_id) const {
+ ERR_FAIL_COND_V(p_rset_member_id >= rpc_functions.size(), MultiplayerAPI::RPC_MODE_DISABLED);
+ return rpc_functions[p_rset_member_id].mode;
+}
+
+MultiplayerAPI::RPCMode GDScript::get_rset_mode(const StringName &p_variable) const {
+ return get_rset_mode_by_id(get_rset_property_id(p_variable));
+}
+
+Variant GDScript::call(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
GDScript *top = this;
while (top) {
@@ -798,7 +902,7 @@ Error GDScript::load_byte_code(const String &p_path) {
Error GDScript::load_source_code(const String &p_path) {
- PoolVector<uint8_t> sourcef;
+ Vector<uint8_t> sourcef;
Error err;
FileAccess *f = FileAccess::open(p_path, FileAccess::READ, &err);
if (err) {
@@ -808,15 +912,15 @@ Error GDScript::load_source_code(const String &p_path) {
int len = f->get_len();
sourcef.resize(len + 1);
- PoolVector<uint8_t>::Write w = sourcef.write();
- int r = f->get_buffer(w.ptr(), len);
+ uint8_t *w = sourcef.ptrw();
+ int r = f->get_buffer(w, len);
f->close();
memdelete(f);
ERR_FAIL_COND_V(r != len, ERR_CANT_OPEN);
w[len] = 0;
String s;
- if (s.parse_utf8((const char *)w.ptr())) {
+ if (s.parse_utf8((const char *)w)) {
ERR_FAIL_V_MSG(ERR_INVALID_DATA, "Script '" + p_path + "' contains invalid unicode (UTF-8), so it was not loaded. Please ensure that scripts are saved in valid UTF-8 unicode.");
}
@@ -891,7 +995,6 @@ void GDScript::get_script_signal_list(List<MethodInfo> *r_signals) const {
GDScript::GDScript() :
script_list(this) {
- _static_ref = this;
valid = false;
subclass_count = 0;
initializer = NULL;
@@ -978,18 +1081,18 @@ bool GDScriptInstance::set(const StringName &p_name, const Variant &p_value) {
const GDScript::MemberInfo *member = &E->get();
if (member->setter) {
const Variant *val = &p_value;
- Variant::CallError err;
+ Callable::CallError err;
call(member->setter, &val, 1, err);
- if (err.error == Variant::CallError::CALL_OK) {
+ if (err.error == Callable::CallError::CALL_OK) {
return true; //function exists, call was successful
}
} else {
if (!member->data_type.is_type(p_value)) {
// Try conversion
- Variant::CallError ce;
+ Callable::CallError ce;
const Variant *value = &p_value;
Variant converted = Variant::construct(member->data_type.builtin_type, &value, 1, ce);
- if (ce.error == Variant::CallError::CALL_OK) {
+ if (ce.error == Callable::CallError::CALL_OK) {
members.write[member->index] = converted;
return true;
} else {
@@ -1012,9 +1115,9 @@ bool GDScriptInstance::set(const StringName &p_name, const Variant &p_value) {
Variant name = p_name;
const Variant *args[2] = { &name, &p_value };
- Variant::CallError err;
+ Callable::CallError err;
Variant ret = E->get()->call(this, (const Variant **)args, 2, err);
- if (err.error == Variant::CallError::CALL_OK && ret.get_type() == Variant::BOOL && ret.operator bool())
+ if (err.error == Callable::CallError::CALL_OK && ret.get_type() == Variant::BOOL && ret.operator bool())
return true;
}
sptr = sptr->_base;
@@ -1032,9 +1135,9 @@ bool GDScriptInstance::get(const StringName &p_name, Variant &r_ret) const {
const Map<StringName, GDScript::MemberInfo>::Element *E = script->member_indices.find(p_name);
if (E) {
if (E->get().getter) {
- Variant::CallError err;
+ Callable::CallError err;
r_ret = const_cast<GDScriptInstance *>(this)->call(E->get().getter, NULL, 0, err);
- if (err.error == Variant::CallError::CALL_OK) {
+ if (err.error == Callable::CallError::CALL_OK) {
return true;
}
}
@@ -1063,9 +1166,9 @@ bool GDScriptInstance::get(const StringName &p_name, Variant &r_ret) const {
Variant name = p_name;
const Variant *args[1] = { &name };
- Variant::CallError err;
+ Callable::CallError err;
Variant ret = const_cast<GDScriptFunction *>(E->get())->call(const_cast<GDScriptInstance *>(this), (const Variant **)args, 1, err);
- if (err.error == Variant::CallError::CALL_OK && ret.get_type() != Variant::NIL) {
+ if (err.error == Callable::CallError::CALL_OK && ret.get_type() != Variant::NIL) {
r_ret = ret;
return true;
}
@@ -1106,9 +1209,9 @@ void GDScriptInstance::get_property_list(List<PropertyInfo> *p_properties) const
const Map<StringName, GDScriptFunction *>::Element *E = sptr->member_functions.find(GDScriptLanguage::get_singleton()->strings._get_property_list);
if (E) {
- Variant::CallError err;
+ Callable::CallError err;
Variant ret = const_cast<GDScriptFunction *>(E->get())->call(const_cast<GDScriptInstance *>(this), NULL, 0, err);
- if (err.error == Variant::CallError::CALL_OK) {
+ if (err.error == Callable::CallError::CALL_OK) {
ERR_FAIL_COND_MSG(ret.get_type() != Variant::ARRAY, "Wrong type for _get_property_list, must be an array of dictionaries.");
@@ -1193,7 +1296,7 @@ bool GDScriptInstance::has_method(const StringName &p_method) const {
return false;
}
-Variant GDScriptInstance::call(const StringName &p_method, const Variant **p_args, int p_argcount, Variant::CallError &r_error) {
+Variant GDScriptInstance::call(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
GDScript *sptr = script.ptr();
while (sptr) {
@@ -1203,14 +1306,14 @@ Variant GDScriptInstance::call(const StringName &p_method, const Variant **p_arg
}
sptr = sptr->_base;
}
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
return Variant();
}
void GDScriptInstance::call_multilevel(const StringName &p_method, const Variant **p_args, int p_argcount) {
GDScript *sptr = script.ptr();
- Variant::CallError ce;
+ Callable::CallError ce;
while (sptr) {
Map<StringName, GDScriptFunction *>::Element *E = sptr->member_functions.find(p_method);
@@ -1226,7 +1329,7 @@ void GDScriptInstance::_ml_call_reversed(GDScript *sptr, const StringName &p_met
if (sptr->_base)
_ml_call_reversed(sptr->_base, p_method, p_args, p_argcount);
- Variant::CallError ce;
+ Callable::CallError ce;
Map<StringName, GDScriptFunction *>::Element *E = sptr->member_functions.find(p_method);
if (E) {
@@ -1251,9 +1354,9 @@ void GDScriptInstance::notification(int p_notification) {
while (sptr) {
Map<StringName, GDScriptFunction *>::Element *E = sptr->member_functions.find(GDScriptLanguage::get_singleton()->strings._notification);
if (E) {
- Variant::CallError err;
+ Callable::CallError err;
E->get()->call(this, args, 1, err);
- if (err.error != Variant::CallError::CALL_OK) {
+ if (err.error != Callable::CallError::CALL_OK) {
//print error about notification call
}
}
@@ -1263,9 +1366,9 @@ void GDScriptInstance::notification(int p_notification) {
String GDScriptInstance::to_string(bool *r_valid) {
if (has_method(CoreStringNames::get_singleton()->_to_string)) {
- Variant::CallError ce;
+ Callable::CallError ce;
Variant ret = call(CoreStringNames::get_singleton()->_to_string, NULL, 0, ce);
- if (ce.error == Variant::CallError::CALL_OK) {
+ if (ce.error == Callable::CallError::CALL_OK) {
if (ret.get_type() != Variant::STRING) {
if (r_valid)
*r_valid = false;
@@ -1291,40 +1394,44 @@ ScriptLanguage *GDScriptInstance::get_language() {
return GDScriptLanguage::get_singleton();
}
-MultiplayerAPI::RPCMode GDScriptInstance::get_rpc_mode(const StringName &p_method) const {
+Vector<ScriptNetData> GDScriptInstance::get_rpc_methods() const {
+ return script->get_rpc_methods();
+}
- const GDScript *cscript = script.ptr();
+uint16_t GDScriptInstance::get_rpc_method_id(const StringName &p_method) const {
+ return script->get_rpc_method_id(p_method);
+}
- while (cscript) {
- const Map<StringName, GDScriptFunction *>::Element *E = cscript->member_functions.find(p_method);
- if (E) {
+StringName GDScriptInstance::get_rpc_method(const uint16_t p_rpc_method_id) const {
+ return script->get_rpc_method(p_rpc_method_id);
+}
- if (E->get()->get_rpc_mode() != MultiplayerAPI::RPC_MODE_DISABLED) {
- return E->get()->get_rpc_mode();
- }
- }
- cscript = cscript->_base;
- }
+MultiplayerAPI::RPCMode GDScriptInstance::get_rpc_mode_by_id(const uint16_t p_rpc_method_id) const {
+ return script->get_rpc_mode_by_id(p_rpc_method_id);
+}
- return MultiplayerAPI::RPC_MODE_DISABLED;
+MultiplayerAPI::RPCMode GDScriptInstance::get_rpc_mode(const StringName &p_method) const {
+ return script->get_rpc_mode(p_method);
}
-MultiplayerAPI::RPCMode GDScriptInstance::get_rset_mode(const StringName &p_variable) const {
+Vector<ScriptNetData> GDScriptInstance::get_rset_properties() const {
+ return script->get_rset_properties();
+}
- const GDScript *cscript = script.ptr();
+uint16_t GDScriptInstance::get_rset_property_id(const StringName &p_variable) const {
+ return script->get_rset_property_id(p_variable);
+}
- while (cscript) {
- const Map<StringName, GDScript::MemberInfo>::Element *E = cscript->member_indices.find(p_variable);
- if (E) {
+StringName GDScriptInstance::get_rset_property(const uint16_t p_rset_member_id) const {
+ return script->get_rset_property(p_rset_member_id);
+}
- if (E->get().rpc_mode) {
- return E->get().rpc_mode;
- }
- }
- cscript = cscript->_base;
- }
+MultiplayerAPI::RPCMode GDScriptInstance::get_rset_mode_by_id(const uint16_t p_rset_member_id) const {
+ return script->get_rset_mode_by_id(p_rset_member_id);
+}
- return MultiplayerAPI::RPC_MODE_DISABLED;
+MultiplayerAPI::RPCMode GDScriptInstance::get_rset_mode(const StringName &p_variable) const {
+ return script->get_rset_mode(p_variable);
}
void GDScriptInstance::reload_members() {
@@ -1685,7 +1792,7 @@ void GDScriptLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_so
obj->get_script_instance()->get_property_state(state);
map[obj->get_instance_id()] = state;
- obj->set_script(RefPtr());
+ obj->set_script(Variant());
}
}
@@ -1701,7 +1808,7 @@ void GDScriptLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_so
map.insert(obj->get_instance_id(), List<Pair<StringName, Variant> >());
List<Pair<StringName, Variant> > &state = map[obj->get_instance_id()];
obj->get_script_instance()->get_property_state(state);
- obj->set_script(RefPtr());
+ obj->set_script(Variant());
} else {
// no instance found. Let's remove it so we don't loop forever
E->get()->placeholders.erase(E->get()->placeholders.front()->get());
@@ -1732,9 +1839,9 @@ void GDScriptLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_so
if (!p_soft_reload) {
//clear it just in case (may be a pending reload state)
- obj->set_script(RefPtr());
+ obj->set_script(Variant());
}
- obj->set_script(scr.get_ref_ptr());
+ obj->set_script(scr);
ScriptInstance *script_instance = obj->get_script_instance();
@@ -1850,10 +1957,8 @@ void GDScriptLanguage::get_reserved_words(List<String> *p_words) const {
"match",
"while",
"remote",
- "sync",
"master",
"puppet",
- "slave",
"remotesync",
"mastersync",
"puppetsync",
@@ -1880,7 +1985,7 @@ bool GDScriptLanguage::handles_global_class_type(const String &p_type) const {
String GDScriptLanguage::get_global_class_name(const String &p_path, String *r_base_type, String *r_icon_path) const {
- PoolVector<uint8_t> sourcef;
+ Vector<uint8_t> sourcef;
Error err;
FileAccessRef f = FileAccess::open(p_path, FileAccess::READ, &err);
if (err) {
diff --git a/modules/gdscript/gdscript.h b/modules/gdscript/gdscript.h
index 4ae52238ce..6598a0023b 100644
--- a/modules/gdscript/gdscript.h
+++ b/modules/gdscript/gdscript.h
@@ -73,7 +73,6 @@ class GDScript : public Script {
friend class GDScriptFunctions;
friend class GDScriptLanguage;
- Variant _static_ref; //used for static call
Ref<GDScriptNativeClass> native;
Ref<GDScript> base;
GDScript *_base; //fast pointer access
@@ -85,6 +84,8 @@ class GDScript : public Script {
Map<StringName, MemberInfo> member_indices; //members are just indices to the instanced script.
Map<StringName, Ref<GDScript> > subclasses;
Map<StringName, Vector<StringName> > _signals;
+ Vector<ScriptNetData> rpc_functions;
+ Vector<ScriptNetData> rpc_variables;
#ifdef TOOLS_ENABLED
@@ -114,7 +115,7 @@ class GDScript : public Script {
String fully_qualified_name;
SelfList<GDScript> script_list;
- GDScriptInstance *_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, bool p_isref, Variant::CallError &r_error);
+ GDScriptInstance *_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, bool p_isref, Callable::CallError &r_error);
void _set_subclass_path(Ref<GDScript> &p_sc, const String &p_path);
@@ -139,7 +140,7 @@ protected:
bool _set(const StringName &p_name, const Variant &p_value);
void _get_property_list(List<PropertyInfo> *p_properties) const;
- Variant call(const StringName &p_method, const Variant **p_args, int p_argcount, Variant::CallError &r_error);
+ Variant call(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error);
//void call_multilevel(const StringName& p_method,const Variant** p_args,int p_argcount);
static void _bind_methods();
@@ -168,7 +169,7 @@ public:
const Map<StringName, GDScriptFunction *> &debug_get_member_functions() const; //this is debug only
StringName debug_get_member_by_index(int p_idx) const;
- Variant _new(const Variant **p_args, int p_argcount, Variant::CallError &r_error);
+ Variant _new(const Variant **p_args, int p_argcount, Callable::CallError &r_error);
virtual bool can_instance() const;
virtual Ref<Script> get_base_script() const;
@@ -213,6 +214,18 @@ public:
virtual void get_constants(Map<StringName, Variant> *p_constants);
virtual void get_members(Set<StringName> *p_members);
+ virtual Vector<ScriptNetData> get_rpc_methods() const;
+ virtual uint16_t get_rpc_method_id(const StringName &p_method) const;
+ virtual StringName get_rpc_method(const uint16_t p_rpc_method_id) const;
+ virtual MultiplayerAPI::RPCMode get_rpc_mode_by_id(const uint16_t p_rpc_method_id) const;
+ virtual MultiplayerAPI::RPCMode get_rpc_mode(const StringName &p_method) const;
+
+ virtual Vector<ScriptNetData> get_rset_properties() const;
+ virtual uint16_t get_rset_property_id(const StringName &p_variable) const;
+ virtual StringName get_rset_property(const uint16_t p_variable_id) const;
+ virtual MultiplayerAPI::RPCMode get_rset_mode_by_id(const uint16_t p_variable_id) const;
+ virtual MultiplayerAPI::RPCMode get_rset_mode(const StringName &p_variable) const;
+
#ifdef TOOLS_ENABLED
virtual bool is_placeholder_fallback_enabled() const { return placeholder_fallback_enabled; }
#endif
@@ -227,6 +240,7 @@ class GDScriptInstance : public ScriptInstance {
friend class GDScriptFunctions;
friend class GDScriptCompiler;
+ ObjectID owner_id;
Object *owner;
Ref<GDScript> script;
#ifdef DEBUG_ENABLED
@@ -247,7 +261,7 @@ public:
virtual void get_method_list(List<MethodInfo> *p_list) const;
virtual bool has_method(const StringName &p_method) const;
- virtual Variant call(const StringName &p_method, const Variant **p_args, int p_argcount, Variant::CallError &r_error);
+ virtual Variant call(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error);
virtual void call_multilevel(const StringName &p_method, const Variant **p_args, int p_argcount);
virtual void call_multilevel_reversed(const StringName &p_method, const Variant **p_args, int p_argcount);
@@ -264,7 +278,16 @@ public:
void reload_members();
+ virtual Vector<ScriptNetData> get_rpc_methods() const;
+ virtual uint16_t get_rpc_method_id(const StringName &p_method) const;
+ virtual StringName get_rpc_method(const uint16_t p_rpc_method_id) const;
+ virtual MultiplayerAPI::RPCMode get_rpc_mode_by_id(const uint16_t p_rpc_method_id) const;
virtual MultiplayerAPI::RPCMode get_rpc_mode(const StringName &p_method) const;
+
+ virtual Vector<ScriptNetData> get_rset_properties() const;
+ virtual uint16_t get_rset_property_id(const StringName &p_variable) const;
+ virtual StringName get_rset_property(const uint16_t p_variable_id) const;
+ virtual MultiplayerAPI::RPCMode get_rset_mode_by_id(const uint16_t p_variable_id) const;
virtual MultiplayerAPI::RPCMode get_rset_mode(const StringName &p_variable) const;
GDScriptInstance();
@@ -463,7 +486,7 @@ public:
virtual bool supports_builtin_mode() const;
virtual bool can_inherit_from_file() { return true; }
virtual int find_function(const String &p_function, const String &p_code) const;
- virtual String make_function(const String &p_class, const String &p_name, const PoolStringArray &p_args) const;
+ virtual String make_function(const String &p_class, const String &p_name, const PackedStringArray &p_args) const;
virtual Error complete_code(const String &p_code, const String &p_path, Object *p_owner, List<ScriptCodeCompletionOption> *r_options, bool &r_forced, String &r_call_hint);
#ifdef TOOLS_ENABLED
virtual Error lookup_code(const String &p_code, const String &p_symbol, const String &p_path, Object *p_owner, LookupResult &r_result);
diff --git a/modules/gdscript/gdscript_compiler.cpp b/modules/gdscript/gdscript_compiler.cpp
index fba1b992ec..4bd425f999 100644
--- a/modules/gdscript/gdscript_compiler.cpp
+++ b/modules/gdscript/gdscript_compiler.cpp
@@ -2076,10 +2076,10 @@ Error GDScriptCompiler::_parse_class_blocks(GDScript *p_script, const GDScriptPa
/* STEP 2, INITIALIZE AND CONSTRUCT */
- Variant::CallError ce;
+ Callable::CallError ce;
p_script->initializer->call(instance, NULL, 0, ce);
- if (ce.error != Variant::CallError::CALL_OK) {
+ if (ce.error != Callable::CallError::CALL_OK) {
//well, tough luck, not goinna do anything here
}
}
diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp
index 65c61cb57c..85265a1fe5 100644
--- a/modules/gdscript/gdscript_editor.cpp
+++ b/modules/gdscript/gdscript_editor.cpp
@@ -457,7 +457,7 @@ void GDScriptLanguage::get_public_constants(List<Pair<String, Variant> > *p_cons
p_constants->push_back(nan);
}
-String GDScriptLanguage::make_function(const String &p_class, const String &p_name, const PoolStringArray &p_args) const {
+String GDScriptLanguage::make_function(const String &p_class, const String &p_name, const PackedStringArray &p_args) const {
#ifdef TOOLS_ENABLED
bool th = EditorSettings::get_singleton()->get_setting("text_editor/completion/add_type_hints");
@@ -905,10 +905,10 @@ static bool _guess_expression_type(GDScriptCompletionContext &p_context, const G
argptr.push_back(&args[i]);
}
- Variant::CallError ce;
+ Callable::CallError ce;
Variant ret = mb->call(baseptr, (const Variant **)argptr.ptr(), argptr.size(), ce);
- if (ce.error == Variant::CallError::CALL_OK && ret.get_type() != Variant::NIL) {
+ if (ce.error == Callable::CallError::CALL_OK && ret.get_type() != Variant::NIL) {
if (ret.get_type() != Variant::OBJECT || ret.operator Object *() != NULL) {
r_type = _type_from_variant(ret);
found = true;
@@ -1060,7 +1060,7 @@ static bool _guess_expression_type(GDScriptCompletionContext &p_context, const G
StringName id = index.value;
found = _guess_identifier_type_from_base(c, base, id, r_type);
} else if (!found && index.type.kind == GDScriptParser::DataType::BUILTIN) {
- Variant::CallError err;
+ Callable::CallError err;
Variant base_val = Variant::construct(base.type.builtin_type, NULL, 0, err);
bool valid = false;
Variant res = base_val.get(index.value, &valid);
@@ -1114,7 +1114,7 @@ static bool _guess_expression_type(GDScriptCompletionContext &p_context, const G
break;
}
- Variant::CallError ce;
+ Callable::CallError ce;
bool v1_use_value = p1.value.get_type() != Variant::NIL && p1.value.get_type() != Variant::OBJECT;
Variant v1 = (v1_use_value) ? p1.value : Variant::construct(p1.type.builtin_type, NULL, 0, ce);
bool v2_use_value = p2.value.get_type() != Variant::NIL && p2.value.get_type() != Variant::OBJECT;
@@ -1124,7 +1124,7 @@ static bool _guess_expression_type(GDScriptCompletionContext &p_context, const G
v2 = 1;
v2_use_value = false;
}
- if (vop == Variant::OP_DIVIDE && v2.get_type() == Variant::REAL) {
+ if (vop == Variant::OP_DIVIDE && v2.get_type() == Variant::FLOAT) {
v2 = 1.0;
v2_use_value = false;
}
@@ -1533,10 +1533,10 @@ static bool _guess_identifier_type_from_base(GDScriptCompletionContext &p_contex
return false;
} break;
case GDScriptParser::DataType::BUILTIN: {
- Variant::CallError err;
+ Callable::CallError err;
Variant tmp = Variant::construct(base_type.builtin_type, NULL, 0, err);
- if (err.error != Variant::CallError::CALL_OK) {
+ if (err.error != Callable::CallError::CALL_OK) {
return false;
}
bool valid = false;
@@ -1703,9 +1703,9 @@ static bool _guess_method_return_type_from_base(GDScriptCompletionContext &p_con
return false;
} break;
case GDScriptParser::DataType::BUILTIN: {
- Variant::CallError err;
+ Callable::CallError err;
Variant tmp = Variant::construct(base_type.builtin_type, NULL, 0, err);
- if (err.error != Variant::CallError::CALL_OK) {
+ if (err.error != Callable::CallError::CALL_OK) {
return false;
}
@@ -2088,9 +2088,9 @@ static void _find_identifiers_in_base(const GDScriptCompletionContext &p_context
return;
} break;
case GDScriptParser::DataType::BUILTIN: {
- Variant::CallError err;
+ Callable::CallError err;
Variant tmp = Variant::construct(base_type.builtin_type, NULL, 0, err);
- if (err.error != Variant::CallError::CALL_OK) {
+ if (err.error != Callable::CallError::CALL_OK) {
return;
}
@@ -2173,8 +2173,8 @@ static void _find_identifiers(const GDScriptCompletionContext &p_context, bool p
static const char *_type_names[Variant::VARIANT_MAX] = {
"null", "bool", "int", "float", "String", "Vector2", "Rect2", "Vector3", "Transform2D", "Plane", "Quat", "AABB", "Basis", "Transform",
- "Color", "NodePath", "RID", "Object", "Dictionary", "Array", "PoolByteArray", "PoolIntArray", "PoolRealArray", "PoolStringArray",
- "PoolVector2Array", "PoolVector3Array", "PoolColorArray"
+ "Color", "NodePath", "RID", "Object", "Callable", "Signal", "Dictionary", "Array", "PackedByteArray", "PackedInt32Array", "PackedInt64Array", "PackedFloat32Array", "PackedFloat64Array", "PackedStringArray",
+ "PackedVector2Array", "PackedVector3Array", "PackedColorArray"
};
for (int i = 0; i < Variant::VARIANT_MAX; i++) {
@@ -2186,7 +2186,7 @@ static void _find_identifiers(const GDScriptCompletionContext &p_context, bool p
"and", "in", "not", "or", "false", "PI", "TAU", "INF", "NAN", "self", "true", "as", "assert",
"breakpoint", "class", "extends", "is", "func", "preload", "setget", "signal", "tool", "yield",
"const", "enum", "export", "onready", "static", "var", "break", "continue", "if", "elif",
- "else", "for", "pass", "return", "match", "while", "remote", "sync", "master", "puppet", "slave",
+ "else", "for", "pass", "return", "match", "while", "remote", "master", "puppet",
"remotesync", "mastersync", "puppetsync",
0
};
@@ -2372,9 +2372,9 @@ static void _find_call_arguments(const GDScriptCompletionContext &p_context, con
} break;
case GDScriptParser::DataType::BUILTIN: {
if (base.get_type() == Variant::NIL) {
- Variant::CallError err;
+ Callable::CallError err;
base = Variant::construct(base_type.builtin_type, NULL, 0, err);
- if (err.error != Variant::CallError::CALL_OK) {
+ if (err.error != Callable::CallError::CALL_OK) {
return;
}
}
@@ -2565,7 +2565,7 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_path
} break;
case GDScriptParser::COMPLETION_FUNCTION: {
is_function = true;
- FALLTHROUGH;
+ [[fallthrough]];
}
case GDScriptParser::COMPLETION_IDENTIFIER: {
_find_identifiers(context, is_function, options);
@@ -2608,7 +2608,7 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_path
} break;
case GDScriptParser::COMPLETION_METHOD: {
is_function = true;
- FALLTHROUGH;
+ [[fallthrough]];
}
case GDScriptParser::COMPLETION_INDEX: {
const GDScriptParser::Node *node = parser.get_completion_node();
@@ -3219,9 +3219,9 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co
v_ref.instance();
v = v_ref;
} else {
- Variant::CallError err;
+ Callable::CallError err;
v = Variant::construct(base_type.builtin_type, NULL, 0, err);
- if (err.error != Variant::CallError::CALL_OK) {
+ if (err.error != Callable::CallError::CALL_OK) {
break;
}
}
@@ -3330,7 +3330,7 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol
case GDScriptParser::COMPLETION_PARENT_FUNCTION:
case GDScriptParser::COMPLETION_FUNCTION: {
is_function = true;
- FALLTHROUGH;
+ [[fallthrough]];
}
case GDScriptParser::COMPLETION_IDENTIFIER: {
@@ -3462,7 +3462,7 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol
} break;
case GDScriptParser::COMPLETION_METHOD: {
is_function = true;
- FALLTHROUGH;
+ [[fallthrough]];
}
case GDScriptParser::COMPLETION_INDEX: {
const GDScriptParser::Node *node = parser.get_completion_node();
diff --git a/modules/gdscript/gdscript_function.cpp b/modules/gdscript/gdscript_function.cpp
index 452b1933eb..27857ea91f 100644
--- a/modules/gdscript/gdscript_function.cpp
+++ b/modules/gdscript/gdscript_function.cpp
@@ -34,7 +34,7 @@
#include "gdscript.h"
#include "gdscript_functions.h"
-Variant *GDScriptFunction::_get_variant(int p_address, GDScriptInstance *p_instance, GDScript *p_script, Variant &self, Variant *p_stack, String &r_error) const {
+Variant *GDScriptFunction::_get_variant(int p_address, GDScriptInstance *p_instance, GDScript *p_script, Variant &self, Variant &static_ref, Variant *p_stack, String &r_error) const {
int address = p_address & ADDR_MASK;
@@ -52,7 +52,7 @@ Variant *GDScriptFunction::_get_variant(int p_address, GDScriptInstance *p_insta
} break;
case ADDR_TYPE_CLASS: {
- return &p_script->_static_ref;
+ return &static_ref;
} break;
case ADDR_TYPE_MEMBER: {
#ifdef DEBUG_ENABLED
@@ -137,18 +137,19 @@ static String _get_var_type(const Variant *p_var) {
String basestr;
if (p_var->get_type() == Variant::OBJECT) {
- Object *bobj = *p_var;
+ bool was_freed;
+ Object *bobj = p_var->get_validated_object_with_check(was_freed);
if (!bobj) {
- basestr = "null instance";
- } else {
- if (ObjectDB::instance_validate(bobj)) {
- if (bobj->get_script_instance())
- basestr = bobj->get_class() + " (" + bobj->get_script_instance()->get_script()->get_path().get_file() + ")";
- else
- basestr = bobj->get_class();
+ if (was_freed) {
+ basestr = "null instance";
} else {
- basestr = "previously freed instance";
+ basestr = "previously freed";
}
+ } else {
+ if (bobj->get_script_instance())
+ basestr = bobj->get_class() + " (" + bobj->get_script_instance()->get_script()->get_path().get_file() + ")";
+ else
+ basestr = bobj->get_class();
}
} else {
@@ -159,11 +160,11 @@ static String _get_var_type(const Variant *p_var) {
}
#endif // DEBUG_ENABLED
-String GDScriptFunction::_get_call_error(const Variant::CallError &p_err, const String &p_where, const Variant **argptrs) const {
+String GDScriptFunction::_get_call_error(const Callable::CallError &p_err, const String &p_where, const Variant **argptrs) const {
String err_text;
- if (p_err.error == Variant::CallError::CALL_ERROR_INVALID_ARGUMENT) {
+ if (p_err.error == Callable::CallError::CALL_ERROR_INVALID_ARGUMENT) {
int errorarg = p_err.argument;
// Handle the Object to Object case separately as we don't have further class details.
#ifdef DEBUG_ENABLED
@@ -172,15 +173,15 @@ String GDScriptFunction::_get_call_error(const Variant::CallError &p_err, const
} else
#endif // DEBUG_ENABLED
{
- err_text = "Invalid type in " + p_where + ". Cannot convert argument " + itos(errorarg + 1) + " from " + Variant::get_type_name(argptrs[errorarg]->get_type()) + " to " + Variant::get_type_name(p_err.expected) + ".";
+ err_text = "Invalid type in " + p_where + ". Cannot convert argument " + itos(errorarg + 1) + " from " + Variant::get_type_name(argptrs[errorarg]->get_type()) + " to " + Variant::get_type_name(Variant::Type(p_err.expected)) + ".";
}
- } else if (p_err.error == Variant::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS) {
+ } else if (p_err.error == Callable::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS) {
err_text = "Invalid call to " + p_where + ". Expected " + itos(p_err.argument) + " arguments.";
- } else if (p_err.error == Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS) {
+ } else if (p_err.error == Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS) {
err_text = "Invalid call to " + p_where + ". Expected " + itos(p_err.argument) + " arguments.";
- } else if (p_err.error == Variant::CallError::CALL_ERROR_INVALID_METHOD) {
+ } else if (p_err.error == Callable::CallError::CALL_ERROR_INVALID_METHOD) {
err_text = "Invalid call. Nonexistent " + p_where + ".";
- } else if (p_err.error == Variant::CallError::CALL_ERROR_INSTANCE_IS_NULL) {
+ } else if (p_err.error == Callable::CallError::CALL_ERROR_INSTANCE_IS_NULL) {
err_text = "Attempt to call " + p_where + " on a null instance.";
} else {
err_text = "Bug, call error: #" + itos(p_err.error);
@@ -257,7 +258,7 @@ String GDScriptFunction::_get_call_error(const Variant::CallError &p_err, const
#define OPCODE_OUT break
#endif
-Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_args, int p_argcount, Variant::CallError &r_err, CallState *p_state) {
+Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_args, int p_argcount, Callable::CallError &r_err, CallState *p_state) {
OPCODES_TABLE;
@@ -266,9 +267,10 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
return Variant();
}
- r_err.error = Variant::CallError::CALL_OK;
+ r_err.error = Callable::CallError::CALL_OK;
Variant self;
+ Variant static_ref;
Variant retvalue;
Variant *stack = NULL;
Variant **call_args;
@@ -304,13 +306,13 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
if (p_argcount > _argument_count) {
- r_err.error = Variant::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS;
+ r_err.error = Callable::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS;
r_err.argument = _argument_count;
return Variant();
} else if (p_argcount < _argument_count - _default_arg_count) {
- r_err.error = Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
+ r_err.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
r_err.argument = _argument_count - _default_arg_count;
return Variant();
} else {
@@ -339,7 +341,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
memnew_placement(&stack[i], Variant);
continue;
} else {
- r_err.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ r_err.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_err.argument = i;
r_err.expected = argument_types[i].kind == GDScriptDataType::BUILTIN ? argument_types[i].builtin_type : Variant::OBJECT;
return Variant();
@@ -403,10 +405,10 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
#define CHECK_SPACE(m_space) \
GD_ERR_BREAK((ip + m_space) > _code_size)
-#define GET_VARIANT_PTR(m_v, m_code_ofs) \
- Variant *m_v; \
- m_v = _get_variant(_code_ptr[ip + m_code_ofs], p_instance, script, self, stack, err_text); \
- if (unlikely(!m_v)) \
+#define GET_VARIANT_PTR(m_v, m_code_ofs) \
+ Variant *m_v; \
+ m_v = _get_variant(_code_ptr[ip + m_code_ofs], p_instance, script, self, static_ref, stack, err_text); \
+ if (unlikely(!m_v)) \
OPCODE_BREAK;
#else
@@ -414,7 +416,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
#define CHECK_SPACE(m_space)
#define GET_VARIANT_PTR(m_v, m_code_ofs) \
Variant *m_v; \
- m_v = _get_variant(_code_ptr[ip + m_code_ofs], p_instance, script, self, stack, err_text);
+ m_v = _get_variant(_code_ptr[ip + m_code_ofs], p_instance, script, self, static_ref, stack, err_text);
#endif
@@ -497,14 +499,26 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
bool extends_ok = false;
if (a->get_type() == Variant::OBJECT && a->operator Object *() != NULL) {
- Object *obj_A = *a;
- Object *obj_B = *b;
#ifdef DEBUG_ENABLED
- if (!ObjectDB::instance_validate(obj_A)) {
- err_text = "Left operand of 'is' was already freed.";
+ bool was_freed;
+ Object *obj_A = a->get_validated_object_with_check(was_freed);
+
+ if (was_freed) {
+ err_text = "Left operand of 'is' is a previously freed instance.";
OPCODE_BREAK;
}
+
+ Object *obj_B = b->get_validated_object_with_check(was_freed);
+
+ if (was_freed) {
+ err_text = "Right operand of 'is' is a previously freed instance.";
+ OPCODE_BREAK;
+ }
+#else
+
+ Object *obj_A = *a;
+ Object *obj_B = *b;
#endif // DEBUG_ENABLED
GDScript *scr_B = Object::cast_to<GDScript>(obj_B);
@@ -778,7 +792,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
#ifdef DEBUG_ENABLED
if (Variant::can_convert_strict(src->get_type(), var_type)) {
#endif // DEBUG_ENABLED
- Variant::CallError ce;
+ Callable::CallError ce;
*dst = Variant::construct(var_type, const_cast<const Variant **>(&src), 1, ce);
} else {
#ifdef DEBUG_ENABLED
@@ -884,11 +898,11 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
GD_ERR_BREAK(to_type < 0 || to_type >= Variant::VARIANT_MAX);
- Variant::CallError err;
+ Callable::CallError err;
*dst = Variant::construct(to_type, (const Variant **)&src, 1, err);
#ifdef DEBUG_ENABLED
- if (err.error != Variant::CallError::CALL_OK) {
+ if (err.error != Callable::CallError::CALL_OK) {
err_text = "Invalid cast: could not convert value to '" + Variant::get_type_name(to_type) + "'.";
OPCODE_BREAK;
}
@@ -987,11 +1001,11 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
}
GET_VARIANT_PTR(dst, 3 + argc);
- Variant::CallError err;
+ Callable::CallError err;
*dst = Variant::construct(t, (const Variant **)argptrs, argc, err);
#ifdef DEBUG_ENABLED
- if (err.error != Variant::CallError::CALL_OK) {
+ if (err.error != Callable::CallError::CALL_OK) {
err_text = _get_call_error(err, "'" + Variant::get_type_name(t) + "' constructor", (const Variant **)argptrs);
OPCODE_BREAK;
@@ -1078,7 +1092,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
}
#endif
- Variant::CallError err;
+ Callable::CallError err;
if (call_ret) {
GET_VARIANT_PTR(ret, argc);
@@ -1092,7 +1106,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
function_call_time += OS::get_singleton()->get_ticks_usec() - call_time;
}
- if (err.error != Variant::CallError::CALL_OK) {
+ if (err.error != Callable::CallError::CALL_OK) {
String methodstr = *methodname;
String basestr = _get_var_type(base);
@@ -1100,13 +1114,13 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
if (methodstr == "call") {
if (argc >= 1) {
methodstr = String(*argptrs[0]) + " (via call)";
- if (err.error == Variant::CallError::CALL_ERROR_INVALID_ARGUMENT) {
+ if (err.error == Callable::CallError::CALL_ERROR_INVALID_ARGUMENT) {
err.argument += 1;
}
}
} else if (methodstr == "free") {
- if (err.error == Variant::CallError::CALL_ERROR_INVALID_METHOD) {
+ if (err.error == Callable::CallError::CALL_ERROR_INVALID_METHOD) {
if (base->is_ref()) {
err_text = "Attempted to free a reference.";
@@ -1147,12 +1161,12 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
GET_VARIANT_PTR(dst, argc);
- Variant::CallError err;
+ Callable::CallError err;
GDScriptFunctions::call(func, (const Variant **)argptrs, argc, *dst, err);
#ifdef DEBUG_ENABLED
- if (err.error != Variant::CallError::CALL_OK) {
+ if (err.error != Callable::CallError::CALL_OK) {
String methodstr = GDScriptFunctions::get_func_name(func);
if (dst->get_type() == Variant::STRING) {
@@ -1210,7 +1224,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
break;
}
- Variant::CallError err;
+ Callable::CallError err;
if (E) {
@@ -1221,23 +1235,23 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
MethodBind *mb = ClassDB::get_method(gds->native->get_name(), *methodname);
if (!mb) {
- err.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
+ err.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
} else {
*dst = mb->call(p_instance->owner, (const Variant **)argptrs, argc, err);
}
} else {
- err.error = Variant::CallError::CALL_OK;
+ err.error = Callable::CallError::CALL_OK;
}
} else {
if (*methodname != GDScriptLanguage::get_singleton()->strings._init) {
- err.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
+ err.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
} else {
- err.error = Variant::CallError::CALL_OK;
+ err.error = Callable::CallError::CALL_OK;
}
}
- if (err.error != Variant::CallError::CALL_OK) {
+ if (err.error != Callable::CallError::CALL_OK) {
String methodstr = *methodname;
err_text = _get_call_error(err, "function '" + methodstr + "'", (const Variant **)argptrs);
@@ -1274,7 +1288,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
gdfs->state.script = Ref<GDScript>(_script);
gdfs->state.ip = ip + ipofs;
gdfs->state.line = line;
- gdfs->state.instance_id = (p_instance && p_instance->get_owner()) ? p_instance->get_owner()->get_instance_id() : 0;
+ gdfs->state.instance_id = (p_instance && p_instance->get_owner()) ? p_instance->get_owner()->get_instance_id() : ObjectID();
//gdfs->state.result_pos=ip+ipofs-1;
gdfs->state.defarg = defarg;
gdfs->state.instance = p_instance;
@@ -1298,33 +1312,36 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
}
#endif
- Object *obj = argobj->operator Object *();
+#ifdef DEBUG_ENABLED
+ bool was_freed;
+ Object *obj = argobj->get_validated_object_with_check(was_freed);
String signal = argname->operator String();
-#ifdef DEBUG_ENABLED
+ if (was_freed) {
+ err_text = "First argument of yield() is a previously freed instance.";
+ OPCODE_BREAK;
+ }
+
if (!obj) {
err_text = "First argument of yield() is null.";
OPCODE_BREAK;
}
- if (ScriptDebugger::get_singleton()) {
- if (!ObjectDB::instance_validate(obj)) {
- err_text = "First argument of yield() is a previously freed instance.";
- OPCODE_BREAK;
- }
- }
if (signal.length() == 0) {
err_text = "Second argument of yield() is an empty string (for signal name).";
OPCODE_BREAK;
}
- Error err = obj->connect(signal, gdfs.ptr(), "_signal_callback", varray(gdfs), Object::CONNECT_ONESHOT);
+ Error err = obj->connect_compat(signal, gdfs.ptr(), "_signal_callback", varray(gdfs), Object::CONNECT_ONESHOT);
if (err != OK) {
err_text = "Error connecting to signal: " + signal + " during yield().";
OPCODE_BREAK;
}
#else
- obj->connect(signal, gdfs.ptr(), "_signal_callback", varray(gdfs), Object::CONNECT_ONESHOT);
+ Object *obj = argobj->operator Object *();
+ String signal = argname->operator String();
+
+ obj->connect_compat(signal, gdfs.ptr(), "_signal_callback", varray(gdfs), Object::CONNECT_ONESHOT);
#endif
}
@@ -1565,14 +1582,14 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
//error
// function, file, line, error, explanation
String err_file;
- if (p_instance && ObjectDB::instance_validate(p_instance->owner) && p_instance->script->is_valid() && p_instance->script->path != "")
+ if (p_instance && ObjectDB::get_instance(p_instance->owner_id) != nullptr && p_instance->script->is_valid() && p_instance->script->path != "")
err_file = p_instance->script->path;
else if (script)
err_file = script->path;
if (err_file == "")
err_file = "<built-in>";
String err_func = name;
- if (p_instance && ObjectDB::instance_validate(p_instance->owner) && p_instance->script->is_valid() && p_instance->script->name != "")
+ if (p_instance && ObjectDB::get_instance(p_instance->owner_id) != nullptr && p_instance->script->is_valid() && p_instance->script->name != "")
err_func = p_instance->script->name + "." + err_func;
int err_line = line;
if (err_text == "") {
@@ -1789,13 +1806,13 @@ GDScriptFunction::~GDScriptFunction() {
/////////////////////
-Variant GDScriptFunctionState::_signal_callback(const Variant **p_args, int p_argcount, Variant::CallError &r_error) {
+Variant GDScriptFunctionState::_signal_callback(const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
Variant arg;
- r_error.error = Variant::CallError::CALL_OK;
+ r_error.error = Callable::CallError::CALL_OK;
if (p_argcount == 0) {
- r_error.error = Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
+ r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
r_error.argument = 1;
return Variant();
} else if (p_argcount == 1) {
@@ -1813,7 +1830,7 @@ Variant GDScriptFunctionState::_signal_callback(const Variant **p_args, int p_ar
Ref<GDScriptFunctionState> self = *p_args[p_argcount - 1];
if (self.is_null()) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = p_argcount - 1;
r_error.expected = Variant::OBJECT;
return Variant();
@@ -1829,7 +1846,7 @@ bool GDScriptFunctionState::is_valid(bool p_extended_check) const {
if (p_extended_check) {
//class instance gone?
- if (state.instance_id && !ObjectDB::get_instance(state.instance_id))
+ if (state.instance_id.is_valid() && !ObjectDB::get_instance(state.instance_id))
return false;
}
@@ -1839,7 +1856,7 @@ bool GDScriptFunctionState::is_valid(bool p_extended_check) const {
Variant GDScriptFunctionState::resume(const Variant &p_arg) {
ERR_FAIL_COND_V(!function, Variant());
- if (state.instance_id && !ObjectDB::get_instance(state.instance_id)) {
+ if (state.instance_id.is_valid() && !ObjectDB::get_instance(state.instance_id)) {
#ifdef DEBUG_ENABLED
ERR_FAIL_V_MSG(Variant(), "Resumed function '" + String(function->get_name()) + "()' after yield, but class instance is gone. At script: " + state.script->get_path() + ":" + itos(state.line));
#else
@@ -1848,7 +1865,7 @@ Variant GDScriptFunctionState::resume(const Variant &p_arg) {
}
state.result = p_arg;
- Variant::CallError err;
+ Callable::CallError err;
Variant ret = function->call(NULL, NULL, 0, err, &state);
bool completed = true;
diff --git a/modules/gdscript/gdscript_function.h b/modules/gdscript/gdscript_function.h
index ad95ebc543..34019e563d 100644
--- a/modules/gdscript/gdscript_function.h
+++ b/modules/gdscript/gdscript_function.h
@@ -77,8 +77,8 @@ struct GDScriptDataType {
return false;
}
- Object *obj = p_variant.operator Object *();
- if (!obj || !ObjectDB::instance_validate(obj)) {
+ Object *obj = p_variant.get_validated_object();
+ if (!obj) {
return false;
}
@@ -100,8 +100,8 @@ struct GDScriptDataType {
return false;
}
- Object *obj = p_variant.operator Object *();
- if (!obj || !ObjectDB::instance_validate(obj)) {
+ Object *obj = p_variant.get_validated_object();
+ if (!obj) {
return false;
}
@@ -265,8 +265,8 @@ private:
List<StackDebug> stack_debug;
- _FORCE_INLINE_ Variant *_get_variant(int p_address, GDScriptInstance *p_instance, GDScript *p_script, Variant &self, Variant *p_stack, String &r_error) const;
- _FORCE_INLINE_ String _get_call_error(const Variant::CallError &p_err, const String &p_where, const Variant **argptrs) const;
+ _FORCE_INLINE_ Variant *_get_variant(int p_address, GDScriptInstance *p_instance, GDScript *p_script, Variant &self, Variant &static_ref, Variant *p_stack, String &r_error) const;
+ _FORCE_INLINE_ String _get_call_error(const Callable::CallError &p_err, const String &p_where, const Variant **argptrs) const;
friend class GDScriptLanguage;
@@ -339,7 +339,7 @@ public:
return default_arguments[p_idx];
}
- Variant call(GDScriptInstance *p_instance, const Variant **p_args, int p_argcount, Variant::CallError &r_err, CallState *p_state = NULL);
+ Variant call(GDScriptInstance *p_instance, const Variant **p_args, int p_argcount, Callable::CallError &r_err, CallState *p_state = NULL);
_FORCE_INLINE_ MultiplayerAPI::RPCMode get_rpc_mode() const { return rpc_mode; }
GDScriptFunction();
@@ -352,7 +352,7 @@ class GDScriptFunctionState : public Reference {
friend class GDScriptFunction;
GDScriptFunction *function;
GDScriptFunction::CallState state;
- Variant _signal_callback(const Variant **p_args, int p_argcount, Variant::CallError &r_error);
+ Variant _signal_callback(const Variant **p_args, int p_argcount, Callable::CallError &r_error);
Ref<GDScriptFunctionState> first_state;
protected:
diff --git a/modules/gdscript/gdscript_functions.cpp b/modules/gdscript/gdscript_functions.cpp
index c398633dc5..aaa308f40f 100644
--- a/modules/gdscript/gdscript_functions.cpp
+++ b/modules/gdscript/gdscript_functions.cpp
@@ -72,7 +72,6 @@ const char *GDScriptFunctions::get_func_name(Function p_func) {
"is_equal_approx",
"is_zero_approx",
"ease",
- "decimals",
"step_decimals",
"stepify",
"lerp",
@@ -140,32 +139,32 @@ const char *GDScriptFunctions::get_func_name(Function p_func) {
return _names[p_func];
}
-void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_count, Variant &r_ret, Variant::CallError &r_error) {
+void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_count, Variant &r_ret, Callable::CallError &r_error) {
- r_error.error = Variant::CallError::CALL_OK;
+ r_error.error = Callable::CallError::CALL_OK;
#ifdef DEBUG_ENABLED
-#define VALIDATE_ARG_COUNT(m_count) \
- if (p_arg_count < m_count) { \
- r_error.error = Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS; \
- r_error.argument = m_count; \
- r_ret = Variant(); \
- return; \
- } \
- if (p_arg_count > m_count) { \
- r_error.error = Variant::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS; \
- r_error.argument = m_count; \
- r_ret = Variant(); \
- return; \
+#define VALIDATE_ARG_COUNT(m_count) \
+ if (p_arg_count < m_count) { \
+ r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS; \
+ r_error.argument = m_count; \
+ r_ret = Variant(); \
+ return; \
+ } \
+ if (p_arg_count > m_count) { \
+ r_error.error = Callable::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS; \
+ r_error.argument = m_count; \
+ r_ret = Variant(); \
+ return; \
}
-#define VALIDATE_ARG_NUM(m_arg) \
- if (!p_args[m_arg]->is_num()) { \
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT; \
- r_error.argument = m_arg; \
- r_error.expected = Variant::REAL; \
- r_ret = Variant(); \
- return; \
+#define VALIDATE_ARG_NUM(m_arg) \
+ if (!p_args[m_arg]->is_num()) { \
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT; \
+ r_error.argument = m_arg; \
+ r_error.expected = Variant::FLOAT; \
+ r_ret = Variant(); \
+ return; \
}
#else
@@ -273,15 +272,15 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
int64_t i = *p_args[0];
r_ret = ABS(i);
- } else if (p_args[0]->get_type() == Variant::REAL) {
+ } else if (p_args[0]->get_type() == Variant::FLOAT) {
double r = *p_args[0];
r_ret = Math::abs(r);
} else {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
- r_error.expected = Variant::REAL;
+ r_error.expected = Variant::FLOAT;
r_ret = Variant();
}
} break;
@@ -291,15 +290,15 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
int64_t i = *p_args[0];
r_ret = i < 0 ? -1 : (i > 0 ? +1 : 0);
- } else if (p_args[0]->get_type() == Variant::REAL) {
+ } else if (p_args[0]->get_type() == Variant::FLOAT) {
real_t r = *p_args[0];
r_ret = r < 0.0 ? -1.0 : (r > 0.0 ? +1.0 : 0.0);
} else {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
- r_error.expected = Variant::REAL;
+ r_error.expected = Variant::FLOAT;
r_ret = Variant();
}
} break;
@@ -346,12 +345,6 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
VALIDATE_ARG_NUM(1);
r_ret = Math::ease((double)*p_args[0], (double)*p_args[1]);
} break;
- case MATH_DECIMALS: {
- VALIDATE_ARG_COUNT(1);
- VALIDATE_ARG_NUM(0);
- r_ret = Math::step_decimals((double)*p_args[0]);
- WARN_DEPRECATED_MSG("GDScript method 'decimals' is deprecated and has been renamed to 'step_decimals', please update your code accordingly.");
- } break;
case MATH_STEP_DECIMALS: {
VALIDATE_ARG_COUNT(1);
VALIDATE_ARG_NUM(0);
@@ -367,12 +360,12 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
VALIDATE_ARG_COUNT(3);
VALIDATE_ARG_NUM(2);
const double t = (double)*p_args[2];
- switch (p_args[0]->get_type() == p_args[1]->get_type() ? p_args[0]->get_type() : Variant::REAL) {
+ switch (p_args[0]->get_type() == p_args[1]->get_type() ? p_args[0]->get_type() : Variant::FLOAT) {
case Variant::VECTOR2: {
r_ret = ((Vector2)*p_args[0]).linear_interpolate((Vector2)*p_args[1], t);
} break;
case Variant::VECTOR3: {
- r_ret = ((Vector3)*p_args[0]).linear_interpolate((Vector3)*p_args[1], t);
+ r_ret = (p_args[0]->operator Vector3()).linear_interpolate(p_args[1]->operator Vector3(), t);
} break;
case Variant::COLOR: {
r_ret = ((Color)*p_args[0]).linear_interpolate((Color)*p_args[1], t);
@@ -592,7 +585,7 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
Ref<WeakRef> wref = memnew(WeakRef);
r_ret = wref;
} else {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
r_error.expected = Variant::OBJECT;
r_ret = Variant();
@@ -603,7 +596,7 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
VALIDATE_ARG_COUNT(2);
if (p_args[0]->get_type() != Variant::OBJECT) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
r_error.expected = Variant::OBJECT;
r_ret = Variant();
@@ -611,7 +604,7 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
}
if (p_args[1]->get_type() != Variant::STRING && p_args[1]->get_type() != Variant::NODE_PATH) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 1;
r_error.expected = Variant::STRING;
r_ret = Variant();
@@ -633,7 +626,7 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
if (type < 0 || type >= Variant::VARIANT_MAX) {
r_ret = RTR("Invalid type argument to convert(), use TYPE_* constants.");
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
r_error.expected = Variant::INT;
return;
@@ -667,7 +660,7 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
if (p_args[0]->get_type() != Variant::STRING) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
r_error.expected = Variant::STRING;
r_ret = Variant();
@@ -678,7 +671,7 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
if (str.length() != 1) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
r_error.expected = Variant::STRING;
r_ret = RTR("Expected a string of length 1 (a character).");
@@ -690,7 +683,7 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
} break;
case TEXT_STR: {
if (p_arg_count < 1) {
- r_error.error = Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
+ r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
r_error.argument = 1;
r_ret = Variant();
@@ -792,7 +785,7 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
case PUSH_ERROR: {
VALIDATE_ARG_COUNT(1);
if (p_args[0]->get_type() != Variant::STRING) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
r_error.expected = Variant::STRING;
r_ret = Variant();
@@ -806,7 +799,7 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
case PUSH_WARNING: {
VALIDATE_ARG_COUNT(1);
if (p_args[0]->get_type() != Variant::STRING) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
r_error.expected = Variant::STRING;
r_ret = Variant();
@@ -826,7 +819,7 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
case STR_TO_VAR: {
VALIDATE_ARG_COUNT(1);
if (p_args[0]->get_type() != Variant::STRING) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
r_error.expected = Variant::STRING;
r_ret = Variant();
@@ -844,17 +837,17 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
case VAR_TO_BYTES: {
bool full_objects = false;
if (p_arg_count < 1) {
- r_error.error = Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
+ r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
r_error.argument = 1;
r_ret = Variant();
return;
} else if (p_arg_count > 2) {
- r_error.error = Variant::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS;
+ r_error.error = Callable::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS;
r_error.argument = 2;
r_ret = Variant();
} else if (p_arg_count == 2) {
if (p_args[1]->get_type() != Variant::BOOL) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 1;
r_error.expected = Variant::BOOL;
r_ret = Variant();
@@ -863,11 +856,11 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
full_objects = *p_args[1];
}
- PoolByteArray barr;
+ PackedByteArray barr;
int len;
Error err = encode_variant(*p_args[0], NULL, len, full_objects);
if (err) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
r_error.expected = Variant::NIL;
r_ret = "Unexpected error encoding variable to bytes, likely unserializable type found (Object or RID).";
@@ -876,25 +869,25 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
barr.resize(len);
{
- PoolByteArray::Write w = barr.write();
- encode_variant(*p_args[0], w.ptr(), len, full_objects);
+ uint8_t *w = barr.ptrw();
+ encode_variant(*p_args[0], w, len, full_objects);
}
r_ret = barr;
} break;
case BYTES_TO_VAR: {
bool allow_objects = false;
if (p_arg_count < 1) {
- r_error.error = Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
+ r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
r_error.argument = 1;
r_ret = Variant();
return;
} else if (p_arg_count > 2) {
- r_error.error = Variant::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS;
+ r_error.error = Callable::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS;
r_error.argument = 2;
r_ret = Variant();
} else if (p_arg_count == 2) {
if (p_args[1]->get_type() != Variant::BOOL) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 1;
r_error.expected = Variant::BOOL;
r_ret = Variant();
@@ -903,24 +896,24 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
allow_objects = *p_args[1];
}
- if (p_args[0]->get_type() != Variant::POOL_BYTE_ARRAY) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ if (p_args[0]->get_type() != Variant::PACKED_BYTE_ARRAY) {
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 1;
- r_error.expected = Variant::POOL_BYTE_ARRAY;
+ r_error.expected = Variant::PACKED_BYTE_ARRAY;
r_ret = Variant();
return;
}
- PoolByteArray varr = *p_args[0];
+ PackedByteArray varr = *p_args[0];
Variant ret;
{
- PoolByteArray::Read r = varr.read();
- Error err = decode_variant(ret, r.ptr(), varr.size(), NULL, allow_objects);
+ const uint8_t *r = varr.ptr();
+ Error err = decode_variant(ret, r, varr.size(), NULL, allow_objects);
if (err != OK) {
r_ret = RTR("Not enough bytes for decoding bytes, or invalid format.");
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
- r_error.expected = Variant::POOL_BYTE_ARRAY;
+ r_error.expected = Variant::PACKED_BYTE_ARRAY;
return;
}
}
@@ -934,7 +927,7 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
case 0: {
- r_error.error = Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
+ r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
r_error.argument = 1;
r_ret = Variant();
@@ -950,7 +943,7 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
}
Error err = arr.resize(count);
if (err != OK) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
r_ret = Variant();
return;
}
@@ -976,7 +969,7 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
}
Error err = arr.resize(to - from);
if (err != OK) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
r_ret = Variant();
return;
}
@@ -996,7 +989,7 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
if (incr == 0) {
r_ret = RTR("Step argument is zero!");
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
return;
}
@@ -1023,7 +1016,7 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
Error err = arr.resize(count);
if (err != OK) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
r_ret = Variant();
return;
}
@@ -1045,7 +1038,7 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
} break;
default: {
- r_error.error = Variant::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS;
+ r_error.error = Callable::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS;
r_error.argument = 3;
r_ret = Variant();
@@ -1056,7 +1049,7 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
case RESOURCE_LOAD: {
VALIDATE_ARG_COUNT(1);
if (p_args[0]->get_type() != Variant::STRING) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
r_error.expected = Variant::STRING;
r_ret = Variant();
@@ -1072,7 +1065,7 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
if (p_args[0]->get_type() == Variant::NIL) {
r_ret = Variant();
} else if (p_args[0]->get_type() != Variant::OBJECT) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
r_ret = Variant();
} else {
@@ -1083,7 +1076,7 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
} else if (!obj->get_script_instance() || obj->get_script_instance()->get_language() != GDScriptLanguage::get_singleton()) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
r_error.expected = Variant::DICTIONARY;
r_ret = RTR("Not a script with an instance");
@@ -1094,7 +1087,7 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
Ref<GDScript> base = ins->get_script();
if (base.is_null()) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
r_error.expected = Variant::DICTIONARY;
r_ret = RTR("Not based on a script");
@@ -1112,7 +1105,7 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
sname.invert();
if (!p->path.is_resource_file()) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
r_error.expected = Variant::DICTIONARY;
r_ret = Variant();
@@ -1144,7 +1137,7 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
if (p_args[0]->get_type() != Variant::DICTIONARY) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
r_error.expected = Variant::DICTIONARY;
r_ret = Variant();
@@ -1156,7 +1149,7 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
if (!d.has("@path")) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
r_error.expected = Variant::OBJECT;
r_ret = RTR("Invalid instance dictionary format (missing @path)");
@@ -1167,7 +1160,7 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
Ref<Script> scr = ResourceLoader::load(d["@path"]);
if (!scr.is_valid()) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
r_error.expected = Variant::OBJECT;
r_ret = RTR("Invalid instance dictionary format (can't load script at @path)");
@@ -1178,7 +1171,7 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
if (!gdscr.is_valid()) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
r_error.expected = Variant::OBJECT;
r_ret = Variant();
@@ -1196,7 +1189,7 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
gdscr = gdscr->subclasses[sub.get_name(i)];
if (!gdscr.is_valid()) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
r_error.expected = Variant::OBJECT;
r_ret = Variant();
@@ -1222,7 +1215,7 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
VALIDATE_ARG_COUNT(1);
if (p_args[0]->get_type() != Variant::STRING) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
r_error.expected = Variant::STRING;
r_ret = Variant();
@@ -1246,7 +1239,7 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
VALIDATE_ARG_COUNT(1);
if (p_args[0]->get_type() != Variant::STRING) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
r_error.expected = Variant::STRING;
r_ret = Variant();
@@ -1278,14 +1271,14 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
case COLOR8: {
if (p_arg_count < 3) {
- r_error.error = Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
+ r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
r_error.argument = 3;
r_ret = Variant();
return;
}
if (p_arg_count > 4) {
- r_error.error = Variant::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS;
+ r_error.error = Callable::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS;
r_error.argument = 4;
r_ret = Variant();
@@ -1309,21 +1302,21 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
case COLORN: {
if (p_arg_count < 1) {
- r_error.error = Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
+ r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
r_error.argument = 1;
r_ret = Variant();
return;
}
if (p_arg_count > 2) {
- r_error.error = Variant::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS;
+ r_error.error = Callable::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS;
r_error.argument = 2;
r_ret = Variant();
return;
}
if (p_args[0]->get_type() != Variant::STRING) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
r_ret = Variant();
} else {
@@ -1366,15 +1359,15 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
case INSTANCE_FROM_ID: {
VALIDATE_ARG_COUNT(1);
- if (p_args[0]->get_type() != Variant::INT && p_args[0]->get_type() != Variant::REAL) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ if (p_args[0]->get_type() != Variant::INT && p_args[0]->get_type() != Variant::FLOAT) {
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
r_error.expected = Variant::INT;
r_ret = Variant();
break;
}
- uint32_t id = *p_args[0];
+ ObjectID id = *p_args[0];
r_ret = ObjectDB::get_instance(id);
} break;
@@ -1397,43 +1390,53 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
Array d = *p_args[0];
r_ret = d.size();
} break;
- case Variant::POOL_BYTE_ARRAY: {
+ case Variant::PACKED_BYTE_ARRAY: {
+
+ Vector<uint8_t> d = *p_args[0];
+ r_ret = d.size();
+ } break;
+ case Variant::PACKED_INT32_ARRAY: {
- PoolVector<uint8_t> d = *p_args[0];
+ Vector<int32_t> d = *p_args[0];
r_ret = d.size();
} break;
- case Variant::POOL_INT_ARRAY: {
+ case Variant::PACKED_INT64_ARRAY: {
- PoolVector<int> d = *p_args[0];
+ Vector<int64_t> d = *p_args[0];
r_ret = d.size();
} break;
- case Variant::POOL_REAL_ARRAY: {
+ case Variant::PACKED_FLOAT32_ARRAY: {
- PoolVector<real_t> d = *p_args[0];
+ Vector<float> d = *p_args[0];
r_ret = d.size();
} break;
- case Variant::POOL_STRING_ARRAY: {
+ case Variant::PACKED_FLOAT64_ARRAY: {
- PoolVector<String> d = *p_args[0];
+ Vector<double> d = *p_args[0];
r_ret = d.size();
} break;
- case Variant::POOL_VECTOR2_ARRAY: {
+ case Variant::PACKED_STRING_ARRAY: {
- PoolVector<Vector2> d = *p_args[0];
+ Vector<String> d = *p_args[0];
r_ret = d.size();
} break;
- case Variant::POOL_VECTOR3_ARRAY: {
+ case Variant::PACKED_VECTOR2_ARRAY: {
- PoolVector<Vector3> d = *p_args[0];
+ Vector<Vector2> d = *p_args[0];
r_ret = d.size();
} break;
- case Variant::POOL_COLOR_ARRAY: {
+ case Variant::PACKED_VECTOR3_ARRAY: {
- PoolVector<Color> d = *p_args[0];
+ Vector<Vector3> d = *p_args[0];
+ r_ret = d.size();
+ } break;
+ case Variant::PACKED_COLOR_ARRAY: {
+
+ Vector<Color> d = *p_args[0];
r_ret = d.size();
} break;
default: {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
r_error.expected = Variant::OBJECT;
r_ret = Variant();
@@ -1448,8 +1451,8 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
if (p_args[0]->get_type() != Variant::OBJECT) {
r_ret = false;
} else {
- Object *obj = *p_args[0];
- r_ret = ObjectDB::instance_validate(obj);
+ Object *obj = p_args[0]->get_validated_object();
+ r_ret = obj != nullptr;
}
} break;
@@ -1492,7 +1495,6 @@ bool GDScriptFunctions::is_deterministic(Function p_func) {
case MATH_ISNAN:
case MATH_ISINF:
case MATH_EASE:
- case MATH_DECIMALS:
case MATH_STEP_DECIMALS:
case MATH_STEPIFY:
case MATH_LERP:
@@ -1538,69 +1540,69 @@ MethodInfo GDScriptFunctions::get_info(Function p_func) {
switch (p_func) {
case MATH_SIN: {
- MethodInfo mi("sin", PropertyInfo(Variant::REAL, "s"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("sin", PropertyInfo(Variant::FLOAT, "s"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_COS: {
- MethodInfo mi("cos", PropertyInfo(Variant::REAL, "s"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("cos", PropertyInfo(Variant::FLOAT, "s"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_TAN: {
- MethodInfo mi("tan", PropertyInfo(Variant::REAL, "s"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("tan", PropertyInfo(Variant::FLOAT, "s"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_SINH: {
- MethodInfo mi("sinh", PropertyInfo(Variant::REAL, "s"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("sinh", PropertyInfo(Variant::FLOAT, "s"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_COSH: {
- MethodInfo mi("cosh", PropertyInfo(Variant::REAL, "s"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("cosh", PropertyInfo(Variant::FLOAT, "s"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_TANH: {
- MethodInfo mi("tanh", PropertyInfo(Variant::REAL, "s"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("tanh", PropertyInfo(Variant::FLOAT, "s"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_ASIN: {
- MethodInfo mi("asin", PropertyInfo(Variant::REAL, "s"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("asin", PropertyInfo(Variant::FLOAT, "s"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_ACOS: {
- MethodInfo mi("acos", PropertyInfo(Variant::REAL, "s"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("acos", PropertyInfo(Variant::FLOAT, "s"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_ATAN: {
- MethodInfo mi("atan", PropertyInfo(Variant::REAL, "s"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("atan", PropertyInfo(Variant::FLOAT, "s"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_ATAN2: {
- MethodInfo mi("atan2", PropertyInfo(Variant::REAL, "y"), PropertyInfo(Variant::REAL, "x"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("atan2", PropertyInfo(Variant::FLOAT, "y"), PropertyInfo(Variant::FLOAT, "x"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_SQRT: {
- MethodInfo mi("sqrt", PropertyInfo(Variant::REAL, "s"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("sqrt", PropertyInfo(Variant::FLOAT, "s"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_FMOD: {
- MethodInfo mi("fmod", PropertyInfo(Variant::REAL, "a"), PropertyInfo(Variant::REAL, "b"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("fmod", PropertyInfo(Variant::FLOAT, "a"), PropertyInfo(Variant::FLOAT, "b"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_FPOSMOD: {
- MethodInfo mi("fposmod", PropertyInfo(Variant::REAL, "a"), PropertyInfo(Variant::REAL, "b"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("fposmod", PropertyInfo(Variant::FLOAT, "a"), PropertyInfo(Variant::FLOAT, "b"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_POSMOD: {
@@ -1609,119 +1611,114 @@ MethodInfo GDScriptFunctions::get_info(Function p_func) {
return mi;
} break;
case MATH_FLOOR: {
- MethodInfo mi("floor", PropertyInfo(Variant::REAL, "s"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("floor", PropertyInfo(Variant::FLOAT, "s"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_CEIL: {
- MethodInfo mi("ceil", PropertyInfo(Variant::REAL, "s"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("ceil", PropertyInfo(Variant::FLOAT, "s"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_ROUND: {
- MethodInfo mi("round", PropertyInfo(Variant::REAL, "s"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("round", PropertyInfo(Variant::FLOAT, "s"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_ABS: {
- MethodInfo mi("abs", PropertyInfo(Variant::REAL, "s"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("abs", PropertyInfo(Variant::FLOAT, "s"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_SIGN: {
- MethodInfo mi("sign", PropertyInfo(Variant::REAL, "s"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("sign", PropertyInfo(Variant::FLOAT, "s"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_POW: {
- MethodInfo mi("pow", PropertyInfo(Variant::REAL, "base"), PropertyInfo(Variant::REAL, "exp"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("pow", PropertyInfo(Variant::FLOAT, "base"), PropertyInfo(Variant::FLOAT, "exp"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_LOG: {
- MethodInfo mi("log", PropertyInfo(Variant::REAL, "s"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("log", PropertyInfo(Variant::FLOAT, "s"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_EXP: {
- MethodInfo mi("exp", PropertyInfo(Variant::REAL, "s"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("exp", PropertyInfo(Variant::FLOAT, "s"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_ISNAN: {
- MethodInfo mi("is_nan", PropertyInfo(Variant::REAL, "s"));
+ MethodInfo mi("is_nan", PropertyInfo(Variant::FLOAT, "s"));
mi.return_val.type = Variant::BOOL;
return mi;
} break;
case MATH_ISINF: {
- MethodInfo mi("is_inf", PropertyInfo(Variant::REAL, "s"));
+ MethodInfo mi("is_inf", PropertyInfo(Variant::FLOAT, "s"));
mi.return_val.type = Variant::BOOL;
return mi;
} break;
case MATH_ISEQUALAPPROX: {
- MethodInfo mi("is_equal_approx", PropertyInfo(Variant::REAL, "a"), PropertyInfo(Variant::REAL, "b"));
+ MethodInfo mi("is_equal_approx", PropertyInfo(Variant::FLOAT, "a"), PropertyInfo(Variant::FLOAT, "b"));
mi.return_val.type = Variant::BOOL;
return mi;
} break;
case MATH_ISZEROAPPROX: {
- MethodInfo mi("is_zero_approx", PropertyInfo(Variant::REAL, "s"));
+ MethodInfo mi("is_zero_approx", PropertyInfo(Variant::FLOAT, "s"));
mi.return_val.type = Variant::BOOL;
return mi;
} break;
case MATH_EASE: {
- MethodInfo mi("ease", PropertyInfo(Variant::REAL, "s"), PropertyInfo(Variant::REAL, "curve"));
- mi.return_val.type = Variant::REAL;
- return mi;
- } break;
- case MATH_DECIMALS: {
- MethodInfo mi("decimals", PropertyInfo(Variant::REAL, "step"));
- mi.return_val.type = Variant::INT;
+ MethodInfo mi("ease", PropertyInfo(Variant::FLOAT, "s"), PropertyInfo(Variant::FLOAT, "curve"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_STEP_DECIMALS: {
- MethodInfo mi("step_decimals", PropertyInfo(Variant::REAL, "step"));
+ MethodInfo mi("step_decimals", PropertyInfo(Variant::FLOAT, "step"));
mi.return_val.type = Variant::INT;
return mi;
} break;
case MATH_STEPIFY: {
- MethodInfo mi("stepify", PropertyInfo(Variant::REAL, "s"), PropertyInfo(Variant::REAL, "step"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("stepify", PropertyInfo(Variant::FLOAT, "s"), PropertyInfo(Variant::FLOAT, "step"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_LERP: {
- MethodInfo mi("lerp", PropertyInfo(Variant::NIL, "from"), PropertyInfo(Variant::NIL, "to"), PropertyInfo(Variant::REAL, "weight"));
+ MethodInfo mi("lerp", PropertyInfo(Variant::NIL, "from"), PropertyInfo(Variant::NIL, "to"), PropertyInfo(Variant::FLOAT, "weight"));
mi.return_val.type = Variant::NIL;
mi.return_val.usage |= PROPERTY_USAGE_NIL_IS_VARIANT;
return mi;
} break;
case MATH_LERP_ANGLE: {
- MethodInfo mi("lerp_angle", PropertyInfo(Variant::REAL, "from"), PropertyInfo(Variant::REAL, "to"), PropertyInfo(Variant::REAL, "weight"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("lerp_angle", PropertyInfo(Variant::FLOAT, "from"), PropertyInfo(Variant::FLOAT, "to"), PropertyInfo(Variant::FLOAT, "weight"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_INVERSE_LERP: {
- MethodInfo mi("inverse_lerp", PropertyInfo(Variant::REAL, "from"), PropertyInfo(Variant::REAL, "to"), PropertyInfo(Variant::REAL, "weight"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("inverse_lerp", PropertyInfo(Variant::FLOAT, "from"), PropertyInfo(Variant::FLOAT, "to"), PropertyInfo(Variant::FLOAT, "weight"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_RANGE_LERP: {
- MethodInfo mi("range_lerp", PropertyInfo(Variant::REAL, "value"), PropertyInfo(Variant::REAL, "istart"), PropertyInfo(Variant::REAL, "istop"), PropertyInfo(Variant::REAL, "ostart"), PropertyInfo(Variant::REAL, "ostop"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("range_lerp", PropertyInfo(Variant::FLOAT, "value"), PropertyInfo(Variant::FLOAT, "istart"), PropertyInfo(Variant::FLOAT, "istop"), PropertyInfo(Variant::FLOAT, "ostart"), PropertyInfo(Variant::FLOAT, "ostop"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_SMOOTHSTEP: {
- MethodInfo mi("smoothstep", PropertyInfo(Variant::REAL, "from"), PropertyInfo(Variant::REAL, "to"), PropertyInfo(Variant::REAL, "weight"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("smoothstep", PropertyInfo(Variant::FLOAT, "from"), PropertyInfo(Variant::FLOAT, "to"), PropertyInfo(Variant::FLOAT, "weight"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_MOVE_TOWARD: {
- MethodInfo mi("move_toward", PropertyInfo(Variant::REAL, "from"), PropertyInfo(Variant::REAL, "to"), PropertyInfo(Variant::REAL, "delta"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("move_toward", PropertyInfo(Variant::FLOAT, "from"), PropertyInfo(Variant::FLOAT, "to"), PropertyInfo(Variant::FLOAT, "delta"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_DECTIME: {
- MethodInfo mi("dectime", PropertyInfo(Variant::REAL, "value"), PropertyInfo(Variant::REAL, "amount"), PropertyInfo(Variant::REAL, "step"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("dectime", PropertyInfo(Variant::FLOAT, "value"), PropertyInfo(Variant::FLOAT, "amount"), PropertyInfo(Variant::FLOAT, "step"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_RANDOMIZE: {
@@ -1736,12 +1733,12 @@ MethodInfo GDScriptFunctions::get_info(Function p_func) {
} break;
case MATH_RANDF: {
MethodInfo mi("randf");
- mi.return_val.type = Variant::REAL;
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_RANDOM: {
- MethodInfo mi("rand_range", PropertyInfo(Variant::REAL, "from"), PropertyInfo(Variant::REAL, "to"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("rand_range", PropertyInfo(Variant::FLOAT, "from"), PropertyInfo(Variant::FLOAT, "to"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_SEED: {
@@ -1755,32 +1752,32 @@ MethodInfo GDScriptFunctions::get_info(Function p_func) {
return mi;
} break;
case MATH_DEG2RAD: {
- MethodInfo mi("deg2rad", PropertyInfo(Variant::REAL, "deg"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("deg2rad", PropertyInfo(Variant::FLOAT, "deg"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_RAD2DEG: {
- MethodInfo mi("rad2deg", PropertyInfo(Variant::REAL, "rad"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("rad2deg", PropertyInfo(Variant::FLOAT, "rad"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_LINEAR2DB: {
- MethodInfo mi("linear2db", PropertyInfo(Variant::REAL, "nrg"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("linear2db", PropertyInfo(Variant::FLOAT, "nrg"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_DB2LINEAR: {
- MethodInfo mi("db2linear", PropertyInfo(Variant::REAL, "db"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("db2linear", PropertyInfo(Variant::FLOAT, "db"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case MATH_POLAR2CARTESIAN: {
- MethodInfo mi("polar2cartesian", PropertyInfo(Variant::REAL, "r"), PropertyInfo(Variant::REAL, "th"));
+ MethodInfo mi("polar2cartesian", PropertyInfo(Variant::FLOAT, "r"), PropertyInfo(Variant::FLOAT, "th"));
mi.return_val.type = Variant::VECTOR2;
return mi;
} break;
case MATH_CARTESIAN2POLAR: {
- MethodInfo mi("cartesian2polar", PropertyInfo(Variant::REAL, "x"), PropertyInfo(Variant::REAL, "y"));
+ MethodInfo mi("cartesian2polar", PropertyInfo(Variant::FLOAT, "x"), PropertyInfo(Variant::FLOAT, "y"));
mi.return_val.type = Variant::VECTOR2;
return mi;
} break;
@@ -1790,24 +1787,24 @@ MethodInfo GDScriptFunctions::get_info(Function p_func) {
return mi;
} break;
case MATH_WRAPF: {
- MethodInfo mi("wrapf", PropertyInfo(Variant::REAL, "value"), PropertyInfo(Variant::REAL, "min"), PropertyInfo(Variant::REAL, "max"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("wrapf", PropertyInfo(Variant::FLOAT, "value"), PropertyInfo(Variant::FLOAT, "min"), PropertyInfo(Variant::FLOAT, "max"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case LOGIC_MAX: {
- MethodInfo mi("max", PropertyInfo(Variant::REAL, "a"), PropertyInfo(Variant::REAL, "b"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("max", PropertyInfo(Variant::FLOAT, "a"), PropertyInfo(Variant::FLOAT, "b"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case LOGIC_MIN: {
- MethodInfo mi("min", PropertyInfo(Variant::REAL, "a"), PropertyInfo(Variant::REAL, "b"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("min", PropertyInfo(Variant::FLOAT, "a"), PropertyInfo(Variant::FLOAT, "b"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case LOGIC_CLAMP: {
- MethodInfo mi("clamp", PropertyInfo(Variant::REAL, "value"), PropertyInfo(Variant::REAL, "min"), PropertyInfo(Variant::REAL, "max"));
- mi.return_val.type = Variant::REAL;
+ MethodInfo mi("clamp", PropertyInfo(Variant::FLOAT, "value"), PropertyInfo(Variant::FLOAT, "min"), PropertyInfo(Variant::FLOAT, "max"));
+ mi.return_val.type = Variant::FLOAT;
return mi;
} break;
case LOGIC_NEAREST_PO2: {
@@ -1954,12 +1951,12 @@ MethodInfo GDScriptFunctions::get_info(Function p_func) {
MethodInfo mi("var2bytes", PropertyInfo(Variant::NIL, "var", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_NIL_IS_VARIANT), PropertyInfo(Variant::BOOL, "full_objects"));
mi.default_arguments.push_back(false);
- mi.return_val.type = Variant::POOL_BYTE_ARRAY;
+ mi.return_val.type = Variant::PACKED_BYTE_ARRAY;
return mi;
} break;
case BYTES_TO_VAR: {
- MethodInfo mi(Variant::NIL, "bytes2var", PropertyInfo(Variant::POOL_BYTE_ARRAY, "bytes"), PropertyInfo(Variant::BOOL, "allow_objects"));
+ MethodInfo mi(Variant::NIL, "bytes2var", PropertyInfo(Variant::PACKED_BYTE_ARRAY, "bytes"), PropertyInfo(Variant::BOOL, "allow_objects"));
mi.default_arguments.push_back(false);
mi.return_val.type = Variant::NIL;
mi.return_val.usage |= PROPERTY_USAGE_NIL_IS_VARIANT;
@@ -2025,7 +2022,7 @@ MethodInfo GDScriptFunctions::get_info(Function p_func) {
} break;
case COLORN: {
- MethodInfo mi("ColorN", PropertyInfo(Variant::STRING, "name"), PropertyInfo(Variant::REAL, "alpha"));
+ MethodInfo mi("ColorN", PropertyInfo(Variant::STRING, "name"), PropertyInfo(Variant::FLOAT, "alpha"));
mi.default_arguments.push_back(1.0f);
mi.return_val.type = Variant::COLOR;
return mi;
diff --git a/modules/gdscript/gdscript_functions.h b/modules/gdscript/gdscript_functions.h
index 1812ddf121..2c6dc02913 100644
--- a/modules/gdscript/gdscript_functions.h
+++ b/modules/gdscript/gdscript_functions.h
@@ -63,7 +63,6 @@ public:
MATH_ISEQUALAPPROX,
MATH_ISZEROAPPROX,
MATH_EASE,
- MATH_DECIMALS,
MATH_STEP_DECIMALS,
MATH_STEPIFY,
MATH_LERP,
@@ -130,7 +129,7 @@ public:
};
static const char *get_func_name(Function p_func);
- static void call(Function p_func, const Variant **p_args, int p_arg_count, Variant &r_ret, Variant::CallError &r_error);
+ static void call(Function p_func, const Variant **p_args, int p_arg_count, Variant &r_ret, Callable::CallError &r_error);
static bool is_deterministic(Function p_func);
static MethodInfo get_info(Function p_func);
};
diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp
index d125da5b79..0382944efd 100644
--- a/modules/gdscript/gdscript_parser.cpp
+++ b/modules/gdscript/gdscript_parser.cpp
@@ -793,7 +793,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
}
_add_warning(GDScriptWarning::UNASSIGNED_VARIABLE_OP_ASSIGN, -1, identifier.operator String());
}
- FALLTHROUGH;
+ [[fallthrough]];
}
case GDScriptTokenizer::TK_OP_ASSIGN: {
lv->assignments += 1;
@@ -1739,7 +1739,7 @@ GDScriptParser::Node *GDScriptParser::_reduce_expression(Node *p_node, bool p_to
vptr = (const Variant **)&ptrs[0];
}
- Variant::CallError ce;
+ Callable::CallError ce;
Variant v;
if (op->arguments[0]->type == Node::TYPE_TYPE) {
@@ -1751,7 +1751,7 @@ GDScriptParser::Node *GDScriptParser::_reduce_expression(Node *p_node, bool p_to
GDScriptFunctions::call(func, vptr, ptrs.size(), v, ce);
}
- if (ce.error != Variant::CallError::CALL_OK) {
+ if (ce.error != Callable::CallError::CALL_OK) {
String errwhere;
if (op->arguments[0]->type == Node::TYPE_TYPE) {
@@ -1765,16 +1765,16 @@ GDScriptParser::Node *GDScriptParser::_reduce_expression(Node *p_node, bool p_to
switch (ce.error) {
- case Variant::CallError::CALL_ERROR_INVALID_ARGUMENT: {
+ case Callable::CallError::CALL_ERROR_INVALID_ARGUMENT: {
_set_error("Invalid argument (#" + itos(ce.argument + 1) + ") for " + errwhere + ".");
} break;
- case Variant::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS: {
+ case Callable::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS: {
_set_error("Too many arguments for " + errwhere + ".");
} break;
- case Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS: {
+ case Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS: {
_set_error("Too few arguments for " + errwhere + ".");
} break;
@@ -2766,13 +2766,12 @@ void GDScriptParser::_parse_block(BlockNode *p_block, bool p_static) {
}
#endif // DEBUG_ENABLED
switch (token) {
- case GDScriptTokenizer::TK_EOF:
+ case GDScriptTokenizer::TK_EOF: {
p_block->end_line = tokenizer->get_token_line();
+ return; // End of file!
+ } break;
case GDScriptTokenizer::TK_ERROR: {
- return; //go back
-
- //end of file!
-
+ return;
} break;
case GDScriptTokenizer::TK_NEWLINE: {
@@ -3109,7 +3108,7 @@ void GDScriptParser::_parse_block(BlockNode *p_block, bool p_static) {
args.push_back(op->arguments[i]);
if (constant && op->arguments[i]->type == Node::TYPE_CONSTANT) {
ConstantNode *c = static_cast<ConstantNode *>(op->arguments[i]);
- if (c->value.get_type() == Variant::REAL || c->value.get_type() == Variant::INT) {
+ if (c->value.get_type() == Variant::FLOAT || c->value.get_type() == Variant::INT) {
constants.push_back(c->value);
constant = true;
}
@@ -3525,11 +3524,12 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
case GDScriptTokenizer::TK_CURSOR: {
tokenizer->advance();
} break;
- case GDScriptTokenizer::TK_EOF:
+ case GDScriptTokenizer::TK_EOF: {
p_class->end_line = tokenizer->get_token_line();
+ return; // End of file!
+ } break;
case GDScriptTokenizer::TK_ERROR: {
- return; //go back
- //end of file!
+ return; // Go back.
} break;
case GDScriptTokenizer::TK_NEWLINE: {
if (!_parse_newline()) {
@@ -3719,7 +3719,7 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
return;
}
- FALLTHROUGH;
+ [[fallthrough]];
}
case GDScriptTokenizer::TK_PR_FUNCTION: {
@@ -4099,10 +4099,6 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
_ADVANCE_AND_CONSUME_NEWLINES;
- if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
- WARN_DEPRECATED_MSG("Exporting bit flags hint requires string constants.");
- break;
- }
if (tokenizer->get_token() != GDScriptTokenizer::TK_COMMA) {
_set_error("Expected \",\" in the bit flags hint.");
return;
@@ -4224,9 +4220,9 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
break;
}
- FALLTHROUGH;
+ [[fallthrough]];
}
- case Variant::REAL: {
+ case Variant::FLOAT: {
if (tokenizer->get_token() == GDScriptTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier() == "EASE") {
current_export.hint = PROPERTY_HINT_EXP_EASING;
@@ -4588,10 +4584,10 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
#undef _ADVANCE_AND_CONSUME_NEWLINES
}
- if (tokenizer->get_token() != GDScriptTokenizer::TK_PR_VAR && tokenizer->get_token() != GDScriptTokenizer::TK_PR_ONREADY && tokenizer->get_token() != GDScriptTokenizer::TK_PR_REMOTE && tokenizer->get_token() != GDScriptTokenizer::TK_PR_MASTER && tokenizer->get_token() != GDScriptTokenizer::TK_PR_PUPPET && tokenizer->get_token() != GDScriptTokenizer::TK_PR_SYNC && tokenizer->get_token() != GDScriptTokenizer::TK_PR_REMOTESYNC && tokenizer->get_token() != GDScriptTokenizer::TK_PR_MASTERSYNC && tokenizer->get_token() != GDScriptTokenizer::TK_PR_PUPPETSYNC && tokenizer->get_token() != GDScriptTokenizer::TK_PR_SLAVE) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_PR_VAR && tokenizer->get_token() != GDScriptTokenizer::TK_PR_ONREADY && tokenizer->get_token() != GDScriptTokenizer::TK_PR_REMOTE && tokenizer->get_token() != GDScriptTokenizer::TK_PR_MASTER && tokenizer->get_token() != GDScriptTokenizer::TK_PR_PUPPET && tokenizer->get_token() != GDScriptTokenizer::TK_PR_REMOTESYNC && tokenizer->get_token() != GDScriptTokenizer::TK_PR_MASTERSYNC && tokenizer->get_token() != GDScriptTokenizer::TK_PR_PUPPETSYNC) {
current_export = PropertyInfo();
- _set_error("Expected \"var\", \"onready\", \"remote\", \"master\", \"puppet\", \"sync\", \"remotesync\", \"mastersync\", \"puppetsync\".");
+ _set_error("Expected \"var\", \"onready\", \"remote\", \"master\", \"puppet\", \"remotesync\", \"mastersync\", \"puppetsync\".");
return;
}
@@ -4648,11 +4644,6 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
rpc_mode = MultiplayerAPI::RPC_MODE_MASTER;
continue;
} break;
- case GDScriptTokenizer::TK_PR_SLAVE:
-#ifdef DEBUG_ENABLED
- _add_warning(GDScriptWarning::DEPRECATED_KEYWORD, tokenizer->get_token_line(), "slave", "puppet");
-#endif
- FALLTHROUGH;
case GDScriptTokenizer::TK_PR_PUPPET: {
//may be fallthrough from export, ignore if so
@@ -4673,8 +4664,7 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
rpc_mode = MultiplayerAPI::RPC_MODE_PUPPET;
continue;
} break;
- case GDScriptTokenizer::TK_PR_REMOTESYNC:
- case GDScriptTokenizer::TK_PR_SYNC: {
+ case GDScriptTokenizer::TK_PR_REMOTESYNC: {
//may be fallthrough from export, ignore if so
tokenizer->advance();
@@ -4819,7 +4809,7 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
}
#ifdef TOOLS_ENABLED
- Variant::CallError ce;
+ Callable::CallError ce;
member.default_value = Variant::construct(member._export.type, NULL, 0, ce);
#endif
@@ -4888,7 +4878,7 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
if (cn->value.get_type() != Variant::NIL) {
if (member._export.type != Variant::NIL && cn->value.get_type() != member._export.type) {
if (Variant::can_convert(cn->value.get_type(), member._export.type)) {
- Variant::CallError err;
+ Callable::CallError err;
const Variant *args = &cn->value;
cn->value = Variant::construct(member._export.type, &args, 1, err);
} else {
@@ -5499,7 +5489,7 @@ String GDScriptParser::DataType::to_string() const {
if (!gds_class.empty()) {
return gds_class;
}
- FALLTHROUGH;
+ [[fallthrough]];
}
case SCRIPT: {
if (is_meta_type) {
@@ -5943,9 +5933,9 @@ GDScriptParser::DataType GDScriptParser::_get_operation_type(const Variant::Oper
a_ref.instance();
a = a_ref;
} else {
- Variant::CallError err;
+ Callable::CallError err;
a = Variant::construct(a_type, NULL, 0, err);
- if (err.error != Variant::CallError::CALL_OK) {
+ if (err.error != Callable::CallError::CALL_OK) {
r_valid = false;
return DataType();
}
@@ -5956,19 +5946,19 @@ GDScriptParser::DataType GDScriptParser::_get_operation_type(const Variant::Oper
b_ref.instance();
b = b_ref;
} else {
- Variant::CallError err;
+ Callable::CallError err;
b = Variant::construct(b_type, NULL, 0, err);
- if (err.error != Variant::CallError::CALL_OK) {
+ if (err.error != Callable::CallError::CALL_OK) {
r_valid = false;
return DataType();
}
}
// Avoid division by zero
- if (a_type == Variant::INT || a_type == Variant::REAL) {
+ if (a_type == Variant::INT || a_type == Variant::FLOAT) {
Variant::evaluate(Variant::OP_ADD, a, 1, a, r_valid);
}
- if (b_type == Variant::INT || b_type == Variant::REAL) {
+ if (b_type == Variant::INT || b_type == Variant::FLOAT) {
Variant::evaluate(Variant::OP_ADD, b, 1, b, r_valid);
}
if (a_type == Variant::STRING && b_type != Variant::ARRAY) {
@@ -6228,7 +6218,7 @@ GDScriptParser::Node *GDScriptParser::_get_default_value_for_type(const DataType
result = alloc_node<DictionaryNode>();
} else {
ConstantNode *c = alloc_node<ConstantNode>();
- Variant::CallError err;
+ Callable::CallError err;
c->value = Variant::construct(p_type.builtin_type, NULL, 0, err);
result = c;
}
@@ -6541,7 +6531,7 @@ GDScriptParser::DataType GDScriptParser::_reduce_node_type(Node *p_node) {
result.has_type = false;
} break;
default: {
- Variant::CallError err;
+ Callable::CallError err;
Variant temp = Variant::construct(base_type.builtin_type, NULL, 0, err);
bool valid = false;
@@ -6606,16 +6596,18 @@ GDScriptParser::DataType GDScriptParser::_reduce_node_type(Node *p_node) {
if (!error) {
switch (base_type.builtin_type) {
// Expect int or real as index
- case Variant::POOL_BYTE_ARRAY:
- case Variant::POOL_COLOR_ARRAY:
- case Variant::POOL_INT_ARRAY:
- case Variant::POOL_REAL_ARRAY:
- case Variant::POOL_STRING_ARRAY:
- case Variant::POOL_VECTOR2_ARRAY:
- case Variant::POOL_VECTOR3_ARRAY:
+ case Variant::PACKED_BYTE_ARRAY:
+ case Variant::PACKED_COLOR_ARRAY:
+ case Variant::PACKED_INT32_ARRAY:
+ case Variant::PACKED_INT64_ARRAY:
+ case Variant::PACKED_FLOAT32_ARRAY:
+ case Variant::PACKED_FLOAT64_ARRAY:
+ case Variant::PACKED_STRING_ARRAY:
+ case Variant::PACKED_VECTOR2_ARRAY:
+ case Variant::PACKED_VECTOR3_ARRAY:
case Variant::ARRAY:
case Variant::STRING: {
- error = index_type.builtin_type != Variant::INT && index_type.builtin_type != Variant::REAL;
+ error = index_type.builtin_type != Variant::INT && index_type.builtin_type != Variant::FLOAT;
} break;
// Expect String only
case Variant::RECT2:
@@ -6631,7 +6623,7 @@ GDScriptParser::DataType GDScriptParser::_reduce_node_type(Node *p_node) {
case Variant::TRANSFORM2D:
case Variant::BASIS:
case Variant::TRANSFORM: {
- error = index_type.builtin_type != Variant::INT && index_type.builtin_type != Variant::REAL &&
+ error = index_type.builtin_type != Variant::INT && index_type.builtin_type != Variant::FLOAT &&
index_type.builtin_type != Variant::STRING;
} break;
// Expect String or int
@@ -6656,17 +6648,19 @@ GDScriptParser::DataType GDScriptParser::_reduce_node_type(Node *p_node) {
case Variant::STRING:
case Variant::ARRAY:
case Variant::DICTIONARY:
- case Variant::POOL_BYTE_ARRAY:
- case Variant::POOL_COLOR_ARRAY:
- case Variant::POOL_INT_ARRAY:
- case Variant::POOL_REAL_ARRAY:
- case Variant::POOL_STRING_ARRAY:
- case Variant::POOL_VECTOR2_ARRAY:
- case Variant::POOL_VECTOR3_ARRAY: {
+ case Variant::PACKED_BYTE_ARRAY:
+ case Variant::PACKED_COLOR_ARRAY:
+ case Variant::PACKED_INT32_ARRAY:
+ case Variant::PACKED_INT64_ARRAY:
+ case Variant::PACKED_FLOAT32_ARRAY:
+ case Variant::PACKED_FLOAT64_ARRAY:
+ case Variant::PACKED_STRING_ARRAY:
+ case Variant::PACKED_VECTOR2_ARRAY:
+ case Variant::PACKED_VECTOR3_ARRAY: {
break;
}
default: {
- Variant::CallError err;
+ Callable::CallError err;
Variant temp = Variant::construct(base_type.builtin_type, NULL, 0, err);
bool valid = false;
@@ -6701,41 +6695,43 @@ GDScriptParser::DataType GDScriptParser::_reduce_node_type(Node *p_node) {
case Variant::NIL:
case Variant::BOOL:
case Variant::INT:
- case Variant::REAL:
+ case Variant::FLOAT:
case Variant::NODE_PATH:
case Variant::_RID: {
_set_error("Can't index on a value of type \"" + base_type.to_string() + "\".", op->line);
return DataType();
} break;
// Return int
- case Variant::POOL_BYTE_ARRAY:
- case Variant::POOL_INT_ARRAY: {
+ case Variant::PACKED_BYTE_ARRAY:
+ case Variant::PACKED_INT32_ARRAY:
+ case Variant::PACKED_INT64_ARRAY: {
result.builtin_type = Variant::INT;
} break;
// Return real
- case Variant::POOL_REAL_ARRAY:
+ case Variant::PACKED_FLOAT32_ARRAY:
+ case Variant::PACKED_FLOAT64_ARRAY:
case Variant::VECTOR2:
case Variant::VECTOR3:
case Variant::QUAT: {
- result.builtin_type = Variant::REAL;
+ result.builtin_type = Variant::FLOAT;
} break;
// Return color
- case Variant::POOL_COLOR_ARRAY: {
+ case Variant::PACKED_COLOR_ARRAY: {
result.builtin_type = Variant::COLOR;
} break;
// Return string
- case Variant::POOL_STRING_ARRAY:
+ case Variant::PACKED_STRING_ARRAY:
case Variant::STRING: {
result.builtin_type = Variant::STRING;
} break;
// Return Vector2
- case Variant::POOL_VECTOR2_ARRAY:
+ case Variant::PACKED_VECTOR2_ARRAY:
case Variant::TRANSFORM2D:
case Variant::RECT2: {
result.builtin_type = Variant::VECTOR2;
} break;
// Return Vector3
- case Variant::POOL_VECTOR3_ARRAY:
+ case Variant::PACKED_VECTOR3_ARRAY:
case Variant::AABB:
case Variant::BASIS: {
result.builtin_type = Variant::VECTOR3;
@@ -7012,7 +7008,7 @@ GDScriptParser::DataType GDScriptParser::_reduce_function_call_type(const Operat
break;
} else {
#ifdef DEBUG_ENABLED
- if (arg_type.kind == DataType::BUILTIN && arg_type.builtin_type == Variant::INT && par_types[i].kind == DataType::BUILTIN && par_types[i].builtin_type == Variant::REAL) {
+ if (arg_type.kind == DataType::BUILTIN && arg_type.builtin_type == Variant::INT && par_types[i].kind == DataType::BUILTIN && par_types[i].builtin_type == Variant::FLOAT) {
_add_warning(GDScriptWarning::NARROWING_CONVERSION, p_call->line, Variant::get_type_name(tn->vtype));
}
if (par_types[i].may_yield && p_call->arguments[i + 1]->type == Node::TYPE_OPERATOR) {
@@ -7105,7 +7101,7 @@ GDScriptParser::DataType GDScriptParser::_reduce_function_call_type(const Operat
}
if (base_type.kind == DataType::BUILTIN) {
- Variant::CallError err;
+ Callable::CallError err;
Variant tmp = Variant::construct(base_type.builtin_type, NULL, 0, err);
if (check_types) {
@@ -7255,7 +7251,7 @@ GDScriptParser::DataType GDScriptParser::_reduce_function_call_type(const Operat
_mark_line_as_unsafe(p_call->line);
}
} else {
- if (arg_type.kind == DataType::BUILTIN && arg_type.builtin_type == Variant::INT && par_type.kind == DataType::BUILTIN && par_type.builtin_type == Variant::REAL) {
+ if (arg_type.kind == DataType::BUILTIN && arg_type.builtin_type == Variant::INT && par_type.kind == DataType::BUILTIN && par_type.builtin_type == Variant::FLOAT) {
_add_warning(GDScriptWarning::NARROWING_CONVERSION, p_call->line, callee_name);
}
}
@@ -8113,7 +8109,7 @@ void GDScriptParser::_check_block_types(BlockNode *p_block) {
lv->assign = convert_call;
lv->assign_op->arguments.write[1] = convert_call;
#ifdef DEBUG_ENABLED
- if (lv->datatype.builtin_type == Variant::INT && assign_type.builtin_type == Variant::REAL) {
+ if (lv->datatype.builtin_type == Variant::INT && assign_type.builtin_type == Variant::FLOAT) {
_add_warning(GDScriptWarning::NARROWING_CONVERSION, lv->line);
}
#endif // DEBUG_ENABLED
@@ -8250,7 +8246,7 @@ void GDScriptParser::_check_block_types(BlockNode *p_block) {
type_match = true; // Since we are converting, the type is matching
}
#ifdef DEBUG_ENABLED
- if (lh_type.builtin_type == Variant::INT && rh_type.builtin_type == Variant::REAL) {
+ if (lh_type.builtin_type == Variant::INT && rh_type.builtin_type == Variant::FLOAT) {
_add_warning(GDScriptWarning::NARROWING_CONVERSION, op->line);
}
#endif // DEBUG_ENABLED
@@ -8355,7 +8351,7 @@ void GDScriptParser::_check_block_types(BlockNode *p_block) {
if (cn->value.get_type() == Variant::STRING) {
break;
}
- FALLTHROUGH;
+ [[fallthrough]];
}
default: {
_mark_line_as_safe(statement->line);
diff --git a/modules/gdscript/gdscript_tokenizer.cpp b/modules/gdscript/gdscript_tokenizer.cpp
index 11ffa22906..9064998d32 100644
--- a/modules/gdscript/gdscript_tokenizer.cpp
+++ b/modules/gdscript/gdscript_tokenizer.cpp
@@ -106,11 +106,9 @@ const char *GDScriptTokenizer::token_names[TK_MAX] = {
"yield",
"signal",
"breakpoint",
- "rpc",
- "sync",
+ "remote",
"master",
"puppet",
- "slave",
"remotesync",
"mastersync",
"puppetsync",
@@ -148,12 +146,15 @@ static const _bit _type_list[] = {
//types
{ Variant::BOOL, "bool" },
{ Variant::INT, "int" },
- { Variant::REAL, "float" },
+ { Variant::FLOAT, "float" },
{ Variant::STRING, "String" },
{ Variant::VECTOR2, "Vector2" },
+ { Variant::VECTOR2I, "Vector2i" },
{ Variant::RECT2, "Rect2" },
+ { Variant::RECT2I, "Rect2i" },
{ Variant::TRANSFORM2D, "Transform2D" },
{ Variant::VECTOR3, "Vector3" },
+ { Variant::VECTOR3I, "Vector3i" },
{ Variant::AABB, "AABB" },
{ Variant::PLANE, "Plane" },
{ Variant::QUAT, "Quat" },
@@ -162,16 +163,21 @@ static const _bit _type_list[] = {
{ Variant::COLOR, "Color" },
{ Variant::_RID, "RID" },
{ Variant::OBJECT, "Object" },
+ { Variant::STRING_NAME, "StringName" },
{ Variant::NODE_PATH, "NodePath" },
{ Variant::DICTIONARY, "Dictionary" },
+ { Variant::CALLABLE, "Callable" },
+ { Variant::SIGNAL, "Signal" },
{ Variant::ARRAY, "Array" },
- { Variant::POOL_BYTE_ARRAY, "PoolByteArray" },
- { Variant::POOL_INT_ARRAY, "PoolIntArray" },
- { Variant::POOL_REAL_ARRAY, "PoolRealArray" },
- { Variant::POOL_STRING_ARRAY, "PoolStringArray" },
- { Variant::POOL_VECTOR2_ARRAY, "PoolVector2Array" },
- { Variant::POOL_VECTOR3_ARRAY, "PoolVector3Array" },
- { Variant::POOL_COLOR_ARRAY, "PoolColorArray" },
+ { Variant::PACKED_BYTE_ARRAY, "PackedByteArray" },
+ { Variant::PACKED_INT32_ARRAY, "PackedInt32Array" },
+ { Variant::PACKED_INT64_ARRAY, "PackedInt64Array" },
+ { Variant::PACKED_FLOAT32_ARRAY, "PackedFloat32Array" },
+ { Variant::PACKED_FLOAT64_ARRAY, "PackedFloat64Array" },
+ { Variant::PACKED_STRING_ARRAY, "PackedStringArray" },
+ { Variant::PACKED_VECTOR2_ARRAY, "PackedVector2Array" },
+ { Variant::PACKED_VECTOR3_ARRAY, "PackedVector3Array" },
+ { Variant::PACKED_COLOR_ARRAY, "PackedColorArray" },
{ Variant::VARIANT_MAX, NULL },
};
@@ -207,9 +213,7 @@ static const _kws _keyword_list[] = {
{ GDScriptTokenizer::TK_PR_BREAKPOINT, "breakpoint" },
{ GDScriptTokenizer::TK_PR_REMOTE, "remote" },
{ GDScriptTokenizer::TK_PR_MASTER, "master" },
- { GDScriptTokenizer::TK_PR_SLAVE, "slave" },
{ GDScriptTokenizer::TK_PR_PUPPET, "puppet" },
- { GDScriptTokenizer::TK_PR_SYNC, "sync" },
{ GDScriptTokenizer::TK_PR_REMOTESYNC, "remotesync" },
{ GDScriptTokenizer::TK_PR_MASTERSYNC, "mastersync" },
{ GDScriptTokenizer::TK_PR_PUPPETSYNC, "puppetsync" },
@@ -255,7 +259,6 @@ bool GDScriptTokenizer::is_token_literal(int p_offset, bool variable_safe) const
case TK_PR_REMOTE:
case TK_PR_MASTER:
case TK_PR_PUPPET:
- case TK_PR_SYNC:
case TK_PR_REMOTESYNC:
case TK_PR_MASTERSYNC:
case TK_PR_PUPPETSYNC:
@@ -342,7 +345,7 @@ StringName GDScriptTokenizer::get_token_literal(int p_offset) const {
default: {
}
}
- }
+ } break;
case TK_OP_AND:
case TK_OP_OR:
break; // Don't get into default, since they can be non-literal
@@ -480,7 +483,7 @@ void GDScriptTokenizerText::_advance() {
}
while (true) {
- bool is_node_path = false;
+ bool is_string_name = false;
StringMode string_mode = STRING_DOUBLE_QUOTE;
switch (GETCHAR(0)) {
@@ -538,7 +541,7 @@ void GDScriptTokenizerText::_advance() {
ignore_warnings = true;
}
#endif // DEBUG_ENABLED
- FALLTHROUGH;
+ [[fallthrough]];
}
case '\n': {
line++;
@@ -754,8 +757,8 @@ void GDScriptTokenizerText::_advance() {
return;
}
INCPOS(1);
- is_node_path = true;
- FALLTHROUGH;
+ is_string_name = true;
+ [[fallthrough]];
case '\'':
case '"': {
@@ -815,7 +818,7 @@ void GDScriptTokenizerText::_advance() {
break; //wtf
case 'u': {
- //hexnumbarh - oct is deprecated
+ // hex number
i += 1;
for (int j = 0; j < 4; j++) {
CharType c = GETCHAR(i + j);
@@ -865,8 +868,8 @@ void GDScriptTokenizerText::_advance() {
}
INCPOS(i);
- if (is_node_path) {
- _make_constant(NodePath(str));
+ if (is_string_name) {
+ _make_constant(StringName(str));
} else {
_make_constant(str);
}
diff --git a/modules/gdscript/gdscript_tokenizer.h b/modules/gdscript/gdscript_tokenizer.h
index 0efc8551cb..3694825d80 100644
--- a/modules/gdscript/gdscript_tokenizer.h
+++ b/modules/gdscript/gdscript_tokenizer.h
@@ -113,9 +113,7 @@ public:
TK_PR_SIGNAL,
TK_PR_BREAKPOINT,
TK_PR_REMOTE,
- TK_PR_SYNC,
TK_PR_MASTER,
- TK_PR_SLAVE, // Deprecated by TK_PR_PUPPET, to remove in 4.0
TK_PR_PUPPET,
TK_PR_REMOTESYNC,
TK_PR_MASTERSYNC,
diff --git a/modules/gdscript/language_server/gdscript_language_protocol.cpp b/modules/gdscript/language_server/gdscript_language_protocol.cpp
index 7133c6b4be..2243a7b81d 100644
--- a/modules/gdscript/language_server/gdscript_language_protocol.cpp
+++ b/modules/gdscript/language_server/gdscript_language_protocol.cpp
@@ -32,32 +32,107 @@
#include "core/io/json.h"
#include "core/os/copymem.h"
#include "core/project_settings.h"
+#include "editor/editor_log.h"
#include "editor/editor_node.h"
GDScriptLanguageProtocol *GDScriptLanguageProtocol::singleton = NULL;
-void GDScriptLanguageProtocol::on_data_received(int p_id) {
- lastest_client_id = p_id;
- Ref<WebSocketPeer> peer = server->get_peer(p_id);
- PoolByteArray data;
- if (OK == peer->get_packet_buffer(data)) {
- String message;
- message.parse_utf8((const char *)data.read().ptr(), data.size());
- if (message.begins_with("Content-Length:")) return;
- String output = process_message(message);
+Error GDScriptLanguageProtocol::LSPeer::handle_data() {
+ int read = 0;
+ // Read headers
+ if (!has_header) {
+ while (true) {
+ if (req_pos >= LSP_MAX_BUFFER_SIZE) {
+ req_pos = 0;
+ ERR_FAIL_COND_V_MSG(true, ERR_OUT_OF_MEMORY, "Response header too big");
+ }
+ Error err = connection->get_partial_data(&req_buf[req_pos], 1, read);
+ if (err != OK)
+ return FAILED;
+ else if (read != 1) // Busy, wait until next poll
+ return ERR_BUSY;
+ char *r = (char *)req_buf;
+ int l = req_pos;
+
+ // End of headers
+ if (l > 3 && r[l] == '\n' && r[l - 1] == '\r' && r[l - 2] == '\n' && r[l - 3] == '\r') {
+ r[l - 3] = '\0'; // Null terminate to read string
+ String header;
+ header.parse_utf8(r);
+ content_length = header.substr(16).to_int();
+ has_header = true;
+ req_pos = 0;
+ break;
+ }
+ req_pos++;
+ }
+ }
+ if (has_header) {
+ while (req_pos < content_length) {
+ if (req_pos >= LSP_MAX_BUFFER_SIZE) {
+ req_pos = 0;
+ has_header = false;
+ ERR_FAIL_COND_V_MSG(req_pos >= LSP_MAX_BUFFER_SIZE, ERR_OUT_OF_MEMORY, "Response content too big");
+ }
+ Error err = connection->get_partial_data(&req_buf[req_pos], 1, read);
+ if (err != OK)
+ return FAILED;
+ else if (read != 1)
+ return ERR_BUSY;
+ req_pos++;
+ }
+
+ // Parse data
+ String msg;
+ msg.parse_utf8((const char *)req_buf, req_pos);
+
+ // Reset to read again
+ req_pos = 0;
+ has_header = false;
+
+ // Response
+ String output = GDScriptLanguageProtocol::get_singleton()->process_message(msg);
if (!output.empty()) {
- CharString charstr = output.utf8();
- peer->put_packet((const uint8_t *)charstr.ptr(), charstr.length());
+ res_queue.push_back(output.utf8());
}
}
+ return OK;
}
-void GDScriptLanguageProtocol::on_client_connected(int p_id, const String &p_protocal) {
- clients.set(p_id, server->get_peer(p_id));
+Error GDScriptLanguageProtocol::LSPeer::send_data() {
+ int sent = 0;
+ if (!res_queue.empty()) {
+ CharString c_res = res_queue[0];
+ if (res_sent < c_res.size()) {
+ Error err = connection->put_partial_data((const uint8_t *)c_res.get_data() + res_sent, c_res.size() - res_sent - 1, sent);
+ if (err != OK) {
+ return err;
+ }
+ res_sent += sent;
+ }
+ // Response sent
+ if (res_sent >= c_res.size() - 1) {
+ res_sent = 0;
+ res_queue.remove(0);
+ }
+ }
+ return OK;
+}
+
+Error GDScriptLanguageProtocol::on_client_connected() {
+ Ref<StreamPeerTCP> tcp_peer = server->take_connection();
+ ERR_FAIL_COND_V_MSG(clients.size() >= LSP_MAX_CLIENTS, FAILED, "Max client limits reached");
+ Ref<LSPeer> peer = memnew(LSPeer);
+ peer->connection = tcp_peer;
+ clients.set(next_client_id, peer);
+ next_client_id++;
+ EditorNode::get_log()->add_message("Connection Taken", EditorLog::MSG_TYPE_EDITOR);
+ return OK;
}
-void GDScriptLanguageProtocol::on_client_disconnected(int p_id, bool p_was_clean_close) {
- clients.erase(p_id);
+void GDScriptLanguageProtocol::on_client_disconnected(const int &p_client_id) {
+ clients.erase(p_client_id);
+ EditorNode::get_log()->add_message("Disconnected", EditorLog::MSG_TYPE_EDITOR);
}
String GDScriptLanguageProtocol::process_message(const String &p_text) {
@@ -83,11 +158,9 @@ String GDScriptLanguageProtocol::format_output(const String &p_text) {
void GDScriptLanguageProtocol::_bind_methods() {
ClassDB::bind_method(D_METHOD("initialize", "params"), &GDScriptLanguageProtocol::initialize);
ClassDB::bind_method(D_METHOD("initialized", "params"), &GDScriptLanguageProtocol::initialized);
- ClassDB::bind_method(D_METHOD("on_data_received"), &GDScriptLanguageProtocol::on_data_received);
ClassDB::bind_method(D_METHOD("on_client_connected"), &GDScriptLanguageProtocol::on_client_connected);
ClassDB::bind_method(D_METHOD("on_client_disconnected"), &GDScriptLanguageProtocol::on_client_disconnected);
- ClassDB::bind_method(D_METHOD("notify_all_clients", "p_method", "p_params"), &GDScriptLanguageProtocol::notify_all_clients, DEFVAL(Variant()));
- ClassDB::bind_method(D_METHOD("notify_client", "p_method", "p_params", "p_client"), &GDScriptLanguageProtocol::notify_client, DEFVAL(Variant()), DEFVAL(-1));
+ ClassDB::bind_method(D_METHOD("notify_client", "p_method", "p_params"), &GDScriptLanguageProtocol::notify_client, DEFVAL(Variant()), DEFVAL(-1));
ClassDB::bind_method(D_METHOD("is_smart_resolve_enabled"), &GDScriptLanguageProtocol::is_smart_resolve_enabled);
ClassDB::bind_method(D_METHOD("get_text_document"), &GDScriptLanguageProtocol::get_text_document);
ClassDB::bind_method(D_METHOD("get_workspace"), &GDScriptLanguageProtocol::get_workspace);
@@ -116,11 +189,12 @@ Dictionary GDScriptLanguageProtocol::initialize(const Dictionary &p_params) {
Dictionary params;
params["path"] = workspace->root;
Dictionary request = make_notification("gdscrip_client/changeWorkspace", params);
- if (Ref<WebSocketPeer> *peer = clients.getptr(lastest_client_id)) {
+
+ Ref<LSPeer> peer = clients.get(latest_client_id);
+ if (peer != NULL) {
String msg = JSON::print(request);
msg = format_output(msg);
- CharString charstr = msg.utf8();
- (*peer)->put_packet((const uint8_t *)charstr.ptr(), charstr.length());
+ (*peer)->res_queue.push_back(msg.utf8());
}
}
@@ -153,61 +227,59 @@ void GDScriptLanguageProtocol::initialized(const Variant &p_params) {
}
void GDScriptLanguageProtocol::poll() {
- server->poll();
+ if (server->is_connection_available()) {
+ on_client_connected();
+ }
+ const int *id = NULL;
+ while ((id = clients.next(id))) {
+ Ref<LSPeer> peer = clients.get(*id);
+ StreamPeerTCP::Status status = peer->connection->get_status();
+ if (status == StreamPeerTCP::STATUS_NONE || status == StreamPeerTCP::STATUS_ERROR) {
+ on_client_disconnected(*id);
+ id = NULL;
+ } else {
+ if (peer->connection->get_available_bytes() > 0) {
+ latest_client_id = *id;
+ Error err = peer->handle_data();
+ if (err != OK && err != ERR_BUSY) {
+ on_client_disconnected(*id);
+ id = NULL;
+ }
+ }
+ Error err = peer->send_data();
+ if (err != OK && err != ERR_BUSY) {
+ on_client_disconnected(*id);
+ id = NULL;
+ }
+ }
+ }
}
Error GDScriptLanguageProtocol::start(int p_port, const IP_Address &p_bind_ip) {
- if (server == NULL) {
- server = dynamic_cast<WebSocketServer *>(ClassDB::instance("WebSocketServer"));
- ERR_FAIL_COND_V(!server, FAILED);
- server->set_buffers(8192, 1024, 8192, 1024); // 8mb should be way more than enough
- server->connect("data_received", this, "on_data_received");
- server->connect("client_connected", this, "on_client_connected");
- server->connect("client_disconnected", this, "on_client_disconnected");
- }
- server->set_bind_ip(p_bind_ip);
- return server->listen(p_port);
+ return server->listen(p_port, p_bind_ip);
}
void GDScriptLanguageProtocol::stop() {
- const int *ptr = clients.next(NULL);
- while (ptr) {
- clients.get(*ptr)->close();
- ptr = clients.next(ptr);
+ const int *id = NULL;
+ while ((id = clients.next(id))) {
+ Ref<LSPeer> peer = clients.get(*id);
+ peer->connection->disconnect_from_host();
}
- server->stop();
- clients.clear();
-}
-
-void GDScriptLanguageProtocol::notify_all_clients(const String &p_method, const Variant &p_params) {
- Dictionary message = make_notification(p_method, p_params);
- String msg = JSON::print(message);
- msg = format_output(msg);
- CharString charstr = msg.utf8();
- const int *p_id = clients.next(NULL);
- while (p_id != NULL) {
- Ref<WebSocketPeer> peer = clients.get(*p_id);
- (*peer)->put_packet((const uint8_t *)charstr.ptr(), charstr.length());
- p_id = clients.next(p_id);
- }
+ server->stop();
}
-void GDScriptLanguageProtocol::notify_client(const String &p_method, const Variant &p_params, int p_client) {
-
- if (p_client == -1) {
- p_client = lastest_client_id;
+void GDScriptLanguageProtocol::notify_client(const String &p_method, const Variant &p_params, int p_client_id) {
+ if (p_client_id == -1) {
+ p_client_id = latest_client_id;
}
-
- Ref<WebSocketPeer> *peer = clients.getptr(p_client);
+ Ref<LSPeer> peer = clients.get(p_client_id);
ERR_FAIL_COND(peer == NULL);
Dictionary message = make_notification(p_method, p_params);
String msg = JSON::print(message);
msg = format_output(msg);
- CharString charstr = msg.utf8();
-
- (*peer)->put_packet((const uint8_t *)charstr.ptr(), charstr.length());
+ peer->res_queue.push_back(msg.utf8());
}
bool GDScriptLanguageProtocol::is_smart_resolve_enabled() const {
@@ -219,7 +291,7 @@ bool GDScriptLanguageProtocol::is_goto_native_symbols_enabled() const {
}
GDScriptLanguageProtocol::GDScriptLanguageProtocol() {
- server = NULL;
+ server.instance();
singleton = this;
_initialized = false;
workspace.instance();
@@ -228,9 +300,6 @@ GDScriptLanguageProtocol::GDScriptLanguageProtocol() {
set_scope("completionItem", text_document.ptr());
set_scope("workspace", workspace.ptr());
workspace->root = ProjectSettings::get_singleton()->get_resource_path();
-}
-
-GDScriptLanguageProtocol::~GDScriptLanguageProtocol() {
- memdelete(server);
- server = NULL;
+ latest_client_id = 0;
+ next_client_id = 0;
}
diff --git a/modules/gdscript/language_server/gdscript_language_protocol.h b/modules/gdscript/language_server/gdscript_language_protocol.h
index 52c680ab19..3f0ae36af2 100644
--- a/modules/gdscript/language_server/gdscript_language_protocol.h
+++ b/modules/gdscript/language_server/gdscript_language_protocol.h
@@ -31,16 +31,36 @@
#ifndef GDSCRIPT_PROTOCAL_SERVER_H
#define GDSCRIPT_PROTOCAL_SERVER_H
+#include "core/io/stream_peer.h"
+#include "core/io/stream_peer_tcp.h"
+#include "core/io/tcp_server.h"
#include "gdscript_text_document.h"
#include "gdscript_workspace.h"
#include "lsp.hpp"
#include "modules/jsonrpc/jsonrpc.h"
-#include "modules/websocket/websocket_peer.h"
-#include "modules/websocket/websocket_server.h"
+
+#define LSP_MAX_BUFFER_SIZE 4194304
+#define LSP_MAX_CLIENTS 8
class GDScriptLanguageProtocol : public JSONRPC {
GDCLASS(GDScriptLanguageProtocol, JSONRPC)
+private:
+ struct LSPeer : Reference {
+ Ref<StreamPeerTCP> connection;
+
+ uint8_t req_buf[LSP_MAX_BUFFER_SIZE];
+ int req_pos = 0;
+ bool has_header = false;
+ bool has_content = false;
+ int content_length = 0;
+ Vector<CharString> res_queue;
+ int res_sent = 0;
+
+ Error handle_data();
+ Error send_data();
+ };
+
enum LSPErrorCode {
RequestCancelled = -32800,
ContentModified = -32801,
@@ -48,16 +68,16 @@ class GDScriptLanguageProtocol : public JSONRPC {
static GDScriptLanguageProtocol *singleton;
- HashMap<int, Ref<WebSocketPeer> > clients;
- WebSocketServer *server;
- int lastest_client_id;
+ HashMap<int, Ref<LSPeer> > clients;
+ Ref<TCP_Server> server;
+ int latest_client_id;
+ int next_client_id;
Ref<GDScriptTextDocument> text_document;
Ref<GDScriptWorkspace> workspace;
- void on_data_received(int p_id);
- void on_client_connected(int p_id, const String &p_protocal);
- void on_client_disconnected(int p_id, bool p_was_clean_close);
+ Error on_client_connected();
+ void on_client_disconnected(const int &p_client_id);
String process_message(const String &p_text);
String format_output(const String &p_text);
@@ -80,14 +100,12 @@ public:
Error start(int p_port, const IP_Address &p_bind_ip);
void stop();
- void notify_all_clients(const String &p_method, const Variant &p_params = Variant());
- void notify_client(const String &p_method, const Variant &p_params = Variant(), int p_client = -1);
+ void notify_client(const String &p_method, const Variant &p_params = Variant(), int p_client_id = -1);
bool is_smart_resolve_enabled() const;
bool is_goto_native_symbols_enabled() const;
GDScriptLanguageProtocol();
- ~GDScriptLanguageProtocol();
};
#endif
diff --git a/modules/gdscript/language_server/gdscript_text_document.cpp b/modules/gdscript/language_server/gdscript_text_document.cpp
index 0572c5f746..d5723fd20f 100644
--- a/modules/gdscript/language_server/gdscript_text_document.cpp
+++ b/modules/gdscript/language_server/gdscript_text_document.cpp
@@ -321,6 +321,8 @@ Variant GDScriptTextDocument::hover(const Dictionary &p_params) {
lsp::Hover hover;
hover.contents = symbol->render();
+ hover.range.start = params.position;
+ hover.range.end = params.position;
return hover.to_json();
} else if (GDScriptLanguageProtocol::get_singleton()->is_smart_resolve_enabled()) {
diff --git a/modules/gdscript/language_server/gdscript_workspace.cpp b/modules/gdscript/language_server/gdscript_workspace.cpp
index 1c0590cff1..ea54784f96 100644
--- a/modules/gdscript/language_server/gdscript_workspace.cpp
+++ b/modules/gdscript/language_server/gdscript_workspace.cpp
@@ -33,8 +33,11 @@
#include "../gdscript_parser.h"
#include "core/project_settings.h"
#include "core/script_language.h"
+#include "editor/editor_file_system.h"
#include "editor/editor_help.h"
+#include "editor/editor_node.h"
#include "gdscript_language_protocol.h"
+#include "scene/resources/packed_scene.h"
void GDScriptWorkspace::_bind_methods() {
ClassDB::bind_method(D_METHOD("symbol"), &GDScriptWorkspace::symbol);
@@ -373,6 +376,46 @@ void GDScriptWorkspace::publish_diagnostics(const String &p_path) {
GDScriptLanguageProtocol::get_singleton()->notify_client("textDocument/publishDiagnostics", params);
}
+void GDScriptWorkspace::_get_owners(EditorFileSystemDirectory *efsd, String p_path, List<String> &owners) {
+ if (!efsd)
+ return;
+
+ for (int i = 0; i < efsd->get_subdir_count(); i++) {
+ _get_owners(efsd->get_subdir(i), p_path, owners);
+ }
+
+ for (int i = 0; i < efsd->get_file_count(); i++) {
+
+ Vector<String> deps = efsd->get_file_deps(i);
+ bool found = false;
+ for (int j = 0; j < deps.size(); j++) {
+ if (deps[j] == p_path) {
+ found = true;
+ break;
+ }
+ }
+ if (!found)
+ continue;
+
+ owners.push_back(efsd->get_file_path(i));
+ }
+}
+
+Node *GDScriptWorkspace::_get_owner_node(String p_path) {
+ Node *owner_node = NULL;
+ List<String> owners;
+
+ _get_owners(EditorFileSystem::get_singleton()->get_filesystem(), p_path, owners);
+
+ if (owners.size() > 0) {
+ NodePath owner_path = owners[0];
+ Ref<PackedScene> owner_res = ResourceLoader::load(owner_path);
+ owner_node = owner_res->instance(PackedScene::GEN_EDIT_STATE_DISABLED);
+ }
+
+ return owner_node;
+}
+
void GDScriptWorkspace::completion(const lsp::CompletionParams &p_params, List<ScriptCodeCompletionOption> *r_options) {
String path = get_file_path(p_params.textDocument.uri);
@@ -380,8 +423,12 @@ void GDScriptWorkspace::completion(const lsp::CompletionParams &p_params, List<S
bool forced = false;
if (const ExtendGDScriptParser *parser = get_parse_result(path)) {
+ Node *owner_node = _get_owner_node(path);
String code = parser->get_text_for_completion(p_params.position);
- GDScriptLanguage::get_singleton()->complete_code(code, path, NULL, r_options, forced, call_hint);
+ GDScriptLanguage::get_singleton()->complete_code(code, path, owner_node, r_options, forced, call_hint);
+ if (owner_node) {
+ memdelete(owner_node);
+ }
}
}
diff --git a/modules/gdscript/language_server/gdscript_workspace.h b/modules/gdscript/language_server/gdscript_workspace.h
index 146a5cb7c9..8b46d345d9 100644
--- a/modules/gdscript/language_server/gdscript_workspace.h
+++ b/modules/gdscript/language_server/gdscript_workspace.h
@@ -33,12 +33,17 @@
#include "../gdscript_parser.h"
#include "core/variant.h"
+#include "editor/editor_file_system.h"
#include "gdscript_extend_parser.h"
#include "lsp.hpp"
class GDScriptWorkspace : public Reference {
GDCLASS(GDScriptWorkspace, Reference);
+private:
+ void _get_owners(EditorFileSystemDirectory *efsd, String p_path, List<String> &owners);
+ Node *_get_owner_node(String p_path);
+
protected:
static void _bind_methods();
void remove_cache_parser(const String &p_path);
diff --git a/modules/glslang/SCsub b/modules/glslang/SCsub
new file mode 100644
index 0000000000..ae102238f2
--- /dev/null
+++ b/modules/glslang/SCsub
@@ -0,0 +1,72 @@
+#!/usr/bin/env python
+
+Import('env')
+Import('env_modules')
+
+env_glslang = env_modules.Clone()
+
+# Thirdparty source files
+if env['builtin_glslang']:
+ thirdparty_dir = "#thirdparty/glslang/"
+ thirdparty_sources = [
+ "glslang/MachineIndependent/RemoveTree.cpp",
+ "glslang/MachineIndependent/ParseHelper.cpp",
+ "glslang/MachineIndependent/iomapper.cpp",
+ "glslang/MachineIndependent/propagateNoContraction.cpp",
+ "glslang/MachineIndependent/Intermediate.cpp",
+ "glslang/MachineIndependent/linkValidate.cpp",
+ "glslang/MachineIndependent/attribute.cpp",
+ "glslang/MachineIndependent/Scan.cpp",
+ "glslang/MachineIndependent/Initialize.cpp",
+ "glslang/MachineIndependent/Constant.cpp",
+ "glslang/MachineIndependent/reflection.cpp",
+ "glslang/MachineIndependent/limits.cpp",
+ "glslang/MachineIndependent/preprocessor/PpScanner.cpp",
+ "glslang/MachineIndependent/preprocessor/PpTokens.cpp",
+ "glslang/MachineIndependent/preprocessor/PpAtom.cpp",
+ "glslang/MachineIndependent/preprocessor/PpContext.cpp",
+ "glslang/MachineIndependent/preprocessor/Pp.cpp",
+ "glslang/MachineIndependent/InfoSink.cpp",
+ "glslang/MachineIndependent/intermOut.cpp",
+ "glslang/MachineIndependent/SymbolTable.cpp",
+ "glslang/MachineIndependent/glslang_tab.cpp",
+ "glslang/MachineIndependent/pch.cpp",
+ "glslang/MachineIndependent/Versions.cpp",
+ "glslang/MachineIndependent/ShaderLang.cpp",
+ "glslang/MachineIndependent/parseConst.cpp",
+ "glslang/MachineIndependent/PoolAlloc.cpp",
+ "glslang/MachineIndependent/ParseContextBase.cpp",
+ "glslang/MachineIndependent/IntermTraverse.cpp",
+ "glslang/GenericCodeGen/Link.cpp",
+ "glslang/GenericCodeGen/CodeGen.cpp",
+ "OGLCompilersDLL/InitializeDll.cpp",
+ "SPIRV/InReadableOrder.cpp",
+ "SPIRV/GlslangToSpv.cpp",
+ "SPIRV/SpvBuilder.cpp",
+ "SPIRV/SpvTools.cpp",
+ "SPIRV/disassemble.cpp",
+ "SPIRV/doc.cpp",
+ "SPIRV/SPVRemapper.cpp",
+ "SPIRV/SpvPostProcess.cpp",
+ "SPIRV/Logger.cpp"
+ ]
+
+ if (env["platform"]=="windows"):
+ thirdparty_sources.append("glslang/OSDependent/Windows/ossource.cpp")
+ else:
+ thirdparty_sources.append("glslang/OSDependent/Unix/ossource.cpp")
+
+ thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
+
+ # Treat glslang headers as system headers to avoid raising warnings. Not supported on MSVC.
+ if not env.msvc:
+ env_glslang.Append(CPPFLAGS=['-isystem', Dir(thirdparty_dir).path])
+ else:
+ env_glslang.Prepend(CPPPATH=[thirdparty_dir])
+
+ env_thirdparty = env_glslang.Clone()
+ env_thirdparty.disable_warnings()
+ env_thirdparty.add_source_files(env.modules_sources, thirdparty_sources)
+
+# Godot's own source files
+env_glslang.add_source_files(env.modules_sources, "*.cpp")
diff --git a/modules/glslang/config.py b/modules/glslang/config.py
new file mode 100644
index 0000000000..1c8cd12a2d
--- /dev/null
+++ b/modules/glslang/config.py
@@ -0,0 +1,5 @@
+def can_build(env, platform):
+ return True
+
+def configure(env):
+ pass
diff --git a/modules/glslang/register_types.cpp b/modules/glslang/register_types.cpp
new file mode 100644
index 0000000000..d2b4a18fc7
--- /dev/null
+++ b/modules/glslang/register_types.cpp
@@ -0,0 +1,246 @@
+/*************************************************************************/
+/* register_types.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#include "register_types.h"
+
+#include "servers/visual/rendering_device.h"
+
+#include <SPIRV/GlslangToSpv.h>
+#include <glslang/Include/Types.h>
+#include <glslang/Public/ShaderLang.h>
+
+static const TBuiltInResource default_builtin_resource = {
+ /*maxLights*/ 32,
+ /*maxClipPlanes*/ 6,
+ /*maxTextureUnits*/ 32,
+ /*maxTextureCoords*/ 32,
+ /*maxVertexAttribs*/ 64,
+ /*maxVertexUniformComponents*/ 4096,
+ /*maxVaryingFloats*/ 64,
+ /*maxVertexTextureImageUnits*/ 32,
+ /*maxCombinedTextureImageUnits*/ 80,
+ /*maxTextureImageUnits*/ 32,
+ /*maxFragmentUniformComponents*/ 4096,
+ /*maxDrawBuffers*/ 32,
+ /*maxVertexUniformVectors*/ 128,
+ /*maxVaryingVectors*/ 8,
+ /*maxFragmentUniformVectors*/ 16,
+ /*maxVertexOutputVectors*/ 16,
+ /*maxFragmentInputVectors*/ 15,
+ /*minProgramTexelOffset*/ -8,
+ /*maxProgramTexelOffset*/ 7,
+ /*maxClipDistances*/ 8,
+ /*maxComputeWorkGroupCountX*/ 65535,
+ /*maxComputeWorkGroupCountY*/ 65535,
+ /*maxComputeWorkGroupCountZ*/ 65535,
+ /*maxComputeWorkGroupSizeX*/ 1024,
+ /*maxComputeWorkGroupSizeY*/ 1024,
+ /*maxComputeWorkGroupSizeZ*/ 64,
+ /*maxComputeUniformComponents*/ 1024,
+ /*maxComputeTextureImageUnits*/ 16,
+ /*maxComputeImageUniforms*/ 8,
+ /*maxComputeAtomicCounters*/ 8,
+ /*maxComputeAtomicCounterBuffers*/ 1,
+ /*maxVaryingComponents*/ 60,
+ /*maxVertexOutputComponents*/ 64,
+ /*maxGeometryInputComponents*/ 64,
+ /*maxGeometryOutputComponents*/ 128,
+ /*maxFragmentInputComponents*/ 128,
+ /*maxImageUnits*/ 8,
+ /*maxCombinedImageUnitsAndFragmentOutputs*/ 8,
+ /*maxCombinedShaderOutputResources*/ 8,
+ /*maxImageSamples*/ 0,
+ /*maxVertexImageUniforms*/ 0,
+ /*maxTessControlImageUniforms*/ 0,
+ /*maxTessEvaluationImageUniforms*/ 0,
+ /*maxGeometryImageUniforms*/ 0,
+ /*maxFragmentImageUniforms*/ 8,
+ /*maxCombinedImageUniforms*/ 8,
+ /*maxGeometryTextureImageUnits*/ 16,
+ /*maxGeometryOutputVertices*/ 256,
+ /*maxGeometryTotalOutputComponents*/ 1024,
+ /*maxGeometryUniformComponents*/ 1024,
+ /*maxGeometryVaryingComponents*/ 64,
+ /*maxTessControlInputComponents*/ 128,
+ /*maxTessControlOutputComponents*/ 128,
+ /*maxTessControlTextureImageUnits*/ 16,
+ /*maxTessControlUniformComponents*/ 1024,
+ /*maxTessControlTotalOutputComponents*/ 4096,
+ /*maxTessEvaluationInputComponents*/ 128,
+ /*maxTessEvaluationOutputComponents*/ 128,
+ /*maxTessEvaluationTextureImageUnits*/ 16,
+ /*maxTessEvaluationUniformComponents*/ 1024,
+ /*maxTessPatchComponents*/ 120,
+ /*maxPatchVertices*/ 32,
+ /*maxTessGenLevel*/ 64,
+ /*maxViewports*/ 16,
+ /*maxVertexAtomicCounters*/ 0,
+ /*maxTessControlAtomicCounters*/ 0,
+ /*maxTessEvaluationAtomicCounters*/ 0,
+ /*maxGeometryAtomicCounters*/ 0,
+ /*maxFragmentAtomicCounters*/ 8,
+ /*maxCombinedAtomicCounters*/ 8,
+ /*maxAtomicCounterBindings*/ 1,
+ /*maxVertexAtomicCounterBuffers*/ 0,
+ /*maxTessControlAtomicCounterBuffers*/ 0,
+ /*maxTessEvaluationAtomicCounterBuffers*/ 0,
+ /*maxGeometryAtomicCounterBuffers*/ 0,
+ /*maxFragmentAtomicCounterBuffers*/ 1,
+ /*maxCombinedAtomicCounterBuffers*/ 1,
+ /*maxAtomicCounterBufferSize*/ 16384,
+ /*maxTransformFeedbackBuffers*/ 4,
+ /*maxTransformFeedbackInterleavedComponents*/ 64,
+ /*maxCullDistances*/ 8,
+ /*maxCombinedClipAndCullDistances*/ 8,
+ /*maxSamples*/ 4,
+ /*maxMeshOutputVerticesNV*/ 0,
+ /*maxMeshOutputPrimitivesNV*/ 0,
+ /*maxMeshWorkGroupSizeX_NV*/ 0,
+ /*maxMeshWorkGroupSizeY_NV*/ 0,
+ /*maxMeshWorkGroupSizeZ_NV*/ 0,
+ /*maxTaskWorkGroupSizeX_NV*/ 0,
+ /*maxTaskWorkGroupSizeY_NV*/ 0,
+ /*maxTaskWorkGroupSizeZ_NV*/ 0,
+ /*maxMeshViewCountNV*/ 0,
+ /*limits*/ {
+ /*nonInductiveForLoops*/ 1,
+ /*whileLoops*/ 1,
+ /*doWhileLoops*/ 1,
+ /*generalUniformIndexing*/ 1,
+ /*generalAttributeMatrixVectorIndexing*/ 1,
+ /*generalVaryingIndexing*/ 1,
+ /*generalSamplerIndexing*/ 1,
+ /*generalVariableIndexing*/ 1,
+ /*generalConstantMatrixVectorIndexing*/ 1,
+ }
+};
+
+static Vector<uint8_t> _compile_shader_glsl(RenderingDevice::ShaderStage p_stage, const String &p_source_code, RenderingDevice::ShaderLanguage p_language, String *r_error) {
+
+ Vector<uint8_t> ret;
+
+ ERR_FAIL_COND_V(p_language == RenderingDevice::SHADER_LANGUAGE_HLSL, ret);
+
+ EShLanguage stages[RenderingDevice::SHADER_STAGE_MAX] = {
+ EShLangVertex,
+ EShLangFragment,
+ EShLangTessControl,
+ EShLangTessEvaluation,
+ EShLangCompute
+ };
+
+ int ClientInputSemanticsVersion = 100; // maps to, say, #define VULKAN 100
+
+ glslang::EShTargetClientVersion VulkanClientVersion = glslang::EShTargetVulkan_1_0;
+ glslang::EShTargetLanguageVersion TargetVersion = glslang::EShTargetSpv_1_0;
+ glslang::TShader::ForbidIncluder includer;
+
+ glslang::TShader shader(stages[p_stage]);
+ CharString cs = p_source_code.ascii();
+ const char *cs_strings = cs.get_data();
+
+ shader.setStrings(&cs_strings, 1);
+ shader.setEnvInput(glslang::EShSourceGlsl, stages[p_stage], glslang::EShClientVulkan, ClientInputSemanticsVersion);
+ shader.setEnvClient(glslang::EShClientVulkan, VulkanClientVersion);
+ shader.setEnvTarget(glslang::EShTargetSpv, TargetVersion);
+
+ EShMessages messages = (EShMessages)(EShMsgSpvRules | EShMsgVulkanRules);
+ const int DefaultVersion = 100;
+ std::string pre_processed_code;
+
+ //preprocess
+ if (!shader.preprocess(&default_builtin_resource, DefaultVersion, ENoProfile, false, false, messages, &pre_processed_code, includer)) {
+
+ if (r_error) {
+ (*r_error) = "Failed pre-process:\n";
+ (*r_error) += shader.getInfoLog();
+ (*r_error) += "\n";
+ (*r_error) += shader.getInfoDebugLog();
+ }
+
+ return ret;
+ }
+ //set back..
+ cs_strings = pre_processed_code.c_str();
+ shader.setStrings(&cs_strings, 1);
+
+ //parse
+ if (!shader.parse(&default_builtin_resource, DefaultVersion, false, messages)) {
+ if (r_error) {
+ (*r_error) = "Failed parse:\n";
+ (*r_error) += shader.getInfoLog();
+ (*r_error) += "\n";
+ (*r_error) += shader.getInfoDebugLog();
+ }
+ return ret;
+ }
+
+ //link
+ glslang::TProgram program;
+ program.addShader(&shader);
+
+ if (!program.link(messages)) {
+ if (r_error) {
+ (*r_error) = "Failed link:\n";
+ (*r_error) += program.getInfoLog();
+ (*r_error) += "\n";
+ (*r_error) += program.getInfoDebugLog();
+ }
+
+ return ret;
+ }
+
+ std::vector<uint32_t> SpirV;
+ spv::SpvBuildLogger logger;
+ glslang::SpvOptions spvOptions;
+ glslang::GlslangToSpv(*program.getIntermediate(stages[p_stage]), SpirV, &logger, &spvOptions);
+
+ ret.resize(SpirV.size() * sizeof(uint32_t));
+ {
+ uint8_t *w = ret.ptrw();
+ copymem(w, &SpirV[0], SpirV.size() * sizeof(uint32_t));
+ }
+
+ return ret;
+}
+
+void preregister_glslang_types() {
+ // initialize in case it's not initialized. This is done once per thread
+ // and it's safe to call multiple times
+ glslang::InitializeProcess();
+ RenderingDevice::shader_set_compile_function(_compile_shader_glsl);
+}
+
+void register_glslang_types() {
+}
+void unregister_glslang_types() {
+
+ glslang::FinalizeProcess();
+}
diff --git a/modules/glslang/register_types.h b/modules/glslang/register_types.h
new file mode 100644
index 0000000000..37a1ef67f2
--- /dev/null
+++ b/modules/glslang/register_types.h
@@ -0,0 +1,34 @@
+/*************************************************************************/
+/* register_types.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#define MODULE_GLSLANG_HAS_PREREGISTER
+void preregister_glslang_types();
+void register_glslang_types();
+void unregister_glslang_types();
diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cpp
index 3d40220869..84075f76fd 100644
--- a/modules/gridmap/grid_map.cpp
+++ b/modules/gridmap/grid_map.cpp
@@ -36,6 +36,7 @@
#include "scene/resources/mesh_library.h"
#include "scene/resources/surface_tool.h"
#include "scene/scene_string_names.h"
+#include "servers/navigation_server.h"
#include "servers/visual_server.h"
bool GridMap::_set(const StringName &p_name, const Variant &p_value) {
@@ -48,9 +49,9 @@ bool GridMap::_set(const StringName &p_name, const Variant &p_value) {
if (d.has("cells")) {
- PoolVector<int> cells = d["cells"];
+ Vector<int> cells = d["cells"];
int amount = cells.size();
- PoolVector<int>::Read r = cells.read();
+ const int *r = cells.ptr();
ERR_FAIL_COND_V(amount % 3, false); // not even
cell_map.clear();
for (int i = 0; i < amount / 3; i++) {
@@ -102,10 +103,10 @@ bool GridMap::_get(const StringName &p_name, Variant &r_ret) const {
Dictionary d;
- PoolVector<int> cells;
+ Vector<int> cells;
cells.resize(cell_map.size() * 3);
{
- PoolVector<int>::Write w = cells.write();
+ int *w = cells.ptrw();
int i = 0;
for (Map<IndexKey, Cell>::Element *E = cell_map.front(); E; E = E->next(), i++) {
@@ -418,12 +419,10 @@ bool GridMap::_octant_update(const OctantKey &p_key) {
}
//erase navigation
- if (navigation) {
- for (Map<IndexKey, Octant::NavMesh>::Element *E = g.navmesh_ids.front(); E; E = E->next()) {
- navigation->navmesh_remove(E->get().id);
- }
- g.navmesh_ids.clear();
+ for (Map<IndexKey, Octant::NavMesh>::Element *E = g.navmesh_ids.front(); E; E = E->next()) {
+ NavigationServer::get_singleton()->free(E->get().region);
}
+ g.navmesh_ids.clear();
//erase multimeshes
@@ -440,7 +439,7 @@ bool GridMap::_octant_update(const OctantKey &p_key) {
return true;
}
- PoolVector<Vector3> col_debug;
+ Vector<Vector3> col_debug;
/*
* foreach item in this octant,
@@ -498,9 +497,11 @@ bool GridMap::_octant_update(const OctantKey &p_key) {
nm.xform = xform * mesh_library->get_item_navmesh_transform(c.item);
if (navigation) {
- nm.id = navigation->navmesh_add(navmesh, xform, this);
- } else {
- nm.id = -1;
+ RID region = NavigationServer::get_singleton()->region_create();
+ NavigationServer::get_singleton()->region_set_navmesh(region, navmesh);
+ NavigationServer::get_singleton()->region_set_transform(region, navigation->get_global_transform() * nm.xform);
+ NavigationServer::get_singleton()->region_set_map(region, navigation->get_rid());
+ nm.region = region;
}
g.navmesh_ids[E->get()] = nm;
}
@@ -513,7 +514,7 @@ bool GridMap::_octant_update(const OctantKey &p_key) {
Octant::MultimeshInstance mmi;
RID mm = VS::get_singleton()->multimesh_create();
- VS::get_singleton()->multimesh_allocate(mm, E->get().size(), VS::MULTIMESH_TRANSFORM_3D, VS::MULTIMESH_COLOR_NONE);
+ VS::get_singleton()->multimesh_allocate(mm, E->get().size(), VS::MULTIMESH_TRANSFORM_3D);
VS::get_singleton()->multimesh_set_mesh(mm, mesh_library->get_item_mesh(E->key())->get_rid());
int idx = 0;
@@ -591,10 +592,14 @@ void GridMap::_octant_enter_world(const OctantKey &p_key) {
if (navigation && mesh_library.is_valid()) {
for (Map<IndexKey, Octant::NavMesh>::Element *F = g.navmesh_ids.front(); F; F = F->next()) {
- if (cell_map.has(F->key()) && F->get().id < 0) {
+ if (cell_map.has(F->key()) && F->get().region.is_valid() == false) {
Ref<NavigationMesh> nm = mesh_library->get_item_navmesh(cell_map[F->key()].item);
if (nm.is_valid()) {
- F->get().id = navigation->navmesh_add(nm, F->get().xform, this);
+ RID region = NavigationServer::get_singleton()->region_create();
+ NavigationServer::get_singleton()->region_set_navmesh(region, nm);
+ NavigationServer::get_singleton()->region_set_transform(region, navigation->get_global_transform() * F->get().xform);
+ NavigationServer::get_singleton()->region_set_map(region, navigation->get_rid());
+ F->get().region = region;
}
}
}
@@ -620,9 +625,9 @@ void GridMap::_octant_exit_world(const OctantKey &p_key) {
if (navigation) {
for (Map<IndexKey, Octant::NavMesh>::Element *F = g.navmesh_ids.front(); F; F = F->next()) {
- if (F->get().id >= 0) {
- navigation->navmesh_remove(F->get().id);
- F->get().id = -1;
+ if (F->get().region.is_valid()) {
+ NavigationServer::get_singleton()->free(F->get().region);
+ F->get().region = RID();
}
}
}
@@ -640,13 +645,11 @@ void GridMap::_octant_clean_up(const OctantKey &p_key) {
PhysicsServer::get_singleton()->free(g.static_body);
- //erase navigation
- if (navigation) {
- for (Map<IndexKey, Octant::NavMesh>::Element *E = g.navmesh_ids.front(); E; E = E->next()) {
- navigation->navmesh_remove(E->get().id);
- }
- g.navmesh_ids.clear();
+ // Erase navigation
+ for (Map<IndexKey, Octant::NavMesh>::Element *E = g.navmesh_ids.front(); E; E = E->next()) {
+ NavigationServer::get_singleton()->free(E->get().region);
}
+ g.navmesh_ids.clear();
//erase multimeshes
@@ -871,7 +874,7 @@ void GridMap::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "cell_center_x"), "set_center_x", "get_center_x");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "cell_center_y"), "set_center_y", "get_center_y");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "cell_center_z"), "set_center_z", "get_center_z");
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "cell_scale"), "set_cell_scale", "get_cell_scale");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "cell_scale"), "set_cell_scale", "get_cell_scale");
ADD_GROUP("Collision", "collision_");
ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_layer", PROPERTY_HINT_LAYERS_3D_PHYSICS), "set_collision_layer", "get_collision_layer");
ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_mask", PROPERTY_HINT_LAYERS_3D_PHYSICS), "set_collision_mask", "get_collision_mask");
diff --git a/modules/gridmap/grid_map.h b/modules/gridmap/grid_map.h
index 705f4929e1..cc1c8c2923 100644
--- a/modules/gridmap/grid_map.h
+++ b/modules/gridmap/grid_map.h
@@ -91,7 +91,7 @@ class GridMap : public Spatial {
struct Octant {
struct NavMesh {
- int id;
+ RID region;
Transform xform;
};
diff --git a/modules/gridmap/grid_map_editor_plugin.cpp b/modules/gridmap/grid_map_editor_plugin.cpp
index 4aa407f966..761771a02c 100644
--- a/modules/gridmap/grid_map_editor_plugin.cpp
+++ b/modules/gridmap/grid_map_editor_plugin.cpp
@@ -840,15 +840,33 @@ void GridMapEditor::_text_changed(const String &p_text) {
void GridMapEditor::_sbox_input(const Ref<InputEvent> &p_ie) {
- Ref<InputEventKey> k = p_ie;
+ const Ref<InputEventKey> k = p_ie;
if (k.is_valid() && (k->get_scancode() == KEY_UP || k->get_scancode() == KEY_DOWN || k->get_scancode() == KEY_PAGEUP || k->get_scancode() == KEY_PAGEDOWN)) {
+ // Forward the key input to the ItemList so it can be scrolled
mesh_library_palette->call("_gui_input", k);
search_box->accept_event();
}
}
+void GridMapEditor::_mesh_library_palette_input(const Ref<InputEvent> &p_ie) {
+
+ const Ref<InputEventMouseButton> mb = p_ie;
+
+ // Zoom in/out using Ctrl + mouse wheel
+ if (mb.is_valid() && mb->is_pressed() && mb->get_command()) {
+
+ if (mb->is_pressed() && mb->get_button_index() == BUTTON_WHEEL_UP) {
+ size_slider->set_value(size_slider->get_value() + 0.2);
+ }
+
+ if (mb->is_pressed() && mb->get_button_index() == BUTTON_WHEEL_DOWN) {
+ size_slider->set_value(size_slider->get_value() - 0.2);
+ }
+ }
+}
+
void GridMapEditor::_icon_size_changed(float p_value) {
mesh_library_palette->set_icon_scale(p_value);
update_palette();
@@ -907,7 +925,7 @@ void GridMapEditor::update_palette() {
for (List<_CGMEItemSort>::Element *E = il.front(); E; E = E->next()) {
int id = E->get().id;
String name = mesh_library->get_item_name(id);
- Ref<Texture> preview = mesh_library->get_item_preview(id);
+ Ref<Texture2D> preview = mesh_library->get_item_preview(id);
if (name == "") {
name = "#" + itos(id);
@@ -936,7 +954,7 @@ void GridMapEditor::update_palette() {
void GridMapEditor::edit(GridMap *p_gridmap) {
if (!p_gridmap && node)
- node->disconnect("cell_size_changed", this, "_draw_grids");
+ node->disconnect_compat("cell_size_changed", this, "_draw_grids");
node = p_gridmap;
@@ -970,7 +988,7 @@ void GridMapEditor::edit(GridMap *p_gridmap) {
update_grid();
_update_clip();
- node->connect("cell_size_changed", this, "_draw_grids");
+ node->connect_compat("cell_size_changed", this, "_draw_grids");
}
void GridMapEditor::_update_clip() {
@@ -1004,8 +1022,7 @@ void GridMapEditor::_draw_grids(const Vector3 &cell_size) {
Vector3 edited_floor = node->has_meta("_editor_floor_") ? node->get_meta("_editor_floor_") : Variant();
for (int i = 0; i < 3; i++) {
- if (VS::get_singleton()->mesh_get_surface_count(grid[i]) > 0)
- VS::get_singleton()->mesh_remove_surface(grid[i], 0);
+ VS::get_singleton()->mesh_clear(grid[i]);
edit_floor[i] = edited_floor[i];
}
@@ -1060,8 +1077,8 @@ void GridMapEditor::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
- get_tree()->connect("node_removed", this, "_node_removed");
- mesh_library_palette->connect("item_selected", this, "_item_selected_cbk");
+ get_tree()->connect_compat("node_removed", this, "_node_removed");
+ mesh_library_palette->connect_compat("item_selected", this, "_item_selected_cbk");
for (int i = 0; i < 3; i++) {
grid[i] = VS::get_singleton()->mesh_create();
@@ -1077,7 +1094,7 @@ void GridMapEditor::_notification(int p_what) {
} break;
case NOTIFICATION_EXIT_TREE: {
- get_tree()->disconnect("node_removed", this, "_node_removed");
+ get_tree()->disconnect_compat("node_removed", this, "_node_removed");
_clear_clipboard_data();
for (int i = 0; i < 3; i++) {
@@ -1183,6 +1200,7 @@ void GridMapEditor::_bind_methods() {
ClassDB::bind_method("_text_changed", &GridMapEditor::_text_changed);
ClassDB::bind_method("_sbox_input", &GridMapEditor::_sbox_input);
+ ClassDB::bind_method("_mesh_library_palette_input", &GridMapEditor::_mesh_library_palette_input);
ClassDB::bind_method("_icon_size_changed", &GridMapEditor::_icon_size_changed);
ClassDB::bind_method("_menu_option", &GridMapEditor::_menu_option);
ClassDB::bind_method("_configure", &GridMapEditor::_configure);
@@ -1223,9 +1241,9 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
floor->get_line_edit()->add_constant_override("minimum_spaces", 16);
spatial_editor_hb->add_child(floor);
- floor->connect("value_changed", this, "_floor_changed");
- floor->connect("mouse_exited", this, "_floor_mouse_exited");
- floor->get_line_edit()->connect("mouse_exited", this, "_floor_mouse_exited");
+ floor->connect_compat("value_changed", this, "_floor_changed");
+ floor->connect_compat("mouse_exited", this, "_floor_mouse_exited");
+ floor->get_line_edit()->connect_compat("mouse_exited", this, "_floor_mouse_exited");
spatial_editor_hb->add_child(memnew(VSeparator));
@@ -1282,7 +1300,7 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
settings_vbc->add_margin_child(TTR("Pick Distance:"), settings_pick_distance);
clip_mode = CLIP_DISABLED;
- options->get_popup()->connect("id_pressed", this, "_menu_option");
+ options->get_popup()->connect_compat("id_pressed", this, "_menu_option");
HBoxContainer *hb = memnew(HBoxContainer);
add_child(hb);
@@ -1292,30 +1310,30 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
search_box->set_h_size_flags(SIZE_EXPAND_FILL);
search_box->set_placeholder(TTR("Filter meshes"));
hb->add_child(search_box);
- search_box->connect("text_changed", this, "_text_changed");
- search_box->connect("gui_input", this, "_sbox_input");
+ search_box->connect_compat("text_changed", this, "_text_changed");
+ search_box->connect_compat("gui_input", this, "_sbox_input");
mode_thumbnail = memnew(ToolButton);
mode_thumbnail->set_toggle_mode(true);
mode_thumbnail->set_pressed(true);
mode_thumbnail->set_icon(p_editor->get_gui_base()->get_icon("FileThumbnail", "EditorIcons"));
hb->add_child(mode_thumbnail);
- mode_thumbnail->connect("pressed", this, "_set_display_mode", varray(DISPLAY_THUMBNAIL));
+ mode_thumbnail->connect_compat("pressed", this, "_set_display_mode", varray(DISPLAY_THUMBNAIL));
mode_list = memnew(ToolButton);
mode_list->set_toggle_mode(true);
mode_list->set_pressed(false);
mode_list->set_icon(p_editor->get_gui_base()->get_icon("FileList", "EditorIcons"));
hb->add_child(mode_list);
- mode_list->connect("pressed", this, "_set_display_mode", varray(DISPLAY_LIST));
+ mode_list->connect_compat("pressed", this, "_set_display_mode", varray(DISPLAY_LIST));
size_slider = memnew(HSlider);
size_slider->set_h_size_flags(SIZE_EXPAND_FILL);
- size_slider->set_min(0.1f);
+ size_slider->set_min(0.2f);
size_slider->set_max(4.0f);
size_slider->set_step(0.1f);
size_slider->set_value(1.0f);
- size_slider->connect("value_changed", this, "_icon_size_changed");
+ size_slider->connect_compat("value_changed", this, "_icon_size_changed");
add_child(size_slider);
EDITOR_DEF("editors/grid_map/preview_size", 64);
@@ -1325,6 +1343,7 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
mesh_library_palette = memnew(ItemList);
add_child(mesh_library_palette);
mesh_library_palette->set_v_size_flags(SIZE_EXPAND_FILL);
+ mesh_library_palette->connect_compat("gui_input", this, "_mesh_library_palette_input");
info_message = memnew(Label);
info_message->set_text(TTR("Give a MeshLibrary resource to this GridMap to use its meshes."));
@@ -1351,9 +1370,9 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
{
// Selection mesh create.
- PoolVector<Vector3> lines;
- PoolVector<Vector3> triangles;
- PoolVector<Vector3> square[3];
+ Vector<Vector3> lines;
+ Vector<Vector3> triangles;
+ Vector<Vector3> square[3];
for (int i = 0; i < 6; i++) {
@@ -1427,8 +1446,8 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
inner_mat.instance();
inner_mat->set_albedo(Color(0.7, 0.7, 1.0, 0.2));
- inner_mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
- inner_mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
+ inner_mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
+ inner_mat->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
d[VS::ARRAY_VERTEX] = triangles;
VisualServer::get_singleton()->mesh_add_surface_from_arrays(selection_mesh, VS::PRIMITIVE_TRIANGLES, d);
@@ -1437,15 +1456,14 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
outer_mat.instance();
outer_mat->set_albedo(Color(0.7, 0.7, 1.0, 0.8));
outer_mat->set_on_top_of_alpha();
- outer_mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
- outer_mat->set_line_width(3.0);
- outer_mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
+
+ outer_mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
+ outer_mat->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
selection_floor_mat.instance();
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_flag(SpatialMaterial::FLAG_UNSHADED, true);
- selection_floor_mat->set_line_width(3.0);
+ selection_floor_mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
d[VS::ARRAY_VERTEX] = lines;
VisualServer::get_singleton()->mesh_add_surface_from_arrays(selection_mesh, VS::PRIMITIVE_LINES, d);
@@ -1472,10 +1490,10 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
accumulated_floor_delta = 0.0;
indicator_mat.instance();
- indicator_mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
- indicator_mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
- indicator_mat->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true);
- indicator_mat->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
+ 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);
+ indicator_mat->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
indicator_mat->set_albedo(Color(0.8, 0.5, 0.1));
}
diff --git a/modules/gridmap/grid_map_editor_plugin.h b/modules/gridmap/grid_map_editor_plugin.h
index 404e95b74c..d6459cee0a 100644
--- a/modules/gridmap/grid_map_editor_plugin.h
+++ b/modules/gridmap/grid_map_editor_plugin.h
@@ -125,10 +125,10 @@ class GridMapEditor : public VBoxContainer {
List<ClipboardItem> clipboard_items;
- Ref<SpatialMaterial> indicator_mat;
- Ref<SpatialMaterial> inner_mat;
- Ref<SpatialMaterial> outer_mat;
- Ref<SpatialMaterial> selection_floor_mat;
+ Ref<StandardMaterial3D> indicator_mat;
+ Ref<StandardMaterial3D> inner_mat;
+ Ref<StandardMaterial3D> outer_mat;
+ Ref<StandardMaterial3D> selection_floor_mat;
bool updating;
@@ -214,6 +214,7 @@ class GridMapEditor : public VBoxContainer {
void _text_changed(const String &p_text);
void _sbox_input(const Ref<InputEvent> &p_ie);
+ void _mesh_library_palette_input(const Ref<InputEvent> &p_ie);
void _icon_size_changed(float p_value);
diff --git a/modules/hdr/image_loader_hdr.cpp b/modules/hdr/image_loader_hdr.cpp
index 3fa7266f1a..c03ae4ab1f 100644
--- a/modules/hdr/image_loader_hdr.cpp
+++ b/modules/hdr/image_loader_hdr.cpp
@@ -63,15 +63,15 @@ Error ImageLoaderHDR::load_image(Ref<Image> p_image, FileAccess *f, bool p_force
int width = f->get_line().to_int();
- PoolVector<uint8_t> imgdata;
+ Vector<uint8_t> imgdata;
imgdata.resize(height * width * sizeof(uint32_t));
{
- PoolVector<uint8_t>::Write w = imgdata.write();
+ uint8_t *w = imgdata.ptrw();
- uint8_t *ptr = (uint8_t *)w.ptr();
+ uint8_t *ptr = (uint8_t *)w;
if (width < 8 || width >= 32768) {
// Read flat data
diff --git a/modules/jpg/image_loader_jpegd.cpp b/modules/jpg/image_loader_jpegd.cpp
index a1f0f0ef6a..9e87d11ac1 100644
--- a/modules/jpg/image_loader_jpegd.cpp
+++ b/modules/jpg/image_loader_jpegd.cpp
@@ -57,13 +57,13 @@ Error jpeg_load_image_from_buffer(Image *p_image, const uint8_t *p_buffer, int p
const int dst_bpl = image_width * comps;
- PoolVector<uint8_t> data;
+ Vector<uint8_t> data;
data.resize(dst_bpl * image_height);
- PoolVector<uint8_t>::Write dw = data.write();
+ uint8_t *dw = data.ptrw();
- jpgd::uint8 *pImage_data = (jpgd::uint8 *)dw.ptr();
+ jpgd::uint8 *pImage_data = (jpgd::uint8 *)dw;
for (int y = 0; y < image_height; y++) {
const jpgd::uint8 *pScan_line;
@@ -96,7 +96,6 @@ Error jpeg_load_image_from_buffer(Image *p_image, const uint8_t *p_buffer, int p
else
fmt = Image::FORMAT_RGB8;
- dw.release();
p_image->create(image_width, image_height, 0, fmt, data);
return OK;
@@ -104,18 +103,18 @@ Error jpeg_load_image_from_buffer(Image *p_image, const uint8_t *p_buffer, int p
Error ImageLoaderJPG::load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear, float p_scale) {
- PoolVector<uint8_t> src_image;
+ Vector<uint8_t> src_image;
int src_image_len = f->get_len();
ERR_FAIL_COND_V(src_image_len == 0, ERR_FILE_CORRUPT);
src_image.resize(src_image_len);
- PoolVector<uint8_t>::Write w = src_image.write();
+ uint8_t *w = src_image.ptrw();
f->get_buffer(&w[0], src_image_len);
f->close();
- Error err = jpeg_load_image_from_buffer(p_image.ptr(), w.ptr(), src_image_len);
+ Error err = jpeg_load_image_from_buffer(p_image.ptr(), w, src_image_len);
return err;
}
diff --git a/modules/mbedtls/crypto_mbedtls.cpp b/modules/mbedtls/crypto_mbedtls.cpp
index 2bd80064e3..ee3c78aeb3 100644
--- a/modules/mbedtls/crypto_mbedtls.cpp
+++ b/modules/mbedtls/crypto_mbedtls.cpp
@@ -53,22 +53,22 @@ CryptoKey *CryptoKeyMbedTLS::create() {
Error CryptoKeyMbedTLS::load(String p_path) {
ERR_FAIL_COND_V_MSG(locks, ERR_ALREADY_IN_USE, "Key is in use");
- PoolByteArray out;
+ PackedByteArray out;
FileAccess *f = FileAccess::open(p_path, FileAccess::READ);
ERR_FAIL_COND_V_MSG(!f, ERR_INVALID_PARAMETER, "Cannot open CryptoKeyMbedTLS file '" + p_path + "'.");
int flen = f->get_len();
out.resize(flen + 1);
{
- PoolByteArray::Write w = out.write();
- f->get_buffer(w.ptr(), flen);
+ uint8_t *w = out.ptrw();
+ f->get_buffer(w, flen);
w[flen] = 0; //end f string
}
memdelete(f);
- int ret = mbedtls_pk_parse_key(&pkey, out.read().ptr(), out.size(), NULL, 0);
+ int ret = mbedtls_pk_parse_key(&pkey, out.ptr(), out.size(), NULL, 0);
// We MUST zeroize the memory for safety!
- mbedtls_platform_zeroize(out.write().ptr(), out.size());
+ mbedtls_platform_zeroize(out.ptrw(), out.size());
ERR_FAIL_COND_V_MSG(ret, FAILED, "Error parsing private key '" + itos(ret) + "'.");
return OK;
@@ -102,20 +102,20 @@ X509Certificate *X509CertificateMbedTLS::create() {
Error X509CertificateMbedTLS::load(String p_path) {
ERR_FAIL_COND_V_MSG(locks, ERR_ALREADY_IN_USE, "Certificate is in use");
- PoolByteArray out;
+ PackedByteArray out;
FileAccess *f = FileAccess::open(p_path, FileAccess::READ);
ERR_FAIL_COND_V_MSG(!f, ERR_INVALID_PARAMETER, "Cannot open X509CertificateMbedTLS file '" + p_path + "'.");
int flen = f->get_len();
out.resize(flen + 1);
{
- PoolByteArray::Write w = out.write();
- f->get_buffer(w.ptr(), flen);
+ uint8_t *w = out.ptrw();
+ f->get_buffer(w, flen);
w[flen] = 0; //end f string
}
memdelete(f);
- int ret = mbedtls_x509_crt_parse(&cert, out.read().ptr(), out.size());
+ int ret = mbedtls_x509_crt_parse(&cert, out.ptr(), out.size());
ERR_FAIL_COND_V_MSG(ret, FAILED, "Error parsing some certificates: " + itos(ret));
return OK;
@@ -210,15 +210,15 @@ void CryptoMbedTLS::load_default_certificates(String p_path) {
#ifdef BUILTIN_CERTS_ENABLED
else {
// Use builtin certs only if user did not override it in project settings.
- PoolByteArray out;
+ PackedByteArray out;
out.resize(_certs_uncompressed_size + 1);
- PoolByteArray::Write w = out.write();
- Compression::decompress(w.ptr(), _certs_uncompressed_size, _certs_compressed, _certs_compressed_size, Compression::MODE_DEFLATE);
+ uint8_t *w = out.ptrw();
+ Compression::decompress(w, _certs_uncompressed_size, _certs_compressed, _certs_compressed_size, Compression::MODE_DEFLATE);
w[_certs_uncompressed_size] = 0; // Make sure it ends with string terminator
#ifdef DEBUG_ENABLED
print_verbose("Loaded builtin certs");
#endif
- default_certs->load_from_memory(out.read().ptr(), out.size());
+ default_certs->load_from_memory(out.ptr(), out.size());
}
#endif
}
@@ -276,9 +276,9 @@ Ref<X509Certificate> CryptoMbedTLS::generate_self_signed_certificate(Ref<CryptoK
return out;
}
-PoolByteArray CryptoMbedTLS::generate_random_bytes(int p_bytes) {
- PoolByteArray out;
+PackedByteArray CryptoMbedTLS::generate_random_bytes(int p_bytes) {
+ PackedByteArray out;
out.resize(p_bytes);
- mbedtls_ctr_drbg_random(&ctr_drbg, out.write().ptr(), p_bytes);
+ mbedtls_ctr_drbg_random(&ctr_drbg, out.ptrw(), p_bytes);
return out;
}
diff --git a/modules/mbedtls/crypto_mbedtls.h b/modules/mbedtls/crypto_mbedtls.h
index edb5841761..6c1c0e255d 100644
--- a/modules/mbedtls/crypto_mbedtls.h
+++ b/modules/mbedtls/crypto_mbedtls.h
@@ -113,7 +113,7 @@ public:
static X509CertificateMbedTLS *get_default_certificates();
static void load_default_certificates(String p_path);
- virtual PoolByteArray generate_random_bytes(int p_bytes);
+ virtual PackedByteArray generate_random_bytes(int p_bytes);
virtual Ref<CryptoKey> generate_rsa(int p_bytes);
virtual Ref<X509Certificate> generate_self_signed_certificate(Ref<CryptoKey> p_key, String p_issuer_name, String p_not_before, String p_not_after);
diff --git a/modules/mbedtls/dtls_server_mbedtls.cpp b/modules/mbedtls/dtls_server_mbedtls.cpp
new file mode 100644
index 0000000000..215b511758
--- /dev/null
+++ b/modules/mbedtls/dtls_server_mbedtls.cpp
@@ -0,0 +1,78 @@
+/*************************************************************************/
+/* dtls_server_mbedtls.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#include "dtls_server_mbedtls.h"
+#include "packet_peer_mbed_dtls.h"
+
+Error DTLSServerMbedTLS::setup(Ref<CryptoKey> p_key, Ref<X509Certificate> p_cert, Ref<X509Certificate> p_ca_chain) {
+ ERR_FAIL_COND_V(_cookies->setup() != OK, ERR_ALREADY_IN_USE);
+ _key = p_key;
+ _cert = p_cert;
+ _ca_chain = p_ca_chain;
+ return OK;
+}
+
+void DTLSServerMbedTLS::stop() {
+ _cookies->clear();
+}
+
+Ref<PacketPeerDTLS> DTLSServerMbedTLS::take_connection(Ref<PacketPeerUDP> p_udp_peer) {
+ Ref<PacketPeerMbedDTLS> out;
+ out.instance();
+
+ ERR_FAIL_COND_V(!out.is_valid(), out);
+ ERR_FAIL_COND_V(!p_udp_peer.is_valid(), out);
+ out->accept_peer(p_udp_peer, _key, _cert, _ca_chain, _cookies);
+ return out;
+}
+
+DTLSServer *DTLSServerMbedTLS::_create_func() {
+
+ return memnew(DTLSServerMbedTLS);
+}
+
+void DTLSServerMbedTLS::initialize() {
+
+ _create = _create_func;
+ available = true;
+}
+
+void DTLSServerMbedTLS::finalize() {
+ _create = NULL;
+ available = false;
+}
+
+DTLSServerMbedTLS::DTLSServerMbedTLS() {
+ _cookies.instance();
+}
+
+DTLSServerMbedTLS::~DTLSServerMbedTLS() {
+ stop();
+}
diff --git a/modules/mbedtls/dtls_server_mbedtls.h b/modules/mbedtls/dtls_server_mbedtls.h
new file mode 100644
index 0000000000..d61ab3179e
--- /dev/null
+++ b/modules/mbedtls/dtls_server_mbedtls.h
@@ -0,0 +1,58 @@
+/*************************************************************************/
+/* dtls_server_mbedtls.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifndef MBED_DTLS_SERVER_H
+#define MBED_DTLS_SERVER_H
+
+#include "core/io/dtls_server.h"
+#include "ssl_context_mbedtls.h"
+
+class DTLSServerMbedTLS : public DTLSServer {
+
+private:
+ static DTLSServer *_create_func();
+ Ref<CryptoKey> _key;
+ Ref<X509Certificate> _cert;
+ Ref<X509Certificate> _ca_chain;
+ Ref<CookieContextMbedTLS> _cookies;
+
+public:
+ static void initialize();
+ static void finalize();
+
+ virtual Error setup(Ref<CryptoKey> p_key, Ref<X509Certificate> p_cert, Ref<X509Certificate> p_ca_chain = Ref<X509Certificate>());
+ virtual void stop();
+ virtual Ref<PacketPeerDTLS> take_connection(Ref<PacketPeerUDP> p_peer);
+
+ DTLSServerMbedTLS();
+ ~DTLSServerMbedTLS();
+};
+
+#endif // MBED_DTLS_SERVER_H
diff --git a/modules/mbedtls/packet_peer_mbed_dtls.cpp b/modules/mbedtls/packet_peer_mbed_dtls.cpp
new file mode 100755
index 0000000000..bdf36ad1b1
--- /dev/null
+++ b/modules/mbedtls/packet_peer_mbed_dtls.cpp
@@ -0,0 +1,297 @@
+/*************************************************************************/
+/* packet_peer_mbed_dtls.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#include "packet_peer_mbed_dtls.h"
+#include "mbedtls/platform_util.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 == NULL || len <= 0) return 0;
+
+ PacketPeerMbedDTLS *sp = (PacketPeerMbedDTLS *)ctx;
+
+ ERR_FAIL_COND_V(sp == NULL, 0);
+
+ Error err = sp->base->put_packet((const uint8_t *)buf, len);
+ if (err == ERR_BUSY) {
+ return MBEDTLS_ERR_SSL_WANT_WRITE;
+ } else if (err != OK) {
+ ERR_FAIL_V(MBEDTLS_ERR_SSL_INTERNAL_ERROR);
+ }
+ return len;
+}
+
+int PacketPeerMbedDTLS::bio_recv(void *ctx, unsigned char *buf, size_t len) {
+
+ if (buf == NULL || len <= 0) return 0;
+
+ PacketPeerMbedDTLS *sp = (PacketPeerMbedDTLS *)ctx;
+
+ ERR_FAIL_COND_V(sp == NULL, 0);
+
+ int pc = sp->base->get_available_packet_count();
+ if (pc == 0) {
+ return MBEDTLS_ERR_SSL_WANT_READ;
+ } else if (pc < 0) {
+ ERR_FAIL_V(MBEDTLS_ERR_SSL_INTERNAL_ERROR);
+ }
+
+ const uint8_t *buffer;
+ int buffer_size = 0;
+ Error err = sp->base->get_packet(&buffer, buffer_size);
+ if (err != OK) {
+ return MBEDTLS_ERR_SSL_INTERNAL_ERROR;
+ }
+ copymem(buf, buffer, buffer_size);
+ return buffer_size;
+}
+
+void PacketPeerMbedDTLS::_cleanup() {
+
+ ssl_ctx->clear();
+ base = Ref<PacketPeer>();
+ status = STATUS_DISCONNECTED;
+}
+
+int PacketPeerMbedDTLS::_set_cookie() {
+ // Setup DTLS session cookie for this client
+ uint8_t client_id[18];
+ IP_Address addr = base->get_packet_address();
+ uint16_t port = base->get_packet_port();
+ copymem(client_id, addr.get_ipv6(), 16);
+ copymem(&client_id[16], (uint8_t *)&port, 2);
+ return mbedtls_ssl_set_client_transport_id(ssl_ctx->get_context(), client_id, 18);
+}
+
+Error PacketPeerMbedDTLS::_do_handshake() {
+ int ret = 0;
+ while ((ret = mbedtls_ssl_handshake(ssl_ctx->get_context())) != 0) {
+ if (ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE) {
+ if (ret != MBEDTLS_ERR_SSL_HELLO_VERIFY_REQUIRED) {
+ ERR_PRINT("TLS handshake error: " + itos(ret));
+ SSLContextMbedTLS::print_mbedtls_error(ret);
+ }
+ _cleanup();
+ status = STATUS_ERROR;
+ return FAILED;
+ }
+ // Will retry via poll later
+ return OK;
+ }
+
+ status = STATUS_CONNECTED;
+ return OK;
+}
+
+Error PacketPeerMbedDTLS::connect_to_peer(Ref<PacketPeerUDP> p_base, bool p_validate_certs, const String &p_for_hostname, Ref<X509Certificate> p_ca_certs) {
+
+ ERR_FAIL_COND_V(!p_base.is_valid() || !p_base->is_connected_to_host(), ERR_INVALID_PARAMETER);
+
+ base = p_base;
+ int ret = 0;
+ int authmode = p_validate_certs ? MBEDTLS_SSL_VERIFY_REQUIRED : MBEDTLS_SSL_VERIFY_NONE;
+
+ Error err = ssl_ctx->init_client(MBEDTLS_SSL_TRANSPORT_DATAGRAM, authmode, p_ca_certs);
+ ERR_FAIL_COND_V(err != OK, err);
+
+ mbedtls_ssl_set_hostname(ssl_ctx->get_context(), p_for_hostname.utf8().get_data());
+ mbedtls_ssl_set_bio(ssl_ctx->get_context(), this, bio_send, bio_recv, NULL);
+ mbedtls_ssl_set_timer_cb(ssl_ctx->get_context(), &timer, mbedtls_timing_set_delay, mbedtls_timing_get_delay);
+
+ status = STATUS_HANDSHAKING;
+
+ if ((ret = _do_handshake()) != OK) {
+ status = STATUS_ERROR_HOSTNAME_MISMATCH;
+ return FAILED;
+ }
+
+ return OK;
+}
+
+Error PacketPeerMbedDTLS::accept_peer(Ref<PacketPeerUDP> p_base, Ref<CryptoKey> p_key, Ref<X509Certificate> p_cert, Ref<X509Certificate> p_ca_chain, Ref<CookieContextMbedTLS> p_cookies) {
+
+ Error err = ssl_ctx->init_server(MBEDTLS_SSL_TRANSPORT_DATAGRAM, MBEDTLS_SSL_VERIFY_NONE, p_key, p_cert, p_cookies);
+ ERR_FAIL_COND_V(err != OK, err);
+
+ base = p_base;
+ base->set_blocking_mode(false);
+
+ mbedtls_ssl_session_reset(ssl_ctx->get_context());
+
+ int ret = _set_cookie();
+ if (ret != 0) {
+ _cleanup();
+ ERR_FAIL_V_MSG(FAILED, "Error setting DTLS client cookie");
+ }
+
+ mbedtls_ssl_set_bio(ssl_ctx->get_context(), this, bio_send, bio_recv, NULL);
+ mbedtls_ssl_set_timer_cb(ssl_ctx->get_context(), &timer, mbedtls_timing_set_delay, mbedtls_timing_get_delay);
+
+ status = STATUS_HANDSHAKING;
+
+ if ((ret = _do_handshake()) != OK) {
+ status = STATUS_ERROR;
+ return FAILED;
+ }
+
+ return OK;
+}
+
+Error PacketPeerMbedDTLS::put_packet(const uint8_t *p_buffer, int p_bytes) {
+
+ ERR_FAIL_COND_V(status != STATUS_CONNECTED, ERR_UNCONFIGURED);
+
+ if (p_bytes == 0)
+ return OK;
+
+ int ret = mbedtls_ssl_write(ssl_ctx->get_context(), p_buffer, p_bytes);
+ if (ret == MBEDTLS_ERR_SSL_WANT_READ || ret == MBEDTLS_ERR_SSL_WANT_WRITE) {
+ ret = 0; // non blocking io
+ } else if (ret <= 0) {
+ SSLContextMbedTLS::print_mbedtls_error(ret);
+ _cleanup();
+ return ERR_CONNECTION_ERROR;
+ }
+
+ return OK;
+}
+
+Error PacketPeerMbedDTLS::get_packet(const uint8_t **r_buffer, int &r_bytes) {
+
+ ERR_FAIL_COND_V(status != STATUS_CONNECTED, ERR_UNCONFIGURED);
+
+ r_bytes = 0;
+
+ int ret = mbedtls_ssl_read(ssl_ctx->get_context(), packet_buffer, PACKET_BUFFER_SIZE);
+ if (ret == MBEDTLS_ERR_SSL_WANT_READ || ret == MBEDTLS_ERR_SSL_WANT_WRITE) {
+ ret = 0; // non blocking io
+ } else if (ret <= 0) {
+ if (ret == MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY) {
+ // Also send close notify back
+ disconnect_from_peer();
+ } else {
+ _cleanup();
+ status = STATUS_ERROR;
+ SSLContextMbedTLS::print_mbedtls_error(ret);
+ }
+ return ERR_CONNECTION_ERROR;
+ }
+ *r_buffer = packet_buffer;
+ r_bytes = ret;
+
+ return OK;
+}
+
+void PacketPeerMbedDTLS::poll() {
+
+ if (status == STATUS_HANDSHAKING) {
+ _do_handshake();
+ return;
+ } else if (status != STATUS_CONNECTED) {
+ return;
+ }
+
+ ERR_FAIL_COND(!base.is_valid());
+
+ int ret = mbedtls_ssl_read(ssl_ctx->get_context(), NULL, 0);
+
+ if (ret < 0 && ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE) {
+ if (ret == MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY) {
+ // Also send close notify back
+ disconnect_from_peer();
+ } else {
+ _cleanup();
+ status = STATUS_ERROR;
+ SSLContextMbedTLS::print_mbedtls_error(ret);
+ }
+ }
+}
+
+int PacketPeerMbedDTLS::get_available_packet_count() const {
+
+ ERR_FAIL_COND_V(status != STATUS_CONNECTED, 0);
+
+ return mbedtls_ssl_get_bytes_avail(&(ssl_ctx->ssl)) > 0 ? 1 : 0;
+}
+
+int PacketPeerMbedDTLS::get_max_packet_size() const {
+
+ return 488; // 512 (UDP in Godot) - 24 (DTLS header)
+}
+
+PacketPeerMbedDTLS::PacketPeerMbedDTLS() {
+
+ ssl_ctx.instance();
+ status = STATUS_DISCONNECTED;
+}
+
+PacketPeerMbedDTLS::~PacketPeerMbedDTLS() {
+ disconnect_from_peer();
+}
+
+void PacketPeerMbedDTLS::disconnect_from_peer() {
+
+ if (status != STATUS_CONNECTED && status != STATUS_HANDSHAKING)
+ return;
+
+ if (status == STATUS_CONNECTED) {
+ int ret = 0;
+ // Send SSL close notification, blocking, but ignore other errors.
+ do
+ ret = mbedtls_ssl_close_notify(ssl_ctx->get_context());
+ while (ret == MBEDTLS_ERR_SSL_WANT_WRITE);
+ }
+
+ _cleanup();
+}
+
+PacketPeerMbedDTLS::Status PacketPeerMbedDTLS::get_status() const {
+
+ return status;
+}
+
+PacketPeerDTLS *PacketPeerMbedDTLS::_create_func() {
+
+ return memnew(PacketPeerMbedDTLS);
+}
+
+void PacketPeerMbedDTLS::initialize_dtls() {
+
+ _create = _create_func;
+ available = true;
+}
+
+void PacketPeerMbedDTLS::finalize_dtls() {
+ _create = NULL;
+ available = false;
+}
diff --git a/modules/mbedtls/packet_peer_mbed_dtls.h b/modules/mbedtls/packet_peer_mbed_dtls.h
new file mode 100755
index 0000000000..26c4543785
--- /dev/null
+++ b/modules/mbedtls/packet_peer_mbed_dtls.h
@@ -0,0 +1,88 @@
+/*************************************************************************/
+/* packet_peer_mbed_dtls.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifndef PACKET_PEER_MBED_DTLS_H
+#define PACKET_PEER_MBED_DTLS_H
+
+#include "core/io/packet_peer_dtls.h"
+#include "ssl_context_mbedtls.h"
+
+#include <mbedtls/timing.h>
+
+class PacketPeerMbedDTLS : public PacketPeerDTLS {
+private:
+ enum {
+ PACKET_BUFFER_SIZE = 65536
+ };
+
+ uint8_t packet_buffer[PACKET_BUFFER_SIZE];
+
+ Status status;
+ String hostname;
+
+ Ref<PacketPeerUDP> base;
+
+ static PacketPeerDTLS *_create_func();
+
+ static int bio_recv(void *ctx, unsigned char *buf, size_t len);
+ static int bio_send(void *ctx, const unsigned char *buf, size_t len);
+ void _cleanup();
+
+protected:
+ Ref<SSLContextMbedTLS> ssl_ctx;
+ mbedtls_timing_delay_context timer;
+
+ static void _bind_methods();
+
+ Error _do_handshake();
+ int _set_cookie();
+
+public:
+ virtual void poll();
+ virtual Error accept_peer(Ref<PacketPeerUDP> p_base, Ref<CryptoKey> p_key, Ref<X509Certificate> p_cert = Ref<X509Certificate>(), Ref<X509Certificate> p_ca_chain = Ref<X509Certificate>(), Ref<CookieContextMbedTLS> p_cookies = Ref<CookieContextMbedTLS>());
+ virtual Error connect_to_peer(Ref<PacketPeerUDP> p_base, bool p_validate_certs = false, const String &p_for_hostname = String(), Ref<X509Certificate> p_ca_certs = Ref<X509Certificate>());
+ virtual Status get_status() const;
+
+ virtual void disconnect_from_peer();
+
+ virtual Error get_packet(const uint8_t **r_buffer, int &r_buffer_size);
+ virtual Error put_packet(const uint8_t *p_buffer, int p_buffer_size);
+
+ virtual int get_available_packet_count() const;
+ virtual int get_max_packet_size() const;
+
+ static void initialize_dtls();
+ static void finalize_dtls();
+
+ PacketPeerMbedDTLS();
+ ~PacketPeerMbedDTLS();
+};
+
+#endif // PACKET_PEER_MBED_DTLS_H
diff --git a/modules/mbedtls/register_types.cpp b/modules/mbedtls/register_types.cpp
index 8f9e2c370b..d39af7fe87 100755
--- a/modules/mbedtls/register_types.cpp
+++ b/modules/mbedtls/register_types.cpp
@@ -31,16 +31,22 @@
#include "register_types.h"
#include "crypto_mbedtls.h"
+#include "dtls_server_mbedtls.h"
+#include "packet_peer_mbed_dtls.h"
#include "stream_peer_mbedtls.h"
void register_mbedtls_types() {
CryptoMbedTLS::initialize_crypto();
StreamPeerMbedTLS::initialize_ssl();
+ PacketPeerMbedDTLS::initialize_dtls();
+ DTLSServerMbedTLS::initialize();
}
void unregister_mbedtls_types() {
+ DTLSServerMbedTLS::finalize();
+ PacketPeerMbedDTLS::finalize_dtls();
StreamPeerMbedTLS::finalize_ssl();
CryptoMbedTLS::finalize_crypto();
}
diff --git a/modules/mbedtls/ssl_context_mbedtls.cpp b/modules/mbedtls/ssl_context_mbedtls.cpp
index 82584e3494..52630bd98c 100644
--- a/modules/mbedtls/ssl_context_mbedtls.cpp
+++ b/modules/mbedtls/ssl_context_mbedtls.cpp
@@ -38,6 +38,53 @@ static void my_debug(void *ctx, int level,
fflush(stdout);
}
+void SSLContextMbedTLS::print_mbedtls_error(int p_ret) {
+ printf("mbedtls error: returned -0x%x\n\n", -p_ret);
+ fflush(stdout);
+}
+
+/// CookieContextMbedTLS
+
+Error CookieContextMbedTLS::setup() {
+ ERR_FAIL_COND_V_MSG(inited, ERR_ALREADY_IN_USE, "This cookie context is already in use");
+
+ mbedtls_ctr_drbg_init(&ctr_drbg);
+ mbedtls_entropy_init(&entropy);
+ mbedtls_ssl_cookie_init(&cookie_ctx);
+ inited = true;
+
+ int ret = mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy, NULL, 0);
+ if (ret != 0) {
+ clear(); // Never leave unusable resources around.
+ ERR_FAIL_V_MSG(FAILED, "mbedtls_ctr_drbg_seed returned an error " + itos(ret));
+ }
+
+ ret = mbedtls_ssl_cookie_setup(&cookie_ctx, mbedtls_ctr_drbg_random, &ctr_drbg);
+ if (ret != 0) {
+ clear();
+ ERR_FAIL_V_MSG(FAILED, "mbedtls_ssl_cookie_setup returned an error " + itos(ret));
+ }
+ return OK;
+}
+
+void CookieContextMbedTLS::clear() {
+ if (!inited)
+ return;
+ mbedtls_ctr_drbg_free(&ctr_drbg);
+ mbedtls_entropy_free(&entropy);
+ mbedtls_ssl_cookie_free(&cookie_ctx);
+}
+
+CookieContextMbedTLS::CookieContextMbedTLS() {
+ inited = false;
+}
+
+CookieContextMbedTLS::~CookieContextMbedTLS() {
+ clear();
+}
+
+/// SSLContextMbedTLS
+
Error SSLContextMbedTLS::_setup(int p_endpoint, int p_transport, int p_authmode) {
ERR_FAIL_COND_V_MSG(inited, ERR_ALREADY_IN_USE, "This SSL context is already active");
@@ -50,7 +97,7 @@ Error SSLContextMbedTLS::_setup(int p_endpoint, int p_transport, int p_authmode)
int ret = mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy, NULL, 0);
if (ret != 0) {
clear(); // Never leave unusable resources around.
- ERR_FAIL_V_MSG(FAILED, "mbedtls_ctr_drbg_seed returned an error" + itos(ret));
+ ERR_FAIL_V_MSG(FAILED, "mbedtls_ctr_drbg_seed returned an error " + itos(ret));
}
ret = mbedtls_ssl_config_defaults(&conf, p_endpoint, p_transport, MBEDTLS_SSL_PRESET_DEFAULT);
@@ -64,7 +111,7 @@ Error SSLContextMbedTLS::_setup(int p_endpoint, int p_transport, int p_authmode)
return OK;
}
-Error SSLContextMbedTLS::init_server(int p_transport, int p_authmode, Ref<CryptoKeyMbedTLS> p_pkey, Ref<X509CertificateMbedTLS> p_cert) {
+Error SSLContextMbedTLS::init_server(int p_transport, int p_authmode, Ref<CryptoKeyMbedTLS> p_pkey, Ref<X509CertificateMbedTLS> p_cert, Ref<CookieContextMbedTLS> p_cookies) {
ERR_FAIL_COND_V(!p_pkey.is_valid(), ERR_INVALID_PARAMETER);
ERR_FAIL_COND_V(!p_cert.is_valid(), ERR_INVALID_PARAMETER);
@@ -89,6 +136,15 @@ Error SSLContextMbedTLS::init_server(int p_transport, int p_authmode, Ref<Crypto
if (certs->cert.next) {
mbedtls_ssl_conf_ca_chain(&conf, certs->cert.next, NULL);
}
+ // DTLS Cookies
+ if (p_transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM) {
+ if (p_cookies.is_null() || !p_cookies->inited) {
+ clear();
+ ERR_FAIL_V(ERR_BUG);
+ }
+ cookies = p_cookies;
+ mbedtls_ssl_conf_dtls_cookies(&conf, mbedtls_ssl_cookie_write, mbedtls_ssl_cookie_check, &(cookies->cookie_ctx));
+ }
mbedtls_ssl_setup(&ssl, &conf);
return OK;
}
@@ -134,6 +190,7 @@ void SSLContextMbedTLS::clear() {
if (pkey.is_valid())
pkey->unlock();
pkey = Ref<CryptoKeyMbedTLS>();
+ cookies = Ref<CookieContextMbedTLS>();
inited = false;
}
diff --git a/modules/mbedtls/ssl_context_mbedtls.h b/modules/mbedtls/ssl_context_mbedtls.h
index 9145e0fd72..d3e1f87a8e 100644
--- a/modules/mbedtls/ssl_context_mbedtls.h
+++ b/modules/mbedtls/ssl_context_mbedtls.h
@@ -34,7 +34,7 @@
#include "crypto_mbedtls.h"
#include "core/os/file_access.h"
-#include "core/pool_vector.h"
+
#include "core/reference.h"
#include <mbedtls/config.h>
@@ -42,25 +42,49 @@
#include <mbedtls/debug.h>
#include <mbedtls/entropy.h>
#include <mbedtls/ssl.h>
+#include <mbedtls/ssl_cookie.h>
+
+class SSLContextMbedTLS;
+
+class CookieContextMbedTLS : public Reference {
+
+ friend class SSLContextMbedTLS;
+
+protected:
+ bool inited;
+ mbedtls_entropy_context entropy;
+ mbedtls_ctr_drbg_context ctr_drbg;
+ mbedtls_ssl_cookie_ctx cookie_ctx;
+
+public:
+ Error setup();
+ void clear();
+
+ CookieContextMbedTLS();
+ ~CookieContextMbedTLS();
+};
class SSLContextMbedTLS : public Reference {
protected:
bool inited;
- static PoolByteArray _read_file(String p_path);
+ static PackedByteArray _read_file(String p_path);
public:
+ static void print_mbedtls_error(int p_ret);
+
Ref<X509CertificateMbedTLS> certs;
mbedtls_entropy_context entropy;
mbedtls_ctr_drbg_context ctr_drbg;
mbedtls_ssl_context ssl;
mbedtls_ssl_config conf;
+ Ref<CookieContextMbedTLS> cookies;
Ref<CryptoKeyMbedTLS> pkey;
Error _setup(int p_endpoint, int p_transport, int p_authmode);
- Error init_server(int p_transport, int p_authmode, Ref<CryptoKeyMbedTLS> p_pkey, Ref<X509CertificateMbedTLS> p_cert);
+ Error init_server(int p_transport, int p_authmode, Ref<CryptoKeyMbedTLS> p_pkey, Ref<X509CertificateMbedTLS> p_cert, Ref<CookieContextMbedTLS> p_cookies = Ref<CookieContextMbedTLS>());
Error init_client(int p_transport, int p_authmode, Ref<X509CertificateMbedTLS> p_valid_cas);
void clear();
diff --git a/modules/mbedtls/stream_peer_mbedtls.cpp b/modules/mbedtls/stream_peer_mbedtls.cpp
index f06327e0d5..03c5922267 100755
--- a/modules/mbedtls/stream_peer_mbedtls.cpp
+++ b/modules/mbedtls/stream_peer_mbedtls.cpp
@@ -33,11 +33,6 @@
#include "core/io/stream_peer_tcp.h"
#include "core/os/file_access.h"
-void _print_error(int ret) {
- printf("mbedtls error: returned -0x%x\n\n", -ret);
- fflush(stdout);
-}
-
int StreamPeerMbedTLS::bio_send(void *ctx, const unsigned char *buf, size_t len) {
if (buf == NULL || len <= 0) return 0;
@@ -89,7 +84,7 @@ Error StreamPeerMbedTLS::_do_handshake() {
if (ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE) {
// An error occurred.
ERR_PRINT("TLS handshake error: " + itos(ret));
- _print_error(ret);
+ SSLContextMbedTLS::print_mbedtls_error(ret);
disconnect_from_stream();
status = STATUS_ERROR;
return FAILED;
@@ -188,7 +183,7 @@ Error StreamPeerMbedTLS::put_partial_data(const uint8_t *p_data, int p_bytes, in
disconnect_from_stream();
return ERR_FILE_EOF;
} else if (ret <= 0) {
- _print_error(ret);
+ SSLContextMbedTLS::print_mbedtls_error(ret);
disconnect_from_stream();
return ERR_CONNECTION_ERROR;
}
@@ -233,7 +228,7 @@ Error StreamPeerMbedTLS::get_partial_data(uint8_t *p_buffer, int p_bytes, int &r
disconnect_from_stream();
return ERR_FILE_EOF;
} else if (ret <= 0) {
- _print_error(ret);
+ SSLContextMbedTLS::print_mbedtls_error(ret);
disconnect_from_stream();
return ERR_CONNECTION_ERROR;
}
@@ -264,7 +259,7 @@ void StreamPeerMbedTLS::poll() {
disconnect_from_stream();
return;
} else if (ret < 0) {
- _print_error(ret);
+ SSLContextMbedTLS::print_mbedtls_error(ret);
disconnect_from_stream();
return;
}
diff --git a/modules/mobile_vr/mobile_vr_interface.cpp b/modules/mobile_vr/mobile_vr_interface.cpp
index 22b708f206..2f1d95cd42 100644
--- a/modules/mobile_vr/mobile_vr_interface.cpp
+++ b/modules/mobile_vr/mobile_vr_interface.cpp
@@ -221,13 +221,13 @@ void MobileVRInterface::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_k2", "k"), &MobileVRInterface::set_k2);
ClassDB::bind_method(D_METHOD("get_k2"), &MobileVRInterface::get_k2);
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "eye_height", PROPERTY_HINT_RANGE, "0.0,3.0,0.1"), "set_eye_height", "get_eye_height");
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "iod", PROPERTY_HINT_RANGE, "4.0,10.0,0.1"), "set_iod", "get_iod");
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "display_width", PROPERTY_HINT_RANGE, "5.0,25.0,0.1"), "set_display_width", "get_display_width");
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "display_to_lens", PROPERTY_HINT_RANGE, "5.0,25.0,0.1"), "set_display_to_lens", "get_display_to_lens");
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "oversample", PROPERTY_HINT_RANGE, "1.0,2.0,0.1"), "set_oversample", "get_oversample");
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "k1", PROPERTY_HINT_RANGE, "0.1,10.0,0.0001"), "set_k1", "get_k1");
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "k2", PROPERTY_HINT_RANGE, "0.1,10.0,0.0001"), "set_k2", "get_k2");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "eye_height", PROPERTY_HINT_RANGE, "0.0,3.0,0.1"), "set_eye_height", "get_eye_height");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "iod", PROPERTY_HINT_RANGE, "4.0,10.0,0.1"), "set_iod", "get_iod");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "display_width", PROPERTY_HINT_RANGE, "5.0,25.0,0.1"), "set_display_width", "get_display_width");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "display_to_lens", PROPERTY_HINT_RANGE, "5.0,25.0,0.1"), "set_display_to_lens", "get_display_to_lens");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "oversample", PROPERTY_HINT_RANGE, "1.0,2.0,0.1"), "set_oversample", "get_oversample");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "k1", PROPERTY_HINT_RANGE, "0.1,10.0,0.0001"), "set_k1", "get_k1");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "k2", PROPERTY_HINT_RANGE, "0.1,10.0,0.0001"), "set_k2", "get_k2");
}
void MobileVRInterface::set_eye_height(const real_t p_eye_height) {
@@ -424,13 +424,7 @@ void MobileVRInterface::commit_for_eye(ARVRInterface::Eyes p_eye, RID p_render_t
}
// we don't offset the eye center vertically (yet)
eye_center.y = 0.0;
-
- // unset our render target so we are outputting to our main screen by making RasterizerStorageGLES3::system_fbo our current FBO
- VSG::rasterizer->set_current_render_target(RID());
-
- // and output
- VSG::rasterizer->output_lens_distorted_to_screen(p_render_target, dest, k1, k2, eye_center, oversample);
-};
+}
void MobileVRInterface::process() {
_THREAD_SAFE_METHOD_
diff --git a/modules/mono/build_scripts/make_android_mono_config.py b/modules/mono/build_scripts/make_android_mono_config.py
index 8cad204d7b..0afd939c57 100644
--- a/modules/mono/build_scripts/make_android_mono_config.py
+++ b/modules/mono/build_scripts/make_android_mono_config.py
@@ -24,7 +24,7 @@ def generate_compressed_config(config_src, output_dir):
#ifdef ANDROID_ENABLED
#include "core/io/compression.h"
-#include "core/pool_vector.h"
+
namespace {
@@ -36,9 +36,9 @@ static const unsigned char config_compressed_data[] = { %s };
} // namespace
String get_godot_android_mono_config() {
- PoolVector<uint8_t> data;
+ Vector<uint8_t> data;
data.resize(config_uncompressed_size);
- PoolVector<uint8_t>::Write w = data.write();
+ uint8_t* w = data.ptrw();
Compression::decompress(w.ptr(), config_uncompressed_size, config_compressed_data,
config_compressed_size, Compression::MODE_DEFLATE);
String s;
diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp
index 2847f3b414..5c1c098e3e 100644
--- a/modules/mono/csharp_script.cpp
+++ b/modules/mono/csharp_script.cpp
@@ -31,6 +31,7 @@
#include "csharp_script.h"
#include <mono/metadata/threads.h>
+#include <stdint.h>
#include "core/io/json.h"
#include "core/os/file_access.h"
@@ -161,11 +162,11 @@ void CSharpLanguage::finish() {
#ifdef DEBUG_ENABLED
for (Map<ObjectID, int>::Element *E = unsafe_object_references.front(); E; E = E->next()) {
- const ObjectID &id = E->get();
+ const ObjectID &id = E->key();
Object *obj = ObjectDB::get_instance(id);
if (obj) {
- ERR_PRINT("Leaked unsafe reference to object: " + obj->get_class() + ":" + itos(id));
+ ERR_PRINT("Leaked unsafe reference to object: " + obj->to_string());
} else {
ERR_PRINT("Leaked unsafe reference to deleted object: " + itos(id));
}
@@ -410,7 +411,7 @@ static String variant_type_to_managed_name(const String &p_var_type_name) {
if (p_var_type_name == Variant::get_type_name(Variant::OBJECT))
return "Godot.Object";
- if (p_var_type_name == Variant::get_type_name(Variant::REAL)) {
+ if (p_var_type_name == Variant::get_type_name(Variant::FLOAT)) {
#ifdef REAL_T_IS_DOUBLE
return "double";
#else
@@ -427,24 +428,24 @@ static String variant_type_to_managed_name(const String &p_var_type_name) {
if (p_var_type_name == Variant::get_type_name(Variant::ARRAY))
return "Collections.Array";
- if (p_var_type_name == Variant::get_type_name(Variant::POOL_BYTE_ARRAY))
+ if (p_var_type_name == Variant::get_type_name(Variant::PACKED_BYTE_ARRAY))
return "byte[]";
- if (p_var_type_name == Variant::get_type_name(Variant::POOL_INT_ARRAY))
+ if (p_var_type_name == Variant::get_type_name(Variant::PACKED_INT32_ARRAY))
return "int[]";
- if (p_var_type_name == Variant::get_type_name(Variant::POOL_REAL_ARRAY)) {
+ if (p_var_type_name == Variant::get_type_name(Variant::PACKED_FLOAT32_ARRAY)) {
#ifdef REAL_T_IS_DOUBLE
return "double[]";
#else
return "float[]";
#endif
}
- if (p_var_type_name == Variant::get_type_name(Variant::POOL_STRING_ARRAY))
+ if (p_var_type_name == Variant::get_type_name(Variant::PACKED_STRING_ARRAY))
return "string[]";
- if (p_var_type_name == Variant::get_type_name(Variant::POOL_VECTOR2_ARRAY))
+ if (p_var_type_name == Variant::get_type_name(Variant::PACKED_VECTOR2_ARRAY))
return "Vector2[]";
- if (p_var_type_name == Variant::get_type_name(Variant::POOL_VECTOR3_ARRAY))
+ if (p_var_type_name == Variant::get_type_name(Variant::PACKED_VECTOR3_ARRAY))
return "Vector3[]";
- if (p_var_type_name == Variant::get_type_name(Variant::POOL_COLOR_ARRAY))
+ if (p_var_type_name == Variant::get_type_name(Variant::PACKED_COLOR_ARRAY))
return "Color[]";
Variant::Type var_types[] = {
@@ -472,7 +473,7 @@ static String variant_type_to_managed_name(const String &p_var_type_name) {
return "object";
}
-String CSharpLanguage::make_function(const String &, const String &p_name, const PoolStringArray &p_args) const {
+String CSharpLanguage::make_function(const String &, const String &p_name, const PackedStringArray &p_args) const {
// FIXME
// - Due to Godot's API limitation this just appends the function to the end of the file
// - Use fully qualified name if there is ambiguity
@@ -490,7 +491,7 @@ String CSharpLanguage::make_function(const String &, const String &p_name, const
return s;
}
#else
-String CSharpLanguage::make_function(const String &, const String &, const PoolStringArray &) const {
+String CSharpLanguage::make_function(const String &, const String &, const PackedStringArray &) const {
return String();
}
#endif
@@ -853,7 +854,7 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) {
while (script->instances.front()) {
Object *obj = script->instances.front()->get();
- obj->set_script(RefPtr()); // Remove script and existing script instances (placeholder are not removed before domain reload)
+ obj->set_script(REF()); // Remove script and existing script instances (placeholder are not removed before domain reload)
}
script->_clear();
@@ -876,7 +877,7 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) {
// Use a placeholder for now to avoid losing the state when saving a scene
- obj->set_script(scr.get_ref_ptr());
+ obj->set_script(scr);
PlaceHolderScriptInstance *placeholder = scr->placeholder_instance_create(obj);
obj->set_script_instance(placeholder);
@@ -1002,7 +1003,7 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) {
CRASH_COND(si != NULL);
#endif
// Re-create script instance
- obj->set_script(script.get_ref_ptr()); // will create the script instance as well
+ obj->set_script(script); // will create the script instance as well
}
}
@@ -1719,7 +1720,7 @@ bool CSharpInstance::has_method(const StringName &p_method) const {
return false;
}
-Variant CSharpInstance::call(const StringName &p_method, const Variant **p_args, int p_argcount, Variant::CallError &r_error) {
+Variant CSharpInstance::call(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
ERR_FAIL_COND_V(!script.is_valid(), Variant());
@@ -1728,7 +1729,7 @@ Variant CSharpInstance::call(const StringName &p_method, const Variant **p_args,
MonoObject *mono_object = get_mono_object();
if (!mono_object) {
- r_error.error = Variant::CallError::CALL_ERROR_INSTANCE_IS_NULL;
+ r_error.error = Callable::CallError::CALL_ERROR_INSTANCE_IS_NULL;
ERR_FAIL_V(Variant());
}
@@ -1740,7 +1741,7 @@ Variant CSharpInstance::call(const StringName &p_method, const Variant **p_args,
if (method) {
MonoObject *return_value = method->invoke(mono_object, p_args);
- r_error.error = Variant::CallError::CALL_OK;
+ r_error.error = Callable::CallError::CALL_OK;
if (return_value) {
return GDMonoMarshal::mono_object_to_variant(return_value);
@@ -1752,7 +1753,7 @@ Variant CSharpInstance::call(const StringName &p_method, const Variant **p_args,
top = top->get_parent_class();
}
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
return Variant();
}
@@ -1979,67 +1980,44 @@ bool CSharpInstance::refcount_decremented() {
return ref_dying;
}
-MultiplayerAPI::RPCMode CSharpInstance::_member_get_rpc_mode(IMonoClassMember *p_member) const {
-
- if (p_member->has_attribute(CACHED_CLASS(RemoteAttribute)))
- return MultiplayerAPI::RPC_MODE_REMOTE;
- if (p_member->has_attribute(CACHED_CLASS(MasterAttribute)))
- return MultiplayerAPI::RPC_MODE_MASTER;
- if (p_member->has_attribute(CACHED_CLASS(PuppetAttribute)))
- return MultiplayerAPI::RPC_MODE_PUPPET;
- if (p_member->has_attribute(CACHED_CLASS(SlaveAttribute)))
- return MultiplayerAPI::RPC_MODE_PUPPET;
- if (p_member->has_attribute(CACHED_CLASS(RemoteSyncAttribute)))
- return MultiplayerAPI::RPC_MODE_REMOTESYNC;
- if (p_member->has_attribute(CACHED_CLASS(SyncAttribute)))
- return MultiplayerAPI::RPC_MODE_REMOTESYNC;
- if (p_member->has_attribute(CACHED_CLASS(MasterSyncAttribute)))
- return MultiplayerAPI::RPC_MODE_MASTERSYNC;
- if (p_member->has_attribute(CACHED_CLASS(PuppetSyncAttribute)))
- return MultiplayerAPI::RPC_MODE_PUPPETSYNC;
+Vector<ScriptNetData> CSharpInstance::get_rpc_methods() const {
+ return script->get_rpc_methods();
+}
- return MultiplayerAPI::RPC_MODE_DISABLED;
+uint16_t CSharpInstance::get_rpc_method_id(const StringName &p_method) const {
+ return script->get_rpc_method_id(p_method);
}
-MultiplayerAPI::RPCMode CSharpInstance::get_rpc_mode(const StringName &p_method) const {
+StringName CSharpInstance::get_rpc_method(const uint16_t p_rpc_method_id) const {
+ return script->get_rpc_method(p_rpc_method_id);
+}
- GD_MONO_SCOPE_THREAD_ATTACH;
+MultiplayerAPI::RPCMode CSharpInstance::get_rpc_mode_by_id(const uint16_t p_rpc_method_id) const {
+ return script->get_rpc_mode_by_id(p_rpc_method_id);
+}
- GDMonoClass *top = script->script_class;
+MultiplayerAPI::RPCMode CSharpInstance::get_rpc_mode(const StringName &p_method) const {
+ return script->get_rpc_mode(p_method);
+}
- while (top && top != script->native) {
- GDMonoMethod *method = top->get_fetched_method_unknown_params(p_method);
+Vector<ScriptNetData> CSharpInstance::get_rset_properties() const {
+ return script->get_rset_properties();
+}
- if (method && !method->is_static())
- return _member_get_rpc_mode(method);
+uint16_t CSharpInstance::get_rset_property_id(const StringName &p_variable) const {
+ return script->get_rset_property_id(p_variable);
+}
- top = top->get_parent_class();
- }
+StringName CSharpInstance::get_rset_property(const uint16_t p_rset_member_id) const {
+ return script->get_rset_property(p_rset_member_id);
+}
- return MultiplayerAPI::RPC_MODE_DISABLED;
+MultiplayerAPI::RPCMode CSharpInstance::get_rset_mode_by_id(const uint16_t p_rset_member_id) const {
+ return script->get_rset_mode_by_id(p_rset_member_id);
}
MultiplayerAPI::RPCMode CSharpInstance::get_rset_mode(const StringName &p_variable) const {
-
- GD_MONO_SCOPE_THREAD_ATTACH;
-
- GDMonoClass *top = script->script_class;
-
- while (top && top != script->native) {
- GDMonoField *field = top->get_field(p_variable);
-
- if (field && !field->is_static())
- return _member_get_rpc_mode(field);
-
- GDMonoProperty *property = top->get_property(p_variable);
-
- if (property && !property->is_static())
- return _member_get_rpc_mode(property);
-
- top = top->get_parent_class();
- }
-
- return MultiplayerAPI::RPC_MODE_DISABLED;
+ return script->get_rset_mode(p_variable);
}
void CSharpInstance::notification(int p_notification) {
@@ -2726,11 +2704,11 @@ void CSharpScript::_clear() {
script_class = NULL;
}
-Variant CSharpScript::call(const StringName &p_method, const Variant **p_args, int p_argcount, Variant::CallError &r_error) {
+Variant CSharpScript::call(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
if (unlikely(GDMono::get_singleton() == NULL)) {
// Probably not the best error but eh.
- r_error.error = Variant::CallError::CALL_ERROR_INSTANCE_IS_NULL;
+ r_error.error = Callable::CallError::CALL_ERROR_INSTANCE_IS_NULL;
return Variant();
}
@@ -2926,7 +2904,7 @@ StringName CSharpScript::get_instance_base_type() const {
return StringName();
}
-CSharpInstance *CSharpScript::_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, bool p_isref, Variant::CallError &r_error) {
+CSharpInstance *CSharpScript::_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, bool p_isref, Callable::CallError &r_error) {
GD_MONO_ASSERT_THREAD_ATTACHED;
@@ -2990,7 +2968,7 @@ CSharpInstance *CSharpScript::_create_instance(const Variant **p_args, int p_arg
CRASH_COND(die == true);
p_owner->set_script_instance(NULL);
- r_error.error = Variant::CallError::CALL_ERROR_INSTANCE_IS_NULL;
+ r_error.error = Callable::CallError::CALL_ERROR_INSTANCE_IS_NULL;
ERR_FAIL_V_MSG(NULL, "Failed to allocate memory for the object.");
}
@@ -3016,14 +2994,14 @@ CSharpInstance *CSharpScript::_create_instance(const Variant **p_args, int p_arg
return instance;
}
-Variant CSharpScript::_new(const Variant **p_args, int p_argcount, Variant::CallError &r_error) {
+Variant CSharpScript::_new(const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
if (!valid) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
return Variant();
}
- r_error.error = Variant::CallError::CALL_OK;
+ r_error.error = Callable::CallError::CALL_OK;
ERR_FAIL_NULL_V(native, Variant());
@@ -3071,7 +3049,7 @@ ScriptInstance *CSharpScript::instance_create(Object *p_this) {
GD_MONO_SCOPE_THREAD_ATTACH;
- Variant::CallError unchecked_error;
+ Callable::CallError unchecked_error;
return _create_instance(NULL, 0, p_this, Object::cast_to<Reference>(p_this) != NULL, unchecked_error);
}
@@ -3251,6 +3229,69 @@ Error CSharpScript::reload(bool p_keep_state) {
_update_exports();
}
+ rpc_functions.clear();
+ rpc_variables.clear();
+
+ GDMonoClass *top = script_class;
+ while (top && top != native) {
+ {
+ Vector<GDMonoMethod *> methods = top->get_all_methods();
+ for (int i = 0; i < methods.size(); i++) {
+ if (!methods[i]->is_static()) {
+ MultiplayerAPI::RPCMode mode = _member_get_rpc_mode(methods[i]);
+ if (MultiplayerAPI::RPC_MODE_DISABLED != mode) {
+ ScriptNetData nd;
+ nd.name = methods[i]->get_name();
+ nd.mode = mode;
+ if (-1 == rpc_functions.find(nd)) {
+ rpc_functions.push_back(nd);
+ }
+ }
+ }
+ }
+ }
+
+ {
+ Vector<GDMonoField *> fields = top->get_all_fields();
+ for (int i = 0; i < fields.size(); i++) {
+ if (!fields[i]->is_static()) {
+ MultiplayerAPI::RPCMode mode = _member_get_rpc_mode(fields[i]);
+ if (MultiplayerAPI::RPC_MODE_DISABLED != mode) {
+ ScriptNetData nd;
+ nd.name = fields[i]->get_name();
+ nd.mode = mode;
+ if (-1 == rpc_variables.find(nd)) {
+ rpc_variables.push_back(nd);
+ }
+ }
+ }
+ }
+ }
+
+ {
+ Vector<GDMonoProperty *> properties = top->get_all_properties();
+ for (int i = 0; i < properties.size(); i++) {
+ if (!properties[i]->is_static()) {
+ MultiplayerAPI::RPCMode mode = _member_get_rpc_mode(properties[i]);
+ if (MultiplayerAPI::RPC_MODE_DISABLED != mode) {
+ ScriptNetData nd;
+ nd.name = properties[i]->get_name();
+ nd.mode = mode;
+ if (-1 == rpc_variables.find(nd)) {
+ rpc_variables.push_back(nd);
+ }
+ }
+ }
+ }
+ }
+
+ top = top->get_parent_class();
+ }
+
+ // Sort so we are 100% that they are always the same.
+ rpc_functions.sort_custom<SortNetData>();
+ rpc_variables.sort_custom<SortNetData>();
+
return OK;
}
@@ -3324,6 +3365,78 @@ int CSharpScript::get_member_line(const StringName &p_member) const {
return -1;
}
+MultiplayerAPI::RPCMode CSharpScript::_member_get_rpc_mode(IMonoClassMember *p_member) const {
+
+ if (p_member->has_attribute(CACHED_CLASS(RemoteAttribute)))
+ return MultiplayerAPI::RPC_MODE_REMOTE;
+ if (p_member->has_attribute(CACHED_CLASS(MasterAttribute)))
+ return MultiplayerAPI::RPC_MODE_MASTER;
+ if (p_member->has_attribute(CACHED_CLASS(PuppetAttribute)))
+ return MultiplayerAPI::RPC_MODE_PUPPET;
+ if (p_member->has_attribute(CACHED_CLASS(RemoteSyncAttribute)))
+ return MultiplayerAPI::RPC_MODE_REMOTESYNC;
+ if (p_member->has_attribute(CACHED_CLASS(MasterSyncAttribute)))
+ return MultiplayerAPI::RPC_MODE_MASTERSYNC;
+ if (p_member->has_attribute(CACHED_CLASS(PuppetSyncAttribute)))
+ return MultiplayerAPI::RPC_MODE_PUPPETSYNC;
+
+ return MultiplayerAPI::RPC_MODE_DISABLED;
+}
+
+Vector<ScriptNetData> CSharpScript::get_rpc_methods() const {
+ return rpc_functions;
+}
+
+uint16_t CSharpScript::get_rpc_method_id(const StringName &p_method) const {
+ for (int i = 0; i < rpc_functions.size(); i++) {
+ if (rpc_functions[i].name == p_method) {
+ return i;
+ }
+ }
+ return UINT16_MAX;
+}
+
+StringName CSharpScript::get_rpc_method(const uint16_t p_rpc_method_id) const {
+ ERR_FAIL_COND_V(p_rpc_method_id >= rpc_functions.size(), StringName());
+ return rpc_functions[p_rpc_method_id].name;
+}
+
+MultiplayerAPI::RPCMode CSharpScript::get_rpc_mode_by_id(const uint16_t p_rpc_method_id) const {
+ ERR_FAIL_COND_V(p_rpc_method_id >= rpc_functions.size(), MultiplayerAPI::RPC_MODE_DISABLED);
+ return rpc_functions[p_rpc_method_id].mode;
+}
+
+MultiplayerAPI::RPCMode CSharpScript::get_rpc_mode(const StringName &p_method) const {
+ return get_rpc_mode_by_id(get_rpc_method_id(p_method));
+}
+
+Vector<ScriptNetData> CSharpScript::get_rset_properties() const {
+ return rpc_variables;
+}
+
+uint16_t CSharpScript::get_rset_property_id(const StringName &p_variable) const {
+ for (int i = 0; i < rpc_variables.size(); i++) {
+ if (rpc_variables[i].name == p_variable) {
+ return i;
+ }
+ }
+ return UINT16_MAX;
+}
+
+StringName CSharpScript::get_rset_property(const uint16_t p_rset_member_id) const {
+ ERR_FAIL_COND_V(p_rset_member_id >= rpc_variables.size(), StringName());
+ return rpc_variables[p_rset_member_id].name;
+}
+
+MultiplayerAPI::RPCMode CSharpScript::get_rset_mode_by_id(const uint16_t p_rset_member_id) const {
+ ERR_FAIL_COND_V(p_rset_member_id >= rpc_functions.size(), MultiplayerAPI::RPC_MODE_DISABLED);
+ return rpc_functions[p_rset_member_id].mode;
+}
+
+MultiplayerAPI::RPCMode CSharpScript::get_rset_mode(const StringName &p_variable) const {
+ return get_rset_mode_by_id(get_rset_property_id(p_variable));
+}
+
Error CSharpScript::load_source_code(const String &p_path) {
Error ferr = read_all_file_utf8(p_path, source);
diff --git a/modules/mono/csharp_script.h b/modules/mono/csharp_script.h
index f244bc4119..627218eaf5 100644
--- a/modules/mono/csharp_script.h
+++ b/modules/mono/csharp_script.h
@@ -113,6 +113,9 @@ class CSharpScript : public Script {
Map<StringName, Vector<Argument> > _signals;
bool signals_invalidated;
+ Vector<ScriptNetData> rpc_functions;
+ Vector<ScriptNetData> rpc_variables;
+
#ifdef TOOLS_ENABLED
List<PropertyInfo> exported_members_cache; // members_cache
Map<StringName, Variant> exported_members_defval_cache; // member_default_values_cache
@@ -138,18 +141,20 @@ class CSharpScript : public Script {
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, Variant::CallError &r_error);
- Variant _new(const Variant **p_args, int p_argcount, Variant::CallError &r_error);
+ CSharpInstance *_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, bool p_isref, 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
friend void GDMonoInternals::tie_managed_to_unmanaged(MonoObject *, Object *);
static Ref<CSharpScript> create_for_managed_type(GDMonoClass *p_class, GDMonoClass *p_native);
static void initialize_for_managed_type(Ref<CSharpScript> p_script, GDMonoClass *p_class, GDMonoClass *p_native);
+ MultiplayerAPI::RPCMode _member_get_rpc_mode(IMonoClassMember *p_member) const;
+
protected:
static void _bind_methods();
- Variant call(const StringName &p_method, const Variant **p_args, int p_argcount, Variant::CallError &r_error);
+ Variant call(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error);
virtual void _resource_path_changed();
bool _get(const StringName &p_name, Variant &r_ret) const;
bool _set(const StringName &p_name, const Variant &p_value);
@@ -187,6 +192,18 @@ public:
virtual int get_member_line(const StringName &p_member) const;
+ virtual Vector<ScriptNetData> get_rpc_methods() const;
+ virtual uint16_t get_rpc_method_id(const StringName &p_method) const;
+ virtual StringName get_rpc_method(const uint16_t p_rpc_method_id) const;
+ virtual MultiplayerAPI::RPCMode get_rpc_mode_by_id(const uint16_t p_rpc_method_id) const;
+ virtual MultiplayerAPI::RPCMode get_rpc_mode(const StringName &p_method) const;
+
+ virtual Vector<ScriptNetData> get_rset_properties() const;
+ virtual uint16_t get_rset_property_id(const StringName &p_variable) const;
+ virtual StringName get_rset_property(const uint16_t p_variable_id) const;
+ virtual MultiplayerAPI::RPCMode get_rset_mode_by_id(const uint16_t p_variable_id) const;
+ virtual MultiplayerAPI::RPCMode get_rset_mode(const StringName &p_variable) const;
+
#ifdef TOOLS_ENABLED
virtual bool is_placeholder_fallback_enabled() const { return placeholder_fallback_enabled; }
#endif
@@ -232,8 +249,6 @@ class CSharpInstance : public ScriptInstance {
void _call_multilevel(MonoObject *p_mono_object, const StringName &p_method, const Variant **p_args, int p_argcount);
- MultiplayerAPI::RPCMode _member_get_rpc_mode(IMonoClassMember *p_member) const;
-
void get_properties_state_for_reloading(List<Pair<StringName, Variant> > &r_state);
public:
@@ -250,7 +265,7 @@ public:
/* TODO */ virtual void get_method_list(List<MethodInfo> *p_list) const {}
virtual bool has_method(const StringName &p_method) const;
- virtual Variant call(const StringName &p_method, const Variant **p_args, int p_argcount, Variant::CallError &r_error);
+ virtual Variant call(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error);
virtual void call_multilevel(const StringName &p_method, const Variant **p_args, int p_argcount);
virtual void call_multilevel_reversed(const StringName &p_method, const Variant **p_args, int p_argcount);
@@ -265,7 +280,16 @@ public:
virtual void refcount_incremented();
virtual bool refcount_decremented();
+ virtual Vector<ScriptNetData> get_rpc_methods() const;
+ virtual uint16_t get_rpc_method_id(const StringName &p_method) const;
+ virtual StringName get_rpc_method(const uint16_t p_rpc_method_id) const;
+ virtual MultiplayerAPI::RPCMode get_rpc_mode_by_id(const uint16_t p_rpc_method_id) const;
virtual MultiplayerAPI::RPCMode get_rpc_mode(const StringName &p_method) const;
+
+ virtual Vector<ScriptNetData> get_rset_properties() const;
+ virtual uint16_t get_rset_property_id(const StringName &p_variable) const;
+ virtual StringName get_rset_property(const uint16_t p_variable_id) const;
+ virtual MultiplayerAPI::RPCMode get_rset_mode_by_id(const uint16_t p_variable_id) const;
virtual MultiplayerAPI::RPCMode get_rset_mode(const StringName &p_variable) const;
virtual void notification(int p_notification);
@@ -408,7 +432,7 @@ public:
virtual bool has_named_classes() const;
virtual bool supports_builtin_mode() const;
/* TODO? */ virtual int find_function(const String &p_function, const String &p_code) const { return -1; }
- virtual String make_function(const String &p_class, const String &p_name, const PoolStringArray &p_args) const;
+ virtual String make_function(const String &p_class, const String &p_name, const PackedStringArray &p_args) const;
virtual String _get_indentation() const;
/* TODO? */ virtual void auto_indent_code(String &p_code, int p_from_line, int p_to_line) const {}
/* TODO */ virtual void add_global_constant(const StringName &p_variable, const Variant &p_value) {}
diff --git a/modules/mono/doc_classes/@C#.xml b/modules/mono/doc_classes/@C#.xml
index 826c106d7e..83a7fbf02c 100644
--- a/modules/mono/doc_classes/@C#.xml
+++ b/modules/mono/doc_classes/@C#.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="@C#" category="Core" version="3.2">
+<class name="@C#" version="4.0">
<brief_description>
</brief_description>
<description>
diff --git a/modules/mono/doc_classes/CSharpScript.xml b/modules/mono/doc_classes/CSharpScript.xml
index de2e246ea9..1eb3404f9e 100644
--- a/modules/mono/doc_classes/CSharpScript.xml
+++ b/modules/mono/doc_classes/CSharpScript.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="CSharpScript" inherits="Script" category="Core" version="3.2">
+<class name="CSharpScript" inherits="Script" version="4.0">
<brief_description>
</brief_description>
<description>
@@ -8,7 +8,7 @@
</tutorials>
<methods>
<method name="new" qualifiers="vararg">
- <return type="Object">
+ <return type="Variant">
</return>
<description>
</description>
diff --git a/modules/mono/doc_classes/GodotSharp.xml b/modules/mono/doc_classes/GodotSharp.xml
index 18556a84ba..19a08d2036 100644
--- a/modules/mono/doc_classes/GodotSharp.xml
+++ b/modules/mono/doc_classes/GodotSharp.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="GodotSharp" inherits="Object" category="Core" version="3.2">
+<class name="GodotSharp" inherits="Object" version="4.0">
<brief_description>
</brief_description>
<description>
diff --git a/modules/mono/editor/GodotTools/GodotTools/BottomPanel.cs b/modules/mono/editor/GodotTools/GodotTools/BottomPanel.cs
index 4c76d2abf1..bd7eb59913 100644
--- a/modules/mono/editor/GodotTools/GodotTools/BottomPanel.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/BottomPanel.cs
@@ -172,7 +172,7 @@ namespace GodotTools
return;
// Notify running game for hot-reload
- Internal.ScriptEditorDebuggerReloadScripts();
+ Internal.EditorDebuggerNodeReloadScripts();
// Hot-reload in the editor
GodotSharpEditor.Instance.GetNode<HotReloadAssemblyWatcher>("HotReloadAssemblyWatcher").RestartTimer();
diff --git a/modules/mono/editor/GodotTools/GodotTools/BuildTab.cs b/modules/mono/editor/GodotTools/GodotTools/BuildTab.cs
index 727581daab..f75fe239e3 100644
--- a/modules/mono/editor/GodotTools/GodotTools/BuildTab.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/BuildTab.cs
@@ -41,7 +41,7 @@ namespace GodotTools
public bool ErrorsVisible { get; set; } = true;
public bool WarningsVisible { get; set; } = true;
- public Texture IconTexture
+ public Texture2D IconTexture
{
get
{
diff --git a/modules/mono/editor/GodotTools/GodotTools/Internals/Internal.cs b/modules/mono/editor/GodotTools/GodotTools/Internals/Internal.cs
index de361ba844..2e121ba879 100644
--- a/modules/mono/editor/GodotTools/GodotTools/Internals/Internal.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/Internals/Internal.cs
@@ -34,7 +34,7 @@ namespace GodotTools.Internals
public static void ReloadAssemblies(bool softReload) => internal_ReloadAssemblies(softReload);
- public static void ScriptEditorDebuggerReloadScripts() => internal_ScriptEditorDebuggerReloadScripts();
+ public static void EditorDebuggerNodeReloadScripts() => internal_EditorDebuggerNodeReloadScripts();
public static bool ScriptEditorEdit(Resource resource, int line, int col, bool grabFocus = true) =>
internal_ScriptEditorEdit(resource, line, col, grabFocus);
@@ -88,7 +88,7 @@ namespace GodotTools.Internals
private static extern void internal_ReloadAssemblies(bool softReload);
[MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void internal_ScriptEditorDebuggerReloadScripts();
+ private static extern void internal_EditorDebuggerNodeReloadScripts();
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern bool internal_ScriptEditorEdit(Resource resource, int line, int col, bool grabFocus);
diff --git a/modules/mono/editor/bindings_generator.cpp b/modules/mono/editor/bindings_generator.cpp
index 34f01ce3c6..908c72c591 100644
--- a/modules/mono/editor/bindings_generator.cpp
+++ b/modules/mono/editor/bindings_generator.cpp
@@ -503,23 +503,23 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf
xml_output.append("<c>");
xml_output.append(tag);
xml_output.append("</c>");
- } else if (tag == "PoolByteArray") {
+ } else if (tag == "PackedByteArray") {
xml_output.append("<see cref=\"byte\"/>");
- } else if (tag == "PoolIntArray") {
+ } else if (tag == "PackedInt32Array") {
xml_output.append("<see cref=\"int\"/>");
- } else if (tag == "PoolRealArray") {
+ } else if (tag == "PackedFloat32Array") {
#ifdef REAL_T_IS_DOUBLE
xml_output.append("<see cref=\"double\"/>");
#else
xml_output.append("<see cref=\"float\"/>");
#endif
- } else if (tag == "PoolStringArray") {
+ } else if (tag == "PackedStringArray") {
xml_output.append("<see cref=\"string\"/>");
- } else if (tag == "PoolVector2Array") {
+ } else if (tag == "PackedVector2Array") {
xml_output.append("<see cref=\"" BINDINGS_NAMESPACE ".Vector2\"/>");
- } else if (tag == "PoolVector3Array") {
+ } else if (tag == "PackedVector3Array") {
xml_output.append("<see cref=\"" BINDINGS_NAMESPACE ".Vector3\"/>");
- } else if (tag == "PoolColorArray") {
+ } else if (tag == "PackedColorArray") {
xml_output.append("<see cref=\"" BINDINGS_NAMESPACE ".Color\"/>");
} else {
const TypeInterface *target_itype = _get_type_or_null(TypeReference(tag));
@@ -2054,7 +2054,7 @@ Error BindingsGenerator::_generate_glue_method(const BindingsGenerator::TypeInte
}
if (p_imethod.is_vararg) {
- p_output.append("\tVariant::CallError vcall_error;\n\t");
+ p_output.append("\tCallable::CallError vcall_error;\n\t");
if (!ret_void) {
// See the comment on the C_LOCAL_VARARG_RET declaration
@@ -2383,7 +2383,7 @@ bool BindingsGenerator::_populate_object_type_interfaces() {
} else {
if (return_info.type == Variant::INT) {
imethod.return_type.cname = _get_int_type_name_from_meta(m ? m->get_argument_meta(-1) : GodotTypeInfo::METADATA_NONE);
- } else if (return_info.type == Variant::REAL) {
+ } else if (return_info.type == Variant::FLOAT) {
imethod.return_type.cname = _get_float_type_name_from_meta(m ? m->get_argument_meta(-1) : GodotTypeInfo::METADATA_NONE);
} else {
imethod.return_type.cname = Variant::get_type_name(return_info.type);
@@ -2410,7 +2410,7 @@ bool BindingsGenerator::_populate_object_type_interfaces() {
} else {
if (arginfo.type == Variant::INT) {
iarg.type.cname = _get_int_type_name_from_meta(m ? m->get_argument_meta(i) : GodotTypeInfo::METADATA_NONE);
- } else if (arginfo.type == Variant::REAL) {
+ } else if (arginfo.type == Variant::FLOAT) {
iarg.type.cname = _get_float_type_name_from_meta(m ? m->get_argument_meta(i) : GodotTypeInfo::METADATA_NONE);
} else {
iarg.type.cname = Variant::get_type_name(arginfo.type);
@@ -2581,7 +2581,7 @@ bool BindingsGenerator::_arg_default_value_from_variant(const Variant &p_val, Ar
r_iarg.default_argument = "(%s)" + r_iarg.default_argument;
}
break;
- case Variant::REAL:
+ case Variant::FLOAT:
#ifndef REAL_T_IS_DOUBLE
r_iarg.default_argument += "f";
#endif
@@ -2628,13 +2628,15 @@ bool BindingsGenerator::_arg_default_value_from_variant(const Variant &p_val, Ar
r_iarg.default_argument = "null";
break;
case Variant::ARRAY:
- case Variant::POOL_BYTE_ARRAY:
- case Variant::POOL_INT_ARRAY:
- case Variant::POOL_REAL_ARRAY:
- case Variant::POOL_STRING_ARRAY:
- case Variant::POOL_VECTOR2_ARRAY:
- case Variant::POOL_VECTOR3_ARRAY:
- case Variant::POOL_COLOR_ARRAY:
+ case Variant::PACKED_BYTE_ARRAY:
+ case Variant::PACKED_INT32_ARRAY:
+ case Variant::PACKED_FLOAT32_ARRAY:
+ case Variant::PACKED_INT64_ARRAY:
+ case Variant::PACKED_FLOAT64_ARRAY:
+ case Variant::PACKED_STRING_ARRAY:
+ case Variant::PACKED_VECTOR2_ARRAY:
+ case Variant::PACKED_VECTOR3_ARRAY:
+ case Variant::PACKED_COLOR_ARRAY:
r_iarg.default_argument = "new %s {}";
r_iarg.def_param_mode = ArgumentInterface::NULLABLE_REF;
break;
@@ -2914,20 +2916,20 @@ void BindingsGenerator::_populate_builtin_type_interfaces() {
#define INSERT_ARRAY(m_type, m_proxy_t) INSERT_ARRAY_FULL(m_type, m_type, m_proxy_t)
- INSERT_ARRAY(PoolIntArray, int);
- INSERT_ARRAY_FULL(PoolByteArray, PoolByteArray, byte);
+ INSERT_ARRAY(PackedInt32Array, int);
+ INSERT_ARRAY_FULL(PackedByteArray, PackedByteArray, byte);
#ifdef REAL_T_IS_DOUBLE
- INSERT_ARRAY(PoolRealArray, double);
+ INSERT_ARRAY(PackedFloat32Array, double);
#else
- INSERT_ARRAY(PoolRealArray, float);
+ INSERT_ARRAY(PackedFloat32Array, float);
#endif
- INSERT_ARRAY(PoolStringArray, string);
+ INSERT_ARRAY(PackedStringArray, string);
- INSERT_ARRAY(PoolColorArray, Color);
- INSERT_ARRAY(PoolVector2Array, Vector2);
- INSERT_ARRAY(PoolVector3Array, Vector3);
+ INSERT_ARRAY(PackedColorArray, Color);
+ INSERT_ARRAY(PackedVector2Array, Vector2);
+ INSERT_ARRAY(PackedVector3Array, Vector3);
#undef INSERT_ARRAY
diff --git a/modules/mono/editor/editor_internal_calls.cpp b/modules/mono/editor/editor_internal_calls.cpp
index c8d20e80be..31996a03d0 100644
--- a/modules/mono/editor/editor_internal_calls.cpp
+++ b/modules/mono/editor/editor_internal_calls.cpp
@@ -36,10 +36,10 @@
#include "core/os/os.h"
#include "core/version.h"
+#include "editor/debugger/editor_debugger_node.h"
#include "editor/editor_node.h"
#include "editor/editor_scale.h"
#include "editor/plugins/script_editor_plugin.h"
-#include "editor/script_editor_debugger.h"
#include "main/main.h"
#include "../csharp_script.h"
@@ -305,8 +305,8 @@ void godot_icall_Internal_ReloadAssemblies(MonoBoolean p_soft_reload) {
#endif
}
-void godot_icall_Internal_ScriptEditorDebuggerReloadScripts() {
- ScriptEditor::get_singleton()->get_debugger()->reload_scripts();
+void godot_icall_Internal_EditorDebuggerNodeReloadScripts() {
+ EditorDebuggerNode::get_singleton()->reload_scripts();
}
MonoBoolean godot_icall_Internal_ScriptEditorEdit(MonoObject *p_resource, int32_t p_line, int32_t p_col, MonoBoolean p_grab_focus) {
@@ -348,9 +348,9 @@ void godot_icall_Internal_EditorRunStop() {
}
void godot_icall_Internal_ScriptEditorDebugger_ReloadScripts() {
- ScriptEditorDebugger *sed = ScriptEditor::get_singleton()->get_debugger();
- if (sed) {
- sed->reload_scripts();
+ EditorDebuggerNode *ed = EditorDebuggerNode::get_singleton();
+ if (ed) {
+ ed->reload_scripts();
}
}
@@ -446,7 +446,7 @@ void register_editor_internal_calls() {
mono_add_internal_call("GodotTools.Internals.Internal::internal_GetEditorApiHash", (void *)godot_icall_Internal_GetEditorApiHash);
mono_add_internal_call("GodotTools.Internals.Internal::internal_IsAssembliesReloadingNeeded", (void *)godot_icall_Internal_IsAssembliesReloadingNeeded);
mono_add_internal_call("GodotTools.Internals.Internal::internal_ReloadAssemblies", (void *)godot_icall_Internal_ReloadAssemblies);
- mono_add_internal_call("GodotTools.Internals.Internal::internal_ScriptEditorDebuggerReloadScripts", (void *)godot_icall_Internal_ScriptEditorDebuggerReloadScripts);
+ mono_add_internal_call("GodotTools.Internals.Internal::internal_EditorDebuggerNodeReloadScripts", (void *)godot_icall_Internal_EditorDebuggerNodeReloadScripts);
mono_add_internal_call("GodotTools.Internals.Internal::internal_ScriptEditorEdit", (void *)godot_icall_Internal_ScriptEditorEdit);
mono_add_internal_call("GodotTools.Internals.Internal::internal_EditorNodeShowScriptScreen", (void *)godot_icall_Internal_EditorNodeShowScriptScreen);
mono_add_internal_call("GodotTools.Internals.Internal::internal_GetScriptsMetadataOrNothing", (void *)godot_icall_Internal_GetScriptsMetadataOrNothing);
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/RPCAttributes.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/RPCAttributes.cs
index 1bf6d5199a..8fc430b6bc 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/RPCAttributes.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/RPCAttributes.cs
@@ -6,18 +6,12 @@ namespace Godot
public class RemoteAttribute : Attribute {}
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Field | AttributeTargets.Property)]
- public class SyncAttribute : Attribute {}
-
- [AttributeUsage(AttributeTargets.Method | AttributeTargets.Field | AttributeTargets.Property)]
public class MasterAttribute : Attribute {}
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Field | AttributeTargets.Property)]
public class PuppetAttribute : Attribute {}
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Field | AttributeTargets.Property)]
- public class SlaveAttribute : Attribute {}
-
- [AttributeUsage(AttributeTargets.Method | AttributeTargets.Field | AttributeTargets.Property)]
public class RemoteSyncAttribute : Attribute {}
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Field | AttributeTargets.Property)]
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Basis.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Basis.cs
index d38589013e..baf470a0cc 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Basis.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Basis.cs
@@ -93,11 +93,15 @@ namespace Godot
}
}
- public Vector3 this[int columnIndex]
+ /// <summary>
+ /// Access whole columns in the form of Vector3.
+ /// </summary>
+ /// <param name="column">Which column vector.</param>
+ public Vector3 this[int column]
{
get
{
- switch (columnIndex)
+ switch (column)
{
case 0:
return Column0;
@@ -111,7 +115,7 @@ namespace Godot
}
set
{
- switch (columnIndex)
+ switch (column)
{
case 0:
Column0 = value;
@@ -128,50 +132,22 @@ namespace Godot
}
}
- public real_t this[int columnIndex, int rowIndex]
+ /// <summary>
+ /// Access matrix elements in column-major order.
+ /// </summary>
+ /// <param name="column">Which column, the matrix horizontal position.</param>
+ /// <param name="row">Which row, the matrix vertical position.</param>
+ public real_t this[int column, int row]
{
get
{
- switch (columnIndex)
- {
- case 0:
- return Column0[rowIndex];
- case 1:
- return Column1[rowIndex];
- case 2:
- return Column2[rowIndex];
- default:
- throw new IndexOutOfRangeException();
- }
+ return this[column][row];
}
set
{
- switch (columnIndex)
- {
- case 0:
- {
- var column0 = Column0;
- column0[rowIndex] = value;
- Column0 = column0;
- return;
- }
- case 1:
- {
- var column1 = Column1;
- column1[rowIndex] = value;
- Column1 = column1;
- return;
- }
- case 2:
- {
- var column2 = Column2;
- column2[rowIndex] = value;
- Column2 = column2;
- return;
- }
- default:
- throw new IndexOutOfRangeException();
- }
+ Vector3 columnVector = this[column];
+ columnVector[row] = value;
+ this[column] = columnVector;
}
}
@@ -290,12 +266,6 @@ namespace Godot
this[index] = value;
}
- [Obsolete("GetAxis is deprecated. Use GetColumn instead.")]
- public Vector3 GetAxis(int axis)
- {
- return new Vector3(this.Row0[axis], this.Row1[axis], this.Row2[axis]);
- }
-
public int GetOrthogonalIndex()
{
var orth = this;
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Mathf.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Mathf.cs
index ddfed180b5..4f7aa99df8 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Mathf.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Mathf.cs
@@ -130,7 +130,7 @@ namespace Godot
public static real_t InverseLerp(real_t from, real_t to, real_t weight)
{
- return (weight - from) / (to - from);
+ return (weight - from) / (to - from);
}
public static bool IsEqualApprox(real_t a, real_t b)
@@ -151,12 +151,12 @@ namespace Godot
public static bool IsInf(real_t s)
{
- return real_t.IsInfinity(s);
+ return real_t.IsInfinity(s);
}
public static bool IsNaN(real_t s)
{
- return real_t.IsNaN(s);
+ return real_t.IsNaN(s);
}
public static bool IsZeroApprox(real_t s)
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Quat.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Quat.cs
index 6702634c51..bbc617ea6e 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Quat.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Quat.cs
@@ -104,33 +104,6 @@ namespace Godot
return this / Length;
}
- [Obsolete("Set is deprecated. Use the Quat(" + nameof(real_t) + ", " + nameof(real_t) + ", " + nameof(real_t) + ", " + nameof(real_t) + ") constructor instead.", error: true)]
- public void Set(real_t x, real_t y, real_t z, real_t w)
- {
- this.x = x;
- this.y = y;
- this.z = z;
- this.w = w;
- }
-
- [Obsolete("Set is deprecated. Use the Quat(" + nameof(Quat) + ") constructor instead.", error: true)]
- public void Set(Quat q)
- {
- this = q;
- }
-
- [Obsolete("SetAxisAngle is deprecated. Use the Quat(" + nameof(Vector3) + ", " + nameof(real_t) + ") constructor instead.", error: true)]
- public void SetAxisAngle(Vector3 axis, real_t angle)
- {
- this = new Quat(axis, angle);
- }
-
- [Obsolete("SetEuler is deprecated. Use the Quat(" + nameof(Vector3) + ") constructor instead.", error: true)]
- public void SetEuler(Vector3 eulerYXZ)
- {
- this = new Quat(eulerYXZ);
- }
-
public Quat Slerp(Quat b, real_t t)
{
#if DEBUG
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs
index e096d37a6f..099eacd7dd 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs
@@ -264,7 +264,8 @@ namespace Godot
instanceIndex++;
toIndex++;
}
- } else
+ }
+ else
{
while (true)
{
@@ -980,7 +981,7 @@ namespace Godot
}
// <summary>
- // Convert the String (which is a character array) to PoolByteArray (which is an array of bytes). The conversion is speeded up in comparison to to_utf8() with the assumption that all the characters the String contains are only ASCII characters.
+ // Convert the String (which is a character array) to PackedByteArray (which is an array of bytes). The conversion is speeded up in comparison to to_utf8() with the assumption that all the characters the String contains are only ASCII characters.
// </summary>
public static byte[] ToAscii(this string instance)
{
@@ -1020,7 +1021,7 @@ namespace Godot
}
// <summary>
- // Convert the String (which is an array of characters) to PoolByteArray (which is an array of bytes). The conversion is a bit slower than to_ascii(), but supports all UTF-8 characters. Therefore, you should prefer this function over to_ascii().
+ // Convert the String (which is an array of characters) to PackedByteArray (which is an array of bytes). The conversion is a bit slower than to_ascii(), but supports all UTF-8 characters. Therefore, you should prefer this function over to_ascii().
// </summary>
public static byte[] ToUTF8(this string instance)
{
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform.cs
index 0b84050f07..aa8815d1aa 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform.cs
@@ -15,6 +15,76 @@ namespace Godot
public Basis basis;
public Vector3 origin;
+ /// <summary>
+ /// Access whole columns in the form of Vector3. The fourth column is the origin vector.
+ /// </summary>
+ /// <param name="column">Which column vector.</param>
+ public Vector3 this[int column]
+ {
+ get
+ {
+ switch (column)
+ {
+ case 0:
+ return basis.Column0;
+ case 1:
+ return basis.Column1;
+ case 2:
+ return basis.Column2;
+ case 3:
+ return origin;
+ default:
+ throw new IndexOutOfRangeException();
+ }
+ }
+ set
+ {
+ switch (column)
+ {
+ case 0:
+ basis.Column0 = value;
+ return;
+ case 1:
+ basis.Column1 = value;
+ return;
+ case 2:
+ basis.Column2 = value;
+ return;
+ case 3:
+ origin = value;
+ return;
+ default:
+ throw new IndexOutOfRangeException();
+ }
+ }
+ }
+
+ /// <summary>
+ /// Access matrix elements in column-major order. The fourth column is the origin vector.
+ /// </summary>
+ /// <param name="column">Which column, the matrix horizontal position.</param>
+ /// <param name="row">Which row, the matrix vertical position.</param>
+ public real_t this[int column, int row]
+ {
+ get
+ {
+ if (column == 3)
+ {
+ return origin[row];
+ }
+ return basis[column, row];
+ }
+ set
+ {
+ if (column == 3)
+ {
+ origin[row] = value;
+ return;
+ }
+ basis[column, row] = value;
+ }
+ }
+
public Transform AffineInverse()
{
Basis basisInv = basis.Inverse();
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform2D.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform2D.cs
index 77ea3e5830..e72a44809a 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform2D.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform2D.cs
@@ -54,11 +54,15 @@ namespace Godot
}
}
- public Vector2 this[int rowIndex]
+ /// <summary>
+ /// Access whole columns in the form of Vector2. The third column is the origin vector.
+ /// </summary>
+ /// <param name="column">Which column vector.</param>
+ public Vector2 this[int column]
{
get
{
- switch (rowIndex)
+ switch (column)
{
case 0:
return x;
@@ -72,7 +76,7 @@ namespace Godot
}
set
{
- switch (rowIndex)
+ switch (column)
{
case 0:
x = value;
@@ -89,38 +93,22 @@ namespace Godot
}
}
- public real_t this[int rowIndex, int columnIndex]
+ /// <summary>
+ /// Access matrix elements in column-major order. The third column is the origin vector.
+ /// </summary>
+ /// <param name="column">Which column, the matrix horizontal position.</param>
+ /// <param name="row">Which row, the matrix vertical position.</param>
+ public real_t this[int column, int row]
{
get
{
- switch (rowIndex)
- {
- case 0:
- return x[columnIndex];
- case 1:
- return y[columnIndex];
- case 2:
- return origin[columnIndex];
- default:
- throw new IndexOutOfRangeException();
- }
+ return this[column][row];
}
set
{
- switch (rowIndex)
- {
- case 0:
- x[columnIndex] = value;
- return;
- case 1:
- y[columnIndex] = value;
- return;
- case 2:
- origin[columnIndex] = value;
- return;
- default:
- throw new IndexOutOfRangeException();
- }
+ Vector2 columnVector = this[column];
+ columnVector[row] = value;
+ this[column] = columnVector;
}
}
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs
index f92453f546..385bfed122 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs
@@ -248,19 +248,6 @@ namespace Godot
return new Vector2(Mathf.Round(x), Mathf.Round(y));
}
- [Obsolete("Set is deprecated. Use the Vector2(" + nameof(real_t) + ", " + nameof(real_t) + ") constructor instead.", error: true)]
- public void Set(real_t x, real_t y)
- {
- this.x = x;
- this.y = y;
- }
- [Obsolete("Set is deprecated. Use the Vector2(" + nameof(Vector2) + ") constructor instead.", error: true)]
- public void Set(Vector2 v)
- {
- x = v.x;
- y = v.y;
- }
-
public Vector2 Sign()
{
Vector2 v;
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs
index fded34002d..390036c654 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs
@@ -270,21 +270,6 @@ namespace Godot
return new Basis(axis, phi).Xform(this);
}
- [Obsolete("Set is deprecated. Use the Vector3(" + nameof(real_t) + ", " + nameof(real_t) + ", " + nameof(real_t) + ") constructor instead.", error: true)]
- public void Set(real_t x, real_t y, real_t z)
- {
- this.x = x;
- this.y = y;
- this.z = z;
- }
- [Obsolete("Set is deprecated. Use the Vector3(" + nameof(Vector3) + ") constructor instead.", error: true)]
- public void Set(Vector3 v)
- {
- x = v.x;
- y = v.y;
- z = v.z;
- }
-
public Vector3 Sign()
{
Vector3 v;
diff --git a/modules/mono/glue/base_object_glue.cpp b/modules/mono/glue/base_object_glue.cpp
index 02246b2f2f..8c77220b85 100644
--- a/modules/mono/glue/base_object_glue.cpp
+++ b/modules/mono/glue/base_object_glue.cpp
@@ -189,12 +189,12 @@ MonoBoolean godot_icall_DynamicGodotObject_InvokeMember(Object *p_ptr, MonoStrin
args.set(i, &arg_store.get(i));
}
- Variant::CallError error;
+ Callable::CallError error;
Variant result = p_ptr->call(StringName(name), args.ptr(), argc, error);
*r_result = GDMonoMarshal::variant_to_mono_object(result);
- return error.error == Variant::CallError::CALL_OK;
+ return error.error == Callable::CallError::CALL_OK;
}
MonoBoolean godot_icall_DynamicGodotObject_GetMember(Object *p_ptr, MonoString *p_name, MonoObject **r_result) {
@@ -224,14 +224,9 @@ MonoString *godot_icall_Object_ToString(Object *p_ptr) {
#ifdef DEBUG_ENABLED
// Cannot happen in C#; would get an ObjectDisposedException instead.
CRASH_COND(p_ptr == NULL);
-
- if (ScriptDebugger::get_singleton() && !Object::cast_to<Reference>(p_ptr)) { // Only if debugging!
- // Cannot happen either in C#; the handle is nullified when the object is destroyed
- CRASH_COND(!ObjectDB::instance_validate(p_ptr));
- }
#endif
- String result = "[" + p_ptr->get_class() + ":" + itos(p_ptr->get_instance_id()) + "]";
+ String result = p_ptr->to_string();
return GDMonoMarshal::mono_string_from_godot(result);
}
diff --git a/modules/mono/glue/gd_glue.cpp b/modules/mono/glue/gd_glue.cpp
index 17483c4457..cdacd90538 100644
--- a/modules/mono/glue/gd_glue.cpp
+++ b/modules/mono/glue/gd_glue.cpp
@@ -44,9 +44,8 @@
MonoObject *godot_icall_GD_bytes2var(MonoArray *p_bytes, MonoBoolean p_allow_objects) {
Variant ret;
- PoolByteArray varr = GDMonoMarshal::mono_array_to_PoolByteArray(p_bytes);
- PoolByteArray::Read r = varr.read();
- Error err = decode_variant(ret, r.ptr(), varr.size(), NULL, p_allow_objects);
+ PackedByteArray varr = GDMonoMarshal::mono_array_to_PackedByteArray(p_bytes);
+ Error err = decode_variant(ret, varr.ptr(), varr.size(), NULL, p_allow_objects);
if (err != OK) {
ret = RTR("Not enough bytes for decoding bytes, or invalid format.");
}
@@ -56,9 +55,9 @@ MonoObject *godot_icall_GD_bytes2var(MonoArray *p_bytes, MonoBoolean p_allow_obj
MonoObject *godot_icall_GD_convert(MonoObject *p_what, int32_t p_type) {
Variant what = GDMonoMarshal::mono_object_to_variant(p_what);
const Variant *args[1] = { &what };
- Variant::CallError ce;
+ Callable::CallError ce;
Variant ret = Variant::construct(Variant::Type(p_type), args, 1, ce);
- ERR_FAIL_COND_V(ce.error != Variant::CallError::CALL_OK, NULL);
+ ERR_FAIL_COND_V(ce.error != Callable::CallError::CALL_OK, NULL);
return GDMonoMarshal::variant_to_mono_object(ret);
}
@@ -67,7 +66,7 @@ int godot_icall_GD_hash(MonoObject *p_var) {
}
MonoObject *godot_icall_GD_instance_from_id(uint64_t p_instance_id) {
- return GDMonoUtils::unmanaged_get_managed(ObjectDB::get_instance(p_instance_id));
+ return GDMonoUtils::unmanaged_get_managed(ObjectDB::get_instance(ObjectID(p_instance_id)));
}
void godot_icall_GD_print(MonoArray *p_what) {
@@ -257,18 +256,15 @@ void godot_icall_GD_pushwarning(MonoString *p_str) {
MonoArray *godot_icall_GD_var2bytes(MonoObject *p_var, MonoBoolean p_full_objects) {
Variant var = GDMonoMarshal::mono_object_to_variant(p_var);
- PoolByteArray barr;
+ PackedByteArray barr;
int len;
Error err = encode_variant(var, NULL, len, p_full_objects);
ERR_FAIL_COND_V_MSG(err != OK, NULL, "Unexpected error encoding variable to bytes, likely unserializable type found (Object or RID).");
barr.resize(len);
- {
- PoolByteArray::Write w = barr.write();
- encode_variant(var, w.ptr(), len, p_full_objects);
- }
+ encode_variant(var, barr.ptrw(), len, p_full_objects);
- return GDMonoMarshal::PoolByteArray_to_mono_array(barr);
+ return GDMonoMarshal::PackedByteArray_to_mono_array(barr);
}
MonoString *godot_icall_GD_var2str(MonoObject *p_var) {
diff --git a/modules/mono/mono_gd/gd_mono_cache.cpp b/modules/mono/mono_gd/gd_mono_cache.cpp
index f1f6524cd2..0ad90a510e 100644
--- a/modules/mono/mono_gd/gd_mono_cache.cpp
+++ b/modules/mono/mono_gd/gd_mono_cache.cpp
@@ -136,10 +136,8 @@ void CachedData::clear_godot_api_cache() {
class_SignalAttribute = NULL;
class_ToolAttribute = NULL;
class_RemoteAttribute = NULL;
- class_SyncAttribute = NULL;
class_MasterAttribute = NULL;
class_PuppetAttribute = NULL;
- class_SlaveAttribute = NULL;
class_RemoteSyncAttribute = NULL;
class_MasterSyncAttribute = NULL;
class_PuppetSyncAttribute = NULL;
@@ -254,10 +252,8 @@ void update_godot_api_cache() {
CACHE_CLASS_AND_CHECK(SignalAttribute, GODOT_API_CLASS(SignalAttribute));
CACHE_CLASS_AND_CHECK(ToolAttribute, GODOT_API_CLASS(ToolAttribute));
CACHE_CLASS_AND_CHECK(RemoteAttribute, GODOT_API_CLASS(RemoteAttribute));
- CACHE_CLASS_AND_CHECK(SyncAttribute, GODOT_API_CLASS(SyncAttribute));
CACHE_CLASS_AND_CHECK(MasterAttribute, GODOT_API_CLASS(MasterAttribute));
CACHE_CLASS_AND_CHECK(PuppetAttribute, GODOT_API_CLASS(PuppetAttribute));
- CACHE_CLASS_AND_CHECK(SlaveAttribute, GODOT_API_CLASS(SlaveAttribute));
CACHE_CLASS_AND_CHECK(RemoteSyncAttribute, GODOT_API_CLASS(RemoteSyncAttribute));
CACHE_CLASS_AND_CHECK(MasterSyncAttribute, GODOT_API_CLASS(MasterSyncAttribute));
CACHE_CLASS_AND_CHECK(PuppetSyncAttribute, GODOT_API_CLASS(PuppetSyncAttribute));
diff --git a/modules/mono/mono_gd/gd_mono_cache.h b/modules/mono/mono_gd/gd_mono_cache.h
index 1dc6b70479..0458e91240 100644
--- a/modules/mono/mono_gd/gd_mono_cache.h
+++ b/modules/mono/mono_gd/gd_mono_cache.h
@@ -106,13 +106,11 @@ struct CachedData {
GDMonoClass *class_SignalAttribute;
GDMonoClass *class_ToolAttribute;
GDMonoClass *class_RemoteAttribute;
- GDMonoClass *class_SyncAttribute;
+ GDMonoClass *class_MasterAttribute;
+ GDMonoClass *class_PuppetAttribute;
GDMonoClass *class_RemoteSyncAttribute;
GDMonoClass *class_MasterSyncAttribute;
GDMonoClass *class_PuppetSyncAttribute;
- GDMonoClass *class_MasterAttribute;
- GDMonoClass *class_PuppetAttribute;
- GDMonoClass *class_SlaveAttribute;
GDMonoClass *class_GodotMethodAttribute;
GDMonoField *field_GodotMethodAttribute_methodName;
diff --git a/modules/mono/mono_gd/gd_mono_field.cpp b/modules/mono/mono_gd/gd_mono_field.cpp
index 178647b968..03b56c9949 100644
--- a/modules/mono/mono_gd/gd_mono_field.cpp
+++ b/modules/mono/mono_gd/gd_mono_field.cpp
@@ -247,37 +247,37 @@ void GDMonoField::set_value_from_variant(MonoObject *p_object, const Variant &p_
}
if (array_type->eklass == CACHED_CLASS_RAW(uint8_t)) {
- SET_FROM_ARRAY(PoolByteArray);
+ SET_FROM_ARRAY(PackedByteArray);
break;
}
if (array_type->eklass == CACHED_CLASS_RAW(int32_t)) {
- SET_FROM_ARRAY(PoolIntArray);
+ SET_FROM_ARRAY(PackedInt32Array);
break;
}
if (array_type->eklass == REAL_T_MONOCLASS) {
- SET_FROM_ARRAY(PoolRealArray);
+ SET_FROM_ARRAY(PackedFloat32Array);
break;
}
if (array_type->eklass == CACHED_CLASS_RAW(String)) {
- SET_FROM_ARRAY(PoolStringArray);
+ SET_FROM_ARRAY(PackedStringArray);
break;
}
if (array_type->eklass == CACHED_CLASS_RAW(Vector2)) {
- SET_FROM_ARRAY(PoolVector2Array);
+ SET_FROM_ARRAY(PackedVector2Array);
break;
}
if (array_type->eklass == CACHED_CLASS_RAW(Vector3)) {
- SET_FROM_ARRAY(PoolVector3Array);
+ SET_FROM_ARRAY(PackedVector3Array);
break;
}
if (array_type->eklass == CACHED_CLASS_RAW(Color)) {
- SET_FROM_ARRAY(PoolColorArray);
+ SET_FROM_ARRAY(PackedColorArray);
break;
}
@@ -370,7 +370,7 @@ void GDMonoField::set_value_from_variant(MonoObject *p_object, const Variant &p_
int32_t val = p_value.operator signed int();
mono_field_set_value(p_object, mono_field, &val);
} break;
- case Variant::REAL: {
+ case Variant::FLOAT: {
#ifdef REAL_T_IS_DOUBLE
double val = p_value.operator double();
mono_field_set_value(p_object, mono_field, &val);
@@ -434,26 +434,26 @@ void GDMonoField::set_value_from_variant(MonoObject *p_object, const Variant &p_
MonoObject *managed = GDMonoUtils::create_managed_from(p_value.operator Array(), CACHED_CLASS(Array));
mono_field_set_value(p_object, mono_field, managed);
} break;
- case Variant::POOL_BYTE_ARRAY: {
- SET_FROM_ARRAY(PoolByteArray);
+ case Variant::PACKED_BYTE_ARRAY: {
+ SET_FROM_ARRAY(PackedByteArray);
} break;
- case Variant::POOL_INT_ARRAY: {
- SET_FROM_ARRAY(PoolIntArray);
+ case Variant::PACKED_INT32_ARRAY: {
+ SET_FROM_ARRAY(PackedInt32Array);
} break;
- case Variant::POOL_REAL_ARRAY: {
- SET_FROM_ARRAY(PoolRealArray);
+ case Variant::PACKED_FLOAT32_ARRAY: {
+ SET_FROM_ARRAY(PackedFloat32Array);
} break;
- case Variant::POOL_STRING_ARRAY: {
- SET_FROM_ARRAY(PoolStringArray);
+ case Variant::PACKED_STRING_ARRAY: {
+ SET_FROM_ARRAY(PackedStringArray);
} break;
- case Variant::POOL_VECTOR2_ARRAY: {
- SET_FROM_ARRAY(PoolVector2Array);
+ case Variant::PACKED_VECTOR2_ARRAY: {
+ SET_FROM_ARRAY(PackedVector2Array);
} break;
- case Variant::POOL_VECTOR3_ARRAY: {
- SET_FROM_ARRAY(PoolVector3Array);
+ case Variant::PACKED_VECTOR3_ARRAY: {
+ SET_FROM_ARRAY(PackedVector3Array);
} break;
- case Variant::POOL_COLOR_ARRAY: {
- SET_FROM_ARRAY(PoolColorArray);
+ case Variant::PACKED_COLOR_ARRAY: {
+ SET_FROM_ARRAY(PackedColorArray);
} break;
default: break;
}
diff --git a/modules/mono/mono_gd/gd_mono_internals.cpp b/modules/mono/mono_gd/gd_mono_internals.cpp
index 75aa77c7b0..74ffa90cb3 100644
--- a/modules/mono/mono_gd/gd_mono_internals.cpp
+++ b/modules/mono/mono_gd/gd_mono_internals.cpp
@@ -107,7 +107,7 @@ void tie_managed_to_unmanaged(MonoObject *managed, Object *unmanaged) {
ScriptInstance *si = CSharpInstance::create_for_managed_type(unmanaged, script.ptr(), gchandle);
- unmanaged->set_script_and_instance(script.get_ref_ptr(), si);
+ unmanaged->set_script_and_instance(script, si);
}
void unhandled_exception(MonoException *p_exc) {
diff --git a/modules/mono/mono_gd/gd_mono_marshal.cpp b/modules/mono/mono_gd/gd_mono_marshal.cpp
index 19d627218e..695be64d6e 100644
--- a/modules/mono/mono_gd/gd_mono_marshal.cpp
+++ b/modules/mono/mono_gd/gd_mono_marshal.cpp
@@ -60,9 +60,9 @@ Variant::Type managed_to_variant_type(const ManagedType &p_type) {
return Variant::INT;
case MONO_TYPE_R4:
- return Variant::REAL;
+ return Variant::FLOAT;
case MONO_TYPE_R8:
- return Variant::REAL;
+ return Variant::FLOAT;
case MONO_TYPE_STRING: {
return Variant::STRING;
@@ -113,25 +113,25 @@ Variant::Type managed_to_variant_type(const ManagedType &p_type) {
return Variant::ARRAY;
if (array_type->eklass == CACHED_CLASS_RAW(uint8_t))
- return Variant::POOL_BYTE_ARRAY;
+ return Variant::PACKED_BYTE_ARRAY;
if (array_type->eklass == CACHED_CLASS_RAW(int32_t))
- return Variant::POOL_INT_ARRAY;
+ return Variant::PACKED_INT32_ARRAY;
if (array_type->eklass == REAL_T_MONOCLASS)
- return Variant::POOL_REAL_ARRAY;
+ return Variant::PACKED_FLOAT32_ARRAY;
if (array_type->eklass == CACHED_CLASS_RAW(String))
- return Variant::POOL_STRING_ARRAY;
+ return Variant::PACKED_STRING_ARRAY;
if (array_type->eklass == CACHED_CLASS_RAW(Vector2))
- return Variant::POOL_VECTOR2_ARRAY;
+ return Variant::PACKED_VECTOR2_ARRAY;
if (array_type->eklass == CACHED_CLASS_RAW(Vector3))
- return Variant::POOL_VECTOR3_ARRAY;
+ return Variant::PACKED_VECTOR3_ARRAY;
if (array_type->eklass == CACHED_CLASS_RAW(Color))
- return Variant::POOL_COLOR_ARRAY;
+ return Variant::PACKED_COLOR_ARRAY;
} break;
case MONO_TYPE_CLASS: {
@@ -491,25 +491,25 @@ MonoObject *variant_to_mono_object(const Variant *p_var, const ManagedType &p_ty
return (MonoObject *)Array_to_mono_array(p_var->operator Array());
if (array_type->eklass == CACHED_CLASS_RAW(uint8_t))
- return (MonoObject *)PoolByteArray_to_mono_array(p_var->operator PoolByteArray());
+ return (MonoObject *)PackedByteArray_to_mono_array(p_var->operator PackedByteArray());
if (array_type->eklass == CACHED_CLASS_RAW(int32_t))
- return (MonoObject *)PoolIntArray_to_mono_array(p_var->operator PoolIntArray());
+ return (MonoObject *)PackedInt32Array_to_mono_array(p_var->operator PackedInt32Array());
if (array_type->eklass == REAL_T_MONOCLASS)
- return (MonoObject *)PoolRealArray_to_mono_array(p_var->operator PoolRealArray());
+ return (MonoObject *)PackedFloat32Array_to_mono_array(p_var->operator PackedFloat32Array());
if (array_type->eklass == CACHED_CLASS_RAW(String))
- return (MonoObject *)PoolStringArray_to_mono_array(p_var->operator PoolStringArray());
+ return (MonoObject *)PackedStringArray_to_mono_array(p_var->operator PackedStringArray());
if (array_type->eklass == CACHED_CLASS_RAW(Vector2))
- return (MonoObject *)PoolVector2Array_to_mono_array(p_var->operator PoolVector2Array());
+ return (MonoObject *)PackedVector2Array_to_mono_array(p_var->operator PackedVector2Array());
if (array_type->eklass == CACHED_CLASS_RAW(Vector3))
- return (MonoObject *)PoolVector3Array_to_mono_array(p_var->operator PoolVector3Array());
+ return (MonoObject *)PackedVector3Array_to_mono_array(p_var->operator PackedVector3Array());
if (array_type->eklass == CACHED_CLASS_RAW(Color))
- return (MonoObject *)PoolColorArray_to_mono_array(p_var->operator PoolColorArray());
+ return (MonoObject *)PackedColorArray_to_mono_array(p_var->operator PackedColorArray());
ERR_FAIL_V_MSG(NULL, "Attempted to convert Variant to a managed array of unmarshallable element type.");
} break;
@@ -577,7 +577,7 @@ MonoObject *variant_to_mono_object(const Variant *p_var, const ManagedType &p_ty
int32_t val = p_var->operator signed int();
return BOX_INT32(val);
}
- case Variant::REAL: {
+ case Variant::FLOAT: {
#ifdef REAL_T_IS_DOUBLE
double val = p_var->operator double();
return BOX_DOUBLE(val);
@@ -638,20 +638,20 @@ MonoObject *variant_to_mono_object(const Variant *p_var, const ManagedType &p_ty
return GDMonoUtils::create_managed_from(p_var->operator Dictionary(), CACHED_CLASS(Dictionary));
case Variant::ARRAY:
return GDMonoUtils::create_managed_from(p_var->operator Array(), CACHED_CLASS(Array));
- case Variant::POOL_BYTE_ARRAY:
- return (MonoObject *)PoolByteArray_to_mono_array(p_var->operator PoolByteArray());
- case Variant::POOL_INT_ARRAY:
- return (MonoObject *)PoolIntArray_to_mono_array(p_var->operator PoolIntArray());
- case Variant::POOL_REAL_ARRAY:
- return (MonoObject *)PoolRealArray_to_mono_array(p_var->operator PoolRealArray());
- case Variant::POOL_STRING_ARRAY:
- return (MonoObject *)PoolStringArray_to_mono_array(p_var->operator PoolStringArray());
- case Variant::POOL_VECTOR2_ARRAY:
- return (MonoObject *)PoolVector2Array_to_mono_array(p_var->operator PoolVector2Array());
- case Variant::POOL_VECTOR3_ARRAY:
- return (MonoObject *)PoolVector3Array_to_mono_array(p_var->operator PoolVector3Array());
- case Variant::POOL_COLOR_ARRAY:
- return (MonoObject *)PoolColorArray_to_mono_array(p_var->operator PoolColorArray());
+ case Variant::PACKED_BYTE_ARRAY:
+ return (MonoObject *)PackedByteArray_to_mono_array(p_var->operator PackedByteArray());
+ case Variant::PACKED_INT32_ARRAY:
+ return (MonoObject *)PackedInt32Array_to_mono_array(p_var->operator PackedInt32Array());
+ case Variant::PACKED_FLOAT32_ARRAY:
+ return (MonoObject *)PackedFloat32Array_to_mono_array(p_var->operator PackedFloat32Array());
+ case Variant::PACKED_STRING_ARRAY:
+ return (MonoObject *)PackedStringArray_to_mono_array(p_var->operator PackedStringArray());
+ case Variant::PACKED_VECTOR2_ARRAY:
+ return (MonoObject *)PackedVector2Array_to_mono_array(p_var->operator PackedVector2Array());
+ case Variant::PACKED_VECTOR3_ARRAY:
+ return (MonoObject *)PackedVector3Array_to_mono_array(p_var->operator PackedVector3Array());
+ case Variant::PACKED_COLOR_ARRAY:
+ return (MonoObject *)PackedColorArray_to_mono_array(p_var->operator PackedColorArray());
default:
return NULL;
}
@@ -785,25 +785,25 @@ Variant mono_object_to_variant_impl(MonoObject *p_obj, const ManagedType &p_type
return mono_array_to_Array((MonoArray *)p_obj);
if (array_type->eklass == CACHED_CLASS_RAW(uint8_t))
- return mono_array_to_PoolByteArray((MonoArray *)p_obj);
+ return mono_array_to_PackedByteArray((MonoArray *)p_obj);
if (array_type->eklass == CACHED_CLASS_RAW(int32_t))
- return mono_array_to_PoolIntArray((MonoArray *)p_obj);
+ return mono_array_to_PackedInt32Array((MonoArray *)p_obj);
if (array_type->eklass == REAL_T_MONOCLASS)
- return mono_array_to_PoolRealArray((MonoArray *)p_obj);
+ return mono_array_to_PackedFloat32Array((MonoArray *)p_obj);
if (array_type->eklass == CACHED_CLASS_RAW(String))
- return mono_array_to_PoolStringArray((MonoArray *)p_obj);
+ return mono_array_to_PackedStringArray((MonoArray *)p_obj);
if (array_type->eklass == CACHED_CLASS_RAW(Vector2))
- return mono_array_to_PoolVector2Array((MonoArray *)p_obj);
+ return mono_array_to_PackedVector2Array((MonoArray *)p_obj);
if (array_type->eklass == CACHED_CLASS_RAW(Vector3))
- return mono_array_to_PoolVector3Array((MonoArray *)p_obj);
+ return mono_array_to_PackedVector3Array((MonoArray *)p_obj);
if (array_type->eklass == CACHED_CLASS_RAW(Color))
- return mono_array_to_PoolColorArray((MonoArray *)p_obj);
+ return mono_array_to_PackedColorArray((MonoArray *)p_obj);
if (p_fail_with_err) {
ERR_FAIL_V_MSG(Variant(), "Attempted to convert a managed array of unmarshallable element type to Variant.");
@@ -987,8 +987,8 @@ Array mono_array_to_Array(MonoArray *p_array) {
// TODO: Use memcpy where possible
-MonoArray *PoolIntArray_to_mono_array(const PoolIntArray &p_array) {
- PoolIntArray::Read r = p_array.read();
+MonoArray *PackedInt32Array_to_mono_array(const PackedInt32Array &p_array) {
+ const int *r = p_array.ptr();
MonoArray *ret = mono_array_new(mono_domain_get(), CACHED_CLASS_RAW(int32_t), p_array.size());
@@ -999,13 +999,13 @@ MonoArray *PoolIntArray_to_mono_array(const PoolIntArray &p_array) {
return ret;
}
-PoolIntArray mono_array_to_PoolIntArray(MonoArray *p_array) {
- PoolIntArray ret;
+PackedInt32Array mono_array_to_PackedInt32Array(MonoArray *p_array) {
+ PackedInt32Array ret;
if (!p_array)
return ret;
int length = mono_array_length(p_array);
ret.resize(length);
- PoolIntArray::Write w = ret.write();
+ int *w = ret.ptrw();
for (int i = 0; i < length; i++) {
w[i] = mono_array_get(p_array, int32_t, i);
@@ -1014,8 +1014,8 @@ PoolIntArray mono_array_to_PoolIntArray(MonoArray *p_array) {
return ret;
}
-MonoArray *PoolByteArray_to_mono_array(const PoolByteArray &p_array) {
- PoolByteArray::Read r = p_array.read();
+MonoArray *PackedByteArray_to_mono_array(const PackedByteArray &p_array) {
+ const uint8_t *r = p_array.ptr();
MonoArray *ret = mono_array_new(mono_domain_get(), CACHED_CLASS_RAW(uint8_t), p_array.size());
@@ -1026,13 +1026,13 @@ MonoArray *PoolByteArray_to_mono_array(const PoolByteArray &p_array) {
return ret;
}
-PoolByteArray mono_array_to_PoolByteArray(MonoArray *p_array) {
- PoolByteArray ret;
+PackedByteArray mono_array_to_PackedByteArray(MonoArray *p_array) {
+ PackedByteArray ret;
if (!p_array)
return ret;
int length = mono_array_length(p_array);
ret.resize(length);
- PoolByteArray::Write w = ret.write();
+ uint8_t *w = ret.ptrw();
for (int i = 0; i < length; i++) {
w[i] = mono_array_get(p_array, uint8_t, i);
@@ -1041,8 +1041,8 @@ PoolByteArray mono_array_to_PoolByteArray(MonoArray *p_array) {
return ret;
}
-MonoArray *PoolRealArray_to_mono_array(const PoolRealArray &p_array) {
- PoolRealArray::Read r = p_array.read();
+MonoArray *PackedFloat32Array_to_mono_array(const PackedFloat32Array &p_array) {
+ const real_t *r = p_array.ptr();
MonoArray *ret = mono_array_new(mono_domain_get(), REAL_T_MONOCLASS, p_array.size());
@@ -1053,13 +1053,13 @@ MonoArray *PoolRealArray_to_mono_array(const PoolRealArray &p_array) {
return ret;
}
-PoolRealArray mono_array_to_PoolRealArray(MonoArray *p_array) {
- PoolRealArray ret;
+PackedFloat32Array mono_array_to_PackedFloat32Array(MonoArray *p_array) {
+ PackedFloat32Array ret;
if (!p_array)
return ret;
int length = mono_array_length(p_array);
ret.resize(length);
- PoolRealArray::Write w = ret.write();
+ real_t *w = ret.ptrw();
for (int i = 0; i < length; i++) {
w[i] = mono_array_get(p_array, real_t, i);
@@ -1068,8 +1068,8 @@ PoolRealArray mono_array_to_PoolRealArray(MonoArray *p_array) {
return ret;
}
-MonoArray *PoolStringArray_to_mono_array(const PoolStringArray &p_array) {
- PoolStringArray::Read r = p_array.read();
+MonoArray *PackedStringArray_to_mono_array(const PackedStringArray &p_array) {
+ const String *r = p_array.ptr();
MonoArray *ret = mono_array_new(mono_domain_get(), CACHED_CLASS_RAW(String), p_array.size());
@@ -1081,13 +1081,13 @@ MonoArray *PoolStringArray_to_mono_array(const PoolStringArray &p_array) {
return ret;
}
-PoolStringArray mono_array_to_PoolStringArray(MonoArray *p_array) {
- PoolStringArray ret;
+PackedStringArray mono_array_to_PackedStringArray(MonoArray *p_array) {
+ PackedStringArray ret;
if (!p_array)
return ret;
int length = mono_array_length(p_array);
ret.resize(length);
- PoolStringArray::Write w = ret.write();
+ String *w = ret.ptrw();
for (int i = 0; i < length; i++) {
MonoString *elem = mono_array_get(p_array, MonoString *, i);
@@ -1097,8 +1097,8 @@ PoolStringArray mono_array_to_PoolStringArray(MonoArray *p_array) {
return ret;
}
-MonoArray *PoolColorArray_to_mono_array(const PoolColorArray &p_array) {
- PoolColorArray::Read r = p_array.read();
+MonoArray *PackedColorArray_to_mono_array(const PackedColorArray &p_array) {
+ const Color *r = p_array.ptr();
MonoArray *ret = mono_array_new(mono_domain_get(), CACHED_CLASS_RAW(Color), p_array.size());
@@ -1110,13 +1110,13 @@ MonoArray *PoolColorArray_to_mono_array(const PoolColorArray &p_array) {
return ret;
}
-PoolColorArray mono_array_to_PoolColorArray(MonoArray *p_array) {
- PoolColorArray ret;
+PackedColorArray mono_array_to_PackedColorArray(MonoArray *p_array) {
+ PackedColorArray ret;
if (!p_array)
return ret;
int length = mono_array_length(p_array);
ret.resize(length);
- PoolColorArray::Write w = ret.write();
+ Color *w = ret.ptrw();
for (int i = 0; i < length; i++) {
w[i] = MARSHALLED_IN(Color, (M_Color *)mono_array_addr_with_size(p_array, sizeof(M_Color), i));
@@ -1125,8 +1125,8 @@ PoolColorArray mono_array_to_PoolColorArray(MonoArray *p_array) {
return ret;
}
-MonoArray *PoolVector2Array_to_mono_array(const PoolVector2Array &p_array) {
- PoolVector2Array::Read r = p_array.read();
+MonoArray *PackedVector2Array_to_mono_array(const PackedVector2Array &p_array) {
+ const Vector2 *r = p_array.ptr();
MonoArray *ret = mono_array_new(mono_domain_get(), CACHED_CLASS_RAW(Vector2), p_array.size());
@@ -1138,13 +1138,13 @@ MonoArray *PoolVector2Array_to_mono_array(const PoolVector2Array &p_array) {
return ret;
}
-PoolVector2Array mono_array_to_PoolVector2Array(MonoArray *p_array) {
- PoolVector2Array ret;
+PackedVector2Array mono_array_to_PackedVector2Array(MonoArray *p_array) {
+ PackedVector2Array ret;
if (!p_array)
return ret;
int length = mono_array_length(p_array);
ret.resize(length);
- PoolVector2Array::Write w = ret.write();
+ Vector2 *w = ret.ptrw();
for (int i = 0; i < length; i++) {
w[i] = MARSHALLED_IN(Vector2, (M_Vector2 *)mono_array_addr_with_size(p_array, sizeof(M_Vector2), i));
@@ -1153,8 +1153,8 @@ PoolVector2Array mono_array_to_PoolVector2Array(MonoArray *p_array) {
return ret;
}
-MonoArray *PoolVector3Array_to_mono_array(const PoolVector3Array &p_array) {
- PoolVector3Array::Read r = p_array.read();
+MonoArray *PackedVector3Array_to_mono_array(const PackedVector3Array &p_array) {
+ const Vector3 *r = p_array.ptr();
MonoArray *ret = mono_array_new(mono_domain_get(), CACHED_CLASS_RAW(Vector3), p_array.size());
@@ -1166,13 +1166,13 @@ MonoArray *PoolVector3Array_to_mono_array(const PoolVector3Array &p_array) {
return ret;
}
-PoolVector3Array mono_array_to_PoolVector3Array(MonoArray *p_array) {
- PoolVector3Array ret;
+PackedVector3Array mono_array_to_PackedVector3Array(MonoArray *p_array) {
+ PackedVector3Array ret;
if (!p_array)
return ret;
int length = mono_array_length(p_array);
ret.resize(length);
- PoolVector3Array::Write w = ret.write();
+ Vector3 *w = ret.ptrw();
for (int i = 0; i < length; i++) {
w[i] = MARSHALLED_IN(Vector3, (M_Vector3 *)mono_array_addr_with_size(p_array, sizeof(M_Vector3), i));
diff --git a/modules/mono/mono_gd/gd_mono_marshal.h b/modules/mono/mono_gd/gd_mono_marshal.h
index e662e7814e..5db59522ce 100644
--- a/modules/mono/mono_gd/gd_mono_marshal.h
+++ b/modules/mono/mono_gd/gd_mono_marshal.h
@@ -127,40 +127,40 @@ String mono_object_to_variant_string(MonoObject *p_obj, MonoException **r_exc);
MonoArray *Array_to_mono_array(const Array &p_array);
Array mono_array_to_Array(MonoArray *p_array);
-// PoolIntArray
+// PackedInt32Array
-MonoArray *PoolIntArray_to_mono_array(const PoolIntArray &p_array);
-PoolIntArray mono_array_to_PoolIntArray(MonoArray *p_array);
+MonoArray *PackedInt32Array_to_mono_array(const PackedInt32Array &p_array);
+PackedInt32Array mono_array_to_PackedInt32Array(MonoArray *p_array);
-// PoolByteArray
+// PackedByteArray
-MonoArray *PoolByteArray_to_mono_array(const PoolByteArray &p_array);
-PoolByteArray mono_array_to_PoolByteArray(MonoArray *p_array);
+MonoArray *PackedByteArray_to_mono_array(const PackedByteArray &p_array);
+PackedByteArray mono_array_to_PackedByteArray(MonoArray *p_array);
-// PoolRealArray
+// PackedFloat32Array
-MonoArray *PoolRealArray_to_mono_array(const PoolRealArray &p_array);
-PoolRealArray mono_array_to_PoolRealArray(MonoArray *p_array);
+MonoArray *PackedFloat32Array_to_mono_array(const PackedFloat32Array &p_array);
+PackedFloat32Array mono_array_to_PackedFloat32Array(MonoArray *p_array);
-// PoolStringArray
+// PackedStringArray
-MonoArray *PoolStringArray_to_mono_array(const PoolStringArray &p_array);
-PoolStringArray mono_array_to_PoolStringArray(MonoArray *p_array);
+MonoArray *PackedStringArray_to_mono_array(const PackedStringArray &p_array);
+PackedStringArray mono_array_to_PackedStringArray(MonoArray *p_array);
-// PoolColorArray
+// PackedColorArray
-MonoArray *PoolColorArray_to_mono_array(const PoolColorArray &p_array);
-PoolColorArray mono_array_to_PoolColorArray(MonoArray *p_array);
+MonoArray *PackedColorArray_to_mono_array(const PackedColorArray &p_array);
+PackedColorArray mono_array_to_PackedColorArray(MonoArray *p_array);
-// PoolVector2Array
+// PackedVector2Array
-MonoArray *PoolVector2Array_to_mono_array(const PoolVector2Array &p_array);
-PoolVector2Array mono_array_to_PoolVector2Array(MonoArray *p_array);
+MonoArray *PackedVector2Array_to_mono_array(const PackedVector2Array &p_array);
+PackedVector2Array mono_array_to_PackedVector2Array(MonoArray *p_array);
-// PoolVector3Array
+// PackedVector3Array
-MonoArray *PoolVector3Array_to_mono_array(const PoolVector3Array &p_array);
-PoolVector3Array mono_array_to_PoolVector3Array(MonoArray *p_array);
+MonoArray *PackedVector3Array_to_mono_array(const PackedVector3Array &p_array);
+PackedVector3Array mono_array_to_PackedVector3Array(MonoArray *p_array);
// Structures
diff --git a/modules/mono/mono_gd/gd_mono_utils.cpp b/modules/mono/mono_gd/gd_mono_utils.cpp
index 05077a00c4..ae6625a6c6 100644
--- a/modules/mono/mono_gd/gd_mono_utils.cpp
+++ b/modules/mono/mono_gd/gd_mono_utils.cpp
@@ -38,7 +38,7 @@
#include "core/reference.h"
#ifdef TOOLS_ENABLED
-#include "editor/script_editor_debugger.h"
+#include "editor/debugger/script_editor_debugger.h"
#endif
#include "../csharp_script.h"
diff --git a/modules/mono/signal_awaiter_utils.cpp b/modules/mono/signal_awaiter_utils.cpp
index d3226762ea..718bc2bb93 100644
--- a/modules/mono/signal_awaiter_utils.cpp
+++ b/modules/mono/signal_awaiter_utils.cpp
@@ -51,7 +51,7 @@ Error connect_signal_awaiter(Object *p_source, const String &p_signal, Object *p
Vector<Variant> binds;
binds.push_back(sa_con);
- Error err = p_source->connect(p_signal, sa_con.ptr(),
+ Error err = p_source->connect_compat(p_signal, sa_con.ptr(),
CSharpLanguage::get_singleton()->get_string_names()._signal_callback,
binds, Object::CONNECT_ONESHOT);
@@ -65,15 +65,15 @@ Error connect_signal_awaiter(Object *p_source, const String &p_signal, Object *p
}
} // namespace SignalAwaiterUtils
-Variant SignalAwaiterHandle::_signal_callback(const Variant **p_args, int p_argcount, Variant::CallError &r_error) {
+Variant SignalAwaiterHandle::_signal_callback(const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
#ifdef DEBUG_ENABLED
- ERR_FAIL_COND_V_MSG(conn_target_id && !ObjectDB::get_instance(conn_target_id), Variant(),
+ ERR_FAIL_COND_V_MSG(conn_target_id.is_valid() && !ObjectDB::get_instance(conn_target_id), Variant(),
"Resumed after await, but class instance is gone.");
#endif
if (p_argcount < 1) {
- r_error.error = Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
+ r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
r_error.argument = 1;
return Variant();
}
@@ -81,7 +81,7 @@ Variant SignalAwaiterHandle::_signal_callback(const Variant **p_args, int p_argc
Ref<SignalAwaiterHandle> self = *p_args[p_argcount - 1];
if (self.is_null()) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = p_argcount - 1;
r_error.expected = Variant::OBJECT;
return Variant();
@@ -116,12 +116,7 @@ void SignalAwaiterHandle::_bind_methods() {
}
SignalAwaiterHandle::SignalAwaiterHandle(MonoObject *p_managed) :
- MonoGCHandle(MonoGCHandle::new_strong_handle(p_managed), STRONG_HANDLE) {
-
-#ifdef DEBUG_ENABLED
- conn_target_id = 0;
-#endif
-}
+ MonoGCHandle(MonoGCHandle::new_strong_handle(p_managed), STRONG_HANDLE) {}
SignalAwaiterHandle::~SignalAwaiterHandle() {
diff --git a/modules/mono/signal_awaiter_utils.h b/modules/mono/signal_awaiter_utils.h
index a9956ad5ba..012f6e5bb3 100644
--- a/modules/mono/signal_awaiter_utils.h
+++ b/modules/mono/signal_awaiter_utils.h
@@ -49,7 +49,7 @@ class SignalAwaiterHandle : public MonoGCHandle {
ObjectID conn_target_id;
#endif
- Variant _signal_callback(const Variant **p_args, int p_argcount, Variant::CallError &r_error);
+ Variant _signal_callback(const Variant **p_args, int p_argcount, Callable::CallError &r_error);
protected:
static void _bind_methods();
diff --git a/modules/mono/utils/string_utils.cpp b/modules/mono/utils/string_utils.cpp
index 911ac5c4a3..49c4fb3f73 100644
--- a/modules/mono/utils/string_utils.cpp
+++ b/modules/mono/utils/string_utils.cpp
@@ -162,22 +162,22 @@ String escape_csharp_keyword(const String &p_name) {
#endif
Error read_all_file_utf8(const String &p_path, String &r_content) {
- PoolVector<uint8_t> sourcef;
+ Vector<uint8_t> sourcef;
Error err;
FileAccess *f = FileAccess::open(p_path, FileAccess::READ, &err);
ERR_FAIL_COND_V_MSG(err != OK, err, "Cannot open file '" + p_path + "'.");
int len = f->get_len();
sourcef.resize(len + 1);
- PoolVector<uint8_t>::Write w = sourcef.write();
- int r = f->get_buffer(w.ptr(), len);
+ uint8_t *w = sourcef.ptrw();
+ int r = f->get_buffer(w, len);
f->close();
memdelete(f);
ERR_FAIL_COND_V(r != len, ERR_CANT_OPEN);
w[len] = 0;
String source;
- if (source.parse_utf8((const char *)w.ptr())) {
+ if (source.parse_utf8((const char *)w)) {
ERR_FAIL_V(ERR_INVALID_DATA);
}
diff --git a/modules/opensimplex/doc_classes/NoiseTexture.xml b/modules/opensimplex/doc_classes/NoiseTexture.xml
index 0790cde557..c06f3096de 100644
--- a/modules/opensimplex/doc_classes/NoiseTexture.xml
+++ b/modules/opensimplex/doc_classes/NoiseTexture.xml
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="NoiseTexture" inherits="Texture" version="4.0">
+<class name="NoiseTexture" inherits="Texture2D" version="4.0">
<brief_description>
[OpenSimplexNoise] filled texture.
</brief_description>
<description>
Uses an [OpenSimplexNoise] to fill the texture data. You can specify the texture size but keep in mind that larger textures will take longer to generate and seamless noise only works with square sized textures.
NoiseTexture can also generate normalmap textures.
- The class uses [Thread]s to generate the texture data internally, so [method Texture.get_data] may return [code]null[/code] if the generation process has not completed yet. In that case, you need to wait for the texture to be generated before accessing the data:
+ The class uses [Thread]s to generate the texture data internally, so [method Texture2D.get_data] may return [code]null[/code] if the generation process has not completed yet. In that case, you need to wait for the texture to be generated before accessing the data:
[codeblock]
var texture = preload("res://noise.tres")
yield(texture, "changed")
@@ -24,7 +24,6 @@
<member name="bump_strength" type="float" setter="set_bump_strength" getter="get_bump_strength" default="8.0">
Strength of the bump maps used in this texture. A higher value will make the bump maps appear larger while a lower value will make them appear softer.
</member>
- <member name="flags" type="int" setter="set_flags" getter="get_flags" override="true" default="7" />
<member name="height" type="int" setter="set_height" getter="get_height" default="512">
Height of the generated texture.
</member>
diff --git a/modules/opensimplex/noise_texture.cpp b/modules/opensimplex/noise_texture.cpp
index aa1c822813..d60099e676 100644
--- a/modules/opensimplex/noise_texture.cpp
+++ b/modules/opensimplex/noise_texture.cpp
@@ -42,17 +42,16 @@ NoiseTexture::NoiseTexture() {
seamless = false;
as_normalmap = false;
bump_strength = 8.0;
- flags = FLAGS_DEFAULT;
noise = Ref<OpenSimplexNoise>();
- texture = VS::get_singleton()->texture_create();
-
_queue_update();
}
NoiseTexture::~NoiseTexture() {
- VS::get_singleton()->free(texture);
+ if (texture.is_valid()) {
+ VS::get_singleton()->free(texture);
+ }
if (noise_thread) {
Thread::wait_to_finish(noise_thread);
memdelete(noise_thread);
@@ -85,7 +84,7 @@ void NoiseTexture::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "height", PROPERTY_HINT_RANGE, "1,2048,1,or_greater"), "set_height", "get_height");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "seamless"), "set_seamless", "get_seamless");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "as_normalmap"), "set_as_normalmap", "is_normalmap");
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "bump_strength", PROPERTY_HINT_RANGE, "0,32,0.1,or_greater"), "set_bump_strength", "get_bump_strength");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "bump_strength", PROPERTY_HINT_RANGE, "0,32,0.1,or_greater"), "set_bump_strength", "get_bump_strength");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "noise", PROPERTY_HINT_RESOURCE_TYPE, "OpenSimplexNoise"), "set_noise", "get_noise");
}
@@ -101,8 +100,12 @@ void NoiseTexture::_validate_property(PropertyInfo &property) const {
void NoiseTexture::_set_texture_data(const Ref<Image> &p_image) {
data = p_image;
if (data.is_valid()) {
- VS::get_singleton()->texture_allocate(texture, size.x, size.y, 0, Image::FORMAT_RGBA8, VS::TEXTURE_TYPE_2D, flags);
- VS::get_singleton()->texture_set_data(texture, p_image);
+ if (texture.is_valid()) {
+ RID new_texture = VS::get_singleton()->texture_2d_create(p_image);
+ VS::get_singleton()->texture_replace(texture, new_texture);
+ } else {
+ texture = VS::get_singleton()->texture_2d_create(p_image);
+ }
}
emit_changed();
}
@@ -181,11 +184,11 @@ void NoiseTexture::set_noise(Ref<OpenSimplexNoise> p_noise) {
if (p_noise == noise)
return;
if (noise.is_valid()) {
- noise->disconnect(CoreStringNames::get_singleton()->changed, this, "_queue_update");
+ noise->disconnect_compat(CoreStringNames::get_singleton()->changed, this, "_queue_update");
}
noise = p_noise;
if (noise.is_valid()) {
- noise->connect(CoreStringNames::get_singleton()->changed, this, "_queue_update");
+ noise->connect_compat(CoreStringNames::get_singleton()->changed, this, "_queue_update");
}
_queue_update();
}
@@ -250,13 +253,12 @@ int NoiseTexture::get_height() const {
return size.y;
}
-void NoiseTexture::set_flags(uint32_t p_flags) {
- flags = p_flags;
- VS::get_singleton()->texture_set_flags(texture, flags);
-}
+RID NoiseTexture::get_rid() const {
+ if (!texture.is_valid()) {
+ texture = VS::get_singleton()->texture_2d_placeholder_create();
+ }
-uint32_t NoiseTexture::get_flags() const {
- return flags;
+ return texture;
}
Ref<Image> NoiseTexture::get_data() const {
diff --git a/modules/opensimplex/noise_texture.h b/modules/opensimplex/noise_texture.h
index 285fd1eba9..b1d7d3fac9 100644
--- a/modules/opensimplex/noise_texture.h
+++ b/modules/opensimplex/noise_texture.h
@@ -39,8 +39,8 @@
#include "editor/editor_plugin.h"
#include "editor/property_editor.h"
-class NoiseTexture : public Texture {
- GDCLASS(NoiseTexture, Texture);
+class NoiseTexture : public Texture2D {
+ GDCLASS(NoiseTexture, Texture2D);
private:
Ref<Image> data;
@@ -51,7 +51,7 @@ private:
bool update_queued;
bool regen_queued;
- RID texture;
+ mutable RID texture;
uint32_t flags;
Ref<OpenSimplexNoise> noise;
@@ -91,10 +91,7 @@ public:
int get_width() const;
int get_height() const;
- virtual void set_flags(uint32_t p_flags);
- virtual uint32_t get_flags() const;
-
- virtual RID get_rid() const { return texture; }
+ virtual RID get_rid() const;
virtual bool has_alpha() const { return false; }
virtual Ref<Image> get_data() const;
diff --git a/modules/opensimplex/open_simplex_noise.cpp b/modules/opensimplex/open_simplex_noise.cpp
index bd187e6b5b..238faa4130 100644
--- a/modules/opensimplex/open_simplex_noise.cpp
+++ b/modules/opensimplex/open_simplex_noise.cpp
@@ -98,10 +98,10 @@ void OpenSimplexNoise::set_lacunarity(float p_lacunarity) {
Ref<Image> OpenSimplexNoise::get_image(int p_width, int p_height) {
- PoolVector<uint8_t> data;
+ Vector<uint8_t> data;
data.resize(p_width * p_height * 4);
- PoolVector<uint8_t>::Write wd8 = data.write();
+ uint8_t *wd8 = data.ptrw();
for (int i = 0; i < p_height; i++) {
for (int j = 0; j < p_width; j++) {
@@ -121,10 +121,10 @@ Ref<Image> OpenSimplexNoise::get_image(int p_width, int p_height) {
Ref<Image> OpenSimplexNoise::get_seamless_image(int p_size) {
- PoolVector<uint8_t> data;
+ Vector<uint8_t> data;
data.resize(p_size * p_size * 4);
- PoolVector<uint8_t>::Write wd8 = data.write();
+ uint8_t *wd8 = data.ptrw();
for (int i = 0; i < p_size; i++) {
for (int j = 0; j < p_size; j++) {
@@ -186,9 +186,9 @@ void OpenSimplexNoise::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "seed"), "set_seed", "get_seed");
ADD_PROPERTY(PropertyInfo(Variant::INT, "octaves", PROPERTY_HINT_RANGE, vformat("1,%d,1", MAX_OCTAVES)), "set_octaves", "get_octaves");
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "period", PROPERTY_HINT_RANGE, "0.1,256.0,0.1"), "set_period", "get_period");
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "persistence", PROPERTY_HINT_RANGE, "0.0,1.0,0.001"), "set_persistence", "get_persistence");
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "lacunarity", PROPERTY_HINT_RANGE, "0.1,4.0,0.01"), "set_lacunarity", "get_lacunarity");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "period", PROPERTY_HINT_RANGE, "0.1,256.0,0.1"), "set_period", "get_period");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "persistence", PROPERTY_HINT_RANGE, "0.0,1.0,0.001"), "set_persistence", "get_persistence");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "lacunarity", PROPERTY_HINT_RANGE, "0.1,4.0,0.01"), "set_lacunarity", "get_lacunarity");
}
float OpenSimplexNoise::get_noise_1d(float x) {
diff --git a/modules/pvr/texture_loader_pvr.cpp b/modules/pvr/texture_loader_pvr.cpp
index 65c21d5af8..dab4f64393 100644
--- a/modules/pvr/texture_loader_pvr.cpp
+++ b/modules/pvr/texture_loader_pvr.cpp
@@ -96,12 +96,12 @@ RES ResourceFormatPVR::load(const String &p_path, const String &p_original_path,
print_line("surfcount: "+itos(surfcount));
*/
- PoolVector<uint8_t> data;
+ Vector<uint8_t> data;
data.resize(surfsize);
ERR_FAIL_COND_V(data.size() == 0, RES());
- PoolVector<uint8_t>::Write w = data.write();
+ uint8_t *w = data.ptrw();
f->get_buffer(&w[0], surfsize);
err = f->get_error();
ERR_FAIL_COND_V(err != OK, RES());
@@ -152,18 +152,11 @@ RES ResourceFormatPVR::load(const String &p_path, const String &p_original_path,
ERR_FAIL_V_MSG(RES(), "Unsupported format in PVR texture: " + itos(flags & 0xFF) + ".");
}
- w.release();
-
- int tex_flags = Texture::FLAG_FILTER | Texture::FLAG_REPEAT;
-
- if (mipmaps)
- tex_flags |= Texture::FLAG_MIPMAPS;
-
Ref<Image> image = memnew(Image(width, height, mipmaps, format, data));
ERR_FAIL_COND_V(image->empty(), RES());
Ref<ImageTexture> texture = memnew(ImageTexture);
- texture->create_from_image(image, tex_flags);
+ texture->create_from_image(image);
if (r_error)
*r_error = OK;
@@ -177,12 +170,12 @@ void ResourceFormatPVR::get_recognized_extensions(List<String> *p_extensions) co
}
bool ResourceFormatPVR::handles_type(const String &p_type) const {
- return ClassDB::is_parent_class(p_type, "Texture");
+ return ClassDB::is_parent_class(p_type, "Texture2D");
}
String ResourceFormatPVR::get_resource_type(const String &p_path) const {
if (p_path.get_extension().to_lower() == "pvr")
- return "Texture";
+ return "Texture2D";
return "";
}
@@ -205,10 +198,10 @@ static void _compress_pvrtc4(Image *p_img) {
new_img.instance();
new_img->create(img->get_width(), img->get_height(), img->has_mipmaps(), use_alpha ? Image::FORMAT_PVRTC4A : Image::FORMAT_PVRTC4);
- PoolVector<uint8_t> data = new_img->get_data();
+ Vector<uint8_t> data = new_img->get_data();
{
- PoolVector<uint8_t>::Write wr = data.write();
- PoolVector<uint8_t>::Read r = img->get_data().read();
+ uint8_t *wr = data.ptrw();
+ const uint8_t *r = img->get_data().ptr();
for (int i = 0; i <= new_img->get_mipmap_count(); i++) {
@@ -645,17 +638,14 @@ static void _pvrtc_decompress(Image *p_img) {
bool _2bit = (p_img->get_format() == Image::FORMAT_PVRTC2 || p_img->get_format() == Image::FORMAT_PVRTC2A);
- PoolVector<uint8_t> data = p_img->get_data();
- PoolVector<uint8_t>::Read r = data.read();
+ Vector<uint8_t> data = p_img->get_data();
+ const uint8_t *r = data.ptr();
- PoolVector<uint8_t> newdata;
+ Vector<uint8_t> newdata;
newdata.resize(p_img->get_width() * p_img->get_height() * 4);
- PoolVector<uint8_t>::Write w = newdata.write();
-
- decompress_pvrtc((PVRTCBlock *)r.ptr(), _2bit, p_img->get_width(), p_img->get_height(), 0, (unsigned char *)w.ptr());
+ uint8_t *w = newdata.ptrw();
- w.release();
- r.release();
+ decompress_pvrtc((PVRTCBlock *)r, _2bit, p_img->get_width(), p_img->get_height(), 0, (unsigned char *)w);
bool make_mipmaps = p_img->has_mipmaps();
p_img->create(p_img->get_width(), p_img->get_height(), false, Image::FORMAT_RGBA8, newdata);
diff --git a/modules/recast/SCsub b/modules/recast/SCsub
deleted file mode 100644
index 94d9968164..0000000000
--- a/modules/recast/SCsub
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/usr/bin/env python
-
-Import('env')
-Import('env_modules')
-
-env_recast = env_modules.Clone()
-
-# Thirdparty source files
-if env['builtin_recast']:
- thirdparty_dir = "#thirdparty/recastnavigation/Recast/"
- thirdparty_sources = [
- "Source/Recast.cpp",
- "Source/RecastAlloc.cpp",
- "Source/RecastArea.cpp",
- "Source/RecastAssert.cpp",
- "Source/RecastContour.cpp",
- "Source/RecastFilter.cpp",
- "Source/RecastLayers.cpp",
- "Source/RecastMesh.cpp",
- "Source/RecastMeshDetail.cpp",
- "Source/RecastRasterization.cpp",
- "Source/RecastRegion.cpp",
- ]
- thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
-
- env_recast.Prepend(CPPPATH=[thirdparty_dir + "/Include"])
-
- env_thirdparty = env_recast.Clone()
- env_thirdparty.disable_warnings()
- env_thirdparty.add_source_files(env.modules_sources, thirdparty_sources)
-
-# Godot source files
-env_recast.add_source_files(env.modules_sources, "*.cpp")
diff --git a/modules/register_module_types.h b/modules/register_module_types.h
index b410457201..acd9fc7c97 100644
--- a/modules/register_module_types.h
+++ b/modules/register_module_types.h
@@ -31,6 +31,7 @@
#ifndef REGISTER_MODULE_TYPES_H
#define REGISTER_MODULE_TYPES_H
+void preregister_module_types();
void register_module_types();
void unregister_module_types();
diff --git a/modules/squish/image_compress_squish.cpp b/modules/squish/image_compress_squish.cpp
index 58b8115dfc..bb77f68590 100644
--- a/modules/squish/image_compress_squish.cpp
+++ b/modules/squish/image_compress_squish.cpp
@@ -37,20 +37,20 @@ void image_decompress_squish(Image *p_image) {
int h = p_image->get_height();
Image::Format target_format = Image::FORMAT_RGBA8;
- PoolVector<uint8_t> data;
+ Vector<uint8_t> data;
int target_size = Image::get_image_data_size(w, h, target_format, p_image->has_mipmaps());
int mm_count = p_image->get_mipmap_count();
data.resize(target_size);
- PoolVector<uint8_t>::Read rb = p_image->get_data().read();
- PoolVector<uint8_t>::Write wb = data.write();
+ const uint8_t *rb = p_image->get_data().ptr();
+ uint8_t *wb = data.ptrw();
int squish_flags = Image::FORMAT_MAX;
if (p_image->get_format() == Image::FORMAT_DXT1) {
squish_flags = squish::kDxt1;
} else if (p_image->get_format() == Image::FORMAT_DXT3) {
squish_flags = squish::kDxt3;
- } else if (p_image->get_format() == Image::FORMAT_DXT5) {
+ } else if (p_image->get_format() == Image::FORMAT_DXT5 || p_image->get_format() == Image::FORMAT_DXT5_RA_AS_RG) {
squish_flags = squish::kDxt5;
} else if (p_image->get_format() == Image::FORMAT_RGTC_R) {
squish_flags = squish::kBc4;
@@ -71,9 +71,13 @@ void image_decompress_squish(Image *p_image) {
}
p_image->create(p_image->get_width(), p_image->get_height(), p_image->has_mipmaps(), target_format, data);
+
+ if (p_image->get_format() == Image::FORMAT_DXT5_RA_AS_RG) {
+ p_image->convert_ra_rgba8_to_rg();
+ }
}
-void image_compress_squish(Image *p_image, float p_lossy_quality, Image::CompressSource p_source) {
+void image_compress_squish(Image *p_image, float p_lossy_quality, Image::UsedChannels p_channels) {
if (p_image->get_format() >= Image::FORMAT_DXT1)
return; //do not compress, already compressed
@@ -92,75 +96,35 @@ void image_compress_squish(Image *p_image, float p_lossy_quality, Image::Compres
Image::Format target_format = Image::FORMAT_RGBA8;
- Image::DetectChannels dc = p_image->get_detected_channels();
-
- if (p_source == Image::COMPRESS_SOURCE_LAYERED) {
- //keep what comes in
- switch (p_image->get_format()) {
- case Image::FORMAT_L8: {
- dc = Image::DETECTED_L;
- } break;
- case Image::FORMAT_LA8: {
- dc = Image::DETECTED_LA;
- } break;
- case Image::FORMAT_R8: {
- dc = Image::DETECTED_R;
- } break;
- case Image::FORMAT_RG8: {
- dc = Image::DETECTED_RG;
- } break;
- case Image::FORMAT_RGB8: {
- dc = Image::DETECTED_RGB;
- } break;
- case Image::FORMAT_RGBA8:
- case Image::FORMAT_RGBA4444:
- case Image::FORMAT_RGBA5551: {
- dc = Image::DETECTED_RGBA;
- } break;
- default: {
- }
- }
- }
-
p_image->convert(Image::FORMAT_RGBA8); //still uses RGBA to convert
- if (p_source == Image::COMPRESS_SOURCE_SRGB && (dc == Image::DETECTED_R || dc == Image::DETECTED_RG)) {
- //R and RG do not support SRGB
- dc = Image::DETECTED_RGB;
- }
-
- if (p_source == Image::COMPRESS_SOURCE_NORMAL) {
- //R and RG do not support SRGB
- dc = Image::DETECTED_RG;
- }
-
- switch (dc) {
- case Image::DETECTED_L: {
+ switch (p_channels) {
+ case Image::USED_CHANNELS_L: {
target_format = Image::FORMAT_DXT1;
squish_comp |= squish::kDxt1;
} break;
- case Image::DETECTED_LA: {
+ case Image::USED_CHANNELS_LA: {
target_format = Image::FORMAT_DXT5;
squish_comp |= squish::kDxt5;
} break;
- case Image::DETECTED_R: {
+ case Image::USED_CHANNELS_R: {
target_format = Image::FORMAT_RGTC_R;
squish_comp |= squish::kBc4;
} break;
- case Image::DETECTED_RG: {
+ case Image::USED_CHANNELS_RG: {
target_format = Image::FORMAT_RGTC_RG;
squish_comp |= squish::kBc5;
} break;
- case Image::DETECTED_RGB: {
+ case Image::USED_CHANNELS_RGB: {
target_format = Image::FORMAT_DXT1;
squish_comp |= squish::kDxt1;
} break;
- case Image::DETECTED_RGBA: {
+ case Image::USED_CHANNELS_RGBA: {
//TODO, should convert both, then measure which one does a better job
target_format = Image::FORMAT_DXT5;
@@ -173,14 +137,14 @@ void image_compress_squish(Image *p_image, float p_lossy_quality, Image::Compres
}
}
- PoolVector<uint8_t> data;
+ Vector<uint8_t> data;
int target_size = Image::get_image_data_size(w, h, target_format, p_image->has_mipmaps());
int mm_count = p_image->has_mipmaps() ? Image::get_image_required_mipmaps(w, h, target_format) : 0;
data.resize(target_size);
int shift = Image::get_format_pixel_rshift(target_format);
- PoolVector<uint8_t>::Read rb = p_image->get_data().read();
- PoolVector<uint8_t>::Write wb = data.write();
+ const uint8_t *rb = p_image->get_data().ptr();
+ uint8_t *wb = data.ptrw();
int dst_ofs = 0;
@@ -196,9 +160,6 @@ void image_compress_squish(Image *p_image, float p_lossy_quality, Image::Compres
h = MAX(h / 2, 1);
}
- rb.release();
- wb.release();
-
p_image->create(p_image->get_width(), p_image->get_height(), p_image->has_mipmaps(), target_format, data);
}
}
diff --git a/modules/squish/image_compress_squish.h b/modules/squish/image_compress_squish.h
index b5a209ceb9..19e6d57474 100644
--- a/modules/squish/image_compress_squish.h
+++ b/modules/squish/image_compress_squish.h
@@ -33,7 +33,7 @@
#include "core/image.h"
-void image_compress_squish(Image *p_image, float p_lossy_quality, Image::CompressSource p_source);
+void image_compress_squish(Image *p_image, float p_lossy_quality, Image::UsedChannels p_channels);
void image_decompress_squish(Image *p_image);
#endif // IMAGE_COMPRESS_SQUISH_H
diff --git a/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp b/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp
index f2d0f5c9a6..054ed088df 100644
--- a/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp
+++ b/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp
@@ -163,32 +163,32 @@ void AudioStreamOGGVorbis::clear_data() {
}
}
-void AudioStreamOGGVorbis::set_data(const PoolVector<uint8_t> &p_data) {
+void AudioStreamOGGVorbis::set_data(const Vector<uint8_t> &p_data) {
int src_data_len = p_data.size();
#define MAX_TEST_MEM (1 << 20)
uint32_t alloc_try = 1024;
- PoolVector<char> alloc_mem;
- PoolVector<char>::Write w;
+ Vector<char> alloc_mem;
+ char *w;
stb_vorbis *ogg_stream = NULL;
stb_vorbis_alloc ogg_alloc;
while (alloc_try < MAX_TEST_MEM) {
alloc_mem.resize(alloc_try);
- w = alloc_mem.write();
+ w = alloc_mem.ptrw();
- ogg_alloc.alloc_buffer = w.ptr();
+ ogg_alloc.alloc_buffer = w;
ogg_alloc.alloc_buffer_length_in_bytes = alloc_try;
- PoolVector<uint8_t>::Read src_datar = p_data.read();
+ const uint8_t *src_datar = p_data.ptr();
int error;
- ogg_stream = stb_vorbis_open_memory((const unsigned char *)src_datar.ptr(), src_data_len, &error, &ogg_alloc);
+ ogg_stream = stb_vorbis_open_memory((const unsigned char *)src_datar, src_data_len, &error, &ogg_alloc);
if (!ogg_stream && error == VORBIS_outofmem) {
- w.release();
+
alloc_try *= 2;
} else {
@@ -209,7 +209,7 @@ void AudioStreamOGGVorbis::set_data(const PoolVector<uint8_t> &p_data) {
// free any existing data
clear_data();
- data = AudioServer::get_singleton()->audio_data_alloc(src_data_len, src_datar.ptr());
+ data = AudioServer::get_singleton()->audio_data_alloc(src_data_len, src_datar);
data_len = src_data_len;
break;
@@ -217,15 +217,15 @@ void AudioStreamOGGVorbis::set_data(const PoolVector<uint8_t> &p_data) {
}
}
-PoolVector<uint8_t> AudioStreamOGGVorbis::get_data() const {
+Vector<uint8_t> AudioStreamOGGVorbis::get_data() const {
- PoolVector<uint8_t> vdata;
+ Vector<uint8_t> vdata;
if (data_len && data) {
vdata.resize(data_len);
{
- PoolVector<uint8_t>::Write w = vdata.write();
- copymem(w.ptr(), data, data_len);
+ uint8_t *w = vdata.ptrw();
+ copymem(w, data, data_len);
}
}
@@ -265,9 +265,9 @@ void AudioStreamOGGVorbis::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_loop_offset", "seconds"), &AudioStreamOGGVorbis::set_loop_offset);
ClassDB::bind_method(D_METHOD("get_loop_offset"), &AudioStreamOGGVorbis::get_loop_offset);
- ADD_PROPERTY(PropertyInfo(Variant::POOL_BYTE_ARRAY, "data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_data", "get_data");
+ ADD_PROPERTY(PropertyInfo(Variant::PACKED_BYTE_ARRAY, "data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_data", "get_data");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "loop"), "set_loop", "has_loop");
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "loop_offset"), "set_loop_offset", "get_loop_offset");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "loop_offset"), "set_loop_offset", "get_loop_offset");
}
AudioStreamOGGVorbis::AudioStreamOGGVorbis() {
diff --git a/modules/stb_vorbis/audio_stream_ogg_vorbis.h b/modules/stb_vorbis/audio_stream_ogg_vorbis.h
index e909759acb..f296e8c19f 100644
--- a/modules/stb_vorbis/audio_stream_ogg_vorbis.h
+++ b/modules/stb_vorbis/audio_stream_ogg_vorbis.h
@@ -102,8 +102,8 @@ public:
virtual Ref<AudioStreamPlayback> instance_playback();
virtual String get_stream_name() const;
- void set_data(const PoolVector<uint8_t> &p_data);
- PoolVector<uint8_t> get_data() const;
+ void set_data(const Vector<uint8_t> &p_data);
+ Vector<uint8_t> get_data() const;
virtual float get_length() const; //if supported, otherwise return 0
diff --git a/modules/stb_vorbis/doc_classes/AudioStreamOGGVorbis.xml b/modules/stb_vorbis/doc_classes/AudioStreamOGGVorbis.xml
index 38d3bd5468..8a1bb62e24 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="PoolByteArray" setter="set_data" getter="get_data" default="PoolByteArray( )">
+ <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/resource_importer_ogg_vorbis.cpp b/modules/stb_vorbis/resource_importer_ogg_vorbis.cpp
index 06399f4005..13d96541e3 100644
--- a/modules/stb_vorbis/resource_importer_ogg_vorbis.cpp
+++ b/modules/stb_vorbis/resource_importer_ogg_vorbis.cpp
@@ -73,7 +73,7 @@ String ResourceImporterOGGVorbis::get_preset_name(int p_idx) const {
void ResourceImporterOGGVorbis::get_import_options(List<ImportOption> *r_options, int p_preset) const {
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "loop"), true));
- r_options->push_back(ImportOption(PropertyInfo(Variant::REAL, "loop_offset"), 0));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::FLOAT, "loop_offset"), 0));
}
Error ResourceImporterOGGVorbis::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) {
@@ -87,11 +87,11 @@ Error ResourceImporterOGGVorbis::import(const String &p_source_file, const Strin
size_t len = f->get_len();
- PoolVector<uint8_t> data;
+ Vector<uint8_t> data;
data.resize(len);
- PoolVector<uint8_t>::Write w = data.write();
+ uint8_t *w = data.ptrw();
- f->get_buffer(w.ptr(), len);
+ f->get_buffer(w, len);
memdelete(f);
diff --git a/modules/svg/image_loader_svg.cpp b/modules/svg/image_loader_svg.cpp
index 7f91908a33..e9d30d015a 100644
--- a/modules/svg/image_loader_svg.cpp
+++ b/modules/svg/image_loader_svg.cpp
@@ -94,10 +94,10 @@ void ImageLoaderSVG::set_convert_colors(Dictionary *p_replace_color) {
}
}
-Error ImageLoaderSVG::_create_image(Ref<Image> p_image, const PoolVector<uint8_t> *p_data, float p_scale, bool upsample, bool convert_colors) {
+Error ImageLoaderSVG::_create_image(Ref<Image> p_image, const Vector<uint8_t> *p_data, float p_scale, bool upsample, bool convert_colors) {
NSVGimage *svg_image;
- PoolVector<uint8_t>::Read src_r = p_data->read();
- svg_image = nsvgParse((char *)src_r.ptr(), "px", 96);
+ const uint8_t *src_r = p_data->ptr();
+ svg_image = nsvgParse((char *)src_r, "px", 96);
if (svg_image == NULL) {
ERR_PRINT("SVG Corrupted");
return ERR_FILE_CORRUPT;
@@ -115,14 +115,13 @@ Error ImageLoaderSVG::_create_image(Ref<Image> p_image, const PoolVector<uint8_t
const int h = (int)(svg_image->height * p_scale * upscale);
ERR_FAIL_COND_V_MSG(h > Image::MAX_HEIGHT, ERR_PARAMETER_RANGE_ERROR, vformat("Can't create image from SVG with scale %s, the resulting image size exceeds max height.", rtos(p_scale)));
- PoolVector<uint8_t> dst_image;
+ Vector<uint8_t> dst_image;
dst_image.resize(w * h * 4);
- PoolVector<uint8_t>::Write dw = dst_image.write();
+ uint8_t *dw = dst_image.ptrw();
- rasterizer.rasterize(svg_image, 0, 0, p_scale * upscale, (unsigned char *)dw.ptr(), w, h, w * 4);
+ rasterizer.rasterize(svg_image, 0, 0, p_scale * upscale, (unsigned char *)dw, w, h, w * 4);
- dw.release();
p_image->create(w, h, false, Image::FORMAT_RGBA8, dst_image);
if (upsample) {
p_image->shrink_x2();
@@ -136,10 +135,10 @@ Error ImageLoaderSVG::_create_image(Ref<Image> p_image, const PoolVector<uint8_t
Error ImageLoaderSVG::create_image_from_string(Ref<Image> p_image, const char *p_svg_str, float p_scale, bool upsample, bool convert_colors) {
size_t str_len = strlen(p_svg_str);
- PoolVector<uint8_t> src_data;
+ Vector<uint8_t> src_data;
src_data.resize(str_len + 1);
- PoolVector<uint8_t>::Write src_w = src_data.write();
- memcpy(src_w.ptr(), p_svg_str, str_len + 1);
+ uint8_t *src_w = src_data.ptrw();
+ memcpy(src_w, p_svg_str, str_len + 1);
return _create_image(p_image, &src_data, p_scale, upsample, convert_colors);
}
@@ -147,11 +146,11 @@ Error ImageLoaderSVG::create_image_from_string(Ref<Image> p_image, const char *p
Error ImageLoaderSVG::load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear, float p_scale) {
uint32_t size = f->get_len();
- PoolVector<uint8_t> src_image;
+ Vector<uint8_t> src_image;
src_image.resize(size + 1);
- PoolVector<uint8_t>::Write src_w = src_image.write();
- f->get_buffer(src_w.ptr(), size);
- src_w.ptr()[size] = '\0';
+ uint8_t *src_w = src_image.ptrw();
+ f->get_buffer(src_w, size);
+ src_w[size] = '\0';
return _create_image(p_image, &src_image, p_scale, 1.0);
}
diff --git a/modules/svg/image_loader_svg.h b/modules/svg/image_loader_svg.h
index 24cee82480..def2885199 100644
--- a/modules/svg/image_loader_svg.h
+++ b/modules/svg/image_loader_svg.h
@@ -60,7 +60,7 @@ class ImageLoaderSVG : public ImageFormatLoader {
} replace_colors;
static SVGRasterizer rasterizer;
static void _convert_colors(NSVGimage *p_svg_image);
- static Error _create_image(Ref<Image> p_image, const PoolVector<uint8_t> *p_data, float p_scale, bool upsample, bool convert_colors = false);
+ static Error _create_image(Ref<Image> p_image, const Vector<uint8_t> *p_data, float p_scale, bool upsample, bool convert_colors = false);
public:
static void set_convert_colors(Dictionary *p_replace_color = NULL);
diff --git a/modules/tga/image_loader_tga.cpp b/modules/tga/image_loader_tga.cpp
index 480016eb97..0e904fdd76 100644
--- a/modules/tga/image_loader_tga.cpp
+++ b/modules/tga/image_loader_tga.cpp
@@ -36,12 +36,12 @@
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 error;
- PoolVector<uint8_t> pixels;
+ Vector<uint8_t> pixels;
error = pixels.resize(p_pixel_size);
if (error != OK)
return error;
- PoolVector<uint8_t>::Write pixels_w = pixels.write();
+ uint8_t *pixels_w = pixels.ptrw();
size_t compressed_pos = 0;
size_t output_pos = 0;
@@ -55,12 +55,12 @@ Error ImageLoaderTGA::decode_tga_rle(const uint8_t *p_compressed_buffer, size_t
if (c & 0x80) {
for (size_t i = 0; i < p_pixel_size; i++) {
- pixels_w.ptr()[i] = p_compressed_buffer[compressed_pos];
+ pixels_w[i] = p_compressed_buffer[compressed_pos];
compressed_pos += 1;
}
for (size_t i = 0; i < count; i++) {
for (size_t j = 0; j < p_pixel_size; j++) {
- p_uncompressed_buffer[output_pos + j] = pixels_w.ptr()[j];
+ p_uncompressed_buffer[output_pos + j] = pixels_w[j];
}
output_pos += p_pixel_size;
}
@@ -116,9 +116,9 @@ Error ImageLoaderTGA::convert_to_image(Ref<Image> p_image, const uint8_t *p_buff
x_end = -1;
}
- PoolVector<uint8_t> image_data;
+ Vector<uint8_t> image_data;
image_data.resize(width * height * sizeof(uint32_t));
- PoolVector<uint8_t>::Write image_data_w = image_data.write();
+ uint8_t *image_data_w = image_data.ptrw();
size_t i = 0;
uint32_t x = x_start;
@@ -199,8 +199,6 @@ Error ImageLoaderTGA::convert_to_image(Ref<Image> p_image, const uint8_t *p_buff
}
}
- image_data_w.release();
-
p_image->create(width, height, 0, Image::FORMAT_RGBA8, image_data);
return OK;
@@ -208,7 +206,7 @@ Error ImageLoaderTGA::convert_to_image(Ref<Image> p_image, const uint8_t *p_buff
Error ImageLoaderTGA::load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear, float p_scale) {
- PoolVector<uint8_t> src_image;
+ Vector<uint8_t> src_image;
int src_image_len = f->get_len();
ERR_FAIL_COND_V(src_image_len == 0, ERR_FILE_CORRUPT);
ERR_FAIL_COND_V(src_image_len < (int)sizeof(tga_header_s), ERR_FILE_CORRUPT);
@@ -259,49 +257,49 @@ Error ImageLoaderTGA::load_image(Ref<Image> p_image, FileAccess *f, bool p_force
if (err == OK) {
f->seek(f->get_position() + tga_header.id_length);
- PoolVector<uint8_t> palette;
+ Vector<uint8_t> palette;
if (has_color_map) {
size_t color_map_size = tga_header.color_map_length * (tga_header.color_map_depth >> 3);
err = palette.resize(color_map_size);
if (err == OK) {
- PoolVector<uint8_t>::Write palette_w = palette.write();
+ uint8_t *palette_w = palette.ptrw();
f->get_buffer(&palette_w[0], color_map_size);
} else {
return OK;
}
}
- PoolVector<uint8_t>::Write src_image_w = src_image.write();
+ uint8_t *src_image_w = src_image.ptrw();
f->get_buffer(&src_image_w[0], src_image_len - f->get_position());
- PoolVector<uint8_t>::Read src_image_r = src_image.read();
+ const uint8_t *src_image_r = src_image.ptr();
const size_t pixel_size = tga_header.pixel_depth >> 3;
const size_t buffer_size = (tga_header.image_width * tga_header.image_height) * pixel_size;
- PoolVector<uint8_t> uncompressed_buffer;
+ Vector<uint8_t> uncompressed_buffer;
uncompressed_buffer.resize(buffer_size);
- PoolVector<uint8_t>::Write uncompressed_buffer_w = uncompressed_buffer.write();
- PoolVector<uint8_t>::Read uncompressed_buffer_r;
+ uint8_t *uncompressed_buffer_w = uncompressed_buffer.ptrw();
+ const uint8_t *uncompressed_buffer_r;
const uint8_t *buffer = NULL;
if (is_encoded) {
- err = decode_tga_rle(src_image_r.ptr(), pixel_size, uncompressed_buffer_w.ptr(), buffer_size);
+ err = decode_tga_rle(src_image_r, pixel_size, uncompressed_buffer_w, buffer_size);
if (err == OK) {
- uncompressed_buffer_r = uncompressed_buffer.read();
- buffer = uncompressed_buffer_r.ptr();
+ uncompressed_buffer_r = uncompressed_buffer.ptr();
+ buffer = uncompressed_buffer_r;
}
} else {
- buffer = src_image_r.ptr();
+ buffer = src_image_r;
};
if (err == OK) {
- PoolVector<uint8_t>::Read palette_r = palette.read();
- err = convert_to_image(p_image, buffer, tga_header, palette_r.ptr(), is_monochrome);
+ const uint8_t *palette_r = palette.ptr();
+ err = convert_to_image(p_image, buffer, tga_header, palette_r, is_monochrome);
}
}
diff --git a/modules/theora/video_stream_theora.cpp b/modules/theora/video_stream_theora.cpp
index 00c7e87568..a44ed0304d 100644
--- a/modules/theora/video_stream_theora.cpp
+++ b/modules/theora/video_stream_theora.cpp
@@ -87,8 +87,8 @@ void VideoStreamPlaybackTheora::video_write(void) {
int pitch = 4;
frame_data.resize(size.x * size.y * pitch);
{
- PoolVector<uint8_t>::Write w = frame_data.write();
- char *dst = (char *)w.ptr();
+ uint8_t *w = frame_data.ptrw();
+ char *dst = (char *)w;
//uv_offset=(ti.pic_x/2)+(yuv[1].stride)*(ti.pic_y/2);
@@ -110,7 +110,7 @@ void VideoStreamPlaybackTheora::video_write(void) {
Ref<Image> img = memnew(Image(size.x, size.y, 0, Image::FORMAT_RGBA8, frame_data)); //zero copy image creation
- texture->set_data(img); //zero copy send to visual server
+ texture->update(img, true); //zero copy send to visual server
frames_pending = 1;
}
@@ -336,7 +336,9 @@ void VideoStreamPlaybackTheora::set_file(const String &p_file) {
size.x = w;
size.y = h;
- texture->create(w, h, Image::FORMAT_RGBA8, Texture::FLAG_FILTER | Texture::FLAG_VIDEO_SURFACE);
+ Ref<Image> img;
+ img.instance();
+ img->create(w, h, false, Image::FORMAT_RGBA8);
} else {
/* tear down the partial theora setup */
@@ -369,7 +371,7 @@ float VideoStreamPlaybackTheora::get_time() const {
return time - /* AudioServer::get_singleton()->get_output_latency() - */ delay_compensation;
};
-Ref<Texture> VideoStreamPlaybackTheora::get_texture() const {
+Ref<Texture2D> VideoStreamPlaybackTheora::get_texture() const {
return texture;
}
diff --git a/modules/theora/video_stream_theora.h b/modules/theora/video_stream_theora.h
index 0f201ffa9d..258b3a1cce 100644
--- a/modules/theora/video_stream_theora.h
+++ b/modules/theora/video_stream_theora.h
@@ -54,7 +54,7 @@ class VideoStreamPlaybackTheora : public VideoStreamPlayback {
//Image frames[MAX_FRAMES];
Image::Format format;
- PoolVector<uint8_t> frame_data;
+ Vector<uint8_t> frame_data;
int frames_pending;
FileAccess *file;
String file_name;
@@ -147,7 +147,7 @@ public:
void set_file(const String &p_file);
- virtual Ref<Texture> get_texture() const;
+ virtual Ref<Texture2D> get_texture() const;
virtual void update(float p_delta);
virtual void set_mix_callback(AudioMixCallback p_callback, void *p_userdata);
diff --git a/modules/tinyexr/image_loader_tinyexr.cpp b/modules/tinyexr/image_loader_tinyexr.cpp
index 79cb135abb..41938f5b42 100644
--- a/modules/tinyexr/image_loader_tinyexr.cpp
+++ b/modules/tinyexr/image_loader_tinyexr.cpp
@@ -37,12 +37,12 @@
Error ImageLoaderTinyEXR::load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear, float p_scale) {
- PoolVector<uint8_t> src_image;
+ Vector<uint8_t> src_image;
int src_image_len = f->get_len();
ERR_FAIL_COND_V(src_image_len == 0, ERR_FILE_CORRUPT);
src_image.resize(src_image_len);
- PoolVector<uint8_t>::Write w = src_image.write();
+ uint8_t *w = src_image.ptrw();
f->get_buffer(&w[0], src_image_len);
@@ -60,13 +60,13 @@ Error ImageLoaderTinyEXR::load_image(Ref<Image> p_image, FileAccess *f, bool p_f
InitEXRHeader(&exr_header);
- int ret = ParseEXRVersionFromMemory(&exr_version, w.ptr(), src_image_len);
+ int ret = ParseEXRVersionFromMemory(&exr_version, w, src_image_len);
if (ret != TINYEXR_SUCCESS) {
return ERR_FILE_CORRUPT;
}
- ret = ParseEXRHeaderFromMemory(&exr_header, &exr_version, w.ptr(), src_image_len, &err);
+ ret = ParseEXRHeaderFromMemory(&exr_header, &exr_version, w, src_image_len, &err);
if (ret != TINYEXR_SUCCESS) {
if (err) {
ERR_PRINT(String(err));
@@ -82,7 +82,7 @@ Error ImageLoaderTinyEXR::load_image(Ref<Image> p_image, FileAccess *f, bool p_f
}
InitEXRImage(&exr_image);
- ret = LoadEXRImageFromMemory(&exr_image, &exr_header, w.ptr(), src_image_len, &err);
+ ret = LoadEXRImageFromMemory(&exr_image, &exr_header, w, src_image_len, &err);
if (ret != TINYEXR_SUCCESS) {
if (err) {
ERR_PRINT(String(err));
@@ -136,7 +136,7 @@ Error ImageLoaderTinyEXR::load_image(Ref<Image> p_image, FileAccess *f, bool p_f
// EXR image data loaded, now parse it into Godot-friendly image data
- PoolVector<uint8_t> imgdata;
+ Vector<uint8_t> imgdata;
Image::Format format;
int output_channels = 0;
@@ -180,8 +180,8 @@ Error ImageLoaderTinyEXR::load_image(Ref<Image> p_image, FileAccess *f, bool p_f
}
{
- PoolVector<uint8_t>::Write wd = imgdata.write();
- uint16_t *iw = (uint16_t *)wd.ptr();
+ uint8_t *wd = imgdata.ptrw();
+ uint16_t *iw = (uint16_t *)wd;
// Assume `out_rgba` have enough memory allocated.
for (int tile_index = 0; tile_index < num_tiles; tile_index++) {
@@ -235,8 +235,6 @@ Error ImageLoaderTinyEXR::load_image(Ref<Image> p_image, FileAccess *f, bool p_f
p_image->create(exr_image.width, exr_image.height, false, format, imgdata);
- w.release();
-
FreeEXRHeader(&exr_header);
FreeEXRImage(&exr_image);
diff --git a/modules/tinyexr/image_saver_tinyexr.cpp b/modules/tinyexr/image_saver_tinyexr.cpp
index 17f920746f..05080289bd 100644
--- a/modules/tinyexr/image_saver_tinyexr.cpp
+++ b/modules/tinyexr/image_saver_tinyexr.cpp
@@ -58,7 +58,8 @@ static bool is_supported_format(Image::Format p_format) {
enum SrcPixelType {
SRC_FLOAT,
SRC_HALF,
- SRC_BYTE
+ SRC_BYTE,
+ SRC_UNSUPPORTED
};
static SrcPixelType get_source_pixel_type(Image::Format p_format) {
@@ -79,7 +80,7 @@ static SrcPixelType get_source_pixel_type(Image::Format p_format) {
case Image::FORMAT_RGBA8:
return SRC_BYTE;
default:
- CRASH_NOW();
+ return SRC_UNSUPPORTED;
}
}
@@ -101,7 +102,7 @@ static int get_target_pixel_type(Image::Format p_format) {
case Image::FORMAT_RGBA8:
return TINYEXR_PIXELTYPE_HALF;
default:
- CRASH_NOW();
+ return -1;
}
}
@@ -112,7 +113,7 @@ static int get_pixel_type_size(int p_pixel_type) {
case TINYEXR_PIXELTYPE_FLOAT:
return 4;
}
- CRASH_NOW();
+ return -1;
}
static int get_channel_count(Image::Format p_format) {
@@ -134,7 +135,7 @@ static int get_channel_count(Image::Format p_format) {
case Image::FORMAT_RGBA8:
return 4;
default:
- CRASH_NOW();
+ return -1;
}
}
@@ -158,7 +159,7 @@ Error save_exr(const String &p_path, const Ref<Image> &p_img, bool p_grayscale)
// Godot does not support more than 4 channels,
// so we can preallocate header infos on the stack and use only the subset we need
- PoolByteArray channels[max_channels];
+ PackedByteArray channels[max_channels];
unsigned char *channels_ptrs[max_channels];
EXRChannelInfo channel_infos[max_channels];
int pixel_types[max_channels];
@@ -173,35 +174,39 @@ Error save_exr(const String &p_path, const Ref<Image> &p_img, bool p_grayscale)
};
int channel_count = get_channel_count(format);
+ ERR_FAIL_COND_V(channel_count < 0, ERR_UNAVAILABLE);
ERR_FAIL_COND_V(p_grayscale && channel_count != 1, ERR_INVALID_PARAMETER);
int target_pixel_type = get_target_pixel_type(format);
+ ERR_FAIL_COND_V(target_pixel_type < 0, ERR_UNAVAILABLE);
int target_pixel_type_size = get_pixel_type_size(target_pixel_type);
+ ERR_FAIL_COND_V(target_pixel_type_size < 0, ERR_UNAVAILABLE);
SrcPixelType src_pixel_type = get_source_pixel_type(format);
+ ERR_FAIL_COND_V(src_pixel_type == SRC_UNSUPPORTED, ERR_UNAVAILABLE);
const int pixel_count = p_img->get_width() * p_img->get_height();
const int *channel_mapping = channel_mappings[channel_count - 1];
{
- PoolByteArray src_data = p_img->get_data();
- PoolByteArray::Read src_r = src_data.read();
+ PackedByteArray src_data = p_img->get_data();
+ const uint8_t *src_r = src_data.ptr();
for (int channel_index = 0; channel_index < channel_count; ++channel_index) {
// De-interleave channels
- PoolByteArray &dst = channels[channel_index];
+ PackedByteArray &dst = channels[channel_index];
dst.resize(pixel_count * target_pixel_type_size);
- PoolByteArray::Write dst_w = dst.write();
+ uint8_t *dst_w = dst.ptrw();
if (src_pixel_type == SRC_FLOAT && target_pixel_type == TINYEXR_PIXELTYPE_FLOAT) {
// Note: we don't save mipmaps
CRASH_COND(src_data.size() < pixel_count * channel_count * target_pixel_type_size);
- const float *src_rp = (float *)src_r.ptr();
- float *dst_wp = (float *)dst_w.ptr();
+ const float *src_rp = (float *)src_r;
+ float *dst_wp = (float *)dst_w;
for (int i = 0; i < pixel_count; ++i) {
dst_wp[i] = src_rp[channel_index + i * channel_count];
@@ -211,8 +216,8 @@ Error save_exr(const String &p_path, const Ref<Image> &p_img, bool p_grayscale)
CRASH_COND(src_data.size() < pixel_count * channel_count * target_pixel_type_size);
- const uint16_t *src_rp = (uint16_t *)src_r.ptr();
- uint16_t *dst_wp = (uint16_t *)dst_w.ptr();
+ const uint16_t *src_rp = (uint16_t *)src_r;
+ uint16_t *dst_wp = (uint16_t *)dst_w;
for (int i = 0; i < pixel_count; ++i) {
dst_wp[i] = src_rp[channel_index + i * channel_count];
@@ -222,8 +227,8 @@ Error save_exr(const String &p_path, const Ref<Image> &p_img, bool p_grayscale)
CRASH_COND(src_data.size() < pixel_count * channel_count);
- const uint8_t *src_rp = (uint8_t *)src_r.ptr();
- uint16_t *dst_wp = (uint16_t *)dst_w.ptr();
+ const uint8_t *src_rp = (uint8_t *)src_r;
+ uint16_t *dst_wp = (uint16_t *)dst_w;
for (int i = 0; i < pixel_count; ++i) {
dst_wp[i] = Math::make_half_float(src_rp[channel_index + i * channel_count] / 255.f);
@@ -235,7 +240,7 @@ Error save_exr(const String &p_path, const Ref<Image> &p_img, bool p_grayscale)
int remapped_index = channel_mapping[channel_index];
- channels_ptrs[remapped_index] = dst_w.ptr();
+ channels_ptrs[remapped_index] = dst_w;
// No conversion
pixel_types[remapped_index] = target_pixel_type;
diff --git a/modules/visual_script/doc_classes/VisualScript.xml b/modules/visual_script/doc_classes/VisualScript.xml
index 9cd79aa781..db1ef2adc6 100644
--- a/modules/visual_script/doc_classes/VisualScript.xml
+++ b/modules/visual_script/doc_classes/VisualScript.xml
@@ -15,7 +15,7 @@
<method name="add_custom_signal">
<return type="void">
</return>
- <argument index="0" name="name" type="String">
+ <argument index="0" name="name" type="StringName">
</argument>
<description>
Add a custom signal with the specified name to the VisualScript.
@@ -24,7 +24,7 @@
<method name="add_function">
<return type="void">
</return>
- <argument index="0" name="name" type="String">
+ <argument index="0" name="name" type="StringName">
</argument>
<description>
Add a function with the specified name to the VisualScript.
@@ -33,7 +33,7 @@
<method name="add_node">
<return type="void">
</return>
- <argument index="0" name="func" type="String">
+ <argument index="0" name="func" type="StringName">
</argument>
<argument index="1" name="id" type="int">
</argument>
@@ -48,7 +48,7 @@
<method name="add_variable">
<return type="void">
</return>
- <argument index="0" name="name" type="String">
+ <argument index="0" name="name" type="StringName">
</argument>
<argument index="1" name="default_value" type="Variant" default="null">
</argument>
@@ -61,7 +61,7 @@
<method name="custom_signal_add_argument">
<return type="void">
</return>
- <argument index="0" name="name" type="String">
+ <argument index="0" name="name" type="StringName">
</argument>
<argument index="1" name="type" type="int" enum="Variant.Type">
</argument>
@@ -76,7 +76,7 @@
<method name="custom_signal_get_argument_count" qualifiers="const">
<return type="int">
</return>
- <argument index="0" name="name" type="String">
+ <argument index="0" name="name" type="StringName">
</argument>
<description>
Get the count of a custom signal's arguments.
@@ -85,7 +85,7 @@
<method name="custom_signal_get_argument_name" qualifiers="const">
<return type="String">
</return>
- <argument index="0" name="name" type="String">
+ <argument index="0" name="name" type="StringName">
</argument>
<argument index="1" name="argidx" type="int">
</argument>
@@ -96,7 +96,7 @@
<method name="custom_signal_get_argument_type" qualifiers="const">
<return type="int" enum="Variant.Type">
</return>
- <argument index="0" name="name" type="String">
+ <argument index="0" name="name" type="StringName">
</argument>
<argument index="1" name="argidx" type="int">
</argument>
@@ -107,7 +107,7 @@
<method name="custom_signal_remove_argument">
<return type="void">
</return>
- <argument index="0" name="name" type="String">
+ <argument index="0" name="name" type="StringName">
</argument>
<argument index="1" name="argidx" type="int">
</argument>
@@ -118,7 +118,7 @@
<method name="custom_signal_set_argument_name">
<return type="void">
</return>
- <argument index="0" name="name" type="String">
+ <argument index="0" name="name" type="StringName">
</argument>
<argument index="1" name="argidx" type="int">
</argument>
@@ -131,7 +131,7 @@
<method name="custom_signal_set_argument_type">
<return type="void">
</return>
- <argument index="0" name="name" type="String">
+ <argument index="0" name="name" type="StringName">
</argument>
<argument index="1" name="argidx" type="int">
</argument>
@@ -144,7 +144,7 @@
<method name="custom_signal_swap_argument">
<return type="void">
</return>
- <argument index="0" name="name" type="String">
+ <argument index="0" name="name" type="StringName">
</argument>
<argument index="1" name="argidx" type="int">
</argument>
@@ -157,7 +157,7 @@
<method name="data_connect">
<return type="void">
</return>
- <argument index="0" name="func" type="String">
+ <argument index="0" name="func" type="StringName">
</argument>
<argument index="1" name="from_node" type="int">
</argument>
@@ -174,7 +174,7 @@
<method name="data_disconnect">
<return type="void">
</return>
- <argument index="0" name="func" type="String">
+ <argument index="0" name="func" type="StringName">
</argument>
<argument index="1" name="from_node" type="int">
</argument>
@@ -191,7 +191,7 @@
<method name="get_function_node_id" qualifiers="const">
<return type="int">
</return>
- <argument index="0" name="name" type="String">
+ <argument index="0" name="name" type="StringName">
</argument>
<description>
Returns the id of a function's entry point node.
@@ -200,7 +200,7 @@
<method name="get_function_scroll" qualifiers="const">
<return type="Vector2">
</return>
- <argument index="0" name="name" type="String">
+ <argument index="0" name="name" type="StringName">
</argument>
<description>
Returns the position of the center of the screen for a given function.
@@ -209,7 +209,7 @@
<method name="get_node" qualifiers="const">
<return type="VisualScriptNode">
</return>
- <argument index="0" name="func" type="String">
+ <argument index="0" name="func" type="StringName">
</argument>
<argument index="1" name="id" type="int">
</argument>
@@ -220,7 +220,7 @@
<method name="get_node_position" qualifiers="const">
<return type="Vector2">
</return>
- <argument index="0" name="func" type="String">
+ <argument index="0" name="func" type="StringName">
</argument>
<argument index="1" name="id" type="int">
</argument>
@@ -231,7 +231,7 @@
<method name="get_variable_default_value" qualifiers="const">
<return type="Variant">
</return>
- <argument index="0" name="name" type="String">
+ <argument index="0" name="name" type="StringName">
</argument>
<description>
Returns the default (initial) value of a variable.
@@ -240,7 +240,7 @@
<method name="get_variable_export" qualifiers="const">
<return type="bool">
</return>
- <argument index="0" name="name" type="String">
+ <argument index="0" name="name" type="StringName">
</argument>
<description>
Returns whether a variable is exported.
@@ -249,7 +249,7 @@
<method name="get_variable_info" qualifiers="const">
<return type="Dictionary">
</return>
- <argument index="0" name="name" type="String">
+ <argument index="0" name="name" type="StringName">
</argument>
<description>
Returns the information for a given variable as a dictionary. The information includes its name, type, hint and usage.
@@ -258,7 +258,7 @@
<method name="has_custom_signal" qualifiers="const">
<return type="bool">
</return>
- <argument index="0" name="name" type="String">
+ <argument index="0" name="name" type="StringName">
</argument>
<description>
Returns whether a signal exists with the specified name.
@@ -267,7 +267,7 @@
<method name="has_data_connection" qualifiers="const">
<return type="bool">
</return>
- <argument index="0" name="func" type="String">
+ <argument index="0" name="func" type="StringName">
</argument>
<argument index="1" name="from_node" type="int">
</argument>
@@ -284,7 +284,7 @@
<method name="has_function" qualifiers="const">
<return type="bool">
</return>
- <argument index="0" name="name" type="String">
+ <argument index="0" name="name" type="StringName">
</argument>
<description>
Returns whether a function exists with the specified name.
@@ -293,7 +293,7 @@
<method name="has_node" qualifiers="const">
<return type="bool">
</return>
- <argument index="0" name="func" type="String">
+ <argument index="0" name="func" type="StringName">
</argument>
<argument index="1" name="id" type="int">
</argument>
@@ -304,7 +304,7 @@
<method name="has_sequence_connection" qualifiers="const">
<return type="bool">
</return>
- <argument index="0" name="func" type="String">
+ <argument index="0" name="func" type="StringName">
</argument>
<argument index="1" name="from_node" type="int">
</argument>
@@ -319,7 +319,7 @@
<method name="has_variable" qualifiers="const">
<return type="bool">
</return>
- <argument index="0" name="name" type="String">
+ <argument index="0" name="name" type="StringName">
</argument>
<description>
Returns whether a variable exists with the specified name.
@@ -328,7 +328,7 @@
<method name="remove_custom_signal">
<return type="void">
</return>
- <argument index="0" name="name" type="String">
+ <argument index="0" name="name" type="StringName">
</argument>
<description>
Remove a custom signal with the given name.
@@ -337,7 +337,7 @@
<method name="remove_function">
<return type="void">
</return>
- <argument index="0" name="name" type="String">
+ <argument index="0" name="name" type="StringName">
</argument>
<description>
Remove a specific function and its nodes from the script.
@@ -346,7 +346,7 @@
<method name="remove_node">
<return type="void">
</return>
- <argument index="0" name="func" type="String">
+ <argument index="0" name="func" type="StringName">
</argument>
<argument index="1" name="id" type="int">
</argument>
@@ -357,7 +357,7 @@
<method name="remove_variable">
<return type="void">
</return>
- <argument index="0" name="name" type="String">
+ <argument index="0" name="name" type="StringName">
</argument>
<description>
Remove a variable with the given name.
@@ -366,9 +366,9 @@
<method name="rename_custom_signal">
<return type="void">
</return>
- <argument index="0" name="name" type="String">
+ <argument index="0" name="name" type="StringName">
</argument>
- <argument index="1" name="new_name" type="String">
+ <argument index="1" name="new_name" type="StringName">
</argument>
<description>
Change the name of a custom signal.
@@ -377,9 +377,9 @@
<method name="rename_function">
<return type="void">
</return>
- <argument index="0" name="name" type="String">
+ <argument index="0" name="name" type="StringName">
</argument>
- <argument index="1" name="new_name" type="String">
+ <argument index="1" name="new_name" type="StringName">
</argument>
<description>
Change the name of a function.
@@ -388,9 +388,9 @@
<method name="rename_variable">
<return type="void">
</return>
- <argument index="0" name="name" type="String">
+ <argument index="0" name="name" type="StringName">
</argument>
- <argument index="1" name="new_name" type="String">
+ <argument index="1" name="new_name" type="StringName">
</argument>
<description>
Change the name of a variable.
@@ -399,7 +399,7 @@
<method name="sequence_connect">
<return type="void">
</return>
- <argument index="0" name="func" type="String">
+ <argument index="0" name="func" type="StringName">
</argument>
<argument index="1" name="from_node" type="int">
</argument>
@@ -415,7 +415,7 @@
<method name="sequence_disconnect">
<return type="void">
</return>
- <argument index="0" name="func" type="String">
+ <argument index="0" name="func" type="StringName">
</argument>
<argument index="1" name="from_node" type="int">
</argument>
@@ -430,7 +430,7 @@
<method name="set_function_scroll">
<return type="void">
</return>
- <argument index="0" name="name" type="String">
+ <argument index="0" name="name" type="StringName">
</argument>
<argument index="1" name="ofs" type="Vector2">
</argument>
@@ -441,7 +441,7 @@
<method name="set_instance_base_type">
<return type="void">
</return>
- <argument index="0" name="type" type="String">
+ <argument index="0" name="type" type="StringName">
</argument>
<description>
Set the base type of the script.
@@ -450,7 +450,7 @@
<method name="set_node_position">
<return type="void">
</return>
- <argument index="0" name="func" type="String">
+ <argument index="0" name="func" type="StringName">
</argument>
<argument index="1" name="id" type="int">
</argument>
@@ -463,7 +463,7 @@
<method name="set_variable_default_value">
<return type="void">
</return>
- <argument index="0" name="name" type="String">
+ <argument index="0" name="name" type="StringName">
</argument>
<argument index="1" name="value" type="Variant">
</argument>
@@ -474,7 +474,7 @@
<method name="set_variable_export">
<return type="void">
</return>
- <argument index="0" name="name" type="String">
+ <argument index="0" name="name" type="StringName">
</argument>
<argument index="1" name="enable" type="bool">
</argument>
@@ -485,7 +485,7 @@
<method name="set_variable_info">
<return type="void">
</return>
- <argument index="0" name="name" type="String">
+ <argument index="0" name="name" type="StringName">
</argument>
<argument index="1" name="value" type="Dictionary">
</argument>
diff --git a/modules/visual_script/doc_classes/VisualScriptBasicTypeConstant.xml b/modules/visual_script/doc_classes/VisualScriptBasicTypeConstant.xml
index c8e391c4a1..4d07f878a2 100644
--- a/modules/visual_script/doc_classes/VisualScriptBasicTypeConstant.xml
+++ b/modules/visual_script/doc_classes/VisualScriptBasicTypeConstant.xml
@@ -14,7 +14,7 @@
<member name="basic_type" type="int" setter="set_basic_type" getter="get_basic_type" enum="Variant.Type" default="0">
The type to get the constant from.
</member>
- <member name="constant" type="String" setter="set_basic_type_constant" getter="get_basic_type_constant">
+ <member name="constant" type="StringName" setter="set_basic_type_constant" getter="get_basic_type_constant">
The name of the constant to return.
</member>
</members>
diff --git a/modules/visual_script/doc_classes/VisualScriptBuiltinFunc.xml b/modules/visual_script/doc_classes/VisualScriptBuiltinFunc.xml
index 95085d9652..ef4183e6f6 100644
--- a/modules/visual_script/doc_classes/VisualScriptBuiltinFunc.xml
+++ b/modules/visual_script/doc_classes/VisualScriptBuiltinFunc.xml
@@ -89,7 +89,7 @@
<constant name="MATH_EASE" value="23" enum="BuiltinFunc">
Easing function, based on exponent. 0 is constant, 1 is linear, 0 to 1 is ease-in, 1+ is ease out. Negative values are in-out/out in.
</constant>
- <constant name="MATH_DECIMALS" value="24" enum="BuiltinFunc">
+ <constant name="MATH_STEP_DECIMALS" value="24" enum="BuiltinFunc">
Return the number of digit places after the decimal that the first non-zero digit occurs.
</constant>
<constant name="MATH_STEPIFY" value="25" enum="BuiltinFunc">
@@ -197,10 +197,10 @@
Deserialize a [Variant] from a string serialized using [constant VAR_TO_STR].
</constant>
<constant name="VAR_TO_BYTES" value="61" enum="BuiltinFunc">
- Serialize a [Variant] to a [PoolByteArray].
+ Serialize a [Variant] to a [PackedByteArray].
</constant>
<constant name="BYTES_TO_VAR" value="62" enum="BuiltinFunc">
- Deserialize a [Variant] from a [PoolByteArray] serialized using [constant VAR_TO_BYTES].
+ Deserialize a [Variant] from a [PackedByteArray] serialized using [constant VAR_TO_BYTES].
</constant>
<constant name="COLORN" value="63" enum="BuiltinFunc">
Return the [Color] with the given name and alpha ranging from 0 to 1.
diff --git a/modules/visual_script/doc_classes/VisualScriptClassConstant.xml b/modules/visual_script/doc_classes/VisualScriptClassConstant.xml
index cf35808823..de5d731cc0 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="String" 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="@&quot;Object&quot;">
The constant's parent class.
</member>
- <member name="constant" type="String" 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="@&quot;&quot;">
The constant to return. See the given class for its available constants.
</member>
</members>
diff --git a/modules/visual_script/doc_classes/VisualScriptEmitSignal.xml b/modules/visual_script/doc_classes/VisualScriptEmitSignal.xml
index 60a19ac7a7..5c9c8d3eca 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="String" setter="set_signal" getter="get_signal" default="&quot;&quot;">
+ <member name="signal" type="StringName" setter="set_signal" getter="get_signal" default="@&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 16c3af7ab2..2d0fac1fa0 100644
--- a/modules/visual_script/doc_classes/VisualScriptFunctionCall.xml
+++ b/modules/visual_script/doc_classes/VisualScriptFunctionCall.xml
@@ -11,19 +11,19 @@
<members>
<member name="base_script" type="String" setter="set_base_script" getter="get_base_script">
</member>
- <member name="base_type" type="String" 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="@&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="String" setter="set_function" getter="get_function" default="&quot;&quot;">
+ <member name="function" type="StringName" setter="set_function" getter="get_function" default="@&quot;&quot;">
</member>
<member name="node_path" type="NodePath" setter="set_base_path" getter="get_base_path">
</member>
<member name="rpc_call_mode" type="int" setter="set_rpc_call_mode" getter="get_rpc_call_mode" enum="VisualScriptFunctionCall.RPCCallMode" default="0">
</member>
- <member name="singleton" type="String" setter="set_singleton" getter="get_singleton">
+ <member name="singleton" type="StringName" setter="set_singleton" getter="get_singleton">
</member>
<member name="use_default_args" type="int" setter="set_use_default_args" getter="get_use_default_args">
</member>
diff --git a/modules/visual_script/doc_classes/VisualScriptInputAction.xml b/modules/visual_script/doc_classes/VisualScriptInputAction.xml
index 0b6325bf0a..6c296fdb4b 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="String" 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="@&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 6c31ae1a30..c3741eea89 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="String" 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="@&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 0a9a509958..619bbb90ca 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="String" 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="@&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 cf436116b8..f13d449064 100644
--- a/modules/visual_script/doc_classes/VisualScriptPropertyGet.xml
+++ b/modules/visual_script/doc_classes/VisualScriptPropertyGet.xml
@@ -11,15 +11,15 @@
<members>
<member name="base_script" type="String" setter="set_base_script" getter="get_base_script">
</member>
- <member name="base_type" type="String" 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="@&quot;Object&quot;">
</member>
<member name="basic_type" type="int" setter="set_basic_type" getter="get_basic_type" enum="Variant.Type">
</member>
- <member name="index" type="String" setter="set_index" getter="get_index">
+ <member name="index" type="StringName" setter="set_index" getter="get_index">
</member>
<member name="node_path" type="NodePath" setter="set_base_path" getter="get_base_path">
</member>
- <member name="property" type="String" setter="set_property" getter="get_property" default="&quot;&quot;">
+ <member name="property" type="StringName" setter="set_property" getter="get_property" default="@&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 357b4b9f5c..629576e261 100644
--- a/modules/visual_script/doc_classes/VisualScriptPropertySet.xml
+++ b/modules/visual_script/doc_classes/VisualScriptPropertySet.xml
@@ -13,15 +13,15 @@
</member>
<member name="base_script" type="String" setter="set_base_script" getter="get_base_script">
</member>
- <member name="base_type" type="String" 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="@&quot;Object&quot;">
</member>
<member name="basic_type" type="int" setter="set_basic_type" getter="get_basic_type" enum="Variant.Type">
</member>
- <member name="index" type="String" setter="set_index" getter="get_index">
+ <member name="index" type="StringName" setter="set_index" getter="get_index">
</member>
<member name="node_path" type="NodePath" setter="set_base_path" getter="get_base_path">
</member>
- <member name="property" type="String" setter="set_property" getter="get_property" default="&quot;&quot;">
+ <member name="property" type="StringName" setter="set_property" getter="get_property" default="@&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 43fe9d16ea..80a8d31041 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="String" 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="@&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 0746ab293e..d182e14e4d 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="String" setter="set_variable" getter="get_variable" default="&quot;&quot;">
+ <member name="var_name" type="StringName" setter="set_variable" getter="get_variable" default="@&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 e7d83e60ab..3bd392dd85 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="String" setter="set_variable" getter="get_variable" default="&quot;&quot;">
+ <member name="var_name" type="StringName" setter="set_variable" getter="get_variable" default="@&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 8f6941ce1e..483cdfeaf8 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="String" 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="@&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="String" setter="set_signal" getter="get_signal" default="&quot;&quot;">
+ <member name="signal" type="StringName" setter="set_signal" getter="get_signal" default="@&quot;&quot;">
</member>
</members>
<constants>
diff --git a/modules/visual_script/visual_script.cpp b/modules/visual_script/visual_script.cpp
index c591e3b5c2..70f650cfd3 100644
--- a/modules/visual_script/visual_script.cpp
+++ b/modules/visual_script/visual_script.cpp
@@ -30,6 +30,8 @@
#include "visual_script.h"
+#include <stdint.h>
+
#include "core/core_string_names.h"
#include "core/os/os.h"
#include "core/project_settings.h"
@@ -86,11 +88,11 @@ void VisualScriptNode::validate_input_default_values() {
continue;
} else {
//not the same, reconvert
- Variant::CallError ce;
+ Callable::CallError ce;
Variant existing = default_input_values[i];
const Variant *existingp = &existing;
default_input_values[i] = Variant::construct(expected, &existingp, 1, ce, false);
- if (ce.error != Variant::CallError::CALL_OK) {
+ if (ce.error != Callable::CallError::CALL_OK) {
//could not convert? force..
default_input_values[i] = Variant::construct(expected, NULL, 0, ce, false);
}
@@ -196,7 +198,7 @@ void VisualScript::remove_function(const StringName &p_name) {
for (Map<int, Function::NodeData>::Element *E = functions[p_name].nodes.front(); E; E = E->next()) {
- E->get().node->disconnect("ports_changed", this, "_node_ports_changed");
+ E->get().node->disconnect_compat("ports_changed", this, "_node_ports_changed");
E->get().node->scripts_used.erase(this);
}
@@ -338,7 +340,7 @@ void VisualScript::add_node(const StringName &p_func, int p_id, const Ref<Visual
nd.pos = p_pos;
Ref<VisualScriptNode> vsn = p_node;
- vsn->connect("ports_changed", this, "_node_ports_changed", varray(p_id));
+ vsn->connect_compat("ports_changed", this, "_node_ports_changed", varray(p_id));
vsn->scripts_used.insert(this);
vsn->validate_input_default_values(); // Validate when fully loaded
@@ -387,7 +389,7 @@ void VisualScript::remove_node(const StringName &p_func, int p_id) {
func.function_id = -1; //revert to invalid
}
- func.nodes[p_id].node->disconnect("ports_changed", this, "_node_ports_changed");
+ func.nodes[p_id].node->disconnect_compat("ports_changed", this, "_node_ports_changed");
func.nodes[p_id].node->scripts_used.erase(this);
func.nodes.erase(p_id);
@@ -1102,6 +1104,60 @@ bool VisualScript::are_subnodes_edited() const {
}
#endif
+Vector<ScriptNetData> VisualScript::get_rpc_methods() const {
+ return rpc_functions;
+}
+
+uint16_t VisualScript::get_rpc_method_id(const StringName &p_method) const {
+ for (int i = 0; i < rpc_functions.size(); i++) {
+ if (rpc_functions[i].name == p_method) {
+ return i;
+ }
+ }
+ return UINT16_MAX;
+}
+
+StringName VisualScript::get_rpc_method(const uint16_t p_rpc_method_id) const {
+ ERR_FAIL_COND_V(p_rpc_method_id >= rpc_functions.size(), StringName());
+ return rpc_functions[p_rpc_method_id].name;
+}
+
+MultiplayerAPI::RPCMode VisualScript::get_rpc_mode_by_id(const uint16_t p_rpc_method_id) const {
+ ERR_FAIL_COND_V(p_rpc_method_id >= rpc_functions.size(), MultiplayerAPI::RPC_MODE_DISABLED);
+ return rpc_functions[p_rpc_method_id].mode;
+}
+
+MultiplayerAPI::RPCMode VisualScript::get_rpc_mode(const StringName &p_method) const {
+ return get_rpc_mode_by_id(get_rpc_method_id(p_method));
+}
+
+Vector<ScriptNetData> VisualScript::get_rset_properties() const {
+ return rpc_variables;
+}
+
+uint16_t VisualScript::get_rset_property_id(const StringName &p_variable) const {
+ for (int i = 0; i < rpc_variables.size(); i++) {
+ if (rpc_variables[i].name == p_variable) {
+ return i;
+ }
+ }
+ return UINT16_MAX;
+}
+
+StringName VisualScript::get_rset_property(const uint16_t p_rset_property_id) const {
+ ERR_FAIL_COND_V(p_rset_property_id >= rpc_variables.size(), StringName());
+ return rpc_variables[p_rset_property_id].name;
+}
+
+MultiplayerAPI::RPCMode VisualScript::get_rset_mode_by_id(const uint16_t p_rset_variable_id) const {
+ ERR_FAIL_COND_V(p_rset_variable_id >= rpc_functions.size(), MultiplayerAPI::RPC_MODE_DISABLED);
+ return rpc_functions[p_rset_variable_id].mode;
+}
+
+MultiplayerAPI::RPCMode VisualScript::get_rset_mode(const StringName &p_variable) const {
+ return get_rset_mode_by_id(get_rset_property_id(p_variable));
+}
+
void VisualScript::_set_data(const Dictionary &p_data) {
Dictionary d = p_data;
@@ -1206,6 +1262,30 @@ void VisualScript::_set_data(const Dictionary &p_data) {
is_tool_script = d["is_tool_script"];
else
is_tool_script = false;
+
+ // Takes all the rpc methods
+ rpc_functions.clear();
+ rpc_variables.clear();
+ for (Map<StringName, Function>::Element *E = functions.front(); E; E = E->next()) {
+ if (E->get().function_id >= 0 && E->get().nodes.find(E->get().function_id)) {
+ Ref<VisualScriptFunction> vsf = E->get().nodes[E->get().function_id].node;
+ if (vsf.is_valid()) {
+ if (vsf->get_rpc_mode() != MultiplayerAPI::RPC_MODE_DISABLED) {
+ ScriptNetData nd;
+ nd.name = E->key();
+ nd.mode = vsf->get_rpc_mode();
+ if (rpc_functions.find(nd) == -1) {
+ rpc_functions.push_back(nd);
+ }
+ }
+ }
+ }
+ }
+
+ // Visual script doesn't have rset :(
+
+ // Sort so we are 100% that they are always the same.
+ rpc_functions.sort_custom<SortNetData>();
}
Dictionary VisualScript::_get_data() const {
@@ -1480,7 +1560,7 @@ bool VisualScriptInstance::has_method(const StringName &p_method) const {
//#define VSDEBUG(m_text) print_line(m_text)
#define VSDEBUG(m_text)
-void VisualScriptInstance::_dependency_step(VisualScriptNodeInstance *node, int p_pass, int *pass_stack, const Variant **input_args, Variant **output_args, Variant *variant_stack, Variant::CallError &r_error, String &error_str, VisualScriptNodeInstance **r_error_node) {
+void VisualScriptInstance::_dependency_step(VisualScriptNodeInstance *node, int p_pass, int *pass_stack, const Variant **input_args, Variant **output_args, Variant *variant_stack, Callable::CallError &r_error, String &error_str, VisualScriptNodeInstance **r_error_node) {
ERR_FAIL_COND(node->pass_idx == -1);
@@ -1497,7 +1577,7 @@ void VisualScriptInstance::_dependency_step(VisualScriptNodeInstance *node, int
for (int i = 0; i < dc; i++) {
_dependency_step(deps[i], p_pass, pass_stack, input_args, output_args, variant_stack, r_error, error_str, r_error_node);
- if (r_error.error != Variant::CallError::CALL_OK)
+ if (r_error.error != Callable::CallError::CALL_OK)
return;
}
}
@@ -1522,12 +1602,12 @@ void VisualScriptInstance::_dependency_step(VisualScriptNodeInstance *node, int
node->step(input_args, output_args, VisualScriptNodeInstance::START_MODE_BEGIN_SEQUENCE, working_mem, r_error, error_str);
//ignore return
- if (r_error.error != Variant::CallError::CALL_OK) {
+ if (r_error.error != Callable::CallError::CALL_OK) {
*r_error_node = node;
}
}
-Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p_stack, int p_stack_size, VisualScriptNodeInstance *p_node, int p_flow_stack_pos, int p_pass, bool p_resuming_yield, Variant::CallError &r_error) {
+Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p_stack, int p_stack_size, VisualScriptNodeInstance *p_node, int p_flow_stack_pos, int p_pass, bool p_resuming_yield, Callable::CallError &r_error) {
Map<StringName, Function>::Element *F = functions.find(p_method);
ERR_FAIL_COND_V(!F, Variant());
@@ -1589,7 +1669,7 @@ Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p
for (int i = 0; i < dc; i++) {
_dependency_step(deps[i], p_pass, pass_stack, input_args, output_args, variant_stack, r_error, error_str, &node);
- if (r_error.error != Variant::CallError::CALL_OK) {
+ if (r_error.error != Callable::CallError::CALL_OK) {
error = true;
current_node_id = node->id;
break;
@@ -1649,7 +1729,7 @@ Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p
int ret = node->step(input_args, output_args, start_mode, working_mem, r_error, error_str);
- if (r_error.error != Variant::CallError::CALL_OK) {
+ if (r_error.error != Callable::CallError::CALL_OK) {
//use error from step
error = true;
break;
@@ -1658,7 +1738,7 @@ Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p
if (ret & VisualScriptNodeInstance::STEP_YIELD_BIT) {
//yielded!
if (node->get_working_memory_size() == 0) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
error_str = RTR("A node yielded without working memory, please read the docs on how to yield properly!");
error = true;
break;
@@ -1667,7 +1747,7 @@ Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p
Ref<VisualScriptFunctionState> state = *working_mem;
if (!state.is_valid()) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
error_str = RTR("Node yielded, but did not return a function state in the first working memory.");
error = true;
break;
@@ -1686,7 +1766,7 @@ Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p
state->pass = p_pass;
copymem(state->stack.ptrw(), p_stack, p_stack_size);
//step 2, run away, return directly
- r_error.error = Variant::CallError::CALL_OK;
+ r_error.error = Callable::CallError::CALL_OK;
#ifdef DEBUG_ENABLED
//will re-enter later, so exiting
@@ -1729,7 +1809,7 @@ Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p
if (ret & VisualScriptNodeInstance::STEP_EXIT_FUNCTION_BIT) {
if (node->get_working_memory_size() == 0) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
error_str = RTR("Return value must be assigned to first element of node working memory! Fix your node please.");
error = true;
} else {
@@ -1746,7 +1826,7 @@ Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p
if ((ret == output || ret & VisualScriptNodeInstance::STEP_FLAG_PUSH_STACK_BIT) && node->sequence_output_count) {
//if no exit bit was set, and has sequence outputs, guess next node
if (output >= node->sequence_output_count) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
error_str = RTR("Node returned an invalid sequence output: ") + itos(output);
error = true;
break;
@@ -1808,7 +1888,7 @@ Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p
}
if (!found) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
error_str = RTR("Found sequence bit but not the node in the stack, report bug!");
error = true;
break;
@@ -1820,7 +1900,7 @@ Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p
} else {
// check for stack overflow
if (flow_stack_pos + 1 >= flow_max) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
error_str = RTR("Stack overflow with stack depth: ") + itos(output);
error = true;
break;
@@ -1872,22 +1952,22 @@ Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p
String err_func = p_method;
int err_line = current_node_id; //not a line but it works as one
- if (node && (r_error.error != Variant::CallError::CALL_ERROR_INVALID_METHOD || error_str == String())) {
+ if (node && (r_error.error != Callable::CallError::CALL_ERROR_INVALID_METHOD || error_str == String())) {
if (error_str != String()) {
error_str += " ";
}
- if (r_error.error == Variant::CallError::CALL_ERROR_INVALID_ARGUMENT) {
+ if (r_error.error == Callable::CallError::CALL_ERROR_INVALID_ARGUMENT) {
int errorarg = r_error.argument;
- error_str += "Cannot convert argument " + itos(errorarg + 1) + " to " + Variant::get_type_name(r_error.expected) + ".";
- } else if (r_error.error == Variant::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS) {
+ error_str += "Cannot convert argument " + itos(errorarg + 1) + " to " + Variant::get_type_name(Variant::Type(r_error.expected)) + ".";
+ } else if (r_error.error == Callable::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS) {
error_str += "Expected " + itos(r_error.argument) + " arguments.";
- } else if (r_error.error == Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS) {
+ } else if (r_error.error == Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS) {
error_str += "Expected " + itos(r_error.argument) + " arguments.";
- } else if (r_error.error == Variant::CallError::CALL_ERROR_INVALID_METHOD) {
+ } else if (r_error.error == Callable::CallError::CALL_ERROR_INVALID_METHOD) {
error_str += "Invalid Call.";
- } else if (r_error.error == Variant::CallError::CALL_ERROR_INSTANCE_IS_NULL) {
+ } else if (r_error.error == Callable::CallError::CALL_ERROR_INSTANCE_IS_NULL) {
error_str += "Base Instance is null";
}
}
@@ -1920,13 +2000,13 @@ Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p
return return_value;
}
-Variant VisualScriptInstance::call(const StringName &p_method, const Variant **p_args, int p_argcount, Variant::CallError &r_error) {
+Variant VisualScriptInstance::call(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
- r_error.error = Variant::CallError::CALL_OK; //ok by default
+ r_error.error = Callable::CallError::CALL_OK; //ok by default
Map<StringName, Function>::Element *F = functions.find(p_method);
if (!F) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
return Variant();
}
@@ -1968,7 +2048,7 @@ Variant VisualScriptInstance::call(const StringName &p_method, const Variant **p
Map<int, VisualScriptNodeInstance *>::Element *E = instances.find(f->node);
if (!E) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
ERR_FAIL_V_MSG(Variant(), "No VisualScriptFunction node in function.");
}
@@ -1982,14 +2062,14 @@ Variant VisualScriptInstance::call(const StringName &p_method, const Variant **p
VSDEBUG("ARGUMENTS: " + itos(f->argument_count) = " RECEIVED: " + itos(p_argcount));
if (p_argcount < f->argument_count) {
- r_error.error = Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
+ r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
r_error.argument = node->get_input_port_count();
return Variant();
}
if (p_argcount > f->argument_count) {
- r_error.error = Variant::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS;
+ r_error.error = Callable::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS;
r_error.argument = node->get_input_port_count();
return Variant();
@@ -2014,15 +2094,15 @@ void VisualScriptInstance::notification(int p_notification) {
Variant what = p_notification;
const Variant *whatp = &what;
- Variant::CallError ce;
+ Callable::CallError ce;
call(VisualScriptLanguage::singleton->notification, &whatp, 1, ce); //do as call
}
String VisualScriptInstance::to_string(bool *r_valid) {
if (has_method(CoreStringNames::get_singleton()->_to_string)) {
- Variant::CallError ce;
+ Callable::CallError ce;
Variant ret = call(CoreStringNames::get_singleton()->_to_string, NULL, 0, ce);
- if (ce.error == Variant::CallError::CALL_OK) {
+ if (ce.error == Callable::CallError::CALL_OK) {
if (ret.get_type() != Variant::STRING) {
if (r_valid)
*r_valid = false;
@@ -2043,31 +2123,44 @@ Ref<Script> VisualScriptInstance::get_script() const {
return script;
}
-MultiplayerAPI::RPCMode VisualScriptInstance::get_rpc_mode(const StringName &p_method) const {
+Vector<ScriptNetData> VisualScriptInstance::get_rpc_methods() const {
+ return script->get_rpc_methods();
+}
- if (p_method == script->get_default_func())
- return MultiplayerAPI::RPC_MODE_DISABLED;
+uint16_t VisualScriptInstance::get_rpc_method_id(const StringName &p_method) const {
+ return script->get_rpc_method_id(p_method);
+}
- const Map<StringName, VisualScript::Function>::Element *E = script->functions.find(p_method);
- if (!E) {
- return MultiplayerAPI::RPC_MODE_DISABLED;
- }
+StringName VisualScriptInstance::get_rpc_method(const uint16_t p_rpc_method_id) const {
+ return script->get_rpc_method(p_rpc_method_id);
+}
- if (E->get().function_id >= 0 && E->get().nodes.has(E->get().function_id)) {
+MultiplayerAPI::RPCMode VisualScriptInstance::get_rpc_mode_by_id(const uint16_t p_rpc_method_id) const {
+ return script->get_rpc_mode_by_id(p_rpc_method_id);
+}
- Ref<VisualScriptFunction> vsf = E->get().nodes[E->get().function_id].node;
- if (vsf.is_valid()) {
+MultiplayerAPI::RPCMode VisualScriptInstance::get_rpc_mode(const StringName &p_method) const {
+ return script->get_rpc_mode(p_method);
+}
- return vsf->get_rpc_mode();
- }
- }
+Vector<ScriptNetData> VisualScriptInstance::get_rset_properties() const {
+ return script->get_rset_properties();
+}
- return MultiplayerAPI::RPC_MODE_DISABLED;
+uint16_t VisualScriptInstance::get_rset_property_id(const StringName &p_variable) const {
+ return script->get_rset_property_id(p_variable);
}
-MultiplayerAPI::RPCMode VisualScriptInstance::get_rset_mode(const StringName &p_variable) const {
+StringName VisualScriptInstance::get_rset_property(const uint16_t p_rset_property_id) const {
+ return script->get_rset_property(p_rset_property_id);
+}
- return MultiplayerAPI::RPC_MODE_DISABLED;
+MultiplayerAPI::RPCMode VisualScriptInstance::get_rset_mode_by_id(const uint16_t p_rset_variable_id) const {
+ return script->get_rset_mode_by_id(p_rset_variable_id);
+}
+
+MultiplayerAPI::RPCMode VisualScriptInstance::get_rset_mode(const StringName &p_variable) const {
+ return script->get_rset_mode(p_variable);
}
void VisualScriptInstance::create(const Ref<VisualScript> &p_script, Object *p_owner) {
@@ -2315,23 +2408,23 @@ VisualScriptInstance::~VisualScriptInstance() {
/////////////////////
-Variant VisualScriptFunctionState::_signal_callback(const Variant **p_args, int p_argcount, Variant::CallError &r_error) {
+Variant VisualScriptFunctionState::_signal_callback(const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
ERR_FAIL_COND_V(function == StringName(), Variant());
#ifdef DEBUG_ENABLED
- ERR_FAIL_COND_V_MSG(instance_id && !ObjectDB::get_instance(instance_id), Variant(), "Resumed after yield, but class instance is gone.");
- ERR_FAIL_COND_V_MSG(script_id && !ObjectDB::get_instance(script_id), Variant(), "Resumed after yield, but script is gone.");
+ ERR_FAIL_COND_V_MSG(instance_id.is_valid() && !ObjectDB::get_instance(instance_id), Variant(), "Resumed after yield, but class instance is gone.");
+ ERR_FAIL_COND_V_MSG(script_id.is_valid() && !ObjectDB::get_instance(script_id), Variant(), "Resumed after yield, but script is gone.");
#endif
- r_error.error = Variant::CallError::CALL_OK;
+ r_error.error = Callable::CallError::CALL_OK;
Array args;
if (p_argcount == 0) {
- r_error.error = Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
+ r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
r_error.argument = 1;
return Variant();
} else if (p_argcount == 1) {
@@ -2346,13 +2439,13 @@ Variant VisualScriptFunctionState::_signal_callback(const Variant **p_args, int
Ref<VisualScriptFunctionState> self = *p_args[p_argcount - 1]; //hi, I'm myself, needed this to remain alive.
if (self.is_null()) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = p_argcount - 1;
r_error.expected = Variant::OBJECT;
return Variant();
}
- r_error.error = Variant::CallError::CALL_OK;
+ r_error.error = Callable::CallError::CALL_OK;
Variant *working_mem = ((Variant *)stack.ptr()) + working_mem_index;
@@ -2370,7 +2463,7 @@ void VisualScriptFunctionState::connect_to_signal(Object *p_obj, const String &p
binds.push_back(p_binds[i]);
}
binds.push_back(Ref<VisualScriptFunctionState>(this)); //add myself on the back to avoid dying from unreferencing
- p_obj->connect(p_signal, this, "_signal_callback", binds, CONNECT_ONESHOT);
+ p_obj->connect_compat(p_signal, this, "_signal_callback", binds, CONNECT_ONESHOT);
}
bool VisualScriptFunctionState::is_valid() const {
@@ -2383,13 +2476,13 @@ Variant VisualScriptFunctionState::resume(Array p_args) {
ERR_FAIL_COND_V(function == StringName(), Variant());
#ifdef DEBUG_ENABLED
- ERR_FAIL_COND_V_MSG(instance_id && !ObjectDB::get_instance(instance_id), Variant(), "Resumed after yield, but class instance is gone.");
- ERR_FAIL_COND_V_MSG(script_id && !ObjectDB::get_instance(script_id), Variant(), "Resumed after yield, but script is gone.");
+ ERR_FAIL_COND_V_MSG(instance_id.is_valid() && !ObjectDB::get_instance(instance_id), Variant(), "Resumed after yield, but class instance is gone.");
+ ERR_FAIL_COND_V_MSG(script_id.is_valid() && !ObjectDB::get_instance(script_id), Variant(), "Resumed after yield, but script is gone.");
#endif
- Variant::CallError r_error;
- r_error.error = Variant::CallError::CALL_OK;
+ Callable::CallError r_error;
+ r_error.error = Callable::CallError::CALL_OK;
Variant *working_mem = ((Variant *)stack.ptr()) + working_mem_index;
@@ -2491,7 +2584,7 @@ int VisualScriptLanguage::find_function(const String &p_function, const String &
return -1;
}
-String VisualScriptLanguage::make_function(const String &p_class, const String &p_name, const PoolStringArray &p_args) const {
+String VisualScriptLanguage::make_function(const String &p_class, const String &p_name, const PackedStringArray &p_args) const {
return String();
}
diff --git a/modules/visual_script/visual_script.h b/modules/visual_script/visual_script.h
index 9305226dc6..08b84bce1d 100644
--- a/modules/visual_script/visual_script.h
+++ b/modules/visual_script/visual_script.h
@@ -155,7 +155,7 @@ public:
virtual int get_working_memory_size() const { return 0; }
- virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) = 0; //do a step, return which sequence port to go out
+ virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) = 0; //do a step, return which sequence port to go out
Ref<VisualScriptNode> get_base_node() { return Ref<VisualScriptNode>(base); }
@@ -245,6 +245,8 @@ private:
Map<StringName, Function> functions;
Map<StringName, Variable> variables;
Map<StringName, Vector<Argument> > custom_signals;
+ Vector<ScriptNetData> rpc_functions;
+ Vector<ScriptNetData> rpc_variables;
Map<Object *, VisualScriptInstance *> instances;
@@ -362,6 +364,18 @@ public:
virtual int get_member_line(const StringName &p_member) const;
+ virtual Vector<ScriptNetData> get_rpc_methods() const;
+ virtual uint16_t get_rpc_method_id(const StringName &p_method) const;
+ virtual StringName get_rpc_method(const uint16_t p_rpc_method_id) const;
+ virtual MultiplayerAPI::RPCMode get_rpc_mode_by_id(const uint16_t p_rpc_method_id) const;
+ virtual MultiplayerAPI::RPCMode get_rpc_mode(const StringName &p_method) const;
+
+ virtual Vector<ScriptNetData> get_rset_properties() const;
+ virtual uint16_t get_rset_property_id(const StringName &p_property) const;
+ virtual StringName get_rset_property(const uint16_t p_rset_property_id) const;
+ virtual MultiplayerAPI::RPCMode get_rset_mode_by_id(const uint16_t p_rpc_method_id) const;
+ virtual MultiplayerAPI::RPCMode get_rset_mode(const StringName &p_variable) const;
+
#ifdef TOOLS_ENABLED
virtual bool are_subnodes_edited() const;
#endif
@@ -394,8 +408,8 @@ class VisualScriptInstance : public ScriptInstance {
StringName source;
- void _dependency_step(VisualScriptNodeInstance *node, int p_pass, int *pass_stack, const Variant **input_args, Variant **output_args, Variant *variant_stack, Variant::CallError &r_error, String &error_str, VisualScriptNodeInstance **r_error_node);
- Variant _call_internal(const StringName &p_method, void *p_stack, int p_stack_size, VisualScriptNodeInstance *p_node, int p_flow_stack_pos, int p_pass, bool p_resuming_yield, Variant::CallError &r_error);
+ void _dependency_step(VisualScriptNodeInstance *node, int p_pass, int *pass_stack, const Variant **input_args, Variant **output_args, Variant *variant_stack, Callable::CallError &r_error, String &error_str, VisualScriptNodeInstance **r_error_node);
+ Variant _call_internal(const StringName &p_method, void *p_stack, int p_stack_size, VisualScriptNodeInstance *p_node, int p_flow_stack_pos, int p_pass, bool p_resuming_yield, Callable::CallError &r_error);
//Map<StringName,Function> functions;
friend class VisualScriptFunctionState; //for yield
@@ -408,7 +422,7 @@ public:
virtual void get_method_list(List<MethodInfo> *p_list) const;
virtual bool has_method(const StringName &p_method) const;
- virtual Variant call(const StringName &p_method, const Variant **p_args, int p_argcount, Variant::CallError &r_error);
+ virtual Variant call(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error);
virtual void notification(int p_notification);
String to_string(bool *r_valid);
@@ -441,7 +455,16 @@ public:
virtual ScriptLanguage *get_language();
+ virtual Vector<ScriptNetData> get_rpc_methods() const;
+ virtual uint16_t get_rpc_method_id(const StringName &p_method) const;
+ virtual StringName get_rpc_method(const uint16_t p_rpc_method_id) const;
+ virtual MultiplayerAPI::RPCMode get_rpc_mode_by_id(const uint16_t p_rpc_method_id) const;
virtual MultiplayerAPI::RPCMode get_rpc_mode(const StringName &p_method) const;
+
+ virtual Vector<ScriptNetData> get_rset_properties() const;
+ virtual uint16_t get_rset_property_id(const StringName &p_property) const;
+ virtual StringName get_rset_property(const uint16_t p_rset_property_id) const;
+ virtual MultiplayerAPI::RPCMode get_rset_mode_by_id(const uint16_t p_rpc_method_id) const;
virtual MultiplayerAPI::RPCMode get_rset_mode(const StringName &p_variable) const;
VisualScriptInstance();
@@ -464,7 +487,7 @@ class VisualScriptFunctionState : public Reference {
int flow_stack_pos;
int pass;
- Variant _signal_callback(const Variant **p_args, int p_argcount, Variant::CallError &r_error);
+ Variant _signal_callback(const Variant **p_args, int p_argcount, Callable::CallError &r_error);
protected:
static void _bind_methods();
@@ -576,7 +599,7 @@ public:
virtual bool has_named_classes() const;
virtual bool supports_builtin_mode() const;
virtual int find_function(const String &p_function, const String &p_code) const;
- virtual String make_function(const String &p_class, const String &p_name, const PoolStringArray &p_args) const;
+ virtual String make_function(const String &p_class, const String &p_name, const PackedStringArray &p_args) const;
virtual void auto_indent_code(String &p_code, int p_from_line, int p_to_line) const;
virtual void add_global_constant(const StringName &p_variable, const Variant &p_value);
diff --git a/modules/visual_script/visual_script_builtin_funcs.cpp b/modules/visual_script/visual_script_builtin_funcs.cpp
index 2894f6367b..07f152efd4 100644
--- a/modules/visual_script/visual_script_builtin_funcs.cpp
+++ b/modules/visual_script/visual_script_builtin_funcs.cpp
@@ -63,7 +63,7 @@ const char *VisualScriptBuiltinFunc::func_name[VisualScriptBuiltinFunc::FUNC_MAX
"is_nan",
"is_inf",
"ease",
- "decimals",
+ "step_decimals",
"stepify",
"lerp",
"inverse_lerp",
@@ -171,7 +171,7 @@ int VisualScriptBuiltinFunc::get_func_argument_count(BuiltinFunc p_func) {
case MATH_EXP:
case MATH_ISNAN:
case MATH_ISINF:
- case MATH_DECIMALS:
+ case MATH_STEP_DECIMALS:
case MATH_SEED:
case MATH_RANDSEED:
case MATH_DEG2RAD:
@@ -277,22 +277,22 @@ PropertyInfo VisualScriptBuiltinFunc::get_input_value_port_info(int p_idx) const
case MATH_EXP:
case MATH_ISNAN:
case MATH_ISINF: {
- return PropertyInfo(Variant::REAL, "s");
+ return PropertyInfo(Variant::FLOAT, "s");
} break;
case MATH_ATAN2: {
if (p_idx == 0)
- return PropertyInfo(Variant::REAL, "y");
+ return PropertyInfo(Variant::FLOAT, "y");
else
- return PropertyInfo(Variant::REAL, "x");
+ return PropertyInfo(Variant::FLOAT, "x");
} break;
case MATH_FMOD:
case MATH_FPOSMOD:
case LOGIC_MAX:
case LOGIC_MIN: {
if (p_idx == 0)
- return PropertyInfo(Variant::REAL, "a");
+ return PropertyInfo(Variant::FLOAT, "a");
else
- return PropertyInfo(Variant::REAL, "b");
+ return PropertyInfo(Variant::FLOAT, "b");
} break;
case MATH_POSMOD: {
if (p_idx == 0)
@@ -302,63 +302,63 @@ PropertyInfo VisualScriptBuiltinFunc::get_input_value_port_info(int p_idx) const
} break;
case MATH_POW: {
if (p_idx == 0)
- return PropertyInfo(Variant::REAL, "base");
+ return PropertyInfo(Variant::FLOAT, "base");
else
- return PropertyInfo(Variant::REAL, "exp");
+ return PropertyInfo(Variant::FLOAT, "exp");
} break;
case MATH_EASE: {
if (p_idx == 0)
- return PropertyInfo(Variant::REAL, "s");
+ return PropertyInfo(Variant::FLOAT, "s");
else
- return PropertyInfo(Variant::REAL, "curve");
+ return PropertyInfo(Variant::FLOAT, "curve");
} break;
- case MATH_DECIMALS: {
- return PropertyInfo(Variant::REAL, "step");
+ case MATH_STEP_DECIMALS: {
+ return PropertyInfo(Variant::FLOAT, "step");
} break;
case MATH_STEPIFY: {
if (p_idx == 0)
- return PropertyInfo(Variant::REAL, "s");
+ return PropertyInfo(Variant::FLOAT, "s");
else
- return PropertyInfo(Variant::REAL, "steps");
+ return PropertyInfo(Variant::FLOAT, "steps");
} break;
case MATH_LERP:
case MATH_LERP_ANGLE:
case MATH_INVERSE_LERP:
case MATH_SMOOTHSTEP: {
if (p_idx == 0)
- return PropertyInfo(Variant::REAL, "from");
+ return PropertyInfo(Variant::FLOAT, "from");
else if (p_idx == 1)
- return PropertyInfo(Variant::REAL, "to");
+ return PropertyInfo(Variant::FLOAT, "to");
else
- return PropertyInfo(Variant::REAL, "weight");
+ return PropertyInfo(Variant::FLOAT, "weight");
} break;
case MATH_RANGE_LERP: {
if (p_idx == 0)
- return PropertyInfo(Variant::REAL, "value");
+ return PropertyInfo(Variant::FLOAT, "value");
else if (p_idx == 1)
- return PropertyInfo(Variant::REAL, "istart");
+ return PropertyInfo(Variant::FLOAT, "istart");
else if (p_idx == 2)
- return PropertyInfo(Variant::REAL, "istop");
+ return PropertyInfo(Variant::FLOAT, "istop");
else if (p_idx == 3)
- return PropertyInfo(Variant::REAL, "ostart");
+ return PropertyInfo(Variant::FLOAT, "ostart");
else
- return PropertyInfo(Variant::REAL, "ostop");
+ return PropertyInfo(Variant::FLOAT, "ostop");
} break;
case MATH_MOVE_TOWARD: {
if (p_idx == 0)
- return PropertyInfo(Variant::REAL, "from");
+ return PropertyInfo(Variant::FLOAT, "from");
else if (p_idx == 1)
- return PropertyInfo(Variant::REAL, "to");
+ return PropertyInfo(Variant::FLOAT, "to");
else
- return PropertyInfo(Variant::REAL, "delta");
+ return PropertyInfo(Variant::FLOAT, "delta");
} break;
case MATH_DECTIME: {
if (p_idx == 0)
- return PropertyInfo(Variant::REAL, "value");
+ return PropertyInfo(Variant::FLOAT, "value");
else if (p_idx == 1)
- return PropertyInfo(Variant::REAL, "amount");
+ return PropertyInfo(Variant::FLOAT, "amount");
else
- return PropertyInfo(Variant::REAL, "step");
+ return PropertyInfo(Variant::FLOAT, "step");
} break;
case MATH_RANDOMIZE:
case MATH_RAND:
@@ -367,37 +367,37 @@ PropertyInfo VisualScriptBuiltinFunc::get_input_value_port_info(int p_idx) const
} break;
case MATH_RANDOM: {
if (p_idx == 0)
- return PropertyInfo(Variant::REAL, "from");
+ return PropertyInfo(Variant::FLOAT, "from");
else
- return PropertyInfo(Variant::REAL, "to");
+ return PropertyInfo(Variant::FLOAT, "to");
} break;
case MATH_SEED:
case MATH_RANDSEED: {
return PropertyInfo(Variant::INT, "seed");
} break;
case MATH_DEG2RAD: {
- return PropertyInfo(Variant::REAL, "deg");
+ return PropertyInfo(Variant::FLOAT, "deg");
} break;
case MATH_RAD2DEG: {
- return PropertyInfo(Variant::REAL, "rad");
+ return PropertyInfo(Variant::FLOAT, "rad");
} break;
case MATH_LINEAR2DB: {
- return PropertyInfo(Variant::REAL, "nrg");
+ return PropertyInfo(Variant::FLOAT, "nrg");
} break;
case MATH_DB2LINEAR: {
- return PropertyInfo(Variant::REAL, "db");
+ return PropertyInfo(Variant::FLOAT, "db");
} break;
case MATH_POLAR2CARTESIAN: {
if (p_idx == 0)
- return PropertyInfo(Variant::REAL, "r");
+ return PropertyInfo(Variant::FLOAT, "r");
else
- return PropertyInfo(Variant::REAL, "th");
+ return PropertyInfo(Variant::FLOAT, "th");
} break;
case MATH_CARTESIAN2POLAR: {
if (p_idx == 0)
- return PropertyInfo(Variant::REAL, "x");
+ return PropertyInfo(Variant::FLOAT, "x");
else
- return PropertyInfo(Variant::REAL, "y");
+ return PropertyInfo(Variant::FLOAT, "y");
} break;
case MATH_WRAP: {
if (p_idx == 0)
@@ -410,11 +410,11 @@ PropertyInfo VisualScriptBuiltinFunc::get_input_value_port_info(int p_idx) const
case MATH_WRAPF:
case LOGIC_CLAMP: {
if (p_idx == 0)
- return PropertyInfo(Variant::REAL, "value");
+ return PropertyInfo(Variant::FLOAT, "value");
else if (p_idx == 1)
- return PropertyInfo(Variant::REAL, "min");
+ return PropertyInfo(Variant::FLOAT, "min");
else
- return PropertyInfo(Variant::REAL, "max");
+ return PropertyInfo(Variant::FLOAT, "max");
} break;
case LOGIC_NEAREST_PO2: {
return PropertyInfo(Variant::INT, "value");
@@ -467,7 +467,7 @@ PropertyInfo VisualScriptBuiltinFunc::get_input_value_port_info(int p_idx) const
case BYTES_TO_VAR: {
if (p_idx == 0)
- return PropertyInfo(Variant::POOL_BYTE_ARRAY, "bytes");
+ return PropertyInfo(Variant::PACKED_BYTE_ARRAY, "bytes");
else
return PropertyInfo(Variant::BOOL, "allow_objects");
} break;
@@ -475,7 +475,7 @@ PropertyInfo VisualScriptBuiltinFunc::get_input_value_port_info(int p_idx) const
if (p_idx == 0)
return PropertyInfo(Variant::STRING, "name");
else
- return PropertyInfo(Variant::REAL, "alpha");
+ return PropertyInfo(Variant::FLOAT, "alpha");
} break;
case FUNC_MAX: {
}
@@ -504,7 +504,7 @@ PropertyInfo VisualScriptBuiltinFunc::get_output_value_port_info(int p_idx) cons
case MATH_FPOSMOD:
case MATH_FLOOR:
case MATH_CEIL: {
- t = Variant::REAL;
+ t = Variant::FLOAT;
} break;
case MATH_POSMOD:
case MATH_ROUND: {
@@ -519,16 +519,16 @@ PropertyInfo VisualScriptBuiltinFunc::get_output_value_port_info(int p_idx) cons
case MATH_POW:
case MATH_LOG:
case MATH_EXP: {
- t = Variant::REAL;
+ t = Variant::FLOAT;
} break;
case MATH_ISNAN:
case MATH_ISINF: {
t = Variant::BOOL;
} break;
case MATH_EASE: {
- t = Variant::REAL;
+ t = Variant::FLOAT;
} break;
- case MATH_DECIMALS: {
+ case MATH_STEP_DECIMALS: {
t = Variant::INT;
} break;
case MATH_STEPIFY:
@@ -539,7 +539,7 @@ PropertyInfo VisualScriptBuiltinFunc::get_output_value_port_info(int p_idx) cons
case MATH_SMOOTHSTEP:
case MATH_MOVE_TOWARD:
case MATH_DECTIME: {
- t = Variant::REAL;
+ t = Variant::FLOAT;
} break;
case MATH_RANDOMIZE: {
@@ -551,7 +551,7 @@ PropertyInfo VisualScriptBuiltinFunc::get_output_value_port_info(int p_idx) cons
} break;
case MATH_RANDF:
case MATH_RANDOM: {
- t = Variant::REAL;
+ t = Variant::FLOAT;
} break;
case MATH_SEED: {
@@ -568,7 +568,7 @@ PropertyInfo VisualScriptBuiltinFunc::get_output_value_port_info(int p_idx) cons
case MATH_LINEAR2DB:
case MATH_WRAPF:
case MATH_DB2LINEAR: {
- t = Variant::REAL;
+ t = Variant::FLOAT;
} break;
case MATH_POLAR2CARTESIAN:
case MATH_CARTESIAN2POLAR: {
@@ -632,7 +632,7 @@ PropertyInfo VisualScriptBuiltinFunc::get_output_value_port_info(int p_idx) cons
} break;
case VAR_TO_BYTES: {
if (p_idx == 0)
- t = Variant::POOL_BYTE_ARRAY;
+ t = Variant::PACKED_BYTE_ARRAY;
else
t = Variant::BOOL;
@@ -675,15 +675,15 @@ VisualScriptBuiltinFunc::BuiltinFunc VisualScriptBuiltinFunc::get_func() {
return func;
}
-#define VALIDATE_ARG_NUM(m_arg) \
- if (!p_inputs[m_arg]->is_num()) { \
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT; \
- r_error.argument = m_arg; \
- r_error.expected = Variant::REAL; \
- return; \
+#define VALIDATE_ARG_NUM(m_arg) \
+ if (!p_inputs[m_arg]->is_num()) { \
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT; \
+ r_error.argument = m_arg; \
+ r_error.expected = Variant::FLOAT; \
+ return; \
}
-void VisualScriptBuiltinFunc::exec_func(BuiltinFunc p_func, const Variant **p_inputs, Variant *r_return, Variant::CallError &r_error, String &r_error_str) {
+void VisualScriptBuiltinFunc::exec_func(BuiltinFunc p_func, const Variant **p_inputs, Variant *r_return, Callable::CallError &r_error, String &r_error_str) {
switch (p_func) {
case VisualScriptBuiltinFunc::MATH_SIN: {
@@ -781,15 +781,15 @@ void VisualScriptBuiltinFunc::exec_func(BuiltinFunc p_func, const Variant **p_in
int64_t i = *p_inputs[0];
*r_return = ABS(i);
- } else if (p_inputs[0]->get_type() == Variant::REAL) {
+ } else if (p_inputs[0]->get_type() == Variant::FLOAT) {
real_t r = *p_inputs[0];
*r_return = Math::abs(r);
} else {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
- r_error.expected = Variant::REAL;
+ r_error.expected = Variant::FLOAT;
}
} break;
case VisualScriptBuiltinFunc::MATH_SIGN: {
@@ -798,15 +798,15 @@ void VisualScriptBuiltinFunc::exec_func(BuiltinFunc p_func, const Variant **p_in
int64_t i = *p_inputs[0];
*r_return = i < 0 ? -1 : (i > 0 ? +1 : 0);
- } else if (p_inputs[0]->get_type() == Variant::REAL) {
+ } else if (p_inputs[0]->get_type() == Variant::FLOAT) {
real_t r = *p_inputs[0];
*r_return = r < 0.0 ? -1.0 : (r > 0.0 ? +1.0 : 0.0);
} else {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
- r_error.expected = Variant::REAL;
+ r_error.expected = Variant::FLOAT;
}
} break;
case VisualScriptBuiltinFunc::MATH_POW: {
@@ -841,7 +841,7 @@ void VisualScriptBuiltinFunc::exec_func(BuiltinFunc p_func, const Variant **p_in
VALIDATE_ARG_NUM(1);
*r_return = Math::ease((double)*p_inputs[0], (double)*p_inputs[1]);
} break;
- case VisualScriptBuiltinFunc::MATH_DECIMALS: {
+ case VisualScriptBuiltinFunc::MATH_STEP_DECIMALS: {
VALIDATE_ARG_NUM(0);
*r_return = Math::step_decimals((double)*p_inputs[0]);
@@ -1047,7 +1047,7 @@ void VisualScriptBuiltinFunc::exec_func(BuiltinFunc p_func, const Variant **p_in
if (p_inputs[0]->get_type() != Variant::OBJECT) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
r_error.expected = Variant::OBJECT;
@@ -1081,7 +1081,7 @@ void VisualScriptBuiltinFunc::exec_func(BuiltinFunc p_func, const Variant **p_in
if (p_inputs[0]->get_type() != Variant::OBJECT) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
r_error.expected = Variant::OBJECT;
@@ -1089,7 +1089,7 @@ void VisualScriptBuiltinFunc::exec_func(BuiltinFunc p_func, const Variant **p_in
}
if (p_inputs[1]->get_type() != Variant::STRING && p_inputs[1]->get_type() != Variant::NODE_PATH) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 1;
r_error.expected = Variant::STRING;
@@ -1111,7 +1111,7 @@ void VisualScriptBuiltinFunc::exec_func(BuiltinFunc p_func, const Variant **p_in
if (type < 0 || type >= Variant::VARIANT_MAX) {
r_error_str = RTR("Invalid type argument to convert(), use TYPE_* constants.");
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
r_error.expected = Variant::INT;
return;
@@ -1141,7 +1141,7 @@ void VisualScriptBuiltinFunc::exec_func(BuiltinFunc p_func, const Variant **p_in
case VisualScriptBuiltinFunc::TEXT_ORD: {
if (p_inputs[0]->get_type() != Variant::STRING) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
r_error.expected = Variant::STRING;
@@ -1151,7 +1151,7 @@ void VisualScriptBuiltinFunc::exec_func(BuiltinFunc p_func, const Variant **p_in
String str = p_inputs[0]->operator String();
if (str.length() != 1) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
r_error.expected = Variant::STRING;
*r_return = "Expected a string of length 1 (a character).";
@@ -1197,7 +1197,7 @@ void VisualScriptBuiltinFunc::exec_func(BuiltinFunc p_func, const Variant **p_in
case VisualScriptBuiltinFunc::STR_TO_VAR: {
if (p_inputs[0]->get_type() != Variant::STRING) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
r_error.expected = Variant::STRING;
@@ -1212,7 +1212,7 @@ void VisualScriptBuiltinFunc::exec_func(BuiltinFunc p_func, const Variant **p_in
Error err = VariantParser::parse(&ss, *r_return, errs, line);
if (err != OK) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
r_error.expected = Variant::STRING;
*r_return = "Parse error at line " + itos(line) + ": " + errs;
@@ -1223,17 +1223,17 @@ void VisualScriptBuiltinFunc::exec_func(BuiltinFunc p_func, const Variant **p_in
case VisualScriptBuiltinFunc::VAR_TO_BYTES: {
if (p_inputs[1]->get_type() != Variant::BOOL) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 1;
r_error.expected = Variant::BOOL;
return;
}
- PoolByteArray barr;
+ PackedByteArray barr;
int len;
bool full_objects = *p_inputs[1];
Error err = encode_variant(*p_inputs[0], NULL, len, full_objects);
if (err) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
r_error.expected = Variant::NIL;
r_error_str = "Unexpected error encoding variable to bytes, likely unserializable type found (Object or RID).";
@@ -1242,37 +1242,37 @@ void VisualScriptBuiltinFunc::exec_func(BuiltinFunc p_func, const Variant **p_in
barr.resize(len);
{
- PoolByteArray::Write w = barr.write();
- encode_variant(*p_inputs[0], w.ptr(), len, full_objects);
+ uint8_t *w = barr.ptrw();
+ encode_variant(*p_inputs[0], w, len, full_objects);
}
*r_return = barr;
} break;
case VisualScriptBuiltinFunc::BYTES_TO_VAR: {
- if (p_inputs[0]->get_type() != Variant::POOL_BYTE_ARRAY) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ if (p_inputs[0]->get_type() != Variant::PACKED_BYTE_ARRAY) {
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
- r_error.expected = Variant::POOL_BYTE_ARRAY;
+ r_error.expected = Variant::PACKED_BYTE_ARRAY;
return;
}
if (p_inputs[1]->get_type() != Variant::BOOL) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 1;
r_error.expected = Variant::BOOL;
return;
}
- PoolByteArray varr = *p_inputs[0];
+ PackedByteArray varr = *p_inputs[0];
bool allow_objects = *p_inputs[1];
Variant ret;
{
- PoolByteArray::Read r = varr.read();
- Error err = decode_variant(ret, r.ptr(), varr.size(), NULL, allow_objects);
+ const uint8_t *r = varr.ptr();
+ Error err = decode_variant(ret, r, varr.size(), NULL, allow_objects);
if (err != OK) {
r_error_str = RTR("Not enough bytes for decoding bytes, or invalid format.");
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
- r_error.expected = Variant::POOL_BYTE_ARRAY;
+ r_error.expected = Variant::PACKED_BYTE_ARRAY;
return;
}
}
@@ -1306,7 +1306,7 @@ public:
//virtual bool is_output_port_unsequenced(int p_idx) const { return false; }
//virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return true; }
- virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) {
+ virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
VisualScriptBuiltinFunc::exec_func(func, p_inputs, p_outputs[0], r_error, r_error_str);
return 0;
@@ -1361,7 +1361,7 @@ void VisualScriptBuiltinFunc::_bind_methods() {
BIND_ENUM_CONSTANT(MATH_ISNAN);
BIND_ENUM_CONSTANT(MATH_ISINF);
BIND_ENUM_CONSTANT(MATH_EASE);
- BIND_ENUM_CONSTANT(MATH_DECIMALS);
+ BIND_ENUM_CONSTANT(MATH_STEP_DECIMALS);
BIND_ENUM_CONSTANT(MATH_STEPIFY);
BIND_ENUM_CONSTANT(MATH_LERP);
BIND_ENUM_CONSTANT(MATH_INVERSE_LERP);
@@ -1455,7 +1455,7 @@ void register_visual_script_builtin_func_node() {
VisualScriptLanguage::singleton->add_register_func("functions/built_in/isinf", create_builtin_func_node<VisualScriptBuiltinFunc::MATH_ISINF>);
VisualScriptLanguage::singleton->add_register_func("functions/built_in/ease", create_builtin_func_node<VisualScriptBuiltinFunc::MATH_EASE>);
- VisualScriptLanguage::singleton->add_register_func("functions/built_in/decimals", create_builtin_func_node<VisualScriptBuiltinFunc::MATH_DECIMALS>);
+ VisualScriptLanguage::singleton->add_register_func("functions/built_in/step_decimals", create_builtin_func_node<VisualScriptBuiltinFunc::MATH_STEP_DECIMALS>);
VisualScriptLanguage::singleton->add_register_func("functions/built_in/stepify", create_builtin_func_node<VisualScriptBuiltinFunc::MATH_STEPIFY>);
VisualScriptLanguage::singleton->add_register_func("functions/built_in/lerp", create_builtin_func_node<VisualScriptBuiltinFunc::MATH_LERP>);
VisualScriptLanguage::singleton->add_register_func("functions/built_in/lerp_angle", create_builtin_func_node<VisualScriptBuiltinFunc::MATH_LERP_ANGLE>);
diff --git a/modules/visual_script/visual_script_builtin_funcs.h b/modules/visual_script/visual_script_builtin_funcs.h
index f5021cb545..d950f858d4 100644
--- a/modules/visual_script/visual_script_builtin_funcs.h
+++ b/modules/visual_script/visual_script_builtin_funcs.h
@@ -63,7 +63,7 @@ public:
MATH_ISNAN,
MATH_ISINF,
MATH_EASE,
- MATH_DECIMALS,
+ MATH_STEP_DECIMALS,
MATH_STEPIFY,
MATH_LERP,
MATH_INVERSE_LERP,
@@ -112,7 +112,7 @@ public:
static int get_func_argument_count(BuiltinFunc p_func);
static String get_func_name(BuiltinFunc p_func);
- static void exec_func(BuiltinFunc p_func, const Variant **p_inputs, Variant *r_return, Variant::CallError &r_error, String &r_error_str);
+ static void exec_func(BuiltinFunc p_func, const Variant **p_inputs, Variant *r_return, Callable::CallError &r_error, String &r_error_str);
static BuiltinFunc find_function(const String &p_string);
private:
diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp
index ec20698ae8..0bbef066a4 100644
--- a/modules/visual_script/visual_script_editor.cpp
+++ b/modules/visual_script/visual_script_editor.cpp
@@ -346,7 +346,7 @@ static Color _color_from_type(Variant::Type p_type, bool dark_theme = true) {
case Variant::BOOL: color = Color(0.55, 0.65, 0.94); break;
case Variant::INT: color = Color(0.49, 0.78, 0.94); break;
- case Variant::REAL: color = Color(0.38, 0.85, 0.96); break;
+ case Variant::FLOAT: color = Color(0.38, 0.85, 0.96); break;
case Variant::STRING: color = Color(0.42, 0.65, 0.93); break;
case Variant::VECTOR2: color = Color(0.74, 0.57, 0.95); break;
@@ -366,13 +366,15 @@ static Color _color_from_type(Variant::Type p_type, bool dark_theme = true) {
case Variant::DICTIONARY: color = Color(0.47, 0.93, 0.69); break;
case Variant::ARRAY: color = Color(0.88, 0.88, 0.88); break;
- case Variant::POOL_BYTE_ARRAY: color = Color(0.67, 0.96, 0.78); break;
- case Variant::POOL_INT_ARRAY: color = Color(0.69, 0.86, 0.96); break;
- case Variant::POOL_REAL_ARRAY: color = Color(0.59, 0.91, 0.97); break;
- case Variant::POOL_STRING_ARRAY: color = Color(0.62, 0.77, 0.95); break;
- case Variant::POOL_VECTOR2_ARRAY: color = Color(0.82, 0.7, 0.96); break;
- case Variant::POOL_VECTOR3_ARRAY: color = Color(0.87, 0.61, 0.95); break;
- case Variant::POOL_COLOR_ARRAY: color = Color(0.91, 1.0, 0.59); break;
+ case Variant::PACKED_BYTE_ARRAY: color = Color(0.67, 0.96, 0.78); break;
+ case Variant::PACKED_INT32_ARRAY: color = Color(0.69, 0.86, 0.96); break;
+ case Variant::PACKED_FLOAT32_ARRAY: color = Color(0.59, 0.91, 0.97); break;
+ case Variant::PACKED_INT64_ARRAY: color = Color(0.69, 0.86, 0.96); break;
+ case Variant::PACKED_FLOAT64_ARRAY: color = Color(0.59, 0.91, 0.97); break;
+ case Variant::PACKED_STRING_ARRAY: color = Color(0.62, 0.77, 0.95); break;
+ case Variant::PACKED_VECTOR2_ARRAY: color = Color(0.82, 0.7, 0.96); break;
+ case Variant::PACKED_VECTOR3_ARRAY: color = Color(0.87, 0.61, 0.95); break;
+ case Variant::PACKED_COLOR_ARRAY: color = Color(0.91, 1.0, 0.59); break;
default:
color.set_hsv(p_type / float(Variant::VARIANT_MAX), 0.7, 0.7);
@@ -383,7 +385,7 @@ static Color _color_from_type(Variant::Type p_type, bool dark_theme = true) {
case Variant::BOOL: color = Color(0.43, 0.56, 0.92); break;
case Variant::INT: color = Color(0.31, 0.7, 0.91); break;
- case Variant::REAL: color = Color(0.15, 0.8, 0.94); break;
+ case Variant::FLOAT: color = Color(0.15, 0.8, 0.94); break;
case Variant::STRING: color = Color(0.27, 0.56, 0.91); break;
case Variant::VECTOR2: color = Color(0.68, 0.46, 0.93); break;
@@ -403,13 +405,15 @@ static Color _color_from_type(Variant::Type p_type, bool dark_theme = true) {
case Variant::DICTIONARY: color = Color(0.34, 0.91, 0.62); break;
case Variant::ARRAY: color = Color(0.45, 0.45, 0.45); break;
- case Variant::POOL_BYTE_ARRAY: color = Color(0.38, 0.92, 0.6); break;
- case Variant::POOL_INT_ARRAY: color = Color(0.38, 0.73, 0.92); break;
- case Variant::POOL_REAL_ARRAY: color = Color(0.25, 0.83, 0.95); break;
- case Variant::POOL_STRING_ARRAY: color = Color(0.38, 0.62, 0.92); break;
- case Variant::POOL_VECTOR2_ARRAY: color = Color(0.62, 0.36, 0.92); break;
- case Variant::POOL_VECTOR3_ARRAY: color = Color(0.79, 0.35, 0.92); break;
- case Variant::POOL_COLOR_ARRAY: color = Color(0.57, 0.73, 0.0); break;
+ case Variant::PACKED_BYTE_ARRAY: color = Color(0.38, 0.92, 0.6); break;
+ case Variant::PACKED_INT32_ARRAY: color = Color(0.38, 0.73, 0.92); break;
+ case Variant::PACKED_FLOAT32_ARRAY: color = Color(0.25, 0.83, 0.95); break;
+ case Variant::PACKED_INT64_ARRAY: color = Color(0.38, 0.73, 0.92); break;
+ case Variant::PACKED_FLOAT64_ARRAY: color = Color(0.25, 0.83, 0.95); break;
+ case Variant::PACKED_STRING_ARRAY: color = Color(0.38, 0.62, 0.92); break;
+ case Variant::PACKED_VECTOR2_ARRAY: color = Color(0.62, 0.36, 0.92); break;
+ case Variant::PACKED_VECTOR3_ARRAY: color = Color(0.79, 0.35, 0.92); break;
+ case Variant::PACKED_COLOR_ARRAY: color = Color(0.57, 0.73, 0.0); break;
default:
color.set_hsv(p_type / float(Variant::VARIANT_MAX), 0.3, 0.3);
@@ -499,7 +503,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
graph->show();
select_func_text->hide();
- Ref<Texture> type_icons[Variant::VARIANT_MAX] = {
+ Ref<Texture2D> type_icons[Variant::VARIANT_MAX] = {
Control::get_icon("Variant", "EditorIcons"),
Control::get_icon("bool", "EditorIcons"),
Control::get_icon("int", "EditorIcons"),
@@ -520,16 +524,16 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
Control::get_icon("MiniObject", "EditorIcons"),
Control::get_icon("Dictionary", "EditorIcons"),
Control::get_icon("Array", "EditorIcons"),
- Control::get_icon("PoolByteArray", "EditorIcons"),
- Control::get_icon("PoolIntArray", "EditorIcons"),
- Control::get_icon("PoolRealArray", "EditorIcons"),
- Control::get_icon("PoolStringArray", "EditorIcons"),
- Control::get_icon("PoolVector2Array", "EditorIcons"),
- Control::get_icon("PoolVector3Array", "EditorIcons"),
- Control::get_icon("PoolColorArray", "EditorIcons")
+ Control::get_icon("PackedByteArray", "EditorIcons"),
+ Control::get_icon("PackedInt32Array", "EditorIcons"),
+ Control::get_icon("PackedFloat32Array", "EditorIcons"),
+ Control::get_icon("PackedStringArray", "EditorIcons"),
+ Control::get_icon("PackedVector2Array", "EditorIcons"),
+ Control::get_icon("PackedVector3Array", "EditorIcons"),
+ Control::get_icon("PackedColorArray", "EditorIcons")
};
- Ref<Texture> seq_port = Control::get_icon("VisualShaderPort", "EditorIcons");
+ Ref<Texture2D> seq_port = Control::get_icon("VisualShaderPort", "EditorIcons");
for (List<StringName>::Element *F = funcs.front(); F; F = F->next()) { // loop through all the functions
@@ -556,8 +560,8 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
gnode->set_meta("__vnode", node);
gnode->set_name(itos(E->get()));
- gnode->connect("dragged", this, "_node_moved", varray(E->get()));
- gnode->connect("close_request", this, "_remove_node", varray(E->get()), CONNECT_DEFERRED);
+ gnode->connect_compat("dragged", this, "_node_moved", varray(E->get()));
+ gnode->connect_compat("close_request", this, "_remove_node", varray(E->get()), CONNECT_DEFERRED);
if (E->get() != script->get_function_node_id(F->get())) {
//function can't be erased
@@ -575,7 +579,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
Button *btn = memnew(Button);
btn->set_text(TTR("Add Input Port"));
hbnc->add_child(btn);
- btn->connect("pressed", this, "_add_input_port", varray(E->get()), CONNECT_DEFERRED);
+ btn->connect_compat("pressed", this, "_add_input_port", varray(E->get()), CONNECT_DEFERRED);
}
if (nd_list->is_output_port_editable()) {
if (nd_list->is_input_port_editable())
@@ -584,7 +588,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
Button *btn = memnew(Button);
btn->set_text(TTR("Add Output Port"));
hbnc->add_child(btn);
- btn->connect("pressed", this, "_add_output_port", varray(E->get()), CONNECT_DEFERRED);
+ btn->connect_compat("pressed", this, "_add_output_port", varray(E->get()), CONNECT_DEFERRED);
}
gnode->add_child(hbnc);
} else if (Object::cast_to<VisualScriptExpression>(node.ptr())) {
@@ -594,7 +598,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
line_edit->set_expand_to_text_length(true);
line_edit->add_font_override("font", get_font("source", "EditorFonts"));
gnode->add_child(line_edit);
- line_edit->connect("text_changed", this, "_expression_text_changed", varray(E->get()));
+ line_edit->connect_compat("text_changed", this, "_expression_text_changed", varray(E->get()));
} else {
String text = node->get_text();
if (!text.empty()) {
@@ -610,7 +614,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
gnode->set_comment(true);
gnode->set_resizable(true);
gnode->set_custom_minimum_size(vsc->get_size() * EDSCALE);
- gnode->connect("resize_request", this, "_comment_node_resized", varray(E->get()));
+ gnode->connect_compat("resize_request", this, "_comment_node_resized", varray(E->get()));
}
if (node_styles.has(node->get_category())) {
@@ -619,16 +623,24 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
sbf = EditorNode::get_singleton()->get_theme_base()->get_theme()->get_stylebox("comment", "GraphNode");
Color c = sbf->get_border_color();
+ Color ic = c;
c.a = 1;
if (EditorSettings::get_singleton()->get("interface/theme/use_graph_node_headers")) {
- Color mono_color = ((c.r + c.g + c.b) / 3) < 0.7 ? Color(1.0, 1.0, 1.0) : Color(0.0, 0.0, 0.0);
+ Color mono_color;
+ if (((c.r + c.g + c.b) / 3) < 0.7) {
+ mono_color = Color(1.0, 1.0, 1.0);
+ ic = Color(0.0, 0.0, 0.0, 0.7);
+ } else {
+ mono_color = Color(0.0, 0.0, 0.0);
+ ic = Color(1.0, 1.0, 1.0, 0.7);
+ }
mono_color.a = 0.85;
c = mono_color;
}
gnode->add_color_override("title_color", c);
c.a = 0.7;
gnode->add_color_override("close_color", c);
- gnode->add_color_override("resizer_color", c);
+ gnode->add_color_override("resizer_color", ic);
gnode->add_style_override("frame", sbf);
}
@@ -702,7 +714,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
vbc->add_child(hbc2);
if (left_ok) {
- Ref<Texture> t;
+ Ref<Texture2D> t;
if (left_type >= 0 && left_type < Variant::VARIANT_MAX) {
t = type_icons[left_type];
}
@@ -720,8 +732,8 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
name_box->set_custom_minimum_size(Size2(60 * EDSCALE, 0));
name_box->set_text(left_name);
name_box->set_expand_to_text_length(true);
- name_box->connect("resized", this, "_update_node_size", varray(E->get()));
- name_box->connect("focus_exited", this, "_port_name_focus_out", varray(name_box, E->get(), i, true));
+ name_box->connect_compat("resized", this, "_update_node_size", varray(E->get()));
+ name_box->connect_compat("focus_exited", this, "_port_name_focus_out", varray(name_box, E->get(), i, true));
} else {
hbc->add_child(memnew(Label(left_name)));
}
@@ -734,13 +746,13 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
opbtn->select(left_type);
opbtn->set_custom_minimum_size(Size2(100 * EDSCALE, 0));
hbc->add_child(opbtn);
- opbtn->connect("item_selected", this, "_change_port_type", varray(E->get(), i, true), CONNECT_DEFERRED);
+ opbtn->connect_compat("item_selected", this, "_change_port_type", varray(E->get(), i, true), CONNECT_DEFERRED);
}
Button *rmbtn = memnew(Button);
rmbtn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("Remove", "EditorIcons"));
hbc->add_child(rmbtn);
- rmbtn->connect("pressed", this, "_remove_input_port", varray(E->get(), i), CONNECT_DEFERRED);
+ rmbtn->connect_compat("pressed", this, "_remove_input_port", varray(E->get(), i), CONNECT_DEFERRED);
} else {
hbc->add_child(memnew(Label(left_name)));
}
@@ -753,14 +765,14 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
if (value.get_type() != left_type) {
//different type? for now convert
//not the same, reconvert
- Variant::CallError ce;
+ Callable::CallError ce;
const Variant *existingp = &value;
value = Variant::construct(left_type, &existingp, 1, ce, false);
}
if (left_type == Variant::COLOR) {
button->set_custom_minimum_size(Size2(30, 0) * EDSCALE);
- button->connect("draw", this, "_draw_color_over_button", varray(button, value));
+ button->connect_compat("draw", this, "_draw_color_over_button", varray(button, value));
} else if (left_type == Variant::OBJECT && Ref<Resource>(value).is_valid()) {
Ref<Resource> res = value;
@@ -776,7 +788,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
button->set_text(value);
}
- button->connect("pressed", this, "_default_value_edited", varray(button, E->get(), i));
+ button->connect_compat("pressed", this, "_default_value_edited", varray(button, E->get(), i));
hbc2->add_child(button);
}
} else {
@@ -802,7 +814,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
Button *rmbtn = memnew(Button);
rmbtn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("Remove", "EditorIcons"));
hbc->add_child(rmbtn);
- rmbtn->connect("pressed", this, "_remove_output_port", varray(E->get(), i), CONNECT_DEFERRED);
+ rmbtn->connect_compat("pressed", this, "_remove_output_port", varray(E->get(), i), CONNECT_DEFERRED);
if (nd_list->is_output_port_type_editable()) {
OptionButton *opbtn = memnew(OptionButton);
@@ -812,7 +824,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
opbtn->select(right_type);
opbtn->set_custom_minimum_size(Size2(100 * EDSCALE, 0));
hbc->add_child(opbtn);
- opbtn->connect("item_selected", this, "_change_port_type", varray(E->get(), i, false), CONNECT_DEFERRED);
+ opbtn->connect_compat("item_selected", this, "_change_port_type", varray(E->get(), i, false), CONNECT_DEFERRED);
}
if (nd_list->is_output_port_name_editable()) {
@@ -821,8 +833,8 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
name_box->set_custom_minimum_size(Size2(60 * EDSCALE, 0));
name_box->set_text(right_name);
name_box->set_expand_to_text_length(true);
- name_box->connect("resized", this, "_update_node_size", varray(E->get()));
- name_box->connect("focus_exited", this, "_port_name_focus_out", varray(name_box, E->get(), i, false));
+ name_box->connect_compat("resized", this, "_update_node_size", varray(E->get()));
+ name_box->connect_compat("focus_exited", this, "_port_name_focus_out", varray(name_box, E->get(), i, false));
} else {
hbc->add_child(memnew(Label(right_name)));
}
@@ -830,7 +842,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
hbc->add_child(memnew(Label(right_name)));
}
- Ref<Texture> t;
+ Ref<Texture2D> t;
if (right_type >= 0 && right_type < Variant::VARIANT_MAX) {
t = type_icons[right_type];
}
@@ -846,7 +858,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
bool dark_theme = get_constant("dark_theme", "Editor");
if (i < mixed_seq_ports) {
- gnode->set_slot(slot_idx, left_ok, left_type, _color_from_type(left_type, dark_theme), true, TYPE_SEQUENCE, mono_color, Ref<Texture>(), seq_port);
+ gnode->set_slot(slot_idx, left_ok, left_type, _color_from_type(left_type, dark_theme), true, TYPE_SEQUENCE, mono_color, Ref<Texture2D>(), seq_port);
} else {
gnode->set_slot(slot_idx, left_ok, left_type, _color_from_type(left_type, dark_theme), right_ok, right_type, _color_from_type(right_type, dark_theme));
}
@@ -955,7 +967,7 @@ void VisualScriptEditor::_update_members() {
variables->add_button(0, Control::get_icon("Add", "EditorIcons"), -1, false, TTR("Create a new variable."));
variables->set_custom_color(0, Control::get_color("mono_color", "Editor"));
- Ref<Texture> type_icons[Variant::VARIANT_MAX] = {
+ Ref<Texture2D> type_icons[Variant::VARIANT_MAX] = {
Control::get_icon("Variant", "EditorIcons"),
Control::get_icon("bool", "EditorIcons"),
Control::get_icon("int", "EditorIcons"),
@@ -976,13 +988,13 @@ void VisualScriptEditor::_update_members() {
Control::get_icon("MiniObject", "EditorIcons"),
Control::get_icon("Dictionary", "EditorIcons"),
Control::get_icon("Array", "EditorIcons"),
- Control::get_icon("PoolByteArray", "EditorIcons"),
- Control::get_icon("PoolIntArray", "EditorIcons"),
- Control::get_icon("PoolRealArray", "EditorIcons"),
- Control::get_icon("PoolStringArray", "EditorIcons"),
- Control::get_icon("PoolVector2Array", "EditorIcons"),
- Control::get_icon("PoolVector3Array", "EditorIcons"),
- Control::get_icon("PoolColorArray", "EditorIcons")
+ Control::get_icon("PackedByteArray", "EditorIcons"),
+ Control::get_icon("PackedInt32Array", "EditorIcons"),
+ Control::get_icon("PackedFloat32Array", "EditorIcons"),
+ Control::get_icon("PackedStringArray", "EditorIcons"),
+ Control::get_icon("PackedVector2Array", "EditorIcons"),
+ Control::get_icon("PackedVector3Array", "EditorIcons"),
+ Control::get_icon("PackedColorArray", "EditorIcons")
};
List<StringName> var_names;
@@ -1225,7 +1237,7 @@ void VisualScriptEditor::_add_func_input() {
LineEdit *name_box = memnew(LineEdit);
name_box->set_h_size_flags(SIZE_EXPAND_FILL);
name_box->set_text("input");
- name_box->connect("focus_entered", this, "_deselect_input_names");
+ name_box->connect_compat("focus_entered", this, "_deselect_input_names");
hbox->add_child(name_box);
Label *type_label = memnew(Label);
@@ -1252,7 +1264,7 @@ void VisualScriptEditor::_add_func_input() {
func_input_vbox->add_child(hbox);
hbox->set_meta("id", hbox->get_position_in_parent());
- delete_button->connect("pressed", this, "_remove_func_input", varray(hbox));
+ delete_button->connect_compat("pressed", this, "_remove_func_input", varray(hbox));
name_box->select_all();
name_box->grab_focus();
@@ -2369,7 +2381,7 @@ void VisualScriptEditor::_draw_color_over_button(Object *obj, Color p_color) {
button->draw_rect(Rect2(normal->get_offset(), button->get_size() - normal->get_minimum_size()), p_color);
}
-void VisualScriptEditor::_button_resource_previewed(const String &p_path, const Ref<Texture> &p_preview, const Ref<Texture> &p_small_preview, Variant p_ud) {
+void VisualScriptEditor::_button_resource_previewed(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, Variant p_ud) {
Array ud = p_ud;
ERR_FAIL_COND(ud.size() != 2);
@@ -2408,7 +2420,7 @@ void VisualScriptEditor::set_edited_resource(const RES &p_res) {
variable_editor->script = script;
variable_editor->undo_redo = undo_redo;
- script->connect("node_ports_changed", this, "_node_ports_changed");
+ script->connect_compat("node_ports_changed", this, "_node_ports_changed");
default_func = script->get_default_func();
@@ -2447,7 +2459,7 @@ String VisualScriptEditor::get_name() {
return name;
}
-Ref<Texture> VisualScriptEditor::get_icon() {
+Ref<Texture2D> VisualScriptEditor::get_icon() {
return Control::get_icon("VisualScript", "EditorIcons");
}
@@ -2585,7 +2597,7 @@ void VisualScriptEditor::get_breakpoints(List<int> *p_breakpoints) {
}
}
-void VisualScriptEditor::add_callback(const String &p_function, PoolStringArray p_args) {
+void VisualScriptEditor::add_callback(const String &p_function, PackedStringArray p_args) {
if (script->has_function(p_function)) {
_update_members();
@@ -2910,8 +2922,8 @@ void VisualScriptEditor::_graph_connected(const String &p_from, int p_from_slot,
if (to_type != Variant::NIL && from_type != Variant::NIL && to_type != from_type) {
// add a constructor node between the ports
bool exceptions = false; // true if there are any exceptions
- exceptions = exceptions || (to_type == Variant::INT && from_type == Variant::REAL);
- exceptions = exceptions || (to_type == Variant::REAL && from_type == Variant::INT);
+ exceptions = exceptions || (to_type == Variant::INT && from_type == Variant::FLOAT);
+ exceptions = exceptions || (to_type == Variant::FLOAT && from_type == Variant::INT);
if (Variant::can_convert(from_type, to_type) && !exceptions) {
MethodInfo mi;
mi.name = Variant::get_type_name(to_type);
@@ -3851,7 +3863,7 @@ void VisualScriptEditor::_default_value_edited(Node *p_button, int p_id, int p_i
Variant existing = vsn->get_default_input_value(p_input_port);
if (pinfo.type != Variant::NIL && existing.get_type() != pinfo.type) {
- Variant::CallError ce;
+ Callable::CallError ce;
const Variant *existingp = &existing;
existing = Variant::construct(pinfo.type, &existingp, 1, ce, false);
}
@@ -3904,9 +3916,9 @@ void VisualScriptEditor::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_READY: {
- variable_editor->connect("changed", this, "_update_members");
- signal_editor->connect("changed", this, "_update_members");
- FALLTHROUGH;
+ variable_editor->connect_compat("changed", this, "_update_members");
+ signal_editor->connect_compat("changed", this, "_update_members");
+ [[fallthrough]];
}
case NOTIFICATION_THEME_CHANGED: {
if (p_what != NOTIFICATION_READY && !is_visible_in_tree()) {
@@ -4467,9 +4479,9 @@ void VisualScriptEditor::_member_rmb_selected(const Vector2 &p_pos) {
TreeItem *root = members->get_root();
- Ref<Texture> del_icon = Control::get_icon("Remove", "EditorIcons");
+ Ref<Texture2D> del_icon = Control::get_icon("Remove", "EditorIcons");
- Ref<Texture> edit_icon = Control::get_icon("Edit", "EditorIcons");
+ Ref<Texture2D> edit_icon = Control::get_icon("Edit", "EditorIcons");
if (ti->get_parent() == root->get_children()) {
@@ -4697,7 +4709,7 @@ VisualScriptEditor::VisualScriptEditor() {
edit_menu->get_popup()->add_separator();
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("visual_script_editor/create_function"), EDIT_CREATE_FUNCTION);
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("visual_script_editor/refresh_nodes"), REFRESH_GRAPH);
- edit_menu->get_popup()->connect("id_pressed", this, "_menu_option");
+ edit_menu->get_popup()->connect_compat("id_pressed", this, "_menu_option");
members_section = memnew(VBoxContainer);
// Add but wait until done setting up this.
@@ -4707,7 +4719,7 @@ VisualScriptEditor::VisualScriptEditor() {
CheckButton *tool_script_check = memnew(CheckButton);
tool_script_check->set_text(TTR("Make Tool:"));
members_section->add_child(tool_script_check);
- tool_script_check->connect("pressed", this, "_toggle_tool_script");
+ tool_script_check->connect_compat("pressed", this, "_toggle_tool_script");
/// Members ///
@@ -4715,11 +4727,11 @@ VisualScriptEditor::VisualScriptEditor() {
members_section->add_margin_child(TTR("Members:"), members, true);
members->set_custom_minimum_size(Size2(0, 50 * EDSCALE));
members->set_hide_root(true);
- members->connect("button_pressed", this, "_member_button");
- members->connect("item_edited", this, "_member_edited");
- members->connect("cell_selected", this, "_member_selected", varray(), CONNECT_DEFERRED);
- members->connect("gui_input", this, "_members_gui_input");
- members->connect("item_rmb_selected", this, "_member_rmb_selected");
+ members->connect_compat("button_pressed", this, "_member_button");
+ members->connect_compat("item_edited", this, "_member_edited");
+ members->connect_compat("cell_selected", this, "_member_selected", varray(), CONNECT_DEFERRED);
+ members->connect_compat("gui_input", this, "_members_gui_input");
+ members->connect_compat("item_rmb_selected", this, "_member_rmb_selected");
members->set_allow_rmb_select(true);
members->set_allow_reselect(true);
members->set_hide_folding(true);
@@ -4727,13 +4739,13 @@ VisualScriptEditor::VisualScriptEditor() {
member_popup = memnew(PopupMenu);
add_child(member_popup);
- member_popup->connect("id_pressed", this, "_member_option");
+ member_popup->connect_compat("id_pressed", this, "_member_option");
function_name_edit = memnew(PopupDialog);
function_name_box = memnew(LineEdit);
function_name_edit->add_child(function_name_box);
function_name_edit->set_h_size_flags(SIZE_EXPAND);
- function_name_box->connect("gui_input", this, "_fn_name_box_input");
+ function_name_box->connect_compat("gui_input", this, "_fn_name_box_input");
function_name_box->set_expand_to_text_length(true);
add_child(function_name_edit);
@@ -4743,15 +4755,15 @@ VisualScriptEditor::VisualScriptEditor() {
add_child(graph);
graph->set_v_size_flags(Control::SIZE_EXPAND_FILL);
graph->set_anchors_and_margins_preset(Control::PRESET_WIDE);
- graph->connect("node_selected", this, "_node_selected");
- graph->connect("_begin_node_move", this, "_begin_node_move");
- graph->connect("_end_node_move", this, "_end_node_move");
- graph->connect("delete_nodes_request", this, "_on_nodes_delete");
- graph->connect("duplicate_nodes_request", this, "_on_nodes_duplicate");
- graph->connect("gui_input", this, "_graph_gui_input");
+ graph->connect_compat("node_selected", this, "_node_selected");
+ graph->connect_compat("_begin_node_move", this, "_begin_node_move");
+ graph->connect_compat("_end_node_move", this, "_end_node_move");
+ graph->connect_compat("delete_nodes_request", this, "_on_nodes_delete");
+ graph->connect_compat("duplicate_nodes_request", this, "_on_nodes_duplicate");
+ graph->connect_compat("gui_input", this, "_graph_gui_input");
graph->set_drag_forwarding(this);
graph->hide();
- graph->connect("scroll_offset_changed", this, "_graph_ofs_changed");
+ graph->connect_compat("scroll_offset_changed", this, "_graph_ofs_changed");
/// Add Buttons to Top Bar/Zoom bar.
HBoxContainer *graph_hbc = graph->get_zoom_hbox();
@@ -4761,18 +4773,18 @@ VisualScriptEditor::VisualScriptEditor() {
graph_hbc->add_child(base_lbl);
base_type_select = memnew(Button);
- base_type_select->connect("pressed", this, "_change_base_type");
+ base_type_select->connect_compat("pressed", this, "_change_base_type");
graph_hbc->add_child(base_type_select);
Button *add_nds = memnew(Button);
add_nds->set_text(TTR("Add Nodes..."));
graph_hbc->add_child(add_nds);
- add_nds->connect("pressed", this, "_add_node_dialog");
+ add_nds->connect_compat("pressed", this, "_add_node_dialog");
Button *fn_btn = memnew(Button);
fn_btn->set_text(TTR("Add Function..."));
graph_hbc->add_child(fn_btn);
- fn_btn->connect("pressed", this, "_create_function_dialog");
+ fn_btn->connect_compat("pressed", this, "_create_function_dialog");
// Add Function Dialog.
VBoxContainer *function_vb = memnew(VBoxContainer);
@@ -4790,7 +4802,7 @@ VisualScriptEditor::VisualScriptEditor() {
func_name_box->set_h_size_flags(SIZE_EXPAND_FILL);
func_name_box->set_placeholder(TTR("function_name"));
func_name_box->set_text("");
- func_name_box->connect("focus_entered", this, "_deselect_input_names");
+ func_name_box->connect_compat("focus_entered", this, "_deselect_input_names");
func_name_hbox->add_child(func_name_box);
// Add minor setting for function if needed, here!
@@ -4800,7 +4812,7 @@ VisualScriptEditor::VisualScriptEditor() {
Button *add_input_button = memnew(Button);
add_input_button->set_h_size_flags(SIZE_EXPAND_FILL);
add_input_button->set_text(TTR("Add Input"));
- add_input_button->connect("pressed", this, "_add_func_input");
+ add_input_button->connect_compat("pressed", this, "_add_func_input");
function_vb->add_child(add_input_button);
func_input_scroll = memnew(ScrollContainer);
@@ -4816,7 +4828,7 @@ VisualScriptEditor::VisualScriptEditor() {
function_create_dialog->set_title(TTR("Create Function"));
function_create_dialog->add_child(function_vb);
function_create_dialog->get_ok()->set_text(TTR("Create"));
- function_create_dialog->get_ok()->connect("pressed", this, "_create_function");
+ function_create_dialog->get_ok()->connect_compat("pressed", this, "_create_function");
add_child(function_create_dialog);
select_func_text = memnew(Label);
@@ -4836,7 +4848,7 @@ VisualScriptEditor::VisualScriptEditor() {
hint_text_timer = memnew(Timer);
hint_text_timer->set_wait_time(4);
- hint_text_timer->connect("timeout", this, "_hide_timer");
+ hint_text_timer->connect_compat("timeout", this, "_hide_timer");
add_child(hint_text_timer);
// Allowed casts (connections).
@@ -4854,9 +4866,9 @@ VisualScriptEditor::VisualScriptEditor() {
graph->add_valid_left_disconnect_type(TYPE_SEQUENCE);
- graph->connect("connection_request", this, "_graph_connected");
- graph->connect("disconnection_request", this, "_graph_disconnected");
- graph->connect("connection_to_empty", this, "_graph_connect_to_empty");
+ graph->connect_compat("connection_request", this, "_graph_connected");
+ graph->connect_compat("disconnection_request", this, "_graph_disconnected");
+ graph->connect_compat("connection_to_empty", this, "_graph_connect_to_empty");
edit_signal_dialog = memnew(AcceptDialog);
edit_signal_dialog->get_ok()->set_text(TTR("Close"));
@@ -4880,7 +4892,7 @@ VisualScriptEditor::VisualScriptEditor() {
select_base_type = memnew(CreateDialog);
select_base_type->set_base_type("Object"); // Anything goes.
- select_base_type->connect("create", this, "_change_base_type_callback");
+ select_base_type->connect_compat("create", this, "_change_base_type_callback");
add_child(select_base_type);
undo_redo = EditorNode::get_singleton()->get_undo_redo();
@@ -4892,22 +4904,22 @@ VisualScriptEditor::VisualScriptEditor() {
default_value_edit = memnew(CustomPropertyEditor);
add_child(default_value_edit);
- default_value_edit->connect("variant_changed", this, "_default_value_changed");
+ default_value_edit->connect_compat("variant_changed", this, "_default_value_changed");
method_select = memnew(VisualScriptPropertySelector);
add_child(method_select);
- method_select->connect("selected", this, "_selected_method");
+ method_select->connect_compat("selected", this, "_selected_method");
error_line = -1;
new_connect_node_select = memnew(VisualScriptPropertySelector);
add_child(new_connect_node_select);
new_connect_node_select->set_resizable(true);
- new_connect_node_select->connect("selected", this, "_selected_connect_node");
- new_connect_node_select->get_cancel()->connect("pressed", this, "_cancel_connect_node");
+ new_connect_node_select->connect_compat("selected", this, "_selected_connect_node");
+ new_connect_node_select->get_cancel()->connect_compat("pressed", this, "_cancel_connect_node");
new_virtual_method_select = memnew(VisualScriptPropertySelector);
add_child(new_virtual_method_select);
- new_virtual_method_select->connect("selected", this, "_selected_new_virtual_method");
+ new_virtual_method_select->connect_compat("selected", this, "_selected_new_virtual_method");
}
VisualScriptEditor::~VisualScriptEditor() {
@@ -4963,7 +4975,7 @@ Ref<VisualScriptNode> _VisualScriptEditor::create_node_custom(const String &p_na
}
_VisualScriptEditor *_VisualScriptEditor::singleton = NULL;
-Map<String, RefPtr> _VisualScriptEditor::custom_nodes;
+Map<String, REF> _VisualScriptEditor::custom_nodes;
_VisualScriptEditor::_VisualScriptEditor() {
singleton = this;
@@ -4975,7 +4987,7 @@ _VisualScriptEditor::~_VisualScriptEditor() {
void _VisualScriptEditor::add_custom_node(const String &p_name, const String &p_category, const Ref<Script> &p_script) {
String node_name = "custom/" + p_category + "/" + p_name;
- custom_nodes.insert(node_name, p_script.get_ref_ptr());
+ custom_nodes.insert(node_name, p_script);
VisualScriptLanguage::singleton->add_register_func(node_name, &_VisualScriptEditor::create_node_custom);
emit_signal("custom_nodes_updated");
}
diff --git a/modules/visual_script/visual_script_editor.h b/modules/visual_script/visual_script_editor.h
index 7f3bf79d50..9a2a42b160 100644
--- a/modules/visual_script/visual_script_editor.h
+++ b/modules/visual_script/visual_script_editor.h
@@ -277,7 +277,7 @@ class VisualScriptEditor : public ScriptEditorBase {
void _selected_method(const String &p_method, const String &p_type, const bool p_connecting);
void _draw_color_over_button(Object *obj, Color p_color);
- void _button_resource_previewed(const String &p_path, const Ref<Texture> &p_preview, const Ref<Texture> &p_small_preview, Variant p_ud);
+ void _button_resource_previewed(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, Variant p_ud);
VisualScriptNode::TypeGuess _guess_output_type(int p_port_action_node, int p_port_action_output, Set<int> &p_visited_nodes);
@@ -298,7 +298,7 @@ public:
virtual Vector<String> get_functions();
virtual void reload_text();
virtual String get_name();
- virtual Ref<Texture> get_icon();
+ virtual Ref<Texture2D> get_icon();
virtual bool is_unsaved();
virtual Variant get_edit_state();
virtual void set_edit_state(const Variant &p_state);
@@ -313,7 +313,7 @@ public:
virtual void tag_saved_version();
virtual void reload(bool p_soft);
virtual void get_breakpoints(List<int> *p_breakpoints);
- virtual void add_callback(const String &p_function, PoolStringArray p_args);
+ virtual void add_callback(const String &p_function, PackedStringArray p_args);
virtual void update_settings();
virtual bool show_members_overview();
virtual void set_debugger_active(bool p_active);
@@ -341,7 +341,7 @@ protected:
static void _bind_methods();
static _VisualScriptEditor *singleton;
- static Map<String, RefPtr> custom_nodes;
+ static Map<String, REF> custom_nodes;
static Ref<VisualScriptNode> create_node_custom(const String &p_name);
public:
diff --git a/modules/visual_script/visual_script_expression.cpp b/modules/visual_script/visual_script_expression.cpp
index 4feef53c2e..23d1c8ccc0 100644
--- a/modules/visual_script/visual_script_expression.cpp
+++ b/modules/visual_script/visual_script_expression.cpp
@@ -392,8 +392,7 @@ Error VisualScriptExpression::_get_token(Token &r_token) {
case 'f': res = 12; break;
case 'r': res = 13; break;
case 'u': {
- //hexnumbarh - oct is deprecated
-
+ // hex number
for (int j = 0; j < 4; j++) {
CharType c = GET_CHAR();
@@ -418,7 +417,7 @@ Error VisualScriptExpression::_get_token(Token &r_token) {
v = c - 'A';
v += 10;
} else {
- ERR_PRINT("BUG");
+ ERR_PRINT("Bug parsing hex constant.");
v = 0;
}
@@ -427,13 +426,8 @@ Error VisualScriptExpression::_get_token(Token &r_token) {
}
} break;
- //case '\"': res='\"'; break;
- //case '\\': res='\\'; break;
- //case '/': res='/'; break;
default: {
res = next;
- //r_err_str="Invalid escape sequence";
- //return ERR_PARSE_ERROR;
} break;
}
@@ -1235,7 +1229,7 @@ public:
//virtual int get_working_memory_size() const { return 0; }
//execute by parsing the tree directly
- virtual bool _execute(const Variant **p_inputs, VisualScriptExpression::ENode *p_node, Variant &r_ret, String &r_error_str, Variant::CallError &ce) {
+ virtual bool _execute(const Variant **p_inputs, VisualScriptExpression::ENode *p_node, Variant &r_ret, String &r_error_str, Callable::CallError &ce) {
switch (p_node->type) {
case VisualScriptExpression::ENode::TYPE_INPUT: {
@@ -1377,7 +1371,7 @@ public:
r_ret = Variant::construct(constructor->data_type, (const Variant **)argp.ptr(), argp.size(), ce);
- if (ce.error != Variant::CallError::CALL_OK) {
+ if (ce.error != Callable::CallError::CALL_OK) {
r_error_str = "Invalid arguments to construct '" + Variant::get_type_name(constructor->data_type) + "'.";
return true;
}
@@ -1404,7 +1398,7 @@ public:
VisualScriptBuiltinFunc::exec_func(bifunc->func, (const Variant **)argp.ptr(), &r_ret, ce, r_error_str);
- if (ce.error != Variant::CallError::CALL_OK) {
+ if (ce.error != Callable::CallError::CALL_OK) {
r_error_str = "Builtin Call Failed. " + r_error_str;
return true;
}
@@ -1436,7 +1430,7 @@ public:
r_ret = base.call(call->method, (const Variant **)argp.ptr(), argp.size(), ce);
- if (ce.error != Variant::CallError::CALL_OK) {
+ if (ce.error != Callable::CallError::CALL_OK) {
r_error_str = "On call to '" + String(call->method) + "':";
return true;
}
@@ -1446,24 +1440,24 @@ public:
return false;
}
- virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) {
+ virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
if (!expression->root || expression->error_set) {
r_error_str = expression->error_str;
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
return 0;
}
bool error = _execute(p_inputs, expression->root, *p_outputs[0], r_error_str, r_error);
- if (error && r_error.error == Variant::CallError::CALL_OK) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
+ if (error && r_error.error == Callable::CallError::CALL_OK) {
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
}
#ifdef DEBUG_ENABLED
if (!error && expression->output_type != Variant::NIL && !Variant::can_convert_strict(p_outputs[0]->get_type(), expression->output_type)) {
r_error_str += "Can't convert expression result from " + Variant::get_type_name(p_outputs[0]->get_type()) + " to " + Variant::get_type_name(expression->output_type) + ".";
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
}
#endif
diff --git a/modules/visual_script/visual_script_flow_control.cpp b/modules/visual_script/visual_script_flow_control.cpp
index 213dc897af..475893e86d 100644
--- a/modules/visual_script/visual_script_flow_control.cpp
+++ b/modules/visual_script/visual_script_flow_control.cpp
@@ -135,7 +135,7 @@ public:
//virtual bool is_output_port_unsequenced(int p_idx) const { return false; }
//virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return true; }
- virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) {
+ virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
if (with_value) {
*p_working_mem = *p_inputs[0];
@@ -237,7 +237,7 @@ public:
//virtual bool is_output_port_unsequenced(int p_idx) const { return false; }
//virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return true; }
- virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) {
+ virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
if (p_start_mode == START_MODE_CONTINUE_SEQUENCE)
return 2;
@@ -323,7 +323,7 @@ public:
//virtual bool is_output_port_unsequenced(int p_idx) const { return false; }
//virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return true; }
- virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) {
+ virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
bool keep_going = p_inputs[0]->operator bool();
@@ -410,7 +410,7 @@ public:
//virtual bool is_output_port_unsequenced(int p_idx) const { return false; }
//virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return true; }
- virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) {
+ virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
if (p_start_mode == START_MODE_BEGIN_SEQUENCE) {
p_working_mem[0] = *p_inputs[0];
@@ -418,7 +418,7 @@ public:
bool can_iter = p_inputs[0]->iter_init(p_working_mem[1], valid);
if (!valid) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
r_error_str = RTR("Input type not iterable: ") + Variant::get_type_name(p_inputs[0]->get_type());
return 0;
}
@@ -429,7 +429,7 @@ public:
*p_outputs[0] = p_working_mem[0].iter_get(p_working_mem[1], valid);
if (!valid) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
r_error_str = RTR("Iterator became invalid");
return 0;
}
@@ -440,7 +440,7 @@ public:
bool can_iter = p_working_mem[0].iter_next(p_working_mem[1], valid);
if (!valid) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
r_error_str = RTR("Iterator became invalid: ") + Variant::get_type_name(p_inputs[0]->get_type());
return 0;
}
@@ -451,7 +451,7 @@ public:
*p_outputs[0] = p_working_mem[0].iter_get(p_working_mem[1], valid);
if (!valid) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
r_error_str = RTR("Iterator became invalid");
return 0;
}
@@ -549,7 +549,7 @@ public:
//virtual bool is_output_port_unsequenced(int p_idx) const { return false; }
//virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return true; }
- virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) {
+ virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
if (p_start_mode == START_MODE_BEGIN_SEQUENCE) {
@@ -645,7 +645,7 @@ public:
//virtual bool is_output_port_unsequenced(int p_idx) const { return false; }
//virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return false; }
- virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) {
+ virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
if (p_start_mode == START_MODE_CONTINUE_SEQUENCE) {
return case_count; //exit
@@ -836,14 +836,14 @@ public:
//virtual bool is_output_port_unsequenced(int p_idx) const { return false; }
//virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return false; }
- virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) {
+ virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
Object *obj = *p_inputs[0];
*p_outputs[0] = Variant();
if (!obj) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
r_error_str = "Instance is null";
return 0;
}
@@ -861,7 +861,7 @@ public:
}
Ref<Script> cast_script = Ref<Resource>(ResourceCache::get(script));
if (!cast_script.is_valid()) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
r_error_str = "Script path is not a script: " + script;
return 1;
}
diff --git a/modules/visual_script/visual_script_func_nodes.cpp b/modules/visual_script/visual_script_func_nodes.cpp
index 63c36ae431..011432ef39 100644
--- a/modules/visual_script/visual_script_func_nodes.cpp
+++ b/modules/visual_script/visual_script_func_nodes.cpp
@@ -788,7 +788,7 @@ public:
return true;
}
- virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) {
+ virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
switch (call_mode) {
@@ -808,14 +808,14 @@ public:
Node *node = Object::cast_to<Node>(instance->get_owner_ptr());
if (!node) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
r_error_str = "Base object is not a Node!";
return 0;
}
Node *another = node->get_node(node_path);
if (!another) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
r_error_str = "Path does not lead Node!";
return 0;
}
@@ -846,7 +846,7 @@ public:
} else if (returns == 1) {
v.call(function, p_inputs + 1, input_args, r_error);
} else {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
r_error_str = "Invalid returns count for call_mode == CALL_MODE_INSTANCE";
return 0;
}
@@ -866,7 +866,7 @@ public:
Object *object = Engine::get_singleton()->get_singleton_object(singleton);
if (!object) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
r_error_str = "Invalid singleton name: '" + String(singleton) + "'";
return 0;
}
@@ -884,7 +884,7 @@ public:
if (!validate) {
//ignore call errors if validation is disabled
- r_error.error = Variant::CallError::CALL_OK;
+ r_error.error = Callable::CallError::CALL_OK;
r_error_str = String();
}
@@ -1020,7 +1020,7 @@ void VisualScriptPropertySet::_adjust_input_index(PropertyInfo &pinfo) const {
if (index != StringName()) {
Variant v;
- Variant::CallError ce;
+ Callable::CallError ce;
v = Variant::construct(pinfo.type, NULL, 0, ce);
Variant i = v.get(index);
pinfo.type = i.get_type();
@@ -1167,7 +1167,7 @@ void VisualScriptPropertySet::_update_cache() {
//not super efficient..
Variant v;
- Variant::CallError ce;
+ Callable::CallError ce;
v = Variant::construct(basic_type, NULL, 0, ce);
List<PropertyInfo> pinfo;
@@ -1409,7 +1409,7 @@ void VisualScriptPropertySet::_validate_property(PropertyInfo &property) const {
if (property.name == "index") {
- Variant::CallError ce;
+ Callable::CallError ce;
Variant v = Variant::construct(type_cache.type, NULL, 0, ce);
List<PropertyInfo> plist;
v.get_property_list(&plist);
@@ -1578,7 +1578,7 @@ public:
}
}
- virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) {
+ virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
switch (call_mode) {
@@ -1597,7 +1597,7 @@ public:
}
if (!valid) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
r_error_str = "Invalid set value '" + String(*p_inputs[0]) + "' on property '" + String(property) + "' of type " + object->get_class();
}
} break;
@@ -1605,14 +1605,14 @@ public:
Node *node = Object::cast_to<Node>(instance->get_owner_ptr());
if (!node) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
r_error_str = "Base object is not a Node!";
return 0;
}
Node *another = node->get_node(node_path);
if (!another) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
r_error_str = "Path does not lead Node!";
return 0;
}
@@ -1629,7 +1629,7 @@ public:
}
if (!valid) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
r_error_str = "Invalid set value '" + String(*p_inputs[0]) + "' on property '" + String(property) + "' of type " + another->get_class();
}
@@ -1651,7 +1651,7 @@ public:
}
if (!valid) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
r_error_str = "Invalid set value '" + String(*p_inputs[1]) + "' (" + Variant::get_type_name(p_inputs[1]->get_type()) + ") on property '" + String(property) + "' of type " + Variant::get_type_name(v.get_type());
}
@@ -1875,7 +1875,7 @@ void VisualScriptPropertyGet::_update_cache() {
//not super efficient..
Variant v;
- Variant::CallError ce;
+ Callable::CallError ce;
v = Variant::construct(basic_type, NULL, 0, ce);
List<PropertyInfo> pinfo;
@@ -2124,7 +2124,7 @@ void VisualScriptPropertyGet::_validate_property(PropertyInfo &property) const {
if (property.name == "index") {
- Variant::CallError ce;
+ Callable::CallError ce;
Variant v = Variant::construct(type_cache, NULL, 0, ce);
List<PropertyInfo> plist;
v.get_property_list(&plist);
@@ -2211,7 +2211,7 @@ public:
VisualScriptPropertyGet *node;
VisualScriptInstance *instance;
- virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) {
+ virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
switch (call_mode) {
@@ -2228,7 +2228,7 @@ public:
}
if (!valid) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
r_error_str = RTR("Invalid index property name.");
return 0;
}
@@ -2237,14 +2237,14 @@ public:
Node *node = Object::cast_to<Node>(instance->get_owner_ptr());
if (!node) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
r_error_str = RTR("Base object is not a Node!");
return 0;
}
Node *another = node->get_node(node_path);
if (!another) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
r_error_str = RTR("Path does not lead Node!");
return 0;
}
@@ -2258,7 +2258,7 @@ public:
}
if (!valid) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
r_error_str = vformat(RTR("Invalid index property name '%s' in node %s."), String(property), another->get_name());
return 0;
}
@@ -2275,7 +2275,7 @@ public:
}
if (!valid) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
r_error_str = RTR("Invalid index property name.");
}
};
@@ -2434,7 +2434,7 @@ public:
//virtual bool is_output_port_unsequenced(int p_idx) const { return false; }
//virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return true; }
- virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) {
+ virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
Object *obj = instance->get_owner_ptr();
@@ -2500,7 +2500,7 @@ void register_visual_script_func_nodes() {
Variant::Type t = Variant::Type(i);
String type_name = Variant::get_type_name(t);
- Variant::CallError ce;
+ Callable::CallError ce;
Variant vt = Variant::construct(t, NULL, 0, ce);
List<MethodInfo> ml;
vt.get_method_list(&ml);
diff --git a/modules/visual_script/visual_script_nodes.cpp b/modules/visual_script/visual_script_nodes.cpp
index 36cafeec73..4a9a6bdb1d 100644
--- a/modules/visual_script/visual_script_nodes.cpp
+++ b/modules/visual_script/visual_script_nodes.cpp
@@ -285,7 +285,7 @@ public:
//virtual int get_working_memory_size() const { return 0; }
- virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) {
+ virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
int ac = node->get_argument_count();
@@ -294,7 +294,7 @@ public:
Variant::Type expected = node->get_argument_type(i);
if (expected != Variant::NIL) {
if (!Variant::can_convert_strict(p_inputs[i]->get_type(), expected)) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.expected = expected;
r_error.argument = i;
return 0;
@@ -762,7 +762,7 @@ public:
int input_count = 0;
virtual int get_working_memory_size() const { return 0; }
- virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) {
+ virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
if (input_count > 0) {
Array arr;
@@ -1031,7 +1031,7 @@ public:
//virtual int get_working_memory_size() const { return 0; }
- virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) {
+ virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
bool valid;
if (unary) {
@@ -1043,7 +1043,7 @@ public:
if (!valid) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
if (p_outputs[0]->get_type() == Variant::STRING) {
r_error_str = *p_outputs[0];
} else {
@@ -1165,7 +1165,7 @@ class VisualScriptNodeInstanceSelect : public VisualScriptNodeInstance {
public:
//virtual int get_working_memory_size() const { return 0; }
- virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) {
+ virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
bool cond = *p_inputs[0];
if (cond)
@@ -1285,10 +1285,10 @@ public:
VisualScriptInstance *instance;
StringName variable;
- virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) {
+ virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
if (!instance->get_variable(variable, p_outputs[0])) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
r_error_str = RTR("VariableGet not found in script: ") + "'" + String(variable) + "'";
return 0;
}
@@ -1407,11 +1407,11 @@ public:
//virtual int get_working_memory_size() const { return 0; }
- virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) {
+ virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
if (!instance->set_variable(variable, *p_inputs[0])) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
r_error_str = RTR("VariableSet not found in script: ") + "'" + String(variable) + "'";
}
@@ -1482,7 +1482,7 @@ void VisualScriptConstant::set_constant_type(Variant::Type p_type) {
return;
type = p_type;
- Variant::CallError ce;
+ Callable::CallError ce;
value = Variant::construct(type, NULL, 0, ce);
ports_changed_notify();
_change_notify();
@@ -1537,7 +1537,7 @@ public:
Variant constant;
//virtual int get_working_memory_size() const { return 0; }
- virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) {
+ virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
*p_outputs[0] = constant;
return 0;
@@ -1642,7 +1642,7 @@ public:
Ref<Resource> preload;
//virtual int get_working_memory_size() const { return 0; }
- virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) {
+ virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
*p_outputs[0] = preload;
return 0;
@@ -1710,13 +1710,13 @@ class VisualScriptNodeInstanceIndexGet : public VisualScriptNodeInstance {
public:
//virtual int get_working_memory_size() const { return 0; }
- virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) {
+ virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
bool valid;
*p_outputs[0] = p_inputs[0]->get(*p_inputs[1], &valid);
if (!valid) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
r_error_str = "Invalid get: " + p_inputs[0]->get_construct_string();
}
return 0;
@@ -1785,14 +1785,14 @@ class VisualScriptNodeInstanceIndexSet : public VisualScriptNodeInstance {
public:
//virtual int get_working_memory_size() const { return 0; }
- virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) {
+ virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
bool valid;
*p_outputs[0] = *p_inputs[0];
p_outputs[0]->set(*p_inputs[1], *p_inputs[2], &valid);
if (!valid) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
r_error_str = "Invalid set: " + p_inputs[1]->get_construct_string();
}
return 0;
@@ -1866,7 +1866,7 @@ public:
int index;
//virtual int get_working_memory_size() const { return 0; }
- virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) {
+ virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
*p_outputs[0] = GlobalConstants::get_global_constant_value(index);
return 0;
@@ -1935,8 +1935,11 @@ PropertyInfo VisualScriptClassConstant::get_input_value_port_info(int p_idx) con
}
PropertyInfo VisualScriptClassConstant::get_output_value_port_info(int p_idx) const {
-
- return PropertyInfo(Variant::INT, String(base_type) + "." + String(name));
+ if (name == "") {
+ return PropertyInfo(Variant::INT, String(base_type));
+ } else {
+ return PropertyInfo(Variant::INT, String(base_type) + "." + String(name));
+ }
}
String VisualScriptClassConstant::get_caption() const {
@@ -1958,6 +1961,22 @@ StringName VisualScriptClassConstant::get_class_constant() {
void VisualScriptClassConstant::set_base_type(const StringName &p_which) {
base_type = p_which;
+ List<String> constants;
+ ClassDB::get_integer_constant_list(base_type, &constants, true);
+ if (constants.size() > 0) {
+ bool found_name = false;
+ for (List<String>::Element *E = constants.front(); E; E = E->next()) {
+ if (E->get() == name) {
+ found_name = true;
+ break;
+ }
+ }
+ if (!found_name) {
+ name = constants[0];
+ }
+ } else {
+ name = "";
+ }
_change_notify();
ports_changed_notify();
}
@@ -1972,11 +1991,11 @@ public:
bool valid;
//virtual int get_working_memory_size() const { return 0; }
- virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) {
+ virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
if (!valid) {
r_error_str = "Invalid constant name, pick a valid class constant.";
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
}
*p_outputs[0] = value;
@@ -2121,11 +2140,11 @@ public:
bool valid;
//virtual int get_working_memory_size() const { return 0; }
- virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) {
+ virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
if (!valid) {
r_error_str = "Invalid constant name, pick a valid basic type constant.";
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
}
*p_outputs[0] = value;
@@ -2240,7 +2259,7 @@ PropertyInfo VisualScriptMathConstant::get_input_value_port_info(int p_idx) cons
PropertyInfo VisualScriptMathConstant::get_output_value_port_info(int p_idx) const {
- return PropertyInfo(Variant::REAL, const_name[constant]);
+ return PropertyInfo(Variant::FLOAT, const_name[constant]);
}
String VisualScriptMathConstant::get_caption() const {
@@ -2264,7 +2283,7 @@ public:
float value;
//virtual int get_working_memory_size() const { return 0; }
- virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) {
+ virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
*p_outputs[0] = value;
return 0;
@@ -2370,7 +2389,7 @@ public:
//virtual int get_working_memory_size() const { return 0; }
- virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) {
+ virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
*p_outputs[0] = singleton;
return 0;
@@ -2493,18 +2512,18 @@ public:
//virtual int get_working_memory_size() const { return 0; }
- virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) {
+ virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
Node *node = Object::cast_to<Node>(instance->get_owner_ptr());
if (!node) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
r_error_str = "Base object is not a Node!";
return 0;
}
Node *another = node->get_node(path);
if (!another) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
r_error_str = "Path does not lead Node!";
return 0;
}
@@ -2677,18 +2696,18 @@ public:
//virtual int get_working_memory_size() const { return 0; }
- virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) {
+ virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
Node *node = Object::cast_to<Node>(instance->get_owner_ptr());
if (!node) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
r_error_str = "Base object is not a Node!";
return 0;
}
SceneTree *tree = node->get_tree();
if (!tree) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
r_error_str = "Attempt to get SceneTree while node is not in the active tree.";
return 0;
}
@@ -2784,7 +2803,7 @@ public:
//virtual int get_working_memory_size() const { return 0; }
- virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) {
+ virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
*p_outputs[0] = path;
return 0;
@@ -2866,7 +2885,7 @@ public:
//virtual int get_working_memory_size() const { return 0; }
- virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) {
+ virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
*p_outputs[0] = instance->get_owner_ptr();
return 0;
@@ -3003,13 +3022,13 @@ public:
int work_mem_size;
virtual int get_working_memory_size() const { return work_mem_size; }
- virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) {
+ virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
if (node->get_script_instance()) {
#ifdef DEBUG_ENABLED
if (!node->get_script_instance()->has_method(VisualScriptLanguage::singleton->_step)) {
r_error_str = RTR("Custom node has no _step() method, can't process graph.");
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
return 0;
}
#endif
@@ -3036,13 +3055,13 @@ public:
Variant ret = node->get_script_instance()->call(VisualScriptLanguage::singleton->_step, in_values, out_values, p_start_mode, work_mem);
if (ret.get_type() == Variant::STRING) {
r_error_str = ret;
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
return 0;
} else if (ret.is_num()) {
ret_out = ret;
} else {
r_error_str = RTR("Invalid return value from _step(), must be integer (seq out), or string (error).");
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
return 0;
}
@@ -3125,7 +3144,7 @@ void VisualScriptCustomNode::_bind_methods() {
}
VisualScriptCustomNode::VisualScriptCustomNode() {
- connect("script_changed", this, "_script_changed");
+ connect_compat("script_changed", this, "_script_changed");
}
//////////////////////////////////////////
@@ -3218,11 +3237,11 @@ public:
//virtual int get_working_memory_size() const { return 0; }
- virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) {
+ virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
if (!valid) {
r_error_str = "Node requires a script with a _subcall(<args>) method to work.";
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
return 0;
}
*p_outputs[0] = subcall->call(VisualScriptLanguage::singleton->_subcall, p_inputs, input_args, r_error);
@@ -3349,7 +3368,7 @@ public:
//virtual int get_working_memory_size() const { return 0; }
- virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) {
+ virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
return 0;
}
@@ -3464,11 +3483,11 @@ public:
//virtual int get_working_memory_size() const { return 0; }
- virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) {
+ virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
- Variant::CallError ce;
+ Callable::CallError ce;
*p_outputs[0] = Variant::construct(type, p_inputs, argcount, ce);
- if (ce.error != Variant::CallError::CALL_OK) {
+ if (ce.error != Callable::CallError::CALL_OK) {
r_error_str = "Invalid arguments for constructor";
}
@@ -3593,7 +3612,7 @@ public:
StringName name;
virtual int get_working_memory_size() const { return 1; }
- virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) {
+ virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
*p_outputs[0] = *p_working_mem;
return 0;
@@ -3714,7 +3733,7 @@ public:
StringName name;
virtual int get_working_memory_size() const { return 1; }
- virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) {
+ virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
*p_working_mem = *p_inputs[0];
*p_outputs[0] = *p_working_mem;
@@ -3849,7 +3868,7 @@ public:
StringName action;
VisualScriptInputAction::Mode mode;
- virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) {
+ virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
switch (mode) {
case VisualScriptInputAction::MODE_PRESSED: {
@@ -3988,7 +4007,7 @@ void VisualScriptDeconstruct::_update_elements() {
elements.clear();
Variant v;
- Variant::CallError ce;
+ Callable::CallError ce;
v = Variant::construct(type, NULL, 0, ce);
List<PropertyInfo> pinfo;
@@ -4046,7 +4065,7 @@ public:
//virtual int get_working_memory_size() const { return 0; }
- virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) {
+ virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
Variant in = *p_inputs[0];
@@ -4055,7 +4074,7 @@ public:
*p_outputs[i] = in.get(outputs[i], &valid);
if (!valid) {
r_error_str = "Can't obtain element '" + String(outputs[i]) + "' from " + Variant::get_type_name(in.get_type());
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
return 0;
}
}
diff --git a/modules/visual_script/visual_script_property_selector.cpp b/modules/visual_script/visual_script_property_selector.cpp
index 99d7ffd05f..20bad364dc 100644
--- a/modules/visual_script/visual_script_property_selector.cpp
+++ b/modules/visual_script/visual_script_property_selector.cpp
@@ -98,7 +98,7 @@ void VisualScriptPropertySelector::_update_search() {
List<MethodInfo> methods;
List<PropertyInfo> props;
TreeItem *category = NULL;
- Ref<Texture> type_icons[Variant::VARIANT_MAX] = {
+ Ref<Texture2D> type_icons[Variant::VARIANT_MAX] = {
Control::get_icon("Variant", "EditorIcons"),
Control::get_icon("bool", "EditorIcons"),
Control::get_icon("int", "EditorIcons"),
@@ -119,13 +119,15 @@ void VisualScriptPropertySelector::_update_search() {
Control::get_icon("Object", "EditorIcons"),
Control::get_icon("Dictionary", "EditorIcons"),
Control::get_icon("Array", "EditorIcons"),
- Control::get_icon("PoolByteArray", "EditorIcons"),
- Control::get_icon("PoolIntArray", "EditorIcons"),
- Control::get_icon("PoolRealArray", "EditorIcons"),
- Control::get_icon("PoolStringArray", "EditorIcons"),
- Control::get_icon("PoolVector2Array", "EditorIcons"),
- Control::get_icon("PoolVector3Array", "EditorIcons"),
- Control::get_icon("PoolColorArray", "EditorIcons")
+ Control::get_icon("PackedByteArray", "EditorIcons"),
+ Control::get_icon("PackedInt32Array", "EditorIcons"),
+ Control::get_icon("PackedFloat32Array", "EditorIcons"),
+ Control::get_icon("PackedInt64Array", "EditorIcons"),
+ Control::get_icon("PackedFloat64Array", "EditorIcons"),
+ Control::get_icon("PackedStringArray", "EditorIcons"),
+ Control::get_icon("PackedVector2Array", "EditorIcons"),
+ Control::get_icon("PackedVector3Array", "EditorIcons"),
+ Control::get_icon("PackedColorArray", "EditorIcons")
};
{
String b = String(E->get());
@@ -133,7 +135,7 @@ void VisualScriptPropertySelector::_update_search() {
if (category) {
category->set_text(0, b.replace_first("*", ""));
category->set_selectable(0, false);
- Ref<Texture> icon;
+ Ref<Texture2D> icon;
String rep = b.replace("*", "");
icon = EditorNode::get_singleton()->get_class_icon(rep);
category->set_icon(0, icon);
@@ -193,7 +195,7 @@ void VisualScriptPropertySelector::_update_search() {
{
if (type != Variant::NIL) {
Variant v;
- Variant::CallError ce;
+ Callable::CallError ce;
v = Variant::construct(type, NULL, 0, ce);
v.get_method_list(&methods);
} else {
@@ -279,7 +281,7 @@ void VisualScriptPropertySelector::_update_search() {
if (type == Variant::BOOL) {
get_visual_node_names("operators/logic/", Set<String>(), found, root, search_box);
}
- if (type == Variant::BOOL || type == Variant::INT || type == Variant::REAL || type == Variant::VECTOR2 || type == Variant::VECTOR3) {
+ if (type == Variant::BOOL || type == Variant::INT || type == Variant::FLOAT || type == Variant::VECTOR2 || type == Variant::VECTOR3) {
get_visual_node_names("operators/math/", Set<String>(), found, root, search_box);
}
}
@@ -355,7 +357,7 @@ void VisualScriptPropertySelector::get_visual_node_names(const String &root_filt
continue;
}
- bool in_modifier = false | p_modifiers.empty();
+ bool in_modifier = p_modifiers.empty();
for (Set<String>::Element *F = p_modifiers.front(); F && in_modifier; F = F->next()) {
if (E->get().findn(F->get()) != -1)
in_modifier = true;
@@ -520,7 +522,7 @@ void VisualScriptPropertySelector::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
- connect("confirmed", this, "_confirmed");
+ connect_compat("confirmed", this, "_confirmed");
}
}
@@ -529,7 +531,6 @@ void VisualScriptPropertySelector::select_method_from_base_type(const String &p_
base_type = p_base;
selected = p_current;
type = Variant::NIL;
- script = 0;
properties = false;
instance = NULL;
virtuals_only = p_virtuals_only;
@@ -554,7 +555,6 @@ void VisualScriptPropertySelector::select_from_base_type(const String &p_base, c
base_type = p_base;
selected = p_current;
type = Variant::NIL;
- script = 0;
properties = true;
visual_script_generic = false;
instance = NULL;
@@ -601,7 +601,6 @@ void VisualScriptPropertySelector::select_from_basic_type(Variant::Type p_type,
base_type = "";
selected = p_current;
type = p_type;
- script = 0;
properties = true;
visual_script_generic = false;
instance = NULL;
@@ -623,7 +622,6 @@ void VisualScriptPropertySelector::select_from_action(const String &p_type, cons
base_type = p_type;
selected = p_current;
type = Variant::NIL;
- script = 0;
properties = false;
visual_script_generic = false;
instance = NULL;
@@ -645,7 +643,6 @@ void VisualScriptPropertySelector::select_from_instance(Object *p_instance, cons
base_type = p_basetype;
selected = p_current;
type = Variant::NIL;
- script = 0;
properties = true;
visual_script_generic = false;
instance = p_instance;
@@ -667,7 +664,6 @@ void VisualScriptPropertySelector::select_from_visual_script(const String &p_bas
base_type = p_base;
selected = "";
type = Variant::NIL;
- script = 0;
properties = true;
visual_script_generic = true;
instance = NULL;
@@ -709,23 +705,23 @@ VisualScriptPropertySelector::VisualScriptPropertySelector() {
//set_child_rect(vbc);
search_box = memnew(LineEdit);
vbc->add_margin_child(TTR("Search:"), search_box);
- search_box->connect("text_changed", this, "_text_changed");
- search_box->connect("gui_input", this, "_sbox_input");
+ search_box->connect_compat("text_changed", this, "_text_changed");
+ search_box->connect_compat("gui_input", this, "_sbox_input");
search_options = memnew(Tree);
vbc->add_margin_child(TTR("Matches:"), search_options, true);
get_ok()->set_text(TTR("Open"));
get_ok()->set_disabled(true);
register_text_enter(search_box);
set_hide_on_ok(false);
- search_options->connect("item_activated", this, "_confirmed");
- search_options->connect("cell_selected", this, "_item_selected");
+ search_options->connect_compat("item_activated", this, "_confirmed");
+ search_options->connect_compat("cell_selected", this, "_item_selected");
search_options->set_hide_root(true);
search_options->set_hide_folding(true);
virtuals_only = false;
seq_connect = false;
help_bit = memnew(EditorHelpBit);
vbc->add_margin_child(TTR("Description:"), help_bit);
- help_bit->connect("request_hide", this, "_closed");
+ help_bit->connect_compat("request_hide", this, "_closed");
search_options->set_columns(3);
search_options->set_column_expand(1, false);
search_options->set_column_expand(2, false);
diff --git a/modules/visual_script/visual_script_yield_nodes.cpp b/modules/visual_script/visual_script_yield_nodes.cpp
index 877d5836d2..858074742e 100644
--- a/modules/visual_script/visual_script_yield_nodes.cpp
+++ b/modules/visual_script/visual_script_yield_nodes.cpp
@@ -99,7 +99,7 @@ public:
//virtual bool is_output_port_unsequenced(int p_idx) const { return false; }
//virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return false; }
- virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) {
+ virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
if (p_start_mode == START_MODE_RESUME_YIELD) {
return 0; //resuming yield
@@ -109,7 +109,7 @@ public:
SceneTree *tree = Object::cast_to<SceneTree>(OS::get_singleton()->get_main_loop());
if (!tree) {
r_error_str = "Main Loop is not SceneTree";
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
return 0;
}
@@ -188,7 +188,7 @@ void VisualScriptYield::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_wait_time"), &VisualScriptYield::get_wait_time);
ADD_PROPERTY(PropertyInfo(Variant::INT, "mode", PROPERTY_HINT_ENUM, "Frame,Physics Frame,Time", PROPERTY_USAGE_NOEDITOR), "set_yield_mode", "get_yield_mode");
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "wait_time"), "set_wait_time", "get_wait_time");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "wait_time"), "set_wait_time", "get_wait_time");
BIND_ENUM_CONSTANT(YIELD_FRAME);
BIND_ENUM_CONSTANT(YIELD_PHYSICS_FRAME);
@@ -509,7 +509,7 @@ public:
//virtual bool is_output_port_unsequenced(int p_idx) const { return false; }
//virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return true; }
- virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) {
+ virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
if (p_start_mode == START_MODE_RESUME_YIELD) {
return 0; //resuming yield
@@ -529,14 +529,14 @@ public:
Node *node = Object::cast_to<Node>(instance->get_owner_ptr());
if (!node) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
r_error_str = "Base object is not a Node!";
return 0;
}
Node *another = node->get_node(node_path);
if (!another) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
r_error_str = "Path does not lead Node!";
return 0;
}
@@ -548,7 +548,7 @@ public:
object = *p_inputs[0];
if (!object) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
r_error_str = "Supplied instance input is null.";
return 0;
}
diff --git a/modules/webm/video_stream_webm.cpp b/modules/webm/video_stream_webm.cpp
index 2763d30bb5..5768392fe5 100644
--- a/modules/webm/video_stream_webm.cpp
+++ b/modules/webm/video_stream_webm.cpp
@@ -141,7 +141,10 @@ bool VideoStreamPlaybackWebm::open_file(const String &p_file) {
}
frame_data.resize((webm->getWidth() * webm->getHeight()) << 2);
- texture->create(webm->getWidth(), webm->getHeight(), Image::FORMAT_RGBA8, Texture::FLAG_FILTER | Texture::FLAG_VIDEO_SURFACE);
+ Ref<Image> img;
+ img.instance();
+ img->create(webm->getWidth(), webm->getHeight(), false, Image::FORMAT_RGBA8);
+ texture->create_from_image(img);
return true;
}
@@ -231,7 +234,7 @@ void VideoStreamPlaybackWebm::set_audio_track(int p_idx) {
audio_track = p_idx;
}
-Ref<Texture> VideoStreamPlaybackWebm::get_texture() const {
+Ref<Texture2D> VideoStreamPlaybackWebm::get_texture() const {
return texture;
}
@@ -312,12 +315,12 @@ void VideoStreamPlaybackWebm::update(float p_delta) {
if (err == VPXDecoder::NO_ERROR && image.w == webm->getWidth() && image.h == webm->getHeight()) {
- PoolVector<uint8_t>::Write w = frame_data.write();
+ uint8_t *w = frame_data.ptrw();
bool converted = false;
if (image.chromaShiftW == 0 && image.chromaShiftH == 0 && image.cs == VPX_CS_SRGB) {
- uint8_t *wp = w.ptr();
+ uint8_t *wp = w;
unsigned char *rRow = image.planes[2];
unsigned char *gRow = image.planes[0];
unsigned char *bRow = image.planes[1];
@@ -335,17 +338,17 @@ void VideoStreamPlaybackWebm::update(float p_delta) {
converted = true;
} else if (image.chromaShiftW == 1 && image.chromaShiftH == 1) {
- yuv420_2_rgb8888(w.ptr(), image.planes[0], image.planes[1], image.planes[2], image.w, image.h, image.linesize[0], image.linesize[1], image.w << 2);
+ yuv420_2_rgb8888(w, image.planes[0], image.planes[1], image.planes[2], image.w, image.h, image.linesize[0], image.linesize[1], image.w << 2);
//libyuv::I420ToARGB(image.planes[0], image.linesize[0], image.planes[2], image.linesize[2], image.planes[1], image.linesize[1], w.ptr(), image.w << 2, image.w, image.h);
converted = true;
} else if (image.chromaShiftW == 1 && image.chromaShiftH == 0) {
- yuv422_2_rgb8888(w.ptr(), image.planes[0], image.planes[1], image.planes[2], image.w, image.h, image.linesize[0], image.linesize[1], image.w << 2);
+ yuv422_2_rgb8888(w, image.planes[0], image.planes[1], image.planes[2], image.w, image.h, image.linesize[0], image.linesize[1], image.w << 2);
//libyuv::I422ToARGB(image.planes[0], image.linesize[0], image.planes[2], image.linesize[2], image.planes[1], image.linesize[1], w.ptr(), image.w << 2, image.w, image.h);
converted = true;
} else if (image.chromaShiftW == 0 && image.chromaShiftH == 0) {
- yuv444_2_rgb8888(w.ptr(), image.planes[0], image.planes[1], image.planes[2], image.w, image.h, image.linesize[0], image.linesize[1], image.w << 2);
+ yuv444_2_rgb8888(w, image.planes[0], image.planes[1], image.planes[2], image.w, image.h, image.linesize[0], image.linesize[1], image.w << 2);
//libyuv::I444ToARGB(image.planes[0], image.linesize[0], image.planes[2], image.linesize[2], image.planes[1], image.linesize[1], w.ptr(), image.w << 2, image.w, image.h);
converted = true;
} else if (image.chromaShiftW == 2 && image.chromaShiftH == 0) {
@@ -356,7 +359,7 @@ void VideoStreamPlaybackWebm::update(float p_delta) {
if (converted) {
Ref<Image> img = memnew(Image(image.w, image.h, 0, Image::FORMAT_RGBA8, frame_data));
- texture->set_data(img); //Zero copy send to visual server
+ texture->update(img); //Zero copy send to visual server
video_frame_done = true;
}
}
diff --git a/modules/webm/video_stream_webm.h b/modules/webm/video_stream_webm.h
index e679196cf2..a3d3c173f4 100644
--- a/modules/webm/video_stream_webm.h
+++ b/modules/webm/video_stream_webm.h
@@ -61,7 +61,7 @@ class VideoStreamPlaybackWebm : public VideoStreamPlayback {
double delay_compensation;
double time, video_frame_delay, video_pos;
- PoolVector<uint8_t> frame_data;
+ Vector<uint8_t> frame_data;
Ref<ImageTexture> texture;
float *pcm;
@@ -90,7 +90,7 @@ public:
virtual void set_audio_track(int p_idx);
- virtual Ref<Texture> get_texture() const;
+ virtual Ref<Texture2D> get_texture() const;
virtual void update(float p_delta);
virtual void set_mix_callback(AudioMixCallback p_callback, void *p_userdata);
diff --git a/modules/webp/image_loader_webp.cpp b/modules/webp/image_loader_webp.cpp
index 7f4afa9a08..09a8985472 100644
--- a/modules/webp/image_loader_webp.cpp
+++ b/modules/webp/image_loader_webp.cpp
@@ -38,9 +38,9 @@
#include <webp/decode.h>
#include <webp/encode.h>
-static PoolVector<uint8_t> _webp_lossy_pack(const Ref<Image> &p_image, float p_quality) {
+static Vector<uint8_t> _webp_lossy_pack(const Ref<Image> &p_image, float p_quality) {
- ERR_FAIL_COND_V(p_image.is_null() || p_image->empty(), PoolVector<uint8_t>());
+ ERR_FAIL_COND_V(p_image.is_null() || p_image->empty(), Vector<uint8_t>());
Ref<Image> img = p_image->duplicate();
if (img->detect_alpha())
@@ -49,37 +49,37 @@ static PoolVector<uint8_t> _webp_lossy_pack(const Ref<Image> &p_image, float p_q
img->convert(Image::FORMAT_RGB8);
Size2 s(img->get_width(), img->get_height());
- PoolVector<uint8_t> data = img->get_data();
- PoolVector<uint8_t>::Read r = data.read();
+ Vector<uint8_t> data = img->get_data();
+ const uint8_t *r = data.ptr();
uint8_t *dst_buff = NULL;
size_t dst_size = 0;
if (img->get_format() == Image::FORMAT_RGB8) {
- dst_size = WebPEncodeRGB(r.ptr(), s.width, s.height, 3 * s.width, CLAMP(p_quality * 100.0, 0, 100.0), &dst_buff);
+ dst_size = WebPEncodeRGB(r, s.width, s.height, 3 * s.width, CLAMP(p_quality * 100.0, 0, 100.0), &dst_buff);
} else {
- dst_size = WebPEncodeRGBA(r.ptr(), s.width, s.height, 4 * s.width, CLAMP(p_quality * 100.0, 0, 100.0), &dst_buff);
+ dst_size = WebPEncodeRGBA(r, s.width, s.height, 4 * s.width, CLAMP(p_quality * 100.0, 0, 100.0), &dst_buff);
}
- ERR_FAIL_COND_V(dst_size == 0, PoolVector<uint8_t>());
- PoolVector<uint8_t> dst;
+ ERR_FAIL_COND_V(dst_size == 0, Vector<uint8_t>());
+ Vector<uint8_t> dst;
dst.resize(4 + dst_size);
- PoolVector<uint8_t>::Write w = dst.write();
+ uint8_t *w = dst.ptrw();
w[0] = 'W';
w[1] = 'E';
w[2] = 'B';
w[3] = 'P';
copymem(&w[4], dst_buff, dst_size);
free(dst_buff);
- w.release();
+
return dst;
}
-static Ref<Image> _webp_lossy_unpack(const PoolVector<uint8_t> &p_buffer) {
+static Ref<Image> _webp_lossy_unpack(const Vector<uint8_t> &p_buffer) {
int size = p_buffer.size() - 4;
ERR_FAIL_COND_V(size <= 0, Ref<Image>());
- PoolVector<uint8_t>::Read r = p_buffer.read();
+ const uint8_t *r = p_buffer.ptr();
ERR_FAIL_COND_V(r[0] != 'W' || r[1] != 'E' || r[2] != 'B' || r[3] != 'P', Ref<Image>());
WebPBitstreamFeatures features;
@@ -93,23 +93,21 @@ static Ref<Image> _webp_lossy_unpack(const PoolVector<uint8_t> &p_buffer) {
print_line("alpha: "+itos(features.has_alpha));
*/
- PoolVector<uint8_t> dst_image;
+ Vector<uint8_t> dst_image;
int datasize = features.width * features.height * (features.has_alpha ? 4 : 3);
dst_image.resize(datasize);
- PoolVector<uint8_t>::Write dst_w = dst_image.write();
+ uint8_t *dst_w = dst_image.ptrw();
bool errdec = false;
if (features.has_alpha) {
- errdec = WebPDecodeRGBAInto(&r[4], size, dst_w.ptr(), datasize, 4 * features.width) == NULL;
+ errdec = WebPDecodeRGBAInto(&r[4], size, dst_w, datasize, 4 * features.width) == NULL;
} else {
- errdec = WebPDecodeRGBInto(&r[4], size, dst_w.ptr(), datasize, 3 * features.width) == NULL;
+ errdec = WebPDecodeRGBInto(&r[4], size, dst_w, datasize, 3 * features.width) == NULL;
}
ERR_FAIL_COND_V_MSG(errdec, Ref<Image>(), "Failed decoding WebP image.");
- dst_w.release();
-
Ref<Image> img = memnew(Image(features.width, features.height, 0, features.has_alpha ? Image::FORMAT_RGBA8 : Image::FORMAT_RGB8, dst_image));
return img;
}
@@ -123,18 +121,17 @@ Error webp_load_image_from_buffer(Image *p_image, const uint8_t *p_buffer, int p
ERR_FAIL_V(ERR_FILE_CORRUPT);
}
- PoolVector<uint8_t> dst_image;
+ Vector<uint8_t> dst_image;
int datasize = features.width * features.height * (features.has_alpha ? 4 : 3);
dst_image.resize(datasize);
- PoolVector<uint8_t>::Write dst_w = dst_image.write();
+ uint8_t *dst_w = dst_image.ptrw();
bool errdec = false;
if (features.has_alpha) {
- errdec = WebPDecodeRGBAInto(p_buffer, p_buffer_len, dst_w.ptr(), datasize, 4 * features.width) == NULL;
+ errdec = WebPDecodeRGBAInto(p_buffer, p_buffer_len, dst_w, datasize, 4 * features.width) == NULL;
} else {
- errdec = WebPDecodeRGBInto(p_buffer, p_buffer_len, dst_w.ptr(), datasize, 3 * features.width) == NULL;
+ errdec = WebPDecodeRGBInto(p_buffer, p_buffer_len, dst_w, datasize, 3 * features.width) == NULL;
}
- dst_w.release();
ERR_FAIL_COND_V_MSG(errdec, ERR_FILE_CORRUPT, "Failed decoding WebP image.");
@@ -154,18 +151,18 @@ static Ref<Image> _webp_mem_loader_func(const uint8_t *p_png, int p_size) {
Error ImageLoaderWEBP::load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear, float p_scale) {
- PoolVector<uint8_t> src_image;
+ Vector<uint8_t> src_image;
int src_image_len = f->get_len();
ERR_FAIL_COND_V(src_image_len == 0, ERR_FILE_CORRUPT);
src_image.resize(src_image_len);
- PoolVector<uint8_t>::Write w = src_image.write();
+ uint8_t *w = src_image.ptrw();
f->get_buffer(&w[0], src_image_len);
f->close();
- Error err = webp_load_image_from_buffer(p_image.ptr(), w.ptr(), src_image_len);
+ Error err = webp_load_image_from_buffer(p_image.ptr(), w, src_image_len);
return err;
}
diff --git a/modules/websocket/doc_classes/WebSocketClient.xml b/modules/websocket/doc_classes/WebSocketClient.xml
index 2549321db3..45db49c913 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="PoolStringArray" default="PoolStringArray( )">
+ <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="PoolStringArray" default="PoolStringArray( )">
+ <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 f66e1bf54b..f7805209e2 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="PoolStringArray" default="PoolStringArray( )">
+ <argument index="1" name="protocols" type="PackedStringArray" default="PackedStringArray( )">
</argument>
<argument index="2" name="gd_mp_api" type="bool" default="false">
</argument>
diff --git a/modules/websocket/emws_client.cpp b/modules/websocket/emws_client.cpp
index 7e68936fc3..e5680ce2e9 100644
--- a/modules/websocket/emws_client.cpp
+++ b/modules/websocket/emws_client.cpp
@@ -91,10 +91,14 @@ Error EMWSClient::connect_to_host(String p_host, String p_path, uint16_t p_port,
int peer_sock = EM_ASM_INT({
var proto_str = UTF8ToString($2);
var socket = null;
- if (proto_str) {
- socket = new WebSocket(UTF8ToString($1), proto_str.split(","));
- } else {
- socket = new WebSocket(UTF8ToString($1));
+ try {
+ if (proto_str) {
+ socket = new WebSocket(UTF8ToString($1), proto_str.split(","));
+ } else {
+ socket = new WebSocket(UTF8ToString($1));
+ }
+ } catch (e) {
+ return -1;
}
var c_ptr = Module.IDHandler.get($0);
socket.binaryType = "arraybuffer";
@@ -174,6 +178,8 @@ Error EMWSClient::connect_to_host(String p_host, String p_path, uint16_t p_port,
return Module.IDHandler.add(socket);
}, _js_id, str.utf8().get_data(), proto_string.utf8().get_data());
/* clang-format on */
+ if (peer_sock == -1)
+ return FAILED;
static_cast<Ref<EMWSPeer> >(_peer)->set_sock(peer_sock, _in_buf_size, _in_pkt_size);
@@ -190,11 +196,11 @@ Ref<WebSocketPeer> EMWSClient::get_peer(int p_peer_id) const {
NetworkedMultiplayerPeer::ConnectionStatus EMWSClient::get_connection_status() const {
- if (_peer->is_connected_to_host())
+ if (_peer->is_connected_to_host()) {
+ if (_is_connecting)
+ return CONNECTION_CONNECTING;
return CONNECTION_CONNECTED;
-
- if (_is_connecting)
- return CONNECTION_CONNECTING;
+ }
return CONNECTION_DISCONNECTED;
};
diff --git a/modules/websocket/emws_peer.cpp b/modules/websocket/emws_peer.cpp
index effed8e4d9..f396a1c812 100644
--- a/modules/websocket/emws_peer.cpp
+++ b/modules/websocket/emws_peer.cpp
@@ -68,12 +68,17 @@ Error EMWSPeer::put_packet(const uint8_t *p_buffer, int p_buffer_size) {
bytes_array[i] = getValue($1+i, 'i8');
}
- if ($3) {
- sock.send(bytes_array.buffer);
- } else {
- var string = new TextDecoder("utf-8").decode(bytes_array);
- sock.send(string);
+ try {
+ if ($3) {
+ sock.send(bytes_array.buffer);
+ } else {
+ var string = new TextDecoder("utf-8").decode(bytes_array);
+ sock.send(string);
+ }
+ } catch (e) {
+ return 1;
}
+ return 0;
}, peer_sock, p_buffer, p_buffer_size, is_bin);
/* clang-format on */
@@ -85,7 +90,7 @@ Error EMWSPeer::get_packet(const uint8_t **r_buffer, int &r_buffer_size) {
if (_in_buffer.packets_left() == 0)
return ERR_UNAVAILABLE;
- PoolVector<uint8_t>::Write rw = _packet_buffer.write();
+ uint8_t *rw = _packet_buffer.ptrw();
int read = 0;
Error err = _in_buffer.read_packet(rw.ptr(), _packet_buffer.size(), &_is_string, read);
ERR_FAIL_COND_V(err != OK, err);
diff --git a/modules/websocket/emws_peer.h b/modules/websocket/emws_peer.h
index 43b42f9be6..6308ebe490 100644
--- a/modules/websocket/emws_peer.h
+++ b/modules/websocket/emws_peer.h
@@ -48,7 +48,7 @@ private:
int peer_sock;
WriteMode write_mode;
- PoolVector<uint8_t> _packet_buffer;
+ Vector<uint8_t> _packet_buffer;
PacketBuffer<uint8_t> _in_buffer;
uint8_t _is_string;
diff --git a/modules/websocket/emws_server.cpp b/modules/websocket/emws_server.cpp
index 23faa05365..8ceefa42b6 100644
--- a/modules/websocket/emws_server.cpp
+++ b/modules/websocket/emws_server.cpp
@@ -53,8 +53,8 @@ Ref<WebSocketPeer> EMWSServer::get_peer(int p_id) const {
return NULL;
}
-PoolVector<String> EMWSServer::get_protocols() const {
- PoolVector<String> out;
+Vector<String> EMWSServer::get_protocols() const {
+ Vector<String> out;
return out;
}
diff --git a/modules/websocket/emws_server.h b/modules/websocket/emws_server.h
index 869e59fe03..f273fd078f 100644
--- a/modules/websocket/emws_server.h
+++ b/modules/websocket/emws_server.h
@@ -53,7 +53,7 @@ public:
void disconnect_peer(int p_peer_id, int p_code = 1000, String p_reason = "");
int get_max_packet_size() const;
virtual void poll();
- virtual PoolVector<String> get_protocols() const;
+ virtual Vector<String> get_protocols() const;
EMWSServer();
~EMWSServer();
diff --git a/modules/websocket/websocket_multiplayer_peer.cpp b/modules/websocket/websocket_multiplayer_peer.cpp
index 27ea50b524..5c01d44ede 100644
--- a/modules/websocket/websocket_multiplayer_peer.cpp
+++ b/modules/websocket/websocket_multiplayer_peer.cpp
@@ -127,12 +127,12 @@ Error WebSocketMultiplayerPeer::put_packet(const uint8_t *p_buffer, int p_buffer
ERR_FAIL_COND_V_MSG(!_is_multiplayer, ERR_UNCONFIGURED, "Please use get_peer(ID).put_packet/var to communicate with peers when not using the MultiplayerAPI.");
- PoolVector<uint8_t> buffer = _make_pkt(SYS_NONE, get_unique_id(), _target_peer, p_buffer, p_buffer_size);
+ Vector<uint8_t> buffer = _make_pkt(SYS_NONE, get_unique_id(), _target_peer, p_buffer, p_buffer_size);
if (is_server()) {
- return _server_relay(1, _target_peer, &(buffer.read()[0]), buffer.size());
+ return _server_relay(1, _target_peer, &(buffer.ptr()[0]), buffer.size());
} else {
- return get_peer(1)->put_packet(&(buffer.read()[0]), buffer.size());
+ return get_peer(1)->put_packet(&(buffer.ptr()[0]), buffer.size());
}
}
@@ -183,16 +183,16 @@ void WebSocketMultiplayerPeer::_send_sys(Ref<WebSocketPeer> p_peer, uint8_t p_ty
ERR_FAIL_COND(!p_peer.is_valid());
ERR_FAIL_COND(!p_peer->is_connected_to_host());
- PoolVector<uint8_t> message = _make_pkt(p_type, 1, 0, (uint8_t *)&p_peer_id, 4);
- p_peer->put_packet(&(message.read()[0]), message.size());
+ Vector<uint8_t> message = _make_pkt(p_type, 1, 0, (uint8_t *)&p_peer_id, 4);
+ p_peer->put_packet(&(message.ptr()[0]), message.size());
}
-PoolVector<uint8_t> WebSocketMultiplayerPeer::_make_pkt(uint8_t p_type, int32_t p_from, int32_t p_to, const uint8_t *p_data, uint32_t p_data_size) {
+Vector<uint8_t> WebSocketMultiplayerPeer::_make_pkt(uint8_t p_type, int32_t p_from, int32_t p_to, const uint8_t *p_data, uint32_t p_data_size) {
- PoolVector<uint8_t> out;
+ Vector<uint8_t> out;
out.resize(PROTO_SIZE + p_data_size);
- PoolVector<uint8_t>::Write w = out.write();
+ uint8_t *w = out.ptrw();
copymem(&w[0], &p_type, 1);
copymem(&w[1], &p_from, 4);
copymem(&w[5], &p_to, 4);
diff --git a/modules/websocket/websocket_multiplayer_peer.h b/modules/websocket/websocket_multiplayer_peer.h
index 27cb6e4eb7..579972ada2 100644
--- a/modules/websocket/websocket_multiplayer_peer.h
+++ b/modules/websocket/websocket_multiplayer_peer.h
@@ -41,7 +41,7 @@ class WebSocketMultiplayerPeer : public NetworkedMultiplayerPeer {
GDCLASS(WebSocketMultiplayerPeer, NetworkedMultiplayerPeer);
private:
- PoolVector<uint8_t> _make_pkt(uint8_t p_type, int32_t p_from, int32_t p_to, const uint8_t *p_data, uint32_t p_data_size);
+ Vector<uint8_t> _make_pkt(uint8_t p_type, int32_t p_from, int32_t p_to, const uint8_t *p_data, uint32_t p_data_size);
void _store_pkt(int32_t p_source, int32_t p_dest, const uint8_t *p_data, uint32_t p_data_size);
Error _server_relay(int32_t p_from, int32_t p_to, const uint8_t *p_buffer, uint32_t p_buffer_size);
diff --git a/modules/websocket/wsl_peer.cpp b/modules/websocket/wsl_peer.cpp
index 08079145e4..ff32e83dc1 100644
--- a/modules/websocket/wsl_peer.cpp
+++ b/modules/websocket/wsl_peer.cpp
@@ -43,10 +43,10 @@ String WSLPeer::generate_key() {
// Random key
RandomNumberGenerator rng;
rng.set_seed(OS::get_singleton()->get_unix_time());
- PoolVector<uint8_t> bkey;
+ Vector<uint8_t> bkey;
int len = 16; // 16 bytes, as per RFC
bkey.resize(len);
- PoolVector<uint8_t>::Write w = bkey.write();
+ uint8_t *w = bkey.ptrw();
for (int i = 0; i < len; i++) {
w[i] = (uint8_t)rng.randi_range(0, 255);
}
@@ -260,10 +260,10 @@ Error WSLPeer::get_packet(const uint8_t **r_buffer, int &r_buffer_size) {
return ERR_UNAVAILABLE;
int read = 0;
- PoolVector<uint8_t>::Write rw = _packet_buffer.write();
- _in_buffer.read_packet(rw.ptr(), _packet_buffer.size(), &_is_string, read);
+ uint8_t *rw = _packet_buffer.ptrw();
+ _in_buffer.read_packet(rw, _packet_buffer.size(), &_is_string, read);
- *r_buffer = rw.ptr();
+ *r_buffer = rw;
r_buffer_size = read;
return OK;
diff --git a/modules/websocket/wsl_peer.h b/modules/websocket/wsl_peer.h
index f1c45ee859..00549cd9bc 100644
--- a/modules/websocket/wsl_peer.h
+++ b/modules/websocket/wsl_peer.h
@@ -86,7 +86,7 @@ private:
// Our packet info is just a boolean (is_string), using uint8_t for it.
PacketBuffer<uint8_t> _in_buffer;
- PoolVector<uint8_t> _packet_buffer;
+ Vector<uint8_t> _packet_buffer;
WriteMode write_mode;