summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/arkit/SCsub10
-rw-r--r--modules/arkit/arkit_interface.h125
-rw-r--r--modules/arkit/arkit_interface.mm738
-rw-r--r--modules/arkit/arkit_session_delegate.h50
-rw-r--r--modules/arkit/arkit_session_delegate.mm56
-rw-r--r--modules/arkit/config.py5
-rw-r--r--modules/arkit/register_types.cpp45
-rw-r--r--modules/arkit/register_types.h32
-rw-r--r--modules/assimp/editor_scene_importer_assimp.cpp32
-rw-r--r--modules/bmp/image_loader_bmp.cpp10
-rw-r--r--modules/bullet/SCsub6
-rw-r--r--modules/bullet/bullet_physics_server.cpp2
-rw-r--r--modules/bullet/bullet_physics_server.h2
-rw-r--r--modules/bullet/collision_object_bullet.cpp2
-rw-r--r--modules/bullet/cone_twist_joint_bullet.cpp2
-rw-r--r--modules/bullet/generic_6dof_joint_bullet.cpp4
-rw-r--r--modules/bullet/hinge_joint_bullet.cpp2
-rw-r--r--modules/bullet/pin_joint_bullet.cpp2
-rw-r--r--modules/bullet/rigid_body_bullet.cpp4
-rw-r--r--modules/bullet/rigid_body_bullet.h2
-rw-r--r--modules/bullet/space_bullet.h3
-rw-r--r--modules/csg/csg.cpp10
-rw-r--r--modules/csg/csg_gizmos.h3
-rw-r--r--modules/csg/csg_shape.cpp8
-rw-r--r--modules/csg/csg_shape.h21
-rw-r--r--modules/csg/doc_classes/CSGBox.xml8
-rw-r--r--modules/csg/doc_classes/CSGCylinder.xml12
-rw-r--r--modules/csg/doc_classes/CSGMesh.xml4
-rw-r--r--modules/csg/doc_classes/CSGPolygon.xml10
-rw-r--r--modules/csg/doc_classes/CSGPrimitive.xml2
-rw-r--r--modules/csg/doc_classes/CSGShape.xml12
-rw-r--r--modules/csg/doc_classes/CSGSphere.xml10
-rw-r--r--modules/csg/doc_classes/CSGTorus.xml12
-rw-r--r--modules/csg/icons/icon_c_s_g_box.svg6
-rw-r--r--modules/csg/icons/icon_c_s_g_capsule.svg6
-rw-r--r--modules/csg/icons/icon_c_s_g_combiner.svg8
-rw-r--r--modules/csg/icons/icon_c_s_g_cylinder.svg6
-rw-r--r--modules/csg/icons/icon_c_s_g_mesh.svg6
-rw-r--r--modules/csg/icons/icon_c_s_g_polygon.svg6
-rw-r--r--modules/csg/icons/icon_c_s_g_sphere.svg6
-rw-r--r--modules/csg/icons/icon_c_s_g_torus.svg6
-rw-r--r--modules/cvtt/image_compress_cvtt.cpp6
-rw-r--r--modules/dds/texture_loader_dds.cpp25
-rw-r--r--modules/dds/texture_loader_dds.h1
-rw-r--r--modules/enet/doc_classes/NetworkedMultiplayerENet.xml34
-rw-r--r--modules/enet/networked_multiplayer_enet.cpp9
-rw-r--r--modules/enet/networked_multiplayer_enet.h3
-rw-r--r--modules/etc/texture_loader_pkm.h1
-rw-r--r--modules/gdnative/android/android_gdn.cpp29
-rw-r--r--modules/gdnative/arvr/arvr_interface_gdnative.cpp37
-rw-r--r--modules/gdnative/arvr/arvr_interface_gdnative.h5
-rw-r--r--modules/gdnative/config.py2
-rw-r--r--modules/gdnative/doc_classes/@NativeScript.xml (renamed from modules/stb_vorbis/doc_classes/ResourceImporterOGGVorbis.xml)2
-rw-r--r--modules/gdnative/doc_classes/ARVRInterfaceGDNative.xml4
-rw-r--r--modules/gdnative/doc_classes/GDNative.xml2
-rw-r--r--modules/gdnative/doc_classes/GDNativeLibrary.xml8
-rw-r--r--modules/gdnative/doc_classes/NativeScript.xml8
-rw-r--r--modules/gdnative/gdnative.h6
-rw-r--r--modules/gdnative/gdnative/array.cpp4
-rw-r--r--modules/gdnative/gdnative_api.json14
-rw-r--r--modules/gdnative/icons/icon_g_d_native_library.svg5
-rw-r--r--modules/gdnative/icons/icon_native_script.svg5
-rw-r--r--modules/gdnative/include/android/godot_android.h2
-rw-r--r--modules/gdnative/include/arvr/godot_arvr.h1
-rw-r--r--modules/gdnative/include/gdnative/gdnative.h6
-rw-r--r--modules/gdnative/nativescript/nativescript.h6
-rw-r--r--modules/gdnative/net/multiplayer_peer_gdnative.cpp2
-rw-r--r--modules/gdnative/net/multiplayer_peer_gdnative.h2
-rw-r--r--modules/gdnative/net/packet_peer_gdnative.h2
-rw-r--r--modules/gdnative/pluginscript/pluginscript_language.cpp2
-rw-r--r--modules/gdnative/pluginscript/pluginscript_loader.h4
-rw-r--r--modules/gdnative/pluginscript/pluginscript_script.cpp30
-rw-r--r--modules/gdnative/videodecoder/video_stream_gdnative.h1
-rw-r--r--modules/gdscript/config.py1
-rw-r--r--modules/gdscript/doc_classes/@GDScript.xml1314
-rw-r--r--modules/gdscript/gdscript.cpp4
-rw-r--r--modules/gdscript/gdscript.h2
-rw-r--r--modules/gdscript/gdscript_compiler.cpp4
-rw-r--r--modules/gdscript/gdscript_editor.cpp12
-rw-r--r--modules/gdscript/gdscript_function.cpp115
-rw-r--r--modules/gdscript/gdscript_functions.cpp2
-rw-r--r--modules/gdscript/gdscript_parser.cpp81
-rw-r--r--modules/gdscript/gdscript_tokenizer.cpp4
-rw-r--r--modules/gdscript/icons/icon_g_d_script.svg5
-rw-r--r--modules/gridmap/doc_classes/GridMap.xml22
-rw-r--r--modules/gridmap/grid_map.cpp5
-rw-r--r--modules/gridmap/grid_map_editor_plugin.cpp12
-rw-r--r--modules/gridmap/icons/icon_grid_map.svg5
-rwxr-xr-xmodules/mbedtls/stream_peer_mbed_tls.cpp2
-rw-r--r--modules/mobile_vr/doc_classes/MobileVRInterface.xml20
-rw-r--r--modules/mono/csharp_script.cpp7
-rw-r--r--modules/mono/csharp_script.h6
-rw-r--r--modules/mono/editor/bindings_generator.cpp9
-rw-r--r--modules/mono/editor/csharp_project.h2
-rw-r--r--modules/mono/editor/godotsharp_editor.h4
-rw-r--r--modules/mono/editor/mono_bottom_panel.h4
-rw-r--r--modules/mono/mono_gc_handle.h2
-rw-r--r--modules/mono/mono_gd/gd_mono.h2
-rw-r--r--modules/mono/mono_gd/gd_mono_internals.cpp2
-rw-r--r--modules/mono/signal_awaiter_utils.h2
-rw-r--r--modules/mono/utils/thread_local.h2
-rw-r--r--modules/opensimplex/doc_classes/NoiseTexture.xml12
-rw-r--r--modules/opensimplex/doc_classes/OpenSimplexNoise.xml14
-rw-r--r--modules/opensimplex/icons/icon_noise_texture.svg3
-rw-r--r--modules/opensimplex/noise_texture.h6
-rw-r--r--modules/opensimplex/open_simplex_noise.h2
-rw-r--r--modules/opus/SCsub2
-rw-r--r--modules/opus/audio_stream_opus.cpp2
-rw-r--r--modules/opus/audio_stream_opus.h5
-rw-r--r--modules/pvr/texture_loader_pvr.h1
-rw-r--r--modules/recast/navigation_mesh_editor_plugin.cpp4
-rw-r--r--modules/recast/navigation_mesh_generator.cpp18
-rw-r--r--modules/regex/doc_classes/RegEx.xml16
-rw-r--r--modules/regex/doc_classes/RegExMatch.xml12
-rw-r--r--modules/stb_vorbis/audio_stream_ogg_vorbis.h4
-rw-r--r--modules/stb_vorbis/config.py1
-rw-r--r--modules/stb_vorbis/doc_classes/AudioStreamOGGVorbis.xml6
-rw-r--r--modules/stb_vorbis/register_types.cpp13
-rw-r--r--modules/stb_vorbis/resource_importer_ogg_vorbis.cpp5
-rw-r--r--modules/stb_vorbis/resource_importer_ogg_vorbis.h3
-rw-r--r--modules/theora/config.py1
-rw-r--r--modules/theora/video_stream_theora.h1
-rw-r--r--modules/tinyexr/image_loader_tinyexr.cpp4
-rw-r--r--modules/upnp/SCsub3
-rw-r--r--modules/upnp/doc_classes/UPNP.xml19
-rw-r--r--modules/upnp/doc_classes/UPNPDevice.xml12
-rw-r--r--modules/visual_script/config.py1
-rw-r--r--modules/visual_script/doc_classes/@VisualScript.xml (renamed from modules/gdnative/doc_classes/ResourceFormatLoaderVideoStreamGDNative.xml)4
-rw-r--r--modules/visual_script/doc_classes/VisualScript.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptBasicTypeConstant.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptBuiltinFunc.xml19
-rw-r--r--modules/visual_script/doc_classes/VisualScriptClassConstant.xml6
-rw-r--r--modules/visual_script/doc_classes/VisualScriptComment.xml6
-rw-r--r--modules/visual_script/doc_classes/VisualScriptConstant.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptCustomNode.xml8
-rw-r--r--modules/visual_script/doc_classes/VisualScriptDeconstruct.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptEmitSignal.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptEngineSingleton.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptFunctionCall.xml10
-rw-r--r--modules/visual_script/doc_classes/VisualScriptGlobalConstant.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptInputAction.xml4
-rw-r--r--modules/visual_script/doc_classes/VisualScriptLocalVar.xml4
-rw-r--r--modules/visual_script/doc_classes/VisualScriptLocalVarSet.xml4
-rw-r--r--modules/visual_script/doc_classes/VisualScriptMathConstant.xml3
-rw-r--r--modules/visual_script/doc_classes/VisualScriptOperator.xml4
-rw-r--r--modules/visual_script/doc_classes/VisualScriptPreload.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptPropertyGet.xml6
-rw-r--r--modules/visual_script/doc_classes/VisualScriptPropertySet.xml8
-rw-r--r--modules/visual_script/doc_classes/VisualScriptResourcePath.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptReturn.xml4
-rw-r--r--modules/visual_script/doc_classes/VisualScriptSceneNode.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptSelect.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptSequence.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptSwitch.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptTypeCast.xml4
-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/VisualScriptYield.xml2
-rw-r--r--modules/visual_script/doc_classes/VisualScriptYieldSignal.xml6
-rw-r--r--modules/visual_script/icons/icon_visual_script.svg6
-rw-r--r--modules/visual_script/visual_script.cpp2
-rw-r--r--modules/visual_script/visual_script.h4
-rw-r--r--modules/visual_script/visual_script_builtin_funcs.h3
-rw-r--r--modules/visual_script/visual_script_editor.cpp14
-rw-r--r--modules/visual_script/visual_script_editor.h4
-rw-r--r--modules/visual_script/visual_script_expression.cpp2
-rw-r--r--modules/visual_script/visual_script_expression.h2
-rw-r--r--modules/visual_script/visual_script_flow_control.h14
-rw-r--r--modules/visual_script/visual_script_func_nodes.cpp7
-rw-r--r--modules/visual_script/visual_script_func_nodes.h11
-rw-r--r--modules/visual_script/visual_script_nodes.h54
-rw-r--r--modules/visual_script/visual_script_property_selector.cpp3
-rw-r--r--modules/visual_script/visual_script_property_selector.h2
-rw-r--r--modules/visual_script/visual_script_yield_nodes.h6
-rw-r--r--modules/vorbis/audio_stream_ogg_vorbis.cpp3
-rw-r--r--modules/vorbis/audio_stream_ogg_vorbis.h1
-rw-r--r--modules/webm/config.py1
-rw-r--r--modules/webm/libvpx/SCsub2
-rw-r--r--modules/webm/video_stream_webm.cpp7
-rw-r--r--modules/webm/video_stream_webm.h3
-rw-r--r--modules/webrtc/config.py3
-rw-r--r--modules/webrtc/doc_classes/WebRTCDataChannel.xml23
-rw-r--r--modules/webrtc/doc_classes/WebRTCMultiplayer.xml85
-rw-r--r--modules/webrtc/doc_classes/WebRTCPeerConnection.xml61
-rw-r--r--modules/webrtc/register_types.cpp2
-rw-r--r--modules/webrtc/webrtc_data_channel_gdnative.cpp1
-rw-r--r--modules/webrtc/webrtc_data_channel_js.cpp35
-rw-r--r--modules/webrtc/webrtc_multiplayer.cpp384
-rw-r--r--modules/webrtc/webrtc_multiplayer.h116
-rw-r--r--modules/websocket/doc_classes/WebSocketClient.xml18
-rw-r--r--modules/websocket/doc_classes/WebSocketMultiplayerPeer.xml21
-rw-r--r--modules/websocket/doc_classes/WebSocketPeer.xml18
-rw-r--r--modules/websocket/doc_classes/WebSocketServer.xml19
-rw-r--r--modules/websocket/emws_client.cpp6
-rw-r--r--modules/websocket/emws_client.h1
-rw-r--r--modules/websocket/emws_server.cpp4
-rw-r--r--modules/websocket/emws_server.h1
-rw-r--r--modules/websocket/lws_client.cpp11
-rw-r--r--modules/websocket/lws_client.h1
-rw-r--r--modules/websocket/lws_server.cpp11
-rw-r--r--modules/websocket/lws_server.h1
-rw-r--r--modules/websocket/websocket_client.h2
-rw-r--r--modules/websocket/websocket_multiplayer_peer.cpp1
-rw-r--r--modules/websocket/websocket_multiplayer_peer.h3
-rw-r--r--modules/websocket/websocket_server.h2
205 files changed, 3936 insertions, 563 deletions
diff --git a/modules/arkit/SCsub b/modules/arkit/SCsub
new file mode 100644
index 0000000000..b43d936768
--- /dev/null
+++ b/modules/arkit/SCsub
@@ -0,0 +1,10 @@
+#!/usr/bin/env python
+
+Import('env')
+Import('env_modules')
+
+env_arkit = env_modules.Clone()
+
+# Add source files
+env_arkit.add_source_files(env.modules_sources, "*.cpp")
+env_arkit.add_source_files(env.modules_sources, "*.mm")
diff --git a/modules/arkit/arkit_interface.h b/modules/arkit/arkit_interface.h
new file mode 100644
index 0000000000..8129611287
--- /dev/null
+++ b/modules/arkit/arkit_interface.h
@@ -0,0 +1,125 @@
+/*************************************************************************/
+/* arkit_interface.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 ARKIT_INTERFACE_H
+#define ARKIT_INTERFACE_H
+
+#include "servers/arvr/arvr_interface.h"
+#include "servers/arvr/arvr_positional_tracker.h"
+#include "servers/camera/camera_feed.h"
+
+/**
+ @author Bastiaan Olij <mux213@gmail.com>
+
+ ARKit interface between iPhone and Godot
+*/
+
+// forward declaration for some needed objects
+class ARKitShader;
+
+class ARKitInterface : public ARVRInterface {
+ GDCLASS(ARKitInterface, ARVRInterface);
+
+private:
+ bool initialized;
+ bool session_was_started;
+ bool plane_detection_is_enabled;
+ bool light_estimation_is_enabled;
+ real_t ambient_intensity;
+ real_t ambient_color_temperature;
+
+ Transform transform;
+ CameraMatrix projection;
+ float eye_height, z_near, z_far;
+
+ Ref<CameraFeed> feed;
+ int image_width[2];
+ int image_height[2];
+ PoolVector<uint8_t> img_data[2];
+
+ struct anchor_map {
+ ARVRPositionalTracker *tracker;
+ unsigned char uuid[16];
+ };
+
+ ///@TODO should use memory map object from Godot?
+ unsigned int num_anchors;
+ unsigned int max_anchors;
+ anchor_map *anchors;
+ ARVRPositionalTracker *get_anchor_for_uuid(const unsigned char *p_uuid);
+ void remove_anchor_for_uuid(const unsigned char *p_uuid);
+ void remove_all_anchors();
+
+protected:
+ static void _bind_methods();
+
+public:
+ void start_session();
+ void stop_session();
+
+ bool get_anchor_detection_is_enabled() const;
+ void set_anchor_detection_is_enabled(bool p_enable);
+ virtual int get_camera_feed_id();
+
+ bool get_light_estimation_is_enabled() const;
+ void set_light_estimation_is_enabled(bool p_enable);
+
+ real_t get_ambient_intensity() const;
+ real_t get_ambient_color_temperature() const;
+
+ /* while Godot has its own raycast logic this takes ARKits camera into account and hits on any ARAnchor */
+ Array raycast(Vector2 p_screen_coord);
+
+ void notification(int p_what);
+
+ virtual StringName get_name() const;
+ virtual int get_capabilities() const;
+
+ virtual bool is_initialized() const;
+ virtual bool initialize();
+ virtual void uninitialize();
+
+ virtual Size2 get_render_targetsize();
+ virtual bool is_stereo();
+ virtual Transform get_transform_for_eye(ARVRInterface::Eyes p_eye, const Transform &p_cam_transform);
+ virtual CameraMatrix get_projection_for_eye(ARVRInterface::Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far);
+ virtual void commit_for_eye(ARVRInterface::Eyes p_eye, RID p_render_target, const Rect2 &p_screen_rect);
+
+ virtual void process();
+
+ // called by delegate (void * because C++ and Obj-C don't always mix, should really change all platform/iphone/*.cpp files to .mm)
+ void _add_or_update_anchor(void *p_anchor);
+ void _remove_anchor(void *p_anchor);
+
+ ARKitInterface();
+ ~ARKitInterface();
+};
+
+#endif /* !ARKIT_INTERFACE_H */
diff --git a/modules/arkit/arkit_interface.mm b/modules/arkit/arkit_interface.mm
new file mode 100644
index 0000000000..de58f93276
--- /dev/null
+++ b/modules/arkit/arkit_interface.mm
@@ -0,0 +1,738 @@
+/*************************************************************************/
+/* arkit_interface.mm */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 "camera_ios.h"
+#include "core/os/input.h"
+#include "core/os/os.h"
+#include "scene/resources/surface_tool.h"
+#include "servers/visual/visual_server_globals.h"
+
+#import <ARKit/ARKit.h>
+#import <UIKit/UIKit.h>
+
+#include "arkit_interface.h"
+#include "arkit_session_delegate.h"
+
+// just a dirty workaround for now, declare these as globals. I'll probably encapsulate ARSession and associated logic into an mm object and change ARKitInterface to a normal cpp object that consumes it.
+ARSession *ar_session;
+ARKitSessionDelegate *ar_delegate;
+NSTimeInterval last_timestamp;
+
+/* this is called when we initialize or when we come back from having our app pushed to the background, just (re)start our session */
+void ARKitInterface::start_session() {
+ // We're active...
+ session_was_started = true;
+
+ // Ignore this if we're not initialized...
+ if (initialized) {
+ print_line("Starting ARKit session");
+ ARWorldTrackingConfiguration *configuration = [ARWorldTrackingConfiguration new];
+ configuration.lightEstimationEnabled = light_estimation_is_enabled;
+ if (plane_detection_is_enabled) {
+ configuration.planeDetection = ARPlaneDetectionVertical | ARPlaneDetectionHorizontal;
+ } else {
+ configuration.planeDetection = 0;
+ }
+
+ // make sure our camera is on
+ if (feed.is_valid()) {
+ feed->set_active(true);
+ }
+
+ [ar_session runWithConfiguration:configuration];
+ }
+}
+
+void ARKitInterface::stop_session() {
+ session_was_started = false;
+
+ // Ignore this if we're not initialized...
+ if (initialized) {
+ // make sure our camera is off
+ if (feed.is_valid()) {
+ feed->set_active(false);
+ }
+
+ [ar_session pause];
+ }
+}
+
+void ARKitInterface::notification(int p_what) {
+ // TODO, this is not being called, need to find out why, possibly because this is not a node.
+ // in that case we need to find a way to get these notifications!
+ switch (p_what) {
+ case MainLoop::NOTIFICATION_WM_FOCUS_IN: {
+ print_line("Focus in");
+
+ start_session();
+ }; break;
+ case MainLoop::NOTIFICATION_WM_FOCUS_OUT: {
+ print_line("Focus out");
+
+ stop_session();
+ }; break;
+ default:
+ break;
+ }
+}
+
+bool ARKitInterface::get_anchor_detection_is_enabled() const {
+ return plane_detection_is_enabled;
+}
+
+void ARKitInterface::set_anchor_detection_is_enabled(bool p_enable) {
+ if (plane_detection_is_enabled != p_enable) {
+ plane_detection_is_enabled = p_enable;
+
+ // Restart our session (this will be ignore if we're not initialised)
+ if (session_was_started) {
+ start_session();
+ }
+ }
+}
+
+int ARKitInterface::get_camera_feed_id() {
+ if (feed.is_null()) {
+ return 0;
+ } else {
+ return feed->get_id();
+ }
+}
+
+bool ARKitInterface::get_light_estimation_is_enabled() const {
+ return light_estimation_is_enabled;
+}
+
+void ARKitInterface::set_light_estimation_is_enabled(bool p_enable) {
+ if (light_estimation_is_enabled != p_enable) {
+ light_estimation_is_enabled = p_enable;
+
+ // Restart our session (this will be ignore if we're not initialised)
+ if (session_was_started) {
+ start_session();
+ }
+ }
+}
+
+real_t ARKitInterface::get_ambient_intensity() const {
+ return ambient_intensity;
+}
+
+real_t ARKitInterface::get_ambient_color_temperature() const {
+ return ambient_color_temperature;
+}
+
+StringName ARKitInterface::get_name() const {
+ return "ARKit";
+}
+
+int ARKitInterface::get_capabilities() const {
+ return ARKitInterface::ARVR_MONO + ARKitInterface::ARVR_AR;
+}
+
+Array ARKitInterface::raycast(Vector2 p_screen_coord) {
+ Array arr;
+ Size2 screen_size = OS::get_singleton()->get_window_size();
+ CGPoint point;
+ point.x = p_screen_coord.x / screen_size.x;
+ point.y = p_screen_coord.y / screen_size.y;
+
+ ///@TODO maybe give more options here, for now we're taking just ARAchors into account that were found during plane detection keeping their size into account
+ NSArray<ARHitTestResult *> *results = [ar_session.currentFrame hittest:point types:ARHitTestResultTypeExistingPlaneUsingExtent];
+
+ for (ARHitTestResult *result in results) {
+ Transform transform;
+
+ matrix_float4x4 m44 = result.worldTransform;
+ transform.basis.elements[0].x = m44.columns[0][0];
+ transform.basis.elements[1].x = m44.columns[0][1];
+ transform.basis.elements[2].x = m44.columns[0][2];
+ transform.basis.elements[0].y = m44.columns[1][0];
+ transform.basis.elements[1].y = m44.columns[1][1];
+ transform.basis.elements[2].y = m44.columns[1][2];
+ transform.basis.elements[0].z = m44.columns[2][0];
+ transform.basis.elements[1].z = m44.columns[2][1];
+ transform.basis.elements[2].z = m44.columns[2][2];
+ transform.origin.x = m44.columns[3][0];
+ transform.origin.y = m44.columns[3][1];
+ transform.origin.z = m44.columns[3][2];
+
+ /* important, NOT scaled to world_scale !! */
+ arr.push_back(transform);
+ }
+
+ return arr;
+}
+
+void ARKitInterface::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("_notification", "what"), &ARKitInterface::_notification);
+
+ ClassDB::bind_method(D_METHOD("set_light_estimation_is_enabled", "enable"), &ARKitInterface::set_light_estimation_is_enabled);
+ ClassDB::bind_method(D_METHOD("get_light_estimation_is_enabled"), &ARKitInterface::get_light_estimation_is_enabled);
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "light_estimation"), "set_light_estimation_is_enabled", "get_light_estimation_is_enabled");
+
+ ClassDB::bind_method(D_METHOD("get_ambient_intensity"), &ARKitInterface::get_ambient_intensity);
+ ClassDB::bind_method(D_METHOD("get_ambient_color_temperature"), &ARKitInterface::get_ambient_color_temperature);
+
+ ClassDB::bind_method(D_METHOD("raycast", "screen_coord"), &ARKitInterface::raycast);
+}
+
+bool ARKitInterface::is_stereo() {
+ // this is a mono device...
+ return false;
+}
+
+bool ARKitInterface::is_initialized() const {
+ return initialized;
+}
+
+bool ARKitInterface::initialize() {
+ ARVRServer *arvr_server = ARVRServer::get_singleton();
+ ERR_FAIL_NULL_V(arvr_server, false);
+
+ if (!initialized) {
+ print_line("initializing ARKit");
+
+ // create our ar session and delegate
+ ar_session = [ARSession new];
+ ar_delegate = [ARKitSessionDelegate new];
+ ar_delegate.arkit_interface = this;
+ ar_session.delegate = ar_delegate;
+
+ // reset our transform
+ transform = Transform();
+
+ // make this our primary interface
+ arvr_server->set_primary_interface(this);
+
+ // make sure we have our feed setup
+ if (feed.is_null()) {
+ feed.instance();
+ feed->set_name("ARKit");
+
+ CameraServer *cs = CameraServer::get_singleton();
+ if (cs != NULL) {
+ cs->add_feed(feed);
+ }
+ }
+ feed->set_active(true);
+
+ // yeah!
+ initialized = true;
+
+ // Start our session...
+ start_session();
+ }
+
+ return true;
+}
+
+void ARKitInterface::uninitialize() {
+ if (initialized) {
+ ARVRServer *arvr_server = ARVRServer::get_singleton();
+ if (arvr_server != NULL) {
+ // no longer our primary interface
+ arvr_server->clear_primary_interface_if(this);
+ }
+
+ if (feed.is_valid()) {
+ CameraServer *cs = CameraServer::get_singleton();
+ if ((cs != NULL)) {
+ cs->remove_feed(feed);
+ }
+ feed.unref();
+ }
+
+ remove_all_anchors();
+
+ [ar_session release];
+ [ar_delegate release];
+ ar_session = NULL;
+ ar_delegate = NULL;
+ initialized = false;
+ session_was_started = false;
+ }
+}
+
+Size2 ARKitInterface::get_render_targetsize() {
+ _THREAD_SAFE_METHOD_
+
+ Size2 target_size = OS::get_singleton()->get_window_size();
+
+ return target_size;
+}
+
+Transform ARKitInterface::get_transform_for_eye(ARVRInterface::Eyes p_eye, const Transform &p_cam_transform) {
+ _THREAD_SAFE_METHOD_
+
+ Transform transform_for_eye;
+
+ ARVRServer *arvr_server = ARVRServer::get_singleton();
+ ERR_FAIL_NULL_V(arvr_server, transform_for_eye);
+
+ if (initialized) {
+ float world_scale = arvr_server->get_world_scale();
+
+ // just scale our origin point of our transform, note that we really shouldn't be using world_scale in ARKit but....
+ transform_for_eye = transform;
+ transform_for_eye.origin *= world_scale;
+
+ transform_for_eye = p_cam_transform * arvr_server->get_reference_frame() * transform_for_eye;
+ } else {
+ // huh? well just return what we got....
+ transform_for_eye = p_cam_transform;
+ }
+
+ return transform_for_eye;
+}
+
+CameraMatrix ARKitInterface::get_projection_for_eye(ARVRInterface::Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far) {
+ // Remember our near and far, it will be used in process when we obtain our projection from our ARKit session.
+ z_near = p_z_near;
+ z_far = p_z_far;
+
+ return projection;
+}
+
+void ARKitInterface::commit_for_eye(ARVRInterface::Eyes p_eye, RID p_render_target, const Rect2 &p_screen_rect) {
+ _THREAD_SAFE_METHOD_
+
+ // We must have a valid render target
+ ERR_FAIL_COND(!p_render_target.is_valid());
+
+ // Because we are rendering to our device we must use our main viewport!
+ ERR_FAIL_COND(p_screen_rect == Rect2());
+
+ // get the size of our screen
+ Rect2 screen_rect = p_screen_rect;
+
+ // screen_rect.position.x += screen_rect.size.x;
+ // screen_rect.size.x = -screen_rect.size.x;
+ // screen_rect.position.y += screen_rect.size.y;
+ // screen_rect.size.y = -screen_rect.size.y;
+
+ VSG::rasterizer->set_current_render_target(RID());
+ VSG::rasterizer->blit_render_target_to_screen(p_render_target, screen_rect, 0);
+}
+
+ARVRPositionalTracker *ARKitInterface::get_anchor_for_uuid(const unsigned char *p_uuid) {
+ if (anchors == NULL) {
+ num_anchors = 0;
+ max_anchors = 10;
+ anchors = (anchor_map *)malloc(sizeof(anchor_map) * max_anchors);
+ }
+
+ ERR_FAIL_NULL_V(anchors, NULL);
+
+ for (unsigned int i = 0; i < num_anchors; i++) {
+ if (memcmp(anchors[i].uuid, p_uuid, 16) == 0) {
+ return anchors[i].tracker;
+ }
+ }
+
+ if (num_anchors + 1 == max_anchors) {
+ max_anchors += 10;
+ anchors = (anchor_map *)realloc(anchors, sizeof(anchor_map) * max_anchors);
+ ERR_FAIL_NULL_V(anchors, NULL);
+ }
+
+ ARVRPositionalTracker *new_tracker = memnew(ARVRPositionalTracker);
+ new_tracker->set_type(ARVRServer::TRACKER_ANCHOR);
+
+ char tracker_name[256];
+ sprintf(tracker_name, "Anchor %02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x", p_uuid[0], p_uuid[1], p_uuid[2], p_uuid[3], p_uuid[4], p_uuid[5], p_uuid[6], p_uuid[7], p_uuid[8], p_uuid[9], p_uuid[10], p_uuid[11], p_uuid[12], p_uuid[13], p_uuid[14], p_uuid[15]);
+
+ String name = tracker_name;
+ print_line("Adding tracker " + name);
+ new_tracker->set_name(name);
+
+ // add our tracker
+ ARVRServer::get_singleton()->add_tracker(new_tracker);
+ anchors[num_anchors].tracker = new_tracker;
+ memcpy(anchors[num_anchors].uuid, p_uuid, 16);
+ num_anchors++;
+
+ return new_tracker;
+}
+
+void ARKitInterface::remove_anchor_for_uuid(const unsigned char *p_uuid) {
+ if (anchors != NULL) {
+ for (unsigned int i = 0; i < num_anchors; i++) {
+ if (memcmp(anchors[i].uuid, p_uuid, 16) == 0) {
+ // remove our tracker
+ ARVRServer::get_singleton()->remove_tracker(anchors[i].tracker);
+ memdelete(anchors[i].tracker);
+
+ // bring remaining forward
+ for (unsigned int j = i + 1; j < num_anchors; j++) {
+ anchors[j - 1] = anchors[j];
+ };
+
+ // decrease count
+ num_anchors--;
+ return;
+ }
+ }
+ }
+}
+
+void ARKitInterface::remove_all_anchors() {
+ if (anchors != NULL) {
+ for (unsigned int i = 0; i < num_anchors; i++) {
+ // remove our tracker
+ ARVRServer::get_singleton()->remove_tracker(anchors[i].tracker);
+ memdelete(anchors[i].tracker);
+ };
+
+ free(anchors);
+ anchors = NULL;
+ num_anchors = 0;
+ }
+}
+
+void ARKitInterface::process() {
+ _THREAD_SAFE_METHOD_
+
+ if (@available(iOS 11.0, *)) {
+ if (initialized) {
+ // get our next ARFrame
+ ARFrame *current_frame = ar_session.currentFrame;
+ if (last_timestamp != current_frame.timestamp) {
+ // only process if we have a new frame
+ last_timestamp = current_frame.timestamp;
+
+ // get some info about our screen and orientation
+ Size2 screen_size = OS::get_singleton()->get_window_size();
+ UIDeviceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
+
+ // Grab our camera image for our backbuffer
+ CVPixelBufferRef pixelBuffer = current_frame.capturedImage;
+ if ((CVPixelBufferGetPlaneCount(pixelBuffer) == 2) && (feed != NULL)) {
+ // Plane 0 is our Y and Plane 1 is our CbCr buffer
+
+ // ignored, we check each plane separately
+ // image_width = CVPixelBufferGetWidth(pixelBuffer);
+ // image_height = CVPixelBufferGetHeight(pixelBuffer);
+
+ // printf("Pixel buffer %i - %i\n", image_width, image_height);
+
+ CVPixelBufferLockBaseAddress(pixelBuffer, kCVPixelBufferLock_ReadOnly);
+
+ // get our buffers
+ unsigned char *dataY = (unsigned char *)CVPixelBufferGetBaseAddressOfPlane(pixelBuffer, 0);
+ unsigned char *dataCbCr = (unsigned char *)CVPixelBufferGetBaseAddressOfPlane(pixelBuffer, 1);
+
+ if (dataY == NULL) {
+ print_line("Couldn't access Y pixel buffer data");
+ } else if (dataCbCr == NULL) {
+ print_line("Couldn't access CbCr pixel buffer data");
+ } else {
+ Ref<Image> img[2];
+ size_t extraLeft, extraRight, extraTop, extraBottom;
+
+ CVPixelBufferGetExtendedPixels(pixelBuffer, &extraLeft, &extraRight, &extraTop, &extraBottom);
+
+ {
+ // do Y
+ int new_width = CVPixelBufferGetWidthOfPlane(pixelBuffer, 0);
+ int new_height = CVPixelBufferGetHeightOfPlane(pixelBuffer, 0);
+ int bytes_per_row = CVPixelBufferGetBytesPerRowOfPlane(pixelBuffer, 0);
+
+ if ((image_width[0] != new_width) || (image_height[0] != new_height)) {
+ printf("- Camera padding l:%lu r:%lu t:%lu b:%lu\n", extraLeft, extraRight, extraTop, extraBottom);
+ printf("- Camera Y plane size: %i, %i - %i\n", new_width, new_height, bytes_per_row);
+
+ image_width[0] = new_width;
+ image_height[0] = new_height;
+ img_data[0].resize(new_width * new_height);
+ }
+
+ PoolVector<uint8_t>::Write w = img_data[0].write();
+ if (new_width == bytes_per_row) {
+ memcpy(w.ptr(), dataY, new_width * new_height);
+ } else {
+ int offset_a = 0;
+ int offset_b = extraLeft + (extraTop * bytes_per_row);
+ for (int r = 0; r < new_height; r++) {
+ memcpy(w.ptr() + offset_a, dataY + offset_b, new_width);
+ offset_a += new_width;
+ offset_b += bytes_per_row;
+ }
+ }
+
+ img[0].instance();
+ img[0]->create(new_width, new_height, 0, Image::FORMAT_R8, img_data[0]);
+ }
+
+ {
+ // do CbCr
+ int new_width = CVPixelBufferGetWidthOfPlane(pixelBuffer, 1);
+ int new_height = CVPixelBufferGetHeightOfPlane(pixelBuffer, 1);
+ int bytes_per_row = CVPixelBufferGetBytesPerRowOfPlane(pixelBuffer, 0);
+
+ if ((image_width[1] != new_width) || (image_height[1] != new_height)) {
+ printf("- Camera CbCr plane size: %i, %i - %i\n", new_width, new_height, bytes_per_row);
+
+ image_width[1] = new_width;
+ image_height[1] = new_height;
+ img_data[1].resize(2 * new_width * new_height);
+ }
+
+ PoolVector<uint8_t>::Write w = img_data[1].write();
+ if ((2 * new_width) == bytes_per_row) {
+ memcpy(w.ptr(), dataCbCr, 2 * new_width * new_height);
+ } else {
+ int offset_a = 0;
+ int offset_b = extraLeft + (extraTop * bytes_per_row);
+ for (int r = 0; r < new_height; r++) {
+ memcpy(w.ptr() + offset_a, dataCbCr + offset_b, 2 * new_width);
+ offset_a += 2 * new_width;
+ offset_b += bytes_per_row;
+ }
+ }
+
+ img[1].instance();
+ img[1]->create(new_width, new_height, 0, Image::FORMAT_RG8, img_data[1]);
+ }
+
+ // set our texture...
+ feed->set_YCbCr_imgs(img[0], img[1]);
+
+ // now build our transform to display this as a background image that matches our camera
+ CGAffineTransform affine_transform = [current_frame displayTransformForOrientation:orientation viewportSize:CGSizeMake(screen_size.width, screen_size.height)];
+
+ // we need to invert this, probably row v.s. column notation
+ affine_transform = CGAffineTransformInvert(affine_transform);
+
+ if (orientation != UIDeviceOrientationPortrait) {
+ affine_transform.b = -affine_transform.b;
+ affine_transform.d = -affine_transform.d;
+ affine_transform.ty = 1.0 - affine_transform.ty;
+ } else {
+ affine_transform.c = -affine_transform.c;
+ affine_transform.a = -affine_transform.a;
+ affine_transform.tx = 1.0 - affine_transform.tx;
+ }
+
+ Transform2D display_transform = Transform2D(
+ affine_transform.a, affine_transform.b,
+ affine_transform.c, affine_transform.d,
+ affine_transform.tx, affine_transform.ty);
+
+ feed->set_transform(display_transform);
+ }
+
+ // and unlock
+ CVPixelBufferUnlockBaseAddress(pixelBuffer, kCVPixelBufferLock_ReadOnly);
+ }
+
+ // Record light estimation to apply to our scene
+ if (light_estimation_is_enabled) {
+ ambient_intensity = current_frame.lightEstimate.ambientIntensity;
+
+ ///@TODO it's there, but not there.. what to do with this...
+ // https://developer.apple.com/documentation/arkit/arlightestimate?language=objc
+ // ambient_color_temperature = current_frame.lightEstimate.ambientColorTemperature;
+ }
+
+ // Process our camera
+ ARCamera *camera = current_frame.camera;
+
+ // strangely enough we have to states, rolling them up into one
+ if (camera.trackingState == ARTrackingStateNotAvailable) {
+ // no tracking, would be good if we black out the screen or something...
+ tracking_state = ARVRInterface::ARVR_NOT_TRACKING;
+ } else {
+ if (camera.trackingState == ARTrackingStateNormal) {
+ tracking_state = ARVRInterface::ARVR_NORMAL_TRACKING;
+ } else if (camera.trackingStateReason == ARTrackingStateReasonExcessiveMotion) {
+ tracking_state = ARVRInterface::ARVR_EXCESSIVE_MOTION;
+ } else if (camera.trackingStateReason == ARTrackingStateReasonInsufficientFeatures) {
+ tracking_state = ARVRInterface::ARVR_INSUFFICIENT_FEATURES;
+ } else {
+ tracking_state = ARVRInterface::ARVR_UNKNOWN_TRACKING;
+ }
+
+ // copy our current frame transform
+ matrix_float4x4 m44 = camera.transform;
+ if (orientation == UIDeviceOrientationLandscapeLeft) {
+ transform.basis.elements[0].x = m44.columns[0][0];
+ transform.basis.elements[1].x = m44.columns[0][1];
+ transform.basis.elements[2].x = m44.columns[0][2];
+ transform.basis.elements[0].y = m44.columns[1][0];
+ transform.basis.elements[1].y = m44.columns[1][1];
+ transform.basis.elements[2].y = m44.columns[1][2];
+ } else if (orientation == UIDeviceOrientationPortrait) {
+ transform.basis.elements[0].x = m44.columns[1][0];
+ transform.basis.elements[1].x = m44.columns[1][1];
+ transform.basis.elements[2].x = m44.columns[1][2];
+ transform.basis.elements[0].y = -m44.columns[0][0];
+ transform.basis.elements[1].y = -m44.columns[0][1];
+ transform.basis.elements[2].y = -m44.columns[0][2];
+ } else if (orientation == UIDeviceOrientationLandscapeRight) {
+ transform.basis.elements[0].x = -m44.columns[0][0];
+ transform.basis.elements[1].x = -m44.columns[0][1];
+ transform.basis.elements[2].x = -m44.columns[0][2];
+ transform.basis.elements[0].y = -m44.columns[1][0];
+ transform.basis.elements[1].y = -m44.columns[1][1];
+ transform.basis.elements[2].y = -m44.columns[1][2];
+ } else if (orientation == UIDeviceOrientationPortraitUpsideDown) {
+ // this may not be correct
+ transform.basis.elements[0].x = m44.columns[1][0];
+ transform.basis.elements[1].x = m44.columns[1][1];
+ transform.basis.elements[2].x = m44.columns[1][2];
+ transform.basis.elements[0].y = m44.columns[0][0];
+ transform.basis.elements[1].y = m44.columns[0][1];
+ transform.basis.elements[2].y = m44.columns[0][2];
+ }
+ transform.basis.elements[0].z = m44.columns[2][0];
+ transform.basis.elements[1].z = m44.columns[2][1];
+ transform.basis.elements[2].z = m44.columns[2][2];
+ transform.origin.x = m44.columns[3][0];
+ transform.origin.y = m44.columns[3][1];
+ transform.origin.z = m44.columns[3][2];
+
+ // copy our current frame projection, investigate using projectionMatrixWithViewportSize:orientation:zNear:zFar: so we can set our own near and far
+ m44 = [camera projectionMatrixForOrientation:orientation viewportSize:CGSizeMake(screen_size.width, screen_size.height) zNear:z_near zFar:z_far];
+ projection.matrix[0][0] = m44.columns[0][0];
+ projection.matrix[1][0] = m44.columns[1][0];
+ projection.matrix[2][0] = m44.columns[2][0];
+ projection.matrix[3][0] = m44.columns[3][0];
+ projection.matrix[0][1] = m44.columns[0][1];
+ projection.matrix[1][1] = m44.columns[1][1];
+ projection.matrix[2][1] = m44.columns[2][1];
+ projection.matrix[3][1] = m44.columns[3][1];
+ projection.matrix[0][2] = m44.columns[0][2];
+ projection.matrix[1][2] = m44.columns[1][2];
+ projection.matrix[2][2] = m44.columns[2][2];
+ projection.matrix[3][2] = m44.columns[3][2];
+ projection.matrix[0][3] = m44.columns[0][3];
+ projection.matrix[1][3] = m44.columns[1][3];
+ projection.matrix[2][3] = m44.columns[2][3];
+ projection.matrix[3][3] = m44.columns[3][3];
+ }
+ }
+ }
+ }
+}
+
+void ARKitInterface::_add_or_update_anchor(void *p_anchor) {
+ _THREAD_SAFE_METHOD_
+
+ ARAnchor *anchor = (ARAnchor *)p_anchor;
+
+ unsigned char uuid[16];
+ [anchor.identifier getUUIDBytes:uuid];
+
+ ARVRPositionalTracker *tracker = get_anchor_for_uuid(uuid);
+ if (tracker != NULL) {
+ // lets update our mesh! (using Arjens code as is for now)
+ // we should also probably limit how often we do this...
+
+ // can we safely cast this?
+ ARPlaneAnchor *planeAnchor = (ARPlaneAnchor *)anchor;
+
+ if (planeAnchor.geometry.triangleCount > 0) {
+ Ref<SurfaceTool> surftool;
+ surftool.instance();
+ surftool->begin(Mesh::PRIMITIVE_TRIANGLES);
+
+ for (int j = planeAnchor.geometry.triangleCount * 3 - 1; j >= 0; j--) {
+ int16_t index = planeAnchor.geometry.triangleIndices[j];
+ simd_float3 vrtx = planeAnchor.geometry.vertices[index];
+ simd_float2 textcoord = planeAnchor.geometry.textureCoordinates[index];
+ surftool->add_uv(Vector2(textcoord[0], textcoord[1]));
+ surftool->add_color(Color(0.8, 0.8, 0.8));
+ surftool->add_vertex(Vector3(vrtx[0], vrtx[1], vrtx[2]));
+ }
+
+ surftool->generate_normals();
+ tracker->set_mesh(surftool->commit());
+ } else {
+ Ref<Mesh> nomesh;
+ tracker->set_mesh(nomesh);
+ }
+
+ // Note, this also contains a scale factor which gives us an idea of the size of the anchor
+ // We may extract that in our ARVRAnchor class
+ Basis b;
+ matrix_float4x4 m44 = anchor.transform;
+ b.elements[0].x = m44.columns[0][0];
+ b.elements[1].x = m44.columns[0][1];
+ b.elements[2].x = m44.columns[0][2];
+ b.elements[0].y = m44.columns[1][0];
+ b.elements[1].y = m44.columns[1][1];
+ b.elements[2].y = m44.columns[1][2];
+ b.elements[0].z = m44.columns[2][0];
+ b.elements[1].z = m44.columns[2][1];
+ b.elements[2].z = m44.columns[2][2];
+ tracker->set_orientation(b);
+ tracker->set_rw_position(Vector3(m44.columns[3][0], m44.columns[3][1], m44.columns[3][2]));
+ }
+}
+
+void ARKitInterface::_remove_anchor(void *p_anchor) {
+ _THREAD_SAFE_METHOD_
+
+ ARAnchor *anchor = (ARAnchor *)p_anchor;
+
+ unsigned char uuid[16];
+ [anchor.identifier getUUIDBytes:uuid];
+
+ remove_anchor_for_uuid(uuid);
+}
+
+ARKitInterface::ARKitInterface() {
+ initialized = false;
+ session_was_started = false;
+ plane_detection_is_enabled = false;
+ light_estimation_is_enabled = false;
+ ar_session = NULL;
+ z_near = 0.01;
+ z_far = 1000.0;
+ projection.set_perspective(60.0, 1.0, z_near, z_far, false);
+ anchors = NULL;
+ num_anchors = 0;
+ ambient_intensity = 1.0;
+ ambient_color_temperature = 1.0;
+ image_width[0] = 0;
+ image_width[1] = 0;
+ image_height[0] = 0;
+ image_height[1] = 0;
+}
+
+ARKitInterface::~ARKitInterface() {
+ remove_all_anchors();
+
+ // and make sure we cleanup if we haven't already
+ if (is_initialized()) {
+ uninitialize();
+ }
+}
diff --git a/modules/arkit/arkit_session_delegate.h b/modules/arkit/arkit_session_delegate.h
new file mode 100644
index 0000000000..afe093656b
--- /dev/null
+++ b/modules/arkit/arkit_session_delegate.h
@@ -0,0 +1,50 @@
+/*************************************************************************/
+/* arkit_session_delegate.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 ARKIT_SESSION_DELEGATE_H
+#define ARKIT_SESSION_DELEGATE_H
+
+#import <ARKit/ARKit.h>
+#import <UIKit/UIKit.h>
+
+class ARKitInterface;
+
+@interface ARKitSessionDelegate : NSObject <ARSessionDelegate> {
+ ARKitInterface *arkit_interface;
+}
+
+@property(nonatomic) ARKitInterface *arkit_interface;
+
+- (void)session:(ARSession *)session didAddAnchors:(NSArray<ARAnchor *> *)anchors;
+- (void)session:(ARSession *)session didRemoveAnchors:(NSArray<ARAnchor *> *)anchors;
+- (void)session:(ARSession *)session didUpdateAnchors:(NSArray<ARAnchor *> *)anchors;
+@end
+
+#endif /* !ARKIT_SESSION_DELEGATE_H */
diff --git a/modules/arkit/arkit_session_delegate.mm b/modules/arkit/arkit_session_delegate.mm
new file mode 100644
index 0000000000..56485c987c
--- /dev/null
+++ b/modules/arkit/arkit_session_delegate.mm
@@ -0,0 +1,56 @@
+/*************************************************************************/
+/* arkit_session_delegate.mm */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 "arkit_session_delegate.h"
+#include "arkit_interface.h"
+
+@implementation ARKitSessionDelegate
+
+@synthesize arkit_interface;
+
+- (void)session:(ARSession *)session didAddAnchors:(NSArray<ARAnchor *> *)anchors {
+ for (ARAnchor *anchor in anchors) {
+ arkit_interface->_add_or_update_anchor(anchor);
+ }
+}
+
+- (void)session:(ARSession *)session didRemoveAnchors:(NSArray<ARAnchor *> *)anchors {
+ for (ARAnchor *anchor in anchors) {
+ arkit_interface->_remove_anchor(anchor);
+ }
+}
+
+- (void)session:(ARSession *)session didUpdateAnchors:(NSArray<ARAnchor *> *)anchors {
+ for (ARAnchor *anchor in anchors) {
+ arkit_interface->_add_or_update_anchor(anchor);
+ }
+}
+
+@end \ No newline at end of file
diff --git a/modules/arkit/config.py b/modules/arkit/config.py
new file mode 100644
index 0000000000..96e41826c5
--- /dev/null
+++ b/modules/arkit/config.py
@@ -0,0 +1,5 @@
+def can_build(env, platform):
+ return platform == 'iphone'
+
+def configure(env):
+ pass
diff --git a/modules/arkit/register_types.cpp b/modules/arkit/register_types.cpp
new file mode 100644
index 0000000000..af35828004
--- /dev/null
+++ b/modules/arkit/register_types.cpp
@@ -0,0 +1,45 @@
+/*************************************************************************/
+/* register_types.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* 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 "arkit_interface.h"
+
+void register_arkit_types() {
+ // does it make sense to register the class?
+
+ Ref<ARKitInterface> arkit_interface;
+ arkit_interface.instance();
+ ARVRServer::get_singleton()->add_interface(arkit_interface);
+}
+
+void unregister_arkit_types() {
+ // should clean itself up nicely :)
+}
diff --git a/modules/arkit/register_types.h b/modules/arkit/register_types.h
new file mode 100644
index 0000000000..6ed2065de2
--- /dev/null
+++ b/modules/arkit/register_types.h
@@ -0,0 +1,32 @@
+/*************************************************************************/
+/* register_types.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* 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. */
+/*************************************************************************/
+
+void register_arkit_types();
+void unregister_arkit_types();
diff --git a/modules/assimp/editor_scene_importer_assimp.cpp b/modules/assimp/editor_scene_importer_assimp.cpp
index 8c3c04674b..093e2f3006 100644
--- a/modules/assimp/editor_scene_importer_assimp.cpp
+++ b/modules/assimp/editor_scene_importer_assimp.cpp
@@ -848,7 +848,7 @@ Ref<Material> EditorSceneImporterAssimp::_generate_material_from_index(ImportSta
if (AI_SUCCESS == ai_material->GetTexture(tex_normal, 0, &ai_filename, NULL, NULL, NULL, NULL, map_mode)) {
filename = _assimp_raw_string_to_string(ai_filename);
- String path = state.path.get_base_dir() + "/" + filename.replace("\\", "/");
+ String path = state.path.get_base_dir().plus_file(filename.replace("\\", "/"));
bool found = false;
_find_texture_path(state.path, path, found);
if (found) {
@@ -869,7 +869,7 @@ Ref<Material> EditorSceneImporterAssimp::_generate_material_from_index(ImportSta
if (AI_SUCCESS == ai_material->Get(AI_MATKEY_FBX_NORMAL_TEXTURE, ai_filename)) {
filename = _assimp_raw_string_to_string(ai_filename);
- String path = state.path.get_base_dir() + "/" + filename.replace("\\", "/");
+ String path = state.path.get_base_dir().plus_file(filename.replace("\\", "/"));
bool found = false;
_find_texture_path(state.path, path, found);
if (found) {
@@ -892,7 +892,7 @@ Ref<Material> EditorSceneImporterAssimp::_generate_material_from_index(ImportSta
if (AI_SUCCESS == ai_material->GetTexture(tex_emissive, 0, &ai_filename, NULL, NULL, NULL, NULL, map_mode)) {
filename = _assimp_raw_string_to_string(ai_filename);
- String path = state.path.get_base_dir() + "/" + filename.replace("\\", "/");
+ String path = state.path.get_base_dir().plus_file(filename.replace("\\", "/"));
bool found = false;
_find_texture_path(state.path, path, found);
if (found) {
@@ -914,7 +914,7 @@ Ref<Material> EditorSceneImporterAssimp::_generate_material_from_index(ImportSta
aiTextureMapMode map_mode[2];
if (AI_SUCCESS == ai_material->GetTexture(tex_albedo, 0, &ai_filename, NULL, NULL, NULL, NULL, map_mode)) {
filename = _assimp_raw_string_to_string(ai_filename);
- String path = state.path.get_base_dir() + "/" + filename.replace("\\", "/");
+ String path = state.path.get_base_dir().plus_file(filename.replace("\\", "/"));
bool found = false;
_find_texture_path(state.path, path, found);
if (found) {
@@ -944,7 +944,7 @@ Ref<Material> EditorSceneImporterAssimp::_generate_material_from_index(ImportSta
aiTextureMapMode map_mode[2];
if (AI_SUCCESS == ai_material->GetTexture(AI_MATKEY_GLTF_PBRMETALLICROUGHNESS_BASE_COLOR_TEXTURE, &tex_gltf_base_color_path, NULL, NULL, NULL, NULL, map_mode)) {
String filename = _assimp_raw_string_to_string(tex_gltf_base_color_path);
- String path = state.path.get_base_dir() + "/" + filename.replace("\\", "/");
+ String path = state.path.get_base_dir().plus_file(filename.replace("\\", "/"));
bool found = false;
_find_texture_path(state.path, path, found);
if (found) {
@@ -973,7 +973,7 @@ Ref<Material> EditorSceneImporterAssimp::_generate_material_from_index(ImportSta
aiString tex_fbx_pbs_base_color_path = aiString();
if (AI_SUCCESS == ai_material->Get(AI_MATKEY_FBX_MAYA_BASE_COLOR_TEXTURE, tex_fbx_pbs_base_color_path)) {
String filename = _assimp_raw_string_to_string(tex_fbx_pbs_base_color_path);
- String path = state.path.get_base_dir() + "/" + filename.replace("\\", "/");
+ String path = state.path.get_base_dir().plus_file(filename.replace("\\", "/"));
bool found = false;
_find_texture_path(state.path, path, found);
if (found) {
@@ -1005,7 +1005,7 @@ Ref<Material> EditorSceneImporterAssimp::_generate_material_from_index(ImportSta
aiString tex_fbx_pbs_normal_path = aiString();
if (AI_SUCCESS == ai_material->Get(AI_MATKEY_FBX_MAYA_NORMAL_TEXTURE, tex_fbx_pbs_normal_path)) {
String filename = _assimp_raw_string_to_string(tex_fbx_pbs_normal_path);
- String path = state.path.get_base_dir() + "/" + filename.replace("\\", "/");
+ String path = state.path.get_base_dir().plus_file(filename.replace("\\", "/"));
bool found = false;
_find_texture_path(state.path, path, found);
if (found) {
@@ -1027,7 +1027,7 @@ Ref<Material> EditorSceneImporterAssimp::_generate_material_from_index(ImportSta
aiString tex_fbx_stingray_normal_path = aiString();
if (AI_SUCCESS == ai_material->Get(AI_MATKEY_FBX_MAYA_STINGRAY_NORMAL_TEXTURE, tex_fbx_stingray_normal_path)) {
String filename = _assimp_raw_string_to_string(tex_fbx_stingray_normal_path);
- String path = state.path.get_base_dir() + "/" + filename.replace("\\", "/");
+ String path = state.path.get_base_dir().plus_file(filename.replace("\\", "/"));
bool found = false;
_find_texture_path(state.path, path, found);
if (found) {
@@ -1045,7 +1045,7 @@ Ref<Material> EditorSceneImporterAssimp::_generate_material_from_index(ImportSta
aiString tex_fbx_pbs_base_color_path = aiString();
if (AI_SUCCESS == ai_material->Get(AI_MATKEY_FBX_MAYA_STINGRAY_COLOR_TEXTURE, tex_fbx_pbs_base_color_path)) {
String filename = _assimp_raw_string_to_string(tex_fbx_pbs_base_color_path);
- String path = state.path.get_base_dir() + "/" + filename.replace("\\", "/");
+ String path = state.path.get_base_dir().plus_file(filename.replace("\\", "/"));
bool found = false;
_find_texture_path(state.path, path, found);
if (found) {
@@ -1077,7 +1077,7 @@ Ref<Material> EditorSceneImporterAssimp::_generate_material_from_index(ImportSta
aiString tex_fbx_pbs_emissive_path = aiString();
if (AI_SUCCESS == ai_material->Get(AI_MATKEY_FBX_MAYA_STINGRAY_EMISSIVE_TEXTURE, tex_fbx_pbs_emissive_path)) {
String filename = _assimp_raw_string_to_string(tex_fbx_pbs_emissive_path);
- String path = state.path.get_base_dir() + "/" + filename.replace("\\", "/");
+ String path = state.path.get_base_dir().plus_file(filename.replace("\\", "/"));
bool found = false;
_find_texture_path(state.path, path, found);
if (found) {
@@ -1107,7 +1107,7 @@ Ref<Material> EditorSceneImporterAssimp::_generate_material_from_index(ImportSta
aiString tex_gltf_pbr_metallicroughness_path;
if (AI_SUCCESS == ai_material->GetTexture(AI_MATKEY_GLTF_PBRMETALLICROUGHNESS_METALLICROUGHNESS_TEXTURE, &tex_gltf_pbr_metallicroughness_path)) {
String filename = _assimp_raw_string_to_string(tex_gltf_pbr_metallicroughness_path);
- String path = state.path.get_base_dir() + "/" + filename.replace("\\", "/");
+ String path = state.path.get_base_dir().plus_file(filename.replace("\\", "/"));
bool found = false;
_find_texture_path(state.path, path, found);
if (found) {
@@ -1134,7 +1134,7 @@ Ref<Material> EditorSceneImporterAssimp::_generate_material_from_index(ImportSta
aiString tex_fbx_pbs_metallic_path;
if (AI_SUCCESS == ai_material->Get(AI_MATKEY_FBX_MAYA_STINGRAY_METALLIC_TEXTURE, tex_fbx_pbs_metallic_path)) {
String filename = _assimp_raw_string_to_string(tex_fbx_pbs_metallic_path);
- String path = state.path.get_base_dir() + "/" + filename.replace("\\", "/");
+ String path = state.path.get_base_dir().plus_file(filename.replace("\\", "/"));
bool found = false;
_find_texture_path(state.path, path, found);
if (found) {
@@ -1154,7 +1154,7 @@ Ref<Material> EditorSceneImporterAssimp::_generate_material_from_index(ImportSta
aiString tex_fbx_pbs_rough_path;
if (AI_SUCCESS == ai_material->Get(AI_MATKEY_FBX_MAYA_STINGRAY_ROUGHNESS_TEXTURE, tex_fbx_pbs_rough_path)) {
String filename = _assimp_raw_string_to_string(tex_fbx_pbs_rough_path);
- String path = state.path.get_base_dir() + "/" + filename.replace("\\", "/");
+ String path = state.path.get_base_dir().plus_file(filename.replace("\\", "/"));
bool found = false;
_find_texture_path(state.path, path, found);
if (found) {
@@ -1177,7 +1177,7 @@ Ref<Material> EditorSceneImporterAssimp::_generate_material_from_index(ImportSta
aiString tex_fbx_pbs_metallic_path;
if (AI_SUCCESS == ai_material->Get(AI_MATKEY_FBX_MAYA_METALNESS_TEXTURE, tex_fbx_pbs_metallic_path)) {
String filename = _assimp_raw_string_to_string(tex_fbx_pbs_metallic_path);
- String path = state.path.get_base_dir() + "/" + filename.replace("\\", "/");
+ String path = state.path.get_base_dir().plus_file(filename.replace("\\", "/"));
bool found = false;
_find_texture_path(state.path, path, found);
if (found) {
@@ -1197,7 +1197,7 @@ Ref<Material> EditorSceneImporterAssimp::_generate_material_from_index(ImportSta
aiString tex_fbx_pbs_rough_path;
if (AI_SUCCESS == ai_material->Get(AI_MATKEY_FBX_MAYA_DIFFUSE_ROUGHNESS_TEXTURE, tex_fbx_pbs_rough_path)) {
String filename = _assimp_raw_string_to_string(tex_fbx_pbs_rough_path);
- String path = state.path.get_base_dir() + "/" + filename.replace("\\", "/");
+ String path = state.path.get_base_dir().plus_file(filename.replace("\\", "/"));
bool found = false;
_find_texture_path(state.path, path, found);
if (found) {
@@ -1684,7 +1684,7 @@ void EditorSceneImporterAssimp::_find_texture_path(const String &p_path, _Direct
path = name;
return;
}
- String name_ignore_sub_directory = p_path.get_base_dir() + "/" + path.get_file().get_basename() + extension;
+ String name_ignore_sub_directory = p_path.get_base_dir().plus_file(path.get_file().get_basename()) + extension;
if (dir.file_exists(name_ignore_sub_directory)) {
found = true;
path = name_ignore_sub_directory;
diff --git a/modules/bmp/image_loader_bmp.cpp b/modules/bmp/image_loader_bmp.cpp
index bcc992db24..a7e8dec11e 100644
--- a/modules/bmp/image_loader_bmp.cpp
+++ b/modules/bmp/image_loader_bmp.cpp
@@ -261,12 +261,10 @@ 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;
- if (color_table_size > 0) {
- // Color table is usually 4 bytes per color -> [B][G][R][0]
- err = 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);
- }
+ // 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);
f->seek(bmp_header.bmp_file_header.bmp_file_offset);
diff --git a/modules/bullet/SCsub b/modules/bullet/SCsub
index 16d694c238..2fe7a1b4c0 100644
--- a/modules/bullet/SCsub
+++ b/modules/bullet/SCsub
@@ -186,7 +186,11 @@ if env['builtin_bullet']:
thirdparty_sources = [thirdparty_dir + file for file in bullet2_src]
- env_bullet.Prepend(CPPPATH=[thirdparty_dir])
+ # Treat Bullet headers as system headers to avoid raising warnings. Not supported on MSVC.
+ if not env.msvc:
+ env_bullet.Append(CPPFLAGS=['-isystem', Dir(thirdparty_dir).path])
+ else:
+ env_bullet.Prepend(CPPPATH=[thirdparty_dir])
# if env['target'] == "debug" or env['target'] == "release_debug":
# env_bullet.Append(CPPFLAGS=['-DBT_DEBUG'])
diff --git a/modules/bullet/bullet_physics_server.cpp b/modules/bullet/bullet_physics_server.cpp
index be4e0b88e8..038001996d 100644
--- a/modules/bullet/bullet_physics_server.cpp
+++ b/modules/bullet/bullet_physics_server.cpp
@@ -267,7 +267,7 @@ RID BulletPhysicsServer::area_get_space(RID p_area) const {
void BulletPhysicsServer::area_set_space_override_mode(RID p_area, AreaSpaceOverrideMode p_mode) {
AreaBullet *area = area_owner.get(p_area);
- ERR_FAIL_COND(!area)
+ ERR_FAIL_COND(!area);
area->set_spOv_mode(p_mode);
}
diff --git a/modules/bullet/bullet_physics_server.h b/modules/bullet/bullet_physics_server.h
index 0b8ad53658..4c598c84f2 100644
--- a/modules/bullet/bullet_physics_server.h
+++ b/modules/bullet/bullet_physics_server.h
@@ -45,7 +45,7 @@
*/
class BulletPhysicsServer : public PhysicsServer {
- GDCLASS(BulletPhysicsServer, PhysicsServer)
+ GDCLASS(BulletPhysicsServer, PhysicsServer);
friend class BulletPhysicsDirectSpaceState;
diff --git a/modules/bullet/collision_object_bullet.cpp b/modules/bullet/collision_object_bullet.cpp
index 166d7e6158..e1800fd3eb 100644
--- a/modules/bullet/collision_object_bullet.cpp
+++ b/modules/bullet/collision_object_bullet.cpp
@@ -305,7 +305,7 @@ void RigidCollisionObjectBullet::set_shape_transform(int p_index, const Transfor
ERR_FAIL_INDEX(p_index, get_shape_count());
shapes.write[p_index].set_transform(p_transform);
- reload_shapes();
+ shape_changed(p_index);
}
const btTransform &RigidCollisionObjectBullet::get_bt_shape_transform(int p_index) const {
diff --git a/modules/bullet/cone_twist_joint_bullet.cpp b/modules/bullet/cone_twist_joint_bullet.cpp
index d9a82d6179..bc7fd52cf6 100644
--- a/modules/bullet/cone_twist_joint_bullet.cpp
+++ b/modules/bullet/cone_twist_joint_bullet.cpp
@@ -84,7 +84,7 @@ void ConeTwistJointBullet::set_param(PhysicsServer::ConeTwistJointParam p_param,
break;
default:
ERR_EXPLAIN("This parameter " + itos(p_param) + " is deprecated");
- WARN_DEPRECATED
+ WARN_DEPRECATED;
break;
}
}
diff --git a/modules/bullet/generic_6dof_joint_bullet.cpp b/modules/bullet/generic_6dof_joint_bullet.cpp
index 8fed933854..0d2c46c579 100644
--- a/modules/bullet/generic_6dof_joint_bullet.cpp
+++ b/modules/bullet/generic_6dof_joint_bullet.cpp
@@ -175,7 +175,7 @@ void Generic6DOFJointBullet::set_param(Vector3::Axis p_axis, PhysicsServer::G6DO
break;
default:
ERR_EXPLAIN("This parameter " + itos(p_param) + " is deprecated");
- WARN_DEPRECATED
+ WARN_DEPRECATED;
break;
}
}
@@ -256,7 +256,7 @@ void Generic6DOFJointBullet::set_flag(Vector3::Axis p_axis, PhysicsServer::G6DOF
break;
default:
ERR_EXPLAIN("This flag " + itos(p_flag) + " is deprecated");
- WARN_DEPRECATED
+ WARN_DEPRECATED;
break;
}
}
diff --git a/modules/bullet/hinge_joint_bullet.cpp b/modules/bullet/hinge_joint_bullet.cpp
index 7b99d3d89f..b7e1e1a4c2 100644
--- a/modules/bullet/hinge_joint_bullet.cpp
+++ b/modules/bullet/hinge_joint_bullet.cpp
@@ -118,7 +118,7 @@ void HingeJointBullet::set_param(PhysicsServer::HingeJointParam p_param, real_t
break;
default:
ERR_EXPLAIN("The HingeJoint parameter " + itos(p_param) + " is deprecated.");
- WARN_DEPRECATED
+ WARN_DEPRECATED;
break;
}
}
diff --git a/modules/bullet/pin_joint_bullet.cpp b/modules/bullet/pin_joint_bullet.cpp
index 58b090006a..c9c4d1af7e 100644
--- a/modules/bullet/pin_joint_bullet.cpp
+++ b/modules/bullet/pin_joint_bullet.cpp
@@ -86,7 +86,7 @@ real_t PinJointBullet::get_param(PhysicsServer::PinJointParam p_param) const {
return p2pConstraint->m_setting.m_impulseClamp;
default:
ERR_EXPLAIN("This parameter " + itos(p_param) + " is deprecated");
- WARN_DEPRECATED
+ WARN_DEPRECATED;
return 0;
}
}
diff --git a/modules/bullet/rigid_body_bullet.cpp b/modules/bullet/rigid_body_bullet.cpp
index 733a900396..085cce9733 100644
--- a/modules/bullet/rigid_body_bullet.cpp
+++ b/modules/bullet/rigid_body_bullet.cpp
@@ -866,7 +866,7 @@ void RigidBodyBullet::on_enter_area(AreaBullet *p_area) {
if (p_area->is_spOv_gravityPoint()) {
++countGravityPointSpaces;
- assert(0 < countGravityPointSpaces);
+ ERR_FAIL_COND(countGravityPointSpaces <= 0);
}
}
@@ -888,7 +888,7 @@ void RigidBodyBullet::on_exit_area(AreaBullet *p_area) {
if (wasTheAreaFound) {
if (p_area->is_spOv_gravityPoint()) {
--countGravityPointSpaces;
- assert(0 <= countGravityPointSpaces);
+ ERR_FAIL_COND(countGravityPointSpaces < 0);
}
--areaWhereIamCount;
diff --git a/modules/bullet/rigid_body_bullet.h b/modules/bullet/rigid_body_bullet.h
index 1e1bea846a..2c9bdb8b0b 100644
--- a/modules/bullet/rigid_body_bullet.h
+++ b/modules/bullet/rigid_body_bullet.h
@@ -54,7 +54,7 @@ class BulletPhysicsDirectBodyState;
/// created by BulletPhysicsServer and is held by the "singleton" variable of this class
/// Each time something require it, the body must be set again.
class BulletPhysicsDirectBodyState : public PhysicsDirectBodyState {
- GDCLASS(BulletPhysicsDirectBodyState, PhysicsDirectBodyState)
+ GDCLASS(BulletPhysicsDirectBodyState, PhysicsDirectBodyState);
static BulletPhysicsDirectBodyState *singleton;
diff --git a/modules/bullet/space_bullet.h b/modules/bullet/space_bullet.h
index 6b3d65edf6..eb4a065e54 100644
--- a/modules/bullet/space_bullet.h
+++ b/modules/bullet/space_bullet.h
@@ -68,7 +68,8 @@ class btGjkEpaPenetrationDepthSolver;
extern ContactAddedCallback gContactAddedCallback;
class BulletPhysicsDirectSpaceState : public PhysicsDirectSpaceState {
- GDCLASS(BulletPhysicsDirectSpaceState, PhysicsDirectSpaceState)
+ GDCLASS(BulletPhysicsDirectSpaceState, PhysicsDirectSpaceState);
+
private:
SpaceBullet *space;
diff --git a/modules/csg/csg.cpp b/modules/csg/csg.cpp
index 3a61afa023..fd0d36eddf 100644
--- a/modules/csg/csg.cpp
+++ b/modules/csg/csg.cpp
@@ -45,7 +45,7 @@ void CSGBrush::build_from_faces(const PoolVector<Vector3> &p_vertices, const Poo
int vc = p_vertices.size();
- ERR_FAIL_COND((vc % 3) != 0)
+ ERR_FAIL_COND((vc % 3) != 0);
PoolVector<Vector3>::Read rv = p_vertices.read();
int uvc = p_uvs.size();
@@ -1018,15 +1018,15 @@ int CSGBrushOperation::MeshMerge::_create_bvh(BVH *p_bvh, BVH **p_bb, int p_from
max_depth = p_depth;
}
- if (p_size <= BVH_LIMIT) {
+ if (p_size == 0) {
+
+ return -1;
+ } else if (p_size <= BVH_LIMIT) {
for (int i = 0; i < p_size - 1; i++) {
p_bb[p_from + i]->next = p_bb[p_from + i + 1] - p_bvh;
}
return p_bb[p_from] - p_bvh;
- } else if (p_size == 0) {
-
- return -1;
}
AABB aabb;
diff --git a/modules/csg/csg_gizmos.h b/modules/csg/csg_gizmos.h
index 0915d05111..d38dafc936 100644
--- a/modules/csg/csg_gizmos.h
+++ b/modules/csg/csg_gizmos.h
@@ -55,7 +55,8 @@ public:
};
class EditorPluginCSG : public EditorPlugin {
- GDCLASS(EditorPluginCSG, EditorPlugin)
+ GDCLASS(EditorPluginCSG, EditorPlugin);
+
public:
EditorPluginCSG(EditorNode *p_editor);
};
diff --git a/modules/csg/csg_shape.cpp b/modules/csg/csg_shape.cpp
index 1d27b9b6f4..a496a214fd 100644
--- a/modules/csg/csg_shape.cpp
+++ b/modules/csg/csg_shape.cpp
@@ -1816,11 +1816,9 @@ CSGBrush *CSGPolygon::_build_brush() {
path_cache = path;
- if (path_cache) {
- path_cache->connect("tree_exited", this, "_path_exited");
- path_cache->connect("curve_changed", this, "_path_changed");
- path_cache = NULL;
- }
+ path_cache->connect("tree_exited", this, "_path_exited");
+ path_cache->connect("curve_changed", this, "_path_changed");
+ path_cache = NULL;
}
curve = path->get_curve();
if (curve.is_null())
diff --git a/modules/csg/csg_shape.h b/modules/csg/csg_shape.h
index a5b2238e6b..6c9419b3c2 100644
--- a/modules/csg/csg_shape.h
+++ b/modules/csg/csg_shape.h
@@ -116,9 +116,9 @@ protected:
virtual void _validate_property(PropertyInfo &property) const;
+public:
Array get_meshes() const;
-public:
void set_operation(Operation p_operation);
Operation get_operation() const;
@@ -156,7 +156,8 @@ public:
VARIANT_ENUM_CAST(CSGShape::Operation)
class CSGCombiner : public CSGShape {
- GDCLASS(CSGCombiner, CSGShape)
+ GDCLASS(CSGCombiner, CSGShape);
+
private:
virtual CSGBrush *_build_brush();
@@ -165,7 +166,7 @@ public:
};
class CSGPrimitive : public CSGShape {
- GDCLASS(CSGPrimitive, CSGShape)
+ GDCLASS(CSGPrimitive, CSGShape);
private:
bool invert_faces;
@@ -182,7 +183,7 @@ public:
};
class CSGMesh : public CSGPrimitive {
- GDCLASS(CSGMesh, CSGPrimitive)
+ GDCLASS(CSGMesh, CSGPrimitive);
virtual CSGBrush *_build_brush();
@@ -204,7 +205,7 @@ public:
class CSGSphere : public CSGPrimitive {
- GDCLASS(CSGSphere, CSGPrimitive)
+ GDCLASS(CSGSphere, CSGPrimitive);
virtual CSGBrush *_build_brush();
Ref<Material> material;
@@ -237,7 +238,7 @@ public:
class CSGBox : public CSGPrimitive {
- GDCLASS(CSGBox, CSGPrimitive)
+ GDCLASS(CSGBox, CSGPrimitive);
virtual CSGBrush *_build_brush();
Ref<Material> material;
@@ -266,7 +267,7 @@ public:
class CSGCylinder : public CSGPrimitive {
- GDCLASS(CSGCylinder, CSGPrimitive)
+ GDCLASS(CSGCylinder, CSGPrimitive);
virtual CSGBrush *_build_brush();
Ref<Material> material;
@@ -303,7 +304,7 @@ public:
class CSGTorus : public CSGPrimitive {
- GDCLASS(CSGTorus, CSGPrimitive)
+ GDCLASS(CSGTorus, CSGPrimitive);
virtual CSGBrush *_build_brush();
Ref<Material> material;
@@ -340,7 +341,7 @@ public:
class CSGPolygon : public CSGPrimitive {
- GDCLASS(CSGPolygon, CSGPrimitive)
+ GDCLASS(CSGPolygon, CSGPrimitive);
public:
enum Mode {
@@ -403,7 +404,7 @@ public:
void set_spin_degrees(float p_spin_degrees);
float get_spin_degrees() const;
- void set_spin_sides(int p_sides);
+ void set_spin_sides(int p_spin_sides);
int get_spin_sides() const;
void set_path_node(const NodePath &p_path);
diff --git a/modules/csg/doc_classes/CSGBox.xml b/modules/csg/doc_classes/CSGBox.xml
index e508468415..d100c01205 100644
--- a/modules/csg/doc_classes/CSGBox.xml
+++ b/modules/csg/doc_classes/CSGBox.xml
@@ -11,16 +11,16 @@
<methods>
</methods>
<members>
- <member name="depth" type="float" setter="set_depth" getter="get_depth">
+ <member name="depth" type="float" setter="set_depth" getter="get_depth" default="2.0">
Depth of the box measured from the center of the box.
</member>
- <member name="height" type="float" setter="set_height" getter="get_height">
+ <member name="height" type="float" setter="set_height" getter="get_height" default="2.0">
Height of the box measured from the center of the box.
</member>
- <member name="material" type="Material" setter="set_material" getter="get_material">
+ <member name="material" type="Material" setter="set_material" getter="get_material" default="null">
The material used to render the box.
</member>
- <member name="width" type="float" setter="set_width" getter="get_width">
+ <member name="width" type="float" setter="set_width" getter="get_width" default="2.0">
Width of the box measured from the center of the box.
</member>
</members>
diff --git a/modules/csg/doc_classes/CSGCylinder.xml b/modules/csg/doc_classes/CSGCylinder.xml
index 24c3f8ba2e..643eb7c7f4 100644
--- a/modules/csg/doc_classes/CSGCylinder.xml
+++ b/modules/csg/doc_classes/CSGCylinder.xml
@@ -11,22 +11,22 @@
<methods>
</methods>
<members>
- <member name="cone" type="bool" setter="set_cone" getter="is_cone">
+ <member name="cone" type="bool" setter="set_cone" getter="is_cone" default="false">
If [code]true[/code] a cone is created, the [member radius] will only apply to one side.
</member>
- <member name="height" type="float" setter="set_height" getter="get_height">
+ <member name="height" type="float" setter="set_height" getter="get_height" default="1.0">
The height of the cylinder.
</member>
- <member name="material" type="Material" setter="set_material" getter="get_material">
+ <member name="material" type="Material" setter="set_material" getter="get_material" default="null">
The material used to render the cylinder.
</member>
- <member name="radius" type="float" setter="set_radius" getter="get_radius">
+ <member name="radius" type="float" setter="set_radius" getter="get_radius" default="1.0">
The radius of the cylinder.
</member>
- <member name="sides" type="int" setter="set_sides" getter="get_sides">
+ <member name="sides" type="int" setter="set_sides" getter="get_sides" default="8">
The number of sides of the cylinder, the higher this number the more detail there will be in the cylinder.
</member>
- <member name="smooth_faces" type="bool" setter="set_smooth_faces" getter="get_smooth_faces">
+ <member name="smooth_faces" type="bool" setter="set_smooth_faces" getter="get_smooth_faces" default="true">
If [code]true[/code] the normals of the cylinder are set to give a smooth effect making the cylinder seem rounded. If [code]false[/code] the cylinder will have a flat shaded look.
</member>
</members>
diff --git a/modules/csg/doc_classes/CSGMesh.xml b/modules/csg/doc_classes/CSGMesh.xml
index afe0bc262d..daa08decb6 100644
--- a/modules/csg/doc_classes/CSGMesh.xml
+++ b/modules/csg/doc_classes/CSGMesh.xml
@@ -11,9 +11,9 @@
<methods>
</methods>
<members>
- <member name="material" type="Material" setter="set_material" getter="get_material">
+ <member name="material" type="Material" setter="set_material" getter="get_material" default="null">
</member>
- <member name="mesh" type="Mesh" setter="set_mesh" getter="get_mesh">
+ <member name="mesh" type="Mesh" setter="set_mesh" getter="get_mesh" default="null">
The mesh resource to use as a CSG shape.
</member>
</members>
diff --git a/modules/csg/doc_classes/CSGPolygon.xml b/modules/csg/doc_classes/CSGPolygon.xml
index 2c5d298222..48f5d730cc 100644
--- a/modules/csg/doc_classes/CSGPolygon.xml
+++ b/modules/csg/doc_classes/CSGPolygon.xml
@@ -11,13 +11,13 @@
<methods>
</methods>
<members>
- <member name="depth" type="float" setter="set_depth" getter="get_depth">
+ <member name="depth" type="float" setter="set_depth" getter="get_depth" default="1.0">
Extrusion depth when [member mode] is [constant MODE_DEPTH].
</member>
- <member name="material" type="Material" setter="set_material" getter="get_material">
+ <member name="material" type="Material" setter="set_material" getter="get_material" default="null">
Material to use for the resulting mesh.
</member>
- <member name="mode" type="int" setter="set_mode" getter="get_mode" enum="CSGPolygon.Mode">
+ <member name="mode" type="int" setter="set_mode" getter="get_mode" enum="CSGPolygon.Mode" default="0">
Extrusion mode.
</member>
<member name="path_continuous_u" type="bool" setter="set_path_continuous_u" getter="is_path_continuous_u">
@@ -38,10 +38,10 @@
<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">
+ <member name="polygon" type="PoolVector2Array" setter="set_polygon" getter="get_polygon" default="PoolVector2Array( 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">
+ <member name="smooth_faces" type="bool" setter="set_smooth_faces" getter="get_smooth_faces" default="false">
Generates smooth normals so smooth shading is applied to our mesh.
</member>
<member name="spin_degrees" type="float" setter="set_spin_degrees" getter="get_spin_degrees">
diff --git a/modules/csg/doc_classes/CSGPrimitive.xml b/modules/csg/doc_classes/CSGPrimitive.xml
index 869e4006fe..6c2f837637 100644
--- a/modules/csg/doc_classes/CSGPrimitive.xml
+++ b/modules/csg/doc_classes/CSGPrimitive.xml
@@ -10,7 +10,7 @@
<methods>
</methods>
<members>
- <member name="invert_faces" type="bool" setter="set_invert_faces" getter="is_inverting_faces">
+ <member name="invert_faces" type="bool" setter="set_invert_faces" getter="is_inverting_faces" default="false">
Invert the faces of the mesh.
</member>
</members>
diff --git a/modules/csg/doc_classes/CSGShape.xml b/modules/csg/doc_classes/CSGShape.xml
index 7fa7c78534..91f54f8246 100644
--- a/modules/csg/doc_classes/CSGShape.xml
+++ b/modules/csg/doc_classes/CSGShape.xml
@@ -64,23 +64,23 @@
</method>
</methods>
<members>
- <member name="calculate_tangents" type="bool" setter="set_calculate_tangents" getter="is_calculating_tangents">
+ <member name="calculate_tangents" type="bool" setter="set_calculate_tangents" getter="is_calculating_tangents" default="true">
Calculate tangents for the CSG shape which allows the use of normal maps. This is only applied on the root shape, this setting is ignored on any child.
</member>
- <member name="collision_layer" type="int" setter="set_collision_layer" getter="get_collision_layer">
+ <member name="collision_layer" type="int" setter="set_collision_layer" getter="get_collision_layer" default="1">
The physics layers this area is in.
Collidable objects can exist in any of 32 different layers. These layers work like a tagging system, and are not visual. A collidable can use these layers to select with which objects it can collide, using the collision_mask property.
A contact is detected if object A is in any of the layers that object B scans, or object B is in any layer scanned by object A.
</member>
- <member name="collision_mask" type="int" setter="set_collision_mask" getter="get_collision_mask">
+ <member name="collision_mask" type="int" setter="set_collision_mask" getter="get_collision_mask" default="1">
The physics layers this CSG shape scans for collisions.
</member>
- <member name="operation" type="int" setter="set_operation" getter="get_operation" enum="CSGShape.Operation">
+ <member name="operation" type="int" setter="set_operation" getter="get_operation" enum="CSGShape.Operation" default="0">
The operation that is performed on this shape. This is ignored for the first CSG child node as the operation is between this node and the previous child of this nodes parent.
</member>
- <member name="snap" type="float" setter="set_snap" getter="get_snap">
+ <member name="snap" type="float" setter="set_snap" getter="get_snap" default="0.001">
</member>
- <member name="use_collision" type="bool" setter="set_use_collision" getter="is_using_collision">
+ <member name="use_collision" type="bool" setter="set_use_collision" getter="is_using_collision" default="false">
Adds a collision shape to the physics engine for our CSG shape. This will always act like a static body. Note that the collision shape is still active even if the CSG shape itself is hidden.
</member>
</members>
diff --git a/modules/csg/doc_classes/CSGSphere.xml b/modules/csg/doc_classes/CSGSphere.xml
index 2a12cf84db..0a62644179 100644
--- a/modules/csg/doc_classes/CSGSphere.xml
+++ b/modules/csg/doc_classes/CSGSphere.xml
@@ -11,19 +11,19 @@
<methods>
</methods>
<members>
- <member name="material" type="Material" setter="set_material" getter="get_material">
+ <member name="material" type="Material" setter="set_material" getter="get_material" default="null">
The material used to render the sphere.
</member>
- <member name="radial_segments" type="int" setter="set_radial_segments" getter="get_radial_segments">
+ <member name="radial_segments" type="int" setter="set_radial_segments" getter="get_radial_segments" default="12">
Number of vertical slices for the sphere.
</member>
- <member name="radius" type="float" setter="set_radius" getter="get_radius">
+ <member name="radius" type="float" setter="set_radius" getter="get_radius" default="1.0">
Radius of the sphere.
</member>
- <member name="rings" type="int" setter="set_rings" getter="get_rings">
+ <member name="rings" type="int" setter="set_rings" getter="get_rings" default="6">
Number of horizontal slices for the sphere.
</member>
- <member name="smooth_faces" type="bool" setter="set_smooth_faces" getter="get_smooth_faces">
+ <member name="smooth_faces" type="bool" setter="set_smooth_faces" getter="get_smooth_faces" default="true">
If [code]true[/code] the normals of the sphere are set to give a smooth effect making the sphere seem rounded. If [code]false[/code] the sphere will have a flat shaded look.
</member>
</members>
diff --git a/modules/csg/doc_classes/CSGTorus.xml b/modules/csg/doc_classes/CSGTorus.xml
index 0d4437d87f..156fb185e7 100644
--- a/modules/csg/doc_classes/CSGTorus.xml
+++ b/modules/csg/doc_classes/CSGTorus.xml
@@ -11,22 +11,22 @@
<methods>
</methods>
<members>
- <member name="inner_radius" type="float" setter="set_inner_radius" getter="get_inner_radius">
+ <member name="inner_radius" type="float" setter="set_inner_radius" getter="get_inner_radius" default="2.0">
The inner radius of the torus.
</member>
- <member name="material" type="Material" setter="set_material" getter="get_material">
+ <member name="material" type="Material" setter="set_material" getter="get_material" default="null">
The material used to render the torus.
</member>
- <member name="outer_radius" type="float" setter="set_outer_radius" getter="get_outer_radius">
+ <member name="outer_radius" type="float" setter="set_outer_radius" getter="get_outer_radius" default="3.0">
The outer radius of the torus.
</member>
- <member name="ring_sides" type="int" setter="set_ring_sides" getter="get_ring_sides">
+ <member name="ring_sides" type="int" setter="set_ring_sides" getter="get_ring_sides" default="6">
The number of edges each ring of the torus is constructed of.
</member>
- <member name="sides" type="int" setter="set_sides" getter="get_sides">
+ <member name="sides" type="int" setter="set_sides" getter="get_sides" default="8">
The number of slices the torus is constructed of.
</member>
- <member name="smooth_faces" type="bool" setter="set_smooth_faces" getter="get_smooth_faces">
+ <member name="smooth_faces" type="bool" setter="set_smooth_faces" getter="get_smooth_faces" default="true">
If [code]true[/code] the normals of the torus are set to give a smooth effect making the torus seem rounded. If [code]false[/code] the torus will have a flat shaded look.
</member>
</members>
diff --git a/modules/csg/icons/icon_c_s_g_box.svg b/modules/csg/icons/icon_c_s_g_box.svg
new file mode 100644
index 0000000000..67e34df444
--- /dev/null
+++ b/modules/csg/icons/icon_c_s_g_box.svg
@@ -0,0 +1,6 @@
+<svg width="16" height="16" version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
+<g transform="translate(0 -1036.4)">
+<path transform="translate(0 1036.4)" d="m12 9c-0.55401 0-1 0.44599-1 1v1h2v2h1c0.55401 0 1-0.44599 1-1v-2c0-0.55401-0.44599-1-1-1h-2zm1 4h-2v-2h-1c-0.55401 0-1 0.44599-1 1v2c0 0.55401 0.44599 1 1 1h2c0.55401 0 1-0.44599 1-1v-1z" fill="#84c2ff"/>
+<path transform="translate(0 1036.4)" d="m8 0.94531-7 3.5v7.2227l7 3.5 0.29492-0.14844c-0.18282-0.30101-0.29492-0.64737-0.29492-1.0195v-2c0-0.72651 0.40824-1.3664 1-1.7168v-1.6699l4-2v1.3867h1c0.36419 0 0.70336 0.10754 1 0.2832v-3.8379zm0 2.1152 3.9395 1.9707-3.9395 1.9688-3.9395-1.9688zm-5 3.5527 4 2v3.9414l-4-2.002z" fill="#fc9c9c" stroke-width="1.0667"/>
+</g>
+</svg>
diff --git a/modules/csg/icons/icon_c_s_g_capsule.svg b/modules/csg/icons/icon_c_s_g_capsule.svg
new file mode 100644
index 0000000000..92a7b5a870
--- /dev/null
+++ b/modules/csg/icons/icon_c_s_g_capsule.svg
@@ -0,0 +1,6 @@
+<svg width="16" height="16" version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
+<g>
+<path d="m8 1c-2.7527 0-5 2.2418-5 4.9902v4.0176c0 2.7484 2.2473 4.9922 5 4.9922 0.092943 0 0.18367-0.008623 0.27539-0.013672-0.17055-0.29341-0.27539-0.62792-0.27539-0.98633v-2c0-0.72887 0.41095-1.3691 1.0059-1.7188v-0.28125c0.34771-0.034464 0.68259-0.10691 1.0156-0.19922 0.10394-0.99856 0.95603-1.8008 1.9785-1.8008h1v-2.0098c0-2.7484-2.2473-4.9902-5-4.9902zm-1.0059 2.127v4.8574c-0.66556-0.1047-1.2974-0.37231-1.9941-0.66211v-1.3223c0-1.3474 0.79841-2.4642 1.9941-2.873zm2.0117 0c1.1957 0.4088 1.9941 1.5256 1.9941 2.873v1.3457c-0.68406 0.3054-1.3142 0.57292-1.9941 0.66602v-4.8848zm-4.0059 6.334c0.67836 0.2231 1.3126 0.44599 1.9941 0.52539v2.8848c-1.1957-0.4092-1.9941-1.5237-1.9941-2.8711v-0.53906z" fill="#fc9c9c"/>
+<path d="m12 9c-0.55401 0-1 0.44599-1 1v1h2v2h1c0.55401 0 1-0.44599 1-1v-2c0-0.55401-0.44599-1-1-1zm1 4h-2v-2h-1c-0.55401 0-1 0.44599-1 1v2c0 0.55401 0.44599 1 1 1h2c0.55401 0 1-0.44599 1-1z" fill="#84c2ff"/>
+</g>
+</svg>
diff --git a/modules/csg/icons/icon_c_s_g_combiner.svg b/modules/csg/icons/icon_c_s_g_combiner.svg
new file mode 100644
index 0000000000..cce2902e24
--- /dev/null
+++ b/modules/csg/icons/icon_c_s_g_combiner.svg
@@ -0,0 +1,8 @@
+<svg width="16" height="16" version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
+<g transform="translate(0 -1036.4)">
+<path transform="translate(0 1036.4)" d="m12 9c-0.55401 0-1 0.44599-1 1v1h2v2h1c0.55401 0 1-0.44599 1-1v-2c0-0.55401-0.44599-1-1-1h-2zm1 4h-2v-2h-1c-0.55401 0-1 0.44599-1 1v2c0 0.55401 0.44599 1 1 1h2c0.55401 0 1-0.44599 1-1v-1z" fill="#84c2ff"/>
+<g fill="#fc9c9c">
+<path transform="translate(0 1036.4)" d="m3 1c-1.1046 0-2 0.89543-2 2h2zm2 0v2h2v-2zm4 0v2h2v-2zm4 0v2h2c0-1.1046-0.89543-2-2-2zm-12 4v2h2v-2zm12 0v2h2v-2zm-12 4v2h2v-2zm0 4c0 1.1046 0.89543 2 2 2v-2zm4 0v2h2v-2z" fill="#fc9c9c"/>
+</g>
+</g>
+</svg>
diff --git a/modules/csg/icons/icon_c_s_g_cylinder.svg b/modules/csg/icons/icon_c_s_g_cylinder.svg
new file mode 100644
index 0000000000..645a74c79b
--- /dev/null
+++ b/modules/csg/icons/icon_c_s_g_cylinder.svg
@@ -0,0 +1,6 @@
+<svg width="16" height="16" version="1.1" viewBox="0 0 14.999999 14.999999" xmlns="http://www.w3.org/2000/svg">
+<g>
+<path transform="scale(.9375)" d="m8 1c-1.7469 0-3.328 0.22648-4.5586 0.63672-0.61528 0.20512-1.1471 0.45187-1.5898 0.80078-0.44272 0.34891-0.85156 0.88101-0.85156 1.5625v8c0 0.68149 0.40884 1.2155 0.85156 1.5645 0.44272 0.34891 0.97457 0.59577 1.5898 0.80078 1.2306 0.41024 2.8117 0.63477 4.5586 0.63477 0.095648 0 0.18467-0.008426 0.2793-0.009766-0.1722-0.29446-0.2793-0.62995-0.2793-0.99023v-1c-1.5668 0-2.9867-0.2195-3.9277-0.5332-0.46329-0.15435-0.90474-0.33752-1.0723-0.4668v-5.8125c0.1468 0.058667 0.2835 0.12515 0.44141 0.17773 1.2306 0.41024 2.8117 0.63477 4.5586 0.63477s3.328-0.22453 4.5586-0.63477c0.15791-0.052267 0.29461-0.11864 0.44141-0.17773v1.8125h1c0.36396 0 0.70348 0.10774 1 0.2832v-4.2832c0-0.68149-0.40884-1.2136-0.85156-1.5625-0.44272-0.34891-0.97457-0.59566-1.5898-0.80078-1.2306-0.41024-2.8117-0.63672-4.5586-0.63672zm0 2c1.5668 0 2.9867 0.22145 3.9277 0.53516 0.46368 0.15456 0.80138 0.33741 0.96875 0.4668-0.16752 0.12928-0.50546 0.3105-0.96875 0.46484-0.94102 0.31371-2.361 0.5332-3.9277 0.5332s-2.9867-0.2195-3.9277-0.5332c-0.46329-0.15435-0.80123-0.33556-0.96875-0.46484 0.16737-0.12939 0.50507-0.31224 0.96875-0.4668 0.94102-0.31371 2.361-0.53516 3.9277-0.53516z" fill="#fc9c9c" stroke-width="1.0667"/>
+<path d="m11.25 8.4375c-0.51938 0-0.9375 0.41812-0.9375 0.9375v0.9375h1.875v1.875h0.9375c0.51938 0 0.9375-0.41812 0.9375-0.9375v-1.875c0-0.51938-0.41812-0.9375-0.9375-0.9375zm0.9375 3.75h-1.875v-1.875h-0.9375c-0.51938 0-0.9375 0.41812-0.9375 0.9375v1.875c0 0.51938 0.41812 0.9375 0.9375 0.9375h1.875c0.51938 0 0.9375-0.41812 0.9375-0.9375z" fill="#84c2ff"/>
+</g>
+</svg>
diff --git a/modules/csg/icons/icon_c_s_g_mesh.svg b/modules/csg/icons/icon_c_s_g_mesh.svg
new file mode 100644
index 0000000000..6e940a4aa5
--- /dev/null
+++ b/modules/csg/icons/icon_c_s_g_mesh.svg
@@ -0,0 +1,6 @@
+<svg width="16" height="16" version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
+<g>
+<path d="m3 1c-1.1046 0-2 0.89543-2 2 5.649e-4 0.71397 0.38169 1.3735 1 1.7305v6.541c-0.61771 0.35663-0.99874 1.0152-1 1.7285 0 1.1046 0.89543 2 2 2 0.71397-5.65e-4 1.3735-0.38169 1.7305-1h3.2695v-2h-3.2715c-0.17478-0.30301-0.42598-0.55488-0.72852-0.73047v-5.8555l4.916 4.916c0.31428-0.20669 0.68609-0.33008 1.084-0.33008 0-0.3979 0.12338-0.76971 0.33008-1.084l-4.916-4.916h5.8574c0.17478 0.30301 0.42598 0.55488 0.72852 0.73047v3.2695h2v-3.2715c0.61771-0.35663 0.99874-1.0152 1-1.7285 0-1.1046-0.89543-2-2-2-0.71397 5.648e-4 -1.3735 0.38169-1.7305 1h-6.541c-0.35663-0.61771-1.0152-0.99874-1.7285-1z" fill="#fc9c9c"/>
+<path d="m12 9c-0.55401 0-1 0.44599-1 1v1h2v2h1c0.55401 0 1-0.44599 1-1v-2c0-0.55401-0.44599-1-1-1zm1 4h-2v-2h-1c-0.55401 0-1 0.44599-1 1v2c0 0.55401 0.44599 1 1 1h2c0.55401 0 1-0.44599 1-1z" fill="#84c2ff"/>
+</g>
+</svg>
diff --git a/modules/csg/icons/icon_c_s_g_polygon.svg b/modules/csg/icons/icon_c_s_g_polygon.svg
new file mode 100644
index 0000000000..71b03cb8e6
--- /dev/null
+++ b/modules/csg/icons/icon_c_s_g_polygon.svg
@@ -0,0 +1,6 @@
+<svg width="16" height="16" version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
+<g transform="translate(0 -1036.4)">
+<path transform="translate(0 1036.4)" d="m7.9629 1.002c-0.14254 0.00487-0.28238 0.04016-0.41016 0.10352l-6 3c-0.33878 0.16944-0.55276 0.51574-0.55273 0.89453v5.832c-0.105 0.61631 0.37487 1.1768 1 1.168h5v2c2.16e-5 0.67546 0.64487 1.1297 1.2617 0.95898-0.16118-0.28721-0.26172-0.61135-0.26172-0.95898v-2c0-0.72673 0.40794-1.3664 1-1.7168v-1.666l4-2v1.3828h1c0.36397 0 0.70348 0.10774 1 0.2832v-3.2773c6e-6 -0.00195 6e-6 -0.0039094 0-0.0058594 2.6e-5 -0.37879-0.21395-0.72509-0.55273-0.89453l-6-3c-0.15022-0.074574-0.31679-0.11017-0.48438-0.10352zm0.037109 2.1172l3.7637 1.8809-2.7637 1.3809v-1.3809c-5.52e-5 -0.55226-0.44774-0.99994-1-1h-1.7617l1.7617-0.88086zm-5 2.8809h4v4h-4v-4z" color="#000000" color-rendering="auto" dominant-baseline="auto" fill="#fc9c9c" image-rendering="auto" shape-rendering="auto" solid-color="#000000" style="font-feature-settings:normal;font-variant-alternates:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal;font-variant-position:normal;isolation:auto;mix-blend-mode:normal;shape-padding:0;text-decoration-color:#000000;text-decoration-line:none;text-decoration-style:solid;text-indent:0;text-orientation:mixed;text-transform:none;white-space:normal"/>
+<path transform="translate(0 1036.4)" d="m12 9c-0.55401 0-1 0.44599-1 1v1h2v2h1c0.55401 0 1-0.44599 1-1v-2c0-0.55401-0.44599-1-1-1h-2zm1 4h-2v-2h-1c-0.55401 0-1 0.44599-1 1v2c0 0.55401 0.44599 1 1 1h2c0.55401 0 1-0.44599 1-1v-1z" fill="#84c2ff"/>
+</g>
+</svg>
diff --git a/modules/csg/icons/icon_c_s_g_sphere.svg b/modules/csg/icons/icon_c_s_g_sphere.svg
new file mode 100644
index 0000000000..f81b566993
--- /dev/null
+++ b/modules/csg/icons/icon_c_s_g_sphere.svg
@@ -0,0 +1,6 @@
+<svg width="16" height="16" version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
+<g>
+<path d="m8 1c-3.8541 0-7 3.1459-7 7 0 3.8542 3.1459 7 7 7 0.093042 0 0.18321-0.01004 0.27539-0.013672-0.17055-0.29341-0.27539-0.62792-0.27539-0.98633v-2c0-0.72673 0.40794-1.3664 1-1.7168v-0.33398c0.34074-0.019259 0.67728-0.069097 1.0156-0.10547 0.083091-1.0187 0.94713-1.8438 1.9844-1.8438h2c0.35841 0 0.69292 0.10484 0.98633 0.27539 0.003633-0.092184 0.013672-0.18235 0.013672-0.27539 0-3.8541-3.1459-7-7-7zm-1 2.0977v4.8711c-1.2931-0.071342-2.6061-0.29819-3.9434-0.69141 0.30081-2.0978 1.8852-3.7665 3.9434-4.1797zm2 0c2.0549 0.41253 3.637 2.0767 3.9414 4.1699-1.3046 0.36677-2.6158 0.60259-3.9414 0.6875v-4.8574zm-5.7793 6.2988c1.2733 0.31892 2.5337 0.50215 3.7793 0.5625v2.9414c-1.8291-0.36719-3.266-1.7339-3.7793-3.5039z" fill="#fc9c9c"/>
+<path d="m12 9c-0.55401 0-1 0.44599-1 1v1h2v2h1c0.55401 0 1-0.44599 1-1v-2c0-0.55401-0.44599-1-1-1zm1 4h-2v-2h-1c-0.55401 0-1 0.44599-1 1v2c0 0.55401 0.44599 1 1 1h2c0.55401 0 1-0.44599 1-1z" fill="#84c2ff"/>
+</g>
+</svg>
diff --git a/modules/csg/icons/icon_c_s_g_torus.svg b/modules/csg/icons/icon_c_s_g_torus.svg
new file mode 100644
index 0000000000..3d30aa47b2
--- /dev/null
+++ b/modules/csg/icons/icon_c_s_g_torus.svg
@@ -0,0 +1,6 @@
+<svg width="16" height="16" version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
+<g transform="translate(0 -1036.4)">
+<path transform="translate(0 1036.4)" d="m8 3c-1.8145 0-3.4691 0.41721-4.7461 1.1621-1.277 0.745-2.2539 1.9082-2.2539 3.3379 0 1.4298 0.9769 2.5949 2.2539 3.3398 1.277 0.7449 2.9316 1.1602 4.7461 1.1602 0-1.0907 0.90931-2 2-2 0-0.080836 0.013744-0.15778 0.023438-0.23633-0.61769 0.14673-1.3008 0.23633-2.0234 0.23633-1.4992 0-2.8437-0.36687-3.7383-0.88867-0.89456-0.5219-1.2617-1.108-1.2617-1.6113 0-0.5032 0.36716-1.0876 1.2617-1.6094 0.89456-0.5219 2.2391-0.89062 3.7383-0.89062s2.8437 0.36872 3.7383 0.89062c0.89456 0.5218 1.2617 1.1062 1.2617 1.6094 0 0.15978-0.053679 0.32822-0.13281 0.5h1.1328c0.32481 0 0.62893 0.088408 0.90234 0.23047 0.057552-0.23582 0.097656-0.47718 0.097656-0.73047 0-1.4297-0.9769-2.5929-2.2539-3.3379-1.277-0.7449-2.9316-1.1621-4.7461-1.1621z" color="#000000" color-rendering="auto" dominant-baseline="auto" fill="#fc9c9c" image-rendering="auto" shape-rendering="auto" solid-color="#000000" style="font-feature-settings:normal;font-variant-alternates:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal;font-variant-position:normal;isolation:auto;mix-blend-mode:normal;shape-padding:0;text-decoration-color:#000000;text-decoration-line:none;text-decoration-style:solid;text-indent:0;text-orientation:mixed;text-transform:none;white-space:normal"/>
+<path transform="translate(0 1036.4)" d="m12 9c-0.55401 0-1 0.44599-1 1v1h2v2h1c0.55401 0 1-0.44599 1-1v-2c0-0.55401-0.44599-1-1-1h-2zm1 4h-2v-2h-1c-0.55401 0-1 0.44599-1 1v2c0 0.55401 0.44599 1 1 1h2c0.55401 0 1-0.44599 1-1v-1z" fill="#84c2ff"/>
+</g>
+</svg>
diff --git a/modules/cvtt/image_compress_cvtt.cpp b/modules/cvtt/image_compress_cvtt.cpp
index 0a70ff535f..024e9ffc3b 100644
--- a/modules/cvtt/image_compress_cvtt.cpp
+++ b/modules/cvtt/image_compress_cvtt.cpp
@@ -145,7 +145,7 @@ void image_compress_cvtt(Image *p_image, float p_lossy_quality, Image::CompressS
int h = p_image->get_height();
bool is_ldr = (p_image->get_format() <= Image::FORMAT_RGBA8);
- bool is_hdr = (p_image->get_format() == Image::FORMAT_RGBH);
+ bool is_hdr = (p_image->get_format() >= Image::FORMAT_RH) && (p_image->get_format() <= Image::FORMAT_RGBE9995);
if (!is_ldr && !is_hdr) {
return; // Not a usable source format
@@ -175,6 +175,10 @@ void image_compress_cvtt(Image *p_image, float p_lossy_quality, Image::CompressS
bool is_signed = false;
if (is_hdr) {
+ if (p_image->get_format() != Image::FORMAT_RGBH) {
+ p_image->convert(Image::FORMAT_RGBH);
+ }
+
PoolVector<uint8_t>::Read rb = p_image->get_data().read();
const uint16_t *source_data = reinterpret_cast<const uint16_t *>(&rb[0]);
diff --git a/modules/dds/texture_loader_dds.cpp b/modules/dds/texture_loader_dds.cpp
index 059c06c37c..50fdc8ab20 100644
--- a/modules/dds/texture_loader_dds.cpp
+++ b/modules/dds/texture_loader_dds.cpp
@@ -31,6 +31,8 @@
#include "texture_loader_dds.h"
#include "core/os/file_access.h"
+#define PF_FOURCC(s) (((s)[3] << 24U) | ((s)[2] << 16U) | ((s)[1] << 8U) | ((s)[0]))
+
enum {
DDS_MAGIC = 0x20534444,
DDSD_CAPS = 0x00000001,
@@ -51,6 +53,7 @@ enum DDSFormat {
DDS_DXT5,
DDS_ATI1,
DDS_ATI2,
+ DDS_A2XY,
DDS_BGRA8,
DDS_BGR8,
DDS_RGBA8, //flipped in dds
@@ -74,9 +77,12 @@ struct DDSFormatInfo {
};
static const DDSFormatInfo dds_format_info[DDS_MAX] = {
- { "DXT1", true, false, 4, 8, Image::FORMAT_DXT1 },
- { "DXT3", true, false, 4, 16, Image::FORMAT_DXT3 },
- { "DXT5", true, false, 4, 16, Image::FORMAT_DXT5 },
+ { "DXT1/BC1", true, false, 4, 8, Image::FORMAT_DXT1 },
+ { "DXT3/BC2", true, false, 4, 16, Image::FORMAT_DXT3 },
+ { "DXT5/BC3", true, false, 4, 16, Image::FORMAT_DXT5 },
+ { "ATI1/BC4", true, false, 4, 8, Image::FORMAT_RGTC_R },
+ { "ATI2/3DC/BC5", true, false, 4, 16, Image::FORMAT_RGTC_RG },
+ { "A2XY/DXN/BC5", true, false, 4, 16, Image::FORMAT_RGTC_RG },
{ "BGRA8", false, false, 1, 4, Image::FORMAT_RGBA8 },
{ "BGR8", false, false, 1, 3, Image::FORMAT_RGB8 },
{ "RGBA8", false, false, 1, 4, Image::FORMAT_RGBA8 },
@@ -158,22 +164,25 @@ RES ResourceFormatDDS::load(const String &p_path, const String &p_original_path,
DDSFormat dds_format;
- if (format_flags & DDPF_FOURCC && format_fourcc == 0x31545844) { //'1TXD'
+ if (format_flags & DDPF_FOURCC && format_fourcc == PF_FOURCC("DXT1")) {
dds_format = DDS_DXT1;
- } else if (format_flags & DDPF_FOURCC && format_fourcc == 0x33545844) { //'3TXD'
+ } else if (format_flags & DDPF_FOURCC && format_fourcc == PF_FOURCC("DXT3")) {
dds_format = DDS_DXT3;
- } else if (format_flags & DDPF_FOURCC && format_fourcc == 0x35545844) { //'5TXD'
+ } else if (format_flags & DDPF_FOURCC && format_fourcc == PF_FOURCC("DXT5")) {
dds_format = DDS_DXT5;
- } else if (format_flags & DDPF_FOURCC && format_fourcc == 0x31495441) { //'1ITA'
+ } else if (format_flags & DDPF_FOURCC && format_fourcc == PF_FOURCC("ATI1")) {
dds_format = DDS_ATI1;
- } else if (format_flags & DDPF_FOURCC && format_fourcc == 0x32495441) { //'2ITA'
+ } else if (format_flags & DDPF_FOURCC && format_fourcc == PF_FOURCC("ATI2")) {
dds_format = DDS_ATI2;
+ } else if (format_flags & DDPF_FOURCC && format_fourcc == PF_FOURCC("A2XY")) {
+
+ dds_format = DDS_A2XY;
} else if (format_flags & DDPF_RGB && format_flags & DDPF_ALPHAPIXELS && format_rgb_bits == 32 && format_red_mask == 0xff0000 && format_green_mask == 0xff00 && format_blue_mask == 0xff && format_alpha_mask == 0xff000000) {
diff --git a/modules/dds/texture_loader_dds.h b/modules/dds/texture_loader_dds.h
index 585f2891bf..6ddef4e770 100644
--- a/modules/dds/texture_loader_dds.h
+++ b/modules/dds/texture_loader_dds.h
@@ -35,7 +35,6 @@
#include "scene/resources/texture.h"
class ResourceFormatDDS : public ResourceFormatLoader {
- GDCLASS(ResourceFormatDDS, ResourceFormatLoader)
public:
virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL);
virtual void get_recognized_extensions(List<String> *p_extensions) const;
diff --git a/modules/enet/doc_classes/NetworkedMultiplayerENet.xml b/modules/enet/doc_classes/NetworkedMultiplayerENet.xml
index d3d1e58b7b..84ed5fd9ee 100644
--- a/modules/enet/doc_classes/NetworkedMultiplayerENet.xml
+++ b/modules/enet/doc_classes/NetworkedMultiplayerENet.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="NetworkedMultiplayerENet" inherits="NetworkedMultiplayerPeer" category="Core" version="3.2">
<brief_description>
- PacketPeer implementation using the ENet library.
+ PacketPeer implementation using the [url=http://enet.bespin.org/index.html]ENet[/url] library.
</brief_description>
<description>
A PacketPeer implementation that should be passed to [member SceneTree.network_peer] after being initialized as either a client or server. Events can then be handled by connecting to [SceneTree] signals.
@@ -34,7 +34,7 @@
<argument index="4" name="client_port" type="int" default="0">
</argument>
<description>
- Create client that connects to a server at [code]address[/code] using specified [code]port[/code]. The given address needs to be either a fully qualified domain name (e.g. [code]www.example.com[/code]) or an IP address in IPv4 or IPv6 format (e.g. [code]192.168.1.1[/code]). The [code]port[/code] is the port the server is listening on. The [code]in_bandwidth[/code] and [code]out_bandwidth[/code] parameters can be used to limit the incoming and outgoing bandwidth to the given number of bytes per second. The default of 0 means unlimited bandwidth. Note that ENet will strategically drop packets on specific sides of a connection between peers to ensure the peer's bandwidth is not overwhelmed. The bandwidth parameters also determine the window size of a connection which limits the amount of reliable packets that may be in transit at any given time. Returns [code]OK[/code] if a client was created, [code]ERR_ALREADY_IN_USE[/code] if this NetworkedMultiplayerEnet instance already has an open connection (in which case you need to call [method close_connection] first) or [code]ERR_CANT_CREATE[/code] if the client could not be created. If [code]client_port[/code] is specified, the client will also listen to the given port, this is useful in some NAT traversal technique.
+ Create client that connects to a server at [code]address[/code] using specified [code]port[/code]. The given address needs to be either a fully qualified domain name (e.g. [code]"www.example.com"[/code]) or an IP address in IPv4 or IPv6 format (e.g. [code]"192.168.1.1"[/code]). The [code]port[/code] is the port the server is listening on. The [code]in_bandwidth[/code] and [code]out_bandwidth[/code] parameters can be used to limit the incoming and outgoing bandwidth to the given number of bytes per second. The default of 0 means unlimited bandwidth. Note that ENet will strategically drop packets on specific sides of a connection between peers to ensure the peer's bandwidth is not overwhelmed. The bandwidth parameters also determine the window size of a connection which limits the amount of reliable packets that may be in transit at any given time. Returns [constant OK] if a client was created, [constant ERR_ALREADY_IN_USE] if this NetworkedMultiplayerENet instance already has an open connection (in which case you need to call [method close_connection] first) or [constant ERR_CANT_CREATE] if the client could not be created. If [code]client_port[/code] is specified, the client will also listen to the given port; this is useful for some NAT traversal techniques.
</description>
</method>
<method name="create_server">
@@ -49,7 +49,7 @@
<argument index="3" name="out_bandwidth" type="int" default="0">
</argument>
<description>
- Create server that listens to connections via [code]port[/code]. The port needs to be an available, unused port between 0 and 65535. Note that ports below 1024 are privileged and may require elevated permissions depending on the platform. To change the interface the server listens on, use [method set_bind_ip]. The default IP is the wildcard [code]*[/code], which listens on all available interfaces. [code]max_clients[/code] is the maximum number of clients that are allowed at once, any number up to 4096 may be used, although the achievable number of simultaneous clients may be far lower and depends on the application. For additional details on the bandwidth parameters, see [method create_client]. Returns [code]OK[/code] if a server was created, [code]ERR_ALREADY_IN_USE[/code] if this NetworkedMultiplayerEnet instance already has an open connection (in which case you need to call [method close_connection] first) or [code]ERR_CANT_CREATE[/code] if the server could not be created.
+ Create server that listens to connections via [code]port[/code]. The port needs to be an available, unused port between 0 and 65535. Note that ports below 1024 are privileged and may require elevated permissions depending on the platform. To change the interface the server listens on, use [method set_bind_ip]. The default IP is the wildcard [code]"*"[/code], which listens on all available interfaces. [code]max_clients[/code] is the maximum number of clients that are allowed at once, any number up to 4096 may be used, although the achievable number of simultaneous clients may be far lower and depends on the application. For additional details on the bandwidth parameters, see [method create_client]. Returns [constant OK] if a server was created, [constant ERR_ALREADY_IN_USE] if this NetworkedMultiplayerENet instance already has an open connection (in which case you need to call [method close_connection] first) or [constant ERR_CANT_CREATE] if the server could not be created.
</description>
</method>
<method name="disconnect_peer">
@@ -101,39 +101,39 @@
<argument index="0" name="ip" type="String">
</argument>
<description>
- 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].
+ 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>
</methods>
<members>
- <member name="always_ordered" type="bool" setter="set_always_ordered" getter="is_always_ordered">
- Always use [code]TRANSFER_MODE_ORDERED[/code] in place of [code]TRANSFER_MODE_UNRELIABLE[/code]. This is the only way to use ordering with the RPC system.
+ <member name="always_ordered" type="bool" setter="set_always_ordered" getter="is_always_ordered" default="false">
+ Enforce ordered packets when using [constant NetworkedMultiplayerPeer.TRANSFER_MODE_UNRELIABLE] (thus behaving similarly to [constant NetworkedMultiplayerPeer.TRANSFER_MODE_UNRELIABLE_ORDERED]). This is the only way to use ordering with the RPC system.
</member>
- <member name="channel_count" type="int" setter="set_channel_count" getter="get_channel_count">
- The number of channels to be used by ENet. Default: [code]3[/code]. Channels are used to separate different kinds of data. In reliable or ordered mode, for example, the packet delivery order is ensured on a per channel basis.
+ <member name="channel_count" type="int" setter="set_channel_count" getter="get_channel_count" default="3">
+ The number of channels to be used by ENet. Channels are used to separate different kinds of data. In reliable or ordered mode, for example, the packet delivery order is ensured on a per channel basis.
</member>
- <member name="compression_mode" type="int" setter="set_compression_mode" getter="get_compression_mode" enum="NetworkedMultiplayerENet.CompressionMode">
- The compression method used for network packets. Default is no compression. 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 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="transfer_channel" type="int" setter="set_transfer_channel" getter="get_transfer_channel">
- 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 name="transfer_channel" type="int" setter="set_transfer_channel" getter="get_transfer_channel" default="-1">
+ 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>
</members>
<constants>
<constant name="COMPRESS_NONE" value="0" enum="CompressionMode">
- No compression.
+ No compression. This uses the most bandwidth, but has the upside of requiring the fewest CPU resources.
</constant>
<constant name="COMPRESS_RANGE_CODER" value="1" enum="CompressionMode">
- ENet's buildin range encoding.
+ ENet's built-in range encoding.
</constant>
<constant name="COMPRESS_FASTLZ" value="2" enum="CompressionMode">
- FastLZ compression.
+ [url=http://fastlz.org/]FastLZ[/url] compression. This option uses less CPU resources compared to [constant COMPRESS_ZLIB], at the expense of using more bandwidth.
</constant>
<constant name="COMPRESS_ZLIB" value="3" enum="CompressionMode">
- zlib compression.
+ [url=https://www.zlib.net/]Zlib[/url] compression. This option uses less bandwidth compared to [constant COMPRESS_FASTLZ], at the expense of using more CPU resources.
</constant>
<constant name="COMPRESS_ZSTD" value="4" enum="CompressionMode">
- ZStandard compression.
+ [url=https://facebook.github.io/zstd/]Zstandard[/url] compression.
</constant>
</constants>
</class>
diff --git a/modules/enet/networked_multiplayer_enet.cpp b/modules/enet/networked_multiplayer_enet.cpp
index 18dfe08e85..a5a356ced2 100644
--- a/modules/enet/networked_multiplayer_enet.cpp
+++ b/modules/enet/networked_multiplayer_enet.cpp
@@ -80,6 +80,7 @@ Error NetworkedMultiplayerENet::create_server(int p_port, int p_max_clients, int
ERR_FAIL_COND_V(p_out_bandwidth < 0, ERR_INVALID_PARAMETER);
ENetAddress address;
+ memset(&address, 0, sizeof(address));
#ifdef GODOT_ENET
if (bind_ip.is_wildcard()) {
@@ -346,7 +347,7 @@ void NetworkedMultiplayerENet::poll() {
uint32_t *id = (uint32_t *)event.peer->data;
- ERR_CONTINUE(event.packet->dataLength < 8)
+ ERR_CONTINUE(event.packet->dataLength < 8);
uint32_t source = decode_uint32(&event.packet->data[0]);
int target = decode_uint32(&event.packet->data[4]);
@@ -462,7 +463,7 @@ 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(!peer_map.has(p_peer));
if (now) {
enet_peer_disconnect_now(peer_map[p_peer], 0);
@@ -881,7 +882,9 @@ NetworkedMultiplayerENet::NetworkedMultiplayerENet() {
NetworkedMultiplayerENet::~NetworkedMultiplayerENet() {
- close_connection();
+ if (active) {
+ close_connection();
+ }
}
// Sets IP for ENet to bind when using create_server or create_client
diff --git a/modules/enet/networked_multiplayer_enet.h b/modules/enet/networked_multiplayer_enet.h
index 957d0830cb..8dcb202314 100644
--- a/modules/enet/networked_multiplayer_enet.h
+++ b/modules/enet/networked_multiplayer_enet.h
@@ -38,7 +38,8 @@
class NetworkedMultiplayerENet : public NetworkedMultiplayerPeer {
- GDCLASS(NetworkedMultiplayerENet, NetworkedMultiplayerPeer)
+ GDCLASS(NetworkedMultiplayerENet, NetworkedMultiplayerPeer);
+
public:
enum CompressionMode {
COMPRESS_NONE,
diff --git a/modules/etc/texture_loader_pkm.h b/modules/etc/texture_loader_pkm.h
index 860fe8b5df..79c17953fc 100644
--- a/modules/etc/texture_loader_pkm.h
+++ b/modules/etc/texture_loader_pkm.h
@@ -35,7 +35,6 @@
#include "scene/resources/texture.h"
class ResourceFormatPKM : public ResourceFormatLoader {
- GDCLASS(ResourceFormatPKM, ResourceFormatLoader)
public:
virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL);
virtual void get_recognized_extensions(List<String> *p_extensions) const;
diff --git a/modules/gdnative/android/android_gdn.cpp b/modules/gdnative/android/android_gdn.cpp
index 8657935602..624ef19dec 100644
--- a/modules/gdnative/android/android_gdn.cpp
+++ b/modules/gdnative/android/android_gdn.cpp
@@ -34,6 +34,8 @@
// These entry points are only for the android platform and are simple stubs in all others.
#ifdef __ANDROID__
+#include "platform/android/java_godot_wrapper.h"
+#include "platform/android/os_android.h"
#include "platform/android/thread_jandroid.h"
#else
#define JNIEnv void
@@ -54,20 +56,31 @@ JNIEnv *GDAPI godot_android_get_env() {
jobject GDAPI godot_android_get_activity() {
#ifdef __ANDROID__
- JNIEnv *env = ThreadAndroid::get_env();
-
- jclass activityThread = env->FindClass("android/app/ActivityThread");
- jmethodID currentActivityThread = env->GetStaticMethodID(activityThread, "currentActivityThread", "()Landroid/app/ActivityThread;");
- jobject at = env->CallStaticObjectMethod(activityThread, currentActivityThread);
- jmethodID getApplication = env->GetMethodID(activityThread, "getApplication", "()Landroid/app/Application;");
- jobject context = env->CallObjectMethod(at, getApplication);
+ OS_Android *os_android = (OS_Android *)OS::get_singleton();
+ return os_android->get_godot_java()->get_activity();
+#else
+ return NULL;
+#endif
+}
- return env->NewGlobalRef(context);
+jobject GDAPI godot_android_get_surface() {
+#ifdef __ANDROID__
+ OS_Android *os_android = (OS_Android *)OS::get_singleton();
+ return os_android->get_godot_java()->get_surface();
#else
return NULL;
#endif
}
+bool GDAPI godot_android_is_activity_resumed() {
+#ifdef __ANDROID__
+ OS_Android *os_android = (OS_Android *)OS::get_singleton();
+ return os_android->get_godot_java()->is_activity_resumed();
+#else
+ return false;
+#endif
+}
+
#ifdef __cplusplus
}
#endif \ No newline at end of file
diff --git a/modules/gdnative/arvr/arvr_interface_gdnative.cpp b/modules/gdnative/arvr/arvr_interface_gdnative.cpp
index c3f8688adb..64e2c362b2 100644
--- a/modules/gdnative/arvr/arvr_interface_gdnative.cpp
+++ b/modules/gdnative/arvr/arvr_interface_gdnative.cpp
@@ -33,9 +33,13 @@
#include "servers/arvr/arvr_positional_tracker.h"
#include "servers/visual/visual_server_globals.h"
+void ARVRInterfaceGDNative::_bind_methods() {
+ ADD_PROPERTY_DEFAULT("interface_is_initialized", false);
+ ADD_PROPERTY_DEFAULT("ar_is_anchor_detection_enabled", false);
+}
+
ARVRInterfaceGDNative::ARVRInterfaceGDNative() {
- // testing
- printf("Construct gdnative interface\n");
+ print_verbose("Construct gdnative interface\n");
// we won't have our data pointer until our library gets set
data = NULL;
@@ -44,9 +48,9 @@ ARVRInterfaceGDNative::ARVRInterfaceGDNative() {
}
ARVRInterfaceGDNative::~ARVRInterfaceGDNative() {
- printf("Destruct gdnative interface\n");
+ print_verbose("Destruct gdnative interface\n");
- if (is_initialized()) {
+ if (interface != NULL && is_initialized()) {
uninitialize();
};
@@ -99,13 +103,10 @@ int ARVRInterfaceGDNative::get_capabilities() const {
}
bool ARVRInterfaceGDNative::get_anchor_detection_is_enabled() const {
- bool enabled;
ERR_FAIL_COND_V(interface == NULL, false);
- enabled = interface->get_anchor_detection_is_enabled(data);
-
- return enabled;
+ return interface->get_anchor_detection_is_enabled(data);
}
void ARVRInterfaceGDNative::set_anchor_detection_is_enabled(bool p_enable) {
@@ -115,6 +116,17 @@ void ARVRInterfaceGDNative::set_anchor_detection_is_enabled(bool p_enable) {
interface->set_anchor_detection_is_enabled(data, p_enable);
}
+int ARVRInterfaceGDNative::get_camera_feed_id() {
+
+ ERR_FAIL_COND_V(interface == NULL, 0);
+
+ if ((interface->version.major > 1) || ((interface->version.major) == 1 && (interface->version.minor >= 1))) {
+ return (unsigned int)interface->get_camera_feed_id(data);
+ } else {
+ return 0;
+ }
+}
+
bool ARVRInterfaceGDNative::is_stereo() {
bool stereo;
@@ -126,21 +138,16 @@ bool ARVRInterfaceGDNative::is_stereo() {
}
bool ARVRInterfaceGDNative::is_initialized() const {
- bool initialized;
ERR_FAIL_COND_V(interface == NULL, false);
- initialized = interface->is_initialized(data);
-
- return initialized;
+ return interface->is_initialized(data);
}
bool ARVRInterfaceGDNative::initialize() {
- bool initialized;
-
ERR_FAIL_COND_V(interface == NULL, false);
- initialized = interface->initialize(data);
+ bool initialized = interface->initialize(data);
if (initialized) {
// if we successfully initialize our interface and we don't have a primary interface yet, this becomes our primary interface
diff --git a/modules/gdnative/arvr/arvr_interface_gdnative.h b/modules/gdnative/arvr/arvr_interface_gdnative.h
index 86396b067a..ab7090876a 100644
--- a/modules/gdnative/arvr/arvr_interface_gdnative.h
+++ b/modules/gdnative/arvr/arvr_interface_gdnative.h
@@ -41,7 +41,7 @@
*/
class ARVRInterfaceGDNative : public ARVRInterface {
- GDCLASS(ARVRInterfaceGDNative, ARVRInterface)
+ GDCLASS(ARVRInterfaceGDNative, ARVRInterface);
void cleanup();
@@ -49,6 +49,8 @@ protected:
const godot_arvr_interface_gdnative *interface;
void *data;
+ static void _bind_methods();
+
public:
/** general interface information **/
ARVRInterfaceGDNative();
@@ -66,6 +68,7 @@ public:
/** specific to AR **/
virtual bool get_anchor_detection_is_enabled() const;
virtual void set_anchor_detection_is_enabled(bool p_enable);
+ virtual int get_camera_feed_id();
/** rendering and internal **/
virtual Size2 get_render_targetsize();
diff --git a/modules/gdnative/config.py b/modules/gdnative/config.py
index 7898de5523..b9e5afcdf3 100644
--- a/modules/gdnative/config.py
+++ b/modules/gdnative/config.py
@@ -6,6 +6,7 @@ def configure(env):
def get_doc_classes():
return [
+ "@NativeScript",
"ARVRInterfaceGDNative",
"GDNative",
"GDNativeLibrary",
@@ -13,7 +14,6 @@ def get_doc_classes():
"NativeScript",
"PacketPeerGDNative",
"PluginScript",
- "ResourceFormatLoaderVideoStreamGDNative",
"StreamPeerGDNative",
"VideoStreamGDNative",
"WebRTCPeerConnectionGDNative",
diff --git a/modules/stb_vorbis/doc_classes/ResourceImporterOGGVorbis.xml b/modules/gdnative/doc_classes/@NativeScript.xml
index 4dd77fed34..cb5de198ac 100644
--- a/modules/stb_vorbis/doc_classes/ResourceImporterOGGVorbis.xml
+++ b/modules/gdnative/doc_classes/@NativeScript.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="ResourceImporterOGGVorbis" inherits="ResourceImporter" category="Core" version="3.2">
+<class name="@NativeScript" category="Core" version="3.2">
<brief_description>
</brief_description>
<description>
diff --git a/modules/gdnative/doc_classes/ARVRInterfaceGDNative.xml b/modules/gdnative/doc_classes/ARVRInterfaceGDNative.xml
index efdb948660..47c2ee3358 100644
--- a/modules/gdnative/doc_classes/ARVRInterfaceGDNative.xml
+++ b/modules/gdnative/doc_classes/ARVRInterfaceGDNative.xml
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="ARVRInterfaceGDNative" inherits="ARVRInterface" category="Core" version="3.2">
<brief_description>
- GDNative wrapper for an ARVR interface
+ GDNative wrapper for an ARVR interface.
</brief_description>
<description>
- This is a wrapper class for GDNative implementations of the ARVR interface. To use a GDNative ARVR interface simply instantiate this object and set your GDNative library containing the ARVR interface implementation.
+ This is a wrapper class for GDNative implementations of the ARVR interface. To use a GDNative ARVR interface, simply instantiate this object and set your GDNative library containing the ARVR interface implementation.
</description>
<tutorials>
</tutorials>
diff --git a/modules/gdnative/doc_classes/GDNative.xml b/modules/gdnative/doc_classes/GDNative.xml
index 8750ddc56d..95ed1fc048 100644
--- a/modules/gdnative/doc_classes/GDNative.xml
+++ b/modules/gdnative/doc_classes/GDNative.xml
@@ -33,7 +33,7 @@
</method>
</methods>
<members>
- <member name="library" type="GDNativeLibrary" setter="set_library" getter="get_library">
+ <member name="library" type="GDNativeLibrary" setter="set_library" getter="get_library" default="null">
</member>
</members>
<constants>
diff --git a/modules/gdnative/doc_classes/GDNativeLibrary.xml b/modules/gdnative/doc_classes/GDNativeLibrary.xml
index 8bfd386b8d..7e1cac243a 100644
--- a/modules/gdnative/doc_classes/GDNativeLibrary.xml
+++ b/modules/gdnative/doc_classes/GDNativeLibrary.xml
@@ -23,13 +23,13 @@
<members>
<member name="config_file" type="ConfigFile" setter="set_config_file" getter="get_config_file">
</member>
- <member name="load_once" type="bool" setter="set_load_once" getter="should_load_once">
+ <member name="load_once" type="bool" setter="set_load_once" getter="should_load_once" default="true">
</member>
- <member name="reloadable" type="bool" setter="set_reloadable" getter="is_reloadable">
+ <member name="reloadable" type="bool" setter="set_reloadable" getter="is_reloadable" default="true">
</member>
- <member name="singleton" type="bool" setter="set_singleton" getter="is_singleton">
+ <member name="singleton" type="bool" setter="set_singleton" getter="is_singleton" default="false">
</member>
- <member name="symbol_prefix" type="String" setter="set_symbol_prefix" getter="get_symbol_prefix">
+ <member name="symbol_prefix" type="String" setter="set_symbol_prefix" getter="get_symbol_prefix" default="&quot;godot_&quot;">
</member>
</members>
<constants>
diff --git a/modules/gdnative/doc_classes/NativeScript.xml b/modules/gdnative/doc_classes/NativeScript.xml
index ac8b793b22..460471386d 100644
--- a/modules/gdnative/doc_classes/NativeScript.xml
+++ b/modules/gdnative/doc_classes/NativeScript.xml
@@ -51,13 +51,13 @@
</method>
</methods>
<members>
- <member name="class_name" type="String" setter="set_class_name" getter="get_class_name">
+ <member name="class_name" type="String" setter="set_class_name" getter="get_class_name" default="&quot;&quot;">
</member>
- <member name="library" type="GDNativeLibrary" setter="set_library" getter="get_library">
+ <member name="library" type="GDNativeLibrary" setter="set_library" getter="get_library" default="null">
</member>
- <member name="script_class_icon_path" type="String" setter="set_script_class_icon_path" getter="get_script_class_icon_path">
+ <member name="script_class_icon_path" type="String" setter="set_script_class_icon_path" getter="get_script_class_icon_path" default="&quot;&quot;">
</member>
- <member name="script_class_name" type="String" setter="set_script_class_name" getter="get_script_class_name">
+ <member name="script_class_name" type="String" setter="set_script_class_name" getter="get_script_class_name" default="&quot;&quot;">
</member>
</members>
<constants>
diff --git a/modules/gdnative/gdnative.h b/modules/gdnative/gdnative.h
index ef57387059..005d1d2bff 100644
--- a/modules/gdnative/gdnative.h
+++ b/modules/gdnative/gdnative.h
@@ -45,7 +45,7 @@ class GDNativeLibraryResourceLoader;
class GDNative;
class GDNativeLibrary : public Resource {
- GDCLASS(GDNativeLibrary, Resource)
+ GDCLASS(GDNativeLibrary, Resource);
static Map<String, Vector<Ref<GDNative> > > *loaded_libraries;
@@ -137,7 +137,7 @@ struct GDNativeCallRegistry {
};
class GDNative : public Reference {
- GDCLASS(GDNative, Reference)
+ GDCLASS(GDNative, Reference);
Ref<GDNativeLibrary> library;
@@ -165,7 +165,6 @@ public:
};
class GDNativeLibraryResourceLoader : public ResourceFormatLoader {
- GDCLASS(GDNativeLibraryResourceLoader, ResourceFormatLoader)
public:
virtual RES load(const String &p_path, const String &p_original_path, Error *r_error);
virtual void get_recognized_extensions(List<String> *p_extensions) const;
@@ -174,7 +173,6 @@ public:
};
class GDNativeLibraryResourceSaver : public ResourceFormatSaver {
- GDCLASS(GDNativeLibraryResourceSaver, ResourceFormatSaver)
public:
virtual Error save(const String &p_path, const RES &p_resource, uint32_t p_flags);
virtual bool recognize(const RES &p_resource) const;
diff --git a/modules/gdnative/gdnative/array.cpp b/modules/gdnative/gdnative/array.cpp
index 6849ff03d7..1ef8e9f900 100644
--- a/modules/gdnative/gdnative/array.cpp
+++ b/modules/gdnative/gdnative/array.cpp
@@ -305,13 +305,13 @@ void GDAPI godot_array_sort_custom(godot_array *p_self, godot_object *p_obj, con
godot_int GDAPI godot_array_bsearch(godot_array *p_self, const godot_variant *p_value, const godot_bool p_before) {
Array *self = (Array *)p_self;
- return self->bsearch((const Variant *)p_value, p_before);
+ return self->bsearch(*(const Variant *)p_value, p_before);
}
godot_int GDAPI godot_array_bsearch_custom(godot_array *p_self, const godot_variant *p_value, godot_object *p_obj, const godot_string *p_func, const godot_bool p_before) {
Array *self = (Array *)p_self;
const String *func = (const String *)p_func;
- return self->bsearch_custom((const Variant *)p_value, (Object *)p_obj, *func, p_before);
+ return self->bsearch_custom(*(const Variant *)p_value, (Object *)p_obj, *func, p_before);
}
void GDAPI godot_array_destroy(godot_array *p_self) {
diff --git a/modules/gdnative/gdnative_api.json b/modules/gdnative/gdnative_api.json
index 52c989037e..6c12ee6534 100644
--- a/modules/gdnative/gdnative_api.json
+++ b/modules/gdnative/gdnative_api.json
@@ -6304,7 +6304,7 @@
"type": "ANDROID",
"version": {
"major": 1,
- "minor": 0
+ "minor": 1
},
"next": null,
"api": [
@@ -6319,6 +6319,18 @@
"return_type": "jobject",
"arguments": [
]
+ },
+ {
+ "name": "godot_android_get_surface",
+ "return_type": "jobject",
+ "arguments": [
+ ]
+ },
+ {
+ "name": "godot_android_is_activity_resumed",
+ "return_type": "bool",
+ "arguments": [
+ ]
}
]
},
diff --git a/modules/gdnative/icons/icon_g_d_native_library.svg b/modules/gdnative/icons/icon_g_d_native_library.svg
new file mode 100644
index 0000000000..b494c7af6e
--- /dev/null
+++ b/modules/gdnative/icons/icon_g_d_native_library.svg
@@ -0,0 +1,5 @@
+<svg width="16" height="16" version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
+<g transform="translate(0 -1036.4)">
+<path transform="translate(0 1036.4)" d="m7 1l-0.56445 2.2578a5 5 0 0 0 -0.68945 0.2793l-1.9883-1.1934-1.4141 1.4141 1.1953 1.9941a5 5 0 0 0 -0.28516 0.68555l-2.2539 0.5625v2l2.2578 0.56445a5 5 0 0 0 0.2793 0.6875l-1.1934 1.9902 1.4141 1.4141 1.9941-1.1953a5 5 0 0 0 0.68555 0.28516l0.5625 2.2539v-5.2695a2 2 0 0 1 -1 -1.7305 2 2 0 0 1 1 -1.7285v-0.27148h1 4.5762a5 5 0 0 0 -0.11328 -0.25195l1.1934-1.9902-1.4141-1.4141-1.9941 1.1953a5 5 0 0 0 -0.68555 -0.28516l-0.5625-2.2539h-2zm2 7v1 5 1h5c0.55228 0 1-0.4477 1-1v-5c0-0.5523-0.44772-1-1-1v4l-1-1-1 1v-4h-3z" fill="#e0e0e0"/>
+</g>
+</svg>
diff --git a/modules/gdnative/icons/icon_native_script.svg b/modules/gdnative/icons/icon_native_script.svg
new file mode 100644
index 0000000000..fb9e135627
--- /dev/null
+++ b/modules/gdnative/icons/icon_native_script.svg
@@ -0,0 +1,5 @@
+<svg width="16" height="16" version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
+<g transform="translate(0 -1036.4)">
+<path transform="translate(0 1036.4)" d="m7 1l-0.56445 2.2578a5 5 0 0 0 -0.68945 0.2793l-1.9883-1.1934-1.4141 1.4141 1.1953 1.9941a5 5 0 0 0 -0.28516 0.68555l-2.2539 0.5625h3v1 1h2v-0.95117a2 2 0 0 1 0 -0.048828 2 2 0 0 1 2 -2 2 2 0 0 1 2 2v1h5v-2l-2.2578-0.56445a5 5 0 0 0 -0.2793 -0.6875l1.1934-1.9902-1.4141-1.4141-1.9941 1.1953a5 5 0 0 0 -0.68555 -0.28516l-0.5625-2.2539h-2zm-6 7v4 4h2a3 3 0 0 0 3 -3 3 3 0 0 0 -3 -3v-2h-2zm6 0v2h2v-2h-2zm3 2v6h2v-4a1 1 0 0 1 1 1v3h2v-3a3 3 0 0 0 -3 -3h-2zm-7 2a1 1 0 0 1 1 1 1 1 0 0 1 -1 1v-2zm4 0v4h2v-4h-2z" fill="#e0e0e0"/>
+</g>
+</svg>
diff --git a/modules/gdnative/include/android/godot_android.h b/modules/gdnative/include/android/godot_android.h
index 32e86838be..7063e1d2c5 100644
--- a/modules/gdnative/include/android/godot_android.h
+++ b/modules/gdnative/include/android/godot_android.h
@@ -46,6 +46,8 @@ extern "C" {
JNIEnv *GDAPI godot_android_get_env();
jobject GDAPI godot_android_get_activity();
+jobject GDAPI godot_android_get_surface();
+bool GDAPI godot_android_is_activity_resumed();
#ifdef __cplusplus
}
diff --git a/modules/gdnative/include/arvr/godot_arvr.h b/modules/gdnative/include/arvr/godot_arvr.h
index 657090fa70..d465bbde54 100644
--- a/modules/gdnative/include/arvr/godot_arvr.h
+++ b/modules/gdnative/include/arvr/godot_arvr.h
@@ -64,6 +64,7 @@ typedef struct {
// only in 1.1 onwards
godot_int (*get_external_texture_for_eye)(void *, godot_int);
void (*notification)(void *, godot_int);
+ godot_int (*get_camera_feed_id)(void *);
} godot_arvr_interface_gdnative;
void GDAPI godot_arvr_register_interface(const godot_arvr_interface_gdnative *p_interface);
diff --git a/modules/gdnative/include/gdnative/gdnative.h b/modules/gdnative/include/gdnative/gdnative.h
index 3c457bf5a7..884bcf60d2 100644
--- a/modules/gdnative/include/gdnative/gdnative.h
+++ b/modules/gdnative/include/gdnative/gdnative.h
@@ -67,7 +67,7 @@ extern "C" {
////// Error
typedef enum {
- GODOT_OK,
+ GODOT_OK, // (0)
GODOT_FAILED, ///< Generic fail error
GODOT_ERR_UNAVAILABLE, ///< What is requested is unsupported/unavailable
GODOT_ERR_UNCONFIGURED, ///< The object being used hasn't been properly set up yet
@@ -97,12 +97,12 @@ typedef enum {
GODOT_ERR_CONNECTION_ERROR,
GODOT_ERR_CANT_ACQUIRE_RESOURCE,
GODOT_ERR_CANT_FORK,
- GODOT_ERR_INVALID_DATA, ///< Data passed is invalid (30)
+ GODOT_ERR_INVALID_DATA, ///< Data passed is invalid (30)
GODOT_ERR_INVALID_PARAMETER, ///< Parameter passed is invalid
GODOT_ERR_ALREADY_EXISTS, ///< When adding, item already exists
GODOT_ERR_DOES_NOT_EXIST, ///< When retrieving/erasing, it item does not exist
GODOT_ERR_DATABASE_CANT_READ, ///< database is full
- GODOT_ERR_DATABASE_CANT_WRITE, ///< database is full (35)
+ GODOT_ERR_DATABASE_CANT_WRITE, ///< database is full (35)
GODOT_ERR_COMPILATION_FAILED,
GODOT_ERR_METHOD_NOT_FOUND,
GODOT_ERR_LINK_FAILED,
diff --git a/modules/gdnative/nativescript/nativescript.h b/modules/gdnative/nativescript/nativescript.h
index be1c499714..79a41df107 100644
--- a/modules/gdnative/nativescript/nativescript.h
+++ b/modules/gdnative/nativescript/nativescript.h
@@ -99,7 +99,7 @@ struct NativeScriptDesc {
};
class NativeScript : public Script {
- GDCLASS(NativeScript, Script)
+ GDCLASS(NativeScript, Script);
#ifdef TOOLS_ENABLED
Set<PlaceHolderScriptInstance *> placeholders;
@@ -370,7 +370,7 @@ inline NativeScriptDesc *NativeScript::get_script_desc() const {
}
class NativeReloadNode : public Node {
- GDCLASS(NativeReloadNode, Node)
+ GDCLASS(NativeReloadNode, Node);
bool unloaded;
public:
@@ -382,7 +382,6 @@ public:
};
class ResourceFormatLoaderNativeScript : public ResourceFormatLoader {
- GDCLASS(ResourceFormatLoaderNativeScript, ResourceFormatLoader)
public:
virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL);
virtual void get_recognized_extensions(List<String> *p_extensions) const;
@@ -391,7 +390,6 @@ public:
};
class ResourceFormatSaverNativeScript : public ResourceFormatSaver {
- GDCLASS(ResourceFormatSaverNativeScript, ResourceFormatSaver)
virtual Error save(const String &p_path, const RES &p_resource, uint32_t p_flags = 0);
virtual bool recognize(const RES &p_resource) const;
virtual void get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const;
diff --git a/modules/gdnative/net/multiplayer_peer_gdnative.cpp b/modules/gdnative/net/multiplayer_peer_gdnative.cpp
index bdeba149d2..d2c95efa77 100644
--- a/modules/gdnative/net/multiplayer_peer_gdnative.cpp
+++ b/modules/gdnative/net/multiplayer_peer_gdnative.cpp
@@ -113,6 +113,8 @@ NetworkedMultiplayerPeer::ConnectionStatus MultiplayerPeerGDNative::get_connecti
}
void MultiplayerPeerGDNative::_bind_methods() {
+ ADD_PROPERTY_DEFAULT("transfer_mode", TRANSFER_MODE_UNRELIABLE);
+ ADD_PROPERTY_DEFAULT("refuse_new_connections", true);
}
extern "C" {
diff --git a/modules/gdnative/net/multiplayer_peer_gdnative.h b/modules/gdnative/net/multiplayer_peer_gdnative.h
index 7d48dc60d1..6fbc62aaa1 100644
--- a/modules/gdnative/net/multiplayer_peer_gdnative.h
+++ b/modules/gdnative/net/multiplayer_peer_gdnative.h
@@ -36,7 +36,7 @@
#include "modules/gdnative/include/net/godot_net.h"
class MultiplayerPeerGDNative : public NetworkedMultiplayerPeer {
- GDCLASS(MultiplayerPeerGDNative, NetworkedMultiplayerPeer)
+ GDCLASS(MultiplayerPeerGDNative, NetworkedMultiplayerPeer);
protected:
static void _bind_methods();
diff --git a/modules/gdnative/net/packet_peer_gdnative.h b/modules/gdnative/net/packet_peer_gdnative.h
index 742fa4e7d5..8483217210 100644
--- a/modules/gdnative/net/packet_peer_gdnative.h
+++ b/modules/gdnative/net/packet_peer_gdnative.h
@@ -36,7 +36,7 @@
#include "modules/gdnative/include/net/godot_net.h"
class PacketPeerGDNative : public PacketPeer {
- GDCLASS(PacketPeerGDNative, PacketPeer)
+ GDCLASS(PacketPeerGDNative, PacketPeer);
protected:
static void _bind_methods();
diff --git a/modules/gdnative/pluginscript/pluginscript_language.cpp b/modules/gdnative/pluginscript/pluginscript_language.cpp
index 7cb47ec623..4bbadc62e7 100644
--- a/modules/gdnative/pluginscript/pluginscript_language.cpp
+++ b/modules/gdnative/pluginscript/pluginscript_language.cpp
@@ -216,7 +216,7 @@ void PluginScriptLanguage::get_public_constants(List<Pair<String, Variant> > *p_
Dictionary constants;
_desc.get_public_constants(_data, (godot_dictionary *)&constants);
for (const Variant *key = constants.next(); key; key = constants.next(key)) {
- Variant value = constants[key];
+ Variant value = constants[*key];
p_constants->push_back(Pair<String, Variant>(*key, value));
}
}
diff --git a/modules/gdnative/pluginscript/pluginscript_loader.h b/modules/gdnative/pluginscript/pluginscript_loader.h
index 69a2ac6bfe..6218037a15 100644
--- a/modules/gdnative/pluginscript/pluginscript_loader.h
+++ b/modules/gdnative/pluginscript/pluginscript_loader.h
@@ -40,8 +40,6 @@ class PluginScriptLanguage;
class ResourceFormatLoaderPluginScript : public ResourceFormatLoader {
- GDCLASS(ResourceFormatLoaderPluginScript, ResourceFormatLoader)
-
PluginScriptLanguage *_language;
public:
@@ -54,8 +52,6 @@ public:
class ResourceFormatSaverPluginScript : public ResourceFormatSaver {
- GDCLASS(ResourceFormatSaverPluginScript, ResourceFormatSaver)
-
PluginScriptLanguage *_language;
public:
diff --git a/modules/gdnative/pluginscript/pluginscript_script.cpp b/modules/gdnative/pluginscript/pluginscript_script.cpp
index 8dbbd2e4eb..3ecb29404a 100644
--- a/modules/gdnative/pluginscript/pluginscript_script.cpp
+++ b/modules/gdnative/pluginscript/pluginscript_script.cpp
@@ -39,12 +39,12 @@
#define ASSERT_SCRIPT_VALID() \
{ \
ERR_EXPLAIN(__ASSERT_SCRIPT_REASON); \
- ERR_FAIL_COND(!can_instance()) \
+ ERR_FAIL_COND(!can_instance()); \
}
-#define ASSERT_SCRIPT_VALID_V(ret) \
- { \
- ERR_EXPLAIN(__ASSERT_SCRIPT_REASON); \
- ERR_FAIL_COND_V(!can_instance(), ret) \
+#define ASSERT_SCRIPT_VALID_V(ret) \
+ { \
+ ERR_EXPLAIN(__ASSERT_SCRIPT_REASON); \
+ ERR_FAIL_COND_V(!can_instance(), ret); \
}
#else
#define ASSERT_SCRIPT_VALID()
@@ -77,7 +77,7 @@ PluginScriptInstance *PluginScript::_create_instance(const Variant **p_args, int
// There is currently no way to get the constructor function name of the script.
// instance->call("__init__", p_args, p_argcount, r_error);
if (p_argcount > 0) {
- WARN_PRINT("PluginScript doesn't support arguments in the constructor")
+ WARN_PRINT("PluginScript doesn't support arguments in the constructor");
}
return instance;
@@ -229,6 +229,8 @@ void PluginScript::set_source_code(const String &p_code) {
}
Error PluginScript::reload(bool p_keep_state) {
+ ERR_FAIL_COND_V(!_language, ERR_UNCONFIGURED);
+
_language->lock();
ERR_FAIL_COND_V(!p_keep_state && _instances.size(), ERR_ALREADY_IN_USE);
_language->unlock();
@@ -284,7 +286,7 @@ Error PluginScript::reload(bool p_keep_state) {
Dictionary *members = (Dictionary *)&manifest.member_lines;
for (const Variant *key = members->next(); key != NULL; key = members->next(key)) {
- _member_lines[*key] = (*members)[key];
+ _member_lines[*key] = (*members)[*key];
}
Array *methods = (Array *)&manifest.methods;
for (int i = 0; i < methods->size(); ++i) {
@@ -473,6 +475,8 @@ MultiplayerAPI::RPCMode PluginScript::get_rset_mode(const StringName &p_variable
PluginScript::PluginScript() :
_data(NULL),
+ _desc(NULL),
+ _language(NULL),
_tool(false),
_valid(false),
_script_list(this) {
@@ -490,11 +494,15 @@ void PluginScript::init(PluginScriptLanguage *language) {
}
PluginScript::~PluginScript() {
- _desc->finish(_data);
+ if (_desc && _data) {
+ _desc->finish(_data);
+ }
#ifdef DEBUG_ENABLED
- _language->lock();
- _language->_script_list.remove(&_script_list);
- _language->unlock();
+ if (_language) {
+ _language->lock();
+ _language->_script_list.remove(&_script_list);
+ _language->unlock();
+ }
#endif
}
diff --git a/modules/gdnative/videodecoder/video_stream_gdnative.h b/modules/gdnative/videodecoder/video_stream_gdnative.h
index aafd02f33d..b9f1c8e4da 100644
--- a/modules/gdnative/videodecoder/video_stream_gdnative.h
+++ b/modules/gdnative/videodecoder/video_stream_gdnative.h
@@ -197,7 +197,6 @@ public:
};
class ResourceFormatLoaderVideoStreamGDNative : public ResourceFormatLoader {
- GDCLASS(ResourceFormatLoaderVideoStreamGDNative, ResourceFormatLoader)
public:
virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL);
virtual void get_recognized_extensions(List<String> *p_extensions) const;
diff --git a/modules/gdscript/config.py b/modules/gdscript/config.py
index 95b40d90af..a525eedaaa 100644
--- a/modules/gdscript/config.py
+++ b/modules/gdscript/config.py
@@ -6,6 +6,7 @@ def configure(env):
def get_doc_classes():
return [
+ "@GDScript",
"GDScript",
"GDScriptFunctionState",
"GDScriptNativeClass",
diff --git a/modules/gdscript/doc_classes/@GDScript.xml b/modules/gdscript/doc_classes/@GDScript.xml
new file mode 100644
index 0000000000..3870a5ea7d
--- /dev/null
+++ b/modules/gdscript/doc_classes/@GDScript.xml
@@ -0,0 +1,1314 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<class name="@GDScript" category="Core" version="3.2">
+ <brief_description>
+ Built-in GDScript functions.
+ </brief_description>
+ <description>
+ List of core built-in GDScript functions. Math functions and other utilities. Everything else is provided by objects. (Keywords: builtin, built in, global functions.)
+ </description>
+ <tutorials>
+ </tutorials>
+ <methods>
+ <method name="Color8">
+ <return type="Color">
+ </return>
+ <argument index="0" name="r8" type="int">
+ </argument>
+ <argument index="1" name="g8" type="int">
+ </argument>
+ <argument index="2" name="b8" type="int">
+ </argument>
+ <argument index="3" name="a8" type="int" default="255">
+ </argument>
+ <description>
+ Returns a 32 bit color with red, green, blue and alpha channels. Each channel has 8 bits of information ranging from 0 to 255.
+ [code]r8[/code] red channel
+ [code]g8[/code] green channel
+ [code]b8[/code] blue channel
+ [code]a8[/code] alpha channel
+ [codeblock]
+ red = Color8(255, 0, 0)
+ [/codeblock]
+ </description>
+ </method>
+ <method name="ColorN">
+ <return type="Color">
+ </return>
+ <argument index="0" name="name" type="String">
+ </argument>
+ <argument index="1" name="alpha" type="float" default="1.0">
+ </argument>
+ <description>
+ Returns a color according to the standardised [code]name[/code] with [code]alpha[/code] ranging from 0 to 1.
+ [codeblock]
+ red = ColorN("red", 1)
+ [/codeblock]
+ Supported color names:
+ "aliceblue", "antiquewhite", "aqua", "aquamarine", "azure", "beige", "bisque", "black", "blanchedalmond", "blue", "blueviolet", "brown", "burlywood", "cadetblue", "chartreuse", "chocolate", "coral", "cornflower", "cornsilk", "crimson", "cyan", "darkblue", "darkcyan", "darkgoldenrod", "darkgray", "darkgreen", "darkkhaki", "darkmagenta", "darkolivegreen", "darkorange", "darkorchid", "darkred", "darksalmon", "darkseagreen", "darkslateblue", "darkslategray", "darkturquoise", "darkviolet", "deeppink", "deepskyblue", "dimgray", "dodgerblue", "firebrick", "floralwhite", "forestgreen", "fuchsia", "gainsboro", "ghostwhite", "gold", "goldenrod", "gray", "webgray", "green", "webgreen", "greenyellow", "honeydew", "hotpink", "indianred", "indigo", "ivory", "khaki", "lavender", "lavenderblush", "lawngreen", "lemonchiffon", "lightblue", "lightcoral", "lightcyan", "lightgoldenrod", "lightgray", "lightgreen", "lightpink", "lightsalmon", "lightseagreen", "lightskyblue", "lightslategray", "lightsteelblue", "lightyellow", "lime", "limegreen", "linen", "magenta", "maroon", "webmaroon", "mediumaquamarine", "mediumblue", "mediumorchid", "mediumpurple", "mediumseagreen", "mediumslateblue", "mediumspringgreen", "mediumturquoise", "mediumvioletred", "midnightblue", "mintcream", "mistyrose", "moccasin", "navajowhite", "navyblue", "oldlace", "olive", "olivedrab", "orange", "orangered", "orchid", "palegoldenrod", "palegreen", "paleturquoise", "palevioletred", "papayawhip", "peachpuff", "peru", "pink", "plum", "powderblue", "purple", "webpurple", "rebeccapurple", "red", "rosybrown", "royalblue", "saddlebrown", "salmon", "sandybrown", "seagreen", "seashell", "sienna", "silver", "skyblue", "slateblue", "slategray", "snow", "springgreen", "steelblue", "tan", "teal", "thistle", "tomato", "turquoise", "violet", "wheat", "white", "whitesmoke", "yellow", "yellowgreen".
+ </description>
+ </method>
+ <method name="abs">
+ <return type="float">
+ </return>
+ <argument index="0" name="s" type="float">
+ </argument>
+ <description>
+ Returns the absolute value of parameter [code]s[/code] (i.e. unsigned value, works for integer and float).
+ [codeblock]
+ # a is 1
+ a = abs(-1)
+ [/codeblock]
+ </description>
+ </method>
+ <method name="acos">
+ <return type="float">
+ </return>
+ <argument index="0" name="s" type="float">
+ </argument>
+ <description>
+ Returns the arc cosine of [code]s[/code] in radians. Use to get the angle of cosine [code]s[/code].
+ [codeblock]
+ # c is 0.523599 or 30 degrees if converted with rad2deg(s)
+ c = acos(0.866025)
+ [/codeblock]
+ </description>
+ </method>
+ <method name="asin">
+ <return type="float">
+ </return>
+ <argument index="0" name="s" type="float">
+ </argument>
+ <description>
+ Returns the arc sine of [code]s[/code] in radians. Use to get the angle of sine [code]s[/code].
+ [codeblock]
+ # s is 0.523599 or 30 degrees if converted with rad2deg(s)
+ s = asin(0.5)
+ [/codeblock]
+ </description>
+ </method>
+ <method name="assert">
+ <return type="void">
+ </return>
+ <argument index="0" name="condition" type="bool">
+ </argument>
+ <description>
+ Asserts that the [code]condition[/code] is [code]true[/code] . If the [code]condition[/code] is [code]false[/code], an error is generated and the program is halted until you resume it. Only executes in debug builds, or when running the game from the editor. Use it for debugging purposes, to make sure a statement is [code]true[/code] during development.
+ [codeblock]
+ # Imagine we always want speed to be between 0 and 20
+ speed = -10
+ assert(speed &lt; 20) # True, the program will continue
+ assert(speed &gt;= 0) # False, the program will stop
+ assert(speed &gt;= 0 &amp;&amp; speed &lt; 20) # You can also combine the two conditional statements in one check
+ [/codeblock]
+ </description>
+ </method>
+ <method name="atan">
+ <return type="float">
+ </return>
+ <argument index="0" name="s" type="float">
+ </argument>
+ <description>
+ Returns the arc tangent of [code]s[/code] in radians. Use it to get the angle from an angle's tangent in trigonometry: [code]atan(tan(angle)) == angle[/code].
+ The method cannot know in which quadrant the angle should fall. See [method atan2] if you always want an exact angle.
+ [codeblock]
+ a = atan(0.5) # a is 0.463648
+ [/codeblock]
+ </description>
+ </method>
+ <method name="atan2">
+ <return type="float">
+ </return>
+ <argument index="0" name="y" type="float">
+ </argument>
+ <argument index="1" name="x" type="float">
+ </argument>
+ <description>
+ Returns the arc tangent of [code]y/x[/code] in radians. Use to get the angle of tangent [code]y/x[/code]. To compute the value, the method takes into account the sign of both arguments in order to determine the quadrant.
+ [codeblock]
+ a = atan2(0, -1) # a is 3.141593
+ [/codeblock]
+ </description>
+ </method>
+ <method name="bytes2var">
+ <return type="Variant">
+ </return>
+ <argument index="0" name="bytes" type="PoolByteArray">
+ </argument>
+ <argument index="1" name="allow_objects" type="bool" default="false">
+ </argument>
+ <description>
+ Decodes a byte array back to a value. When [code]allow_objects[/code] is [code]true[/code] decoding objects is allowed.
+ [b]WARNING:[/b] Deserialized object can contain code which gets executed. Do not use this option if the serialized object comes from untrusted sources to avoid potential security threats (remote code execution).
+ </description>
+ </method>
+ <method name="cartesian2polar">
+ <return type="Vector2">
+ </return>
+ <argument index="0" name="x" type="float">
+ </argument>
+ <argument index="1" name="y" type="float">
+ </argument>
+ <description>
+ Converts a 2D point expressed in the cartesian coordinate system (X and Y axis) to the polar coordinate system (a distance from the origin and an angle).
+ </description>
+ </method>
+ <method name="ceil">
+ <return type="float">
+ </return>
+ <argument index="0" name="s" type="float">
+ </argument>
+ <description>
+ Rounds [code]s[/code] upward, returning the smallest integral value that is not less than [code]s[/code].
+ [codeblock]
+ i = ceil(1.45) # i is 2
+ i = ceil(1.001) # i is 2
+ [/codeblock]
+ </description>
+ </method>
+ <method name="char">
+ <return type="String">
+ </return>
+ <argument index="0" name="ascii" type="int">
+ </argument>
+ <description>
+ Returns a character as a String of the given ASCII code.
+ [codeblock]
+ a = char(65) # a is "A"
+ a = char(65 + 32) # a is "a"
+ [/codeblock]
+ </description>
+ </method>
+ <method name="clamp">
+ <return type="float">
+ </return>
+ <argument index="0" name="value" type="float">
+ </argument>
+ <argument index="1" name="min" type="float">
+ </argument>
+ <argument index="2" name="max" type="float">
+ </argument>
+ <description>
+ Clamps [code]value[/code] and returns a value not less than [code]min[/code] and not more than [code]max[/code].
+ [codeblock]
+ speed = 1000
+ # a is 20
+ a = clamp(speed, 1, 20)
+
+ speed = -10
+ # a is 1
+ a = clamp(speed, 1, 20)
+ [/codeblock]
+ </description>
+ </method>
+ <method name="convert">
+ <return type="Variant">
+ </return>
+ <argument index="0" name="what" type="Variant">
+ </argument>
+ <argument index="1" name="type" type="int">
+ </argument>
+ <description>
+ Converts from a type to another in the best way possible. The [code]type[/code] parameter uses the enum [code]TYPE_*[/code] in [@GlobalScope].
+ [codeblock]
+ a = Vector2(1, 0)
+ # Prints 1
+ print(a.length())
+ a = convert(a, TYPE_STRING)
+ # Prints 6 as "(1, 0)" is 6 characters
+ print(a.length())
+ [/codeblock]
+ </description>
+ </method>
+ <method name="cos">
+ <return type="float">
+ </return>
+ <argument index="0" name="s" type="float">
+ </argument>
+ <description>
+ Returns the cosine of angle [code]s[/code] in radians.
+ [codeblock]
+ # Prints 1 then -1
+ print(cos(PI * 2))
+ print(cos(PI))
+ [/codeblock]
+ </description>
+ </method>
+ <method name="cosh">
+ <return type="float">
+ </return>
+ <argument index="0" name="s" type="float">
+ </argument>
+ <description>
+ Returns the hyperbolic cosine of [code]s[/code] in radians.
+ [codeblock]
+ # Prints 1.543081
+ print(cosh(1))
+ [/codeblock]
+ </description>
+ </method>
+ <method name="db2linear">
+ <return type="float">
+ </return>
+ <argument index="0" name="db" type="float">
+ </argument>
+ <description>
+ 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>
+ <argument index="0" name="value" type="float">
+ </argument>
+ <argument index="1" name="amount" type="float">
+ </argument>
+ <argument index="2" name="step" type="float">
+ </argument>
+ <description>
+ Returns the result of [code]value[/code] decreased by [code]step[/code] * [code]amount[/code].
+ [codeblock]
+ # a = 59
+ a = dectime(60, 10, 0.1))
+ [/codeblock]
+ </description>
+ </method>
+ <method name="deg2rad">
+ <return type="float">
+ </return>
+ <argument index="0" name="deg" type="float">
+ </argument>
+ <description>
+ Returns degrees converted to radians.
+ [codeblock]
+ # r is 3.141593
+ r = deg2rad(180)
+ [/codeblock]
+ </description>
+ </method>
+ <method name="dict2inst">
+ <return type="Object">
+ </return>
+ <argument index="0" name="dict" type="Dictionary">
+ </argument>
+ <description>
+ Converts a previously converted instance to a dictionary, back into an instance. Useful for deserializing.
+ </description>
+ </method>
+ <method name="ease">
+ <return type="float">
+ </return>
+ <argument index="0" name="s" type="float">
+ </argument>
+ <argument index="1" name="curve" type="float">
+ </argument>
+ <description>
+ 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.
+ </description>
+ </method>
+ <method name="exp">
+ <return type="float">
+ </return>
+ <argument index="0" name="s" type="float">
+ </argument>
+ <description>
+ The natural exponential function. It raises the mathematical constant [b]e[/b] to the power of [code]s[/code] and returns it.
+ [b]e[/b] has an approximate value of 2.71828.
+ [codeblock]
+ a = exp(2) # Approximately 7.39
+ [/codeblock]
+ </description>
+ </method>
+ <method name="floor">
+ <return type="float">
+ </return>
+ <argument index="0" name="s" type="float">
+ </argument>
+ <description>
+ Rounds [code]s[/code] to the closest smaller integer and returns it.
+ [codeblock]
+ # a is 2
+ a = floor(2.99)
+ # a is -3
+ a = floor(-2.99)
+ [/codeblock]
+ </description>
+ </method>
+ <method name="fmod">
+ <return type="float">
+ </return>
+ <argument index="0" name="x" type="float">
+ </argument>
+ <argument index="1" name="y" type="float">
+ </argument>
+ <description>
+ Returns the floating-point remainder of [code]x/y[/code].
+ [codeblock]
+ # Remainder is 1.5
+ var remainder = fmod(7, 5.5)
+ [/codeblock]
+ </description>
+ </method>
+ <method name="fposmod">
+ <return type="float">
+ </return>
+ <argument index="0" name="x" type="float">
+ </argument>
+ <argument index="1" name="y" type="float">
+ </argument>
+ <description>
+ Returns the floating-point remainder of [code]x/y[/code] that wraps equally in positive and negative.
+ [codeblock]
+ var i = -10
+ while i &lt; 0:
+ prints(i, fposmod(i, 10))
+ i += 1
+ [/codeblock]
+ Produces:
+ [codeblock]
+ -10 10
+ -9 1
+ -8 2
+ -7 3
+ -6 4
+ -5 5
+ -4 6
+ -3 7
+ -2 8
+ -1 9
+ [/codeblock]
+ </description>
+ </method>
+ <method name="funcref">
+ <return type="FuncRef">
+ </return>
+ <argument index="0" name="instance" type="Object">
+ </argument>
+ <argument index="1" name="funcname" type="String">
+ </argument>
+ <description>
+ Returns a reference to the specified function [code]funcname[/code] in the [code]instance[/code] node. As functions aren't first-class objects in GDscript, use [code]funcref[/code] to store a [FuncRef] in a variable and call it later.
+ [codeblock]
+ func foo():
+ return("bar")
+
+ a = funcref(self, "foo")
+ print(a.call_func()) # Prints bar
+ [/codeblock]
+ </description>
+ </method>
+ <method name="get_stack">
+ <return type="Array">
+ </return>
+ <description>
+ Returns an array of dictionaries representing the current call stack.
+ [codeblock]
+ func _ready():
+ foo()
+
+ func foo():
+ bar()
+
+ func bar():
+ print(get_stack())
+ [/codeblock]
+ would print
+ [codeblock]
+ [{function:bar, line:12, source:res://script.gd}, {function:foo, line:9, source:res://script.gd}, {function:_ready, line:6, source:res://script.gd}]
+ [/codeblock]
+ </description>
+ </method>
+ <method name="hash">
+ <return type="int">
+ </return>
+ <argument index="0" name="var" type="Variant">
+ </argument>
+ <description>
+ Returns the integer hash of the variable passed.
+ [codeblock]
+ print(hash("a")) # Prints 177670
+ [/codeblock]
+ </description>
+ </method>
+ <method name="inst2dict">
+ <return type="Dictionary">
+ </return>
+ <argument index="0" name="inst" type="Object">
+ </argument>
+ <description>
+ Returns the passed instance converted to a dictionary (useful for serializing).
+ [codeblock]
+ var foo = "bar"
+ func _ready():
+ var d = inst2dict(self)
+ print(d.keys())
+ print(d.values())
+ [/codeblock]
+ Prints out:
+ [codeblock]
+ [@subpath, @path, foo]
+ [, res://test.gd, bar]
+ [/codeblock]
+ </description>
+ </method>
+ <method name="instance_from_id">
+ <return type="Object">
+ </return>
+ <argument index="0" name="instance_id" type="int">
+ </argument>
+ <description>
+ Returns the Object that corresponds to [code]instance_id[/code]. All Objects have a unique instance ID.
+ [codeblock]
+ var foo = "bar"
+ func _ready():
+ var id = get_instance_id()
+ var inst = instance_from_id(id)
+ print(inst.foo) # Prints bar
+ [/codeblock]
+ </description>
+ </method>
+ <method name="inverse_lerp">
+ <return type="float">
+ </return>
+ <argument index="0" name="from" type="float">
+ </argument>
+ <argument index="1" name="to" type="float">
+ </argument>
+ <argument index="2" name="weight" type="float">
+ </argument>
+ <description>
+ Returns a normalized value considering the given range.
+ [codeblock]
+ inverse_lerp(3, 5, 4) # Returns 0.5
+ [/codeblock]
+ </description>
+ </method>
+ <method name="is_equal_approx">
+ <return type="bool">
+ </return>
+ <argument index="0" name="a" type="float">
+ </argument>
+ <argument index="1" name="b" type="float">
+ </argument>
+ <description>
+ Returns True/False whether [code]a[/code] and [code]b[/code] are approximately equal to each other.
+ </description>
+ </method>
+ <method name="is_inf">
+ <return type="bool">
+ </return>
+ <argument index="0" name="s" type="float">
+ </argument>
+ <description>
+ Returns whether [code]s[/code] is an infinity value (either positive infinity or negative infinity).
+ </description>
+ </method>
+ <method name="is_instance_valid">
+ <return type="bool">
+ </return>
+ <argument index="0" name="instance" type="Object">
+ </argument>
+ <description>
+ Returns whether [code]instance[/code] is a valid object (e.g. has not been deleted from memory).
+ </description>
+ </method>
+ <method name="is_nan">
+ <return type="bool">
+ </return>
+ <argument index="0" name="s" type="float">
+ </argument>
+ <description>
+ Returns whether [code]s[/code] is a NaN (Not-A-Number) value.
+ </description>
+ </method>
+ <method name="is_zero_approx">
+ <return type="bool">
+ </return>
+ <argument index="0" name="s" type="float">
+ </argument>
+ <description>
+ Returns True/False whether [code]s[/code] is zero or almost zero.
+ </description>
+ </method>
+ <method name="len">
+ <return type="int">
+ </return>
+ <argument index="0" name="var" type="Variant">
+ </argument>
+ <description>
+ Returns length of Variant [code]var[/code]. Length is the character count of String, element count of Array, size of Dictionary, etc.
+ [b]Note:[/b] Generates a fatal error if Variant can not provide a length.
+ [codeblock]
+ a = [1, 2, 3, 4]
+ len(a) # Returns 4
+ [/codeblock]
+ </description>
+ </method>
+ <method name="lerp">
+ <return type="Variant">
+ </return>
+ <argument index="0" name="from" type="Variant">
+ </argument>
+ <argument index="1" name="to" type="Variant">
+ </argument>
+ <argument index="2" name="weight" type="float">
+ </argument>
+ <description>
+ Linearly interpolates between two values by a normalized value.
+ If the [code]from[/code] and [code]to[/code] arguments are of type [int] or [float], the return value is a [float].
+ If both are of the same vector type ([Vector2], [Vector3] or [Color]), the return value will be of the same type ([code]lerp[/code] then calls the vector type's [code]linear_interpolate[/code] method).
+ [codeblock]
+ lerp(0, 4, 0.75) # Returns 3.0
+ lerp(Vector2(1, 5), Vector2(3, 2), 0.5) # Returns Vector2(2, 3.5)
+ [/codeblock]
+ </description>
+ </method>
+ <method name="linear2db">
+ <return type="float">
+ </return>
+ <argument index="0" name="nrg" type="float">
+ </argument>
+ <description>
+ Converts from linear energy to decibels (audio).
+ </description>
+ </method>
+ <method name="load">
+ <return type="Resource">
+ </return>
+ <argument index="0" name="path" type="String">
+ </argument>
+ <description>
+ Loads a resource from the filesystem located at [code]path[/code].
+ [b]Note:[/b] Resource paths can be obtained by right-clicking on a resource in the FileSystem dock and choosing [b]Copy Path[/b].
+ [codeblock]
+ # Load a scene called main located in the root of the project directory
+ var main = load("res://main.tscn")
+ [/codeblock]
+ </description>
+ </method>
+ <method name="log">
+ <return type="float">
+ </return>
+ <argument index="0" name="s" type="float">
+ </argument>
+ <description>
+ Natural logarithm. The amount of time needed to reach a certain level of continuous growth.
+ [b]Note:[/b] This is not the same as the "log" function on most calculators, which uses a base 10 logarithm.
+ [codeblock]
+ log(10) # Returns 2.302585
+ [/codeblock]
+ </description>
+ </method>
+ <method name="max">
+ <return type="float">
+ </return>
+ <argument index="0" name="a" type="float">
+ </argument>
+ <argument index="1" name="b" type="float">
+ </argument>
+ <description>
+ Returns the maximum of two values.
+ [codeblock]
+ max(1, 2) # Returns 2
+ max(-3.99, -4) # Returns -3.99
+ [/codeblock]
+ </description>
+ </method>
+ <method name="min">
+ <return type="float">
+ </return>
+ <argument index="0" name="a" type="float">
+ </argument>
+ <argument index="1" name="b" type="float">
+ </argument>
+ <description>
+ Returns the minimum of two values.
+ [codeblock]
+ min(1, 2) # Returns 1
+ min(-3.99, -4) # Returns -4
+ [/codeblock]
+ </description>
+ </method>
+ <method name="move_toward">
+ <return type="float">
+ </return>
+ <argument index="0" name="from" type="float">
+ </argument>
+ <argument index="1" name="to" type="float">
+ </argument>
+ <argument index="2" name="delta" type="float">
+ </argument>
+ <description>
+ Moves [code]from[/code] toward [code]to[/code] by the [code]delta[/code] value.
+ Use a negative [code]delta[/code] value to move away.
+ [codeblock]
+ move_toward(10, 5, 4) # Returns 6
+ [/codeblock]
+ </description>
+ </method>
+ <method name="nearest_po2">
+ <return type="int">
+ </return>
+ <argument index="0" name="value" type="int">
+ </argument>
+ <description>
+ Returns the nearest larger power of 2 for integer [code]value[/code].
+ [codeblock]
+ nearest_po2(3) # Returns 4
+ nearest_po2(4) # Returns 4
+ nearest_po2(5) # Returns 8
+ [/codeblock]
+ </description>
+ </method>
+ <method name="parse_json">
+ <return type="Variant">
+ </return>
+ <argument index="0" name="json" type="String">
+ </argument>
+ <description>
+ Parse JSON text to a Variant (use [method typeof] to check if it is what you expect).
+ Be aware that the JSON specification does not define integer or float types, but only a number type. Therefore, parsing a JSON text will convert all numerical values to [float] types.
+ Note that JSON objects do not preserve key order like Godot dictionaries, thus you should not rely on keys being in a certain order if a dictionary is constructed from JSON. In contrast, JSON arrays retain the order of their elements:
+ [codeblock]
+ p = parse_json('["a", "b", "c"]')
+ if typeof(p) == TYPE_ARRAY:
+ print(p[0]) # Prints a
+ else:
+ print("unexpected results")
+ [/codeblock]
+ </description>
+ </method>
+ <method name="polar2cartesian">
+ <return type="Vector2">
+ </return>
+ <argument index="0" name="r" type="float">
+ </argument>
+ <argument index="1" name="th" type="float">
+ </argument>
+ <description>
+ Converts a 2D point expressed in the polar coordinate system (a distance from the origin [code]r[/code] and an angle [code]th[/code]) to the cartesian coordinate system (X and Y axis).
+ </description>
+ </method>
+ <method name="pow">
+ <return type="float">
+ </return>
+ <argument index="0" name="x" type="float">
+ </argument>
+ <argument index="1" name="y" type="float">
+ </argument>
+ <description>
+ Returns the result of [code]x[/code] raised to the power of [code]y[/code].
+ [codeblock]
+ pow(2, 5) # Returns 32
+ [/codeblock]
+ </description>
+ </method>
+ <method name="preload">
+ <return type="Resource">
+ </return>
+ <argument index="0" name="path" type="String">
+ </argument>
+ <description>
+ Returns a resource from the filesystem that is loaded during script parsing.
+ [b]Note:[/b] Resource paths can be obtained by right clicking on a resource in the Assets Panel and choosing "Copy Path".
+ [codeblock]
+ # Load a scene called main located in the root of the project directory
+ var main = preload("res://main.tscn")
+ [/codeblock]
+ </description>
+ </method>
+ <method name="print" qualifiers="vararg">
+ <return type="void">
+ </return>
+ <description>
+ Converts one or more arguments to strings in the best way possible and prints them to the console.
+ [codeblock]
+ a = [1, 2, 3]
+ print("a", "b", a) # Prints ab[1, 2, 3]
+ [/codeblock]
+ </description>
+ </method>
+ <method name="print_debug" qualifiers="vararg">
+ <return type="void">
+ </return>
+ <description>
+ Like [method print], but prints only when used in debug mode.
+ </description>
+ </method>
+ <method name="print_stack">
+ <return type="void">
+ </return>
+ <description>
+ Prints a stack track at code location, only works when running with debugger turned on.
+ Output in the console would look something like this:
+ [codeblock]
+ Frame 0 - res://test.gd:16 in function '_process'
+ [/codeblock]
+ </description>
+ </method>
+ <method name="printerr" qualifiers="vararg">
+ <return type="void">
+ </return>
+ <description>
+ Prints one or more arguments to strings in the best way possible to standard error line.
+ [codeblock]
+ printerr("prints to stderr")
+ [/codeblock]
+ </description>
+ </method>
+ <method name="printraw" qualifiers="vararg">
+ <return type="void">
+ </return>
+ <description>
+ Prints one or more arguments to strings in the best way possible to console. No newline is added at the end.
+ [codeblock]
+ printraw("A")
+ printraw("B")
+ # Prints AB
+ [/codeblock]
+ </description>
+ </method>
+ <method name="prints" qualifiers="vararg">
+ <return type="void">
+ </return>
+ <description>
+ Prints one or more arguments to the console with a space between each argument.
+ [codeblock]
+ prints("A", "B", "C") # Prints A B C
+ [/codeblock]
+ </description>
+ </method>
+ <method name="printt" qualifiers="vararg">
+ <return type="void">
+ </return>
+ <description>
+ Prints one or more arguments to the console with a tab between each argument.
+ [codeblock]
+ printt("A", "B", "C") # Prints A B C
+ [/codeblock]
+ </description>
+ </method>
+ <method name="push_error">
+ <return type="void">
+ </return>
+ <argument index="0" name="message" type="String">
+ </argument>
+ <description>
+ Pushes an error message to Godot's built-in debugger and to the OS terminal.
+ [codeblock]
+ push_error("test error") # Prints "test error" to debugger and terminal as error call
+ [/codeblock]
+ </description>
+ </method>
+ <method name="push_warning">
+ <return type="void">
+ </return>
+ <argument index="0" name="message" type="String">
+ </argument>
+ <description>
+ Pushes a warning message to Godot's built-in debugger and to the OS terminal.
+ [codeblock]
+ push_warning("test warning") # Prints "test warning" to debugger and terminal as warning call
+ [/codeblock]
+ </description>
+ </method>
+ <method name="rad2deg">
+ <return type="float">
+ </return>
+ <argument index="0" name="rad" type="float">
+ </argument>
+ <description>
+ Converts from radians to degrees.
+ [codeblock]
+ rad2deg(0.523599) # Returns 30
+ [/codeblock]
+ </description>
+ </method>
+ <method name="rand_range">
+ <return type="float">
+ </return>
+ <argument index="0" name="from" type="float">
+ </argument>
+ <argument index="1" name="to" type="float">
+ </argument>
+ <description>
+ Random range, any floating point value between [code]from[/code] and [code]to[/code].
+ [codeblock]
+ prints(rand_range(0, 1), rand_range(0, 1)) # Prints e.g. 0.135591 0.405263
+ [/codeblock]
+ </description>
+ </method>
+ <method name="rand_seed">
+ <return type="Array">
+ </return>
+ <argument index="0" name="seed" type="int">
+ </argument>
+ <description>
+ Random from seed: pass a [code]seed[/code], and an array with both number and new seed is returned. "Seed" here refers to the internal state of the pseudo random number generator. The internal state of the current implementation is 64 bits.
+ </description>
+ </method>
+ <method name="randf">
+ <return type="float">
+ </return>
+ <description>
+ Returns a random floating point value on the interval [code][0, 1][/code].
+ [codeblock]
+ randf() # Returns e.g. 0.375671
+ [/codeblock]
+ </description>
+ </method>
+ <method name="randi">
+ <return type="int">
+ </return>
+ <description>
+ Returns a random unsigned 32 bit integer. Use remainder to obtain a random value in the interval [code][0, N][/code] (where N is smaller than 2^32 -1).
+ [codeblock]
+ randi() # Returns random integer between 0 and 2^32 - 1
+ randi() % 20 # Returns random integer between 0 and 19
+ randi() % 100 # Returns random integer between 0 and 99
+ randi() % 100 + 1 # Returns random integer between 1 and 100
+ [/codeblock]
+ </description>
+ </method>
+ <method name="randomize">
+ <return type="void">
+ </return>
+ <description>
+ Randomizes the seed (or the internal state) of the random number generator. Current implementation reseeds using a number based on time.
+ [codeblock]
+ func _ready():
+ randomize()
+ [/codeblock]
+ </description>
+ </method>
+ <method name="range" qualifiers="vararg">
+ <return type="Array">
+ </return>
+ <description>
+ Returns an array with the given range. Range can be 1 argument N (0 to N-1), two arguments (initial, final-1) or three arguments (initial, final-1, increment).
+ [codeblock]
+ for i in range(4):
+ print(i)
+ for i in range(2, 5):
+ print(i)
+ for i in range(0, 6, 2):
+ print(i)
+ [/codeblock]
+ Output:
+ [codeblock]
+ 0
+ 1
+ 2
+ 3
+
+ 2
+ 3
+ 4
+
+ 0
+ 2
+ 4
+ [/codeblock]
+ </description>
+ </method>
+ <method name="range_lerp">
+ <return type="float">
+ </return>
+ <argument index="0" name="value" type="float">
+ </argument>
+ <argument index="1" name="istart" type="float">
+ </argument>
+ <argument index="2" name="istop" type="float">
+ </argument>
+ <argument index="3" name="ostart" type="float">
+ </argument>
+ <argument index="4" name="ostop" type="float">
+ </argument>
+ <description>
+ Maps a [code]value[/code] from range [code][istart, istop][/code] to [code][ostart, ostop][/code].
+ [codeblock]
+ range_lerp(75, 0, 100, -1, 1) # Returns 0.5
+ [/codeblock]
+ </description>
+ </method>
+ <method name="round">
+ <return type="float">
+ </return>
+ <argument index="0" name="s" type="float">
+ </argument>
+ <description>
+ Returns the integral value that is nearest to [code]s[/code], with halfway cases rounded away from zero.
+ [codeblock]
+ round(2.6) # Returns 3
+ [/codeblock]
+ </description>
+ </method>
+ <method name="seed">
+ <return type="void">
+ </return>
+ <argument index="0" name="seed" type="int">
+ </argument>
+ <description>
+ Sets seed for the random number generator.
+ [codeblock]
+ my_seed = "Godot Rocks"
+ seed(my_seed.hash())
+ [/codeblock]
+ </description>
+ </method>
+ <method name="sign">
+ <return type="float">
+ </return>
+ <argument index="0" name="s" type="float">
+ </argument>
+ <description>
+ Returns the sign of [code]s[/code]: -1 or 1. Returns 0 if [code]s[/code] is 0.
+ [codeblock]
+ sign(-6) # Returns -1
+ sign(0) # Returns 0
+ sign(6) # Returns 1
+ [/codeblock]
+ </description>
+ </method>
+ <method name="sin">
+ <return type="float">
+ </return>
+ <argument index="0" name="s" type="float">
+ </argument>
+ <description>
+ Returns the sine of angle [code]s[/code] in radians.
+ [codeblock]
+ sin(0.523599) # Returns 0.5
+ [/codeblock]
+ </description>
+ </method>
+ <method name="sinh">
+ <return type="float">
+ </return>
+ <argument index="0" name="s" type="float">
+ </argument>
+ <description>
+ Returns the hyperbolic sine of [code]s[/code].
+ [codeblock]
+ a = log(2.0) # Returns 0.693147
+ sinh(a) # Returns 0.75
+ [/codeblock]
+ </description>
+ </method>
+ <method name="smoothstep">
+ <return type="float">
+ </return>
+ <argument index="0" name="from" type="float">
+ </argument>
+ <argument index="1" name="to" type="float">
+ </argument>
+ <argument index="2" name="weight" type="float">
+ </argument>
+ <description>
+ Returns a number smoothly interpolated between the [code]from[/code] and [code]to[/code], based on the [code]weight[/code]. Similar to [method lerp], but interpolates faster at the beginning and slower at the end.
+ [codeblock]
+ smoothstep(0, 2, 0.5) # Returns 0.15
+ smoothstep(0, 2, 1.0) # Returns 0.5
+ smoothstep(0, 2, 2.0) # Returns 1.0
+ [/codeblock]
+ </description>
+ </method>
+ <method name="sqrt">
+ <return type="float">
+ </return>
+ <argument index="0" name="s" type="float">
+ </argument>
+ <description>
+ Returns the square root of [code]s[/code].
+ [codeblock]
+ sqrt(9) # Returns 3
+ [/codeblock]
+ </description>
+ </method>
+ <method name="step_decimals">
+ <return type="int">
+ </return>
+ <argument index="0" name="step" type="float">
+ </argument>
+ <description>
+ Returns the position of the first non-zero digit, after the decimal point.
+ [codeblock]
+ # n is 0
+ n = step_decimals(5)
+ # n is 4
+ n = step_decimals(1.0005)
+ # n is 9
+ n = step_decimals(0.000000005)
+ [/codeblock]
+ </description>
+ </method>
+ <method name="stepify">
+ <return type="float">
+ </return>
+ <argument index="0" name="s" type="float">
+ </argument>
+ <argument index="1" name="step" type="float">
+ </argument>
+ <description>
+ Snaps float value [code]s[/code] to a given [code]step[/code].
+ </description>
+ </method>
+ <method name="str" qualifiers="vararg">
+ <return type="String">
+ </return>
+ <description>
+ Converts one or more arguments to string in the best way possible.
+ [codeblock]
+ var a = [10, 20, 30]
+ var b = str(a);
+ len(a) # Returns 3
+ len(b) # Returns 12
+ [/codeblock]
+ </description>
+ </method>
+ <method name="str2var">
+ <return type="Variant">
+ </return>
+ <argument index="0" name="string" type="String">
+ </argument>
+ <description>
+ Converts a formatted string that was returned by [method var2str] to the original value.
+ [codeblock]
+ a = '{ "a": 1, "b": 2 }'
+ b = str2var(a)
+ print(b["a"]) # Prints 1
+ [/codeblock]
+ </description>
+ </method>
+ <method name="tan">
+ <return type="float">
+ </return>
+ <argument index="0" name="s" type="float">
+ </argument>
+ <description>
+ Returns the tangent of angle [code]s[/code] in radians.
+ [codeblock]
+ tan(deg2rad(45)) # Returns 1
+ [/codeblock]
+ </description>
+ </method>
+ <method name="tanh">
+ <return type="float">
+ </return>
+ <argument index="0" name="s" type="float">
+ </argument>
+ <description>
+ Returns the hyperbolic tangent of [code]s[/code].
+ [codeblock]
+ a = log(2.0) # Returns 0.693147
+ tanh(a) # Returns 0.6
+ [/codeblock]
+ </description>
+ </method>
+ <method name="to_json">
+ <return type="String">
+ </return>
+ <argument index="0" name="var" type="Variant">
+ </argument>
+ <description>
+ Converts a Variant [code]var[/code] to JSON text and return the result. Useful for serializing data to store or send over the network.
+ [codeblock]
+ a = { "a": 1, "b": 2 }
+ b = to_json(a)
+ print(b) # {"a":1, "b":2}
+ [/codeblock]
+ </description>
+ </method>
+ <method name="type_exists">
+ <return type="bool">
+ </return>
+ <argument index="0" name="type" type="String">
+ </argument>
+ <description>
+ Returns whether the given class exists in [ClassDB].
+ [codeblock]
+ type_exists("Sprite") # Returns true
+ type_exists("Variant") # Returns false
+ [/codeblock]
+ </description>
+ </method>
+ <method name="typeof">
+ <return type="int">
+ </return>
+ <argument index="0" name="what" type="Variant">
+ </argument>
+ <description>
+ Returns the internal type of the given Variant object, using the [code]TYPE_*[/code] enum in [@GlobalScope].
+ [codeblock]
+ p = parse_json('["a", "b", "c"]')
+ if typeof(p) == TYPE_ARRAY:
+ print(p[0]) # Prints a
+ else:
+ print("unexpected results")
+ [/codeblock]
+ </description>
+ </method>
+ <method name="validate_json">
+ <return type="String">
+ </return>
+ <argument index="0" name="json" type="String">
+ </argument>
+ <description>
+ Checks that [code]json[/code] is valid JSON data. Returns empty string if valid. Returns error message if not valid.
+ [codeblock]
+ j = to_json([1, 2, 3])
+ v = validate_json(j)
+ if not v:
+ print("valid")
+ else:
+ prints("invalid", v)
+ [/codeblock]
+ </description>
+ </method>
+ <method name="var2bytes">
+ <return type="PoolByteArray">
+ </return>
+ <argument index="0" name="var" type="Variant">
+ </argument>
+ <argument index="1" name="full_objects" type="bool" default="false">
+ </argument>
+ <description>
+ Encodes a variable value to a byte array. When [code]full_objects[/code] is [code]true[/code] encoding objects is allowed (and can potentially include code).
+ </description>
+ </method>
+ <method name="var2str">
+ <return type="String">
+ </return>
+ <argument index="0" name="var" type="Variant">
+ </argument>
+ <description>
+ Converts a Variant [code]var[/code] to a formatted string that can later be parsed using [method str2var].
+ [codeblock]
+ a = { "a": 1, "b": 2 }
+ print(var2str(a))
+ [/codeblock]
+ prints
+ [codeblock]
+ {
+ "a": 1,
+ "b": 2
+ }
+ [/codeblock]
+ </description>
+ </method>
+ <method name="weakref">
+ <return type="WeakRef">
+ </return>
+ <argument index="0" name="obj" type="Object">
+ </argument>
+ <description>
+ Returns a weak reference to an object.
+ A weak reference to an object is not enough to keep the object alive: when the only remaining references to a referent are weak references, garbage collection is free to destroy the referent and reuse its memory for something else. However, until the object is actually destroyed the weak reference may return the object even if there are no strong references to it.
+ </description>
+ </method>
+ <method name="wrapf">
+ <return type="float">
+ </return>
+ <argument index="0" name="value" type="float">
+ </argument>
+ <argument index="1" name="min" type="float">
+ </argument>
+ <argument index="2" name="max" type="float">
+ </argument>
+ <description>
+ Wraps float [code]value[/code] between [code]min[/code] and [code]max[/code].
+ Usable for creating loop-alike behavior or infinite surfaces.
+ [codeblock]
+ # a is 0.5
+ a = wrapf(10.5, 0.0, 10.0)
+ [/codeblock]
+ [codeblock]
+ # a is 9.5
+ a = wrapf(-0.5, 0.0, 10.0)
+ [/codeblock]
+ [codeblock]
+ # Infinite loop between 0.0 and 0.99
+ f = wrapf(f + 0.1, 0.0, 1.0)
+ [/codeblock]
+ [codeblock]
+ # Infinite rotation (in radians)
+ angle = wrapf(angle + 0.1, 0.0, TAU)
+ [/codeblock]
+ [b]Note:[/b] If you just want to wrap between 0.0 and [code]n[/code] (where [code]n[/code] is a positive floating-point value), it is better for performance to use the [method fmod] method like [code]fmod(number, n)[/code].
+ [code]wrapf[/code] is more flexible than using the [method fmod] approach by giving the user a simple control over the minimum value. It also fully supports negative numbers, e.g.
+ [codeblock]
+ # Infinite rotation (in radians)
+ angle = wrapf(angle + 0.1, -PI, PI)
+ [/codeblock]
+ </description>
+ </method>
+ <method name="wrapi">
+ <return type="int">
+ </return>
+ <argument index="0" name="value" type="int">
+ </argument>
+ <argument index="1" name="min" type="int">
+ </argument>
+ <argument index="2" name="max" type="int">
+ </argument>
+ <description>
+ Wraps integer [code]value[/code] between [code]min[/code] and [code]max[/code].
+ Usable for creating loop-alike behavior or infinite surfaces.
+ [codeblock]
+ # a is 0
+ a = wrapi(10, 0, 10)
+ [/codeblock]
+ [codeblock]
+ # a is 9
+ a = wrapi(-1, 0, 10)
+ [/codeblock]
+ [codeblock]
+ # Infinite loop between 0 and 9
+ frame = wrapi(frame + 1, 0, 10)
+ [/codeblock]
+ [b]Note:[/b] If you just want to wrap between 0 and [code]n[/code] (where [code]n[/code] is a positive integer value), it is better for performance to use the modulo operator like [code]number % n[/code].
+ [code]wrapi[/code] is more flexible than using the modulo approach by giving the user a simple control over the minimum value. It also fully supports negative numbers, e.g.
+ [codeblock]
+ # result is -2
+ var result = wrapi(-6, -5, -1)
+ [/codeblock]
+ </description>
+ </method>
+ <method name="yield">
+ <return type="GDScriptFunctionState">
+ </return>
+ <argument index="0" name="object" type="Object" default="null">
+ </argument>
+ <argument index="1" name="signal" type="String" default="&quot;&quot;">
+ </argument>
+ <description>
+ Stops the function execution and returns the current suspended state to the calling function.
+ From the caller, call [method GDScriptFunctionState.resume] on the state to resume execution. This invalidates the state. Within the resumed function, [code]yield()[/code] returns whatever was passed to the [code]resume()[/code] function call.
+ If passed an object and a signal, the execution is resumed when the object emits the given signal. In this case, [code]yield()[/code] returns the argument passed to [code]emit_signal()[/code] if the signal takes only one argument, or an array containing all the arguments passed to [code]emit_signal()[/code] if the signal takes multiple arguments.
+ </description>
+ </method>
+ </methods>
+ <constants>
+ <constant name="PI" value="3.141593">
+ Constant that represents how many times the diameter of a circle fits around its perimeter.
+ </constant>
+ <constant name="TAU" value="6.283185">
+ The circle constant, the circumference of the unit circle.
+ </constant>
+ <constant name="INF" value="inf">
+ A positive infinity. (For negative infinity, use -INF).
+ </constant>
+ <constant name="NAN" value="nan">
+ Macro constant that expands to an expression of type float that represents a NaN.
+ The NaN values are used to identify undefined or non-representable values for floating-point elements, such as the square root of negative numbers or the result of 0/0.
+ </constant>
+ </constants>
+</class>
diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp
index 3fb9268702..bc28f7009e 100644
--- a/modules/gdscript/gdscript.cpp
+++ b/modules/gdscript/gdscript.cpp
@@ -69,7 +69,7 @@ Variant GDScriptNativeClass::_new() {
Object *o = instance();
if (!o) {
ERR_EXPLAIN("Class type: '" + String(name) + "' is not instantiable.");
- ERR_FAIL_COND_V(!o, Variant());
+ ERR_FAIL_V(Variant());
}
Reference *ref = Object::cast_to<Reference>(o);
@@ -332,7 +332,7 @@ ScriptInstance *GDScript::instance_create(Object *p_this) {
}
Variant::CallError unchecked_error;
- return _create_instance(NULL, 0, p_this, Object::cast_to<Reference>(p_this), unchecked_error);
+ return _create_instance(NULL, 0, p_this, Object::cast_to<Reference>(p_this) != NULL, unchecked_error);
}
PlaceHolderScriptInstance *GDScript::placeholder_instance_create(Object *p_this) {
diff --git a/modules/gdscript/gdscript.h b/modules/gdscript/gdscript.h
index 40b773d99f..1756f6eabc 100644
--- a/modules/gdscript/gdscript.h
+++ b/modules/gdscript/gdscript.h
@@ -509,7 +509,6 @@ public:
};
class ResourceFormatLoaderGDScript : public ResourceFormatLoader {
- GDCLASS(ResourceFormatLoaderGDScript, ResourceFormatLoader)
public:
virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL);
virtual void get_recognized_extensions(List<String> *p_extensions) const;
@@ -519,7 +518,6 @@ public:
};
class ResourceFormatSaverGDScript : public ResourceFormatSaver {
- GDCLASS(ResourceFormatSaverGDScript, ResourceFormatSaver)
public:
virtual Error save(const String &p_path, const RES &p_resource, uint32_t p_flags = 0);
virtual void get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const;
diff --git a/modules/gdscript/gdscript_compiler.cpp b/modules/gdscript/gdscript_compiler.cpp
index 189317b163..4c976bd2e0 100644
--- a/modules/gdscript/gdscript_compiler.cpp
+++ b/modules/gdscript/gdscript_compiler.cpp
@@ -1073,7 +1073,7 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
int set_index;
bool named = false;
- if (static_cast<const GDScriptParser::OperatorNode *>(op)->op == GDScriptParser::OperatorNode::OP_INDEX_NAMED) {
+ if (op->op == GDScriptParser::OperatorNode::OP_INDEX_NAMED) {
set_index = codegen.get_name_map_pos(static_cast<const GDScriptParser::IdentifierNode *>(op->arguments[1])->name);
named = true;
@@ -1259,8 +1259,6 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
ERR_FAIL_V(-1); //unreachable code
} break;
}
-
- ERR_FAIL_V(-1); //unreachable code
}
Error GDScriptCompiler::_parse_block(CodeGen &codegen, const GDScriptParser::BlockNode *p_block, int p_stack_level, int p_break_addr, int p_continue_addr) {
diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp
index 6c77968f44..26b14a6148 100644
--- a/modules/gdscript/gdscript_editor.cpp
+++ b/modules/gdscript/gdscript_editor.cpp
@@ -2498,7 +2498,8 @@ 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);
} break;
@@ -2537,7 +2538,8 @@ 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();
if (node->type != GDScriptParser::Node::TYPE_OPERATOR) {
@@ -3234,7 +3236,8 @@ 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: {
if (!is_function) {
@@ -3365,7 +3368,8 @@ 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();
if (node->type != GDScriptParser::Node::TYPE_OPERATOR) {
diff --git a/modules/gdscript/gdscript_function.cpp b/modules/gdscript/gdscript_function.cpp
index cff9ba55b8..d5e74c07c9 100644
--- a/modules/gdscript/gdscript_function.cpp
+++ b/modules/gdscript/gdscript_function.cpp
@@ -133,35 +133,13 @@ Variant *GDScriptFunction::_get_variant(int p_address, GDScriptInstance *p_insta
return NULL;
}
-String GDScriptFunction::_get_call_error(const Variant::CallError &p_err, const String &p_where, const Variant **argptrs) const {
-
- String err_text;
-
- if (p_err.error == Variant::CallError::CALL_ERROR_INVALID_ARGUMENT) {
- int errorarg = p_err.argument;
- 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) + ".";
- } else if (p_err.error == Variant::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) {
- err_text = "Invalid call to " + p_where + ". Expected " + itos(p_err.argument) + " arguments.";
- } else if (p_err.error == Variant::CallError::CALL_ERROR_INVALID_METHOD) {
- err_text = "Invalid call. Nonexistent " + p_where + ".";
- } else if (p_err.error == Variant::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);
- }
-
- return err_text;
-}
-
#ifdef DEBUG_ENABLED
-static String _get_var_type(const Variant *p_type) {
+static String _get_var_type(const Variant *p_var) {
String basestr;
- if (p_type->get_type() == Variant::OBJECT) {
- Object *bobj = *p_type;
+ if (p_var->get_type() == Variant::OBJECT) {
+ Object *bobj = *p_var;
if (!bobj) {
basestr = "null instance";
} else {
@@ -176,12 +154,42 @@ static String _get_var_type(const Variant *p_type) {
}
} else {
- basestr = Variant::get_type_name(p_type->get_type());
+ basestr = Variant::get_type_name(p_var->get_type());
}
return basestr;
}
-#endif
+#endif // DEBUG_ENABLED
+
+String GDScriptFunction::_get_call_error(const Variant::CallError &p_err, const String &p_where, const Variant **argptrs) const {
+
+ String err_text;
+
+ if (p_err.error == Variant::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
+ if (p_err.expected == Variant::OBJECT && argptrs[errorarg]->get_type() == p_err.expected) {
+ err_text = "Invalid type in " + p_where + ". The Object-derived class of argument " + itos(errorarg + 1) + " (" + _get_var_type(argptrs[errorarg]) + ") is not a subclass of the expected argument class.";
+ } 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) + ".";
+ }
+ } else if (p_err.error == Variant::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) {
+ err_text = "Invalid call to " + p_where + ". Expected " + itos(p_err.argument) + " arguments.";
+ } else if (p_err.error == Variant::CallError::CALL_ERROR_INVALID_METHOD) {
+ err_text = "Invalid call. Nonexistent " + p_where + ".";
+ } else if (p_err.error == Variant::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);
+ }
+
+ return err_text;
+}
#if defined(__GNUC__)
#define OPCODES_TABLE \
@@ -1548,14 +1556,14 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
//error
// function, file, line, error, explanation
String err_file;
- if (p_instance)
+ if (p_instance && 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 && p_instance->script->name != "")
+ if (p_instance && p_instance->script->is_valid() && p_instance->script->name != "")
err_func = p_instance->script->name + "." + err_func;
int err_line = line;
if (err_text == "") {
@@ -1583,15 +1591,26 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
GDScriptLanguage::get_singleton()->script_frame_time += time_taken - function_call_time;
}
- if (ScriptDebugger::get_singleton())
- GDScriptLanguage::get_singleton()->exit_function();
+ bool yielded = retvalue.is_ref() && Object::cast_to<GDScriptFunctionState>(retvalue);
+
+ // Check if this is the last time the function is resuming from yield
+ // Will be true if never yielded as well
+ // When it's the last resume it will postpone the exit from stack,
+ // so the debugger knows which function triggered the resume of the next function (if any)
+ if (!p_state || yielded) {
+ if (ScriptDebugger::get_singleton())
+ GDScriptLanguage::get_singleton()->exit_function();
#endif
- if (_stack_size) {
- //free stack
- for (int i = 0; i < _stack_size; i++)
- stack[i].~Variant();
+ if (_stack_size) {
+ //free stack
+ for (int i = 0; i < _stack_size; i++)
+ stack[i].~Variant();
+ }
+
+#ifdef DEBUG_ENABLED
}
+#endif
return retvalue;
}
@@ -1767,7 +1786,7 @@ Variant GDScriptFunctionState::_signal_callback(const Variant **p_args, int p_ar
if (state.instance_id && !ObjectDB::get_instance(state.instance_id)) {
#ifdef DEBUG_ENABLED
- ERR_EXPLAIN("Resumed after yield, but class instance is gone");
+ ERR_EXPLAIN("Resumed function '" + String(function->get_name()) + "()' after yield, but class instance is gone. At script: " + state.script->get_path() + ":" + itos(state.line));
ERR_FAIL_V(Variant());
#else
return Variant();
@@ -1830,6 +1849,17 @@ Variant GDScriptFunctionState::_signal_callback(const Variant **p_args, int p_ar
}
}
+#ifdef DEBUG_ENABLED
+ if (ScriptDebugger::get_singleton())
+ GDScriptLanguage::get_singleton()->exit_function();
+ if (state.stack_size) {
+ //free stack
+ Variant *stack = (Variant *)state.stack.ptr();
+ for (int i = 0; i < state.stack_size; i++)
+ stack[i].~Variant();
+ }
+#endif
+
return ret;
}
@@ -1852,7 +1882,7 @@ Variant GDScriptFunctionState::resume(const Variant &p_arg) {
ERR_FAIL_COND_V(!function, Variant());
if (state.instance_id && !ObjectDB::get_instance(state.instance_id)) {
#ifdef DEBUG_ENABLED
- ERR_EXPLAIN("Resumed after yield, but class instance is gone");
+ ERR_EXPLAIN("Resumed function '" + String(function->get_name()) + "()' after yield, but class instance is gone. At script: " + state.script->get_path() + ":" + itos(state.line));
ERR_FAIL_V(Variant());
#else
return Variant();
@@ -1884,6 +1914,17 @@ Variant GDScriptFunctionState::resume(const Variant &p_arg) {
} else {
emit_signal("completed", ret);
}
+
+#ifdef DEBUG_ENABLED
+ if (ScriptDebugger::get_singleton())
+ GDScriptLanguage::get_singleton()->exit_function();
+ if (state.stack_size) {
+ //free stack
+ Variant *stack = (Variant *)state.stack.ptr();
+ for (int i = 0; i < state.stack_size; i++)
+ stack[i].~Variant();
+ }
+#endif
}
return ret;
diff --git a/modules/gdscript/gdscript_functions.cpp b/modules/gdscript/gdscript_functions.cpp
index 98263d43e5..0736f3d010 100644
--- a/modules/gdscript/gdscript_functions.cpp
+++ b/modules/gdscript/gdscript_functions.cpp
@@ -342,7 +342,7 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
VALIDATE_ARG_NUM(0);
r_ret = Math::step_decimals((double)*p_args[0]);
ERR_EXPLAIN("GDScript method 'decimals' is deprecated and has been renamed to 'step_decimals', please update your code accordingly.");
- WARN_DEPRECATED
+ WARN_DEPRECATED;
} break;
case MATH_STEP_DECIMALS: {
VALIDATE_ARG_COUNT(1);
diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp
index 44a91303e9..9ab86a5459 100644
--- a/modules/gdscript/gdscript_parser.cpp
+++ b/modules/gdscript/gdscript_parser.cpp
@@ -463,7 +463,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
}
if (!path.is_abs_path() && base_path != "")
- path = base_path + "/" + path;
+ path = base_path.plus_file(path);
path = path.replace("///", "//").simplify_path();
if (path == self_path) {
@@ -847,24 +847,11 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
if (current_function) {
int arg_idx = current_function->arguments.find(identifier);
if (arg_idx != -1) {
- switch (tokenizer->get_token()) {
- case GDScriptTokenizer::TK_OP_ASSIGN_ADD:
- case GDScriptTokenizer::TK_OP_ASSIGN_BIT_AND:
- case GDScriptTokenizer::TK_OP_ASSIGN_BIT_OR:
- case GDScriptTokenizer::TK_OP_ASSIGN_BIT_XOR:
- case GDScriptTokenizer::TK_OP_ASSIGN_DIV:
- case GDScriptTokenizer::TK_OP_ASSIGN_MOD:
- case GDScriptTokenizer::TK_OP_ASSIGN_MUL:
- case GDScriptTokenizer::TK_OP_ASSIGN_SHIFT_LEFT:
- case GDScriptTokenizer::TK_OP_ASSIGN_SHIFT_RIGHT:
- case GDScriptTokenizer::TK_OP_ASSIGN_SUB:
- case GDScriptTokenizer::TK_OP_ASSIGN: {
- // Assignment is not really usage
- current_function->arguments_usage.write[arg_idx] = current_function->arguments_usage[arg_idx] - 1;
- } break;
- default: {
- current_function->arguments_usage.write[arg_idx] = current_function->arguments_usage[arg_idx] + 1;
- }
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_OP_ASSIGN) {
+ // Assignment is not really usage
+ current_function->arguments_usage.write[arg_idx] = current_function->arguments_usage[arg_idx] - 1;
+ } else {
+ current_function->arguments_usage.write[arg_idx] = current_function->arguments_usage[arg_idx] + 1;
}
}
}
@@ -1150,7 +1137,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
if (!expr) {
ERR_EXPLAIN("GDScriptParser bug, couldn't figure out what expression is...");
- ERR_FAIL_COND_V(!expr, NULL);
+ ERR_FAIL_V(NULL);
}
/******************/
@@ -1493,7 +1480,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
if (next_op == -1) {
_set_error("Yet another parser bug....");
- ERR_FAIL_COND_V(next_op == -1, NULL);
+ ERR_FAIL_V(NULL);
}
// OK! create operator..
@@ -1995,7 +1982,6 @@ GDScriptParser::Node *GDScriptParser::_reduce_expression(Node *p_node, bool p_to
}
}
- ERR_FAIL_V(op);
} break;
default: {
return p_node;
@@ -4025,7 +4011,7 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
ERR_EXPLAIN("Exporting bit flags hint requires string constants.");
- WARN_DEPRECATED
+ WARN_DEPRECATED;
break;
}
if (tokenizer->get_token() != GDScriptTokenizer::TK_COMMA) {
@@ -4068,6 +4054,50 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
break;
}
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier() == "LAYERS_2D_RENDER") {
+
+ tokenizer->advance();
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
+ _set_error("Expected ')' in layers 2D render hint.");
+ return;
+ }
+ current_export.hint = PROPERTY_HINT_LAYERS_2D_RENDER;
+ break;
+ }
+
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier() == "LAYERS_2D_PHYSICS") {
+
+ tokenizer->advance();
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
+ _set_error("Expected ')' in layers 2D physics hint.");
+ return;
+ }
+ current_export.hint = PROPERTY_HINT_LAYERS_2D_PHYSICS;
+ break;
+ }
+
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier() == "LAYERS_3D_RENDER") {
+
+ tokenizer->advance();
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
+ _set_error("Expected ')' in layers 3D render hint.");
+ return;
+ }
+ current_export.hint = PROPERTY_HINT_LAYERS_3D_RENDER;
+ break;
+ }
+
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier() == "LAYERS_3D_PHYSICS") {
+
+ tokenizer->advance();
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
+ _set_error("Expected ')' in layers 3D physics hint.");
+ return;
+ }
+ current_export.hint = PROPERTY_HINT_LAYERS_3D_PHYSICS;
+ break;
+ }
+
if (tokenizer->get_token() == GDScriptTokenizer::TK_CONSTANT && tokenizer->get_token_constant().get_type() == Variant::STRING) {
//enumeration
current_export.hint = PROPERTY_HINT_ENUM;
@@ -5901,11 +5931,8 @@ bool GDScriptParser::_is_type_compatible(const DataType &p_container, const Data
if (p_container.kind == DataType::BUILTIN && p_container.builtin_type == Variant::OBJECT) {
// Object built-in is a special case, it's compatible with any object and with null
- if (p_expression.kind == DataType::BUILTIN && p_expression.builtin_type == Variant::NIL) {
- return true;
- }
if (p_expression.kind == DataType::BUILTIN) {
- return false;
+ return p_expression.builtin_type == Variant::NIL;
}
// If it's not a built-in, must be an object
return true;
diff --git a/modules/gdscript/gdscript_tokenizer.cpp b/modules/gdscript/gdscript_tokenizer.cpp
index a93d1ceebb..95715ab648 100644
--- a/modules/gdscript/gdscript_tokenizer.cpp
+++ b/modules/gdscript/gdscript_tokenizer.cpp
@@ -1189,7 +1189,7 @@ Error GDScriptTokenizerBuffer::set_code_buffer(const Vector<uint8_t> &p_buffer)
int version = decode_uint32(&buf[4]);
if (version > BYTECODE_VERSION) {
ERR_EXPLAIN("Bytecode is too New! Please use a newer engine version.");
- ERR_FAIL_COND_V(version > BYTECODE_VERSION, ERR_INVALID_DATA);
+ ERR_FAIL_V(ERR_INVALID_DATA);
}
int identifier_count = decode_uint32(&buf[8]);
int constant_count = decode_uint32(&buf[12]);
@@ -1303,7 +1303,7 @@ Vector<uint8_t> GDScriptTokenizerBuffer::parse_code_string(const String &p_code)
} break;
case TK_CONSTANT: {
- Variant c = tt.get_token_constant();
+ const Variant &c = tt.get_token_constant();
if (!constant_map.has(c)) {
int idx = constant_map.size();
constant_map[c] = idx;
diff --git a/modules/gdscript/icons/icon_g_d_script.svg b/modules/gdscript/icons/icon_g_d_script.svg
new file mode 100644
index 0000000000..953bb9ae9e
--- /dev/null
+++ b/modules/gdscript/icons/icon_g_d_script.svg
@@ -0,0 +1,5 @@
+<svg width="16" height="16" version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
+<g transform="translate(0 -1036.4)">
+<path transform="translate(0 1036.4)" d="m7 1l-0.56445 2.2578a5 5 0 0 0 -0.68945 0.2793l-1.9883-1.1934-1.4141 1.4141 1.1953 1.9941a5 5 0 0 0 -0.28516 0.68555l-2.2539 0.5625v2l2.2578 0.56445a5 5 0 0 0 0.2793 0.6875l-1.1934 1.9902 1.4141 1.4141 1.9941-1.1953a5 5 0 0 0 0.68555 0.28516l0.5625 2.2539h2l0.56445-2.2578a5 5 0 0 0 0.6875 -0.2793l1.9902 1.1934 1.4141-1.4141-1.1953-1.9941a5 5 0 0 0 0.28516 -0.68555l2.2539-0.5625v-2l-2.2578-0.56445a5 5 0 0 0 -0.2793 -0.6875l1.1934-1.9902-1.4141-1.4141-1.9941 1.1953a5 5 0 0 0 -0.68555 -0.28516l-0.5625-2.2539h-2zm1 5a2 2 0 0 1 2 2 2 2 0 0 1 -2 2 2 2 0 0 1 -2 -2 2 2 0 0 1 2 -2z" fill="#e0e0e0"/>
+</g>
+</svg>
diff --git a/modules/gridmap/doc_classes/GridMap.xml b/modules/gridmap/doc_classes/GridMap.xml
index f8f9fc1af9..325432579f 100644
--- a/modules/gridmap/doc_classes/GridMap.xml
+++ b/modules/gridmap/doc_classes/GridMap.xml
@@ -86,14 +86,14 @@
<return type="Array">
</return>
<description>
- Array of [Transform] and [Mesh] references corresponding to the non empty cells in the grid. The transforms are specified in world space.
+ Array of [Transform] and [Mesh] references corresponding to the non-empty cells in the grid. The transforms are specified in world space.
</description>
</method>
<method name="get_used_cells" qualifiers="const">
<return type="Array">
</return>
<description>
- Array of [Vector3] with the non empty cell coordinates in the grid map.
+ Array of [Vector3] with the non-empty cell coordinates in the grid map.
</description>
</method>
<method name="make_baked_meshes">
@@ -189,28 +189,28 @@
</method>
</methods>
<members>
- <member name="cell_center_x" type="bool" setter="set_center_x" getter="get_center_x">
+ <member name="cell_center_x" type="bool" setter="set_center_x" getter="get_center_x" default="true">
If [code]true[/code], grid items are centered on the X axis.
</member>
- <member name="cell_center_y" type="bool" setter="set_center_y" getter="get_center_y">
+ <member name="cell_center_y" type="bool" setter="set_center_y" getter="get_center_y" default="true">
If [code]true[/code], grid items are centered on the Y axis.
</member>
- <member name="cell_center_z" type="bool" setter="set_center_z" getter="get_center_z">
+ <member name="cell_center_z" type="bool" setter="set_center_z" getter="get_center_z" default="true">
If [code]true[/code], grid items are centered on the Z axis.
</member>
- <member name="cell_octant_size" type="int" setter="set_octant_size" getter="get_octant_size">
+ <member name="cell_octant_size" type="int" setter="set_octant_size" getter="get_octant_size" default="8">
The size of each octant measured in number of cells. This applies to all three axis.
</member>
- <member name="cell_scale" type="float" setter="set_cell_scale" getter="get_cell_scale">
+ <member name="cell_scale" type="float" setter="set_cell_scale" getter="get_cell_scale" default="1.0">
</member>
- <member name="cell_size" type="Vector3" setter="set_cell_size" getter="get_cell_size">
+ <member name="cell_size" type="Vector3" setter="set_cell_size" getter="get_cell_size" default="Vector3( 2, 2, 2 )">
The dimensions of the grid's cells.
</member>
- <member name="collision_layer" type="int" setter="set_collision_layer" getter="get_collision_layer">
+ <member name="collision_layer" type="int" setter="set_collision_layer" getter="get_collision_layer" default="1">
</member>
- <member name="collision_mask" type="int" setter="set_collision_mask" getter="get_collision_mask">
+ <member name="collision_mask" type="int" setter="set_collision_mask" getter="get_collision_mask" default="1">
</member>
- <member name="mesh_library" type="MeshLibrary" setter="set_mesh_library" getter="get_mesh_library">
+ <member name="mesh_library" type="MeshLibrary" setter="set_mesh_library" getter="get_mesh_library" default="null">
The assigned [MeshLibrary].
</member>
<member name="theme" type="MeshLibrary" setter="set_theme" getter="get_theme">
diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cpp
index 32a014e76d..994a84fbc4 100644
--- a/modules/gridmap/grid_map.cpp
+++ b/modules/gridmap/grid_map.cpp
@@ -197,7 +197,7 @@ bool GridMap::get_collision_layer_bit(int p_bit) const {
void GridMap::set_theme(const Ref<MeshLibrary> &p_theme) {
ERR_EXPLAIN("GridMap.theme/set_theme() is deprecated and will be removed in a future version. Use GridMap.mesh_library/set_mesh_library() instead.");
- WARN_DEPRECATED
+ WARN_DEPRECATED;
set_mesh_library(p_theme);
}
@@ -205,7 +205,7 @@ void GridMap::set_theme(const Ref<MeshLibrary> &p_theme) {
Ref<MeshLibrary> GridMap::get_theme() const {
ERR_EXPLAIN("GridMap.theme/get_theme() is deprecated and will be removed in a future version. Use GridMap.mesh_library/get_mesh_library() instead.");
- WARN_DEPRECATED
+ WARN_DEPRECATED;
return get_mesh_library();
}
@@ -241,6 +241,7 @@ Vector3 GridMap::get_cell_size() const {
void GridMap::set_octant_size(int p_size) {
+ ERR_FAIL_COND(p_size == 0);
octant_size = p_size;
_recreate_octant_data();
}
diff --git a/modules/gridmap/grid_map_editor_plugin.cpp b/modules/gridmap/grid_map_editor_plugin.cpp
index 890bd730f7..20e454c218 100644
--- a/modules/gridmap/grid_map_editor_plugin.cpp
+++ b/modules/gridmap/grid_map_editor_plugin.cpp
@@ -235,7 +235,7 @@ void GridMapEditor::_menu_option(int p_option) {
options->get_popup()->set_item_checked(idx, !options->get_popup()->is_item_checked(idx));
} break;
- case MENU_OPTION_SELECTION_DUPLICATE: // fallthrough
+ case MENU_OPTION_SELECTION_DUPLICATE:
case MENU_OPTION_SELECTION_CUT: {
if (!(selection.active && input_action == INPUT_NONE))
break;
@@ -279,7 +279,7 @@ void GridMapEditor::_update_cursor_transform() {
cursor_transform = Transform();
cursor_transform.origin = cursor_origin;
cursor_transform.basis.set_orthogonal_index(cursor_rot);
- cursor_transform = node->get_transform() * cursor_transform;
+ cursor_transform = node->get_global_transform() * cursor_transform;
if (cursor_instance.is_valid()) {
VisualServer::get_singleton()->instance_set_transform(cursor_instance, cursor_transform);
@@ -420,7 +420,7 @@ bool GridMapEditor::do_input_action(Camera *p_camera, const Point2 &p_point, boo
}
last_mouseover = Vector3(cell[0], cell[1], cell[2]);
- VS::get_singleton()->instance_set_transform(grid_instance[edit_axis], Transform(Basis(), grid_ofs));
+ VS::get_singleton()->instance_set_transform(grid_instance[edit_axis], node->get_global_transform() * edit_grid_xform);
if (cursor_instance.is_valid()) {
@@ -664,8 +664,10 @@ bool GridMapEditor::forward_spatial_input_event(Camera *p_camera, const Ref<Inpu
}
if (mb->is_pressed()) {
-
- if (mb->get_button_index() == BUTTON_LEFT) {
+ SpatialEditorViewport::NavigationScheme nav_scheme = (SpatialEditorViewport::NavigationScheme)EditorSettings::get_singleton()->get("editors/3d/navigation/navigation_scheme").operator int();
+ if ((nav_scheme == SpatialEditorViewport::NAVIGATION_MAYA || nav_scheme == SpatialEditorViewport::NAVIGATION_MODO) && mb->get_alt()) {
+ input_action = INPUT_NONE;
+ } else if (mb->get_button_index() == BUTTON_LEFT) {
if (input_action == INPUT_PASTE) {
_do_paste();
diff --git a/modules/gridmap/icons/icon_grid_map.svg b/modules/gridmap/icons/icon_grid_map.svg
new file mode 100644
index 0000000000..eafe1211f2
--- /dev/null
+++ b/modules/gridmap/icons/icon_grid_map.svg
@@ -0,0 +1,5 @@
+<svg width="16" height="16" version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
+<g transform="translate(0 -1036.4)">
+<path transform="translate(0 1036.4)" d="m8 1-6 3v8l6 3 6-3v-2l-2-1-4 2-2-1v-4l2-1v-2l2-1zm4 2-2 1v2l2 1 2-1v-2z" fill="#fc9c9c" fill-opacity=".99608"/>
+</g>
+</svg>
diff --git a/modules/mbedtls/stream_peer_mbed_tls.cpp b/modules/mbedtls/stream_peer_mbed_tls.cpp
index 45d3b86919..3541eff25a 100755
--- a/modules/mbedtls/stream_peer_mbed_tls.cpp
+++ b/modules/mbedtls/stream_peer_mbed_tls.cpp
@@ -122,6 +122,8 @@ Error StreamPeerMbedTLS::_do_handshake() {
Error StreamPeerMbedTLS::connect_to_stream(Ref<StreamPeer> p_base, bool p_validate_certs, const String &p_for_hostname) {
+ ERR_FAIL_COND_V(p_base.is_null(), ERR_INVALID_PARAMETER);
+
base = p_base;
int ret = 0;
int authmode = p_validate_certs ? MBEDTLS_SSL_VERIFY_REQUIRED : MBEDTLS_SSL_VERIFY_NONE;
diff --git a/modules/mobile_vr/doc_classes/MobileVRInterface.xml b/modules/mobile_vr/doc_classes/MobileVRInterface.xml
index 8876bcbe9d..a132333a87 100644
--- a/modules/mobile_vr/doc_classes/MobileVRInterface.xml
+++ b/modules/mobile_vr/doc_classes/MobileVRInterface.xml
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="MobileVRInterface" inherits="ARVRInterface" category="Core" version="3.2">
<brief_description>
- Generic mobile VR implementation
+ Generic mobile VR implementation.
</brief_description>
<description>
- This is a generic mobile VR implementation where you need to provide details about the phone and HMD used. It does not rely on any existing framework. This is the most basic interface we have. For the best effect you do need a mobile phone with a gyroscope and accelerometer.
- Note that even though there is no positional tracking the camera will assume the headset is at a height of 1.85 meters, you can change this by setting [member eye_height].
+ This is a generic mobile VR implementation where you need to provide details about the phone and HMD used. It does not rely on any existing framework. This is the most basic interface we have. For the best effect, you need a mobile phone with a gyroscope and accelerometer.
+ Note that even though there is no positional tracking, the camera will assume the headset is at a height of 1.85 meters. You can change this by setting [member eye_height].
You can initialise this interface as follows:
[codeblock]
var interface = ARVRServer.find_interface("Native mobile")
@@ -18,25 +18,25 @@
<methods>
</methods>
<members>
- <member name="display_to_lens" type="float" setter="set_display_to_lens" getter="get_display_to_lens">
+ <member name="display_to_lens" type="float" setter="set_display_to_lens" getter="get_display_to_lens" default="4.0">
The distance between the display and the lenses inside of the device in centimeters.
</member>
- <member name="display_width" type="float" setter="set_display_width" getter="get_display_width">
+ <member name="display_width" type="float" setter="set_display_width" getter="get_display_width" default="14.5">
The width of the display in centimeters.
</member>
- <member name="eye_height" type="float" setter="set_eye_height" getter="get_eye_height">
+ <member name="eye_height" type="float" setter="set_eye_height" getter="get_eye_height" default="1.85">
The height at which the camera is placed in relation to the ground (i.e. [ARVROrigin] node).
</member>
- <member name="iod" type="float" setter="set_iod" getter="get_iod">
+ <member name="iod" type="float" setter="set_iod" getter="get_iod" default="6.0">
The interocular distance, also known as the interpupillary distance. The distance between the pupils of the left and right eye.
</member>
- <member name="k1" type="float" setter="set_k1" getter="get_k1">
+ <member name="k1" type="float" setter="set_k1" getter="get_k1" default="0.215">
The k1 lens factor is one of the two constants that define the strength of the lens used and directly influences the lens distortion effect.
</member>
- <member name="k2" type="float" setter="set_k2" getter="get_k2">
+ <member name="k2" type="float" setter="set_k2" getter="get_k2" default="0.215">
The k2 lens factor, see k1.
</member>
- <member name="oversample" type="float" setter="set_oversample" getter="get_oversample">
+ <member name="oversample" type="float" setter="set_oversample" getter="get_oversample" default="1.5">
The oversample setting. Because of the lens distortion we have to render our buffers at a higher resolution then the screen can natively handle. A value between 1.5 and 2.0 often provides good results but at the cost of performance.
</member>
</members>
diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp
index 72199281ff..9522eaee77 100644
--- a/modules/mono/csharp_script.cpp
+++ b/modules/mono/csharp_script.cpp
@@ -2701,7 +2701,7 @@ ScriptInstance *CSharpScript::instance_create(Object *p_this) {
}
Variant::CallError unchecked_error;
- return _create_instance(NULL, 0, p_this, Object::cast_to<Reference>(p_this), unchecked_error);
+ return _create_instance(NULL, 0, p_this, Object::cast_to<Reference>(p_this) != NULL, unchecked_error);
}
PlaceHolderScriptInstance *CSharpScript::placeholder_instance_create(Object *p_this) {
@@ -2898,10 +2898,7 @@ void CSharpScript::update_exports() {
}
bool CSharpScript::has_script_signal(const StringName &p_signal) const {
- if (_signals.has(p_signal))
- return true;
-
- return false;
+ return _signals.has(p_signal);
}
void CSharpScript::get_script_signal_list(List<MethodInfo> *r_signals) const {
diff --git a/modules/mono/csharp_script.h b/modules/mono/csharp_script.h
index 4a1fb8e5ed..a2f1ec8f27 100644
--- a/modules/mono/csharp_script.h
+++ b/modules/mono/csharp_script.h
@@ -63,7 +63,7 @@ TScriptInstance *cast_script_instance(ScriptInstance *p_inst) {
class CSharpScript : public Script {
- GDCLASS(CSharpScript, Script)
+ GDCLASS(CSharpScript, Script);
friend class CSharpInstance;
friend class CSharpLanguage;
@@ -337,7 +337,7 @@ public:
_FORCE_INLINE_ static CSharpLanguage *get_singleton() { return singleton; }
static void release_script_gchandle(Ref<MonoGCHandle> &p_gchandle);
- static void release_script_gchandle(MonoObject *p_pinned_expected_obj, Ref<MonoGCHandle> &p_gchandle);
+ static void release_script_gchandle(MonoObject *p_expected_obj, Ref<MonoGCHandle> &p_gchandle);
bool debug_break(const String &p_error, bool p_allow_continue = true);
bool debug_break_parse(const String &p_file, int p_line, const String &p_error);
@@ -440,7 +440,6 @@ public:
};
class ResourceFormatLoaderCSharpScript : public ResourceFormatLoader {
- GDCLASS(ResourceFormatLoaderCSharpScript, ResourceFormatLoader)
public:
virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL);
virtual void get_recognized_extensions(List<String> *p_extensions) const;
@@ -449,7 +448,6 @@ public:
};
class ResourceFormatSaverCSharpScript : public ResourceFormatSaver {
- GDCLASS(ResourceFormatSaverCSharpScript, ResourceFormatSaver)
public:
virtual Error save(const String &p_path, const RES &p_resource, uint32_t p_flags = 0);
virtual void get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const;
diff --git a/modules/mono/editor/bindings_generator.cpp b/modules/mono/editor/bindings_generator.cpp
index cd7774e7a1..2d618f7891 100644
--- a/modules/mono/editor/bindings_generator.cpp
+++ b/modules/mono/editor/bindings_generator.cpp
@@ -2536,13 +2536,8 @@ void BindingsGenerator::_default_argument_from_variant(const Variant &p_val, Arg
switch (p_val.get_type()) {
case Variant::NIL:
- if (ClassDB::class_exists(r_iarg.type.cname)) {
- // Object type
- r_iarg.default_argument = "null";
- } else {
- // Variant
- r_iarg.default_argument = "null";
- }
+ // Either Object type or Variant
+ r_iarg.default_argument = "null";
break;
// Atomic types
case Variant::BOOL:
diff --git a/modules/mono/editor/csharp_project.h b/modules/mono/editor/csharp_project.h
index 3d5a65f8da..b08c9090c7 100644
--- a/modules/mono/editor/csharp_project.h
+++ b/modules/mono/editor/csharp_project.h
@@ -36,7 +36,7 @@
namespace CSharpProject {
String generate_core_api_project(const String &p_dir, const Vector<String> &p_files = Vector<String>());
-String generate_editor_api_project(const String &p_dir, const String &p_core_dll_path, const Vector<String> &p_files = Vector<String>());
+String generate_editor_api_project(const String &p_dir, const String &p_core_proj_path, const Vector<String> &p_files = Vector<String>());
String generate_game_project(const String &p_dir, const String &p_name, const Vector<String> &p_files = Vector<String>());
void add_item(const String &p_project_path, const String &p_item_type, const String &p_include);
diff --git a/modules/mono/editor/godotsharp_editor.h b/modules/mono/editor/godotsharp_editor.h
index d9523c384c..d5bd8ba126 100644
--- a/modules/mono/editor/godotsharp_editor.h
+++ b/modules/mono/editor/godotsharp_editor.h
@@ -35,7 +35,7 @@
#include "monodevelop_instance.h"
class GodotSharpEditor : public Node {
- GDCLASS(GodotSharpEditor, Object)
+ GDCLASS(GodotSharpEditor, Node);
EditorNode *editor;
@@ -109,7 +109,7 @@ public:
};
class MonoReloadNode : public Node {
- GDCLASS(MonoReloadNode, Node)
+ GDCLASS(MonoReloadNode, Node);
Timer *reload_timer;
diff --git a/modules/mono/editor/mono_bottom_panel.h b/modules/mono/editor/mono_bottom_panel.h
index 406e46f7ce..9b362e51df 100644
--- a/modules/mono/editor/mono_bottom_panel.h
+++ b/modules/mono/editor/mono_bottom_panel.h
@@ -40,7 +40,7 @@ class MonoBuildTab;
class MonoBottomPanel : public VBoxContainer {
- GDCLASS(MonoBottomPanel, VBoxContainer)
+ GDCLASS(MonoBottomPanel, VBoxContainer);
EditorNode *editor;
@@ -87,7 +87,7 @@ public:
class MonoBuildTab : public VBoxContainer {
- GDCLASS(MonoBuildTab, VBoxContainer)
+ GDCLASS(MonoBuildTab, VBoxContainer);
public:
enum BuildResult {
diff --git a/modules/mono/mono_gc_handle.h b/modules/mono/mono_gc_handle.h
index 63b61aff18..60a1eed212 100644
--- a/modules/mono/mono_gc_handle.h
+++ b/modules/mono/mono_gc_handle.h
@@ -37,7 +37,7 @@
class MonoGCHandle : public Reference {
- GDCLASS(MonoGCHandle, Reference)
+ GDCLASS(MonoGCHandle, Reference);
bool released;
bool weak;
diff --git a/modules/mono/mono_gd/gd_mono.h b/modules/mono/mono_gd/gd_mono.h
index 216c96a612..95340edcca 100644
--- a/modules/mono/mono_gd/gd_mono.h
+++ b/modules/mono/mono_gd/gd_mono.h
@@ -267,7 +267,7 @@ public:
(void)__gdmono__scope__exit__domain__unload__;
class _GodotSharp : public Object {
- GDCLASS(_GodotSharp, Object)
+ GDCLASS(_GodotSharp, Object);
friend class GDMono;
diff --git a/modules/mono/mono_gd/gd_mono_internals.cpp b/modules/mono/mono_gd/gd_mono_internals.cpp
index 63bcfe053c..cb28efb4e5 100644
--- a/modules/mono/mono_gd/gd_mono_internals.cpp
+++ b/modules/mono/mono_gd/gd_mono_internals.cpp
@@ -105,8 +105,6 @@ 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);
-
- return;
}
void unhandled_exception(MonoException *p_exc) {
diff --git a/modules/mono/signal_awaiter_utils.h b/modules/mono/signal_awaiter_utils.h
index 098008ded7..4fb3cdb56d 100644
--- a/modules/mono/signal_awaiter_utils.h
+++ b/modules/mono/signal_awaiter_utils.h
@@ -41,7 +41,7 @@ Error connect_signal_awaiter(Object *p_source, const String &p_signal, Object *p
class SignalAwaiterHandle : public MonoGCHandle {
- GDCLASS(SignalAwaiterHandle, MonoGCHandle)
+ GDCLASS(SignalAwaiterHandle, MonoGCHandle);
bool completed;
diff --git a/modules/mono/utils/thread_local.h b/modules/mono/utils/thread_local.h
index 488cc2619a..e52b6e73ef 100644
--- a/modules/mono/utils/thread_local.h
+++ b/modules/mono/utils/thread_local.h
@@ -76,7 +76,7 @@ struct ThreadLocalStorage {
void *get_value() const;
void set_value(void *p_value) const;
- void alloc(void(_CALLBACK_FUNC_ *p_dest_callback)(void *));
+ void alloc(void(_CALLBACK_FUNC_ *p_destr_callback)(void *));
void free();
private:
diff --git a/modules/opensimplex/doc_classes/NoiseTexture.xml b/modules/opensimplex/doc_classes/NoiseTexture.xml
index c789724fc4..4826b6cd2a 100644
--- a/modules/opensimplex/doc_classes/NoiseTexture.xml
+++ b/modules/opensimplex/doc_classes/NoiseTexture.xml
@@ -12,21 +12,21 @@
<methods>
</methods>
<members>
- <member name="as_normalmap" type="bool" setter="set_as_normalmap" getter="is_normalmap">
+ <member name="as_normalmap" type="bool" setter="set_as_normalmap" getter="is_normalmap" default="false">
If [code]true[/code], the resulting texture contains a normal map created from the original noise interpreted as a bump map.
</member>
- <member name="bump_strength" type="float" setter="set_bump_strength" getter="get_bump_strength">
+ <member name="bump_strength" type="float" setter="set_bump_strength" getter="get_bump_strength" default="8.0">
</member>
- <member name="height" type="int" setter="set_height" getter="get_height">
+ <member name="height" type="int" setter="set_height" getter="get_height" default="512">
Height of the generated texture.
</member>
- <member name="noise" type="OpenSimplexNoise" setter="set_noise" getter="get_noise">
+ <member name="noise" type="OpenSimplexNoise" setter="set_noise" getter="get_noise" default="null">
The [OpenSimplexNoise] instance used to generate the noise.
</member>
- <member name="seamless" type="bool" setter="set_seamless" getter="get_seamless">
+ <member name="seamless" type="bool" setter="set_seamless" getter="get_seamless" default="false">
Whether the texture can be tiled without visible seams or not. Seamless textures take longer to generate.
</member>
- <member name="width" type="int" setter="set_width" getter="get_width">
+ <member name="width" type="int" setter="set_width" getter="get_width" default="512">
Width of the generated texture.
</member>
</members>
diff --git a/modules/opensimplex/doc_classes/OpenSimplexNoise.xml b/modules/opensimplex/doc_classes/OpenSimplexNoise.xml
index dc7fc7fe31..f3fbbab3da 100644
--- a/modules/opensimplex/doc_classes/OpenSimplexNoise.xml
+++ b/modules/opensimplex/doc_classes/OpenSimplexNoise.xml
@@ -41,6 +41,8 @@
<argument index="0" name="x" type="float">
</argument>
<description>
+ Returns the 1D noise value [code][-1,1][/code] at the given x-coordinate.
+ [b]Note:[/b] This method actually returns the 2D noise value [code][-1,1][/code] with fixed y-coordinate value 0.0.
</description>
</method>
<method name="get_noise_2d">
@@ -106,24 +108,24 @@
<argument index="0" name="size" type="int">
</argument>
<description>
- Generate a tileable noise image, based on the current noise parameters. Generated seamless images are always square ([code]size[/code] x [code]size[/code]).
+ Generate a tileable noise image, based on the current noise parameters. Generated seamless images are always square ([code]size[/code] × [code]size[/code]).
</description>
</method>
</methods>
<members>
- <member name="lacunarity" type="float" setter="set_lacunarity" getter="get_lacunarity">
+ <member name="lacunarity" type="float" setter="set_lacunarity" getter="get_lacunarity" default="2.0">
Difference in period between [member octaves].
</member>
- <member name="octaves" type="int" setter="set_octaves" getter="get_octaves">
+ <member name="octaves" type="int" setter="set_octaves" getter="get_octaves" default="3">
Number of OpenSimplex noise layers that are sampled to get the fractal noise.
</member>
- <member name="period" type="float" setter="set_period" getter="get_period">
+ <member name="period" type="float" setter="set_period" getter="get_period" default="64.0">
Period of the base octave. A lower period results in a higher-frequency noise (more value changes across the same distance).
</member>
- <member name="persistence" type="float" setter="set_persistence" getter="get_persistence">
+ <member name="persistence" type="float" setter="set_persistence" getter="get_persistence" default="0.5">
Contribution factor of the different octaves. A [code]persistence[/code] value of 1 means all the octaves have the same contribution, a value of 0.5 means each octave contributes half as much as the previous one.
</member>
- <member name="seed" type="int" setter="set_seed" getter="get_seed">
+ <member name="seed" type="int" setter="set_seed" getter="get_seed" default="0">
Seed used to generate random values, different seeds will generate different noise maps.
</member>
</members>
diff --git a/modules/opensimplex/icons/icon_noise_texture.svg b/modules/opensimplex/icons/icon_noise_texture.svg
new file mode 100644
index 0000000000..5908c2b2d4
--- /dev/null
+++ b/modules/opensimplex/icons/icon_noise_texture.svg
@@ -0,0 +1,3 @@
+<svg width="16" height="16" version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
+<path d="m2 1c-0.55228 0-1 0.44772-1 1v12c0 0.55228 0.44772 1 1 1h12c0.55228 0 1-0.44772 1-1v-12c0-0.55228-0.44772-1-1-1zm1 2h10v8h-10zm3 1v2h2v-2zm2 2v2h2v2h2v-6h-2v2zm0 2h-2v-2h-2v4h4z" fill="#e0e0e0" fill-opacity=".99608"/>
+</svg>
diff --git a/modules/opensimplex/noise_texture.h b/modules/opensimplex/noise_texture.h
index 0d00ee154d..5e4a02fcee 100644
--- a/modules/opensimplex/noise_texture.h
+++ b/modules/opensimplex/noise_texture.h
@@ -40,7 +40,7 @@
#include "editor/property_editor.h"
class NoiseTexture : public Texture {
- GDCLASS(NoiseTexture, Texture)
+ GDCLASS(NoiseTexture, Texture);
private:
Ref<Image> data;
@@ -77,12 +77,12 @@ public:
Ref<OpenSimplexNoise> get_noise();
void set_width(int p_width);
- void set_height(int p_hieght);
+ void set_height(int p_height);
void set_seamless(bool p_seamless);
bool get_seamless();
- void set_as_normalmap(bool p_seamless);
+ void set_as_normalmap(bool p_as_normalmap);
bool is_normalmap();
void set_bump_strength(float p_bump_strength);
diff --git a/modules/opensimplex/open_simplex_noise.h b/modules/opensimplex/open_simplex_noise.h
index 96885f5893..c31cbf68c3 100644
--- a/modules/opensimplex/open_simplex_noise.h
+++ b/modules/opensimplex/open_simplex_noise.h
@@ -38,7 +38,7 @@
#include "thirdparty/misc/open-simplex-noise.h"
class OpenSimplexNoise : public Resource {
- GDCLASS(OpenSimplexNoise, Resource)
+ GDCLASS(OpenSimplexNoise, Resource);
OBJ_SAVE_TYPE(OpenSimplexNoise);
osn_context contexts[6];
diff --git a/modules/opus/SCsub b/modules/opus/SCsub
index f3c981dd45..a4a431bab7 100644
--- a/modules/opus/SCsub
+++ b/modules/opus/SCsub
@@ -221,7 +221,7 @@ if env['builtin_opus']:
env_opus.Prepend(CPPPATH=[thirdparty_dir + "/" + dir for dir in thirdparty_include_paths])
if env["platform"] == "android":
- if ("android_arch" in env and env["android_arch"] in ["armv6", "armv7"]):
+ if ("android_arch" in env and env["android_arch"] == "armv7"):
env_opus.Append(CPPFLAGS=["-DOPUS_ARM_OPT"])
elif ("android_arch" in env and env["android_arch"] == "arm64v8"):
env_opus.Append(CPPFLAGS=["-DOPUS_ARM64_OPT"])
diff --git a/modules/opus/audio_stream_opus.cpp b/modules/opus/audio_stream_opus.cpp
index fda82295de..70d0f770d8 100644
--- a/modules/opus/audio_stream_opus.cpp
+++ b/modules/opus/audio_stream_opus.cpp
@@ -313,7 +313,7 @@ int AudioStreamPlaybackOpus::mix(int16_t *p_buffer, int p_frames) {
bool ok = op_pcm_seek(opus_file, (loop_restart_time * osrate) + pre_skip) == 0;
if (!ok) {
playing = false;
- ERR_PRINT("loop restart time rejected")
+ ERR_PRINT("Loop restart time rejected");
}
frames_mixed = (loop_restart_time * osrate) + pre_skip;
diff --git a/modules/opus/audio_stream_opus.h b/modules/opus/audio_stream_opus.h
index f53bff0288..04c2e9d9f0 100644
--- a/modules/opus/audio_stream_opus.h
+++ b/modules/opus/audio_stream_opus.h
@@ -43,7 +43,7 @@
class AudioStreamPlaybackOpus : public AudioStreamPlayback {
- GDCLASS(AudioStreamPlaybackOpus, AudioStreamPlayback)
+ GDCLASS(AudioStreamPlaybackOpus, AudioStreamPlayback);
enum {
MIN_MIX = 1024
@@ -117,7 +117,7 @@ public:
class AudioStreamOpus : public AudioStream {
- GDCLASS(AudioStreamOpus, AudioStream)
+ GDCLASS(AudioStreamOpus, AudioStream);
String file;
@@ -132,7 +132,6 @@ public:
};
class ResourceFormatLoaderAudioStreamOpus : public ResourceFormatLoader {
- GDCLASS(ResourceFormatLoaderAudioStreamOpus, ResourceFormatLoader)
public:
virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL);
virtual void get_recognized_extensions(List<String> *p_extensions) const;
diff --git a/modules/pvr/texture_loader_pvr.h b/modules/pvr/texture_loader_pvr.h
index 2808b4ff03..606268e447 100644
--- a/modules/pvr/texture_loader_pvr.h
+++ b/modules/pvr/texture_loader_pvr.h
@@ -35,7 +35,6 @@
#include "scene/resources/texture.h"
class ResourceFormatPVR : public ResourceFormatLoader {
- GDCLASS(ResourceFormatPVR, ResourceFormatLoader)
public:
virtual RES load(const String &p_path, const String &p_original_path, Error *r_error = NULL);
virtual void get_recognized_extensions(List<String> *p_extensions) const;
diff --git a/modules/recast/navigation_mesh_editor_plugin.cpp b/modules/recast/navigation_mesh_editor_plugin.cpp
index eadc11fcee..9f30806925 100644
--- a/modules/recast/navigation_mesh_editor_plugin.cpp
+++ b/modules/recast/navigation_mesh_editor_plugin.cpp
@@ -67,9 +67,7 @@ void NavigationMeshEditor::_bake_pressed() {
EditorNavigationMeshGenerator::get_singleton()->clear(node->get_navigation_mesh());
EditorNavigationMeshGenerator::get_singleton()->bake(node->get_navigation_mesh(), node);
- if (node) {
- node->update_gizmo();
- }
+ node->update_gizmo();
}
void NavigationMeshEditor::_clear_pressed() {
diff --git a/modules/recast/navigation_mesh_generator.cpp b/modules/recast/navigation_mesh_generator.cpp
index 0cac07e3e7..14467dc5c7 100644
--- a/modules/recast/navigation_mesh_generator.cpp
+++ b/modules/recast/navigation_mesh_generator.cpp
@@ -45,6 +45,10 @@
#include "scene/resources/shape.h"
#include "scene/resources/sphere_shape.h"
+#ifdef MODULE_CSG_ENABLED
+#include "modules/csg/csg_shape.h"
+#endif
+
EditorNavigationMeshGenerator *EditorNavigationMeshGenerator::singleton = NULL;
void EditorNavigationMeshGenerator::_add_vertex(const Vector3 &p_vec3, Vector<float> &p_verticies) {
@@ -134,6 +138,20 @@ void EditorNavigationMeshGenerator::_parse_geometry(Transform p_accumulated_tran
}
}
+#ifdef MODULE_CSG_ENABLED
+ if (Object::cast_to<CSGShape>(p_node) && p_generate_from != NavigationMesh::PARSED_GEOMETRY_STATIC_COLLIDERS) {
+
+ CSGShape *csg_shape = Object::cast_to<CSGShape>(p_node);
+ Array meshes = csg_shape->get_meshes();
+ if (!meshes.empty()) {
+ Ref<Mesh> mesh = meshes[1];
+ if (mesh.is_valid()) {
+ _add_mesh(mesh, p_accumulated_transform * csg_shape->get_transform(), p_verticies, p_indices);
+ }
+ }
+ }
+#endif
+
if (Object::cast_to<StaticBody>(p_node) && p_generate_from != NavigationMesh::PARSED_GEOMETRY_MESH_INSTANCES) {
StaticBody *static_body = Object::cast_to<StaticBody>(p_node);
diff --git a/modules/regex/doc_classes/RegEx.xml b/modules/regex/doc_classes/RegEx.xml
index cc8205e400..74b06039d4 100644
--- a/modules/regex/doc_classes/RegEx.xml
+++ b/modules/regex/doc_classes/RegEx.xml
@@ -4,7 +4,7 @@
Class for searching text for patterns using regular expressions.
</brief_description>
<description>
- Regular Expression (or regex) is a compact programming language that can be used to recognise strings that follow a specific pattern, such as URLs, email addresses, complete sentences, etc. For instance, a regex of [code]ab[0-9][/code] would find any string that is [code]ab[/code] followed by any number from [code]0[/code] to [code]9[/code]. For a more in-depth look, you can easily find various tutorials and detailed explanations on the Internet.
+ A regular expression (or regex) is a compact language that can be used to recognise strings that follow a specific pattern, such as URLs, email addresses, complete sentences, etc. For instance, a regex of [code]ab[0-9][/code] would find any string that is [code]ab[/code] followed by any number from [code]0[/code] to [code]9[/code]. For a more in-depth look, you can easily find various tutorials and detailed explanations on the Internet.
To begin, the RegEx object needs to be compiled with the search pattern using [method compile] before it can be used.
[codeblock]
var regex = RegEx.new()
@@ -19,7 +19,7 @@
if result:
print(result.get_string()) # Would print n-0123
[/codeblock]
- The results of capturing groups [code]()[/code] can be retrieved by passing the group number to the various functions in [RegExMatch]. Group 0 is the default and would always refer to the entire pattern. In the above example, calling [code]result.get_string(1)[/code] would give you [code]0123[/code].
+ The results of capturing groups [code]()[/code] can be retrieved by passing the group number to the various functions in [RegExMatch]. Group 0 is the default and will always refer to the entire pattern. In the above example, calling [code]result.get_string(1)[/code] would give you [code]0123[/code].
This version of RegEx also supports named capturing groups, and the names can be used to retrieve the results. If two or more groups have the same name, the name would only refer to the first one with a match.
[codeblock]
var regex = RegEx.new()
@@ -28,7 +28,7 @@
if result:
print(result.get_string("digit")) # Would print 2f
[/codeblock]
- If you need to process multiple results, [method search_all] generates a list of all non-overlapping results. This can be combined with a for-loop for convenience.
+ If you need to process multiple results, [method search_all] generates a list of all non-overlapping results. This can be combined with a [code]for[/code] loop for convenience.
[codeblock]
for result in regex.search_all("d01, d03, d0c, x3f and x42"):
print(result.get_string("digit"))
@@ -43,7 +43,7 @@
<return type="void">
</return>
<description>
- This method resets the state of the object, as it was freshly created. Namely, it unassigns the regular expression of this object.
+ This method resets the state of the object, as if it was freshly created. Namely, it unassigns the regular expression of this object.
</description>
</method>
<method name="compile">
@@ -52,7 +52,7 @@
<argument index="0" name="pattern" type="String">
</argument>
<description>
- Compiles and assign the search pattern to use. Returns OK if the compilation is successful. If an error is encountered the details are printed to STDOUT and FAILED is returned.
+ Compiles and assign the search pattern to use. Returns [constant OK] if the compilation is successful. If an error is encountered, details are printed to standard output and an error is returned.
</description>
</method>
<method name="get_group_count" qualifiers="const">
@@ -93,7 +93,7 @@
<argument index="2" name="end" type="int" default="-1">
</argument>
<description>
- Searches the text for the compiled pattern. Returns a [RegExMatch] container of the first matching result if found, otherwise null. The region to search within can be specified without modifying where the start and end anchor would be.
+ Searches the text for the compiled pattern. Returns a [RegExMatch] container of the first matching result if found, otherwise [code]null[/code]. The region to search within can be specified without modifying where the start and end anchor would be.
</description>
</method>
<method name="search_all" qualifiers="const">
@@ -106,7 +106,7 @@
<argument index="2" name="end" type="int" default="-1">
</argument>
<description>
- Searches the text for the compiled pattern. Returns an array of [RegExMatch] containers for each non-overlapping result. If no results were found an empty array is returned instead. The region to search within can be specified without modifying where the start and end anchor would be.
+ Searches the text for the compiled pattern. Returns an array of [RegExMatch] containers for each non-overlapping result. If no results were found, an empty array is returned instead. The region to search within can be specified without modifying where the start and end anchor would be.
</description>
</method>
<method name="sub" qualifiers="const">
@@ -123,7 +123,7 @@
<argument index="4" name="end" type="int" default="-1">
</argument>
<description>
- Searches the text for the compiled pattern and replaces it with the specified string. Escapes and backreferences such as [code]$1[/code] and [code]$name[/code] are expanded and resolved. By default only the first instance is replaced but it can be changed for all instances (global replacement). The region to search within can be specified without modifying where the start and end anchor would be.
+ Searches the text for the compiled pattern and replaces it with the specified string. Escapes and backreferences such as [code]$1[/code] and [code]$name[/code] are expanded and resolved. By default, only the first instance is replaced, but it can be changed for all instances (global replacement). The region to search within can be specified without modifying where the start and end anchor would be.
</description>
</method>
</methods>
diff --git a/modules/regex/doc_classes/RegExMatch.xml b/modules/regex/doc_classes/RegExMatch.xml
index 245201006d..e279607d13 100644
--- a/modules/regex/doc_classes/RegExMatch.xml
+++ b/modules/regex/doc_classes/RegExMatch.xml
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="RegExMatch" inherits="Reference" category="Core" version="3.2">
<brief_description>
- Contains the results of a regex search.
+ Contains the results of a [RegEx] search.
</brief_description>
<description>
- Contains the results of a single regex match returned by [method RegEx.search] and [method RegEx.search_all]. It can be used to find the position and range of the match and its capturing groups, and it can extract its sub-string for you.
+ Contains the results of a single [RegEx] match returned by [method RegEx.search] and [method RegEx.search_all]. It can be used to find the position and range of the match and its capturing groups, and it can extract its substring for you.
</description>
<tutorials>
</tutorials>
@@ -48,13 +48,15 @@
</method>
</methods>
<members>
- <member name="names" type="Dictionary" setter="" getter="get_names">
+ <member name="names" type="Dictionary" setter="" getter="get_names" default="{
+
+}">
A dictionary of named groups and its corresponding group number. Only groups with that were matched are included. If multiple groups have the same name, that name would refer to the first matching one.
</member>
- <member name="strings" type="Array" setter="" getter="get_strings">
+ <member name="strings" type="Array" setter="" getter="get_strings" default="[ ]">
An [Array] of the match and its capturing groups.
</member>
- <member name="subject" type="String" setter="" getter="get_subject">
+ <member name="subject" type="String" setter="" getter="get_subject" default="&quot;&quot;">
The source string used with the search pattern to find this matching result.
</member>
</members>
diff --git a/modules/stb_vorbis/audio_stream_ogg_vorbis.h b/modules/stb_vorbis/audio_stream_ogg_vorbis.h
index cbff9d47bb..c8c179554a 100644
--- a/modules/stb_vorbis/audio_stream_ogg_vorbis.h
+++ b/modules/stb_vorbis/audio_stream_ogg_vorbis.h
@@ -40,7 +40,7 @@ class AudioStreamOGGVorbis;
class AudioStreamPlaybackOGGVorbis : public AudioStreamPlaybackResampled {
- GDCLASS(AudioStreamPlaybackOGGVorbis, AudioStreamPlaybackResampled)
+ GDCLASS(AudioStreamPlaybackOGGVorbis, AudioStreamPlaybackResampled);
stb_vorbis *ogg_stream;
stb_vorbis_alloc ogg_alloc;
@@ -72,7 +72,7 @@ public:
class AudioStreamOGGVorbis : public AudioStream {
- GDCLASS(AudioStreamOGGVorbis, AudioStream)
+ GDCLASS(AudioStreamOGGVorbis, AudioStream);
OBJ_SAVE_TYPE(AudioStream) //children are all saved as AudioStream, so they can be exchanged
RES_BASE_EXTENSION("oggstr");
diff --git a/modules/stb_vorbis/config.py b/modules/stb_vorbis/config.py
index d75e41797a..200b8dfd50 100644
--- a/modules/stb_vorbis/config.py
+++ b/modules/stb_vorbis/config.py
@@ -7,7 +7,6 @@ def configure(env):
def get_doc_classes():
return [
"AudioStreamOGGVorbis",
- "ResourceImporterOGGVorbis",
]
def get_doc_path():
diff --git a/modules/stb_vorbis/doc_classes/AudioStreamOGGVorbis.xml b/modules/stb_vorbis/doc_classes/AudioStreamOGGVorbis.xml
index 388c5e81ed..9403199398 100644
--- a/modules/stb_vorbis/doc_classes/AudioStreamOGGVorbis.xml
+++ b/modules/stb_vorbis/doc_classes/AudioStreamOGGVorbis.xml
@@ -11,12 +11,12 @@
<methods>
</methods>
<members>
- <member name="data" type="PoolByteArray" setter="set_data" getter="get_data">
+ <member name="data" type="PoolByteArray" setter="set_data" getter="get_data" default="PoolByteArray( )">
Contains the audio data in bytes.
</member>
- <member name="loop" type="bool" setter="set_loop" getter="has_loop">
+ <member name="loop" type="bool" setter="set_loop" getter="has_loop" default="false">
</member>
- <member name="loop_offset" type="float" setter="set_loop_offset" getter="get_loop_offset">
+ <member name="loop_offset" type="float" setter="set_loop_offset" getter="get_loop_offset" default="0.0">
</member>
</members>
<constants>
diff --git a/modules/stb_vorbis/register_types.cpp b/modules/stb_vorbis/register_types.cpp
index 88a1766e47..ce64626e4b 100644
--- a/modules/stb_vorbis/register_types.cpp
+++ b/modules/stb_vorbis/register_types.cpp
@@ -29,15 +29,22 @@
/*************************************************************************/
#include "register_types.h"
+
#include "audio_stream_ogg_vorbis.h"
+
+#ifdef TOOLS_ENABLED
+#include "core/engine.h"
#include "resource_importer_ogg_vorbis.h"
+#endif
void register_stb_vorbis_types() {
#ifdef TOOLS_ENABLED
- Ref<ResourceImporterOGGVorbis> ogg_import;
- ogg_import.instance();
- ResourceFormatImporter::get_singleton()->add_importer(ogg_import);
+ if (Engine::get_singleton()->is_editor_hint()) {
+ Ref<ResourceImporterOGGVorbis> ogg_import;
+ ogg_import.instance();
+ ResourceFormatImporter::get_singleton()->add_importer(ogg_import);
+ }
#endif
ClassDB::register_class<AudioStreamOGGVorbis>();
}
diff --git a/modules/stb_vorbis/resource_importer_ogg_vorbis.cpp b/modules/stb_vorbis/resource_importer_ogg_vorbis.cpp
index 7254f57672..e10f29e310 100644
--- a/modules/stb_vorbis/resource_importer_ogg_vorbis.cpp
+++ b/modules/stb_vorbis/resource_importer_ogg_vorbis.cpp
@@ -82,9 +82,8 @@ Error ResourceImporterOGGVorbis::import(const String &p_source_file, const Strin
float loop_offset = p_options["loop_offset"];
FileAccess *f = FileAccess::open(p_source_file, FileAccess::READ);
- if (!f) {
- ERR_FAIL_COND_V(!f, ERR_CANT_OPEN);
- }
+
+ ERR_FAIL_COND_V(!f, ERR_CANT_OPEN);
size_t len = f->get_len();
diff --git a/modules/stb_vorbis/resource_importer_ogg_vorbis.h b/modules/stb_vorbis/resource_importer_ogg_vorbis.h
index d3d0574d56..8e4fbde916 100644
--- a/modules/stb_vorbis/resource_importer_ogg_vorbis.h
+++ b/modules/stb_vorbis/resource_importer_ogg_vorbis.h
@@ -35,7 +35,8 @@
#include "core/io/resource_importer.h"
class ResourceImporterOGGVorbis : public ResourceImporter {
- GDCLASS(ResourceImporterOGGVorbis, ResourceImporter)
+ GDCLASS(ResourceImporterOGGVorbis, ResourceImporter);
+
public:
virtual String get_importer_name() const;
virtual String get_visible_name() const;
diff --git a/modules/theora/config.py b/modules/theora/config.py
index 7504166237..c7713d7607 100644
--- a/modules/theora/config.py
+++ b/modules/theora/config.py
@@ -6,7 +6,6 @@ def configure(env):
def get_doc_classes():
return [
- "ResourceImporterTheora",
"VideoStreamTheora",
]
diff --git a/modules/theora/video_stream_theora.h b/modules/theora/video_stream_theora.h
index 85d73d3c0d..0c37d33358 100644
--- a/modules/theora/video_stream_theora.h
+++ b/modules/theora/video_stream_theora.h
@@ -186,7 +186,6 @@ public:
};
class ResourceFormatLoaderTheora : public ResourceFormatLoader {
- GDCLASS(ResourceFormatLoaderTheora, ResourceFormatLoader)
public:
virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL);
virtual void get_recognized_extensions(List<String> *p_extensions) const;
diff --git a/modules/tinyexr/image_loader_tinyexr.cpp b/modules/tinyexr/image_loader_tinyexr.cpp
index bd84a28c84..a9340b1498 100644
--- a/modules/tinyexr/image_loader_tinyexr.cpp
+++ b/modules/tinyexr/image_loader_tinyexr.cpp
@@ -122,13 +122,13 @@ Error ImageLoaderTinyEXR::load_image(Ref<Image> p_image, FileAccess *f, bool p_f
}
if (idxG == -1) {
- ERR_PRINT("TinyEXR: G channel not found.")
+ ERR_PRINT("TinyEXR: G channel not found.");
// @todo { free exr_image }
return ERR_FILE_CORRUPT;
}
if (idxB == -1) {
- ERR_PRINT("TinyEXR: B channel not found.")
+ ERR_PRINT("TinyEXR: B channel not found.");
// @todo { free exr_image }
return ERR_FILE_CORRUPT;
}
diff --git a/modules/upnp/SCsub b/modules/upnp/SCsub
index 6d669ab73b..ec1d7f44d5 100644
--- a/modules/upnp/SCsub
+++ b/modules/upnp/SCsub
@@ -23,10 +23,11 @@ if env['builtin_miniupnpc']:
"portlistingparse.c",
"upnpreplyparse.c",
]
- thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
+ thirdparty_sources = [thirdparty_dir + "miniupnpc/" + file for file in thirdparty_sources]
env_upnp.Prepend(CPPPATH=[thirdparty_dir])
env_upnp.Append(CPPFLAGS=["-DMINIUPNP_STATICLIB"])
+ env_upnp.Append(CPPFLAGS=["-DMINIUPNPC_SET_SOCKET_TIMEOUT"])
env_thirdparty = env_upnp.Clone()
env_thirdparty.disable_warnings()
diff --git a/modules/upnp/doc_classes/UPNP.xml b/modules/upnp/doc_classes/UPNP.xml
index 0516ea9d54..aac0932995 100644
--- a/modules/upnp/doc_classes/UPNP.xml
+++ b/modules/upnp/doc_classes/UPNP.xml
@@ -5,6 +5,17 @@
</brief_description>
<description>
Provides UPNP functionality to discover [UPNPDevice]s on the local network and execute commands on them, like managing port mappings (port forwarding) and querying the local and remote network IP address. Note that methods on this class are synchronous and block the calling thread.
+ To forward a specific port:
+ [codeblock]
+ const PORT = 7777
+ var upnp = UPNP.new()
+ upnp.discover(2000, 2, "InternetGatewayDevice")
+ upnp.add_port_mapping(port)
+ [/codeblock]
+ To close a specific port (e.g. after you have finished using it):
+ [codeblock]
+ upnp.delete_port_mapping(port)
+ [/codeblock]
</description>
<tutorials>
</tutorials>
@@ -123,13 +134,13 @@
</method>
</methods>
<members>
- <member name="discover_ipv6" type="bool" setter="set_discover_ipv6" getter="is_discover_ipv6">
+ <member name="discover_ipv6" type="bool" setter="set_discover_ipv6" getter="is_discover_ipv6" default="false">
If [code]true[/code], IPv6 is used for [UPNPDevice] discovery.
</member>
- <member name="discover_local_port" type="int" setter="set_discover_local_port" getter="get_discover_local_port">
+ <member name="discover_local_port" type="int" setter="set_discover_local_port" getter="get_discover_local_port" default="0">
If [code]0[/code], the local port to use for discovery is chosen automatically by the system. If [code]1[/code], discovery will be done from the source port 1900 (same as destination port). Otherwise, the value will be used as the port.
</member>
- <member name="discover_multicast_if" type="String" setter="set_discover_multicast_if" getter="get_discover_multicast_if">
+ <member name="discover_multicast_if" type="String" setter="set_discover_multicast_if" getter="get_discover_multicast_if" default="&quot;&quot;">
Multicast interface to use for discovery. Uses the default multicast interface if empty.
</member>
</members>
@@ -171,7 +182,7 @@
No port maps are available. May also be returned if port mapping functionality is not available.
</constant>
<constant name="UPNP_RESULT_CONFLICT_WITH_OTHER_MECHANISM" value="12" enum="UPNPResult">
- Conflict with other mechanism. May be returned instead of [code]UPNP_RESULT_CONFLICT_WITH_OTHER_MAPPING[/code] if a port mapping conflicts with an existing one.
+ Conflict with other mechanism. May be returned instead of [constant UPNP_RESULT_CONFLICT_WITH_OTHER_MAPPING] if a port mapping conflicts with an existing one.
</constant>
<constant name="UPNP_RESULT_CONFLICT_WITH_OTHER_MAPPING" value="13" enum="UPNPResult">
Conflict with an existing port mapping.
diff --git a/modules/upnp/doc_classes/UPNPDevice.xml b/modules/upnp/doc_classes/UPNPDevice.xml
index 1d9a728365..4d3a0f4f1d 100644
--- a/modules/upnp/doc_classes/UPNPDevice.xml
+++ b/modules/upnp/doc_classes/UPNPDevice.xml
@@ -53,22 +53,22 @@
</method>
</methods>
<members>
- <member name="description_url" type="String" setter="set_description_url" getter="get_description_url">
+ <member name="description_url" type="String" setter="set_description_url" getter="get_description_url" default="&quot;&quot;">
URL to the device description.
</member>
- <member name="igd_control_url" type="String" setter="set_igd_control_url" getter="get_igd_control_url">
+ <member name="igd_control_url" type="String" setter="set_igd_control_url" getter="get_igd_control_url" default="&quot;&quot;">
IDG control URL.
</member>
- <member name="igd_our_addr" type="String" setter="set_igd_our_addr" getter="get_igd_our_addr">
+ <member name="igd_our_addr" type="String" setter="set_igd_our_addr" getter="get_igd_our_addr" default="&quot;&quot;">
Address of the local machine in the network connecting it to this [UPNPDevice].
</member>
- <member name="igd_service_type" type="String" setter="set_igd_service_type" getter="get_igd_service_type">
+ <member name="igd_service_type" type="String" setter="set_igd_service_type" getter="get_igd_service_type" default="&quot;&quot;">
IGD service type.
</member>
- <member name="igd_status" type="int" setter="set_igd_status" getter="get_igd_status" enum="UPNPDevice.IGDStatus">
+ <member name="igd_status" type="int" setter="set_igd_status" getter="get_igd_status" enum="UPNPDevice.IGDStatus" default="9">
IGD status. See [enum IGDStatus].
</member>
- <member name="service_type" type="String" setter="set_service_type" getter="get_service_type">
+ <member name="service_type" type="String" setter="set_service_type" getter="get_service_type" default="&quot;&quot;">
Service type.
</member>
</members>
diff --git a/modules/visual_script/config.py b/modules/visual_script/config.py
index 07a0450734..04e1a40b81 100644
--- a/modules/visual_script/config.py
+++ b/modules/visual_script/config.py
@@ -6,6 +6,7 @@ def configure(env):
def get_doc_classes():
return [
+ "@VisualScript",
"VisualScriptBasicTypeConstant",
"VisualScriptBuiltinFunc",
"VisualScriptClassConstant",
diff --git a/modules/gdnative/doc_classes/ResourceFormatLoaderVideoStreamGDNative.xml b/modules/visual_script/doc_classes/@VisualScript.xml
index cd8b336778..8d9408e6d4 100644
--- a/modules/gdnative/doc_classes/ResourceFormatLoaderVideoStreamGDNative.xml
+++ b/modules/visual_script/doc_classes/@VisualScript.xml
@@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="ResourceFormatLoaderVideoStreamGDNative" inherits="ResourceFormatLoader" category="Core" version="3.2">
+<class name="@VisualScript" category="Core" version="3.2">
<brief_description>
+ Built-in visual script functions.
</brief_description>
<description>
+ A list of built-in visual script functions, see [VisualScriptBuiltinFunc] and [VisualScript].
</description>
<tutorials>
</tutorials>
diff --git a/modules/visual_script/doc_classes/VisualScript.xml b/modules/visual_script/doc_classes/VisualScript.xml
index 8f0d881f30..0d95075152 100644
--- a/modules/visual_script/doc_classes/VisualScript.xml
+++ b/modules/visual_script/doc_classes/VisualScript.xml
@@ -252,7 +252,7 @@
<argument index="0" name="name" type="String">
</argument>
<description>
- Returns the info for a given variable as a dictionary. The information includes its name, type, hint and usage.
+ Returns the information for a given variable as a dictionary. The information includes its name, type, hint and usage.
</description>
</method>
<method name="has_custom_signal" qualifiers="const">
diff --git a/modules/visual_script/doc_classes/VisualScriptBasicTypeConstant.xml b/modules/visual_script/doc_classes/VisualScriptBasicTypeConstant.xml
index b591dc9a51..6dc54dbc03 100644
--- a/modules/visual_script/doc_classes/VisualScriptBasicTypeConstant.xml
+++ b/modules/visual_script/doc_classes/VisualScriptBasicTypeConstant.xml
@@ -11,7 +11,7 @@
<methods>
</methods>
<members>
- <member name="basic_type" type="int" setter="set_basic_type" getter="get_basic_type" enum="Variant.Type">
+ <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">
diff --git a/modules/visual_script/doc_classes/VisualScriptBuiltinFunc.xml b/modules/visual_script/doc_classes/VisualScriptBuiltinFunc.xml
index 21e8a38c16..470a3a5e35 100644
--- a/modules/visual_script/doc_classes/VisualScriptBuiltinFunc.xml
+++ b/modules/visual_script/doc_classes/VisualScriptBuiltinFunc.xml
@@ -12,7 +12,7 @@
<methods>
</methods>
<members>
- <member name="function" type="int" setter="set_func" getter="get_func" enum="VisualScriptBuiltinFunc.BuiltinFunc">
+ <member name="function" type="int" setter="set_func" getter="get_func" enum="VisualScriptBuiltinFunc.BuiltinFunc" default="0">
The function to be executed.
</member>
</members>
@@ -106,7 +106,7 @@
Moves the number toward a value, based on the third input.
</constant>
<constant name="MATH_DECTIME" value="30" enum="BuiltinFunc">
- Return the result of 'value' decreased by 'step' * 'amount'.
+ Return the result of [code]value[/code] decreased by [code]step[/code] * [code]amount[/code].
</constant>
<constant name="MATH_RANDOMIZE" value="31" enum="BuiltinFunc">
Randomize the seed (or the internal state) of the random number generator. Current implementation reseeds using a number based on time.
@@ -139,10 +139,10 @@
Convert the input from decibel volume to linear volume.
</constant>
<constant name="MATH_POLAR2CARTESIAN" value="41" enum="BuiltinFunc">
- Converts a 2D point expressed in the polar coordinate system (a distance from the origin [code]r[/code] and an angle [code]th[/code]) to the cartesian coordinate system (x and y axis).
+ Converts a 2D point expressed in the polar coordinate system (a distance from the origin [code]r[/code] and an angle [code]th[/code]) to the cartesian coordinate system (X and Y axis).
</constant>
<constant name="MATH_CARTESIAN2POLAR" value="42" enum="BuiltinFunc">
- Converts a 2D point expressed in the cartesian coordinate system (x and y axis) to the polar coordinate system (a distance from the origin and an angle).
+ Converts a 2D point expressed in the cartesian coordinate system (X and Y axis) to the polar coordinate system (a distance from the origin and an angle).
</constant>
<constant name="MATH_WRAP" value="43" enum="BuiltinFunc">
</constant>
@@ -194,26 +194,27 @@
Serialize a [Variant] to a string.
</constant>
<constant name="STR_TO_VAR" value="60" enum="BuiltinFunc">
- Deserialize a [Variant] from a string serialized using [code]VAR_TO_STR[/code].
+ 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].
</constant>
<constant name="BYTES_TO_VAR" value="62" enum="BuiltinFunc">
- Deserialize a [Variant] from a [PoolByteArray] serialized using [code]VAR_TO_BYTES[/code].
+ Deserialize a [Variant] from a [PoolByteArray] 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. Note: names are defined in color_names.inc.
+ Return the [Color] with the given name and alpha ranging from 0 to 1
+ [b]Note:[/b] Names are defined in [code]color_names.inc[/code].
</constant>
<constant name="MATH_SMOOTHSTEP" value="64" enum="BuiltinFunc">
- Return a number smoothly interpolated between the first two inputs, based on the third input. Similar to [code]MATH_LERP[/code], but interpolates faster at the beginning and slower at the end. Using Hermite interpolation formula:
+ Return a number smoothly interpolated between the first two inputs, based on the third input. Similar to [constant MATH_LERP], but interpolates faster at the beginning and slower at the end. Using Hermite interpolation formula:
[codeblock]
var t = clamp((weight - from) / (to - from), 0.0, 1.0)
return t * t * (3.0 - 2.0 * t)
[/codeblock]
</constant>
<constant name="FUNC_MAX" value="65" enum="BuiltinFunc">
- The maximum value the [member function] property can have.
+ Represents the size of the [enum BuiltinFunc] enum.
</constant>
</constants>
</class>
diff --git a/modules/visual_script/doc_classes/VisualScriptClassConstant.xml b/modules/visual_script/doc_classes/VisualScriptClassConstant.xml
index 6e48e7c416..49ea7850ef 100644
--- a/modules/visual_script/doc_classes/VisualScriptClassConstant.xml
+++ b/modules/visual_script/doc_classes/VisualScriptClassConstant.xml
@@ -4,7 +4,7 @@
Gets a constant from a given class.
</brief_description>
<description>
- This node returns a constant from a given class, such as [constant @GlobalScope.TYPE_INT]. See the given class' documentation for available constants.
+ This node returns a constant from a given class, such as [constant TYPE_INT]. See the given class' documentation for available constants.
[b]Input Ports:[/b]
none
[b]Output Ports:[/b]
@@ -15,10 +15,10 @@
<methods>
</methods>
<members>
- <member name="base_type" type="String" setter="set_base_type" getter="get_base_type">
+ <member name="base_type" type="String" 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">
+ <member name="constant" type="String" 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/VisualScriptComment.xml b/modules/visual_script/doc_classes/VisualScriptComment.xml
index 9652654610..2538bc8356 100644
--- a/modules/visual_script/doc_classes/VisualScriptComment.xml
+++ b/modules/visual_script/doc_classes/VisualScriptComment.xml
@@ -12,13 +12,13 @@
<methods>
</methods>
<members>
- <member name="description" type="String" setter="set_description" getter="get_description">
+ <member name="description" type="String" setter="set_description" getter="get_description" default="&quot;&quot;">
The text inside the comment node.
</member>
- <member name="size" type="Vector2" setter="set_size" getter="get_size">
+ <member name="size" type="Vector2" setter="set_size" getter="get_size" default="Vector2( 150, 150 )">
The comment node's size (in pixels).
</member>
- <member name="title" type="String" setter="set_title" getter="get_title">
+ <member name="title" type="String" setter="set_title" getter="get_title" default="&quot;Comment&quot;">
The comment node's title.
</member>
</members>
diff --git a/modules/visual_script/doc_classes/VisualScriptConstant.xml b/modules/visual_script/doc_classes/VisualScriptConstant.xml
index b15af8e4ea..eb12fc3731 100644
--- a/modules/visual_script/doc_classes/VisualScriptConstant.xml
+++ b/modules/visual_script/doc_classes/VisualScriptConstant.xml
@@ -15,7 +15,7 @@
<methods>
</methods>
<members>
- <member name="type" type="int" setter="set_constant_type" getter="get_constant_type" enum="Variant.Type">
+ <member name="type" type="int" setter="set_constant_type" getter="get_constant_type" enum="Variant.Type" default="0">
The constant's type.
</member>
<member name="value" type="Variant" setter="set_constant_value" getter="get_constant_value">
diff --git a/modules/visual_script/doc_classes/VisualScriptCustomNode.xml b/modules/visual_script/doc_classes/VisualScriptCustomNode.xml
index 1ab9f807fb..b079653591 100644
--- a/modules/visual_script/doc_classes/VisualScriptCustomNode.xml
+++ b/modules/visual_script/doc_classes/VisualScriptCustomNode.xml
@@ -45,7 +45,7 @@
<argument index="0" name="idx" type="int">
</argument>
<description>
- Return the specified input port's type. See the TYPE_* enum in [@GlobalScope].
+ Return the specified input port's type. See the [code]TYPE_*[/code] enum in [@GlobalScope].
</description>
</method>
<method name="_get_output_sequence_port_count" qualifiers="virtual">
@@ -86,7 +86,7 @@
<argument index="0" name="idx" type="int">
</argument>
<description>
- Return the specified output's type. See the TYPE_* enum in [@GlobalScope].
+ Return the specified output's type. See the [code]TYPE_*[/code] enum in [@GlobalScope].
</description>
</method>
<method name="_get_text" qualifiers="virtual">
@@ -125,9 +125,9 @@
Execute the custom node's logic, returning the index of the output sequence port to use or a [String] when there is an error.
The [code]inputs[/code] array contains the values of the input ports.
[code]outputs[/code] is an array whose indices should be set to the respective outputs.
- The [code]start_mode[/code] is usually [code]START_MODE_BEGIN_SEQUENCE[/code], unless you have used the STEP_* constants.
+ The [code]start_mode[/code] is usually [constant START_MODE_BEGIN_SEQUENCE], unless you have used the [code]STEP_*[/code] constants.
[code]working_mem[/code] is an array which can be used to persist information between runs of the custom node.
- When returning, you can mask the returned value with one of the STEP_* constants.
+ When returning, you can mask the returned value with one of the [code]STEP_*[/code] constants.
</description>
</method>
</methods>
diff --git a/modules/visual_script/doc_classes/VisualScriptDeconstruct.xml b/modules/visual_script/doc_classes/VisualScriptDeconstruct.xml
index a0eed5b753..c8543287b4 100644
--- a/modules/visual_script/doc_classes/VisualScriptDeconstruct.xml
+++ b/modules/visual_script/doc_classes/VisualScriptDeconstruct.xml
@@ -11,7 +11,7 @@
<methods>
</methods>
<members>
- <member name="type" type="int" setter="set_deconstruct_type" getter="get_deconstruct_type" enum="Variant.Type">
+ <member name="type" type="int" setter="set_deconstruct_type" getter="get_deconstruct_type" enum="Variant.Type" default="0">
The type to deconstruct.
</member>
</members>
diff --git a/modules/visual_script/doc_classes/VisualScriptEmitSignal.xml b/modules/visual_script/doc_classes/VisualScriptEmitSignal.xml
index 623aa1ba86..1a567905a9 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">
+ <member name="signal" type="String" setter="set_signal" getter="get_signal" default="&quot;&quot;">
The signal to emit.
</member>
</members>
diff --git a/modules/visual_script/doc_classes/VisualScriptEngineSingleton.xml b/modules/visual_script/doc_classes/VisualScriptEngineSingleton.xml
index 525389366a..05bd87ec22 100644
--- a/modules/visual_script/doc_classes/VisualScriptEngineSingleton.xml
+++ b/modules/visual_script/doc_classes/VisualScriptEngineSingleton.xml
@@ -11,7 +11,7 @@
<methods>
</methods>
<members>
- <member name="constant" type="String" setter="set_singleton" getter="get_singleton">
+ <member name="constant" type="String" setter="set_singleton" getter="get_singleton" default="&quot;&quot;">
The singleton's name.
</member>
</members>
diff --git a/modules/visual_script/doc_classes/VisualScriptFunctionCall.xml b/modules/visual_script/doc_classes/VisualScriptFunctionCall.xml
index e4d0bb7672..f7f86e8c80 100644
--- a/modules/visual_script/doc_classes/VisualScriptFunctionCall.xml
+++ b/modules/visual_script/doc_classes/VisualScriptFunctionCall.xml
@@ -11,23 +11,23 @@
<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">
+ <member name="base_type" type="String" 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">
+ <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">
+ <member name="function" type="String" 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">
+ <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>
<member name="use_default_args" type="int" setter="set_use_default_args" getter="get_use_default_args">
</member>
- <member name="validate" type="bool" setter="set_validate" getter="get_validate">
+ <member name="validate" type="bool" setter="set_validate" getter="get_validate" default="true">
</member>
</members>
<constants>
diff --git a/modules/visual_script/doc_classes/VisualScriptGlobalConstant.xml b/modules/visual_script/doc_classes/VisualScriptGlobalConstant.xml
index 4099a351e6..6c70dc7dc4 100644
--- a/modules/visual_script/doc_classes/VisualScriptGlobalConstant.xml
+++ b/modules/visual_script/doc_classes/VisualScriptGlobalConstant.xml
@@ -9,7 +9,7 @@
<methods>
</methods>
<members>
- <member name="constant" type="int" setter="set_global_constant" getter="get_global_constant">
+ <member name="constant" type="int" setter="set_global_constant" getter="get_global_constant" default="0">
</member>
</members>
<constants>
diff --git a/modules/visual_script/doc_classes/VisualScriptInputAction.xml b/modules/visual_script/doc_classes/VisualScriptInputAction.xml
index 4bd1430cf6..8c942813b2 100644
--- a/modules/visual_script/doc_classes/VisualScriptInputAction.xml
+++ b/modules/visual_script/doc_classes/VisualScriptInputAction.xml
@@ -9,9 +9,9 @@
<methods>
</methods>
<members>
- <member name="action" type="String" setter="set_action_name" getter="get_action_name">
+ <member name="action" type="String" 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">
+ <member name="mode" type="int" setter="set_action_mode" getter="get_action_mode" enum="VisualScriptInputAction.Mode" default="0">
</member>
</members>
<constants>
diff --git a/modules/visual_script/doc_classes/VisualScriptLocalVar.xml b/modules/visual_script/doc_classes/VisualScriptLocalVar.xml
index 5d061ea79f..8c21c3f0bc 100644
--- a/modules/visual_script/doc_classes/VisualScriptLocalVar.xml
+++ b/modules/visual_script/doc_classes/VisualScriptLocalVar.xml
@@ -15,10 +15,10 @@
<methods>
</methods>
<members>
- <member name="type" type="int" setter="set_var_type" getter="get_var_type" enum="Variant.Type">
+ <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">
+ <member name="var_name" type="String" 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 049195d890..a981432cdb 100644
--- a/modules/visual_script/doc_classes/VisualScriptLocalVarSet.xml
+++ b/modules/visual_script/doc_classes/VisualScriptLocalVarSet.xml
@@ -17,10 +17,10 @@
<methods>
</methods>
<members>
- <member name="type" type="int" setter="set_var_type" getter="get_var_type" enum="Variant.Type">
+ <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">
+ <member name="var_name" type="String" 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/VisualScriptMathConstant.xml b/modules/visual_script/doc_classes/VisualScriptMathConstant.xml
index 430f9ee7d4..3be392aef5 100644
--- a/modules/visual_script/doc_classes/VisualScriptMathConstant.xml
+++ b/modules/visual_script/doc_classes/VisualScriptMathConstant.xml
@@ -15,7 +15,7 @@
<methods>
</methods>
<members>
- <member name="constant" type="int" setter="set_math_constant" getter="get_math_constant" enum="VisualScriptMathConstant.MathConstant">
+ <member name="constant" type="int" setter="set_math_constant" getter="get_math_constant" enum="VisualScriptMathConstant.MathConstant" default="0">
The math constant.
</member>
</members>
@@ -45,6 +45,7 @@
Not a number: [code]nan[/code]
</constant>
<constant name="MATH_CONSTANT_MAX" value="8" enum="MathConstant">
+ Represents the size of the [enum MathConstant] enum.
</constant>
</constants>
</class>
diff --git a/modules/visual_script/doc_classes/VisualScriptOperator.xml b/modules/visual_script/doc_classes/VisualScriptOperator.xml
index a0827972e0..80449ac521 100644
--- a/modules/visual_script/doc_classes/VisualScriptOperator.xml
+++ b/modules/visual_script/doc_classes/VisualScriptOperator.xml
@@ -14,9 +14,9 @@
<methods>
</methods>
<members>
- <member name="operator" type="int" setter="set_operator" getter="get_operator" enum="Variant.Operator">
+ <member name="operator" type="int" setter="set_operator" getter="get_operator" enum="Variant.Operator" default="6">
</member>
- <member name="type" type="int" setter="set_typed" getter="get_typed" enum="Variant.Type">
+ <member name="type" type="int" setter="set_typed" getter="get_typed" enum="Variant.Type" default="0">
</member>
</members>
<constants>
diff --git a/modules/visual_script/doc_classes/VisualScriptPreload.xml b/modules/visual_script/doc_classes/VisualScriptPreload.xml
index b3b39691c9..05ed0ad1e5 100644
--- a/modules/visual_script/doc_classes/VisualScriptPreload.xml
+++ b/modules/visual_script/doc_classes/VisualScriptPreload.xml
@@ -15,7 +15,7 @@
<methods>
</methods>
<members>
- <member name="resource" type="Resource" setter="set_preload" getter="get_preload">
+ <member name="resource" type="Resource" setter="set_preload" getter="get_preload" default="null">
The [Resource] to load.
</member>
</members>
diff --git a/modules/visual_script/doc_classes/VisualScriptPropertyGet.xml b/modules/visual_script/doc_classes/VisualScriptPropertyGet.xml
index 697a31ca46..af1e8e68e8 100644
--- a/modules/visual_script/doc_classes/VisualScriptPropertyGet.xml
+++ b/modules/visual_script/doc_classes/VisualScriptPropertyGet.xml
@@ -11,7 +11,7 @@
<members>
<member name="base_script" type="String" setter="set_base_script" getter="get_base_script">
</member>
- <member name="base_type" type="String" setter="set_base_type" getter="get_base_type">
+ <member name="base_type" type="String" 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>
@@ -19,9 +19,9 @@
</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">
+ <member name="property" type="String" 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">
+ <member name="set_mode" type="int" setter="set_call_mode" getter="get_call_mode" enum="VisualScriptPropertyGet.CallMode" default="0">
</member>
</members>
<constants>
diff --git a/modules/visual_script/doc_classes/VisualScriptPropertySet.xml b/modules/visual_script/doc_classes/VisualScriptPropertySet.xml
index c41e3781d4..380c196caf 100644
--- a/modules/visual_script/doc_classes/VisualScriptPropertySet.xml
+++ b/modules/visual_script/doc_classes/VisualScriptPropertySet.xml
@@ -9,11 +9,11 @@
<methods>
</methods>
<members>
- <member name="assign_op" type="int" setter="set_assign_op" getter="get_assign_op" enum="VisualScriptPropertySet.AssignOp">
+ <member name="assign_op" type="int" setter="set_assign_op" getter="get_assign_op" enum="VisualScriptPropertySet.AssignOp" default="0">
</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">
+ <member name="base_type" type="String" 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>
@@ -21,9 +21,9 @@
</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">
+ <member name="property" type="String" 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">
+ <member name="set_mode" type="int" setter="set_call_mode" getter="get_call_mode" enum="VisualScriptPropertySet.CallMode" default="0">
</member>
</members>
<constants>
diff --git a/modules/visual_script/doc_classes/VisualScriptResourcePath.xml b/modules/visual_script/doc_classes/VisualScriptResourcePath.xml
index 40862b810b..da37bbbb2c 100644
--- a/modules/visual_script/doc_classes/VisualScriptResourcePath.xml
+++ b/modules/visual_script/doc_classes/VisualScriptResourcePath.xml
@@ -9,7 +9,7 @@
<methods>
</methods>
<members>
- <member name="path" type="String" setter="set_resource_path" getter="get_resource_path">
+ <member name="path" type="String" setter="set_resource_path" getter="get_resource_path" default="&quot;&quot;">
</member>
</members>
<constants>
diff --git a/modules/visual_script/doc_classes/VisualScriptReturn.xml b/modules/visual_script/doc_classes/VisualScriptReturn.xml
index 40c8963efe..9a81c671d4 100644
--- a/modules/visual_script/doc_classes/VisualScriptReturn.xml
+++ b/modules/visual_script/doc_classes/VisualScriptReturn.xml
@@ -16,10 +16,10 @@
<methods>
</methods>
<members>
- <member name="return_enabled" type="bool" setter="set_enable_return_value" getter="is_return_value_enabled">
+ <member name="return_enabled" type="bool" setter="set_enable_return_value" getter="is_return_value_enabled" default="false">
If [code]true[/code], the [code]return[/code] input port is available.
</member>
- <member name="return_type" type="int" setter="set_return_type" getter="get_return_type" enum="Variant.Type">
+ <member name="return_type" type="int" setter="set_return_type" getter="get_return_type" enum="Variant.Type" default="0">
The return value's data type.
</member>
</members>
diff --git a/modules/visual_script/doc_classes/VisualScriptSceneNode.xml b/modules/visual_script/doc_classes/VisualScriptSceneNode.xml
index 81ef4ceedc..99f4acbd27 100644
--- a/modules/visual_script/doc_classes/VisualScriptSceneNode.xml
+++ b/modules/visual_script/doc_classes/VisualScriptSceneNode.xml
@@ -15,7 +15,7 @@
<methods>
</methods>
<members>
- <member name="node_path" type="NodePath" setter="set_node_path" getter="get_node_path">
+ <member name="node_path" type="NodePath" setter="set_node_path" getter="get_node_path" default="NodePath(&quot;.&quot;)">
The node's path in the scene tree.
</member>
</members>
diff --git a/modules/visual_script/doc_classes/VisualScriptSelect.xml b/modules/visual_script/doc_classes/VisualScriptSelect.xml
index 3b1e7f7f02..e6a6cd5a48 100644
--- a/modules/visual_script/doc_classes/VisualScriptSelect.xml
+++ b/modules/visual_script/doc_classes/VisualScriptSelect.xml
@@ -17,7 +17,7 @@
<methods>
</methods>
<members>
- <member name="type" type="int" setter="set_typed" getter="get_typed" enum="Variant.Type">
+ <member name="type" type="int" setter="set_typed" getter="get_typed" enum="Variant.Type" default="0">
The input variables' type.
</member>
</members>
diff --git a/modules/visual_script/doc_classes/VisualScriptSequence.xml b/modules/visual_script/doc_classes/VisualScriptSequence.xml
index 26af15b404..2ceceb199f 100644
--- a/modules/visual_script/doc_classes/VisualScriptSequence.xml
+++ b/modules/visual_script/doc_classes/VisualScriptSequence.xml
@@ -17,7 +17,7 @@
<methods>
</methods>
<members>
- <member name="steps" type="int" setter="set_steps" getter="get_steps">
+ <member name="steps" type="int" setter="set_steps" getter="get_steps" default="1">
The number of steps in the sequence.
</member>
</members>
diff --git a/modules/visual_script/doc_classes/VisualScriptSwitch.xml b/modules/visual_script/doc_classes/VisualScriptSwitch.xml
index 35929b16ac..3e3b88ebe0 100644
--- a/modules/visual_script/doc_classes/VisualScriptSwitch.xml
+++ b/modules/visual_script/doc_classes/VisualScriptSwitch.xml
@@ -4,7 +4,7 @@
Branches program flow based on a given input's value.
</brief_description>
<description>
- Branches the flow based on an input's value. Use "Case Count" in the Inspector to set the number of branches and each comparison's optional type.
+ Branches the flow based on an input's value. Use [b]Case Count[/b] in the Inspector to set the number of branches and each comparison's optional type.
[b]Input Ports:[/b]
- Sequence: [code]'input' is[/code]
- Data (variant): [code]=[/code]
diff --git a/modules/visual_script/doc_classes/VisualScriptTypeCast.xml b/modules/visual_script/doc_classes/VisualScriptTypeCast.xml
index a9e920bca6..999a190a9a 100644
--- a/modules/visual_script/doc_classes/VisualScriptTypeCast.xml
+++ b/modules/visual_script/doc_classes/VisualScriptTypeCast.xml
@@ -9,9 +9,9 @@
<methods>
</methods>
<members>
- <member name="base_script" type="String" setter="set_base_script" getter="get_base_script">
+ <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">
+ <member name="base_type" type="String" 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 e1c7c4e4d4..40e461294b 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">
+ <member name="var_name" type="String" 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 7339482908..6c53ad61b4 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">
+ <member name="var_name" type="String" setter="set_variable" getter="get_variable" default="&quot;&quot;">
The variable's name.
</member>
</members>
diff --git a/modules/visual_script/doc_classes/VisualScriptYield.xml b/modules/visual_script/doc_classes/VisualScriptYield.xml
index 9f61a5f88c..c506e6db01 100644
--- a/modules/visual_script/doc_classes/VisualScriptYield.xml
+++ b/modules/visual_script/doc_classes/VisualScriptYield.xml
@@ -9,7 +9,7 @@
<methods>
</methods>
<members>
- <member name="mode" type="int" setter="set_yield_mode" getter="get_yield_mode" enum="VisualScriptYield.YieldMode">
+ <member name="mode" type="int" setter="set_yield_mode" getter="get_yield_mode" enum="VisualScriptYield.YieldMode" default="1">
</member>
<member name="wait_time" type="float" setter="set_wait_time" getter="get_wait_time">
</member>
diff --git a/modules/visual_script/doc_classes/VisualScriptYieldSignal.xml b/modules/visual_script/doc_classes/VisualScriptYieldSignal.xml
index 6791375182..b9d7aedaab 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">
+ <member name="base_type" type="String" 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">
+ <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">
+ <member name="signal" type="String" setter="set_signal" getter="get_signal" default="&quot;&quot;">
</member>
</members>
<constants>
diff --git a/modules/visual_script/icons/icon_visual_script.svg b/modules/visual_script/icons/icon_visual_script.svg
new file mode 100644
index 0000000000..f6475d590e
--- /dev/null
+++ b/modules/visual_script/icons/icon_visual_script.svg
@@ -0,0 +1,6 @@
+<svg width="16" height="16" version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
+<g transform="translate(0 -1036.4)">
+<ellipse cx="3" cy="1039.4" r="2" fill="#6e6e6e"/>
+<path transform="translate(0 1036.4)" d="m7 1l-0.56445 2.2578a5 5 0 0 0 -0.68945 0.2793l-1.9883-1.1934-1.4141 1.4141 1.1953 1.9941a5 5 0 0 0 -0.28516 0.68555l-2.2539 0.5625v2h5.2715a2 2 0 0 1 -0.27148 -1 2 2 0 0 1 2 -2 2 2 0 0 1 2 2 2 2 0 0 1 -0.26953 1h5.2695v-2l-2.2578-0.56445a5 5 0 0 0 -0.2793 -0.6875l1.1934-1.9902-1.4141-1.4141-1.9941 1.1953a5 5 0 0 0 -0.68555 -0.28516l-0.5625-2.2539h-2zm-4 9v6h2a3 3 0 0 0 3 -3v-3h-2v3a1 1 0 0 1 -1 1v-4h-2zm8 0a2 2 0 0 0 -1.7324 1 2 2 0 0 0 0 2 2 2 0 0 0 1.7324 1h-2v2h2a2 2 0 0 0 1.7324 -1 2 2 0 0 0 0 -2 2 2 0 0 0 -1.7324 -1h2v-2h-2z" fill="#e0e0e0"/>
+</g>
+</svg>
diff --git a/modules/visual_script/visual_script.cpp b/modules/visual_script/visual_script.cpp
index 85fc867901..df5bb9ca2e 100644
--- a/modules/visual_script/visual_script.cpp
+++ b/modules/visual_script/visual_script.cpp
@@ -1692,7 +1692,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 < 0 || output >= node->sequence_output_count) {
+ if (output >= node->sequence_output_count) {
r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
error_str = RTR("Node returned an invalid sequence output: ") + itos(output);
error = true;
diff --git a/modules/visual_script/visual_script.h b/modules/visual_script/visual_script.h
index 89f32f54f7..098c28370d 100644
--- a/modules/visual_script/visual_script.h
+++ b/modules/visual_script/visual_script.h
@@ -39,7 +39,7 @@ class VisualScriptNodeInstance;
class VisualScript;
class VisualScriptNode : public Resource {
- GDCLASS(VisualScriptNode, Resource)
+ GDCLASS(VisualScriptNode, Resource);
friend class VisualScript;
@@ -165,7 +165,7 @@ public:
class VisualScript : public Script {
- GDCLASS(VisualScript, Script)
+ GDCLASS(VisualScript, Script);
RES_BASE_EXTENSION("vs");
diff --git a/modules/visual_script/visual_script_builtin_funcs.h b/modules/visual_script/visual_script_builtin_funcs.h
index 3e452cd94f..f009f49b5b 100644
--- a/modules/visual_script/visual_script_builtin_funcs.h
+++ b/modules/visual_script/visual_script_builtin_funcs.h
@@ -35,7 +35,8 @@
class VisualScriptBuiltinFunc : public VisualScriptNode {
- GDCLASS(VisualScriptBuiltinFunc, VisualScriptNode)
+ GDCLASS(VisualScriptBuiltinFunc, VisualScriptNode);
+
public:
enum BuiltinFunc {
MATH_SIN,
diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp
index aad6e95845..4579644d49 100644
--- a/modules/visual_script/visual_script_editor.cpp
+++ b/modules/visual_script/visual_script_editor.cpp
@@ -46,7 +46,7 @@
#ifdef TOOLS_ENABLED
class VisualScriptEditorSignalEdit : public Object {
- GDCLASS(VisualScriptEditorSignalEdit, Object)
+ GDCLASS(VisualScriptEditorSignalEdit, Object);
StringName sig;
@@ -186,7 +186,7 @@ public:
class VisualScriptEditorVariableEdit : public Object {
- GDCLASS(VisualScriptEditorVariableEdit, Object)
+ GDCLASS(VisualScriptEditorVariableEdit, Object);
StringName var;
@@ -1099,6 +1099,9 @@ void VisualScriptEditor::_expression_text_changed(const String &p_text, int p_id
void VisualScriptEditor::_available_node_doubleclicked() {
+ if (edited_func == String())
+ return;
+
TreeItem *item = nodes->get_selected();
if (!item)
@@ -1107,7 +1110,6 @@ void VisualScriptEditor::_available_node_doubleclicked() {
String which = item->get_metadata(0);
if (which == String())
return;
-
Vector2 ofs = graph->get_scroll_ofs() + graph->get_size() * 0.5;
if (graph->is_using_snap()) {
@@ -2111,6 +2113,9 @@ void VisualScriptEditor::clear_executing_line() {
void VisualScriptEditor::trim_trailing_whitespace() {
}
+void VisualScriptEditor::insert_final_newline() {
+}
+
void VisualScriptEditor::convert_indent_to_spaces() {
}
@@ -3756,4 +3761,7 @@ void _VisualScriptEditor::_bind_methods() {
ClassDB::bind_method(D_METHOD("remove_custom_node", "name", "category"), &_VisualScriptEditor::remove_custom_node);
ADD_SIGNAL(MethodInfo("custom_nodes_updated"));
}
+
+void VisualScriptEditor::validate() {
+}
#endif
diff --git a/modules/visual_script/visual_script_editor.h b/modules/visual_script/visual_script_editor.h
index 3d3a49f672..4f302d1d72 100644
--- a/modules/visual_script/visual_script_editor.h
+++ b/modules/visual_script/visual_script_editor.h
@@ -44,7 +44,7 @@ class VisualScriptEditorVariableEdit;
#ifdef TOOLS_ENABLED
class VisualScriptEditor : public ScriptEditorBase {
- GDCLASS(VisualScriptEditor, ScriptEditorBase)
+ GDCLASS(VisualScriptEditor, ScriptEditorBase);
enum {
TYPE_SEQUENCE = 1000,
@@ -266,6 +266,7 @@ public:
virtual void set_executing_line(int p_line);
virtual void clear_executing_line();
virtual void trim_trailing_whitespace();
+ virtual void insert_final_newline();
virtual void convert_indent_to_spaces();
virtual void convert_indent_to_tabs();
virtual void ensure_focus();
@@ -280,6 +281,7 @@ public:
virtual Control *get_edit_menu();
virtual void clear_edit_menu();
virtual bool can_lose_focus_on_node_selection() { return false; }
+ virtual void validate();
static void register_editor();
diff --git a/modules/visual_script/visual_script_expression.cpp b/modules/visual_script/visual_script_expression.cpp
index 772092fabe..4b74c088e0 100644
--- a/modules/visual_script/visual_script_expression.cpp
+++ b/modules/visual_script/visual_script_expression.cpp
@@ -1130,7 +1130,7 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() {
if (next_op == -1) {
_set_error("Yet another parser bug....");
- ERR_FAIL_COND_V(next_op == -1, NULL);
+ ERR_FAIL_V(NULL);
}
// OK! create operator..
diff --git a/modules/visual_script/visual_script_expression.h b/modules/visual_script/visual_script_expression.h
index 3b2e3b9f78..3a045d2cf7 100644
--- a/modules/visual_script/visual_script_expression.h
+++ b/modules/visual_script/visual_script_expression.h
@@ -36,7 +36,7 @@
class VisualScriptExpression : public VisualScriptNode {
- GDCLASS(VisualScriptExpression, VisualScriptNode)
+ GDCLASS(VisualScriptExpression, VisualScriptNode);
friend class VisualScriptNodeInstanceExpression;
struct Input {
diff --git a/modules/visual_script/visual_script_flow_control.h b/modules/visual_script/visual_script_flow_control.h
index a42605a50e..d3c7aa68e3 100644
--- a/modules/visual_script/visual_script_flow_control.h
+++ b/modules/visual_script/visual_script_flow_control.h
@@ -35,7 +35,7 @@
class VisualScriptReturn : public VisualScriptNode {
- GDCLASS(VisualScriptReturn, VisualScriptNode)
+ GDCLASS(VisualScriptReturn, VisualScriptNode);
Variant::Type type;
bool with_value;
@@ -72,7 +72,7 @@ public:
class VisualScriptCondition : public VisualScriptNode {
- GDCLASS(VisualScriptCondition, VisualScriptNode)
+ GDCLASS(VisualScriptCondition, VisualScriptNode);
protected:
static void _bind_methods();
@@ -100,7 +100,7 @@ public:
class VisualScriptWhile : public VisualScriptNode {
- GDCLASS(VisualScriptWhile, VisualScriptNode)
+ GDCLASS(VisualScriptWhile, VisualScriptNode);
protected:
static void _bind_methods();
@@ -128,7 +128,7 @@ public:
class VisualScriptIterator : public VisualScriptNode {
- GDCLASS(VisualScriptIterator, VisualScriptNode)
+ GDCLASS(VisualScriptIterator, VisualScriptNode);
protected:
static void _bind_methods();
@@ -156,7 +156,7 @@ public:
class VisualScriptSequence : public VisualScriptNode {
- GDCLASS(VisualScriptSequence, VisualScriptNode)
+ GDCLASS(VisualScriptSequence, VisualScriptNode);
int steps;
@@ -189,7 +189,7 @@ public:
class VisualScriptSwitch : public VisualScriptNode {
- GDCLASS(VisualScriptSwitch, VisualScriptNode)
+ GDCLASS(VisualScriptSwitch, VisualScriptNode);
struct Case {
Variant::Type type;
@@ -231,7 +231,7 @@ public:
class VisualScriptTypeCast : public VisualScriptNode {
- GDCLASS(VisualScriptTypeCast, VisualScriptNode)
+ GDCLASS(VisualScriptTypeCast, VisualScriptNode);
StringName base_type;
String script;
diff --git a/modules/visual_script/visual_script_func_nodes.cpp b/modules/visual_script/visual_script_func_nodes.cpp
index 8fa7d2c0d4..f8cb6cfa3c 100644
--- a/modules/visual_script/visual_script_func_nodes.cpp
+++ b/modules/visual_script/visual_script_func_nodes.cpp
@@ -51,10 +51,7 @@ int VisualScriptFunctionCall::get_output_sequence_port_count() const {
bool VisualScriptFunctionCall::has_input_sequence_port() const {
- if ((method_cache.flags & METHOD_FLAG_CONST && call_mode != CALL_MODE_INSTANCE) || (call_mode == CALL_MODE_BASIC_TYPE && Variant::is_method_const(basic_type, function)))
- return false;
- else
- return true;
+ return !((method_cache.flags & METHOD_FLAG_CONST && call_mode != CALL_MODE_INSTANCE) || (call_mode == CALL_MODE_BASIC_TYPE && Variant::is_method_const(basic_type, function)));
}
#ifdef TOOLS_ENABLED
@@ -949,7 +946,7 @@ int VisualScriptPropertySet::get_output_sequence_port_count() const {
bool VisualScriptPropertySet::has_input_sequence_port() const {
- return call_mode != CALL_MODE_BASIC_TYPE ? true : false;
+ return call_mode != CALL_MODE_BASIC_TYPE;
}
Node *VisualScriptPropertySet::_get_base_node() const {
diff --git a/modules/visual_script/visual_script_func_nodes.h b/modules/visual_script/visual_script_func_nodes.h
index 7b1e7871b6..11eb96293b 100644
--- a/modules/visual_script/visual_script_func_nodes.h
+++ b/modules/visual_script/visual_script_func_nodes.h
@@ -35,7 +35,8 @@
class VisualScriptFunctionCall : public VisualScriptNode {
- GDCLASS(VisualScriptFunctionCall, VisualScriptNode)
+ GDCLASS(VisualScriptFunctionCall, VisualScriptNode);
+
public:
enum CallMode {
CALL_MODE_SELF,
@@ -137,7 +138,8 @@ VARIANT_ENUM_CAST(VisualScriptFunctionCall::RPCCallMode);
class VisualScriptPropertySet : public VisualScriptNode {
- GDCLASS(VisualScriptPropertySet, VisualScriptNode)
+ GDCLASS(VisualScriptPropertySet, VisualScriptNode);
+
public:
enum CallMode {
CALL_MODE_SELF,
@@ -242,7 +244,8 @@ VARIANT_ENUM_CAST(VisualScriptPropertySet::AssignOp);
class VisualScriptPropertyGet : public VisualScriptNode {
- GDCLASS(VisualScriptPropertyGet, VisualScriptNode)
+ GDCLASS(VisualScriptPropertyGet, VisualScriptNode);
+
public:
enum CallMode {
CALL_MODE_SELF,
@@ -323,7 +326,7 @@ VARIANT_ENUM_CAST(VisualScriptPropertyGet::CallMode);
class VisualScriptEmitSignal : public VisualScriptNode {
- GDCLASS(VisualScriptEmitSignal, VisualScriptNode)
+ GDCLASS(VisualScriptEmitSignal, VisualScriptNode);
private:
StringName name;
diff --git a/modules/visual_script/visual_script_nodes.h b/modules/visual_script/visual_script_nodes.h
index b3d199fb38..762a1bdfb6 100644
--- a/modules/visual_script/visual_script_nodes.h
+++ b/modules/visual_script/visual_script_nodes.h
@@ -35,7 +35,7 @@
class VisualScriptFunction : public VisualScriptNode {
- GDCLASS(VisualScriptFunction, VisualScriptNode)
+ GDCLASS(VisualScriptFunction, VisualScriptNode);
struct Argument {
String name;
@@ -105,7 +105,7 @@ public:
class VisualScriptOperator : public VisualScriptNode {
- GDCLASS(VisualScriptOperator, VisualScriptNode)
+ GDCLASS(VisualScriptOperator, VisualScriptNode);
Variant::Type typed;
Variant::Operator op;
@@ -141,7 +141,7 @@ public:
class VisualScriptSelect : public VisualScriptNode {
- GDCLASS(VisualScriptSelect, VisualScriptNode)
+ GDCLASS(VisualScriptSelect, VisualScriptNode);
Variant::Type typed;
@@ -174,7 +174,7 @@ public:
class VisualScriptVariableGet : public VisualScriptNode {
- GDCLASS(VisualScriptVariableGet, VisualScriptNode)
+ GDCLASS(VisualScriptVariableGet, VisualScriptNode);
StringName variable;
@@ -207,7 +207,7 @@ public:
class VisualScriptVariableSet : public VisualScriptNode {
- GDCLASS(VisualScriptVariableSet, VisualScriptNode)
+ GDCLASS(VisualScriptVariableSet, VisualScriptNode);
StringName variable;
@@ -240,7 +240,7 @@ public:
class VisualScriptConstant : public VisualScriptNode {
- GDCLASS(VisualScriptConstant, VisualScriptNode)
+ GDCLASS(VisualScriptConstant, VisualScriptNode);
Variant::Type type;
Variant value;
@@ -277,7 +277,7 @@ public:
class VisualScriptPreload : public VisualScriptNode {
- GDCLASS(VisualScriptPreload, VisualScriptNode)
+ GDCLASS(VisualScriptPreload, VisualScriptNode);
Ref<Resource> preload;
@@ -309,7 +309,7 @@ public:
class VisualScriptIndexGet : public VisualScriptNode {
- GDCLASS(VisualScriptIndexGet, VisualScriptNode)
+ GDCLASS(VisualScriptIndexGet, VisualScriptNode);
public:
virtual int get_output_sequence_port_count() const;
@@ -333,7 +333,7 @@ public:
class VisualScriptIndexSet : public VisualScriptNode {
- GDCLASS(VisualScriptIndexSet, VisualScriptNode)
+ GDCLASS(VisualScriptIndexSet, VisualScriptNode);
public:
virtual int get_output_sequence_port_count() const;
@@ -357,7 +357,7 @@ public:
class VisualScriptGlobalConstant : public VisualScriptNode {
- GDCLASS(VisualScriptGlobalConstant, VisualScriptNode)
+ GDCLASS(VisualScriptGlobalConstant, VisualScriptNode);
int index;
@@ -388,7 +388,7 @@ public:
class VisualScriptClassConstant : public VisualScriptNode {
- GDCLASS(VisualScriptClassConstant, VisualScriptNode)
+ GDCLASS(VisualScriptClassConstant, VisualScriptNode);
StringName base_type;
StringName name;
@@ -425,7 +425,7 @@ public:
class VisualScriptBasicTypeConstant : public VisualScriptNode {
- GDCLASS(VisualScriptBasicTypeConstant, VisualScriptNode)
+ GDCLASS(VisualScriptBasicTypeConstant, VisualScriptNode);
Variant::Type type;
StringName name;
@@ -463,7 +463,8 @@ public:
class VisualScriptMathConstant : public VisualScriptNode {
- GDCLASS(VisualScriptMathConstant, VisualScriptNode)
+ GDCLASS(VisualScriptMathConstant, VisualScriptNode);
+
public:
enum MathConstant {
MATH_CONSTANT_ONE,
@@ -512,7 +513,7 @@ VARIANT_ENUM_CAST(VisualScriptMathConstant::MathConstant)
class VisualScriptEngineSingleton : public VisualScriptNode {
- GDCLASS(VisualScriptEngineSingleton, VisualScriptNode)
+ GDCLASS(VisualScriptEngineSingleton, VisualScriptNode);
String singleton;
@@ -545,7 +546,7 @@ public:
class VisualScriptSceneNode : public VisualScriptNode {
- GDCLASS(VisualScriptSceneNode, VisualScriptNode)
+ GDCLASS(VisualScriptSceneNode, VisualScriptNode);
NodePath path;
@@ -580,7 +581,7 @@ public:
class VisualScriptSceneTree : public VisualScriptNode {
- GDCLASS(VisualScriptSceneTree, VisualScriptNode)
+ GDCLASS(VisualScriptSceneTree, VisualScriptNode);
protected:
virtual void _validate_property(PropertyInfo &property) const;
@@ -610,7 +611,7 @@ public:
class VisualScriptResourcePath : public VisualScriptNode {
- GDCLASS(VisualScriptResourcePath, VisualScriptNode)
+ GDCLASS(VisualScriptResourcePath, VisualScriptNode);
String path;
@@ -642,7 +643,7 @@ public:
class VisualScriptSelf : public VisualScriptNode {
- GDCLASS(VisualScriptSelf, VisualScriptNode)
+ GDCLASS(VisualScriptSelf, VisualScriptNode);
protected:
static void _bind_methods();
@@ -671,7 +672,7 @@ public:
class VisualScriptCustomNode : public VisualScriptNode {
- GDCLASS(VisualScriptCustomNode, VisualScriptNode)
+ GDCLASS(VisualScriptCustomNode, VisualScriptNode);
protected:
static void _bind_methods();
@@ -719,7 +720,7 @@ VARIANT_ENUM_CAST(VisualScriptCustomNode::StartMode);
class VisualScriptSubCall : public VisualScriptNode {
- GDCLASS(VisualScriptSubCall, VisualScriptNode)
+ GDCLASS(VisualScriptSubCall, VisualScriptNode);
protected:
static void _bind_methods();
@@ -747,7 +748,7 @@ public:
class VisualScriptComment : public VisualScriptNode {
- GDCLASS(VisualScriptComment, VisualScriptNode)
+ GDCLASS(VisualScriptComment, VisualScriptNode);
String title;
String description;
@@ -788,7 +789,7 @@ public:
class VisualScriptConstructor : public VisualScriptNode {
- GDCLASS(VisualScriptConstructor, VisualScriptNode)
+ GDCLASS(VisualScriptConstructor, VisualScriptNode);
Variant::Type type;
MethodInfo constructor;
@@ -824,7 +825,7 @@ public:
class VisualScriptLocalVar : public VisualScriptNode {
- GDCLASS(VisualScriptLocalVar, VisualScriptNode)
+ GDCLASS(VisualScriptLocalVar, VisualScriptNode);
StringName name;
Variant::Type type;
@@ -860,7 +861,7 @@ public:
class VisualScriptLocalVarSet : public VisualScriptNode {
- GDCLASS(VisualScriptLocalVarSet, VisualScriptNode)
+ GDCLASS(VisualScriptLocalVarSet, VisualScriptNode);
StringName name;
Variant::Type type;
@@ -897,7 +898,8 @@ public:
class VisualScriptInputAction : public VisualScriptNode {
- GDCLASS(VisualScriptInputAction, VisualScriptNode)
+ GDCLASS(VisualScriptInputAction, VisualScriptNode);
+
public:
enum Mode {
MODE_PRESSED,
@@ -944,7 +946,7 @@ VARIANT_ENUM_CAST(VisualScriptInputAction::Mode)
class VisualScriptDeconstruct : public VisualScriptNode {
- GDCLASS(VisualScriptDeconstruct, VisualScriptNode)
+ GDCLASS(VisualScriptDeconstruct, VisualScriptNode);
struct Element {
StringName name;
diff --git a/modules/visual_script/visual_script_property_selector.cpp b/modules/visual_script/visual_script_property_selector.cpp
index ceec79c0d5..1e7ed3019c 100644
--- a/modules/visual_script/visual_script_property_selector.cpp
+++ b/modules/visual_script/visual_script_property_selector.cpp
@@ -188,7 +188,6 @@ void VisualScriptPropertySelector::_update_search() {
}
}
}
- bool script_methods = false;
{
if (type != Variant::NIL) {
Variant v;
@@ -211,7 +210,7 @@ void VisualScriptPropertySelector::_update_search() {
for (List<MethodInfo>::Element *M = methods.front(); M; M = M->next()) {
String name = M->get().name.get_slice(":", 0);
- if (!script_methods && name.begins_with("_") && !(M->get().flags & METHOD_FLAG_VIRTUAL))
+ if (name.begins_with("_") && !(M->get().flags & METHOD_FLAG_VIRTUAL))
continue;
if (virtuals_only && !(M->get().flags & METHOD_FLAG_VIRTUAL))
diff --git a/modules/visual_script/visual_script_property_selector.h b/modules/visual_script/visual_script_property_selector.h
index 1588243bc1..6235e4ba1d 100644
--- a/modules/visual_script/visual_script_property_selector.h
+++ b/modules/visual_script/visual_script_property_selector.h
@@ -36,7 +36,7 @@
#include "scene/gui/rich_text_label.h"
class VisualScriptPropertySelector : public ConfirmationDialog {
- GDCLASS(VisualScriptPropertySelector, ConfirmationDialog)
+ GDCLASS(VisualScriptPropertySelector, ConfirmationDialog);
LineEdit *search_box;
Tree *search_options;
diff --git a/modules/visual_script/visual_script_yield_nodes.h b/modules/visual_script/visual_script_yield_nodes.h
index 851bf6aa74..647f2b1e2e 100644
--- a/modules/visual_script/visual_script_yield_nodes.h
+++ b/modules/visual_script/visual_script_yield_nodes.h
@@ -35,7 +35,8 @@
class VisualScriptYield : public VisualScriptNode {
- GDCLASS(VisualScriptYield, VisualScriptNode)
+ GDCLASS(VisualScriptYield, VisualScriptNode);
+
public:
enum YieldMode {
YIELD_RETURN,
@@ -84,7 +85,8 @@ VARIANT_ENUM_CAST(VisualScriptYield::YieldMode)
class VisualScriptYieldSignal : public VisualScriptNode {
- GDCLASS(VisualScriptYieldSignal, VisualScriptNode)
+ GDCLASS(VisualScriptYieldSignal, VisualScriptNode);
+
public:
enum CallMode {
CALL_MODE_SELF,
diff --git a/modules/vorbis/audio_stream_ogg_vorbis.cpp b/modules/vorbis/audio_stream_ogg_vorbis.cpp
index 692705e411..e652abbe6a 100644
--- a/modules/vorbis/audio_stream_ogg_vorbis.cpp
+++ b/modules/vorbis/audio_stream_ogg_vorbis.cpp
@@ -143,8 +143,7 @@ int AudioStreamPlaybackOGGVorbis::mix(int16_t *p_buffer, int p_frames) {
bool ok = ov_time_seek(&vf, loop_restart_time) == 0;
if (!ok) {
playing = false;
- //ERR_EXPLAIN("loop restart time rejected");
- ERR_PRINT("loop restart time rejected")
+ ERR_PRINT("Loop restart time rejected");
}
frames_mixed = stream_srate * loop_restart_time;
diff --git a/modules/vorbis/audio_stream_ogg_vorbis.h b/modules/vorbis/audio_stream_ogg_vorbis.h
index fa9d5fe664..a37867d9f9 100644
--- a/modules/vorbis/audio_stream_ogg_vorbis.h
+++ b/modules/vorbis/audio_stream_ogg_vorbis.h
@@ -127,7 +127,6 @@ public:
};
class ResourceFormatLoaderAudioStreamOGGVorbis : public ResourceFormatLoader {
- GDCLASS(ResourceFormatLoaderAudioStreamOGGVorbis, ResourceFormatLoader)
public:
virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL);
virtual void get_recognized_extensions(List<String> *p_extensions) const;
diff --git a/modules/webm/config.py b/modules/webm/config.py
index 72a4073423..ba4dcce2f5 100644
--- a/modules/webm/config.py
+++ b/modules/webm/config.py
@@ -6,7 +6,6 @@ def configure(env):
def get_doc_classes():
return [
- "ResourceImporterWebm",
"VideoStreamWebm",
]
diff --git a/modules/webm/libvpx/SCsub b/modules/webm/libvpx/SCsub
index a6be1380a6..c76585013c 100644
--- a/modules/webm/libvpx/SCsub
+++ b/modules/webm/libvpx/SCsub
@@ -384,8 +384,6 @@ elif webm_cpu_arm:
env_libvpx.add_source_files(env.modules_sources, [libvpx_dir + "third_party/android/cpu-features.c"])
env_libvpx_neon = env_libvpx.Clone()
- if env["platform"] == 'android' and env["android_arch"] == 'armv6':
- env_libvpx_neon.Append(CCFLAGS=['-mfpu=neon'])
env_libvpx_neon.add_source_files(env.modules_sources, libvpx_sources_arm_neon)
if env["platform"] == 'uwp':
diff --git a/modules/webm/video_stream_webm.cpp b/modules/webm/video_stream_webm.cpp
index 6485c95360..3670edc9ea 100644
--- a/modules/webm/video_stream_webm.cpp
+++ b/modules/webm/video_stream_webm.cpp
@@ -413,10 +413,11 @@ void VideoStreamPlaybackWebm::delete_pointers() {
if (audio_frame)
memdelete(audio_frame);
- for (int i = 0; i < video_frames_capacity; ++i)
- memdelete(video_frames[i]);
- if (video_frames)
+ if (video_frames) {
+ for (int i = 0; i < video_frames_capacity; ++i)
+ memdelete(video_frames[i]);
memfree(video_frames);
+ }
if (video)
memdelete(video);
diff --git a/modules/webm/video_stream_webm.h b/modules/webm/video_stream_webm.h
index 992095ba4c..ddcbb1eb08 100644
--- a/modules/webm/video_stream_webm.h
+++ b/modules/webm/video_stream_webm.h
@@ -41,7 +41,7 @@ class OpusVorbisDecoder;
class VideoStreamPlaybackWebm : public VideoStreamPlayback {
- GDCLASS(VideoStreamPlaybackWebm, VideoStreamPlayback)
+ GDCLASS(VideoStreamPlaybackWebm, VideoStreamPlayback);
String file_name;
int audio_track;
@@ -127,7 +127,6 @@ public:
};
class ResourceFormatLoaderWebm : public ResourceFormatLoader {
- GDCLASS(ResourceFormatLoaderWebm, ResourceFormatLoader)
public:
virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL);
virtual void get_recognized_extensions(List<String> *p_extensions) const;
diff --git a/modules/webrtc/config.py b/modules/webrtc/config.py
index 2e3a18ad0e..48b4c33c5d 100644
--- a/modules/webrtc/config.py
+++ b/modules/webrtc/config.py
@@ -7,7 +7,8 @@ def configure(env):
def get_doc_classes():
return [
"WebRTCPeerConnection",
- "WebRTCDataChannel"
+ "WebRTCDataChannel",
+ "WebRTCMultiplayer"
]
def get_doc_path():
diff --git a/modules/webrtc/doc_classes/WebRTCDataChannel.xml b/modules/webrtc/doc_classes/WebRTCDataChannel.xml
index dcc14d4ddb..98715ee99b 100644
--- a/modules/webrtc/doc_classes/WebRTCDataChannel.xml
+++ b/modules/webrtc/doc_classes/WebRTCDataChannel.xml
@@ -11,85 +11,106 @@
<return type="void">
</return>
<description>
+ Closes this data channel, notifying the other peer.
</description>
</method>
<method name="get_id" qualifiers="const">
<return type="int">
</return>
<description>
+ Returns the id assigned to this channel during creation (or auto-assigned during negotiation).
+ If the channel is not negotiated out-of-band the id will only be available after the connection is established (will return [code]65535[/code] until then).
</description>
</method>
<method name="get_label" qualifiers="const">
<return type="String">
</return>
<description>
+ Returns the label assigned to this channel during creation.
</description>
</method>
<method name="get_max_packet_life_time" qualifiers="const">
<return type="int">
</return>
<description>
+ Returns the [code]maxPacketLifeTime[/code] value assigned to this channel during creation.
+ Will be [code]65535[/code] if not specified.
</description>
</method>
<method name="get_max_retransmits" qualifiers="const">
<return type="int">
</return>
<description>
+ Returns the [code]maxRetransmits[/code] value assigned to this channel during creation.
+ Will be [code]65535[/code] if not specified.
</description>
</method>
<method name="get_protocol" qualifiers="const">
<return type="String">
</return>
<description>
+ Returns the sub-protocol assigned to this channel during creation. An empty string if not specified.
</description>
</method>
<method name="get_ready_state" qualifiers="const">
<return type="int" enum="WebRTCDataChannel.ChannelState">
</return>
<description>
+ Returns the current state of this channel, see [enum ChannelState].
</description>
</method>
<method name="is_negotiated" qualifiers="const">
<return type="bool">
</return>
<description>
+ Returns [code]true[/code] if this channel was created with out-of-band configuration.
</description>
</method>
<method name="is_ordered" qualifiers="const">
<return type="bool">
</return>
<description>
+ Returns [code]true[/code] if this channel was created with ordering enabled (default).
</description>
</method>
<method name="poll">
<return type="int" enum="Error">
</return>
<description>
+ Reserved, but not used for now.
</description>
</method>
<method name="was_string_packet" qualifiers="const">
<return type="bool">
</return>
<description>
+ Returns [code]true[/code] if the last received packet was transferred as text. See [member write_mode].
</description>
</method>
</methods>
<members>
- <member name="write_mode" type="int" setter="set_write_mode" getter="get_write_mode" enum="WebRTCDataChannel.WriteMode">
+ <member name="write_mode" type="int" setter="set_write_mode" getter="get_write_mode" enum="WebRTCDataChannel.WriteMode" default="1">
+ The transfer mode to use when sending outgoing packet. Either text or binary.
</member>
</members>
<constants>
<constant name="WRITE_MODE_TEXT" value="0" enum="WriteMode">
+ Tells the channel to send data over this channel as text. An external peer (non-Godot) would receive this as a string.
</constant>
<constant name="WRITE_MODE_BINARY" value="1" enum="WriteMode">
+ Tells the channel to send data over this channel as binary. An external peer (non-Godot) would receive this as array buffer or blob.
</constant>
<constant name="STATE_CONNECTING" value="0" enum="ChannelState">
+ The channel was created, but it's still trying to connect.
</constant>
<constant name="STATE_OPEN" value="1" enum="ChannelState">
+ The channel is currently open, and data can flow over it.
</constant>
<constant name="STATE_CLOSING" value="2" enum="ChannelState">
+ The channel is being closed, no new messages will be accepted, but those already in queue will be flushed.
</constant>
<constant name="STATE_CLOSED" value="3" enum="ChannelState">
+ The channel was closed, or connection failed.
</constant>
</constants>
</class>
diff --git a/modules/webrtc/doc_classes/WebRTCMultiplayer.xml b/modules/webrtc/doc_classes/WebRTCMultiplayer.xml
new file mode 100644
index 0000000000..2b0622fffa
--- /dev/null
+++ b/modules/webrtc/doc_classes/WebRTCMultiplayer.xml
@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<class name="WebRTCMultiplayer" inherits="NetworkedMultiplayerPeer" category="Core" version="3.2">
+ <brief_description>
+ A simple interface to create a peer-to-peer mesh network composed of [WebRTCPeerConnection] that is compatible with the [MultiplayerAPI].
+ </brief_description>
+ <description>
+ This class constructs a full mesh of [WebRTCPeerConnection] (one connection for each peer) that can be used as a [member MultiplayerAPI.network_peer].
+ You can add each [WebRTCPeerConnection] via [method add_peer] or remove them via [method remove_peer]. Peers must be added in [constant WebRTCPeerConnection.STATE_NEW] state to allow it to create the appropriate channels. This class will not create offers nor set descriptions, it will only poll them, and notify connections and disconnections.
+ [signal NetworkedMultiplayerPeer.connection_succeeded] and [signal NetworkedMultiplayerPeer.server_disconnected] will not be emitted unless [code]server_compatibility[/code] is [code]true[/code] in [method initialize]. Beside that data transfer works like in a [NetworkedMultiplayerPeer].
+ </description>
+ <tutorials>
+ </tutorials>
+ <methods>
+ <method name="add_peer">
+ <return type="int" enum="Error">
+ </return>
+ <argument index="0" name="peer" type="WebRTCPeerConnection">
+ </argument>
+ <argument index="1" name="peer_id" type="int">
+ </argument>
+ <argument index="2" name="unreliable_lifetime" type="int" default="1">
+ </argument>
+ <description>
+ Add a new peer to the mesh with the given [code]peer_id[/code]. The [WebRTCPeerConnection] must be in state [constant WebRTCPeerConnection.STATE_NEW].
+ Three channels will be created for reliable, unreliable, and ordered transport. The value of [code]unreliable_lifetime[/code] will be passed to the [code]maxPacketLifetime[/code] option when creating unreliable and ordered channels (see [method WebRTCPeerConnection.create_data_channel]).
+ </description>
+ </method>
+ <method name="close">
+ <return type="void">
+ </return>
+ <description>
+ Close all the add peer connections and channels, freeing all resources.
+ </description>
+ </method>
+ <method name="get_peer">
+ <return type="Dictionary">
+ </return>
+ <argument index="0" name="peer_id" type="int">
+ </argument>
+ <description>
+ Return a dictionary representation of the peer with given [code]peer_id[/code] with three keys. [code]connection[/code] containing the [WebRTCPeerConnection] to this peer, [code]channels[/code] an array of three [WebRTCDataChannel], and [code]connected[/code] a boolean representing if the peer connection is currently connected (all three channels are open).
+ </description>
+ </method>
+ <method name="get_peers">
+ <return type="Dictionary">
+ </return>
+ <description>
+ Returns a dictionary which keys are the peer ids and values the peer representation as in [method get_peer]
+ </description>
+ </method>
+ <method name="has_peer">
+ <return type="bool">
+ </return>
+ <argument index="0" name="peer_id" type="int">
+ </argument>
+ <description>
+ Returns [code]true[/code] if the given [code]peer_id[/code] is in the peers map (it might not be connected though).
+ </description>
+ </method>
+ <method name="initialize">
+ <return type="int" enum="Error">
+ </return>
+ <argument index="0" name="peer_id" type="int">
+ </argument>
+ <argument index="1" name="server_compatibility" type="bool" default="false">
+ </argument>
+ <description>
+ Initialize the multiplayer peer with the given [code]peer_id[/code] (must be between 1 and 2147483647).
+ If [code]server_compatibilty[/code] is [code]false[/code] (default), the multiplayer peer will be immediately in state [constant NetworkedMultiplayerPeer.CONNECTION_CONNECTED] and [signal NetworkedMultiplayerPeer.connection_succeeded] will not be emitted.
+ If [code]server_compatibilty[/code] is [code]true[/code] the peer will suppress all [signal NetworkedMultiplayerPeer.peer_connected] signals until a peer with id [constant NetworkedMultiplayerPeer.TARGET_PEER_SERVER] connects and then emit [signal NetworkedMultiplayerPeer.connection_succeeded]. After that the signal [signal NetworkedMultiplayerPeer.peer_connected] will be emitted for every already connected peer, and any new peer that might connect. If the server peer disconnects after that, signal [signal NetworkedMultiplayerPeer.server_disconnected] will be emitted and state will become [constant NetworkedMultiplayerPeer.CONNECTION_CONNECTED].
+ </description>
+ </method>
+ <method name="remove_peer">
+ <return type="void">
+ </return>
+ <argument index="0" name="peer_id" type="int">
+ </argument>
+ <description>
+ Remove the peer with given [code]peer_id[/code] from the mesh. If the peer was connected, and [signal NetworkedMultiplayerPeer.peer_connected] was emitted for it, then [signal NetworkedMultiplayerPeer.peer_disconnected] will be emitted.
+ </description>
+ </method>
+ </methods>
+ <constants>
+ </constants>
+</class>
diff --git a/modules/webrtc/doc_classes/WebRTCPeerConnection.xml b/modules/webrtc/doc_classes/WebRTCPeerConnection.xml
index 8b14c60deb..26082d73a8 100644
--- a/modules/webrtc/doc_classes/WebRTCPeerConnection.xml
+++ b/modules/webrtc/doc_classes/WebRTCPeerConnection.xml
@@ -1,8 +1,15 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="WebRTCPeerConnection" inherits="Reference" category="Core" version="3.2">
<brief_description>
+ Interface to a WebRTC peer connection.
</brief_description>
<description>
+ A WebRTC connection between the local computer and a remote peer. Provides an interface to connect, maintain and monitor the connection.
+ Setting up a WebRTC connection between two peers from now on) may not seem a trivial task, but it can be broken down into 3 main steps:
+ - The peer that wants to initiate the connection ([code]A[/code] from now on) creates an offer and send it to the other peer ([code]B[/code] from now on).
+ - [code]B[/code] receives the offer, generate and answer, and sends it to [code]A[/code]).
+ - [code]A[/code] and [code]B[/code] then generates and exchange ICE candidates with each other.
+ After these steps, the connection should become connected. Keep on reading or look into the tutorial for more information.
</description>
<tutorials>
</tutorials>
@@ -17,12 +24,14 @@
<argument index="2" name="name" type="String">
</argument>
<description>
+ Add an ice candidate generated by a remote peer (and received over the signaling server). See [signal ice_candidate_created].
</description>
</method>
<method name="close">
<return type="void">
</return>
<description>
+ Close the peer connection and all data channels associated with it. Note, you cannot reuse this object for a new connection unless you call [method initialize].
</description>
</method>
<method name="create_data_channel">
@@ -35,18 +44,38 @@
}">
</argument>
<description>
+ Returns a new [WebRTCDataChannel] (or [code]null[/code] on failure) with given [code]label[/code] and optionally configured via the [code]options[/code] dictionary. This method can only be called when the connection is in state [constant STATE_NEW].
+ There are two ways to create a working data channel: either call [method create_data_channel] on only one of the peer and listen to [signal data_channel_received] on the other, or call [method create_data_channel] on both peers, with the same values, and the [code]negotiated[/code] option set to [code]true[/code].
+ Valid [code]options[/code] are:
+ [codeblock]
+ {
+ "negotiated": true, # When set to true (default off), means the channel is negotiated out of band. "id" must be set too. data_channel_received will not be called.
+ "id": 1, # When "negotiated" is true this value must also be set to the same value on both peer.
+
+ # Only one of maxRetransmits and maxPacketLifeTime can be specified, not both. They make the channel unreliable (but also better at real time).
+ "maxRetransmits": 1, # Specify the maximum number of attempt the peer will make to retransmits packets if they are not acknowledged.
+ "maxPacketLifeTime": 100, # Specify the maximum amount of time before giving up retransmitions of unacknowledged packets (in milliseconds).
+ "ordered": true, # When in unreliable mode (i.e. either "maxRetransmits" or "maxPacketLifetime" is set), "ordered" (true by default) specify if packet ordering is to be enforced.
+
+ "protocol": "my-custom-protocol", # A custom sub-protocol string for this channel.
+ }
+ [/codeblock]
+ [b]Note:[/b] You must keep a reference to channels created this way, or it will be closed.
</description>
</method>
<method name="create_offer">
<return type="int" enum="Error">
</return>
<description>
+ Creates a new SDP offer to start a WebRTC connection with a remote peer. At least one [WebRTCDataChannel] must have been created before calling this method.
+ If this functions returns [constant OK], [signal session_description_created] will be called when the session is ready to be sent.
</description>
</method>
<method name="get_connection_state" qualifiers="const">
<return type="int" enum="WebRTCPeerConnection.ConnectionState">
</return>
<description>
+ Returns the connection state. See [enum ConnectionState].
</description>
</method>
<method name="initialize">
@@ -57,12 +86,29 @@
}">
</argument>
<description>
+ Re-initialize this peer connection, closing any previously active connection, and going back to state [constant STATE_NEW]. A dictionary of [code]options[/code] can be passed to configure the peer connection.
+ Valid [code]options[/code] are:
+ [codeblock]
+ {
+ "iceServers": [
+ {
+ "urls": [ "stun:stun.example.com:3478" ], # One or more STUN servers.
+ },
+ {
+ "urls": [ "turn:turn.example.com:3478" ], # One or more TURN servers.
+ "username": "a_username", # Optional username for the TURN server.
+ "credentials": "a_password", # Optional password for the TURN server.
+ }
+ ]
+ }
+ [/codeblock]
</description>
</method>
<method name="poll">
<return type="int" enum="Error">
</return>
<description>
+ Call this method frequently (e.g. in [method Node._process] or [method Node._physics_process]) to properly receive signals.
</description>
</method>
<method name="set_local_description">
@@ -73,6 +119,8 @@
<argument index="1" name="sdp" type="String">
</argument>
<description>
+ Sets the SDP description of the local peer. This should be called in response to [signal session_description_created].
+ If [code]type[/code] is [code]answer[/code] the peer will start emitting [signal ice_candidate_created].
</description>
</method>
<method name="set_remote_description">
@@ -83,6 +131,9 @@
<argument index="1" name="sdp" type="String">
</argument>
<description>
+ Sets the SDP description of the remote peer. This should be called with the values generated by a remote peer and received over the signaling server.
+ If [code]type[/code] is [code]offer[/code] the peer will emit [signal session_description_created] with the appropriate answer.
+ If [code]type[/code] is [code]answer[/code] the peer will start emitting [signal ice_candidate_created].
</description>
</method>
</methods>
@@ -91,6 +142,8 @@
<argument index="0" name="channel" type="Object">
</argument>
<description>
+ Emitted when a new in-band channel is received, i.e. when the channel was created with [code]negotiated: false[/code] (default).
+ The object will be an instance of [WebRTCDataChannel]. You must keep a reference of it or it will be closed automatically. See [method create_data_channel]
</description>
</signal>
<signal name="ice_candidate_created">
@@ -101,6 +154,7 @@
<argument index="2" name="name" type="String">
</argument>
<description>
+ Emitted when a new ICE candidate has been created. The three parameters are meant to be passed to the remote peer over the signaling server.
</description>
</signal>
<signal name="session_description_created">
@@ -109,21 +163,28 @@
<argument index="1" name="sdp" type="String">
</argument>
<description>
+ Emitted after a successful call to [method create_offer] or [method set_remote_description] (when it generates an answer). The parameters are meant to be passed to [method set_local_description] on this object, and sent to the remote peer over the signaling server.
</description>
</signal>
</signals>
<constants>
<constant name="STATE_NEW" value="0" enum="ConnectionState">
+ The connection is new, data channels and an offer can be created in this state.
</constant>
<constant name="STATE_CONNECTING" value="1" enum="ConnectionState">
+ The peer is connecting, ICE is in progress, none of the transports has failed.
</constant>
<constant name="STATE_CONNECTED" value="2" enum="ConnectionState">
+ The peer is connected, all ICE transports are connected.
</constant>
<constant name="STATE_DISCONNECTED" value="3" enum="ConnectionState">
+ At least one ICE transport is disconnected.
</constant>
<constant name="STATE_FAILED" value="4" enum="ConnectionState">
+ One or more of the ICE transports failed.
</constant>
<constant name="STATE_CLOSED" value="5" enum="ConnectionState">
+ The peer connection is closed (after calling [method close] for example).
</constant>
</constants>
</class>
diff --git a/modules/webrtc/register_types.cpp b/modules/webrtc/register_types.cpp
index 44e072cc89..58b68d926b 100644
--- a/modules/webrtc/register_types.cpp
+++ b/modules/webrtc/register_types.cpp
@@ -40,6 +40,7 @@
#include "webrtc_data_channel_gdnative.h"
#include "webrtc_peer_connection_gdnative.h"
#endif
+#include "webrtc_multiplayer.h"
void register_webrtc_types() {
#ifdef JAVASCRIPT_ENABLED
@@ -54,6 +55,7 @@ void register_webrtc_types() {
ClassDB::register_class<WebRTCDataChannelGDNative>();
#endif
ClassDB::register_virtual_class<WebRTCDataChannel>();
+ ClassDB::register_class<WebRTCMultiplayer>();
}
void unregister_webrtc_types() {}
diff --git a/modules/webrtc/webrtc_data_channel_gdnative.cpp b/modules/webrtc/webrtc_data_channel_gdnative.cpp
index 4f33491af2..6362634626 100644
--- a/modules/webrtc/webrtc_data_channel_gdnative.cpp
+++ b/modules/webrtc/webrtc_data_channel_gdnative.cpp
@@ -35,6 +35,7 @@
#include "modules/gdnative/nativescript/nativescript.h"
void WebRTCDataChannelGDNative::_bind_methods() {
+ ADD_PROPERTY_DEFAULT("write_mode", WRITE_MODE_BINARY);
}
WebRTCDataChannelGDNative::WebRTCDataChannelGDNative() {
diff --git a/modules/webrtc/webrtc_data_channel_js.cpp b/modules/webrtc/webrtc_data_channel_js.cpp
index 2e7c64aa72..069918cc9c 100644
--- a/modules/webrtc/webrtc_data_channel_js.cpp
+++ b/modules/webrtc/webrtc_data_channel_js.cpp
@@ -68,7 +68,7 @@ void WebRTCDataChannelJS::_on_error() {
}
void WebRTCDataChannelJS::_on_message(uint8_t *p_data, uint32_t p_size, bool p_is_string) {
- if (in_buffer.space_left() < p_size + 5) {
+ if (in_buffer.space_left() < (int)(p_size + 5)) {
ERR_EXPLAIN("Buffer full! Dropping data");
ERR_FAIL();
}
@@ -205,30 +205,45 @@ String WebRTCDataChannelJS::get_label() const {
}
/* clang-format off */
-#define _JS_GET(PROP) \
+#define _JS_GET(PROP, DEF) \
EM_ASM_INT({ \
var dict = Module.IDHandler.get($0); \
if (!dict || !dict["channel"]) { \
- return 0; \
- }; \
- return dict["channel"].PROP; \
+ return DEF; \
+ } \
+ var out = dict["channel"].PROP; \
+ return out === null ? DEF : out; \
}, _js_id)
/* clang-format on */
bool WebRTCDataChannelJS::is_ordered() const {
- return _JS_GET(ordered);
+ return _JS_GET(ordered, true);
}
int WebRTCDataChannelJS::get_id() const {
- return _JS_GET(id);
+ return _JS_GET(id, 65535);
}
int WebRTCDataChannelJS::get_max_packet_life_time() const {
- return _JS_GET(maxPacketLifeTime);
+ // Can't use macro, webkit workaround.
+ /* clang-format off */
+ return EM_ASM_INT({
+ var dict = Module.IDHandler.get($0);
+ if (!dict || !dict["channel"]) {
+ return 65535;
+ }
+ if (dict["channel"].maxRetransmitTime !== undefined) {
+ // Guess someone didn't appreciate the standardization process.
+ return dict["channel"].maxRetransmitTime;
+ }
+ var out = dict["channel"].maxPacketLifeTime;
+ return out === null ? 65535 : out;
+ }, _js_id);
+ /* clang-format on */
}
int WebRTCDataChannelJS::get_max_retransmits() const {
- return _JS_GET(maxRetransmits);
+ return _JS_GET(maxRetransmits, 65535);
}
String WebRTCDataChannelJS::get_protocol() const {
@@ -236,7 +251,7 @@ String WebRTCDataChannelJS::get_protocol() const {
}
bool WebRTCDataChannelJS::is_negotiated() const {
- return _JS_GET(negotiated);
+ return _JS_GET(negotiated, false);
}
WebRTCDataChannelJS::WebRTCDataChannelJS() {
diff --git a/modules/webrtc/webrtc_multiplayer.cpp b/modules/webrtc/webrtc_multiplayer.cpp
new file mode 100644
index 0000000000..17dafff93a
--- /dev/null
+++ b/modules/webrtc/webrtc_multiplayer.cpp
@@ -0,0 +1,384 @@
+/*************************************************************************/
+/* webrtc_multiplayer.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* 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 "webrtc_multiplayer.h"
+
+#include "core/io/marshalls.h"
+#include "core/os/os.h"
+
+void WebRTCMultiplayer::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("initialize", "peer_id", "server_compatibility"), &WebRTCMultiplayer::initialize, DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("add_peer", "peer", "peer_id", "unreliable_lifetime"), &WebRTCMultiplayer::add_peer, DEFVAL(1));
+ ClassDB::bind_method(D_METHOD("remove_peer", "peer_id"), &WebRTCMultiplayer::remove_peer);
+ ClassDB::bind_method(D_METHOD("has_peer", "peer_id"), &WebRTCMultiplayer::has_peer);
+ ClassDB::bind_method(D_METHOD("get_peer", "peer_id"), &WebRTCMultiplayer::get_peer);
+ ClassDB::bind_method(D_METHOD("get_peers"), &WebRTCMultiplayer::get_peers);
+ ClassDB::bind_method(D_METHOD("close"), &WebRTCMultiplayer::close);
+}
+
+void WebRTCMultiplayer::set_transfer_mode(TransferMode p_mode) {
+ transfer_mode = p_mode;
+}
+
+NetworkedMultiplayerPeer::TransferMode WebRTCMultiplayer::get_transfer_mode() const {
+ return transfer_mode;
+}
+
+void WebRTCMultiplayer::set_target_peer(int p_peer_id) {
+ target_peer = p_peer_id;
+}
+
+/* Returns the ID of the NetworkedMultiplayerPeer who sent the most recent packet: */
+int WebRTCMultiplayer::get_packet_peer() const {
+ return next_packet_peer;
+}
+
+bool WebRTCMultiplayer::is_server() const {
+ return unique_id == TARGET_PEER_SERVER;
+}
+
+void WebRTCMultiplayer::poll() {
+ if (peer_map.size() == 0)
+ return;
+
+ List<int> remove;
+ List<int> add;
+ for (Map<int, Ref<ConnectedPeer> >::Element *E = peer_map.front(); E; E = E->next()) {
+ Ref<ConnectedPeer> peer = E->get();
+ peer->connection->poll();
+ // Check peer state
+ switch (peer->connection->get_connection_state()) {
+ case WebRTCPeerConnection::STATE_NEW:
+ case WebRTCPeerConnection::STATE_CONNECTING:
+ // Go to next peer, not ready yet.
+ continue;
+ case WebRTCPeerConnection::STATE_CONNECTED:
+ // Good to go, go ahead and check channel state.
+ break;
+ default:
+ // Peer is closed or in error state. Got to next peer.
+ remove.push_back(E->key());
+ continue;
+ }
+ // Check channels state
+ int ready = 0;
+ for (List<Ref<WebRTCDataChannel> >::Element *C = peer->channels.front(); C && C->get().is_valid(); C = C->next()) {
+ Ref<WebRTCDataChannel> ch = C->get();
+ switch (ch->get_ready_state()) {
+ case WebRTCDataChannel::STATE_CONNECTING:
+ continue;
+ case WebRTCDataChannel::STATE_OPEN:
+ ready++;
+ continue;
+ default:
+ // Channel was closed or in error state, remove peer id.
+ remove.push_back(E->key());
+ }
+ // We got a closed channel break out, the peer will be removed.
+ break;
+ }
+ // This peer has newly connected, and all channels are now open.
+ if (ready == peer->channels.size() && !peer->connected) {
+ peer->connected = true;
+ add.push_back(E->key());
+ }
+ }
+ // Remove disconnected peers
+ for (List<int>::Element *E = remove.front(); E; E = E->next()) {
+ remove_peer(E->get());
+ if (next_packet_peer == E->get())
+ next_packet_peer = 0;
+ }
+ // Signal newly connected peers
+ for (List<int>::Element *E = add.front(); E; E = E->next()) {
+ // Already connected to server: simply notify new peer.
+ // NOTE: Mesh is always connected.
+ if (connection_status == CONNECTION_CONNECTED)
+ emit_signal("peer_connected", E->get());
+
+ // Server emulation mode suppresses peer_conencted until server connects.
+ if (server_compat && E->get() == TARGET_PEER_SERVER) {
+ // Server connected.
+ connection_status = CONNECTION_CONNECTED;
+ emit_signal("peer_connected", TARGET_PEER_SERVER);
+ emit_signal("connection_succeeded");
+ // Notify of all previously connected peers
+ for (Map<int, Ref<ConnectedPeer> >::Element *F = peer_map.front(); F; F = F->next()) {
+ if (F->key() != 1 && F->get()->connected)
+ emit_signal("peer_connected", F->key());
+ }
+ break; // Because we already notified of all newly added peers.
+ }
+ }
+ // Fetch next packet
+ if (next_packet_peer == 0)
+ _find_next_peer();
+}
+
+void WebRTCMultiplayer::_find_next_peer() {
+ Map<int, Ref<ConnectedPeer> >::Element *E = peer_map.find(next_packet_peer);
+ if (E) E = E->next();
+ // After last.
+ while (E) {
+ for (List<Ref<WebRTCDataChannel> >::Element *F = E->get()->channels.front(); F; F = F->next()) {
+ if (F->get()->get_available_packet_count()) {
+ next_packet_peer = E->key();
+ return;
+ }
+ }
+ E = E->next();
+ }
+ E = peer_map.front();
+ // Before last
+ while (E) {
+ for (List<Ref<WebRTCDataChannel> >::Element *F = E->get()->channels.front(); F; F = F->next()) {
+ if (F->get()->get_available_packet_count()) {
+ next_packet_peer = E->key();
+ return;
+ }
+ }
+ if (E->key() == (int)next_packet_peer)
+ break;
+ E = E->next();
+ }
+ // No packet found
+ next_packet_peer = 0;
+}
+
+void WebRTCMultiplayer::set_refuse_new_connections(bool p_enable) {
+ refuse_connections = p_enable;
+}
+
+bool WebRTCMultiplayer::is_refusing_new_connections() const {
+ return refuse_connections;
+}
+
+NetworkedMultiplayerPeer::ConnectionStatus WebRTCMultiplayer::get_connection_status() const {
+ return connection_status;
+}
+
+Error WebRTCMultiplayer::initialize(int p_self_id, bool p_server_compat) {
+ ERR_FAIL_COND_V(p_self_id < 0 || p_self_id > ~(1 << 31), ERR_INVALID_PARAMETER);
+ unique_id = p_self_id;
+ server_compat = p_server_compat;
+
+ // Mesh and server are always connected
+ if (!server_compat || p_self_id == 1)
+ connection_status = CONNECTION_CONNECTED;
+ else
+ connection_status = CONNECTION_CONNECTING;
+ return OK;
+}
+
+int WebRTCMultiplayer::get_unique_id() const {
+ ERR_FAIL_COND_V(connection_status == CONNECTION_DISCONNECTED, 1);
+ return unique_id;
+}
+
+void WebRTCMultiplayer::_peer_to_dict(Ref<ConnectedPeer> p_connected_peer, Dictionary &r_dict) {
+ Array channels;
+ for (List<Ref<WebRTCDataChannel> >::Element *F = p_connected_peer->channels.front(); F; F = F->next()) {
+ channels.push_back(F->get());
+ }
+ r_dict["connection"] = p_connected_peer->connection;
+ r_dict["connected"] = p_connected_peer->connected;
+ r_dict["channels"] = channels;
+}
+
+bool WebRTCMultiplayer::has_peer(int p_peer_id) {
+ return peer_map.has(p_peer_id);
+}
+
+Dictionary WebRTCMultiplayer::get_peer(int p_peer_id) {
+ ERR_FAIL_COND_V(!peer_map.has(p_peer_id), Dictionary());
+ Dictionary out;
+ _peer_to_dict(peer_map[p_peer_id], out);
+ return out;
+}
+
+Dictionary WebRTCMultiplayer::get_peers() {
+ Dictionary out;
+ for (Map<int, Ref<ConnectedPeer> >::Element *E = peer_map.front(); E; E = E->next()) {
+ Dictionary d;
+ _peer_to_dict(E->get(), d);
+ out[E->key()] = d;
+ }
+ return out;
+}
+
+Error WebRTCMultiplayer::add_peer(Ref<WebRTCPeerConnection> p_peer, int p_peer_id, int p_unreliable_lifetime) {
+ ERR_FAIL_COND_V(p_peer_id < 0 || p_peer_id > ~(1 << 31), ERR_INVALID_PARAMETER);
+ ERR_FAIL_COND_V(p_unreliable_lifetime < 0, ERR_INVALID_PARAMETER);
+ ERR_FAIL_COND_V(refuse_connections, ERR_UNAUTHORIZED);
+ // Peer must be valid, and in new state (to create data channels)
+ ERR_FAIL_COND_V(!p_peer.is_valid(), ERR_INVALID_PARAMETER);
+ ERR_FAIL_COND_V(p_peer->get_connection_state() != WebRTCPeerConnection::STATE_NEW, ERR_INVALID_PARAMETER);
+
+ Ref<ConnectedPeer> peer = memnew(ConnectedPeer);
+ peer->connection = p_peer;
+
+ // Initialize data channels
+ Dictionary cfg;
+ cfg["negotiated"] = true;
+ cfg["ordered"] = true;
+
+ cfg["id"] = 1;
+ peer->channels[CH_RELIABLE] = p_peer->create_data_channel("reliable", cfg);
+ ERR_FAIL_COND_V(!peer->channels[CH_RELIABLE].is_valid(), FAILED);
+
+ cfg["id"] = 2;
+ cfg["maxPacketLifetime"] = p_unreliable_lifetime;
+ peer->channels[CH_ORDERED] = p_peer->create_data_channel("ordered", cfg);
+ ERR_FAIL_COND_V(!peer->channels[CH_ORDERED].is_valid(), FAILED);
+
+ cfg["id"] = 3;
+ cfg["ordered"] = false;
+ peer->channels[CH_UNRELIABLE] = p_peer->create_data_channel("unreliable", cfg);
+ ERR_FAIL_COND_V(!peer->channels[CH_UNRELIABLE].is_valid(), FAILED);
+
+ peer_map[p_peer_id] = peer; // add the new peer connection to the peer_map
+
+ return OK;
+}
+
+void WebRTCMultiplayer::remove_peer(int p_peer_id) {
+ ERR_FAIL_COND(!peer_map.has(p_peer_id));
+ Ref<ConnectedPeer> peer = peer_map[p_peer_id];
+ peer_map.erase(p_peer_id);
+ if (peer->connected) {
+ peer->connected = false;
+ emit_signal("peer_disconnected", p_peer_id);
+ if (server_compat && p_peer_id == TARGET_PEER_SERVER) {
+ emit_signal("server_disconnected");
+ connection_status = CONNECTION_DISCONNECTED;
+ }
+ }
+}
+
+Error WebRTCMultiplayer::get_packet(const uint8_t **r_buffer, int &r_buffer_size) {
+ // Peer not available
+ if (next_packet_peer == 0 || !peer_map.has(next_packet_peer)) {
+ _find_next_peer();
+ ERR_FAIL_V(ERR_UNAVAILABLE);
+ }
+ for (List<Ref<WebRTCDataChannel> >::Element *E = peer_map[next_packet_peer]->channels.front(); E; E = E->next()) {
+ if (E->get()->get_available_packet_count()) {
+ Error err = E->get()->get_packet(r_buffer, r_buffer_size);
+ _find_next_peer();
+ return err;
+ }
+ }
+ // Channels for that peer were empty. Bug?
+ _find_next_peer();
+ ERR_FAIL_V(ERR_BUG);
+}
+
+Error WebRTCMultiplayer::put_packet(const uint8_t *p_buffer, int p_buffer_size) {
+ ERR_FAIL_COND_V(connection_status == CONNECTION_DISCONNECTED, ERR_UNCONFIGURED);
+
+ int ch = CH_RELIABLE;
+ switch (transfer_mode) {
+ case TRANSFER_MODE_RELIABLE:
+ ch = CH_RELIABLE;
+ break;
+ case TRANSFER_MODE_UNRELIABLE_ORDERED:
+ ch = CH_ORDERED;
+ break;
+ case TRANSFER_MODE_UNRELIABLE:
+ ch = CH_UNRELIABLE;
+ break;
+ }
+
+ Map<int, Ref<ConnectedPeer> >::Element *E = NULL;
+
+ if (target_peer > 0) {
+
+ E = peer_map.find(target_peer);
+ if (!E) {
+ ERR_EXPLAIN("Invalid Target Peer: " + itos(target_peer));
+ ERR_FAIL_V(ERR_INVALID_PARAMETER);
+ }
+ ERR_FAIL_COND_V(E->value()->channels.size() <= ch, ERR_BUG);
+ ERR_FAIL_COND_V(!E->value()->channels[ch].is_valid(), ERR_BUG);
+ return E->value()->channels[ch]->put_packet(p_buffer, p_buffer_size);
+
+ } else {
+ int exclude = -target_peer;
+
+ for (Map<int, Ref<ConnectedPeer> >::Element *F = peer_map.front(); F; F = F->next()) {
+
+ // Exclude packet. If target_peer == 0 then don't exclude any packets
+ if (target_peer != 0 && F->key() == exclude)
+ continue;
+
+ ERR_CONTINUE(F->value()->channels.size() <= ch || !F->value()->channels[ch].is_valid());
+ F->value()->channels[ch]->put_packet(p_buffer, p_buffer_size);
+ }
+ }
+ return OK;
+}
+
+int WebRTCMultiplayer::get_available_packet_count() const {
+ if (next_packet_peer == 0)
+ return 0; // To be sure next call to get_packet works if size > 0 .
+ int size = 0;
+ for (Map<int, Ref<ConnectedPeer> >::Element *E = peer_map.front(); E; E = E->next()) {
+ for (List<Ref<WebRTCDataChannel> >::Element *F = E->get()->channels.front(); F; F = F->next()) {
+ size += F->get()->get_available_packet_count();
+ }
+ }
+ return size;
+}
+
+int WebRTCMultiplayer::get_max_packet_size() const {
+ return 1200;
+}
+
+void WebRTCMultiplayer::close() {
+ peer_map.clear();
+ unique_id = 0;
+ next_packet_peer = 0;
+ target_peer = 0;
+ connection_status = CONNECTION_DISCONNECTED;
+}
+
+WebRTCMultiplayer::WebRTCMultiplayer() {
+ unique_id = 0;
+ next_packet_peer = 0;
+ target_peer = 0;
+ transfer_mode = TRANSFER_MODE_RELIABLE;
+ refuse_connections = false;
+ connection_status = CONNECTION_DISCONNECTED;
+ server_compat = false;
+}
+
+WebRTCMultiplayer::~WebRTCMultiplayer() {
+ close();
+}
diff --git a/modules/webrtc/webrtc_multiplayer.h b/modules/webrtc/webrtc_multiplayer.h
new file mode 100644
index 0000000000..82bbfd4f68
--- /dev/null
+++ b/modules/webrtc/webrtc_multiplayer.h
@@ -0,0 +1,116 @@
+/*************************************************************************/
+/* webrtc_multiplayer.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* 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 WEBRTC_MULTIPLAYER_H
+#define WEBRTC_MULTIPLAYER_H
+
+#include "core/io/networked_multiplayer_peer.h"
+#include "webrtc_peer_connection.h"
+
+class WebRTCMultiplayer : public NetworkedMultiplayerPeer {
+
+ GDCLASS(WebRTCMultiplayer, NetworkedMultiplayerPeer);
+
+protected:
+ static void _bind_methods();
+
+private:
+ enum {
+ CH_RELIABLE = 0,
+ CH_ORDERED = 1,
+ CH_UNRELIABLE = 2,
+ CH_RESERVED_MAX = 3
+ };
+
+ class ConnectedPeer : public Reference {
+
+ public:
+ Ref<WebRTCPeerConnection> connection;
+ List<Ref<WebRTCDataChannel> > channels;
+ bool connected;
+
+ ConnectedPeer() {
+ connected = false;
+ for (int i = 0; i < CH_RESERVED_MAX; i++)
+ channels.push_front(Ref<WebRTCDataChannel>());
+ }
+ };
+
+ uint32_t unique_id;
+ int target_peer;
+ int client_count;
+ bool refuse_connections;
+ ConnectionStatus connection_status;
+ TransferMode transfer_mode;
+ int next_packet_peer;
+ bool server_compat;
+
+ Map<int, Ref<ConnectedPeer> > peer_map;
+
+ void _peer_to_dict(Ref<ConnectedPeer> p_connected_peer, Dictionary &r_dict);
+ void _find_next_peer();
+
+public:
+ WebRTCMultiplayer();
+ ~WebRTCMultiplayer();
+
+ Error initialize(int p_self_id, bool p_server_compat = false);
+ Error add_peer(Ref<WebRTCPeerConnection> p_peer, int p_peer_id, int p_unreliable_lifetime = 1);
+ void remove_peer(int p_peer_id);
+ bool has_peer(int p_peer_id);
+ Dictionary get_peer(int p_peer_id);
+ Dictionary get_peers();
+ void close();
+
+ // PacketPeer
+ Error get_packet(const uint8_t **r_buffer, int &r_buffer_size); ///< buffer is GONE after next get_packet
+ Error put_packet(const uint8_t *p_buffer, int p_buffer_size);
+ int get_available_packet_count() const;
+ int get_max_packet_size() const;
+
+ // NetworkedMultiplayerPeer
+ void set_transfer_mode(TransferMode p_mode);
+ TransferMode get_transfer_mode() const;
+ void set_target_peer(int p_peer_id);
+
+ int get_unique_id() const;
+ int get_packet_peer() const;
+
+ bool is_server() const;
+
+ void poll();
+
+ void set_refuse_new_connections(bool p_enable);
+ bool is_refusing_new_connections() const;
+
+ ConnectionStatus get_connection_status() const;
+};
+
+#endif
diff --git a/modules/websocket/doc_classes/WebSocketClient.xml b/modules/websocket/doc_classes/WebSocketClient.xml
index 26122dfad4..0d425ad1dd 100644
--- a/modules/websocket/doc_classes/WebSocketClient.xml
+++ b/modules/websocket/doc_classes/WebSocketClient.xml
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="WebSocketClient" inherits="WebSocketMultiplayerPeer" category="Core" version="3.2">
<brief_description>
- A WebSocket client implementation
+ A WebSocket client implementation.
</brief_description>
<description>
- This class implements a WebSocket client compatible with any RFC 6455 complaint WebSocket server.
+ This class implements a WebSocket client compatible with any RFC 6455-compliant WebSocket server.
This client can be optionally used as a network peer for the [MultiplayerAPI].
After starting the client ([method connect_to_url]), you will need to [method NetworkedMultiplayerPeer.poll] it at regular intervals (e.g. inside [method Node._process]).
- You will received appropriate signals when connecting, disconnecting, or when new data is available.
+ You will receive appropriate signals when connecting, disconnecting, or when new data is available.
</description>
<tutorials>
</tutorials>
@@ -22,8 +22,8 @@
<argument index="2" name="gd_mp_api" type="bool" default="false">
</argument>
<description>
- Connect to the given URL requesting one of the given [code]protocols[/code] as sub-protocol.
- If [code]true[/code] is passed as [code]gd_mp_api[/code], the client will behave like a network peer for the [MultiplayerAPI], connections to non Godot servers will not work, and [signal data_received] will not be emitted.
+ Connects to the given URL requesting one of the given [code]protocols[/code] as sub-protocol.
+ If [code]true[/code] is passed as [code]gd_mp_api[/code], the client will behave like a network peer for the [MultiplayerAPI], connections to non-Godot servers will not work, and [signal data_received] will not be emitted.
If [code]false[/code] is passed instead (default), you must call [PacketPeer] functions ([code]put_packet[/code], [code]get_packet[/code], etc.) on the [WebSocketPeer] returned via [code]get_peer(1)[/code] and not on this object directly (e.g. [code]get_peer(1).put_packet(data)[/code]).
</description>
</method>
@@ -35,13 +35,14 @@
<argument index="1" name="reason" type="String" default="&quot;&quot;">
</argument>
<description>
- Disconnect this client from the connected host. See [method WebSocketPeer.close] for more info.
+ Disconnects this client from the connected host. See [method WebSocketPeer.close] for more information.
</description>
</method>
</methods>
<members>
<member name="verify_ssl" type="bool" setter="set_verify_ssl_enabled" getter="is_verify_ssl_enabled">
- Enable or disable SSL certificate verification. Note: You must specify the certificates to be used in the project settings for it to work when exported.
+ If [code]true[/code], SSL certificate verification is enabled.
+ [b]Note:[/b] You must specify the certificates to be used in the Project Settings for it to work when exported.
</member>
</members>
<signals>
@@ -66,7 +67,8 @@
</signal>
<signal name="data_received">
<description>
- Emitted when a WebSocket message is received. Note: This signal is NOT emitted when used as high level multiplayer peer.
+ Emitted when a WebSocket message is received.
+ [b]Note:[/b] This signal is [i]not[/i] emitted when used as high-level multiplayer peer.
</description>
</signal>
<signal name="server_close_request">
diff --git a/modules/websocket/doc_classes/WebSocketMultiplayerPeer.xml b/modules/websocket/doc_classes/WebSocketMultiplayerPeer.xml
index 8548d21323..b80a28e648 100644
--- a/modules/websocket/doc_classes/WebSocketMultiplayerPeer.xml
+++ b/modules/websocket/doc_classes/WebSocketMultiplayerPeer.xml
@@ -18,13 +18,32 @@
Returns the [WebSocketPeer] associated to the given [code]peer_id[/code].
</description>
</method>
+ <method name="set_buffers">
+ <return type="int" enum="Error">
+ </return>
+ <argument index="0" name="input_buffer_size_kb" type="int">
+ </argument>
+ <argument index="1" name="input_max_packets" type="int">
+ </argument>
+ <argument index="2" name="output_buffer_size_kb" type="int">
+ </argument>
+ <argument index="3" name="output_max_packets" type="int">
+ </argument>
+ <description>
+ Configures the buffer sizes for this WebSocket peer. Default values can be specified in the Project Settings under [code]network/limits[/code]. For server, values are meant per connected peer.
+ The first two parameters define the size and queued packets limits of the input buffer, the last two of the output buffer.
+ Buffer sizes are expressed in KiB, so [code]4 = 2^12 = 4096 bytes[/code]. All parameters will be rounded up to the nearest power of two.
+ [b]Note:[/b] HTML5 exports only use the input buffer since the output one is managed by browsers.
+ </description>
+ </method>
</methods>
<signals>
<signal name="peer_packet">
<argument index="0" name="peer_source" type="int">
</argument>
<description>
- Emitted when a packet is received from a peer. Note: this signal is only emitted when the client or server is configured to use Godot multiplayer API.
+ Emitted when a packet is received from a peer.
+ [b]Note:[/b] This signal is only emitted when the client or server is configured to use Godot multiplayer API.
</description>
</signal>
</signals>
diff --git a/modules/websocket/doc_classes/WebSocketPeer.xml b/modules/websocket/doc_classes/WebSocketPeer.xml
index 8a6868d311..dd95f7432e 100644
--- a/modules/websocket/doc_classes/WebSocketPeer.xml
+++ b/modules/websocket/doc_classes/WebSocketPeer.xml
@@ -18,30 +18,32 @@
<argument index="1" name="reason" type="String" default="&quot;&quot;">
</argument>
<description>
- Close this WebSocket connection. [code]code[/code] is the status code for the closure (see RFC6455 section 7.4 for a list of valid status codes). [code]reason[/code] is the human readable reason for closing the connection (can be any UTF8 string, must be less than 123 bytes).
- Note: To achieve a clean close, you will need to keep polling until either [signal WebSocketClient.connection_closed] or [signal WebSocketServer.client_disconnected] is received.
- Note: HTML5 export might not support all status codes. Please refer to browsers-specific documentation for more details.
+ Closes this WebSocket connection. [code]code[/code] is the status code for the closure (see RFC 6455 section 7.4 for a list of valid status codes). [code]reason[/code] is the human readable reason for closing the connection (can be any UTF-8 string that's smaller than 123 bytes).
+ [b]Note:[/b] To achieve a clean close, you will need to keep polling until either [signal WebSocketClient.connection_closed] or [signal WebSocketServer.client_disconnected] is received.
+ [b]Note:[/b] The HTML5 export might not support all status codes. Please refer to browser-specific documentation for more details.
</description>
</method>
<method name="get_connected_host" qualifiers="const">
<return type="String">
</return>
<description>
- Returns the IP Address of the connected peer. (Not available in HTML5 export)
+ Returns the IP address of the connected peer.
+ [b]Note:[/b] Not available in the HTML5 export.
</description>
</method>
<method name="get_connected_port" qualifiers="const">
<return type="int">
</return>
<description>
- Returns the remote port of the connected peer. (Not available in HTML5 export)
+ Returns the remote port of the connected peer.
+ [b]Note:[/b] Not available in the HTML5 export.
</description>
</method>
<method name="get_write_mode" qualifiers="const">
<return type="int" enum="WebSocketPeer.WriteMode">
</return>
<description>
- Get the current selected write mode. See [enum WriteMode].
+ Gets the current selected write mode. See [enum WriteMode].
</description>
</method>
<method name="is_connected_to_host" qualifiers="const">
@@ -70,10 +72,10 @@
</methods>
<constants>
<constant name="WRITE_MODE_TEXT" value="0" enum="WriteMode">
- Specify that WebSockets messages should be transferred as text payload (only valid UTF-8 is allowed).
+ Specifies that WebSockets messages should be transferred as text payload (only valid UTF-8 is allowed).
</constant>
<constant name="WRITE_MODE_BINARY" value="1" enum="WriteMode">
- Specify that WebSockets messages should be transferred as binary payload (any byte combination is allowed).
+ Specifies that WebSockets messages should be transferred as binary payload (any byte combination is allowed).
</constant>
</constants>
</class>
diff --git a/modules/websocket/doc_classes/WebSocketServer.xml b/modules/websocket/doc_classes/WebSocketServer.xml
index 51945d410a..1af5e403e6 100644
--- a/modules/websocket/doc_classes/WebSocketServer.xml
+++ b/modules/websocket/doc_classes/WebSocketServer.xml
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="WebSocketServer" inherits="WebSocketMultiplayerPeer" category="Core" version="3.2">
<brief_description>
- A WebSocket server implementation
+ A WebSocket server implementation.
</brief_description>
<description>
- This class implements a WebSocket server that can also support the high level multiplayer API.
+ This class implements a WebSocket server that can also support the high-level multiplayer API.
After starting the server ([method listen]), you will need to [method NetworkedMultiplayerPeer.poll] it at regular intervals (e.g. inside [method Node._process]). When clients connect, disconnect, or send data, you will receive the appropriate signal.
- Note: This class will not work in HTML5 exports due to browser restrictions.
+ [b]Note:[/b] This class will not work in HTML5 exports due to browser restrictions.
</description>
<tutorials>
</tutorials>
@@ -21,7 +21,7 @@
<argument index="2" name="reason" type="String" default="&quot;&quot;">
</argument>
<description>
- Disconnects the peer identified by [code]id[/code] from the server. See [method WebSocketPeer.close] for more info.
+ Disconnects the peer identified by [code]id[/code] from the server. See [method WebSocketPeer.close] for more information.
</description>
</method>
<method name="get_peer_address" qualifiers="const">
@@ -68,17 +68,17 @@
<argument index="2" name="gd_mp_api" type="bool" default="false">
</argument>
<description>
- Start listening on the given port.
+ Starts listening on the given port.
You can specify the desired subprotocols via the "protocols" array. If the list empty (default), "binary" will be used.
- If [code]true[/code] is passed as [code]gd_mp_api[/code], the server will behave like a network peer for the [MultiplayerAPI], connections from non Godot clients will not work, and [signal data_received] will not be emitted.
- If [code]false[/code] is passed instead (default), you must call [PacketPeer] functions ([code]put_packet[/code], [code]get_packet[/code], etc.), on the [WebSocketPeer] returned via [code]get_peer(ID)[/code] to communicate with the peer with given [code]ID[/code] (e.g. [code]get_peer(ID).get_available_packet_count[/code]).
+ If [code]true[/code] is passed as [code]gd_mp_api[/code], the server will behave like a network peer for the [MultiplayerAPI], connections from non-Godot clients will not work, and [signal data_received] will not be emitted.
+ If [code]false[/code] is passed instead (default), you must call [PacketPeer] functions ([code]put_packet[/code], [code]get_packet[/code], etc.), on the [WebSocketPeer] returned via [code]get_peer(id)[/code] to communicate with the peer with given [code]id[/code] (e.g. [code]get_peer(id).get_available_packet_count[/code]).
</description>
</method>
<method name="stop">
<return type="void">
</return>
<description>
- Stop the server and clear its state.
+ Stops the server and clear its state.
</description>
</method>
</methods>
@@ -116,7 +116,8 @@
<argument index="0" name="id" type="int">
</argument>
<description>
- Emitted when a new message is received. Note: This signal is NOT emitted when used as high level multiplayer peer.
+ Emitted when a new message is received.
+ [b]Note:[/b] This signal is [i]not[/i] emitted when used as high-level multiplayer peer.
</description>
</signal>
</signals>
diff --git a/modules/websocket/emws_client.cpp b/modules/websocket/emws_client.cpp
index aafae8f1c2..409cc9f699 100644
--- a/modules/websocket/emws_client.cpp
+++ b/modules/websocket/emws_client.cpp
@@ -205,6 +205,12 @@ int EMWSClient::get_max_packet_size() const {
return (1 << _in_buf_size) - PROTO_SIZE;
}
+Error EMWSClient::set_buffers(int p_in_buffer, int p_in_packets, int p_out_buffer, int p_out_packets) {
+ _in_buf_size = nearest_shift(p_in_buffer - 1) + 10;
+ _in_pkt_size = nearest_shift(p_in_packets - 1);
+ return OK;
+}
+
EMWSClient::EMWSClient() {
_in_buf_size = nearest_shift((int)GLOBAL_GET(WSC_IN_BUF) - 1) + 10;
_in_pkt_size = nearest_shift((int)GLOBAL_GET(WSC_IN_PKT) - 1);
diff --git a/modules/websocket/emws_client.h b/modules/websocket/emws_client.h
index 9bc29c1913..1811d05eea 100644
--- a/modules/websocket/emws_client.h
+++ b/modules/websocket/emws_client.h
@@ -49,6 +49,7 @@ private:
public:
bool _is_connecting;
+ Error set_buffers(int p_in_buffer, int p_in_packets, int p_out_buffer, int p_out_packets);
Error connect_to_host(String p_host, String p_path, uint16_t p_port, bool p_ssl, PoolVector<String> p_protocol = PoolVector<String>());
Ref<WebSocketPeer> get_peer(int p_peer_id) const;
void disconnect_from_host(int p_code = 1000, String p_reason = "");
diff --git a/modules/websocket/emws_server.cpp b/modules/websocket/emws_server.cpp
index 0eef1c4ba9..c4bb459ad0 100644
--- a/modules/websocket/emws_server.cpp
+++ b/modules/websocket/emws_server.cpp
@@ -79,6 +79,10 @@ int EMWSServer::get_max_packet_size() const {
return 0;
}
+Error EMWSServer::set_buffers(int p_in_buffer, int p_in_packets, int p_out_buffer, int p_out_packets) {
+ return OK;
+}
+
EMWSServer::EMWSServer() {
}
diff --git a/modules/websocket/emws_server.h b/modules/websocket/emws_server.h
index bb101cd155..a5e5b4090e 100644
--- a/modules/websocket/emws_server.h
+++ b/modules/websocket/emws_server.h
@@ -42,6 +42,7 @@ class EMWSServer : public WebSocketServer {
GDCIIMPL(EMWSServer, WebSocketServer);
public:
+ Error set_buffers(int p_in_buffer, int p_in_packets, int p_out_buffer, int p_out_packets);
Error listen(int p_port, PoolVector<String> p_protocols = PoolVector<String>(), bool gd_mp_api = false);
void stop();
bool is_listening() const;
diff --git a/modules/websocket/lws_client.cpp b/modules/websocket/lws_client.cpp
index 08df76293b..f139a4ef66 100644
--- a/modules/websocket/lws_client.cpp
+++ b/modules/websocket/lws_client.cpp
@@ -215,6 +215,17 @@ uint16_t LWSClient::get_connected_port() const {
return 1025;
};
+Error LWSClient::set_buffers(int p_in_buffer, int p_in_packets, int p_out_buffer, int p_out_packets) {
+ ERR_EXPLAIN("Buffers sizes can only be set before listening or connecting");
+ ERR_FAIL_COND_V(context != NULL, FAILED);
+
+ _in_buf_size = nearest_shift(p_in_buffer - 1) + 10;
+ _in_pkt_size = nearest_shift(p_in_packets - 1);
+ _out_buf_size = nearest_shift(p_out_buffer - 1) + 10;
+ _out_pkt_size = nearest_shift(p_out_packets - 1);
+ return OK;
+}
+
LWSClient::LWSClient() {
_in_buf_size = nearest_shift((int)GLOBAL_GET(WSC_IN_BUF) - 1) + 10;
_in_pkt_size = nearest_shift((int)GLOBAL_GET(WSC_IN_PKT) - 1);
diff --git a/modules/websocket/lws_client.h b/modules/websocket/lws_client.h
index b3a1237550..df4aabec7f 100644
--- a/modules/websocket/lws_client.h
+++ b/modules/websocket/lws_client.h
@@ -51,6 +51,7 @@ private:
int _out_pkt_size;
public:
+ Error set_buffers(int p_in_buffer, int p_in_packets, int p_out_buffer, int p_out_packets);
Error connect_to_host(String p_host, String p_path, uint16_t p_port, bool p_ssl, PoolVector<String> p_protocol = PoolVector<String>());
int get_max_packet_size() const;
Ref<WebSocketPeer> get_peer(int p_peer_id) const;
diff --git a/modules/websocket/lws_server.cpp b/modules/websocket/lws_server.cpp
index 61ccdca74a..482c02dc60 100644
--- a/modules/websocket/lws_server.cpp
+++ b/modules/websocket/lws_server.cpp
@@ -197,6 +197,17 @@ void LWSServer::disconnect_peer(int p_peer_id, int p_code, String p_reason) {
get_peer(p_peer_id)->close(p_code, p_reason);
}
+Error LWSServer::set_buffers(int p_in_buffer, int p_in_packets, int p_out_buffer, int p_out_packets) {
+ ERR_EXPLAIN("Buffers sizes can only be set before listening or connecting");
+ ERR_FAIL_COND_V(context != NULL, FAILED);
+
+ _in_buf_size = nearest_shift(p_in_buffer - 1) + 10;
+ _in_pkt_size = nearest_shift(p_in_packets - 1);
+ _out_buf_size = nearest_shift(p_out_buffer - 1) + 10;
+ _out_pkt_size = nearest_shift(p_out_packets - 1);
+ return OK;
+}
+
LWSServer::LWSServer() {
_in_buf_size = nearest_shift((int)GLOBAL_GET(WSS_IN_BUF) - 1) + 10;
_in_pkt_size = nearest_shift((int)GLOBAL_GET(WSS_IN_PKT) - 1);
diff --git a/modules/websocket/lws_server.h b/modules/websocket/lws_server.h
index 5096ee0f88..b331852d26 100644
--- a/modules/websocket/lws_server.h
+++ b/modules/websocket/lws_server.h
@@ -52,6 +52,7 @@ private:
int _out_pkt_size;
public:
+ Error set_buffers(int p_in_buffer, int p_in_packets, int p_out_buffer, int p_out_packets);
Error listen(int p_port, PoolVector<String> p_protocols = PoolVector<String>(), bool gd_mp_api = false);
void stop();
bool is_listening() const;
diff --git a/modules/websocket/websocket_client.h b/modules/websocket/websocket_client.h
index c464d97c7f..7ddb9468a5 100644
--- a/modules/websocket/websocket_client.h
+++ b/modules/websocket/websocket_client.h
@@ -67,6 +67,8 @@ public:
void _on_disconnect(bool p_was_clean);
void _on_error();
+ virtual Error set_buffers(int p_in_buffer, int p_in_packets, int p_out_buffer, int p_out_packets) = 0;
+
WebSocketClient();
~WebSocketClient();
};
diff --git a/modules/websocket/websocket_multiplayer_peer.cpp b/modules/websocket/websocket_multiplayer_peer.cpp
index 6aab8a7e81..23cbf916eb 100644
--- a/modules/websocket/websocket_multiplayer_peer.cpp
+++ b/modules/websocket/websocket_multiplayer_peer.cpp
@@ -87,6 +87,7 @@ void WebSocketMultiplayerPeer::_clear() {
void WebSocketMultiplayerPeer::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("set_buffers", "input_buffer_size_kb", "input_max_packets", "output_buffer_size_kb", "output_max_packets"), &WebSocketMultiplayerPeer::set_buffers);
ClassDB::bind_method(D_METHOD("get_peer", "peer_id"), &WebSocketMultiplayerPeer::get_peer);
ADD_SIGNAL(MethodInfo("peer_packet", PropertyInfo(Variant::INT, "peer_source")));
diff --git a/modules/websocket/websocket_multiplayer_peer.h b/modules/websocket/websocket_multiplayer_peer.h
index b050449ee0..7fd97a6595 100644
--- a/modules/websocket/websocket_multiplayer_peer.h
+++ b/modules/websocket/websocket_multiplayer_peer.h
@@ -82,7 +82,7 @@ public:
/* NetworkedMultiplayerPeer */
void set_transfer_mode(TransferMode p_mode);
TransferMode get_transfer_mode() const;
- void set_target_peer(int p_peer_id);
+ void set_target_peer(int p_target_peer);
int get_packet_peer() const;
int get_unique_id() const;
virtual bool is_server() const = 0;
@@ -97,6 +97,7 @@ public:
virtual Error put_packet(const uint8_t *p_buffer, int p_buffer_size);
/* WebSocketPeer */
+ virtual Error set_buffers(int p_in_buffer, int p_in_packets, int p_out_buffer, int p_out_packets) = 0;
virtual Ref<WebSocketPeer> get_peer(int p_peer_id) const = 0;
void _process_multiplayer(Ref<WebSocketPeer> p_peer, uint32_t p_peer_id);
diff --git a/modules/websocket/websocket_server.h b/modules/websocket/websocket_server.h
index 7a94c4047b..83c0c10419 100644
--- a/modules/websocket/websocket_server.h
+++ b/modules/websocket/websocket_server.h
@@ -62,6 +62,8 @@ public:
void _on_disconnect(int32_t p_peer_id, bool p_was_clean);
void _on_close_request(int32_t p_peer_id, int p_code, String p_reason);
+ virtual Error set_buffers(int p_in_buffer, int p_in_packets, int p_out_buffer, int p_out_packets) = 0;
+
WebSocketServer();
~WebSocketServer();
};