diff options
Diffstat (limited to 'modules')
71 files changed, 1403 insertions, 240 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/bmp/image_loader_bmp.cpp b/modules/bmp/image_loader_bmp.cpp index b4530c2df1..a7e8dec11e 100644 --- a/modules/bmp/image_loader_bmp.cpp +++ b/modules/bmp/image_loader_bmp.cpp @@ -262,7 +262,7 @@ Error ImageLoaderBMP::load_image(Ref<Image> p_image, FileAccess *f, PoolVector<uint8_t> bmp_color_table; // Color table is usually 4 bytes per color -> [B][G][R][0] - err = bmp_color_table.resize(color_table_size * 4); + 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); 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/csg/csg_shape.h b/modules/csg/csg_shape.h index 553a7553c6..6c9419b3c2 100644 --- a/modules/csg/csg_shape.h +++ b/modules/csg/csg_shape.h @@ -404,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/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/enet/doc_classes/NetworkedMultiplayerENet.xml b/modules/enet/doc_classes/NetworkedMultiplayerENet.xml index d3d1e58b7b..8a8511c008 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. + 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> <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. + 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. Default value: [constant COMPRESS_NONE]. </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. + 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 dcb4b7fd75..a5a356ced2 100644 --- a/modules/enet/networked_multiplayer_enet.cpp +++ b/modules/enet/networked_multiplayer_enet.cpp @@ -882,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/gdnative/arvr/arvr_interface_gdnative.cpp b/modules/gdnative/arvr/arvr_interface_gdnative.cpp index da01f573ce..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) { @@ -137,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 651e5c8715..ab7090876a 100644 --- a/modules/gdnative/arvr/arvr_interface_gdnative.h +++ b/modules/gdnative/arvr/arvr_interface_gdnative.h @@ -49,6 +49,8 @@ protected: const godot_arvr_interface_gdnative *interface; void *data; + static void _bind_methods(); + public: /** general interface information **/ ARVRInterfaceGDNative(); 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/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/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/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/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/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_script.cpp b/modules/gdnative/pluginscript/pluginscript_script.cpp index 1d6f9db349..3ecb29404a 100644 --- a/modules/gdnative/pluginscript/pluginscript_script.cpp +++ b/modules/gdnative/pluginscript/pluginscript_script.cpp @@ -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/gdscript/doc_classes/@GDScript.xml b/modules/gdscript/doc_classes/@GDScript.xml index b6de5dbf62..3870a5ea7d 100644 --- a/modules/gdscript/doc_classes/@GDScript.xml +++ b/modules/gdscript/doc_classes/@GDScript.xml @@ -149,7 +149,7 @@ <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). + 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"> @@ -173,10 +173,8 @@ <description> Returns a character as a String of the given ASCII code. [codeblock] - # a is 'A' - a = char(65) - # a is 'a' - a = char(65 + 32) + a = char(65) # a is "A" + a = char(65 + 32) # a is "a" [/codeblock] </description> </method> @@ -210,14 +208,13 @@ <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 TYPE_* in [@GlobalScope]. + 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 + # Prints 1 print(a.length()) a = convert(a, TYPE_STRING) - # prints 6 - # (1, 0) is 6 characters + # Prints 6 as "(1, 0)" is 6 characters print(a.length()) [/codeblock] </description> @@ -230,7 +227,7 @@ <description> Returns the cosine of angle [code]s[/code] in radians. [codeblock] - # prints 1 and -1 + # Prints 1 then -1 print(cos(PI * 2)) print(cos(PI)) [/codeblock] @@ -244,7 +241,7 @@ <description> Returns the hyperbolic cosine of [code]s[/code] in radians. [codeblock] - # prints 1.543081 + # Prints 1.543081 print(cosh(1)) [/codeblock] </description> @@ -264,7 +261,7 @@ <argument index="0" name="step" type="float"> </argument> <description> - Deprecated alias for "[method step_decimals]". + Deprecated alias for [method step_decimals]. </description> </method> <method name="dectime"> @@ -326,7 +323,7 @@ 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 + a = exp(2) # Approximately 7.39 [/codeblock] </description> </method> @@ -355,7 +352,7 @@ <description> Returns the floating-point remainder of [code]x/y[/code]. [codeblock] - # remainder is 1.5 + # Remainder is 1.5 var remainder = fmod(7, 5.5) [/codeblock] </description> @@ -404,7 +401,7 @@ return("bar") a = funcref(self, "foo") - print(a.call_func()) # prints bar + print(a.call_func()) # Prints bar [/codeblock] </description> </method> @@ -437,7 +434,7 @@ <description> Returns the integer hash of the variable passed. [codeblock] - print(hash("a")) # prints 177670 + print(hash("a")) # Prints 177670 [/codeblock] </description> </method> @@ -474,7 +471,7 @@ func _ready(): var id = get_instance_id() var inst = instance_from_id(id) - print(inst.foo) # prints bar + print(inst.foo) # Prints bar [/codeblock] </description> </method> @@ -490,7 +487,7 @@ <description> Returns a normalized value considering the given range. [codeblock] - inverse_lerp(3, 5, 4) # returns 0.5 + inverse_lerp(3, 5, 4) # Returns 0.5 [/codeblock] </description> </method> @@ -551,7 +548,7 @@ [b]Note:[/b] Generates a fatal error if Variant can not provide a length. [codeblock] a = [1, 2, 3, 4] - len(a) # returns 4 + len(a) # Returns 4 [/codeblock] </description> </method> @@ -569,8 +566,8 @@ 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) + 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> @@ -590,9 +587,9 @@ </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 Assets Panel and choosing "Copy Path". + [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 + # Load a scene called main located in the root of the project directory var main = load("res://main.tscn") [/codeblock] </description> @@ -604,9 +601,9 @@ </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 your calculator which is a base 10 logarithm. + [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 + log(10) # Returns 2.302585 [/codeblock] </description> </method> @@ -620,8 +617,8 @@ <description> Returns the maximum of two values. [codeblock] - max(1, 2) # returns 2 - max(-3.99, -4) # returns -3.99 + max(1, 2) # Returns 2 + max(-3.99, -4) # Returns -3.99 [/codeblock] </description> </method> @@ -635,8 +632,8 @@ <description> Returns the minimum of two values. [codeblock] - min(1, 2) # returns 1 - min(-3.99, -4) # returns -4 + min(1, 2) # Returns 1 + min(-3.99, -4) # Returns -4 [/codeblock] </description> </method> @@ -653,7 +650,7 @@ 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 + move_toward(10, 5, 4) # Returns 6 [/codeblock] </description> </method> @@ -665,9 +662,9 @@ <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 + nearest_po2(3) # Returns 4 + nearest_po2(4) # Returns 4 + nearest_po2(5) # Returns 8 [/codeblock] </description> </method> @@ -683,7 +680,7 @@ [codeblock] p = parse_json('["a", "b", "c"]') if typeof(p) == TYPE_ARRAY: - print(p[0]) # prints a + print(p[0]) # Prints a else: print("unexpected results") [/codeblock] @@ -697,7 +694,7 @@ <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). + 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"> @@ -710,7 +707,7 @@ <description> Returns the result of [code]x[/code] raised to the power of [code]y[/code]. [codeblock] - pow(2, 5) # returns 32 + pow(2, 5) # Returns 32 [/codeblock] </description> </method> @@ -723,7 +720,7 @@ 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 + # Load a scene called main located in the root of the project directory var main = preload("res://main.tscn") [/codeblock] </description> @@ -735,7 +732,7 @@ 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] + print("a", "b", a) # Prints ab[1, 2, 3] [/codeblock] </description> </method> @@ -775,7 +772,7 @@ [codeblock] printraw("A") printraw("B") - # prints AB + # Prints AB [/codeblock] </description> </method> @@ -785,7 +782,7 @@ <description> Prints one or more arguments to the console with a space between each argument. [codeblock] - prints("A", "B", "C") # prints A B C + prints("A", "B", "C") # Prints A B C [/codeblock] </description> </method> @@ -795,7 +792,7 @@ <description> Prints one or more arguments to the console with a tab between each argument. [codeblock] - printt("A", "B", "C") # prints A B C + printt("A", "B", "C") # Prints A B C [/codeblock] </description> </method> @@ -807,7 +804,7 @@ <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 + push_error("test error") # Prints "test error" to debugger and terminal as error call [/codeblock] </description> </method> @@ -819,7 +816,7 @@ <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 + push_warning("test warning") # Prints "test warning" to debugger and terminal as warning call [/codeblock] </description> </method> @@ -831,7 +828,7 @@ <description> Converts from radians to degrees. [codeblock] - rad2deg(0.523599) # returns 30 + rad2deg(0.523599) # Returns 30 [/codeblock] </description> </method> @@ -845,7 +842,7 @@ <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 + prints(rand_range(0, 1), rand_range(0, 1)) # Prints e.g. 0.135591 0.405263 [/codeblock] </description> </method> @@ -864,7 +861,7 @@ <description> Returns a random floating point value on the interval [code][0, 1][/code]. [codeblock] - randf() # returns e.g. 0.375671 + randf() # Returns e.g. 0.375671 [/codeblock] </description> </method> @@ -874,10 +871,10 @@ <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 + 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> @@ -938,7 +935,7 @@ <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 + range_lerp(75, 0, 100, -1, 1) # Returns 0.5 [/codeblock] </description> </method> @@ -950,7 +947,7 @@ <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 + round(2.6) # Returns 3 [/codeblock] </description> </method> @@ -975,9 +972,9 @@ <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 + sign(-6) # Returns -1 + sign(0) # Returns 0 + sign(6) # Returns 1 [/codeblock] </description> </method> @@ -989,7 +986,7 @@ <description> Returns the sine of angle [code]s[/code] in radians. [codeblock] - sin(0.523599) # returns 0.5 + sin(0.523599) # Returns 0.5 [/codeblock] </description> </method> @@ -1001,8 +998,8 @@ <description> Returns the hyperbolic sine of [code]s[/code]. [codeblock] - a = log(2.0) # returns 0.693147 - sinh(a) # returns 0.75 + a = log(2.0) # Returns 0.693147 + sinh(a) # Returns 0.75 [/codeblock] </description> </method> @@ -1018,9 +1015,9 @@ <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 + 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> @@ -1032,7 +1029,7 @@ <description> Returns the square root of [code]s[/code]. [codeblock] - sqrt(9) # returns 3 + sqrt(9) # Returns 3 [/codeblock] </description> </method> @@ -1072,8 +1069,8 @@ [codeblock] var a = [10, 20, 30] var b = str(a); - len(a) # returns 3 - len(b) # returns 12 + len(a) # Returns 3 + len(b) # Returns 12 [/codeblock] </description> </method> @@ -1087,7 +1084,7 @@ [codeblock] a = '{ "a": 1, "b": 2 }' b = str2var(a) - print(b['a']) # prints 1 + print(b["a"]) # Prints 1 [/codeblock] </description> </method> @@ -1099,7 +1096,7 @@ <description> Returns the tangent of angle [code]s[/code] in radians. [codeblock] - tan(deg2rad(45)) # returns 1 + tan(deg2rad(45)) # Returns 1 [/codeblock] </description> </method> @@ -1111,8 +1108,8 @@ <description> Returns the hyperbolic tangent of [code]s[/code]. [codeblock] - a = log(2.0) # returns 0.693147 - tanh(a) # returns 0.6 + a = log(2.0) # Returns 0.693147 + tanh(a) # Returns 0.6 [/codeblock] </description> </method> @@ -1124,7 +1121,7 @@ <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 } + a = { "a": 1, "b": 2 } b = to_json(a) print(b) # {"a":1, "b":2} [/codeblock] @@ -1138,8 +1135,8 @@ <description> Returns whether the given class exists in [ClassDB]. [codeblock] - type_exists("Sprite") # returns true - type_exists("Variant") # returns false + type_exists("Sprite") # Returns true + type_exists("Variant") # Returns false [/codeblock] </description> </method> @@ -1149,11 +1146,11 @@ <argument index="0" name="what" type="Variant"> </argument> <description> - Returns the internal type of the given Variant object, using the TYPE_* enum in [@GlobalScope]. + 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 + print(p[0]) # Prints a else: print("unexpected results") [/codeblock] @@ -1195,7 +1192,7 @@ <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 } + a = { "a": 1, "b": 2 } print(var2str(a)) [/codeblock] prints @@ -1238,9 +1235,19 @@ a = wrapf(-0.5, 0.0, 10.0) [/codeblock] [codeblock] - # infinite loop between 0.0 and 0.99 + # 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"> @@ -1264,9 +1271,15 @@ a = wrapi(-1, 0, 10) [/codeblock] [codeblock] - # infinite loop between 0 and 9 + # 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"> diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index 3fb9268702..95f3c12806 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); diff --git a/modules/gdscript/gdscript_compiler.cpp b/modules/gdscript/gdscript_compiler.cpp index 189317b163..caffe04700 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; 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_parser.cpp b/modules/gdscript/gdscript_parser.cpp index ec3e72eef7..a4a27c39d7 100644 --- a/modules/gdscript/gdscript_parser.cpp +++ b/modules/gdscript/gdscript_parser.cpp @@ -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.. @@ -5944,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..951a49e0c1 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"> diff --git a/modules/gridmap/grid_map_editor_plugin.cpp b/modules/gridmap/grid_map_editor_plugin.cpp index 6b9a97efb4..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()) { 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/mobile_vr/doc_classes/MobileVRInterface.xml b/modules/mobile_vr/doc_classes/MobileVRInterface.xml index 8876bcbe9d..8cd63b304a 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") diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index 72199281ff..20b227bda1 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -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 64e3b40063..a2f1ec8f27 100644 --- a/modules/mono/csharp_script.h +++ b/modules/mono/csharp_script.h @@ -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); 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 4a28492bad..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; 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/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/OpenSimplexNoise.xml b/modules/opensimplex/doc_classes/OpenSimplexNoise.xml index 894a1b3ced..86acd4eaea 100644 --- a/modules/opensimplex/doc_classes/OpenSimplexNoise.xml +++ b/modules/opensimplex/doc_classes/OpenSimplexNoise.xml @@ -42,7 +42,7 @@ </argument> <description> Returns the 1D noise value [code][-1,1][/code] at the given x-coordinate. - Note: This method actually returns the 2D noise value [code][-1,1][/code] with fixed y-coordinate value 0.0. + [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"> @@ -108,7 +108,7 @@ <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> 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 445bf974b8..5e4a02fcee 100644 --- a/modules/opensimplex/noise_texture.h +++ b/modules/opensimplex/noise_texture.h @@ -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/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..398d2ee3b6 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> diff --git a/modules/upnp/doc_classes/UPNP.xml b/modules/upnp/doc_classes/UPNP.xml index 0516ea9d54..d3eb21e159 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> @@ -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/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/VisualScriptBuiltinFunc.xml b/modules/visual_script/doc_classes/VisualScriptBuiltinFunc.xml index 21e8a38c16..7add0bc2ba 100644 --- a/modules/visual_script/doc_classes/VisualScriptBuiltinFunc.xml +++ b/modules/visual_script/doc_classes/VisualScriptBuiltinFunc.xml @@ -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..7d83cd0203 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] 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/VisualScriptMathConstant.xml b/modules/visual_script/doc_classes/VisualScriptMathConstant.xml index 430f9ee7d4..fb4e423f0e 100644 --- a/modules/visual_script/doc_classes/VisualScriptMathConstant.xml +++ b/modules/visual_script/doc_classes/VisualScriptMathConstant.xml @@ -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/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/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_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_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/webrtc/doc_classes/WebRTCDataChannel.xml b/modules/webrtc/doc_classes/WebRTCDataChannel.xml index 7cce97244d..6d600f6239 100644 --- a/modules/webrtc/doc_classes/WebRTCDataChannel.xml +++ b/modules/webrtc/doc_classes/WebRTCDataChannel.xml @@ -56,7 +56,7 @@ <return type="int" enum="WebRTCDataChannel.ChannelState"> </return> <description> - Returns the current state of this channel, see [enum WebRTCDataChannel.ChannelState]. + Returns the current state of this channel, see [enum ChannelState]. </description> </method> <method name="is_negotiated" qualifiers="const"> diff --git a/modules/webrtc/doc_classes/WebRTCPeerConnection.xml b/modules/webrtc/doc_classes/WebRTCPeerConnection.xml index ae709877f4..26082d73a8 100644 --- a/modules/webrtc/doc_classes/WebRTCPeerConnection.xml +++ b/modules/webrtc/doc_classes/WebRTCPeerConnection.xml @@ -7,7 +7,7 @@ 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]B[/code]). + - [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> @@ -60,7 +60,7 @@ "protocol": "my-custom-protocol", # A custom sub-protocol string for this channel. } [/codeblock] - NOTE: You must keep a reference to channels created this way, or it will be closed. + [b]Note:[/b] You must keep a reference to channels created this way, or it will be closed. </description> </method> <method name="create_offer"> @@ -68,7 +68,7 @@ </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 [code]OK[/code], [signal session_description_created] will be called when the session is ready to be sent. + 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"> @@ -172,7 +172,7 @@ 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, non of the transports has failed. + 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. 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/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=""""> </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 103dbd771b..b80a28e648 100644 --- a/modules/websocket/doc_classes/WebSocketMultiplayerPeer.xml +++ b/modules/websocket/doc_classes/WebSocketMultiplayerPeer.xml @@ -30,10 +30,10 @@ <argument index="3" name="output_max_packets" type="int"> </argument> <description> - Configure the buffers sizes for this WebSocket peer. Default values can be specified in project settings under [code]network/limits[/code]. For server, values are meant per connected peer. + 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. - NOTE: HTML5 exports only use the input buffer since the output one is managed by browsers. + [b]Note:[/b] HTML5 exports only use the input buffer since the output one is managed by browsers. </description> </method> </methods> @@ -42,7 +42,8 @@ <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=""""> </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=""""> </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/websocket_multiplayer_peer.h b/modules/websocket/websocket_multiplayer_peer.h index 089bc25fe9..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; |