diff options
Diffstat (limited to 'modules')
693 files changed, 13998 insertions, 26679 deletions
diff --git a/modules/SCsub b/modules/SCsub index 24598f4b28..64da3bd0be 100644 --- a/modules/SCsub +++ b/modules/SCsub @@ -45,18 +45,6 @@ for name, path in env.module_list.items(): else: SConscript(path + "/SCsub") # Custom. - # Some modules are not linked automatically but can be enabled optionally - # on iOS, so we handle those specially. - if env["platform"] == "iphone" and name in [ - "arkit", - "camera", - "camera_iphone", - "gamecenter", - "inappstore", - "icloud", - ]: - continue - lib = env_modules.add_library("module_%s" % name, env.modules_sources) env.Prepend(LIBS=[lib]) if env["vsproj"]: diff --git a/modules/arkit/SCsub b/modules/arkit/SCsub deleted file mode 100644 index 7e103d6565..0000000000 --- a/modules/arkit/SCsub +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env python - -Import("env") -Import("env_modules") - -env_arkit = env_modules.Clone() - -# (iOS) Enable module support -env_arkit.Append(CCFLAGS=["-fmodules", "-fcxx-modules"]) - -# (iOS) Build as separate static library -modules_sources = [] -env_arkit.add_source_files(modules_sources, "*.cpp") -env_arkit.add_source_files(modules_sources, "*.mm") -mod_lib = env_modules.add_library("#bin/libgodot_arkit_module" + env["LIBSUFFIX"], modules_sources) diff --git a/modules/arkit/arkit.gdip b/modules/arkit/arkit.gdip deleted file mode 100644 index 22c0a07e26..0000000000 --- a/modules/arkit/arkit.gdip +++ /dev/null @@ -1,18 +0,0 @@ -[config] -name="ARKit" -binary="arkit_lib.a" - -initialization="register_arkit_types" -deinitialization="unregister_arkit_types" - -[dependencies] -linked=[] -embedded=[] -system=["AVFoundation.framework", "ARKit.framework"] - -capabilities=["arkit"] - -files=[] - -[plist] -NSCameraUsageDescription="Device camera is used for some functionality" diff --git a/modules/arkit/arkit_interface.mm b/modules/arkit/arkit_interface.mm deleted file mode 100644 index 1c42e6e008..0000000000 --- a/modules/arkit/arkit_interface.mm +++ /dev/null @@ -1,791 +0,0 @@ -/*************************************************************************/ -/* arkit_interface.mm */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include "core/input/input.h" -#include "core/os/os.h" -#include "scene/resources/surface_tool.h" -#include "servers/rendering/rendering_server_globals.h" - -#import <ARKit/ARKit.h> -#import <UIKit/UIKit.h> - -#include <dlfcn.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. -API_AVAILABLE(ios(11.0)) -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"); - - if (@available(iOS 11, *)) { - Class ARWorldTrackingConfigurationClass = NSClassFromString(@"ARWorldTrackingConfiguration"); - ARWorldTrackingConfiguration *configuration = [ARWorldTrackingConfigurationClass new]; - - configuration.lightEstimationEnabled = light_estimation_is_enabled; - if (plane_detection_is_enabled) { - if (@available(iOS 11.3, *)) { - configuration.planeDetection = ARPlaneDetectionVertical | ARPlaneDetectionHorizontal; - } else { - configuration.planeDetection = 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); - } - - if (@available(iOS 11.0, *)) { - [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 DisplayServer::WINDOW_EVENT_FOCUS_IN: { - print_line("Focus in"); - - start_session(); - }; break; - case DisplayServer::WINDOW_EVENT_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::XR_MONO + ARKitInterface::XR_AR; -} - -Array ARKitInterface::raycast(Vector2 p_screen_coord) { - if (@available(iOS 11, *)) { - Array arr; - Size2 screen_size = DisplayServer::get_singleton()->screen_get_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; - } else { - return Array(); - } -} - -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() { - XRServer *xr_server = XRServer::get_singleton(); - ERR_FAIL_NULL_V(xr_server, false); - - if (@available(iOS 11, *)) { - if (!initialized) { - print_line("initializing ARKit"); - - // create our ar session and delegate - Class ARSessionClass = NSClassFromString(@"ARSession"); - if (ARSessionClass == Nil) { - void *arkit_handle = dlopen("/System/Library/Frameworks/ARKit.framework/ARKit", RTLD_NOW); - if (arkit_handle) { - ARSessionClass = NSClassFromString(@"ARSession"); - } else { - print_line("ARKit init failed"); - return false; - } - } - ar_session = [ARSessionClass 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 - xr_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; - } else { - return false; - } -} - -void ARKitInterface::uninitialize() { - if (initialized) { - XRServer *xr_server = XRServer::get_singleton(); - if (xr_server != NULL) { - // no longer our primary interface - xr_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(); - - if (@available(iOS 11.0, *)) { - ar_session = nil; - } - - ar_delegate = nil; - initialized = false; - session_was_started = false; - } -} - -Size2 ARKitInterface::get_render_targetsize() { - // _THREAD_SAFE_METHOD_ - - Size2 target_size = DisplayServer::get_singleton()->screen_get_size(); - - return target_size; -} - -Transform ARKitInterface::get_transform_for_eye(XRInterface::Eyes p_eye, const Transform &p_cam_transform) { - // _THREAD_SAFE_METHOD_ - - Transform transform_for_eye; - - XRServer *xr_server = XRServer::get_singleton(); - ERR_FAIL_NULL_V(xr_server, transform_for_eye); - - if (initialized) { - float world_scale = xr_server->get_world_scale(); - - // just scale our origin point of our transform, 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 * xr_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(XRInterface::Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far) { - // Remember our near and far, it will be used in process when we obtain our projection from our ARKit session. - z_near = p_z_near; - z_far = p_z_far; - - return projection; -} - -void ARKitInterface::commit_for_eye(XRInterface::Eyes p_eye, RID p_render_target, const Rect2 &p_screen_rect) { - // _THREAD_SAFE_METHOD_ - - // We must have a valid render target - 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); -} - -XRPositionalTracker *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); - } - - XRPositionalTracker *new_tracker = memnew(XRPositionalTracker); - new_tracker->set_tracker_type(XRServer::TRACKER_ANCHOR); - - char tracker_name[256]; - sprintf(tracker_name, "Anchor %02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x", p_uuid[0], p_uuid[1], p_uuid[2], p_uuid[3], p_uuid[4], p_uuid[5], p_uuid[6], p_uuid[7], p_uuid[8], p_uuid[9], p_uuid[10], p_uuid[11], p_uuid[12], p_uuid[13], p_uuid[14], p_uuid[15]); - - String name = tracker_name; - print_line("Adding tracker " + name); - new_tracker->set_tracker_name(name); - - // add our tracker - XRServer::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 - XRServer::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 - XRServer::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 = DisplayServer::get_singleton()->screen_get_size(); - UIInterfaceOrientation orientation = UIInterfaceOrientationUnknown; - - if (@available(iOS 13, *)) { - orientation = [UIApplication sharedApplication].delegate.window.windowScene.interfaceOrientation; -#if !defined(TARGET_OS_SIMULATOR) || !TARGET_OS_SIMULATOR - } else { - orientation = [[UIApplication sharedApplication] statusBarOrientation]; -#endif - } - - // 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 - size_t new_width = CVPixelBufferGetWidthOfPlane(pixelBuffer, 0); - size_t new_height = CVPixelBufferGetHeightOfPlane(pixelBuffer, 0); - size_t 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: %lu, %lu - %lu\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); - } - - uint8_t *w = img_data[0].ptrw(); - if (new_width == bytes_per_row) { - memcpy(w, dataY, new_width * new_height); - } else { - size_t offset_a = 0; - size_t offset_b = extraLeft + (extraTop * bytes_per_row); - for (size_t r = 0; r < new_height; r++) { - memcpy(w + 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 - size_t new_width = CVPixelBufferGetWidthOfPlane(pixelBuffer, 1); - size_t new_height = CVPixelBufferGetHeightOfPlane(pixelBuffer, 1); - size_t bytes_per_row = CVPixelBufferGetBytesPerRowOfPlane(pixelBuffer, 0); - - if ((image_width[1] != new_width) || (image_height[1] != new_height)) { - printf("- Camera CbCr plane size: %lu, %lu - %lu\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); - } - - uint8_t *w = img_data[1].ptrw(); - if ((2 * new_width) == bytes_per_row) { - memcpy(w, dataCbCr, 2 * new_width * new_height); - } else { - size_t offset_a = 0; - size_t offset_b = extraLeft + (extraTop * bytes_per_row); - for (size_t r = 0; r < new_height; r++) { - memcpy(w + 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 != UIInterfaceOrientationPortrait) { - 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 = XRInterface::XR_NOT_TRACKING; - } else { - if (camera.trackingState == ARTrackingStateNormal) { - tracking_state = XRInterface::XR_NORMAL_TRACKING; - } else if (camera.trackingStateReason == ARTrackingStateReasonExcessiveMotion) { - tracking_state = XRInterface::XR_EXCESSIVE_MOTION; - } else if (camera.trackingStateReason == ARTrackingStateReasonInsufficientFeatures) { - tracking_state = XRInterface::XR_INSUFFICIENT_FEATURES; - } else { - tracking_state = XRInterface::XR_UNKNOWN_TRACKING; - } - - // copy our current frame transform - matrix_float4x4 m44 = camera.transform; - if (orientation == UIInterfaceOrientationLandscapeLeft) { - 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 == UIInterfaceOrientationPortrait) { - 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 == UIInterfaceOrientationLandscapeRight) { - 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 == UIInterfaceOrientationPortraitUpsideDown) { - // 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(GodotARAnchor *p_anchor) { - // _THREAD_SAFE_METHOD_ - - if (@available(iOS 11.0, *)) { - ARAnchor *anchor = (ARAnchor *)p_anchor; - - unsigned char uuid[16]; - [anchor.identifier getUUIDBytes:uuid]; - - XRPositionalTracker *tracker = get_anchor_for_uuid(uuid); - if (tracker != NULL) { - // lets update our mesh! (using Arjens code as is for now) - // we should also probably limit how often we do this... - - // can we safely cast this? - ARPlaneAnchor *planeAnchor = (ARPlaneAnchor *)anchor; - - if (@available(iOS 11.3, *)) { - 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->set_uv(Vector2(textcoord[0], textcoord[1])); - surftool->set_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); - } - } 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 XRAnchor 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(GodotARAnchor *p_anchor) { - // _THREAD_SAFE_METHOD_ - - if (@available(iOS 11.0, *)) { - 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; - if (@available(iOS 11.0, *)) { - ar_session = nil; - } - 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 deleted file mode 100644 index df98bf506e..0000000000 --- a/modules/arkit/arkit_session_delegate.h +++ /dev/null @@ -1,50 +0,0 @@ -/*************************************************************************/ -/* arkit_session_delegate.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef 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 API_AVAILABLE(ios(11.0)); -- (void)session:(ARSession *)session didRemoveAnchors:(NSArray<ARAnchor *> *)anchors API_AVAILABLE(ios(11.0)); -- (void)session:(ARSession *)session didUpdateAnchors:(NSArray<ARAnchor *> *)anchors API_AVAILABLE(ios(11.0)); -@end - -#endif /* !ARKIT_SESSION_DELEGATE_H */ diff --git a/modules/arkit/arkit_session_delegate.mm b/modules/arkit/arkit_session_delegate.mm deleted file mode 100644 index f44f46b7b7..0000000000 --- a/modules/arkit/arkit_session_delegate.mm +++ /dev/null @@ -1,56 +0,0 @@ -/*************************************************************************/ -/* arkit_session_delegate.mm */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include "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 diff --git a/modules/arkit/config.py b/modules/arkit/config.py deleted file mode 100644 index e68603fc93..0000000000 --- a/modules/arkit/config.py +++ /dev/null @@ -1,6 +0,0 @@ -def can_build(env, platform): - return platform == "iphone" - - -def configure(env): - pass diff --git a/modules/basis_universal/register_types.cpp b/modules/basis_universal/register_types.cpp index 27b299a65d..cf5581265b 100644 --- a/modules/basis_universal/register_types.cpp +++ b/modules/basis_universal/register_types.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -216,7 +216,7 @@ static Ref<Image> basis_universal_unpacker(const Vector<uint8_t> &p_buffer) { format = basist::transcoder_texture_format::cTFETC2; // get this from renderer imgfmt = Image::FORMAT_ETC2_RGBA8; } else { - //gles2 most likely, bad for normalmaps, nothing to do about this. + //gles2 most likely, bad for normal maps, nothing to do about this. format = basist::transcoder_texture_format::cTFRGBA32; imgfmt = Image::FORMAT_RGBA8; } diff --git a/modules/basis_universal/register_types.h b/modules/basis_universal/register_types.h index 5053dc27ce..30b465e344 100644 --- a/modules/basis_universal/register_types.h +++ b/modules/basis_universal/register_types.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/basis_universal/texture_basisu.cpp b/modules/basis_universal/texture_basisu.cpp index 5831d3de2a..92882a1cc8 100644 --- a/modules/basis_universal/texture_basisu.cpp +++ b/modules/basis_universal/texture_basisu.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -207,7 +207,6 @@ Vector<uint8_t> TextureBasisU::get_basisu_data() const { }; TextureBasisU::TextureBasisU() { - flags = FLAGS_DEFAULT; texture = RenderingServer::get_singleton()->texture_create(); }; diff --git a/modules/basis_universal/texture_basisu.h b/modules/basis_universal/texture_basisu.h index 99248f9162..282a0dfc8a 100644 --- a/modules/basis_universal/texture_basisu.h +++ b/modules/basis_universal/texture_basisu.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -47,7 +47,7 @@ class TextureBasisU : public Texture { RID texture; Size2 tex_size; - uint32_t flags; + uint32_t flags = FLAGS_DEFAULT; Vector<uint8_t> data; diff --git a/modules/bmp/image_loader_bmp.cpp b/modules/bmp/image_loader_bmp.cpp index b08970d110..c7fdf56af4 100644 --- a/modules/bmp/image_loader_bmp.cpp +++ b/modules/bmp/image_loader_bmp.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/bmp/image_loader_bmp.h b/modules/bmp/image_loader_bmp.h index 3f10a1c598..379e971458 100644 --- a/modules/bmp/image_loader_bmp.h +++ b/modules/bmp/image_loader_bmp.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -55,24 +55,24 @@ protected: struct bmp_header_s { struct bmp_file_header_s { - uint16_t bmp_signature; - uint32_t bmp_file_size; - uint32_t bmp_file_padding; - uint32_t bmp_file_offset; + uint16_t bmp_signature = 0; + uint32_t bmp_file_size = 0; + uint32_t bmp_file_padding = 0; + uint32_t bmp_file_offset = 0; } bmp_file_header; struct bmp_info_header_s { - uint32_t bmp_header_size; - uint32_t bmp_width; - uint32_t bmp_height; - uint16_t bmp_planes; - uint16_t bmp_bit_count; - uint32_t bmp_compression; - uint32_t bmp_size_image; - uint32_t bmp_pixels_per_meter_x; - uint32_t bmp_pixels_per_meter_y; - uint32_t bmp_colors_used; - uint32_t bmp_important_colors; + uint32_t bmp_header_size = 0; + uint32_t bmp_width = 0; + uint32_t bmp_height = 0; + uint16_t bmp_planes = 0; + uint16_t bmp_bit_count = 0; + uint32_t bmp_compression = 0; + uint32_t bmp_size_image = 0; + uint32_t bmp_pixels_per_meter_x = 0; + uint32_t bmp_pixels_per_meter_y = 0; + uint32_t bmp_colors_used = 0; + uint32_t bmp_important_colors = 0; } bmp_info_header; }; diff --git a/modules/bmp/register_types.cpp b/modules/bmp/register_types.cpp index 6220e956d6..d36ce9cdaf 100644 --- a/modules/bmp/register_types.cpp +++ b/modules/bmp/register_types.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/bmp/register_types.h b/modules/bmp/register_types.h index e7561dc32d..3ce81eba1b 100644 --- a/modules/bmp/register_types.h +++ b/modules/bmp/register_types.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/bullet/area_bullet.cpp b/modules/bullet/area_bullet.cpp index f8f7d79a11..c3bd84c329 100644 --- a/modules/bullet/area_bullet.cpp +++ b/modules/bullet/area_bullet.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/bullet/area_bullet.h b/modules/bullet/area_bullet.h index 152fd785c0..7cf666c119 100644 --- a/modules/bullet/area_bullet.h +++ b/modules/bullet/area_bullet.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -80,18 +80,18 @@ public: private: // These are used by function callEvent. Instead to create this each call I create if one time. Variant call_event_res[5]; - Variant *call_event_res_ptr[5]; + Variant *call_event_res_ptr[5] = {}; - btGhostObject *btGhost; + btGhostObject *btGhost = nullptr; Vector<OverlappingObjectData> overlappingObjects; bool monitorable = true; PhysicsServer3D::AreaSpaceOverrideMode spOv_mode = PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED; bool spOv_gravityPoint = false; - real_t spOv_gravityPointDistanceScale = 0; - real_t spOv_gravityPointAttenuation = 1; + real_t spOv_gravityPointDistanceScale = 0.0; + real_t spOv_gravityPointAttenuation = 1.0; Vector3 spOv_gravityVec = Vector3(0, -1, 0); - real_t spOv_gravityMag = 10; + real_t spOv_gravityMag = 10.0; real_t spOv_linearDump = 0.1; real_t spOv_angularDump = 0.1; int spOv_priority = 0; diff --git a/modules/bullet/btRayShape.cpp b/modules/bullet/btRayShape.cpp index a754ca6a89..109854c9dd 100644 --- a/modules/bullet/btRayShape.cpp +++ b/modules/bullet/btRayShape.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -39,11 +39,9 @@ */ btRayShape::btRayShape(btScalar length) : - btConvexInternalShape(), - m_shapeAxis(0, 0, 1) { + btConvexInternalShape() { m_shapeType = CUSTOM_CONVEX_SHAPE_TYPE; setLength(length); - slipsOnSlope = false; } btRayShape::~btRayShape() { diff --git a/modules/bullet/btRayShape.h b/modules/bullet/btRayShape.h index d9ecde81e6..330755aa31 100644 --- a/modules/bullet/btRayShape.h +++ b/modules/bullet/btRayShape.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -42,10 +42,10 @@ /// Ray shape around z axis ATTRIBUTE_ALIGNED16(class) btRayShape : public btConvexInternalShape { - btScalar m_length; - bool slipsOnSlope; + btScalar m_length = 0; + bool slipsOnSlope = false; /// The default axis is the z - btVector3 m_shapeAxis; + btVector3 m_shapeAxis = btVector3(0, 0, 1); btTransform m_cacheSupportPoint; btScalar m_cacheScaledLength; diff --git a/modules/bullet/bullet_physics_server.cpp b/modules/bullet/bullet_physics_server.cpp index 3b548b7faa..26e9f5a044 100644 --- a/modules/bullet/bullet_physics_server.cpp +++ b/modules/bullet/bullet_physics_server.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -625,14 +625,14 @@ uint32_t BulletPhysicsServer3D::body_get_user_flags(RID p_body) const { return 0; } -void BulletPhysicsServer3D::body_set_param(RID p_body, BodyParameter p_param, float p_value) { +void BulletPhysicsServer3D::body_set_param(RID p_body, BodyParameter p_param, real_t p_value) { RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_param(p_param, p_value); } -float BulletPhysicsServer3D::body_get_param(RID p_body, BodyParameter p_param) const { +real_t BulletPhysicsServer3D::body_get_param(RID p_body, BodyParameter p_param) const { RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, 0); @@ -807,11 +807,11 @@ int BulletPhysicsServer3D::body_get_max_contacts_reported(RID p_body) const { return body->get_max_collisions_detection(); } -void BulletPhysicsServer3D::body_set_contacts_reported_depth_threshold(RID p_body, float p_threshold) { +void BulletPhysicsServer3D::body_set_contacts_reported_depth_threshold(RID p_body, real_t p_threshold) { // Not supported by bullet and even Godot } -float BulletPhysicsServer3D::body_get_contacts_reported_depth_threshold(RID p_body) const { +real_t BulletPhysicsServer3D::body_get_contacts_reported_depth_threshold(RID p_body) const { // Not supported by bullet and even Godot return 0.; } @@ -862,7 +862,7 @@ bool BulletPhysicsServer3D::body_test_motion(RID p_body, const Transform &p_from return body->get_space()->test_body_motion(body, p_from, p_motion, p_infinite_inertia, r_result, p_exclude_raycast_shapes); } -int BulletPhysicsServer3D::body_test_ray_separation(RID p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, SeparationResult *r_results, int p_result_max, float p_margin) { +int BulletPhysicsServer3D::body_test_ray_separation(RID p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, SeparationResult *r_results, int p_result_max, real_t p_margin) { RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, 0); ERR_FAIL_COND_V(!body->get_space(), 0); @@ -1059,16 +1059,16 @@ real_t BulletPhysicsServer3D::soft_body_get_linear_stiffness(RID p_body) { return body->get_linear_stiffness(); } -void BulletPhysicsServer3D::soft_body_set_areaAngular_stiffness(RID p_body, real_t p_stiffness) { +void BulletPhysicsServer3D::soft_body_set_angular_stiffness(RID p_body, real_t p_stiffness) { SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND(!body); - body->set_areaAngular_stiffness(p_stiffness); + body->set_angular_stiffness(p_stiffness); } -real_t BulletPhysicsServer3D::soft_body_get_areaAngular_stiffness(RID p_body) { +real_t BulletPhysicsServer3D::soft_body_get_angular_stiffness(RID p_body) { SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, 0.f); - return body->get_areaAngular_stiffness(); + return body->get_angular_stiffness(); } void BulletPhysicsServer3D::soft_body_set_volume_stiffness(RID p_body, real_t p_stiffness) { @@ -1221,7 +1221,7 @@ RID BulletPhysicsServer3D::joint_create_pin(RID p_body_A, const Vector3 &p_local CreateThenReturnRID(joint_owner, joint); } -void BulletPhysicsServer3D::pin_joint_set_param(RID p_joint, PinJointParam p_param, float p_value) { +void BulletPhysicsServer3D::pin_joint_set_param(RID p_joint, PinJointParam p_param, real_t p_value) { JointBullet *joint = joint_owner.getornull(p_joint); ERR_FAIL_COND(!joint); ERR_FAIL_COND(joint->get_type() != JOINT_PIN); @@ -1229,7 +1229,7 @@ void BulletPhysicsServer3D::pin_joint_set_param(RID p_joint, PinJointParam p_par pin_joint->set_param(p_param, p_value); } -float BulletPhysicsServer3D::pin_joint_get_param(RID p_joint, PinJointParam p_param) const { +real_t BulletPhysicsServer3D::pin_joint_get_param(RID p_joint, PinJointParam p_param) const { JointBullet *joint = joint_owner.getornull(p_joint); ERR_FAIL_COND_V(!joint, 0); ERR_FAIL_COND_V(joint->get_type() != JOINT_PIN, 0); @@ -1309,7 +1309,7 @@ RID BulletPhysicsServer3D::joint_create_hinge_simple(RID p_body_A, const Vector3 CreateThenReturnRID(joint_owner, joint); } -void BulletPhysicsServer3D::hinge_joint_set_param(RID p_joint, HingeJointParam p_param, float p_value) { +void BulletPhysicsServer3D::hinge_joint_set_param(RID p_joint, HingeJointParam p_param, real_t p_value) { JointBullet *joint = joint_owner.getornull(p_joint); ERR_FAIL_COND(!joint); ERR_FAIL_COND(joint->get_type() != JOINT_HINGE); @@ -1317,7 +1317,7 @@ void BulletPhysicsServer3D::hinge_joint_set_param(RID p_joint, HingeJointParam p hinge_joint->set_param(p_param, p_value); } -float BulletPhysicsServer3D::hinge_joint_get_param(RID p_joint, HingeJointParam p_param) const { +real_t BulletPhysicsServer3D::hinge_joint_get_param(RID p_joint, HingeJointParam p_param) const { JointBullet *joint = joint_owner.getornull(p_joint); ERR_FAIL_COND_V(!joint, 0); ERR_FAIL_COND_V(joint->get_type() != JOINT_HINGE, 0); @@ -1361,7 +1361,7 @@ RID BulletPhysicsServer3D::joint_create_slider(RID p_body_A, const Transform &p_ CreateThenReturnRID(joint_owner, joint); } -void BulletPhysicsServer3D::slider_joint_set_param(RID p_joint, SliderJointParam p_param, float p_value) { +void BulletPhysicsServer3D::slider_joint_set_param(RID p_joint, SliderJointParam p_param, real_t p_value) { JointBullet *joint = joint_owner.getornull(p_joint); ERR_FAIL_COND(!joint); ERR_FAIL_COND(joint->get_type() != JOINT_SLIDER); @@ -1369,7 +1369,7 @@ void BulletPhysicsServer3D::slider_joint_set_param(RID p_joint, SliderJointParam slider_joint->set_param(p_param, p_value); } -float BulletPhysicsServer3D::slider_joint_get_param(RID p_joint, SliderJointParam p_param) const { +real_t BulletPhysicsServer3D::slider_joint_get_param(RID p_joint, SliderJointParam p_param) const { JointBullet *joint = joint_owner.getornull(p_joint); ERR_FAIL_COND_V(!joint, 0); ERR_FAIL_COND_V(joint->get_type() != JOINT_SLIDER, 0); @@ -1395,7 +1395,7 @@ RID BulletPhysicsServer3D::joint_create_cone_twist(RID p_body_A, const Transform CreateThenReturnRID(joint_owner, joint); } -void BulletPhysicsServer3D::cone_twist_joint_set_param(RID p_joint, ConeTwistJointParam p_param, float p_value) { +void BulletPhysicsServer3D::cone_twist_joint_set_param(RID p_joint, ConeTwistJointParam p_param, real_t p_value) { JointBullet *joint = joint_owner.getornull(p_joint); ERR_FAIL_COND(!joint); ERR_FAIL_COND(joint->get_type() != JOINT_CONE_TWIST); @@ -1403,7 +1403,7 @@ void BulletPhysicsServer3D::cone_twist_joint_set_param(RID p_joint, ConeTwistJoi coneTwist_joint->set_param(p_param, p_value); } -float BulletPhysicsServer3D::cone_twist_joint_get_param(RID p_joint, ConeTwistJointParam p_param) const { +real_t BulletPhysicsServer3D::cone_twist_joint_get_param(RID p_joint, ConeTwistJointParam p_param) const { JointBullet *joint = joint_owner.getornull(p_joint); ERR_FAIL_COND_V(!joint, 0.); ERR_FAIL_COND_V(joint->get_type() != JOINT_CONE_TWIST, 0.); @@ -1431,7 +1431,7 @@ RID BulletPhysicsServer3D::joint_create_generic_6dof(RID p_body_A, const Transfo CreateThenReturnRID(joint_owner, joint); } -void BulletPhysicsServer3D::generic_6dof_joint_set_param(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisParam p_param, float p_value) { +void BulletPhysicsServer3D::generic_6dof_joint_set_param(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisParam p_param, real_t p_value) { JointBullet *joint = joint_owner.getornull(p_joint); ERR_FAIL_COND(!joint); ERR_FAIL_COND(joint->get_type() != JOINT_6DOF); @@ -1439,7 +1439,7 @@ void BulletPhysicsServer3D::generic_6dof_joint_set_param(RID p_joint, Vector3::A generic_6dof_joint->set_param(p_axis, p_param, p_value); } -float BulletPhysicsServer3D::generic_6dof_joint_get_param(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisParam p_param) { +real_t BulletPhysicsServer3D::generic_6dof_joint_get_param(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisParam p_param) { JointBullet *joint = joint_owner.getornull(p_joint); ERR_FAIL_COND_V(!joint, 0); ERR_FAIL_COND_V(joint->get_type() != JOINT_6DOF, 0); @@ -1525,7 +1525,7 @@ void BulletPhysicsServer3D::init() { BulletPhysicsDirectBodyState3D::initSingleton(); } -void BulletPhysicsServer3D::step(float p_deltaTime) { +void BulletPhysicsServer3D::step(real_t p_deltaTime) { if (!active) { return; } diff --git a/modules/bullet/bullet_physics_server.h b/modules/bullet/bullet_physics_server.h index 07a32e510c..97b719ae8e 100644 --- a/modules/bullet/bullet_physics_server.h +++ b/modules/bullet/bullet_physics_server.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -207,8 +207,8 @@ public: /// This is not supported by physics server virtual uint32_t body_get_user_flags(RID p_body) const override; - virtual void body_set_param(RID p_body, BodyParameter p_param, float p_value) override; - virtual float body_get_param(RID p_body, BodyParameter p_param) const override; + virtual void body_set_param(RID p_body, BodyParameter p_param, real_t p_value) override; + virtual real_t body_get_param(RID p_body, BodyParameter p_param) const override; virtual void body_set_kinematic_safe_margin(RID p_body, real_t p_margin) override; virtual real_t body_get_kinematic_safe_margin(RID p_body) const override; @@ -241,8 +241,8 @@ public: virtual void body_set_max_contacts_reported(RID p_body, int p_contacts) override; virtual int body_get_max_contacts_reported(RID p_body) const override; - virtual void body_set_contacts_reported_depth_threshold(RID p_body, float p_threshold) override; - virtual float body_get_contacts_reported_depth_threshold(RID p_body) const override; + virtual void body_set_contacts_reported_depth_threshold(RID p_body, real_t p_threshold) override; + virtual real_t body_get_contacts_reported_depth_threshold(RID p_body) const override; virtual void body_set_omit_force_integration(RID p_body, bool p_omit) override; virtual bool body_is_omitting_force_integration(RID p_body) const override; @@ -256,7 +256,7 @@ public: virtual PhysicsDirectBodyState3D *body_get_direct_state(RID p_body) override; virtual bool body_test_motion(RID p_body, const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia, MotionResult *r_result = nullptr, bool p_exclude_raycast_shapes = true) override; - virtual int body_test_ray_separation(RID p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, SeparationResult *r_results, int p_result_max, float p_margin = 0.001) override; + virtual int body_test_ray_separation(RID p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, SeparationResult *r_results, int p_result_max, real_t p_margin = 0.001) override; /* SOFT BODY API */ @@ -298,8 +298,8 @@ public: virtual void soft_body_set_linear_stiffness(RID p_body, real_t p_stiffness) override; virtual real_t soft_body_get_linear_stiffness(RID p_body) override; - virtual void soft_body_set_areaAngular_stiffness(RID p_body, real_t p_stiffness) override; - virtual real_t soft_body_get_areaAngular_stiffness(RID p_body) override; + virtual void soft_body_set_angular_stiffness(RID p_body, real_t p_stiffness) override; + virtual real_t soft_body_get_angular_stiffness(RID p_body) override; virtual void soft_body_set_volume_stiffness(RID p_body, real_t p_stiffness) override; virtual real_t soft_body_get_volume_stiffness(RID p_body) override; @@ -337,8 +337,8 @@ public: virtual RID joint_create_pin(RID p_body_A, const Vector3 &p_local_A, RID p_body_B, const Vector3 &p_local_B) override; - virtual void pin_joint_set_param(RID p_joint, PinJointParam p_param, float p_value) override; - virtual float pin_joint_get_param(RID p_joint, PinJointParam p_param) const override; + virtual void pin_joint_set_param(RID p_joint, PinJointParam p_param, real_t p_value) override; + virtual real_t pin_joint_get_param(RID p_joint, PinJointParam p_param) const override; virtual void pin_joint_set_local_a(RID p_joint, const Vector3 &p_A) override; virtual Vector3 pin_joint_get_local_a(RID p_joint) const override; @@ -349,8 +349,8 @@ public: virtual RID joint_create_hinge(RID p_body_A, const Transform &p_hinge_A, RID p_body_B, const Transform &p_hinge_B) override; virtual RID joint_create_hinge_simple(RID p_body_A, const Vector3 &p_pivot_A, const Vector3 &p_axis_A, RID p_body_B, const Vector3 &p_pivot_B, const Vector3 &p_axis_B) override; - virtual void hinge_joint_set_param(RID p_joint, HingeJointParam p_param, float p_value) override; - virtual float hinge_joint_get_param(RID p_joint, HingeJointParam p_param) const override; + virtual void hinge_joint_set_param(RID p_joint, HingeJointParam p_param, real_t p_value) override; + virtual real_t hinge_joint_get_param(RID p_joint, HingeJointParam p_param) const override; virtual void hinge_joint_set_flag(RID p_joint, HingeJointFlag p_flag, bool p_value) override; virtual bool hinge_joint_get_flag(RID p_joint, HingeJointFlag p_flag) const override; @@ -358,20 +358,20 @@ public: /// Reference frame is A virtual RID joint_create_slider(RID p_body_A, const Transform &p_local_frame_A, RID p_body_B, const Transform &p_local_frame_B) override; - virtual void slider_joint_set_param(RID p_joint, SliderJointParam p_param, float p_value) override; - virtual float slider_joint_get_param(RID p_joint, SliderJointParam p_param) const override; + virtual void slider_joint_set_param(RID p_joint, SliderJointParam p_param, real_t p_value) override; + virtual real_t slider_joint_get_param(RID p_joint, SliderJointParam p_param) const override; /// Reference frame is A virtual RID joint_create_cone_twist(RID p_body_A, const Transform &p_local_frame_A, RID p_body_B, const Transform &p_local_frame_B) override; - virtual void cone_twist_joint_set_param(RID p_joint, ConeTwistJointParam p_param, float p_value) override; - virtual float cone_twist_joint_get_param(RID p_joint, ConeTwistJointParam p_param) const override; + virtual void cone_twist_joint_set_param(RID p_joint, ConeTwistJointParam p_param, real_t p_value) override; + virtual real_t cone_twist_joint_get_param(RID p_joint, ConeTwistJointParam p_param) const override; /// Reference frame is A virtual RID joint_create_generic_6dof(RID p_body_A, const Transform &p_local_frame_A, RID p_body_B, const Transform &p_local_frame_B) override; - virtual void generic_6dof_joint_set_param(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisParam p_param, float p_value) override; - virtual float generic_6dof_joint_get_param(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisParam p_param) override; + virtual void generic_6dof_joint_set_param(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisParam p_param, real_t p_value) override; + virtual real_t generic_6dof_joint_get_param(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisParam p_param) override; virtual void generic_6dof_joint_set_flag(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisFlag p_flag, bool p_enable) override; virtual bool generic_6dof_joint_get_flag(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisFlag p_flag) override; @@ -393,7 +393,7 @@ public: } virtual void init() override; - virtual void step(float p_deltaTime) override; + virtual void step(real_t p_deltaTime) override; virtual void flush_queries() override; virtual void finish() override; diff --git a/modules/bullet/bullet_types_converter.cpp b/modules/bullet/bullet_types_converter.cpp index 09b90fe09e..7b21e4e4b2 100644 --- a/modules/bullet/bullet_types_converter.cpp +++ b/modules/bullet/bullet_types_converter.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/bullet/bullet_types_converter.h b/modules/bullet/bullet_types_converter.h index fef07c55b7..ca9b7175dd 100644 --- a/modules/bullet/bullet_types_converter.h +++ b/modules/bullet/bullet_types_converter.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/bullet/bullet_utilities.h b/modules/bullet/bullet_utilities.h index a5e33d9829..a7c0fafbea 100644 --- a/modules/bullet/bullet_utilities.h +++ b/modules/bullet/bullet_utilities.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/bullet/collision_object_bullet.cpp b/modules/bullet/collision_object_bullet.cpp index a3158a15e5..bce8ec8076 100644 --- a/modules/bullet/collision_object_bullet.cpp +++ b/modules/bullet/collision_object_bullet.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/bullet/collision_object_bullet.h b/modules/bullet/collision_object_bullet.h index e2d05f2c38..c8081a53f1 100644 --- a/modules/bullet/collision_object_bullet.h +++ b/modules/bullet/collision_object_bullet.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -110,7 +110,7 @@ public: }; protected: - Type type; + Type type = TYPE_AREA; ObjectID instance_id; uint32_t collisionLayer = 0; uint32_t collisionMask = 0; diff --git a/modules/bullet/cone_twist_joint_bullet.cpp b/modules/bullet/cone_twist_joint_bullet.cpp index b4735fa9e9..e785780c5b 100644 --- a/modules/bullet/cone_twist_joint_bullet.cpp +++ b/modules/bullet/cone_twist_joint_bullet.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/bullet/cone_twist_joint_bullet.h b/modules/bullet/cone_twist_joint_bullet.h index ed4baa9d1b..7d6bafd292 100644 --- a/modules/bullet/cone_twist_joint_bullet.h +++ b/modules/bullet/cone_twist_joint_bullet.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/bullet/config.py b/modules/bullet/config.py index d22f9454ed..be7cf74f6f 100644 --- a/modules/bullet/config.py +++ b/modules/bullet/config.py @@ -1,5 +1,6 @@ def can_build(env, platform): - return True + # API Changed and bullet is disabled at the moment + return False def configure(env): diff --git a/modules/bullet/constraint_bullet.cpp b/modules/bullet/constraint_bullet.cpp index c47a23e75f..e610727685 100644 --- a/modules/bullet/constraint_bullet.cpp +++ b/modules/bullet/constraint_bullet.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/bullet/constraint_bullet.h b/modules/bullet/constraint_bullet.h index 538808be51..6afd8c9b52 100644 --- a/modules/bullet/constraint_bullet.h +++ b/modules/bullet/constraint_bullet.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/bullet/generic_6dof_joint_bullet.cpp b/modules/bullet/generic_6dof_joint_bullet.cpp index d75bf1fb98..43ad6c56d5 100644 --- a/modules/bullet/generic_6dof_joint_bullet.cpp +++ b/modules/bullet/generic_6dof_joint_bullet.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/bullet/generic_6dof_joint_bullet.h b/modules/bullet/generic_6dof_joint_bullet.h index ed25337745..62b8e85a81 100644 --- a/modules/bullet/generic_6dof_joint_bullet.h +++ b/modules/bullet/generic_6dof_joint_bullet.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/bullet/godot_collision_configuration.cpp b/modules/bullet/godot_collision_configuration.cpp index ec7a1dbd9a..94f150b712 100644 --- a/modules/bullet/godot_collision_configuration.cpp +++ b/modules/bullet/godot_collision_configuration.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/bullet/godot_collision_configuration.h b/modules/bullet/godot_collision_configuration.h index ffad1b1bda..8ed55cb1da 100644 --- a/modules/bullet/godot_collision_configuration.h +++ b/modules/bullet/godot_collision_configuration.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/bullet/godot_collision_dispatcher.cpp b/modules/bullet/godot_collision_dispatcher.cpp index d919c85469..5d1e4d34d8 100644 --- a/modules/bullet/godot_collision_dispatcher.cpp +++ b/modules/bullet/godot_collision_dispatcher.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/bullet/godot_collision_dispatcher.h b/modules/bullet/godot_collision_dispatcher.h index 13e7255abf..77472a9432 100644 --- a/modules/bullet/godot_collision_dispatcher.h +++ b/modules/bullet/godot_collision_dispatcher.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/bullet/godot_motion_state.h b/modules/bullet/godot_motion_state.h index 90d1614a77..ca17349130 100644 --- a/modules/bullet/godot_motion_state.h +++ b/modules/bullet/godot_motion_state.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -51,7 +51,7 @@ class GodotMotionState : public btMotionState { /// This data is used to store last world position btTransform bodyCurrentWorldTransform; - RigidBodyBullet *owner; + RigidBodyBullet *owner = nullptr; public: GodotMotionState(RigidBodyBullet *p_owner) : diff --git a/modules/bullet/godot_ray_world_algorithm.cpp b/modules/bullet/godot_ray_world_algorithm.cpp index a84f3511ba..a8291d4ab4 100644 --- a/modules/bullet/godot_ray_world_algorithm.cpp +++ b/modules/bullet/godot_ray_world_algorithm.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/bullet/godot_ray_world_algorithm.h b/modules/bullet/godot_ray_world_algorithm.h index 9786732d40..25798aecb4 100644 --- a/modules/bullet/godot_ray_world_algorithm.h +++ b/modules/bullet/godot_ray_world_algorithm.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -45,7 +45,7 @@ class GodotRayWorldAlgorithm : public btActivatingCollisionAlgorithm { const btDiscreteDynamicsWorld *m_world; btPersistentManifold *m_manifoldPtr; bool m_ownManifold = false; - bool m_isSwapped; + bool m_isSwapped = false; public: GodotRayWorldAlgorithm(const btDiscreteDynamicsWorld *world, btPersistentManifold *mf, const btCollisionAlgorithmConstructionInfo &ci, const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap, bool isSwapped); diff --git a/modules/bullet/godot_result_callbacks.cpp b/modules/bullet/godot_result_callbacks.cpp index f82648d6ff..15d625afeb 100644 --- a/modules/bullet/godot_result_callbacks.cpp +++ b/modules/bullet/godot_result_callbacks.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/bullet/godot_result_callbacks.h b/modules/bullet/godot_result_callbacks.h index 1325542973..f92665f3e4 100644 --- a/modules/bullet/godot_result_callbacks.h +++ b/modules/bullet/godot_result_callbacks.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -59,8 +59,8 @@ struct GodotClosestRayResultCallback : public btCollisionWorld::ClosestRayResult bool m_pickRay = false; int m_shapeId = 0; - bool collide_with_bodies; - bool collide_with_areas; + bool collide_with_bodies = false; + bool collide_with_areas = false; public: GodotClosestRayResultCallback(const btVector3 &rayFromWorld, const btVector3 &rayToWorld, const Set<RID> *p_exclude, bool p_collide_with_bodies, bool p_collide_with_areas) : @@ -84,8 +84,8 @@ public: // store all colliding object struct GodotAllConvexResultCallback : public btCollisionWorld::ConvexResultCallback { public: - PhysicsDirectSpaceState3D::ShapeResult *m_results; - int m_resultMax; + PhysicsDirectSpaceState3D::ShapeResult *m_results = nullptr; + int m_resultMax = 0; const Set<RID> *m_exclude; int count = 0; @@ -117,8 +117,8 @@ public: const Set<RID> *m_exclude; int m_shapeId = 0; - bool collide_with_bodies; - bool collide_with_areas; + bool collide_with_bodies = false; + bool collide_with_areas = false; GodotClosestConvexResultCallback(const btVector3 &convexFromWorld, const btVector3 &convexToWorld, const Set<RID> *p_exclude, bool p_collide_with_bodies, bool p_collide_with_areas) : btCollisionWorld::ClosestConvexResultCallback(convexFromWorld, convexToWorld), @@ -134,13 +134,13 @@ public: struct GodotAllContactResultCallback : public btCollisionWorld::ContactResultCallback { public: const btCollisionObject *m_self_object; - PhysicsDirectSpaceState3D::ShapeResult *m_results; - int m_resultMax; + PhysicsDirectSpaceState3D::ShapeResult *m_results = nullptr; + int m_resultMax = 0; const Set<RID> *m_exclude; int m_count = 0; - bool collide_with_bodies; - bool collide_with_areas; + bool collide_with_bodies = false; + bool collide_with_areas = false; GodotAllContactResultCallback(btCollisionObject *p_self_object, PhysicsDirectSpaceState3D::ShapeResult *p_results, int p_resultMax, const Set<RID> *p_exclude, bool p_collide_with_bodies, bool p_collide_with_areas) : m_self_object(p_self_object), @@ -159,13 +159,13 @@ public: struct GodotContactPairContactResultCallback : public btCollisionWorld::ContactResultCallback { public: const btCollisionObject *m_self_object; - Vector3 *m_results; - int m_resultMax; + Vector3 *m_results = nullptr; + int m_resultMax = 0; const Set<RID> *m_exclude; int m_count = 0; - bool collide_with_bodies; - bool collide_with_areas; + bool collide_with_bodies = false; + bool collide_with_areas = false; GodotContactPairContactResultCallback(btCollisionObject *p_self_object, Vector3 *p_results, int p_resultMax, const Set<RID> *p_exclude, bool p_collide_with_bodies, bool p_collide_with_areas) : m_self_object(p_self_object), @@ -183,14 +183,14 @@ public: struct GodotRestInfoContactResultCallback : public btCollisionWorld::ContactResultCallback { public: const btCollisionObject *m_self_object; - PhysicsDirectSpaceState3D::ShapeRestInfo *m_result; + PhysicsDirectSpaceState3D::ShapeRestInfo *m_result = nullptr; const Set<RID> *m_exclude; bool m_collided = false; - real_t m_min_distance = 0; - const btCollisionObject *m_rest_info_collision_object; + real_t m_min_distance = 0.0; + const btCollisionObject *m_rest_info_collision_object = nullptr; btVector3 m_rest_info_bt_point; - bool collide_with_bodies; - bool collide_with_areas; + bool collide_with_bodies = false; + bool collide_with_areas = false; GodotRestInfoContactResultCallback(btCollisionObject *p_self_object, PhysicsDirectSpaceState3D::ShapeRestInfo *p_result, const Set<RID> *p_exclude, bool p_collide_with_bodies, bool p_collide_with_areas) : m_self_object(p_self_object), diff --git a/modules/bullet/hinge_joint_bullet.cpp b/modules/bullet/hinge_joint_bullet.cpp index 2338277565..4ceb98729f 100644 --- a/modules/bullet/hinge_joint_bullet.cpp +++ b/modules/bullet/hinge_joint_bullet.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/bullet/hinge_joint_bullet.h b/modules/bullet/hinge_joint_bullet.h index 120c40e5c0..06a95be374 100644 --- a/modules/bullet/hinge_joint_bullet.h +++ b/modules/bullet/hinge_joint_bullet.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/bullet/joint_bullet.cpp b/modules/bullet/joint_bullet.cpp index 6257ff0058..ac371658f5 100644 --- a/modules/bullet/joint_bullet.cpp +++ b/modules/bullet/joint_bullet.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/bullet/joint_bullet.h b/modules/bullet/joint_bullet.h index c70cea817e..5bb8b50961 100644 --- a/modules/bullet/joint_bullet.h +++ b/modules/bullet/joint_bullet.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/bullet/pin_joint_bullet.cpp b/modules/bullet/pin_joint_bullet.cpp index 1cfbc65c78..8e8ff57f11 100644 --- a/modules/bullet/pin_joint_bullet.cpp +++ b/modules/bullet/pin_joint_bullet.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/bullet/pin_joint_bullet.h b/modules/bullet/pin_joint_bullet.h index e7d05f34d4..6fbb6f7e02 100644 --- a/modules/bullet/pin_joint_bullet.h +++ b/modules/bullet/pin_joint_bullet.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/bullet/register_types.cpp b/modules/bullet/register_types.cpp index d29b699ecd..b5ad5749a6 100644 --- a/modules/bullet/register_types.cpp +++ b/modules/bullet/register_types.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/bullet/register_types.h b/modules/bullet/register_types.h index 5a01a1422e..e405996705 100644 --- a/modules/bullet/register_types.h +++ b/modules/bullet/register_types.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/bullet/rid_bullet.h b/modules/bullet/rid_bullet.h index 0db09b2b78..face6b4861 100644 --- a/modules/bullet/rid_bullet.h +++ b/modules/bullet/rid_bullet.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -41,7 +41,7 @@ class BulletPhysicsServer3D; class RIDBullet { RID self; - BulletPhysicsServer3D *physicsServer; + BulletPhysicsServer3D *physicsServer = nullptr; public: _FORCE_INLINE_ void set_self(const RID &p_self) { self = p_self; } diff --git a/modules/bullet/rigid_body_bullet.cpp b/modules/bullet/rigid_body_bullet.cpp index 284a22717b..a5093afe9d 100644 --- a/modules/bullet/rigid_body_bullet.cpp +++ b/modules/bullet/rigid_body_bullet.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -56,11 +56,11 @@ Vector3 BulletPhysicsDirectBodyState3D::get_total_gravity() const { return gVec; } -float BulletPhysicsDirectBodyState3D::get_total_angular_damp() const { +real_t BulletPhysicsDirectBodyState3D::get_total_angular_damp() const { return body->btBody->getAngularDamping(); } -float BulletPhysicsDirectBodyState3D::get_total_linear_damp() const { +real_t BulletPhysicsDirectBodyState3D::get_total_linear_damp() const { return body->btBody->getLinearDamping(); } @@ -74,7 +74,7 @@ Basis BulletPhysicsDirectBodyState3D::get_principal_inertia_axes() const { return Basis(); } -float BulletPhysicsDirectBodyState3D::get_inverse_mass() const { +real_t BulletPhysicsDirectBodyState3D::get_inverse_mass() const { return body->btBody->getInvMass(); } @@ -158,7 +158,7 @@ Vector3 BulletPhysicsDirectBodyState3D::get_contact_local_normal(int p_contact_i return body->collisions[p_contact_idx].hitNormal; } -float BulletPhysicsDirectBodyState3D::get_contact_impulse(int p_contact_idx) const { +real_t BulletPhysicsDirectBodyState3D::get_contact_impulse(int p_contact_idx) const { return body->collisions[p_contact_idx].appliedImpulse; } @@ -322,7 +322,8 @@ void RigidBodyBullet::set_space(SpaceBullet *p_space) { if (space) { can_integrate_forces = false; isScratchedSpaceOverrideModificator = false; - + // Remove any constraints + space->remove_rigid_body_constraints(this); // Remove this object form the physics world space->remove_rigid_body(this); } @@ -411,7 +412,7 @@ void RigidBodyBullet::on_collision_checker_end() { isTransformChanged = btBody->isActive() && !btBody->isStaticOrKinematicObject(); } -bool RigidBodyBullet::add_collision_object(RigidBodyBullet *p_otherObject, const Vector3 &p_hitWorldLocation, const Vector3 &p_hitLocalLocation, const Vector3 &p_hitNormal, const float &p_appliedImpulse, int p_other_shape_index, int p_local_shape_index) { +bool RigidBodyBullet::add_collision_object(RigidBodyBullet *p_otherObject, const Vector3 &p_hitWorldLocation, const Vector3 &p_hitLocalLocation, const Vector3 &p_hitNormal, const real_t &p_appliedImpulse, int p_other_shape_index, int p_local_shape_index) { if (collisionsCount >= maxCollisionsDetection) { return false; } @@ -709,12 +710,12 @@ bool RigidBodyBullet::is_axis_locked(PhysicsServer3D::BodyAxis p_axis) const { } void RigidBodyBullet::reload_axis_lock() { - btBody->setLinearFactor(btVector3(float(!is_axis_locked(PhysicsServer3D::BODY_AXIS_LINEAR_X)), float(!is_axis_locked(PhysicsServer3D::BODY_AXIS_LINEAR_Y)), float(!is_axis_locked(PhysicsServer3D::BODY_AXIS_LINEAR_Z)))); + btBody->setLinearFactor(btVector3(btScalar(!is_axis_locked(PhysicsServer3D::BODY_AXIS_LINEAR_X)), btScalar(!is_axis_locked(PhysicsServer3D::BODY_AXIS_LINEAR_Y)), btScalar(!is_axis_locked(PhysicsServer3D::BODY_AXIS_LINEAR_Z)))); if (PhysicsServer3D::BODY_MODE_CHARACTER == mode) { /// When character angular is always locked btBody->setAngularFactor(btVector3(0., 0., 0.)); } else { - btBody->setAngularFactor(btVector3(float(!is_axis_locked(PhysicsServer3D::BODY_AXIS_ANGULAR_X)), float(!is_axis_locked(PhysicsServer3D::BODY_AXIS_ANGULAR_Y)), float(!is_axis_locked(PhysicsServer3D::BODY_AXIS_ANGULAR_Z)))); + btBody->setAngularFactor(btVector3(btScalar(!is_axis_locked(PhysicsServer3D::BODY_AXIS_ANGULAR_X)), btScalar(!is_axis_locked(PhysicsServer3D::BODY_AXIS_ANGULAR_Y)), btScalar(!is_axis_locked(PhysicsServer3D::BODY_AXIS_ANGULAR_Z)))); } } diff --git a/modules/bullet/rigid_body_bullet.h b/modules/bullet/rigid_body_bullet.h index 8ff96577b6..a4be7f9e07 100644 --- a/modules/bullet/rigid_body_bullet.h +++ b/modules/bullet/rigid_body_bullet.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -81,21 +81,21 @@ public: } public: - RigidBodyBullet *body; - real_t deltaTime; + RigidBodyBullet *body = nullptr; + real_t deltaTime = 0.0; private: BulletPhysicsDirectBodyState3D() {} public: virtual Vector3 get_total_gravity() const override; - virtual float get_total_angular_damp() const override; - virtual float get_total_linear_damp() const override; + virtual real_t get_total_angular_damp() const override; + virtual real_t get_total_linear_damp() const override; virtual Vector3 get_center_of_mass() const override; virtual Basis get_principal_inertia_axes() const override; // get the mass - virtual float get_inverse_mass() const override; + virtual real_t get_inverse_mass() const override; // get density of this body space virtual Vector3 get_inverse_inertia() const override; // get density of this body space @@ -124,7 +124,7 @@ public: virtual Vector3 get_contact_local_position(int p_contact_idx) const override; virtual Vector3 get_contact_local_normal(int p_contact_idx) const override; - virtual float get_contact_impulse(int p_contact_idx) const override; + virtual real_t get_contact_impulse(int p_contact_idx) const override; virtual int get_contact_local_shape(int p_contact_idx) const override; virtual RID get_contact_collider(int p_contact_idx) const override; @@ -144,13 +144,13 @@ public: class RigidBodyBullet : public RigidCollisionObjectBullet { public: struct CollisionData { - RigidBodyBullet *otherObject; - int other_object_shape; - int local_shape; + RigidBodyBullet *otherObject = nullptr; + int other_object_shape = 0; + int local_shape = 0; Vector3 hitLocalLocation; Vector3 hitWorldLocation; Vector3 hitNormal; - float appliedImpulse; + real_t appliedImpulse = 0.0; }; struct ForceIntegrationCallback { @@ -169,7 +169,7 @@ public: }; struct KinematicUtilities { - RigidBodyBullet *owner; + RigidBodyBullet *owner = nullptr; btScalar safe_margin; Vector<KinematicShape> shapes; @@ -194,10 +194,10 @@ private: GodotMotionState *godotMotionState; btRigidBody *btBody; uint16_t locked_axis = 0; - real_t mass = 1; - real_t gravity_scale = 1; - real_t linearDamp = 0; - real_t angularDamp = 0; + real_t mass = 1.0; + real_t gravity_scale = 1.0; + real_t linearDamp = 0.0; + real_t angularDamp = 0.0; bool can_sleep = true; bool omit_forces_integration = false; bool can_integrate_forces = false; @@ -264,7 +264,7 @@ public: } bool can_add_collision() { return collisionsCount < maxCollisionsDetection; } - bool add_collision_object(RigidBodyBullet *p_otherObject, const Vector3 &p_hitWorldLocation, const Vector3 &p_hitLocalLocation, const Vector3 &p_hitNormal, const float &p_appliedImpulse, int p_other_shape_index, int p_local_shape_index); + bool add_collision_object(RigidBodyBullet *p_otherObject, const Vector3 &p_hitWorldLocation, const Vector3 &p_hitLocalLocation, const Vector3 &p_hitNormal, const real_t &p_appliedImpulse, int p_other_shape_index, int p_local_shape_index); bool was_colliding(RigidBodyBullet *p_other_object); void set_activation_state(bool p_active); diff --git a/modules/bullet/shape_bullet.cpp b/modules/bullet/shape_bullet.cpp index c7b761e92a..82876ab77c 100644 --- a/modules/bullet/shape_bullet.cpp +++ b/modules/bullet/shape_bullet.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -480,7 +480,11 @@ void HeightMapShapeBullet::set_data(const Variant &p_data) { Vector<real_t> l_heights; Variant l_heights_v = d["heights"]; +#ifdef REAL_T_IS_DOUBLE + if (l_heights_v.get_type() == Variant::PACKED_FLOAT64_ARRAY) { +#else if (l_heights_v.get_type() == Variant::PACKED_FLOAT32_ARRAY) { +#endif // Ready-to-use heights can be passed l_heights = l_heights_v; @@ -503,7 +507,7 @@ void HeightMapShapeBullet::set_data(const Variant &p_data) { real_t *w = l_heights.ptrw(); const uint8_t *r = im_data.ptr(); - float *rp = (float *)r; + real_t *rp = (real_t *)r; // At this point, `rp` could be used directly for Bullet, but I don't know how safe it would be. for (int i = 0; i < l_heights.size(); ++i) { @@ -511,7 +515,11 @@ void HeightMapShapeBullet::set_data(const Variant &p_data) { } } else { +#ifdef REAL_T_IS_DOUBLE + ERR_FAIL_MSG("Expected PackedFloat64Array or float Image."); +#else ERR_FAIL_MSG("Expected PackedFloat32Array or float Image."); +#endif } ERR_FAIL_COND(l_width <= 0); diff --git a/modules/bullet/shape_bullet.h b/modules/bullet/shape_bullet.h index 1c29dc1b1f..bfd95747eb 100644 --- a/modules/bullet/shape_bullet.h +++ b/modules/bullet/shape_bullet.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -213,10 +213,10 @@ private: class HeightMapShapeBullet : public ShapeBullet { public: Vector<real_t> heights; - int width; - int depth; - real_t min_height; - real_t max_height; + int width = 0; + int depth = 0; + real_t min_height = 0.0; + real_t max_height = 0.0; HeightMapShapeBullet(); @@ -231,7 +231,7 @@ private: class RayShapeBullet : public ShapeBullet { public: - real_t length = 1; + real_t length = 1.0; bool slips_on_slope = false; RayShapeBullet(); diff --git a/modules/bullet/shape_owner_bullet.cpp b/modules/bullet/shape_owner_bullet.cpp index d63096d9a3..ea8821eaec 100644 --- a/modules/bullet/shape_owner_bullet.cpp +++ b/modules/bullet/shape_owner_bullet.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/bullet/shape_owner_bullet.h b/modules/bullet/shape_owner_bullet.h index f909632c99..4bd583e096 100644 --- a/modules/bullet/shape_owner_bullet.h +++ b/modules/bullet/shape_owner_bullet.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/bullet/slider_joint_bullet.cpp b/modules/bullet/slider_joint_bullet.cpp index 6d5d95d07a..45c892851b 100644 --- a/modules/bullet/slider_joint_bullet.cpp +++ b/modules/bullet/slider_joint_bullet.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/bullet/slider_joint_bullet.h b/modules/bullet/slider_joint_bullet.h index 6410b952ed..90964671c2 100644 --- a/modules/bullet/slider_joint_bullet.h +++ b/modules/bullet/slider_joint_bullet.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/bullet/soft_body_bullet.cpp b/modules/bullet/soft_body_bullet.cpp index 6794d6c313..91a1934e07 100644 --- a/modules/bullet/soft_body_bullet.cpp +++ b/modules/bullet/soft_body_bullet.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -259,10 +259,10 @@ void SoftBodyBullet::set_linear_stiffness(real_t p_val) { } } -void SoftBodyBullet::set_areaAngular_stiffness(real_t p_val) { - areaAngular_stiffness = p_val; +void SoftBodyBullet::set_angular_stiffness(real_t p_val) { + angular_stiffness = p_val; if (bt_soft_body) { - mat0->m_kAST = areaAngular_stiffness; + mat0->m_kAST = angular_stiffness; } } @@ -409,7 +409,7 @@ void SoftBodyBullet::setup_soft_body() { bt_soft_body->generateBendingConstraints(2, mat0); mat0->m_kLST = linear_stiffness; - mat0->m_kAST = areaAngular_stiffness; + mat0->m_kAST = angular_stiffness; mat0->m_kVST = volume_stiffness; // Clusters allow to have Soft vs Soft collision but doesn't work well right now diff --git a/modules/bullet/soft_body_bullet.h b/modules/bullet/soft_body_bullet.h index da8a2412ed..23f6fba9a6 100644 --- a/modules/bullet/soft_body_bullet.h +++ b/modules/bullet/soft_body_bullet.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -59,7 +59,7 @@ class SoftBodyBullet : public CollisionObjectBullet { private: btSoftBody *bt_soft_body = nullptr; Vector<Vector<int>> indices_table; - btSoftBody::Material *mat0; // This is just a copy of pointer managed by btSoftBody + btSoftBody::Material *mat0 = nullptr; // This is just a copy of pointer managed by btSoftBody bool isScratched = false; Ref<Mesh> soft_mesh; @@ -67,7 +67,7 @@ private: int simulation_precision = 5; real_t total_mass = 1.; real_t linear_stiffness = 0.5; // [0,1] - real_t areaAngular_stiffness = 0.5; // [0,1] + real_t angular_stiffness = 0.5; // [0,1] real_t volume_stiffness = 0.5; // [0,1] real_t pressure_coefficient = 0.; // [-inf,+inf] real_t pose_matching_coefficient = 0.; // [0,1] @@ -129,8 +129,8 @@ public: void set_linear_stiffness(real_t p_val); _FORCE_INLINE_ real_t get_linear_stiffness() const { return linear_stiffness; } - void set_areaAngular_stiffness(real_t p_val); - _FORCE_INLINE_ real_t get_areaAngular_stiffness() const { return areaAngular_stiffness; } + void set_angular_stiffness(real_t p_val); + _FORCE_INLINE_ real_t get_angular_stiffness() const { return angular_stiffness; } void set_volume_stiffness(real_t p_val); _FORCE_INLINE_ real_t get_volume_stiffness() const { return volume_stiffness; } diff --git a/modules/bullet/space_bullet.cpp b/modules/bullet/space_bullet.cpp index 3bfcd83606..7d337bc4d0 100644 --- a/modules/bullet/space_bullet.cpp +++ b/modules/bullet/space_bullet.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -117,7 +117,7 @@ bool BulletPhysicsDirectSpaceState::intersect_ray(const Vector3 &p_from, const V } } -int BulletPhysicsDirectSpaceState::intersect_shape(const RID &p_shape, const Transform &p_xform, float p_margin, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) { +int BulletPhysicsDirectSpaceState::intersect_shape(const RID &p_shape, const Transform &p_xform, real_t p_margin, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) { if (p_result_max <= 0) { return 0; } @@ -152,7 +152,7 @@ int BulletPhysicsDirectSpaceState::intersect_shape(const RID &p_shape, const Tra return btQuery.m_count; } -bool BulletPhysicsDirectSpaceState::cast_motion(const RID &p_shape, const Transform &p_xform, const Vector3 &p_motion, float p_margin, float &r_closest_safe, float &r_closest_unsafe, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas, ShapeRestInfo *r_info) { +bool BulletPhysicsDirectSpaceState::cast_motion(const RID &p_shape, const Transform &p_xform, const Vector3 &p_motion, real_t p_margin, real_t &r_closest_safe, real_t &r_closest_unsafe, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas, ShapeRestInfo *r_info) { r_closest_safe = 0.0f; r_closest_unsafe = 0.0f; btVector3 bt_motion; @@ -177,8 +177,10 @@ bool BulletPhysicsDirectSpaceState::cast_motion(const RID &p_shape, const Transf bt_xform_to.getOrigin() += bt_motion; if ((bt_xform_to.getOrigin() - bt_xform_from.getOrigin()).fuzzyZero()) { + r_closest_safe = 1.0f; + r_closest_unsafe = 1.0f; bulletdelete(btShape); - return false; + return true; } GodotClosestConvexResultCallback btResult(bt_xform_from.getOrigin(), bt_xform_to.getOrigin(), &p_exclude, p_collide_with_bodies, p_collide_with_areas); @@ -212,7 +214,7 @@ bool BulletPhysicsDirectSpaceState::cast_motion(const RID &p_shape, const Transf } /// Returns the list of contacts pairs in this order: Local contact, other body contact -bool BulletPhysicsDirectSpaceState::collide_shape(RID p_shape, const Transform &p_shape_xform, float p_margin, Vector3 *r_results, int p_result_max, int &r_result_count, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) { +bool BulletPhysicsDirectSpaceState::collide_shape(RID p_shape, const Transform &p_shape_xform, real_t p_margin, Vector3 *r_results, int p_result_max, int &r_result_count, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) { if (p_result_max <= 0) { return false; } @@ -248,7 +250,7 @@ bool BulletPhysicsDirectSpaceState::collide_shape(RID p_shape, const Transform & return btQuery.m_count; } -bool BulletPhysicsDirectSpaceState::rest_info(RID p_shape, const Transform &p_shape_xform, float p_margin, ShapeRestInfo *r_info, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) { +bool BulletPhysicsDirectSpaceState::rest_info(RID p_shape, const Transform &p_shape_xform, real_t p_margin, ShapeRestInfo *r_info, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) { ShapeBullet *shape = space->get_physics_server()->get_shape_owner()->getornull(p_shape); ERR_FAIL_COND_V(!shape, false); @@ -477,16 +479,20 @@ void SpaceBullet::add_rigid_body(RigidBodyBullet *p_body) { } } -void SpaceBullet::remove_rigid_body(RigidBodyBullet *p_body) { +void SpaceBullet::remove_rigid_body_constraints(RigidBodyBullet *p_body) { btRigidBody *btBody = p_body->get_bt_rigid_body(); int constraints = btBody->getNumConstraintRefs(); if (constraints > 0) { - WARN_PRINT("A body connected to joints was removed. Ensure bodies are disconnected from joints before removing them."); + ERR_PRINT("A body connected to joints was removed."); for (int i = 0; i < constraints; i++) { dynamicsWorld->removeConstraint(btBody->getConstraintRef(i)); } } +} + +void SpaceBullet::remove_rigid_body(RigidBodyBullet *p_body) { + btRigidBody *btBody = p_body->get_bt_rigid_body(); if (p_body->is_static()) { dynamicsWorld->removeCollisionObject(btBody); @@ -835,20 +841,32 @@ void SpaceBullet::check_body_collision() { Vector3 collisionWorldPosition; Vector3 collisionLocalPosition; Vector3 normalOnB; - float appliedImpulse = pt.m_appliedImpulse; + real_t appliedImpulse = pt.m_appliedImpulse; B_TO_G(pt.m_normalWorldOnB, normalOnB); + // The pt.m_index only contains the shape index when more than one collision shape is used + // and only if the collision shape is not a concave collision shape. + // A value of -1 in pt.m_partId indicates the pt.m_index is a shape index. + int shape_index_a = 0; + if (bodyA->get_shape_count() > 1 && pt.m_partId0 == -1) { + shape_index_a = pt.m_index0; + } + int shape_index_b = 0; + if (bodyB->get_shape_count() > 1 && pt.m_partId1 == -1) { + shape_index_b = pt.m_index1; + } + if (bodyA->can_add_collision()) { B_TO_G(pt.getPositionWorldOnB(), collisionWorldPosition); /// pt.m_localPointB Doesn't report the exact point in local space B_TO_G(pt.getPositionWorldOnB() - contactManifold->getBody1()->getWorldTransform().getOrigin(), collisionLocalPosition); - bodyA->add_collision_object(bodyB, collisionWorldPosition, collisionLocalPosition, normalOnB, appliedImpulse, pt.m_index1, pt.m_index0); + bodyA->add_collision_object(bodyB, collisionWorldPosition, collisionLocalPosition, normalOnB, appliedImpulse, shape_index_b, shape_index_a); } if (bodyB->can_add_collision()) { B_TO_G(pt.getPositionWorldOnA(), collisionWorldPosition); /// pt.m_localPointA Doesn't report the exact point in local space B_TO_G(pt.getPositionWorldOnA() - contactManifold->getBody0()->getWorldTransform().getOrigin(), collisionLocalPosition); - bodyB->add_collision_object(bodyA, collisionWorldPosition, collisionLocalPosition, normalOnB * -1, appliedImpulse * -1, pt.m_index0, pt.m_index1); + bodyB->add_collision_object(bodyA, collisionWorldPosition, collisionLocalPosition, normalOnB * -1, appliedImpulse * -1, shape_index_a, shape_index_b); } #ifdef DEBUG_ENABLED @@ -1044,7 +1062,7 @@ bool SpaceBullet::test_body_motion(RigidBodyBullet *p_body, const Transform &p_f return has_penetration; } -int SpaceBullet::test_ray_separation(RigidBodyBullet *p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, PhysicsServer3D::SeparationResult *r_results, int p_result_max, float p_margin) { +int SpaceBullet::test_ray_separation(RigidBodyBullet *p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, PhysicsServer3D::SeparationResult *r_results, int p_result_max, real_t p_margin) { btTransform body_transform; G_TO_B(p_transform, body_transform); UNSCALE_BT_BASIS(body_transform); @@ -1074,13 +1092,13 @@ private: btDbvtVolume bounds; const btCollisionObject *self_collision_object; - uint32_t collision_layer; - uint32_t collision_mask; + uint32_t collision_layer = 0; + uint32_t collision_mask = 0; struct CompoundLeafCallback : btDbvt::ICollide { private: - RecoverPenetrationBroadPhaseCallback *parent_callback; - btCollisionObject *collision_object; + RecoverPenetrationBroadPhaseCallback *parent_callback = nullptr; + btCollisionObject *collision_object = nullptr; public: CompoundLeafCallback(RecoverPenetrationBroadPhaseCallback *p_parent_callback, btCollisionObject *p_collision_object) : @@ -1098,8 +1116,8 @@ private: public: struct BroadphaseResult { - btCollisionObject *collision_object; - int compound_child_index; + btCollisionObject *collision_object = nullptr; + int compound_child_index = 0; }; Vector<BroadphaseResult> results; diff --git a/modules/bullet/space_bullet.h b/modules/bullet/space_bullet.h index e362f27d39..87aa2b9e93 100644 --- a/modules/bullet/space_bullet.h +++ b/modules/bullet/space_bullet.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -78,11 +78,11 @@ public: virtual int intersect_point(const Vector3 &p_point, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false) override; virtual bool intersect_ray(const Vector3 &p_from, const Vector3 &p_to, RayResult &r_result, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false, bool p_pick_ray = false) override; - virtual int intersect_shape(const RID &p_shape, const Transform &p_xform, float p_margin, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false) override; - virtual bool cast_motion(const RID &p_shape, const Transform &p_xform, const Vector3 &p_motion, float p_margin, float &r_closest_safe, float &r_closest_unsafe, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false, ShapeRestInfo *r_info = nullptr) override; + virtual int intersect_shape(const RID &p_shape, const Transform &p_xform, real_t p_margin, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false) override; + virtual bool cast_motion(const RID &p_shape, const Transform &p_xform, const Vector3 &p_motion, real_t p_margin, real_t &r_closest_safe, real_t &r_closest_unsafe, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false, ShapeRestInfo *r_info = nullptr) override; /// Returns the list of contacts pairs in this order: Local contact, other body contact - virtual bool collide_shape(RID p_shape, const Transform &p_shape_xform, float p_margin, Vector3 *r_results, int p_result_max, int &r_result_count, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false) override; - virtual bool rest_info(RID p_shape, const Transform &p_shape_xform, float p_margin, ShapeRestInfo *r_info, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false) override; + virtual bool collide_shape(RID p_shape, const Transform &p_shape_xform, real_t p_margin, Vector3 *r_results, int p_result_max, int &r_result_count, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false) override; + virtual bool rest_info(RID p_shape, const Transform &p_shape_xform, real_t p_margin, ShapeRestInfo *r_info, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false) override; virtual Vector3 get_closest_point_to_object_volume(RID p_object, const Vector3 p_point) const override; }; @@ -100,12 +100,12 @@ class SpaceBullet : public RIDBullet { btGhostPairCallback *ghostPairCallback = nullptr; GodotFilterCallback *godotFilterCallback = nullptr; - btGjkEpaPenetrationDepthSolver *gjk_epa_pen_solver; - btVoronoiSimplexSolver *gjk_simplex_solver; + btGjkEpaPenetrationDepthSolver *gjk_epa_pen_solver = nullptr; + btVoronoiSimplexSolver *gjk_simplex_solver = nullptr; BulletPhysicsDirectSpaceState *direct_access; Vector3 gravityDirection = Vector3(0, -1, 0); - real_t gravityMagnitude = 10; + real_t gravityMagnitude = 10.0; real_t linear_damp = 0.0; real_t angular_damp = 0.0; @@ -151,6 +151,7 @@ public: void reload_collision_filters(AreaBullet *p_area); void add_rigid_body(RigidBodyBullet *p_body); + void remove_rigid_body_constraints(RigidBodyBullet *p_body); void remove_rigid_body(RigidBodyBullet *p_body); void reload_collision_filters(RigidBodyBullet *p_body); @@ -167,7 +168,7 @@ public: BulletPhysicsDirectSpaceState *get_direct_state(); void set_debug_contacts(int p_amount) { contactDebug.resize(p_amount); } - _FORCE_INLINE_ bool is_debugging_contacts() const { return !contactDebug.empty(); } + _FORCE_INLINE_ bool is_debugging_contacts() const { return !contactDebug.is_empty(); } _FORCE_INLINE_ void reset_debug_contact_count() { contactDebugCount = 0; } @@ -188,7 +189,7 @@ public: real_t get_angular_damp() const { return angular_damp; } bool test_body_motion(RigidBodyBullet *p_body, const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia, PhysicsServer3D::MotionResult *r_result, bool p_exclude_raycast_shapes); - int test_ray_separation(RigidBodyBullet *p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, PhysicsServer3D::SeparationResult *r_results, int p_result_max, float p_margin); + int test_ray_separation(RigidBodyBullet *p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, PhysicsServer3D::SeparationResult *r_results, int p_result_max, real_t p_margin); private: void create_empty_world(bool p_create_soft_world); diff --git a/modules/camera/camera_osx.h b/modules/camera/camera_osx.h index a07b83c6af..964b7c1edc 100644 --- a/modules/camera/camera_osx.h +++ b/modules/camera/camera_osx.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/camera/camera_osx.mm b/modules/camera/camera_osx.mm index 306632a016..3d2053ad23 100644 --- a/modules/camera/camera_osx.mm +++ b/modules/camera/camera_osx.mm @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/camera/camera_win.cpp b/modules/camera/camera_win.cpp index 1646644be3..226a642dcf 100644 --- a/modules/camera/camera_win.cpp +++ b/modules/camera/camera_win.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/camera/camera_win.h b/modules/camera/camera_win.h index bbc8880c12..671e7d5beb 100644 --- a/modules/camera/camera_win.h +++ b/modules/camera/camera_win.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/camera/register_types.cpp b/modules/camera/register_types.cpp index 9479310a13..0d33ff9ddc 100644 --- a/modules/camera/register_types.cpp +++ b/modules/camera/register_types.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/camera/register_types.h b/modules/camera/register_types.h index e34f84bf2c..0ae9aa2c0b 100644 --- a/modules/camera/register_types.h +++ b/modules/camera/register_types.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/camera_iphone/SCsub b/modules/camera_iphone/SCsub deleted file mode 100644 index 0a37d9a6f5..0000000000 --- a/modules/camera_iphone/SCsub +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env python - -Import("env") -Import("env_modules") - -env_camera = env_modules.Clone() - -# (iOS) Enable module support -env_camera.Append(CCFLAGS=["-fmodules", "-fcxx-modules"]) - -# (iOS) Build as separate static library -modules_sources = [] -env_camera.add_source_files(modules_sources, "*.cpp") -env_camera.add_source_files(modules_sources, "*.mm") -mod_lib = env_modules.add_library("#bin/libgodot_camera_module" + env["LIBSUFFIX"], modules_sources) diff --git a/modules/camera_iphone/camera.gdip b/modules/camera_iphone/camera.gdip deleted file mode 100644 index 09017b8d27..0000000000 --- a/modules/camera_iphone/camera.gdip +++ /dev/null @@ -1,18 +0,0 @@ -[config] -name="Camera" -binary="camera_lib.a" - -initialization="register_camera_types" -deinitialization="unregister_camera_types" - -[dependencies] -linked=[] -embedded=[] -system=["AVFoundation.framework"] - -capabilities=[] - -files=[] - -[plist] -NSCameraUsageDescription="Device camera is used for some functionality" diff --git a/modules/camera_iphone/camera_ios.h b/modules/camera_iphone/camera_ios.h deleted file mode 100644 index 7da43e4851..0000000000 --- a/modules/camera_iphone/camera_ios.h +++ /dev/null @@ -1,45 +0,0 @@ -/*************************************************************************/ -/* camera_ios.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef CAMERAIOS_H -#define CAMERAIOS_H - -#include "servers/camera_server.h" - -class CameraIOS : public CameraServer { -private: -public: - CameraIOS(); - ~CameraIOS(); - - void update_feeds(); -}; - -#endif /* CAMERAIOS_H */ diff --git a/modules/camera_iphone/camera_ios.mm b/modules/camera_iphone/camera_ios.mm deleted file mode 100644 index e4cb928805..0000000000 --- a/modules/camera_iphone/camera_ios.mm +++ /dev/null @@ -1,445 +0,0 @@ -/*************************************************************************/ -/* camera_ios.mm */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -///@TODO this is a near duplicate of CameraOSX, we should find a way to combine those to minimize code duplication!!!! -// If you fix something here, make sure you fix it there as wel! - -#include "camera_ios.h" -#include "servers/camera/camera_feed.h" - -#import <AVFoundation/AVFoundation.h> -#import <UIKit/UIKit.h> - -////////////////////////////////////////////////////////////////////////// -// MyCaptureSession - This is a little helper class so we can capture our frames - -@interface MyCaptureSession : AVCaptureSession <AVCaptureVideoDataOutputSampleBufferDelegate> { - Ref<CameraFeed> feed; - size_t width[2]; - size_t height[2]; - Vector<uint8_t> img_data[2]; - - AVCaptureDeviceInput *input; - AVCaptureVideoDataOutput *output; -} - -@end - -@implementation MyCaptureSession - -- (id)initForFeed:(Ref<CameraFeed>)p_feed andDevice:(AVCaptureDevice *)p_device { - if (self = [super init]) { - NSError *error; - feed = p_feed; - width[0] = 0; - height[0] = 0; - width[1] = 0; - height[1] = 0; - - // prepare our device - [p_device lockForConfiguration:&error]; - - [p_device setFocusMode:AVCaptureFocusModeLocked]; - [p_device setExposureMode:AVCaptureExposureModeLocked]; - [p_device setWhiteBalanceMode:AVCaptureWhiteBalanceModeLocked]; - - [p_device unlockForConfiguration]; - - [self beginConfiguration]; - - // setup our capture - self.sessionPreset = AVCaptureSessionPreset1280x720; - - input = [AVCaptureDeviceInput deviceInputWithDevice:p_device error:&error]; - if (!input) { - print_line("Couldn't get input device for camera"); - } else { - [self addInput:input]; - } - - output = [AVCaptureVideoDataOutput new]; - if (!output) { - print_line("Couldn't get output device for camera"); - } else { - NSDictionary *settings = @{ (NSString *)kCVPixelBufferPixelFormatTypeKey : @(kCVPixelFormatType_420YpCbCr8BiPlanarFullRange) }; - output.videoSettings = settings; - - // discard if the data output queue is blocked (as we process the still image) - [output setAlwaysDiscardsLateVideoFrames:YES]; - - // now set ourselves as the delegate to receive new frames. Note that we're doing this on the main thread at the moment, we may need to change this.. - [output setSampleBufferDelegate:self queue:dispatch_get_main_queue()]; - - [self addOutput:output]; - } - - [self commitConfiguration]; - - // kick off our session.. - [self startRunning]; - }; - return self; -} - -- (void)cleanup { - // stop running - [self stopRunning]; - - // cleanup - [self beginConfiguration]; - - if (input) { - [self removeInput:input]; - // don't release this - input = nil; - } - - if (output) { - [self removeOutput:output]; - [output setSampleBufferDelegate:nil queue:NULL]; - output = nil; - } - - [self commitConfiguration]; -} - -- (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection { - // This gets called every time our camera has a new image for us to process. - // May need to investigate in a way to throttle this if we get more images then we're rendering frames.. - - // For now, version 1, we're just doing the bare minimum to make this work... - - CVImageBufferRef pixelBuffer = CMSampleBufferGetImageBuffer(sampleBuffer); - // int width = CVPixelBufferGetWidth(pixelBuffer); - // int height = CVPixelBufferGetHeight(pixelBuffer); - - // It says that we need to lock this on the documentation pages but it's not in the samples - // need to lock our base address so we can access our pixel buffers, better safe then sorry? - 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 { - UIInterfaceOrientation orientation = UIInterfaceOrientationUnknown; - - if (@available(iOS 13, *)) { - orientation = [UIApplication sharedApplication].delegate.window.windowScene.interfaceOrientation; -#if !defined(TARGET_OS_SIMULATOR) || !TARGET_OS_SIMULATOR - } else { - orientation = [[UIApplication sharedApplication] statusBarOrientation]; -#endif - } - - Ref<Image> img[2]; - - { - // do Y - size_t new_width = CVPixelBufferGetWidthOfPlane(pixelBuffer, 0); - size_t new_height = CVPixelBufferGetHeightOfPlane(pixelBuffer, 0); - - if ((width[0] != new_width) || (height[0] != new_height)) { - width[0] = new_width; - height[0] = new_height; - img_data[0].resize(new_width * new_height); - } - - uint8_t *w = img_data[0].ptrw(); - memcpy(w, dataY, new_width * new_height); - - img[0].instance(); - img[0]->create(new_width, new_height, 0, Image::FORMAT_R8, img_data[0]); - } - - { - // do CbCr - size_t new_width = CVPixelBufferGetWidthOfPlane(pixelBuffer, 1); - size_t new_height = CVPixelBufferGetHeightOfPlane(pixelBuffer, 1); - - if ((width[1] != new_width) || (height[1] != new_height)) { - width[1] = new_width; - height[1] = new_height; - img_data[1].resize(2 * new_width * new_height); - } - - uint8_t *w = img_data[1].ptrw(); - memcpy(w, dataCbCr, 2 * new_width * new_height); - - ///TODO GLES2 doesn't support FORMAT_RG8, need to do some form of conversion - img[1].instance(); - 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]); - - // update our matrix to match the orientation, note, before changing anything - // here, be aware that the project orientation settings must match your xcode - // settings or this will go wrong! - Transform2D display_transform; - switch (orientation) { - case UIInterfaceOrientationPortrait: { - display_transform = Transform2D(0.0, -1.0, -1.0, 0.0, 1.0, 1.0); - } break; - case UIInterfaceOrientationLandscapeRight: { - display_transform = Transform2D(1.0, 0.0, 0.0, -1.0, 0.0, 1.0); - } break; - case UIInterfaceOrientationLandscapeLeft: { - display_transform = Transform2D(-1.0, 0.0, 0.0, 1.0, 1.0, 0.0); - } break; - default: { - display_transform = Transform2D(0.0, 1.0, 1.0, 0.0, 0.0, 0.0); - } break; - } - - //TODO: this is correct for the camera on the back, I have a feeling this needs to be inversed for the camera on the front! - feed->set_transform(display_transform); - } - - // and unlock - CVPixelBufferUnlockBaseAddress(pixelBuffer, kCVPixelBufferLock_ReadOnly); -} - -@end - -////////////////////////////////////////////////////////////////////////// -// CameraFeedIOS - Subclass for camera feeds in iOS - -class CameraFeedIOS : public CameraFeed { -private: - AVCaptureDevice *device; - MyCaptureSession *capture_session; - -public: - bool get_is_arkit() const; - AVCaptureDevice *get_device() const; - - CameraFeedIOS(); - ~CameraFeedIOS(); - - void set_device(AVCaptureDevice *p_device); - - bool activate_feed(); - void deactivate_feed(); -}; - -AVCaptureDevice *CameraFeedIOS::get_device() const { - return device; -}; - -CameraFeedIOS::CameraFeedIOS() { - capture_session = NULL; - device = NULL; - transform = Transform2D(1.0, 0.0, 0.0, 1.0, 0.0, 0.0); /* should re-orientate this based on device orientation */ -}; - -void CameraFeedIOS::set_device(AVCaptureDevice *p_device) { - device = p_device; - - // get some info - NSString *device_name = p_device.localizedName; - name = device_name.UTF8String; - position = CameraFeed::FEED_UNSPECIFIED; - if ([p_device position] == AVCaptureDevicePositionBack) { - position = CameraFeed::FEED_BACK; - } else if ([p_device position] == AVCaptureDevicePositionFront) { - position = CameraFeed::FEED_FRONT; - }; -}; - -CameraFeedIOS::~CameraFeedIOS() { - if (capture_session) { - capture_session = nil; - }; - - if (device) { - device = nil; - }; -}; - -bool CameraFeedIOS::activate_feed() { - if (capture_session) { - // already recording! - } else { - // start camera capture - capture_session = [[MyCaptureSession alloc] initForFeed:this andDevice:device]; - }; - - return true; -}; - -void CameraFeedIOS::deactivate_feed() { - // end camera capture if we have one - if (capture_session) { - [capture_session cleanup]; - capture_session = nil; - }; -}; - -////////////////////////////////////////////////////////////////////////// -// MyDeviceNotifications - This is a little helper class gets notifications -// when devices are connected/disconnected - -@interface MyDeviceNotifications : NSObject { - CameraIOS *camera_server; -} - -@end - -@implementation MyDeviceNotifications - -- (void)devices_changed:(NSNotification *)notification { - camera_server->update_feeds(); -} - -- (id)initForServer:(CameraIOS *)p_server { - if (self = [super init]) { - camera_server = p_server; - - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(devices_changed:) name:AVCaptureDeviceWasConnectedNotification object:nil]; - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(devices_changed:) name:AVCaptureDeviceWasDisconnectedNotification object:nil]; - }; - return self; -} - -- (void)dealloc { - // remove notifications - [[NSNotificationCenter defaultCenter] removeObserver:self name:AVCaptureDeviceWasConnectedNotification object:nil]; - [[NSNotificationCenter defaultCenter] removeObserver:self name:AVCaptureDeviceWasDisconnectedNotification object:nil]; -} - -@end - -MyDeviceNotifications *device_notifications = nil; - -////////////////////////////////////////////////////////////////////////// -// CameraIOS - Subclass for our camera server on iPhone - -void CameraIOS::update_feeds() { - // this way of doing things is deprecated but still works, - // rewrite to using AVCaptureDeviceDiscoverySession - - NSMutableArray *deviceTypes = [NSMutableArray array]; - - if (@available(iOS 10, *)) { - [deviceTypes addObject:AVCaptureDeviceTypeBuiltInWideAngleCamera]; - [deviceTypes addObject:AVCaptureDeviceTypeBuiltInTelephotoCamera]; - - if (@available(iOS 10.2, *)) { - [deviceTypes addObject:AVCaptureDeviceTypeBuiltInDualCamera]; - } - - if (@available(iOS 11.1, *)) { - [deviceTypes addObject:AVCaptureDeviceTypeBuiltInTrueDepthCamera]; - } - - AVCaptureDeviceDiscoverySession *session = [AVCaptureDeviceDiscoverySession - discoverySessionWithDeviceTypes:deviceTypes - mediaType:AVMediaTypeVideo - position:AVCaptureDevicePositionUnspecified]; - - // remove devices that are gone.. - for (int i = feeds.size() - 1; i >= 0; i--) { - Ref<CameraFeedIOS> feed(feeds[i]); - - if (feed.is_null()) { - // feed not managed by us - } else if (![session.devices containsObject:feed->get_device()]) { - // remove it from our array, this will also destroy it ;) - remove_feed(feed); - }; - }; - - // add new devices.. - for (AVCaptureDevice *device in session.devices) { - bool found = false; - - for (int i = 0; i < feeds.size() && !found; i++) { - Ref<CameraFeedIOS> feed(feeds[i]); - - if (feed.is_null()) { - // feed not managed by us - } else if (feed->get_device() == device) { - found = true; - }; - }; - - if (!found) { - Ref<CameraFeedIOS> newfeed; - newfeed.instance(); - newfeed->set_device(device); - add_feed(newfeed); - }; - }; - } -}; - -CameraIOS::CameraIOS() { - // check if we have our usage description - NSString *usage_desc = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSCameraUsageDescription"]; - if (usage_desc == NULL) { - // don't initialise if we don't get anything - print_line("No NSCameraUsageDescription key in pList, no access to cameras."); - return; - } else if (usage_desc.length == 0) { - // don't initialise if we don't get anything - print_line("Empty NSCameraUsageDescription key in pList, no access to cameras."); - return; - } - - // now we'll request access. - // If this is the first time the user will be prompted with the string (iOS will read it). - // Once a decision is made it is returned. If the user wants to change it later on they - // need to go into setting. - print_line("Requesting Camera permissions"); - - [AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo - completionHandler:^(BOOL granted) { - if (granted) { - print_line("Access to cameras granted!"); - - // Find available cameras we have at this time - update_feeds(); - - // should only have one of these.... - device_notifications = [[MyDeviceNotifications alloc] initForServer:this]; - } else { - print_line("No access to cameras!"); - } - }]; -}; - -CameraIOS::~CameraIOS() { - device_notifications = nil; -}; diff --git a/modules/camera_iphone/camera_module.cpp b/modules/camera_iphone/camera_module.cpp deleted file mode 100644 index f3d00be204..0000000000 --- a/modules/camera_iphone/camera_module.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/*************************************************************************/ -/* camera_module.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include "camera_module.h" - -#include "camera_ios.h" - -void register_camera_types() { - CameraServer::make_default<CameraIOS>(); -} - -void unregister_camera_types() { -} diff --git a/modules/camera_iphone/camera_module.h b/modules/camera_iphone/camera_module.h deleted file mode 100644 index d123071a70..0000000000 --- a/modules/camera_iphone/camera_module.h +++ /dev/null @@ -1,32 +0,0 @@ -/*************************************************************************/ -/* camera_module.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -void register_camera_types(); -void unregister_camera_types(); diff --git a/modules/camera_iphone/config.py b/modules/camera_iphone/config.py deleted file mode 100644 index e68603fc93..0000000000 --- a/modules/camera_iphone/config.py +++ /dev/null @@ -1,6 +0,0 @@ -def can_build(env, platform): - return platform == "iphone" - - -def configure(env): - pass diff --git a/modules/csg/csg.cpp b/modules/csg/csg.cpp index 04e1c4de35..f0a2f17ba9 100644 --- a/modules/csg/csg.cpp +++ b/modules/csg/csg.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/csg/csg.h b/modules/csg/csg.h index ef1103e1ac..3fbed66e5c 100644 --- a/modules/csg/csg.h +++ b/modules/csg/csg.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -48,9 +48,9 @@ struct CSGBrush { Vector3 vertices[3]; Vector2 uvs[3]; AABB aabb; - bool smooth; - bool invert; - int material; + bool smooth = false; + bool invert = false; + int material = 0; }; Vector<Face> faces; @@ -74,20 +74,20 @@ struct CSGBrushOperation { struct MeshMerge { struct Face { - bool from_b; - bool inside; - int points[3]; + bool from_b = false; + bool inside = false; + int points[3] = {}; Vector2 uvs[3]; - bool smooth; - bool invert; - int material_idx; + bool smooth = false; + bool invert = false; + int material_idx = 0; }; struct FaceBVH { - int face; - int left; - int right; - int next; + int face = 0; + int left = 0; + int right = 0; + int next = 0; Vector3 center; AABB aabb; }; @@ -142,7 +142,7 @@ struct CSGBrushOperation { Map<Ref<Material>, int> materials; Map<Vector3, int> vertex_map; OAHashMap<VertexKey, int, VertexKeyHash> snap_cache; - float vertex_snap; + float vertex_snap = 0.0; inline void _add_distance(List<real_t> &r_intersectionsA, List<real_t> &r_intersectionsB, bool p_from_B, real_t p_distance) const; inline bool _bvh_inside(FaceBVH *facebvhptr, int p_max_depth, int p_bvh_first, int p_face_idx) const; @@ -159,7 +159,7 @@ struct CSGBrushOperation { }; struct Face2D { - int vertex_idx[3]; + int vertex_idx[3] = {}; }; Vector<Vertex2D> vertices; @@ -167,7 +167,7 @@ struct CSGBrushOperation { Plane plane; Transform to_2D; Transform to_3D; - float vertex_snap2; + float vertex_snap2 = 0.0; inline int _get_point_idx(const Vector2 &p_point); inline int _add_vertex(const Vertex2D &p_vertex); diff --git a/modules/csg/csg_gizmos.cpp b/modules/csg/csg_gizmos.cpp index f8c05761bb..e23442ef99 100644 --- a/modules/csg/csg_gizmos.cpp +++ b/modules/csg/csg_gizmos.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -56,8 +56,7 @@ String CSGShape3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, } if (Object::cast_to<CSGBox3D>(cs)) { - static const char *hname[3] = { "Width", "Height", "Depth" }; - return hname[p_idx]; + return "Size"; } if (Object::cast_to<CSGCylinder3D>(cs)) { @@ -81,14 +80,7 @@ Variant CSGShape3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int if (Object::cast_to<CSGBox3D>(cs)) { CSGBox3D *s = Object::cast_to<CSGBox3D>(cs); - switch (p_idx) { - case 0: - return s->get_width(); - case 1: - return s->get_height(); - case 2: - return s->get_depth(); - } + return s->get_size(); } if (Object::cast_to<CSGCylinder3D>(cs)) { @@ -123,7 +115,7 @@ void CSGShape3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Ca Geometry3D::get_closest_points_between_segments(Vector3(), Vector3(4096, 0, 0), sg[0], sg[1], ra, rb); float d = ra.x; if (Node3DEditor::get_singleton()->is_snap_enabled()) { - d = Math::stepify(d, Node3DEditor::get_singleton()->get_translate_snap()); + d = Math::snapped(d, Node3DEditor::get_singleton()->get_translate_snap()); } if (d < 0.001) { @@ -142,24 +134,16 @@ void CSGShape3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Ca Geometry3D::get_closest_points_between_segments(Vector3(), axis * 4096, sg[0], sg[1], ra, rb); float d = ra[p_idx]; if (Node3DEditor::get_singleton()->is_snap_enabled()) { - d = Math::stepify(d, Node3DEditor::get_singleton()->get_translate_snap()); + d = Math::snapped(d, Node3DEditor::get_singleton()->get_translate_snap()); } if (d < 0.001) { d = 0.001; } - switch (p_idx) { - case 0: - s->set_width(d * 2); - break; - case 1: - s->set_height(d * 2); - break; - case 2: - s->set_depth(d * 2); - break; - } + Vector3 h = s->get_size(); + h[p_idx] = d * 2; + s->set_size(h); } if (Object::cast_to<CSGCylinder3D>(cs)) { @@ -171,7 +155,7 @@ void CSGShape3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Ca Geometry3D::get_closest_points_between_segments(Vector3(), axis * 4096, sg[0], sg[1], ra, rb); float d = axis.dot(ra); if (Node3DEditor::get_singleton()->is_snap_enabled()) { - d = Math::stepify(d, Node3DEditor::get_singleton()->get_translate_snap()); + d = Math::snapped(d, Node3DEditor::get_singleton()->get_translate_snap()); } if (d < 0.001) { @@ -194,7 +178,7 @@ void CSGShape3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Ca Geometry3D::get_closest_points_between_segments(Vector3(), axis * 4096, sg[0], sg[1], ra, rb); float d = axis.dot(ra); if (Node3DEditor::get_singleton()->is_snap_enabled()) { - d = Math::stepify(d, Node3DEditor::get_singleton()->get_translate_snap()); + d = Math::snapped(d, Node3DEditor::get_singleton()->get_translate_snap()); } if (d < 0.001) { @@ -229,38 +213,14 @@ void CSGShape3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, if (Object::cast_to<CSGBox3D>(cs)) { CSGBox3D *s = Object::cast_to<CSGBox3D>(cs); if (p_cancel) { - switch (p_idx) { - case 0: - s->set_width(p_restore); - break; - case 1: - s->set_height(p_restore); - break; - case 2: - s->set_depth(p_restore); - break; - } + s->set_size(p_restore); return; } UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo(); - ur->create_action(TTR("Change Box Shape Extents")); - static const char *method[3] = { "set_width", "set_height", "set_depth" }; - float current = 0; - switch (p_idx) { - case 0: - current = s->get_width(); - break; - case 1: - current = s->get_height(); - break; - case 2: - current = s->get_depth(); - break; - } - - ur->add_do_method(s, method[p_idx], current); - ur->add_undo_method(s, method[p_idx], p_restore); + ur->create_action(TTR("Change Box Shape Size")); + ur->add_do_method(s, "set_size", s->get_size()); + ur->add_undo_method(s, "set_size", p_restore); ur->commit_action(); } @@ -408,9 +368,13 @@ void CSGShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { CSGBox3D *s = Object::cast_to<CSGBox3D>(cs); Vector<Vector3> handles; - handles.push_back(Vector3(s->get_width() * 0.5, 0, 0)); - handles.push_back(Vector3(0, s->get_height() * 0.5, 0)); - handles.push_back(Vector3(0, 0, s->get_depth() * 0.5)); + + for (int i = 0; i < 3; i++) { + Vector3 h; + h[i] = s->get_size()[i] / 2; + handles.push_back(h); + } + p_gizmo->add_handles(handles, handles_material); } diff --git a/modules/csg/csg_gizmos.h b/modules/csg/csg_gizmos.h index cf44f76f37..8f7da35de3 100644 --- a/modules/csg/csg_gizmos.h +++ b/modules/csg/csg_gizmos.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/csg/csg_shape.cpp b/modules/csg/csg_shape.cpp index 376dfe5031..40ba457e43 100644 --- a/modules/csg/csg_shape.cpp +++ b/modules/csg/csg_shape.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -45,7 +45,8 @@ void CSGShape3D::set_use_collision(bool p_enable) { if (use_collision) { root_collision_shape.instance(); - root_collision_instance = PhysicsServer3D::get_singleton()->body_create(PhysicsServer3D::BODY_MODE_STATIC); + root_collision_instance = PhysicsServer3D::get_singleton()->body_create(); + PhysicsServer3D::get_singleton()->body_set_mode(root_collision_instance, PhysicsServer3D::BODY_MODE_STATIC); PhysicsServer3D::get_singleton()->body_set_state(root_collision_instance, PhysicsServer3D::BODY_STATE_TRANSFORM, get_global_transform()); PhysicsServer3D::get_singleton()->body_add_shape(root_collision_instance, root_collision_shape->get_rid()); PhysicsServer3D::get_singleton()->body_set_space(root_collision_instance, get_world_3d()->get_space()); @@ -58,7 +59,7 @@ void CSGShape3D::set_use_collision(bool p_enable) { root_collision_instance = RID(); root_collision_shape.unref(); } - _change_notify(); + notify_property_list_changed(); } bool CSGShape3D::is_using_collision() const { @@ -494,7 +495,8 @@ void CSGShape3D::_notification(int p_what) { if (use_collision && is_root_shape()) { root_collision_shape.instance(); - root_collision_instance = PhysicsServer3D::get_singleton()->body_create(PhysicsServer3D::BODY_MODE_STATIC); + root_collision_instance = PhysicsServer3D::get_singleton()->body_create(); + PhysicsServer3D::get_singleton()->body_set_mode(root_collision_instance, PhysicsServer3D::BODY_MODE_STATIC); PhysicsServer3D::get_singleton()->body_set_state(root_collision_instance, PhysicsServer3D::BODY_STATE_TRANSFORM, get_global_transform()); PhysicsServer3D::get_singleton()->body_add_shape(root_collision_instance, root_collision_shape->get_rid()); PhysicsServer3D::get_singleton()->body_set_space(root_collision_instance, get_world_3d()->get_space()); @@ -625,15 +627,6 @@ void CSGShape3D::_bind_methods() { } CSGShape3D::CSGShape3D() { - operation = OPERATION_UNION; - parent = nullptr; - brush = nullptr; - dirty = false; - snap = 0.001; - use_collision = false; - collision_layer = 1; - collision_mask = 1; - calculate_tangents = true; set_notify_local_transform(true); } @@ -927,25 +920,27 @@ CSGBrush *CSGSphere3D::_build_brush() { bool *invertw = invert.ptrw(); int face = 0; + const double lat_step = Math_TAU / rings; + const double lon_step = Math_TAU / radial_segments; for (int i = 1; i <= rings; i++) { - double lat0 = Math_PI * (-0.5 + (double)(i - 1) / rings); + double lat0 = lat_step * (i - 1) - Math_TAU / 4; double z0 = Math::sin(lat0); double zr0 = Math::cos(lat0); double u0 = double(i - 1) / rings; - double lat1 = Math_PI * (-0.5 + (double)i / rings); + double lat1 = lat_step * i - Math_TAU / 4; double z1 = Math::sin(lat1); double zr1 = Math::cos(lat1); double u1 = double(i) / rings; for (int j = radial_segments; j >= 1; j--) { - double lng0 = 2 * Math_PI * (double)(j - 1) / radial_segments; + double lng0 = lon_step * (j - 1); double x0 = Math::cos(lng0); double y0 = Math::sin(lng0); double v0 = double(i - 1) / radial_segments; - double lng1 = 2 * Math_PI * (double)(j) / radial_segments; + double lng1 = lon_step * j; double x1 = Math::cos(lng1); double y1 = Math::sin(lng1); double v1 = double(i) / radial_segments; @@ -1038,7 +1033,6 @@ void CSGSphere3D::set_radius(const float p_radius) { radius = p_radius; _make_dirty(); update_gizmo(); - _change_notify("radius"); } float CSGSphere3D::get_radius() const { @@ -1125,7 +1119,7 @@ CSGBrush *CSGBox3D::_build_brush() { int face = 0; - Vector3 vertex_mul(width * 0.5, height * 0.5, depth * 0.5); + Vector3 vertex_mul = size / 2; { for (int i = 0; i < 6; i++) { @@ -1194,55 +1188,24 @@ CSGBrush *CSGBox3D::_build_brush() { } void CSGBox3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_width", "width"), &CSGBox3D::set_width); - ClassDB::bind_method(D_METHOD("get_width"), &CSGBox3D::get_width); - - ClassDB::bind_method(D_METHOD("set_height", "height"), &CSGBox3D::set_height); - ClassDB::bind_method(D_METHOD("get_height"), &CSGBox3D::get_height); - - ClassDB::bind_method(D_METHOD("set_depth", "depth"), &CSGBox3D::set_depth); - ClassDB::bind_method(D_METHOD("get_depth"), &CSGBox3D::get_depth); + ClassDB::bind_method(D_METHOD("set_size", "size"), &CSGBox3D::set_size); + ClassDB::bind_method(D_METHOD("get_size"), &CSGBox3D::get_size); ClassDB::bind_method(D_METHOD("set_material", "material"), &CSGBox3D::set_material); ClassDB::bind_method(D_METHOD("get_material"), &CSGBox3D::get_material); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "width", PROPERTY_HINT_EXP_RANGE, "0.001,1000.0,0.001,or_greater"), "set_width", "get_width"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "height", PROPERTY_HINT_EXP_RANGE, "0.001,1000.0,0.001,or_greater"), "set_height", "get_height"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "depth", PROPERTY_HINT_EXP_RANGE, "0.001,1000.0,0.001,or_greater"), "set_depth", "get_depth"); + ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "size"), "set_size", "get_size"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "StandardMaterial3D,ShaderMaterial"), "set_material", "get_material"); } -void CSGBox3D::set_width(const float p_width) { - width = p_width; - _make_dirty(); - update_gizmo(); - _change_notify("width"); -} - -float CSGBox3D::get_width() const { - return width; -} - -void CSGBox3D::set_height(const float p_height) { - height = p_height; +void CSGBox3D::set_size(const Vector3 &p_size) { + size = p_size; _make_dirty(); update_gizmo(); - _change_notify("height"); } -float CSGBox3D::get_height() const { - return height; -} - -void CSGBox3D::set_depth(const float p_depth) { - depth = p_depth; - _make_dirty(); - update_gizmo(); - _change_notify("depth"); -} - -float CSGBox3D::get_depth() const { - return depth; +Vector3 CSGBox3D::get_size() const { + return size; } void CSGBox3D::set_material(const Ref<Material> &p_material) { @@ -1255,13 +1218,6 @@ Ref<Material> CSGBox3D::get_material() const { return material; } -CSGBox3D::CSGBox3D() { - // defaults - width = 2.0; - height = 2.0; - depth = 2.0; -} - /////////////// CSGBrush *CSGCylinder3D::_build_brush() { @@ -1303,8 +1259,8 @@ CSGBrush *CSGCylinder3D::_build_brush() { float inc = float(i) / sides; float inc_n = float((i + 1)) / sides; - float ang = inc * Math_PI * 2.0; - float ang_n = inc_n * Math_PI * 2.0; + float ang = inc * Math_TAU; + float ang_n = inc_n * Math_TAU; Vector3 base(Math::cos(ang), 0, Math::sin(ang)); Vector3 base_n(Math::cos(ang_n), 0, Math::sin(ang_n)); @@ -1427,7 +1383,6 @@ void CSGCylinder3D::set_radius(const float p_radius) { radius = p_radius; _make_dirty(); update_gizmo(); - _change_notify("radius"); } float CSGCylinder3D::get_radius() const { @@ -1438,7 +1393,6 @@ void CSGCylinder3D::set_height(const float p_height) { height = p_height; _make_dirty(); update_gizmo(); - _change_notify("height"); } float CSGCylinder3D::get_height() const { @@ -1545,8 +1499,8 @@ CSGBrush *CSGTorus3D::_build_brush() { float inci = float(i) / sides; float inci_n = float((i + 1)) / sides; - float angi = inci * Math_PI * 2.0; - float angi_n = inci_n * Math_PI * 2.0; + float angi = inci * Math_TAU; + float angi_n = inci_n * Math_TAU; Vector3 normali = Vector3(Math::cos(angi), 0, Math::sin(angi)); Vector3 normali_n = Vector3(Math::cos(angi_n), 0, Math::sin(angi_n)); @@ -1555,8 +1509,8 @@ CSGBrush *CSGTorus3D::_build_brush() { float incj = float(j) / ring_sides; float incj_n = float((j + 1)) / ring_sides; - float angj = incj * Math_PI * 2.0; - float angj_n = incj_n * Math_PI * 2.0; + float angj = incj * Math_TAU; + float angj_n = incj_n * Math_TAU; Vector2 normalj = Vector2(Math::cos(angj), Math::sin(angj)) * radius + Vector2(min_radius + radius, 0); Vector2 normalj_n = Vector2(Math::cos(angj_n), Math::sin(angj_n)) * radius + Vector2(min_radius + radius, 0); @@ -1648,7 +1602,6 @@ void CSGTorus3D::set_inner_radius(const float p_inner_radius) { inner_radius = p_inner_radius; _make_dirty(); update_gizmo(); - _change_notify("inner_radius"); } float CSGTorus3D::get_inner_radius() const { @@ -1659,7 +1612,6 @@ void CSGTorus3D::set_outer_radius(const float p_outer_radius) { outer_radius = p_outer_radius; _make_dirty(); update_gizmo(); - _change_notify("outer_radius"); } float CSGTorus3D::get_outer_radius() const { @@ -1928,8 +1880,8 @@ CSGBrush *CSGPolygon3D::_build_brush() { float inci = float(i) / spin_sides; float inci_n = float((i + 1)) / spin_sides; - float angi = -(inci * spin_degrees / 360.0) * Math_PI * 2.0; - float angi_n = -(inci_n * spin_degrees / 360.0) * Math_PI * 2.0; + float angi = -Math::deg2rad(inci * spin_degrees); + float angi_n = -Math::deg2rad(inci_n * spin_degrees); Vector3 normali = Vector3(Math::cos(angi), 0, Math::sin(angi)); Vector3 normali_n = Vector3(Math::cos(angi_n), 0, Math::sin(angi_n)); @@ -2306,7 +2258,7 @@ void CSGPolygon3D::set_mode(Mode p_mode) { mode = p_mode; _make_dirty(); update_gizmo(); - _change_notify(); + notify_property_list_changed(); } CSGPolygon3D::Mode CSGPolygon3D::get_mode() const { diff --git a/modules/csg/csg_shape.h b/modules/csg/csg_shape.h index d93693f145..de7de09f00 100644 --- a/modules/csg/csg_shape.h +++ b/modules/csg/csg_shape.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -50,23 +50,23 @@ public: }; private: - Operation operation; - CSGShape3D *parent; + Operation operation = OPERATION_UNION; + CSGShape3D *parent = nullptr; - CSGBrush *brush; + CSGBrush *brush = nullptr; AABB node_aabb; - bool dirty; - float snap; + bool dirty = false; + float snap = 0.001; - bool use_collision; - uint32_t collision_layer; - uint32_t collision_mask; + bool use_collision = false; + uint32_t collision_layer = 1; + uint32_t collision_mask = 1; Ref<ConcavePolygonShape3D> root_collision_shape; RID root_collision_instance; - bool calculate_tangents; + bool calculate_tangents = true; Ref<ArrayMesh> root_mesh; @@ -85,12 +85,12 @@ private: Vector<Vector2> uvs; Vector<float> tans; Ref<Material> material; - int last_added; + int last_added = 0; - Vector3 *verticesw; - Vector3 *normalsw; - Vector2 *uvsw; - float *tansw; + Vector3 *verticesw = nullptr; + Vector3 *normalsw = nullptr; + Vector2 *uvsw = nullptr; + float *tansw = nullptr; }; //mikktspace callbacks @@ -240,27 +240,19 @@ class CSGBox3D : public CSGPrimitive3D { virtual CSGBrush *_build_brush() override; Ref<Material> material; - float width; - float height; - float depth; + Vector3 size = Vector3(2, 2, 2); protected: static void _bind_methods(); public: - void set_width(const float p_width); - float get_width() const; - - void set_height(const float p_height); - float get_height() const; - - void set_depth(const float p_depth); - float get_depth() const; + void set_size(const Vector3 &p_size); + Vector3 get_size() const; void set_material(const Ref<Material> &p_material); Ref<Material> get_material() const; - CSGBox3D(); + CSGBox3D() {} }; class CSGCylinder3D : public CSGPrimitive3D { diff --git a/modules/csg/doc_classes/CSGBox3D.xml b/modules/csg/doc_classes/CSGBox3D.xml index 492bf68c44..b1d0454b76 100644 --- a/modules/csg/doc_classes/CSGBox3D.xml +++ b/modules/csg/doc_classes/CSGBox3D.xml @@ -11,17 +11,11 @@ <methods> </methods> <members> - <member name="depth" type="float" setter="set_depth" getter="get_depth" default="2.0"> - Depth of the box measured from the center of the box. - </member> - <member name="height" type="float" setter="set_height" getter="get_height" default="2.0"> - Height of the box measured from the center of the box. - </member> <member name="material" type="Material" setter="set_material" getter="get_material"> The material used to render the box. </member> - <member name="width" type="float" setter="set_width" getter="get_width" default="2.0"> - Width of the box measured from the center of the box. + <member name="size" type="Vector3" setter="set_size" getter="get_size" default="Vector3( 2, 2, 2 )"> + The box's width, height and depth. </member> </members> <constants> diff --git a/modules/csg/register_types.cpp b/modules/csg/register_types.cpp index a8bcc2fed1..e28f44d1eb 100644 --- a/modules/csg/register_types.cpp +++ b/modules/csg/register_types.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/csg/register_types.h b/modules/csg/register_types.h index 926e598561..8747b3fade 100644 --- a/modules/csg/register_types.h +++ b/modules/csg/register_types.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/cvtt/image_compress_cvtt.cpp b/modules/cvtt/image_compress_cvtt.cpp index 787b6dbf80..3beca3d12a 100644 --- a/modules/cvtt/image_compress_cvtt.cpp +++ b/modules/cvtt/image_compress_cvtt.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -33,30 +33,31 @@ #include "core/os/os.h" #include "core/os/thread.h" #include "core/string/print_string.h" +#include "core/templates/safe_refcount.h" #include <ConvectionKernels.h> struct CVTTCompressionJobParams { - bool is_hdr; - bool is_signed; - int bytes_per_pixel; + bool is_hdr = false; + bool is_signed = false; + int bytes_per_pixel = 0; cvtt::Options options; }; struct CVTTCompressionRowTask { const uint8_t *in_mm_bytes; - uint8_t *out_mm_bytes; - int y_start; - int width; - int height; + uint8_t *out_mm_bytes = nullptr; + int y_start = 0; + int width = 0; + int height = 0; }; struct CVTTCompressionJobQueue { CVTTCompressionJobParams job_params; const CVTTCompressionRowTask *job_tasks; - uint32_t num_tasks; - uint32_t current_task; + uint32_t num_tasks = 0; + SafeNumeric<uint32_t> current_task; }; static void _digest_row_task(const CVTTCompressionJobParams &p_job_params, const CVTTCompressionRowTask &p_row_task) { @@ -131,7 +132,7 @@ static void _digest_row_task(const CVTTCompressionJobParams &p_job_params, const static void _digest_job_queue(void *p_job_queue) { CVTTCompressionJobQueue *job_queue = static_cast<CVTTCompressionJobQueue *>(p_job_queue); - for (uint32_t next_task = atomic_increment(&job_queue->current_task); next_task <= job_queue->num_tasks; next_task = atomic_increment(&job_queue->current_task)) { + for (uint32_t next_task = job_queue->current_task.increment(); next_task <= job_queue->num_tasks; next_task = job_queue->current_task.increment()) { _digest_row_task(job_queue->job_params, job_queue->job_tasks[next_task - 1]); } } @@ -168,7 +169,7 @@ void image_compress_cvtt(Image *p_image, float p_lossy_quality, Image::UsedChann flags |= cvtt::Flags::BC7_RespectPunchThrough; - if (p_channels == Image::USED_CHANNELS_RG) { //guessing this is a normalmap + if (p_channels == Image::USED_CHANNELS_RG) { //guessing this is a normal map flags |= cvtt::Flags::Uniform; } options.flags = flags; @@ -263,16 +264,17 @@ void image_compress_cvtt(Image *p_image, float p_lossy_quality, Image::UsedChann const CVTTCompressionRowTask *tasks_rb = tasks.ptr(); job_queue.job_tasks = &tasks_rb[0]; - job_queue.current_task = 0; + job_queue.current_task.set(0); job_queue.num_tasks = static_cast<uint32_t>(tasks.size()); for (int i = 0; i < num_job_threads; i++) { - threads_wb[i] = Thread::create(_digest_job_queue, &job_queue); + threads_wb[i] = memnew(Thread); + threads_wb[i]->start(_digest_job_queue, &job_queue); } _digest_job_queue(&job_queue); for (int i = 0; i < num_job_threads; i++) { - Thread::wait_to_finish(threads_wb[i]); + threads_wb[i]->wait_to_finish(); memdelete(threads_wb[i]); } } diff --git a/modules/cvtt/image_compress_cvtt.h b/modules/cvtt/image_compress_cvtt.h index 483fb876a6..bef5653fa9 100644 --- a/modules/cvtt/image_compress_cvtt.h +++ b/modules/cvtt/image_compress_cvtt.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/cvtt/register_types.cpp b/modules/cvtt/register_types.cpp index e4a01cc787..055b5dc6e3 100644 --- a/modules/cvtt/register_types.cpp +++ b/modules/cvtt/register_types.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/cvtt/register_types.h b/modules/cvtt/register_types.h index 36b5e332d6..e62e8c0e9a 100644 --- a/modules/cvtt/register_types.h +++ b/modules/cvtt/register_types.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/dds/register_types.cpp b/modules/dds/register_types.cpp index 3991964a28..1444d33171 100644 --- a/modules/dds/register_types.cpp +++ b/modules/dds/register_types.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/dds/register_types.h b/modules/dds/register_types.h index 3cb7b5c2a6..b84bcd06c8 100644 --- a/modules/dds/register_types.h +++ b/modules/dds/register_types.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/dds/texture_loader_dds.cpp b/modules/dds/texture_loader_dds.cpp index 627153fbc8..2fef576b77 100644 --- a/modules/dds/texture_loader_dds.cpp +++ b/modules/dds/texture_loader_dds.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -69,11 +69,11 @@ enum DDSFormat { struct DDSFormatInfo { const char *name; - bool compressed; - bool palette; - uint32_t divisor; - uint32_t block_size; - Image::Format format; + bool compressed = false; + bool palette = false; + uint32_t divisor = 0; + uint32_t block_size = 0; + Image::Format format = Image::Format::FORMAT_BPTC_RGBA; }; static const DDSFormatInfo dds_format_info[DDS_MAX] = { @@ -94,7 +94,7 @@ static const DDSFormatInfo dds_format_info[DDS_MAX] = { { "GRAYSCALE_ALPHA", false, false, 1, 2, Image::FORMAT_LA8 } }; -RES ResourceFormatDDS::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, bool p_no_cache) { +RES ResourceFormatDDS::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, CacheMode p_cache_mode) { if (r_error) { *r_error = ERR_CANT_OPEN; } diff --git a/modules/dds/texture_loader_dds.h b/modules/dds/texture_loader_dds.h index ef08967df7..cf93156423 100644 --- a/modules/dds/texture_loader_dds.h +++ b/modules/dds/texture_loader_dds.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -36,7 +36,7 @@ class ResourceFormatDDS : public ResourceFormatLoader { public: - virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr, bool p_no_cache = false); + virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr, CacheMode p_cache_mode = CACHE_MODE_REUSE); virtual void get_recognized_extensions(List<String> *p_extensions) const; virtual bool handles_type(const String &p_type) const; virtual String get_resource_type(const String &p_path) const; diff --git a/modules/denoise/denoise_wrapper.cpp b/modules/denoise/denoise_wrapper.cpp index c12c6d9c31..e71fce5958 100644 --- a/modules/denoise/denoise_wrapper.cpp +++ b/modules/denoise/denoise_wrapper.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/denoise/denoise_wrapper.h b/modules/denoise/denoise_wrapper.h index 2107df09c1..25e342bc93 100644 --- a/modules/denoise/denoise_wrapper.h +++ b/modules/denoise/denoise_wrapper.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/denoise/lightmap_denoiser.cpp b/modules/denoise/lightmap_denoiser.cpp index 29d02e8ee2..003bc832b0 100644 --- a/modules/denoise/lightmap_denoiser.cpp +++ b/modules/denoise/lightmap_denoiser.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/denoise/lightmap_denoiser.h b/modules/denoise/lightmap_denoiser.h index f4e4335d9b..f1992a1733 100644 --- a/modules/denoise/lightmap_denoiser.h +++ b/modules/denoise/lightmap_denoiser.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/denoise/register_types.cpp b/modules/denoise/register_types.cpp index 552495ed87..936e5f604d 100644 --- a/modules/denoise/register_types.cpp +++ b/modules/denoise/register_types.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/denoise/register_types.h b/modules/denoise/register_types.h index f0f1f44bfe..516a91b134 100644 --- a/modules/denoise/register_types.h +++ b/modules/denoise/register_types.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/enet/doc_classes/NetworkedMultiplayerENet.xml b/modules/enet/doc_classes/NetworkedMultiplayerENet.xml index f46ef2d812..6c713fa1ce 100644 --- a/modules/enet/doc_classes/NetworkedMultiplayerENet.xml +++ b/modules/enet/doc_classes/NetworkedMultiplayerENet.xml @@ -5,6 +5,8 @@ </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. + ENet's purpose is to provide a relatively thin, simple and robust network communication layer on top of UDP (User Datagram Protocol). + [b]Note:[/b] ENet only uses UDP, not TCP. When forwarding the server port to make your server accessible on the public Internet, you only need to forward the server port in UDP. You can use the [UPNP] class to try to forward the server port automatically when starting the server. </description> <tutorials> <link title="High-level multiplayer">https://docs.godotengine.org/en/latest/tutorials/networking/high_level_multiplayer.html</link> diff --git a/modules/enet/networked_multiplayer_enet.cpp b/modules/enet/networked_multiplayer_enet.cpp index 64977ad237..91984b8928 100644 --- a/modules/enet/networked_multiplayer_enet.cpp +++ b/modules/enet/networked_multiplayer_enet.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -866,28 +866,12 @@ void NetworkedMultiplayerENet::_bind_methods() { } NetworkedMultiplayerENet::NetworkedMultiplayerENet() { - active = false; - server = false; - refuse_connections = false; - server_relay = true; - unique_id = 0; - target_peer = 0; - current_packet.packet = nullptr; - transfer_mode = TRANSFER_MODE_RELIABLE; - channel_count = SYSCH_MAX; - transfer_channel = -1; - always_ordered = false; - connection_status = CONNECTION_DISCONNECTED; - compression_mode = COMPRESS_NONE; enet_compressor.context = this; enet_compressor.compress = enet_compress; enet_compressor.decompress = enet_decompress; enet_compressor.destroy = enet_compressor_destroy; bind_ip = IP_Address("*"); - - dtls_enabled = false; - dtls_verify = true; } NetworkedMultiplayerENet::~NetworkedMultiplayerENet() { diff --git a/modules/enet/networked_multiplayer_enet.h b/modules/enet/networked_multiplayer_enet.h index 722c7001fd..eb70d71c2c 100644 --- a/modules/enet/networked_multiplayer_enet.h +++ b/modules/enet/networked_multiplayer_enet.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -62,35 +62,35 @@ private: SYSCH_MAX }; - bool active; - bool server; + bool active = false; + bool server = false; - uint32_t unique_id; + uint32_t unique_id = 0; - int target_peer; - TransferMode transfer_mode; - int transfer_channel; - int channel_count; - bool always_ordered; + int target_peer = 0; + TransferMode transfer_mode = TRANSFER_MODE_RELIABLE; + int transfer_channel = -1; + int channel_count = SYSCH_MAX; + bool always_ordered = false; ENetEvent event; - ENetPeer *peer; - ENetHost *host; + ENetPeer *peer = nullptr; + ENetHost *host = nullptr; - bool refuse_connections; - bool server_relay; + bool refuse_connections = false; + bool server_relay = true; - ConnectionStatus connection_status; + ConnectionStatus connection_status = CONNECTION_DISCONNECTED; Map<int, ENetPeer *> peer_map; struct Packet { - ENetPacket *packet; - int from; - int channel; + ENetPacket *packet = nullptr; + int from = 0; + int channel = 0; }; - CompressionMode compression_mode; + CompressionMode compression_mode = COMPRESS_NONE; List<Packet> incoming_packets; @@ -110,10 +110,10 @@ private: IP_Address bind_ip; - bool dtls_enabled; + bool dtls_enabled = false; Ref<CryptoKey> dtls_key; Ref<X509Certificate> dtls_cert; - bool dtls_verify; + bool dtls_verify = true; protected: static void _bind_methods(); diff --git a/modules/enet/register_types.cpp b/modules/enet/register_types.cpp index 2683f3155b..8da2d17e13 100644 --- a/modules/enet/register_types.cpp +++ b/modules/enet/register_types.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/enet/register_types.h b/modules/enet/register_types.h index cac0a4f7ee..75f4cba61b 100644 --- a/modules/enet/register_types.h +++ b/modules/enet/register_types.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/etc/image_compress_etc.cpp b/modules/etc/image_compress_etc.cpp index 552d3025f4..41cbbe3f54 100644 --- a/modules/etc/image_compress_etc.cpp +++ b/modules/etc/image_compress_etc.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/etc/image_compress_etc.h b/modules/etc/image_compress_etc.h index 016e64e4fc..44a06194e9 100644 --- a/modules/etc/image_compress_etc.h +++ b/modules/etc/image_compress_etc.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/etc/register_types.cpp b/modules/etc/register_types.cpp index 225ba6b954..b165bccb3e 100644 --- a/modules/etc/register_types.cpp +++ b/modules/etc/register_types.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/etc/register_types.h b/modules/etc/register_types.h index 247c7213af..e8cbb635ae 100644 --- a/modules/etc/register_types.h +++ b/modules/etc/register_types.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/etc/texture_loader_pkm.cpp b/modules/etc/texture_loader_pkm.cpp index c40e9612a8..95db9315d5 100644 --- a/modules/etc/texture_loader_pkm.cpp +++ b/modules/etc/texture_loader_pkm.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -35,14 +35,14 @@ struct ETC1Header { char tag[6]; // "PKM 10" - uint16_t format; // Format == number of mips (== zero) - uint16_t texWidth; // Texture dimensions, multiple of 4 (big-endian) - uint16_t texHeight; - uint16_t origWidth; // Original dimensions (big-endian) - uint16_t origHeight; + uint16_t format = 0; // Format == number of mips (== zero) + uint16_t texWidth = 0; // Texture dimensions, multiple of 4 (big-endian) + uint16_t texHeight = 0; + uint16_t origWidth = 0; // Original dimensions (big-endian) + uint16_t origHeight = 0; }; -RES ResourceFormatPKM::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, bool p_no_cache) { +RES ResourceFormatPKM::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, CacheMode p_cache_mode) { if (r_error) { *r_error = ERR_CANT_OPEN; } diff --git a/modules/etc/texture_loader_pkm.h b/modules/etc/texture_loader_pkm.h index 6507e0bdec..2ed5e75807 100644 --- a/modules/etc/texture_loader_pkm.h +++ b/modules/etc/texture_loader_pkm.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -36,7 +36,7 @@ class ResourceFormatPKM : public ResourceFormatLoader { public: - virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr, bool p_no_cache = false); + virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr, CacheMode p_cache_mode = CACHE_MODE_REUSE); virtual void get_recognized_extensions(List<String> *p_extensions) const; virtual bool handles_type(const String &p_type) const; virtual String get_resource_type(const String &p_path) const; diff --git a/modules/fbx/data/fbx_anim_container.h b/modules/fbx/data/fbx_anim_container.h index e45dd84d6a..8c25d65871 100644 --- a/modules/fbx/data/fbx_anim_container.h +++ b/modules/fbx/data/fbx_anim_container.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/fbx/data/fbx_bone.cpp b/modules/fbx/data/fbx_bone.cpp index 7ccb0b3717..38dada33af 100644 --- a/modules/fbx/data/fbx_bone.cpp +++ b/modules/fbx/data/fbx_bone.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/fbx/data/fbx_bone.h b/modules/fbx/data/fbx_bone.h index 5d797da24f..efba147b89 100644 --- a/modules/fbx/data/fbx_bone.h +++ b/modules/fbx/data/fbx_bone.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/fbx/data/fbx_material.cpp b/modules/fbx/data/fbx_material.cpp index b00ac2083e..5995097b2f 100644 --- a/modules/fbx/data/fbx_material.cpp +++ b/modules/fbx/data/fbx_material.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -42,7 +42,7 @@ void FBXMaterial::set_imported_material(FBXDocParser::Material *p_material) { } void FBXMaterial::add_search_string(String p_filename, String p_current_directory, String search_directory, Vector<String> &texture_search_paths) { - if (search_directory.empty()) { + if (search_directory.is_empty()) { texture_search_paths.push_back(p_current_directory.get_base_dir().plus_file(p_filename)); } else { texture_search_paths.push_back(p_current_directory.get_base_dir().plus_file(search_directory + "/" + p_filename)); @@ -188,7 +188,7 @@ Ref<StandardMaterial3D> FBXMaterial::import_material(ImportState &state) { spatial_material->set_transparency(BaseMaterial3D::TRANSPARENCY_ALPHA); } - ERR_CONTINUE_MSG(file_extension.empty(), "your texture has no file extension so we had to ignore it, let us know if you think this is wrong file an issue on github! " + debug_string); + ERR_CONTINUE_MSG(file_extension.is_empty(), "your texture has no file extension so we had to ignore it, let us know if you think this is wrong file an issue on github! " + debug_string); ERR_CONTINUE_MSG(fbx_texture_map.count(fbx_mapping_name) <= 0, "This material has a texture with mapping name: " + String(fbx_mapping_name.c_str()) + " which is not yet supported by this importer. Consider opening an issue so we can support it."); ERR_CONTINUE_MSG( file_extension_uppercase != "PNG" && @@ -211,7 +211,7 @@ Ref<StandardMaterial3D> FBXMaterial::import_material(ImportState &state) { texture = state.cached_image_searches[texture_name]; } else { String path = find_texture_path_by_filename(texture_name, p_fbx_current_directory); - if (!path.empty()) { + if (!path.is_empty()) { Ref<Texture2D> image_texture = ResourceLoader::load(path); ERR_CONTINUE(image_texture.is_null()); diff --git a/modules/fbx/data/fbx_material.h b/modules/fbx/data/fbx_material.h index 08b93ac01b..23310b8e1d 100644 --- a/modules/fbx/data/fbx_material.h +++ b/modules/fbx/data/fbx_material.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -217,9 +217,6 @@ struct FBXMaterial : public Reference { { "TransparencyFactor", PROPERTY_DESC_TRANSPARENT }, { "Maya|opacity", PROPERTY_DESC_TRANSPARENT }, - /* Metallic */ - { "Shininess", PROPERTY_DESC_METALLIC }, - { "Reflectivity", PROPERTY_DESC_METALLIC }, { "Maya|metalness", PROPERTY_DESC_METALLIC }, { "Maya|metallic", PROPERTY_DESC_METALLIC }, @@ -241,6 +238,8 @@ struct FBXMaterial : public Reference { { "Maya|emissionColor", PROPERTY_DESC_EMISSIVE_COLOR }, /* Ignore */ + { "Shininess", PROPERTY_DESC_IGNORE }, + { "Reflectivity", PROPERTY_DESC_IGNORE }, { "Maya|diffuseRoughness", PROPERTY_DESC_IGNORE }, { "Maya", PROPERTY_DESC_IGNORE }, { "Diffuse", PROPERTY_DESC_ALBEDO_COLOR }, diff --git a/modules/fbx/data/fbx_mesh_data.cpp b/modules/fbx/data/fbx_mesh_data.cpp index 0728866adb..883651943e 100644 --- a/modules/fbx/data/fbx_mesh_data.cpp +++ b/modules/fbx/data/fbx_mesh_data.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -34,11 +34,11 @@ #include "scene/resources/mesh.h" #include "scene/resources/surface_tool.h" -#include "thirdparty/misc/triangulator.h" +#include "thirdparty/misc/polypartition.h" template <class T> T collect_first(const Vector<VertexData<T>> *p_data, T p_fall_back) { - if (p_data->empty()) { + if (p_data->is_empty()) { return p_fall_back; } @@ -47,7 +47,7 @@ T collect_first(const Vector<VertexData<T>> *p_data, T p_fall_back) { template <class T> HashMap<int, T> collect_all(const Vector<VertexData<T>> *p_data, HashMap<int, T> p_fall_back) { - if (p_data->empty()) { + if (p_data->is_empty()) { return p_fall_back; } @@ -61,7 +61,7 @@ HashMap<int, T> collect_all(const Vector<VertexData<T>> *p_data, HashMap<int, T> template <class T> T collect_average(const Vector<VertexData<T>> *p_data, T p_fall_back) { - if (p_data->empty()) { + if (p_data->is_empty()) { return p_fall_back; } @@ -76,7 +76,7 @@ T collect_average(const Vector<VertexData<T>> *p_data, T p_fall_back) { } HashMap<int, Vector3> collect_normal(const Vector<VertexData<Vector3>> *p_data, HashMap<int, Vector3> p_fall_back) { - if (p_data->empty()) { + if (p_data->is_empty()) { return p_fall_back; } @@ -89,7 +89,7 @@ HashMap<int, Vector3> collect_normal(const Vector<VertexData<Vector3>> *p_data, } HashMap<int, Vector2> collect_uv(const Vector<VertexData<Vector2>> *p_data, HashMap<int, Vector2> p_fall_back) { - if (p_data->empty()) { + if (p_data->is_empty()) { return p_fall_back; } @@ -135,26 +135,6 @@ EditorSceneImporterMeshNode3D *FBXMeshData::create_fbx_mesh(const ImportState &s &collect_all, HashMap<int, Vector3>()); - // List<int> keys; - // normals.get_key_list(&keys); - // - // const std::vector<Assimp::FBX::MeshGeometry::Edge>& edges = mesh_geometry->get_edge_map(); - // for (int index = 0; index < keys.size(); index++) { - // const int key = keys[index]; - // const int v1 = edges[key].vertex_0; - // const int v2 = edges[key].vertex_1; - // const Vector3& n1 = normals.get(v1); - // const Vector3& n2 = normals.get(v2); - // print_verbose("[" + itos(v1) + "] n1: " + n1 + "\n[" + itos(v2) + "] n2: " + n2); - // //print_verbose("[" + itos(key) + "] n1: " + n1 + ", n2: " + n2) ; - // //print_verbose("vindex: " + itos(edges[key].vertex_0) + ", vindex2: " + itos(edges[key].vertex_1)); - // //Vector3 ver1 = vertices[edges[key].vertex_0]; - // //Vector3 ver2 = vertices[edges[key].vertex_1]; - // /*real_t angle1 = Math::rad2deg(n1.angle_to(n2)); - // real_t angle2 = Math::rad2deg(n2.angle_to(n1)); - // print_verbose("angle of normals: " + rtos(angle1) + " angle 2" + rtos(angle2));*/ - // } - HashMap<int, Vector2> uvs_0; HashMap<int, HashMap<int, Vector2>> uvs_0_raw = extract_per_vertex_data( vertices.size(), @@ -231,7 +211,7 @@ EditorSceneImporterMeshNode3D *FBXMeshData::create_fbx_mesh(const ImportState &s // Phase 2. For each material create a surface tool (So a different mesh). { - if (polygon_surfaces.empty()) { + if (polygon_surfaces.is_empty()) { // No material, just use the default one with index -1. // Set -1 to all polygons. const int polygon_count = count_polygons(polygon_indices); @@ -371,6 +351,9 @@ EditorSceneImporterMeshNode3D *FBXMeshData::create_fbx_mesh(const ImportState &s normals_ptr[vertex]); } + if (state.is_blender_fbx) { + morph_st->generate_normals(); + } morph_st->generate_tangents(); surface->morphs.push_back(morph_st->commit_to_arrays()); } @@ -393,6 +376,9 @@ EditorSceneImporterMeshNode3D *FBXMeshData::create_fbx_mesh(const ImportState &s for (const SurfaceId *surface_id = surfaces.next(nullptr); surface_id != nullptr; surface_id = surfaces.next(surface_id)) { SurfaceData *surface = surfaces.getptr(*surface_id); + if (state.is_blender_fbx) { + surface->surface_tool->generate_normals(); + } // you can't generate them without a valid uv map. if (uvs_0_raw.size() > 0) { surface->surface_tool->generate_tangents(); @@ -785,7 +771,7 @@ void FBXMeshData::add_vertex( const Vector3 &p_morph_normal) { ERR_FAIL_INDEX_MSG(p_vertex, (Vertex)p_vertices_position.size(), "FBX file is corrupted, the position of the vertex can't be retrieved."); - if (p_normals.has(p_vertex)) { + if (p_normals.has(p_vertex) && !state.is_blender_fbx) { p_surface_tool->set_normal(p_normals[p_vertex] + p_morph_normal); } @@ -944,30 +930,30 @@ void FBXMeshData::triangulate_polygon(Ref<SurfaceTool> st, Vector<int> p_polygon } } - TriangulatorPoly triangulator_poly; - triangulator_poly.Init(polygon_vertex_count); + TPPLPoly tppl_poly; + tppl_poly.Init(polygon_vertex_count); std::vector<Vector2> projected_vertices(polygon_vertex_count); for (int i = 0; i < polygon_vertex_count; i += 1) { const Vector2 pv(poly_vertices[i][axis_1_coord], poly_vertices[i][axis_2_coord]); projected_vertices[i] = pv; - triangulator_poly.GetPoint(i) = pv; + tppl_poly.GetPoint(i) = pv; } - triangulator_poly.SetOrientation(TRIANGULATOR_CCW); + tppl_poly.SetOrientation(TPPL_ORIENTATION_CCW); - List<TriangulatorPoly> out_poly; + List<TPPLPoly> out_poly; - TriangulatorPartition triangulator_partition; - if (triangulator_partition.Triangulate_OPT(&triangulator_poly, &out_poly) == 0) { // Good result. - if (triangulator_partition.Triangulate_EC(&triangulator_poly, &out_poly) == 0) { // Medium result. - if (triangulator_partition.Triangulate_MONO(&triangulator_poly, &out_poly) == 0) { // Really poor result. + TPPLPartition tppl_partition; + if (tppl_partition.Triangulate_OPT(&tppl_poly, &out_poly) == 0) { // Good result. + if (tppl_partition.Triangulate_EC(&tppl_poly, &out_poly) == 0) { // Medium result. + if (tppl_partition.Triangulate_MONO(&tppl_poly, &out_poly) == 0) { // Really poor result. ERR_FAIL_MSG("The triangulation of this polygon failed, please try to triangulate your mesh or check if it has broken polygons."); } } } std::vector<Vector2> tris(out_poly.size()); - for (List<TriangulatorPoly>::Element *I = out_poly.front(); I; I = I->next()) { - TriangulatorPoly &tp = I->get(); + for (List<TPPLPoly>::Element *I = out_poly.front(); I; I = I->next()) { + TPPLPoly &tp = I->get(); ERR_FAIL_COND_MSG(tp.GetNumPoints() != 3, "The triangulator retuned more points, how this is possible?"); // Find Index @@ -990,7 +976,7 @@ void FBXMeshData::triangulate_polygon(Ref<SurfaceTool> st, Vector<int> p_polygon } void FBXMeshData::gen_weight_info(Ref<SurfaceTool> st, Vertex vertex_id) const { - if (vertex_weights.empty()) { + if (vertex_weights.is_empty()) { return; } @@ -1417,7 +1403,7 @@ void FBXMeshData::extract_morphs(const FBXDocParser::MeshGeometry *mesh_geometry const std::vector<const FBXDocParser::ShapeGeometry *> &shape_geometries = blend_shape_channel->GetShapeGeometries(); for (const FBXDocParser::ShapeGeometry *shape_geometry : shape_geometries) { String morph_name = ImportUtils::FBXAnimMeshName(shape_geometry->Name()).c_str(); - if (morph_name.empty()) { + if (morph_name.is_empty()) { morph_name = "morph"; } diff --git a/modules/fbx/data/fbx_mesh_data.h b/modules/fbx/data/fbx_mesh_data.h index b6e87bb9e2..77510ff2ec 100644 --- a/modules/fbx/data/fbx_mesh_data.h +++ b/modules/fbx/data/fbx_mesh_data.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/fbx/data/fbx_node.h b/modules/fbx/data/fbx_node.h index d8efcaa982..a6f62f3388 100644 --- a/modules/fbx/data/fbx_node.h +++ b/modules/fbx/data/fbx_node.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/fbx/data/fbx_skeleton.cpp b/modules/fbx/data/fbx_skeleton.cpp index 93aeffc132..622b589feb 100644 --- a/modules/fbx/data/fbx_skeleton.cpp +++ b/modules/fbx/data/fbx_skeleton.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/fbx/data/fbx_skeleton.h b/modules/fbx/data/fbx_skeleton.h index a2e330114c..df937cde49 100644 --- a/modules/fbx/data/fbx_skeleton.h +++ b/modules/fbx/data/fbx_skeleton.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/fbx/data/import_state.h b/modules/fbx/data/import_state.h index 34021ca7b1..83bc43faff 100644 --- a/modules/fbx/data/import_state.h +++ b/modules/fbx/data/import_state.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -64,6 +64,7 @@ struct FBXSkeleton; struct ImportState { bool enable_material_import = true; bool enable_animation_import = true; + bool is_blender_fbx = false; Map<StringName, Ref<Texture>> cached_image_searches; Map<uint64_t, Ref<Material>> cached_materials; diff --git a/modules/fbx/data/model_abstraction.h b/modules/fbx/data/model_abstraction.h index b21ab0badb..528960ab49 100644 --- a/modules/fbx/data/model_abstraction.h +++ b/modules/fbx/data/model_abstraction.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/fbx/data/pivot_transform.cpp b/modules/fbx/data/pivot_transform.cpp index c12e94097f..1895af6f9f 100644 --- a/modules/fbx/data/pivot_transform.cpp +++ b/modules/fbx/data/pivot_transform.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -76,12 +76,14 @@ void PivotTransform::ReadTransformChain() { const Vector3 &Scaling = ImportUtils::safe_import_vector3(FBXDocParser::PropertyGet<Vector3>(props, "Lcl Scaling", ok)); if (ok) { scaling = Scaling; + } else { + scaling = Vector3(1, 1, 1); } const Vector3 &GeometricScaling = ImportUtils::safe_import_vector3(FBXDocParser::PropertyGet<Vector3>(props, "GeometricScaling", ok)); if (ok) { geometric_scaling = GeometricScaling; } else { - geometric_scaling = Vector3(0, 0, 0); + geometric_scaling = Vector3(1, 1, 1); } const Vector3 &GeometricRotation = ImportUtils::safe_import_vector3(FBXDocParser::PropertyGet<Vector3>(props, "GeometricRotation", ok)); @@ -207,6 +209,8 @@ Transform PivotTransform::ComputeGlobalTransform(Vector3 p_translation, Quat p_r Transform local_transform = T * Roff * Rp * Rpre * R * Rpost.affine_inverse() * Rp.affine_inverse() * Soff * Sp * S * Sp.affine_inverse(); //Transform local_translation_pivoted = Transform(Basis(), LocalTransform.origin); + ERR_FAIL_COND_V_MSG(local_transform.basis.determinant() == 0, Transform(), "Det == 0 prevented in scene file"); + // manual hack to force SSC not to be compensated for - until we can handle it properly with tests return parent_global_xform * local_transform; } @@ -290,5 +294,14 @@ void PivotTransform::Execute() { ComputePivotTransform(); ImportUtils::debug_xform("global xform: ", GlobalTransform); + + if (LocalTransform.basis.determinant() == 0) { + print_error("Serious det == 0!"); + } + + if (GlobalTransform.basis.determinant() == 0) { + print_error("Serious! node has det == 0!"); + } + computed_global_xform = true; } diff --git a/modules/fbx/data/pivot_transform.h b/modules/fbx/data/pivot_transform.h index 025c8dd58d..9996027870 100644 --- a/modules/fbx/data/pivot_transform.h +++ b/modules/fbx/data/pivot_transform.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/fbx/doc_classes/EditorSceneImporterFBX.xml b/modules/fbx/doc_classes/EditorSceneImporterFBX.xml index 72b6e0f5fd..da1a68c27c 100644 --- a/modules/fbx/doc_classes/EditorSceneImporterFBX.xml +++ b/modules/fbx/doc_classes/EditorSceneImporterFBX.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="EditorSceneImporterFBX" inherits="EditorSceneImporter" version="3.2"> +<class name="EditorSceneImporterFBX" inherits="EditorSceneImporter" version="4.0"> <brief_description> FBX 3D asset importer. </brief_description> diff --git a/modules/fbx/editor_scene_importer_fbx.cpp b/modules/fbx/editor_scene_importer_fbx.cpp index d37befbbfd..6576147b2b 100644 --- a/modules/fbx/editor_scene_importer_fbx.cpp +++ b/modules/fbx/editor_scene_importer_fbx.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -63,8 +63,7 @@ void EditorSceneImporterFBX::get_extensions(List<String> *r_extensions) const { const String fbx_str = "fbx"; Vector<String> exts; exts.push_back(fbx_str); - _register_project_setting_import(fbx_str, import_setting_string, exts, r_extensions, - true); + _register_project_setting_import(fbx_str, import_setting_string, exts, r_extensions, true); } void EditorSceneImporterFBX::_register_project_setting_import(const String generic, @@ -181,10 +180,12 @@ Node3D *EditorSceneImporterFBX::import_scene(const String &p_path, uint32_t p_fl } if (is_blender_fbx) { - WARN_PRINT("Blender FBX files will not work properly with keyframes or skeletons until we make fixes stand by."); + WARN_PRINT("We don't officially support Blender FBX animations yet, due to issues with upstream Blender,\n" + "so please wait for us to work around remaining issues. We will continue to import the file but it may be broken.\n" + "For minimal breakage, please export FBX from Blender with -Z forward, and Y up."); } - Node3D *spatial = _generate_scene(p_path, &doc, p_flags, p_bake_fps, 8); + Node3D *spatial = _generate_scene(p_path, &doc, p_flags, p_bake_fps, 8, is_blender_fbx); // todo: move to document shutdown (will need to be validated after moving; this code has been validated already) for (FBXDocParser::TokenPtr token : tokens) { if (token) { @@ -196,7 +197,7 @@ Node3D *EditorSceneImporterFBX::import_scene(const String &p_path, uint32_t p_fl return spatial; } else { - print_error("Cannot import file: " + p_path + " version of file is unsupported, please re-export in your modelling package file version is: " + itos(doc.FBXVersion())); + ERR_PRINT(vformat("Cannot import FBX file: %s. It uses file format %d which is unsupported by Godot. Please re-export it or convert it to a newer format.", p_path, doc.FBXVersion())); } } @@ -328,8 +329,10 @@ Node3D *EditorSceneImporterFBX::_generate_scene( const FBXDocParser::Document *p_document, const uint32_t p_flags, int p_bake_fps, - const int32_t p_max_bone_weights) { + const int32_t p_max_bone_weights, + bool p_is_blender_fbx) { ImportState state; + state.is_blender_fbx = p_is_blender_fbx; state.path = p_path; state.animation_player = NULL; @@ -550,8 +553,8 @@ Node3D *EditorSceneImporterFBX::_generate_scene( print_verbose("populating skeleton with bone: " + bone->bone_name); - // // populate bone skeleton - since fbx has no DOM for the skeleton just a node. - // bone->bone_skeleton = fbx_skeleton_inst; + //// populate bone skeleton - since fbx has no DOM for the skeleton just a node. + //bone->bone_skeleton = fbx_skeleton_inst; // now populate bone on the armature node list fbx_skeleton_inst->skeleton_bones.push_back(bone); @@ -688,8 +691,8 @@ Node3D *EditorSceneImporterFBX::_generate_scene( // // Get Mesh Node Xform only // - // ERR_CONTINUE_MSG(!state.fbx_target_map.has(mesh_id), "invalid xform for the skin pose: " + itos(mesh_id)); - // Ref<FBXNode> mesh_node_xform_data = state.fbx_target_map[mesh_id]; + //ERR_CONTINUE_MSG(!state.fbx_target_map.has(mesh_id), "invalid xform for the skin pose: " + itos(mesh_id)); + //Ref<FBXNode> mesh_node_xform_data = state.fbx_target_map[mesh_id]; if (!mesh_skin) { continue; // not a deformer. diff --git a/modules/fbx/editor_scene_importer_fbx.h b/modules/fbx/editor_scene_importer_fbx.h index ff1d243ede..39f8648b0f 100644 --- a/modules/fbx/editor_scene_importer_fbx.h +++ b/modules/fbx/editor_scene_importer_fbx.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -114,7 +114,9 @@ private: Node3D *_generate_scene(const String &p_path, const FBXDocParser::Document *p_document, const uint32_t p_flags, - int p_bake_fps, const int32_t p_max_bone_weights); + int p_bake_fps, + const int32_t p_max_bone_weights, + bool p_is_blender_fbx); template <class T> T _interpolate_track(const Vector<float> &p_times, const Vector<T> &p_values, float p_time, AssetImportAnimation::Interpolation p_interp); diff --git a/modules/fbx/fbx_parser/ByteSwapper.h b/modules/fbx/fbx_parser/ByteSwapper.h index 0a46a7df26..f759c9117c 100644 --- a/modules/fbx/fbx_parser/ByteSwapper.h +++ b/modules/fbx/fbx_parser/ByteSwapper.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/fbx/fbx_parser/FBXAnimation.cpp b/modules/fbx/fbx_parser/FBXAnimation.cpp index bfd3e97314..b11e2c7f55 100644 --- a/modules/fbx/fbx_parser/FBXAnimation.cpp +++ b/modules/fbx/fbx_parser/FBXAnimation.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/fbx/fbx_parser/FBXBinaryTokenizer.cpp b/modules/fbx/fbx_parser/FBXBinaryTokenizer.cpp index 0fc66b13cd..1d2b7765c5 100644 --- a/modules/fbx/fbx_parser/FBXBinaryTokenizer.cpp +++ b/modules/fbx/fbx_parser/FBXBinaryTokenizer.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/fbx/fbx_parser/FBXCommon.h b/modules/fbx/fbx_parser/FBXCommon.h index 98a3d78f0d..641d6d351e 100644 --- a/modules/fbx/fbx_parser/FBXCommon.h +++ b/modules/fbx/fbx_parser/FBXCommon.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/fbx/fbx_parser/FBXDeformer.cpp b/modules/fbx/fbx_parser/FBXDeformer.cpp index 325641bc32..4b774e6b2a 100644 --- a/modules/fbx/fbx_parser/FBXDeformer.cpp +++ b/modules/fbx/fbx_parser/FBXDeformer.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/fbx/fbx_parser/FBXDocument.cpp b/modules/fbx/fbx_parser/FBXDocument.cpp index 74798a655a..bcf7fa1565 100644 --- a/modules/fbx/fbx_parser/FBXDocument.cpp +++ b/modules/fbx/fbx_parser/FBXDocument.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/fbx/fbx_parser/FBXDocument.h b/modules/fbx/fbx_parser/FBXDocument.h index 7c08f3de65..b810197d7e 100644 --- a/modules/fbx/fbx_parser/FBXDocument.h +++ b/modules/fbx/fbx_parser/FBXDocument.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/fbx/fbx_parser/FBXDocumentUtil.cpp b/modules/fbx/fbx_parser/FBXDocumentUtil.cpp index 70b2b3bbe9..835b66ab23 100644 --- a/modules/fbx/fbx_parser/FBXDocumentUtil.cpp +++ b/modules/fbx/fbx_parser/FBXDocumentUtil.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/fbx/fbx_parser/FBXDocumentUtil.h b/modules/fbx/fbx_parser/FBXDocumentUtil.h index fb6eb04aea..daa9de4a33 100644 --- a/modules/fbx/fbx_parser/FBXDocumentUtil.h +++ b/modules/fbx/fbx_parser/FBXDocumentUtil.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/fbx/fbx_parser/FBXImportSettings.h b/modules/fbx/fbx_parser/FBXImportSettings.h index 4abca6b990..97ce496eaf 100644 --- a/modules/fbx/fbx_parser/FBXImportSettings.h +++ b/modules/fbx/fbx_parser/FBXImportSettings.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/fbx/fbx_parser/FBXMaterial.cpp b/modules/fbx/fbx_parser/FBXMaterial.cpp index 5d25809d7b..9970a2b0b1 100644 --- a/modules/fbx/fbx_parser/FBXMaterial.cpp +++ b/modules/fbx/fbx_parser/FBXMaterial.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/fbx/fbx_parser/FBXMeshGeometry.cpp b/modules/fbx/fbx_parser/FBXMeshGeometry.cpp index 4fa5fc0ac9..ccc06550fe 100644 --- a/modules/fbx/fbx_parser/FBXMeshGeometry.cpp +++ b/modules/fbx/fbx_parser/FBXMeshGeometry.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/fbx/fbx_parser/FBXMeshGeometry.h b/modules/fbx/fbx_parser/FBXMeshGeometry.h index 666da46edd..710e644c68 100644 --- a/modules/fbx/fbx_parser/FBXMeshGeometry.h +++ b/modules/fbx/fbx_parser/FBXMeshGeometry.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/fbx/fbx_parser/FBXModel.cpp b/modules/fbx/fbx_parser/FBXModel.cpp index 5867f59d6a..767994441f 100644 --- a/modules/fbx/fbx_parser/FBXModel.cpp +++ b/modules/fbx/fbx_parser/FBXModel.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/fbx/fbx_parser/FBXNodeAttribute.cpp b/modules/fbx/fbx_parser/FBXNodeAttribute.cpp index c5051bd147..2749fc9f4d 100644 --- a/modules/fbx/fbx_parser/FBXNodeAttribute.cpp +++ b/modules/fbx/fbx_parser/FBXNodeAttribute.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/fbx/fbx_parser/FBXParseTools.h b/modules/fbx/fbx_parser/FBXParseTools.h index edc52009b3..21472f5b7b 100644 --- a/modules/fbx/fbx_parser/FBXParseTools.h +++ b/modules/fbx/fbx_parser/FBXParseTools.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/fbx/fbx_parser/FBXParser.cpp b/modules/fbx/fbx_parser/FBXParser.cpp index 208358f55e..44c24ff926 100644 --- a/modules/fbx/fbx_parser/FBXParser.cpp +++ b/modules/fbx/fbx_parser/FBXParser.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/fbx/fbx_parser/FBXParser.h b/modules/fbx/fbx_parser/FBXParser.h index 3cba81ff83..37d27d3dca 100644 --- a/modules/fbx/fbx_parser/FBXParser.h +++ b/modules/fbx/fbx_parser/FBXParser.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/fbx/fbx_parser/FBXPose.cpp b/modules/fbx/fbx_parser/FBXPose.cpp index 1bee2fa2f0..6d80b85e38 100644 --- a/modules/fbx/fbx_parser/FBXPose.cpp +++ b/modules/fbx/fbx_parser/FBXPose.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/fbx/fbx_parser/FBXProperties.cpp b/modules/fbx/fbx_parser/FBXProperties.cpp index 2994a84dbd..8ab94e1ef4 100644 --- a/modules/fbx/fbx_parser/FBXProperties.cpp +++ b/modules/fbx/fbx_parser/FBXProperties.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/fbx/fbx_parser/FBXProperties.h b/modules/fbx/fbx_parser/FBXProperties.h index a007660c45..27cacfaf76 100644 --- a/modules/fbx/fbx_parser/FBXProperties.h +++ b/modules/fbx/fbx_parser/FBXProperties.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/fbx/fbx_parser/FBXTokenizer.cpp b/modules/fbx/fbx_parser/FBXTokenizer.cpp index 3748bfabf8..ea4568fe32 100644 --- a/modules/fbx/fbx_parser/FBXTokenizer.cpp +++ b/modules/fbx/fbx_parser/FBXTokenizer.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/fbx/fbx_parser/FBXTokenizer.h b/modules/fbx/fbx_parser/FBXTokenizer.h index 1761869c69..1e7e5e6535 100644 --- a/modules/fbx/fbx_parser/FBXTokenizer.h +++ b/modules/fbx/fbx_parser/FBXTokenizer.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/fbx/fbx_parser/FBXUtil.cpp b/modules/fbx/fbx_parser/FBXUtil.cpp index 508407ea51..80ea5fab4c 100644 --- a/modules/fbx/fbx_parser/FBXUtil.cpp +++ b/modules/fbx/fbx_parser/FBXUtil.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/fbx/fbx_parser/FBXUtil.h b/modules/fbx/fbx_parser/FBXUtil.h index 553d5fbc6b..efc131831b 100644 --- a/modules/fbx/fbx_parser/FBXUtil.h +++ b/modules/fbx/fbx_parser/FBXUtil.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/fbx/register_types.cpp b/modules/fbx/register_types.cpp index 28fa69282e..c0591dbc77 100644 --- a/modules/fbx/register_types.cpp +++ b/modules/fbx/register_types.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/fbx/register_types.h b/modules/fbx/register_types.h index 26328c4c15..e5741afd72 100644 --- a/modules/fbx/register_types.h +++ b/modules/fbx/register_types.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/fbx/tools/import_utils.cpp b/modules/fbx/tools/import_utils.cpp index 5c9e433ab8..c87dd1fd3a 100644 --- a/modules/fbx/tools/import_utils.cpp +++ b/modules/fbx/tools/import_utils.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/fbx/tools/import_utils.h b/modules/fbx/tools/import_utils.h index 98a0cef908..6261138812 100644 --- a/modules/fbx/tools/import_utils.h +++ b/modules/fbx/tools/import_utils.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/fbx/tools/validation_tools.cpp b/modules/fbx/tools/validation_tools.cpp index 0c4d7abe8d..9dbd8bf544 100644 --- a/modules/fbx/tools/validation_tools.cpp +++ b/modules/fbx/tools/validation_tools.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/fbx/tools/validation_tools.h b/modules/fbx/tools/validation_tools.h index 649842a1cb..ced100aed2 100644 --- a/modules/fbx/tools/validation_tools.h +++ b/modules/fbx/tools/validation_tools.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/freetype/register_types.cpp b/modules/freetype/register_types.cpp index 15fa193183..e4e6a4c146 100644 --- a/modules/freetype/register_types.cpp +++ b/modules/freetype/register_types.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/freetype/register_types.h b/modules/freetype/register_types.h index aa8088d2e8..7a4f64b54b 100644 --- a/modules/freetype/register_types.h +++ b/modules/freetype/register_types.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/freetype/uwpdef.h b/modules/freetype/uwpdef.h index 2f9b2f4a53..f829edea67 100644 --- a/modules/freetype/uwpdef.h +++ b/modules/freetype/uwpdef.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gamecenter/SCsub b/modules/gamecenter/SCsub deleted file mode 100644 index 72fbf7ab0e..0000000000 --- a/modules/gamecenter/SCsub +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env python - -Import("env") -Import("env_modules") - -env_gamecenter = env_modules.Clone() - -# (iOS) Enable module support -env_gamecenter.Append(CCFLAGS=["-fmodules", "-fcxx-modules"]) - -# (iOS) Build as separate static library -modules_sources = [] -env_gamecenter.add_source_files(modules_sources, "*.cpp") -env_gamecenter.add_source_files(modules_sources, "*.mm") -mod_lib = env_modules.add_library("#bin/libgodot_gamecenter_module" + env["LIBSUFFIX"], modules_sources) diff --git a/modules/gamecenter/config.py b/modules/gamecenter/config.py deleted file mode 100644 index e68603fc93..0000000000 --- a/modules/gamecenter/config.py +++ /dev/null @@ -1,6 +0,0 @@ -def can_build(env, platform): - return platform == "iphone" - - -def configure(env): - pass diff --git a/modules/gamecenter/game_center.mm b/modules/gamecenter/game_center.mm deleted file mode 100644 index 114f639a32..0000000000 --- a/modules/gamecenter/game_center.mm +++ /dev/null @@ -1,380 +0,0 @@ -/*************************************************************************/ -/* game_center.mm */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include "game_center.h" -#import "platform/iphone/app_delegate.h" - -#import "game_center_delegate.h" -#import "platform/iphone/view_controller.h" -#import <GameKit/GameKit.h> - -GameCenter *GameCenter::instance = NULL; -GodotGameCenterDelegate *gameCenterDelegate = nil; - -void GameCenter::_bind_methods() { - ClassDB::bind_method(D_METHOD("authenticate"), &GameCenter::authenticate); - ClassDB::bind_method(D_METHOD("is_authenticated"), &GameCenter::is_authenticated); - - ClassDB::bind_method(D_METHOD("post_score"), &GameCenter::post_score); - ClassDB::bind_method(D_METHOD("award_achievement", "achievement"), &GameCenter::award_achievement); - ClassDB::bind_method(D_METHOD("reset_achievements"), &GameCenter::reset_achievements); - ClassDB::bind_method(D_METHOD("request_achievements"), &GameCenter::request_achievements); - ClassDB::bind_method(D_METHOD("request_achievement_descriptions"), &GameCenter::request_achievement_descriptions); - ClassDB::bind_method(D_METHOD("show_game_center"), &GameCenter::show_game_center); - ClassDB::bind_method(D_METHOD("request_identity_verification_signature"), &GameCenter::request_identity_verification_signature); - - ClassDB::bind_method(D_METHOD("get_pending_event_count"), &GameCenter::get_pending_event_count); - ClassDB::bind_method(D_METHOD("pop_pending_event"), &GameCenter::pop_pending_event); -}; - -Error GameCenter::authenticate() { - //if this class isn't available, game center isn't implemented - if ((NSClassFromString(@"GKLocalPlayer")) == nil) { - return ERR_UNAVAILABLE; - } - - GKLocalPlayer *player = [GKLocalPlayer localPlayer]; - ERR_FAIL_COND_V(![player respondsToSelector:@selector(authenticateHandler)], ERR_UNAVAILABLE); - - UIViewController *root_controller = [[UIApplication sharedApplication] delegate].window.rootViewController; - ERR_FAIL_COND_V(!root_controller, FAILED); - - // This handler is called several times. First when the view needs to be shown, then again - // after the view is cancelled or the user logs in. Or if the user's already logged in, it's - // called just once to confirm they're authenticated. This is why no result needs to be specified - // in the presentViewController phase. In this case, more calls to this function will follow. - _weakify(root_controller); - _weakify(player); - player.authenticateHandler = (^(UIViewController *controller, NSError *error) { - _strongify(root_controller); - _strongify(player); - - if (controller) { - [root_controller presentViewController:controller animated:YES completion:nil]; - } else { - Dictionary ret; - ret["type"] = "authentication"; - if (player.isAuthenticated) { - ret["result"] = "ok"; - if (@available(iOS 13, *)) { - ret["player_id"] = [player.teamPlayerID UTF8String]; -#if !defined(TARGET_OS_SIMULATOR) || !TARGET_OS_SIMULATOR - } else { - ret["player_id"] = [player.playerID UTF8String]; -#endif - } - - GameCenter::get_singleton()->authenticated = true; - } else { - ret["result"] = "error"; - ret["error_code"] = (int64_t)error.code; - ret["error_description"] = [error.localizedDescription UTF8String]; - GameCenter::get_singleton()->authenticated = false; - }; - - pending_events.push_back(ret); - }; - }); - - return OK; -}; - -bool GameCenter::is_authenticated() { - return authenticated; -}; - -Error GameCenter::post_score(Dictionary p_score) { - ERR_FAIL_COND_V(!p_score.has("score") || !p_score.has("category"), ERR_INVALID_PARAMETER); - float score = p_score["score"]; - String category = p_score["category"]; - - NSString *cat_str = [[NSString alloc] initWithUTF8String:category.utf8().get_data()]; - GKScore *reporter = [[GKScore alloc] initWithLeaderboardIdentifier:cat_str]; - reporter.value = score; - - ERR_FAIL_COND_V([GKScore respondsToSelector:@selector(reportScores)], ERR_UNAVAILABLE); - - [GKScore reportScores:@[ reporter ] - withCompletionHandler:^(NSError *error) { - Dictionary ret; - ret["type"] = "post_score"; - if (error == nil) { - ret["result"] = "ok"; - } else { - ret["result"] = "error"; - ret["error_code"] = (int64_t)error.code; - ret["error_description"] = [error.localizedDescription UTF8String]; - }; - - pending_events.push_back(ret); - }]; - - return OK; -}; - -Error GameCenter::award_achievement(Dictionary p_params) { - ERR_FAIL_COND_V(!p_params.has("name") || !p_params.has("progress"), ERR_INVALID_PARAMETER); - String name = p_params["name"]; - float progress = p_params["progress"]; - - NSString *name_str = [[NSString alloc] initWithUTF8String:name.utf8().get_data()]; - GKAchievement *achievement = [[GKAchievement alloc] initWithIdentifier:name_str]; - ERR_FAIL_COND_V(!achievement, FAILED); - - ERR_FAIL_COND_V([GKAchievement respondsToSelector:@selector(reportAchievements)], ERR_UNAVAILABLE); - - achievement.percentComplete = progress; - achievement.showsCompletionBanner = NO; - if (p_params.has("show_completion_banner")) { - achievement.showsCompletionBanner = p_params["show_completion_banner"] ? YES : NO; - } - - [GKAchievement reportAchievements:@[ achievement ] - withCompletionHandler:^(NSError *error) { - Dictionary ret; - ret["type"] = "award_achievement"; - if (error == nil) { - ret["result"] = "ok"; - } else { - ret["result"] = "error"; - ret["error_code"] = (int64_t)error.code; - }; - - pending_events.push_back(ret); - }]; - - return OK; -}; - -void GameCenter::request_achievement_descriptions() { - [GKAchievementDescription loadAchievementDescriptionsWithCompletionHandler:^(NSArray *descriptions, NSError *error) { - Dictionary ret; - ret["type"] = "achievement_descriptions"; - if (error == nil) { - ret["result"] = "ok"; - PackedStringArray names; - PackedStringArray titles; - PackedStringArray unachieved_descriptions; - PackedStringArray achieved_descriptions; - PackedInt32Array maximum_points; - Array hidden; - Array replayable; - - for (NSUInteger i = 0; i < [descriptions count]; i++) { - GKAchievementDescription *description = [descriptions objectAtIndex:i]; - - const char *str = [description.identifier UTF8String]; - names.push_back(String::utf8(str != NULL ? str : "")); - - str = [description.title UTF8String]; - titles.push_back(String::utf8(str != NULL ? str : "")); - - str = [description.unachievedDescription UTF8String]; - unachieved_descriptions.push_back(String::utf8(str != NULL ? str : "")); - - str = [description.achievedDescription UTF8String]; - achieved_descriptions.push_back(String::utf8(str != NULL ? str : "")); - - maximum_points.push_back(description.maximumPoints); - - hidden.push_back(description.hidden == YES); - - replayable.push_back(description.replayable == YES); - } - - ret["names"] = names; - ret["titles"] = titles; - ret["unachieved_descriptions"] = unachieved_descriptions; - ret["achieved_descriptions"] = achieved_descriptions; - ret["maximum_points"] = maximum_points; - ret["hidden"] = hidden; - ret["replayable"] = replayable; - - } else { - ret["result"] = "error"; - ret["error_code"] = (int64_t)error.code; - }; - - pending_events.push_back(ret); - }]; -}; - -void GameCenter::request_achievements() { - [GKAchievement loadAchievementsWithCompletionHandler:^(NSArray *achievements, NSError *error) { - Dictionary ret; - ret["type"] = "achievements"; - if (error == nil) { - ret["result"] = "ok"; - PackedStringArray names; - PackedFloat32Array percentages; - - for (NSUInteger i = 0; i < [achievements count]; i++) { - GKAchievement *achievement = [achievements objectAtIndex:i]; - const char *str = [achievement.identifier UTF8String]; - names.push_back(String::utf8(str != NULL ? str : "")); - - percentages.push_back(achievement.percentComplete); - } - - ret["names"] = names; - ret["progress"] = percentages; - - } else { - ret["result"] = "error"; - ret["error_code"] = (int64_t)error.code; - }; - - pending_events.push_back(ret); - }]; -}; - -void GameCenter::reset_achievements() { - [GKAchievement resetAchievementsWithCompletionHandler:^(NSError *error) { - Dictionary ret; - ret["type"] = "reset_achievements"; - if (error == nil) { - ret["result"] = "ok"; - } else { - ret["result"] = "error"; - ret["error_code"] = (int64_t)error.code; - }; - - pending_events.push_back(ret); - }]; -}; - -Error GameCenter::show_game_center(Dictionary p_params) { - ERR_FAIL_COND_V(!NSProtocolFromString(@"GKGameCenterControllerDelegate"), FAILED); - - GKGameCenterViewControllerState view_state = GKGameCenterViewControllerStateDefault; - if (p_params.has("view")) { - String view_name = p_params["view"]; - if (view_name == "default") { - view_state = GKGameCenterViewControllerStateDefault; - } else if (view_name == "leaderboards") { - view_state = GKGameCenterViewControllerStateLeaderboards; - } else if (view_name == "achievements") { - view_state = GKGameCenterViewControllerStateAchievements; - } else if (view_name == "challenges") { - view_state = GKGameCenterViewControllerStateChallenges; - } else { - return ERR_INVALID_PARAMETER; - } - } - - GKGameCenterViewController *controller = [[GKGameCenterViewController alloc] init]; - ERR_FAIL_COND_V(!controller, FAILED); - - UIViewController *root_controller = [[UIApplication sharedApplication] delegate].window.rootViewController; - ERR_FAIL_COND_V(!root_controller, FAILED); - - controller.gameCenterDelegate = gameCenterDelegate; - controller.viewState = view_state; - if (view_state == GKGameCenterViewControllerStateLeaderboards) { - controller.leaderboardIdentifier = nil; - if (p_params.has("leaderboard_name")) { - String name = p_params["leaderboard_name"]; - NSString *name_str = [[NSString alloc] initWithUTF8String:name.utf8().get_data()]; - controller.leaderboardIdentifier = name_str; - } - } - - [root_controller presentViewController:controller animated:YES completion:nil]; - - return OK; -}; - -Error GameCenter::request_identity_verification_signature() { - ERR_FAIL_COND_V(!is_authenticated(), ERR_UNAUTHORIZED); - - GKLocalPlayer *player = [GKLocalPlayer localPlayer]; - [player generateIdentityVerificationSignatureWithCompletionHandler:^(NSURL *publicKeyUrl, NSData *signature, NSData *salt, uint64_t timestamp, NSError *error) { - Dictionary ret; - ret["type"] = "identity_verification_signature"; - if (error == nil) { - ret["result"] = "ok"; - ret["public_key_url"] = [publicKeyUrl.absoluteString UTF8String]; - ret["signature"] = [[signature base64EncodedStringWithOptions:0] UTF8String]; - ret["salt"] = [[salt base64EncodedStringWithOptions:0] UTF8String]; - ret["timestamp"] = timestamp; - if (@available(iOS 13, *)) { - ret["player_id"] = [player.teamPlayerID UTF8String]; -#if !defined(TARGET_OS_SIMULATOR) || !TARGET_OS_SIMULATOR - } else { - ret["player_id"] = [player.playerID UTF8String]; -#endif - } - } else { - ret["result"] = "error"; - ret["error_code"] = (int64_t)error.code; - ret["error_description"] = [error.localizedDescription UTF8String]; - }; - - pending_events.push_back(ret); - }]; - - return OK; -}; - -void GameCenter::game_center_closed() { - Dictionary ret; - ret["type"] = "show_game_center"; - ret["result"] = "ok"; - pending_events.push_back(ret); -} - -int GameCenter::get_pending_event_count() { - return pending_events.size(); -}; - -Variant GameCenter::pop_pending_event() { - Variant front = pending_events.front()->get(); - pending_events.pop_front(); - - return front; -}; - -GameCenter *GameCenter::get_singleton() { - return instance; -}; - -GameCenter::GameCenter() { - ERR_FAIL_COND(instance != NULL); - instance = this; - authenticated = false; - - gameCenterDelegate = [[GodotGameCenterDelegate alloc] init]; -}; - -GameCenter::~GameCenter() { - if (gameCenterDelegate) { - gameCenterDelegate = nil; - } -} diff --git a/modules/gamecenter/game_center_delegate.h b/modules/gamecenter/game_center_delegate.h deleted file mode 100644 index 1b7025f915..0000000000 --- a/modules/gamecenter/game_center_delegate.h +++ /dev/null @@ -1,35 +0,0 @@ -/*************************************************************************/ -/* game_center_delegate.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#import <GameKit/GameKit.h> - -@interface GodotGameCenterDelegate : NSObject <GKGameCenterControllerDelegate> - -@end diff --git a/modules/gamecenter/game_center_delegate.mm b/modules/gamecenter/game_center_delegate.mm deleted file mode 100644 index 9a10c439c6..0000000000 --- a/modules/gamecenter/game_center_delegate.mm +++ /dev/null @@ -1,45 +0,0 @@ -/*************************************************************************/ -/* game_center_delegate.mm */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#import "game_center_delegate.h" - -#include "game_center.h" - -@implementation GodotGameCenterDelegate - -- (void)gameCenterViewControllerDidFinish:(GKGameCenterViewController *)gameCenterViewController { - //[gameCenterViewController dismissViewControllerAnimated:YES completion:^{GameCenter::get_singleton()->game_center_closed();}];//version for signaling when overlay is completely gone - if (GameCenter::get_singleton()) { - GameCenter::get_singleton()->game_center_closed(); - } - [gameCenterViewController dismissViewControllerAnimated:YES completion:nil]; -} - -@end diff --git a/modules/gamecenter/game_center_module.h b/modules/gamecenter/game_center_module.h deleted file mode 100644 index 8da3ae02ee..0000000000 --- a/modules/gamecenter/game_center_module.h +++ /dev/null @@ -1,32 +0,0 @@ -/*************************************************************************/ -/* game_center_module.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -void register_gamecenter_types(); -void unregister_gamecenter_types(); diff --git a/modules/gamecenter/gamecenter.gdip b/modules/gamecenter/gamecenter.gdip deleted file mode 100644 index eb44effbdd..0000000000 --- a/modules/gamecenter/gamecenter.gdip +++ /dev/null @@ -1,17 +0,0 @@ -[config] -name="GameCenter" -binary="gamecenter_lib.a" - -initialization="register_gamecenter_types" -deinitialization="unregister_gamecenter_types" - -[dependencies] -linked=[] -embedded=[] -system=["GameKit.framework"] - -capabilities=["gamekit"] - -files=[] - -[plist] diff --git a/modules/gdnative/android/android_gdn.cpp b/modules/gdnative/android/android_gdn.cpp index bc39be1813..fe3b3e7e12 100644 --- a/modules/gdnative/android/android_gdn.cpp +++ b/modules/gdnative/android/android_gdn.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -48,7 +48,7 @@ extern "C" { JNIEnv *GDAPI godot_android_get_env() { #ifdef __ANDROID__ - return ThreadAndroid::get_env(); + return get_jni_env(); #else return nullptr; #endif diff --git a/modules/gdnative/gdnative.cpp b/modules/gdnative/gdnative.cpp index f397ee96c5..86bd8b820d 100644 --- a/modules/gdnative/gdnative.cpp +++ b/modules/gdnative/gdnative.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -110,6 +110,16 @@ bool GDNativeLibrary::_get(const StringName &p_name, Variant &r_property) const return false; } +void GDNativeLibrary::reset_state() { + config_file.instance(); + current_library_path = ""; + current_dependencies.clear(); + symbol_prefix = default_symbol_prefix; + load_once = default_load_once; + singleton = default_singleton; + reloadable = default_reloadable; +} + void GDNativeLibrary::_get_property_list(List<PropertyInfo> *p_list) const { // set entries List<String> entry_key_list; @@ -286,7 +296,7 @@ bool GDNative::initialize() { } String lib_path = library->get_current_library_path(); - if (lib_path.empty()) { + if (lib_path.is_empty()) { ERR_PRINT("No library set for this platform"); return false; } @@ -508,7 +518,7 @@ Error GDNative::get_symbol(StringName p_procedure_name, void *&r_handle, bool p_ return result; } -RES GDNativeLibraryResourceLoader::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, bool p_no_cache) { +RES GDNativeLibraryResourceLoader::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, CacheMode p_cache_mode) { Ref<GDNativeLibrary> lib; lib.instance(); diff --git a/modules/gdnative/gdnative.h b/modules/gdnative/gdnative.h index bba2c04a2a..a28c58ec0d 100644 --- a/modules/gdnative/gdnative.h +++ b/modules/gdnative/gdnative.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -63,6 +63,8 @@ class GDNativeLibrary : public Resource { bool reloadable; public: + virtual void reset_state() override; + GDNativeLibrary(); ~GDNativeLibrary(); @@ -166,7 +168,7 @@ public: class GDNativeLibraryResourceLoader : public ResourceFormatLoader { public: - virtual RES load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads = false, float *r_progress = nullptr, bool p_no_cache = false); + virtual RES load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads = false, float *r_progress = nullptr, CacheMode p_cache_mode = CACHE_MODE_REUSE); virtual void get_recognized_extensions(List<String> *p_extensions) const; virtual bool handles_type(const String &p_type) const; virtual String get_resource_type(const String &p_path) const; diff --git a/modules/gdnative/gdnative/aabb.cpp b/modules/gdnative/gdnative/aabb.cpp index dc1b79b9e5..5d3f224adc 100644 --- a/modules/gdnative/gdnative/aabb.cpp +++ b/modules/gdnative/gdnative/aabb.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -31,195 +31,15 @@ #include "gdnative/aabb.h" #include "core/math/aabb.h" -#include "core/variant/variant.h" + +static_assert(sizeof(godot_aabb) == sizeof(AABB), "AABB size mismatch"); #ifdef __cplusplus extern "C" { #endif -static_assert(sizeof(godot_aabb) == sizeof(AABB), "AABB size mismatch"); - -void GDAPI godot_aabb_new(godot_aabb *r_dest, const godot_vector3 *p_pos, const godot_vector3 *p_size) { - const Vector3 *pos = (const Vector3 *)p_pos; - const Vector3 *size = (const Vector3 *)p_size; - AABB *dest = (AABB *)r_dest; - *dest = AABB(*pos, *size); -} - -godot_vector3 GDAPI godot_aabb_get_position(const godot_aabb *p_self) { - godot_vector3 raw_ret; - const AABB *self = (const AABB *)p_self; - Vector3 *ret = (Vector3 *)&raw_ret; - *ret = self->position; - return raw_ret; -} - -void GDAPI godot_aabb_set_position(const godot_aabb *p_self, const godot_vector3 *p_v) { - AABB *self = (AABB *)p_self; - const Vector3 *v = (const Vector3 *)p_v; - self->position = *v; -} - -godot_vector3 GDAPI godot_aabb_get_size(const godot_aabb *p_self) { - godot_vector3 raw_ret; - const AABB *self = (const AABB *)p_self; - Vector3 *ret = (Vector3 *)&raw_ret; - *ret = self->size; - return raw_ret; -} - -void GDAPI godot_aabb_set_size(const godot_aabb *p_self, const godot_vector3 *p_v) { - AABB *self = (AABB *)p_self; - const Vector3 *v = (const Vector3 *)p_v; - self->size = *v; -} - -godot_string GDAPI godot_aabb_as_string(const godot_aabb *p_self) { - godot_string ret; - const AABB *self = (const AABB *)p_self; - memnew_placement(&ret, String(*self)); - return ret; -} - -godot_aabb GDAPI godot_aabb_abs(const godot_aabb *p_self) { - godot_aabb dest; - const AABB *self = (const AABB *)p_self; - *((AABB *)&dest) = self->abs(); - return dest; -} - -godot_real GDAPI godot_aabb_get_area(const godot_aabb *p_self) { - const AABB *self = (const AABB *)p_self; - return self->get_area(); -} - -godot_bool GDAPI godot_aabb_has_no_area(const godot_aabb *p_self) { - const AABB *self = (const AABB *)p_self; - return self->has_no_area(); -} - -godot_bool GDAPI godot_aabb_has_no_surface(const godot_aabb *p_self) { - const AABB *self = (const AABB *)p_self; - return self->has_no_surface(); -} - -godot_bool GDAPI godot_aabb_intersects(const godot_aabb *p_self, const godot_aabb *p_with) { - const AABB *self = (const AABB *)p_self; - const AABB *with = (const AABB *)p_with; - return self->intersects(*with); -} - -godot_bool GDAPI godot_aabb_encloses(const godot_aabb *p_self, const godot_aabb *p_with) { - const AABB *self = (const AABB *)p_self; - const AABB *with = (const AABB *)p_with; - return self->encloses(*with); -} - -godot_aabb GDAPI godot_aabb_merge(const godot_aabb *p_self, const godot_aabb *p_with) { - godot_aabb dest; - const AABB *self = (const AABB *)p_self; - const AABB *with = (const AABB *)p_with; - *((AABB *)&dest) = self->merge(*with); - return dest; -} - -godot_aabb GDAPI godot_aabb_intersection(const godot_aabb *p_self, const godot_aabb *p_with) { - godot_aabb dest; - const AABB *self = (const AABB *)p_self; - const AABB *with = (const AABB *)p_with; - *((AABB *)&dest) = self->intersection(*with); - return dest; -} - -godot_bool GDAPI godot_aabb_intersects_plane(const godot_aabb *p_self, const godot_plane *p_plane) { - const AABB *self = (const AABB *)p_self; - const Plane *plane = (const Plane *)p_plane; - return self->intersects_plane(*plane); -} - -godot_bool GDAPI godot_aabb_intersects_segment(const godot_aabb *p_self, const godot_vector3 *p_from, const godot_vector3 *p_to) { - const AABB *self = (const AABB *)p_self; - const Vector3 *from = (const Vector3 *)p_from; - const Vector3 *to = (const Vector3 *)p_to; - return self->intersects_segment(*from, *to); -} - -godot_bool GDAPI godot_aabb_has_point(const godot_aabb *p_self, const godot_vector3 *p_point) { - const AABB *self = (const AABB *)p_self; - const Vector3 *point = (const Vector3 *)p_point; - return self->has_point(*point); -} - -godot_vector3 GDAPI godot_aabb_get_support(const godot_aabb *p_self, const godot_vector3 *p_dir) { - godot_vector3 dest; - const AABB *self = (const AABB *)p_self; - const Vector3 *dir = (const Vector3 *)p_dir; - *((Vector3 *)&dest) = self->get_support(*dir); - return dest; -} - -godot_vector3 GDAPI godot_aabb_get_longest_axis(const godot_aabb *p_self) { - godot_vector3 dest; - const AABB *self = (const AABB *)p_self; - *((Vector3 *)&dest) = self->get_longest_axis(); - return dest; -} - -godot_int GDAPI godot_aabb_get_longest_axis_index(const godot_aabb *p_self) { - const AABB *self = (const AABB *)p_self; - return self->get_longest_axis_index(); -} - -godot_real GDAPI godot_aabb_get_longest_axis_size(const godot_aabb *p_self) { - const AABB *self = (const AABB *)p_self; - return self->get_longest_axis_size(); -} - -godot_vector3 GDAPI godot_aabb_get_shortest_axis(const godot_aabb *p_self) { - godot_vector3 dest; - const AABB *self = (const AABB *)p_self; - *((Vector3 *)&dest) = self->get_shortest_axis(); - return dest; -} - -godot_int GDAPI godot_aabb_get_shortest_axis_index(const godot_aabb *p_self) { - const AABB *self = (const AABB *)p_self; - return self->get_shortest_axis_index(); -} - -godot_real GDAPI godot_aabb_get_shortest_axis_size(const godot_aabb *p_self) { - const AABB *self = (const AABB *)p_self; - return self->get_shortest_axis_size(); -} - -godot_aabb GDAPI godot_aabb_expand(const godot_aabb *p_self, const godot_vector3 *p_to_point) { - godot_aabb dest; - const AABB *self = (const AABB *)p_self; - const Vector3 *to_point = (const Vector3 *)p_to_point; - *((AABB *)&dest) = self->expand(*to_point); - return dest; -} - -godot_aabb GDAPI godot_aabb_grow(const godot_aabb *p_self, const godot_real p_by) { - godot_aabb dest; - const AABB *self = (const AABB *)p_self; - - *((AABB *)&dest) = self->grow(p_by); - return dest; -} - -godot_vector3 GDAPI godot_aabb_get_endpoint(const godot_aabb *p_self, const godot_int p_idx) { - godot_vector3 dest; - const AABB *self = (const AABB *)p_self; - - *((Vector3 *)&dest) = self->get_endpoint(p_idx); - return dest; -} - -godot_bool GDAPI godot_aabb_operator_equal(const godot_aabb *p_self, const godot_aabb *p_b) { - const AABB *self = (const AABB *)p_self; - const AABB *b = (const AABB *)p_b; - return *self == *b; +void GDAPI godot_aabb_new(godot_aabb *p_self) { + memnew_placement(p_self, AABB); } #ifdef __cplusplus diff --git a/modules/gdnative/gdnative/array.cpp b/modules/gdnative/gdnative/array.cpp index 863889acbc..e68b60c5e6 100644 --- a/modules/gdnative/gdnative/array.cpp +++ b/modules/gdnative/gdnative/array.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -33,367 +33,28 @@ #include "core/os/memory.h" #include "core/variant/array.h" -#include "core/math/color.h" - -#include "core/variant/variant.h" +static_assert(sizeof(godot_array) == sizeof(Array), "Array size mismatch"); #ifdef __cplusplus extern "C" { #endif -static_assert(sizeof(godot_array) == sizeof(Array), "Array size mismatch"); - -void GDAPI godot_array_new(godot_array *r_dest) { - Array *dest = (Array *)r_dest; - memnew_placement(dest, Array); -} - -void GDAPI godot_array_new_copy(godot_array *r_dest, const godot_array *p_src) { - Array *dest = (Array *)r_dest; - const Array *src = (const Array *)p_src; - memnew_placement(dest, Array(*src)); -} - -void GDAPI godot_array_new_packed_color_array(godot_array *r_dest, const godot_packed_color_array *p_pca) { - Array *dest = (Array *)r_dest; - Vector<Color> *pca = (Vector<Color> *)p_pca; - memnew_placement(dest, Array); - dest->resize(pca->size()); - - for (int i = 0; i < dest->size(); i++) { - Variant v = pca->operator[](i); - dest->operator[](i) = v; - } -} - -void GDAPI godot_array_new_packed_vector3_array(godot_array *r_dest, const godot_packed_vector3_array *p_pv3a) { - Array *dest = (Array *)r_dest; - Vector<Vector3> *pca = (Vector<Vector3> *)p_pv3a; - memnew_placement(dest, Array); - dest->resize(pca->size()); - - for (int i = 0; i < dest->size(); i++) { - Variant v = pca->operator[](i); - dest->operator[](i) = v; - } -} - -void GDAPI godot_array_new_packed_vector2_array(godot_array *r_dest, const godot_packed_vector2_array *p_pv2a) { - Array *dest = (Array *)r_dest; - Vector<Vector2> *pca = (Vector<Vector2> *)p_pv2a; - memnew_placement(dest, Array); - dest->resize(pca->size()); - - for (int i = 0; i < dest->size(); i++) { - Variant v = pca->operator[](i); - dest->operator[](i) = v; - } -} - -void GDAPI godot_array_new_packed_vector2i_array(godot_array *r_dest, const godot_packed_vector2i_array *p_pv2a) { - Array *dest = (Array *)r_dest; - Vector<Vector2i> *pca = (Vector<Vector2i> *)p_pv2a; - memnew_placement(dest, Array); - dest->resize(pca->size()); - - for (int i = 0; i < dest->size(); i++) { - Variant v = pca->operator[](i); - dest->operator[](i) = v; - } -} - -void GDAPI godot_array_new_packed_string_array(godot_array *r_dest, const godot_packed_string_array *p_psa) { - Array *dest = (Array *)r_dest; - Vector<String> *pca = (Vector<String> *)p_psa; - memnew_placement(dest, Array); - dest->resize(pca->size()); - - for (int i = 0; i < dest->size(); i++) { - Variant v = pca->operator[](i); - dest->operator[](i) = v; - } -} - -void GDAPI godot_array_new_packed_float32_array(godot_array *r_dest, const godot_packed_float32_array *p_pra) { - Array *dest = (Array *)r_dest; - Vector<float> *pca = (Vector<float> *)p_pra; - memnew_placement(dest, Array); - dest->resize(pca->size()); - - for (int i = 0; i < dest->size(); i++) { - Variant v = pca->operator[](i); - dest->operator[](i) = v; - } -} - -void GDAPI godot_array_new_packed_float64_array(godot_array *r_dest, const godot_packed_float64_array *p_pra) { - Array *dest = (Array *)r_dest; - Vector<double> *pca = (Vector<double> *)p_pra; - memnew_placement(dest, Array); - dest->resize(pca->size()); - - for (int i = 0; i < dest->size(); i++) { - Variant v = pca->operator[](i); - dest->operator[](i) = v; - } -} - -void GDAPI godot_array_new_packed_int32_array(godot_array *r_dest, const godot_packed_int32_array *p_pia) { - Array *dest = (Array *)r_dest; - Vector<int32_t> *pca = (Vector<int32_t> *)p_pia; - memnew_placement(dest, Array); - dest->resize(pca->size()); - - for (int i = 0; i < dest->size(); i++) { - Variant v = pca->operator[](i); - dest->operator[](i) = v; - } -} - -void GDAPI godot_array_new_packed_int64_array(godot_array *r_dest, const godot_packed_int64_array *p_pia) { - Array *dest = (Array *)r_dest; - Vector<int64_t> *pca = (Vector<int64_t> *)p_pia; - memnew_placement(dest, Array); - dest->resize(pca->size()); - - for (int i = 0; i < dest->size(); i++) { - Variant v = pca->operator[](i); - dest->operator[](i) = v; - } -} - -void GDAPI godot_array_new_packed_byte_array(godot_array *r_dest, const godot_packed_byte_array *p_pba) { - Array *dest = (Array *)r_dest; - Vector<uint8_t> *pca = (Vector<uint8_t> *)p_pba; - memnew_placement(dest, Array); - dest->resize(pca->size()); - - for (int i = 0; i < dest->size(); i++) { - Variant v = pca->operator[](i); - dest->operator[](i) = v; - } -} - -void GDAPI godot_array_set(godot_array *p_self, const godot_int p_idx, const godot_variant *p_value) { - Array *self = (Array *)p_self; - Variant *val = (Variant *)p_value; - self->operator[](p_idx) = *val; -} - -godot_variant GDAPI godot_array_get(const godot_array *p_self, const godot_int p_idx) { - godot_variant raw_dest; - Variant *dest = (Variant *)&raw_dest; - const Array *self = (const Array *)p_self; - memnew_placement(dest, Variant(self->operator[](p_idx))); - return raw_dest; -} - -godot_variant GDAPI *godot_array_operator_index(godot_array *p_self, const godot_int p_idx) { - Array *self = (Array *)p_self; - return (godot_variant *)&self->operator[](p_idx); -} - -const godot_variant GDAPI *godot_array_operator_index_const(const godot_array *p_self, const godot_int p_idx) { - const Array *self = (const Array *)p_self; - return (const godot_variant *)&self->operator[](p_idx); -} - -void GDAPI godot_array_append(godot_array *p_self, const godot_variant *p_value) { - Array *self = (Array *)p_self; - Variant *val = (Variant *)p_value; - self->append(*val); -} - -void GDAPI godot_array_clear(godot_array *p_self) { - Array *self = (Array *)p_self; - self->clear(); -} - -godot_int GDAPI godot_array_count(const godot_array *p_self, const godot_variant *p_value) { - const Array *self = (const Array *)p_self; - const Variant *val = (const Variant *)p_value; - return self->count(*val); -} - -godot_bool GDAPI godot_array_empty(const godot_array *p_self) { - const Array *self = (const Array *)p_self; - return self->empty(); -} - -void GDAPI godot_array_erase(godot_array *p_self, const godot_variant *p_value) { - Array *self = (Array *)p_self; - const Variant *val = (const Variant *)p_value; - self->erase(*val); -} - -godot_variant GDAPI godot_array_front(const godot_array *p_self) { - const Array *self = (const Array *)p_self; - godot_variant v; - Variant *val = (Variant *)&v; - memnew_placement(val, Variant); - *val = self->front(); - return v; -} - -godot_variant GDAPI godot_array_back(const godot_array *p_self) { - const Array *self = (const Array *)p_self; - godot_variant v; - Variant *val = (Variant *)&v; - memnew_placement(val, Variant); - *val = self->back(); - return v; -} - -godot_int GDAPI godot_array_find(const godot_array *p_self, const godot_variant *p_what, const godot_int p_from) { - const Array *self = (const Array *)p_self; - const Variant *val = (const Variant *)p_what; - return self->find(*val, p_from); -} - -godot_int GDAPI godot_array_find_last(const godot_array *p_self, const godot_variant *p_what) { - const Array *self = (const Array *)p_self; - const Variant *val = (const Variant *)p_what; - return self->find_last(*val); -} - -godot_bool GDAPI godot_array_has(const godot_array *p_self, const godot_variant *p_value) { - const Array *self = (const Array *)p_self; - const Variant *val = (const Variant *)p_value; - return self->has(*val); -} - -godot_int GDAPI godot_array_hash(const godot_array *p_self) { - const Array *self = (const Array *)p_self; - return self->hash(); -} - -void GDAPI godot_array_insert(godot_array *p_self, const godot_int p_pos, const godot_variant *p_value) { - Array *self = (Array *)p_self; - const Variant *val = (const Variant *)p_value; - self->insert(p_pos, *val); -} - -void GDAPI godot_array_invert(godot_array *p_self) { - Array *self = (Array *)p_self; - self->invert(); -} - -godot_variant GDAPI godot_array_pop_back(godot_array *p_self) { - Array *self = (Array *)p_self; - godot_variant v; - Variant *val = (Variant *)&v; - memnew_placement(val, Variant); - *val = self->pop_back(); - return v; -} - -godot_variant GDAPI godot_array_pop_front(godot_array *p_self) { - Array *self = (Array *)p_self; - godot_variant v; - Variant *val = (Variant *)&v; - memnew_placement(val, Variant); - *val = self->pop_front(); - return v; -} - -void GDAPI godot_array_push_back(godot_array *p_self, const godot_variant *p_value) { - Array *self = (Array *)p_self; - const Variant *val = (const Variant *)p_value; - self->push_back(*val); -} - -void GDAPI godot_array_push_front(godot_array *p_self, const godot_variant *p_value) { - Array *self = (Array *)p_self; - const Variant *val = (const Variant *)p_value; - self->push_front(*val); -} - -void GDAPI godot_array_remove(godot_array *p_self, const godot_int p_idx) { - Array *self = (Array *)p_self; - self->remove(p_idx); -} - -void GDAPI godot_array_resize(godot_array *p_self, const godot_int p_size) { - Array *self = (Array *)p_self; - self->resize(p_size); -} - -godot_int GDAPI godot_array_rfind(const godot_array *p_self, const godot_variant *p_what, const godot_int p_from) { - const Array *self = (const Array *)p_self; - const Variant *val = (const Variant *)p_what; - return self->rfind(*val, p_from); -} - -godot_int GDAPI godot_array_size(const godot_array *p_self) { - const Array *self = (const Array *)p_self; - return self->size(); -} - -void GDAPI godot_array_sort(godot_array *p_self) { - Array *self = (Array *)p_self; - self->sort(); -} - -void GDAPI godot_array_sort_custom(godot_array *p_self, godot_object *p_obj, const godot_string *p_func) { - Array *self = (Array *)p_self; - const String *func = (const String *)p_func; - self->sort_custom((Object *)p_obj, *func); -} - -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); -} - -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); +void GDAPI godot_array_new(godot_array *p_self) { + memnew_placement(p_self, Array); } void GDAPI godot_array_destroy(godot_array *p_self) { ((Array *)p_self)->~Array(); } -godot_array GDAPI godot_array_duplicate(const godot_array *p_self, const godot_bool p_deep) { - const Array *self = (const Array *)p_self; - godot_array res; - Array *val = (Array *)&res; - memnew_placement(val, Array); - *val = self->duplicate(p_deep); - return res; -} - -godot_array GDAPI godot_array_slice(const godot_array *p_self, const godot_int p_begin, const godot_int p_end, const godot_int p_step, const godot_bool p_deep) { - const Array *self = (const Array *)p_self; - godot_array res; - Array *val = (Array *)&res; - memnew_placement(val, Array); - *val = self->slice(p_begin, p_end, p_step, p_deep); - return res; -} - -godot_variant GDAPI godot_array_max(const godot_array *p_self) { - const Array *self = (const Array *)p_self; - godot_variant v; - Variant *val = (Variant *)&v; - memnew_placement(val, Variant); - *val = self->max(); - return v; +godot_variant GDAPI *godot_array_operator_index(godot_array *p_self, godot_int p_index) { + Array *self = (Array *)p_self; + return (godot_variant *)&self->operator[](p_index); } -godot_variant GDAPI godot_array_min(const godot_array *p_self) { +const godot_variant GDAPI *godot_array_operator_index_const(const godot_array *p_self, godot_int p_index) { const Array *self = (const Array *)p_self; - godot_variant v; - Variant *val = (Variant *)&v; - memnew_placement(val, Variant); - *val = self->min(); - return v; -} - -void GDAPI godot_array_shuffle(godot_array *p_self) { - Array *self = (Array *)p_self; - self->shuffle(); + return (const godot_variant *)&self->operator[](p_index); } #ifdef __cplusplus diff --git a/modules/gdnative/gdnative/basis.cpp b/modules/gdnative/gdnative/basis.cpp index e5891562a1..df3e1255ac 100644 --- a/modules/gdnative/gdnative/basis.cpp +++ b/modules/gdnative/gdnative/basis.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -31,266 +31,25 @@ #include "gdnative/basis.h" #include "core/math/basis.h" -#include "core/variant/variant.h" + +static_assert(sizeof(godot_basis) == sizeof(Basis), "Basis size mismatch"); #ifdef __cplusplus extern "C" { #endif -static_assert(sizeof(godot_basis) == sizeof(Basis), "Basis size mismatch"); - -void GDAPI godot_basis_new_with_rows(godot_basis *r_dest, const godot_vector3 *p_x_axis, const godot_vector3 *p_y_axis, const godot_vector3 *p_z_axis) { - const Vector3 *x_axis = (const Vector3 *)p_x_axis; - const Vector3 *y_axis = (const Vector3 *)p_y_axis; - const Vector3 *z_axis = (const Vector3 *)p_z_axis; - Basis *dest = (Basis *)r_dest; - *dest = Basis(*x_axis, *y_axis, *z_axis); -} - -void GDAPI godot_basis_new_with_axis_and_angle(godot_basis *r_dest, const godot_vector3 *p_axis, const godot_real p_phi) { - const Vector3 *axis = (const Vector3 *)p_axis; - Basis *dest = (Basis *)r_dest; - *dest = Basis(*axis, p_phi); -} - -void GDAPI godot_basis_new_with_euler(godot_basis *r_dest, const godot_vector3 *p_euler) { - const Vector3 *euler = (const Vector3 *)p_euler; - Basis *dest = (Basis *)r_dest; - *dest = Basis(*euler); -} - -godot_string GDAPI godot_basis_as_string(const godot_basis *p_self) { - godot_string ret; - const Basis *self = (const Basis *)p_self; - memnew_placement(&ret, String(*self)); - return ret; -} - -godot_basis GDAPI godot_basis_inverse(const godot_basis *p_self) { - godot_basis dest; - const Basis *self = (const Basis *)p_self; - *((Basis *)&dest) = self->inverse(); - return dest; -} - -godot_basis GDAPI godot_basis_transposed(const godot_basis *p_self) { - godot_basis dest; - const Basis *self = (const Basis *)p_self; - *((Basis *)&dest) = self->transposed(); - return dest; -} - -godot_basis GDAPI godot_basis_orthonormalized(const godot_basis *p_self) { - godot_basis dest; - const Basis *self = (const Basis *)p_self; - *((Basis *)&dest) = self->orthonormalized(); - return dest; -} - -godot_real GDAPI godot_basis_determinant(const godot_basis *p_self) { - const Basis *self = (const Basis *)p_self; - return self->determinant(); -} - -godot_basis GDAPI godot_basis_rotated(const godot_basis *p_self, const godot_vector3 *p_axis, const godot_real p_phi) { - godot_basis dest; - const Basis *self = (const Basis *)p_self; - const Vector3 *axis = (const Vector3 *)p_axis; - *((Basis *)&dest) = self->rotated(*axis, p_phi); - return dest; -} - -godot_basis GDAPI godot_basis_scaled(const godot_basis *p_self, const godot_vector3 *p_scale) { - godot_basis dest; - const Basis *self = (const Basis *)p_self; - const Vector3 *scale = (const Vector3 *)p_scale; - *((Basis *)&dest) = self->scaled(*scale); - return dest; -} - -godot_vector3 GDAPI godot_basis_get_scale(const godot_basis *p_self) { - godot_vector3 dest; - const Basis *self = (const Basis *)p_self; - *((Vector3 *)&dest) = self->get_scale(); - return dest; -} - -godot_quat GDAPI godot_basis_get_quat(const godot_basis *p_self) { - godot_quat dest; - const Basis *self = (const Basis *)p_self; - *((Quat *)&dest) = self->get_quat(); - return dest; -} - -void GDAPI godot_basis_set_quat(godot_basis *p_self, const godot_quat *p_quat) { - Basis *self = (Basis *)p_self; - const Quat *quat = (const Quat *)p_quat; - self->set_quat(*quat); +void GDAPI godot_basis_new(godot_basis *p_self) { + memnew_placement(p_self, Basis); } -void GDAPI godot_basis_set_axis_angle_scale(godot_basis *p_self, const godot_vector3 *p_axis, godot_real p_phi, const godot_vector3 *p_scale) { +godot_vector3 GDAPI *godot_basis_operator_index(godot_basis *p_self, godot_int p_index) { Basis *self = (Basis *)p_self; - const Vector3 *axis = (const Vector3 *)p_axis; - const Vector3 *scale = (const Vector3 *)p_scale; - self->set_axis_angle_scale(*axis, p_phi, *scale); -} - -void GDAPI godot_basis_set_euler_scale(godot_basis *p_self, const godot_vector3 *p_euler, const godot_vector3 *p_scale) { - Basis *self = (Basis *)p_self; - const Vector3 *euler = (const Vector3 *)p_euler; - const Vector3 *scale = (const Vector3 *)p_scale; - self->set_euler_scale(*euler, *scale); -} - -void GDAPI godot_basis_set_quat_scale(godot_basis *p_self, const godot_quat *p_quat, const godot_vector3 *p_scale) { - Basis *self = (Basis *)p_self; - const Quat *quat = (const Quat *)p_quat; - const Vector3 *scale = (const Vector3 *)p_scale; - self->set_quat_scale(*quat, *scale); -} - -godot_vector3 GDAPI godot_basis_get_euler(const godot_basis *p_self) { - godot_vector3 dest; - const Basis *self = (const Basis *)p_self; - *((Vector3 *)&dest) = self->get_euler(); - return dest; -} - -godot_real GDAPI godot_basis_tdotx(const godot_basis *p_self, const godot_vector3 *p_with) { - const Basis *self = (const Basis *)p_self; - const Vector3 *with = (const Vector3 *)p_with; - return self->tdotx(*with); -} - -godot_real GDAPI godot_basis_tdoty(const godot_basis *p_self, const godot_vector3 *p_with) { - const Basis *self = (const Basis *)p_self; - const Vector3 *with = (const Vector3 *)p_with; - return self->tdoty(*with); -} - -godot_real GDAPI godot_basis_tdotz(const godot_basis *p_self, const godot_vector3 *p_with) { - const Basis *self = (const Basis *)p_self; - const Vector3 *with = (const Vector3 *)p_with; - return self->tdotz(*with); -} - -godot_vector3 GDAPI godot_basis_xform(const godot_basis *p_self, const godot_vector3 *p_v) { - godot_vector3 dest; - const Basis *self = (const Basis *)p_self; - const Vector3 *v = (const Vector3 *)p_v; - *((Vector3 *)&dest) = self->xform(*v); - return dest; -} - -godot_vector3 GDAPI godot_basis_xform_inv(const godot_basis *p_self, const godot_vector3 *p_v) { - godot_vector3 dest; - const Basis *self = (const Basis *)p_self; - const Vector3 *v = (const Vector3 *)p_v; - *((Vector3 *)&dest) = self->xform_inv(*v); - return dest; -} - -godot_int GDAPI godot_basis_get_orthogonal_index(const godot_basis *p_self) { - const Basis *self = (const Basis *)p_self; - return self->get_orthogonal_index(); -} - -void GDAPI godot_basis_new(godot_basis *r_dest) { - Basis *dest = (Basis *)r_dest; - *dest = Basis(); -} - -void GDAPI godot_basis_new_with_euler_quat(godot_basis *r_dest, const godot_quat *p_euler) { - Basis *dest = (Basis *)r_dest; - const Quat *euler = (const Quat *)p_euler; - *dest = Basis(*euler); -} - -// p_elements is a pointer to an array of 3 (!!) vector3 -void GDAPI godot_basis_get_elements(const godot_basis *p_self, godot_vector3 *p_elements) { - const Basis *self = (const Basis *)p_self; - Vector3 *elements = (Vector3 *)p_elements; - elements[0] = self->elements[0]; - elements[1] = self->elements[1]; - elements[2] = self->elements[2]; -} - -godot_vector3 GDAPI godot_basis_get_axis(const godot_basis *p_self, const godot_int p_axis) { - godot_vector3 dest; - Vector3 *d = (Vector3 *)&dest; - const Basis *self = (const Basis *)p_self; - *d = self->get_axis(p_axis); - return dest; -} - -void GDAPI godot_basis_set_axis(godot_basis *p_self, const godot_int p_axis, const godot_vector3 *p_value) { - Basis *self = (Basis *)p_self; - const Vector3 *value = (const Vector3 *)p_value; - self->set_axis(p_axis, *value); -} - -godot_vector3 GDAPI godot_basis_get_row(const godot_basis *p_self, const godot_int p_row) { - godot_vector3 dest; - Vector3 *d = (Vector3 *)&dest; - const Basis *self = (const Basis *)p_self; - *d = self->get_row(p_row); - return dest; -} - -void GDAPI godot_basis_set_row(godot_basis *p_self, const godot_int p_row, const godot_vector3 *p_value) { - Basis *self = (Basis *)p_self; - const Vector3 *value = (const Vector3 *)p_value; - self->set_row(p_row, *value); -} - -godot_bool GDAPI godot_basis_operator_equal(const godot_basis *p_self, const godot_basis *p_b) { - const Basis *self = (const Basis *)p_self; - const Basis *b = (const Basis *)p_b; - return *self == *b; -} - -godot_basis GDAPI godot_basis_operator_add(const godot_basis *p_self, const godot_basis *p_b) { - godot_basis raw_dest; - Basis *dest = (Basis *)&raw_dest; - const Basis *self = (const Basis *)p_self; - const Basis *b = (const Basis *)p_b; - *dest = *self + *b; - return raw_dest; -} - -godot_basis GDAPI godot_basis_operator_subtract(const godot_basis *p_self, const godot_basis *p_b) { - godot_basis raw_dest; - Basis *dest = (Basis *)&raw_dest; - const Basis *self = (const Basis *)p_self; - const Basis *b = (const Basis *)p_b; - *dest = *self - *b; - return raw_dest; -} - -godot_basis GDAPI godot_basis_operator_multiply_vector(const godot_basis *p_self, const godot_basis *p_b) { - godot_basis raw_dest; - Basis *dest = (Basis *)&raw_dest; - const Basis *self = (const Basis *)p_self; - const Basis *b = (const Basis *)p_b; - *dest = *self * *b; - return raw_dest; -} - -godot_basis GDAPI godot_basis_operator_multiply_scalar(const godot_basis *p_self, const godot_real p_b) { - godot_basis raw_dest; - Basis *dest = (Basis *)&raw_dest; - const Basis *self = (const Basis *)p_self; - *dest = *self * p_b; - return raw_dest; + return (godot_vector3 *)&self->operator[](p_index); } -godot_basis GDAPI godot_basis_slerp(const godot_basis *p_self, const godot_basis *p_b, const godot_real p_t) { - godot_basis raw_dest; - Basis *dest = (Basis *)&raw_dest; +const godot_vector3 GDAPI *godot_basis_operator_index_const(const godot_basis *p_self, godot_int p_index) { const Basis *self = (const Basis *)p_self; - const Basis *b = (const Basis *)p_b; - *dest = self->slerp(*b, p_t); - return raw_dest; + return (const godot_vector3 *)&self->operator[](p_index); } #ifdef __cplusplus diff --git a/modules/gdnative/gdnative/callable.cpp b/modules/gdnative/gdnative/callable.cpp index f200e9f171..7c62b5928f 100644 --- a/modules/gdnative/gdnative/callable.cpp +++ b/modules/gdnative/gdnative/callable.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -30,36 +30,17 @@ #include "gdnative/callable.h" -#include "core/io/resource.h" #include "core/variant/callable.h" #include "core/variant/variant.h" +static_assert(sizeof(godot_callable) == sizeof(Callable), "Callable size mismatch"); + #ifdef __cplusplus extern "C" { #endif -static_assert(sizeof(godot_callable) == sizeof(Callable), "Callable size mismatch"); -static_assert(sizeof(godot_signal) == sizeof(Signal), "Signal size mismatch"); - -// Callable - -void GDAPI godot_callable_new_with_object(godot_callable *r_dest, const godot_object *p_object, const godot_string_name *p_method) { - Callable *dest = (Callable *)r_dest; - const Object *object = (const Object *)p_object; - const StringName *method = (const StringName *)p_method; - memnew_placement(dest, Callable(object, *method)); -} - -void GDAPI godot_callable_new_with_object_id(godot_callable *r_dest, uint64_t p_objectid, const godot_string_name *p_method) { - Callable *dest = (Callable *)r_dest; - const StringName *method = (const StringName *)p_method; - memnew_placement(dest, Callable(ObjectID(p_objectid), *method)); -} - -void GDAPI godot_callable_new_copy(godot_callable *r_dest, const godot_callable *p_src) { - Callable *dest = (Callable *)r_dest; - const Callable *src = (const Callable *)p_src; - memnew_placement(dest, Callable(*src)); +void GDAPI godot_callable_new(godot_callable *p_self) { + memnew_placement(p_self, Callable); } void GDAPI godot_callable_destroy(godot_callable *p_self) { @@ -67,186 +48,6 @@ void GDAPI godot_callable_destroy(godot_callable *p_self) { self->~Callable(); } -godot_int GDAPI godot_callable_call(const godot_callable *p_self, const godot_variant **p_arguments, godot_int p_argcount, godot_variant *r_return_value) { - const Callable *self = (const Callable *)p_self; - const Variant **arguments = (const Variant **)p_arguments; - Variant *return_value = (Variant *)r_return_value; - Variant ret; - Callable::CallError err; - self->call(arguments, p_argcount, ret, err); - if (return_value) - (*return_value) = ret; - return (godot_int)err.error; -} - -void GDAPI godot_callable_call_deferred(const godot_callable *p_self, const godot_variant **p_arguments, godot_int p_argcount) { - const Callable *self = (const Callable *)p_self; - const Variant **arguments = (const Variant **)p_arguments; - self->call_deferred(arguments, p_argcount); -} - -godot_bool GDAPI godot_callable_is_null(const godot_callable *p_self) { - const Callable *self = (const Callable *)p_self; - return self->is_null(); -} - -godot_bool GDAPI godot_callable_is_custom(const godot_callable *p_self) { - const Callable *self = (const Callable *)p_self; - return self->is_custom(); -} - -godot_bool GDAPI godot_callable_is_standard(const godot_callable *p_self) { - const Callable *self = (const Callable *)p_self; - return self->is_standard(); -} - -godot_object GDAPI *godot_callable_get_object(const godot_callable *p_self) { - const Callable *self = (const Callable *)p_self; - return (godot_object *)self->get_object(); -} - -uint64_t GDAPI godot_callable_get_object_id(const godot_callable *p_self) { - const Callable *self = (const Callable *)p_self; - return (uint64_t)self->get_object_id(); -} - -godot_string_name GDAPI godot_callable_get_method(const godot_callable *p_self) { - godot_string_name raw_dest; - const Callable *self = (const Callable *)p_self; - StringName *dest = (StringName *)&raw_dest; - memnew_placement(dest, StringName(self->get_method())); - return raw_dest; -} - -uint32_t GDAPI godot_callable_hash(const godot_callable *p_self) { - const Callable *self = (const Callable *)p_self; - return self->hash(); -} - -godot_string GDAPI godot_callable_as_string(const godot_callable *p_self) { - godot_string ret; - const Callable *self = (const Callable *)p_self; - memnew_placement(&ret, String(*self)); - return ret; -} - -godot_bool GDAPI godot_callable_operator_equal(const godot_callable *p_self, const godot_callable *p_other) { - const Callable *self = (const Callable *)p_self; - const Callable *other = (const Callable *)p_other; - return *self == *other; -} - -godot_bool GDAPI godot_callable_operator_less(const godot_callable *p_self, const godot_callable *p_other) { - const Callable *self = (const Callable *)p_self; - const Callable *other = (const Callable *)p_other; - return *self < *other; -} - -// Signal - -void GDAPI godot_signal_new_with_object(godot_signal *r_dest, const godot_object *p_object, const godot_string_name *p_name) { - Signal *dest = (Signal *)r_dest; - const Object *object = (const Object *)p_object; - const StringName *name = (const StringName *)p_name; - memnew_placement(dest, Signal(object, *name)); -} - -void GDAPI godot_signal_new_with_object_id(godot_signal *r_dest, uint64_t p_objectid, const godot_string_name *p_name) { - Signal *dest = (Signal *)r_dest; - const StringName *name = (const StringName *)p_name; - memnew_placement(dest, Signal(ObjectID(p_objectid), *name)); -} - -void GDAPI godot_signal_new_copy(godot_signal *r_dest, const godot_signal *p_src) { - Signal *dest = (Signal *)r_dest; - const Signal *src = (const Signal *)p_src; - memnew_placement(dest, Signal(*src)); -} - -void GDAPI godot_signal_destroy(godot_signal *p_self) { - Signal *self = (Signal *)p_self; - self->~Signal(); -} - -godot_int GDAPI godot_signal_emit(const godot_signal *p_self, const godot_variant **p_arguments, godot_int p_argcount) { - const Signal *self = (const Signal *)p_self; - const Variant **arguments = (const Variant **)p_arguments; - return (godot_int)self->emit(arguments, p_argcount); -} - -godot_int GDAPI godot_signal_connect(godot_signal *p_self, const godot_callable *p_callable, const godot_array *p_binds, uint32_t p_flags) { - Signal *self = (Signal *)p_self; - const Callable *callable = (const Callable *)p_callable; - const Array *binds_ar = (const Array *)p_binds; - Vector<Variant> binds; - for (int i = 0; i < binds_ar->size(); i++) { - binds.push_back(binds_ar->get(i)); - } - return (godot_int)self->connect(*callable, binds, p_flags); -} - -void GDAPI godot_signal_disconnect(godot_signal *p_self, const godot_callable *p_callable) { - Signal *self = (Signal *)p_self; - const Callable *callable = (const Callable *)p_callable; - self->disconnect(*callable); -} - -godot_bool GDAPI godot_signal_is_null(const godot_signal *p_self) { - const Signal *self = (const Signal *)p_self; - return self->is_null(); -} - -godot_bool GDAPI godot_signal_is_connected(const godot_signal *p_self, const godot_callable *p_callable) { - const Signal *self = (const Signal *)p_self; - const Callable *callable = (const Callable *)p_callable; - return self->is_connected(*callable); -} - -godot_array GDAPI godot_signal_get_connections(const godot_signal *p_self) { - godot_array raw_dest; - const Signal *self = (const Signal *)p_self; - Array *dest = (Array *)&raw_dest; - memnew_placement(dest, Array(self->get_connections())); - return raw_dest; -} - -godot_object GDAPI *godot_signal_get_object(const godot_signal *p_self) { - const Signal *self = (const Signal *)p_self; - return (godot_object *)self->get_object(); -} - -uint64_t GDAPI godot_signal_get_object_id(const godot_signal *p_self) { - const Signal *self = (const Signal *)p_self; - return (uint64_t)self->get_object_id(); -} - -godot_string_name GDAPI godot_signal_get_name(const godot_signal *p_self) { - godot_string_name raw_dest; - const Signal *self = (const Signal *)p_self; - StringName *dest = (StringName *)&raw_dest; - memnew_placement(dest, StringName(self->get_name())); - return raw_dest; -} - -godot_string GDAPI godot_signal_as_string(const godot_signal *p_self) { - godot_string ret; - const Signal *self = (const Signal *)p_self; - memnew_placement(&ret, String(*self)); - return ret; -} - -godot_bool GDAPI godot_signal_operator_equal(const godot_signal *p_self, const godot_signal *p_other) { - const Signal *self = (const Signal *)p_self; - const Signal *other = (const Signal *)p_other; - return *self == *other; -} - -godot_bool GDAPI godot_signal_operator_less(const godot_signal *p_self, const godot_signal *p_other) { - const Signal *self = (const Signal *)p_self; - const Signal *other = (const Signal *)p_other; - return *self < *other; -} - #ifdef __cplusplus } #endif diff --git a/modules/gdnative/gdnative/color.cpp b/modules/gdnative/gdnative/color.cpp index a93181e142..12a800d333 100644 --- a/modules/gdnative/gdnative/color.cpp +++ b/modules/gdnative/gdnative/color.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -31,178 +31,25 @@ #include "gdnative/color.h" #include "core/math/color.h" -#include "core/variant/variant.h" + +static_assert(sizeof(godot_color) == sizeof(Color), "Color size mismatch"); #ifdef __cplusplus extern "C" { #endif -static_assert(sizeof(godot_color) == sizeof(Color), "Color size mismatch"); - -void GDAPI godot_color_new_rgba(godot_color *r_dest, const godot_real p_r, const godot_real p_g, const godot_real p_b, const godot_real p_a) { - Color *dest = (Color *)r_dest; - *dest = Color(p_r, p_g, p_b, p_a); -} - -void GDAPI godot_color_new_rgb(godot_color *r_dest, const godot_real p_r, const godot_real p_g, const godot_real p_b) { - Color *dest = (Color *)r_dest; - *dest = Color(p_r, p_g, p_b); -} - -godot_real godot_color_get_r(const godot_color *p_self) { - const Color *self = (const Color *)p_self; - return self->r; -} - -void godot_color_set_r(godot_color *p_self, const godot_real val) { - Color *self = (Color *)p_self; - self->r = val; -} - -godot_real godot_color_get_g(const godot_color *p_self) { - const Color *self = (const Color *)p_self; - return self->g; -} - -void godot_color_set_g(godot_color *p_self, const godot_real val) { - Color *self = (Color *)p_self; - self->g = val; -} - -godot_real godot_color_get_b(const godot_color *p_self) { - const Color *self = (const Color *)p_self; - return self->b; +void GDAPI godot_color_new(godot_color *p_self) { + memnew_placement(p_self, Color); } -void godot_color_set_b(godot_color *p_self, const godot_real val) { +float GDAPI *godot_color_operator_index(godot_color *p_self, godot_int p_index) { Color *self = (Color *)p_self; - self->b = val; -} - -godot_real godot_color_get_a(const godot_color *p_self) { - const Color *self = (const Color *)p_self; - return self->a; -} - -void godot_color_set_a(godot_color *p_self, const godot_real val) { - Color *self = (Color *)p_self; - self->a = val; -} - -godot_real godot_color_get_h(const godot_color *p_self) { - const Color *self = (const Color *)p_self; - return self->get_h(); -} - -godot_real godot_color_get_s(const godot_color *p_self) { - const Color *self = (const Color *)p_self; - return self->get_s(); -} - -godot_real godot_color_get_v(const godot_color *p_self) { - const Color *self = (const Color *)p_self; - return self->get_v(); -} - -godot_string GDAPI godot_color_as_string(const godot_color *p_self) { - godot_string ret; - const Color *self = (const Color *)p_self; - memnew_placement(&ret, String(*self)); - return ret; -} - -godot_int GDAPI godot_color_to_rgba32(const godot_color *p_self) { - const Color *self = (const Color *)p_self; - return self->to_rgba32(); -} - -godot_int GDAPI godot_color_to_abgr32(const godot_color *p_self) { - const Color *self = (const Color *)p_self; - return self->to_abgr32(); -} - -godot_int GDAPI godot_color_to_abgr64(const godot_color *p_self) { - const Color *self = (const Color *)p_self; - return self->to_abgr64(); -} - -godot_int GDAPI godot_color_to_argb64(const godot_color *p_self) { - const Color *self = (const Color *)p_self; - return self->to_argb64(); -} - -godot_int GDAPI godot_color_to_rgba64(const godot_color *p_self) { - const Color *self = (const Color *)p_self; - return self->to_rgba64(); -} - -godot_int GDAPI godot_color_to_argb32(const godot_color *p_self) { - const Color *self = (const Color *)p_self; - return self->to_argb32(); -} - -godot_color GDAPI godot_color_inverted(const godot_color *p_self) { - godot_color dest; - const Color *self = (const Color *)p_self; - *((Color *)&dest) = self->inverted(); - return dest; -} - -godot_color GDAPI godot_color_lerp(const godot_color *p_self, const godot_color *p_b, const godot_real p_t) { - godot_color dest; - const Color *self = (const Color *)p_self; - const Color *b = (const Color *)p_b; - *((Color *)&dest) = self->lerp(*b, p_t); - return dest; -} - -godot_color GDAPI godot_color_blend(const godot_color *p_self, const godot_color *p_over) { - godot_color dest; - const Color *self = (const Color *)p_self; - const Color *over = (const Color *)p_over; - *((Color *)&dest) = self->blend(*over); - return dest; -} - -godot_color GDAPI godot_color_darkened(const godot_color *p_self, const godot_real p_amount) { - godot_color dest; - const Color *self = (const Color *)p_self; - *((Color *)&dest) = self->darkened(p_amount); - return dest; -} - -godot_color GDAPI godot_color_from_hsv(const godot_color *p_self, const godot_real p_h, const godot_real p_s, const godot_real p_v, const godot_real p_a) { - godot_color dest; - const Color *self = (const Color *)p_self; - *((Color *)&dest) = self->from_hsv(p_h, p_s, p_v, p_a); - return dest; -} - -godot_color GDAPI godot_color_lightened(const godot_color *p_self, const godot_real p_amount) { - godot_color dest; - const Color *self = (const Color *)p_self; - *((Color *)&dest) = self->lightened(p_amount); - return dest; -} - -godot_string GDAPI godot_color_to_html(const godot_color *p_self, const godot_bool p_with_alpha) { - godot_string dest; - const Color *self = (const Color *)p_self; - - memnew_placement(&dest, String(self->to_html(p_with_alpha))); - return dest; -} - -godot_bool GDAPI godot_color_operator_equal(const godot_color *p_self, const godot_color *p_b) { - const Color *self = (const Color *)p_self; - const Color *b = (const Color *)p_b; - return *self == *b; + return (float *)&self->operator[](p_index); } -godot_bool GDAPI godot_color_operator_less(const godot_color *p_self, const godot_color *p_b) { +const float GDAPI *godot_color_operator_index_const(const godot_color *p_self, godot_int p_index) { const Color *self = (const Color *)p_self; - const Color *b = (const Color *)p_b; - return *self < *b; + return (const float *)&self->operator[](p_index); } #ifdef __cplusplus diff --git a/modules/gdnative/gdnative/dictionary.cpp b/modules/gdnative/gdnative/dictionary.cpp index b6900b28bb..9fa4a27a83 100644 --- a/modules/gdnative/gdnative/dictionary.cpp +++ b/modules/gdnative/gdnative/dictionary.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -30,26 +30,17 @@ #include "gdnative/dictionary.h" -#include "core/variant/variant.h" -// core/variant/variant.h before to avoid compile errors with MSVC -#include "core/io/json.h" #include "core/variant/dictionary.h" +#include "core/variant/variant.h" + +static_assert(sizeof(godot_dictionary) == sizeof(Dictionary), "Dictionary size mismatch"); #ifdef __cplusplus extern "C" { #endif -static_assert(sizeof(godot_dictionary) == sizeof(Dictionary), "Dictionary size mismatch"); - -void GDAPI godot_dictionary_new(godot_dictionary *r_dest) { - Dictionary *dest = (Dictionary *)r_dest; - memnew_placement(dest, Dictionary); -} - -void GDAPI godot_dictionary_new_copy(godot_dictionary *r_dest, const godot_dictionary *p_src) { - Dictionary *dest = (Dictionary *)r_dest; - const Dictionary *src = (const Dictionary *)p_src; - memnew_placement(dest, Dictionary(*src)); +void GDAPI godot_dictionary_new(godot_dictionary *p_self) { + memnew_placement(p_self, Dictionary); } void GDAPI godot_dictionary_destroy(godot_dictionary *p_self) { @@ -57,133 +48,14 @@ void GDAPI godot_dictionary_destroy(godot_dictionary *p_self) { self->~Dictionary(); } -godot_dictionary GDAPI godot_dictionary_duplicate(const godot_dictionary *p_self, const godot_bool p_deep) { - const Dictionary *self = (const Dictionary *)p_self; - godot_dictionary res; - Dictionary *val = (Dictionary *)&res; - memnew_placement(val, Dictionary); - *val = self->duplicate(p_deep); - return res; -} - -godot_int GDAPI godot_dictionary_size(const godot_dictionary *p_self) { - const Dictionary *self = (const Dictionary *)p_self; - return self->size(); -} - -godot_bool GDAPI godot_dictionary_empty(const godot_dictionary *p_self) { - const Dictionary *self = (const Dictionary *)p_self; - return self->empty(); -} - -void GDAPI godot_dictionary_clear(godot_dictionary *p_self) { - Dictionary *self = (Dictionary *)p_self; - self->clear(); -} - -godot_bool GDAPI godot_dictionary_has(const godot_dictionary *p_self, const godot_variant *p_key) { - const Dictionary *self = (const Dictionary *)p_self; - const Variant *key = (const Variant *)p_key; - return self->has(*key); -} - -godot_bool GDAPI godot_dictionary_has_all(const godot_dictionary *p_self, const godot_array *p_keys) { - const Dictionary *self = (const Dictionary *)p_self; - const Array *keys = (const Array *)p_keys; - return self->has_all(*keys); -} - -void GDAPI godot_dictionary_erase(godot_dictionary *p_self, const godot_variant *p_key) { - Dictionary *self = (Dictionary *)p_self; - const Variant *key = (const Variant *)p_key; - self->erase(*key); -} - -godot_int GDAPI godot_dictionary_hash(const godot_dictionary *p_self) { - const Dictionary *self = (const Dictionary *)p_self; - return self->hash(); -} - -godot_array GDAPI godot_dictionary_keys(const godot_dictionary *p_self) { - godot_array dest; - const Dictionary *self = (const Dictionary *)p_self; - memnew_placement(&dest, Array(self->keys())); - return dest; -} - -godot_array GDAPI godot_dictionary_values(const godot_dictionary *p_self) { - godot_array dest; - const Dictionary *self = (const Dictionary *)p_self; - memnew_placement(&dest, Array(self->values())); - return dest; -} - -godot_variant GDAPI godot_dictionary_get(const godot_dictionary *p_self, const godot_variant *p_key) { - godot_variant raw_dest; - Variant *dest = (Variant *)&raw_dest; - const Dictionary *self = (const Dictionary *)p_self; - const Variant *key = (const Variant *)p_key; - memnew_placement(dest, Variant(self->operator[](*key))); - return raw_dest; -} - -void GDAPI godot_dictionary_set(godot_dictionary *p_self, const godot_variant *p_key, const godot_variant *p_value) { - Dictionary *self = (Dictionary *)p_self; - const Variant *key = (const Variant *)p_key; - const Variant *value = (const Variant *)p_value; - self->operator[](*key) = *value; -} - godot_variant GDAPI *godot_dictionary_operator_index(godot_dictionary *p_self, const godot_variant *p_key) { Dictionary *self = (Dictionary *)p_self; - const Variant *key = (const Variant *)p_key; - return (godot_variant *)&self->operator[](*key); + return (godot_variant *)&self->operator[](*((const Variant *)p_key)); } const godot_variant GDAPI *godot_dictionary_operator_index_const(const godot_dictionary *p_self, const godot_variant *p_key) { const Dictionary *self = (const Dictionary *)p_self; - const Variant *key = (const Variant *)p_key; - return (const godot_variant *)&self->operator[](*key); -} - -godot_variant GDAPI *godot_dictionary_next(const godot_dictionary *p_self, const godot_variant *p_key) { - Dictionary *self = (Dictionary *)p_self; - const Variant *key = (const Variant *)p_key; - return (godot_variant *)self->next(key); -} - -godot_bool GDAPI godot_dictionary_operator_equal(const godot_dictionary *p_self, const godot_dictionary *p_b) { - const Dictionary *self = (const Dictionary *)p_self; - const Dictionary *b = (const Dictionary *)p_b; - return *self == *b; -} - -godot_string GDAPI godot_dictionary_to_json(const godot_dictionary *p_self) { - godot_string raw_dest; - String *dest = (String *)&raw_dest; - const Dictionary *self = (const Dictionary *)p_self; - memnew_placement(dest, String(JSON::print(Variant(*self)))); - return raw_dest; -} - -// GDNative core 1.1 - -godot_bool GDAPI godot_dictionary_erase_with_return(godot_dictionary *p_self, const godot_variant *p_key) { - Dictionary *self = (Dictionary *)p_self; - const Variant *key = (const Variant *)p_key; - return self->erase(*key); -} - -godot_variant GDAPI godot_dictionary_get_with_default(const godot_dictionary *p_self, const godot_variant *p_key, const godot_variant *p_default) { - const Dictionary *self = (const Dictionary *)p_self; - const Variant *key = (const Variant *)p_key; - const Variant *def = (const Variant *)p_default; - - godot_variant raw_dest; - Variant *dest = (Variant *)&raw_dest; - memnew_placement(dest, Variant(self->get(*key, *def))); - - return raw_dest; + return (const godot_variant *)&self->operator[](*((const Variant *)p_key)); } #ifdef __cplusplus diff --git a/modules/gdnative/gdnative/gdnative.cpp b/modules/gdnative/gdnative/gdnative.cpp index 4142ea892b..b84ce2d192 100644 --- a/modules/gdnative/gdnative/gdnative.cpp +++ b/modules/gdnative/gdnative/gdnative.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -99,7 +99,7 @@ godot_class_constructor GDAPI godot_get_class_constructor(const char *p_classnam godot_dictionary GDAPI godot_get_global_constants() { godot_dictionary constants; - godot_dictionary_new(&constants); + memnew_placement(&constants, Dictionary); Dictionary *p_constants = (Dictionary *)&constants; const int constants_count = CoreConstants::get_global_constant_count(); for (int i = 0; i < constants_count; ++i) { @@ -127,16 +127,15 @@ void GDAPI godot_free(void *p_ptr) { memfree(p_ptr); } +// Helper print functions. void GDAPI godot_print_error(const char *p_description, const char *p_function, const char *p_file, int p_line) { _err_print_error(p_function, p_file, p_line, p_description, ERR_HANDLER_ERROR); } - void GDAPI godot_print_warning(const char *p_description, const char *p_function, const char *p_file, int p_line) { _err_print_error(p_function, p_file, p_line, p_description, ERR_HANDLER_WARNING); } - -void GDAPI godot_print(const godot_string *p_message) { - print_line(*(String *)p_message); +void GDAPI godot_print_script_error(const char *p_description, const char *p_function, const char *p_file, int p_line) { + _err_print_error(p_function, p_file, p_line, p_description, ERR_HANDLER_SCRIPT); } void _gdnative_report_version_mismatch(const godot_object *p_library, const char *p_ext, godot_gdnative_api_version p_want, godot_gdnative_api_version p_have) { diff --git a/modules/gdnative/gdnative/node_path.cpp b/modules/gdnative/gdnative/node_path.cpp index c031498612..02c2f9b22b 100644 --- a/modules/gdnative/gdnative/node_path.cpp +++ b/modules/gdnative/gdnative/node_path.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -31,24 +31,15 @@ #include "gdnative/node_path.h" #include "core/string/node_path.h" -#include "core/variant/variant.h" + +static_assert(sizeof(godot_node_path) == sizeof(NodePath), "NodePath size mismatch"); #ifdef __cplusplus extern "C" { #endif -static_assert(sizeof(godot_node_path) == sizeof(NodePath), "NodePath size mismatch"); - -void GDAPI godot_node_path_new(godot_node_path *r_dest, const godot_string *p_from) { - NodePath *dest = (NodePath *)r_dest; - const String *from = (const String *)p_from; - memnew_placement(dest, NodePath(*from)); -} - -void GDAPI godot_node_path_new_copy(godot_node_path *r_dest, const godot_node_path *p_src) { - NodePath *dest = (NodePath *)r_dest; - const NodePath *src = (const NodePath *)p_src; - memnew_placement(dest, NodePath(*src)); +void GDAPI godot_node_path_new(godot_node_path *p_self) { + memnew_placement(p_self, NodePath); } void GDAPI godot_node_path_destroy(godot_node_path *p_self) { @@ -56,71 +47,6 @@ void GDAPI godot_node_path_destroy(godot_node_path *p_self) { self->~NodePath(); } -godot_string GDAPI godot_node_path_as_string(const godot_node_path *p_self) { - godot_string ret; - const NodePath *self = (const NodePath *)p_self; - memnew_placement(&ret, String(*self)); - return ret; -} - -godot_bool GDAPI godot_node_path_is_absolute(const godot_node_path *p_self) { - const NodePath *self = (const NodePath *)p_self; - return self->is_absolute(); -} - -godot_int GDAPI godot_node_path_get_name_count(const godot_node_path *p_self) { - const NodePath *self = (const NodePath *)p_self; - return self->get_name_count(); -} - -godot_string GDAPI godot_node_path_get_name(const godot_node_path *p_self, const godot_int p_idx) { - godot_string dest; - const NodePath *self = (const NodePath *)p_self; - - memnew_placement(&dest, String(self->get_name(p_idx))); - return dest; -} - -godot_int GDAPI godot_node_path_get_subname_count(const godot_node_path *p_self) { - const NodePath *self = (const NodePath *)p_self; - return self->get_subname_count(); -} - -godot_string GDAPI godot_node_path_get_subname(const godot_node_path *p_self, const godot_int p_idx) { - godot_string dest; - const NodePath *self = (const NodePath *)p_self; - - memnew_placement(&dest, String(self->get_subname(p_idx))); - return dest; -} - -godot_string GDAPI godot_node_path_get_concatenated_subnames(const godot_node_path *p_self) { - godot_string dest; - const NodePath *self = (const NodePath *)p_self; - memnew_placement(&dest, String(self->get_concatenated_subnames())); - return dest; -} - -godot_bool GDAPI godot_node_path_is_empty(const godot_node_path *p_self) { - const NodePath *self = (const NodePath *)p_self; - return self->is_empty(); -} - -godot_bool GDAPI godot_node_path_operator_equal(const godot_node_path *p_self, const godot_node_path *p_b) { - const NodePath *self = (const NodePath *)p_self; - const NodePath *b = (const NodePath *)p_b; - return *self == *b; -} - -godot_node_path godot_node_path_get_as_property_path(const godot_node_path *p_self) { - const NodePath *self = (const NodePath *)p_self; - godot_node_path res; - NodePath *val = (NodePath *)&res; - memnew_placement(val, NodePath); - *val = self->get_as_property_path(); - return res; -} - #ifdef __cplusplus } #endif diff --git a/modules/gdnative/gdnative/packed_arrays.cpp b/modules/gdnative/gdnative/packed_arrays.cpp index cc1e05b8a4..63a2425b87 100644 --- a/modules/gdnative/gdnative/packed_arrays.cpp +++ b/modules/gdnative/gdnative/packed_arrays.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -30,1110 +30,247 @@ #include "gdnative/packed_arrays.h" -#include "core/variant/array.h" - #include "core/variant/variant.h" -#include "core/math/color.h" #include "core/math/vector2.h" -#include "core/math/vector3.h" +#include "core/math/vector3i.h" + +static_assert(sizeof(godot_packed_byte_array) == sizeof(PackedByteArray), "PackedByteArray size mismatch"); +static_assert(sizeof(godot_packed_int32_array) == sizeof(PackedInt32Array), "PackedInt32Array size mismatch"); +static_assert(sizeof(godot_packed_int64_array) == sizeof(PackedInt64Array), "PackedInt64Array size mismatch"); +static_assert(sizeof(godot_packed_float32_array) == sizeof(PackedFloat32Array), "PackedFloat32Array size mismatch"); +static_assert(sizeof(godot_packed_float64_array) == sizeof(PackedFloat64Array), "PackedFloat64Array size mismatch"); +static_assert(sizeof(godot_packed_string_array) == sizeof(PackedStringArray), "PackedStringArray size mismatch"); +static_assert(sizeof(godot_packed_vector2_array) == sizeof(PackedVector2Array), "PackedVector2Array size mismatch"); +static_assert(sizeof(godot_packed_vector2i_array) == sizeof(Vector<Vector2i>), "Vector<Vector2i> size mismatch"); +static_assert(sizeof(godot_packed_vector3_array) == sizeof(PackedVector3Array), "PackedVector3Array size mismatch"); +static_assert(sizeof(godot_packed_vector3i_array) == sizeof(Vector<Vector3i>), "Vector<Vector3i> size mismatch"); +static_assert(sizeof(godot_packed_color_array) == sizeof(PackedColorArray), "PackedColorArray size mismatch"); #ifdef __cplusplus extern "C" { #endif -static_assert(sizeof(godot_packed_byte_array) == sizeof(Vector<uint8_t>), "Vector<uint8_t> size mismatch"); -static_assert(sizeof(godot_packed_int32_array) == sizeof(Vector<int32_t>), "Vector<int32_t> size mismatch"); -static_assert(sizeof(godot_packed_int64_array) == sizeof(Vector<int64_t>), "Vector<int64_t> size mismatch"); -static_assert(sizeof(godot_packed_float32_array) == sizeof(Vector<float>), "Vector<float> size mismatch"); -static_assert(sizeof(godot_packed_float64_array) == sizeof(Vector<double>), "Vector<double> size mismatch"); -static_assert(sizeof(godot_packed_string_array) == sizeof(Vector<String>), "Vector<String> size mismatch"); -static_assert(sizeof(godot_packed_vector2_array) == sizeof(Vector<Vector2>), "Vector<Vector2> size mismatch"); -static_assert(sizeof(godot_packed_vector2i_array) == sizeof(Vector<Vector2i>), "Vector<Vector2i> size mismatch"); -static_assert(sizeof(godot_packed_vector3_array) == sizeof(Vector<Vector3>), "Vector<Vector3> size mismatch"); -static_assert(sizeof(godot_packed_color_array) == sizeof(Vector<Color>), "Vector<Color> size mismatch"); - #define memnew_placement_custom(m_placement, m_class, m_constr) _post_initialize(new (m_placement, sizeof(m_class), "") m_constr) // byte -void GDAPI godot_packed_byte_array_new(godot_packed_byte_array *r_dest) { - Vector<uint8_t> *dest = (Vector<uint8_t> *)r_dest; - memnew_placement(dest, Vector<uint8_t>); -} - -void GDAPI godot_packed_byte_array_new_copy(godot_packed_byte_array *r_dest, const godot_packed_byte_array *p_src) { - Vector<uint8_t> *dest = (Vector<uint8_t> *)r_dest; - const Vector<uint8_t> *src = (const Vector<uint8_t> *)p_src; - memnew_placement(dest, Vector<uint8_t>(*src)); -} - -void GDAPI godot_packed_byte_array_new_with_array(godot_packed_byte_array *r_dest, const godot_array *p_a) { - Vector<uint8_t> *dest = (Vector<uint8_t> *)r_dest; - Array *a = (Array *)p_a; - memnew_placement(dest, Vector<uint8_t>); - - dest->resize(a->size()); - for (int i = 0; i < a->size(); i++) { - dest->set(i, (*a)[i]); - } -} - -const uint8_t GDAPI *godot_packed_byte_array_ptr(const godot_packed_byte_array *p_self) { - const Vector<uint8_t> *self = (const Vector<uint8_t> *)p_self; - return self->ptr(); -} - -uint8_t GDAPI *godot_packed_byte_array_ptrw(godot_packed_byte_array *p_self) { - Vector<uint8_t> *self = (Vector<uint8_t> *)p_self; - return self->ptrw(); -} - -void GDAPI godot_packed_byte_array_append(godot_packed_byte_array *p_self, const uint8_t p_data) { - Vector<uint8_t> *self = (Vector<uint8_t> *)p_self; - self->push_back(p_data); -} - -void GDAPI godot_packed_byte_array_append_array(godot_packed_byte_array *p_self, const godot_packed_byte_array *p_array) { - Vector<uint8_t> *self = (Vector<uint8_t> *)p_self; - Vector<uint8_t> *array = (Vector<uint8_t> *)p_array; - self->append_array(*array); -} - -godot_error GDAPI godot_packed_byte_array_insert(godot_packed_byte_array *p_self, const godot_int p_idx, const uint8_t p_data) { - Vector<uint8_t> *self = (Vector<uint8_t> *)p_self; - return (godot_error)self->insert(p_idx, p_data); -} - -godot_bool GDAPI godot_packed_byte_array_has(godot_packed_byte_array *p_self, const uint8_t p_value) { - Vector<uint8_t> *self = (Vector<uint8_t> *)p_self; - return (godot_bool)self->has(p_value); -} - -void GDAPI godot_packed_byte_array_sort(godot_packed_byte_array *p_self) { - Vector<uint8_t> *self = (Vector<uint8_t> *)p_self; - self->sort(); -} - -void GDAPI godot_packed_byte_array_invert(godot_packed_byte_array *p_self) { - Vector<uint8_t> *self = (Vector<uint8_t> *)p_self; - self->invert(); -} - -void GDAPI godot_packed_byte_array_push_back(godot_packed_byte_array *p_self, const uint8_t p_data) { - Vector<uint8_t> *self = (Vector<uint8_t> *)p_self; - self->push_back(p_data); -} - -void GDAPI godot_packed_byte_array_remove(godot_packed_byte_array *p_self, const godot_int p_idx) { - Vector<uint8_t> *self = (Vector<uint8_t> *)p_self; - self->remove(p_idx); -} - -void GDAPI godot_packed_byte_array_resize(godot_packed_byte_array *p_self, const godot_int p_size) { - Vector<uint8_t> *self = (Vector<uint8_t> *)p_self; - self->resize(p_size); -} - -void GDAPI godot_packed_byte_array_set(godot_packed_byte_array *p_self, const godot_int p_idx, const uint8_t p_data) { - Vector<uint8_t> *self = (Vector<uint8_t> *)p_self; - self->set(p_idx, p_data); -} - -uint8_t GDAPI godot_packed_byte_array_get(const godot_packed_byte_array *p_self, const godot_int p_idx) { - const Vector<uint8_t> *self = (const Vector<uint8_t> *)p_self; - return self->get(p_idx); -} - -godot_int GDAPI godot_packed_byte_array_size(const godot_packed_byte_array *p_self) { - const Vector<uint8_t> *self = (const Vector<uint8_t> *)p_self; - return self->size(); -} - -godot_bool GDAPI godot_packed_byte_array_empty(const godot_packed_byte_array *p_self) { - const Vector<uint8_t> *self = (const Vector<uint8_t> *)p_self; - return self->empty(); +void GDAPI godot_packed_byte_array_new(godot_packed_byte_array *p_self) { + memnew_placement(p_self, PackedByteArray); } void GDAPI godot_packed_byte_array_destroy(godot_packed_byte_array *p_self) { - ((Vector<uint8_t> *)p_self)->~Vector(); + ((PackedByteArray *)p_self)->~PackedByteArray(); } -// int32 - -void GDAPI godot_packed_int32_array_new(godot_packed_int32_array *r_dest) { - Vector<int32_t> *dest = (Vector<int32_t> *)r_dest; - memnew_placement(dest, Vector<int32_t>); +uint8_t GDAPI *godot_packed_byte_array_operator_index(godot_packed_byte_array *p_self, godot_int p_index) { + PackedByteArray *self = (PackedByteArray *)p_self; + return (uint8_t *)&self->operator[](p_index); } -void GDAPI godot_packed_int32_array_new_copy(godot_packed_int32_array *r_dest, const godot_packed_int32_array *p_src) { - Vector<int32_t> *dest = (Vector<int32_t> *)r_dest; - const Vector<int32_t> *src = (const Vector<int32_t> *)p_src; - memnew_placement(dest, Vector<int32_t>(*src)); +const uint8_t GDAPI *godot_packed_byte_array_operator_index_const(const godot_packed_byte_array *p_self, godot_int p_index) { + const PackedByteArray *self = (const PackedByteArray *)p_self; + return (const uint8_t *)&self->operator[](p_index); } -void GDAPI godot_packed_int32_array_new_with_array(godot_packed_int32_array *r_dest, const godot_array *p_a) { - Vector<int32_t> *dest = (Vector<int32_t> *)r_dest; - Array *a = (Array *)p_a; - memnew_placement(dest, Vector<int32_t>); - - dest->resize(a->size()); - for (int i = 0; i < a->size(); i++) { - dest->set(i, (*a)[i]); - } -} - -const int32_t GDAPI *godot_packed_int32_array_ptr(const godot_packed_int32_array *p_self) { - const Vector<int32_t> *self = (const Vector<int32_t> *)p_self; - return self->ptr(); -} - -int32_t GDAPI *godot_packed_int32_array_ptrw(godot_packed_int32_array *p_self) { - Vector<int32_t> *self = (Vector<int32_t> *)p_self; - return self->ptrw(); -} - -void GDAPI godot_packed_int32_array_append(godot_packed_int32_array *p_self, const int32_t p_data) { - Vector<int32_t> *self = (Vector<int32_t> *)p_self; - self->push_back(p_data); -} - -void GDAPI godot_packed_int32_array_append_array(godot_packed_int32_array *p_self, const godot_packed_int32_array *p_array) { - Vector<int32_t> *self = (Vector<int32_t> *)p_self; - Vector<int32_t> *array = (Vector<int32_t> *)p_array; - self->append_array(*array); -} - -godot_error GDAPI godot_packed_int32_array_insert(godot_packed_int32_array *p_self, const godot_int p_idx, const int32_t p_data) { - Vector<int32_t> *self = (Vector<int32_t> *)p_self; - return (godot_error)self->insert(p_idx, p_data); -} - -godot_bool GDAPI godot_packed_int32_array_has(godot_packed_int32_array *p_self, const int32_t p_value) { - Vector<int32_t> *self = (Vector<int32_t> *)p_self; - return (godot_bool)self->has(p_value); -} - -void GDAPI godot_packed_int32_array_sort(godot_packed_int32_array *p_self) { - Vector<int32_t> *self = (Vector<int32_t> *)p_self; - self->sort(); -} - -void GDAPI godot_packed_int32_array_invert(godot_packed_int32_array *p_self) { - Vector<int32_t> *self = (Vector<int32_t> *)p_self; - self->invert(); -} - -void GDAPI godot_packed_int32_array_push_back(godot_packed_int32_array *p_self, const int32_t p_data) { - Vector<int32_t> *self = (Vector<int32_t> *)p_self; - self->push_back(p_data); -} - -void GDAPI godot_packed_int32_array_remove(godot_packed_int32_array *p_self, const godot_int p_idx) { - Vector<int32_t> *self = (Vector<int32_t> *)p_self; - self->remove(p_idx); -} - -void GDAPI godot_packed_int32_array_resize(godot_packed_int32_array *p_self, const godot_int p_size) { - Vector<int32_t> *self = (Vector<int32_t> *)p_self; - self->resize(p_size); -} - -void GDAPI godot_packed_int32_array_set(godot_packed_int32_array *p_self, const godot_int p_idx, const int32_t p_data) { - Vector<int32_t> *self = (Vector<int32_t> *)p_self; - self->set(p_idx, p_data); -} - -int32_t GDAPI godot_packed_int32_array_get(const godot_packed_int32_array *p_self, const godot_int p_idx) { - const Vector<int32_t> *self = (const Vector<int32_t> *)p_self; - return self->get(p_idx); -} - -godot_int GDAPI godot_packed_int32_array_size(const godot_packed_int32_array *p_self) { - const Vector<int32_t> *self = (const Vector<int32_t> *)p_self; - return self->size(); -} +// int32 -godot_bool GDAPI godot_packed_int32_array_empty(const godot_packed_int32_array *p_self) { - const Vector<int32_t> *self = (const Vector<int32_t> *)p_self; - return self->empty(); +void GDAPI godot_packed_int32_array_new(godot_packed_int32_array *p_self) { + memnew_placement(p_self, PackedInt32Array); } void GDAPI godot_packed_int32_array_destroy(godot_packed_int32_array *p_self) { - ((Vector<int32_t> *)p_self)->~Vector(); -} - -// int64 - -void GDAPI godot_packed_int64_array_new(godot_packed_int64_array *r_dest) { - Vector<int64_t> *dest = (Vector<int64_t> *)r_dest; - memnew_placement(dest, Vector<int64_t>); -} - -void GDAPI godot_packed_int64_array_new_copy(godot_packed_int64_array *r_dest, const godot_packed_int64_array *p_src) { - Vector<int64_t> *dest = (Vector<int64_t> *)r_dest; - const Vector<int64_t> *src = (const Vector<int64_t> *)p_src; - memnew_placement(dest, Vector<int64_t>(*src)); -} - -void GDAPI godot_packed_int64_array_new_with_array(godot_packed_int64_array *r_dest, const godot_array *p_a) { - Vector<int64_t> *dest = (Vector<int64_t> *)r_dest; - Array *a = (Array *)p_a; - memnew_placement(dest, Vector<int64_t>); - - dest->resize(a->size()); - for (int i = 0; i < a->size(); i++) { - dest->set(i, (*a)[i]); - } -} - -const int64_t GDAPI *godot_packed_int64_array_ptr(const godot_packed_int64_array *p_self) { - const Vector<int64_t> *self = (const Vector<int64_t> *)p_self; - return self->ptr(); -} - -int64_t GDAPI *godot_packed_int64_array_ptrw(godot_packed_int64_array *p_self) { - Vector<int64_t> *self = (Vector<int64_t> *)p_self; - return self->ptrw(); + ((PackedInt32Array *)p_self)->~PackedInt32Array(); } -void GDAPI godot_packed_int64_array_append(godot_packed_int64_array *p_self, const int64_t p_data) { - Vector<int64_t> *self = (Vector<int64_t> *)p_self; - self->push_back(p_data); +int32_t GDAPI *godot_packed_int32_array_operator_index(godot_packed_int32_array *p_self, godot_int p_index) { + PackedInt32Array *self = (PackedInt32Array *)p_self; + return (int32_t *)&self->operator[](p_index); } -void GDAPI godot_packed_int64_array_append_array(godot_packed_int64_array *p_self, const godot_packed_int64_array *p_array) { - Vector<int64_t> *self = (Vector<int64_t> *)p_self; - Vector<int64_t> *array = (Vector<int64_t> *)p_array; - self->append_array(*array); +const int32_t GDAPI *godot_packed_int32_array_operator_index_const(const godot_packed_int32_array *p_self, godot_int p_index) { + const PackedInt32Array *self = (const PackedInt32Array *)p_self; + return (const int32_t *)&self->operator[](p_index); } -godot_error GDAPI godot_packed_int64_array_insert(godot_packed_int64_array *p_self, const godot_int p_idx, const int64_t p_data) { - Vector<int64_t> *self = (Vector<int64_t> *)p_self; - return (godot_error)self->insert(p_idx, p_data); -} - -godot_bool GDAPI godot_packed_int64_array_has(godot_packed_int64_array *p_self, const int64_t p_value) { - Vector<int64_t> *self = (Vector<int64_t> *)p_self; - return (godot_bool)self->has(p_value); -} - -void GDAPI godot_packed_int64_array_sort(godot_packed_int64_array *p_self) { - Vector<int64_t> *self = (Vector<int64_t> *)p_self; - self->sort(); -} - -void GDAPI godot_packed_int64_array_invert(godot_packed_int64_array *p_self) { - Vector<int64_t> *self = (Vector<int64_t> *)p_self; - self->invert(); -} - -void GDAPI godot_packed_int64_array_push_back(godot_packed_int64_array *p_self, const int64_t p_data) { - Vector<int64_t> *self = (Vector<int64_t> *)p_self; - self->push_back(p_data); -} - -void GDAPI godot_packed_int64_array_remove(godot_packed_int64_array *p_self, const godot_int p_idx) { - Vector<int64_t> *self = (Vector<int64_t> *)p_self; - self->remove(p_idx); -} - -void GDAPI godot_packed_int64_array_resize(godot_packed_int64_array *p_self, const godot_int p_size) { - Vector<int64_t> *self = (Vector<int64_t> *)p_self; - self->resize(p_size); -} - -void GDAPI godot_packed_int64_array_set(godot_packed_int64_array *p_self, const godot_int p_idx, const int64_t p_data) { - Vector<int64_t> *self = (Vector<int64_t> *)p_self; - self->set(p_idx, p_data); -} - -int64_t GDAPI godot_packed_int64_array_get(const godot_packed_int64_array *p_self, const godot_int p_idx) { - const Vector<int64_t> *self = (const Vector<int64_t> *)p_self; - return self->get(p_idx); -} - -godot_int GDAPI godot_packed_int64_array_size(const godot_packed_int64_array *p_self) { - const Vector<int64_t> *self = (const Vector<int64_t> *)p_self; - return self->size(); -} +// int64 -godot_bool GDAPI godot_packed_int64_array_empty(const godot_packed_int64_array *p_self) { - const Vector<int64_t> *self = (const Vector<int64_t> *)p_self; - return self->empty(); +void GDAPI godot_packed_int64_array_new(godot_packed_int64_array *p_self) { + memnew_placement(p_self, PackedInt64Array); } void GDAPI godot_packed_int64_array_destroy(godot_packed_int64_array *p_self) { - ((Vector<int64_t> *)p_self)->~Vector(); -} - -// float32 - -void GDAPI godot_packed_float32_array_new(godot_packed_float32_array *r_dest) { - Vector<float> *dest = (Vector<float> *)r_dest; - memnew_placement(dest, Vector<float>); -} - -void GDAPI godot_packed_float32_array_new_copy(godot_packed_float32_array *r_dest, const godot_packed_float32_array *p_src) { - Vector<float> *dest = (Vector<float> *)r_dest; - const Vector<float> *src = (const Vector<float> *)p_src; - memnew_placement(dest, Vector<float>(*src)); -} - -void GDAPI godot_packed_float32_array_new_with_array(godot_packed_float32_array *r_dest, const godot_array *p_a) { - Vector<float> *dest = (Vector<float> *)r_dest; - Array *a = (Array *)p_a; - memnew_placement(dest, Vector<float>); - - dest->resize(a->size()); - for (int i = 0; i < a->size(); i++) { - dest->set(i, (*a)[i]); - } -} - -const float GDAPI *godot_packed_float32_array_ptr(const godot_packed_float32_array *p_self) { - const Vector<float> *self = (const Vector<float> *)p_self; - return self->ptr(); -} - -float GDAPI *godot_packed_float32_array_ptrw(godot_packed_float32_array *p_self) { - Vector<float> *self = (Vector<float> *)p_self; - return self->ptrw(); -} - -void GDAPI godot_packed_float32_array_append(godot_packed_float32_array *p_self, const float p_data) { - Vector<float> *self = (Vector<float> *)p_self; - self->push_back(p_data); -} - -void GDAPI godot_packed_float32_array_append_array(godot_packed_float32_array *p_self, const godot_packed_float32_array *p_array) { - Vector<float> *self = (Vector<float> *)p_self; - Vector<float> *array = (Vector<float> *)p_array; - self->append_array(*array); -} - -godot_error GDAPI godot_packed_float32_array_insert(godot_packed_float32_array *p_self, const godot_int p_idx, const float p_data) { - Vector<float> *self = (Vector<float> *)p_self; - return (godot_error)self->insert(p_idx, p_data); -} - -godot_bool GDAPI godot_packed_float32_array_has(godot_packed_float32_array *p_self, const float p_value) { - Vector<float> *self = (Vector<float> *)p_self; - return (godot_bool)self->has(p_value); -} - -void GDAPI godot_packed_float32_array_sort(godot_packed_float32_array *p_self) { - Vector<float> *self = (Vector<float> *)p_self; - self->sort(); + ((PackedInt64Array *)p_self)->~PackedInt64Array(); } -void GDAPI godot_packed_float32_array_invert(godot_packed_float32_array *p_self) { - Vector<float> *self = (Vector<float> *)p_self; - self->invert(); +int64_t GDAPI *godot_packed_int64_array_operator_index(godot_packed_int64_array *p_self, godot_int p_index) { + PackedInt64Array *self = (PackedInt64Array *)p_self; + return (int64_t *)&self->operator[](p_index); } -void GDAPI godot_packed_float32_array_push_back(godot_packed_float32_array *p_self, const float p_data) { - Vector<float> *self = (Vector<float> *)p_self; - self->push_back(p_data); +const int64_t GDAPI *godot_packed_int64_array_operator_index_const(const godot_packed_int64_array *p_self, godot_int p_index) { + const PackedInt64Array *self = (const PackedInt64Array *)p_self; + return (const int64_t *)&self->operator[](p_index); } -void GDAPI godot_packed_float32_array_remove(godot_packed_float32_array *p_self, const godot_int p_idx) { - Vector<float> *self = (Vector<float> *)p_self; - self->remove(p_idx); -} - -void GDAPI godot_packed_float32_array_resize(godot_packed_float32_array *p_self, const godot_int p_size) { - Vector<float> *self = (Vector<float> *)p_self; - self->resize(p_size); -} - -void GDAPI godot_packed_float32_array_set(godot_packed_float32_array *p_self, const godot_int p_idx, const float p_data) { - Vector<float> *self = (Vector<float> *)p_self; - self->set(p_idx, p_data); -} - -float GDAPI godot_packed_float32_array_get(const godot_packed_float32_array *p_self, const godot_int p_idx) { - const Vector<float> *self = (const Vector<float> *)p_self; - return self->get(p_idx); -} - -godot_int GDAPI godot_packed_float32_array_size(const godot_packed_float32_array *p_self) { - const Vector<float> *self = (const Vector<float> *)p_self; - return self->size(); -} +// float32 -godot_bool GDAPI godot_packed_float32_array_empty(const godot_packed_float32_array *p_self) { - const Vector<float> *self = (const Vector<float> *)p_self; - return self->empty(); +void GDAPI godot_packed_float32_array_new(godot_packed_float32_array *p_self) { + memnew_placement(p_self, PackedFloat32Array); } void GDAPI godot_packed_float32_array_destroy(godot_packed_float32_array *p_self) { - ((Vector<float> *)p_self)->~Vector(); -} - -// float64 - -void GDAPI godot_packed_float64_array_new(godot_packed_float64_array *r_dest) { - Vector<double> *dest = (Vector<double> *)r_dest; - memnew_placement(dest, Vector<double>); -} - -void GDAPI godot_packed_float64_array_new_copy(godot_packed_float64_array *r_dest, const godot_packed_float64_array *p_src) { - Vector<double> *dest = (Vector<double> *)r_dest; - const Vector<double> *src = (const Vector<double> *)p_src; - memnew_placement(dest, Vector<double>(*src)); -} - -void GDAPI godot_packed_float64_array_new_with_array(godot_packed_float64_array *r_dest, const godot_array *p_a) { - Vector<double> *dest = (Vector<double> *)r_dest; - Array *a = (Array *)p_a; - memnew_placement(dest, Vector<double>); - - dest->resize(a->size()); - for (int i = 0; i < a->size(); i++) { - dest->set(i, (*a)[i]); - } -} - -const double GDAPI *godot_packed_float64_array_ptr(const godot_packed_float64_array *p_self) { - const Vector<double> *self = (const Vector<double> *)p_self; - return self->ptr(); + ((PackedFloat32Array *)p_self)->~PackedFloat32Array(); } -double GDAPI *godot_packed_float64_array_ptrw(godot_packed_float64_array *p_self) { - Vector<double> *self = (Vector<double> *)p_self; - return self->ptrw(); +float GDAPI *godot_packed_float32_array_operator_index(godot_packed_float32_array *p_self, godot_int p_index) { + PackedFloat32Array *self = (PackedFloat32Array *)p_self; + return (float *)&self->operator[](p_index); } -void GDAPI godot_packed_float64_array_append(godot_packed_float64_array *p_self, const double p_data) { - Vector<double> *self = (Vector<double> *)p_self; - self->push_back(p_data); +const float GDAPI *godot_packed_float32_array_operator_index_const(const godot_packed_float32_array *p_self, godot_int p_index) { + const PackedFloat32Array *self = (const PackedFloat32Array *)p_self; + return (const float *)&self->operator[](p_index); } -void GDAPI godot_packed_float64_array_append_array(godot_packed_float64_array *p_self, const godot_packed_float64_array *p_array) { - Vector<double> *self = (Vector<double> *)p_self; - Vector<double> *array = (Vector<double> *)p_array; - self->append_array(*array); -} - -godot_error GDAPI godot_packed_float64_array_insert(godot_packed_float64_array *p_self, const godot_int p_idx, const double p_data) { - Vector<double> *self = (Vector<double> *)p_self; - return (godot_error)self->insert(p_idx, p_data); -} - -godot_bool GDAPI godot_packed_float64_array_has(godot_packed_float64_array *p_self, const double p_value) { - Vector<double> *self = (Vector<double> *)p_self; - return (godot_bool)self->has(p_value); -} - -void GDAPI godot_packed_float64_array_sort(godot_packed_float64_array *p_self) { - Vector<double> *self = (Vector<double> *)p_self; - self->sort(); -} - -void GDAPI godot_packed_float64_array_invert(godot_packed_float64_array *p_self) { - Vector<double> *self = (Vector<double> *)p_self; - self->invert(); -} - -void GDAPI godot_packed_float64_array_push_back(godot_packed_float64_array *p_self, const double p_data) { - Vector<double> *self = (Vector<double> *)p_self; - self->push_back(p_data); -} - -void GDAPI godot_packed_float64_array_remove(godot_packed_float64_array *p_self, const godot_int p_idx) { - Vector<double> *self = (Vector<double> *)p_self; - self->remove(p_idx); -} - -void GDAPI godot_packed_float64_array_resize(godot_packed_float64_array *p_self, const godot_int p_size) { - Vector<double> *self = (Vector<double> *)p_self; - self->resize(p_size); -} - -void GDAPI godot_packed_float64_array_set(godot_packed_float64_array *p_self, const godot_int p_idx, const double p_data) { - Vector<double> *self = (Vector<double> *)p_self; - self->set(p_idx, p_data); -} - -double GDAPI godot_packed_float64_array_get(const godot_packed_float64_array *p_self, const godot_int p_idx) { - const Vector<double> *self = (const Vector<double> *)p_self; - return self->get(p_idx); -} - -godot_int GDAPI godot_packed_float64_array_size(const godot_packed_float64_array *p_self) { - const Vector<double> *self = (const Vector<double> *)p_self; - return self->size(); -} +// float64 -godot_bool GDAPI godot_packed_float64_array_empty(const godot_packed_float64_array *p_self) { - const Vector<double> *self = (const Vector<double> *)p_self; - return self->empty(); +void GDAPI godot_packed_float64_array_new(godot_packed_float64_array *p_self) { + memnew_placement(p_self, PackedFloat64Array); } void GDAPI godot_packed_float64_array_destroy(godot_packed_float64_array *p_self) { - ((Vector<double> *)p_self)->~Vector(); -} - -// string - -void GDAPI godot_packed_string_array_new(godot_packed_string_array *r_dest) { - Vector<String> *dest = (Vector<String> *)r_dest; - memnew_placement(dest, Vector<String>); -} - -void GDAPI godot_packed_string_array_new_copy(godot_packed_string_array *r_dest, const godot_packed_string_array *p_src) { - Vector<String> *dest = (Vector<String> *)r_dest; - const Vector<String> *src = (const Vector<String> *)p_src; - memnew_placement(dest, Vector<String>(*src)); -} - -void GDAPI godot_packed_string_array_new_with_array(godot_packed_string_array *r_dest, const godot_array *p_a) { - Vector<String> *dest = (Vector<String> *)r_dest; - Array *a = (Array *)p_a; - memnew_placement(dest, Vector<String>); - - dest->resize(a->size()); - for (int i = 0; i < a->size(); i++) { - dest->set(i, (*a)[i]); - } -} - -const godot_string GDAPI *godot_packed_string_array_ptr(const godot_packed_string_array *p_self) { - const Vector<String> *self = (const Vector<String> *)p_self; - return (const godot_string *)self->ptr(); -} - -godot_string GDAPI *godot_packed_string_array_ptrw(godot_packed_string_array *p_self) { - Vector<String> *self = (Vector<String> *)p_self; - return (godot_string *)self->ptrw(); -} - -void GDAPI godot_packed_string_array_append(godot_packed_string_array *p_self, const godot_string *p_data) { - Vector<String> *self = (Vector<String> *)p_self; - String &s = *(String *)p_data; - self->push_back(s); -} - -void GDAPI godot_packed_string_array_append_array(godot_packed_string_array *p_self, const godot_packed_string_array *p_array) { - Vector<String> *self = (Vector<String> *)p_self; - Vector<String> *array = (Vector<String> *)p_array; - self->append_array(*array); -} - -godot_error GDAPI godot_packed_string_array_insert(godot_packed_string_array *p_self, const godot_int p_idx, const godot_string *p_data) { - Vector<String> *self = (Vector<String> *)p_self; - String &s = *(String *)p_data; - return (godot_error)self->insert(p_idx, s); -} - -godot_bool GDAPI godot_packed_string_array_has(godot_packed_string_array *p_self, const godot_string *p_value) { - Vector<String> *self = (Vector<String> *)p_self; - String &s = *(String *)p_value; - return (godot_bool)self->has(s); + ((PackedFloat64Array *)p_self)->~PackedFloat64Array(); } -void GDAPI godot_packed_string_array_sort(godot_packed_string_array *p_self) { - Vector<String> *self = (Vector<String> *)p_self; - self->sort(); +double GDAPI *godot_packed_float64_array_operator_index(godot_packed_float64_array *p_self, godot_int p_index) { + PackedFloat64Array *self = (PackedFloat64Array *)p_self; + return (double *)&self->operator[](p_index); } -void GDAPI godot_packed_string_array_invert(godot_packed_string_array *p_self) { - Vector<String> *self = (Vector<String> *)p_self; - self->invert(); +const double GDAPI *godot_packed_float64_array_operator_index_const(const godot_packed_float64_array *p_self, godot_int p_index) { + const PackedFloat64Array *self = (const PackedFloat64Array *)p_self; + return (const double *)&self->operator[](p_index); } -void GDAPI godot_packed_string_array_push_back(godot_packed_string_array *p_self, const godot_string *p_data) { - Vector<String> *self = (Vector<String> *)p_self; - String &s = *(String *)p_data; - self->push_back(s); -} - -void GDAPI godot_packed_string_array_remove(godot_packed_string_array *p_self, const godot_int p_idx) { - Vector<String> *self = (Vector<String> *)p_self; - self->remove(p_idx); -} - -void GDAPI godot_packed_string_array_resize(godot_packed_string_array *p_self, const godot_int p_size) { - Vector<String> *self = (Vector<String> *)p_self; - self->resize(p_size); -} - -void GDAPI godot_packed_string_array_set(godot_packed_string_array *p_self, const godot_int p_idx, const godot_string *p_data) { - Vector<String> *self = (Vector<String> *)p_self; - String &s = *(String *)p_data; - self->set(p_idx, s); -} - -godot_string GDAPI godot_packed_string_array_get(const godot_packed_string_array *p_self, const godot_int p_idx) { - const Vector<String> *self = (const Vector<String> *)p_self; - godot_string str; - String *s = (String *)&str; - memnew_placement(s, String); - *s = self->get(p_idx); - return str; -} - -godot_int GDAPI godot_packed_string_array_size(const godot_packed_string_array *p_self) { - const Vector<String> *self = (const Vector<String> *)p_self; - return self->size(); -} +// string -godot_bool GDAPI godot_packed_string_array_empty(const godot_packed_string_array *p_self) { - const Vector<String> *self = (const Vector<String> *)p_self; - return self->empty(); +void GDAPI godot_packed_string_array_new(godot_packed_string_array *p_self) { + memnew_placement(p_self, PackedStringArray); } void GDAPI godot_packed_string_array_destroy(godot_packed_string_array *p_self) { - ((Vector<String> *)p_self)->~Vector(); -} - -// vector2 - -void GDAPI godot_packed_vector2_array_new(godot_packed_vector2_array *r_dest) { - Vector<Vector2> *dest = (Vector<Vector2> *)r_dest; - memnew_placement(dest, Vector<Vector2>); -} - -void GDAPI godot_packed_vector2_array_new_copy(godot_packed_vector2_array *r_dest, const godot_packed_vector2_array *p_src) { - Vector<Vector2> *dest = (Vector<Vector2> *)r_dest; - const Vector<Vector2> *src = (const Vector<Vector2> *)p_src; - memnew_placement(dest, Vector<Vector2>(*src)); -} - -void GDAPI godot_packed_vector2_array_new_with_array(godot_packed_vector2_array *r_dest, const godot_array *p_a) { - Vector<Vector2> *dest = (Vector<Vector2> *)r_dest; - Array *a = (Array *)p_a; - memnew_placement(dest, Vector<Vector2>); - - dest->resize(a->size()); - for (int i = 0; i < a->size(); i++) { - dest->set(i, (*a)[i]); - } + ((PackedStringArray *)p_self)->~PackedStringArray(); } -const godot_vector2 GDAPI *godot_packed_vector2_array_ptr(const godot_packed_vector2_array *p_self) { - const Vector<Vector2> *self = (const Vector<Vector2> *)p_self; - return (const godot_vector2 *)self->ptr(); +godot_string GDAPI *godot_packed_string_array_operator_index(godot_packed_string_array *p_self, godot_int p_index) { + PackedStringArray *self = (PackedStringArray *)p_self; + return (godot_string *)&self->operator[](p_index); } -godot_vector2 GDAPI *godot_packed_vector2_array_ptrw(godot_packed_vector2_array *p_self) { - Vector<Vector2> *self = (Vector<Vector2> *)p_self; - return (godot_vector2 *)self->ptrw(); +const godot_string GDAPI *godot_packed_string_array_operator_index_const(const godot_packed_string_array *p_self, godot_int p_index) { + const PackedStringArray *self = (const PackedStringArray *)p_self; + return (const godot_string *)&self->operator[](p_index); } -void GDAPI godot_packed_vector2_array_append(godot_packed_vector2_array *p_self, const godot_vector2 *p_data) { - Vector<Vector2> *self = (Vector<Vector2> *)p_self; - Vector2 &s = *(Vector2 *)p_data; - self->push_back(s); -} - -void GDAPI godot_packed_vector2_array_append_array(godot_packed_vector2_array *p_self, const godot_packed_vector2_array *p_array) { - Vector<Vector2> *self = (Vector<Vector2> *)p_self; - Vector<Vector2> *array = (Vector<Vector2> *)p_array; - self->append_array(*array); -} - -godot_error GDAPI godot_packed_vector2_array_insert(godot_packed_vector2_array *p_self, const godot_int p_idx, const godot_vector2 *p_data) { - Vector<Vector2> *self = (Vector<Vector2> *)p_self; - Vector2 &s = *(Vector2 *)p_data; - return (godot_error)self->insert(p_idx, s); -} - -godot_bool GDAPI godot_packed_vector2_array_has(godot_packed_vector2_array *p_self, const godot_vector2 *p_value) { - Vector<Vector2> *self = (Vector<Vector2> *)p_self; - Vector2 &v = *(Vector2 *)p_value; - return (godot_bool)self->has(v); -} - -void GDAPI godot_packed_vector2_array_sort(godot_packed_vector2_array *p_self) { - Vector<Vector2> *self = (Vector<Vector2> *)p_self; - self->sort(); -} - -void GDAPI godot_packed_vector2_array_invert(godot_packed_vector2_array *p_self) { - Vector<Vector2> *self = (Vector<Vector2> *)p_self; - self->invert(); -} - -void GDAPI godot_packed_vector2_array_push_back(godot_packed_vector2_array *p_self, const godot_vector2 *p_data) { - Vector<Vector2> *self = (Vector<Vector2> *)p_self; - Vector2 &s = *(Vector2 *)p_data; - self->push_back(s); -} - -void GDAPI godot_packed_vector2_array_remove(godot_packed_vector2_array *p_self, const godot_int p_idx) { - Vector<Vector2> *self = (Vector<Vector2> *)p_self; - self->remove(p_idx); -} - -void GDAPI godot_packed_vector2_array_resize(godot_packed_vector2_array *p_self, const godot_int p_size) { - Vector<Vector2> *self = (Vector<Vector2> *)p_self; - self->resize(p_size); -} - -void GDAPI godot_packed_vector2_array_set(godot_packed_vector2_array *p_self, const godot_int p_idx, const godot_vector2 *p_data) { - Vector<Vector2> *self = (Vector<Vector2> *)p_self; - Vector2 &s = *(Vector2 *)p_data; - self->set(p_idx, s); -} - -godot_vector2 GDAPI godot_packed_vector2_array_get(const godot_packed_vector2_array *p_self, const godot_int p_idx) { - const Vector<Vector2> *self = (const Vector<Vector2> *)p_self; - godot_vector2 v; - Vector2 *s = (Vector2 *)&v; - *s = self->get(p_idx); - return v; -} - -godot_int GDAPI godot_packed_vector2_array_size(const godot_packed_vector2_array *p_self) { - const Vector<Vector2> *self = (const Vector<Vector2> *)p_self; - return self->size(); -} +// vector2 -godot_bool GDAPI godot_packed_vector2_array_empty(const godot_packed_vector2_array *p_self) { - const Vector<Vector2> *self = (const Vector<Vector2> *)p_self; - return self->empty(); +void GDAPI godot_packed_vector2_array_new(godot_packed_vector2_array *p_self) { + memnew_placement(p_self, PackedVector2Array); } void GDAPI godot_packed_vector2_array_destroy(godot_packed_vector2_array *p_self) { - ((Vector<Vector2> *)p_self)->~Vector(); -} - -// vector2i - -void GDAPI godot_packed_vector2i_array_new(godot_packed_vector2i_array *r_dest) { - Vector<Vector2i> *dest = (Vector<Vector2i> *)r_dest; - memnew_placement(dest, Vector<Vector2i>); -} - -void GDAPI godot_packed_vector2i_array_new_copy(godot_packed_vector2i_array *r_dest, const godot_packed_vector2i_array *p_src) { - Vector<Vector2i> *dest = (Vector<Vector2i> *)r_dest; - const Vector<Vector2i> *src = (const Vector<Vector2i> *)p_src; - memnew_placement(dest, Vector<Vector2i>(*src)); -} - -void GDAPI godot_packed_vector2i_array_new_with_array(godot_packed_vector2i_array *r_dest, const godot_array *p_a) { - Vector<Vector2i> *dest = (Vector<Vector2i> *)r_dest; - Array *a = (Array *)p_a; - memnew_placement(dest, Vector<Vector2i>); - - dest->resize(a->size()); - for (int i = 0; i < a->size(); i++) { - dest->set(i, (*a)[i]); - } -} - -const godot_vector2i GDAPI *godot_packed_vector2i_array_ptr(const godot_packed_vector2i_array *p_self) { - const Vector<Vector2i> *self = (const Vector<Vector2i> *)p_self; - return (const godot_vector2i *)self->ptr(); -} - -godot_vector2i GDAPI *godot_packed_vector2i_array_ptrw(godot_packed_vector2i_array *p_self) { - Vector<Vector2i> *self = (Vector<Vector2i> *)p_self; - return (godot_vector2i *)self->ptrw(); -} - -void GDAPI godot_packed_vector2i_array_append(godot_packed_vector2i_array *p_self, const godot_vector2i *p_data) { - Vector<Vector2i> *self = (Vector<Vector2i> *)p_self; - Vector2i &s = *(Vector2i *)p_data; - self->push_back(s); + ((PackedVector2Array *)p_self)->~PackedVector2Array(); } -void GDAPI godot_packed_vector2i_array_append_array(godot_packed_vector2i_array *p_self, const godot_packed_vector2i_array *p_array) { - Vector<Vector2i> *self = (Vector<Vector2i> *)p_self; - Vector<Vector2i> *array = (Vector<Vector2i> *)p_array; - self->append_array(*array); -} - -godot_error GDAPI godot_packed_vector2i_array_insert(godot_packed_vector2i_array *p_self, const godot_int p_idx, const godot_vector2i *p_data) { - Vector<Vector2i> *self = (Vector<Vector2i> *)p_self; - Vector2i &s = *(Vector2i *)p_data; - return (godot_error)self->insert(p_idx, s); +godot_vector2 GDAPI *godot_packed_vector2_array_operator_index(godot_packed_vector2_array *p_self, godot_int p_index) { + PackedVector2Array *self = (PackedVector2Array *)p_self; + return (godot_vector2 *)&self->operator[](p_index); } -godot_bool GDAPI godot_packed_vector2i_array_has(godot_packed_vector2i_array *p_self, const godot_vector2i *p_value) { - Vector<Vector2i> *self = (Vector<Vector2i> *)p_self; - Vector2i &v = *(Vector2i *)p_value; - return (godot_bool)self->has(v); -} - -void GDAPI godot_packed_vector2i_array_sort(godot_packed_vector2i_array *p_self) { - Vector<Vector2i> *self = (Vector<Vector2i> *)p_self; - self->sort(); -} - -void GDAPI godot_packed_vector2i_array_invert(godot_packed_vector2i_array *p_self) { - Vector<Vector2i> *self = (Vector<Vector2i> *)p_self; - self->invert(); +const godot_vector2 GDAPI *godot_packed_vector2_array_operator_index_const(const godot_packed_vector2_array *p_self, godot_int p_index) { + const PackedVector2Array *self = (const PackedVector2Array *)p_self; + return (const godot_vector2 *)&self->operator[](p_index); } -void GDAPI godot_packed_vector2i_array_push_back(godot_packed_vector2i_array *p_self, const godot_vector2i *p_data) { - Vector<Vector2i> *self = (Vector<Vector2i> *)p_self; - Vector2i &s = *(Vector2i *)p_data; - self->push_back(s); -} +// vector2i -void GDAPI godot_packed_vector2i_array_remove(godot_packed_vector2i_array *p_self, const godot_int p_idx) { - Vector<Vector2i> *self = (Vector<Vector2i> *)p_self; - self->remove(p_idx); +void GDAPI godot_packed_vector2i_array_new(godot_packed_vector2i_array *p_self) { + memnew_placement(p_self, Vector<Vector2i>); } -void GDAPI godot_packed_vector2i_array_resize(godot_packed_vector2i_array *p_self, const godot_int p_size) { - Vector<Vector2i> *self = (Vector<Vector2i> *)p_self; - self->resize(p_size); +void GDAPI godot_packed_vector2i_array_destroy(godot_packed_vector2i_array *p_self) { + ((Vector<Vector2i> *)p_self)->~Vector(); } -void GDAPI godot_packed_vector2i_array_set(godot_packed_vector2i_array *p_self, const godot_int p_idx, const godot_vector2i *p_data) { +godot_vector2i GDAPI *godot_packed_vector2i_array_operator_index(godot_packed_vector2i_array *p_self, godot_int p_index) { Vector<Vector2i> *self = (Vector<Vector2i> *)p_self; - Vector2i &s = *(Vector2i *)p_data; - self->set(p_idx, s); + return (godot_vector2i *)&self->operator[](p_index); } -godot_vector2i GDAPI godot_packed_vector2i_array_get(const godot_packed_vector2i_array *p_self, const godot_int p_idx) { +const godot_vector2i GDAPI *godot_packed_vector2i_array_operator_index_const(const godot_packed_vector2i_array *p_self, godot_int p_index) { const Vector<Vector2i> *self = (const Vector<Vector2i> *)p_self; - godot_vector2i v; - Vector2i *s = (Vector2i *)&v; - *s = self->get(p_idx); - return v; -} - -godot_int GDAPI godot_packed_vector2i_array_size(const godot_packed_vector2i_array *p_self) { - const Vector<Vector2i> *self = (const Vector<Vector2i> *)p_self; - return self->size(); -} - -godot_bool GDAPI godot_packed_vector2i_array_empty(const godot_packed_vector2i_array *p_self) { - const Vector<Vector2i> *self = (const Vector<Vector2i> *)p_self; - return self->empty(); -} - -void GDAPI godot_packed_vector2i_array_destroy(godot_packed_vector2i_array *p_self) { - ((Vector<Vector2i> *)p_self)->~Vector(); + return (const godot_vector2i *)&self->operator[](p_index); } // vector3 -void GDAPI godot_packed_vector3_array_new(godot_packed_vector3_array *r_dest) { - Vector<Vector3> *dest = (Vector<Vector3> *)r_dest; - memnew_placement(dest, Vector<Vector3>); -} - -void GDAPI godot_packed_vector3_array_new_copy(godot_packed_vector3_array *r_dest, const godot_packed_vector3_array *p_src) { - Vector<Vector3> *dest = (Vector<Vector3> *)r_dest; - const Vector<Vector3> *src = (const Vector<Vector3> *)p_src; - memnew_placement(dest, Vector<Vector3>(*src)); -} - -void GDAPI godot_packed_vector3_array_new_with_array(godot_packed_vector3_array *r_dest, const godot_array *p_a) { - Vector<Vector3> *dest = (Vector<Vector3> *)r_dest; - Array *a = (Array *)p_a; - memnew_placement(dest, Vector<Vector3>); - - dest->resize(a->size()); - for (int i = 0; i < a->size(); i++) { - dest->set(i, (*a)[i]); - } -} - -const godot_vector3 GDAPI *godot_packed_vector3_array_ptr(const godot_packed_vector3_array *p_self) { - const Vector<Vector3> *self = (const Vector<Vector3> *)p_self; - return (const godot_vector3 *)self->ptr(); -} - -godot_vector3 GDAPI *godot_packed_vector3_array_ptrw(godot_packed_vector3_array *p_self) { - Vector<Vector3> *self = (Vector<Vector3> *)p_self; - return (godot_vector3 *)self->ptrw(); -} - -void GDAPI godot_packed_vector3_array_append(godot_packed_vector3_array *p_self, const godot_vector3 *p_data) { - Vector<Vector3> *self = (Vector<Vector3> *)p_self; - Vector3 &s = *(Vector3 *)p_data; - self->push_back(s); -} - -void GDAPI godot_packed_vector3_array_append_array(godot_packed_vector3_array *p_self, const godot_packed_vector3_array *p_array) { - Vector<Vector3> *self = (Vector<Vector3> *)p_self; - Vector<Vector3> *array = (Vector<Vector3> *)p_array; - self->append_array(*array); -} - -godot_error GDAPI godot_packed_vector3_array_insert(godot_packed_vector3_array *p_self, const godot_int p_idx, const godot_vector3 *p_data) { - Vector<Vector3> *self = (Vector<Vector3> *)p_self; - Vector3 &s = *(Vector3 *)p_data; - return (godot_error)self->insert(p_idx, s); -} - -godot_bool GDAPI godot_packed_vector3_array_has(godot_packed_vector3_array *p_self, const godot_vector3 *p_value) { - Vector<Vector3> *self = (Vector<Vector3> *)p_self; - Vector3 &v = *(Vector3 *)p_value; - return (godot_bool)self->has(v); -} - -void GDAPI godot_packed_vector3_array_sort(godot_packed_vector3_array *p_self) { - Vector<Vector3> *self = (Vector<Vector3> *)p_self; - self->sort(); -} - -void GDAPI godot_packed_vector3_array_invert(godot_packed_vector3_array *p_self) { - Vector<Vector3> *self = (Vector<Vector3> *)p_self; - self->invert(); -} - -void GDAPI godot_packed_vector3_array_push_back(godot_packed_vector3_array *p_self, const godot_vector3 *p_data) { - Vector<Vector3> *self = (Vector<Vector3> *)p_self; - Vector3 &s = *(Vector3 *)p_data; - self->push_back(s); -} - -void GDAPI godot_packed_vector3_array_remove(godot_packed_vector3_array *p_self, const godot_int p_idx) { - Vector<Vector3> *self = (Vector<Vector3> *)p_self; - self->remove(p_idx); -} - -void GDAPI godot_packed_vector3_array_resize(godot_packed_vector3_array *p_self, const godot_int p_size) { - Vector<Vector3> *self = (Vector<Vector3> *)p_self; - self->resize(p_size); -} - -void GDAPI godot_packed_vector3_array_set(godot_packed_vector3_array *p_self, const godot_int p_idx, const godot_vector3 *p_data) { - Vector<Vector3> *self = (Vector<Vector3> *)p_self; - Vector3 &s = *(Vector3 *)p_data; - self->set(p_idx, s); -} - -godot_vector3 GDAPI godot_packed_vector3_array_get(const godot_packed_vector3_array *p_self, const godot_int p_idx) { - const Vector<Vector3> *self = (const Vector<Vector3> *)p_self; - godot_vector3 v; - Vector3 *s = (Vector3 *)&v; - *s = self->get(p_idx); - return v; -} - -godot_int GDAPI godot_packed_vector3_array_size(const godot_packed_vector3_array *p_self) { - const Vector<Vector3> *self = (const Vector<Vector3> *)p_self; - return self->size(); -} - -godot_bool GDAPI godot_packed_vector3_array_empty(const godot_packed_vector3_array *p_self) { - const Vector<Vector3> *self = (const Vector<Vector3> *)p_self; - return self->empty(); +void GDAPI godot_packed_vector3_array_new(godot_packed_vector3_array *p_self) { + memnew_placement(p_self, PackedVector3Array); } void GDAPI godot_packed_vector3_array_destroy(godot_packed_vector3_array *p_self) { - ((Vector<Vector3> *)p_self)->~Vector(); -} - -// color - -void GDAPI godot_packed_color_array_new(godot_packed_color_array *r_dest) { - Vector<Color> *dest = (Vector<Color> *)r_dest; - memnew_placement(dest, Vector<Color>); + ((PackedVector3Array *)p_self)->~PackedVector3Array(); } -void GDAPI godot_packed_color_array_new_copy(godot_packed_color_array *r_dest, const godot_packed_color_array *p_src) { - Vector<Color> *dest = (Vector<Color> *)r_dest; - const Vector<Color> *src = (const Vector<Color> *)p_src; - memnew_placement(dest, Vector<Color>(*src)); -} - -void GDAPI godot_packed_color_array_new_with_array(godot_packed_color_array *r_dest, const godot_array *p_a) { - Vector<Color> *dest = (Vector<Color> *)r_dest; - Array *a = (Array *)p_a; - memnew_placement(dest, Vector<Color>); - - dest->resize(a->size()); - for (int i = 0; i < a->size(); i++) { - dest->set(i, (*a)[i]); - } +godot_vector3 GDAPI *godot_packed_vector3_array_operator_index(godot_packed_vector3_array *p_self, godot_int p_index) { + PackedVector3Array *self = (PackedVector3Array *)p_self; + return (godot_vector3 *)&self->operator[](p_index); } -const godot_color GDAPI *godot_packed_color_array_ptr(const godot_packed_color_array *p_self) { - const Vector<Color> *self = (const Vector<Color> *)p_self; - return (const godot_color *)self->ptr(); +const godot_vector3 GDAPI *godot_packed_vector3_array_operator_index_const(const godot_packed_vector3_array *p_self, godot_int p_index) { + const PackedVector3Array *self = (const PackedVector3Array *)p_self; + return (const godot_vector3 *)&self->operator[](p_index); } -godot_color GDAPI *godot_packed_color_array_ptrw(godot_packed_color_array *p_self) { - Vector<Color> *self = (Vector<Color> *)p_self; - return (godot_color *)self->ptrw(); -} - -void GDAPI godot_packed_color_array_append(godot_packed_color_array *p_self, const godot_color *p_data) { - Vector<Color> *self = (Vector<Color> *)p_self; - Color &s = *(Color *)p_data; - self->push_back(s); -} - -void GDAPI godot_packed_color_array_append_array(godot_packed_color_array *p_self, const godot_packed_color_array *p_array) { - Vector<Color> *self = (Vector<Color> *)p_self; - Vector<Color> *array = (Vector<Color> *)p_array; - self->append_array(*array); -} +// vector3i -godot_error GDAPI godot_packed_color_array_insert(godot_packed_color_array *p_self, const godot_int p_idx, const godot_color *p_data) { - Vector<Color> *self = (Vector<Color> *)p_self; - Color &s = *(Color *)p_data; - return (godot_error)self->insert(p_idx, s); +void GDAPI godot_packed_vector3i_array_new(godot_packed_vector3i_array *p_self) { + memnew_placement(p_self, Vector<Vector3i>); } -godot_bool GDAPI godot_packed_color_array_has(godot_packed_color_array *p_self, const godot_color *p_value) { - Vector<Color> *self = (Vector<Color> *)p_self; - Color &c = *(Color *)p_value; - return (godot_bool)self->has(c); +void GDAPI godot_packed_vector3i_array_destroy(godot_packed_vector3i_array *p_self) { + ((Vector<Vector3i> *)p_self)->~Vector(); } -void GDAPI godot_packed_color_array_sort(godot_packed_color_array *p_self) { - Vector<Color> *self = (Vector<Color> *)p_self; - self->sort(); +godot_vector3i GDAPI *godot_packed_vector3i_array_operator_index(godot_packed_vector3i_array *p_self, godot_int p_index) { + Vector<Vector3i> *self = (Vector<Vector3i> *)p_self; + return (godot_vector3i *)&self->operator[](p_index); } -void GDAPI godot_packed_color_array_invert(godot_packed_color_array *p_self) { - Vector<Color> *self = (Vector<Color> *)p_self; - self->invert(); +const godot_vector3i GDAPI *godot_packed_vector3i_array_operator_index_const(const godot_packed_vector3i_array *p_self, godot_int p_index) { + const Vector<Vector3i> *self = (const Vector<Vector3i> *)p_self; + return (const godot_vector3i *)&self->operator[](p_index); } -void GDAPI godot_packed_color_array_push_back(godot_packed_color_array *p_self, const godot_color *p_data) { - Vector<Color> *self = (Vector<Color> *)p_self; - Color &s = *(Color *)p_data; - self->push_back(s); -} - -void GDAPI godot_packed_color_array_remove(godot_packed_color_array *p_self, const godot_int p_idx) { - Vector<Color> *self = (Vector<Color> *)p_self; - self->remove(p_idx); -} - -void GDAPI godot_packed_color_array_resize(godot_packed_color_array *p_self, const godot_int p_size) { - Vector<Color> *self = (Vector<Color> *)p_self; - self->resize(p_size); -} - -void GDAPI godot_packed_color_array_set(godot_packed_color_array *p_self, const godot_int p_idx, const godot_color *p_data) { - Vector<Color> *self = (Vector<Color> *)p_self; - Color &s = *(Color *)p_data; - self->set(p_idx, s); -} +// color -godot_color GDAPI godot_packed_color_array_get(const godot_packed_color_array *p_self, const godot_int p_idx) { - const Vector<Color> *self = (const Vector<Color> *)p_self; - godot_color v; - Color *s = (Color *)&v; - *s = self->get(p_idx); - return v; +void GDAPI godot_packed_color_array_new(godot_packed_color_array *p_self) { + memnew_placement(p_self, PackedColorArray); } -godot_int GDAPI godot_packed_color_array_size(const godot_packed_color_array *p_self) { - const Vector<Color> *self = (const Vector<Color> *)p_self; - return self->size(); +void GDAPI godot_packed_color_array_destroy(godot_packed_color_array *p_self) { + ((PackedColorArray *)p_self)->~PackedColorArray(); } -godot_bool GDAPI godot_packed_color_array_empty(const godot_packed_color_array *p_self) { - const Vector<Color> *self = (const Vector<Color> *)p_self; - return self->empty(); +godot_color GDAPI *godot_packed_color_array_operator_index(godot_packed_color_array *p_self, godot_int p_index) { + PackedColorArray *self = (PackedColorArray *)p_self; + return (godot_color *)&self->operator[](p_index); } -void GDAPI godot_packed_color_array_destroy(godot_packed_color_array *p_self) { - ((Vector<Color> *)p_self)->~Vector(); +const godot_color GDAPI *godot_packed_color_array_operator_index_const(const godot_packed_color_array *p_self, godot_int p_index) { + const PackedColorArray *self = (const PackedColorArray *)p_self; + return (const godot_color *)&self->operator[](p_index); } #ifdef __cplusplus diff --git a/modules/gdnative/gdnative/plane.cpp b/modules/gdnative/gdnative/plane.cpp index 99fb5ff10a..61d5e09fad 100644 --- a/modules/gdnative/gdnative/plane.cpp +++ b/modules/gdnative/gdnative/plane.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -31,139 +31,15 @@ #include "gdnative/plane.h" #include "core/math/plane.h" -#include "core/variant/variant.h" + +static_assert(sizeof(godot_plane) == sizeof(Plane), "Plane size mismatch"); #ifdef __cplusplus extern "C" { #endif -static_assert(sizeof(godot_plane) == sizeof(Plane), "Plane size mismatch"); - -void GDAPI godot_plane_new_with_reals(godot_plane *r_dest, const godot_real p_a, const godot_real p_b, const godot_real p_c, const godot_real p_d) { - Plane *dest = (Plane *)r_dest; - *dest = Plane(p_a, p_b, p_c, p_d); -} - -void GDAPI godot_plane_new_with_vectors(godot_plane *r_dest, const godot_vector3 *p_v1, const godot_vector3 *p_v2, const godot_vector3 *p_v3) { - const Vector3 *v1 = (const Vector3 *)p_v1; - const Vector3 *v2 = (const Vector3 *)p_v2; - const Vector3 *v3 = (const Vector3 *)p_v3; - Plane *dest = (Plane *)r_dest; - *dest = Plane(*v1, *v2, *v3); -} - -void GDAPI godot_plane_new_with_normal(godot_plane *r_dest, const godot_vector3 *p_normal, const godot_real p_d) { - const Vector3 *normal = (const Vector3 *)p_normal; - Plane *dest = (Plane *)r_dest; - *dest = Plane(*normal, p_d); -} - -godot_string GDAPI godot_plane_as_string(const godot_plane *p_self) { - godot_string ret; - const Plane *self = (const Plane *)p_self; - memnew_placement(&ret, String(*self)); - return ret; -} - -godot_plane GDAPI godot_plane_normalized(const godot_plane *p_self) { - godot_plane dest; - const Plane *self = (const Plane *)p_self; - *((Plane *)&dest) = self->normalized(); - return dest; -} - -godot_vector3 GDAPI godot_plane_center(const godot_plane *p_self) { - godot_vector3 dest; - const Plane *self = (const Plane *)p_self; - *((Vector3 *)&dest) = self->center(); - return dest; -} - -godot_bool GDAPI godot_plane_is_point_over(const godot_plane *p_self, const godot_vector3 *p_point) { - const Plane *self = (const Plane *)p_self; - const Vector3 *point = (const Vector3 *)p_point; - return self->is_point_over(*point); -} - -godot_real GDAPI godot_plane_distance_to(const godot_plane *p_self, const godot_vector3 *p_point) { - const Plane *self = (const Plane *)p_self; - const Vector3 *point = (const Vector3 *)p_point; - return self->distance_to(*point); -} - -godot_bool GDAPI godot_plane_has_point(const godot_plane *p_self, const godot_vector3 *p_point, const godot_real p_epsilon) { - const Plane *self = (const Plane *)p_self; - const Vector3 *point = (const Vector3 *)p_point; - return self->has_point(*point, p_epsilon); -} - -godot_vector3 GDAPI godot_plane_project(const godot_plane *p_self, const godot_vector3 *p_point) { - godot_vector3 dest; - const Plane *self = (const Plane *)p_self; - const Vector3 *point = (const Vector3 *)p_point; - *((Vector3 *)&dest) = self->project(*point); - return dest; -} - -godot_bool GDAPI godot_plane_intersect_3(const godot_plane *p_self, godot_vector3 *r_dest, const godot_plane *p_b, const godot_plane *p_c) { - const Plane *self = (const Plane *)p_self; - const Plane *b = (const Plane *)p_b; - const Plane *c = (const Plane *)p_c; - Vector3 *dest = (Vector3 *)r_dest; - return self->intersect_3(*b, *c, dest); -} - -godot_bool GDAPI godot_plane_intersects_ray(const godot_plane *p_self, godot_vector3 *r_dest, const godot_vector3 *p_from, const godot_vector3 *p_dir) { - const Plane *self = (const Plane *)p_self; - const Vector3 *from = (const Vector3 *)p_from; - const Vector3 *dir = (const Vector3 *)p_dir; - Vector3 *dest = (Vector3 *)r_dest; - return self->intersects_ray(*from, *dir, dest); -} - -godot_bool GDAPI godot_plane_intersects_segment(const godot_plane *p_self, godot_vector3 *r_dest, const godot_vector3 *p_begin, const godot_vector3 *p_end) { - const Plane *self = (const Plane *)p_self; - const Vector3 *begin = (const Vector3 *)p_begin; - const Vector3 *end = (const Vector3 *)p_end; - Vector3 *dest = (Vector3 *)r_dest; - return self->intersects_segment(*begin, *end, dest); -} - -godot_plane GDAPI godot_plane_operator_neg(const godot_plane *p_self) { - godot_plane raw_dest; - Plane *dest = (Plane *)&raw_dest; - const Plane *self = (const Plane *)p_self; - *dest = -(*self); - return raw_dest; -} - -godot_bool GDAPI godot_plane_operator_equal(const godot_plane *p_self, const godot_plane *p_b) { - const Plane *self = (const Plane *)p_self; - const Plane *b = (const Plane *)p_b; - return *self == *b; -} - -void GDAPI godot_plane_set_normal(godot_plane *p_self, const godot_vector3 *p_normal) { - Plane *self = (Plane *)p_self; - const Vector3 *normal = (const Vector3 *)p_normal; - self->set_normal(*normal); -} - -godot_vector3 GDAPI godot_plane_get_normal(const godot_plane *p_self) { - const Plane *self = (const Plane *)p_self; - const Vector3 normal = self->get_normal(); - godot_vector3 *v3 = (godot_vector3 *)&normal; - return *v3; -} - -godot_real GDAPI godot_plane_get_d(const godot_plane *p_self) { - const Plane *self = (const Plane *)p_self; - return self->d; -} - -void GDAPI godot_plane_set_d(godot_plane *p_self, const godot_real p_d) { - Plane *self = (Plane *)p_self; - self->d = p_d; +void GDAPI godot_plane_new(godot_plane *p_self) { + memnew_placement(p_self, Plane); } #ifdef __cplusplus diff --git a/modules/gdnative/gdnative/quat.cpp b/modules/gdnative/gdnative/quat.cpp index a41886e780..836d6390d6 100644 --- a/modules/gdnative/gdnative/quat.cpp +++ b/modules/gdnative/gdnative/quat.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -31,205 +31,25 @@ #include "gdnative/quat.h" #include "core/math/quat.h" -#include "core/variant/variant.h" + +static_assert(sizeof(godot_quat) == sizeof(Quat), "Quat size mismatch"); #ifdef __cplusplus extern "C" { #endif -static_assert(sizeof(godot_quat) == sizeof(Quat), "Quat size mismatch"); - -void GDAPI godot_quat_new(godot_quat *r_dest, const godot_real p_x, const godot_real p_y, const godot_real p_z, const godot_real p_w) { - Quat *dest = (Quat *)r_dest; - *dest = Quat(p_x, p_y, p_z, p_w); -} - -void GDAPI godot_quat_new_with_axis_angle(godot_quat *r_dest, const godot_vector3 *p_axis, const godot_real p_angle) { - const Vector3 *axis = (const Vector3 *)p_axis; - Quat *dest = (Quat *)r_dest; - *dest = Quat(*axis, p_angle); +void GDAPI godot_quat_new(godot_quat *p_self) { + memnew_placement(p_self, Quat); } -void GDAPI godot_quat_new_with_basis(godot_quat *r_dest, const godot_basis *p_basis) { - const Basis *basis = (const Basis *)p_basis; - Quat *dest = (Quat *)r_dest; - *dest = Quat(*basis); -} - -void GDAPI godot_quat_new_with_euler(godot_quat *r_dest, const godot_vector3 *p_euler) { - const Vector3 *euler = (const Vector3 *)p_euler; - Quat *dest = (Quat *)r_dest; - *dest = Quat(*euler); -} - -godot_real GDAPI godot_quat_get_x(const godot_quat *p_self) { - const Quat *self = (const Quat *)p_self; - return self->x; -} - -void GDAPI godot_quat_set_x(godot_quat *p_self, const godot_real val) { - Quat *self = (Quat *)p_self; - self->x = val; -} - -godot_real GDAPI godot_quat_get_y(const godot_quat *p_self) { - const Quat *self = (const Quat *)p_self; - return self->y; -} - -void GDAPI godot_quat_set_y(godot_quat *p_self, const godot_real val) { +godot_real_t GDAPI *godot_quat_operator_index(godot_quat *p_self, godot_int p_index) { Quat *self = (Quat *)p_self; - self->y = val; -} - -godot_real GDAPI godot_quat_get_z(const godot_quat *p_self) { - const Quat *self = (const Quat *)p_self; - return self->z; -} - -void GDAPI godot_quat_set_z(godot_quat *p_self, const godot_real val) { - Quat *self = (Quat *)p_self; - self->z = val; -} - -godot_real GDAPI godot_quat_get_w(const godot_quat *p_self) { - const Quat *self = (const Quat *)p_self; - return self->w; -} - -void GDAPI godot_quat_set_w(godot_quat *p_self, const godot_real val) { - Quat *self = (Quat *)p_self; - self->w = val; -} - -godot_string GDAPI godot_quat_as_string(const godot_quat *p_self) { - godot_string ret; - const Quat *self = (const Quat *)p_self; - memnew_placement(&ret, String(*self)); - return ret; -} - -godot_real GDAPI godot_quat_length(const godot_quat *p_self) { - const Quat *self = (const Quat *)p_self; - return self->length(); -} - -godot_real GDAPI godot_quat_length_squared(const godot_quat *p_self) { - const Quat *self = (const Quat *)p_self; - return self->length_squared(); -} - -godot_quat GDAPI godot_quat_normalized(const godot_quat *p_self) { - godot_quat dest; - const Quat *self = (const Quat *)p_self; - *((Quat *)&dest) = self->normalized(); - return dest; -} - -godot_bool GDAPI godot_quat_is_normalized(const godot_quat *p_self) { - const Quat *self = (const Quat *)p_self; - return self->is_normalized(); -} - -godot_quat GDAPI godot_quat_inverse(const godot_quat *p_self) { - godot_quat dest; - const Quat *self = (const Quat *)p_self; - *((Quat *)&dest) = self->inverse(); - return dest; -} - -godot_real GDAPI godot_quat_dot(const godot_quat *p_self, const godot_quat *p_b) { - const Quat *self = (const Quat *)p_self; - const Quat *b = (const Quat *)p_b; - return self->dot(*b); + return (godot_real_t *)&self->operator[](p_index); } -godot_vector3 GDAPI godot_quat_xform(const godot_quat *p_self, const godot_vector3 *p_v) { - godot_vector3 dest; +const godot_real_t GDAPI *godot_quat_operator_index_const(const godot_quat *p_self, godot_int p_index) { const Quat *self = (const Quat *)p_self; - const Vector3 *v = (const Vector3 *)p_v; - *((Vector3 *)&dest) = self->xform(*v); - return dest; -} - -godot_quat GDAPI godot_quat_slerp(const godot_quat *p_self, const godot_quat *p_b, const godot_real p_t) { - godot_quat dest; - const Quat *self = (const Quat *)p_self; - const Quat *b = (const Quat *)p_b; - *((Quat *)&dest) = self->slerp(*b, p_t); - return dest; -} - -godot_quat GDAPI godot_quat_slerpni(const godot_quat *p_self, const godot_quat *p_b, const godot_real p_t) { - godot_quat dest; - const Quat *self = (const Quat *)p_self; - const Quat *b = (const Quat *)p_b; - *((Quat *)&dest) = self->slerpni(*b, p_t); - return dest; -} - -godot_quat GDAPI godot_quat_cubic_slerp(const godot_quat *p_self, const godot_quat *p_b, const godot_quat *p_pre_a, const godot_quat *p_post_b, const godot_real p_t) { - godot_quat dest; - const Quat *self = (const Quat *)p_self; - const Quat *b = (const Quat *)p_b; - const Quat *pre_a = (const Quat *)p_pre_a; - const Quat *post_b = (const Quat *)p_post_b; - *((Quat *)&dest) = self->cubic_slerp(*b, *pre_a, *post_b, p_t); - return dest; -} - -godot_quat GDAPI godot_quat_operator_multiply(const godot_quat *p_self, const godot_real p_b) { - godot_quat raw_dest; - Quat *dest = (Quat *)&raw_dest; - const Quat *self = (const Quat *)p_self; - *dest = *self * p_b; - return raw_dest; -} - -godot_quat GDAPI godot_quat_operator_add(const godot_quat *p_self, const godot_quat *p_b) { - godot_quat raw_dest; - Quat *dest = (Quat *)&raw_dest; - const Quat *self = (const Quat *)p_self; - const Quat *b = (const Quat *)p_b; - *dest = *self + *b; - return raw_dest; -} - -godot_quat GDAPI godot_quat_operator_subtract(const godot_quat *p_self, const godot_quat *p_b) { - godot_quat raw_dest; - Quat *dest = (Quat *)&raw_dest; - const Quat *self = (const Quat *)p_self; - const Quat *b = (const Quat *)p_b; - *dest = *self - *b; - return raw_dest; -} - -godot_quat GDAPI godot_quat_operator_divide(const godot_quat *p_self, const godot_real p_b) { - godot_quat raw_dest; - Quat *dest = (Quat *)&raw_dest; - const Quat *self = (const Quat *)p_self; - *dest = *self / p_b; - return raw_dest; -} - -godot_bool GDAPI godot_quat_operator_equal(const godot_quat *p_self, const godot_quat *p_b) { - const Quat *self = (const Quat *)p_self; - const Quat *b = (const Quat *)p_b; - return *self == *b; -} - -godot_quat GDAPI godot_quat_operator_neg(const godot_quat *p_self) { - godot_quat raw_dest; - Quat *dest = (Quat *)&raw_dest; - const Quat *self = (const Quat *)p_self; - *dest = -(*self); - return raw_dest; -} - -void GDAPI godot_quat_set_axis_angle(godot_quat *p_self, const godot_vector3 *p_axis, const godot_real p_angle) { - Quat *self = (Quat *)p_self; - const Vector3 *axis = (const Vector3 *)p_axis; - self->set_axis_angle(*axis, p_angle); + return (const godot_real_t *)&self->operator[](p_index); } #ifdef __cplusplus diff --git a/modules/gdnative/gdnative/rect2.cpp b/modules/gdnative/gdnative/rect2.cpp index 9897b96c09..086592ec22 100644 --- a/modules/gdnative/gdnative/rect2.cpp +++ b/modules/gdnative/gdnative/rect2.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -30,300 +30,21 @@ #include "gdnative/rect2.h" -#include "core/math/transform_2d.h" -#include "core/variant/variant.h" - -#ifdef __cplusplus -extern "C" { -#endif +#include "core/math/rect2.h" static_assert(sizeof(godot_rect2) == sizeof(Rect2), "Rect2 size mismatch"); static_assert(sizeof(godot_rect2i) == sizeof(Rect2i), "Rect2i size mismatch"); -// Rect2 - -void GDAPI godot_rect2_new_with_position_and_size(godot_rect2 *r_dest, const godot_vector2 *p_pos, const godot_vector2 *p_size) { - const Vector2 *position = (const Vector2 *)p_pos; - const Vector2 *size = (const Vector2 *)p_size; - Rect2 *dest = (Rect2 *)r_dest; - *dest = Rect2(*position, *size); -} - -void GDAPI godot_rect2_new(godot_rect2 *r_dest, const godot_real p_x, const godot_real p_y, const godot_real p_width, const godot_real p_height) { - Rect2 *dest = (Rect2 *)r_dest; - *dest = Rect2(p_x, p_y, p_width, p_height); -} - -godot_string GDAPI godot_rect2_as_string(const godot_rect2 *p_self) { - godot_string ret; - const Rect2 *self = (const Rect2 *)p_self; - memnew_placement(&ret, String(*self)); - return ret; -} - -godot_rect2i GDAPI godot_rect2_as_rect2i(const godot_rect2 *p_self) { - godot_rect2i dest; - const Rect2 *self = (const Rect2 *)p_self; - *((Rect2i *)&dest) = Rect2i(*self); - return dest; -} - -godot_real GDAPI godot_rect2_get_area(const godot_rect2 *p_self) { - const Rect2 *self = (const Rect2 *)p_self; - return self->get_area(); -} - -godot_bool GDAPI godot_rect2_intersects(const godot_rect2 *p_self, const godot_rect2 *p_b) { - const Rect2 *self = (const Rect2 *)p_self; - const Rect2 *b = (const Rect2 *)p_b; - return self->intersects(*b); -} - -godot_bool GDAPI godot_rect2_encloses(const godot_rect2 *p_self, const godot_rect2 *p_b) { - const Rect2 *self = (const Rect2 *)p_self; - const Rect2 *b = (const Rect2 *)p_b; - return self->encloses(*b); -} - -godot_bool GDAPI godot_rect2_has_no_area(const godot_rect2 *p_self) { - const Rect2 *self = (const Rect2 *)p_self; - return self->has_no_area(); -} - -godot_rect2 GDAPI godot_rect2_intersection(const godot_rect2 *p_self, const godot_rect2 *p_b) { - godot_rect2 dest; - const Rect2 *self = (const Rect2 *)p_self; - const Rect2 *b = (const Rect2 *)p_b; - *((Rect2 *)&dest) = self->intersection(*b); - return dest; -} - -godot_rect2 GDAPI godot_rect2_merge(const godot_rect2 *p_self, const godot_rect2 *p_b) { - godot_rect2 dest; - const Rect2 *self = (const Rect2 *)p_self; - const Rect2 *b = (const Rect2 *)p_b; - *((Rect2 *)&dest) = self->merge(*b); - return dest; -} - -godot_bool GDAPI godot_rect2_has_point(const godot_rect2 *p_self, const godot_vector2 *p_point) { - const Rect2 *self = (const Rect2 *)p_self; - const Vector2 *point = (const Vector2 *)p_point; - return self->has_point(*point); -} - -godot_rect2 GDAPI godot_rect2_grow(const godot_rect2 *p_self, const godot_real p_by) { - godot_rect2 dest; - const Rect2 *self = (const Rect2 *)p_self; - - *((Rect2 *)&dest) = self->grow(p_by); - return dest; -} - -godot_rect2 GDAPI godot_rect2_grow_individual(const godot_rect2 *p_self, const godot_real p_left, const godot_real p_top, const godot_real p_right, const godot_real p_bottom) { - godot_rect2 dest; - const Rect2 *self = (const Rect2 *)p_self; - *((Rect2 *)&dest) = self->grow_individual(p_left, p_top, p_right, p_bottom); - return dest; -} - -godot_rect2 GDAPI godot_rect2_grow_margin(const godot_rect2 *p_self, const godot_int p_side, const godot_real p_by) { - godot_rect2 dest; - const Rect2 *self = (const Rect2 *)p_self; - *((Rect2 *)&dest) = self->grow_margin((Side)p_side, p_by); - return dest; -} - -godot_rect2 GDAPI godot_rect2_abs(const godot_rect2 *p_self) { - godot_rect2 dest; - const Rect2 *self = (const Rect2 *)p_self; - *((Rect2 *)&dest) = self->abs(); - return dest; -} - -godot_rect2 GDAPI godot_rect2_expand(const godot_rect2 *p_self, const godot_vector2 *p_to) { - godot_rect2 dest; - const Rect2 *self = (const Rect2 *)p_self; - const Vector2 *to = (const Vector2 *)p_to; - *((Rect2 *)&dest) = self->expand(*to); - return dest; -} - -godot_bool GDAPI godot_rect2_operator_equal(const godot_rect2 *p_self, const godot_rect2 *p_b) { - const Rect2 *self = (const Rect2 *)p_self; - const Rect2 *b = (const Rect2 *)p_b; - return *self == *b; -} - -godot_vector2 GDAPI godot_rect2_get_position(const godot_rect2 *p_self) { - godot_vector2 dest; - Vector2 *d = (Vector2 *)&dest; - const Rect2 *self = (const Rect2 *)p_self; - *d = self->get_position(); - return dest; -} - -godot_vector2 GDAPI godot_rect2_get_size(const godot_rect2 *p_self) { - godot_vector2 dest; - Vector2 *d = (Vector2 *)&dest; - const Rect2 *self = (const Rect2 *)p_self; - *d = self->get_size(); - return dest; -} - -void GDAPI godot_rect2_set_position(godot_rect2 *p_self, const godot_vector2 *p_pos) { - Rect2 *self = (Rect2 *)p_self; - const Vector2 *position = (const Vector2 *)p_pos; - self->set_position(*position); -} - -void GDAPI godot_rect2_set_size(godot_rect2 *p_self, const godot_vector2 *p_size) { - Rect2 *self = (Rect2 *)p_self; - const Vector2 *size = (const Vector2 *)p_size; - self->set_size(*size); -} - -// Rect2i - -void GDAPI godot_rect2i_new_with_position_and_size(godot_rect2i *r_dest, const godot_vector2i *p_pos, const godot_vector2i *p_size) { - const Vector2i *position = (const Vector2i *)p_pos; - const Vector2i *size = (const Vector2i *)p_size; - Rect2i *dest = (Rect2i *)r_dest; - *dest = Rect2i(*position, *size); -} - -void GDAPI godot_rect2i_new(godot_rect2i *r_dest, const godot_int p_x, const godot_int p_y, const godot_int p_width, const godot_int p_height) { - Rect2i *dest = (Rect2i *)r_dest; - *dest = Rect2i(p_x, p_y, p_width, p_height); -} - -godot_string GDAPI godot_rect2i_as_string(const godot_rect2i *p_self) { - godot_string ret; - const Rect2i *self = (const Rect2i *)p_self; - memnew_placement(&ret, String(*self)); - return ret; -} - -godot_rect2 GDAPI godot_rect2i_as_rect2(const godot_rect2i *p_self) { - godot_rect2 dest; - const Rect2i *self = (const Rect2i *)p_self; - *((Rect2 *)&dest) = Rect2(*self); - return dest; -} - -godot_int GDAPI godot_rect2i_get_area(const godot_rect2i *p_self) { - const Rect2i *self = (const Rect2i *)p_self; - return self->get_area(); -} - -godot_bool GDAPI godot_rect2i_intersects(const godot_rect2i *p_self, const godot_rect2i *p_b) { - const Rect2i *self = (const Rect2i *)p_self; - const Rect2i *b = (const Rect2i *)p_b; - return self->intersects(*b); -} - -godot_bool GDAPI godot_rect2i_encloses(const godot_rect2i *p_self, const godot_rect2i *p_b) { - const Rect2i *self = (const Rect2i *)p_self; - const Rect2i *b = (const Rect2i *)p_b; - return self->encloses(*b); -} - -godot_bool GDAPI godot_rect2i_has_no_area(const godot_rect2i *p_self) { - const Rect2i *self = (const Rect2i *)p_self; - return self->has_no_area(); -} - -godot_rect2i GDAPI godot_rect2i_intersection(const godot_rect2i *p_self, const godot_rect2i *p_b) { - godot_rect2i dest; - const Rect2i *self = (const Rect2i *)p_self; - const Rect2i *b = (const Rect2i *)p_b; - *((Rect2i *)&dest) = self->intersection(*b); - return dest; -} - -godot_rect2i GDAPI godot_rect2i_merge(const godot_rect2i *p_self, const godot_rect2i *p_b) { - godot_rect2i dest; - const Rect2i *self = (const Rect2i *)p_self; - const Rect2i *b = (const Rect2i *)p_b; - *((Rect2i *)&dest) = self->merge(*b); - return dest; -} - -godot_bool GDAPI godot_rect2i_has_point(const godot_rect2i *p_self, const godot_vector2i *p_point) { - const Rect2i *self = (const Rect2i *)p_self; - const Vector2i *point = (const Vector2i *)p_point; - return self->has_point(*point); -} - -godot_rect2i GDAPI godot_rect2i_grow(const godot_rect2i *p_self, const godot_int p_by) { - godot_rect2i dest; - const Rect2i *self = (const Rect2i *)p_self; - - *((Rect2i *)&dest) = self->grow(p_by); - return dest; -} - -godot_rect2i GDAPI godot_rect2i_grow_individual(const godot_rect2i *p_self, const godot_int p_left, const godot_int p_top, const godot_int p_right, const godot_int p_bottom) { - godot_rect2i dest; - const Rect2i *self = (const Rect2i *)p_self; - *((Rect2i *)&dest) = self->grow_individual(p_left, p_top, p_right, p_bottom); - return dest; -} - -godot_rect2i GDAPI godot_rect2i_grow_margin(const godot_rect2i *p_self, const godot_int p_side, const godot_int p_by) { - godot_rect2i dest; - const Rect2i *self = (const Rect2i *)p_self; - *((Rect2i *)&dest) = self->grow_margin((Side)p_side, p_by); - return dest; -} - -godot_rect2i GDAPI godot_rect2i_abs(const godot_rect2i *p_self) { - godot_rect2i dest; - const Rect2i *self = (const Rect2i *)p_self; - *((Rect2i *)&dest) = self->abs(); - return dest; -} - -godot_rect2i GDAPI godot_rect2i_expand(const godot_rect2i *p_self, const godot_vector2i *p_to) { - godot_rect2i dest; - const Rect2i *self = (const Rect2i *)p_self; - const Vector2i *to = (const Vector2i *)p_to; - *((Rect2i *)&dest) = self->expand(*to); - return dest; -} - -godot_bool GDAPI godot_rect2i_operator_equal(const godot_rect2i *p_self, const godot_rect2i *p_b) { - const Rect2i *self = (const Rect2i *)p_self; - const Rect2i *b = (const Rect2i *)p_b; - return *self == *b; -} - -godot_vector2i GDAPI godot_rect2i_get_position(const godot_rect2i *p_self) { - godot_vector2i dest; - Vector2i *d = (Vector2i *)&dest; - const Rect2i *self = (const Rect2i *)p_self; - *d = self->get_position(); - return dest; -} - -godot_vector2i GDAPI godot_rect2i_get_size(const godot_rect2i *p_self) { - godot_vector2i dest; - Vector2i *d = (Vector2i *)&dest; - const Rect2i *self = (const Rect2i *)p_self; - *d = self->get_size(); - return dest; -} +#ifdef __cplusplus +extern "C" { +#endif -void GDAPI godot_rect2i_set_position(godot_rect2i *p_self, const godot_vector2i *p_pos) { - Rect2i *self = (Rect2i *)p_self; - const Vector2i *position = (const Vector2i *)p_pos; - self->set_position(*position); +void GDAPI godot_rect2_new(godot_rect2 *p_self) { + memnew_placement(p_self, Rect2); } -void GDAPI godot_rect2i_set_size(godot_rect2i *p_self, const godot_vector2i *p_size) { - Rect2i *self = (Rect2i *)p_self; - const Vector2i *size = (const Vector2i *)p_size; - self->set_size(*size); +void GDAPI godot_rect2i_new(godot_rect2i *p_self) { + memnew_placement(p_self, Rect2i); } #ifdef __cplusplus diff --git a/modules/gdnative/gdnative/rid.cpp b/modules/gdnative/gdnative/rid.cpp index 24af04558b..5cab9a21ed 100644 --- a/modules/gdnative/gdnative/rid.cpp +++ b/modules/gdnative/gdnative/rid.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -30,45 +30,17 @@ #include "gdnative/rid.h" -#include "core/io/resource.h" +#include "core/os/memory.h" #include "core/templates/rid.h" -#include "core/variant/variant.h" + +static_assert(sizeof(godot_rid) == sizeof(RID), "RID size mismatch"); #ifdef __cplusplus extern "C" { #endif -static_assert(sizeof(godot_rid) == sizeof(RID), "RID size mismatch"); - -void GDAPI godot_rid_new(godot_rid *r_dest) { - RID *dest = (RID *)r_dest; - memnew_placement(dest, RID); -} - -godot_int GDAPI godot_rid_get_id(const godot_rid *p_self) { - const RID *self = (const RID *)p_self; - return self->get_id(); -} - -void GDAPI godot_rid_new_with_resource(godot_rid *r_dest, const godot_object *p_from) { - const Resource *res_from = Object::cast_to<Resource>((Object *)p_from); - godot_rid_new(r_dest); - if (res_from) { - RID *dest = (RID *)r_dest; - *dest = RID(res_from->get_rid()); - } -} - -godot_bool GDAPI godot_rid_operator_equal(const godot_rid *p_self, const godot_rid *p_b) { - const RID *self = (const RID *)p_self; - const RID *b = (const RID *)p_b; - return *self == *b; -} - -godot_bool GDAPI godot_rid_operator_less(const godot_rid *p_self, const godot_rid *p_b) { - const RID *self = (const RID *)p_self; - const RID *b = (const RID *)p_b; - return *self < *b; +void GDAPI godot_rid_new(godot_rid *p_self) { + memnew_placement(p_self, RID); } #ifdef __cplusplus diff --git a/modules/inappstore/in_app_store_module.cpp b/modules/gdnative/gdnative/signal.cpp index 039bdd4f83..bcb4c93b62 100644 --- a/modules/inappstore/in_app_store_module.cpp +++ b/modules/gdnative/gdnative/signal.cpp @@ -1,12 +1,12 @@ /*************************************************************************/ -/* in_app_store_module.cpp */ +/* signal.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -28,21 +28,26 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "in_app_store_module.h" +#include "gdnative/signal.h" -#include "core/config/engine.h" +#include "core/variant/callable.h" +#include "core/variant/variant.h" -#include "in_app_store.h" +static_assert(sizeof(godot_signal) == sizeof(Signal), "Signal size mismatch"); -InAppStore *store_kit; +#ifdef __cplusplus +extern "C" { +#endif -void register_inappstore_types() { - store_kit = memnew(InAppStore); - Engine::get_singleton()->add_singleton(Engine::Singleton("InAppStore", store_kit)); +void GDAPI godot_signal_new(godot_signal *p_self) { + memnew_placement(p_self, Signal); } -void unregister_inappstore_types() { - if (store_kit) { - memdelete(store_kit); - } +void GDAPI godot_signal_destroy(godot_signal *p_self) { + Signal *self = (Signal *)p_self; + self->~Signal(); } + +#ifdef __cplusplus +} +#endif diff --git a/modules/gdnative/gdnative/string.cpp b/modules/gdnative/gdnative/string.cpp index 47c7f7b6e7..19d95f2048 100644 --- a/modules/gdnative/gdnative/string.cpp +++ b/modules/gdnative/gdnative/string.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -30,57 +30,15 @@ #include "gdnative/string.h" -#include "core/string/string_name.h" #include "core/string/ustring.h" -#include "core/variant/variant.h" -#include <string.h> +static_assert(sizeof(godot_string) == sizeof(String), "String size mismatch"); +static_assert(sizeof(godot_char_type) == sizeof(char32_t), "char32_t size mismatch"); #ifdef __cplusplus extern "C" { #endif -static_assert(sizeof(godot_char16_string) == sizeof(Char16String), "Char16String size mismatch"); -static_assert(sizeof(godot_char_string) == sizeof(CharString), "CharString size mismatch"); -static_assert(sizeof(godot_string) == sizeof(String), "String size mismatch"); -static_assert(sizeof(godot_char_type) == sizeof(char32_t), "char32_t size mismatch"); - -godot_int GDAPI godot_char_string_length(const godot_char_string *p_cs) { - const CharString *cs = (const CharString *)p_cs; - - return cs->length(); -} - -const char GDAPI *godot_char_string_get_data(const godot_char_string *p_cs) { - const CharString *cs = (const CharString *)p_cs; - - return cs->get_data(); -} - -void GDAPI godot_char_string_destroy(godot_char_string *p_cs) { - CharString *cs = (CharString *)p_cs; - - cs->~CharString(); -} - -godot_int GDAPI godot_char16_string_length(const godot_char16_string *p_cs) { - const Char16String *cs = (const Char16String *)p_cs; - - return cs->length(); -} - -const char16_t GDAPI *godot_char16_string_get_data(const godot_char16_string *p_cs) { - const Char16String *cs = (const Char16String *)p_cs; - - return cs->get_data(); -} - -void GDAPI godot_char16_string_destroy(godot_char16_string *p_cs) { - Char16String *cs = (Char16String *)p_cs; - - cs->~Char16String(); -} - void GDAPI godot_string_new(godot_string *r_dest) { String *dest = (String *)r_dest; memnew_placement(dest, String); @@ -167,1206 +125,11 @@ void GDAPI godot_string_new_with_wide_chars_and_len(godot_string *r_dest, const } } -const godot_char_type GDAPI *godot_string_operator_index(godot_string *p_self, const godot_int p_idx) { - String *self = (String *)p_self; - return &(self->operator[](p_idx)); -} - -godot_char_type GDAPI godot_string_operator_index_const(const godot_string *p_self, const godot_int p_idx) { - const String *self = (const String *)p_self; - return self->operator[](p_idx); -} - -const godot_char_type GDAPI *godot_string_get_data(const godot_string *p_self) { - const String *self = (const String *)p_self; - return self->get_data(); -} - -godot_bool GDAPI godot_string_operator_equal(const godot_string *p_self, const godot_string *p_b) { - const String *self = (const String *)p_self; - const String *b = (const String *)p_b; - return *self == *b; -} - -godot_bool GDAPI godot_string_operator_less(const godot_string *p_self, const godot_string *p_b) { - const String *self = (const String *)p_self; - const String *b = (const String *)p_b; - return *self < *b; -} - -godot_string GDAPI godot_string_operator_plus(const godot_string *p_self, const godot_string *p_b) { - godot_string ret; - const String *self = (const String *)p_self; - const String *b = (const String *)p_b; - memnew_placement(&ret, String(*self + *b)); - return ret; -} - void GDAPI godot_string_destroy(godot_string *p_self) { String *self = (String *)p_self; self->~String(); } -/* Standard size stuff */ - -godot_int GDAPI godot_string_length(const godot_string *p_self) { - const String *self = (const String *)p_self; - - return self->length(); -} - -/* Helpers */ - -signed char GDAPI godot_string_casecmp_to(const godot_string *p_self, const godot_string *p_str) { - const String *self = (const String *)p_self; - const String *str = (const String *)p_str; - - return self->casecmp_to(*str); -} - -signed char GDAPI godot_string_nocasecmp_to(const godot_string *p_self, const godot_string *p_str) { - const String *self = (const String *)p_self; - const String *str = (const String *)p_str; - - return self->nocasecmp_to(*str); -} - -signed char GDAPI godot_string_naturalnocasecmp_to(const godot_string *p_self, const godot_string *p_str) { - const String *self = (const String *)p_self; - const String *str = (const String *)p_str; - - return self->naturalnocasecmp_to(*str); -} - -godot_bool GDAPI godot_string_begins_with(const godot_string *p_self, const godot_string *p_string) { - const String *self = (const String *)p_self; - const String *string = (const String *)p_string; - - return self->begins_with(*string); -} - -godot_bool GDAPI godot_string_begins_with_char_array(const godot_string *p_self, const char *p_char_array) { - const String *self = (const String *)p_self; - - return self->begins_with(p_char_array); -} - -godot_packed_string_array GDAPI godot_string_bigrams(const godot_string *p_self) { - const String *self = (const String *)p_self; - godot_packed_string_array ret; - memnew_placement(&ret, Vector<String>(self->bigrams())); - return ret; -}; - -godot_string GDAPI godot_string_chr(godot_char_type p_character) { - godot_string result; - memnew_placement(&result, String(String::chr(p_character))); - - return result; -} - -godot_bool GDAPI godot_string_ends_with(const godot_string *p_self, const godot_string *p_string) { - const String *self = (const String *)p_self; - const String *string = (const String *)p_string; - - return self->ends_with(*string); -} - -godot_bool GDAPI godot_string_ends_with_char_array(const godot_string *p_self, const char *p_char_array) { - const String *self = (const String *)p_self; - - return self->ends_with(p_char_array); -} - -godot_int GDAPI godot_string_count(const godot_string *p_self, const godot_string *p_what, godot_int p_from, godot_int p_to) { - const String *self = (const String *)p_self; - const String *what = (const String *)p_what; - - return self->count(*what, p_from, p_to); -} - -godot_int GDAPI godot_string_countn(const godot_string *p_self, const godot_string *p_what, godot_int p_from, godot_int p_to) { - const String *self = (const String *)p_self; - const String *what = (const String *)p_what; - - return self->countn(*what, p_from, p_to); -} - -godot_int GDAPI godot_string_find(const godot_string *p_self, const godot_string *p_what) { - const String *self = (const String *)p_self; - const String *what = (const String *)p_what; - - return self->find(*what); -} - -godot_int GDAPI godot_string_find_from(const godot_string *p_self, const godot_string *p_what, godot_int p_from) { - const String *self = (const String *)p_self; - const String *what = (const String *)p_what; - - return self->find(*what, p_from); -} - -godot_int GDAPI godot_string_findmk(const godot_string *p_self, const godot_packed_string_array *p_keys) { - const String *self = (const String *)p_self; - const Vector<String> *keys = (const Vector<String> *)p_keys; - return self->findmk(*keys); -} - -godot_int GDAPI godot_string_findmk_from(const godot_string *p_self, const godot_packed_string_array *p_keys, godot_int p_from) { - const String *self = (const String *)p_self; - const Vector<String> *keys = (const Vector<String> *)p_keys; - return self->findmk(*keys, p_from); -} - -godot_int GDAPI godot_string_findmk_from_in_place(const godot_string *p_self, const godot_packed_string_array *p_keys, godot_int p_from, godot_int *r_key) { - const String *self = (const String *)p_self; - const Vector<String> *keys = (const Vector<String> *)p_keys; - int key; - int ret = self->findmk(*keys, p_from, &key); - if (r_key) { - *r_key = key; - } - return ret; -} - -godot_int GDAPI godot_string_findn(const godot_string *p_self, const godot_string *p_what) { - const String *self = (const String *)p_self; - const String *what = (const String *)p_what; - - return self->findn(*what); -} - -godot_int GDAPI godot_string_findn_from(const godot_string *p_self, const godot_string *p_what, godot_int p_from) { - const String *self = (const String *)p_self; - const String *what = (const String *)p_what; - - return self->findn(*what, p_from); -} - -godot_string GDAPI godot_string_format(const godot_string *p_self, const godot_variant *p_values) { - const String *self = (const String *)p_self; - const Variant *values = (const Variant *)p_values; - godot_string result; - memnew_placement(&result, String(self->format(*values))); - - return result; -} - -godot_string GDAPI godot_string_format_with_custom_placeholder(const godot_string *p_self, const godot_variant *p_values, const char *p_placeholder) { - const String *self = (const String *)p_self; - const Variant *values = (const Variant *)p_values; - String placeholder = String(p_placeholder); - godot_string result; - memnew_placement(&result, String(self->format(*values, placeholder))); - - return result; -} - -godot_string GDAPI godot_string_hex_encode_buffer(const uint8_t *p_buffer, godot_int p_len) { - godot_string result; - memnew_placement(&result, String(String::hex_encode_buffer(p_buffer, p_len))); - - return result; -} - -godot_string GDAPI godot_string_insert(const godot_string *p_self, godot_int p_at_pos, const godot_string *p_string) { - const String *self = (const String *)p_self; - const String *content = (const String *)p_string; - godot_string result; - memnew_placement(&result, String(self->insert(p_at_pos, *content))); - - return result; -} - -godot_bool GDAPI godot_string_is_numeric(const godot_string *p_self) { - const String *self = (const String *)p_self; - - return self->is_numeric(); -} - -godot_bool GDAPI godot_string_is_subsequence_of(const godot_string *p_self, const godot_string *p_string) { - const String *self = (const String *)p_self; - const String *string = (const String *)p_string; - - return self->is_subsequence_of(*string); -} - -godot_bool GDAPI godot_string_is_subsequence_ofi(const godot_string *p_self, const godot_string *p_string) { - const String *self = (const String *)p_self; - const String *string = (const String *)p_string; - - return self->is_subsequence_ofi(*string); -} - -godot_string GDAPI godot_string_lpad(const godot_string *p_self, godot_int p_min_length) { - const String *self = (const String *)p_self; - godot_string result; - memnew_placement(&result, String(self->lpad(p_min_length))); - - return result; -} - -godot_string GDAPI godot_string_lpad_with_custom_character(const godot_string *p_self, godot_int p_min_length, const godot_string *p_character) { - const String *self = (const String *)p_self; - const String *character = (const String *)p_character; - godot_string result; - memnew_placement(&result, String(self->lpad(p_min_length, *character))); - - return result; -} - -godot_bool GDAPI godot_string_match(const godot_string *p_self, const godot_string *p_wildcard) { - const String *self = (const String *)p_self; - const String *wildcard = (const String *)p_wildcard; - - return self->match(*wildcard); -} - -godot_bool GDAPI godot_string_matchn(const godot_string *p_self, const godot_string *p_wildcard) { - const String *self = (const String *)p_self; - const String *wildcard = (const String *)p_wildcard; - - return self->matchn(*wildcard); -} - -godot_string GDAPI godot_string_md5(const uint8_t *p_md5) { - godot_string result; - memnew_placement(&result, String(String::md5(p_md5))); - - return result; -} - -godot_string GDAPI godot_string_num(double p_num) { - godot_string result; - memnew_placement(&result, String(String::num(p_num))); - - return result; -} - -godot_string GDAPI godot_string_num_int64(int64_t p_num, godot_int p_base) { - godot_string result; - memnew_placement(&result, String(String::num_int64(p_num, p_base))); - - return result; -} - -godot_string GDAPI godot_string_num_int64_capitalized(int64_t p_num, godot_int p_base, godot_bool p_capitalize_hex) { - godot_string result; - memnew_placement(&result, String(String::num_int64(p_num, p_base, true))); - - return result; -} - -godot_string GDAPI godot_string_num_real(double p_num) { - godot_string result; - memnew_placement(&result, String(String::num_real(p_num))); - - return result; -} - -godot_string GDAPI godot_string_num_scientific(double p_num) { - godot_string result; - memnew_placement(&result, String(String::num_scientific(p_num))); - - return result; -} - -godot_string GDAPI godot_string_num_with_decimals(double p_num, godot_int p_decimals) { - godot_string result; - memnew_placement(&result, String(String::num(p_num, p_decimals))); - - return result; -} - -godot_string GDAPI godot_string_pad_decimals(const godot_string *p_self, godot_int p_digits) { - const String *self = (const String *)p_self; - godot_string result; - memnew_placement(&result, String(self->pad_decimals(p_digits))); - - return result; -} - -godot_string GDAPI godot_string_pad_zeros(const godot_string *p_self, godot_int p_digits) { - const String *self = (const String *)p_self; - godot_string result; - memnew_placement(&result, String(self->pad_zeros(p_digits))); - - return result; -} - -godot_string GDAPI godot_string_replace(const godot_string *p_self, const godot_string *p_key, const godot_string *p_with) { - const String *self = (const String *)p_self; - const String *key = (const String *)p_key; - const String *with = (const String *)p_with; - godot_string result; - memnew_placement(&result, String(self->replace(*key, *with))); - - return result; -} - -godot_string GDAPI godot_string_replacen(const godot_string *p_self, const godot_string *p_key, const godot_string *p_with) { - const String *self = (const String *)p_self; - const String *key = (const String *)p_key; - const String *with = (const String *)p_with; - godot_string result; - memnew_placement(&result, String(self->replacen(*key, *with))); - - return result; -} - -godot_int GDAPI godot_string_rfind(const godot_string *p_self, const godot_string *p_what) { - const String *self = (const String *)p_self; - const String *what = (const String *)p_what; - - return self->rfind(*what); -} - -godot_int GDAPI godot_string_rfindn(const godot_string *p_self, const godot_string *p_what) { - const String *self = (const String *)p_self; - const String *what = (const String *)p_what; - - return self->rfindn(*what); -} - -godot_int GDAPI godot_string_rfind_from(const godot_string *p_self, const godot_string *p_what, godot_int p_from) { - const String *self = (const String *)p_self; - const String *what = (const String *)p_what; - - return self->rfind(*what, p_from); -} - -godot_int GDAPI godot_string_rfindn_from(const godot_string *p_self, const godot_string *p_what, godot_int p_from) { - const String *self = (const String *)p_self; - const String *what = (const String *)p_what; - - return self->rfindn(*what, p_from); -} - -godot_string GDAPI godot_string_replace_first(const godot_string *p_self, const godot_string *p_key, const godot_string *p_with) { - const String *self = (const String *)p_self; - const String *key = (const String *)p_key; - const String *with = (const String *)p_with; - godot_string result; - memnew_placement(&result, String(self->replace_first(*key, *with))); - - return result; -} - -godot_string GDAPI godot_string_rpad(const godot_string *p_self, godot_int p_min_length) { - const String *self = (const String *)p_self; - godot_string result; - memnew_placement(&result, String(self->rpad(p_min_length))); - - return result; -} - -godot_string GDAPI godot_string_rpad_with_custom_character(const godot_string *p_self, godot_int p_min_length, const godot_string *p_character) { - const String *self = (const String *)p_self; - const String *character = (const String *)p_character; - godot_string result; - memnew_placement(&result, String(self->rpad(p_min_length, *character))); - - return result; -} - -godot_real GDAPI godot_string_similarity(const godot_string *p_self, const godot_string *p_string) { - const String *self = (const String *)p_self; - const String *string = (const String *)p_string; - - return self->similarity(*string); -} - -godot_string GDAPI godot_string_sprintf(const godot_string *p_self, const godot_array *p_values, godot_bool *p_error) { - const String *self = (const String *)p_self; - const Array *values = (const Array *)p_values; - - godot_string result; - String return_value = self->sprintf(*values, p_error); - memnew_placement(&result, String(return_value)); - - return result; -} - -godot_string GDAPI godot_string_substr(const godot_string *p_self, godot_int p_from, godot_int p_chars) { - const String *self = (const String *)p_self; - godot_string result; - memnew_placement(&result, String(self->substr(p_from, p_chars))); - - return result; -} - -godot_int GDAPI godot_string_to_int(const godot_string *p_self) { - const String *self = (const String *)p_self; - - return self->to_int(); -} - -double GDAPI godot_string_to_float(const godot_string *p_self) { - const String *self = (const String *)p_self; - - return self->to_float(); -} - -godot_string GDAPI godot_string_capitalize(const godot_string *p_self) { - const String *self = (const String *)p_self; - godot_string result; - memnew_placement(&result, String(self->capitalize())); - - return result; -} - -godot_string GDAPI godot_string_camelcase_to_underscore(const godot_string *p_self) { - const String *self = (const String *)p_self; - godot_string result; - memnew_placement(&result, String(self->camelcase_to_underscore(false))); - - return result; -} - -godot_string GDAPI godot_string_camelcase_to_underscore_lowercased(const godot_string *p_self) { - const String *self = (const String *)p_self; - godot_string result; - memnew_placement(&result, String(self->camelcase_to_underscore())); - - return result; -} - -double GDAPI godot_string_char_to_float(const char *p_what) { - return String::to_float(p_what); -} - -double GDAPI godot_string_wchar_to_float(const wchar_t *p_str, const wchar_t **r_end) { - return String::to_float(p_str, r_end); -} - -godot_int GDAPI godot_string_char_to_int(const char *p_what) { - return String::to_int(p_what); -} - -godot_int GDAPI godot_string_wchar_to_int(const wchar_t *p_str) { - return String::to_int(p_str); -} - -godot_int GDAPI godot_string_char_to_int_with_len(const char *p_what, godot_int p_len) { - return String::to_int(p_what, p_len); -} - -godot_int GDAPI godot_string_wchar_to_int_with_len(const wchar_t *p_str, int p_len) { - return String::to_int(p_str, p_len); -} - -godot_int GDAPI godot_string_hex_to_int(const godot_string *p_self) { - const String *self = (const String *)p_self; - - return self->hex_to_int(false); -} - -godot_int GDAPI godot_string_hex_to_int_with_prefix(const godot_string *p_self) { - const String *self = (const String *)p_self; - - return self->hex_to_int(); -} - -godot_string GDAPI godot_string_get_slice(const godot_string *p_self, const godot_string *p_splitter, godot_int p_slice) { - const String *self = (const String *)p_self; - const String *splitter = (const String *)p_splitter; - godot_string result; - memnew_placement(&result, String(self->get_slice(*splitter, p_slice))); - - return result; -} - -godot_string GDAPI godot_string_get_slicec(const godot_string *p_self, godot_char_type p_splitter, godot_int p_slice) { - const String *self = (const String *)p_self; - godot_string result; - memnew_placement(&result, String(self->get_slicec(p_splitter, p_slice))); - - return result; -} - -godot_packed_string_array GDAPI godot_string_split(const godot_string *p_self, const godot_string *p_splitter) { - const String *self = (const String *)p_self; - const String *splitter = (const String *)p_splitter; - godot_packed_string_array ret; - memnew_placement(&ret, Vector<String>(self->split(*splitter, false))); - return ret; -} - -godot_packed_string_array GDAPI godot_string_split_allow_empty(const godot_string *p_self, const godot_string *p_splitter) { - const String *self = (const String *)p_self; - const String *splitter = (const String *)p_splitter; - godot_packed_string_array ret; - memnew_placement(&ret, Vector<String>(self->split(*splitter, true))); - return ret; -} - -godot_packed_string_array GDAPI godot_string_split_with_maxsplit(const godot_string *p_self, const godot_string *p_splitter, const godot_bool p_allow_empty, const godot_int p_maxsplit) { - const String *self = (const String *)p_self; - const String *splitter = (const String *)p_splitter; - godot_packed_string_array ret; - memnew_placement(&ret, Vector<String>(self->split(*splitter, p_allow_empty, p_maxsplit))); - return ret; -} - -godot_packed_string_array GDAPI godot_string_rsplit(const godot_string *p_self, const godot_string *p_splitter) { - const String *self = (const String *)p_self; - const String *splitter = (const String *)p_splitter; - - godot_packed_string_array ret; - memnew_placement(&ret, Vector<String>(self->rsplit(*splitter, false))); - return ret; -} - -godot_packed_string_array GDAPI godot_string_rsplit_allow_empty(const godot_string *p_self, const godot_string *p_splitter) { - const String *self = (const String *)p_self; - const String *splitter = (const String *)p_splitter; - - godot_packed_string_array ret; - memnew_placement(&ret, Vector<String>(self->rsplit(*splitter, true))); - return ret; -} - -godot_packed_string_array GDAPI godot_string_rsplit_with_maxsplit(const godot_string *p_self, const godot_string *p_splitter, const godot_bool p_allow_empty, const godot_int p_maxsplit) { - const String *self = (const String *)p_self; - const String *splitter = (const String *)p_splitter; - - godot_packed_string_array ret; - memnew_placement(&ret, Vector<String>(self->rsplit(*splitter, p_allow_empty, p_maxsplit))); - return ret; -} - -godot_packed_float32_array GDAPI godot_string_split_floats(const godot_string *p_self, const godot_string *p_splitter) { - const String *self = (const String *)p_self; - const String *splitter = (const String *)p_splitter; - - godot_packed_float32_array ret; - memnew_placement(&ret, Vector<float>(self->split_floats(*splitter, false))); - return ret; -} - -godot_packed_float32_array GDAPI godot_string_split_floats_allow_empty(const godot_string *p_self, const godot_string *p_splitter) { - const String *self = (const String *)p_self; - const String *splitter = (const String *)p_splitter; - - godot_packed_float32_array ret; - memnew_placement(&ret, Vector<float>(self->split_floats(*splitter, true))); - return ret; -} - -godot_packed_float32_array GDAPI godot_string_split_floats_mk(const godot_string *p_self, const godot_packed_string_array *p_splitters) { - const String *self = (const String *)p_self; - const Vector<String> *splitters = (const Vector<String> *)p_splitters; - - godot_packed_float32_array ret; - memnew_placement(&ret, Vector<float>(self->split_floats_mk(*splitters, false))); - return ret; -} - -godot_packed_float32_array GDAPI godot_string_split_floats_mk_allow_empty(const godot_string *p_self, const godot_packed_string_array *p_splitters) { - const String *self = (const String *)p_self; - const Vector<String> *splitters = (const Vector<String> *)p_splitters; - - godot_packed_float32_array ret; - memnew_placement(&ret, Vector<float>(self->split_floats_mk(*splitters, true))); - return ret; -} - -godot_packed_int32_array GDAPI godot_string_split_ints(const godot_string *p_self, const godot_string *p_splitter) { - const String *self = (const String *)p_self; - const String *splitter = (const String *)p_splitter; - - godot_packed_int32_array ret; - memnew_placement(&ret, Vector<int>(self->split_ints(*splitter, false))); - return ret; -} - -godot_packed_int32_array GDAPI godot_string_split_ints_allow_empty(const godot_string *p_self, const godot_string *p_splitter) { - const String *self = (const String *)p_self; - const String *splitter = (const String *)p_splitter; - - godot_packed_int32_array ret; - memnew_placement(&ret, Vector<int>(self->split_ints(*splitter, true))); - return ret; -} - -godot_packed_int32_array GDAPI godot_string_split_ints_mk(const godot_string *p_self, const godot_packed_string_array *p_splitters) { - const String *self = (const String *)p_self; - const Vector<String> *splitters = (const Vector<String> *)p_splitters; - - godot_packed_int32_array ret; - memnew_placement(&ret, Vector<int>(self->split_ints_mk(*splitters, false))); - return ret; -} - -godot_packed_int32_array GDAPI godot_string_split_ints_mk_allow_empty(const godot_string *p_self, const godot_packed_string_array *p_splitters) { - const String *self = (const String *)p_self; - const Vector<String> *splitters = (const Vector<String> *)p_splitters; - - godot_packed_int32_array ret; - memnew_placement(&ret, Vector<int>(self->split_ints_mk(*splitters, true))); - return ret; -} - -godot_packed_string_array GDAPI godot_string_split_spaces(const godot_string *p_self) { - const String *self = (const String *)p_self; - - godot_packed_string_array ret; - memnew_placement(&ret, Vector<String>(self->split_spaces())); - return ret; -} - -godot_int GDAPI godot_string_get_slice_count(const godot_string *p_self, const godot_string *p_splitter) { - const String *self = (const String *)p_self; - const String *splitter = (const String *)p_splitter; - - return self->get_slice_count(*splitter); -} - -godot_char_type GDAPI godot_string_char_lowercase(godot_char_type p_char) { - return String::char_lowercase(p_char); -} - -godot_char_type GDAPI godot_string_char_uppercase(godot_char_type p_char) { - return String::char_uppercase(p_char); -} - -godot_string GDAPI godot_string_to_lower(const godot_string *p_self) { - const String *self = (const String *)p_self; - godot_string result; - memnew_placement(&result, String(self->to_lower())); - - return result; -} - -godot_string GDAPI godot_string_to_upper(const godot_string *p_self) { - const String *self = (const String *)p_self; - godot_string result; - memnew_placement(&result, String(self->to_upper())); - - return result; -} - -godot_string GDAPI godot_string_get_basename(const godot_string *p_self) { - const String *self = (const String *)p_self; - godot_string result; - memnew_placement(&result, String(self->get_basename())); - - return result; -} - -godot_string GDAPI godot_string_get_extension(const godot_string *p_self) { - const String *self = (const String *)p_self; - godot_string result; - memnew_placement(&result, String(self->get_extension())); - - return result; -} - -godot_string GDAPI godot_string_left(const godot_string *p_self, godot_int p_pos) { - const String *self = (const String *)p_self; - godot_string result; - memnew_placement(&result, String(self->left(p_pos))); - - return result; -} - -godot_char_type GDAPI godot_string_ord_at(const godot_string *p_self, godot_int p_idx) { - const String *self = (const String *)p_self; - - return self->ord_at(p_idx); -} - -godot_string GDAPI godot_string_plus_file(const godot_string *p_self, const godot_string *p_file) { - const String *self = (const String *)p_self; - const String *file = (const String *)p_file; - godot_string result; - memnew_placement(&result, String(self->plus_file(*file))); - - return result; -} - -godot_string GDAPI godot_string_right(const godot_string *p_self, godot_int p_pos) { - const String *self = (const String *)p_self; - godot_string result; - memnew_placement(&result, String(self->right(p_pos))); - - return result; -} - -godot_string GDAPI godot_string_repeat(const godot_string *p_self, godot_int p_count) { - const String *self = (const String *)p_self; - godot_string result; - memnew_placement(&result, String(self->repeat(p_count))); - - return result; -} - -godot_string GDAPI godot_string_strip_edges(const godot_string *p_self, godot_bool p_left, godot_bool p_right) { - const String *self = (const String *)p_self; - godot_string result; - memnew_placement(&result, String(self->strip_edges(p_left, p_right))); - - return result; -} - -godot_string GDAPI godot_string_strip_escapes(const godot_string *p_self) { - const String *self = (const String *)p_self; - godot_string result; - memnew_placement(&result, String(self->strip_escapes())); - - return result; -} - -void GDAPI godot_string_erase(godot_string *p_self, godot_int p_pos, godot_int p_chars) { - String *self = (String *)p_self; - - return self->erase(p_pos, p_chars); -} - -godot_char_string GDAPI godot_string_ascii(const godot_string *p_self) { - const String *self = (const String *)p_self; - godot_char_string result; - - memnew_placement(&result, CharString(self->ascii())); - - return result; -} - -godot_char_string GDAPI godot_string_latin1(const godot_string *p_self) { - const String *self = (const String *)p_self; - - godot_char_string result; - - memnew_placement(&result, CharString(self->ascii(true))); - - return result; -} - -godot_char_string GDAPI godot_string_utf8(const godot_string *p_self) { - const String *self = (const String *)p_self; - - godot_char_string result; - - memnew_placement(&result, CharString(self->utf8())); - - return result; -} - -godot_bool GDAPI godot_string_parse_utf8(godot_string *p_self, const char *p_utf8) { - String *self = (String *)p_self; - - return self->parse_utf8(p_utf8); -} - -godot_bool GDAPI godot_string_parse_utf8_with_len(godot_string *p_self, const char *p_utf8, godot_int p_len) { - String *self = (String *)p_self; - - return self->parse_utf8(p_utf8, p_len); -} - -godot_string GDAPI godot_string_chars_to_utf8(const char *p_utf8) { - godot_string result; - memnew_placement(&result, String(String::utf8(p_utf8))); - - return result; -} - -godot_string GDAPI godot_string_chars_to_utf8_with_len(const char *p_utf8, godot_int p_len) { - godot_string result; - memnew_placement(&result, String(String::utf8(p_utf8, p_len))); - - return result; -} - -godot_char16_string GDAPI godot_string_utf16(const godot_string *p_self) { - const String *self = (const String *)p_self; - - godot_char16_string result; - - memnew_placement(&result, Char16String(self->utf16())); - - return result; -} - -godot_bool GDAPI godot_string_parse_utf16(godot_string *p_self, const char16_t *p_utf16) { - String *self = (String *)p_self; - - return self->parse_utf16(p_utf16); -} - -godot_bool GDAPI godot_string_parse_utf16_with_len(godot_string *p_self, const char16_t *p_utf16, godot_int p_len) { - String *self = (String *)p_self; - - return self->parse_utf16(p_utf16, p_len); -} - -godot_string GDAPI godot_string_chars_to_utf16(const char16_t *p_utf16) { - godot_string result; - memnew_placement(&result, String(String::utf16(p_utf16))); - - return result; -} - -godot_string GDAPI godot_string_chars_to_utf16_with_len(const char16_t *p_utf16, godot_int p_len) { - godot_string result; - memnew_placement(&result, String(String::utf16(p_utf16, p_len))); - - return result; -} - -uint32_t GDAPI godot_string_hash(const godot_string *p_self) { - const String *self = (const String *)p_self; - - return self->hash(); -} - -uint64_t GDAPI godot_string_hash64(const godot_string *p_self) { - const String *self = (const String *)p_self; - - return self->hash64(); -} - -uint32_t GDAPI godot_string_hash_chars(const char *p_cstr) { - return String::hash(p_cstr); -} - -uint32_t GDAPI godot_string_hash_chars_with_len(const char *p_cstr, godot_int p_len) { - return String::hash(p_cstr, p_len); -} - -uint32_t GDAPI godot_string_hash_wide_chars(const wchar_t *p_str) { - return String::hash(p_str); -} - -uint32_t GDAPI godot_string_hash_wide_chars_with_len(const wchar_t *p_str, godot_int p_len) { - return String::hash(p_str, p_len); -} - -godot_packed_byte_array GDAPI godot_string_md5_buffer(const godot_string *p_self) { - const String *self = (const String *)p_self; - godot_packed_byte_array result; - memnew_placement(&result, PackedByteArray(self->md5_buffer())); - return result; -} - -godot_string GDAPI godot_string_md5_text(const godot_string *p_self) { - const String *self = (const String *)p_self; - godot_string result; - memnew_placement(&result, String(self->md5_text())); - - return result; -} - -godot_packed_byte_array GDAPI godot_string_sha1_buffer(const godot_string *p_self) { - const String *self = (const String *)p_self; - godot_packed_byte_array result; - memnew_placement(&result, PackedByteArray(self->sha1_buffer())); - return result; -} - -godot_string GDAPI godot_string_sha1_text(const godot_string *p_self) { - const String *self = (const String *)p_self; - godot_string result; - memnew_placement(&result, String(self->sha1_text())); - - return result; -} - -godot_packed_byte_array GDAPI godot_string_sha256_buffer(const godot_string *p_self) { - const String *self = (const String *)p_self; - godot_packed_byte_array result; - memnew_placement(&result, PackedByteArray(self->sha256_buffer())); - return result; -} - -godot_string GDAPI godot_string_sha256_text(const godot_string *p_self) { - const String *self = (const String *)p_self; - godot_string result; - memnew_placement(&result, String(self->sha256_text())); - - return result; -} - -godot_bool godot_string_empty(const godot_string *p_self) { - const String *self = (const String *)p_self; - - return self->empty(); -} - -// path functions -godot_string GDAPI godot_string_get_base_dir(const godot_string *p_self) { - const String *self = (const String *)p_self; - godot_string result; - String return_value = self->get_base_dir(); - memnew_placement(&result, String(return_value)); - - return result; -} - -godot_string GDAPI godot_string_get_file(const godot_string *p_self) { - const String *self = (const String *)p_self; - godot_string result; - String return_value = self->get_file(); - memnew_placement(&result, String(return_value)); - - return result; -} - -godot_string GDAPI godot_string_humanize_size(size_t p_size) { - godot_string result; - String return_value = String::humanize_size(p_size); - memnew_placement(&result, String(return_value)); - - return result; -} - -godot_bool GDAPI godot_string_is_abs_path(const godot_string *p_self) { - const String *self = (const String *)p_self; - - return self->is_abs_path(); -} - -godot_bool GDAPI godot_string_is_rel_path(const godot_string *p_self) { - const String *self = (const String *)p_self; - - return self->is_rel_path(); -} - -godot_bool GDAPI godot_string_is_resource_file(const godot_string *p_self) { - const String *self = (const String *)p_self; - - return self->is_resource_file(); -} - -godot_string GDAPI godot_string_path_to(const godot_string *p_self, const godot_string *p_path) { - const String *self = (const String *)p_self; - String *path = (String *)p_path; - godot_string result; - String return_value = self->path_to(*path); - memnew_placement(&result, String(return_value)); - - return result; -} - -godot_string GDAPI godot_string_path_to_file(const godot_string *p_self, const godot_string *p_path) { - const String *self = (const String *)p_self; - String *path = (String *)p_path; - godot_string result; - String return_value = self->path_to_file(*path); - memnew_placement(&result, String(return_value)); - - return result; -} - -godot_string GDAPI godot_string_simplify_path(const godot_string *p_self) { - const String *self = (const String *)p_self; - godot_string result; - String return_value = self->simplify_path(); - memnew_placement(&result, String(return_value)); - - return result; -} - -godot_string GDAPI godot_string_c_escape(const godot_string *p_self) { - const String *self = (const String *)p_self; - godot_string result; - String return_value = self->c_escape(); - memnew_placement(&result, String(return_value)); - - return result; -} - -godot_string GDAPI godot_string_c_escape_multiline(const godot_string *p_self) { - const String *self = (const String *)p_self; - godot_string result; - String return_value = self->c_escape_multiline(); - memnew_placement(&result, String(return_value)); - - return result; -} - -godot_string GDAPI godot_string_c_unescape(const godot_string *p_self) { - const String *self = (const String *)p_self; - godot_string result; - String return_value = self->c_unescape(); - memnew_placement(&result, String(return_value)); - - return result; -} - -godot_string GDAPI godot_string_http_escape(const godot_string *p_self) { - const String *self = (const String *)p_self; - godot_string result; - String return_value = self->http_escape(); - memnew_placement(&result, String(return_value)); - - return result; -} - -godot_string GDAPI godot_string_http_unescape(const godot_string *p_self) { - const String *self = (const String *)p_self; - godot_string result; - String return_value = self->http_unescape(); - memnew_placement(&result, String(return_value)); - - return result; -} - -godot_string GDAPI godot_string_json_escape(const godot_string *p_self) { - const String *self = (const String *)p_self; - godot_string result; - String return_value = self->json_escape(); - memnew_placement(&result, String(return_value)); - - return result; -} - -godot_string GDAPI godot_string_xml_escape(const godot_string *p_self) { - const String *self = (const String *)p_self; - godot_string result; - String return_value = self->xml_escape(); - memnew_placement(&result, String(return_value)); - - return result; -} - -godot_string GDAPI godot_string_xml_escape_with_quotes(const godot_string *p_self) { - const String *self = (const String *)p_self; - godot_string result; - String return_value = self->xml_escape(true); - memnew_placement(&result, String(return_value)); - - return result; -} - -godot_string GDAPI godot_string_xml_unescape(const godot_string *p_self) { - const String *self = (const String *)p_self; - godot_string result; - String return_value = self->xml_unescape(); - memnew_placement(&result, String(return_value)); - - return result; -} - -godot_string GDAPI godot_string_percent_decode(const godot_string *p_self) { - const String *self = (const String *)p_self; - godot_string result; - String return_value = self->percent_decode(); - memnew_placement(&result, String(return_value)); - - return result; -} - -godot_string GDAPI godot_string_percent_encode(const godot_string *p_self) { - const String *self = (const String *)p_self; - godot_string result; - String return_value = self->percent_encode(); - memnew_placement(&result, String(return_value)); - - return result; -} - -godot_string GDAPI godot_string_join(const godot_string *p_self, const godot_packed_string_array *p_parts) { - const String *self = (const String *)p_self; - const Vector<String> *parts = (const Vector<String> *)p_parts; - godot_string result; - String return_value = self->join(*parts); - memnew_placement(&result, String(return_value)); - - return result; -} - -godot_bool GDAPI godot_string_is_valid_filename(const godot_string *p_self) { - const String *self = (const String *)p_self; - - return self->is_valid_filename(); -} - -godot_bool GDAPI godot_string_is_valid_float(const godot_string *p_self) { - const String *self = (const String *)p_self; - - return self->is_valid_float(); -} - -godot_bool GDAPI godot_string_is_valid_hex_number(const godot_string *p_self, godot_bool p_with_prefix) { - const String *self = (const String *)p_self; - - return self->is_valid_hex_number(p_with_prefix); -} - -godot_bool GDAPI godot_string_is_valid_html_color(const godot_string *p_self) { - const String *self = (const String *)p_self; - - return self->is_valid_html_color(); -} - -godot_bool GDAPI godot_string_is_valid_identifier(const godot_string *p_self) { - const String *self = (const String *)p_self; - - return self->is_valid_identifier(); -} - -godot_bool GDAPI godot_string_is_valid_integer(const godot_string *p_self) { - const String *self = (const String *)p_self; - - return self->is_valid_integer(); -} - -godot_bool GDAPI godot_string_is_valid_ip_address(const godot_string *p_self) { - const String *self = (const String *)p_self; - - return self->is_valid_ip_address(); -} - -godot_string GDAPI godot_string_dedent(const godot_string *p_self) { - const String *self = (const String *)p_self; - godot_string result; - String return_value = self->dedent(); - memnew_placement(&result, String(return_value)); - - return result; -} - -godot_string GDAPI godot_string_trim_prefix(const godot_string *p_self, const godot_string *p_prefix) { - const String *self = (const String *)p_self; - String *prefix = (String *)p_prefix; - godot_string result; - String return_value = self->trim_prefix(*prefix); - memnew_placement(&result, String(return_value)); - - return result; -} - -godot_string GDAPI godot_string_trim_suffix(const godot_string *p_self, const godot_string *p_suffix) { - const String *self = (const String *)p_self; - String *suffix = (String *)p_suffix; - godot_string result; - String return_value = self->trim_suffix(*suffix); - memnew_placement(&result, String(return_value)); - - return result; -} - -godot_string GDAPI godot_string_lstrip(const godot_string *p_self, const godot_string *p_chars) { - const String *self = (const String *)p_self; - String *chars = (String *)p_chars; - godot_string result; - String return_value = self->lstrip(*chars); - memnew_placement(&result, String(return_value)); - - return result; -} - -godot_string GDAPI godot_string_rstrip(const godot_string *p_self, const godot_string *p_chars) { - const String *self = (const String *)p_self; - String *chars = (String *)p_chars; - godot_string result; - String return_value = self->rstrip(*chars); - memnew_placement(&result, String(return_value)); - - return result; -} - #ifdef __cplusplus } #endif diff --git a/modules/gdnative/gdnative/string_name.cpp b/modules/gdnative/gdnative/string_name.cpp index a840d74e18..c9d2dd5bc3 100644 --- a/modules/gdnative/gdnative/string_name.cpp +++ b/modules/gdnative/gdnative/string_name.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -31,54 +31,27 @@ #include "gdnative/string_name.h" #include "core/string/string_name.h" -#include "core/string/ustring.h" -#include <string.h> +static_assert(sizeof(godot_string_name) == sizeof(StringName), "StringName size mismatch"); #ifdef __cplusplus extern "C" { #endif -static_assert(sizeof(godot_string_name) == sizeof(StringName), "StringName size mismatch"); - -void GDAPI godot_string_name_new(godot_string_name *r_dest, const godot_string *p_name) { +void GDAPI godot_string_name_new(godot_string_name *r_dest) { StringName *dest = (StringName *)r_dest; - const String *name = (const String *)p_name; - memnew_placement(dest, StringName(*name)); + memnew_placement(dest, StringName); } -void GDAPI godot_string_name_new_data(godot_string_name *r_dest, const char *p_name) { +void GDAPI godot_string_name_new_copy(godot_string_name *r_dest, const godot_string_name *p_src) { StringName *dest = (StringName *)r_dest; - memnew_placement(dest, StringName(p_name)); -} - -godot_string GDAPI godot_string_name_get_name(const godot_string_name *p_self) { - godot_string ret; - const StringName *self = (const StringName *)p_self; - memnew_placement(&ret, String(*self)); - return ret; -} - -uint32_t GDAPI godot_string_name_get_hash(const godot_string_name *p_self) { - const StringName *self = (const StringName *)p_self; - return self->hash(); -} - -const void GDAPI *godot_string_name_get_data_unique_pointer(const godot_string_name *p_self) { - const StringName *self = (const StringName *)p_self; - return self->data_unique_pointer(); + const StringName *src = (const StringName *)p_src; + memnew_placement(dest, StringName(*src)); } -godot_bool GDAPI godot_string_name_operator_equal(const godot_string_name *p_self, const godot_string_name *p_other) { - const StringName *self = (const StringName *)p_self; - const StringName *other = (const StringName *)p_other; - return self == other; -} - -godot_bool GDAPI godot_string_name_operator_less(const godot_string_name *p_self, const godot_string_name *p_other) { - const StringName *self = (const StringName *)p_self; - const StringName *other = (const StringName *)p_other; - return self < other; +void GDAPI godot_string_name_new_with_latin1_chars(godot_string_name *r_dest, const char *p_contents) { + StringName *dest = (StringName *)r_dest; + memnew_placement(dest, StringName(p_contents)); } void GDAPI godot_string_name_destroy(godot_string_name *p_self) { diff --git a/modules/gdnative/gdnative/transform.cpp b/modules/gdnative/gdnative/transform.cpp index b17d6f8d4c..eae981bd07 100644 --- a/modules/gdnative/gdnative/transform.cpp +++ b/modules/gdnative/gdnative/transform.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -31,198 +31,15 @@ #include "gdnative/transform.h" #include "core/math/transform.h" -#include "core/variant/variant.h" + +static_assert(sizeof(godot_transform) == sizeof(Transform), "Transform size mismatch"); #ifdef __cplusplus extern "C" { #endif -static_assert(sizeof(godot_transform) == sizeof(Transform), "Transform size mismatch"); - -void GDAPI godot_transform_new_with_axis_origin(godot_transform *r_dest, const godot_vector3 *p_x_axis, const godot_vector3 *p_y_axis, const godot_vector3 *p_z_axis, const godot_vector3 *p_origin) { - const Vector3 *x_axis = (const Vector3 *)p_x_axis; - const Vector3 *y_axis = (const Vector3 *)p_y_axis; - const Vector3 *z_axis = (const Vector3 *)p_z_axis; - const Vector3 *origin = (const Vector3 *)p_origin; - Transform *dest = (Transform *)r_dest; - dest->basis.set_axis(0, *x_axis); - dest->basis.set_axis(1, *y_axis); - dest->basis.set_axis(2, *z_axis); - dest->origin = *origin; -} - -void GDAPI godot_transform_new(godot_transform *r_dest, const godot_basis *p_basis, const godot_vector3 *p_origin) { - const Basis *basis = (const Basis *)p_basis; - const Vector3 *origin = (const Vector3 *)p_origin; - Transform *dest = (Transform *)r_dest; - *dest = Transform(*basis, *origin); -} - -void GDAPI godot_transform_new_with_quat(godot_transform *r_dest, const godot_quat *p_quat) { - const Quat *quat = (const Quat *)p_quat; - Transform *dest = (Transform *)r_dest; - *dest = Transform(*quat); -} - -godot_basis GDAPI godot_transform_get_basis(const godot_transform *p_self) { - godot_basis dest; - const Transform *self = (const Transform *)p_self; - *((Basis *)&dest) = self->basis; - return dest; -} - -void GDAPI godot_transform_set_basis(godot_transform *p_self, const godot_basis *p_v) { - Transform *self = (Transform *)p_self; - const Basis *v = (const Basis *)p_v; - self->basis = *v; -} - -godot_vector3 GDAPI godot_transform_get_origin(const godot_transform *p_self) { - godot_vector3 dest; - const Transform *self = (const Transform *)p_self; - *((Vector3 *)&dest) = self->origin; - return dest; -} - -void GDAPI godot_transform_set_origin(godot_transform *p_self, const godot_vector3 *p_v) { - Transform *self = (Transform *)p_self; - const Vector3 *v = (const Vector3 *)p_v; - self->origin = *v; -} - -godot_string GDAPI godot_transform_as_string(const godot_transform *p_self) { - godot_string ret; - const Transform *self = (const Transform *)p_self; - memnew_placement(&ret, String(*self)); - return ret; -} - -godot_transform GDAPI godot_transform_inverse(const godot_transform *p_self) { - godot_transform dest; - const Transform *self = (const Transform *)p_self; - *((Transform *)&dest) = self->inverse(); - return dest; -} - -godot_transform GDAPI godot_transform_affine_inverse(const godot_transform *p_self) { - godot_transform dest; - const Transform *self = (const Transform *)p_self; - *((Transform *)&dest) = self->affine_inverse(); - return dest; -} - -godot_transform GDAPI godot_transform_orthonormalized(const godot_transform *p_self) { - godot_transform dest; - const Transform *self = (const Transform *)p_self; - *((Transform *)&dest) = self->orthonormalized(); - return dest; -} - -godot_transform GDAPI godot_transform_rotated(const godot_transform *p_self, const godot_vector3 *p_axis, const godot_real p_phi) { - godot_transform dest; - const Transform *self = (const Transform *)p_self; - const Vector3 *axis = (const Vector3 *)p_axis; - *((Transform *)&dest) = self->rotated(*axis, p_phi); - return dest; -} - -godot_transform GDAPI godot_transform_scaled(const godot_transform *p_self, const godot_vector3 *p_scale) { - godot_transform dest; - const Transform *self = (const Transform *)p_self; - const Vector3 *scale = (const Vector3 *)p_scale; - *((Transform *)&dest) = self->scaled(*scale); - return dest; -} - -godot_transform GDAPI godot_transform_translated(const godot_transform *p_self, const godot_vector3 *p_ofs) { - godot_transform dest; - const Transform *self = (const Transform *)p_self; - const Vector3 *ofs = (const Vector3 *)p_ofs; - *((Transform *)&dest) = self->translated(*ofs); - return dest; -} - -godot_transform GDAPI godot_transform_looking_at(const godot_transform *p_self, const godot_vector3 *p_target, const godot_vector3 *p_up) { - godot_transform dest; - const Transform *self = (const Transform *)p_self; - const Vector3 *target = (const Vector3 *)p_target; - const Vector3 *up = (const Vector3 *)p_up; - *((Transform *)&dest) = self->looking_at(*target, *up); - return dest; -} - -godot_plane GDAPI godot_transform_xform_plane(const godot_transform *p_self, const godot_plane *p_v) { - godot_plane raw_dest; - Plane *dest = (Plane *)&raw_dest; - const Transform *self = (const Transform *)p_self; - const Plane *v = (const Plane *)p_v; - *dest = self->xform(*v); - return raw_dest; -} - -godot_plane GDAPI godot_transform_xform_inv_plane(const godot_transform *p_self, const godot_plane *p_v) { - godot_plane raw_dest; - Plane *dest = (Plane *)&raw_dest; - const Transform *self = (const Transform *)p_self; - const Plane *v = (const Plane *)p_v; - *dest = self->xform_inv(*v); - return raw_dest; -} - -void GDAPI godot_transform_new_identity(godot_transform *r_dest) { - Transform *dest = (Transform *)r_dest; - *dest = Transform(); -} - -godot_bool GDAPI godot_transform_operator_equal(const godot_transform *p_self, const godot_transform *p_b) { - const Transform *self = (const Transform *)p_self; - const Transform *b = (const Transform *)p_b; - return *self == *b; -} - -godot_transform GDAPI godot_transform_operator_multiply(const godot_transform *p_self, const godot_transform *p_b) { - godot_transform raw_dest; - Transform *dest = (Transform *)&raw_dest; - const Transform *self = (const Transform *)p_self; - const Transform *b = (const Transform *)p_b; - *dest = *self * *b; - return raw_dest; -} - -godot_vector3 GDAPI godot_transform_xform_vector3(const godot_transform *p_self, const godot_vector3 *p_v) { - godot_vector3 raw_dest; - Vector3 *dest = (Vector3 *)&raw_dest; - const Transform *self = (const Transform *)p_self; - const Vector3 *v = (const Vector3 *)p_v; - *dest = self->xform(*v); - return raw_dest; -} - -godot_vector3 GDAPI godot_transform_xform_inv_vector3(const godot_transform *p_self, const godot_vector3 *p_v) { - godot_vector3 raw_dest; - Vector3 *dest = (Vector3 *)&raw_dest; - const Transform *self = (const Transform *)p_self; - const Vector3 *v = (const Vector3 *)p_v; - *dest = self->xform_inv(*v); - return raw_dest; -} - -godot_aabb GDAPI godot_transform_xform_aabb(const godot_transform *p_self, const godot_aabb *p_v) { - godot_aabb raw_dest; - AABB *dest = (AABB *)&raw_dest; - const Transform *self = (const Transform *)p_self; - const AABB *v = (const AABB *)p_v; - *dest = self->xform(*v); - return raw_dest; -} - -godot_aabb GDAPI godot_transform_xform_inv_aabb(const godot_transform *p_self, const godot_aabb *p_v) { - godot_aabb raw_dest; - AABB *dest = (AABB *)&raw_dest; - const Transform *self = (const Transform *)p_self; - const AABB *v = (const AABB *)p_v; - *dest = self->xform_inv(*v); - return raw_dest; +void GDAPI godot_transform_new(godot_transform *p_self) { + memnew_placement(p_self, Transform); } #ifdef __cplusplus diff --git a/modules/gdnative/gdnative/transform2d.cpp b/modules/gdnative/gdnative/transform2d.cpp index 3c1105e323..679174d5a5 100644 --- a/modules/gdnative/gdnative/transform2d.cpp +++ b/modules/gdnative/gdnative/transform2d.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -31,179 +31,25 @@ #include "gdnative/transform2d.h" #include "core/math/transform_2d.h" -#include "core/variant/variant.h" + +static_assert(sizeof(godot_transform2d) == sizeof(Transform2D), "Transform2D size mismatch"); #ifdef __cplusplus extern "C" { #endif -static_assert(sizeof(godot_transform2d) == sizeof(Transform2D), "Transform2D size mismatch"); - -void GDAPI godot_transform2d_new(godot_transform2d *r_dest, const godot_real p_rot, const godot_vector2 *p_pos) { - const Vector2 *pos = (const Vector2 *)p_pos; - Transform2D *dest = (Transform2D *)r_dest; - *dest = Transform2D(p_rot, *pos); -} - -void GDAPI godot_transform2d_new_axis_origin(godot_transform2d *r_dest, const godot_vector2 *p_x_axis, const godot_vector2 *p_y_axis, const godot_vector2 *p_origin) { - const Vector2 *x_axis = (const Vector2 *)p_x_axis; - const Vector2 *y_axis = (const Vector2 *)p_y_axis; - const Vector2 *origin = (const Vector2 *)p_origin; - Transform2D *dest = (Transform2D *)r_dest; - *dest = Transform2D(x_axis->x, x_axis->y, y_axis->x, y_axis->y, origin->x, origin->y); -} - -godot_string GDAPI godot_transform2d_as_string(const godot_transform2d *p_self) { - godot_string ret; - const Transform2D *self = (const Transform2D *)p_self; - memnew_placement(&ret, String(*self)); - return ret; -} - -godot_transform2d GDAPI godot_transform2d_inverse(const godot_transform2d *p_self) { - godot_transform2d dest; - const Transform2D *self = (const Transform2D *)p_self; - *((Transform2D *)&dest) = self->inverse(); - return dest; -} - -godot_transform2d GDAPI godot_transform2d_affine_inverse(const godot_transform2d *p_self) { - godot_transform2d dest; - const Transform2D *self = (const Transform2D *)p_self; - *((Transform2D *)&dest) = self->affine_inverse(); - return dest; -} - -godot_real GDAPI godot_transform2d_get_rotation(const godot_transform2d *p_self) { - const Transform2D *self = (const Transform2D *)p_self; - return self->get_rotation(); -} - -godot_vector2 GDAPI godot_transform2d_get_origin(const godot_transform2d *p_self) { - godot_vector2 dest; - const Transform2D *self = (const Transform2D *)p_self; - *((Vector2 *)&dest) = self->get_origin(); - return dest; -} - -godot_vector2 GDAPI godot_transform2d_get_scale(const godot_transform2d *p_self) { - godot_vector2 dest; - const Transform2D *self = (const Transform2D *)p_self; - *((Vector2 *)&dest) = self->get_scale(); - return dest; -} - -godot_transform2d GDAPI godot_transform2d_orthonormalized(const godot_transform2d *p_self) { - godot_transform2d dest; - const Transform2D *self = (const Transform2D *)p_self; - *((Transform2D *)&dest) = self->orthonormalized(); - return dest; -} - -godot_transform2d GDAPI godot_transform2d_rotated(const godot_transform2d *p_self, const godot_real p_phi) { - godot_transform2d dest; - const Transform2D *self = (const Transform2D *)p_self; - - *((Transform2D *)&dest) = self->rotated(p_phi); - return dest; +void GDAPI godot_transform2d_new(godot_transform2d *p_self) { + memnew_placement(p_self, Transform2D); } -godot_transform2d GDAPI godot_transform2d_scaled(const godot_transform2d *p_self, const godot_vector2 *p_scale) { - godot_transform2d dest; - const Transform2D *self = (const Transform2D *)p_self; - const Vector2 *scale = (const Vector2 *)p_scale; - *((Transform2D *)&dest) = self->scaled(*scale); - return dest; -} - -godot_transform2d GDAPI godot_transform2d_translated(const godot_transform2d *p_self, const godot_vector2 *p_offset) { - godot_transform2d dest; - const Transform2D *self = (const Transform2D *)p_self; - const Vector2 *offset = (const Vector2 *)p_offset; - *((Transform2D *)&dest) = self->translated(*offset); - return dest; -} - -godot_vector2 GDAPI godot_transform2d_xform_vector2(const godot_transform2d *p_self, const godot_vector2 *p_v) { - godot_vector2 raw_dest; - Vector2 *dest = (Vector2 *)&raw_dest; - const Transform2D *self = (const Transform2D *)p_self; - const Vector2 *v = (const Vector2 *)p_v; - *dest = self->xform(*v); - return raw_dest; -} - -godot_vector2 GDAPI godot_transform2d_xform_inv_vector2(const godot_transform2d *p_self, const godot_vector2 *p_v) { - godot_vector2 raw_dest; - Vector2 *dest = (Vector2 *)&raw_dest; - const Transform2D *self = (const Transform2D *)p_self; - const Vector2 *v = (const Vector2 *)p_v; - *dest = self->xform_inv(*v); - return raw_dest; -} - -godot_vector2 GDAPI godot_transform2d_basis_xform_vector2(const godot_transform2d *p_self, const godot_vector2 *p_v) { - godot_vector2 raw_dest; - Vector2 *dest = (Vector2 *)&raw_dest; - const Transform2D *self = (const Transform2D *)p_self; - const Vector2 *v = (const Vector2 *)p_v; - *dest = self->basis_xform(*v); - return raw_dest; -} - -godot_vector2 GDAPI godot_transform2d_basis_xform_inv_vector2(const godot_transform2d *p_self, const godot_vector2 *p_v) { - godot_vector2 raw_dest; - Vector2 *dest = (Vector2 *)&raw_dest; - const Transform2D *self = (const Transform2D *)p_self; - const Vector2 *v = (const Vector2 *)p_v; - *dest = self->basis_xform_inv(*v); - return raw_dest; -} - -godot_transform2d GDAPI godot_transform2d_interpolate_with(const godot_transform2d *p_self, const godot_transform2d *p_m, const godot_real p_c) { - godot_transform2d dest; - const Transform2D *self = (const Transform2D *)p_self; - const Transform2D *m = (const Transform2D *)p_m; - *((Transform2D *)&dest) = self->interpolate_with(*m, p_c); - return dest; -} - -godot_bool GDAPI godot_transform2d_operator_equal(const godot_transform2d *p_self, const godot_transform2d *p_b) { - const Transform2D *self = (const Transform2D *)p_self; - const Transform2D *b = (const Transform2D *)p_b; - return *self == *b; -} - -godot_transform2d GDAPI godot_transform2d_operator_multiply(const godot_transform2d *p_self, const godot_transform2d *p_b) { - godot_transform2d raw_dest; - Transform2D *dest = (Transform2D *)&raw_dest; - const Transform2D *self = (const Transform2D *)p_self; - const Transform2D *b = (const Transform2D *)p_b; - *dest = *self * *b; - return raw_dest; -} - -void GDAPI godot_transform2d_new_identity(godot_transform2d *r_dest) { - Transform2D *dest = (Transform2D *)r_dest; - *dest = Transform2D(); -} - -godot_rect2 GDAPI godot_transform2d_xform_rect2(const godot_transform2d *p_self, const godot_rect2 *p_v) { - godot_rect2 raw_dest; - Rect2 *dest = (Rect2 *)&raw_dest; - const Transform2D *self = (const Transform2D *)p_self; - const Rect2 *v = (const Rect2 *)p_v; - *dest = self->xform(*v); - return raw_dest; +godot_vector2 GDAPI *godot_transform2d_operator_index(godot_transform2d *p_self, godot_int p_index) { + Transform2D *self = (Transform2D *)p_self; + return (godot_vector2 *)&self->operator[](p_index); } -godot_rect2 GDAPI godot_transform2d_xform_inv_rect2(const godot_transform2d *p_self, const godot_rect2 *p_v) { - godot_rect2 raw_dest; - Rect2 *dest = (Rect2 *)&raw_dest; +const godot_vector2 GDAPI *godot_transform2d_operator_index_const(const godot_transform2d *p_self, godot_int p_index) { const Transform2D *self = (const Transform2D *)p_self; - const Rect2 *v = (const Rect2 *)p_v; - *dest = self->xform_inv(*v); - return raw_dest; + return (const godot_vector2 *)&self->operator[](p_index); } #ifdef __cplusplus diff --git a/modules/gdnative/gdnative/variant.cpp b/modules/gdnative/gdnative/variant.cpp index 417abeaad3..ee4353bb48 100644 --- a/modules/gdnative/gdnative/variant.cpp +++ b/modules/gdnative/gdnative/variant.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -55,16 +55,11 @@ static_assert(sizeof(godot_variant) == sizeof(Variant), "Variant size mismatch") #pragma GCC pop_options #endif -// Constructors - -godot_variant_type GDAPI godot_variant_get_type(const godot_variant *p_self) { - const Variant *self = (const Variant *)p_self; - return (godot_variant_type)self->get_type(); -} +// Memory void GDAPI godot_variant_new_copy(godot_variant *p_dest, const godot_variant *p_src) { Variant *dest = (Variant *)p_dest; - Variant *src = (Variant *)p_src; + const Variant *src = (const Variant *)p_src; memnew_placement(dest, Variant(*src)); } @@ -78,139 +73,134 @@ void GDAPI godot_variant_new_bool(godot_variant *r_dest, const godot_bool p_b) { memnew_placement_custom(dest, Variant, Variant(p_b)); } -void GDAPI godot_variant_new_uint(godot_variant *r_dest, const uint64_t p_i) { +void GDAPI godot_variant_new_int(godot_variant *r_dest, const godot_int p_i) { Variant *dest = (Variant *)r_dest; memnew_placement_custom(dest, Variant, Variant(p_i)); } -void GDAPI godot_variant_new_int(godot_variant *r_dest, const int64_t p_i) { - Variant *dest = (Variant *)r_dest; - memnew_placement_custom(dest, Variant, Variant(p_i)); -} - -void GDAPI godot_variant_new_real(godot_variant *r_dest, const double p_r) { +void GDAPI godot_variant_new_float(godot_variant *r_dest, const godot_float p_r) { Variant *dest = (Variant *)r_dest; memnew_placement_custom(dest, Variant, Variant(p_r)); } void GDAPI godot_variant_new_string(godot_variant *r_dest, const godot_string *p_s) { Variant *dest = (Variant *)r_dest; - String *s = (String *)p_s; + const String *s = (const String *)p_s; memnew_placement_custom(dest, Variant, Variant(*s)); } void GDAPI godot_variant_new_string_name(godot_variant *r_dest, const godot_string_name *p_s) { Variant *dest = (Variant *)r_dest; - StringName *s = (StringName *)p_s; + const StringName *s = (const StringName *)p_s; memnew_placement_custom(dest, Variant, Variant(*s)); } void GDAPI godot_variant_new_vector2(godot_variant *r_dest, const godot_vector2 *p_v2) { Variant *dest = (Variant *)r_dest; - Vector2 *v2 = (Vector2 *)p_v2; + const Vector2 *v2 = (const Vector2 *)p_v2; memnew_placement_custom(dest, Variant, Variant(*v2)); } void GDAPI godot_variant_new_vector2i(godot_variant *r_dest, const godot_vector2i *p_v2) { Variant *dest = (Variant *)r_dest; - Vector2i *v2 = (Vector2i *)p_v2; + const Vector2i *v2 = (const Vector2i *)p_v2; memnew_placement_custom(dest, Variant, Variant(*v2)); } void GDAPI godot_variant_new_rect2(godot_variant *r_dest, const godot_rect2 *p_rect2) { Variant *dest = (Variant *)r_dest; - Rect2 *rect2 = (Rect2 *)p_rect2; + const Rect2 *rect2 = (const Rect2 *)p_rect2; memnew_placement_custom(dest, Variant, Variant(*rect2)); } void GDAPI godot_variant_new_rect2i(godot_variant *r_dest, const godot_rect2i *p_rect2) { Variant *dest = (Variant *)r_dest; - Rect2i *rect2 = (Rect2i *)p_rect2; + const Rect2i *rect2 = (const Rect2i *)p_rect2; memnew_placement_custom(dest, Variant, Variant(*rect2)); } void GDAPI godot_variant_new_vector3(godot_variant *r_dest, const godot_vector3 *p_v3) { Variant *dest = (Variant *)r_dest; - Vector3 *v3 = (Vector3 *)p_v3; + const Vector3 *v3 = (const Vector3 *)p_v3; memnew_placement_custom(dest, Variant, Variant(*v3)); } void GDAPI godot_variant_new_vector3i(godot_variant *r_dest, const godot_vector3i *p_v3) { Variant *dest = (Variant *)r_dest; - Vector3i *v3 = (Vector3i *)p_v3; + const Vector3i *v3 = (const Vector3i *)p_v3; memnew_placement_custom(dest, Variant, Variant(*v3)); } void GDAPI godot_variant_new_transform2d(godot_variant *r_dest, const godot_transform2d *p_t2d) { Variant *dest = (Variant *)r_dest; - Transform2D *t2d = (Transform2D *)p_t2d; + const Transform2D *t2d = (const Transform2D *)p_t2d; memnew_placement_custom(dest, Variant, Variant(*t2d)); } void GDAPI godot_variant_new_plane(godot_variant *r_dest, const godot_plane *p_plane) { Variant *dest = (Variant *)r_dest; - Plane *plane = (Plane *)p_plane; + const Plane *plane = (const Plane *)p_plane; memnew_placement_custom(dest, Variant, Variant(*plane)); } void GDAPI godot_variant_new_quat(godot_variant *r_dest, const godot_quat *p_quat) { Variant *dest = (Variant *)r_dest; - Quat *quat = (Quat *)p_quat; + const Quat *quat = (const Quat *)p_quat; memnew_placement_custom(dest, Variant, Variant(*quat)); } void GDAPI godot_variant_new_aabb(godot_variant *r_dest, const godot_aabb *p_aabb) { Variant *dest = (Variant *)r_dest; - AABB *aabb = (AABB *)p_aabb; + const AABB *aabb = (const AABB *)p_aabb; memnew_placement_custom(dest, Variant, Variant(*aabb)); } void GDAPI godot_variant_new_basis(godot_variant *r_dest, const godot_basis *p_basis) { Variant *dest = (Variant *)r_dest; - Basis *basis = (Basis *)p_basis; + const Basis *basis = (const Basis *)p_basis; memnew_placement_custom(dest, Variant, Variant(*basis)); } void GDAPI godot_variant_new_transform(godot_variant *r_dest, const godot_transform *p_trans) { Variant *dest = (Variant *)r_dest; - Transform *trans = (Transform *)p_trans; + const Transform *trans = (const Transform *)p_trans; memnew_placement_custom(dest, Variant, Variant(*trans)); } void GDAPI godot_variant_new_color(godot_variant *r_dest, const godot_color *p_color) { Variant *dest = (Variant *)r_dest; - Color *color = (Color *)p_color; + const Color *color = (const Color *)p_color; memnew_placement_custom(dest, Variant, Variant(*color)); } void GDAPI godot_variant_new_node_path(godot_variant *r_dest, const godot_node_path *p_np) { Variant *dest = (Variant *)r_dest; - NodePath *np = (NodePath *)p_np; + const NodePath *np = (const NodePath *)p_np; memnew_placement_custom(dest, Variant, Variant(*np)); } void GDAPI godot_variant_new_rid(godot_variant *r_dest, const godot_rid *p_rid) { Variant *dest = (Variant *)r_dest; - RID *rid = (RID *)p_rid; + const RID *rid = (const RID *)p_rid; memnew_placement_custom(dest, Variant, Variant(*rid)); } void GDAPI godot_variant_new_callable(godot_variant *r_dest, const godot_callable *p_cb) { Variant *dest = (Variant *)r_dest; - Callable *cb = (Callable *)p_cb; + const Callable *cb = (const Callable *)p_cb; memnew_placement_custom(dest, Variant, Variant(*cb)); } void GDAPI godot_variant_new_signal(godot_variant *r_dest, const godot_signal *p_signal) { Variant *dest = (Variant *)r_dest; - Signal *signal = (Signal *)p_signal; + const Signal *signal = (const Signal *)p_signal; memnew_placement_custom(dest, Variant, Variant(*signal)); } void GDAPI godot_variant_new_object(godot_variant *r_dest, const godot_object *p_obj) { Variant *dest = (Variant *)r_dest; - Object *obj = (Object *)p_obj; - Reference *reference = Object::cast_to<Reference>(obj); + const Object *obj = (const Object *)p_obj; + const Reference *reference = Object::cast_to<Reference>(obj); REF ref; if (reference) { ref = REF(reference); @@ -229,67 +219,67 @@ void GDAPI godot_variant_new_object(godot_variant *r_dest, const godot_object *p void GDAPI godot_variant_new_dictionary(godot_variant *r_dest, const godot_dictionary *p_dict) { Variant *dest = (Variant *)r_dest; - Dictionary *dict = (Dictionary *)p_dict; + const Dictionary *dict = (const Dictionary *)p_dict; memnew_placement_custom(dest, Variant, Variant(*dict)); } void GDAPI godot_variant_new_array(godot_variant *r_dest, const godot_array *p_arr) { Variant *dest = (Variant *)r_dest; - Array *arr = (Array *)p_arr; + const Array *arr = (const Array *)p_arr; memnew_placement_custom(dest, Variant, Variant(*arr)); } void GDAPI godot_variant_new_packed_byte_array(godot_variant *r_dest, const godot_packed_byte_array *p_pba) { Variant *dest = (Variant *)r_dest; - PackedByteArray *pba = (PackedByteArray *)p_pba; + const PackedByteArray *pba = (const PackedByteArray *)p_pba; memnew_placement_custom(dest, Variant, Variant(*pba)); } void GDAPI godot_variant_new_packed_int32_array(godot_variant *r_dest, const godot_packed_int32_array *p_pia) { Variant *dest = (Variant *)r_dest; - PackedInt32Array *pia = (PackedInt32Array *)p_pia; + const PackedInt32Array *pia = (const PackedInt32Array *)p_pia; memnew_placement_custom(dest, Variant, Variant(*pia)); } void GDAPI godot_variant_new_packed_int64_array(godot_variant *r_dest, const godot_packed_int64_array *p_pia) { Variant *dest = (Variant *)r_dest; - PackedInt64Array *pia = (PackedInt64Array *)p_pia; + const PackedInt64Array *pia = (const PackedInt64Array *)p_pia; memnew_placement_custom(dest, Variant, Variant(*pia)); } void GDAPI godot_variant_new_packed_float32_array(godot_variant *r_dest, const godot_packed_float32_array *p_pra) { Variant *dest = (Variant *)r_dest; - PackedFloat32Array *pra = (PackedFloat32Array *)p_pra; + const PackedFloat32Array *pra = (const PackedFloat32Array *)p_pra; memnew_placement_custom(dest, Variant, Variant(*pra)); } void GDAPI godot_variant_new_packed_float64_array(godot_variant *r_dest, const godot_packed_float64_array *p_pra) { Variant *dest = (Variant *)r_dest; - PackedFloat64Array *pra = (PackedFloat64Array *)p_pra; + const PackedFloat64Array *pra = (const PackedFloat64Array *)p_pra; memnew_placement_custom(dest, Variant, Variant(*pra)); } void GDAPI godot_variant_new_packed_string_array(godot_variant *r_dest, const godot_packed_string_array *p_psa) { Variant *dest = (Variant *)r_dest; - PackedStringArray *psa = (PackedStringArray *)p_psa; + const PackedStringArray *psa = (const PackedStringArray *)p_psa; memnew_placement_custom(dest, Variant, Variant(*psa)); } void GDAPI godot_variant_new_packed_vector2_array(godot_variant *r_dest, const godot_packed_vector2_array *p_pv2a) { Variant *dest = (Variant *)r_dest; - PackedVector2Array *pv2a = (PackedVector2Array *)p_pv2a; + const PackedVector2Array *pv2a = (const PackedVector2Array *)p_pv2a; memnew_placement_custom(dest, Variant, Variant(*pv2a)); } void GDAPI godot_variant_new_packed_vector3_array(godot_variant *r_dest, const godot_packed_vector3_array *p_pv3a) { Variant *dest = (Variant *)r_dest; - PackedVector3Array *pv3a = (PackedVector3Array *)p_pv3a; + const PackedVector3Array *pv3a = (const PackedVector3Array *)p_pv3a; memnew_placement_custom(dest, Variant, Variant(*pv3a)); } void GDAPI godot_variant_new_packed_color_array(godot_variant *r_dest, const godot_packed_color_array *p_pca) { Variant *dest = (Variant *)r_dest; - PackedColorArray *pca = (PackedColorArray *)p_pca; + const PackedColorArray *pca = (const PackedColorArray *)p_pca; memnew_placement_custom(dest, Variant, Variant(*pca)); } @@ -298,17 +288,12 @@ godot_bool GDAPI godot_variant_as_bool(const godot_variant *p_self) { return self->operator bool(); } -uint64_t GDAPI godot_variant_as_uint(const godot_variant *p_self) { - const Variant *self = (const Variant *)p_self; - return self->operator uint64_t(); -} - -int64_t GDAPI godot_variant_as_int(const godot_variant *p_self) { +godot_int GDAPI godot_variant_as_int(const godot_variant *p_self) { const Variant *self = (const Variant *)p_self; return self->operator int64_t(); } -double GDAPI godot_variant_as_real(const godot_variant *p_self) { +godot_float GDAPI godot_variant_as_float(const godot_variant *p_self) { const Variant *self = (const Variant *)p_self; return self->operator double(); } @@ -569,47 +554,137 @@ godot_packed_color_array GDAPI godot_variant_as_packed_color_array(const godot_v return raw_dest; } -godot_variant GDAPI godot_variant_call(godot_variant *p_self, const godot_string *p_method, const godot_variant **p_args, const godot_int p_argcount, godot_variant_call_error *r_error) { +void GDAPI godot_variant_destroy(godot_variant *p_self) { + Variant *self = (Variant *)p_self; + self->~Variant(); +} + +// Dynamic interaction. + +void GDAPI godot_variant_call(godot_variant *p_self, const godot_string_name *p_method, const godot_variant **p_args, const godot_int p_argcount, godot_variant *r_return, godot_variant_call_error *r_error) { Variant *self = (Variant *)p_self; - String *method = (String *)p_method; + const StringName *method = (const StringName *)p_method; const Variant **args = (const Variant **)p_args; - godot_variant raw_dest; - Variant *dest = (Variant *)&raw_dest; - Callable::CallError error; Variant ret; + Callable::CallError error; self->call(*method, args, p_argcount, ret, error); - memnew_placement_custom(dest, Variant, Variant(ret)); + memnew_placement_custom(r_return, Variant, Variant(ret)); + if (r_error) { r_error->error = (godot_variant_call_error_error)error.error; r_error->argument = error.argument; r_error->expected = (godot_variant_type)error.expected; } - return raw_dest; } -godot_bool GDAPI godot_variant_has_method(const godot_variant *p_self, const godot_string *p_method) { +void GDAPI godot_variant_evaluate(godot_variant_operator p_op, const godot_variant *p_a, const godot_variant *p_b, godot_variant *r_return, bool *r_valid) { + Variant::Operator op = (Variant::Operator)p_op; + const Variant *a = (const Variant *)p_a; + const Variant *b = (const Variant *)p_b; + Variant *ret = (Variant *)r_return; + Variant::evaluate(op, *a, *b, *ret, *r_valid); +} + +void GDAPI godot_variant_set(godot_variant *p_self, const godot_variant *p_key, const godot_variant *p_value, bool *r_valid) { + Variant *self = (Variant *)p_self; + const Variant *key = (const Variant *)p_key; + const Variant *value = (const Variant *)p_value; + + self->set(*key, *value, r_valid); +} + +void GDAPI godot_variant_set_named(godot_variant *p_self, const godot_string_name *p_name, const godot_variant *p_value, bool *r_valid) { + Variant *self = (Variant *)p_self; + const StringName *name = (const StringName *)p_name; + const Variant *value = (const Variant *)p_value; + + self->set_named(*name, *value, *r_valid); +} + +void GDAPI godot_variant_set_keyed(godot_variant *p_self, const godot_variant *p_key, const godot_variant *p_value, bool *r_valid) { + Variant *self = (Variant *)p_self; + const Variant *key = (const Variant *)p_key; + const Variant *value = (const Variant *)p_value; + + self->set_keyed(*key, *value, *r_valid); +} + +void GDAPI godot_variant_set_indexed(godot_variant *p_self, godot_int p_index, const godot_variant *p_value, bool *r_valid, bool *r_oob) { + Variant *self = (Variant *)p_self; + const Variant *value = (const Variant *)p_value; + + self->set_indexed(p_index, value, *r_valid, *r_oob); +} + +godot_variant GDAPI godot_variant_get(const godot_variant *p_self, const godot_variant *p_key, bool *r_valid) { const Variant *self = (const Variant *)p_self; - const String *method = (const String *)p_method; - return self->has_method(*method); + const Variant *key = (const Variant *)p_key; + Variant ret; + + ret = self->get(*key, r_valid); + godot_variant result; + memnew_placement_custom(&result, Variant, Variant(ret)); + return result; } -godot_bool GDAPI godot_variant_operator_equal(const godot_variant *p_self, const godot_variant *p_other) { +godot_variant GDAPI godot_variant_get_named(const godot_variant *p_self, const godot_string_name *p_key, bool *r_valid) { const Variant *self = (const Variant *)p_self; - const Variant *other = (const Variant *)p_other; - return self->operator==(*other); + const StringName *key = (const StringName *)p_key; + Variant ret; + + ret = self->get_named(*key, *r_valid); + godot_variant result; + memnew_placement_custom(&result, Variant, Variant(ret)); + return result; } -godot_bool GDAPI godot_variant_operator_less(const godot_variant *p_self, const godot_variant *p_other) { +godot_variant GDAPI godot_variant_get_keyed(const godot_variant *p_self, const godot_variant *p_key, bool *r_valid) { const Variant *self = (const Variant *)p_self; - const Variant *other = (const Variant *)p_other; - return self->operator<(*other); + const Variant *key = (const Variant *)p_key; + Variant ret; + + ret = self->get_keyed(*key, *r_valid); + godot_variant result; + memnew_placement_custom(&result, Variant, Variant(ret)); + return result; +} + +godot_variant GDAPI godot_variant_get_indexed(const godot_variant *p_self, godot_int p_index, bool *r_valid, bool *r_oob) { + const Variant *self = (const Variant *)p_self; + Variant ret; + + ret = self->get_indexed(p_index, *r_valid, *r_oob); + godot_variant result; + memnew_placement_custom(&result, Variant, Variant(ret)); + return result; } -uint32_t GDAPI godot_variant_hash(const godot_variant *p_self) { +/// Iteration. +bool GDAPI godot_variant_iter_init(const godot_variant *p_self, godot_variant *r_iter, bool *r_valid) { const Variant *self = (const Variant *)p_self; - return self->hash(); + Variant *iter = (Variant *)r_iter; + + return self->iter_init(*iter, *r_valid); } +bool GDAPI godot_variant_iter_next(const godot_variant *p_self, godot_variant *r_iter, bool *r_valid) { + const Variant *self = (const Variant *)p_self; + Variant *iter = (Variant *)r_iter; + + return self->iter_next(*iter, *r_valid); +} + +godot_variant GDAPI godot_variant_iter_get(const godot_variant *p_self, godot_variant *r_iter, bool *r_valid) { + const Variant *self = (const Variant *)p_self; + Variant *iter = (Variant *)r_iter; + + Variant result = self->iter_next(*iter, *r_valid); + godot_variant ret; + memnew_placement_custom(&ret, Variant, Variant(result)); + return ret; +} + +/// Variant functions. godot_bool GDAPI godot_variant_hash_compare(const godot_variant *p_self, const godot_variant *p_other) { const Variant *self = (const Variant *)p_self; const Variant *other = (const Variant *)p_other; @@ -621,27 +696,503 @@ godot_bool GDAPI godot_variant_booleanize(const godot_variant *p_self) { return self->booleanize(); } -void GDAPI godot_variant_destroy(godot_variant *p_self) { - Variant *self = (Variant *)p_self; - self->~Variant(); +void GDAPI godot_variant_blend(const godot_variant *p_a, const godot_variant *p_b, float p_c, godot_variant *r_dst) { + const Variant *a = (const Variant *)p_a; + const Variant *b = (const Variant *)p_b; + Variant *dst = (Variant *)r_dst; + Variant::blend(*a, *b, p_c, *dst); } -// GDNative core 1.1 +void GDAPI godot_variant_interpolate(const godot_variant *p_a, const godot_variant *p_b, float p_c, godot_variant *r_dst) { + const Variant *a = (const Variant *)p_a; + const Variant *b = (const Variant *)p_b; + Variant *dst = (Variant *)r_dst; + Variant::interpolate(*a, *b, p_c, *dst); +} -godot_string GDAPI godot_variant_get_operator_name(godot_variant_operator p_op) { - Variant::Operator op = (Variant::Operator)p_op; - godot_string raw_dest; - String *dest = (String *)&raw_dest; - memnew_placement(dest, String(Variant::get_operator_name(op))); // operator = is overloaded by String - return raw_dest; +godot_variant GDAPI godot_variant_duplicate(const godot_variant *p_self, godot_bool p_deep) { + const Variant *self = (const Variant *)p_self; + Variant result = self->duplicate(p_deep); + godot_variant ret; + memnew_placement_custom(&ret, Variant, Variant(result)); + return ret; } -void GDAPI godot_variant_evaluate(godot_variant_operator p_op, const godot_variant *p_a, const godot_variant *p_b, godot_variant *r_ret, godot_bool *r_valid) { - Variant::Operator op = (Variant::Operator)p_op; - const Variant *a = (const Variant *)p_a; - const Variant *b = (const Variant *)p_b; +godot_string GDAPI godot_variant_stringify(const godot_variant *p_self) { + const Variant *self = (const Variant *)p_self; + String result = *self; + godot_string ret; + memnew_placement_custom(&ret, String, String(result)); + return ret; +} + +// Discovery API + +/// Operators +godot_validated_operator_evaluator GDAPI godot_variant_get_validated_operator_evaluator(godot_variant_operator p_operator, godot_variant_type p_type_a, godot_variant_type p_type_b) { + return (godot_validated_operator_evaluator)Variant::get_validated_operator_evaluator((Variant::Operator)p_operator, (Variant::Type)p_type_a, (Variant::Type)p_type_b); +} + +godot_ptr_operator_evaluator GDAPI godot_variant_get_ptr_operator_evaluator(godot_variant_operator p_operator, godot_variant_type p_type_a, godot_variant_type p_type_b) { + return (godot_ptr_operator_evaluator)Variant::get_ptr_operator_evaluator((Variant::Operator)p_operator, (Variant::Type)p_type_a, (Variant::Type)p_type_b); +} + +godot_variant_type GDAPI godot_variant_get_operator_return_type(godot_variant_operator p_operator, godot_variant_type p_type_a, godot_variant_type p_type_b) { + return (godot_variant_type)Variant::get_operator_return_type((Variant::Operator)p_operator, (Variant::Type)p_type_a, (Variant::Type)p_type_b); +} + +godot_string GDAPI godot_variant_get_operator_name(godot_variant_operator p_operator) { + String op_name = Variant::get_operator_name((Variant::Operator)p_operator); + godot_string ret; + memnew_placement_custom(&ret, String, String(op_name)); + return ret; +} + +/// Built-in Methods + +bool GDAPI godot_variant_has_builtin_method(godot_variant_type p_type, const godot_string_name *p_method) { + return Variant::has_builtin_method((Variant::Type)p_type, *((const StringName *)p_method)); +} + +bool GDAPI godot_variant_has_builtin_method_with_cstring(godot_variant_type p_type, const char *p_method) { + return Variant::has_builtin_method((Variant::Type)p_type, StringName(p_method)); +} + +godot_validated_builtin_method GDAPI godot_variant_get_validated_builtin_method(godot_variant_type p_type, const godot_string_name *p_method) { + return (godot_validated_builtin_method)Variant::get_validated_builtin_method((Variant::Type)p_type, *((const StringName *)p_method)); +} + +godot_validated_builtin_method GDAPI godot_variant_get_validated_builtin_method_with_cstring(godot_variant_type p_type, const char *p_method) { + return (godot_validated_builtin_method)Variant::get_validated_builtin_method((Variant::Type)p_type, StringName(p_method)); +} + +godot_ptr_builtin_method GDAPI godot_variant_get_ptr_builtin_method(godot_variant_type p_type, const godot_string_name *p_method) { + return (godot_ptr_builtin_method)Variant::get_ptr_builtin_method((Variant::Type)p_type, *((const StringName *)p_method)); +} + +godot_ptr_builtin_method GDAPI godot_variant_get_ptr_builtin_method_with_cstring(godot_variant_type p_type, const char *p_method) { + return (godot_ptr_builtin_method)Variant::get_ptr_builtin_method((Variant::Type)p_type, StringName(p_method)); +} + +int GDAPI godot_variant_get_builtin_method_argument_count(godot_variant_type p_type, const godot_string_name *p_method) { + return Variant::get_builtin_method_argument_count((Variant::Type)p_type, *((const StringName *)p_method)); +} + +int GDAPI godot_variant_get_builtin_method_argument_count_with_cstring(godot_variant_type p_type, const char *p_method) { + return Variant::get_builtin_method_argument_count((Variant::Type)p_type, StringName(p_method)); +} + +godot_variant_type GDAPI godot_variant_get_builtin_method_argument_type(godot_variant_type p_type, const godot_string_name *p_method, int p_argument) { + return (godot_variant_type)Variant::get_builtin_method_argument_type((Variant::Type)p_type, *((const StringName *)p_method), p_argument); +} + +godot_variant_type GDAPI godot_variant_get_builtin_method_argument_type_with_cstring(godot_variant_type p_type, const char *p_method, int p_argument) { + return (godot_variant_type)Variant::get_builtin_method_argument_type((Variant::Type)p_type, StringName(p_method), p_argument); +} + +godot_string GDAPI godot_variant_get_builtin_method_argument_name(godot_variant_type p_type, const godot_string_name *p_method, int p_argument) { + String name = Variant::get_builtin_method_argument_name((Variant::Type)p_type, *((const StringName *)p_method), p_argument); + return *(godot_string *)&name; +} + +godot_string GDAPI godot_variant_get_builtin_method_argument_name_with_cstring(godot_variant_type p_type, const char *p_method, int p_argument) { + String name = Variant::get_builtin_method_argument_name((Variant::Type)p_type, StringName(p_method), p_argument); + return *(godot_string *)&name; +} + +bool GDAPI godot_variant_has_builtin_method_return_value(godot_variant_type p_type, const godot_string_name *p_method) { + return Variant::has_builtin_method_return_value((Variant::Type)p_type, *((const StringName *)p_method)); +} + +bool GDAPI godot_variant_has_builtin_method_return_value_with_cstring(godot_variant_type p_type, const char *p_method) { + return Variant::has_builtin_method_return_value((Variant::Type)p_type, StringName(p_method)); +} + +godot_variant_type GDAPI godot_variant_get_builtin_method_return_type(godot_variant_type p_type, const godot_string_name *p_method) { + return (godot_variant_type)Variant::get_builtin_method_return_type((Variant::Type)p_type, *((const StringName *)p_method)); +} + +godot_variant_type GDAPI godot_variant_get_builtin_method_return_type_with_cstring(godot_variant_type p_type, const char *p_method) { + return (godot_variant_type)Variant::get_builtin_method_return_type((Variant::Type)p_type, StringName(p_method)); +} + +bool GDAPI godot_variant_is_builtin_method_const(godot_variant_type p_type, const godot_string_name *p_method) { + return Variant::is_builtin_method_const((Variant::Type)p_type, *((const StringName *)p_method)); +} + +bool GDAPI godot_variant_is_builtin_method_const_with_cstring(godot_variant_type p_type, const char *p_method) { + return Variant::is_builtin_method_const((Variant::Type)p_type, StringName(p_method)); +} + +bool GDAPI godot_variant_is_builtin_method_vararg(godot_variant_type p_type, const godot_string_name *p_method) { + return Variant::is_builtin_method_vararg((Variant::Type)p_type, *((const StringName *)p_method)); +} + +bool GDAPI godot_variant_is_builtin_method_vararg_with_cstring(godot_variant_type p_type, const char *p_method) { + return Variant::is_builtin_method_vararg((Variant::Type)p_type, StringName(p_method)); +} + +int GDAPI godot_variant_get_builtin_method_count(godot_variant_type p_type) { + return Variant::get_builtin_method_count((Variant::Type)p_type); +} + +void GDAPI godot_variant_get_builtin_method_list(godot_variant_type p_type, godot_string_name *r_list) { + List<StringName> list; + Variant::get_builtin_method_list((Variant::Type)p_type, &list); + int i = 0; + for (const List<StringName>::Element *E = list.front(); E; E = E->next()) { + memnew_placement_custom(&r_list[i], StringName, StringName(E->get())); + } +} + +/// Constructors + +int GDAPI godot_variant_get_constructor_count(godot_variant_type p_type) { + return Variant::get_constructor_count((Variant::Type)p_type); +} + +godot_validated_constructor GDAPI godot_variant_get_validated_constructor(godot_variant_type p_type, int p_constructor) { + return (godot_validated_constructor)Variant::get_validated_constructor((Variant::Type)p_type, p_constructor); +} + +godot_ptr_constructor GDAPI godot_variant_get_ptr_constructor(godot_variant_type p_type, int p_constructor) { + return (godot_ptr_constructor)Variant::get_ptr_constructor((Variant::Type)p_type, p_constructor); +} + +int GDAPI godot_variant_get_constructor_argument_count(godot_variant_type p_type, int p_constructor) { + return Variant::get_constructor_argument_count((Variant::Type)p_type, p_constructor); +} + +godot_variant_type GDAPI godot_variant_get_constructor_argument_type(godot_variant_type p_type, int p_constructor, int p_argument) { + return (godot_variant_type)Variant::get_constructor_argument_type((Variant::Type)p_type, p_constructor, p_argument); +} + +godot_string GDAPI godot_variant_get_constructor_argument_name(godot_variant_type p_type, int p_constructor, int p_argument) { + String name = Variant::get_constructor_argument_name((Variant::Type)p_type, p_constructor, p_argument); + godot_string ret; + memnew_placement(&ret, String(name)); + return ret; +} + +void GDAPI godot_variant_construct(godot_variant_type p_type, godot_variant *p_base, const godot_variant **p_args, int p_argcount, godot_variant_call_error *r_error) { + Variant::construct((Variant::Type)p_type, *((Variant *)p_base), (const Variant **)p_args, p_argcount, *((Callable::CallError *)r_error)); +} + +/// Properties. +godot_variant_type GDAPI godot_variant_get_member_type(godot_variant_type p_type, const godot_string_name *p_member) { + return (godot_variant_type)Variant::get_member_type((Variant::Type)p_type, *((const StringName *)p_member)); +} + +godot_variant_type GDAPI godot_variant_get_member_type_with_cstring(godot_variant_type p_type, const char *p_member) { + return (godot_variant_type)Variant::get_member_type((Variant::Type)p_type, StringName(p_member)); +} + +int GDAPI godot_variant_get_member_count(godot_variant_type p_type) { + return Variant::get_member_count((Variant::Type)p_type); +} + +void GDAPI godot_variant_get_member_list(godot_variant_type p_type, godot_string_name *r_list) { + List<StringName> members; + Variant::get_member_list((Variant::Type)p_type, &members); + int i = 0; + for (const List<StringName>::Element *E = members.front(); E; E = E->next()) { + memnew_placement_custom(&r_list[i++], StringName, StringName(E->get())); + } +} + +godot_validated_setter GDAPI godot_variant_get_validated_setter(godot_variant_type p_type, const godot_string_name *p_member) { + return (godot_validated_setter)Variant::get_member_validated_setter((Variant::Type)p_type, *((const StringName *)p_member)); +} + +godot_validated_setter GDAPI godot_variant_get_validated_setter_with_cstring(godot_variant_type p_type, const char *p_member) { + return (godot_validated_setter)Variant::get_member_validated_setter((Variant::Type)p_type, StringName(p_member)); +} + +godot_validated_getter GDAPI godot_variant_get_validated_getter(godot_variant_type p_type, const godot_string_name *p_member) { + return (godot_validated_getter)Variant::get_member_validated_getter((Variant::Type)p_type, *((const StringName *)p_member)); +} + +godot_validated_getter GDAPI godot_variant_get_validated_getter_with_cstring(godot_variant_type p_type, const char *p_member) { + return (godot_validated_getter)Variant::get_member_validated_getter((Variant::Type)p_type, StringName(p_member)); +} + +godot_ptr_setter GDAPI godot_variant_get_ptr_setter(godot_variant_type p_type, const godot_string_name *p_member) { + return (godot_ptr_setter)Variant::get_member_ptr_setter((Variant::Type)p_type, *((const StringName *)p_member)); +} + +godot_ptr_setter GDAPI godot_variant_get_ptr_setter_with_cstring(godot_variant_type p_type, const char *p_member) { + return (godot_ptr_setter)Variant::get_member_ptr_setter((Variant::Type)p_type, StringName(p_member)); +} + +godot_ptr_getter GDAPI godot_variant_get_ptr_getter(godot_variant_type p_type, const godot_string_name *p_member) { + return (godot_ptr_getter)Variant::get_member_ptr_getter((Variant::Type)p_type, *((const StringName *)p_member)); +} + +godot_ptr_getter GDAPI godot_variant_get_ptr_getter_with_cstring(godot_variant_type p_type, const char *p_member) { + return (godot_ptr_getter)Variant::get_member_ptr_getter((Variant::Type)p_type, StringName(p_member)); +} + +/// Indexing. +bool GDAPI godot_variant_has_indexing(godot_variant_type p_type) { + return Variant::has_indexing((Variant::Type)p_type); +} + +godot_variant_type GDAPI godot_variant_get_indexed_element_type(godot_variant_type p_type) { + return (godot_variant_type)Variant::get_indexed_element_type((Variant::Type)p_type); +} + +godot_validated_indexed_setter GDAPI godot_variant_get_validated_indexed_setter(godot_variant_type p_type) { + return (godot_validated_indexed_setter)Variant::get_member_validated_indexed_setter((Variant::Type)p_type); +} + +godot_validated_indexed_getter GDAPI godot_variant_get_validated_indexed_getter(godot_variant_type p_type) { + return (godot_validated_indexed_getter)Variant::get_member_validated_indexed_getter((Variant::Type)p_type); +} + +godot_ptr_indexed_setter GDAPI godot_variant_get_ptr_indexed_setter(godot_variant_type p_type) { + return (godot_ptr_indexed_setter)Variant::get_member_ptr_indexed_setter((Variant::Type)p_type); +} + +godot_ptr_indexed_getter GDAPI godot_variant_get_ptr_indexed_getter(godot_variant_type p_type) { + return (godot_ptr_indexed_getter)Variant::get_member_ptr_indexed_getter((Variant::Type)p_type); +} + +uint64_t GDAPI godot_variant_get_indexed_size(const godot_variant *p_self) { + const Variant *self = (const Variant *)p_self; + return self->get_indexed_size(); +} + +/// Keying. +bool GDAPI godot_variant_is_keyed(godot_variant_type p_type) { + return Variant::is_keyed((Variant::Type)p_type); +} + +godot_validated_keyed_setter GDAPI godot_variant_get_validated_keyed_setter(godot_variant_type p_type) { + return (godot_validated_keyed_setter)Variant::get_member_validated_keyed_setter((Variant::Type)p_type); +} + +godot_validated_keyed_getter GDAPI godot_variant_get_validated_keyed_getter(godot_variant_type p_type) { + return (godot_validated_keyed_getter)Variant::get_member_validated_keyed_getter((Variant::Type)p_type); +} + +godot_validated_keyed_checker GDAPI godot_variant_get_validated_keyed_checker(godot_variant_type p_type) { + return (godot_validated_keyed_checker)Variant::get_member_validated_keyed_checker((Variant::Type)p_type); +} + +godot_ptr_keyed_setter GDAPI godot_variant_get_ptr_keyed_setter(godot_variant_type p_type) { + return (godot_ptr_keyed_setter)Variant::get_member_ptr_keyed_setter((Variant::Type)p_type); +} + +godot_ptr_keyed_getter GDAPI godot_variant_get_ptr_keyed_getter(godot_variant_type p_type) { + return (godot_ptr_keyed_getter)Variant::get_member_ptr_keyed_getter((Variant::Type)p_type); +} + +godot_ptr_keyed_checker GDAPI godot_variant_get_ptr_keyed_checker(godot_variant_type p_type) { + return (godot_ptr_keyed_checker)Variant::get_member_ptr_keyed_checker((Variant::Type)p_type); +} + +/// Constants. +int GDAPI godot_variant_get_constants_count(godot_variant_type p_type) { + return Variant::get_constants_count_for_type((Variant::Type)p_type); +} + +void GDAPI godot_variant_get_constants_list(godot_variant_type p_type, godot_string_name *r_list) { + List<StringName> constants; + int i = 0; + Variant::get_constants_for_type((Variant::Type)p_type, &constants); + for (const List<StringName>::Element *E = constants.front(); E; E = E->next()) { + memnew_placement_custom(&r_list[i++], StringName, StringName(E->get())); + } +} + +bool GDAPI godot_variant_has_constant(godot_variant_type p_type, const godot_string_name *p_constant) { + return Variant::has_constant((Variant::Type)p_type, *((const StringName *)p_constant)); +} + +bool GDAPI godot_variant_has_constant_with_cstring(godot_variant_type p_type, const char *p_constant) { + return Variant::has_constant((Variant::Type)p_type, StringName(p_constant)); +} + +godot_variant GDAPI godot_variant_get_constant_value(godot_variant_type p_type, const godot_string_name *p_constant) { + Variant constant = Variant::get_constant_value((Variant::Type)p_type, *((const StringName *)p_constant)); + godot_variant ret; + memnew_placement_custom(&ret, Variant, Variant(constant)); + return ret; +} + +godot_variant GDAPI godot_variant_get_constant_value_with_cstring(godot_variant_type p_type, const char *p_constant) { + Variant constant = Variant::get_constant_value((Variant::Type)p_type, StringName(p_constant)); + godot_variant ret; + memnew_placement_custom(&ret, Variant, Variant(constant)); + return ret; +} + +/// Utilities. +bool GDAPI godot_variant_has_utility_function(const godot_string_name *p_function) { + return Variant::has_utility_function(*((const StringName *)p_function)); +} + +bool GDAPI godot_variant_has_utility_function_with_cstring(const char *p_function) { + return Variant::has_utility_function(StringName(p_function)); +} + +void GDAPI godot_variant_call_utility_function(const godot_string_name *p_function, godot_variant *r_ret, const godot_variant **p_args, int p_argument_count, godot_variant_call_error *r_error) { + const StringName *function = (const StringName *)p_function; Variant *ret = (Variant *)r_ret; - Variant::evaluate(op, *a, *b, *ret, *r_valid); + const Variant **args = (const Variant **)p_args; + Callable::CallError error; + + Variant::call_utility_function(*function, ret, args, p_argument_count, error); + + if (r_error) { + r_error->error = (godot_variant_call_error_error)error.error; + r_error->argument = error.argument; + r_error->expected = (godot_variant_type)error.expected; + } +} + +void GDAPI godot_variant_call_utility_function_with_cstring(const char *p_function, godot_variant *r_ret, const godot_variant **p_args, int p_argument_count, godot_variant_call_error *r_error) { + Variant *ret = (Variant *)r_ret; + const Variant **args = (const Variant **)p_args; + Callable::CallError error; + + Variant::call_utility_function(StringName(p_function), ret, args, p_argument_count, error); + + if (r_error) { + r_error->error = (godot_variant_call_error_error)error.error; + r_error->argument = error.argument; + r_error->expected = (godot_variant_type)error.expected; + } +} + +godot_ptr_utility_function GDAPI godot_variant_get_ptr_utility_function(const godot_string_name *p_function) { + return (godot_ptr_utility_function)Variant::get_ptr_utility_function(*((const StringName *)p_function)); +} + +godot_ptr_utility_function GDAPI godot_variant_get_ptr_utility_function_with_cstring(const char *p_function) { + return (godot_ptr_utility_function)Variant::get_ptr_utility_function(StringName(p_function)); +} + +godot_validated_utility_function GDAPI godot_variant_get_validated_utility_function(const godot_string_name *p_function) { + return (godot_validated_utility_function)Variant::get_validated_utility_function(*((const StringName *)p_function)); +} + +godot_validated_utility_function GDAPI godot_variant_get_validated_utility_function_with_cstring(const char *p_function) { + return (godot_validated_utility_function)Variant::get_validated_utility_function(StringName(p_function)); +} + +godot_variant_utility_function_type GDAPI godot_variant_get_utility_function_type(const godot_string_name *p_function) { + return (godot_variant_utility_function_type)Variant::get_utility_function_type(*((const StringName *)p_function)); +} + +godot_variant_utility_function_type GDAPI godot_variant_get_utility_function_type_with_cstring(const char *p_function) { + return (godot_variant_utility_function_type)Variant::get_utility_function_type(StringName(p_function)); +} + +int GDAPI godot_variant_get_utility_function_argument_count(const godot_string_name *p_function) { + return Variant::get_utility_function_argument_count(*((const StringName *)p_function)); +} + +int GDAPI godot_variant_get_utility_function_argument_count_with_cstring(const char *p_function) { + return Variant::get_utility_function_argument_count(StringName(p_function)); +} + +godot_variant_type GDAPI godot_variant_get_utility_function_argument_type(const godot_string_name *p_function, int p_argument) { + return (godot_variant_type)Variant::get_utility_function_argument_type(*((const StringName *)p_function), p_argument); +} + +godot_variant_type GDAPI godot_variant_get_utility_function_argument_type_with_cstring(const char *p_function, int p_argument) { + return (godot_variant_type)Variant::get_utility_function_argument_type(StringName(p_function), p_argument); +} + +godot_string GDAPI godot_variant_get_utility_function_argument_name(const godot_string_name *p_function, int p_argument) { + String argument_name = Variant::get_utility_function_argument_name(*((const StringName *)p_function), p_argument); + godot_string ret; + memnew_placement_custom(&ret, String, String(argument_name)); + return ret; +} + +godot_string GDAPI godot_variant_get_utility_function_argument_name_with_cstring(const char *p_function, int p_argument) { + String argument_name = Variant::get_utility_function_argument_name(StringName(p_function), p_argument); + godot_string ret; + memnew_placement_custom(&ret, String, String(argument_name)); + return ret; +} + +bool GDAPI godot_variant_has_utility_function_return_value(const godot_string_name *p_function) { + return Variant::has_utility_function_return_value(*((const StringName *)p_function)); +} + +bool GDAPI godot_variant_has_utility_function_return_value_with_cstring(const char *p_function) { + return Variant::has_utility_function_return_value(StringName(p_function)); +} + +godot_variant_type GDAPI godot_variant_get_utility_function_return_type(const godot_string_name *p_function) { + return (godot_variant_type)Variant::get_utility_function_return_type(*((const StringName *)p_function)); +} + +godot_variant_type GDAPI godot_variant_get_utility_function_return_type_with_cstring(const char *p_function) { + return (godot_variant_type)Variant::get_utility_function_return_type(StringName(p_function)); +} + +bool GDAPI godot_variant_is_utility_function_vararg(const godot_string_name *p_function) { + return Variant::is_utility_function_vararg(*((const StringName *)p_function)); +} + +bool GDAPI godot_variant_is_utility_function_vararg_with_cstring(const char *p_function) { + return Variant::is_utility_function_vararg(StringName(p_function)); +} + +int GDAPI godot_variant_get_utility_function_count() { + return Variant::get_utility_function_count(); +} + +void GDAPI godot_variant_get_utility_function_list(godot_string_name *r_functions) { + List<StringName> functions; + godot_string_name *func = r_functions; + Variant::get_utility_function_list(&functions); + + for (const List<StringName>::Element *E = functions.front(); E; E = E->next()) { + memnew_placement_custom(func++, StringName, StringName(E->get())); + } +} + +// Introspection. + +godot_variant_type GDAPI godot_variant_get_type(const godot_variant *p_self) { + const Variant *self = (const Variant *)p_self; + return (godot_variant_type)self->get_type(); +} + +bool GDAPI godot_variant_has_method(const godot_variant *p_self, const godot_string_name *p_method) { + const Variant *self = (const Variant *)p_self; + const StringName *method = (const StringName *)p_method; + return self->has_method(*method); +} + +bool GDAPI godot_variant_has_member(godot_variant_type p_type, const godot_string_name *p_member) { + return Variant::has_member((Variant::Type)p_type, *((const StringName *)p_member)); +} + +bool GDAPI godot_variant_has_key(const godot_variant *p_self, const godot_variant *p_key, bool *r_valid) { + const Variant *self = (const Variant *)p_self; + const Variant *key = (const Variant *)p_key; + return self->has_key(*key, *r_valid); +} + +godot_string GDAPI godot_variant_get_type_name(godot_variant_type p_type) { + String name = Variant::get_type_name((Variant::Type)p_type); + godot_string ret; + memnew_placement_custom(&ret, String, String(name)); + return ret; +} + +bool GDAPI godot_variant_can_convert(godot_variant_type p_from, godot_variant_type p_to) { + return Variant::can_convert((Variant::Type)p_from, (Variant::Type)p_to); +} + +bool GDAPI godot_variant_can_convert_strict(godot_variant_type p_from, godot_variant_type p_to) { + return Variant::can_convert_strict((Variant::Type)p_from, (Variant::Type)p_to); } #ifdef __cplusplus diff --git a/modules/gdnative/gdnative/vector2.cpp b/modules/gdnative/gdnative/vector2.cpp index 1ba846d315..ebb1996649 100644 --- a/modules/gdnative/gdnative/vector2.cpp +++ b/modules/gdnative/gdnative/vector2.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -31,430 +31,40 @@ #include "gdnative/vector2.h" #include "core/math/vector2.h" -#include "core/variant/variant.h" - -#ifdef __cplusplus -extern "C" { -#endif static_assert(sizeof(godot_vector2) == sizeof(Vector2), "Vector2 size mismatch"); static_assert(sizeof(godot_vector2i) == sizeof(Vector2i), "Vector2i size mismatch"); -// Vector2 - -void GDAPI godot_vector2_new(godot_vector2 *r_dest, const godot_real p_x, const godot_real p_y) { - Vector2 *dest = (Vector2 *)r_dest; - *dest = Vector2(p_x, p_y); -} - -godot_string GDAPI godot_vector2_as_string(const godot_vector2 *p_self) { - godot_string ret; - const Vector2 *self = (const Vector2 *)p_self; - memnew_placement(&ret, String(*self)); - return ret; -} - -godot_vector2i GDAPI godot_vector2_as_vector2i(const godot_vector2 *p_self) { - godot_vector2i dest; - const Vector2 *self = (const Vector2 *)p_self; - *((Vector2i *)&dest) = Vector2i(*self); - return dest; -} - -godot_vector2 GDAPI godot_vector2_normalized(const godot_vector2 *p_self) { - godot_vector2 dest; - const Vector2 *self = (const Vector2 *)p_self; - *((Vector2 *)&dest) = self->normalized(); - return dest; -} - -godot_real GDAPI godot_vector2_length(const godot_vector2 *p_self) { - const Vector2 *self = (const Vector2 *)p_self; - return self->length(); -} - -godot_real GDAPI godot_vector2_angle(const godot_vector2 *p_self) { - const Vector2 *self = (const Vector2 *)p_self; - return self->angle(); -} - -godot_real GDAPI godot_vector2_length_squared(const godot_vector2 *p_self) { - const Vector2 *self = (const Vector2 *)p_self; - return self->length_squared(); -} - -godot_bool GDAPI godot_vector2_is_normalized(const godot_vector2 *p_self) { - const Vector2 *self = (const Vector2 *)p_self; - return self->is_normalized(); -} - -godot_vector2 GDAPI godot_vector2_direction_to(const godot_vector2 *p_self, const godot_vector2 *p_to) { - godot_vector2 dest; - const Vector2 *self = (const Vector2 *)p_self; - const Vector2 *to = (const Vector2 *)p_to; - *((Vector2 *)&dest) = self->direction_to(*to); - return dest; -} - -godot_real GDAPI godot_vector2_distance_to(const godot_vector2 *p_self, const godot_vector2 *p_to) { - const Vector2 *self = (const Vector2 *)p_self; - const Vector2 *to = (const Vector2 *)p_to; - return self->distance_to(*to); -} - -godot_real GDAPI godot_vector2_distance_squared_to(const godot_vector2 *p_self, const godot_vector2 *p_to) { - const Vector2 *self = (const Vector2 *)p_self; - const Vector2 *to = (const Vector2 *)p_to; - return self->distance_squared_to(*to); -} - -godot_real GDAPI godot_vector2_angle_to(const godot_vector2 *p_self, const godot_vector2 *p_to) { - const Vector2 *self = (const Vector2 *)p_self; - const Vector2 *to = (const Vector2 *)p_to; - return self->angle_to(*to); -} - -godot_real GDAPI godot_vector2_angle_to_point(const godot_vector2 *p_self, const godot_vector2 *p_to) { - const Vector2 *self = (const Vector2 *)p_self; - const Vector2 *to = (const Vector2 *)p_to; - return self->angle_to_point(*to); -} - -godot_vector2 GDAPI godot_vector2_lerp(const godot_vector2 *p_self, const godot_vector2 *p_b, const godot_real p_t) { - godot_vector2 dest; - const Vector2 *self = (const Vector2 *)p_self; - const Vector2 *b = (const Vector2 *)p_b; - *((Vector2 *)&dest) = self->lerp(*b, p_t); - return dest; -} - -godot_vector2 GDAPI godot_vector2_cubic_interpolate(const godot_vector2 *p_self, const godot_vector2 *p_b, const godot_vector2 *p_pre_a, const godot_vector2 *p_post_b, const godot_real p_t) { - godot_vector2 dest; - const Vector2 *self = (const Vector2 *)p_self; - const Vector2 *b = (const Vector2 *)p_b; - const Vector2 *pre_a = (const Vector2 *)p_pre_a; - const Vector2 *post_b = (const Vector2 *)p_post_b; - *((Vector2 *)&dest) = self->cubic_interpolate(*b, *pre_a, *post_b, p_t); - return dest; -} - -godot_vector2 GDAPI godot_vector2_move_toward(const godot_vector2 *p_self, const godot_vector2 *p_to, const godot_real p_delta) { - godot_vector2 dest; - const Vector2 *self = (const Vector2 *)p_self; - const Vector2 *to = (const Vector2 *)p_to; - *((Vector2 *)&dest) = self->move_toward(*to, p_delta); - return dest; -} - -godot_vector2 GDAPI godot_vector2_rotated(const godot_vector2 *p_self, const godot_real p_phi) { - godot_vector2 dest; - const Vector2 *self = (const Vector2 *)p_self; - - *((Vector2 *)&dest) = self->rotated(p_phi); - return dest; -} - -godot_vector2 GDAPI godot_vector2_tangent(const godot_vector2 *p_self) { - godot_vector2 dest; - const Vector2 *self = (const Vector2 *)p_self; - *((Vector2 *)&dest) = self->tangent(); - return dest; -} - -godot_vector2 GDAPI godot_vector2_floor(const godot_vector2 *p_self) { - godot_vector2 dest; - const Vector2 *self = (const Vector2 *)p_self; - *((Vector2 *)&dest) = self->floor(); - return dest; -} - -godot_vector2 GDAPI godot_vector2_sign(const godot_vector2 *p_self) { - godot_vector2 dest; - const Vector2 *self = (const Vector2 *)p_self; - *((Vector2 *)&dest) = self->sign(); - return dest; -} - -godot_vector2 GDAPI godot_vector2_snapped(const godot_vector2 *p_self, const godot_vector2 *p_by) { - godot_vector2 dest; - const Vector2 *self = (const Vector2 *)p_self; - const Vector2 *by = (const Vector2 *)p_by; - *((Vector2 *)&dest) = self->snapped(*by); - return dest; -} - -godot_real GDAPI godot_vector2_aspect(const godot_vector2 *p_self) { - const Vector2 *self = (const Vector2 *)p_self; - return self->aspect(); -} - -godot_real GDAPI godot_vector2_dot(const godot_vector2 *p_self, const godot_vector2 *p_with) { - const Vector2 *self = (const Vector2 *)p_self; - const Vector2 *with = (const Vector2 *)p_with; - return self->dot(*with); -} - -godot_vector2 GDAPI godot_vector2_slide(const godot_vector2 *p_self, const godot_vector2 *p_n) { - godot_vector2 dest; - const Vector2 *self = (const Vector2 *)p_self; - const Vector2 *n = (const Vector2 *)p_n; - *((Vector2 *)&dest) = self->slide(*n); - return dest; -} - -godot_vector2 GDAPI godot_vector2_bounce(const godot_vector2 *p_self, const godot_vector2 *p_n) { - godot_vector2 dest; - const Vector2 *self = (const Vector2 *)p_self; - const Vector2 *n = (const Vector2 *)p_n; - *((Vector2 *)&dest) = self->bounce(*n); - return dest; -} - -godot_vector2 GDAPI godot_vector2_reflect(const godot_vector2 *p_self, const godot_vector2 *p_n) { - godot_vector2 dest; - const Vector2 *self = (const Vector2 *)p_self; - const Vector2 *n = (const Vector2 *)p_n; - *((Vector2 *)&dest) = self->reflect(*n); - return dest; -} - -godot_vector2 GDAPI godot_vector2_abs(const godot_vector2 *p_self) { - godot_vector2 dest; - const Vector2 *self = (const Vector2 *)p_self; - *((Vector2 *)&dest) = self->abs(); - return dest; -} - -godot_vector2 GDAPI godot_vector2_clamped(const godot_vector2 *p_self, const godot_real p_length) { - godot_vector2 dest; - const Vector2 *self = (const Vector2 *)p_self; - - *((Vector2 *)&dest) = self->clamped(p_length); - return dest; -} - -godot_vector2 GDAPI godot_vector2_operator_add(const godot_vector2 *p_self, const godot_vector2 *p_b) { - godot_vector2 raw_dest; - Vector2 *dest = (Vector2 *)&raw_dest; - const Vector2 *self = (const Vector2 *)p_self; - const Vector2 *b = (const Vector2 *)p_b; - *dest = *self + *b; - return raw_dest; -} - -godot_vector2 GDAPI godot_vector2_operator_subtract(const godot_vector2 *p_self, const godot_vector2 *p_b) { - godot_vector2 raw_dest; - Vector2 *dest = (Vector2 *)&raw_dest; - const Vector2 *self = (const Vector2 *)p_self; - const Vector2 *b = (const Vector2 *)p_b; - *dest = *self - *b; - return raw_dest; -} - -godot_vector2 GDAPI godot_vector2_operator_multiply_vector(const godot_vector2 *p_self, const godot_vector2 *p_b) { - godot_vector2 raw_dest; - Vector2 *dest = (Vector2 *)&raw_dest; - const Vector2 *self = (const Vector2 *)p_self; - const Vector2 *b = (const Vector2 *)p_b; - *dest = *self * *b; - return raw_dest; -} - -godot_vector2 GDAPI godot_vector2_operator_multiply_scalar(const godot_vector2 *p_self, const godot_real p_b) { - godot_vector2 raw_dest; - Vector2 *dest = (Vector2 *)&raw_dest; - const Vector2 *self = (const Vector2 *)p_self; - *dest = *self * p_b; - return raw_dest; -} - -godot_vector2 GDAPI godot_vector2_operator_divide_vector(const godot_vector2 *p_self, const godot_vector2 *p_b) { - godot_vector2 raw_dest; - Vector2 *dest = (Vector2 *)&raw_dest; - const Vector2 *self = (const Vector2 *)p_self; - const Vector2 *b = (const Vector2 *)p_b; - *dest = *self / *b; - return raw_dest; -} - -godot_vector2 GDAPI godot_vector2_operator_divide_scalar(const godot_vector2 *p_self, const godot_real p_b) { - godot_vector2 raw_dest; - Vector2 *dest = (Vector2 *)&raw_dest; - const Vector2 *self = (const Vector2 *)p_self; - *dest = *self / p_b; - return raw_dest; -} - -godot_bool GDAPI godot_vector2_operator_equal(const godot_vector2 *p_self, const godot_vector2 *p_b) { - const Vector2 *self = (const Vector2 *)p_self; - const Vector2 *b = (const Vector2 *)p_b; - return *self == *b; -} - -godot_bool GDAPI godot_vector2_operator_less(const godot_vector2 *p_self, const godot_vector2 *p_b) { - const Vector2 *self = (const Vector2 *)p_self; - const Vector2 *b = (const Vector2 *)p_b; - return *self < *b; -} +#ifdef __cplusplus +extern "C" { +#endif -godot_vector2 GDAPI godot_vector2_operator_neg(const godot_vector2 *p_self) { - godot_vector2 raw_dest; - Vector2 *dest = (Vector2 *)&raw_dest; - const Vector2 *self = (const Vector2 *)p_self; - *dest = -(*self); - return raw_dest; +void GDAPI godot_vector2_new(godot_vector2 *p_self) { + memnew_placement(p_self, Vector2); } -void GDAPI godot_vector2_set_x(godot_vector2 *p_self, const godot_real p_x) { - Vector2 *self = (Vector2 *)p_self; - self->x = p_x; +void GDAPI godot_vector2i_new(godot_vector2i *p_self) { + memnew_placement(p_self, Vector2i); } -void GDAPI godot_vector2_set_y(godot_vector2 *p_self, const godot_real p_y) { +godot_real_t GDAPI *godot_vector2_operator_index(godot_vector2 *p_self, godot_int p_index) { Vector2 *self = (Vector2 *)p_self; - self->y = p_y; + return (godot_real_t *)&self->operator[](p_index); } -godot_real GDAPI godot_vector2_get_x(const godot_vector2 *p_self) { +const godot_real_t GDAPI *godot_vector2_operator_index_const(const godot_vector2 *p_self, godot_int p_index) { const Vector2 *self = (const Vector2 *)p_self; - return self->x; -} - -godot_real GDAPI godot_vector2_get_y(const godot_vector2 *p_self) { - const Vector2 *self = (const Vector2 *)p_self; - return self->y; -} - -// Vector2i - -void GDAPI godot_vector2i_new(godot_vector2i *r_dest, const godot_int p_x, const godot_int p_y) { - Vector2i *dest = (Vector2i *)r_dest; - *dest = Vector2i(p_x, p_y); -} - -godot_string GDAPI godot_vector2i_as_string(const godot_vector2i *p_self) { - godot_string ret; - const Vector2i *self = (const Vector2i *)p_self; - memnew_placement(&ret, String(*self)); - return ret; -} - -godot_vector2 GDAPI godot_vector2i_as_vector2(const godot_vector2i *p_self) { - godot_vector2 dest; - const Vector2i *self = (const Vector2i *)p_self; - *((Vector2 *)&dest) = Vector2(*self); - return dest; -} - -godot_real GDAPI godot_vector2i_aspect(const godot_vector2i *p_self) { - const Vector2i *self = (const Vector2i *)p_self; - return self->aspect(); -} - -godot_vector2i GDAPI godot_vector2i_abs(const godot_vector2i *p_self) { - godot_vector2i dest; - const Vector2i *self = (const Vector2i *)p_self; - *((Vector2i *)&dest) = self->abs(); - return dest; -} - -godot_vector2i GDAPI godot_vector2i_sign(const godot_vector2i *p_self) { - godot_vector2i dest; - const Vector2i *self = (const Vector2i *)p_self; - *((Vector2i *)&dest) = self->sign(); - return dest; -} - -godot_vector2i GDAPI godot_vector2i_operator_add(const godot_vector2i *p_self, const godot_vector2i *p_b) { - godot_vector2i raw_dest; - Vector2i *dest = (Vector2i *)&raw_dest; - const Vector2i *self = (const Vector2i *)p_self; - const Vector2i *b = (const Vector2i *)p_b; - *dest = *self + *b; - return raw_dest; -} - -godot_vector2i GDAPI godot_vector2i_operator_subtract(const godot_vector2i *p_self, const godot_vector2i *p_b) { - godot_vector2i raw_dest; - Vector2i *dest = (Vector2i *)&raw_dest; - const Vector2i *self = (const Vector2i *)p_self; - const Vector2i *b = (const Vector2i *)p_b; - *dest = *self - *b; - return raw_dest; -} - -godot_vector2i GDAPI godot_vector2i_operator_multiply_vector(const godot_vector2i *p_self, const godot_vector2i *p_b) { - godot_vector2i raw_dest; - Vector2i *dest = (Vector2i *)&raw_dest; - const Vector2i *self = (const Vector2i *)p_self; - const Vector2i *b = (const Vector2i *)p_b; - *dest = *self * *b; - return raw_dest; -} - -godot_vector2i GDAPI godot_vector2i_operator_multiply_scalar(const godot_vector2i *p_self, const godot_int p_b) { - godot_vector2i raw_dest; - Vector2i *dest = (Vector2i *)&raw_dest; - const Vector2i *self = (const Vector2i *)p_self; - *dest = *self * p_b; - return raw_dest; + return (const godot_real_t *)&self->operator[](p_index); } -godot_vector2i GDAPI godot_vector2i_operator_divide_vector(const godot_vector2i *p_self, const godot_vector2i *p_b) { - godot_vector2i raw_dest; - Vector2i *dest = (Vector2i *)&raw_dest; - const Vector2i *self = (const Vector2i *)p_self; - const Vector2i *b = (const Vector2i *)p_b; - *dest = *self / *b; - return raw_dest; -} - -godot_vector2i GDAPI godot_vector2i_operator_divide_scalar(const godot_vector2i *p_self, const godot_int p_b) { - godot_vector2i raw_dest; - Vector2i *dest = (Vector2i *)&raw_dest; - const Vector2i *self = (const Vector2i *)p_self; - *dest = *self / p_b; - return raw_dest; -} - -godot_bool GDAPI godot_vector2i_operator_equal(const godot_vector2i *p_self, const godot_vector2i *p_b) { - const Vector2i *self = (const Vector2i *)p_self; - const Vector2i *b = (const Vector2i *)p_b; - return *self == *b; -} - -godot_bool GDAPI godot_vector2i_operator_less(const godot_vector2i *p_self, const godot_vector2i *p_b) { - const Vector2i *self = (const Vector2i *)p_self; - const Vector2i *b = (const Vector2i *)p_b; - return *self < *b; -} - -godot_vector2i GDAPI godot_vector2i_operator_neg(const godot_vector2i *p_self) { - godot_vector2i raw_dest; - Vector2i *dest = (Vector2i *)&raw_dest; - const Vector2i *self = (const Vector2i *)p_self; - *dest = -(*self); - return raw_dest; -} - -void GDAPI godot_vector2i_set_x(godot_vector2i *p_self, const godot_int p_x) { - Vector2i *self = (Vector2i *)p_self; - self->x = p_x; -} - -void GDAPI godot_vector2i_set_y(godot_vector2i *p_self, const godot_int p_y) { +int32_t GDAPI *godot_vector2i_operator_index(godot_vector2i *p_self, godot_int p_index) { Vector2i *self = (Vector2i *)p_self; - self->y = p_y; -} - -godot_int GDAPI godot_vector2i_get_x(const godot_vector2i *p_self) { - const Vector2i *self = (const Vector2i *)p_self; - return self->x; + return (int32_t *)&self->operator[](p_index); } -godot_int GDAPI godot_vector2i_get_y(const godot_vector2i *p_self) { +const int32_t GDAPI *godot_vector2i_operator_index_const(const godot_vector2i *p_self, godot_int p_index) { const Vector2i *self = (const Vector2i *)p_self; - return self->y; + return (const int32_t *)&self->operator[](p_index); } #ifdef __cplusplus diff --git a/modules/gdnative/gdnative/vector3.cpp b/modules/gdnative/gdnative/vector3.cpp index 3284afdc31..0fe1b292a7 100644 --- a/modules/gdnative/gdnative/vector3.cpp +++ b/modules/gdnative/gdnative/vector3.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -30,433 +30,41 @@ #include "gdnative/vector3.h" -#include "core/templates/vector.h" -#include "core/variant/variant.h" - -#ifdef __cplusplus -extern "C" { -#endif +#include "core/math/vector3.h" static_assert(sizeof(godot_vector3) == sizeof(Vector3), "Vector3 size mismatch"); static_assert(sizeof(godot_vector3i) == sizeof(Vector3i), "Vector3i size mismatch"); -// Vector3 - -void GDAPI godot_vector3_new(godot_vector3 *r_dest, const godot_real p_x, const godot_real p_y, const godot_real p_z) { - Vector3 *dest = (Vector3 *)r_dest; - *dest = Vector3(p_x, p_y, p_z); -} - -godot_string GDAPI godot_vector3_as_string(const godot_vector3 *p_self) { - godot_string ret; - const Vector3 *self = (const Vector3 *)p_self; - memnew_placement(&ret, String(*self)); - return ret; -} - -godot_vector3i GDAPI godot_vector3_as_vector3i(const godot_vector3 *p_self) { - godot_vector3i dest; - const Vector3 *self = (const Vector3 *)p_self; - *((Vector3i *)&dest) = Vector3i(*self); - return dest; -} - -godot_int GDAPI godot_vector3_min_axis(const godot_vector3 *p_self) { - const Vector3 *self = (const Vector3 *)p_self; - return self->min_axis(); -} - -godot_int GDAPI godot_vector3_max_axis(const godot_vector3 *p_self) { - const Vector3 *self = (const Vector3 *)p_self; - return self->max_axis(); -} - -godot_real GDAPI godot_vector3_length(const godot_vector3 *p_self) { - const Vector3 *self = (const Vector3 *)p_self; - return self->length(); -} - -godot_real GDAPI godot_vector3_length_squared(const godot_vector3 *p_self) { - const Vector3 *self = (const Vector3 *)p_self; - return self->length_squared(); -} - -godot_bool GDAPI godot_vector3_is_normalized(const godot_vector3 *p_self) { - const Vector3 *self = (const Vector3 *)p_self; - return self->is_normalized(); -} - -godot_vector3 GDAPI godot_vector3_normalized(const godot_vector3 *p_self) { - godot_vector3 dest; - const Vector3 *self = (const Vector3 *)p_self; - *((Vector3 *)&dest) = self->normalized(); - return dest; -} - -godot_vector3 GDAPI godot_vector3_inverse(const godot_vector3 *p_self) { - godot_vector3 dest; - const Vector3 *self = (const Vector3 *)p_self; - *((Vector3 *)&dest) = self->inverse(); - return dest; -} - -godot_vector3 GDAPI godot_vector3_snapped(const godot_vector3 *p_self, const godot_vector3 *p_by) { - godot_vector3 dest; - const Vector3 *self = (const Vector3 *)p_self; - const Vector3 *snap_axis = (const Vector3 *)p_by; - - *((Vector3 *)&dest) = self->snapped(*snap_axis); - return dest; -} - -godot_vector3 GDAPI godot_vector3_rotated(const godot_vector3 *p_self, const godot_vector3 *p_axis, const godot_real p_phi) { - godot_vector3 dest; - const Vector3 *self = (const Vector3 *)p_self; - const Vector3 *axis = (const Vector3 *)p_axis; - *((Vector3 *)&dest) = self->rotated(*axis, p_phi); - return dest; -} - -godot_vector3 GDAPI godot_vector3_lerp(const godot_vector3 *p_self, const godot_vector3 *p_b, const godot_real p_t) { - godot_vector3 dest; - const Vector3 *self = (const Vector3 *)p_self; - const Vector3 *b = (const Vector3 *)p_b; - *((Vector3 *)&dest) = self->lerp(*b, p_t); - return dest; -} - -godot_vector3 GDAPI godot_vector3_cubic_interpolate(const godot_vector3 *p_self, const godot_vector3 *p_b, const godot_vector3 *p_pre_a, const godot_vector3 *p_post_b, const godot_real p_t) { - godot_vector3 dest; - const Vector3 *self = (const Vector3 *)p_self; - const Vector3 *b = (const Vector3 *)p_b; - const Vector3 *pre_a = (const Vector3 *)p_pre_a; - const Vector3 *post_b = (const Vector3 *)p_post_b; - *((Vector3 *)&dest) = self->cubic_interpolate(*b, *pre_a, *post_b, p_t); - return dest; -} - -godot_vector3 GDAPI godot_vector3_move_toward(const godot_vector3 *p_self, const godot_vector3 *p_to, const godot_real p_delta) { - godot_vector3 dest; - const Vector3 *self = (const Vector3 *)p_self; - const Vector3 *to = (const Vector3 *)p_to; - *((Vector3 *)&dest) = self->move_toward(*to, p_delta); - return dest; -} - -godot_real GDAPI godot_vector3_dot(const godot_vector3 *p_self, const godot_vector3 *p_b) { - const Vector3 *self = (const Vector3 *)p_self; - const Vector3 *b = (const Vector3 *)p_b; - return self->dot(*b); -} - -godot_vector3 GDAPI godot_vector3_cross(const godot_vector3 *p_self, const godot_vector3 *p_b) { - godot_vector3 dest; - const Vector3 *self = (const Vector3 *)p_self; - const Vector3 *b = (const Vector3 *)p_b; - *((Vector3 *)&dest) = self->cross(*b); - return dest; -} - -godot_basis GDAPI godot_vector3_outer(const godot_vector3 *p_self, const godot_vector3 *p_b) { - godot_basis dest; - const Vector3 *self = (const Vector3 *)p_self; - const Vector3 *b = (const Vector3 *)p_b; - *((Basis *)&dest) = self->outer(*b); - return dest; -} - -godot_basis GDAPI godot_vector3_to_diagonal_matrix(const godot_vector3 *p_self) { - godot_basis dest; - const Vector3 *self = (const Vector3 *)p_self; - *((Basis *)&dest) = self->to_diagonal_matrix(); - return dest; -} - -godot_vector3 GDAPI godot_vector3_abs(const godot_vector3 *p_self) { - godot_vector3 dest; - const Vector3 *self = (const Vector3 *)p_self; - *((Vector3 *)&dest) = self->abs(); - return dest; -} - -godot_vector3 GDAPI godot_vector3_sign(const godot_vector3 *p_self) { - godot_vector3 dest; - const Vector3 *self = (const Vector3 *)p_self; - *((Vector3 *)&dest) = self->sign(); - return dest; -} - -godot_vector3 GDAPI godot_vector3_floor(const godot_vector3 *p_self) { - godot_vector3 dest; - const Vector3 *self = (const Vector3 *)p_self; - *((Vector3 *)&dest) = self->floor(); - return dest; -} - -godot_vector3 GDAPI godot_vector3_ceil(const godot_vector3 *p_self) { - godot_vector3 dest; - const Vector3 *self = (const Vector3 *)p_self; - *((Vector3 *)&dest) = self->ceil(); - return dest; -} - -godot_vector3 GDAPI godot_vector3_direction_to(const godot_vector3 *p_self, const godot_vector3 *p_to) { - godot_vector3 dest; - const Vector3 *self = (const Vector3 *)p_self; - const Vector3 *to = (const Vector3 *)p_to; - *((Vector3 *)&dest) = self->direction_to(*to); - return dest; -} - -godot_real GDAPI godot_vector3_distance_to(const godot_vector3 *p_self, const godot_vector3 *p_b) { - const Vector3 *self = (const Vector3 *)p_self; - const Vector3 *b = (const Vector3 *)p_b; - return self->distance_to(*b); -} - -godot_real GDAPI godot_vector3_distance_squared_to(const godot_vector3 *p_self, const godot_vector3 *p_b) { - const Vector3 *self = (const Vector3 *)p_self; - const Vector3 *b = (const Vector3 *)p_b; - return self->distance_squared_to(*b); -} - -godot_real GDAPI godot_vector3_angle_to(const godot_vector3 *p_self, const godot_vector3 *p_to) { - const Vector3 *self = (const Vector3 *)p_self; - const Vector3 *to = (const Vector3 *)p_to; - return self->angle_to(*to); -} - -godot_vector3 GDAPI godot_vector3_slide(const godot_vector3 *p_self, const godot_vector3 *p_n) { - godot_vector3 dest; - const Vector3 *self = (const Vector3 *)p_self; - const Vector3 *n = (const Vector3 *)p_n; - *((Vector3 *)&dest) = self->slide(*n); - return dest; -} - -godot_vector3 GDAPI godot_vector3_bounce(const godot_vector3 *p_self, const godot_vector3 *p_n) { - godot_vector3 dest; - const Vector3 *self = (const Vector3 *)p_self; - const Vector3 *n = (const Vector3 *)p_n; - *((Vector3 *)&dest) = self->bounce(*n); - return dest; -} - -godot_vector3 GDAPI godot_vector3_reflect(const godot_vector3 *p_self, const godot_vector3 *p_n) { - godot_vector3 dest; - const Vector3 *self = (const Vector3 *)p_self; - const Vector3 *n = (const Vector3 *)p_n; - *((Vector3 *)&dest) = self->reflect(*n); - return dest; -} - -godot_vector3 GDAPI godot_vector3_operator_add(const godot_vector3 *p_self, const godot_vector3 *p_b) { - godot_vector3 raw_dest; - Vector3 *dest = (Vector3 *)&raw_dest; - Vector3 *self = (Vector3 *)p_self; - const Vector3 *b = (const Vector3 *)p_b; - *dest = *self + *b; - return raw_dest; -} - -godot_vector3 GDAPI godot_vector3_operator_subtract(const godot_vector3 *p_self, const godot_vector3 *p_b) { - godot_vector3 raw_dest; - Vector3 *dest = (Vector3 *)&raw_dest; - Vector3 *self = (Vector3 *)p_self; - const Vector3 *b = (const Vector3 *)p_b; - *dest = *self - *b; - return raw_dest; -} - -godot_vector3 GDAPI godot_vector3_operator_multiply_vector(const godot_vector3 *p_self, const godot_vector3 *p_b) { - godot_vector3 raw_dest; - Vector3 *dest = (Vector3 *)&raw_dest; - Vector3 *self = (Vector3 *)p_self; - const Vector3 *b = (const Vector3 *)p_b; - *dest = *self * *b; - return raw_dest; -} - -godot_vector3 GDAPI godot_vector3_operator_multiply_scalar(const godot_vector3 *p_self, const godot_real p_b) { - godot_vector3 raw_dest; - Vector3 *dest = (Vector3 *)&raw_dest; - Vector3 *self = (Vector3 *)p_self; - *dest = *self * p_b; - return raw_dest; -} - -godot_vector3 GDAPI godot_vector3_operator_divide_vector(const godot_vector3 *p_self, const godot_vector3 *p_b) { - godot_vector3 raw_dest; - Vector3 *dest = (Vector3 *)&raw_dest; - Vector3 *self = (Vector3 *)p_self; - const Vector3 *b = (const Vector3 *)p_b; - *dest = *self / *b; - return raw_dest; -} - -godot_vector3 GDAPI godot_vector3_operator_divide_scalar(const godot_vector3 *p_self, const godot_real p_b) { - godot_vector3 raw_dest; - Vector3 *dest = (Vector3 *)&raw_dest; - Vector3 *self = (Vector3 *)p_self; - *dest = *self / p_b; - return raw_dest; -} - -godot_bool GDAPI godot_vector3_operator_equal(const godot_vector3 *p_self, const godot_vector3 *p_b) { - Vector3 *self = (Vector3 *)p_self; - const Vector3 *b = (const Vector3 *)p_b; - return *self == *b; -} +#ifdef __cplusplus +extern "C" { +#endif -godot_bool GDAPI godot_vector3_operator_less(const godot_vector3 *p_self, const godot_vector3 *p_b) { - Vector3 *self = (Vector3 *)p_self; - const Vector3 *b = (const Vector3 *)p_b; - return *self < *b; +void GDAPI godot_vector3_new(godot_vector3 *p_self) { + memnew_placement(p_self, Vector3); } -godot_vector3 GDAPI godot_vector3_operator_neg(const godot_vector3 *p_self) { - godot_vector3 raw_dest; - Vector3 *dest = (Vector3 *)&raw_dest; - const Vector3 *self = (const Vector3 *)p_self; - *dest = -(*self); - return raw_dest; +void GDAPI godot_vector3i_new(godot_vector3i *p_self) { + memnew_placement(p_self, Vector3i); } -void GDAPI godot_vector3_set_axis(godot_vector3 *p_self, const godot_vector3_axis p_axis, const godot_real p_val) { +godot_real_t GDAPI *godot_vector3_operator_index(godot_vector3 *p_self, godot_int p_index) { Vector3 *self = (Vector3 *)p_self; - self->set_axis(p_axis, p_val); + return (godot_real_t *)&self->operator[](p_index); } -godot_real GDAPI godot_vector3_get_axis(const godot_vector3 *p_self, const godot_vector3_axis p_axis) { +const godot_real_t GDAPI *godot_vector3_operator_index_const(const godot_vector3 *p_self, godot_int p_index) { const Vector3 *self = (const Vector3 *)p_self; - return self->get_axis(p_axis); -} - -// Vector3i - -void GDAPI godot_vector3i_new(godot_vector3i *r_dest, const godot_int p_x, const godot_int p_y, const godot_int p_z) { - Vector3i *dest = (Vector3i *)r_dest; - *dest = Vector3i(p_x, p_y, p_z); -} - -godot_string GDAPI godot_vector3i_as_string(const godot_vector3i *p_self) { - godot_string ret; - const Vector3i *self = (const Vector3i *)p_self; - memnew_placement(&ret, String(*self)); - return ret; -} - -godot_vector3 GDAPI godot_vector3i_as_vector3(const godot_vector3i *p_self) { - godot_vector3 dest; - const Vector3i *self = (const Vector3i *)p_self; - *((Vector3 *)&dest) = Vector3(*self); - return dest; -} - -godot_int GDAPI godot_vector3i_min_axis(const godot_vector3i *p_self) { - const Vector3i *self = (const Vector3i *)p_self; - return self->min_axis(); -} - -godot_int GDAPI godot_vector3i_max_axis(const godot_vector3i *p_self) { - const Vector3i *self = (const Vector3i *)p_self; - return self->max_axis(); -} - -godot_vector3i GDAPI godot_vector3i_abs(const godot_vector3i *p_self) { - godot_vector3i dest; - const Vector3i *self = (const Vector3i *)p_self; - *((Vector3i *)&dest) = self->abs(); - return dest; -} - -godot_vector3i GDAPI godot_vector3i_sign(const godot_vector3i *p_self) { - godot_vector3i dest; - const Vector3i *self = (const Vector3i *)p_self; - *((Vector3i *)&dest) = self->sign(); - return dest; -} - -godot_vector3i GDAPI godot_vector3i_operator_add(const godot_vector3i *p_self, const godot_vector3i *p_b) { - godot_vector3i raw_dest; - Vector3i *dest = (Vector3i *)&raw_dest; - Vector3i *self = (Vector3i *)p_self; - const Vector3i *b = (const Vector3i *)p_b; - *dest = *self + *b; - return raw_dest; -} - -godot_vector3i GDAPI godot_vector3i_operator_subtract(const godot_vector3i *p_self, const godot_vector3i *p_b) { - godot_vector3i raw_dest; - Vector3i *dest = (Vector3i *)&raw_dest; - Vector3i *self = (Vector3i *)p_self; - const Vector3i *b = (const Vector3i *)p_b; - *dest = *self - *b; - return raw_dest; -} - -godot_vector3i GDAPI godot_vector3i_operator_multiply_vector(const godot_vector3i *p_self, const godot_vector3i *p_b) { - godot_vector3i raw_dest; - Vector3i *dest = (Vector3i *)&raw_dest; - Vector3i *self = (Vector3i *)p_self; - const Vector3i *b = (const Vector3i *)p_b; - *dest = *self * *b; - return raw_dest; -} - -godot_vector3i GDAPI godot_vector3i_operator_multiply_scalar(const godot_vector3i *p_self, const godot_int p_b) { - godot_vector3i raw_dest; - Vector3i *dest = (Vector3i *)&raw_dest; - Vector3i *self = (Vector3i *)p_self; - *dest = *self * p_b; - return raw_dest; -} - -godot_vector3i GDAPI godot_vector3i_operator_divide_vector(const godot_vector3i *p_self, const godot_vector3i *p_b) { - godot_vector3i raw_dest; - Vector3i *dest = (Vector3i *)&raw_dest; - Vector3i *self = (Vector3i *)p_self; - const Vector3i *b = (const Vector3i *)p_b; - *dest = *self / *b; - return raw_dest; -} - -godot_vector3i GDAPI godot_vector3i_operator_divide_scalar(const godot_vector3i *p_self, const godot_int p_b) { - godot_vector3i raw_dest; - Vector3i *dest = (Vector3i *)&raw_dest; - Vector3i *self = (Vector3i *)p_self; - *dest = *self / p_b; - return raw_dest; -} - -godot_bool GDAPI godot_vector3i_operator_equal(const godot_vector3i *p_self, const godot_vector3i *p_b) { - Vector3i *self = (Vector3i *)p_self; - const Vector3i *b = (const Vector3i *)p_b; - return *self == *b; -} - -godot_bool GDAPI godot_vector3i_operator_less(const godot_vector3i *p_self, const godot_vector3i *p_b) { - Vector3i *self = (Vector3i *)p_self; - const Vector3i *b = (const Vector3i *)p_b; - return *self < *b; -} - -godot_vector3i GDAPI godot_vector3i_operator_neg(const godot_vector3i *p_self) { - godot_vector3i raw_dest; - Vector3i *dest = (Vector3i *)&raw_dest; - const Vector3i *self = (const Vector3i *)p_self; - *dest = -(*self); - return raw_dest; + return (const godot_real_t *)&self->operator[](p_index); } -void GDAPI godot_vector3i_set_axis(godot_vector3i *p_self, const godot_vector3_axis p_axis, const godot_int p_val) { +int32_t GDAPI *godot_vector3i_operator_index(godot_vector3i *p_self, godot_int p_index) { Vector3i *self = (Vector3i *)p_self; - self->set_axis(p_axis, p_val); + return (int32_t *)&self->operator[](p_index); } -godot_int GDAPI godot_vector3i_get_axis(const godot_vector3i *p_self, const godot_vector3_axis p_axis) { +const int32_t GDAPI *godot_vector3i_operator_index_const(const godot_vector3i *p_self, godot_int p_index) { const Vector3i *self = (const Vector3i *)p_self; - return self->get_axis(p_axis); + return (const int32_t *)&self->operator[](p_index); } #ifdef __cplusplus diff --git a/modules/gdnative/gdnative_api.json b/modules/gdnative/gdnative_api.json index b3fd033e6c..c163fbbc1b 100644 --- a/modules/gdnative/gdnative_api.json +++ b/modules/gdnative/gdnative_api.json @@ -1,8074 +1,5249 @@ { - "core": { - "type": "CORE", - "version": { - "major": 4, - "minor": 0 - }, - "next": null, - "api": [ - { - "name": "godot_aabb_new", - "return_type": "void", - "arguments": [ - ["godot_aabb *", "r_dest"], - ["const godot_vector3 *", "p_pos"], - ["const godot_vector3 *", "p_size"] - ] - }, - { - "name": "godot_aabb_get_position", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_aabb *", "p_self"] - ] - }, - { - "name": "godot_aabb_set_position", - "return_type": "void", - "arguments": [ - ["const godot_aabb *", "p_self"], - ["const godot_vector3 *", "p_v"] - ] - }, - { - "name": "godot_aabb_get_size", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_aabb *", "p_self"] - ] - }, - { - "name": "godot_aabb_set_size", - "return_type": "void", - "arguments": [ - ["const godot_aabb *", "p_self"], - ["const godot_vector3 *", "p_v"] - ] - }, - { - "name": "godot_aabb_as_string", - "return_type": "godot_string", - "arguments": [ - ["const godot_aabb *", "p_self"] - ] - }, - { - "name": "godot_aabb_abs", - "return_type": "godot_aabb", - "arguments": [ - ["const godot_aabb *", "p_self"] - ] - }, - { - "name": "godot_aabb_get_area", - "return_type": "godot_real", - "arguments": [ - ["const godot_aabb *", "p_self"] - ] - }, - { - "name": "godot_aabb_has_no_area", - "return_type": "godot_bool", - "arguments": [ - ["const godot_aabb *", "p_self"] - ] - }, - { - "name": "godot_aabb_has_no_surface", - "return_type": "godot_bool", - "arguments": [ - ["const godot_aabb *", "p_self"] - ] - }, - { - "name": "godot_aabb_intersects", - "return_type": "godot_bool", - "arguments": [ - ["const godot_aabb *", "p_self"], - ["const godot_aabb *", "p_with"] - ] - }, - { - "name": "godot_aabb_encloses", - "return_type": "godot_bool", - "arguments": [ - ["const godot_aabb *", "p_self"], - ["const godot_aabb *", "p_with"] - ] - }, - { - "name": "godot_aabb_merge", - "return_type": "godot_aabb", - "arguments": [ - ["const godot_aabb *", "p_self"], - ["const godot_aabb *", "p_with"] - ] - }, - { - "name": "godot_aabb_intersection", - "return_type": "godot_aabb", - "arguments": [ - ["const godot_aabb *", "p_self"], - ["const godot_aabb *", "p_with"] - ] - }, - { - "name": "godot_aabb_intersects_plane", - "return_type": "godot_bool", - "arguments": [ - ["const godot_aabb *", "p_self"], - ["const godot_plane *", "p_plane"] - ] - }, - { - "name": "godot_aabb_intersects_segment", - "return_type": "godot_bool", - "arguments": [ - ["const godot_aabb *", "p_self"], - ["const godot_vector3 *", "p_from"], - ["const godot_vector3 *", "p_to"] - ] - }, - { - "name": "godot_aabb_has_point", - "return_type": "godot_bool", - "arguments": [ - ["const godot_aabb *", "p_self"], - ["const godot_vector3 *", "p_point"] - ] - }, - { - "name": "godot_aabb_get_support", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_aabb *", "p_self"], - ["const godot_vector3 *", "p_dir"] - ] - }, - { - "name": "godot_aabb_get_longest_axis", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_aabb *", "p_self"] - ] - }, - { - "name": "godot_aabb_get_longest_axis_index", - "return_type": "godot_int", - "arguments": [ - ["const godot_aabb *", "p_self"] - ] - }, - { - "name": "godot_aabb_get_longest_axis_size", - "return_type": "godot_real", - "arguments": [ - ["const godot_aabb *", "p_self"] - ] - }, - { - "name": "godot_aabb_get_shortest_axis", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_aabb *", "p_self"] - ] - }, - { - "name": "godot_aabb_get_shortest_axis_index", - "return_type": "godot_int", - "arguments": [ - ["const godot_aabb *", "p_self"] - ] - }, - { - "name": "godot_aabb_get_shortest_axis_size", - "return_type": "godot_real", - "arguments": [ - ["const godot_aabb *", "p_self"] - ] - }, - { - "name": "godot_aabb_expand", - "return_type": "godot_aabb", - "arguments": [ - ["const godot_aabb *", "p_self"], - ["const godot_vector3 *", "p_to_point"] - ] - }, - { - "name": "godot_aabb_grow", - "return_type": "godot_aabb", - "arguments": [ - ["const godot_aabb *", "p_self"], - ["const godot_real", "p_by"] - ] - }, - { - "name": "godot_aabb_get_endpoint", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_aabb *", "p_self"], - ["const godot_int", "p_idx"] - ] - }, - { - "name": "godot_aabb_operator_equal", - "return_type": "godot_bool", - "arguments": [ - ["const godot_aabb *", "p_self"], - ["const godot_aabb *", "p_b"] - ] - }, - { - "name": "godot_array_new", - "return_type": "void", - "arguments": [ - ["godot_array *", "r_dest"] - ] - }, - { - "name": "godot_array_new_copy", - "return_type": "void", - "arguments": [ - ["godot_array *", "r_dest"], - ["const godot_array *", "p_src"] - ] - }, - { - "name": "godot_array_new_packed_color_array", - "return_type": "void", - "arguments": [ - ["godot_array *", "r_dest"], - ["const godot_packed_color_array *", "p_pca"] - ] - }, - { - "name": "godot_array_new_packed_vector3_array", - "return_type": "void", - "arguments": [ - ["godot_array *", "r_dest"], - ["const godot_packed_vector3_array *", "p_pv3a"] - ] - }, - { - "name": "godot_array_new_packed_vector2_array", - "return_type": "void", - "arguments": [ - ["godot_array *", "r_dest"], - ["const godot_packed_vector2_array *", "p_pv2a"] - ] - }, - { - "name": "godot_array_new_packed_vector2i_array", - "return_type": "void", - "arguments": [ - ["godot_array *", "r_dest"], - ["const godot_packed_vector2i_array *", "p_pv2a"] - ] - }, - { - "name": "godot_array_new_packed_string_array", - "return_type": "void", - "arguments": [ - ["godot_array *", "r_dest"], - ["const godot_packed_string_array *", "p_psa"] - ] - }, - { - "name": "godot_array_new_packed_float32_array", - "return_type": "void", - "arguments": [ - ["godot_array *", "r_dest"], - ["const godot_packed_float32_array *", "p_pra"] - ] - }, - { - "name": "godot_array_new_packed_float64_array", - "return_type": "void", - "arguments": [ - ["godot_array *", "r_dest"], - ["const godot_packed_float64_array *", "p_pra"] - ] - }, - { - "name": "godot_array_new_packed_int32_array", - "return_type": "void", - "arguments": [ - ["godot_array *", "r_dest"], - ["const godot_packed_int32_array *", "p_pia"] - ] - }, - { - "name": "godot_array_new_packed_int64_array", - "return_type": "void", - "arguments": [ - ["godot_array *", "r_dest"], - ["const godot_packed_int64_array *", "p_pia"] - ] - }, - { - "name": "godot_array_new_packed_byte_array", - "return_type": "void", - "arguments": [ - ["godot_array *", "r_dest"], - ["const godot_packed_byte_array *", "p_pba"] - ] - }, - { - "name": "godot_array_set", - "return_type": "void", - "arguments": [ - ["godot_array *", "p_self"], - ["const godot_int", "p_idx"], - ["const godot_variant *", "p_value"] - ] - }, - { - "name": "godot_array_get", - "return_type": "godot_variant", - "arguments": [ - ["const godot_array *", "p_self"], - ["const godot_int", "p_idx"] - ] - }, - { - "name": "godot_array_operator_index", - "return_type": "godot_variant *", - "arguments": [ - ["godot_array *", "p_self"], - ["const godot_int", "p_idx"] - ] - }, - { - "name": "godot_array_operator_index_const", - "return_type": "const godot_variant *", - "arguments": [ - ["const godot_array *", "p_self"], - ["const godot_int", "p_idx"] - ] - }, - { - "name": "godot_array_append", - "return_type": "void", - "arguments": [ - ["godot_array *", "p_self"], - ["const godot_variant *", "p_value"] - ] - }, - { - "name": "godot_array_clear", - "return_type": "void", - "arguments": [ - ["godot_array *", "p_self"] - ] - }, - { - "name": "godot_array_count", - "return_type": "godot_int", - "arguments": [ - ["const godot_array *", "p_self"], - ["const godot_variant *", "p_value"] - ] - }, - { - "name": "godot_array_duplicate", - "return_type": "godot_array", - "arguments": [ - ["const godot_array *", "p_self"], - ["const godot_bool", "p_deep"] - ] - }, - { - "name": "godot_array_empty", - "return_type": "godot_bool", - "arguments": [ - ["const godot_array *", "p_self"] - ] - }, - { - "name": "godot_array_erase", - "return_type": "void", - "arguments": [ - ["godot_array *", "p_self"], - ["const godot_variant *", "p_value"] - ] - }, - { - "name": "godot_array_front", - "return_type": "godot_variant", - "arguments": [ - ["const godot_array *", "p_self"] - ] - }, - { - "name": "godot_array_back", - "return_type": "godot_variant", - "arguments": [ - ["const godot_array *", "p_self"] - ] - }, - { - "name": "godot_array_find", - "return_type": "godot_int", - "arguments": [ - ["const godot_array *", "p_self"], - ["const godot_variant *", "p_what"], - ["const godot_int", "p_from"] - ] - }, - { - "name": "godot_array_find_last", - "return_type": "godot_int", - "arguments": [ - ["const godot_array *", "p_self"], - ["const godot_variant *", "p_what"] - ] - }, - { - "name": "godot_array_has", - "return_type": "godot_bool", - "arguments": [ - ["const godot_array *", "p_self"], - ["const godot_variant *", "p_value"] - ] - }, - { - "name": "godot_array_hash", - "return_type": "godot_int", - "arguments": [ - ["const godot_array *", "p_self"] - ] - }, - { - "name": "godot_array_insert", - "return_type": "void", - "arguments": [ - ["godot_array *", "p_self"], - ["const godot_int", "p_pos"], - ["const godot_variant *", "p_value"] - ] - }, - { - "name": "godot_array_invert", - "return_type": "void", - "arguments": [ - ["godot_array *", "p_self"] - ] - }, - { - "name": "godot_array_max", - "return_type": "godot_variant", - "arguments": [ - ["const godot_array *", "p_self"] - ] - }, - { - "name": "godot_array_min", - "return_type": "godot_variant", - "arguments": [ - ["const godot_array *", "p_self"] - ] - }, - { - "name": "godot_array_pop_back", - "return_type": "godot_variant", - "arguments": [ - ["godot_array *", "p_self"] - ] - }, - { - "name": "godot_array_pop_front", - "return_type": "godot_variant", - "arguments": [ - ["godot_array *", "p_self"] - ] - }, - { - "name": "godot_array_push_back", - "return_type": "void", - "arguments": [ - ["godot_array *", "p_self"], - ["const godot_variant *", "p_value"] - ] - }, - { - "name": "godot_array_push_front", - "return_type": "void", - "arguments": [ - ["godot_array *", "p_self"], - ["const godot_variant *", "p_value"] - ] - }, - { - "name": "godot_array_remove", - "return_type": "void", - "arguments": [ - ["godot_array *", "p_self"], - ["const godot_int", "p_idx"] - ] - }, - { - "name": "godot_array_resize", - "return_type": "void", - "arguments": [ - ["godot_array *", "p_self"], - ["const godot_int", "p_size"] - ] - }, - { - "name": "godot_array_rfind", - "return_type": "godot_int", - "arguments": [ - ["const godot_array *", "p_self"], - ["const godot_variant *", "p_what"], - ["const godot_int", "p_from"] - ] - }, - { - "name": "godot_array_size", - "return_type": "godot_int", - "arguments": [ - ["const godot_array *", "p_self"] - ] - }, - { - "name": "godot_array_shuffle", - "return_type": "void", - "arguments": [ - ["godot_array *", "p_self"] - ] - }, - { - "name": "godot_array_slice", - "return_type": "godot_array", - "arguments": [ - ["const godot_array *", "p_self"], - ["const godot_int", "p_begin"], - ["const godot_int", "p_end"], - ["const godot_int", "p_step"], - ["const godot_bool", "p_deep"] - ] - }, - { - "name": "godot_array_sort", - "return_type": "void", - "arguments": [ - ["godot_array *", "p_self"] - ] - }, - { - "name": "godot_array_sort_custom", - "return_type": "void", - "arguments": [ - ["godot_array *", "p_self"], - ["godot_object *", "p_obj"], - ["const godot_string *", "p_func"] - ] - }, - { - "name": "godot_array_bsearch", - "return_type": "godot_int", - "arguments": [ - ["godot_array *", "p_self"], - ["const godot_variant *", "p_value"], - ["const godot_bool", "p_before"] - ] - }, - { - "name": "godot_array_bsearch_custom", - "return_type": "godot_int", - "arguments": [ - ["godot_array *", "p_self"], - ["const godot_variant *", "p_value"], - ["godot_object *", "p_obj"], - ["const godot_string *", "p_func"], - ["const godot_bool", "p_before"] - ] - }, - { - "name": "godot_array_destroy", - "return_type": "void", - "arguments": [ - ["godot_array *", "p_self"] - ] - }, - { - "name": "godot_basis_new_with_rows", - "return_type": "void", - "arguments": [ - ["godot_basis *", "r_dest"], - ["const godot_vector3 *", "p_x_axis"], - ["const godot_vector3 *", "p_y_axis"], - ["const godot_vector3 *", "p_z_axis"] - ] - }, - { - "name": "godot_basis_new_with_axis_and_angle", - "return_type": "void", - "arguments": [ - ["godot_basis *", "r_dest"], - ["const godot_vector3 *", "p_axis"], - ["const godot_real", "p_phi"] - ] - }, - { - "name": "godot_basis_new_with_euler", - "return_type": "void", - "arguments": [ - ["godot_basis *", "r_dest"], - ["const godot_vector3 *", "p_euler"] - ] - }, - { - "name": "godot_basis_as_string", - "return_type": "godot_string", - "arguments": [ - ["const godot_basis *", "p_self"] - ] - }, - { - "name": "godot_basis_inverse", - "return_type": "godot_basis", - "arguments": [ - ["const godot_basis *", "p_self"] - ] - }, - { - "name": "godot_basis_transposed", - "return_type": "godot_basis", - "arguments": [ - ["const godot_basis *", "p_self"] - ] - }, - { - "name": "godot_basis_orthonormalized", - "return_type": "godot_basis", - "arguments": [ - ["const godot_basis *", "p_self"] - ] - }, - { - "name": "godot_basis_determinant", - "return_type": "godot_real", - "arguments": [ - ["const godot_basis *", "p_self"] - ] - }, - { - "name": "godot_basis_rotated", - "return_type": "godot_basis", - "arguments": [ - ["const godot_basis *", "p_self"], - ["const godot_vector3 *", "p_axis"], - ["const godot_real", "p_phi"] - ] - }, - { - "name": "godot_basis_scaled", - "return_type": "godot_basis", - "arguments": [ - ["const godot_basis *", "p_self"], - ["const godot_vector3 *", "p_scale"] - ] - }, - { - "name": "godot_basis_get_scale", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_basis *", "p_self"] - ] - }, - { - "name": "godot_basis_get_euler", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_basis *", "p_self"] - ] - }, - { - "name": "godot_basis_tdotx", - "return_type": "godot_real", - "arguments": [ - ["const godot_basis *", "p_self"], - ["const godot_vector3 *", "p_with"] - ] - }, - { - "name": "godot_basis_tdoty", - "return_type": "godot_real", - "arguments": [ - ["const godot_basis *", "p_self"], - ["const godot_vector3 *", "p_with"] - ] - }, - { - "name": "godot_basis_tdotz", - "return_type": "godot_real", - "arguments": [ - ["const godot_basis *", "p_self"], - ["const godot_vector3 *", "p_with"] - ] - }, - { - "name": "godot_basis_xform", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_basis *", "p_self"], - ["const godot_vector3 *", "p_v"] - ] - }, - { - "name": "godot_basis_xform_inv", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_basis *", "p_self"], - ["const godot_vector3 *", "p_v"] - ] - }, - { - "name": "godot_basis_get_orthogonal_index", - "return_type": "godot_int", - "arguments": [ - ["const godot_basis *", "p_self"] - ] - }, - { - "name": "godot_basis_new", - "return_type": "void", - "arguments": [ - ["godot_basis *", "r_dest"] - ] - }, - { - "name": "godot_basis_new_with_euler_quat", - "return_type": "void", - "arguments": [ - ["godot_basis *", "r_dest"], - ["const godot_quat *", "p_euler"] - ] - }, - { - "name": "godot_basis_get_elements", - "return_type": "void", - "arguments": [ - ["const godot_basis *", "p_self"], - ["godot_vector3 *", "p_elements"] - ] - }, - { - "name": "godot_basis_get_axis", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_basis *", "p_self"], - ["const godot_int", "p_axis"] - ] - }, - { - "name": "godot_basis_set_axis", - "return_type": "void", - "arguments": [ - ["godot_basis *", "p_self"], - ["const godot_int", "p_axis"], - ["const godot_vector3 *", "p_value"] - ] - }, - { - "name": "godot_basis_get_row", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_basis *", "p_self"], - ["const godot_int", "p_row"] - ] - }, - { - "name": "godot_basis_set_row", - "return_type": "void", - "arguments": [ - ["godot_basis *", "p_self"], - ["const godot_int", "p_row"], - ["const godot_vector3 *", "p_value"] - ] - }, - { - "name": "godot_basis_operator_equal", - "return_type": "godot_bool", - "arguments": [ - ["const godot_basis *", "p_self"], - ["const godot_basis *", "p_b"] - ] - }, - { - "name": "godot_basis_operator_add", - "return_type": "godot_basis", - "arguments": [ - ["const godot_basis *", "p_self"], - ["const godot_basis *", "p_b"] - ] - }, - { - "name": "godot_basis_operator_subtract", - "return_type": "godot_basis", - "arguments": [ - ["const godot_basis *", "p_self"], - ["const godot_basis *", "p_b"] - ] - }, - { - "name": "godot_basis_operator_multiply_vector", - "return_type": "godot_basis", - "arguments": [ - ["const godot_basis *", "p_self"], - ["const godot_basis *", "p_b"] - ] - }, - { - "name": "godot_basis_operator_multiply_scalar", - "return_type": "godot_basis", - "arguments": [ - ["const godot_basis *", "p_self"], - ["const godot_real", "p_b"] - ] - }, - { - "name": "godot_basis_slerp", - "return_type": "godot_basis", - "arguments": [ - ["const godot_basis *", "p_self"], - ["const godot_basis *", "p_b"], - ["const godot_real", "p_t"] - ] - }, - { - "name": "godot_basis_get_quat", - "return_type": "godot_quat", - "arguments": [ - ["const godot_basis *", "p_self"] - ] - }, - { - "name": "godot_basis_set_quat", - "return_type": "void", - "arguments": [ - ["godot_basis *", "p_self"], - ["const godot_quat *", "p_quat"] - ] - }, - { - "name": "godot_basis_set_axis_angle_scale", - "return_type": "void", - "arguments": [ - ["godot_basis *", "p_self"], - ["const godot_vector3 *", "p_axis"], - ["godot_real", "p_phi"], - ["const godot_vector3 *", "p_scale"] - ] - }, - { - "name": "godot_basis_set_euler_scale", - "return_type": "void", - "arguments": [ - ["godot_basis *", "p_self"], - ["const godot_vector3 *", "p_euler"], - ["const godot_vector3 *", "p_scale"] - ] - }, - { - "name": "godot_basis_set_quat_scale", - "return_type": "void", - "arguments": [ - ["godot_basis *", "p_self"], - ["const godot_quat *", "p_quat"], - ["const godot_vector3 *", "p_scale"] - ] - }, - { - "name": "godot_callable_new_with_object", - "return_type": "void", - "arguments": [ - ["godot_callable *", "r_dest"], - ["const godot_object *", "p_object"], - ["const godot_string_name *", "p_method"] - ] - }, - { - "name": "godot_callable_new_with_object_id", - "return_type": "void", - "arguments": [ - ["godot_callable *", "r_dest"], - ["uint64_t", "p_objectid"], - ["const godot_string_name *", "p_method"] - ] - }, - { - "name": "godot_callable_new_copy", - "return_type": "void", - "arguments": [ - ["godot_callable *", "r_dest"], - ["const godot_callable *", "p_src"] - ] - }, - { - "name": "godot_callable_destroy", - "return_type": "void", - "arguments": [ - ["godot_callable *", "p_self"] - ] - }, - { - "name": "godot_callable_call", - "return_type": "godot_int", - "arguments": [ - ["const godot_callable *", "p_self"], - ["const godot_variant **", "p_arguments"], - ["godot_int", "p_argcount"], - ["godot_variant *", "r_return_value"] - ] - }, - { - "name": "godot_callable_call_deferred", - "return_type": "void", - "arguments": [ - ["const godot_callable *", "p_self"], - ["const godot_variant **", "p_arguments"], - ["godot_int", "p_argcount"] - ] - }, - { - "name": "godot_callable_is_null", - "return_type": "godot_bool", - "arguments": [ - ["const godot_callable *", "p_self"] - ] - }, - { - "name": "godot_callable_is_custom", - "return_type": "godot_bool", - "arguments": [ - ["const godot_callable *", "p_self"] - ] - }, - { - "name": "godot_callable_is_standard", - "return_type": "godot_bool", - "arguments": [ - ["const godot_callable *", "p_self"] - ] - }, - { - "name": "godot_callable_get_object", - "return_type": "godot_object *", - "arguments": [ - ["const godot_callable *", "p_self"] - ] - }, - { - "name": "godot_callable_get_object_id", - "return_type": "uint64_t", - "arguments": [ - ["const godot_callable *", "p_self"] - ] - }, - { - "name": "godot_callable_get_method", - "return_type": "godot_string_name", - "arguments": [ - ["const godot_callable *", "p_self"] - ] - }, - { - "name": "godot_callable_hash", - "return_type": "uint32_t", - "arguments": [ - ["const godot_callable *", "p_self"] - ] - }, - { - "name": "godot_callable_as_string", - "return_type": "godot_string", - "arguments": [ - ["const godot_callable *", "p_self"] - ] - }, - { - "name": "godot_callable_operator_equal", - "return_type": "godot_bool", - "arguments": [ - ["const godot_callable *", "p_self"], - ["const godot_callable *", "p_other"] - ] - }, - { - "name": "godot_callable_operator_less", - "return_type": "godot_bool", - "arguments": [ - ["const godot_callable *", "p_self"], - ["const godot_callable *", "p_other"] - ] - }, - { - "name": "godot_signal_new_with_object", - "return_type": "void", - "arguments": [ - ["godot_signal *", "r_dest"], - ["const godot_object *", "p_object"], - ["const godot_string_name *", "p_method"] - ] - }, - { - "name": "godot_signal_new_with_object_id", - "return_type": "void", - "arguments": [ - ["godot_signal *", "r_dest"], - ["uint64_t", "p_objectid"], - ["const godot_string_name *", "p_method"] - ] - }, - { - "name": "godot_signal_new_copy", - "return_type": "void", - "arguments": [ - ["godot_signal *", "r_dest"], - ["const godot_signal *", "p_src"] - ] - }, - { - "name": "godot_signal_destroy", - "return_type": "void", - "arguments": [ - ["godot_signal *", "p_self"] - ] - }, - { - "name": "godot_signal_emit", - "return_type": "godot_int", - "arguments": [ - ["const godot_signal *", "p_self"], - ["const godot_variant **", "p_arguments"], - ["godot_int", "p_argcount"] - ] - }, - { - "name": "godot_signal_connect", - "return_type": "godot_int", - "arguments": [ - ["godot_signal *", "p_self"], - ["const godot_callable *", "p_callable"], - ["const godot_array *", "p_binds"], - ["uint32_t", "p_flags"] - ] - }, - { - "name": "godot_signal_disconnect", - "return_type": "void", - "arguments": [ - ["godot_signal *", "p_self"], - ["const godot_callable *", "p_callable"] - ] - }, - { - "name": "godot_signal_is_null", - "return_type": "godot_bool", - "arguments": [ - ["const godot_signal *", "p_self"] - ] - }, - { - "name": "godot_signal_is_connected", - "return_type": "godot_bool", - "arguments": [ - ["const godot_signal *", "p_self"], - ["const godot_callable *", "p_callable"] - ] - }, - { - "name": "godot_signal_get_connections", - "return_type": "godot_array", - "arguments": [ - ["const godot_signal *", "p_self"] - ] - }, - { - "name": "godot_signal_get_object", - "return_type": "godot_object *", - "arguments": [ - ["const godot_signal *", "p_self"] - ] - }, - { - "name": "godot_signal_get_object_id", - "return_type": "uint64_t", - "arguments": [ - ["const godot_signal *", "p_self"] - ] - }, - { - "name": "godot_signal_get_name", - "return_type": "godot_string_name", - "arguments": [ - ["const godot_signal *", "p_self"] - ] - }, - { - "name": "godot_signal_as_string", - "return_type": "godot_string", - "arguments": [ - ["const godot_signal *", "p_self"] - ] - }, - { - "name": "godot_signal_operator_equal", - "return_type": "godot_bool", - "arguments": [ - ["const godot_signal *", "p_self"], - ["const godot_signal *", "p_other"] - ] - }, - { - "name": "godot_signal_operator_less", - "return_type": "godot_bool", - "arguments": [ - ["const godot_signal *", "p_self"], - ["const godot_signal *", "p_other"] - ] - }, - { - "name": "godot_color_new_rgba", - "return_type": "void", - "arguments": [ - ["godot_color *", "r_dest"], - ["const godot_real", "p_r"], - ["const godot_real", "p_g"], - ["const godot_real", "p_b"], - ["const godot_real", "p_a"] - ] - }, - { - "name": "godot_color_new_rgb", - "return_type": "void", - "arguments": [ - ["godot_color *", "r_dest"], - ["const godot_real", "p_r"], - ["const godot_real", "p_g"], - ["const godot_real", "p_b"] - ] - }, - { - "name": "godot_color_get_r", - "return_type": "godot_real", - "arguments": [ - ["const godot_color *", "p_self"] - ] - }, - { - "name": "godot_color_set_r", - "return_type": "void", - "arguments": [ - ["godot_color *", "p_self"], - ["const godot_real", "r"] - ] - }, - { - "name": "godot_color_get_g", - "return_type": "godot_real", - "arguments": [ - ["const godot_color *", "p_self"] - ] - }, - { - "name": "godot_color_set_g", - "return_type": "void", - "arguments": [ - ["godot_color *", "p_self"], - ["const godot_real", "g"] - ] - }, - { - "name": "godot_color_get_b", - "return_type": "godot_real", - "arguments": [ - ["const godot_color *", "p_self"] - ] - }, - { - "name": "godot_color_set_b", - "return_type": "void", - "arguments": [ - ["godot_color *", "p_self"], - ["const godot_real", "b"] - ] - }, - { - "name": "godot_color_get_a", - "return_type": "godot_real", - "arguments": [ - ["const godot_color *", "p_self"] - ] - }, - { - "name": "godot_color_set_a", - "return_type": "void", - "arguments": [ - ["godot_color *", "p_self"], - ["const godot_real", "a"] - ] - }, - { - "name": "godot_color_get_h", - "return_type": "godot_real", - "arguments": [ - ["const godot_color *", "p_self"] - ] - }, - { - "name": "godot_color_get_s", - "return_type": "godot_real", - "arguments": [ - ["const godot_color *", "p_self"] - ] - }, - { - "name": "godot_color_get_v", - "return_type": "godot_real", - "arguments": [ - ["const godot_color *", "p_self"] - ] - }, - { - "name": "godot_color_as_string", - "return_type": "godot_string", - "arguments": [ - ["const godot_color *", "p_self"] - ] - }, - { - "name": "godot_color_to_rgba32", - "return_type": "godot_int", - "arguments": [ - ["const godot_color *", "p_self"] - ] - }, - { - "name": "godot_color_to_argb32", - "return_type": "godot_int", - "arguments": [ - ["const godot_color *", "p_self"] - ] - }, - { - "name": "godot_color_inverted", - "return_type": "godot_color", - "arguments": [ - ["const godot_color *", "p_self"] - ] - }, - { - "name": "godot_color_lerp", - "return_type": "godot_color", - "arguments": [ - ["const godot_color *", "p_self"], - ["const godot_color *", "p_b"], - ["const godot_real", "p_t"] - ] - }, - { - "name": "godot_color_blend", - "return_type": "godot_color", - "arguments": [ - ["const godot_color *", "p_self"], - ["const godot_color *", "p_over"] - ] - }, - { - "name": "godot_color_to_html", - "return_type": "godot_string", - "arguments": [ - ["const godot_color *", "p_self"], - ["const godot_bool", "p_with_alpha"] - ] - }, - { - "name": "godot_color_operator_equal", - "return_type": "godot_bool", - "arguments": [ - ["const godot_color *", "p_self"], - ["const godot_color *", "p_b"] - ] - }, - { - "name": "godot_color_operator_less", - "return_type": "godot_bool", - "arguments": [ - ["const godot_color *", "p_self"], - ["const godot_color *", "p_b"] - ] - }, - { - "name": "godot_color_to_abgr32", - "return_type": "godot_int", - "arguments": [ - ["const godot_color *", "p_self"] - ] - }, - { - "name": "godot_color_to_abgr64", - "return_type": "godot_int", - "arguments": [ - ["const godot_color *", "p_self"] - ] - }, - { - "name": "godot_color_to_argb64", - "return_type": "godot_int", - "arguments": [ - ["const godot_color *", "p_self"] - ] - }, - { - "name": "godot_color_to_rgba64", - "return_type": "godot_int", - "arguments": [ - ["const godot_color *", "p_self"] - ] - }, - { - "name": "godot_color_darkened", - "return_type": "godot_color", - "arguments": [ - ["const godot_color *", "p_self"], - ["const godot_real", "p_amount"] - ] - }, - { - "name": "godot_color_from_hsv", - "return_type": "godot_color", - "arguments": [ - ["const godot_color *", "p_self"], - ["const godot_real", "p_h"], - ["const godot_real", "p_s"], - ["const godot_real", "p_v"], - ["const godot_real", "p_a"] - ] - }, - { - "name": "godot_color_lightened", - "return_type": "godot_color", - "arguments": [ - ["const godot_color *", "p_self"], - ["const godot_real", "p_amount"] - ] - }, - { - "name": "godot_dictionary_new", - "return_type": "void", - "arguments": [ - ["godot_dictionary *", "r_dest"] - ] - }, - { - "name": "godot_dictionary_new_copy", - "return_type": "void", - "arguments": [ - ["godot_dictionary *", "r_dest"], - ["const godot_dictionary *", "p_src"] - ] - }, - { - "name": "godot_dictionary_destroy", - "return_type": "void", - "arguments": [ - ["godot_dictionary *", "p_self"] - ] - }, - { - "name": "godot_dictionary_size", - "return_type": "godot_int", - "arguments": [ - ["const godot_dictionary *", "p_self"] - ] - }, - { - "name": "godot_dictionary_empty", - "return_type": "godot_bool", - "arguments": [ - ["const godot_dictionary *", "p_self"] - ] - }, - { - "name": "godot_dictionary_clear", - "return_type": "void", - "arguments": [ - ["godot_dictionary *", "p_self"] - ] - }, - { - "name": "godot_dictionary_has", - "return_type": "godot_bool", - "arguments": [ - ["const godot_dictionary *", "p_self"], - ["const godot_variant *", "p_key"] - ] - }, - { - "name": "godot_dictionary_has_all", - "return_type": "godot_bool", - "arguments": [ - ["const godot_dictionary *", "p_self"], - ["const godot_array *", "p_keys"] - ] - }, - { - "name": "godot_dictionary_erase", - "return_type": "void", - "arguments": [ - ["godot_dictionary *", "p_self"], - ["const godot_variant *", "p_key"] - ] - }, - { - "name": "godot_dictionary_hash", - "return_type": "godot_int", - "arguments": [ - ["const godot_dictionary *", "p_self"] - ] - }, - { - "name": "godot_dictionary_keys", - "return_type": "godot_array", - "arguments": [ - ["const godot_dictionary *", "p_self"] - ] - }, - { - "name": "godot_dictionary_values", - "return_type": "godot_array", - "arguments": [ - ["const godot_dictionary *", "p_self"] - ] - }, - { - "name": "godot_dictionary_get", - "return_type": "godot_variant", - "arguments": [ - ["const godot_dictionary *", "p_self"], - ["const godot_variant *", "p_key"] - ] - }, - { - "name": "godot_dictionary_set", - "return_type": "void", - "arguments": [ - ["godot_dictionary *", "p_self"], - ["const godot_variant *", "p_key"], - ["const godot_variant *", "p_value"] - ] - }, - { - "name": "godot_dictionary_operator_index", - "return_type": "godot_variant *", - "arguments": [ - ["godot_dictionary *", "p_self"], - ["const godot_variant *", "p_key"] - ] - }, - { - "name": "godot_dictionary_operator_index_const", - "return_type": "const godot_variant *", - "arguments": [ - ["const godot_dictionary *", "p_self"], - ["const godot_variant *", "p_key"] - ] - }, - { - "name": "godot_dictionary_next", - "return_type": "godot_variant *", - "arguments": [ - ["const godot_dictionary *", "p_self"], - ["const godot_variant *", "p_key"] - ] - }, - { - "name": "godot_dictionary_operator_equal", - "return_type": "godot_bool", - "arguments": [ - ["const godot_dictionary *", "p_self"], - ["const godot_dictionary *", "p_b"] - ] - }, - { - "name": "godot_dictionary_to_json", - "return_type": "godot_string", - "arguments": [ - ["const godot_dictionary *", "p_self"] - ] - }, - { - "name": "godot_dictionary_duplicate", - "return_type": "godot_dictionary", - "arguments": [ - ["const godot_dictionary *", "p_self"], - ["const godot_bool", "p_deep"] - ] - }, - { - "name": "godot_dictionary_get_with_default", - "return_type": "godot_variant", - "arguments": [ - ["const godot_dictionary *", "p_self"], - ["const godot_variant *", "p_key"], - ["const godot_variant *", "p_default"] - ] - }, - { - "name": "godot_dictionary_erase_with_return", - "return_type": "bool", - "arguments": [ - ["godot_dictionary *", "p_self"], - ["const godot_variant *", "p_key"] - ] - }, - { - "name": "godot_node_path_new", - "return_type": "void", - "arguments": [ - ["godot_node_path *", "r_dest"], - ["const godot_string *", "p_from"] - ] - }, - { - "name": "godot_node_path_new_copy", - "return_type": "void", - "arguments": [ - ["godot_node_path *", "r_dest"], - ["const godot_node_path *", "p_src"] - ] - }, - { - "name": "godot_node_path_destroy", - "return_type": "void", - "arguments": [ - ["godot_node_path *", "p_self"] - ] - }, - { - "name": "godot_node_path_as_string", - "return_type": "godot_string", - "arguments": [ - ["const godot_node_path *", "p_self"] - ] - }, - { - "name": "godot_node_path_is_absolute", - "return_type": "godot_bool", - "arguments": [ - ["const godot_node_path *", "p_self"] - ] - }, - { - "name": "godot_node_path_get_name_count", - "return_type": "godot_int", - "arguments": [ - ["const godot_node_path *", "p_self"] - ] - }, - { - "name": "godot_node_path_get_name", - "return_type": "godot_string", - "arguments": [ - ["const godot_node_path *", "p_self"], - ["const godot_int", "p_idx"] - ] - }, - { - "name": "godot_node_path_get_subname_count", - "return_type": "godot_int", - "arguments": [ - ["const godot_node_path *", "p_self"] - ] - }, - { - "name": "godot_node_path_get_subname", - "return_type": "godot_string", - "arguments": [ - ["const godot_node_path *", "p_self"], - ["const godot_int", "p_idx"] - ] - }, - { - "name": "godot_node_path_get_concatenated_subnames", - "return_type": "godot_string", - "arguments": [ - ["const godot_node_path *", "p_self"] - ] - }, - { - "name": "godot_node_path_is_empty", - "return_type": "godot_bool", - "arguments": [ - ["const godot_node_path *", "p_self"] - ] - }, - { - "name": "godot_node_path_operator_equal", - "return_type": "godot_bool", - "arguments": [ - ["const godot_node_path *", "p_self"], - ["const godot_node_path *", "p_b"] - ] - }, - { - "name": "godot_node_path_get_as_property_path", - "return_type": "godot_node_path", - "arguments": [ - ["const godot_node_path *", "p_self"] - ] - }, - { - "name": "godot_packed_byte_array_new", - "return_type": "void", - "arguments": [ - ["godot_packed_byte_array *", "r_dest"] - ] - }, - { - "name": "godot_packed_byte_array_new_copy", - "return_type": "void", - "arguments": [ - ["godot_packed_byte_array *", "r_dest"], - ["const godot_packed_byte_array *", "p_src"] - ] - }, - { - "name": "godot_packed_byte_array_new_with_array", - "return_type": "void", - "arguments": [ - ["godot_packed_byte_array *", "r_dest"], - ["const godot_array *", "p_a"] - ] - }, - { - "name": "godot_packed_byte_array_empty", - "return_type": "godot_bool", - "arguments": [ - ["const godot_packed_byte_array *", "p_self"] - ] - }, - { - "name": "godot_packed_byte_array_append", - "return_type": "void", - "arguments": [ - ["godot_packed_byte_array *", "p_self"], - ["const uint8_t", "p_data"] - ] - }, - { - "name": "godot_packed_byte_array_append_array", - "return_type": "void", - "arguments": [ - ["godot_packed_byte_array *", "p_self"], - ["const godot_packed_byte_array *", "p_array"] - ] - }, - { - "name": "godot_packed_byte_array_insert", - "return_type": "godot_error", - "arguments": [ - ["godot_packed_byte_array *", "p_self"], - ["const godot_int", "p_idx"], - ["const uint8_t", "p_data"] - ] - }, - { - "name": "godot_packed_byte_array_has", - "return_type": "godot_bool", - "arguments": [ - ["godot_packed_byte_array *", "p_self"], - ["const uint8_t", "p_value"] - ] - }, - { - "name": "godot_packed_byte_array_sort", - "return_type": "void", - "arguments": [ - ["godot_packed_byte_array *", "p_self"] - ] - }, - { - "name": "godot_packed_byte_array_invert", - "return_type": "void", - "arguments": [ - ["godot_packed_byte_array *", "p_self"] - ] - }, - { - "name": "godot_packed_byte_array_push_back", - "return_type": "void", - "arguments": [ - ["godot_packed_byte_array *", "p_self"], - ["const uint8_t", "p_data"] - ] - }, - { - "name": "godot_packed_byte_array_remove", - "return_type": "void", - "arguments": [ - ["godot_packed_byte_array *", "p_self"], - ["const godot_int", "p_idx"] - ] - }, - { - "name": "godot_packed_byte_array_resize", - "return_type": "void", - "arguments": [ - ["godot_packed_byte_array *", "p_self"], - ["const godot_int", "p_size"] - ] - }, - { - "name": "godot_packed_byte_array_ptr", - "return_type": "const uint8_t *", - "arguments": [ - ["const godot_packed_byte_array *", "p_self"] - ] - }, - { - "name": "godot_packed_byte_array_ptrw", - "return_type": "uint8_t *", - "arguments": [ - ["godot_packed_byte_array *", "p_self"] - ] - }, - { - "name": "godot_packed_byte_array_set", - "return_type": "void", - "arguments": [ - ["godot_packed_byte_array *", "p_self"], - ["const godot_int", "p_idx"], - ["const uint8_t", "p_data"] - ] - }, - { - "name": "godot_packed_byte_array_get", - "return_type": "uint8_t", - "arguments": [ - ["const godot_packed_byte_array *", "p_self"], - ["const godot_int", "p_idx"] - ] - }, - { - "name": "godot_packed_byte_array_size", - "return_type": "godot_int", - "arguments": [ - ["const godot_packed_byte_array *", "p_self"] - ] - }, - { - "name": "godot_packed_byte_array_destroy", - "return_type": "void", - "arguments": [ - ["godot_packed_byte_array *", "p_self"] - ] - }, - { - "name": "godot_packed_int32_array_new", - "return_type": "void", - "arguments": [ - ["godot_packed_int32_array *", "r_dest"] - ] - }, - { - "name": "godot_packed_int32_array_new_copy", - "return_type": "void", - "arguments": [ - ["godot_packed_int32_array *", "r_dest"], - ["const godot_packed_int32_array *", "p_src"] - ] - }, - { - "name": "godot_packed_int32_array_new_with_array", - "return_type": "void", - "arguments": [ - ["godot_packed_int32_array *", "r_dest"], - ["const godot_array *", "p_a"] - ] - }, - { - "name": "godot_packed_int32_array_empty", - "return_type": "godot_bool", - "arguments": [ - ["const godot_packed_int32_array *", "p_self"] - ] - }, - { - "name": "godot_packed_int32_array_append", - "return_type": "void", - "arguments": [ - ["godot_packed_int32_array *", "p_self"], - ["const int32_t", "p_data"] - ] - }, - { - "name": "godot_packed_int32_array_append_array", - "return_type": "void", - "arguments": [ - ["godot_packed_int32_array *", "p_self"], - ["const godot_packed_int32_array *", "p_array"] - ] - }, - { - "name": "godot_packed_int32_array_insert", - "return_type": "godot_error", - "arguments": [ - ["godot_packed_int32_array *", "p_self"], - ["const godot_int", "p_idx"], - ["const int32_t", "p_data"] - ] - }, - { - "name": "godot_packed_int32_array_has", - "return_type": "godot_bool", - "arguments": [ - ["godot_packed_int32_array *", "p_self"], - ["const int32_t", "p_value"] - ] - }, - { - "name": "godot_packed_int32_array_sort", - "return_type": "void", - "arguments": [ - ["godot_packed_int32_array *", "p_self"] - ] - }, - { - "name": "godot_packed_int32_array_invert", - "return_type": "void", - "arguments": [ - ["godot_packed_int32_array *", "p_self"] - ] - }, - { - "name": "godot_packed_int32_array_push_back", - "return_type": "void", - "arguments": [ - ["godot_packed_int32_array *", "p_self"], - ["const int32_t", "p_data"] - ] - }, - { - "name": "godot_packed_int32_array_remove", - "return_type": "void", - "arguments": [ - ["godot_packed_int32_array *", "p_self"], - ["const godot_int", "p_idx"] - ] - }, - { - "name": "godot_packed_int32_array_resize", - "return_type": "void", - "arguments": [ - ["godot_packed_int32_array *", "p_self"], - ["const godot_int", "p_size"] - ] - }, - { - "name": "godot_packed_int32_array_ptr", - "return_type": "const int32_t *", - "arguments": [ - ["const godot_packed_int32_array *", "p_self"] - ] - }, - { - "name": "godot_packed_int32_array_ptrw", - "return_type": "int32_t *", - "arguments": [ - ["godot_packed_int32_array *", "p_self"] - ] - }, - { - "name": "godot_packed_int32_array_set", - "return_type": "void", - "arguments": [ - ["godot_packed_int32_array *", "p_self"], - ["const godot_int", "p_idx"], - ["const int32_t", "p_data"] - ] - }, - { - "name": "godot_packed_int32_array_get", - "return_type": "int32_t", - "arguments": [ - ["const godot_packed_int32_array *", "p_self"], - ["const godot_int", "p_idx"] - ] - }, - { - "name": "godot_packed_int32_array_size", - "return_type": "godot_int", - "arguments": [ - ["const godot_packed_int32_array *", "p_self"] - ] - }, - { - "name": "godot_packed_int32_array_destroy", - "return_type": "void", - "arguments": [ - ["godot_packed_int32_array *", "p_self"] - ] - }, - { - "name": "godot_packed_int64_array_new", - "return_type": "void", - "arguments": [ - ["godot_packed_int64_array *", "r_dest"] - ] - }, - { - "name": "godot_packed_int64_array_new_copy", - "return_type": "void", - "arguments": [ - ["godot_packed_int64_array *", "r_dest"], - ["const godot_packed_int64_array *", "p_src"] - ] - }, - { - "name": "godot_packed_int64_array_new_with_array", - "return_type": "void", - "arguments": [ - ["godot_packed_int64_array *", "r_dest"], - ["const godot_array *", "p_a"] - ] - }, - { - "name": "godot_packed_int64_array_empty", - "return_type": "godot_bool", - "arguments": [ - ["const godot_packed_int64_array *", "p_self"] - ] - }, - { - "name": "godot_packed_int64_array_append", - "return_type": "void", - "arguments": [ - ["godot_packed_int64_array *", "p_self"], - ["const int64_t", "p_data"] - ] - }, - { - "name": "godot_packed_int64_array_append_array", - "return_type": "void", - "arguments": [ - ["godot_packed_int64_array *", "p_self"], - ["const godot_packed_int64_array *", "p_array"] - ] - }, - { - "name": "godot_packed_int64_array_insert", - "return_type": "godot_error", - "arguments": [ - ["godot_packed_int64_array *", "p_self"], - ["const godot_int", "p_idx"], - ["const int64_t", "p_data"] - ] - }, - { - "name": "godot_packed_int64_array_has", - "return_type": "godot_bool", - "arguments": [ - ["godot_packed_int64_array *", "p_self"], - ["const int64_t", "p_value"] - ] - }, - { - "name": "godot_packed_int64_array_sort", - "return_type": "void", - "arguments": [ - ["godot_packed_int64_array *", "p_self"] - ] - }, - { - "name": "godot_packed_int64_array_invert", - "return_type": "void", - "arguments": [ - ["godot_packed_int64_array *", "p_self"] - ] - }, - { - "name": "godot_packed_int64_array_push_back", - "return_type": "void", - "arguments": [ - ["godot_packed_int64_array *", "p_self"], - ["const int64_t", "p_data"] - ] - }, - { - "name": "godot_packed_int64_array_remove", - "return_type": "void", - "arguments": [ - ["godot_packed_int64_array *", "p_self"], - ["const godot_int", "p_idx"] - ] - }, - { - "name": "godot_packed_int64_array_resize", - "return_type": "void", - "arguments": [ - ["godot_packed_int64_array *", "p_self"], - ["const godot_int", "p_size"] - ] - }, - { - "name": "godot_packed_int64_array_ptr", - "return_type": "const int64_t *", - "arguments": [ - ["const godot_packed_int64_array *", "p_self"] - ] - }, - { - "name": "godot_packed_int64_array_ptrw", - "return_type": "int64_t *", - "arguments": [ - ["godot_packed_int64_array *", "p_self"] - ] - }, - { - "name": "godot_packed_int64_array_set", - "return_type": "void", - "arguments": [ - ["godot_packed_int64_array *", "p_self"], - ["const godot_int", "p_idx"], - ["const int64_t", "p_data"] - ] - }, - { - "name": "godot_packed_int64_array_get", - "return_type": "int64_t", - "arguments": [ - ["const godot_packed_int64_array *", "p_self"], - ["const godot_int", "p_idx"] - ] - }, - { - "name": "godot_packed_int64_array_size", - "return_type": "godot_int", - "arguments": [ - ["const godot_packed_int64_array *", "p_self"] - ] - }, - { - "name": "godot_packed_int64_array_destroy", - "return_type": "void", - "arguments": [ - ["godot_packed_int64_array *", "p_self"] - ] - }, - { - "name": "godot_packed_float32_array_new", - "return_type": "void", - "arguments": [ - ["godot_packed_float32_array *", "r_dest"] - ] - }, - { - "name": "godot_packed_float32_array_new_copy", - "return_type": "void", - "arguments": [ - ["godot_packed_float32_array *", "r_dest"], - ["const godot_packed_float32_array *", "p_src"] - ] - }, - { - "name": "godot_packed_float32_array_new_with_array", - "return_type": "void", - "arguments": [ - ["godot_packed_float32_array *", "r_dest"], - ["const godot_array *", "p_a"] - ] - }, - { - "name": "godot_packed_float32_array_empty", - "return_type": "godot_bool", - "arguments": [ - ["const godot_packed_float32_array *", "p_self"] - ] - }, - { - "name": "godot_packed_float32_array_append", - "return_type": "void", - "arguments": [ - ["godot_packed_float32_array *", "p_self"], - ["const float", "p_data"] - ] - }, - { - "name": "godot_packed_float32_array_append_array", - "return_type": "void", - "arguments": [ - ["godot_packed_float32_array *", "p_self"], - ["const godot_packed_float32_array *", "p_array"] - ] - }, - { - "name": "godot_packed_float32_array_insert", - "return_type": "godot_error", - "arguments": [ - ["godot_packed_float32_array *", "p_self"], - ["const godot_int", "p_idx"], - ["const float", "p_data"] - ] - }, - { - "name": "godot_packed_float32_array_has", - "return_type": "godot_bool", - "arguments": [ - ["godot_packed_float32_array *", "p_self"], - ["const float", "p_value"] - ] - }, - { - "name": "godot_packed_float32_array_sort", - "return_type": "void", - "arguments": [ - ["godot_packed_float32_array *", "p_self"] - ] - }, - { - "name": "godot_packed_float32_array_invert", - "return_type": "void", - "arguments": [ - ["godot_packed_float32_array *", "p_self"] - ] - }, - { - "name": "godot_packed_float32_array_push_back", - "return_type": "void", - "arguments": [ - ["godot_packed_float32_array *", "p_self"], - ["const float", "p_data"] - ] - }, - { - "name": "godot_packed_float32_array_remove", - "return_type": "void", - "arguments": [ - ["godot_packed_float32_array *", "p_self"], - ["const godot_int", "p_idx"] - ] - }, - { - "name": "godot_packed_float32_array_resize", - "return_type": "void", - "arguments": [ - ["godot_packed_float32_array *", "p_self"], - ["const godot_int", "p_size"] - ] - }, - { - "name": "godot_packed_float32_array_ptr", - "return_type": "const float *", - "arguments": [ - ["const godot_packed_float32_array *", "p_self"] - ] - }, - { - "name": "godot_packed_float32_array_ptrw", - "return_type": "float *", - "arguments": [ - ["godot_packed_float32_array *", "p_self"] - ] - }, - { - "name": "godot_packed_float32_array_set", - "return_type": "void", - "arguments": [ - ["godot_packed_float32_array *", "p_self"], - ["const godot_int", "p_idx"], - ["const float", "p_data"] - ] - }, - { - "name": "godot_packed_float32_array_get", - "return_type": "float", - "arguments": [ - ["const godot_packed_float32_array *", "p_self"], - ["const godot_int", "p_idx"] - ] - }, - { - "name": "godot_packed_float32_array_size", - "return_type": "godot_int", - "arguments": [ - ["const godot_packed_float32_array *", "p_self"] - ] - }, - { - "name": "godot_packed_float32_array_destroy", - "return_type": "void", - "arguments": [ - ["godot_packed_float32_array *", "p_self"] - ] - }, - { - "name": "godot_packed_float64_array_new", - "return_type": "void", - "arguments": [ - ["godot_packed_float64_array *", "r_dest"] - ] - }, - { - "name": "godot_packed_float64_array_new_copy", - "return_type": "void", - "arguments": [ - ["godot_packed_float64_array *", "r_dest"], - ["const godot_packed_float64_array *", "p_src"] - ] - }, - { - "name": "godot_packed_float64_array_new_with_array", - "return_type": "void", - "arguments": [ - ["godot_packed_float64_array *", "r_dest"], - ["const godot_array *", "p_a"] - ] - }, - { - "name": "godot_packed_float64_array_empty", - "return_type": "godot_bool", - "arguments": [ - ["const godot_packed_float64_array *", "p_self"] - ] - }, - { - "name": "godot_packed_float64_array_append", - "return_type": "void", - "arguments": [ - ["godot_packed_float64_array *", "p_self"], - ["const double", "p_data"] - ] - }, - { - "name": "godot_packed_float64_array_append_array", - "return_type": "void", - "arguments": [ - ["godot_packed_float64_array *", "p_self"], - ["const godot_packed_float64_array *", "p_array"] - ] - }, - { - "name": "godot_packed_float64_array_insert", - "return_type": "godot_error", - "arguments": [ - ["godot_packed_float64_array *", "p_self"], - ["const godot_int", "p_idx"], - ["const double", "p_data"] - ] - }, - { - "name": "godot_packed_float64_array_has", - "return_type": "godot_bool", - "arguments": [ - ["godot_packed_float64_array *", "p_self"], - ["const double", "p_value"] - ] - }, - { - "name": "godot_packed_float64_array_sort", - "return_type": "void", - "arguments": [ - ["godot_packed_float64_array *", "p_self"] - ] - }, - { - "name": "godot_packed_float64_array_invert", - "return_type": "void", - "arguments": [ - ["godot_packed_float64_array *", "p_self"] - ] - }, - { - "name": "godot_packed_float64_array_push_back", - "return_type": "void", - "arguments": [ - ["godot_packed_float64_array *", "p_self"], - ["const double", "p_data"] - ] - }, - { - "name": "godot_packed_float64_array_remove", - "return_type": "void", - "arguments": [ - ["godot_packed_float64_array *", "p_self"], - ["const godot_int", "p_idx"] - ] - }, - { - "name": "godot_packed_float64_array_resize", - "return_type": "void", - "arguments": [ - ["godot_packed_float64_array *", "p_self"], - ["const godot_int", "p_size"] - ] - }, - { - "name": "godot_packed_float64_array_ptr", - "return_type": "const double *", - "arguments": [ - ["const godot_packed_float64_array *", "p_self"] - ] - }, - { - "name": "godot_packed_float64_array_ptrw", - "return_type": "double *", - "arguments": [ - ["godot_packed_float64_array *", "p_self"] - ] - }, - { - "name": "godot_packed_float64_array_set", - "return_type": "void", - "arguments": [ - ["godot_packed_float64_array *", "p_self"], - ["const godot_int", "p_idx"], - ["const double", "p_data"] - ] - }, - { - "name": "godot_packed_float64_array_get", - "return_type": "double", - "arguments": [ - ["const godot_packed_float64_array *", "p_self"], - ["const godot_int", "p_idx"] - ] - }, - { - "name": "godot_packed_float64_array_size", - "return_type": "godot_int", - "arguments": [ - ["const godot_packed_float64_array *", "p_self"] - ] - }, - { - "name": "godot_packed_float64_array_destroy", - "return_type": "void", - "arguments": [ - ["godot_packed_float64_array *", "p_self"] - ] - }, - { - "name": "godot_packed_string_array_new", - "return_type": "void", - "arguments": [ - ["godot_packed_string_array *", "r_dest"] - ] - }, - { - "name": "godot_packed_string_array_new_copy", - "return_type": "void", - "arguments": [ - ["godot_packed_string_array *", "r_dest"], - ["const godot_packed_string_array *", "p_src"] - ] - }, - { - "name": "godot_packed_string_array_new_with_array", - "return_type": "void", - "arguments": [ - ["godot_packed_string_array *", "r_dest"], - ["const godot_array *", "p_a"] - ] - }, - { - "name": "godot_packed_string_array_empty", - "return_type": "godot_bool", - "arguments": [ - ["const godot_packed_string_array *", "p_self"] - ] - }, - { - "name": "godot_packed_string_array_append", - "return_type": "void", - "arguments": [ - ["godot_packed_string_array *", "p_self"], - ["const godot_string *", "p_data"] - ] - }, - { - "name": "godot_packed_string_array_append_array", - "return_type": "void", - "arguments": [ - ["godot_packed_string_array *", "p_self"], - ["const godot_packed_string_array *", "p_array"] - ] - }, - { - "name": "godot_packed_string_array_insert", - "return_type": "godot_error", - "arguments": [ - ["godot_packed_string_array *", "p_self"], - ["const godot_int", "p_idx"], - ["const godot_string *", "p_data"] - ] - }, - { - "name": "godot_packed_string_array_has", - "return_type": "godot_bool", - "arguments": [ - ["godot_packed_string_array *", "p_self"], - ["const godot_string *", "p_value"] - ] - }, - { - "name": "godot_packed_string_array_sort", - "return_type": "void", - "arguments": [ - ["godot_packed_string_array *", "p_self"] - ] - }, - { - "name": "godot_packed_string_array_invert", - "return_type": "void", - "arguments": [ - ["godot_packed_string_array *", "p_self"] - ] - }, - { - "name": "godot_packed_string_array_push_back", - "return_type": "void", - "arguments": [ - ["godot_packed_string_array *", "p_self"], - ["const godot_string *", "p_data"] - ] - }, - { - "name": "godot_packed_string_array_remove", - "return_type": "void", - "arguments": [ - ["godot_packed_string_array *", "p_self"], - ["const godot_int", "p_idx"] - ] - }, - { - "name": "godot_packed_string_array_resize", - "return_type": "void", - "arguments": [ - ["godot_packed_string_array *", "p_self"], - ["const godot_int", "p_size"] - ] - }, - { - "name": "godot_packed_string_array_ptr", - "return_type": "const godot_string *", - "arguments": [ - ["const godot_packed_string_array *", "p_self"] - ] - }, - { - "name": "godot_packed_string_array_ptrw", - "return_type": "godot_string *", - "arguments": [ - ["godot_packed_string_array *", "p_self"] - ] - }, - { - "name": "godot_packed_string_array_set", - "return_type": "void", - "arguments": [ - ["godot_packed_string_array *", "p_self"], - ["const godot_int", "p_idx"], - ["const godot_string *", "p_data"] - ] - }, - { - "name": "godot_packed_string_array_get", - "return_type": "godot_string", - "arguments": [ - ["const godot_packed_string_array *", "p_self"], - ["const godot_int", "p_idx"] - ] - }, - { - "name": "godot_packed_string_array_size", - "return_type": "godot_int", - "arguments": [ - ["const godot_packed_string_array *", "p_self"] - ] - }, - { - "name": "godot_packed_string_array_destroy", - "return_type": "void", - "arguments": [ - ["godot_packed_string_array *", "p_self"] - ] - }, - { - "name": "godot_packed_vector2_array_new", - "return_type": "void", - "arguments": [ - ["godot_packed_vector2_array *", "r_dest"] - ] - }, - { - "name": "godot_packed_vector2_array_new_copy", - "return_type": "void", - "arguments": [ - ["godot_packed_vector2_array *", "r_dest"], - ["const godot_packed_vector2_array *", "p_src"] - ] - }, - { - "name": "godot_packed_vector2_array_new_with_array", - "return_type": "void", - "arguments": [ - ["godot_packed_vector2_array *", "r_dest"], - ["const godot_array *", "p_a"] - ] - }, - { - "name": "godot_packed_vector2_array_empty", - "return_type": "godot_bool", - "arguments": [ - ["const godot_packed_vector2_array *", "p_self"] - ] - }, - { - "name": "godot_packed_vector2_array_append", - "return_type": "void", - "arguments": [ - ["godot_packed_vector2_array *", "p_self"], - ["const godot_vector2 *", "p_data"] - ] - }, - { - "name": "godot_packed_vector2_array_append_array", - "return_type": "void", - "arguments": [ - ["godot_packed_vector2_array *", "p_self"], - ["const godot_packed_vector2_array *", "p_array"] - ] - }, - { - "name": "godot_packed_vector2_array_insert", - "return_type": "godot_error", - "arguments": [ - ["godot_packed_vector2_array *", "p_self"], - ["const godot_int", "p_idx"], - ["const godot_vector2 *", "p_data"] - ] - }, - { - "name": "godot_packed_vector2_array_has", - "return_type": "godot_bool", - "arguments": [ - ["godot_packed_vector2_array *", "p_self"], - ["const godot_vector2 *", "p_value"] - ] - }, - { - "name": "godot_packed_vector2_array_sort", - "return_type": "void", - "arguments": [ - ["godot_packed_vector2_array *", "p_self"] - ] - }, - { - "name": "godot_packed_vector2_array_invert", - "return_type": "void", - "arguments": [ - ["godot_packed_vector2_array *", "p_self"] - ] - }, - { - "name": "godot_packed_vector2_array_push_back", - "return_type": "void", - "arguments": [ - ["godot_packed_vector2_array *", "p_self"], - ["const godot_vector2 *", "p_data"] - ] - }, - { - "name": "godot_packed_vector2_array_remove", - "return_type": "void", - "arguments": [ - ["godot_packed_vector2_array *", "p_self"], - ["const godot_int", "p_idx"] - ] - }, - { - "name": "godot_packed_vector2_array_resize", - "return_type": "void", - "arguments": [ - ["godot_packed_vector2_array *", "p_self"], - ["const godot_int", "p_size"] - ] - }, - { - "name": "godot_packed_vector2_array_ptr", - "return_type": "const godot_vector2 *", - "arguments": [ - ["const godot_packed_vector2_array *", "p_self"] - ] - }, - { - "name": "godot_packed_vector2_array_ptrw", - "return_type": "godot_vector2 *", - "arguments": [ - ["godot_packed_vector2_array *", "p_self"] - ] - }, - { - "name": "godot_packed_vector2_array_set", - "return_type": "void", - "arguments": [ - ["godot_packed_vector2_array *", "p_self"], - ["const godot_int", "p_idx"], - ["const godot_vector2 *", "p_data"] - ] - }, - { - "name": "godot_packed_vector2_array_get", - "return_type": "godot_vector2", - "arguments": [ - ["const godot_packed_vector2_array *", "p_self"], - ["const godot_int", "p_idx"] - ] - }, - { - "name": "godot_packed_vector2_array_size", - "return_type": "godot_int", - "arguments": [ - ["const godot_packed_vector2_array *", "p_self"] - ] - }, - { - "name": "godot_packed_vector2_array_destroy", - "return_type": "void", - "arguments": [ - ["godot_packed_vector2_array *", "p_self"] - ] - }, - { - "name": "godot_packed_vector2i_array_new", - "return_type": "void", - "arguments": [ - ["godot_packed_vector2i_array *", "r_dest"] - ] - }, - { - "name": "godot_packed_vector2i_array_new_copy", - "return_type": "void", - "arguments": [ - ["godot_packed_vector2i_array *", "r_dest"], - ["const godot_packed_vector2i_array *", "p_src"] - ] - }, - { - "name": "godot_packed_vector2i_array_new_with_array", - "return_type": "void", - "arguments": [ - ["godot_packed_vector2i_array *", "r_dest"], - ["const godot_array *", "p_a"] - ] - }, - { - "name": "godot_packed_vector2i_array_empty", - "return_type": "godot_bool", - "arguments": [ - ["const godot_packed_vector2i_array *", "p_self"] - ] - }, - { - "name": "godot_packed_vector2i_array_append", - "return_type": "void", - "arguments": [ - ["godot_packed_vector2i_array *", "p_self"], - ["const godot_vector2i *", "p_data"] - ] - }, - { - "name": "godot_packed_vector2i_array_append_array", - "return_type": "void", - "arguments": [ - ["godot_packed_vector2i_array *", "p_self"], - ["const godot_packed_vector2i_array *", "p_array"] - ] - }, - { - "name": "godot_packed_vector2i_array_insert", - "return_type": "godot_error", - "arguments": [ - ["godot_packed_vector2i_array *", "p_self"], - ["const godot_int", "p_idx"], - ["const godot_vector2i *", "p_data"] - ] - }, - { - "name": "godot_packed_vector2i_array_has", - "return_type": "godot_bool", - "arguments": [ - ["godot_packed_vector2i_array *", "p_self"], - ["const godot_vector2i *", "p_value"] - ] - }, - { - "name": "godot_packed_vector2i_array_sort", - "return_type": "void", - "arguments": [ - ["godot_packed_vector2i_array *", "p_self"] - ] - }, - { - "name": "godot_packed_vector2i_array_invert", - "return_type": "void", - "arguments": [ - ["godot_packed_vector2i_array *", "p_self"] - ] - }, - { - "name": "godot_packed_vector2i_array_push_back", - "return_type": "void", - "arguments": [ - ["godot_packed_vector2i_array *", "p_self"], - ["const godot_vector2i *", "p_data"] - ] - }, - { - "name": "godot_packed_vector2i_array_remove", - "return_type": "void", - "arguments": [ - ["godot_packed_vector2i_array *", "p_self"], - ["const godot_int", "p_idx"] - ] - }, - { - "name": "godot_packed_vector2i_array_resize", - "return_type": "void", - "arguments": [ - ["godot_packed_vector2i_array *", "p_self"], - ["const godot_int", "p_size"] - ] - }, - { - "name": "godot_packed_vector2i_array_ptr", - "return_type": "const godot_vector2i *", - "arguments": [ - ["const godot_packed_vector2i_array *", "p_self"] - ] - }, - { - "name": "godot_packed_vector2i_array_ptrw", - "return_type": "godot_vector2i *", - "arguments": [ - ["godot_packed_vector2i_array *", "p_self"] - ] - }, - { - "name": "godot_packed_vector2i_array_set", - "return_type": "void", - "arguments": [ - ["godot_packed_vector2i_array *", "p_self"], - ["const godot_int", "p_idx"], - ["const godot_vector2i *", "p_data"] - ] - }, - { - "name": "godot_packed_vector2i_array_get", - "return_type": "godot_vector2i", - "arguments": [ - ["const godot_packed_vector2i_array *", "p_self"], - ["const godot_int", "p_idx"] - ] - }, - { - "name": "godot_packed_vector2i_array_size", - "return_type": "godot_int", - "arguments": [ - ["const godot_packed_vector2i_array *", "p_self"] - ] - }, - { - "name": "godot_packed_vector2i_array_destroy", - "return_type": "void", - "arguments": [ - ["godot_packed_vector2i_array *", "p_self"] - ] - }, - { - "name": "godot_packed_vector3_array_new", - "return_type": "void", - "arguments": [ - ["godot_packed_vector3_array *", "r_dest"] - ] - }, - { - "name": "godot_packed_vector3_array_new_copy", - "return_type": "void", - "arguments": [ - ["godot_packed_vector3_array *", "r_dest"], - ["const godot_packed_vector3_array *", "p_src"] - ] - }, - { - "name": "godot_packed_vector3_array_new_with_array", - "return_type": "void", - "arguments": [ - ["godot_packed_vector3_array *", "r_dest"], - ["const godot_array *", "p_a"] - ] - }, - { - "name": "godot_packed_vector3_array_empty", - "return_type": "godot_bool", - "arguments": [ - ["const godot_packed_vector3_array *", "p_self"] - ] - }, - { - "name": "godot_packed_vector3_array_append", - "return_type": "void", - "arguments": [ - ["godot_packed_vector3_array *", "p_self"], - ["const godot_vector3 *", "p_data"] - ] - }, - { - "name": "godot_packed_vector3_array_append_array", - "return_type": "void", - "arguments": [ - ["godot_packed_vector3_array *", "p_self"], - ["const godot_packed_vector3_array *", "p_array"] - ] - }, - { - "name": "godot_packed_vector3_array_insert", - "return_type": "godot_error", - "arguments": [ - ["godot_packed_vector3_array *", "p_self"], - ["const godot_int", "p_idx"], - ["const godot_vector3 *", "p_data"] - ] - }, - { - "name": "godot_packed_vector3_array_has", - "return_type": "godot_bool", - "arguments": [ - ["godot_packed_vector3_array *", "p_self"], - ["const godot_vector3 *", "p_value"] - ] - }, - { - "name": "godot_packed_vector3_array_sort", - "return_type": "void", - "arguments": [ - ["godot_packed_vector3_array *", "p_self"] - ] - }, - { - "name": "godot_packed_vector3_array_invert", - "return_type": "void", - "arguments": [ - ["godot_packed_vector3_array *", "p_self"] - ] - }, - { - "name": "godot_packed_vector3_array_push_back", - "return_type": "void", - "arguments": [ - ["godot_packed_vector3_array *", "p_self"], - ["const godot_vector3 *", "p_data"] - ] - }, - { - "name": "godot_packed_vector3_array_remove", - "return_type": "void", - "arguments": [ - ["godot_packed_vector3_array *", "p_self"], - ["const godot_int", "p_idx"] - ] - }, - { - "name": "godot_packed_vector3_array_resize", - "return_type": "void", - "arguments": [ - ["godot_packed_vector3_array *", "p_self"], - ["const godot_int", "p_size"] - ] - }, - { - "name": "godot_packed_vector3_array_ptr", - "return_type": "const godot_vector3 *", - "arguments": [ - ["const godot_packed_vector3_array *", "p_self"] - ] - }, - { - "name": "godot_packed_vector3_array_ptrw", - "return_type": "godot_vector3 *", - "arguments": [ - ["godot_packed_vector3_array *", "p_self"] - ] - }, - { - "name": "godot_packed_vector3_array_set", - "return_type": "void", - "arguments": [ - ["godot_packed_vector3_array *", "p_self"], - ["const godot_int", "p_idx"], - ["const godot_vector3 *", "p_data"] - ] - }, - { - "name": "godot_packed_vector3_array_get", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_packed_vector3_array *", "p_self"], - ["const godot_int", "p_idx"] - ] - }, - { - "name": "godot_packed_vector3_array_size", - "return_type": "godot_int", - "arguments": [ - ["const godot_packed_vector3_array *", "p_self"] - ] - }, - { - "name": "godot_packed_vector3_array_destroy", - "return_type": "void", - "arguments": [ - ["godot_packed_vector3_array *", "p_self"] - ] - }, - { - "name": "godot_packed_color_array_new", - "return_type": "void", - "arguments": [ - ["godot_packed_color_array *", "r_dest"] - ] - }, - { - "name": "godot_packed_color_array_new_copy", - "return_type": "void", - "arguments": [ - ["godot_packed_color_array *", "r_dest"], - ["const godot_packed_color_array *", "p_src"] - ] - }, - { - "name": "godot_packed_color_array_new_with_array", - "return_type": "void", - "arguments": [ - ["godot_packed_color_array *", "r_dest"], - ["const godot_array *", "p_a"] - ] - }, - { - "name": "godot_packed_color_array_empty", - "return_type": "godot_bool", - "arguments": [ - ["const godot_packed_color_array *", "p_self"] - ] - }, - { - "name": "godot_packed_color_array_append", - "return_type": "void", - "arguments": [ - ["godot_packed_color_array *", "p_self"], - ["const godot_color *", "p_data"] - ] - }, - { - "name": "godot_packed_color_array_append_array", - "return_type": "void", - "arguments": [ - ["godot_packed_color_array *", "p_self"], - ["const godot_packed_color_array *", "p_array"] - ] - }, - { - "name": "godot_packed_color_array_insert", - "return_type": "godot_error", - "arguments": [ - ["godot_packed_color_array *", "p_self"], - ["const godot_int", "p_idx"], - ["const godot_color *", "p_data"] - ] - }, - { - "name": "godot_packed_color_array_has", - "return_type": "godot_bool", - "arguments": [ - ["godot_packed_color_array *", "p_self"], - ["const godot_color *", "p_value"] - ] - }, - { - "name": "godot_packed_color_array_sort", - "return_type": "void", - "arguments": [ - ["godot_packed_color_array *", "p_self"] - ] - }, - { - "name": "godot_packed_color_array_invert", - "return_type": "void", - "arguments": [ - ["godot_packed_color_array *", "p_self"] - ] - }, - { - "name": "godot_packed_color_array_push_back", - "return_type": "void", - "arguments": [ - ["godot_packed_color_array *", "p_self"], - ["const godot_color *", "p_data"] - ] - }, - { - "name": "godot_packed_color_array_remove", - "return_type": "void", - "arguments": [ - ["godot_packed_color_array *", "p_self"], - ["const godot_int", "p_idx"] - ] - }, - { - "name": "godot_packed_color_array_resize", - "return_type": "void", - "arguments": [ - ["godot_packed_color_array *", "p_self"], - ["const godot_int", "p_size"] - ] - }, - { - "name": "godot_packed_color_array_ptr", - "return_type": "const godot_color *", - "arguments": [ - ["const godot_packed_color_array *", "p_self"] - ] - }, - { - "name": "godot_packed_color_array_ptrw", - "return_type": "godot_color *", - "arguments": [ - ["godot_packed_color_array *", "p_self"] - ] - }, - { - "name": "godot_packed_color_array_set", - "return_type": "void", - "arguments": [ - ["godot_packed_color_array *", "p_self"], - ["const godot_int", "p_idx"], - ["const godot_color *", "p_data"] - ] - }, - { - "name": "godot_packed_color_array_get", - "return_type": "godot_color", - "arguments": [ - ["const godot_packed_color_array *", "p_self"], - ["const godot_int", "p_idx"] - ] - }, - { - "name": "godot_packed_color_array_size", - "return_type": "godot_int", - "arguments": [ - ["const godot_packed_color_array *", "p_self"] - ] - }, - { - "name": "godot_packed_color_array_destroy", - "return_type": "void", - "arguments": [ - ["godot_packed_color_array *", "p_self"] - ] - }, - { - "name": "godot_plane_new_with_reals", - "return_type": "void", - "arguments": [ - ["godot_plane *", "r_dest"], - ["const godot_real", "p_a"], - ["const godot_real", "p_b"], - ["const godot_real", "p_c"], - ["const godot_real", "p_d"] - ] - }, - { - "name": "godot_plane_new_with_vectors", - "return_type": "void", - "arguments": [ - ["godot_plane *", "r_dest"], - ["const godot_vector3 *", "p_v1"], - ["const godot_vector3 *", "p_v2"], - ["const godot_vector3 *", "p_v3"] - ] - }, - { - "name": "godot_plane_new_with_normal", - "return_type": "void", - "arguments": [ - ["godot_plane *", "r_dest"], - ["const godot_vector3 *", "p_normal"], - ["const godot_real", "p_d"] - ] - }, - { - "name": "godot_plane_as_string", - "return_type": "godot_string", - "arguments": [ - ["const godot_plane *", "p_self"] - ] - }, - { - "name": "godot_plane_normalized", - "return_type": "godot_plane", - "arguments": [ - ["const godot_plane *", "p_self"] - ] - }, - { - "name": "godot_plane_center", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_plane *", "p_self"] - ] - }, - { - "name": "godot_plane_is_point_over", - "return_type": "godot_bool", - "arguments": [ - ["const godot_plane *", "p_self"], - ["const godot_vector3 *", "p_point"] - ] - }, - { - "name": "godot_plane_distance_to", - "return_type": "godot_real", - "arguments": [ - ["const godot_plane *", "p_self"], - ["const godot_vector3 *", "p_point"] - ] - }, - { - "name": "godot_plane_has_point", - "return_type": "godot_bool", - "arguments": [ - ["const godot_plane *", "p_self"], - ["const godot_vector3 *", "p_point"], - ["const godot_real", "p_epsilon"] - ] - }, - { - "name": "godot_plane_project", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_plane *", "p_self"], - ["const godot_vector3 *", "p_point"] - ] - }, - { - "name": "godot_plane_intersect_3", - "return_type": "godot_bool", - "arguments": [ - ["const godot_plane *", "p_self"], - ["godot_vector3 *", "r_dest"], - ["const godot_plane *", "p_b"], - ["const godot_plane *", "p_c"] - ] - }, - { - "name": "godot_plane_intersects_ray", - "return_type": "godot_bool", - "arguments": [ - ["const godot_plane *", "p_self"], - ["godot_vector3 *", "r_dest"], - ["const godot_vector3 *", "p_from"], - ["const godot_vector3 *", "p_dir"] - ] - }, - { - "name": "godot_plane_intersects_segment", - "return_type": "godot_bool", - "arguments": [ - ["const godot_plane *", "p_self"], - ["godot_vector3 *", "r_dest"], - ["const godot_vector3 *", "p_begin"], - ["const godot_vector3 *", "p_end"] - ] - }, - { - "name": "godot_plane_operator_neg", - "return_type": "godot_plane", - "arguments": [ - ["const godot_plane *", "p_self"] - ] - }, - { - "name": "godot_plane_operator_equal", - "return_type": "godot_bool", - "arguments": [ - ["const godot_plane *", "p_self"], - ["const godot_plane *", "p_b"] - ] - }, - { - "name": "godot_plane_set_normal", - "return_type": "void", - "arguments": [ - ["godot_plane *", "p_self"], - ["const godot_vector3 *", "p_normal"] - ] - }, - { - "name": "godot_plane_get_normal", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_plane *", "p_self"] - ] - }, - { - "name": "godot_plane_get_d", - "return_type": "godot_real", - "arguments": [ - ["const godot_plane *", "p_self"] - ] - }, - { - "name": "godot_plane_set_d", - "return_type": "void", - "arguments": [ - ["godot_plane *", "p_self"], - ["const godot_real", "p_d"] - ] - }, - { - "name": "godot_quat_new", - "return_type": "void", - "arguments": [ - ["godot_quat *", "r_dest"], - ["const godot_real", "p_x"], - ["const godot_real", "p_y"], - ["const godot_real", "p_z"], - ["const godot_real", "p_w"] - ] - }, - { - "name": "godot_quat_new_with_axis_angle", - "return_type": "void", - "arguments": [ - ["godot_quat *", "r_dest"], - ["const godot_vector3 *", "p_axis"], - ["const godot_real", "p_angle"] - ] - }, - { - "name": "godot_quat_new_with_basis", - "return_type": "void", - "arguments": [ - ["godot_quat *", "r_dest"], - ["const godot_basis *", "p_basis"] - ] - }, - { - "name": "godot_quat_new_with_euler", - "return_type": "void", - "arguments": [ - ["godot_quat *", "r_dest"], - ["const godot_vector3 *", "p_euler"] - ] - }, - { - "name": "godot_quat_get_x", - "return_type": "godot_real", - "arguments": [ - ["const godot_quat *", "p_self"] - ] - }, - { - "name": "godot_quat_set_x", - "return_type": "void", - "arguments": [ - ["godot_quat *", "p_self"], - ["const godot_real", "val"] - ] - }, - { - "name": "godot_quat_get_y", - "return_type": "godot_real", - "arguments": [ - ["const godot_quat *", "p_self"] - ] - }, - { - "name": "godot_quat_set_y", - "return_type": "void", - "arguments": [ - ["godot_quat *", "p_self"], - ["const godot_real", "val"] - ] - }, - { - "name": "godot_quat_get_z", - "return_type": "godot_real", - "arguments": [ - ["const godot_quat *", "p_self"] - ] - }, - { - "name": "godot_quat_set_z", - "return_type": "void", - "arguments": [ - ["godot_quat *", "p_self"], - ["const godot_real", "val"] - ] - }, - { - "name": "godot_quat_get_w", - "return_type": "godot_real", - "arguments": [ - ["const godot_quat *", "p_self"] - ] - }, - { - "name": "godot_quat_set_w", - "return_type": "void", - "arguments": [ - ["godot_quat *", "p_self"], - ["const godot_real", "val"] - ] - }, - { - "name": "godot_quat_set_axis_angle", - "return_type": "void", - "arguments": [ - ["godot_quat *", "p_self"], - ["const godot_vector3 *", "p_axis"], - ["const godot_real", "p_angle"] - ] - }, - { - "name": "godot_quat_as_string", - "return_type": "godot_string", - "arguments": [ - ["const godot_quat *", "p_self"] - ] - }, - { - "name": "godot_quat_length", - "return_type": "godot_real", - "arguments": [ - ["const godot_quat *", "p_self"] - ] - }, - { - "name": "godot_quat_length_squared", - "return_type": "godot_real", - "arguments": [ - ["const godot_quat *", "p_self"] - ] - }, - { - "name": "godot_quat_normalized", - "return_type": "godot_quat", - "arguments": [ - ["const godot_quat *", "p_self"] - ] - }, - { - "name": "godot_quat_is_normalized", - "return_type": "godot_bool", - "arguments": [ - ["const godot_quat *", "p_self"] - ] - }, - { - "name": "godot_quat_inverse", - "return_type": "godot_quat", - "arguments": [ - ["const godot_quat *", "p_self"] - ] - }, - { - "name": "godot_quat_dot", - "return_type": "godot_real", - "arguments": [ - ["const godot_quat *", "p_self"], - ["const godot_quat *", "p_b"] - ] - }, - { - "name": "godot_quat_xform", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_quat *", "p_self"], - ["const godot_vector3 *", "p_v"] - ] - }, - { - "name": "godot_quat_slerp", - "return_type": "godot_quat", - "arguments": [ - ["const godot_quat *", "p_self"], - ["const godot_quat *", "p_b"], - ["const godot_real", "p_t"] - ] - }, - { - "name": "godot_quat_slerpni", - "return_type": "godot_quat", - "arguments": [ - ["const godot_quat *", "p_self"], - ["const godot_quat *", "p_b"], - ["const godot_real", "p_t"] - ] - }, - { - "name": "godot_quat_cubic_slerp", - "return_type": "godot_quat", - "arguments": [ - ["const godot_quat *", "p_self"], - ["const godot_quat *", "p_b"], - ["const godot_quat *", "p_pre_a"], - ["const godot_quat *", "p_post_b"], - ["const godot_real", "p_t"] - ] - }, - { - "name": "godot_quat_operator_multiply", - "return_type": "godot_quat", - "arguments": [ - ["const godot_quat *", "p_self"], - ["const godot_real", "p_b"] - ] - }, - { - "name": "godot_quat_operator_add", - "return_type": "godot_quat", - "arguments": [ - ["const godot_quat *", "p_self"], - ["const godot_quat *", "p_b"] - ] - }, - { - "name": "godot_quat_operator_subtract", - "return_type": "godot_quat", - "arguments": [ - ["const godot_quat *", "p_self"], - ["const godot_quat *", "p_b"] - ] - }, - { - "name": "godot_quat_operator_divide", - "return_type": "godot_quat", - "arguments": [ - ["const godot_quat *", "p_self"], - ["const godot_real", "p_b"] - ] - }, - { - "name": "godot_quat_operator_equal", - "return_type": "godot_bool", - "arguments": [ - ["const godot_quat *", "p_self"], - ["const godot_quat *", "p_b"] - ] - }, - { - "name": "godot_quat_operator_neg", - "return_type": "godot_quat", - "arguments": [ - ["const godot_quat *", "p_self"] - ] - }, - { - "name": "godot_rect2_new_with_position_and_size", - "return_type": "void", - "arguments": [ - ["godot_rect2 *", "r_dest"], - ["const godot_vector2 *", "p_pos"], - ["const godot_vector2 *", "p_size"] - ] - }, - { - "name": "godot_rect2_new", - "return_type": "void", - "arguments": [ - ["godot_rect2 *", "r_dest"], - ["const godot_real", "p_x"], - ["const godot_real", "p_y"], - ["const godot_real", "p_width"], - ["const godot_real", "p_height"] - ] - }, - { - "name": "godot_rect2_as_rect2i", - "return_type": "godot_rect2i", - "arguments": [ - ["const godot_rect2 *", "p_self"] - ] - }, - { - "name": "godot_rect2_as_string", - "return_type": "godot_string", - "arguments": [ - ["const godot_rect2 *", "p_self"] - ] - }, - { - "name": "godot_rect2_get_area", - "return_type": "godot_real", - "arguments": [ - ["const godot_rect2 *", "p_self"] - ] - }, - { - "name": "godot_rect2_grow_individual", - "return_type": "godot_rect2", - "arguments": [ - ["const godot_rect2 *", "p_self"], - ["const godot_real", "p_left"], - ["const godot_real", "p_top"], - ["const godot_real", "p_right"], - ["const godot_real", "p_bottom"] - ] - }, - { - "name": "godot_rect2_grow_margin", - "return_type": "godot_rect2", - "arguments": [ - ["const godot_rect2 *", "p_self"], - ["const godot_int", "p_margin"], - ["const godot_real", "p_by"] - ] - }, - { - "name": "godot_rect2_abs", - "return_type": "godot_rect2", - "arguments": [ - ["const godot_rect2 *", "p_self"] - ] - }, - { - "name": "godot_rect2_intersects", - "return_type": "godot_bool", - "arguments": [ - ["const godot_rect2 *", "p_self"], - ["const godot_rect2 *", "p_b"] - ] - }, - { - "name": "godot_rect2_encloses", - "return_type": "godot_bool", - "arguments": [ - ["const godot_rect2 *", "p_self"], - ["const godot_rect2 *", "p_b"] - ] - }, - { - "name": "godot_rect2_has_no_area", - "return_type": "godot_bool", - "arguments": [ - ["const godot_rect2 *", "p_self"] - ] - }, - { - "name": "godot_rect2_intersection", - "return_type": "godot_rect2", - "arguments": [ - ["const godot_rect2 *", "p_self"], - ["const godot_rect2 *", "p_b"] - ] - }, - { - "name": "godot_rect2_merge", - "return_type": "godot_rect2", - "arguments": [ - ["const godot_rect2 *", "p_self"], - ["const godot_rect2 *", "p_b"] - ] - }, - { - "name": "godot_rect2_has_point", - "return_type": "godot_bool", - "arguments": [ - ["const godot_rect2 *", "p_self"], - ["const godot_vector2 *", "p_point"] - ] - }, - { - "name": "godot_rect2_grow", - "return_type": "godot_rect2", - "arguments": [ - ["const godot_rect2 *", "p_self"], - ["const godot_real", "p_by"] - ] - }, - { - "name": "godot_rect2_expand", - "return_type": "godot_rect2", - "arguments": [ - ["const godot_rect2 *", "p_self"], - ["const godot_vector2 *", "p_to"] - ] - }, - { - "name": "godot_rect2_operator_equal", - "return_type": "godot_bool", - "arguments": [ - ["const godot_rect2 *", "p_self"], - ["const godot_rect2 *", "p_b"] - ] - }, - { - "name": "godot_rect2_get_position", - "return_type": "godot_vector2", - "arguments": [ - ["const godot_rect2 *", "p_self"] - ] - }, - { - "name": "godot_rect2_get_size", - "return_type": "godot_vector2", - "arguments": [ - ["const godot_rect2 *", "p_self"] - ] - }, - { - "name": "godot_rect2_set_position", - "return_type": "void", - "arguments": [ - ["godot_rect2 *", "p_self"], - ["const godot_vector2 *", "p_pos"] - ] - }, - { - "name": "godot_rect2_set_size", - "return_type": "void", - "arguments": [ - ["godot_rect2 *", "p_self"], - ["const godot_vector2 *", "p_size"] - ] - }, - { - "name": "godot_rect2i_new_with_position_and_size", - "return_type": "void", - "arguments": [ - ["godot_rect2i *", "r_dest"], - ["const godot_vector2i *", "p_pos"], - ["const godot_vector2i *", "p_size"] - ] - }, - { - "name": "godot_rect2i_new", - "return_type": "void", - "arguments": [ - ["godot_rect2i *", "r_dest"], - ["const godot_int", "p_x"], - ["const godot_int", "p_y"], - ["const godot_int", "p_width"], - ["const godot_int", "p_height"] - ] - }, - { - "name": "godot_rect2i_as_string", - "return_type": "godot_string", - "arguments": [ - ["const godot_rect2i *", "p_self"] - ] - }, - { - "name": "godot_rect2i_as_rect2", - "return_type": "godot_rect2", - "arguments": [ - ["const godot_rect2i *", "p_self"] - ] - }, - { - "name": "godot_rect2i_get_area", - "return_type": "godot_int", - "arguments": [ - ["const godot_rect2i *", "p_self"] - ] - }, - { - "name": "godot_rect2i_intersects", - "return_type": "godot_bool", - "arguments": [ - ["const godot_rect2i *", "p_self"], - ["const godot_rect2i *", "p_b"] - ] - }, - { - "name": "godot_rect2i_encloses", - "return_type": "godot_bool", - "arguments": [ - ["const godot_rect2i *", "p_self"], - ["const godot_rect2i *", "p_b"] - ] - }, - { - "name": "godot_rect2i_has_no_area", - "return_type": "godot_bool", - "arguments": [ - ["const godot_rect2i *", "p_self"] - ] - }, - { - "name": "godot_rect2i_intersection", - "return_type": "godot_rect2i", - "arguments": [ - ["const godot_rect2i *", "p_self"], - ["const godot_rect2i *", "p_b"] - ] - }, - { - "name": "godot_rect2i_merge", - "return_type": "godot_rect2i", - "arguments": [ - ["const godot_rect2i *", "p_self"], - ["const godot_rect2i *", "p_b"] - ] - }, - { - "name": "godot_rect2i_has_point", - "return_type": "godot_bool", - "arguments": [ - ["const godot_rect2i *", "p_self"], - ["const godot_vector2i *", "p_point"] - ] - }, - { - "name": "godot_rect2i_grow", - "return_type": "godot_rect2i", - "arguments": [ - ["const godot_rect2i *", "p_self"], - ["const godot_int", "p_by"] - ] - }, - { - "name": "godot_rect2i_grow_individual", - "return_type": "godot_rect2i", - "arguments": [ - ["const godot_rect2i *", "p_self"], - ["const godot_int", "p_left"], - ["const godot_int", "p_top"], - ["const godot_int", "p_right"], - ["const godot_int", "p_bottom"] - ] - }, - { - "name": "godot_rect2i_grow_margin", - "return_type": "godot_rect2i", - "arguments": [ - ["const godot_rect2i *", "p_self"], - ["const godot_int", "p_margin"], - ["const godot_int", "p_by"] - ] - }, - { - "name": "godot_rect2i_abs", - "return_type": "godot_rect2i", - "arguments": [ - ["const godot_rect2i *", "p_self"] - ] - }, - { - "name": "godot_rect2i_expand", - "return_type": "godot_rect2i", - "arguments": [ - ["const godot_rect2i *", "p_self"], - ["const godot_vector2i *", "p_to"] - ] - }, - { - "name": "godot_rect2i_operator_equal", - "return_type": "godot_bool", - "arguments": [ - ["const godot_rect2i *", "p_self"], - ["const godot_rect2i *", "p_b"] - ] - }, - { - "name": "godot_rect2i_get_position", - "return_type": "godot_vector2i", - "arguments": [ - ["const godot_rect2i *", "p_self"] - ] - }, - { - "name": "godot_rect2i_get_size", - "return_type": "godot_vector2i", - "arguments": [ - ["const godot_rect2i *", "p_self"] - ] - }, - { - "name": "godot_rect2i_set_position", - "return_type": "void", - "arguments": [ - ["godot_rect2i *", "p_self"], - ["const godot_vector2i *", "p_pos"] - ] - }, - { - "name": "godot_rect2i_set_size", - "return_type": "void", - "arguments": [ - ["godot_rect2i *", "p_self"], - ["const godot_vector2i *", "p_size"] - ] - }, - { - "name": "godot_rid_new", - "return_type": "void", - "arguments": [ - ["godot_rid *", "r_dest"] - ] - }, - { - "name": "godot_rid_get_id", - "return_type": "godot_int", - "arguments": [ - ["const godot_rid *", "p_self"] - ] - }, - { - "name": "godot_rid_new_with_resource", - "return_type": "void", - "arguments": [ - ["godot_rid *", "r_dest"], - ["const godot_object *", "p_from"] - ] - }, - { - "name": "godot_rid_operator_equal", - "return_type": "godot_bool", - "arguments": [ - ["const godot_rid *", "p_self"], - ["const godot_rid *", "p_b"] - ] - }, - { - "name": "godot_rid_operator_less", - "return_type": "godot_bool", - "arguments": [ - ["const godot_rid *", "p_self"], - ["const godot_rid *", "p_b"] - ] - }, - { - "name": "godot_char_string_length", - "return_type": "godot_int", - "arguments": [ - ["const godot_char_string *", "p_cs"] - ] - }, - { - "name": "godot_char_string_get_data", - "return_type": "const char *", - "arguments": [ - ["const godot_char_string *", "p_cs"] - ] - }, - { - "name": "godot_char_string_destroy", - "return_type": "void", - "arguments": [ - ["godot_char_string *", "p_cs"] - ] - }, - { - "name": "godot_char16_string_length", - "return_type": "godot_int", - "arguments": [ - ["const godot_char16_string *", "p_cs"] - ] - }, - { - "name": "godot_char16_string_get_data", - "return_type": "const char16_t *", - "arguments": [ - ["const godot_char16_string *", "p_cs"] - ] - }, - { - "name": "godot_char16_string_destroy", - "return_type": "void", - "arguments": [ - ["godot_char16_string *", "p_cs"] - ] - }, - { - "name": "godot_string_new", - "return_type": "void", - "arguments": [ - ["godot_string *", "r_dest"] - ] - }, - { - "name": "godot_string_new_copy", - "return_type": "void", - "arguments": [ - ["godot_string *", "r_dest"], - ["const godot_string *", "p_src"] - ] - }, - { - "name": "godot_string_new_with_latin1_chars", - "return_type": "void", - "arguments": [ - ["godot_string *", "r_dest"], - ["const char *", "p_contents"] - ] - }, - { - "name": "godot_string_new_with_utf8_chars", - "return_type": "void", - "arguments": [ - ["godot_string *", "r_dest"], - ["const char *", "p_contents"] - ] - }, - { - "name": "godot_string_new_with_utf16_chars", - "return_type": "void", - "arguments": [ - ["godot_string *", "r_dest"], - ["const char16_t *", "p_contents"] - ] - }, - { - "name": "godot_string_new_with_utf32_chars", - "return_type": "void", - "arguments": [ - ["godot_string *", "r_dest"], - ["const char32_t *", "p_contents"] - ] - }, - { - "name": "godot_string_new_with_wide_chars", - "return_type": "void", - "arguments": [ - ["godot_string *", "r_dest"], - ["const wchar_t *", "p_contents"] - ] - }, - { - "name": "godot_string_new_with_latin1_chars_and_len", - "return_type": "void", - "arguments": [ - ["godot_string *", "r_dest"], - ["const char *", "p_contents"], - ["const int", "p_size"] - ] - }, - { - "name": "godot_string_new_with_utf8_chars_and_len", - "return_type": "void", - "arguments": [ - ["godot_string *", "r_dest"], - ["const char *", "p_contents"], - ["const int", "p_size"] - ] - }, - { - "name": "godot_string_new_with_utf16_chars_and_len", - "return_type": "void", - "arguments": [ - ["godot_string *", "r_dest"], - ["const char16_t *", "p_contents"], - ["const int", "p_size"] - ] - }, - { - "name": "godot_string_new_with_utf32_chars_and_len", - "return_type": "void", - "arguments": [ - ["godot_string *", "r_dest"], - ["const char32_t *", "p_contents"], - ["const int", "p_size"] - ] - }, - { - "name": "godot_string_new_with_wide_chars_and_len", - "return_type": "void", - "arguments": [ - ["godot_string *", "r_dest"], - ["const wchar_t *", "p_contents"], - ["const int", "p_size"] - ] - }, - { - "name": "godot_string_operator_index", - "return_type": "const godot_char_type *", - "arguments": [ - ["godot_string *", "p_self"], - ["const godot_int", "p_idx"] - ] - }, - { - "name": "godot_string_operator_index_const", - "return_type": "godot_char_type", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_int", "p_idx"] - ] - }, - { - "name": "godot_string_get_data", - "return_type": "const godot_char_type *", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_operator_equal", - "return_type": "godot_bool", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_string *", "p_b"] - ] - }, - { - "name": "godot_string_operator_less", - "return_type": "godot_bool", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_string *", "p_b"] - ] - }, - { - "name": "godot_string_operator_plus", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_string *", "p_b"] - ] - }, - { - "name": "godot_string_count", - "return_type": "godot_int", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_string *", "p_what"], - ["godot_int", "p_from"], - ["godot_int", "p_to"] - ] - }, - { - "name": "godot_string_countn", - "return_type": "godot_int", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_string *", "p_what"], - ["godot_int", "p_from"], - ["godot_int", "p_to"] - ] - }, - { - "name": "godot_string_dedent", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_length", - "return_type": "godot_int", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_casecmp_to", - "return_type": "signed char", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_string *", "p_str"] - ] - }, - { - "name": "godot_string_nocasecmp_to", - "return_type": "signed char", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_string *", "p_str"] - ] - }, - { - "name": "godot_string_naturalnocasecmp_to", - "return_type": "signed char", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_string *", "p_str"] - ] - }, - { - "name": "godot_string_begins_with", - "return_type": "godot_bool", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_string *", "p_string"] - ] - }, - { - "name": "godot_string_begins_with_char_array", - "return_type": "godot_bool", - "arguments": [ - ["const godot_string *", "p_self"], - ["const char *", "p_char_array"] - ] - }, - { - "name": "godot_string_bigrams", - "return_type": "godot_packed_string_array", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_chr", - "return_type": "godot_string", - "arguments": [ - ["godot_char_type", "p_character"] - ] - }, - { - "name": "godot_string_ends_with", - "return_type": "godot_bool", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_string *", "p_string"] - ] - }, - { - "name": "godot_string_ends_with_char_array", - "return_type": "godot_bool", - "arguments": [ - ["const godot_string *", "p_self"], - ["const char *", "p_char_array"] - ] - }, - { - "name": "godot_string_find", - "return_type": "godot_int", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_string *", "p_what"] - ] - }, - { - "name": "godot_string_find_from", - "return_type": "godot_int", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_string *", "p_what"], - ["godot_int", "p_from"] - ] - }, - { - "name": "godot_string_findmk", - "return_type": "godot_int", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_packed_string_array *", "p_keys"] - ] - }, - { - "name": "godot_string_findmk_from", - "return_type": "godot_int", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_packed_string_array *", "p_keys"], - ["godot_int", "p_from"] - ] - }, - { - "name": "godot_string_findmk_from_in_place", - "return_type": "godot_int", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_packed_string_array *", "p_keys"], - ["godot_int", "p_from"], - ["godot_int *", "r_key"] - ] - }, - { - "name": "godot_string_findn", - "return_type": "godot_int", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_string *", "p_what"] - ] - }, - { - "name": "godot_string_findn_from", - "return_type": "godot_int", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_string *", "p_what"], - ["godot_int", "p_from"] - ] - }, - { - "name": "godot_string_format", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_variant *", "p_values"] - ] - }, - { - "name": "godot_string_format_with_custom_placeholder", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_variant *", "p_values"], - ["const char *", "p_placeholder"] - ] - }, - { - "name": "godot_string_hex_encode_buffer", - "return_type": "godot_string", - "arguments": [ - ["const uint8_t *", "p_buffer"], - ["godot_int", "p_len"] - ] - }, - { - "name": "godot_string_insert", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"], - ["godot_int", "p_at_pos"], - ["const godot_string *", "p_string"] - ] - }, - { - "name": "godot_string_is_numeric", - "return_type": "godot_bool", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_is_subsequence_of", - "return_type": "godot_bool", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_string *", "p_string"] - ] - }, - { - "name": "godot_string_is_subsequence_ofi", - "return_type": "godot_bool", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_string *", "p_string"] - ] - }, - { - "name": "godot_string_lpad", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"], - ["godot_int", "p_min_length"] - ] - }, - { - "name": "godot_string_lpad_with_custom_character", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"], - ["godot_int", "p_min_length"], - ["const godot_string *", "p_character"] - ] - }, - { - "name": "godot_string_match", - "return_type": "godot_bool", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_string *", "p_wildcard"] - ] - }, - { - "name": "godot_string_matchn", - "return_type": "godot_bool", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_string *", "p_wildcard"] - ] - }, - { - "name": "godot_string_md5", - "return_type": "godot_string", - "arguments": [ - ["const uint8_t *", "p_md5"] - ] - }, - { - "name": "godot_string_num", - "return_type": "godot_string", - "arguments": [ - ["double", "p_num"] - ] - }, - { - "name": "godot_string_num_int64", - "return_type": "godot_string", - "arguments": [ - ["int64_t", "p_num"], - ["godot_int", "p_base"] - ] - }, - { - "name": "godot_string_num_int64_capitalized", - "return_type": "godot_string", - "arguments": [ - ["int64_t", "p_num"], - ["godot_int", "p_base"], - ["godot_bool", "p_capitalize_hex"] - ] - }, - { - "name": "godot_string_num_real", - "return_type": "godot_string", - "arguments": [ - ["double", "p_num"] - ] - }, - { - "name": "godot_string_num_scientific", - "return_type": "godot_string", - "arguments": [ - ["double", "p_num"] - ] - }, - { - "name": "godot_string_num_with_decimals", - "return_type": "godot_string", - "arguments": [ - ["double", "p_num"], - ["godot_int", "p_decimals"] - ] - }, - { - "name": "godot_string_pad_decimals", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"], - ["godot_int", "p_digits"] - ] - }, - { - "name": "godot_string_pad_zeros", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"], - ["godot_int", "p_digits"] - ] - }, - { - "name": "godot_string_replace_first", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_string *", "p_key"], - ["const godot_string *", "p_with"] - ] - }, - { - "name": "godot_string_replace", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_string *", "p_key"], - ["const godot_string *", "p_with"] - ] - }, - { - "name": "godot_string_replacen", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_string *", "p_key"], - ["const godot_string *", "p_with"] - ] - }, - { - "name": "godot_string_rfind", - "return_type": "godot_int", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_string *", "p_what"] - ] - }, - { - "name": "godot_string_rfindn", - "return_type": "godot_int", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_string *", "p_what"] - ] - }, - { - "name": "godot_string_rfind_from", - "return_type": "godot_int", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_string *", "p_what"], - ["godot_int", "p_from"] - ] - }, - { - "name": "godot_string_rfindn_from", - "return_type": "godot_int", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_string *", "p_what"], - ["godot_int", "p_from"] - ] - }, - { - "name": "godot_string_rpad", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"], - ["godot_int", "p_min_length"] - ] - }, - { - "name": "godot_string_rpad_with_custom_character", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"], - ["godot_int", "p_min_length"], - ["const godot_string *", "p_character"] - ] - }, - { - "name": "godot_string_similarity", - "return_type": "godot_real", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_string *", "p_string"] - ] - }, - { - "name": "godot_string_sprintf", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_array *", "p_values"], - ["godot_bool *", "p_error"] - ] - }, - { - "name": "godot_string_substr", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"], - ["godot_int", "p_from"], - ["godot_int", "p_chars"] - ] - }, - { - "name": "godot_string_to_int", - "return_type": "godot_int", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_to_float", - "return_type": "double", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_camelcase_to_underscore", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_camelcase_to_underscore_lowercased", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_capitalize", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_char_to_float", - "return_type": "double", - "arguments": [ - ["const char *", "p_what"] - ] - }, - { - "name": "godot_string_wchar_to_float", - "return_type": "double", - "arguments": [ - ["const wchar_t *", "p_str"], - ["const wchar_t **", "r_end"] - ] - }, - { - "name": "godot_string_char_to_int", - "return_type": "godot_int", - "arguments": [ - ["const char *", "p_what"] - ] - }, - { - "name": "godot_string_wchar_to_int", - "return_type": "godot_int", - "arguments": [ - ["const wchar_t *", "p_str"] - ] - }, - { - "name": "godot_string_char_to_int_with_len", - "return_type": "godot_int", - "arguments": [ - ["const char *", "p_what"], - ["godot_int", "p_len"] - ] - }, - { - "name": "godot_string_wchar_to_int_with_len", - "return_type": "godot_int", - "arguments": [ - ["const wchar_t *", "p_str"], - ["int", "p_len"] - ] - }, - { - "name": "godot_string_hex_to_int", - "return_type": "godot_int", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_hex_to_int_with_prefix", - "return_type": "godot_int", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_get_slice_count", - "return_type": "godot_int", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_string *", "p_splitter"] - ] - }, - { - "name": "godot_string_get_slice", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_string *", "p_splitter"], - ["godot_int", "p_slice"] - ] - }, - { - "name": "godot_string_get_slicec", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"], - ["godot_char_type", "p_splitter"], - ["godot_int", "p_slice"] - ] - }, - { - "name": "godot_string_split", - "return_type": "godot_packed_string_array", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_string *", "p_splitter"] - ] - }, - { - "name": "godot_string_split_allow_empty", - "return_type": "godot_packed_string_array", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_string *", "p_splitter"] - ] - }, - { - "name": "godot_string_split_with_maxsplit", - "return_type": "godot_packed_string_array", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_string *", "p_splitter"], - ["const godot_bool", "p_allow_empty"], - ["const godot_int", "p_maxsplit"] - ] - }, - { - "name": "godot_string_rsplit", - "return_type": "godot_packed_string_array", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_string *", "p_splitter"] - ] - }, - { - "name": "godot_string_rsplit_allow_empty", - "return_type": "godot_packed_string_array", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_string *", "p_splitter"] - ] - }, - { - "name": "godot_string_rsplit_with_maxsplit", - "return_type": "godot_packed_string_array", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_string *", "p_splitter"], - ["const godot_bool", "p_allow_empty"], - ["const godot_int", "p_maxsplit"] - ] - }, - { - "name": "godot_string_split_floats", - "return_type": "godot_packed_float32_array", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_string *", "p_splitter"] - ] - }, - { - "name": "godot_string_split_floats_allow_empty", - "return_type": "godot_packed_float32_array", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_string *", "p_splitter"] - ] - }, - { - "name": "godot_string_split_floats_mk", - "return_type": "godot_packed_float32_array", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_packed_string_array *", "p_splitters"] - ] - }, - { - "name": "godot_string_split_floats_mk_allow_empty", - "return_type": "godot_packed_float32_array", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_packed_string_array *", "p_splitters"] - ] - }, - { - "name": "godot_string_split_ints", - "return_type": "godot_packed_int32_array", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_string *", "p_splitter"] - ] - }, - { - "name": "godot_string_split_ints_allow_empty", - "return_type": "godot_packed_int32_array", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_string *", "p_splitter"] - ] - }, - { - "name": "godot_string_split_ints_mk", - "return_type": "godot_packed_int32_array", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_packed_string_array *", "p_splitters"] - ] - }, - { - "name": "godot_string_split_ints_mk_allow_empty", - "return_type": "godot_packed_int32_array", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_packed_string_array *", "p_splitters"] - ] - }, - { - "name": "godot_string_split_spaces", - "return_type": "godot_packed_string_array", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_lstrip", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_string *", "p_chars"] - ] - }, - { - "name": "godot_string_rstrip", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_string *", "p_chars"] - ] - }, - { - "name": "godot_string_trim_prefix", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_string *", "p_prefix"] - ] - }, - { - "name": "godot_string_trim_suffix", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_string *", "p_suffix"] - ] - }, - { - "name": "godot_string_char_lowercase", - "return_type": "godot_char_type", - "arguments": [ - ["godot_char_type", "p_char"] - ] - }, - { - "name": "godot_string_char_uppercase", - "return_type": "godot_char_type", - "arguments": [ - ["godot_char_type", "p_char"] - ] - }, - { - "name": "godot_string_to_lower", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_to_upper", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_get_basename", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_get_extension", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_left", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"], - ["godot_int", "p_pos"] - ] - }, - { - "name": "godot_string_ord_at", - "return_type": "godot_char_type", - "arguments": [ - ["const godot_string *", "p_self"], - ["godot_int", "p_idx"] - ] - }, - { - "name": "godot_string_plus_file", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_string *", "p_file"] - ] - }, - { - "name": "godot_string_right", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"], - ["godot_int", "p_pos"] - ] - }, - { - "name": "godot_string_repeat", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"], - ["godot_int", "p_count"] - ] - }, - { - "name": "godot_string_strip_edges", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"], - ["godot_bool", "p_left"], - ["godot_bool", "p_right"] - ] - }, - { - "name": "godot_string_strip_escapes", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_erase", - "return_type": "void", - "arguments": [ - ["godot_string *", "p_self"], - ["godot_int", "p_pos"], - ["godot_int", "p_chars"] - ] - }, - { - "name": "godot_string_ascii", - "return_type": "godot_char_string", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_latin1", - "return_type": "godot_char_string", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_utf8", - "return_type": "godot_char_string", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_parse_utf8", - "return_type": "godot_bool", - "arguments": [ - ["godot_string *", "p_self"], - ["const char *", "p_utf8"] - ] - }, - { - "name": "godot_string_parse_utf8_with_len", - "return_type": "godot_bool", - "arguments": [ - ["godot_string *", "p_self"], - ["const char *", "p_utf8"], - ["godot_int", "p_len"] - ] - }, - { - "name": "godot_string_utf16", - "return_type": "godot_char16_string", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_parse_utf16", - "return_type": "godot_bool", - "arguments": [ - ["godot_string *", "p_self"], - ["const char16_t *", "p_utf16"] - ] - }, - { - "name": "godot_string_parse_utf16_with_len", - "return_type": "godot_bool", - "arguments": [ - ["godot_string *", "p_self"], - ["const char16_t *", "p_utf16"], - ["godot_int", "p_len"] - ] - }, - { - "name": "godot_string_hash", - "return_type": "uint32_t", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_hash64", - "return_type": "uint64_t", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_hash_chars", - "return_type": "uint32_t", - "arguments": [ - ["const char *", "p_cstr"] - ] - }, - { - "name": "godot_string_hash_chars_with_len", - "return_type": "uint32_t", - "arguments": [ - ["const char *", "p_cstr"], - ["godot_int", "p_len"] - ] - }, - { - "name": "godot_string_hash_wide_chars", - "return_type": "uint32_t", - "arguments": [ - ["const wchar_t *", "p_str"] - ] - }, - { - "name": "godot_string_hash_wide_chars_with_len", - "return_type": "uint32_t", - "arguments": [ - ["const wchar_t *", "p_str"], - ["godot_int", "p_len"] - ] - }, - { - "name": "godot_string_md5_buffer", - "return_type": "godot_packed_byte_array", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_md5_text", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_sha1_buffer", - "return_type": "godot_packed_byte_array", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_sha1_text", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_sha256_buffer", - "return_type": "godot_packed_byte_array", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_sha256_text", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_empty", - "return_type": "godot_bool", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_get_base_dir", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_get_file", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_humanize_size", - "return_type": "godot_string", - "arguments": [ - ["size_t", "p_size"] - ] - }, - { - "name": "godot_string_is_abs_path", - "return_type": "godot_bool", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_is_rel_path", - "return_type": "godot_bool", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_is_resource_file", - "return_type": "godot_bool", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_path_to", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_string *", "p_path"] - ] - }, - { - "name": "godot_string_path_to_file", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_string *", "p_path"] - ] - }, - { - "name": "godot_string_simplify_path", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_c_escape", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_c_escape_multiline", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_c_unescape", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_http_escape", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_http_unescape", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_json_escape", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_xml_escape", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_xml_escape_with_quotes", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_xml_unescape", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_percent_decode", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_percent_encode", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_join", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_packed_string_array *", "p_parts"] - ] - }, - { - "name": "godot_string_is_valid_filename", - "return_type": "godot_bool", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_is_valid_float", - "return_type": "godot_bool", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_is_valid_hex_number", - "return_type": "godot_bool", - "arguments": [ - ["const godot_string *", "p_self"], - ["godot_bool", "p_with_prefix"] - ] - }, - { - "name": "godot_string_is_valid_html_color", - "return_type": "godot_bool", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_is_valid_identifier", - "return_type": "godot_bool", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_is_valid_integer", - "return_type": "godot_bool", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_is_valid_ip_address", - "return_type": "godot_bool", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_destroy", - "return_type": "void", - "arguments": [ - ["godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_name_new", - "return_type": "void", - "arguments": [ - ["godot_string_name *", "r_dest"], - ["const godot_string *", "p_name"] - ] - }, - { - "name": "godot_string_name_new_data", - "return_type": "void", - "arguments": [ - ["godot_string_name *", "r_dest"], - ["const char *", "p_name"] - ] - }, - { - "name": "godot_string_name_get_name", - "return_type": "godot_string", - "arguments": [ - ["const godot_string_name *", "p_self"] - ] - }, - { - "name": "godot_string_name_get_hash", - "return_type": "uint32_t", - "arguments": [ - ["const godot_string_name *", "p_self"] - ] - }, - { - "name": "godot_string_name_get_data_unique_pointer", - "return_type": "const void *", - "arguments": [ - ["const godot_string_name *", "p_self"] - ] - }, - { - "name": "godot_string_name_operator_equal", - "return_type": "godot_bool", - "arguments": [ - ["const godot_string_name *", "p_self"], - ["const godot_string_name *", "p_other"] - ] - }, - { - "name": "godot_string_name_operator_less", - "return_type": "godot_bool", - "arguments": [ - ["const godot_string_name *", "p_self"], - ["const godot_string_name *", "p_other"] - ] - }, - { - "name": "godot_string_name_destroy", - "return_type": "void", - "arguments": [ - ["godot_string_name *", "p_self"] - ] - }, - { - "name": "godot_transform_new_with_axis_origin", - "return_type": "void", - "arguments": [ - ["godot_transform *", "r_dest"], - ["const godot_vector3 *", "p_x_axis"], - ["const godot_vector3 *", "p_y_axis"], - ["const godot_vector3 *", "p_z_axis"], - ["const godot_vector3 *", "p_origin"] - ] - }, - { - "name": "godot_transform_new_with_quat", - "return_type": "void", - "arguments": [ - ["godot_transform *", "r_dest"], - ["const godot_quat *", "p_quat"] - ] - }, - { - "name": "godot_transform_new", - "return_type": "void", - "arguments": [ - ["godot_transform *", "r_dest"], - ["const godot_basis *", "p_basis"], - ["const godot_vector3 *", "p_origin"] - ] - }, - { - "name": "godot_transform_get_basis", - "return_type": "godot_basis", - "arguments": [ - ["const godot_transform *", "p_self"] - ] - }, - { - "name": "godot_transform_set_basis", - "return_type": "void", - "arguments": [ - ["godot_transform *", "p_self"], - ["const godot_basis *", "p_v"] - ] - }, - { - "name": "godot_transform_get_origin", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_transform *", "p_self"] - ] - }, - { - "name": "godot_transform_set_origin", - "return_type": "void", - "arguments": [ - ["godot_transform *", "p_self"], - ["const godot_vector3 *", "p_v"] - ] - }, - { - "name": "godot_transform_as_string", - "return_type": "godot_string", - "arguments": [ - ["const godot_transform *", "p_self"] - ] - }, - { - "name": "godot_transform_inverse", - "return_type": "godot_transform", - "arguments": [ - ["const godot_transform *", "p_self"] - ] - }, - { - "name": "godot_transform_affine_inverse", - "return_type": "godot_transform", - "arguments": [ - ["const godot_transform *", "p_self"] - ] - }, - { - "name": "godot_transform_orthonormalized", - "return_type": "godot_transform", - "arguments": [ - ["const godot_transform *", "p_self"] - ] - }, - { - "name": "godot_transform_rotated", - "return_type": "godot_transform", - "arguments": [ - ["const godot_transform *", "p_self"], - ["const godot_vector3 *", "p_axis"], - ["const godot_real", "p_phi"] - ] - }, - { - "name": "godot_transform_scaled", - "return_type": "godot_transform", - "arguments": [ - ["const godot_transform *", "p_self"], - ["const godot_vector3 *", "p_scale"] - ] - }, - { - "name": "godot_transform_translated", - "return_type": "godot_transform", - "arguments": [ - ["const godot_transform *", "p_self"], - ["const godot_vector3 *", "p_ofs"] - ] - }, - { - "name": "godot_transform_looking_at", - "return_type": "godot_transform", - "arguments": [ - ["const godot_transform *", "p_self"], - ["const godot_vector3 *", "p_target"], - ["const godot_vector3 *", "p_up"] - ] - }, - { - "name": "godot_transform_xform_plane", - "return_type": "godot_plane", - "arguments": [ - ["const godot_transform *", "p_self"], - ["const godot_plane *", "p_v"] - ] - }, - { - "name": "godot_transform_xform_inv_plane", - "return_type": "godot_plane", - "arguments": [ - ["const godot_transform *", "p_self"], - ["const godot_plane *", "p_v"] - ] - }, - { - "name": "godot_transform_new_identity", - "return_type": "void", - "arguments": [ - ["godot_transform *", "r_dest"] - ] - }, - { - "name": "godot_transform_operator_equal", - "return_type": "godot_bool", - "arguments": [ - ["const godot_transform *", "p_self"], - ["const godot_transform *", "p_b"] - ] - }, - { - "name": "godot_transform_operator_multiply", - "return_type": "godot_transform", - "arguments": [ - ["const godot_transform *", "p_self"], - ["const godot_transform *", "p_b"] - ] - }, - { - "name": "godot_transform_xform_vector3", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_transform *", "p_self"], - ["const godot_vector3 *", "p_v"] - ] - }, - { - "name": "godot_transform_xform_inv_vector3", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_transform *", "p_self"], - ["const godot_vector3 *", "p_v"] - ] - }, - { - "name": "godot_transform_xform_aabb", - "return_type": "godot_aabb", - "arguments": [ - ["const godot_transform *", "p_self"], - ["const godot_aabb *", "p_v"] - ] - }, - { - "name": "godot_transform_xform_inv_aabb", - "return_type": "godot_aabb", - "arguments": [ - ["const godot_transform *", "p_self"], - ["const godot_aabb *", "p_v"] - ] - }, - { - "name": "godot_transform2d_new", - "return_type": "void", - "arguments": [ - ["godot_transform2d *", "r_dest"], - ["const godot_real", "p_rot"], - ["const godot_vector2 *", "p_pos"] - ] - }, - { - "name": "godot_transform2d_new_axis_origin", - "return_type": "void", - "arguments": [ - ["godot_transform2d *", "r_dest"], - ["const godot_vector2 *", "p_x_axis"], - ["const godot_vector2 *", "p_y_axis"], - ["const godot_vector2 *", "p_origin"] - ] - }, - { - "name": "godot_transform2d_as_string", - "return_type": "godot_string", - "arguments": [ - ["const godot_transform2d *", "p_self"] - ] - }, - { - "name": "godot_transform2d_inverse", - "return_type": "godot_transform2d", - "arguments": [ - ["const godot_transform2d *", "p_self"] - ] - }, - { - "name": "godot_transform2d_affine_inverse", - "return_type": "godot_transform2d", - "arguments": [ - ["const godot_transform2d *", "p_self"] - ] - }, - { - "name": "godot_transform2d_get_rotation", - "return_type": "godot_real", - "arguments": [ - ["const godot_transform2d *", "p_self"] - ] - }, - { - "name": "godot_transform2d_get_origin", - "return_type": "godot_vector2", - "arguments": [ - ["const godot_transform2d *", "p_self"] - ] - }, - { - "name": "godot_transform2d_get_scale", - "return_type": "godot_vector2", - "arguments": [ - ["const godot_transform2d *", "p_self"] - ] - }, - { - "name": "godot_transform2d_orthonormalized", - "return_type": "godot_transform2d", - "arguments": [ - ["const godot_transform2d *", "p_self"] - ] - }, - { - "name": "godot_transform2d_rotated", - "return_type": "godot_transform2d", - "arguments": [ - ["const godot_transform2d *", "p_self"], - ["const godot_real", "p_phi"] - ] - }, - { - "name": "godot_transform2d_scaled", - "return_type": "godot_transform2d", - "arguments": [ - ["const godot_transform2d *", "p_self"], - ["const godot_vector2 *", "p_scale"] - ] - }, - { - "name": "godot_transform2d_translated", - "return_type": "godot_transform2d", - "arguments": [ - ["const godot_transform2d *", "p_self"], - ["const godot_vector2 *", "p_offset"] - ] - }, - { - "name": "godot_transform2d_xform_vector2", - "return_type": "godot_vector2", - "arguments": [ - ["const godot_transform2d *", "p_self"], - ["const godot_vector2 *", "p_v"] - ] - }, - { - "name": "godot_transform2d_xform_inv_vector2", - "return_type": "godot_vector2", - "arguments": [ - ["const godot_transform2d *", "p_self"], - ["const godot_vector2 *", "p_v"] - ] - }, - { - "name": "godot_transform2d_basis_xform_vector2", - "return_type": "godot_vector2", - "arguments": [ - ["const godot_transform2d *", "p_self"], - ["const godot_vector2 *", "p_v"] - ] - }, - { - "name": "godot_transform2d_basis_xform_inv_vector2", - "return_type": "godot_vector2", - "arguments": [ - ["const godot_transform2d *", "p_self"], - ["const godot_vector2 *", "p_v"] - ] - }, - { - "name": "godot_transform2d_interpolate_with", - "return_type": "godot_transform2d", - "arguments": [ - ["const godot_transform2d *", "p_self"], - ["const godot_transform2d *", "p_m"], - ["const godot_real", "p_c"] - ] - }, - { - "name": "godot_transform2d_operator_equal", - "return_type": "godot_bool", - "arguments": [ - ["const godot_transform2d *", "p_self"], - ["const godot_transform2d *", "p_b"] - ] - }, - { - "name": "godot_transform2d_operator_multiply", - "return_type": "godot_transform2d", - "arguments": [ - ["const godot_transform2d *", "p_self"], - ["const godot_transform2d *", "p_b"] - ] - }, - { - "name": "godot_transform2d_new_identity", - "return_type": "void", - "arguments": [ - ["godot_transform2d *", "r_dest"] - ] - }, - { - "name": "godot_transform2d_xform_rect2", - "return_type": "godot_rect2", - "arguments": [ - ["const godot_transform2d *", "p_self"], - ["const godot_rect2 *", "p_v"] - ] - }, - { - "name": "godot_transform2d_xform_inv_rect2", - "return_type": "godot_rect2", - "arguments": [ - ["const godot_transform2d *", "p_self"], - ["const godot_rect2 *", "p_v"] - ] - }, - { - "name": "godot_variant_get_type", - "return_type": "godot_variant_type", - "arguments": [ - ["const godot_variant *", "p_v"] - ] - }, - { - "name": "godot_variant_new_copy", - "return_type": "void", - "arguments": [ - ["godot_variant *", "r_dest"], - ["const godot_variant *", "p_src"] - ] - }, - { - "name": "godot_variant_new_nil", - "return_type": "void", - "arguments": [ - ["godot_variant *", "r_dest"] - ] - }, - { - "name": "godot_variant_new_bool", - "return_type": "void", - "arguments": [ - ["godot_variant *", "r_dest"], - ["const godot_bool", "p_b"] - ] - }, - { - "name": "godot_variant_new_uint", - "return_type": "void", - "arguments": [ - ["godot_variant *", "r_dest"], - ["const uint64_t", "p_i"] - ] - }, - { - "name": "godot_variant_new_int", - "return_type": "void", - "arguments": [ - ["godot_variant *", "r_dest"], - ["const int64_t", "p_i"] - ] - }, - { - "name": "godot_variant_new_real", - "return_type": "void", - "arguments": [ - ["godot_variant *", "r_dest"], - ["const double", "p_r"] - ] - }, - { - "name": "godot_variant_new_string", - "return_type": "void", - "arguments": [ - ["godot_variant *", "r_dest"], - ["const godot_string *", "p_s"] - ] - }, - { - "name": "godot_variant_new_string_name", - "return_type": "void", - "arguments": [ - ["godot_variant *", "r_dest"], - ["const godot_string_name *", "p_s"] - ] - }, - { - "name": "godot_variant_new_vector2", - "return_type": "void", - "arguments": [ - ["godot_variant *", "r_dest"], - ["const godot_vector2 *", "p_v2"] - ] - }, - { - "name": "godot_variant_new_vector2i", - "return_type": "void", - "arguments": [ - ["godot_variant *", "r_dest"], - ["const godot_vector2i *", "p_v2"] - ] - }, - { - "name": "godot_variant_new_rect2", - "return_type": "void", - "arguments": [ - ["godot_variant *", "r_dest"], - ["const godot_rect2 *", "p_rect2"] - ] - }, - { - "name": "godot_variant_new_rect2i", - "return_type": "void", - "arguments": [ - ["godot_variant *", "r_dest"], - ["const godot_rect2i *", "p_rect2"] - ] - }, - { - "name": "godot_variant_new_vector3", - "return_type": "void", - "arguments": [ - ["godot_variant *", "r_dest"], - ["const godot_vector3 *", "p_v3"] - ] - }, - { - "name": "godot_variant_new_vector3i", - "return_type": "void", - "arguments": [ - ["godot_variant *", "r_dest"], - ["const godot_vector3i *", "p_v3"] - ] - }, - { - "name": "godot_variant_new_transform2d", - "return_type": "void", - "arguments": [ - ["godot_variant *", "r_dest"], - ["const godot_transform2d *", "p_t2d"] - ] - }, - { - "name": "godot_variant_new_plane", - "return_type": "void", - "arguments": [ - ["godot_variant *", "r_dest"], - ["const godot_plane *", "p_plane"] - ] - }, - { - "name": "godot_variant_new_quat", - "return_type": "void", - "arguments": [ - ["godot_variant *", "r_dest"], - ["const godot_quat *", "p_quat"] - ] - }, - { - "name": "godot_variant_new_aabb", - "return_type": "void", - "arguments": [ - ["godot_variant *", "r_dest"], - ["const godot_aabb *", "p_aabb"] - ] - }, - { - "name": "godot_variant_new_basis", - "return_type": "void", - "arguments": [ - ["godot_variant *", "r_dest"], - ["const godot_basis *", "p_basis"] - ] - }, - { - "name": "godot_variant_new_transform", - "return_type": "void", - "arguments": [ - ["godot_variant *", "r_dest"], - ["const godot_transform *", "p_trans"] - ] - }, - { - "name": "godot_variant_new_color", - "return_type": "void", - "arguments": [ - ["godot_variant *", "r_dest"], - ["const godot_color *", "p_color"] - ] - }, - { - "name": "godot_variant_new_node_path", - "return_type": "void", - "arguments": [ - ["godot_variant *", "r_dest"], - ["const godot_node_path *", "p_np"] - ] - }, - { - "name": "godot_variant_new_rid", - "return_type": "void", - "arguments": [ - ["godot_variant *", "r_dest"], - ["const godot_rid *", "p_rid"] - ] - }, - { - "name": "godot_variant_new_object", - "return_type": "void", - "arguments": [ - ["godot_variant *", "r_dest"], - ["const godot_object *", "p_obj"] - ] - }, - { - "name": "godot_variant_new_callable", - "return_type": "void", - "arguments": [ - ["godot_variant *", "r_dest"], - ["const godot_callable *", "p_cb"] - ] - }, - { - "name": "godot_variant_new_signal", - "return_type": "void", - "arguments": [ - ["godot_variant *", "r_dest"], - ["const godot_signal *", "p_signal"] - ] - }, - { - "name": "godot_variant_new_dictionary", - "return_type": "void", - "arguments": [ - ["godot_variant *", "r_dest"], - ["const godot_dictionary *", "p_dict"] - ] - }, - { - "name": "godot_variant_new_array", - "return_type": "void", - "arguments": [ - ["godot_variant *", "r_dest"], - ["const godot_array *", "p_arr"] - ] - }, - { - "name": "godot_variant_new_packed_byte_array", - "return_type": "void", - "arguments": [ - ["godot_variant *", "r_dest"], - ["const godot_packed_byte_array *", "p_pba"] - ] - }, - { - "name": "godot_variant_new_packed_int32_array", - "return_type": "void", - "arguments": [ - ["godot_variant *", "r_dest"], - ["const godot_packed_int32_array *", "p_pia"] - ] - }, - { - "name": "godot_variant_new_packed_int64_array", - "return_type": "void", - "arguments": [ - ["godot_variant *", "r_dest"], - ["const godot_packed_int64_array *", "p_pia"] - ] - }, - { - "name": "godot_variant_new_packed_float32_array", - "return_type": "void", - "arguments": [ - ["godot_variant *", "r_dest"], - ["const godot_packed_float32_array *", "p_pra"] - ] - }, - { - "name": "godot_variant_new_packed_float64_array", - "return_type": "void", - "arguments": [ - ["godot_variant *", "r_dest"], - ["const godot_packed_float64_array *", "p_pra"] - ] - }, - { - "name": "godot_variant_new_packed_string_array", - "return_type": "void", - "arguments": [ - ["godot_variant *", "r_dest"], - ["const godot_packed_string_array *", "p_psa"] - ] - }, - { - "name": "godot_variant_new_packed_vector2_array", - "return_type": "void", - "arguments": [ - ["godot_variant *", "r_dest"], - ["const godot_packed_vector2_array *", "p_pv2a"] - ] - }, - { - "name": "godot_variant_new_packed_vector3_array", - "return_type": "void", - "arguments": [ - ["godot_variant *", "r_dest"], - ["const godot_packed_vector3_array *", "p_pv3a"] - ] - }, - { - "name": "godot_variant_new_packed_color_array", - "return_type": "void", - "arguments": [ - ["godot_variant *", "r_dest"], - ["const godot_packed_color_array *", "p_pca"] - ] - }, - { - "name": "godot_variant_as_bool", - "return_type": "godot_bool", - "arguments": [ - ["const godot_variant *", "p_self"] - ] - }, - { - "name": "godot_variant_as_uint", - "return_type": "uint64_t", - "arguments": [ - ["const godot_variant *", "p_self"] - ] - }, - { - "name": "godot_variant_as_int", - "return_type": "int64_t", - "arguments": [ - ["const godot_variant *", "p_self"] - ] - }, - { - "name": "godot_variant_as_real", - "return_type": "double", - "arguments": [ - ["const godot_variant *", "p_self"] - ] - }, - { - "name": "godot_variant_as_string", - "return_type": "godot_string", - "arguments": [ - ["const godot_variant *", "p_self"] - ] - }, - { - "name": "godot_variant_as_string_name", - "return_type": "godot_string_name", - "arguments": [ - ["const godot_variant *", "p_self"] - ] - }, - { - "name": "godot_variant_as_vector2", - "return_type": "godot_vector2", - "arguments": [ - ["const godot_variant *", "p_self"] - ] - }, - { - "name": "godot_variant_as_vector2i", - "return_type": "godot_vector2i", - "arguments": [ - ["const godot_variant *", "p_self"] - ] - }, - { - "name": "godot_variant_as_rect2", - "return_type": "godot_rect2", - "arguments": [ - ["const godot_variant *", "p_self"] - ] - }, - { - "name": "godot_variant_as_rect2i", - "return_type": "godot_rect2i", - "arguments": [ - ["const godot_variant *", "p_self"] - ] - }, - { - "name": "godot_variant_as_vector3", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_variant *", "p_self"] - ] - }, - { - "name": "godot_variant_as_vector3i", - "return_type": "godot_vector3i", - "arguments": [ - ["const godot_variant *", "p_self"] - ] - }, - { - "name": "godot_variant_as_transform2d", - "return_type": "godot_transform2d", - "arguments": [ - ["const godot_variant *", "p_self"] - ] - }, - { - "name": "godot_variant_as_plane", - "return_type": "godot_plane", - "arguments": [ - ["const godot_variant *", "p_self"] - ] - }, - { - "name": "godot_variant_as_quat", - "return_type": "godot_quat", - "arguments": [ - ["const godot_variant *", "p_self"] - ] - }, - { - "name": "godot_variant_as_aabb", - "return_type": "godot_aabb", - "arguments": [ - ["const godot_variant *", "p_self"] - ] - }, - { - "name": "godot_variant_as_basis", - "return_type": "godot_basis", - "arguments": [ - ["const godot_variant *", "p_self"] - ] - }, - { - "name": "godot_variant_as_transform", - "return_type": "godot_transform", - "arguments": [ - ["const godot_variant *", "p_self"] - ] - }, - { - "name": "godot_variant_as_color", - "return_type": "godot_color", - "arguments": [ - ["const godot_variant *", "p_self"] - ] - }, - { - "name": "godot_variant_as_node_path", - "return_type": "godot_node_path", - "arguments": [ - ["const godot_variant *", "p_self"] - ] - }, - { - "name": "godot_variant_as_rid", - "return_type": "godot_rid", - "arguments": [ - ["const godot_variant *", "p_self"] - ] - }, - { - "name": "godot_variant_as_object", - "return_type": "godot_object *", - "arguments": [ - ["const godot_variant *", "p_self"] - ] - }, - { - "name": "godot_variant_as_callable", - "return_type": "godot_callable", - "arguments": [ - ["const godot_variant *", "p_self"] - ] - }, - { - "name": "godot_variant_as_signal", - "return_type": "godot_signal", - "arguments": [ - ["const godot_variant *", "p_self"] - ] - }, - { - "name": "godot_variant_as_dictionary", - "return_type": "godot_dictionary", - "arguments": [ - ["const godot_variant *", "p_self"] - ] - }, - { - "name": "godot_variant_as_array", - "return_type": "godot_array", - "arguments": [ - ["const godot_variant *", "p_self"] - ] - }, - { - "name": "godot_variant_as_packed_byte_array", - "return_type": "godot_packed_byte_array", - "arguments": [ - ["const godot_variant *", "p_self"] - ] - }, - { - "name": "godot_variant_as_packed_int32_array", - "return_type": "godot_packed_int32_array", - "arguments": [ - ["const godot_variant *", "p_self"] - ] - }, - { - "name": "godot_variant_as_packed_int64_array", - "return_type": "godot_packed_int64_array", - "arguments": [ - ["const godot_variant *", "p_self"] - ] - }, - { - "name": "godot_variant_as_packed_float32_array", - "return_type": "godot_packed_float32_array", - "arguments": [ - ["const godot_variant *", "p_self"] - ] - }, - { - "name": "godot_variant_as_packed_float64_array", - "return_type": "godot_packed_float64_array", - "arguments": [ - ["const godot_variant *", "p_self"] - ] - }, - { - "name": "godot_variant_as_packed_string_array", - "return_type": "godot_packed_string_array", - "arguments": [ - ["const godot_variant *", "p_self"] - ] - }, - { - "name": "godot_variant_as_packed_vector2_array", - "return_type": "godot_packed_vector2_array", - "arguments": [ - ["const godot_variant *", "p_self"] - ] - }, - { - "name": "godot_variant_as_packed_vector3_array", - "return_type": "godot_packed_vector3_array", - "arguments": [ - ["const godot_variant *", "p_self"] - ] - }, - { - "name": "godot_variant_as_packed_color_array", - "return_type": "godot_packed_color_array", - "arguments": [ - ["const godot_variant *", "p_self"] - ] - }, - { - "name": "godot_variant_call", - "return_type": "godot_variant", - "arguments": [ - ["godot_variant *", "p_self"], - ["const godot_string *", "p_method"], - ["const godot_variant **", "p_args"], - ["const godot_int", "p_argcount"], - ["godot_variant_call_error *", "r_error"] - ] - }, - { - "name": "godot_variant_has_method", - "return_type": "godot_bool", - "arguments": [ - ["const godot_variant *", "p_self"], - ["const godot_string *", "p_method"] - ] - }, - { - "name": "godot_variant_hash", - "return_type": "uint32_t", - "arguments": [ - ["const godot_variant *", "p_self"] - ] - }, - { - "name": "godot_variant_operator_equal", - "return_type": "godot_bool", - "arguments": [ - ["const godot_variant *", "p_self"], - ["const godot_variant *", "p_other"] - ] - }, - { - "name": "godot_variant_operator_less", - "return_type": "godot_bool", - "arguments": [ - ["const godot_variant *", "p_self"], - ["const godot_variant *", "p_other"] - ] - }, - { - "name": "godot_variant_get_operator_name", - "return_type": "godot_string", - "arguments": [ - ["godot_variant_operator", "p_op"] - ] - }, - { - "name": "godot_variant_evaluate", - "return_type": "void", - "arguments": [ - ["godot_variant_operator", "p_op"], - ["const godot_variant *", "p_a"], - ["const godot_variant *", "p_b"], - ["godot_variant *", "r_ret"], - ["godot_bool *", "r_valid"] - ] - }, - { - "name": "godot_variant_hash_compare", - "return_type": "godot_bool", - "arguments": [ - ["const godot_variant *", "p_self"], - ["const godot_variant *", "p_other"] - ] - }, - { - "name": "godot_variant_booleanize", - "return_type": "godot_bool", - "arguments": [ - ["const godot_variant *", "p_self"] - ] - }, - { - "name": "godot_variant_destroy", - "return_type": "void", - "arguments": [ - ["godot_variant *", "p_self"] - ] - }, - { - "name": "godot_vector2_as_vector2i", - "return_type": "godot_vector2i", - "arguments": [ - ["const godot_vector2 *", "p_self"] - ] - }, - { - "name": "godot_vector2_sign", - "return_type": "godot_vector2", - "arguments": [ - ["const godot_vector2 *", "p_self"] - ] - }, - { - "name": "godot_vector2_move_toward", - "return_type": "godot_vector2", - "arguments": [ - ["const godot_vector2 *", "p_self"], - ["const godot_vector2 *", "p_to"], - ["const godot_real", "p_delta"] - ] - }, - { - "name": "godot_vector2_direction_to", - "return_type": "godot_vector2", - "arguments": [ - ["const godot_vector2 *", "p_self"], - ["const godot_vector2 *", "p_to"] - ] - }, - { - "name": "godot_vector2_new", - "return_type": "void", - "arguments": [ - ["godot_vector2 *", "r_dest"], - ["const godot_real", "p_x"], - ["const godot_real", "p_y"] - ] - }, - { - "name": "godot_vector2_as_string", - "return_type": "godot_string", - "arguments": [ - ["const godot_vector2 *", "p_self"] - ] - }, - { - "name": "godot_vector2_normalized", - "return_type": "godot_vector2", - "arguments": [ - ["const godot_vector2 *", "p_self"] - ] - }, - { - "name": "godot_vector2_length", - "return_type": "godot_real", - "arguments": [ - ["const godot_vector2 *", "p_self"] - ] - }, - { - "name": "godot_vector2_angle", - "return_type": "godot_real", - "arguments": [ - ["const godot_vector2 *", "p_self"] - ] - }, - { - "name": "godot_vector2_length_squared", - "return_type": "godot_real", - "arguments": [ - ["const godot_vector2 *", "p_self"] - ] - }, - { - "name": "godot_vector2_is_normalized", - "return_type": "godot_bool", - "arguments": [ - ["const godot_vector2 *", "p_self"] - ] - }, - { - "name": "godot_vector2_distance_to", - "return_type": "godot_real", - "arguments": [ - ["const godot_vector2 *", "p_self"], - ["const godot_vector2 *", "p_to"] - ] - }, - { - "name": "godot_vector2_distance_squared_to", - "return_type": "godot_real", - "arguments": [ - ["const godot_vector2 *", "p_self"], - ["const godot_vector2 *", "p_to"] - ] - }, - { - "name": "godot_vector2_angle_to", - "return_type": "godot_real", - "arguments": [ - ["const godot_vector2 *", "p_self"], - ["const godot_vector2 *", "p_to"] - ] - }, - { - "name": "godot_vector2_angle_to_point", - "return_type": "godot_real", - "arguments": [ - ["const godot_vector2 *", "p_self"], - ["const godot_vector2 *", "p_to"] - ] - }, - { - "name": "godot_vector2_lerp", - "return_type": "godot_vector2", - "arguments": [ - ["const godot_vector2 *", "p_self"], - ["const godot_vector2 *", "p_b"], - ["const godot_real", "p_t"] - ] - }, - { - "name": "godot_vector2_cubic_interpolate", - "return_type": "godot_vector2", - "arguments": [ - ["const godot_vector2 *", "p_self"], - ["const godot_vector2 *", "p_b"], - ["const godot_vector2 *", "p_pre_a"], - ["const godot_vector2 *", "p_post_b"], - ["const godot_real", "p_t"] - ] - }, - { - "name": "godot_vector2_rotated", - "return_type": "godot_vector2", - "arguments": [ - ["const godot_vector2 *", "p_self"], - ["const godot_real", "p_phi"] - ] - }, - { - "name": "godot_vector2_tangent", - "return_type": "godot_vector2", - "arguments": [ - ["const godot_vector2 *", "p_self"] - ] - }, - { - "name": "godot_vector2_floor", - "return_type": "godot_vector2", - "arguments": [ - ["const godot_vector2 *", "p_self"] - ] - }, - { - "name": "godot_vector2_snapped", - "return_type": "godot_vector2", - "arguments": [ - ["const godot_vector2 *", "p_self"], - ["const godot_vector2 *", "p_by"] - ] - }, - { - "name": "godot_vector2_aspect", - "return_type": "godot_real", - "arguments": [ - ["const godot_vector2 *", "p_self"] - ] - }, - { - "name": "godot_vector2_dot", - "return_type": "godot_real", - "arguments": [ - ["const godot_vector2 *", "p_self"], - ["const godot_vector2 *", "p_with"] - ] - }, - { - "name": "godot_vector2_slide", - "return_type": "godot_vector2", - "arguments": [ - ["const godot_vector2 *", "p_self"], - ["const godot_vector2 *", "p_n"] - ] - }, - { - "name": "godot_vector2_bounce", - "return_type": "godot_vector2", - "arguments": [ - ["const godot_vector2 *", "p_self"], - ["const godot_vector2 *", "p_n"] - ] - }, - { - "name": "godot_vector2_reflect", - "return_type": "godot_vector2", - "arguments": [ - ["const godot_vector2 *", "p_self"], - ["const godot_vector2 *", "p_n"] - ] - }, - { - "name": "godot_vector2_abs", - "return_type": "godot_vector2", - "arguments": [ - ["const godot_vector2 *", "p_self"] - ] - }, - { - "name": "godot_vector2_clamped", - "return_type": "godot_vector2", - "arguments": [ - ["const godot_vector2 *", "p_self"], - ["const godot_real", "p_length"] - ] - }, - { - "name": "godot_vector2_operator_add", - "return_type": "godot_vector2", - "arguments": [ - ["const godot_vector2 *", "p_self"], - ["const godot_vector2 *", "p_b"] - ] - }, - { - "name": "godot_vector2_operator_subtract", - "return_type": "godot_vector2", - "arguments": [ - ["const godot_vector2 *", "p_self"], - ["const godot_vector2 *", "p_b"] - ] - }, - { - "name": "godot_vector2_operator_multiply_vector", - "return_type": "godot_vector2", - "arguments": [ - ["const godot_vector2 *", "p_self"], - ["const godot_vector2 *", "p_b"] - ] - }, - { - "name": "godot_vector2_operator_multiply_scalar", - "return_type": "godot_vector2", - "arguments": [ - ["const godot_vector2 *", "p_self"], - ["const godot_real", "p_b"] - ] - }, - { - "name": "godot_vector2_operator_divide_vector", - "return_type": "godot_vector2", - "arguments": [ - ["const godot_vector2 *", "p_self"], - ["const godot_vector2 *", "p_b"] - ] - }, - { - "name": "godot_vector2_operator_divide_scalar", - "return_type": "godot_vector2", - "arguments": [ - ["const godot_vector2 *", "p_self"], - ["const godot_real", "p_b"] - ] - }, - { - "name": "godot_vector2_operator_equal", - "return_type": "godot_bool", - "arguments": [ - ["const godot_vector2 *", "p_self"], - ["const godot_vector2 *", "p_b"] - ] - }, - { - "name": "godot_vector2_operator_less", - "return_type": "godot_bool", - "arguments": [ - ["const godot_vector2 *", "p_self"], - ["const godot_vector2 *", "p_b"] - ] - }, - { - "name": "godot_vector2_operator_neg", - "return_type": "godot_vector2", - "arguments": [ - ["const godot_vector2 *", "p_self"] - ] - }, - { - "name": "godot_vector2_set_x", - "return_type": "void", - "arguments": [ - ["godot_vector2 *", "p_self"], - ["const godot_real", "p_x"] - ] - }, - { - "name": "godot_vector2_set_y", - "return_type": "void", - "arguments": [ - ["godot_vector2 *", "p_self"], - ["const godot_real", "p_y"] - ] - }, - { - "name": "godot_vector2_get_x", - "return_type": "godot_real", - "arguments": [ - ["const godot_vector2 *", "p_self"] - ] - }, - { - "name": "godot_vector2_get_y", - "return_type": "godot_real", - "arguments": [ - ["const godot_vector2 *", "p_self"] - ] - }, - { - "name": "godot_vector2i_new", - "return_type": "void", - "arguments": [ - ["godot_vector2i *", "r_dest"], - ["const godot_int", "p_x"], - ["const godot_int", "p_y"] - ] - }, - { - "name": "godot_vector2i_as_string", - "return_type": "godot_string", - "arguments": [ - ["const godot_vector2i *", "p_self"] - ] - }, - { - "name": "godot_vector2i_as_vector2", - "return_type": "godot_vector2", - "arguments": [ - ["const godot_vector2i *", "p_self"] - ] - }, - { - "name": "godot_vector2i_aspect", - "return_type": "godot_real", - "arguments": [ - ["const godot_vector2i *", "p_self"] - ] - }, - { - "name": "godot_vector2i_abs", - "return_type": "godot_vector2i", - "arguments": [ - ["const godot_vector2i *", "p_self"] - ] - }, - { - "name": "godot_vector2i_sign", - "return_type": "godot_vector2i", - "arguments": [ - ["const godot_vector2i *", "p_self"] - ] - }, - { - "name": "godot_vector2i_operator_add", - "return_type": "godot_vector2i", - "arguments": [ - ["const godot_vector2i *", "p_self"], - ["const godot_vector2i *", "p_b"] - ] - }, - { - "name": "godot_vector2i_operator_subtract", - "return_type": "godot_vector2i", - "arguments": [ - ["const godot_vector2i *", "p_self"], - ["const godot_vector2i *", "p_b"] - ] - }, - { - "name": "godot_vector2i_operator_multiply_vector", - "return_type": "godot_vector2i", - "arguments": [ - ["const godot_vector2i *", "p_self"], - ["const godot_vector2i *", "p_b"] - ] - }, - { - "name": "godot_vector2i_operator_multiply_scalar", - "return_type": "godot_vector2i", - "arguments": [ - ["const godot_vector2i *", "p_self"], - ["const godot_int", "p_b"] - ] - }, - { - "name": "godot_vector2i_operator_divide_vector", - "return_type": "godot_vector2i", - "arguments": [ - ["const godot_vector2i *", "p_self"], - ["const godot_vector2i *", "p_b"] - ] - }, - { - "name": "godot_vector2i_operator_divide_scalar", - "return_type": "godot_vector2i", - "arguments": [ - ["const godot_vector2i *", "p_self"], - ["const godot_int", "p_b"] - ] - }, - { - "name": "godot_vector2i_operator_equal", - "return_type": "godot_bool", - "arguments": [ - ["const godot_vector2i *", "p_self"], - ["const godot_vector2i *", "p_b"] - ] - }, - { - "name": "godot_vector2i_operator_less", - "return_type": "godot_bool", - "arguments": [ - ["const godot_vector2i *", "p_self"], - ["const godot_vector2i *", "p_b"] - ] - }, - { - "name": "godot_vector2i_operator_neg", - "return_type": "godot_vector2i", - "arguments": [ - ["const godot_vector2i *", "p_self"] - ] - }, - { - "name": "godot_vector2i_set_x", - "return_type": "void", - "arguments": [ - ["godot_vector2i *", "p_self"], - ["const godot_int", "p_x"] - ] - }, - { - "name": "godot_vector2i_set_y", - "return_type": "void", - "arguments": [ - ["godot_vector2i *", "p_self"], - ["const godot_int", "p_y"] - ] - }, - { - "name": "godot_vector2i_get_x", - "return_type": "godot_int", - "arguments": [ - ["const godot_vector2i *", "p_self"] - ] - }, - { - "name": "godot_vector2i_get_y", - "return_type": "godot_int", - "arguments": [ - ["const godot_vector2i *", "p_self"] - ] - }, - { - "name": "godot_vector3_as_vector3i", - "return_type": "godot_vector3i", - "arguments": [ - ["const godot_vector3 *", "p_self"] - ] - }, - { - "name": "godot_vector3_sign", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_vector3 *", "p_self"] - ] - }, - { - "name": "godot_vector3_move_toward", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_vector3 *", "p_self"], - ["const godot_vector3 *", "p_to"], - ["const godot_real", "p_delta"] - ] - }, - { - "name": "godot_vector3_direction_to", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_vector3 *", "p_self"], - ["const godot_vector3 *", "p_to"] - ] - }, - { - "name": "godot_vector3_new", - "return_type": "void", - "arguments": [ - ["godot_vector3 *", "r_dest"], - ["const godot_real", "p_x"], - ["const godot_real", "p_y"], - ["const godot_real", "p_z"] - ] - }, - { - "name": "godot_vector3_as_string", - "return_type": "godot_string", - "arguments": [ - ["const godot_vector3 *", "p_self"] - ] - }, - { - "name": "godot_vector3_min_axis", - "return_type": "godot_int", - "arguments": [ - ["const godot_vector3 *", "p_self"] - ] - }, - { - "name": "godot_vector3_max_axis", - "return_type": "godot_int", - "arguments": [ - ["const godot_vector3 *", "p_self"] - ] - }, - { - "name": "godot_vector3_length", - "return_type": "godot_real", - "arguments": [ - ["const godot_vector3 *", "p_self"] - ] - }, - { - "name": "godot_vector3_length_squared", - "return_type": "godot_real", - "arguments": [ - ["const godot_vector3 *", "p_self"] - ] - }, - { - "name": "godot_vector3_is_normalized", - "return_type": "godot_bool", - "arguments": [ - ["const godot_vector3 *", "p_self"] - ] - }, - { - "name": "godot_vector3_normalized", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_vector3 *", "p_self"] - ] - }, - { - "name": "godot_vector3_inverse", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_vector3 *", "p_self"] - ] - }, - { - "name": "godot_vector3_snapped", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_vector3 *", "p_self"], - ["const godot_vector3 *", "p_by"] - ] - }, - { - "name": "godot_vector3_rotated", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_vector3 *", "p_self"], - ["const godot_vector3 *", "p_axis"], - ["const godot_real", "p_phi"] - ] - }, - { - "name": "godot_vector3_lerp", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_vector3 *", "p_self"], - ["const godot_vector3 *", "p_b"], - ["const godot_real", "p_t"] - ] - }, - { - "name": "godot_vector3_cubic_interpolate", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_vector3 *", "p_self"], - ["const godot_vector3 *", "p_b"], - ["const godot_vector3 *", "p_pre_a"], - ["const godot_vector3 *", "p_post_b"], - ["const godot_real", "p_t"] - ] - }, - { - "name": "godot_vector3_dot", - "return_type": "godot_real", - "arguments": [ - ["const godot_vector3 *", "p_self"], - ["const godot_vector3 *", "p_b"] - ] - }, - { - "name": "godot_vector3_cross", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_vector3 *", "p_self"], - ["const godot_vector3 *", "p_b"] - ] - }, - { - "name": "godot_vector3_outer", - "return_type": "godot_basis", - "arguments": [ - ["const godot_vector3 *", "p_self"], - ["const godot_vector3 *", "p_b"] - ] - }, - { - "name": "godot_vector3_to_diagonal_matrix", - "return_type": "godot_basis", - "arguments": [ - ["const godot_vector3 *", "p_self"] - ] - }, - { - "name": "godot_vector3_abs", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_vector3 *", "p_self"] - ] - }, - { - "name": "godot_vector3_floor", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_vector3 *", "p_self"] - ] - }, - { - "name": "godot_vector3_ceil", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_vector3 *", "p_self"] - ] - }, - { - "name": "godot_vector3_distance_to", - "return_type": "godot_real", - "arguments": [ - ["const godot_vector3 *", "p_self"], - ["const godot_vector3 *", "p_b"] - ] - }, - { - "name": "godot_vector3_distance_squared_to", - "return_type": "godot_real", - "arguments": [ - ["const godot_vector3 *", "p_self"], - ["const godot_vector3 *", "p_b"] - ] - }, - { - "name": "godot_vector3_angle_to", - "return_type": "godot_real", - "arguments": [ - ["const godot_vector3 *", "p_self"], - ["const godot_vector3 *", "p_to"] - ] - }, - { - "name": "godot_vector3_slide", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_vector3 *", "p_self"], - ["const godot_vector3 *", "p_n"] - ] - }, - { - "name": "godot_vector3_bounce", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_vector3 *", "p_self"], - ["const godot_vector3 *", "p_n"] - ] - }, - { - "name": "godot_vector3_reflect", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_vector3 *", "p_self"], - ["const godot_vector3 *", "p_n"] - ] - }, - { - "name": "godot_vector3_operator_add", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_vector3 *", "p_self"], - ["const godot_vector3 *", "p_b"] - ] - }, - { - "name": "godot_vector3_operator_subtract", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_vector3 *", "p_self"], - ["const godot_vector3 *", "p_b"] - ] - }, - { - "name": "godot_vector3_operator_multiply_vector", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_vector3 *", "p_self"], - ["const godot_vector3 *", "p_b"] - ] - }, - { - "name": "godot_vector3_operator_multiply_scalar", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_vector3 *", "p_self"], - ["const godot_real", "p_b"] - ] - }, - { - "name": "godot_vector3_operator_divide_vector", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_vector3 *", "p_self"], - ["const godot_vector3 *", "p_b"] - ] - }, - { - "name": "godot_vector3_operator_divide_scalar", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_vector3 *", "p_self"], - ["const godot_real", "p_b"] - ] - }, - { - "name": "godot_vector3_operator_equal", - "return_type": "godot_bool", - "arguments": [ - ["const godot_vector3 *", "p_self"], - ["const godot_vector3 *", "p_b"] - ] - }, - { - "name": "godot_vector3_operator_less", - "return_type": "godot_bool", - "arguments": [ - ["const godot_vector3 *", "p_self"], - ["const godot_vector3 *", "p_b"] - ] - }, - { - "name": "godot_vector3_operator_neg", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_vector3 *", "p_self"] - ] - }, - { - "name": "godot_vector3_set_axis", - "return_type": "void", - "arguments": [ - ["godot_vector3 *", "p_self"], - ["const godot_vector3_axis", "p_axis"], - ["const godot_real", "p_val"] - ] - }, - { - "name": "godot_vector3_get_axis", - "return_type": "godot_real", - "arguments": [ - ["const godot_vector3 *", "p_self"], - ["const godot_vector3_axis", "p_axis"] - ] - }, - { - "name": "godot_vector3i_new", - "return_type": "void", - "arguments": [ - ["godot_vector3i *", "r_dest"], - ["const godot_int", "p_x"], - ["const godot_int", "p_y"], - ["const godot_int", "p_z"] - ] - }, - { - "name": "godot_vector3i_as_string", - "return_type": "godot_string", - "arguments": [ - ["const godot_vector3i *", "p_self"] - ] - }, - { - "name": "godot_vector3i_as_vector3", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_vector3i *", "p_self"] - ] - }, - { - "name": "godot_vector3i_min_axis", - "return_type": "godot_int", - "arguments": [ - ["const godot_vector3i *", "p_self"] - ] - }, - { - "name": "godot_vector3i_max_axis", - "return_type": "godot_int", - "arguments": [ - ["const godot_vector3i *", "p_self"] - ] - }, - { - "name": "godot_vector3i_abs", - "return_type": "godot_vector3i", - "arguments": [ - ["const godot_vector3i *", "p_self"] - ] - }, - { - "name": "godot_vector3i_sign", - "return_type": "godot_vector3i", - "arguments": [ - ["const godot_vector3i *", "p_self"] - ] - }, - { - "name": "godot_vector3i_operator_add", - "return_type": "godot_vector3i", - "arguments": [ - ["const godot_vector3i *", "p_self"], - ["const godot_vector3i *", "p_b"] - ] - }, - { - "name": "godot_vector3i_operator_subtract", - "return_type": "godot_vector3i", - "arguments": [ - ["const godot_vector3i *", "p_self"], - ["const godot_vector3i *", "p_b"] - ] - }, - { - "name": "godot_vector3i_operator_multiply_vector", - "return_type": "godot_vector3i", - "arguments": [ - ["const godot_vector3i *", "p_self"], - ["const godot_vector3i *", "p_b"] - ] - }, - { - "name": "godot_vector3i_operator_multiply_scalar", - "return_type": "godot_vector3i", - "arguments": [ - ["const godot_vector3i *", "p_self"], - ["const godot_int", "p_b"] - ] - }, - { - "name": "godot_vector3i_operator_divide_vector", - "return_type": "godot_vector3i", - "arguments": [ - ["const godot_vector3i *", "p_self"], - ["const godot_vector3i *", "p_b"] - ] - }, - { - "name": "godot_vector3i_operator_divide_scalar", - "return_type": "godot_vector3i", - "arguments": [ - ["const godot_vector3i *", "p_self"], - ["const godot_int", "p_b"] - ] - }, - { - "name": "godot_vector3i_operator_equal", - "return_type": "godot_bool", - "arguments": [ - ["const godot_vector3i *", "p_self"], - ["const godot_vector3i *", "p_b"] - ] - }, - { - "name": "godot_vector3i_operator_less", - "return_type": "godot_bool", - "arguments": [ - ["const godot_vector3i *", "p_self"], - ["const godot_vector3i *", "p_b"] - ] - }, - { - "name": "godot_vector3i_operator_neg", - "return_type": "godot_vector3i", - "arguments": [ - ["const godot_vector3i *", "p_self"] - ] - }, - { - "name": "godot_vector3i_set_axis", - "return_type": "void", - "arguments": [ - ["godot_vector3i *", "p_self"], - ["const godot_vector3_axis", "p_axis"], - ["const godot_int", "p_val"] - ] - }, - { - "name": "godot_vector3i_get_axis", - "return_type": "godot_int", - "arguments": [ - ["const godot_vector3i *", "p_self"], - ["const godot_vector3_axis", "p_axis"] - ] - }, - { - "name": "godot_global_get_singleton", - "return_type": "godot_object *", - "arguments": [ - ["char *", "p_name"] - ] - }, - { - "name": "godot_get_class_tag", - "return_type": "void *", - "arguments": [ - ["const godot_string_name *", "p_class"] - ] - }, - { - "name": "godot_object_cast_to", - "return_type": "godot_object *", - "arguments": [ - ["const godot_object *", "p_object"], - ["void *", "p_class_tag"] - ] - }, - { - "name": "godot_object_get_instance_id", - "return_type": "uint64_t", - "arguments": [ - ["const godot_object *", "p_object"] - ] - }, - { - "name": "godot_instance_from_id", - "return_type": "godot_object *", - "arguments": [ - ["uint64_t", "p_instance_id"] - ] - }, - { - "name": "godot_object_destroy", - "return_type": "void", - "arguments": [ - ["godot_object *", "p_o"] - ] - }, - { - "name": "godot_method_bind_get_method", - "return_type": "godot_method_bind *", - "arguments": [ - ["const char *", "p_classname"], - ["const char *", "p_methodname"] - ] - }, - { - "name": "godot_method_bind_ptrcall", - "return_type": "void", - "arguments": [ - ["godot_method_bind *", "p_method_bind"], - ["godot_object *", "p_instance"], - ["const void **", "p_args"], - ["void *", "p_ret"] - ] - }, - { - "name": "godot_method_bind_call", - "return_type": "godot_variant", - "arguments": [ - ["godot_method_bind *", "p_method_bind"], - ["godot_object *", "p_instance"], - ["const godot_variant **", "p_args"], - ["const int", "p_arg_count"], - ["godot_variant_call_error *", "p_call_error"] - ] - }, - { - "name": "godot_get_class_constructor", - "return_type": "godot_class_constructor", - "arguments": [ - ["const char *", "p_classname"] - ] - }, - { - "name": "godot_get_global_constants", - "return_type": "godot_dictionary", - "arguments": [ - ] - }, - { - "name": "godot_register_native_call_type", - "return_type": "void", - "arguments": [ - ["const char *", "call_type"], - ["native_call_cb", "p_callback"] - ] - }, - { - "name": "godot_alloc", - "return_type": "void *", - "arguments": [ - ["int", "p_bytes"] - ] - }, - { - "name": "godot_realloc", - "return_type": "void *", - "arguments": [ - ["void *", "p_ptr"], - ["int", "p_bytes"] - ] - }, - { - "name": "godot_free", - "return_type": "void", - "arguments": [ - ["void *", "p_ptr"] - ] - }, - { - "name": "godot_print_error", - "return_type": "void", - "arguments": [ - ["const char *", "p_description"], - ["const char *", "p_function"], - ["const char *", "p_file"], - ["int", "p_line"] - ] - }, - { - "name": "godot_print_warning", - "return_type": "void", - "arguments": [ - ["const char *", "p_description"], - ["const char *", "p_function"], - ["const char *", "p_file"], - ["int", "p_line"] - ] - }, - { - "name": "godot_print", - "return_type": "void", - "arguments": [ - ["const godot_string *", "p_message"] - ] - } - ] - }, - "extensions": [ - { - "name": "nativescript", - "type": "NATIVESCRIPT", - "version": { - "major": 4, - "minor": 0 - }, - "next": null, - "api": [ - { - "name": "godot_nativescript_register_class", - "return_type": "void", - "arguments": [ - ["void *", "p_gdnative_handle"], - ["const char *", "p_name"], - ["const char *", "p_base"], - ["godot_nativescript_instance_create_func", "p_create_func"], - ["godot_nativescript_instance_destroy_func", "p_destroy_func"] - ] - }, - { - "name": "godot_nativescript_register_tool_class", - "return_type": "void", - "arguments": [ - ["void *", "p_gdnative_handle"], - ["const char *", "p_name"], - ["const char *", "p_base"], - ["godot_nativescript_instance_create_func", "p_create_func"], - ["godot_nativescript_instance_destroy_func", "p_destroy_func"] - ] - }, - { - "name": "godot_nativescript_register_method", - "return_type": "void", - "arguments": [ - ["void *", "p_gdnative_handle"], - ["const char *", "p_name"], - ["const char *", "p_function_name"], - ["godot_nativescript_method_attributes", "p_attr"], - ["godot_nativescript_instance_method", "p_method"] - ] - }, - { - "name": "godot_nativescript_set_method_argument_information", - "return_type": "void", - "arguments": [ - ["void *", "p_gdnative_handle"], - ["const char *", "p_name"], - ["const char *", "p_function_name"], - ["int", "p_num_args"], - ["const godot_nativescript_method_argument *", "p_args"] - ] - }, - { - "name": "godot_nativescript_register_property", - "return_type": "void", - "arguments": [ - ["void *", "p_gdnative_handle"], - ["const char *", "p_name"], - ["const char *", "p_path"], - ["godot_nativescript_property_attributes *", "p_attr"], - ["godot_nativescript_property_set_func", "p_set_func"], - ["godot_nativescript_property_get_func", "p_get_func"] - ] - }, - { - "name": "godot_nativescript_register_signal", - "return_type": "void", - "arguments": [ - ["void *", "p_gdnative_handle"], - ["const char *", "p_name"], - ["const godot_nativescript_signal *", "p_signal"] - ] - }, - { - "name": "godot_nativescript_get_userdata", - "return_type": "void *", - "arguments": [ - ["godot_object *", "p_instance"] - ] - }, - { - "name": "godot_nativescript_set_class_documentation", - "return_type": "void", - "arguments": [ - ["void *", "p_gdnative_handle"], - ["const char *", "p_name"], - ["godot_string", "p_documentation"] - ] - }, - { - "name": "godot_nativescript_set_method_documentation", - "return_type": "void", - "arguments": [ - ["void *", "p_gdnative_handle"], - ["const char *", "p_name"], - ["const char *", "p_function_name"], - ["godot_string", "p_documentation"] - ] - }, - { - "name": "godot_nativescript_set_property_documentation", - "return_type": "void", - "arguments": [ - ["void *", "p_gdnative_handle"], - ["const char *", "p_name"], - ["const char *", "p_path"], - ["godot_string", "p_documentation"] - ] - }, - { - "name": "godot_nativescript_set_signal_documentation", - "return_type": "void", - "arguments": [ - ["void *", "p_gdnative_handle"], - ["const char *", "p_name"], - ["const char *", "p_signal_name"], - ["godot_string", "p_documentation"] - ] - }, - { - "name": "godot_nativescript_set_global_type_tag", - "return_type": "void", - "arguments": [ - ["int", "p_idx"], - ["const char *", "p_name"], - ["const void *", "p_type_tag"] - ] - }, - { - "name": "godot_nativescript_get_global_type_tag", - "return_type": "const void *", - "arguments": [ - ["int", "p_idx"], - ["const char *", "p_name"] - ] - }, - { - "name": "godot_nativescript_set_type_tag", - "return_type": "void", - "arguments": [ - ["void *", "p_gdnative_handle"], - ["const char *", "p_name"], - ["const void *", "p_type_tag"] - ] - }, - { - "name": "godot_nativescript_get_type_tag", - "return_type": "const void *", - "arguments": [ - ["const godot_object *", "p_object"] - ] - }, - { - "name": "godot_nativescript_register_instance_binding_data_functions", - "return_type": "int", - "arguments": [ - ["godot_nativescript_instance_binding_functions", "p_binding_functions"] - ] - }, - { - "name": "godot_nativescript_unregister_instance_binding_data_functions", - "return_type": "void", - "arguments": [ - ["int", "p_idx"] - ] - }, - { - "name": "godot_nativescript_get_instance_binding_data", - "return_type": "void *", - "arguments": [ - ["int", "p_idx"], - ["godot_object *", "p_object"] - ] - }, - { - "name": "godot_nativescript_profiling_add_data", - "return_type": "void", - "arguments": [ - ["const char *", "p_signature"], - ["uint64_t", "p_line"] - ] - } - ] - }, - { - "name": "pluginscript", - "type": "PLUGINSCRIPT", - "version": { - "major": 1, - "minor": 0 - }, - "next": null, - "api": [ - { - "name": "godot_pluginscript_register_language", - "return_type": "void", - "arguments": [ - ["const godot_pluginscript_language_desc *", "language_desc"] - ] - } - ] - }, - { - "name": "android", - "type": "ANDROID", - "version": { - "major": 1, - "minor": 1 - }, - "next": null, - "api": [ - { - "name": "godot_android_get_env", - "return_type": "JNIEnv*", - "arguments": [ - ] - }, - { - "name": "godot_android_get_activity", - "return_type": "jobject", - "arguments": [ - ] - }, - { - "name": "godot_android_get_surface", - "return_type": "jobject", - "arguments": [ - ] - }, - { - "name": "godot_android_is_activity_resumed", - "return_type": "bool", - "arguments": [ - ] - } - ] - }, - { - "name": "xr", - "type": "XR", - "version": { - "major": 1, - "minor": 1 - }, - "next": null, - "api": [ - { - "name": "godot_xr_register_interface", - "return_type": "void", - "arguments": [ - ["const godot_xr_interface_gdnative *", "p_interface"] - ] - }, - { - "name": "godot_xr_get_worldscale", - "return_type": "godot_real", - "arguments": [] - }, - { - "name": "godot_xr_get_reference_frame", - "return_type": "godot_transform", - "arguments": [] - }, - { - "name": "godot_xr_blit", - "return_type": "void", - "arguments": [ - ["godot_int", "p_eye"], - ["godot_rid *", "p_render_target"], - ["godot_rect2 *", "p_screen_rect"] - ] - }, - { - "name": "godot_xr_get_texid", - "return_type": "godot_int", - "arguments": [ - ["godot_rid *", "p_render_target"] - ] - }, - { - "name": "godot_xr_add_controller", - "return_type": "godot_int", - "arguments": [ - ["char *", "p_device_name"], - ["godot_int", "p_hand"], - ["godot_bool", "p_tracks_orientation"], - ["godot_bool", "p_tracks_position"] - ] - }, - { - "name": "godot_xr_remove_controller", - "return_type": "void", - "arguments": [ - ["godot_int", "p_controller_id"] - ] - }, - { - "name": "godot_xr_set_controller_transform", - "return_type": "void", - "arguments": [ - ["godot_int", "p_controller_id"], - ["godot_transform *", "p_transform"], - ["godot_bool", "p_tracks_orientation"], - ["godot_bool", "p_tracks_position"] - ] - }, - { - "name": "godot_xr_set_controller_button", - "return_type": "void", - "arguments": [ - ["godot_int", "p_controller_id"], - ["godot_int", "p_button"], - ["godot_bool", "p_is_pressed"] - ] - }, - { - "name": "godot_xr_set_controller_axis", - "return_type": "void", - "arguments": [ - ["godot_int", "p_controller_id"], - ["godot_int", "p_exis"], - ["godot_real", "p_value"], - ["godot_bool", "p_can_be_negative"] - ] - }, - { - "name": "godot_xr_get_controller_rumble", - "return_type": "godot_real", - "arguments": [ - ["godot_int", "p_controller_id"] - ] - } - ] - }, - { - "name": "videodecoder", - "type": "VIDEODECODER", - "version": { - "major": 0, - "minor": 1 - }, - "next": null, - "api": [ - { - "name": "godot_videodecoder_file_read", - "return_type": "godot_int", - "arguments": [ - ["void *", "file_ptr"], - ["uint8_t *", "buf"], - ["int", "buf_size"] - ] - }, - { - "name": "godot_videodecoder_file_seek", - "return_type": "int64_t", - "arguments": [ - [ "void *", "file_ptr"], - ["int64_t", "pos"], - ["int", "whence"] - ] - }, - { - "name": "godot_videodecoder_register_decoder", - "return_type": "void", - "arguments": [ - ["const godot_videodecoder_interface_gdnative *", "p_interface"] - ] - } - ] - }, - { - "name": "net", - "type": "NET", - "version": { - "major": 4, - "minor": 0 - }, - "next": null, - "api": [ - { - "name": "godot_net_bind_stream_peer", - "return_type": "void", - "arguments": [ - ["godot_object *", "p_obj"], - ["const godot_net_stream_peer *", "p_interface"] - ] - }, - { - "name": "godot_net_bind_packet_peer", - "return_type": "void", - "arguments": [ - ["godot_object *", "p_obj"], - ["const godot_net_packet_peer *", "p_interface"] - ] - }, - { - "name": "godot_net_bind_multiplayer_peer", - "return_type": "void", - "arguments": [ - ["godot_object *", "p_obj"], - ["const godot_net_multiplayer_peer *", "p_interface"] - ] - }, - { - "name": "godot_net_set_webrtc_library", - "return_type": "godot_error", - "arguments": [ - ["const godot_net_webrtc_library *", "p_library"] - ] - }, - { - "name": "godot_net_bind_webrtc_peer_connection", - "return_type": "void", - "arguments": [ - ["godot_object *", "p_obj"], - ["const godot_net_webrtc_peer_connection *", "p_interface"] - ] - }, - { - "name": "godot_net_bind_webrtc_data_channel", - "return_type": "void", - "arguments": [ - ["godot_object *", "p_obj"], - ["const godot_net_webrtc_data_channel *", "p_interface"] - ] - } - ] - }, - { - "name": "text", - "type": "TEXT", - "version": { - "major": 1, - "minor": 0 - }, - "next": null, - "api": [ - { - "name": "godot_text_register_interface", - "return_type": "void", - "arguments": [ - ["const godot_text_interface_gdnative *", "p_interface"], - ["const godot_string *", "p_name"], - ["uint32_t", "p_features"] - ] - }, - { - "name": "godot_glyph_new", - "return_type": "void", - "arguments": [ - ["godot_glyph *", "r_dest"] - ] - }, - { - "name": "godot_glyph_get_range", - "return_type": "godot_vector2i", - "arguments": [ - ["const godot_glyph *", "p_self"] - ] - }, - { - "name": "godot_glyph_set_range", - "return_type": "void", - "arguments": [ - ["godot_glyph *", "p_self"], - ["const godot_vector2i *", "p_range"] - ] - }, - { - "name": "godot_glyph_get_count", - "return_type": "godot_int", - "arguments": [ - ["const godot_glyph *", "p_self"] - ] - }, - { - "name": "godot_glyph_set_count", - "return_type": "void", - "arguments": [ - ["godot_glyph *", "p_self"], - ["godot_int", "p_count"] - ] - }, - { - "name": "godot_glyph_get_repeat", - "return_type": "godot_int", - "arguments": [ - ["const godot_glyph *", "p_self"] - ] - }, - { - "name": "godot_glyph_set_repeat", - "return_type": "void", - "arguments": [ - ["godot_glyph *", "p_self"], - ["godot_int", "p_repeat"] - ] - }, - { - "name": "godot_glyph_get_flags", - "return_type": "godot_int", - "arguments": [ - ["const godot_glyph *", "p_self"] - ] - }, - { - "name": "godot_glyph_set_flags", - "return_type": "void", - "arguments": [ - ["godot_glyph *", "p_self"], - ["godot_int", "p_flags"] - ] - }, - { - "name": "godot_glyph_get_offset", - "return_type": "godot_vector2", - "arguments": [ - ["const godot_glyph *", "p_self"] - ] - }, - { - "name": "godot_glyph_set_offset", - "return_type": "void", - "arguments": [ - ["godot_glyph *", "p_self"], - ["const godot_vector2 *", "p_offset"] - ] - }, - { - "name": "godot_glyph_get_advance", - "return_type": "godot_real", - "arguments": [ - ["const godot_glyph *", "p_self"] - ] - }, - { - "name": "godot_glyph_set_advance", - "return_type": "void", - "arguments": [ - ["godot_glyph *", "p_self"], - ["godot_real", "p_advance"] - ] - }, - { - "name": "godot_glyph_get_font", - "return_type": "godot_rid", - "arguments": [ - ["const godot_glyph *", "p_self"] - ] - }, - { - "name": "godot_glyph_set_font", - "return_type": "void ", - "arguments": [ - ["godot_glyph *", "p_self"], - ["godot_rid *", "p_font"] - ] - }, - { - "name": "godot_glyph_get_font_size", - "return_type": "godot_int", - "arguments": [ - ["const godot_glyph *", "p_self"] - ] - }, - { - "name": "godot_glyph_set_font_size", - "return_type": "void", - "arguments": [ - ["godot_glyph *", "p_self"], - ["godot_int", "p_size"] - ] - }, - { - "name": "godot_glyph_get_index", - "return_type": "godot_int", - "arguments": [ - ["const godot_glyph *", "p_self"] - ] - }, - { - "name": "godot_glyph_set_index", - "return_type": "void", - "arguments": [ - ["godot_glyph *", "p_self"], - ["godot_int", "p_index"] - ] - }, - { - "name": "godot_packed_glyph_array_new", - "return_type": "void", - "arguments": [ - ["godot_packed_glyph_array *", "r_dest"] - ] - }, - { - "name": "godot_packed_glyph_array_new_copy", - "return_type": "void", - "arguments": [ - ["godot_packed_glyph_array *", "r_dest"], - ["const godot_packed_glyph_array *", "p_src"] - ] - }, - { - "name": "godot_packed_glyph_array_empty", - "return_type": "godot_bool", - "arguments": [ - ["const godot_packed_glyph_array *", "p_self"] - ] - }, - { - "name": "godot_packed_glyph_array_append", - "return_type": "void", - "arguments": [ - ["godot_packed_glyph_array *", "p_self"], - ["const godot_glyph *", "p_data"] - ] - }, - { - "name": "godot_packed_glyph_array_append_array", - "return_type": "void", - "arguments": [ - ["godot_packed_glyph_array *", "p_self"], - ["const godot_packed_glyph_array *", "p_array"] - ] - }, - { - "name": "godot_packed_glyph_array_insert", - "return_type": "godot_error", - "arguments": [ - ["godot_packed_glyph_array *", "p_self"], - ["const godot_int", "p_idx"], - ["const godot_glyph *", "p_data"] - ] - }, - { - "name": "godot_packed_glyph_array_has", - "return_type": "godot_bool", - "arguments": [ - ["godot_packed_glyph_array *", "p_self"], - ["const godot_glyph *", "p_value"] - ] - }, - { - "name": "godot_packed_glyph_array_sort", - "return_type": "void", - "arguments": [ - ["godot_packed_glyph_array *", "p_self"] - ] - }, - { - "name": "godot_packed_glyph_array_invert", - "return_type": "void", - "arguments": [ - ["godot_packed_glyph_array *", "p_self"] - ] - }, - { - "name": "godot_packed_glyph_array_push_back", - "return_type": "void", - "arguments": [ - ["godot_packed_glyph_array *", "p_self"], - ["const godot_glyph *", "p_data"] - ] - }, - { - "name": "godot_packed_glyph_array_remove", - "return_type": "void", - "arguments": [ - ["godot_packed_glyph_array *", "p_self"], - ["const godot_int", "p_idx"] - ] - }, - { - "name": "godot_packed_glyph_array_resize", - "return_type": "void", - "arguments": [ - ["godot_packed_glyph_array *", "p_self"], - ["const godot_int", "p_size"] - ] - }, - { - "name": "godot_packed_glyph_array_ptr", - "return_type": "const godot_glyph *", - "arguments": [ - ["const godot_packed_glyph_array *", "p_self"] - ] - }, - { - "name": "godot_packed_glyph_array_ptrw", - "return_type": "godot_glyph *", - "arguments": [ - ["godot_packed_glyph_array *", "p_self"] - ] - }, - { - "name": "godot_packed_glyph_array_set", - "return_type": "void", - "arguments": [ - ["godot_packed_glyph_array *", "p_self"], - ["const godot_int", "p_idx"], - ["const godot_glyph *", "p_data"] - ] - }, - { - "name": "godot_packed_glyph_array_get", - "return_type": "godot_glyph", - "arguments": [ - ["const godot_packed_glyph_array *", "p_self"], - ["const godot_int", "p_idx"] - ] - }, - { - "name": "godot_packed_glyph_array_size", - "return_type": "godot_int", - "arguments": [ - ["const godot_packed_glyph_array *", "p_self"] - ] - }, - { - "name": "godot_packed_glyph_array_destroy", - "return_type": "void", - "arguments": [ - ["godot_packed_glyph_array *", "p_self"] - ] - } - ] - } - ] + "core": { + "type": "CORE", + "version": { + "major": 4, + "minor": 0 + }, + "next": null, + "api": [ + { + "name": "godot_object_destroy", + "return_type": "void", + "arguments": [ + [ + "godot_object *", + "p_o" + ] + ] + }, + { + "name": "godot_global_get_singleton", + "return_type": "godot_object *", + "arguments": [ + [ + "char *", + "p_name" + ] + ] + }, + { + "name": "godot_method_bind_get_method", + "return_type": "godot_method_bind *", + "arguments": [ + [ + "const char *", + "p_classname" + ], + [ + "const char *", + "p_methodname" + ] + ] + }, + { + "name": "godot_method_bind_ptrcall", + "return_type": "void", + "arguments": [ + [ + "godot_method_bind *", + "p_method_bind" + ], + [ + "godot_object *", + "p_instance" + ], + [ + "const void **", + "p_args" + ], + [ + "void *", + "p_ret" + ] + ] + }, + { + "name": "godot_method_bind_call", + "return_type": "godot_variant", + "arguments": [ + [ + "godot_method_bind *", + "p_method_bind" + ], + [ + "godot_object *", + "p_instance" + ], + [ + "const godot_variant **", + "p_args" + ], + [ + "const int", + "p_arg_count" + ], + [ + "godot_variant_call_error *", + "p_call_error" + ] + ] + }, + { + "name": "godot_get_class_constructor", + "return_type": "godot_class_constructor", + "arguments": [ + [ + "const char *", + "p_classname" + ] + ] + }, + { + "name": "godot_get_global_constants", + "return_type": "godot_dictionary", + "arguments": [] + }, + { + "name": "godot_register_native_call_type", + "return_type": "void", + "arguments": [ + [ + "const char *", + "call_type" + ], + [ + "native_call_cb", + "p_callback" + ] + ] + }, + { + "name": "godot_alloc", + "return_type": "void *", + "arguments": [ + [ + "int", + "p_bytes" + ] + ] + }, + { + "name": "godot_realloc", + "return_type": "void *", + "arguments": [ + [ + "void *", + "p_ptr" + ], + [ + "int", + "p_bytes" + ] + ] + }, + { + "name": "godot_free", + "return_type": "void", + "arguments": [ + [ + "void *", + "p_ptr" + ] + ] + }, + { + "name": "godot_print_error", + "return_type": "void", + "arguments": [ + [ + "const char *", + "p_description" + ], + [ + "const char *", + "p_function" + ], + [ + "const char *", + "p_file" + ], + [ + "int", + "p_line" + ] + ] + }, + { + "name": "godot_print_warning", + "return_type": "void", + "arguments": [ + [ + "const char *", + "p_description" + ], + [ + "const char *", + "p_function" + ], + [ + "const char *", + "p_file" + ], + [ + "int", + "p_line" + ] + ] + }, + { + "name": "godot_print_script_error", + "return_type": "void", + "arguments": [ + [ + "const char *", + "p_description" + ], + [ + "const char *", + "p_function" + ], + [ + "const char *", + "p_file" + ], + [ + "int", + "p_line" + ] + ] + }, + { + "name": "godot_get_class_tag", + "return_type": "void *", + "arguments": [ + [ + "const godot_string_name *", + "p_class" + ] + ] + }, + { + "name": "godot_object_cast_to", + "return_type": "godot_object *", + "arguments": [ + [ + "const godot_object *", + "p_object" + ], + [ + "void *", + "p_class_tag" + ] + ] + }, + { + "name": "godot_instance_from_id", + "return_type": "godot_object *", + "arguments": [ + [ + "uint64_t", + "p_instance_id" + ] + ] + }, + { + "name": "godot_object_get_instance_id", + "return_type": "uint64_t", + "arguments": [ + [ + "const godot_object *", + "p_object" + ] + ] + }, + { + "name": "godot_variant_new_copy", + "return_type": "void", + "arguments": [ + [ + "godot_variant *", + "r_dest" + ], + [ + "const godot_variant *", + "p_src" + ] + ] + }, + { + "name": "godot_variant_new_nil", + "return_type": "void", + "arguments": [ + [ + "godot_variant *", + "r_dest" + ] + ] + }, + { + "name": "godot_variant_new_bool", + "return_type": "void", + "arguments": [ + [ + "godot_variant *", + "r_dest" + ], + [ + "const godot_bool", + "p_b" + ] + ] + }, + { + "name": "godot_variant_new_int", + "return_type": "void", + "arguments": [ + [ + "godot_variant *", + "r_dest" + ], + [ + "const int64_t", + "p_i" + ] + ] + }, + { + "name": "godot_variant_new_float", + "return_type": "void", + "arguments": [ + [ + "godot_variant *", + "r_dest" + ], + [ + "const double", + "p_f" + ] + ] + }, + { + "name": "godot_variant_new_string", + "return_type": "void", + "arguments": [ + [ + "godot_variant *", + "r_dest" + ], + [ + "const godot_string *", + "p_s" + ] + ] + }, + { + "name": "godot_variant_new_string_name", + "return_type": "void", + "arguments": [ + [ + "godot_variant *", + "r_dest" + ], + [ + "const godot_string_name *", + "p_s" + ] + ] + }, + { + "name": "godot_variant_new_vector2", + "return_type": "void", + "arguments": [ + [ + "godot_variant *", + "r_dest" + ], + [ + "const godot_vector2 *", + "p_v2" + ] + ] + }, + { + "name": "godot_variant_new_vector2i", + "return_type": "void", + "arguments": [ + [ + "godot_variant *", + "r_dest" + ], + [ + "const godot_vector2i *", + "p_v2" + ] + ] + }, + { + "name": "godot_variant_new_rect2", + "return_type": "void", + "arguments": [ + [ + "godot_variant *", + "r_dest" + ], + [ + "const godot_rect2 *", + "p_rect2" + ] + ] + }, + { + "name": "godot_variant_new_rect2i", + "return_type": "void", + "arguments": [ + [ + "godot_variant *", + "r_dest" + ], + [ + "const godot_rect2i *", + "p_rect2" + ] + ] + }, + { + "name": "godot_variant_new_vector3", + "return_type": "void", + "arguments": [ + [ + "godot_variant *", + "r_dest" + ], + [ + "const godot_vector3 *", + "p_v3" + ] + ] + }, + { + "name": "godot_variant_new_vector3i", + "return_type": "void", + "arguments": [ + [ + "godot_variant *", + "r_dest" + ], + [ + "const godot_vector3i *", + "p_v3" + ] + ] + }, + { + "name": "godot_variant_new_transform2d", + "return_type": "void", + "arguments": [ + [ + "godot_variant *", + "r_dest" + ], + [ + "const godot_transform2d *", + "p_t2d" + ] + ] + }, + { + "name": "godot_variant_new_plane", + "return_type": "void", + "arguments": [ + [ + "godot_variant *", + "r_dest" + ], + [ + "const godot_plane *", + "p_plane" + ] + ] + }, + { + "name": "godot_variant_new_quat", + "return_type": "void", + "arguments": [ + [ + "godot_variant *", + "r_dest" + ], + [ + "const godot_quat *", + "p_quat" + ] + ] + }, + { + "name": "godot_variant_new_aabb", + "return_type": "void", + "arguments": [ + [ + "godot_variant *", + "r_dest" + ], + [ + "const godot_aabb *", + "p_aabb" + ] + ] + }, + { + "name": "godot_variant_new_basis", + "return_type": "void", + "arguments": [ + [ + "godot_variant *", + "r_dest" + ], + [ + "const godot_basis *", + "p_basis" + ] + ] + }, + { + "name": "godot_variant_new_transform", + "return_type": "void", + "arguments": [ + [ + "godot_variant *", + "r_dest" + ], + [ + "const godot_transform *", + "p_trans" + ] + ] + }, + { + "name": "godot_variant_new_color", + "return_type": "void", + "arguments": [ + [ + "godot_variant *", + "r_dest" + ], + [ + "const godot_color *", + "p_color" + ] + ] + }, + { + "name": "godot_variant_new_node_path", + "return_type": "void", + "arguments": [ + [ + "godot_variant *", + "r_dest" + ], + [ + "const godot_node_path *", + "p_np" + ] + ] + }, + { + "name": "godot_variant_new_rid", + "return_type": "void", + "arguments": [ + [ + "godot_variant *", + "r_dest" + ], + [ + "const godot_rid *", + "p_rid" + ] + ] + }, + { + "name": "godot_variant_new_object", + "return_type": "void", + "arguments": [ + [ + "godot_variant *", + "r_dest" + ], + [ + "const godot_object *", + "p_obj" + ] + ] + }, + { + "name": "godot_variant_new_callable", + "return_type": "void", + "arguments": [ + [ + "godot_variant *", + "r_dest" + ], + [ + "const godot_callable *", + "p_cb" + ] + ] + }, + { + "name": "godot_variant_new_signal", + "return_type": "void", + "arguments": [ + [ + "godot_variant *", + "r_dest" + ], + [ + "const godot_signal *", + "p_signal" + ] + ] + }, + { + "name": "godot_variant_new_dictionary", + "return_type": "void", + "arguments": [ + [ + "godot_variant *", + "r_dest" + ], + [ + "const godot_dictionary *", + "p_dict" + ] + ] + }, + { + "name": "godot_variant_new_array", + "return_type": "void", + "arguments": [ + [ + "godot_variant *", + "r_dest" + ], + [ + "const godot_array *", + "p_arr" + ] + ] + }, + { + "name": "godot_variant_new_packed_byte_array", + "return_type": "void", + "arguments": [ + [ + "godot_variant *", + "r_dest" + ], + [ + "const godot_packed_byte_array *", + "p_pba" + ] + ] + }, + { + "name": "godot_variant_new_packed_int32_array", + "return_type": "void", + "arguments": [ + [ + "godot_variant *", + "r_dest" + ], + [ + "const godot_packed_int32_array *", + "p_pia" + ] + ] + }, + { + "name": "godot_variant_new_packed_int64_array", + "return_type": "void", + "arguments": [ + [ + "godot_variant *", + "r_dest" + ], + [ + "const godot_packed_int64_array *", + "p_pia" + ] + ] + }, + { + "name": "godot_variant_new_packed_float32_array", + "return_type": "void", + "arguments": [ + [ + "godot_variant *", + "r_dest" + ], + [ + "const godot_packed_float32_array *", + "p_pra" + ] + ] + }, + { + "name": "godot_variant_new_packed_float64_array", + "return_type": "void", + "arguments": [ + [ + "godot_variant *", + "r_dest" + ], + [ + "const godot_packed_float64_array *", + "p_pra" + ] + ] + }, + { + "name": "godot_variant_new_packed_string_array", + "return_type": "void", + "arguments": [ + [ + "godot_variant *", + "r_dest" + ], + [ + "const godot_packed_string_array *", + "p_psa" + ] + ] + }, + { + "name": "godot_variant_new_packed_vector2_array", + "return_type": "void", + "arguments": [ + [ + "godot_variant *", + "r_dest" + ], + [ + "const godot_packed_vector2_array *", + "p_pv2a" + ] + ] + }, + { + "name": "godot_variant_new_packed_vector3_array", + "return_type": "void", + "arguments": [ + [ + "godot_variant *", + "r_dest" + ], + [ + "const godot_packed_vector3_array *", + "p_pv3a" + ] + ] + }, + { + "name": "godot_variant_new_packed_color_array", + "return_type": "void", + "arguments": [ + [ + "godot_variant *", + "r_dest" + ], + [ + "const godot_packed_color_array *", + "p_pca" + ] + ] + }, + { + "name": "godot_variant_as_bool", + "return_type": "godot_bool", + "arguments": [ + [ + "const godot_variant *", + "p_self" + ] + ] + }, + { + "name": "godot_variant_as_int", + "return_type": "int64_t", + "arguments": [ + [ + "const godot_variant *", + "p_self" + ] + ] + }, + { + "name": "godot_variant_as_float", + "return_type": "double", + "arguments": [ + [ + "const godot_variant *", + "p_self" + ] + ] + }, + { + "name": "godot_variant_as_string", + "return_type": "godot_string", + "arguments": [ + [ + "const godot_variant *", + "p_self" + ] + ] + }, + { + "name": "godot_variant_as_string_name", + "return_type": "godot_string_name", + "arguments": [ + [ + "const godot_variant *", + "p_self" + ] + ] + }, + { + "name": "godot_variant_as_vector2", + "return_type": "godot_vector2", + "arguments": [ + [ + "const godot_variant *", + "p_self" + ] + ] + }, + { + "name": "godot_variant_as_vector2i", + "return_type": "godot_vector2i", + "arguments": [ + [ + "const godot_variant *", + "p_self" + ] + ] + }, + { + "name": "godot_variant_as_rect2", + "return_type": "godot_rect2", + "arguments": [ + [ + "const godot_variant *", + "p_self" + ] + ] + }, + { + "name": "godot_variant_as_rect2i", + "return_type": "godot_rect2i", + "arguments": [ + [ + "const godot_variant *", + "p_self" + ] + ] + }, + { + "name": "godot_variant_as_vector3", + "return_type": "godot_vector3", + "arguments": [ + [ + "const godot_variant *", + "p_self" + ] + ] + }, + { + "name": "godot_variant_as_vector3i", + "return_type": "godot_vector3i", + "arguments": [ + [ + "const godot_variant *", + "p_self" + ] + ] + }, + { + "name": "godot_variant_as_transform2d", + "return_type": "godot_transform2d", + "arguments": [ + [ + "const godot_variant *", + "p_self" + ] + ] + }, + { + "name": "godot_variant_as_plane", + "return_type": "godot_plane", + "arguments": [ + [ + "const godot_variant *", + "p_self" + ] + ] + }, + { + "name": "godot_variant_as_quat", + "return_type": "godot_quat", + "arguments": [ + [ + "const godot_variant *", + "p_self" + ] + ] + }, + { + "name": "godot_variant_as_aabb", + "return_type": "godot_aabb", + "arguments": [ + [ + "const godot_variant *", + "p_self" + ] + ] + }, + { + "name": "godot_variant_as_basis", + "return_type": "godot_basis", + "arguments": [ + [ + "const godot_variant *", + "p_self" + ] + ] + }, + { + "name": "godot_variant_as_transform", + "return_type": "godot_transform", + "arguments": [ + [ + "const godot_variant *", + "p_self" + ] + ] + }, + { + "name": "godot_variant_as_color", + "return_type": "godot_color", + "arguments": [ + [ + "const godot_variant *", + "p_self" + ] + ] + }, + { + "name": "godot_variant_as_node_path", + "return_type": "godot_node_path", + "arguments": [ + [ + "const godot_variant *", + "p_self" + ] + ] + }, + { + "name": "godot_variant_as_rid", + "return_type": "godot_rid", + "arguments": [ + [ + "const godot_variant *", + "p_self" + ] + ] + }, + { + "name": "godot_variant_as_object", + "return_type": "godot_object *", + "arguments": [ + [ + "const godot_variant *", + "p_self" + ] + ] + }, + { + "name": "godot_variant_as_callable", + "return_type": "godot_callable", + "arguments": [ + [ + "const godot_variant *", + "p_self" + ] + ] + }, + { + "name": "godot_variant_as_signal", + "return_type": "godot_signal", + "arguments": [ + [ + "const godot_variant *", + "p_self" + ] + ] + }, + { + "name": "godot_variant_as_dictionary", + "return_type": "godot_dictionary", + "arguments": [ + [ + "const godot_variant *", + "p_self" + ] + ] + }, + { + "name": "godot_variant_as_array", + "return_type": "godot_array", + "arguments": [ + [ + "const godot_variant *", + "p_self" + ] + ] + }, + { + "name": "godot_variant_as_packed_byte_array", + "return_type": "godot_packed_byte_array", + "arguments": [ + [ + "const godot_variant *", + "p_self" + ] + ] + }, + { + "name": "godot_variant_as_packed_int32_array", + "return_type": "godot_packed_int32_array", + "arguments": [ + [ + "const godot_variant *", + "p_self" + ] + ] + }, + { + "name": "godot_variant_as_packed_int64_array", + "return_type": "godot_packed_int64_array", + "arguments": [ + [ + "const godot_variant *", + "p_self" + ] + ] + }, + { + "name": "godot_variant_as_packed_float32_array", + "return_type": "godot_packed_float32_array", + "arguments": [ + [ + "const godot_variant *", + "p_self" + ] + ] + }, + { + "name": "godot_variant_as_packed_float64_array", + "return_type": "godot_packed_float64_array", + "arguments": [ + [ + "const godot_variant *", + "p_self" + ] + ] + }, + { + "name": "godot_variant_as_packed_string_array", + "return_type": "godot_packed_string_array", + "arguments": [ + [ + "const godot_variant *", + "p_self" + ] + ] + }, + { + "name": "godot_variant_as_packed_vector2_array", + "return_type": "godot_packed_vector2_array", + "arguments": [ + [ + "const godot_variant *", + "p_self" + ] + ] + }, + { + "name": "godot_variant_as_packed_vector3_array", + "return_type": "godot_packed_vector3_array", + "arguments": [ + [ + "const godot_variant *", + "p_self" + ] + ] + }, + { + "name": "godot_variant_as_packed_color_array", + "return_type": "godot_packed_color_array", + "arguments": [ + [ + "const godot_variant *", + "p_self" + ] + ] + }, + { + "name": "godot_variant_destroy", + "return_type": "void", + "arguments": [ + [ + "godot_variant *", + "p_self" + ] + ] + }, + { + "name": "godot_variant_call", + "return_type": "void", + "arguments": [ + [ + "godot_variant *", + "p_self" + ], + [ + "const godot_string_name *", + "p_method" + ], + [ + "const godot_variant **", + "p_args" + ], + [ + "const godot_int", + "p_argument_count" + ], + [ + "godot_variant *", + "r_return" + ], + [ + "godot_variant_call_error *", + "r_error" + ] + ] + }, + { + "name": "godot_variant_evaluate", + "return_type": "void", + "arguments": [ + [ + "godot_variant_operator", + "p_op" + ], + [ + "const godot_variant *", + "p_a" + ], + [ + "const godot_variant *", + "p_b" + ], + [ + "godot_variant *", + "r_return" + ], + [ + "bool *", + "r_valid" + ] + ] + }, + { + "name": "godot_variant_set", + "return_type": "void", + "arguments": [ + [ + "godot_variant *", + "p_self" + ], + [ + "const godot_variant *", + "p_key" + ], + [ + "const godot_variant *", + "p_value" + ], + [ + "bool *", + "r_valid" + ] + ] + }, + { + "name": "godot_variant_set_named", + "return_type": "void", + "arguments": [ + [ + "godot_variant *", + "p_self" + ], + [ + "const godot_string_name *", + "p_name" + ], + [ + "const godot_variant *", + "p_value" + ], + [ + "bool *", + "r_valid" + ] + ] + }, + { + "name": "godot_variant_set_keyed", + "return_type": "void", + "arguments": [ + [ + "godot_variant *", + "p_self" + ], + [ + "const godot_variant *", + "p_key" + ], + [ + "const godot_variant *", + "p_value" + ], + [ + "bool *", + "r_valid" + ] + ] + }, + { + "name": "godot_variant_set_indexed", + "return_type": "void", + "arguments": [ + [ + "godot_variant *", + "p_self" + ], + [ + "godot_int", + "p_index" + ], + [ + "const godot_variant *", + "p_value" + ], + [ + "bool *", + "r_valid" + ], + [ + "bool *", + "r_oob" + ] + ] + }, + { + "name": "godot_variant_get", + "return_type": "godot_variant", + "arguments": [ + [ + "const godot_variant *", + "p_self" + ], + [ + "const godot_variant *", + "p_key" + ], + [ + "bool *", + "r_valid" + ] + ] + }, + { + "name": "godot_variant_get_named", + "return_type": "godot_variant", + "arguments": [ + [ + "const godot_variant *", + "p_self" + ], + [ + "const godot_string_name *", + "p_key" + ], + [ + "bool *", + "r_valid" + ] + ] + }, + { + "name": "godot_variant_get_keyed", + "return_type": "godot_variant", + "arguments": [ + [ + "const godot_variant *", + "p_self" + ], + [ + "const godot_variant *", + "p_key" + ], + [ + "bool *", + "r_valid" + ] + ] + }, + { + "name": "godot_variant_get_indexed", + "return_type": "godot_variant", + "arguments": [ + [ + "const godot_variant *", + "p_self" + ], + [ + "godot_int", + "p_index" + ], + [ + "bool *", + "r_valid" + ], + [ + "bool *", + "r_oob" + ] + ] + }, + { + "name": "godot_variant_iter_init", + "return_type": "bool", + "arguments": [ + [ + "const godot_variant *", + "p_self" + ], + [ + "godot_variant *", + "r_iter" + ], + [ + "bool *", + "r_valid" + ] + ] + }, + { + "name": "godot_variant_iter_next", + "return_type": "bool", + "arguments": [ + [ + "const godot_variant *", + "p_self" + ], + [ + "godot_variant *", + "r_iter" + ], + [ + "bool *", + "r_valid" + ] + ] + }, + { + "name": "godot_variant_iter_get", + "return_type": "godot_variant", + "arguments": [ + [ + "const godot_variant *", + "p_self" + ], + [ + "godot_variant *", + "r_iter" + ], + [ + "bool *", + "r_valid" + ] + ] + }, + { + "name": "godot_variant_hash_compare", + "return_type": "godot_bool", + "arguments": [ + [ + "const godot_variant *", + "p_self" + ], + [ + "const godot_variant *", + "p_other" + ] + ] + }, + { + "name": "godot_variant_booleanize", + "return_type": "godot_bool", + "arguments": [ + [ + "const godot_variant *", + "p_self" + ] + ] + }, + { + "name": "godot_variant_blend", + "return_type": "void", + "arguments": [ + [ + "const godot_variant *", + "p_a" + ], + [ + "const godot_variant *", + "p_b" + ], + [ + "float", + "p_c" + ], + [ + "godot_variant *", + "r_dst" + ] + ] + }, + { + "name": "godot_variant_interpolate", + "return_type": "void", + "arguments": [ + [ + "const godot_variant *", + "p_a" + ], + [ + "const godot_variant *", + "p_b" + ], + [ + "float", + "p_c" + ], + [ + "godot_variant *", + "r_dst" + ] + ] + }, + { + "name": "godot_variant_duplicate", + "return_type": "godot_variant", + "arguments": [ + [ + "const godot_variant *", + "p_self" + ], + [ + "godot_bool", + "p_deep" + ] + ] + }, + { + "name": "godot_variant_stringify", + "return_type": "godot_string", + "arguments": [ + [ + "const godot_variant *", + "p_self" + ] + ] + }, + { + "name": "godot_variant_get_validated_operator_evaluator", + "return_type": "godot_validated_operator_evaluator", + "arguments": [ + [ + "godot_variant_operator", + "p_operator" + ], + [ + "godot_variant_type", + "p_type_a" + ], + [ + "godot_variant_type", + "p_type_b" + ] + ] + }, + { + "name": "godot_variant_get_ptr_operator_evaluator", + "return_type": "godot_ptr_operator_evaluator", + "arguments": [ + [ + "godot_variant_operator", + "p_operator" + ], + [ + "godot_variant_type", + "p_type_a" + ], + [ + "godot_variant_type", + "p_type_b" + ] + ] + }, + { + "name": "godot_variant_get_operator_return_type", + "return_type": "godot_variant_type", + "arguments": [ + [ + "godot_variant_operator", + "p_operator" + ], + [ + "godot_variant_type", + "p_type_a" + ], + [ + "godot_variant_type", + "p_type_b" + ] + ] + }, + { + "name": "godot_variant_get_operator_name", + "return_type": "godot_string", + "arguments": [ + [ + "godot_variant_operator", + "p_operator" + ] + ] + }, + { + "name": "godot_variant_has_builtin_method", + "return_type": "bool", + "arguments": [ + [ + "godot_variant_type", + "p_type" + ], + [ + "const godot_string_name *", + "p_method" + ] + ] + }, + { + "name": "godot_variant_has_builtin_method_with_cstring", + "return_type": "bool", + "arguments": [ + [ + "godot_variant_type", + "p_type" + ], + [ + "const char *", + "p_method" + ] + ] + }, + { + "name": "godot_variant_get_validated_builtin_method", + "return_type": "godot_validated_builtin_method", + "arguments": [ + [ + "godot_variant_type", + "p_type" + ], + [ + "const godot_string_name *", + "p_method" + ] + ] + }, + { + "name": "godot_variant_get_validated_builtin_method_with_cstring", + "return_type": "godot_validated_builtin_method", + "arguments": [ + [ + "godot_variant_type", + "p_type" + ], + [ + "const char *", + "p_method" + ] + ] + }, + { + "name": "godot_variant_get_ptr_builtin_method", + "return_type": "godot_ptr_builtin_method", + "arguments": [ + [ + "godot_variant_type", + "p_type" + ], + [ + "const godot_string_name *", + "p_method" + ] + ] + }, + { + "name": "godot_variant_get_ptr_builtin_method_with_cstring", + "return_type": "godot_ptr_builtin_method", + "arguments": [ + [ + "godot_variant_type", + "p_type" + ], + [ + "const char *", + "p_method" + ] + ] + }, + { + "name": "godot_variant_get_builtin_method_argument_count", + "return_type": "int", + "arguments": [ + [ + "godot_variant_type", + "p_type" + ], + [ + "const godot_string_name *", + "p_method" + ] + ] + }, + { + "name": "godot_variant_get_builtin_method_argument_count_with_cstring", + "return_type": "int", + "arguments": [ + [ + "godot_variant_type", + "p_type" + ], + [ + "const char *", + "p_method" + ] + ] + }, + { + "name": "godot_variant_get_builtin_method_argument_type", + "return_type": "godot_variant_type", + "arguments": [ + [ + "godot_variant_type", + "p_type" + ], + [ + "const godot_string_name *", + "p_method" + ], + [ + "int", + "p_argument" + ] + ] + }, + { + "name": "godot_variant_get_builtin_method_argument_type_with_cstring", + "return_type": "godot_variant_type", + "arguments": [ + [ + "godot_variant_type", + "p_type" + ], + [ + "const char *", + "p_method" + ], + [ + "int", + "p_argument" + ] + ] + }, + { + "name": "godot_variant_get_builtin_method_argument_name", + "return_type": "godot_string", + "arguments": [ + [ + "godot_variant_type", + "p_type" + ], + [ + "const godot_string_name *", + "p_method" + ], + [ + "int", + "p_argument" + ] + ] + }, + { + "name": "godot_variant_get_builtin_method_argument_name_with_cstring", + "return_type": "godot_string", + "arguments": [ + [ + "godot_variant_type", + "p_type" + ], + [ + "const char *", + "p_method" + ], + [ + "int", + "p_argument" + ] + ] + }, + { + "name": "godot_variant_has_builtin_method_return_value", + "return_type": "bool", + "arguments": [ + [ + "godot_variant_type", + "p_type" + ], + [ + "const godot_string_name *", + "p_method" + ] + ] + }, + { + "name": "godot_variant_has_builtin_method_return_value_with_cstring", + "return_type": "bool", + "arguments": [ + [ + "godot_variant_type", + "p_type" + ], + [ + "const char *", + "p_method" + ] + ] + }, + { + "name": "godot_variant_get_builtin_method_return_type", + "return_type": "godot_variant_type", + "arguments": [ + [ + "godot_variant_type", + "p_type" + ], + [ + "const godot_string_name *", + "p_method" + ] + ] + }, + { + "name": "godot_variant_get_builtin_method_return_type_with_cstring", + "return_type": "godot_variant_type", + "arguments": [ + [ + "godot_variant_type", + "p_type" + ], + [ + "const char *", + "p_method" + ] + ] + }, + { + "name": "godot_variant_is_builtin_method_const", + "return_type": "bool", + "arguments": [ + [ + "godot_variant_type", + "p_type" + ], + [ + "const godot_string_name *", + "p_method" + ] + ] + }, + { + "name": "godot_variant_is_builtin_method_const_with_cstring", + "return_type": "bool", + "arguments": [ + [ + "godot_variant_type", + "p_type" + ], + [ + "const char *", + "p_method" + ] + ] + }, + { + "name": "godot_variant_is_builtin_method_vararg", + "return_type": "bool", + "arguments": [ + [ + "godot_variant_type", + "p_type" + ], + [ + "const godot_string_name *", + "p_method" + ] + ] + }, + { + "name": "godot_variant_is_builtin_method_vararg_with_cstring", + "return_type": "bool", + "arguments": [ + [ + "godot_variant_type", + "p_type" + ], + [ + "const char *", + "p_method" + ] + ] + }, + { + "name": "godot_variant_get_builtin_method_count", + "return_type": "int", + "arguments": [ + [ + "godot_variant_type", + "p_type" + ] + ] + }, + { + "name": "godot_variant_get_builtin_method_list", + "return_type": "void", + "arguments": [ + [ + "godot_variant_type", + "p_type" + ], + [ + "godot_string_name *", + "r_list" + ] + ] + }, + { + "name": "godot_variant_get_constructor_count", + "return_type": "int", + "arguments": [ + [ + "godot_variant_type", + "p_type" + ] + ] + }, + { + "name": "godot_variant_get_validated_constructor", + "return_type": "godot_validated_constructor", + "arguments": [ + [ + "godot_variant_type", + "p_type" + ], + [ + "int", + "p_constructor" + ] + ] + }, + { + "name": "godot_variant_get_ptr_constructor", + "return_type": "godot_ptr_constructor", + "arguments": [ + [ + "godot_variant_type", + "p_type" + ], + [ + "int", + "p_constructor" + ] + ] + }, + { + "name": "godot_variant_get_constructor_argument_count", + "return_type": "int", + "arguments": [ + [ + "godot_variant_type", + "p_type" + ], + [ + "int", + "p_constructor" + ] + ] + }, + { + "name": "godot_variant_get_constructor_argument_type", + "return_type": "godot_variant_type", + "arguments": [ + [ + "godot_variant_type", + "p_type" + ], + [ + "int", + "p_constructor" + ], + [ + "int", + "p_argument" + ] + ] + }, + { + "name": "godot_variant_get_constructor_argument_name", + "return_type": "godot_string", + "arguments": [ + [ + "godot_variant_type", + "p_type" + ], + [ + "int", + "p_constructor" + ], + [ + "int", + "p_argument" + ] + ] + }, + { + "name": "godot_variant_construct", + "return_type": "void", + "arguments": [ + [ + "godot_variant_type", + "p_type" + ], + [ + "godot_variant *", + "p_base" + ], + [ + "const godot_variant **", + "p_args" + ], + [ + "int", + "p_argument_count" + ], + [ + "godot_variant_call_error *", + "r_error" + ] + ] + }, + { + "name": "godot_variant_get_member_type", + "return_type": "godot_variant_type", + "arguments": [ + [ + "godot_variant_type", + "p_type" + ], + [ + "const godot_string_name *", + "p_member" + ] + ] + }, + { + "name": "godot_variant_get_member_type_with_cstring", + "return_type": "godot_variant_type", + "arguments": [ + [ + "godot_variant_type", + "p_type" + ], + [ + "const char *", + "p_member" + ] + ] + }, + { + "name": "godot_variant_get_member_count", + "return_type": "int", + "arguments": [ + [ + "godot_variant_type", + "p_type" + ] + ] + }, + { + "name": "godot_variant_get_member_list", + "return_type": "void", + "arguments": [ + [ + "godot_variant_type", + "p_type" + ], + [ + "godot_string_name *", + "r_list" + ] + ] + }, + { + "name": "godot_variant_get_validated_setter", + "return_type": "godot_validated_setter", + "arguments": [ + [ + "godot_variant_type", + "p_type" + ], + [ + "const godot_string_name *", + "p_member" + ] + ] + }, + { + "name": "godot_variant_get_validated_setter_with_cstring", + "return_type": "godot_validated_setter", + "arguments": [ + [ + "godot_variant_type", + "p_type" + ], + [ + "const char *", + "p_member" + ] + ] + }, + { + "name": "godot_variant_get_validated_getter", + "return_type": "godot_validated_getter", + "arguments": [ + [ + "godot_variant_type", + "p_type" + ], + [ + "const godot_string_name *", + "p_member" + ] + ] + }, + { + "name": "godot_variant_get_validated_getter_with_cstring", + "return_type": "godot_validated_getter", + "arguments": [ + [ + "godot_variant_type", + "p_type" + ], + [ + "const char *", + "p_member" + ] + ] + }, + { + "name": "godot_variant_get_ptr_setter", + "return_type": "godot_ptr_setter", + "arguments": [ + [ + "godot_variant_type", + "p_type" + ], + [ + "const godot_string_name *", + "p_member" + ] + ] + }, + { + "name": "godot_variant_get_ptr_setter_with_cstring", + "return_type": "godot_ptr_setter", + "arguments": [ + [ + "godot_variant_type", + "p_type" + ], + [ + "const char *", + "p_member" + ] + ] + }, + { + "name": "godot_variant_get_ptr_getter", + "return_type": "godot_ptr_getter", + "arguments": [ + [ + "godot_variant_type", + "p_type" + ], + [ + "const godot_string_name *", + "p_member" + ] + ] + }, + { + "name": "godot_variant_get_ptr_getter_with_cstring", + "return_type": "godot_ptr_getter", + "arguments": [ + [ + "godot_variant_type", + "p_type" + ], + [ + "const char *", + "p_member" + ] + ] + }, + { + "name": "godot_variant_has_indexing", + "return_type": "bool", + "arguments": [ + [ + "godot_variant_type", + "p_type" + ] + ] + }, + { + "name": "godot_variant_get_indexed_element_type", + "return_type": "godot_variant_type", + "arguments": [ + [ + "godot_variant_type", + "p_type" + ] + ] + }, + { + "name": "godot_variant_get_validated_indexed_setter", + "return_type": "godot_validated_indexed_setter", + "arguments": [ + [ + "godot_variant_type", + "p_type" + ] + ] + }, + { + "name": "godot_variant_get_validated_indexed_getter", + "return_type": "godot_validated_indexed_getter", + "arguments": [ + [ + "godot_variant_type", + "p_type" + ] + ] + }, + { + "name": "godot_variant_get_ptr_indexed_setter", + "return_type": "godot_ptr_indexed_setter", + "arguments": [ + [ + "godot_variant_type", + "p_type" + ] + ] + }, + { + "name": "godot_variant_get_ptr_indexed_getter", + "return_type": "godot_ptr_indexed_getter", + "arguments": [ + [ + "godot_variant_type", + "p_type" + ] + ] + }, + { + "name": "godot_variant_get_indexed_size", + "return_type": "uint64_t", + "arguments": [ + [ + "const godot_variant *", + "p_self" + ] + ] + }, + { + "name": "godot_variant_is_keyed", + "return_type": "bool", + "arguments": [ + [ + "godot_variant_type", + "p_type" + ] + ] + }, + { + "name": "godot_variant_get_validated_keyed_setter", + "return_type": "godot_validated_keyed_setter", + "arguments": [ + [ + "godot_variant_type", + "p_type" + ] + ] + }, + { + "name": "godot_variant_get_validated_keyed_getter", + "return_type": "godot_validated_keyed_getter", + "arguments": [ + [ + "godot_variant_type", + "p_type" + ] + ] + }, + { + "name": "godot_variant_get_validated_keyed_checker", + "return_type": "godot_validated_keyed_checker", + "arguments": [ + [ + "godot_variant_type", + "p_type" + ] + ] + }, + { + "name": "godot_variant_get_ptr_keyed_setter", + "return_type": "godot_ptr_keyed_setter", + "arguments": [ + [ + "godot_variant_type", + "p_type" + ] + ] + }, + { + "name": "godot_variant_get_ptr_keyed_getter", + "return_type": "godot_ptr_keyed_getter", + "arguments": [ + [ + "godot_variant_type", + "p_type" + ] + ] + }, + { + "name": "godot_variant_get_ptr_keyed_checker", + "return_type": "godot_ptr_keyed_checker", + "arguments": [ + [ + "godot_variant_type", + "p_type" + ] + ] + }, + { + "name": "godot_variant_get_constants_count", + "return_type": "int", + "arguments": [ + [ + "godot_variant_type", + "p_type" + ] + ] + }, + { + "name": "godot_variant_get_constants_list", + "return_type": "void", + "arguments": [ + [ + "godot_variant_type", + "p_type" + ], + [ + "godot_string_name *", + "r_list" + ] + ] + }, + { + "name": "godot_variant_has_constant", + "return_type": "bool", + "arguments": [ + [ + "godot_variant_type", + "p_type" + ], + [ + "const godot_string_name *", + "p_constant" + ] + ] + }, + { + "name": "godot_variant_has_constant_with_cstring", + "return_type": "bool", + "arguments": [ + [ + "godot_variant_type", + "p_type" + ], + [ + "const char *", + "p_constant" + ] + ] + }, + { + "name": "godot_variant_get_constant_value", + "return_type": "godot_variant", + "arguments": [ + [ + "godot_variant_type", + "p_type" + ], + [ + "const godot_string_name *", + "p_constant" + ] + ] + }, + { + "name": "godot_variant_get_constant_value_with_cstring", + "return_type": "godot_variant", + "arguments": [ + [ + "godot_variant_type", + "p_type" + ], + [ + "const char *", + "p_constant" + ] + ] + }, + { + "name": "godot_variant_has_utility_function", + "return_type": "bool", + "arguments": [ + [ + "const godot_string_name *", + "p_function" + ] + ] + }, + { + "name": "godot_variant_has_utility_function_with_cstring", + "return_type": "bool", + "arguments": [ + [ + "const char *", + "p_function" + ] + ] + }, + { + "name": "godot_variant_call_utility_function", + "return_type": "void", + "arguments": [ + [ + "const godot_string_name *", + "p_function" + ], + [ + "godot_variant *", + "r_ret" + ], + [ + "const godot_variant **", + "p_args" + ], + [ + "int", + "p_argument_count" + ], + [ + "godot_variant_call_error *", + "r_error" + ] + ] + }, + { + "name": "godot_variant_call_utility_function_with_cstring", + "return_type": "void", + "arguments": [ + [ + "const char *", + "p_function" + ], + [ + "godot_variant *", + "r_ret" + ], + [ + "const godot_variant **", + "p_args" + ], + [ + "int", + "p_argument_count" + ], + [ + "godot_variant_call_error *", + "r_error" + ] + ] + }, + { + "name": "godot_variant_get_ptr_utility_function", + "return_type": "godot_ptr_utility_function", + "arguments": [ + [ + "const godot_string_name *", + "p_function" + ] + ] + }, + { + "name": "godot_variant_get_ptr_utility_function_with_cstring", + "return_type": "godot_ptr_utility_function", + "arguments": [ + [ + "const char *", + "p_function" + ] + ] + }, + { + "name": "godot_variant_get_validated_utility_function", + "return_type": "godot_validated_utility_function", + "arguments": [ + [ + "const godot_string_name *", + "p_function" + ] + ] + }, + { + "name": "godot_variant_get_validated_utility_function_with_cstring", + "return_type": "godot_validated_utility_function", + "arguments": [ + [ + "const char *", + "p_function" + ] + ] + }, + { + "name": "godot_variant_get_utility_function_type", + "return_type": "godot_variant_utility_function_type", + "arguments": [ + [ + "const godot_string_name *", + "p_function" + ] + ] + }, + { + "name": "godot_variant_get_utility_function_type_with_cstring", + "return_type": "godot_variant_utility_function_type", + "arguments": [ + [ + "const char *", + "p_function" + ] + ] + }, + { + "name": "godot_variant_get_utility_function_argument_count", + "return_type": "int", + "arguments": [ + [ + "const godot_string_name *", + "p_function" + ] + ] + }, + { + "name": "godot_variant_get_utility_function_argument_count_with_cstring", + "return_type": "int", + "arguments": [ + [ + "const char *", + "p_function" + ] + ] + }, + { + "name": "godot_variant_get_utility_function_argument_type", + "return_type": "godot_variant_type", + "arguments": [ + [ + "const godot_string_name *", + "p_function" + ], + [ + "int", + "p_argument" + ] + ] + }, + { + "name": "godot_variant_get_utility_function_argument_type_with_cstring", + "return_type": "godot_variant_type", + "arguments": [ + [ + "const char *", + "p_function" + ], + [ + "int", + "p_argument" + ] + ] + }, + { + "name": "godot_variant_get_utility_function_argument_name", + "return_type": "godot_string", + "arguments": [ + [ + "const godot_string_name *", + "p_function" + ], + [ + "int", + "p_argument" + ] + ] + }, + { + "name": "godot_variant_get_utility_function_argument_name_with_cstring", + "return_type": "godot_string", + "arguments": [ + [ + "const char *", + "p_function" + ], + [ + "int", + "p_argument" + ] + ] + }, + { + "name": "godot_variant_has_utility_function_return_value", + "return_type": "bool", + "arguments": [ + [ + "const godot_string_name *", + "p_function" + ] + ] + }, + { + "name": "godot_variant_has_utility_function_return_value_with_cstring", + "return_type": "bool", + "arguments": [ + [ + "const char *", + "p_function" + ] + ] + }, + { + "name": "godot_variant_get_utility_function_return_type", + "return_type": "godot_variant_type", + "arguments": [ + [ + "const godot_string_name *", + "p_function" + ] + ] + }, + { + "name": "godot_variant_get_utility_function_return_type_with_cstring", + "return_type": "godot_variant_type", + "arguments": [ + [ + "const char *", + "p_function" + ] + ] + }, + { + "name": "godot_variant_is_utility_function_vararg", + "return_type": "bool", + "arguments": [ + [ + "const godot_string_name *", + "p_function" + ] + ] + }, + { + "name": "godot_variant_is_utility_function_vararg_with_cstring", + "return_type": "bool", + "arguments": [ + [ + "const char *", + "p_function" + ] + ] + }, + { + "name": "godot_variant_get_utility_function_count", + "return_type": "int", + "arguments": [] + }, + { + "name": "godot_variant_get_utility_function_list", + "return_type": "void", + "arguments": [ + [ + "godot_string_name *", + "r_functions" + ] + ] + }, + { + "name": "godot_variant_get_type", + "return_type": "godot_variant_type", + "arguments": [ + [ + "const godot_variant *", + "p_self" + ] + ] + }, + { + "name": "godot_variant_has_method", + "return_type": "bool", + "arguments": [ + [ + "const godot_variant *", + "p_self" + ], + [ + "const godot_string_name *", + "p_method" + ] + ] + }, + { + "name": "godot_variant_has_member", + "return_type": "bool", + "arguments": [ + [ + "godot_variant_type", + "p_type" + ], + [ + "const godot_string_name *", + "p_member" + ] + ] + }, + { + "name": "godot_variant_has_key", + "return_type": "bool", + "arguments": [ + [ + "const godot_variant *", + "p_self" + ], + [ + "const godot_variant *", + "p_key" + ], + [ + "bool *", + "r_valid" + ] + ] + }, + { + "name": "godot_variant_get_type_name", + "return_type": "godot_string", + "arguments": [ + [ + "godot_variant_type", + "p_type" + ] + ] + }, + { + "name": "godot_variant_can_convert", + "return_type": "bool", + "arguments": [ + [ + "godot_variant_type", + "p_from" + ], + [ + "godot_variant_type", + "p_to" + ] + ] + }, + { + "name": "godot_variant_can_convert_strict", + "return_type": "bool", + "arguments": [ + [ + "godot_variant_type", + "p_from" + ], + [ + "godot_variant_type", + "p_to" + ] + ] + }, + { + "name": "godot_aabb_new", + "return_type": "void", + "arguments": [ + [ + "godot_aabb *", + "p_self" + ] + ] + }, + { + "name": "godot_array_new", + "return_type": "void", + "arguments": [ + [ + "godot_array *", + "p_self" + ] + ] + }, + { + "name": "godot_array_destroy", + "return_type": "void", + "arguments": [ + [ + "godot_array *", + "p_self" + ] + ] + }, + { + "name": "godot_array_operator_index", + "return_type": "godot_variant *", + "arguments": [ + [ + "godot_array *", + "p_self" + ], + [ + "godot_int", + "p_index" + ] + ] + }, + { + "name": "godot_array_operator_index_const", + "return_type": "const godot_variant *", + "arguments": [ + [ + "const godot_array *", + "p_self" + ], + [ + "godot_int", + "p_index" + ] + ] + }, + { + "name": "godot_basis_new", + "return_type": "void", + "arguments": [ + [ + "godot_basis *", + "p_self" + ] + ] + }, + { + "name": "godot_basis_operator_index", + "return_type": "godot_vector3 *", + "arguments": [ + [ + "godot_basis *", + "p_self" + ], + [ + "godot_int", + "p_index" + ] + ] + }, + { + "name": "godot_basis_operator_index_const", + "return_type": "const godot_vector3 *", + "arguments": [ + [ + "const godot_basis *", + "p_self" + ], + [ + "godot_int", + "p_index" + ] + ] + }, + { + "name": "godot_callable_new", + "return_type": "void", + "arguments": [ + [ + "godot_callable *", + "p_self" + ] + ] + }, + { + "name": "godot_callable_destroy", + "return_type": "void", + "arguments": [ + [ + "godot_callable *", + "p_self" + ] + ] + }, + { + "name": "godot_color_new", + "return_type": "void", + "arguments": [ + [ + "godot_color *", + "p_self" + ] + ] + }, + { + "name": "godot_color_operator_index", + "return_type": "float *", + "arguments": [ + [ + "godot_color *", + "p_self" + ], + [ + "godot_int", + "p_index" + ] + ] + }, + { + "name": "godot_color_operator_index_const", + "return_type": "const float *", + "arguments": [ + [ + "const godot_color *", + "p_self" + ], + [ + "godot_int", + "p_index" + ] + ] + }, + { + "name": "godot_dictionary_new", + "return_type": "void", + "arguments": [ + [ + "godot_dictionary *", + "p_self" + ] + ] + }, + { + "name": "godot_dictionary_destroy", + "return_type": "void", + "arguments": [ + [ + "godot_dictionary *", + "p_self" + ] + ] + }, + { + "name": "godot_dictionary_operator_index", + "return_type": "godot_variant *", + "arguments": [ + [ + "godot_dictionary *", + "p_self" + ], + [ + "const godot_variant *", + "p_key" + ] + ] + }, + { + "name": "godot_dictionary_operator_index_const", + "return_type": "const godot_variant *", + "arguments": [ + [ + "const godot_dictionary *", + "p_self" + ], + [ + "const godot_variant *", + "p_key" + ] + ] + }, + { + "name": "godot_node_path_new", + "return_type": "void", + "arguments": [ + [ + "godot_node_path *", + "p_self" + ] + ] + }, + { + "name": "godot_node_path_destroy", + "return_type": "void", + "arguments": [ + [ + "godot_node_path *", + "p_self" + ] + ] + }, + { + "name": "godot_packed_byte_array_new", + "return_type": "void", + "arguments": [ + [ + "godot_packed_byte_array *", + "p_self" + ] + ] + }, + { + "name": "godot_packed_byte_array_destroy", + "return_type": "void", + "arguments": [ + [ + "godot_packed_byte_array *", + "p_self" + ] + ] + }, + { + "name": "godot_packed_byte_array_operator_index", + "return_type": "uint8_t *", + "arguments": [ + [ + "godot_packed_byte_array *", + "p_self" + ], + [ + "godot_int", + "p_index" + ] + ] + }, + { + "name": "godot_packed_byte_array_operator_index_const", + "return_type": "const uint8_t *", + "arguments": [ + [ + "const godot_packed_byte_array *", + "p_self" + ], + [ + "godot_int", + "p_index" + ] + ] + }, + { + "name": "godot_packed_int32_array_new", + "return_type": "void", + "arguments": [ + [ + "godot_packed_int32_array *", + "p_self" + ] + ] + }, + { + "name": "godot_packed_int32_array_destroy", + "return_type": "void", + "arguments": [ + [ + "godot_packed_int32_array *", + "p_self" + ] + ] + }, + { + "name": "godot_packed_int32_array_operator_index", + "return_type": "int32_t *", + "arguments": [ + [ + "godot_packed_int32_array *", + "p_self" + ], + [ + "godot_int", + "p_index" + ] + ] + }, + { + "name": "godot_packed_int32_array_operator_index_const", + "return_type": "const int32_t *", + "arguments": [ + [ + "const godot_packed_int32_array *", + "p_self" + ], + [ + "godot_int", + "p_index" + ] + ] + }, + { + "name": "godot_packed_int64_array_new", + "return_type": "void", + "arguments": [ + [ + "godot_packed_int64_array *", + "p_self" + ] + ] + }, + { + "name": "godot_packed_int64_array_destroy", + "return_type": "void", + "arguments": [ + [ + "godot_packed_int64_array *", + "p_self" + ] + ] + }, + { + "name": "godot_packed_int64_array_operator_index", + "return_type": "int64_t *", + "arguments": [ + [ + "godot_packed_int64_array *", + "p_self" + ], + [ + "godot_int", + "p_index" + ] + ] + }, + { + "name": "godot_packed_int64_array_operator_index_const", + "return_type": "const int64_t *", + "arguments": [ + [ + "const godot_packed_int64_array *", + "p_self" + ], + [ + "godot_int", + "p_index" + ] + ] + }, + { + "name": "godot_packed_float32_array_new", + "return_type": "void", + "arguments": [ + [ + "godot_packed_float32_array *", + "p_self" + ] + ] + }, + { + "name": "godot_packed_float32_array_destroy", + "return_type": "void", + "arguments": [ + [ + "godot_packed_float32_array *", + "p_self" + ] + ] + }, + { + "name": "godot_packed_float32_array_operator_index", + "return_type": "float *", + "arguments": [ + [ + "godot_packed_float32_array *", + "p_self" + ], + [ + "godot_int", + "p_index" + ] + ] + }, + { + "name": "godot_packed_float32_array_operator_index_const", + "return_type": "const float *", + "arguments": [ + [ + "const godot_packed_float32_array *", + "p_self" + ], + [ + "godot_int", + "p_index" + ] + ] + }, + { + "name": "godot_packed_float64_array_new", + "return_type": "void", + "arguments": [ + [ + "godot_packed_float64_array *", + "p_self" + ] + ] + }, + { + "name": "godot_packed_float64_array_destroy", + "return_type": "void", + "arguments": [ + [ + "godot_packed_float64_array *", + "p_self" + ] + ] + }, + { + "name": "godot_packed_float64_array_operator_index", + "return_type": "double *", + "arguments": [ + [ + "godot_packed_float64_array *", + "p_self" + ], + [ + "godot_int", + "p_index" + ] + ] + }, + { + "name": "godot_packed_float64_array_operator_index_const", + "return_type": "const double *", + "arguments": [ + [ + "const godot_packed_float64_array *", + "p_self" + ], + [ + "godot_int", + "p_index" + ] + ] + }, + { + "name": "godot_packed_string_array_new", + "return_type": "void", + "arguments": [ + [ + "godot_packed_string_array *", + "p_self" + ] + ] + }, + { + "name": "godot_packed_string_array_destroy", + "return_type": "void", + "arguments": [ + [ + "godot_packed_string_array *", + "p_self" + ] + ] + }, + { + "name": "godot_packed_string_array_operator_index", + "return_type": "godot_string *", + "arguments": [ + [ + "godot_packed_string_array *", + "p_self" + ], + [ + "godot_int", + "p_index" + ] + ] + }, + { + "name": "godot_packed_string_array_operator_index_const", + "return_type": "const godot_string *", + "arguments": [ + [ + "const godot_packed_string_array *", + "p_self" + ], + [ + "godot_int", + "p_index" + ] + ] + }, + { + "name": "godot_packed_vector2_array_new", + "return_type": "void", + "arguments": [ + [ + "godot_packed_vector2_array *", + "p_self" + ] + ] + }, + { + "name": "godot_packed_vector2_array_destroy", + "return_type": "void", + "arguments": [ + [ + "godot_packed_vector2_array *", + "p_self" + ] + ] + }, + { + "name": "godot_packed_vector2_array_operator_index", + "return_type": "godot_vector2 *", + "arguments": [ + [ + "godot_packed_vector2_array *", + "p_self" + ], + [ + "godot_int", + "p_index" + ] + ] + }, + { + "name": "godot_packed_vector2_array_operator_index_const", + "return_type": "const godot_vector2 *", + "arguments": [ + [ + "const godot_packed_vector2_array *", + "p_self" + ], + [ + "godot_int", + "p_index" + ] + ] + }, + { + "name": "godot_packed_vector2i_array_new", + "return_type": "void", + "arguments": [ + [ + "godot_packed_vector2i_array *", + "p_self" + ] + ] + }, + { + "name": "godot_packed_vector2i_array_destroy", + "return_type": "void", + "arguments": [ + [ + "godot_packed_vector2i_array *", + "p_self" + ] + ] + }, + { + "name": "godot_packed_vector2i_array_operator_index", + "return_type": "godot_vector2i *", + "arguments": [ + [ + "godot_packed_vector2i_array *", + "p_self" + ], + [ + "godot_int", + "p_index" + ] + ] + }, + { + "name": "godot_packed_vector2i_array_operator_index_const", + "return_type": "const godot_vector2i *", + "arguments": [ + [ + "const godot_packed_vector2i_array *", + "p_self" + ], + [ + "godot_int", + "p_index" + ] + ] + }, + { + "name": "godot_packed_vector3_array_new", + "return_type": "void", + "arguments": [ + [ + "godot_packed_vector3_array *", + "p_self" + ] + ] + }, + { + "name": "godot_packed_vector3_array_destroy", + "return_type": "void", + "arguments": [ + [ + "godot_packed_vector3_array *", + "p_self" + ] + ] + }, + { + "name": "godot_packed_vector3_array_operator_index", + "return_type": "godot_vector3 *", + "arguments": [ + [ + "godot_packed_vector3_array *", + "p_self" + ], + [ + "godot_int", + "p_index" + ] + ] + }, + { + "name": "godot_packed_vector3_array_operator_index_const", + "return_type": "const godot_vector3 *", + "arguments": [ + [ + "const godot_packed_vector3_array *", + "p_self" + ], + [ + "godot_int", + "p_index" + ] + ] + }, + { + "name": "godot_packed_vector3i_array_new", + "return_type": "void", + "arguments": [ + [ + "godot_packed_vector3i_array *", + "p_self" + ] + ] + }, + { + "name": "godot_packed_vector3i_array_destroy", + "return_type": "void", + "arguments": [ + [ + "godot_packed_vector3i_array *", + "p_self" + ] + ] + }, + { + "name": "godot_packed_vector3i_array_operator_index", + "return_type": "godot_vector3i *", + "arguments": [ + [ + "godot_packed_vector3i_array *", + "p_self" + ], + [ + "godot_int", + "p_index" + ] + ] + }, + { + "name": "godot_packed_vector3i_array_operator_index_const", + "return_type": "const godot_vector3i *", + "arguments": [ + [ + "const godot_packed_vector3i_array *", + "p_self" + ], + [ + "godot_int", + "p_index" + ] + ] + }, + { + "name": "godot_packed_color_array_new", + "return_type": "void", + "arguments": [ + [ + "godot_packed_color_array *", + "p_self" + ] + ] + }, + { + "name": "godot_packed_color_array_destroy", + "return_type": "void", + "arguments": [ + [ + "godot_packed_color_array *", + "p_self" + ] + ] + }, + { + "name": "godot_packed_color_array_operator_index", + "return_type": "godot_color *", + "arguments": [ + [ + "godot_packed_color_array *", + "p_self" + ], + [ + "godot_int", + "p_index" + ] + ] + }, + { + "name": "godot_packed_color_array_operator_index_const", + "return_type": "const godot_color *", + "arguments": [ + [ + "const godot_packed_color_array *", + "p_self" + ], + [ + "godot_int", + "p_index" + ] + ] + }, + { + "name": "godot_plane_new", + "return_type": "void", + "arguments": [ + [ + "godot_plane *", + "p_self" + ] + ] + }, + { + "name": "godot_quat_new", + "return_type": "void", + "arguments": [ + [ + "godot_quat *", + "p_self" + ] + ] + }, + { + "name": "godot_quat_operator_index", + "return_type": "godot_real_t *", + "arguments": [ + [ + "godot_quat *", + "p_self" + ], + [ + "godot_int", + "p_index" + ] + ] + }, + { + "name": "godot_quat_operator_index_const", + "return_type": "const godot_real_t *", + "arguments": [ + [ + "const godot_quat *", + "p_self" + ], + [ + "godot_int", + "p_index" + ] + ] + }, + { + "name": "godot_rect2_new", + "return_type": "void", + "arguments": [ + [ + "godot_rect2 *", + "p_self" + ] + ] + }, + { + "name": "godot_rect2i_new", + "return_type": "void", + "arguments": [ + [ + "godot_rect2i *", + "p_self" + ] + ] + }, + { + "name": "godot_rid_new", + "return_type": "void", + "arguments": [ + [ + "godot_rid *", + "p_self" + ] + ] + }, + { + "name": "godot_signal_new", + "return_type": "void", + "arguments": [ + [ + "godot_signal *", + "p_self" + ] + ] + }, + { + "name": "godot_signal_destroy", + "return_type": "void", + "arguments": [ + [ + "godot_signal *", + "p_self" + ] + ] + }, + { + "name": "godot_string_new", + "return_type": "void", + "arguments": [ + [ + "godot_string *", + "r_dest" + ] + ] + }, + { + "name": "godot_string_new_copy", + "return_type": "void", + "arguments": [ + [ + "godot_string *", + "r_dest" + ], + [ + "const godot_string *", + "p_src" + ] + ] + }, + { + "name": "godot_string_destroy", + "return_type": "void", + "arguments": [ + [ + "godot_string *", + "p_self" + ] + ] + }, + { + "name": "godot_string_new_with_latin1_chars", + "return_type": "void", + "arguments": [ + [ + "godot_string *", + "r_dest" + ], + [ + "const char *", + "p_contents" + ] + ] + }, + { + "name": "godot_string_new_with_utf8_chars", + "return_type": "void", + "arguments": [ + [ + "godot_string *", + "r_dest" + ], + [ + "const char *", + "p_contents" + ] + ] + }, + { + "name": "godot_string_new_with_utf16_chars", + "return_type": "void", + "arguments": [ + [ + "godot_string *", + "r_dest" + ], + [ + "const char16_t *", + "p_contents" + ] + ] + }, + { + "name": "godot_string_new_with_utf32_chars", + "return_type": "void", + "arguments": [ + [ + "godot_string *", + "r_dest" + ], + [ + "const char32_t *", + "p_contents" + ] + ] + }, + { + "name": "godot_string_new_with_wide_chars", + "return_type": "void", + "arguments": [ + [ + "godot_string *", + "r_dest" + ], + [ + "const wchar_t *", + "p_contents" + ] + ] + }, + { + "name": "godot_string_new_with_latin1_chars_and_len", + "return_type": "void", + "arguments": [ + [ + "godot_string *", + "r_dest" + ], + [ + "const char *", + "p_contents" + ], + [ + "const int", + "p_size" + ] + ] + }, + { + "name": "godot_string_new_with_utf8_chars_and_len", + "return_type": "void", + "arguments": [ + [ + "godot_string *", + "r_dest" + ], + [ + "const char *", + "p_contents" + ], + [ + "const int", + "p_size" + ] + ] + }, + { + "name": "godot_string_new_with_utf16_chars_and_len", + "return_type": "void", + "arguments": [ + [ + "godot_string *", + "r_dest" + ], + [ + "const char16_t *", + "p_contents" + ], + [ + "const int", + "p_size" + ] + ] + }, + { + "name": "godot_string_new_with_utf32_chars_and_len", + "return_type": "void", + "arguments": [ + [ + "godot_string *", + "r_dest" + ], + [ + "const char32_t *", + "p_contents" + ], + [ + "const int", + "p_size" + ] + ] + }, + { + "name": "godot_string_new_with_wide_chars_and_len", + "return_type": "void", + "arguments": [ + [ + "godot_string *", + "r_dest" + ], + [ + "const wchar_t *", + "p_contents" + ], + [ + "const int", + "p_size" + ] + ] + }, + { + "name": "godot_string_name_new", + "return_type": "void", + "arguments": [ + [ + "godot_string_name *", + "r_dest" + ] + ] + }, + { + "name": "godot_string_name_new_copy", + "return_type": "void", + "arguments": [ + [ + "godot_string_name *", + "r_dest" + ], + [ + "const godot_string_name *", + "p_src" + ] + ] + }, + { + "name": "godot_string_name_destroy", + "return_type": "void", + "arguments": [ + [ + "godot_string_name *", + "p_self" + ] + ] + }, + { + "name": "godot_string_name_new_with_latin1_chars", + "return_type": "void", + "arguments": [ + [ + "godot_string_name *", + "r_dest" + ], + [ + "const char *", + "p_contents" + ] + ] + }, + { + "name": "godot_transform_new", + "return_type": "void", + "arguments": [ + [ + "godot_transform *", + "r_dest" + ] + ] + }, + { + "name": "godot_transform2d_new", + "return_type": "void", + "arguments": [ + [ + "godot_transform2d *", + "r_dest" + ] + ] + }, + { + "name": "godot_transform2d_operator_index", + "return_type": "godot_vector2 *", + "arguments": [ + [ + "godot_transform2d *", + "p_self" + ], + [ + "godot_int", + "p_index" + ] + ] + }, + { + "name": "godot_transform2d_operator_index_const", + "return_type": "const godot_vector2 *", + "arguments": [ + [ + "const godot_transform2d *", + "p_self" + ], + [ + "godot_int", + "p_index" + ] + ] + }, + { + "name": "godot_vector2_new", + "return_type": "void", + "arguments": [ + [ + "godot_vector2 *", + "r_dest" + ] + ] + }, + { + "name": "godot_vector2_operator_index", + "return_type": "godot_real_t *", + "arguments": [ + [ + "godot_vector2 *", + "p_self" + ], + [ + "godot_int", + "p_index" + ] + ] + }, + { + "name": "godot_vector2_operator_index_const", + "return_type": "const godot_real_t *", + "arguments": [ + [ + "const godot_vector2 *", + "p_self" + ], + [ + "godot_int", + "p_index" + ] + ] + }, + { + "name": "godot_vector2i_new", + "return_type": "void", + "arguments": [ + [ + "godot_vector2i *", + "r_dest" + ] + ] + }, + { + "name": "godot_vector2i_operator_index", + "return_type": "int32_t *", + "arguments": [ + [ + "godot_vector2i *", + "p_self" + ], + [ + "godot_int", + "p_index" + ] + ] + }, + { + "name": "godot_vector2i_operator_index_const", + "return_type": "const int32_t *", + "arguments": [ + [ + "const godot_vector2i *", + "p_self" + ], + [ + "godot_int", + "p_index" + ] + ] + }, + { + "name": "godot_vector3_new", + "return_type": "void", + "arguments": [ + [ + "godot_vector3 *", + "r_dest" + ] + ] + }, + { + "name": "godot_vector3_operator_index", + "return_type": "godot_real_t *", + "arguments": [ + [ + "godot_vector3 *", + "p_self" + ], + [ + "godot_int", + "p_index" + ] + ] + }, + { + "name": "godot_vector3_operator_index_const", + "return_type": "const godot_real_t *", + "arguments": [ + [ + "const godot_vector3 *", + "p_self" + ], + [ + "godot_int", + "p_index" + ] + ] + }, + { + "name": "godot_vector3i_new", + "return_type": "void", + "arguments": [ + [ + "godot_vector3i *", + "r_dest" + ] + ] + }, + { + "name": "godot_vector3i_operator_index", + "return_type": "int32_t *", + "arguments": [ + [ + "godot_vector3i *", + "p_self" + ], + [ + "godot_int", + "p_index" + ] + ] + }, + { + "name": "godot_vector3i_operator_index_const", + "return_type": "const int32_t *", + "arguments": [ + [ + "const godot_vector3i *", + "p_self" + ], + [ + "godot_int", + "p_index" + ] + ] + } + ] + }, + "extensions": [ + { + "name": "nativescript", + "type": "NATIVESCRIPT", + "version": { + "major": 4, + "minor": 0 + }, + "next": null, + "api": [ + { + "name": "godot_nativescript_register_class", + "return_type": "void", + "arguments": [ + [ + "void *", + "p_gdnative_handle" + ], + [ + "const char *", + "p_name" + ], + [ + "const char *", + "p_base" + ], + [ + "godot_nativescript_instance_create_func", + "p_create_func" + ], + [ + "godot_nativescript_instance_destroy_func", + "p_destroy_func" + ] + ] + }, + { + "name": "godot_nativescript_register_tool_class", + "return_type": "void", + "arguments": [ + [ + "void *", + "p_gdnative_handle" + ], + [ + "const char *", + "p_name" + ], + [ + "const char *", + "p_base" + ], + [ + "godot_nativescript_instance_create_func", + "p_create_func" + ], + [ + "godot_nativescript_instance_destroy_func", + "p_destroy_func" + ] + ] + }, + { + "name": "godot_nativescript_register_method", + "return_type": "void", + "arguments": [ + [ + "void *", + "p_gdnative_handle" + ], + [ + "const char *", + "p_name" + ], + [ + "const char *", + "p_function_name" + ], + [ + "godot_nativescript_method_attributes", + "p_attr" + ], + [ + "godot_nativescript_instance_method", + "p_method" + ] + ] + }, + { + "name": "godot_nativescript_set_method_argument_information", + "return_type": "void", + "arguments": [ + [ + "void *", + "p_gdnative_handle" + ], + [ + "const char *", + "p_name" + ], + [ + "const char *", + "p_function_name" + ], + [ + "int", + "p_num_args" + ], + [ + "const godot_nativescript_method_argument *", + "p_args" + ] + ] + }, + { + "name": "godot_nativescript_register_property", + "return_type": "void", + "arguments": [ + [ + "void *", + "p_gdnative_handle" + ], + [ + "const char *", + "p_name" + ], + [ + "const char *", + "p_path" + ], + [ + "godot_nativescript_property_attributes *", + "p_attr" + ], + [ + "godot_nativescript_property_set_func", + "p_set_func" + ], + [ + "godot_nativescript_property_get_func", + "p_get_func" + ] + ] + }, + { + "name": "godot_nativescript_register_signal", + "return_type": "void", + "arguments": [ + [ + "void *", + "p_gdnative_handle" + ], + [ + "const char *", + "p_name" + ], + [ + "const godot_nativescript_signal *", + "p_signal" + ] + ] + }, + { + "name": "godot_nativescript_get_userdata", + "return_type": "void *", + "arguments": [ + [ + "godot_object *", + "p_instance" + ] + ] + }, + { + "name": "godot_nativescript_set_class_documentation", + "return_type": "void", + "arguments": [ + [ + "void *", + "p_gdnative_handle" + ], + [ + "const char *", + "p_name" + ], + [ + "godot_string", + "p_documentation" + ] + ] + }, + { + "name": "godot_nativescript_set_method_documentation", + "return_type": "void", + "arguments": [ + [ + "void *", + "p_gdnative_handle" + ], + [ + "const char *", + "p_name" + ], + [ + "const char *", + "p_function_name" + ], + [ + "godot_string", + "p_documentation" + ] + ] + }, + { + "name": "godot_nativescript_set_property_documentation", + "return_type": "void", + "arguments": [ + [ + "void *", + "p_gdnative_handle" + ], + [ + "const char *", + "p_name" + ], + [ + "const char *", + "p_path" + ], + [ + "godot_string", + "p_documentation" + ] + ] + }, + { + "name": "godot_nativescript_set_signal_documentation", + "return_type": "void", + "arguments": [ + [ + "void *", + "p_gdnative_handle" + ], + [ + "const char *", + "p_name" + ], + [ + "const char *", + "p_signal_name" + ], + [ + "godot_string", + "p_documentation" + ] + ] + }, + { + "name": "godot_nativescript_set_global_type_tag", + "return_type": "void", + "arguments": [ + [ + "int", + "p_idx" + ], + [ + "const char *", + "p_name" + ], + [ + "const void *", + "p_type_tag" + ] + ] + }, + { + "name": "godot_nativescript_get_global_type_tag", + "return_type": "const void *", + "arguments": [ + [ + "int", + "p_idx" + ], + [ + "const char *", + "p_name" + ] + ] + }, + { + "name": "godot_nativescript_set_type_tag", + "return_type": "void", + "arguments": [ + [ + "void *", + "p_gdnative_handle" + ], + [ + "const char *", + "p_name" + ], + [ + "const void *", + "p_type_tag" + ] + ] + }, + { + "name": "godot_nativescript_get_type_tag", + "return_type": "const void *", + "arguments": [ + [ + "const godot_object *", + "p_object" + ] + ] + }, + { + "name": "godot_nativescript_register_instance_binding_data_functions", + "return_type": "int", + "arguments": [ + [ + "godot_nativescript_instance_binding_functions", + "p_binding_functions" + ] + ] + }, + { + "name": "godot_nativescript_unregister_instance_binding_data_functions", + "return_type": "void", + "arguments": [ + [ + "int", + "p_idx" + ] + ] + }, + { + "name": "godot_nativescript_get_instance_binding_data", + "return_type": "void *", + "arguments": [ + [ + "int", + "p_idx" + ], + [ + "godot_object *", + "p_object" + ] + ] + }, + { + "name": "godot_nativescript_profiling_add_data", + "return_type": "void", + "arguments": [ + [ + "const char *", + "p_signature" + ], + [ + "uint64_t", + "p_line" + ] + ] + } + ] + }, + { + "name": "pluginscript", + "type": "PLUGINSCRIPT", + "version": { + "major": 1, + "minor": 0 + }, + "next": null, + "api": [ + { + "name": "godot_pluginscript_register_language", + "return_type": "void", + "arguments": [ + [ + "const godot_pluginscript_language_desc *", + "language_desc" + ] + ] + } + ] + }, + { + "name": "android", + "type": "ANDROID", + "version": { + "major": 1, + "minor": 1 + }, + "next": null, + "api": [ + { + "name": "godot_android_get_env", + "return_type": "JNIEnv*", + "arguments": [] + }, + { + "name": "godot_android_get_activity", + "return_type": "jobject", + "arguments": [] + }, + { + "name": "godot_android_get_surface", + "return_type": "jobject", + "arguments": [] + }, + { + "name": "godot_android_is_activity_resumed", + "return_type": "bool", + "arguments": [] + } + ] + }, + { + "name": "xr", + "type": "XR", + "version": { + "major": 1, + "minor": 1 + }, + "next": null, + "api": [ + { + "name": "godot_xr_register_interface", + "return_type": "void", + "arguments": [ + [ + "const godot_xr_interface_gdnative *", + "p_interface" + ] + ] + }, + { + "name": "godot_xr_get_worldscale", + "return_type": "godot_float", + "arguments": [] + }, + { + "name": "godot_xr_get_reference_frame", + "return_type": "godot_transform", + "arguments": [] + }, + { + "name": "godot_xr_blit", + "return_type": "void", + "arguments": [ + [ + "godot_int", + "p_eye" + ], + [ + "godot_rid *", + "p_render_target" + ], + [ + "godot_rect2 *", + "p_screen_rect" + ] + ] + }, + { + "name": "godot_xr_get_texid", + "return_type": "godot_int", + "arguments": [ + [ + "godot_rid *", + "p_render_target" + ] + ] + }, + { + "name": "godot_xr_add_controller", + "return_type": "godot_int", + "arguments": [ + [ + "char *", + "p_device_name" + ], + [ + "godot_int", + "p_hand" + ], + [ + "godot_bool", + "p_tracks_orientation" + ], + [ + "godot_bool", + "p_tracks_position" + ] + ] + }, + { + "name": "godot_xr_remove_controller", + "return_type": "void", + "arguments": [ + [ + "godot_int", + "p_controller_id" + ] + ] + }, + { + "name": "godot_xr_set_controller_transform", + "return_type": "void", + "arguments": [ + [ + "godot_int", + "p_controller_id" + ], + [ + "godot_transform *", + "p_transform" + ], + [ + "godot_bool", + "p_tracks_orientation" + ], + [ + "godot_bool", + "p_tracks_position" + ] + ] + }, + { + "name": "godot_xr_set_controller_button", + "return_type": "void", + "arguments": [ + [ + "godot_int", + "p_controller_id" + ], + [ + "godot_int", + "p_button" + ], + [ + "godot_bool", + "p_is_pressed" + ] + ] + }, + { + "name": "godot_xr_set_controller_axis", + "return_type": "void", + "arguments": [ + [ + "godot_int", + "p_controller_id" + ], + [ + "godot_int", + "p_exis" + ], + [ + "godot_float", + "p_value" + ], + [ + "godot_bool", + "p_can_be_negative" + ] + ] + }, + { + "name": "godot_xr_get_controller_rumble", + "return_type": "godot_float", + "arguments": [ + [ + "godot_int", + "p_controller_id" + ] + ] + } + ] + }, + { + "name": "videodecoder", + "type": "VIDEODECODER", + "version": { + "major": 0, + "minor": 1 + }, + "next": null, + "api": [ + { + "name": "godot_videodecoder_file_read", + "return_type": "godot_int", + "arguments": [ + [ + "void *", + "file_ptr" + ], + [ + "uint8_t *", + "buf" + ], + [ + "int", + "buf_size" + ] + ] + }, + { + "name": "godot_videodecoder_file_seek", + "return_type": "int64_t", + "arguments": [ + [ + "void *", + "file_ptr" + ], + [ + "int64_t", + "pos" + ], + [ + "int", + "whence" + ] + ] + }, + { + "name": "godot_videodecoder_register_decoder", + "return_type": "void", + "arguments": [ + [ + "const godot_videodecoder_interface_gdnative *", + "p_interface" + ] + ] + } + ] + }, + { + "name": "net", + "type": "NET", + "version": { + "major": 4, + "minor": 0 + }, + "next": null, + "api": [ + { + "name": "godot_net_bind_stream_peer", + "return_type": "void", + "arguments": [ + [ + "godot_object *", + "p_obj" + ], + [ + "const godot_net_stream_peer *", + "p_interface" + ] + ] + }, + { + "name": "godot_net_bind_packet_peer", + "return_type": "void", + "arguments": [ + [ + "godot_object *", + "p_obj" + ], + [ + "const godot_net_packet_peer *", + "p_interface" + ] + ] + }, + { + "name": "godot_net_bind_multiplayer_peer", + "return_type": "void", + "arguments": [ + [ + "godot_object *", + "p_obj" + ], + [ + "const godot_net_multiplayer_peer *", + "p_interface" + ] + ] + }, + { + "name": "godot_net_set_webrtc_library", + "return_type": "godot_error", + "arguments": [ + [ + "const godot_net_webrtc_library *", + "p_library" + ] + ] + }, + { + "name": "godot_net_bind_webrtc_peer_connection", + "return_type": "void", + "arguments": [ + [ + "godot_object *", + "p_obj" + ], + [ + "const godot_net_webrtc_peer_connection *", + "p_interface" + ] + ] + }, + { + "name": "godot_net_bind_webrtc_data_channel", + "return_type": "void", + "arguments": [ + [ + "godot_object *", + "p_obj" + ], + [ + "const godot_net_webrtc_data_channel *", + "p_interface" + ] + ] + } + ] + }, + { + "name": "text", + "type": "TEXT", + "version": { + "major": 1, + "minor": 0 + }, + "next": null, + "api": [ + { + "name": "godot_text_register_interface", + "return_type": "void", + "arguments": [ + [ + "const godot_text_interface_gdnative *", + "p_interface" + ], + [ + "const godot_string *", + "p_name" + ], + [ + "uint32_t", + "p_features" + ] + ] + }, + { + "name": "godot_glyph_new", + "return_type": "void", + "arguments": [ + [ + "godot_glyph *", + "r_dest" + ] + ] + }, + { + "name": "godot_glyph_get_range", + "return_type": "godot_vector2i", + "arguments": [ + [ + "const godot_glyph *", + "p_self" + ] + ] + }, + { + "name": "godot_glyph_set_range", + "return_type": "void", + "arguments": [ + [ + "godot_glyph *", + "p_self" + ], + [ + "const godot_vector2i *", + "p_range" + ] + ] + }, + { + "name": "godot_glyph_get_count", + "return_type": "godot_int", + "arguments": [ + [ + "const godot_glyph *", + "p_self" + ] + ] + }, + { + "name": "godot_glyph_set_count", + "return_type": "void", + "arguments": [ + [ + "godot_glyph *", + "p_self" + ], + [ + "godot_int", + "p_count" + ] + ] + }, + { + "name": "godot_glyph_get_repeat", + "return_type": "godot_int", + "arguments": [ + [ + "const godot_glyph *", + "p_self" + ] + ] + }, + { + "name": "godot_glyph_set_repeat", + "return_type": "void", + "arguments": [ + [ + "godot_glyph *", + "p_self" + ], + [ + "godot_int", + "p_repeat" + ] + ] + }, + { + "name": "godot_glyph_get_flags", + "return_type": "godot_int", + "arguments": [ + [ + "const godot_glyph *", + "p_self" + ] + ] + }, + { + "name": "godot_glyph_set_flags", + "return_type": "void", + "arguments": [ + [ + "godot_glyph *", + "p_self" + ], + [ + "godot_int", + "p_flags" + ] + ] + }, + { + "name": "godot_glyph_get_offset", + "return_type": "godot_vector2", + "arguments": [ + [ + "const godot_glyph *", + "p_self" + ] + ] + }, + { + "name": "godot_glyph_set_offset", + "return_type": "void", + "arguments": [ + [ + "godot_glyph *", + "p_self" + ], + [ + "const godot_vector2 *", + "p_offset" + ] + ] + }, + { + "name": "godot_glyph_get_advance", + "return_type": "godot_float", + "arguments": [ + [ + "const godot_glyph *", + "p_self" + ] + ] + }, + { + "name": "godot_glyph_set_advance", + "return_type": "void", + "arguments": [ + [ + "godot_glyph *", + "p_self" + ], + [ + "godot_float", + "p_advance" + ] + ] + }, + { + "name": "godot_glyph_get_font", + "return_type": "godot_rid", + "arguments": [ + [ + "const godot_glyph *", + "p_self" + ] + ] + }, + { + "name": "godot_glyph_set_font", + "return_type": "void", + "arguments": [ + [ + "godot_glyph *", + "p_self" + ], + [ + "godot_rid *", + "p_font" + ] + ] + }, + { + "name": "godot_glyph_get_font_size", + "return_type": "godot_int", + "arguments": [ + [ + "const godot_glyph *", + "p_self" + ] + ] + }, + { + "name": "godot_glyph_set_font_size", + "return_type": "void", + "arguments": [ + [ + "godot_glyph *", + "p_self" + ], + [ + "godot_int", + "p_size" + ] + ] + }, + { + "name": "godot_glyph_get_index", + "return_type": "godot_int", + "arguments": [ + [ + "const godot_glyph *", + "p_self" + ] + ] + }, + { + "name": "godot_glyph_set_index", + "return_type": "void", + "arguments": [ + [ + "godot_glyph *", + "p_self" + ], + [ + "godot_int", + "p_index" + ] + ] + }, + { + "name": "godot_packed_glyph_array_new", + "return_type": "void", + "arguments": [ + [ + "godot_packed_glyph_array *", + "r_dest" + ] + ] + }, + { + "name": "godot_packed_glyph_array_new_copy", + "return_type": "void", + "arguments": [ + [ + "godot_packed_glyph_array *", + "r_dest" + ], + [ + "const godot_packed_glyph_array *", + "p_src" + ] + ] + }, + { + "name": "godot_packed_glyph_array_is_empty", + "return_type": "godot_bool", + "arguments": [ + [ + "const godot_packed_glyph_array *", + "p_self" + ] + ] + }, + { + "name": "godot_packed_glyph_array_append", + "return_type": "void", + "arguments": [ + [ + "godot_packed_glyph_array *", + "p_self" + ], + [ + "const godot_glyph *", + "p_data" + ] + ] + }, + { + "name": "godot_packed_glyph_array_append_array", + "return_type": "void", + "arguments": [ + [ + "godot_packed_glyph_array *", + "p_self" + ], + [ + "const godot_packed_glyph_array *", + "p_array" + ] + ] + }, + { + "name": "godot_packed_glyph_array_insert", + "return_type": "godot_error", + "arguments": [ + [ + "godot_packed_glyph_array *", + "p_self" + ], + [ + "const godot_int", + "p_idx" + ], + [ + "const godot_glyph *", + "p_data" + ] + ] + }, + { + "name": "godot_packed_glyph_array_has", + "return_type": "godot_bool", + "arguments": [ + [ + "godot_packed_glyph_array *", + "p_self" + ], + [ + "const godot_glyph *", + "p_value" + ] + ] + }, + { + "name": "godot_packed_glyph_array_sort", + "return_type": "void", + "arguments": [ + [ + "godot_packed_glyph_array *", + "p_self" + ] + ] + }, + { + "name": "godot_packed_glyph_array_invert", + "return_type": "void", + "arguments": [ + [ + "godot_packed_glyph_array *", + "p_self" + ] + ] + }, + { + "name": "godot_packed_glyph_array_push_back", + "return_type": "void", + "arguments": [ + [ + "godot_packed_glyph_array *", + "p_self" + ], + [ + "const godot_glyph *", + "p_data" + ] + ] + }, + { + "name": "godot_packed_glyph_array_remove", + "return_type": "void", + "arguments": [ + [ + "godot_packed_glyph_array *", + "p_self" + ], + [ + "const godot_int", + "p_idx" + ] + ] + }, + { + "name": "godot_packed_glyph_array_resize", + "return_type": "void", + "arguments": [ + [ + "godot_packed_glyph_array *", + "p_self" + ], + [ + "const godot_int", + "p_size" + ] + ] + }, + { + "name": "godot_packed_glyph_array_ptr", + "return_type": "const godot_glyph *", + "arguments": [ + [ + "const godot_packed_glyph_array *", + "p_self" + ] + ] + }, + { + "name": "godot_packed_glyph_array_ptrw", + "return_type": "godot_glyph *", + "arguments": [ + [ + "godot_packed_glyph_array *", + "p_self" + ] + ] + }, + { + "name": "godot_packed_glyph_array_set", + "return_type": "void", + "arguments": [ + [ + "godot_packed_glyph_array *", + "p_self" + ], + [ + "const godot_int", + "p_idx" + ], + [ + "const godot_glyph *", + "p_data" + ] + ] + }, + { + "name": "godot_packed_glyph_array_get", + "return_type": "godot_glyph", + "arguments": [ + [ + "const godot_packed_glyph_array *", + "p_self" + ], + [ + "const godot_int", + "p_idx" + ] + ] + }, + { + "name": "godot_packed_glyph_array_size", + "return_type": "godot_int", + "arguments": [ + [ + "const godot_packed_glyph_array *", + "p_self" + ] + ] + }, + { + "name": "godot_packed_glyph_array_destroy", + "return_type": "void", + "arguments": [ + [ + "godot_packed_glyph_array *", + "p_self" + ] + ] + } + ] + } + ] } diff --git a/modules/gdnative/gdnative_library_editor_plugin.cpp b/modules/gdnative/gdnative_library_editor_plugin.cpp index 5ea5c8ee8d..dfb26c13e3 100644 --- a/modules/gdnative/gdnative_library_editor_plugin.cpp +++ b/modules/gdnative/gdnative_library_editor_plugin.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -65,7 +65,7 @@ void GDNativeLibraryEditor::_update_tree() { continue; } Map<String, NativePlatformConfig>::Element *E = platforms.find(filter_list->get_item_metadata(i)); - if (!text.empty()) { + if (!text.is_empty()) { text += ", "; } text += E->get().name; @@ -91,7 +91,7 @@ void GDNativeLibraryEditor::_update_tree() { bit->add_button(1, get_theme_icon("Folder", "EditorIcons"), BUTTON_SELECT_LIBRARY, false, TTR("Select the dynamic library for this entry")); String file = entry_configs[target].library; - if (!file.empty()) { + if (!file.is_empty()) { bit->add_button(1, get_theme_icon("Clear", "EditorIcons"), BUTTON_CLEAR_LIBRARY, false, TTR("Clear")); } bit->set_text(1, file); @@ -195,7 +195,7 @@ void GDNativeLibraryEditor::_on_item_activated() { void GDNativeLibraryEditor::_on_create_new_entry() { String platform = new_architecture_dialog->get_meta("platform"); String entry = new_architecture_input->get_text().strip_edges(); - if (!entry.empty()) { + if (!entry.is_empty()) { platforms[platform].entries.push_back(entry); _update_tree(); } @@ -248,7 +248,7 @@ void GDNativeLibraryEditor::_translate_to_config_file() { for (Map<String, NativePlatformConfig>::Element *E = platforms.front(); E; E = E->next()) { for (List<String>::Element *it = E->value().entries.front(); it; it = it->next()) { String target = E->key() + "." + it->get(); - if (entry_configs[target].library.empty() && entry_configs[target].dependencies.empty()) { + if (entry_configs[target].library.is_empty() && entry_configs[target].dependencies.is_empty()) { continue; } @@ -257,7 +257,7 @@ void GDNativeLibraryEditor::_translate_to_config_file() { } } - library->_change_notify(); + library->notify_property_list_changed(); } } diff --git a/modules/gdnative/gdnative_library_editor_plugin.h b/modules/gdnative/gdnative_library_editor_plugin.h index 180ab7707c..61afb1aaaa 100644 --- a/modules/gdnative/gdnative_library_editor_plugin.h +++ b/modules/gdnative/gdnative_library_editor_plugin.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -95,9 +95,9 @@ public: class GDNativeLibraryEditorPlugin : public EditorPlugin { GDCLASS(GDNativeLibraryEditorPlugin, EditorPlugin); - GDNativeLibraryEditor *library_editor; - EditorNode *editor; - Button *button; + GDNativeLibraryEditor *library_editor = nullptr; + EditorNode *editor = nullptr; + Button *button = nullptr; public: virtual String get_name() const override { return "GDNativeLibrary"; } diff --git a/modules/gdnative/gdnative_library_singleton_editor.cpp b/modules/gdnative/gdnative_library_singleton_editor.cpp index 409b6cbffe..f1b4a9a81b 100644 --- a/modules/gdnative/gdnative_library_singleton_editor.cpp +++ b/modules/gdnative/gdnative_library_singleton_editor.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gdnative/gdnative_library_singleton_editor.h b/modules/gdnative/gdnative_library_singleton_editor.h index 1a213d8094..5bb823d920 100644 --- a/modules/gdnative/gdnative_library_singleton_editor.h +++ b/modules/gdnative/gdnative_library_singleton_editor.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gdnative/include/android/godot_android.h b/modules/gdnative/include/android/godot_android.h index 45d4eaff37..867ef9e03a 100644 --- a/modules/gdnative/include/android/godot_android.h +++ b/modules/gdnative/include/android/godot_android.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gdnative/include/gdnative/aabb.h b/modules/gdnative/include/gdnative/aabb.h index c776297944..be0235221f 100644 --- a/modules/gdnative/include/gdnative/aabb.h +++ b/modules/gdnative/include/gdnative/aabb.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -35,9 +35,9 @@ extern "C" { #endif -#include <stdint.h> +#include <gdnative/math_defs.h> -#define GODOT_AABB_SIZE 24 +#define GODOT_AABB_SIZE (sizeof(godot_real_t) * 6) #ifndef GODOT_CORE_API_GODOT_AABB_TYPE_DEFINED #define GODOT_CORE_API_GODOT_AABB_TYPE_DEFINED @@ -46,72 +46,9 @@ typedef struct { } godot_aabb; #endif -// reduce extern "C" nesting for VS2013 -#ifdef __cplusplus -} -#endif - #include <gdnative/gdnative.h> -#include <gdnative/plane.h> -#include <gdnative/vector3.h> - -#ifdef __cplusplus -extern "C" { -#endif - -void GDAPI godot_aabb_new(godot_aabb *r_dest, const godot_vector3 *p_pos, const godot_vector3 *p_size); - -godot_vector3 GDAPI godot_aabb_get_position(const godot_aabb *p_self); -void GDAPI godot_aabb_set_position(const godot_aabb *p_self, const godot_vector3 *p_v); - -godot_vector3 GDAPI godot_aabb_get_size(const godot_aabb *p_self); -void GDAPI godot_aabb_set_size(const godot_aabb *p_self, const godot_vector3 *p_v); - -godot_string GDAPI godot_aabb_as_string(const godot_aabb *p_self); - -godot_aabb GDAPI godot_aabb_abs(const godot_aabb *p_self); - -godot_real GDAPI godot_aabb_get_area(const godot_aabb *p_self); - -godot_bool GDAPI godot_aabb_has_no_area(const godot_aabb *p_self); - -godot_bool GDAPI godot_aabb_has_no_surface(const godot_aabb *p_self); - -godot_bool GDAPI godot_aabb_intersects(const godot_aabb *p_self, const godot_aabb *p_with); - -godot_bool GDAPI godot_aabb_encloses(const godot_aabb *p_self, const godot_aabb *p_with); - -godot_aabb GDAPI godot_aabb_merge(const godot_aabb *p_self, const godot_aabb *p_with); - -godot_aabb GDAPI godot_aabb_intersection(const godot_aabb *p_self, const godot_aabb *p_with); - -godot_bool GDAPI godot_aabb_intersects_plane(const godot_aabb *p_self, const godot_plane *p_plane); - -godot_bool GDAPI godot_aabb_intersects_segment(const godot_aabb *p_self, const godot_vector3 *p_from, const godot_vector3 *p_to); - -godot_bool GDAPI godot_aabb_has_point(const godot_aabb *p_self, const godot_vector3 *p_point); - -godot_vector3 GDAPI godot_aabb_get_support(const godot_aabb *p_self, const godot_vector3 *p_dir); - -godot_vector3 GDAPI godot_aabb_get_longest_axis(const godot_aabb *p_self); - -godot_int GDAPI godot_aabb_get_longest_axis_index(const godot_aabb *p_self); - -godot_real GDAPI godot_aabb_get_longest_axis_size(const godot_aabb *p_self); - -godot_vector3 GDAPI godot_aabb_get_shortest_axis(const godot_aabb *p_self); - -godot_int GDAPI godot_aabb_get_shortest_axis_index(const godot_aabb *p_self); - -godot_real GDAPI godot_aabb_get_shortest_axis_size(const godot_aabb *p_self); - -godot_aabb GDAPI godot_aabb_expand(const godot_aabb *p_self, const godot_vector3 *p_to_point); - -godot_aabb GDAPI godot_aabb_grow(const godot_aabb *p_self, const godot_real p_by); - -godot_vector3 GDAPI godot_aabb_get_endpoint(const godot_aabb *p_self, const godot_int p_idx); -godot_bool GDAPI godot_aabb_operator_equal(const godot_aabb *p_self, const godot_aabb *p_b); +void GDAPI godot_aabb_new(godot_aabb *p_self); #ifdef __cplusplus } diff --git a/modules/gdnative/include/gdnative/array.h b/modules/gdnative/include/gdnative/array.h index 7a59493b7d..7603edaa73 100644 --- a/modules/gdnative/include/gdnative/array.h +++ b/modules/gdnative/include/gdnative/array.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -46,102 +46,13 @@ typedef struct { } godot_array; #endif -// reduce extern "C" nesting for VS2013 -#ifdef __cplusplus -} -#endif - -#include <gdnative/packed_arrays.h> -#include <gdnative/variant.h> - #include <gdnative/gdnative.h> +#include <gdnative/variant_struct.h> -#ifdef __cplusplus -extern "C" { -#endif - -void GDAPI godot_array_new(godot_array *r_dest); -void GDAPI godot_array_new_copy(godot_array *r_dest, const godot_array *p_src); -void GDAPI godot_array_new_packed_color_array(godot_array *r_dest, const godot_packed_color_array *p_pca); -void GDAPI godot_array_new_packed_vector3_array(godot_array *r_dest, const godot_packed_vector3_array *p_pv3a); -void GDAPI godot_array_new_packed_vector2_array(godot_array *r_dest, const godot_packed_vector2_array *p_pv2a); -void GDAPI godot_array_new_packed_vector2i_array(godot_array *r_dest, const godot_packed_vector2i_array *p_pv2a); -void GDAPI godot_array_new_packed_string_array(godot_array *r_dest, const godot_packed_string_array *p_psa); -void GDAPI godot_array_new_packed_float32_array(godot_array *r_dest, const godot_packed_float32_array *p_pra); -void GDAPI godot_array_new_packed_float64_array(godot_array *r_dest, const godot_packed_float64_array *p_pra); -void GDAPI godot_array_new_packed_int32_array(godot_array *r_dest, const godot_packed_int32_array *p_pia); -void GDAPI godot_array_new_packed_int64_array(godot_array *r_dest, const godot_packed_int64_array *p_pia); -void GDAPI godot_array_new_packed_byte_array(godot_array *r_dest, const godot_packed_byte_array *p_pba); - -void GDAPI godot_array_set(godot_array *p_self, const godot_int p_idx, const godot_variant *p_value); - -godot_variant GDAPI godot_array_get(const godot_array *p_self, const godot_int p_idx); - -godot_variant GDAPI *godot_array_operator_index(godot_array *p_self, const godot_int p_idx); - -const godot_variant GDAPI *godot_array_operator_index_const(const godot_array *p_self, const godot_int p_idx); - -void GDAPI godot_array_append(godot_array *p_self, const godot_variant *p_value); - -void GDAPI godot_array_clear(godot_array *p_self); - -godot_int GDAPI godot_array_count(const godot_array *p_self, const godot_variant *p_value); - -godot_bool GDAPI godot_array_empty(const godot_array *p_self); - -void GDAPI godot_array_erase(godot_array *p_self, const godot_variant *p_value); - -godot_variant GDAPI godot_array_front(const godot_array *p_self); - -godot_variant GDAPI godot_array_back(const godot_array *p_self); - -godot_int GDAPI godot_array_find(const godot_array *p_self, const godot_variant *p_what, const godot_int p_from); - -godot_int GDAPI godot_array_find_last(const godot_array *p_self, const godot_variant *p_what); - -godot_bool GDAPI godot_array_has(const godot_array *p_self, const godot_variant *p_value); - -godot_int GDAPI godot_array_hash(const godot_array *p_self); - -void GDAPI godot_array_insert(godot_array *p_self, const godot_int p_pos, const godot_variant *p_value); - -void GDAPI godot_array_invert(godot_array *p_self); - -godot_variant GDAPI godot_array_pop_back(godot_array *p_self); - -godot_variant GDAPI godot_array_pop_front(godot_array *p_self); - -void GDAPI godot_array_push_back(godot_array *p_self, const godot_variant *p_value); - -void GDAPI godot_array_push_front(godot_array *p_self, const godot_variant *p_value); - -void GDAPI godot_array_remove(godot_array *p_self, const godot_int p_idx); - -void GDAPI godot_array_resize(godot_array *p_self, const godot_int p_size); - -godot_int GDAPI godot_array_rfind(const godot_array *p_self, const godot_variant *p_what, const godot_int p_from); - -godot_int GDAPI godot_array_size(const godot_array *p_self); - -void GDAPI godot_array_sort(godot_array *p_self); - -void GDAPI godot_array_sort_custom(godot_array *p_self, godot_object *p_obj, const godot_string *p_func); - -godot_int GDAPI godot_array_bsearch(godot_array *p_self, const godot_variant *p_value, const godot_bool 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); - +void GDAPI godot_array_new(godot_array *p_self); void GDAPI godot_array_destroy(godot_array *p_self); - -godot_array GDAPI godot_array_duplicate(const godot_array *p_self, const godot_bool p_deep); - -godot_array GDAPI godot_array_slice(const godot_array *p_self, const godot_int p_begin, const godot_int p_end, const godot_int p_step, const godot_bool p_deep); - -godot_variant GDAPI godot_array_max(const godot_array *p_self); - -godot_variant GDAPI godot_array_min(const godot_array *p_self); - -void GDAPI godot_array_shuffle(godot_array *p_self); +godot_variant GDAPI *godot_array_operator_index(godot_array *p_self, godot_int p_index); +const godot_variant GDAPI *godot_array_operator_index_const(const godot_array *p_self, godot_int p_index); #ifdef __cplusplus } diff --git a/modules/gdnative/include/gdnative/basis.h b/modules/gdnative/include/gdnative/basis.h index c7425ebbfa..af8d7cbdd3 100644 --- a/modules/gdnative/include/gdnative/basis.h +++ b/modules/gdnative/include/gdnative/basis.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -35,9 +35,9 @@ extern "C" { #endif -#include <stdint.h> +#include <gdnative/math_defs.h> -#define GODOT_BASIS_SIZE 36 +#define GODOT_BASIS_SIZE (sizeof(godot_real_t) * 9) #ifndef GODOT_CORE_API_GODOT_BASIS_TYPE_DEFINED #define GODOT_CORE_API_GODOT_BASIS_TYPE_DEFINED @@ -46,88 +46,11 @@ typedef struct { } godot_basis; #endif -// reduce extern "C" nesting for VS2013 -#ifdef __cplusplus -} -#endif - #include <gdnative/gdnative.h> -#include <gdnative/quat.h> -#include <gdnative/vector3.h> - -#ifdef __cplusplus -extern "C" { -#endif - -void GDAPI godot_basis_new_with_rows(godot_basis *r_dest, const godot_vector3 *p_x_axis, const godot_vector3 *p_y_axis, const godot_vector3 *p_z_axis); -void GDAPI godot_basis_new_with_axis_and_angle(godot_basis *r_dest, const godot_vector3 *p_axis, const godot_real p_phi); -void GDAPI godot_basis_new_with_euler(godot_basis *r_dest, const godot_vector3 *p_euler); -void GDAPI godot_basis_new_with_euler_quat(godot_basis *r_dest, const godot_quat *p_euler); - -godot_string GDAPI godot_basis_as_string(const godot_basis *p_self); - -godot_basis GDAPI godot_basis_inverse(const godot_basis *p_self); - -godot_basis GDAPI godot_basis_transposed(const godot_basis *p_self); - -godot_basis GDAPI godot_basis_orthonormalized(const godot_basis *p_self); - -godot_real GDAPI godot_basis_determinant(const godot_basis *p_self); - -godot_basis GDAPI godot_basis_rotated(const godot_basis *p_self, const godot_vector3 *p_axis, const godot_real p_phi); - -godot_basis GDAPI godot_basis_scaled(const godot_basis *p_self, const godot_vector3 *p_scale); - -godot_vector3 GDAPI godot_basis_get_scale(const godot_basis *p_self); - -godot_vector3 GDAPI godot_basis_get_euler(const godot_basis *p_self); - -godot_quat GDAPI godot_basis_get_quat(const godot_basis *p_self); - -void GDAPI godot_basis_set_quat(godot_basis *p_self, const godot_quat *p_quat); - -void GDAPI godot_basis_set_axis_angle_scale(godot_basis *p_self, const godot_vector3 *p_axis, godot_real p_phi, const godot_vector3 *p_scale); - -void GDAPI godot_basis_set_euler_scale(godot_basis *p_self, const godot_vector3 *p_euler, const godot_vector3 *p_scale); - -void GDAPI godot_basis_set_quat_scale(godot_basis *p_self, const godot_quat *p_quat, const godot_vector3 *p_scale); - -godot_real GDAPI godot_basis_tdotx(const godot_basis *p_self, const godot_vector3 *p_with); - -godot_real GDAPI godot_basis_tdoty(const godot_basis *p_self, const godot_vector3 *p_with); - -godot_real GDAPI godot_basis_tdotz(const godot_basis *p_self, const godot_vector3 *p_with); - -godot_vector3 GDAPI godot_basis_xform(const godot_basis *p_self, const godot_vector3 *p_v); - -godot_vector3 GDAPI godot_basis_xform_inv(const godot_basis *p_self, const godot_vector3 *p_v); - -godot_int GDAPI godot_basis_get_orthogonal_index(const godot_basis *p_self); - -void GDAPI godot_basis_new(godot_basis *r_dest); - -// p_elements is a pointer to an array of 3 (!!) vector3 -void GDAPI godot_basis_get_elements(const godot_basis *p_self, godot_vector3 *p_elements); - -godot_vector3 GDAPI godot_basis_get_axis(const godot_basis *p_self, const godot_int p_axis); - -void GDAPI godot_basis_set_axis(godot_basis *p_self, const godot_int p_axis, const godot_vector3 *p_value); - -godot_vector3 GDAPI godot_basis_get_row(const godot_basis *p_self, const godot_int p_row); - -void GDAPI godot_basis_set_row(godot_basis *p_self, const godot_int p_row, const godot_vector3 *p_value); - -godot_bool GDAPI godot_basis_operator_equal(const godot_basis *p_self, const godot_basis *p_b); - -godot_basis GDAPI godot_basis_operator_add(const godot_basis *p_self, const godot_basis *p_b); - -godot_basis GDAPI godot_basis_operator_subtract(const godot_basis *p_self, const godot_basis *p_b); - -godot_basis GDAPI godot_basis_operator_multiply_vector(const godot_basis *p_self, const godot_basis *p_b); - -godot_basis GDAPI godot_basis_operator_multiply_scalar(const godot_basis *p_self, const godot_real p_b); -godot_basis GDAPI godot_basis_slerp(const godot_basis *p_self, const godot_basis *p_b, const godot_real p_t); +void GDAPI godot_basis_new(godot_basis *p_self); +godot_vector3 GDAPI *godot_basis_operator_index(godot_basis *p_self, godot_int p_index); +const godot_vector3 GDAPI *godot_basis_operator_index_const(const godot_basis *p_self, godot_int p_index); #ifdef __cplusplus } diff --git a/modules/gdnative/include/gdnative/callable.h b/modules/gdnative/include/gdnative/callable.h index dbb5d02590..6f359ada5e 100644 --- a/modules/gdnative/include/gdnative/callable.h +++ b/modules/gdnative/include/gdnative/callable.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -46,79 +46,11 @@ typedef struct { } godot_callable; #endif -#define GODOT_SIGNAL_SIZE (16) - -#ifndef GODOT_CORE_API_GODOT_SIGNAL_TYPE_DEFINED -#define GODOT_CORE_API_GODOT_SIGNAL_TYPE_DEFINED -typedef struct { - uint8_t _dont_touch_that[GODOT_SIGNAL_SIZE]; -} godot_signal; -#endif - -#ifdef __cplusplus -} -#endif - #include <gdnative/gdnative.h> -#include <gdnative/string_name.h> - -#ifdef __cplusplus -extern "C" { -#endif - -// Callable - -void GDAPI godot_callable_new_with_object(godot_callable *r_dest, const godot_object *p_object, const godot_string_name *p_method); -void GDAPI godot_callable_new_with_object_id(godot_callable *r_dest, uint64_t p_objectid, const godot_string_name *p_method); -void GDAPI godot_callable_new_copy(godot_callable *r_dest, const godot_callable *p_src); +void GDAPI godot_callable_new(godot_callable *p_self); void GDAPI godot_callable_destroy(godot_callable *p_self); -godot_int GDAPI godot_callable_call(const godot_callable *p_self, const godot_variant **p_arguments, godot_int p_argcount, godot_variant *r_return_value); -void GDAPI godot_callable_call_deferred(const godot_callable *p_self, const godot_variant **p_arguments, godot_int p_argcount); - -godot_bool GDAPI godot_callable_is_null(const godot_callable *p_self); -godot_bool GDAPI godot_callable_is_custom(const godot_callable *p_self); -godot_bool GDAPI godot_callable_is_standard(const godot_callable *p_self); - -godot_object GDAPI *godot_callable_get_object(const godot_callable *p_self); -uint64_t GDAPI godot_callable_get_object_id(const godot_callable *p_self); -godot_string_name GDAPI godot_callable_get_method(const godot_callable *p_self); - -uint32_t GDAPI godot_callable_hash(const godot_callable *p_self); - -godot_string GDAPI godot_callable_as_string(const godot_callable *p_self); - -godot_bool GDAPI godot_callable_operator_equal(const godot_callable *p_self, const godot_callable *p_other); -godot_bool GDAPI godot_callable_operator_less(const godot_callable *p_self, const godot_callable *p_other); - -// Signal - -void GDAPI godot_signal_new_with_object(godot_signal *r_dest, const godot_object *p_object, const godot_string_name *p_name); -void GDAPI godot_signal_new_with_object_id(godot_signal *r_dest, uint64_t p_objectid, const godot_string_name *p_name); -void GDAPI godot_signal_new_copy(godot_signal *r_dest, const godot_signal *p_src); - -void GDAPI godot_signal_destroy(godot_signal *p_self); - -godot_int GDAPI godot_signal_emit(const godot_signal *p_self, const godot_variant **p_arguments, godot_int p_argcount); - -godot_int GDAPI godot_signal_connect(godot_signal *p_self, const godot_callable *p_callable, const godot_array *p_binds, uint32_t p_flags); -void GDAPI godot_signal_disconnect(godot_signal *p_self, const godot_callable *p_callable); - -godot_bool GDAPI godot_signal_is_null(const godot_signal *p_self); -godot_bool GDAPI godot_signal_is_connected(const godot_signal *p_self, const godot_callable *p_callable); - -godot_array GDAPI godot_signal_get_connections(const godot_signal *p_self); - -godot_object GDAPI *godot_signal_get_object(const godot_signal *p_self); -uint64_t GDAPI godot_signal_get_object_id(const godot_signal *p_self); -godot_string_name GDAPI godot_signal_get_name(const godot_signal *p_self); - -godot_string GDAPI godot_signal_as_string(const godot_signal *p_self); - -godot_bool GDAPI godot_signal_operator_equal(const godot_signal *p_self, const godot_signal *p_other); -godot_bool GDAPI godot_signal_operator_less(const godot_signal *p_self, const godot_signal *p_other); - #ifdef __cplusplus } #endif diff --git a/modules/gdnative/include/gdnative/color.h b/modules/gdnative/include/gdnative/color.h index e64097ef57..17a021e6ea 100644 --- a/modules/gdnative/include/gdnative/color.h +++ b/modules/gdnative/include/gdnative/color.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -35,9 +35,10 @@ extern "C" { #endif -#include <stdint.h> +#include <gdnative/math_defs.h> -#define GODOT_COLOR_SIZE 16 +// Colors should always use 32-bit floats, so don't use real_t here. +#define GODOT_COLOR_SIZE (sizeof(float) * 4) #ifndef GODOT_CORE_API_GODOT_COLOR_TYPE_DEFINED #define GODOT_CORE_API_GODOT_COLOR_TYPE_DEFINED @@ -46,68 +47,11 @@ typedef struct { } godot_color; #endif -// reduce extern "C" nesting for VS2013 -#ifdef __cplusplus -} -#endif - #include <gdnative/gdnative.h> -#include <gdnative/string.h> - -#ifdef __cplusplus -extern "C" { -#endif - -void GDAPI godot_color_new_rgba(godot_color *r_dest, const godot_real p_r, const godot_real p_g, const godot_real p_b, const godot_real p_a); -void GDAPI godot_color_new_rgb(godot_color *r_dest, const godot_real p_r, const godot_real p_g, const godot_real p_b); - -godot_real godot_color_get_r(const godot_color *p_self); -void godot_color_set_r(godot_color *p_self, const godot_real r); - -godot_real godot_color_get_g(const godot_color *p_self); -void godot_color_set_g(godot_color *p_self, const godot_real g); - -godot_real godot_color_get_b(const godot_color *p_self); -void godot_color_set_b(godot_color *p_self, const godot_real b); - -godot_real godot_color_get_a(const godot_color *p_self); -void godot_color_set_a(godot_color *p_self, const godot_real a); - -godot_real godot_color_get_h(const godot_color *p_self); -godot_real godot_color_get_s(const godot_color *p_self); -godot_real godot_color_get_v(const godot_color *p_self); - -godot_string GDAPI godot_color_as_string(const godot_color *p_self); - -godot_int GDAPI godot_color_to_rgba32(const godot_color *p_self); - -godot_int GDAPI godot_color_to_abgr32(const godot_color *p_self); - -godot_int GDAPI godot_color_to_abgr64(const godot_color *p_self); - -godot_int GDAPI godot_color_to_argb64(const godot_color *p_self); - -godot_int GDAPI godot_color_to_rgba64(const godot_color *p_self); - -godot_int GDAPI godot_color_to_argb32(const godot_color *p_self); - -godot_color GDAPI godot_color_inverted(const godot_color *p_self); - -godot_color GDAPI godot_color_lerp(const godot_color *p_self, const godot_color *p_b, const godot_real p_t); - -godot_color GDAPI godot_color_blend(const godot_color *p_self, const godot_color *p_over); - -godot_color GDAPI godot_color_darkened(const godot_color *p_self, const godot_real p_amount); - -godot_color GDAPI godot_color_from_hsv(const godot_color *p_self, const godot_real p_h, const godot_real p_s, const godot_real p_v, const godot_real p_a); - -godot_color GDAPI godot_color_lightened(const godot_color *p_self, const godot_real p_amount); - -godot_string GDAPI godot_color_to_html(const godot_color *p_self, const godot_bool p_with_alpha); - -godot_bool GDAPI godot_color_operator_equal(const godot_color *p_self, const godot_color *p_b); -godot_bool GDAPI godot_color_operator_less(const godot_color *p_self, const godot_color *p_b); +void GDAPI godot_color_new(godot_color *p_self); +float GDAPI *godot_color_operator_index(godot_color *p_self, godot_int p_index); +const float GDAPI *godot_color_operator_index_const(const godot_color *p_self, godot_int p_index); #ifdef __cplusplus } diff --git a/modules/gdnative/include/gdnative/dictionary.h b/modules/gdnative/include/gdnative/dictionary.h index 873efaa9bf..d2afbc4c94 100644 --- a/modules/gdnative/include/gdnative/dictionary.h +++ b/modules/gdnative/include/gdnative/dictionary.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -46,62 +46,14 @@ typedef struct { } godot_dictionary; #endif -// reduce extern "C" nesting for VS2013 -#ifdef __cplusplus -} -#endif - -#include <gdnative/array.h> #include <gdnative/gdnative.h> -#include <gdnative/variant.h> - -#ifdef __cplusplus -extern "C" { -#endif +#include <gdnative/variant_struct.h> -void GDAPI godot_dictionary_new(godot_dictionary *r_dest); -void GDAPI godot_dictionary_new_copy(godot_dictionary *r_dest, const godot_dictionary *p_src); +void GDAPI godot_dictionary_new(godot_dictionary *p_self); void GDAPI godot_dictionary_destroy(godot_dictionary *p_self); - -godot_dictionary GDAPI godot_dictionary_duplicate(const godot_dictionary *p_self, const godot_bool p_deep); - -godot_int GDAPI godot_dictionary_size(const godot_dictionary *p_self); - -godot_bool GDAPI godot_dictionary_empty(const godot_dictionary *p_self); - -void GDAPI godot_dictionary_clear(godot_dictionary *p_self); - -godot_bool GDAPI godot_dictionary_has(const godot_dictionary *p_self, const godot_variant *p_key); - -godot_bool GDAPI godot_dictionary_has_all(const godot_dictionary *p_self, const godot_array *p_keys); - -void GDAPI godot_dictionary_erase(godot_dictionary *p_self, const godot_variant *p_key); - -godot_int GDAPI godot_dictionary_hash(const godot_dictionary *p_self); - -godot_array GDAPI godot_dictionary_keys(const godot_dictionary *p_self); - -godot_array GDAPI godot_dictionary_values(const godot_dictionary *p_self); - -godot_variant GDAPI godot_dictionary_get(const godot_dictionary *p_self, const godot_variant *p_key); -void GDAPI godot_dictionary_set(godot_dictionary *p_self, const godot_variant *p_key, const godot_variant *p_value); - godot_variant GDAPI *godot_dictionary_operator_index(godot_dictionary *p_self, const godot_variant *p_key); - const godot_variant GDAPI *godot_dictionary_operator_index_const(const godot_dictionary *p_self, const godot_variant *p_key); -godot_variant GDAPI *godot_dictionary_next(const godot_dictionary *p_self, const godot_variant *p_key); - -godot_bool GDAPI godot_dictionary_operator_equal(const godot_dictionary *p_self, const godot_dictionary *p_b); - -godot_string GDAPI godot_dictionary_to_json(const godot_dictionary *p_self); - -// GDNative core 1.1 - -godot_bool GDAPI godot_dictionary_erase_with_return(godot_dictionary *p_self, const godot_variant *p_key); - -godot_variant GDAPI godot_dictionary_get_with_default(const godot_dictionary *p_self, const godot_variant *p_key, const godot_variant *p_default); - #ifdef __cplusplus } #endif diff --git a/modules/gdnative/include/gdnative/gdnative.h b/modules/gdnative/include/gdnative/gdnative.h index 6a0a375da8..a4ed7ebb8c 100644 --- a/modules/gdnative/include/gdnative/gdnative.h +++ b/modules/gdnative/include/gdnative/gdnative.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -62,8 +62,6 @@ extern "C" { #include <stdbool.h> #include <stdint.h> -#define GODOT_API_VERSION 1 - ////// Error typedef enum { @@ -118,21 +116,6 @@ typedef enum { GODOT_ERR_PRINTER_ON_FIRE, /// the parallel port printer is engulfed in flames } godot_error; -////// bool - -typedef bool godot_bool; - -#define GODOT_TRUE 1 -#define GODOT_FALSE 0 - -/////// int - -typedef int64_t godot_int; - -/////// real - -typedef float godot_real; - /////// Object (forward declared) typedef void godot_object; @@ -215,7 +198,7 @@ void GDAPI godot_object_destroy(godot_object *p_o); ////// Singleton API -godot_object GDAPI *godot_global_get_singleton(char *p_name); // result shouldn't be freed +godot_object GDAPI *godot_global_get_singleton(char *p_name); // Result shouldn't be freed. ////// MethodBind API @@ -281,12 +264,10 @@ void GDAPI *godot_alloc(int p_bytes); void GDAPI *godot_realloc(void *p_ptr, int p_bytes); void GDAPI godot_free(void *p_ptr); -//print using Godot's error handler list +// Helper print functions. void GDAPI godot_print_error(const char *p_description, const char *p_function, const char *p_file, int p_line); void GDAPI godot_print_warning(const char *p_description, const char *p_function, const char *p_file, int p_line); -void GDAPI godot_print(const godot_string *p_message); - -// GDNATIVE CORE 1.0.2? +void GDAPI godot_print_script_error(const char *p_description, const char *p_function, const char *p_file, int p_line); //tags used for safe dynamic casting void GDAPI *godot_get_class_tag(const godot_string_name *p_class); @@ -301,4 +282,4 @@ uint64_t GDAPI godot_object_get_instance_id(const godot_object *p_object); } #endif -#endif // GODOT_C_H +#endif // GODOT_GDNATIVE_H diff --git a/modules/icloud/icloud_module.cpp b/modules/gdnative/include/gdnative/math_defs.h index 43fdc7d45e..b5cf389506 100644 --- a/modules/icloud/icloud_module.cpp +++ b/modules/gdnative/include/gdnative/math_defs.h @@ -1,12 +1,12 @@ /*************************************************************************/ -/* icloud_module.cpp */ +/* math_defs.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -28,21 +28,39 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "icloud_module.h" +#ifndef GODOT_GDNATIVE_MATH_DEFS_H +#define GODOT_GDNATIVE_MATH_DEFS_H -#include "core/config/engine.h" +#ifdef __cplusplus +extern "C" { +#endif -#include "icloud.h" +#include <stdbool.h> +#include <stdint.h> -ICloud *icloud; +////// bool -void register_icloud_types() { - icloud = memnew(ICloud); - Engine::get_singleton()->add_singleton(Engine::Singleton("ICloud", icloud)); -} +typedef bool godot_bool; + +#define GODOT_TRUE 1 +#define GODOT_FALSE 0 + +/////// int + +typedef int64_t godot_int; -void unregister_icloud_types() { - if (icloud) { - memdelete(icloud); - } +/////// float + +typedef double godot_float; + +#ifdef REAL_T_IS_DOUBLE +typedef double godot_real_t; +#else +typedef float godot_real_t; +#endif + +#ifdef __cplusplus } +#endif + +#endif // GODOT_C_H diff --git a/modules/gdnative/include/gdnative/node_path.h b/modules/gdnative/include/gdnative/node_path.h index 0cd0c3cb9c..3c31b9a98f 100644 --- a/modules/gdnative/include/gdnative/node_path.h +++ b/modules/gdnative/include/gdnative/node_path.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -46,42 +46,11 @@ typedef struct { } godot_node_path; #endif -// reduce extern "C" nesting for VS2013 -#ifdef __cplusplus -} -#endif - #include <gdnative/gdnative.h> -#include <gdnative/string.h> -#ifdef __cplusplus -extern "C" { -#endif - -void GDAPI godot_node_path_new(godot_node_path *r_dest, const godot_string *p_from); -void GDAPI godot_node_path_new_copy(godot_node_path *r_dest, const godot_node_path *p_src); +void GDAPI godot_node_path_new(godot_node_path *p_self); void GDAPI godot_node_path_destroy(godot_node_path *p_self); -godot_string GDAPI godot_node_path_as_string(const godot_node_path *p_self); - -godot_bool GDAPI godot_node_path_is_absolute(const godot_node_path *p_self); - -godot_int GDAPI godot_node_path_get_name_count(const godot_node_path *p_self); - -godot_string GDAPI godot_node_path_get_name(const godot_node_path *p_self, const godot_int p_idx); - -godot_int GDAPI godot_node_path_get_subname_count(const godot_node_path *p_self); - -godot_string GDAPI godot_node_path_get_subname(const godot_node_path *p_self, const godot_int p_idx); - -godot_string GDAPI godot_node_path_get_concatenated_subnames(const godot_node_path *p_self); - -godot_bool GDAPI godot_node_path_is_empty(const godot_node_path *p_self); - -godot_bool GDAPI godot_node_path_operator_equal(const godot_node_path *p_self, const godot_node_path *p_b); - -godot_node_path godot_node_path_get_as_property_path(const godot_node_path *p_self); - #ifdef __cplusplus } #endif diff --git a/modules/gdnative/include/gdnative/packed_arrays.h b/modules/gdnative/include/gdnative/packed_arrays.h index ce9579f307..621ed60cdf 100644 --- a/modules/gdnative/include/gdnative/packed_arrays.h +++ b/modules/gdnative/include/gdnative/packed_arrays.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -136,6 +136,17 @@ typedef struct { } godot_packed_vector3_array; #endif +/////// PackedVector3iArray + +#define GODOT_PACKED_VECTOR3I_ARRAY_SIZE (2 * sizeof(void *)) + +#ifndef GODOT_CORE_API_GODOT_PACKED_VECTOR3I_ARRAY_TYPE_DEFINED +#define GODOT_CORE_API_GODOT_PACKED_VECTOR3I_ARRAY_TYPE_DEFINED +typedef struct { + uint8_t _dont_touch_that[GODOT_PACKED_VECTOR3I_ARRAY_SIZE]; +} godot_packed_vector3i_array; +#endif + /////// PackedColorArray #define GODOT_PACKED_COLOR_ARRAY_SIZE (2 * sizeof(void *)) @@ -147,384 +158,87 @@ typedef struct { } godot_packed_color_array; #endif -// reduce extern "C" nesting for VS2013 -#ifdef __cplusplus -} -#endif - -#include <gdnative/array.h> -#include <gdnative/color.h> -#include <gdnative/vector2.h> -#include <gdnative/vector3.h> - #include <gdnative/gdnative.h> -#ifdef __cplusplus -extern "C" { -#endif - -// byte - -void GDAPI godot_packed_byte_array_new(godot_packed_byte_array *r_dest); -void GDAPI godot_packed_byte_array_new_copy(godot_packed_byte_array *r_dest, const godot_packed_byte_array *p_src); -void GDAPI godot_packed_byte_array_new_with_array(godot_packed_byte_array *r_dest, const godot_array *p_a); - -const uint8_t GDAPI *godot_packed_byte_array_ptr(const godot_packed_byte_array *p_self); -uint8_t GDAPI *godot_packed_byte_array_ptrw(godot_packed_byte_array *p_self); - -void GDAPI godot_packed_byte_array_append(godot_packed_byte_array *p_self, const uint8_t p_data); - -void GDAPI godot_packed_byte_array_append_array(godot_packed_byte_array *p_self, const godot_packed_byte_array *p_array); - -godot_error GDAPI godot_packed_byte_array_insert(godot_packed_byte_array *p_self, const godot_int p_idx, const uint8_t p_data); - -godot_bool GDAPI godot_packed_byte_array_has(godot_packed_byte_array *p_self, const uint8_t p_value); - -void GDAPI godot_packed_byte_array_sort(godot_packed_byte_array *p_self); - -void GDAPI godot_packed_byte_array_invert(godot_packed_byte_array *p_self); - -void GDAPI godot_packed_byte_array_push_back(godot_packed_byte_array *p_self, const uint8_t p_data); - -void GDAPI godot_packed_byte_array_remove(godot_packed_byte_array *p_self, const godot_int p_idx); - -void GDAPI godot_packed_byte_array_resize(godot_packed_byte_array *p_self, const godot_int p_size); - -void GDAPI godot_packed_byte_array_set(godot_packed_byte_array *p_self, const godot_int p_idx, const uint8_t p_data); -uint8_t GDAPI godot_packed_byte_array_get(const godot_packed_byte_array *p_self, const godot_int p_idx); - -godot_int GDAPI godot_packed_byte_array_size(const godot_packed_byte_array *p_self); - -godot_bool GDAPI godot_packed_byte_array_empty(const godot_packed_byte_array *p_self); +// Byte. +void GDAPI godot_packed_byte_array_new(godot_packed_byte_array *p_self); void GDAPI godot_packed_byte_array_destroy(godot_packed_byte_array *p_self); +uint8_t GDAPI *godot_packed_byte_array_operator_index(godot_packed_byte_array *p_self, godot_int p_index); +const uint8_t GDAPI *godot_packed_byte_array_operator_index_const(const godot_packed_byte_array *p_self, godot_int p_index); -// int32 - -void GDAPI godot_packed_int32_array_new(godot_packed_int32_array *r_dest); -void GDAPI godot_packed_int32_array_new_copy(godot_packed_int32_array *r_dest, const godot_packed_int32_array *p_src); -void GDAPI godot_packed_int32_array_new_with_array(godot_packed_int32_array *r_dest, const godot_array *p_a); - -const int32_t GDAPI *godot_packed_int32_array_ptr(const godot_packed_int32_array *p_self); -int32_t GDAPI *godot_packed_int32_array_ptrw(godot_packed_int32_array *p_self); - -void GDAPI godot_packed_int32_array_append(godot_packed_int32_array *p_self, const int32_t p_data); - -void GDAPI godot_packed_int32_array_append_array(godot_packed_int32_array *p_self, const godot_packed_int32_array *p_array); - -godot_error GDAPI godot_packed_int32_array_insert(godot_packed_int32_array *p_self, const godot_int p_idx, const int32_t p_data); - -godot_bool GDAPI godot_packed_int32_array_has(godot_packed_int32_array *p_self, const int32_t p_value); - -void GDAPI godot_packed_int32_array_sort(godot_packed_int32_array *p_self); - -void GDAPI godot_packed_int32_array_invert(godot_packed_int32_array *p_self); - -void GDAPI godot_packed_int32_array_push_back(godot_packed_int32_array *p_self, const int32_t p_data); - -void GDAPI godot_packed_int32_array_remove(godot_packed_int32_array *p_self, const godot_int p_idx); - -void GDAPI godot_packed_int32_array_resize(godot_packed_int32_array *p_self, const godot_int p_size); - -void GDAPI godot_packed_int32_array_set(godot_packed_int32_array *p_self, const godot_int p_idx, const int32_t p_data); -int32_t GDAPI godot_packed_int32_array_get(const godot_packed_int32_array *p_self, const godot_int p_idx); - -godot_int GDAPI godot_packed_int32_array_size(const godot_packed_int32_array *p_self); - -godot_bool GDAPI godot_packed_int32_array_empty(const godot_packed_int32_array *p_self); +// Int32. +void GDAPI godot_packed_int32_array_new(godot_packed_int32_array *p_self); void GDAPI godot_packed_int32_array_destroy(godot_packed_int32_array *p_self); +int32_t GDAPI *godot_packed_int32_array_operator_index(godot_packed_int32_array *p_self, godot_int p_index); +const int32_t GDAPI *godot_packed_int32_array_operator_index_const(const godot_packed_int32_array *p_self, godot_int p_index); -// int64 - -void GDAPI godot_packed_int64_array_new(godot_packed_int64_array *r_dest); -void GDAPI godot_packed_int64_array_new_copy(godot_packed_int64_array *r_dest, const godot_packed_int64_array *p_src); -void GDAPI godot_packed_int64_array_new_with_array(godot_packed_int64_array *r_dest, const godot_array *p_a); - -const int64_t GDAPI *godot_packed_int64_array_ptr(const godot_packed_int64_array *p_self); -int64_t GDAPI *godot_packed_int64_array_ptrw(godot_packed_int64_array *p_self); - -void GDAPI godot_packed_int64_array_append(godot_packed_int64_array *p_self, const int64_t p_data); - -void GDAPI godot_packed_int64_array_append_array(godot_packed_int64_array *p_self, const godot_packed_int64_array *p_array); - -godot_error GDAPI godot_packed_int64_array_insert(godot_packed_int64_array *p_self, const godot_int p_idx, const int64_t p_data); - -godot_bool GDAPI godot_packed_int64_array_has(godot_packed_int64_array *p_self, const int64_t p_value); - -void GDAPI godot_packed_int64_array_sort(godot_packed_int64_array *p_self); - -void GDAPI godot_packed_int64_array_invert(godot_packed_int64_array *p_self); - -void GDAPI godot_packed_int64_array_push_back(godot_packed_int64_array *p_self, const int64_t p_data); - -void GDAPI godot_packed_int64_array_remove(godot_packed_int64_array *p_self, const godot_int p_idx); - -void GDAPI godot_packed_int64_array_resize(godot_packed_int64_array *p_self, const godot_int p_size); - -void GDAPI godot_packed_int64_array_set(godot_packed_int64_array *p_self, const godot_int p_idx, const int64_t p_data); -int64_t GDAPI godot_packed_int64_array_get(const godot_packed_int64_array *p_self, const godot_int p_idx); - -godot_int GDAPI godot_packed_int64_array_size(const godot_packed_int64_array *p_self); - -godot_bool GDAPI godot_packed_int64_array_empty(const godot_packed_int64_array *p_self); +// Int64. +void GDAPI godot_packed_int64_array_new(godot_packed_int64_array *p_self); void GDAPI godot_packed_int64_array_destroy(godot_packed_int64_array *p_self); +int64_t GDAPI *godot_packed_int64_array_operator_index(godot_packed_int64_array *p_self, godot_int p_index); +const int64_t GDAPI *godot_packed_int64_array_operator_index_const(const godot_packed_int64_array *p_self, godot_int p_index); -// float32 - -void GDAPI godot_packed_float32_array_new(godot_packed_float32_array *r_dest); -void GDAPI godot_packed_float32_array_new_copy(godot_packed_float32_array *r_dest, const godot_packed_float32_array *p_src); -void GDAPI godot_packed_float32_array_new_with_array(godot_packed_float32_array *r_dest, const godot_array *p_a); - -const float GDAPI *godot_packed_float32_array_ptr(const godot_packed_float32_array *p_self); -float GDAPI *godot_packed_float32_array_ptrw(godot_packed_float32_array *p_self); - -void GDAPI godot_packed_float32_array_append(godot_packed_float32_array *p_self, const float p_data); - -void GDAPI godot_packed_float32_array_append_array(godot_packed_float32_array *p_self, const godot_packed_float32_array *p_array); - -godot_error GDAPI godot_packed_float32_array_insert(godot_packed_float32_array *p_self, const godot_int p_idx, const float p_data); - -godot_bool GDAPI godot_packed_float32_array_has(godot_packed_float32_array *p_self, const float p_value); - -void GDAPI godot_packed_float32_array_sort(godot_packed_float32_array *p_self); - -void GDAPI godot_packed_float32_array_invert(godot_packed_float32_array *p_self); - -void GDAPI godot_packed_float32_array_push_back(godot_packed_float32_array *p_self, const float p_data); - -void GDAPI godot_packed_float32_array_remove(godot_packed_float32_array *p_self, const godot_int p_idx); - -void GDAPI godot_packed_float32_array_resize(godot_packed_float32_array *p_self, const godot_int p_size); - -void GDAPI godot_packed_float32_array_set(godot_packed_float32_array *p_self, const godot_int p_idx, const float p_data); -float GDAPI godot_packed_float32_array_get(const godot_packed_float32_array *p_self, const godot_int p_idx); - -godot_int GDAPI godot_packed_float32_array_size(const godot_packed_float32_array *p_self); - -godot_bool GDAPI godot_packed_float32_array_empty(const godot_packed_float32_array *p_self); +// Float32. +void GDAPI godot_packed_float32_array_new(godot_packed_float32_array *p_self); void GDAPI godot_packed_float32_array_destroy(godot_packed_float32_array *p_self); +float GDAPI *godot_packed_float32_array_operator_index(godot_packed_float32_array *p_self, godot_int p_index); +const float GDAPI *godot_packed_float32_array_operator_index_const(const godot_packed_float32_array *p_self, godot_int p_index); -// float64 - -void GDAPI godot_packed_float64_array_new(godot_packed_float64_array *r_dest); -void GDAPI godot_packed_float64_array_new_copy(godot_packed_float64_array *r_dest, const godot_packed_float64_array *p_src); -void GDAPI godot_packed_float64_array_new_with_array(godot_packed_float64_array *r_dest, const godot_array *p_a); - -const double GDAPI *godot_packed_float64_array_ptr(const godot_packed_float64_array *p_self); -double GDAPI *godot_packed_float64_array_ptrw(godot_packed_float64_array *p_self); - -void GDAPI godot_packed_float64_array_append(godot_packed_float64_array *p_self, const double p_data); - -void GDAPI godot_packed_float64_array_append_array(godot_packed_float64_array *p_self, const godot_packed_float64_array *p_array); - -godot_error GDAPI godot_packed_float64_array_insert(godot_packed_float64_array *p_self, const godot_int p_idx, const double p_data); - -godot_bool GDAPI godot_packed_float64_array_has(godot_packed_float64_array *p_self, const double p_value); - -void GDAPI godot_packed_float64_array_sort(godot_packed_float64_array *p_self); - -void GDAPI godot_packed_float64_array_invert(godot_packed_float64_array *p_self); - -void GDAPI godot_packed_float64_array_push_back(godot_packed_float64_array *p_self, const double p_data); - -void GDAPI godot_packed_float64_array_remove(godot_packed_float64_array *p_self, const godot_int p_idx); - -void GDAPI godot_packed_float64_array_resize(godot_packed_float64_array *p_self, const godot_int p_size); - -void GDAPI godot_packed_float64_array_set(godot_packed_float64_array *p_self, const godot_int p_idx, const double p_data); -double GDAPI godot_packed_float64_array_get(const godot_packed_float64_array *p_self, const godot_int p_idx); - -godot_int GDAPI godot_packed_float64_array_size(const godot_packed_float64_array *p_self); - -godot_bool GDAPI godot_packed_float64_array_empty(const godot_packed_float64_array *p_self); +// Float64. +void GDAPI godot_packed_float64_array_new(godot_packed_float64_array *p_self); void GDAPI godot_packed_float64_array_destroy(godot_packed_float64_array *p_self); +double GDAPI *godot_packed_float64_array_operator_index(godot_packed_float64_array *p_self, godot_int p_index); +const double GDAPI *godot_packed_float64_array_operator_index_const(const godot_packed_float64_array *p_self, godot_int p_index); -// string - -void GDAPI godot_packed_string_array_new(godot_packed_string_array *r_dest); -void GDAPI godot_packed_string_array_new_copy(godot_packed_string_array *r_dest, const godot_packed_string_array *p_src); -void GDAPI godot_packed_string_array_new_with_array(godot_packed_string_array *r_dest, const godot_array *p_a); - -const godot_string GDAPI *godot_packed_string_array_ptr(const godot_packed_string_array *p_self); -godot_string GDAPI *godot_packed_string_array_ptrw(godot_packed_string_array *p_self); - -void GDAPI godot_packed_string_array_append(godot_packed_string_array *p_self, const godot_string *p_data); - -void GDAPI godot_packed_string_array_append_array(godot_packed_string_array *p_self, const godot_packed_string_array *p_array); - -godot_error GDAPI godot_packed_string_array_insert(godot_packed_string_array *p_self, const godot_int p_idx, const godot_string *p_data); - -godot_bool GDAPI godot_packed_string_array_has(godot_packed_string_array *p_self, const godot_string *p_value); - -void GDAPI godot_packed_string_array_sort(godot_packed_string_array *p_self); - -void GDAPI godot_packed_string_array_invert(godot_packed_string_array *p_self); - -void GDAPI godot_packed_string_array_push_back(godot_packed_string_array *p_self, const godot_string *p_data); - -void GDAPI godot_packed_string_array_remove(godot_packed_string_array *p_self, const godot_int p_idx); - -void GDAPI godot_packed_string_array_resize(godot_packed_string_array *p_self, const godot_int p_size); - -void GDAPI godot_packed_string_array_set(godot_packed_string_array *p_self, const godot_int p_idx, const godot_string *p_data); -godot_string GDAPI godot_packed_string_array_get(const godot_packed_string_array *p_self, const godot_int p_idx); - -godot_int GDAPI godot_packed_string_array_size(const godot_packed_string_array *p_self); - -godot_bool GDAPI godot_packed_string_array_empty(const godot_packed_string_array *p_self); +// String. +void GDAPI godot_packed_string_array_new(godot_packed_string_array *p_self); void GDAPI godot_packed_string_array_destroy(godot_packed_string_array *p_self); +godot_string GDAPI *godot_packed_string_array_operator_index(godot_packed_string_array *p_self, godot_int p_index); +const godot_string GDAPI *godot_packed_string_array_operator_index_const(const godot_packed_string_array *p_self, godot_int p_index); -// vector2 - -void GDAPI godot_packed_vector2_array_new(godot_packed_vector2_array *r_dest); -void GDAPI godot_packed_vector2_array_new_copy(godot_packed_vector2_array *r_dest, const godot_packed_vector2_array *p_src); -void GDAPI godot_packed_vector2_array_new_with_array(godot_packed_vector2_array *r_dest, const godot_array *p_a); - -const godot_vector2 GDAPI *godot_packed_vector2_array_ptr(const godot_packed_vector2_array *p_self); -godot_vector2 GDAPI *godot_packed_vector2_array_ptrw(godot_packed_vector2_array *p_self); - -void GDAPI godot_packed_vector2_array_append(godot_packed_vector2_array *p_self, const godot_vector2 *p_data); - -void GDAPI godot_packed_vector2_array_append_array(godot_packed_vector2_array *p_self, const godot_packed_vector2_array *p_array); - -godot_error GDAPI godot_packed_vector2_array_insert(godot_packed_vector2_array *p_self, const godot_int p_idx, const godot_vector2 *p_data); - -godot_bool GDAPI godot_packed_vector2_array_has(godot_packed_vector2_array *p_self, const godot_vector2 *p_value); - -void GDAPI godot_packed_vector2_array_sort(godot_packed_vector2_array *p_self); - -void GDAPI godot_packed_vector2_array_invert(godot_packed_vector2_array *p_self); - -void GDAPI godot_packed_vector2_array_push_back(godot_packed_vector2_array *p_self, const godot_vector2 *p_data); - -void GDAPI godot_packed_vector2_array_remove(godot_packed_vector2_array *p_self, const godot_int p_idx); - -void GDAPI godot_packed_vector2_array_resize(godot_packed_vector2_array *p_self, const godot_int p_size); - -void GDAPI godot_packed_vector2_array_set(godot_packed_vector2_array *p_self, const godot_int p_idx, const godot_vector2 *p_data); -godot_vector2 GDAPI godot_packed_vector2_array_get(const godot_packed_vector2_array *p_self, const godot_int p_idx); - -godot_int GDAPI godot_packed_vector2_array_size(const godot_packed_vector2_array *p_self); - -godot_bool GDAPI godot_packed_vector2_array_empty(const godot_packed_vector2_array *p_self); +// Vector2. +void GDAPI godot_packed_vector2_array_new(godot_packed_vector2_array *p_self); void GDAPI godot_packed_vector2_array_destroy(godot_packed_vector2_array *p_self); +godot_vector2 GDAPI *godot_packed_vector2_array_operator_index(godot_packed_vector2_array *p_self, godot_int p_index); +const godot_vector2 GDAPI *godot_packed_vector2_array_operator_index_const(const godot_packed_vector2_array *p_self, godot_int p_index); -// vector2i - -void GDAPI godot_packed_vector2i_array_new(godot_packed_vector2i_array *r_dest); -void GDAPI godot_packed_vector2i_array_new_copy(godot_packed_vector2i_array *r_dest, const godot_packed_vector2i_array *p_src); -void GDAPI godot_packed_vector2i_array_new_with_array(godot_packed_vector2i_array *r_dest, const godot_array *p_a); - -const godot_vector2i GDAPI *godot_packed_vector2i_array_ptr(const godot_packed_vector2i_array *p_self); -godot_vector2i GDAPI *godot_packed_vector2i_array_ptrw(godot_packed_vector2i_array *p_self); - -void GDAPI godot_packed_vector2i_array_append(godot_packed_vector2i_array *p_self, const godot_vector2i *p_data); - -void GDAPI godot_packed_vector2i_array_append_array(godot_packed_vector2i_array *p_self, const godot_packed_vector2i_array *p_array); - -godot_error GDAPI godot_packed_vector2i_array_insert(godot_packed_vector2i_array *p_self, const godot_int p_idx, const godot_vector2i *p_data); - -godot_bool GDAPI godot_packed_vector2i_array_has(godot_packed_vector2i_array *p_self, const godot_vector2i *p_value); - -void GDAPI godot_packed_vector2i_array_sort(godot_packed_vector2i_array *p_self); - -void GDAPI godot_packed_vector2i_array_invert(godot_packed_vector2i_array *p_self); - -void GDAPI godot_packed_vector2i_array_push_back(godot_packed_vector2i_array *p_self, const godot_vector2i *p_data); - -void GDAPI godot_packed_vector2i_array_remove(godot_packed_vector2i_array *p_self, const godot_int p_idx); - -void GDAPI godot_packed_vector2i_array_resize(godot_packed_vector2i_array *p_self, const godot_int p_size); - -void GDAPI godot_packed_vector2i_array_set(godot_packed_vector2i_array *p_self, const godot_int p_idx, const godot_vector2i *p_data); -godot_vector2i GDAPI godot_packed_vector2i_array_get(const godot_packed_vector2i_array *p_self, const godot_int p_idx); - -godot_int GDAPI godot_packed_vector2i_array_size(const godot_packed_vector2i_array *p_self); - -godot_bool GDAPI godot_packed_vector2i_array_empty(const godot_packed_vector2i_array *p_self); +// Vector2i. +void GDAPI godot_packed_vector2i_array_new(godot_packed_vector2i_array *p_self); void GDAPI godot_packed_vector2i_array_destroy(godot_packed_vector2i_array *p_self); +godot_vector2i GDAPI *godot_packed_vector2i_array_operator_index(godot_packed_vector2i_array *p_self, godot_int p_index); +const godot_vector2i GDAPI *godot_packed_vector2i_array_operator_index_const(const godot_packed_vector2i_array *p_self, godot_int p_index); -// vector3 - -void GDAPI godot_packed_vector3_array_new(godot_packed_vector3_array *r_dest); -void GDAPI godot_packed_vector3_array_new_copy(godot_packed_vector3_array *r_dest, const godot_packed_vector3_array *p_src); -void GDAPI godot_packed_vector3_array_new_with_array(godot_packed_vector3_array *r_dest, const godot_array *p_a); - -const godot_vector3 GDAPI *godot_packed_vector3_array_ptr(const godot_packed_vector3_array *p_self); -godot_vector3 GDAPI *godot_packed_vector3_array_ptrw(godot_packed_vector3_array *p_self); - -void GDAPI godot_packed_vector3_array_append(godot_packed_vector3_array *p_self, const godot_vector3 *p_data); - -void GDAPI godot_packed_vector3_array_append_array(godot_packed_vector3_array *p_self, const godot_packed_vector3_array *p_array); - -godot_error GDAPI godot_packed_vector3_array_insert(godot_packed_vector3_array *p_self, const godot_int p_idx, const godot_vector3 *p_data); - -godot_bool GDAPI godot_packed_vector3_array_has(godot_packed_vector3_array *p_self, const godot_vector3 *p_value); - -void GDAPI godot_packed_vector3_array_sort(godot_packed_vector3_array *p_self); - -void GDAPI godot_packed_vector3_array_invert(godot_packed_vector3_array *p_self); - -void GDAPI godot_packed_vector3_array_push_back(godot_packed_vector3_array *p_self, const godot_vector3 *p_data); - -void GDAPI godot_packed_vector3_array_remove(godot_packed_vector3_array *p_self, const godot_int p_idx); - -void GDAPI godot_packed_vector3_array_resize(godot_packed_vector3_array *p_self, const godot_int p_size); - -void GDAPI godot_packed_vector3_array_set(godot_packed_vector3_array *p_self, const godot_int p_idx, const godot_vector3 *p_data); -godot_vector3 GDAPI godot_packed_vector3_array_get(const godot_packed_vector3_array *p_self, const godot_int p_idx); - -godot_int GDAPI godot_packed_vector3_array_size(const godot_packed_vector3_array *p_self); - -godot_bool GDAPI godot_packed_vector3_array_empty(const godot_packed_vector3_array *p_self); +// Vector3. +void GDAPI godot_packed_vector3_array_new(godot_packed_vector3_array *p_self); void GDAPI godot_packed_vector3_array_destroy(godot_packed_vector3_array *p_self); +godot_vector3 GDAPI *godot_packed_vector3_array_operator_index(godot_packed_vector3_array *p_self, godot_int p_index); +const godot_vector3 GDAPI *godot_packed_vector3_array_operator_index_const(const godot_packed_vector3_array *p_self, godot_int p_index); -// color - -void GDAPI godot_packed_color_array_new(godot_packed_color_array *r_dest); -void GDAPI godot_packed_color_array_new_copy(godot_packed_color_array *r_dest, const godot_packed_color_array *p_src); -void GDAPI godot_packed_color_array_new_with_array(godot_packed_color_array *r_dest, const godot_array *p_a); - -const godot_color GDAPI *godot_packed_color_array_ptr(const godot_packed_color_array *p_self); -godot_color GDAPI *godot_packed_color_array_ptrw(godot_packed_color_array *p_self); - -void GDAPI godot_packed_color_array_append(godot_packed_color_array *p_self, const godot_color *p_data); - -void GDAPI godot_packed_color_array_append_array(godot_packed_color_array *p_self, const godot_packed_color_array *p_array); - -godot_error GDAPI godot_packed_color_array_insert(godot_packed_color_array *p_self, const godot_int p_idx, const godot_color *p_data); - -godot_bool GDAPI godot_packed_color_array_has(godot_packed_color_array *p_self, const godot_color *p_value); - -void GDAPI godot_packed_color_array_sort(godot_packed_color_array *p_self); - -void GDAPI godot_packed_color_array_invert(godot_packed_color_array *p_self); - -void GDAPI godot_packed_color_array_push_back(godot_packed_color_array *p_self, const godot_color *p_data); - -void GDAPI godot_packed_color_array_remove(godot_packed_color_array *p_self, const godot_int p_idx); - -void GDAPI godot_packed_color_array_resize(godot_packed_color_array *p_self, const godot_int p_size); - -void GDAPI godot_packed_color_array_set(godot_packed_color_array *p_self, const godot_int p_idx, const godot_color *p_data); -godot_color GDAPI godot_packed_color_array_get(const godot_packed_color_array *p_self, const godot_int p_idx); +// Vector3i. -godot_int GDAPI godot_packed_color_array_size(const godot_packed_color_array *p_self); +void GDAPI godot_packed_vector3i_array_new(godot_packed_vector3i_array *p_self); +void GDAPI godot_packed_vector3i_array_destroy(godot_packed_vector3i_array *p_self); +godot_vector3i GDAPI *godot_packed_vector3i_array_operator_index(godot_packed_vector3i_array *p_self, godot_int p_index); +const godot_vector3i GDAPI *godot_packed_vector3i_array_operator_index_const(const godot_packed_vector3i_array *p_self, godot_int p_index); -godot_bool GDAPI godot_packed_color_array_empty(const godot_packed_color_array *p_self); +// Color. +void GDAPI godot_packed_color_array_new(godot_packed_color_array *p_self); void GDAPI godot_packed_color_array_destroy(godot_packed_color_array *p_self); +godot_color GDAPI *godot_packed_color_array_operator_index(godot_packed_color_array *p_self, godot_int p_index); +const godot_color GDAPI *godot_packed_color_array_operator_index_const(const godot_packed_color_array *p_self, godot_int p_index); #ifdef __cplusplus } #endif -#endif // GODOT_POOL_ARRAYS_H +#endif // GODOT_PACKED_ARRAYS_H diff --git a/modules/gdnative/include/gdnative/plane.h b/modules/gdnative/include/gdnative/plane.h index 9843056489..ed10955e5f 100644 --- a/modules/gdnative/include/gdnative/plane.h +++ b/modules/gdnative/include/gdnative/plane.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -35,9 +35,9 @@ extern "C" { #endif -#include <stdint.h> +#include <gdnative/math_defs.h> -#define GODOT_PLANE_SIZE 16 +#define GODOT_PLANE_SIZE (sizeof(godot_real_t) * 4) #ifndef GODOT_CORE_API_GODOT_PLANE_TYPE_DEFINED #define GODOT_CORE_API_GODOT_PLANE_TYPE_DEFINED @@ -46,53 +46,9 @@ typedef struct { } godot_plane; #endif -// reduce extern "C" nesting for VS2013 -#ifdef __cplusplus -} -#endif - #include <gdnative/gdnative.h> -#include <gdnative/vector3.h> - -#ifdef __cplusplus -extern "C" { -#endif - -void GDAPI godot_plane_new_with_reals(godot_plane *r_dest, const godot_real p_a, const godot_real p_b, const godot_real p_c, const godot_real p_d); -void GDAPI godot_plane_new_with_vectors(godot_plane *r_dest, const godot_vector3 *p_v1, const godot_vector3 *p_v2, const godot_vector3 *p_v3); -void GDAPI godot_plane_new_with_normal(godot_plane *r_dest, const godot_vector3 *p_normal, const godot_real p_d); - -godot_string GDAPI godot_plane_as_string(const godot_plane *p_self); - -godot_plane GDAPI godot_plane_normalized(const godot_plane *p_self); - -godot_vector3 GDAPI godot_plane_center(const godot_plane *p_self); - -godot_bool GDAPI godot_plane_is_point_over(const godot_plane *p_self, const godot_vector3 *p_point); - -godot_real GDAPI godot_plane_distance_to(const godot_plane *p_self, const godot_vector3 *p_point); - -godot_bool GDAPI godot_plane_has_point(const godot_plane *p_self, const godot_vector3 *p_point, const godot_real p_epsilon); - -godot_vector3 GDAPI godot_plane_project(const godot_plane *p_self, const godot_vector3 *p_point); - -godot_bool GDAPI godot_plane_intersect_3(const godot_plane *p_self, godot_vector3 *r_dest, const godot_plane *p_b, const godot_plane *p_c); - -godot_bool GDAPI godot_plane_intersects_ray(const godot_plane *p_self, godot_vector3 *r_dest, const godot_vector3 *p_from, const godot_vector3 *p_dir); - -godot_bool GDAPI godot_plane_intersects_segment(const godot_plane *p_self, godot_vector3 *r_dest, const godot_vector3 *p_begin, const godot_vector3 *p_end); - -godot_plane GDAPI godot_plane_operator_neg(const godot_plane *p_self); - -godot_bool GDAPI godot_plane_operator_equal(const godot_plane *p_self, const godot_plane *p_b); - -void GDAPI godot_plane_set_normal(godot_plane *p_self, const godot_vector3 *p_normal); - -godot_vector3 GDAPI godot_plane_get_normal(const godot_plane *p_self); - -godot_real GDAPI godot_plane_get_d(const godot_plane *p_self); -void GDAPI godot_plane_set_d(godot_plane *p_self, const godot_real p_d); +void GDAPI godot_plane_new(godot_plane *p_self); #ifdef __cplusplus } diff --git a/modules/gdnative/include/gdnative/quat.h b/modules/gdnative/include/gdnative/quat.h index d315b2d754..69bf427611 100644 --- a/modules/gdnative/include/gdnative/quat.h +++ b/modules/gdnative/include/gdnative/quat.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -35,9 +35,9 @@ extern "C" { #endif -#include <stdint.h> +#include <gdnative/math_defs.h> -#define GODOT_QUAT_SIZE 16 +#define GODOT_QUAT_SIZE (sizeof(godot_real_t) * 4) #ifndef GODOT_CORE_API_GODOT_QUAT_TYPE_DEFINED #define GODOT_CORE_API_GODOT_QUAT_TYPE_DEFINED @@ -46,70 +46,11 @@ typedef struct { } godot_quat; #endif -// reduce extern "C" nesting for VS2013 -#ifdef __cplusplus -} -#endif - #include <gdnative/gdnative.h> -#include <gdnative/vector3.h> - -#ifdef __cplusplus -extern "C" { -#endif - -void GDAPI godot_quat_new(godot_quat *r_dest, const godot_real p_x, const godot_real p_y, const godot_real p_z, const godot_real p_w); -void GDAPI godot_quat_new_with_axis_angle(godot_quat *r_dest, const godot_vector3 *p_axis, const godot_real p_angle); -void GDAPI godot_quat_new_with_basis(godot_quat *r_dest, const godot_basis *p_basis); -void GDAPI godot_quat_new_with_euler(godot_quat *r_dest, const godot_vector3 *p_euler); - -godot_real GDAPI godot_quat_get_x(const godot_quat *p_self); -void GDAPI godot_quat_set_x(godot_quat *p_self, const godot_real val); - -godot_real GDAPI godot_quat_get_y(const godot_quat *p_self); -void GDAPI godot_quat_set_y(godot_quat *p_self, const godot_real val); - -godot_real GDAPI godot_quat_get_z(const godot_quat *p_self); -void GDAPI godot_quat_set_z(godot_quat *p_self, const godot_real val); - -godot_real GDAPI godot_quat_get_w(const godot_quat *p_self); -void GDAPI godot_quat_set_w(godot_quat *p_self, const godot_real val); - -godot_string GDAPI godot_quat_as_string(const godot_quat *p_self); - -godot_real GDAPI godot_quat_length(const godot_quat *p_self); - -godot_real GDAPI godot_quat_length_squared(const godot_quat *p_self); - -godot_quat GDAPI godot_quat_normalized(const godot_quat *p_self); - -godot_bool GDAPI godot_quat_is_normalized(const godot_quat *p_self); - -godot_quat GDAPI godot_quat_inverse(const godot_quat *p_self); - -godot_real GDAPI godot_quat_dot(const godot_quat *p_self, const godot_quat *p_b); - -godot_vector3 GDAPI godot_quat_xform(const godot_quat *p_self, const godot_vector3 *p_v); - -godot_quat GDAPI godot_quat_slerp(const godot_quat *p_self, const godot_quat *p_b, const godot_real p_t); - -godot_quat GDAPI godot_quat_slerpni(const godot_quat *p_self, const godot_quat *p_b, const godot_real p_t); - -godot_quat GDAPI godot_quat_cubic_slerp(const godot_quat *p_self, const godot_quat *p_b, const godot_quat *p_pre_a, const godot_quat *p_post_b, const godot_real p_t); - -godot_quat GDAPI godot_quat_operator_multiply(const godot_quat *p_self, const godot_real p_b); - -godot_quat GDAPI godot_quat_operator_add(const godot_quat *p_self, const godot_quat *p_b); - -godot_quat GDAPI godot_quat_operator_subtract(const godot_quat *p_self, const godot_quat *p_b); - -godot_quat GDAPI godot_quat_operator_divide(const godot_quat *p_self, const godot_real p_b); - -godot_bool GDAPI godot_quat_operator_equal(const godot_quat *p_self, const godot_quat *p_b); - -godot_quat GDAPI godot_quat_operator_neg(const godot_quat *p_self); -void GDAPI godot_quat_set_axis_angle(godot_quat *p_self, const godot_vector3 *p_axis, const godot_real p_angle); +void GDAPI godot_quat_new(godot_quat *p_self); +godot_real_t GDAPI *godot_quat_operator_index(godot_quat *p_self, godot_int p_index); +const godot_real_t GDAPI *godot_quat_operator_index_const(const godot_quat *p_self, godot_int p_index); #ifdef __cplusplus } diff --git a/modules/gdnative/include/gdnative/rect2.h b/modules/gdnative/include/gdnative/rect2.h index 2c8f836d16..9e51254cfe 100644 --- a/modules/gdnative/include/gdnative/rect2.h +++ b/modules/gdnative/include/gdnative/rect2.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -35,119 +35,30 @@ extern "C" { #endif -#include <stdint.h> +#include <gdnative/math_defs.h> + +#define GODOT_RECT2_SIZE (sizeof(godot_real_t) * 4) #ifndef GODOT_CORE_API_GODOT_RECT2_TYPE_DEFINED #define GODOT_CORE_API_GODOT_RECT2_TYPE_DEFINED typedef struct godot_rect2 { - uint8_t _dont_touch_that[16]; + uint8_t _dont_touch_that[GODOT_RECT2_SIZE]; } godot_rect2; #endif +#define GODOT_RECT2I_SIZE (sizeof(int32_t) * 4) + #ifndef GODOT_CORE_API_GODOT_RECT2I_TYPE_DEFINED #define GODOT_CORE_API_GODOT_RECT2I_TYPE_DEFINED typedef struct godot_rect2i { - uint8_t _dont_touch_that[16]; + uint8_t _dont_touch_that[GODOT_RECT2I_SIZE]; } godot_rect2i; #endif -// reduce extern "C" nesting for VS2013 -#ifdef __cplusplus -} -#endif - #include <gdnative/gdnative.h> -#include <gdnative/vector2.h> - -#ifdef __cplusplus -extern "C" { -#endif - -// Rect2 - -void GDAPI godot_rect2_new_with_position_and_size(godot_rect2 *r_dest, const godot_vector2 *p_pos, const godot_vector2 *p_size); -void GDAPI godot_rect2_new(godot_rect2 *r_dest, const godot_real p_x, const godot_real p_y, const godot_real p_width, const godot_real p_height); - -godot_string GDAPI godot_rect2_as_string(const godot_rect2 *p_self); - -godot_rect2i GDAPI godot_rect2_as_rect2i(const godot_rect2 *p_self); - -godot_real GDAPI godot_rect2_get_area(const godot_rect2 *p_self); - -godot_bool GDAPI godot_rect2_intersects(const godot_rect2 *p_self, const godot_rect2 *p_b); - -godot_bool GDAPI godot_rect2_encloses(const godot_rect2 *p_self, const godot_rect2 *p_b); - -godot_bool GDAPI godot_rect2_has_no_area(const godot_rect2 *p_self); - -godot_rect2 GDAPI godot_rect2_intersection(const godot_rect2 *p_self, const godot_rect2 *p_b); - -godot_rect2 GDAPI godot_rect2_merge(const godot_rect2 *p_self, const godot_rect2 *p_b); - -godot_bool GDAPI godot_rect2_has_point(const godot_rect2 *p_self, const godot_vector2 *p_point); - -godot_rect2 GDAPI godot_rect2_grow(const godot_rect2 *p_self, const godot_real p_by); - -godot_rect2 GDAPI godot_rect2_grow_individual(const godot_rect2 *p_self, const godot_real p_left, const godot_real p_top, const godot_real p_right, const godot_real p_bottom); - -godot_rect2 GDAPI godot_rect2_grow_margin(const godot_rect2 *p_self, const godot_int p_margin, const godot_real p_by); - -godot_rect2 GDAPI godot_rect2_abs(const godot_rect2 *p_self); - -godot_rect2 GDAPI godot_rect2_expand(const godot_rect2 *p_self, const godot_vector2 *p_to); - -godot_bool GDAPI godot_rect2_operator_equal(const godot_rect2 *p_self, const godot_rect2 *p_b); - -godot_vector2 GDAPI godot_rect2_get_position(const godot_rect2 *p_self); - -godot_vector2 GDAPI godot_rect2_get_size(const godot_rect2 *p_self); - -void GDAPI godot_rect2_set_position(godot_rect2 *p_self, const godot_vector2 *p_pos); - -void GDAPI godot_rect2_set_size(godot_rect2 *p_self, const godot_vector2 *p_size); - -// Rect2I - -void GDAPI godot_rect2i_new_with_position_and_size(godot_rect2i *r_dest, const godot_vector2i *p_pos, const godot_vector2i *p_size); -void GDAPI godot_rect2i_new(godot_rect2i *r_dest, const godot_int p_x, const godot_int p_y, const godot_int p_width, const godot_int p_height); - -godot_string GDAPI godot_rect2i_as_string(const godot_rect2i *p_self); - -godot_rect2 GDAPI godot_rect2i_as_rect2(const godot_rect2i *p_self); - -godot_int GDAPI godot_rect2i_get_area(const godot_rect2i *p_self); - -godot_bool GDAPI godot_rect2i_intersects(const godot_rect2i *p_self, const godot_rect2i *p_b); - -godot_bool GDAPI godot_rect2i_encloses(const godot_rect2i *p_self, const godot_rect2i *p_b); - -godot_bool GDAPI godot_rect2i_has_no_area(const godot_rect2i *p_self); - -godot_rect2i GDAPI godot_rect2i_intersection(const godot_rect2i *p_self, const godot_rect2i *p_b); - -godot_rect2i GDAPI godot_rect2i_merge(const godot_rect2i *p_self, const godot_rect2i *p_b); - -godot_bool GDAPI godot_rect2i_has_point(const godot_rect2i *p_self, const godot_vector2i *p_point); - -godot_rect2i GDAPI godot_rect2i_grow(const godot_rect2i *p_self, const godot_int p_by); - -godot_rect2i GDAPI godot_rect2i_grow_individual(const godot_rect2i *p_self, const godot_int p_left, const godot_int p_top, const godot_int p_right, const godot_int p_bottom); - -godot_rect2i GDAPI godot_rect2i_grow_margin(const godot_rect2i *p_self, const godot_int p_margin, const godot_int p_by); - -godot_rect2i GDAPI godot_rect2i_abs(const godot_rect2i *p_self); - -godot_rect2i GDAPI godot_rect2i_expand(const godot_rect2i *p_self, const godot_vector2i *p_to); - -godot_bool GDAPI godot_rect2i_operator_equal(const godot_rect2i *p_self, const godot_rect2i *p_b); - -godot_vector2i GDAPI godot_rect2i_get_position(const godot_rect2i *p_self); - -godot_vector2i GDAPI godot_rect2i_get_size(const godot_rect2i *p_self); - -void GDAPI godot_rect2i_set_position(godot_rect2i *p_self, const godot_vector2i *p_pos); -void GDAPI godot_rect2i_set_size(godot_rect2i *p_self, const godot_vector2i *p_size); +void GDAPI godot_rect2_new(godot_rect2 *p_self); +void GDAPI godot_rect2i_new(godot_rect2i *p_self); #ifdef __cplusplus } diff --git a/modules/gdnative/include/gdnative/rid.h b/modules/gdnative/include/gdnative/rid.h index 73b601dc04..7ea8cfd174 100644 --- a/modules/gdnative/include/gdnative/rid.h +++ b/modules/gdnative/include/gdnative/rid.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -46,26 +46,9 @@ typedef struct { } godot_rid; #endif -// reduce extern "C" nesting for VS2013 -#ifdef __cplusplus -} -#endif - #include <gdnative/gdnative.h> -#ifdef __cplusplus -extern "C" { -#endif - -void GDAPI godot_rid_new(godot_rid *r_dest); - -godot_int GDAPI godot_rid_get_id(const godot_rid *p_self); - -void GDAPI godot_rid_new_with_resource(godot_rid *r_dest, const godot_object *p_from); - -godot_bool GDAPI godot_rid_operator_equal(const godot_rid *p_self, const godot_rid *p_b); - -godot_bool GDAPI godot_rid_operator_less(const godot_rid *p_self, const godot_rid *p_b); +void GDAPI godot_rid_new(godot_rid *p_self); #ifdef __cplusplus } diff --git a/modules/gdnative/include/gdnative/signal.h b/modules/gdnative/include/gdnative/signal.h new file mode 100644 index 0000000000..ad84542677 --- /dev/null +++ b/modules/gdnative/include/gdnative/signal.h @@ -0,0 +1,58 @@ +/*************************************************************************/ +/* signal.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 GODOT_SIGNAL_H +#define GODOT_SIGNAL_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdint.h> + +#define GODOT_SIGNAL_SIZE (16) + +#ifndef GODOT_CORE_API_GODOT_SIGNAL_TYPE_DEFINED +#define GODOT_CORE_API_GODOT_SIGNAL_TYPE_DEFINED +typedef struct { + uint8_t _dont_touch_that[GODOT_SIGNAL_SIZE]; +} godot_signal; +#endif + +#include <gdnative/gdnative.h> + +void GDAPI godot_signal_new(godot_signal *p_self); +void GDAPI godot_signal_destroy(godot_signal *p_self); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/modules/gdnative/include/gdnative/string.h b/modules/gdnative/include/gdnative/string.h index 6043351e84..10fbb2c078 100644 --- a/modules/gdnative/include/gdnative/string.h +++ b/modules/gdnative/include/gdnative/string.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -39,61 +39,26 @@ extern "C" { #include <stdint.h> #ifndef __cplusplus -typedef uint32_t char32_t; typedef uint16_t char16_t; +typedef uint32_t char32_t; #endif typedef char32_t godot_char_type; #define GODOT_STRING_SIZE sizeof(void *) -#define GODOT_CHAR_STRING_SIZE sizeof(void *) -#define GODOT_CHAR16_STRING_SIZE sizeof(void *) #ifndef GODOT_CORE_API_GODOT_STRING_TYPE_DEFINED #define GODOT_CORE_API_GODOT_STRING_TYPE_DEFINED typedef struct { uint8_t _dont_touch_that[GODOT_STRING_SIZE]; } godot_string; - -#endif - -#ifndef GODOT_CORE_API_GODOT_CHAR_STRING_TYPE_DEFINED -#define GODOT_CORE_API_GODOT_CHAR_STRING_TYPE_DEFINED -typedef struct { - uint8_t _dont_touch_that[GODOT_CHAR_STRING_SIZE]; -} godot_char_string; -#endif - -#ifndef GODOT_CORE_API_GODOT_CHAR16_STRING_TYPE_DEFINED -#define GODOT_CORE_API_GODOT_CHAR16_STRING_TYPE_DEFINED -typedef struct { - uint8_t _dont_touch_that[GODOT_CHAR16_STRING_SIZE]; -} godot_char16_string; #endif -// reduce extern "C" nesting for VS2013 -#ifdef __cplusplus -} -#endif - -#include <gdnative/array.h> #include <gdnative/gdnative.h> -#include <gdnative/variant.h> - -#ifdef __cplusplus -extern "C" { -#endif - -godot_int GDAPI godot_char_string_length(const godot_char_string *p_cs); -const char GDAPI *godot_char_string_get_data(const godot_char_string *p_cs); -void GDAPI godot_char_string_destroy(godot_char_string *p_cs); - -godot_int GDAPI godot_char16_string_length(const godot_char16_string *p_cs); -const char16_t GDAPI *godot_char16_string_get_data(const godot_char16_string *p_cs); -void GDAPI godot_char16_string_destroy(godot_char16_string *p_cs); void GDAPI godot_string_new(godot_string *r_dest); void GDAPI godot_string_new_copy(godot_string *r_dest, const godot_string *p_src); +void GDAPI godot_string_destroy(godot_string *p_self); void GDAPI godot_string_new_with_latin1_chars(godot_string *r_dest, const char *p_contents); void GDAPI godot_string_new_with_utf8_chars(godot_string *r_dest, const char *p_contents); @@ -107,198 +72,6 @@ void GDAPI godot_string_new_with_utf16_chars_and_len(godot_string *r_dest, const void GDAPI godot_string_new_with_utf32_chars_and_len(godot_string *r_dest, const char32_t *p_contents, const int p_size); void GDAPI godot_string_new_with_wide_chars_and_len(godot_string *r_dest, const wchar_t *p_contents, const int p_size); -const godot_char_type GDAPI *godot_string_operator_index(godot_string *p_self, const godot_int p_idx); -godot_char_type GDAPI godot_string_operator_index_const(const godot_string *p_self, const godot_int p_idx); -const godot_char_type GDAPI *godot_string_get_data(const godot_string *p_self); - -godot_bool GDAPI godot_string_operator_equal(const godot_string *p_self, const godot_string *p_b); -godot_bool GDAPI godot_string_operator_less(const godot_string *p_self, const godot_string *p_b); -godot_string GDAPI godot_string_operator_plus(const godot_string *p_self, const godot_string *p_b); - -/* Standard size stuff */ - -/*+++*/ godot_int GDAPI godot_string_length(const godot_string *p_self); - -/* Helpers */ - -signed char GDAPI godot_string_casecmp_to(const godot_string *p_self, const godot_string *p_str); -signed char GDAPI godot_string_nocasecmp_to(const godot_string *p_self, const godot_string *p_str); -signed char GDAPI godot_string_naturalnocasecmp_to(const godot_string *p_self, const godot_string *p_str); - -godot_bool GDAPI godot_string_begins_with(const godot_string *p_self, const godot_string *p_string); -godot_bool GDAPI godot_string_begins_with_char_array(const godot_string *p_self, const char *p_char_array); -godot_packed_string_array GDAPI godot_string_bigrams(const godot_string *p_self); -godot_string GDAPI godot_string_chr(godot_char_type p_character); -godot_bool GDAPI godot_string_ends_with(const godot_string *p_self, const godot_string *p_string); -godot_bool GDAPI godot_string_ends_with_char_array(const godot_string *p_self, const char *p_char_array); -godot_int GDAPI godot_string_count(const godot_string *p_self, const godot_string *p_what, godot_int p_from, godot_int p_to); -godot_int GDAPI godot_string_countn(const godot_string *p_self, const godot_string *p_what, godot_int p_from, godot_int p_to); -godot_int GDAPI godot_string_find(const godot_string *p_self, const godot_string *p_what); -godot_int GDAPI godot_string_find_from(const godot_string *p_self, const godot_string *p_what, godot_int p_from); -godot_int GDAPI godot_string_findmk(const godot_string *p_self, const godot_packed_string_array *p_keys); -godot_int GDAPI godot_string_findmk_from(const godot_string *p_self, const godot_packed_string_array *p_keys, godot_int p_from); -godot_int GDAPI godot_string_findmk_from_in_place(const godot_string *p_self, const godot_packed_string_array *p_keys, godot_int p_from, godot_int *r_key); -godot_int GDAPI godot_string_findn(const godot_string *p_self, const godot_string *p_what); -godot_int GDAPI godot_string_findn_from(const godot_string *p_self, const godot_string *p_what, godot_int p_from); -godot_string GDAPI godot_string_format(const godot_string *p_self, const godot_variant *p_values); -godot_string GDAPI godot_string_format_with_custom_placeholder(const godot_string *p_self, const godot_variant *p_values, const char *p_placeholder); -godot_string GDAPI godot_string_hex_encode_buffer(const uint8_t *p_buffer, godot_int p_len); -godot_int GDAPI godot_string_hex_to_int(const godot_string *p_self); -godot_int GDAPI godot_string_hex_to_int_with_prefix(const godot_string *p_self); -godot_string GDAPI godot_string_insert(const godot_string *p_self, godot_int p_at_pos, const godot_string *p_string); -godot_bool GDAPI godot_string_is_numeric(const godot_string *p_self); -godot_bool GDAPI godot_string_is_subsequence_of(const godot_string *p_self, const godot_string *p_string); -godot_bool GDAPI godot_string_is_subsequence_ofi(const godot_string *p_self, const godot_string *p_string); -godot_string GDAPI godot_string_lpad(const godot_string *p_self, godot_int p_min_length); -godot_string GDAPI godot_string_lpad_with_custom_character(const godot_string *p_self, godot_int p_min_length, const godot_string *p_character); -godot_bool GDAPI godot_string_match(const godot_string *p_self, const godot_string *p_wildcard); -godot_bool GDAPI godot_string_matchn(const godot_string *p_self, const godot_string *p_wildcard); -godot_string GDAPI godot_string_md5(const uint8_t *p_md5); -godot_string GDAPI godot_string_num(double p_num); -godot_string GDAPI godot_string_num_int64(int64_t p_num, godot_int p_base); -godot_string GDAPI godot_string_num_int64_capitalized(int64_t p_num, godot_int p_base, godot_bool p_capitalize_hex); -godot_string GDAPI godot_string_num_real(double p_num); -godot_string GDAPI godot_string_num_scientific(double p_num); -godot_string GDAPI godot_string_num_with_decimals(double p_num, godot_int p_decimals); -godot_string GDAPI godot_string_pad_decimals(const godot_string *p_self, godot_int p_digits); -godot_string GDAPI godot_string_pad_zeros(const godot_string *p_self, godot_int p_digits); -godot_string GDAPI godot_string_replace_first(const godot_string *p_self, const godot_string *p_key, const godot_string *p_with); -godot_string GDAPI godot_string_replace(const godot_string *p_self, const godot_string *p_key, const godot_string *p_with); -godot_string GDAPI godot_string_replacen(const godot_string *p_self, const godot_string *p_key, const godot_string *p_with); -godot_int GDAPI godot_string_rfind(const godot_string *p_self, const godot_string *p_what); -godot_int GDAPI godot_string_rfindn(const godot_string *p_self, const godot_string *p_what); -godot_int GDAPI godot_string_rfind_from(const godot_string *p_self, const godot_string *p_what, godot_int p_from); -godot_int GDAPI godot_string_rfindn_from(const godot_string *p_self, const godot_string *p_what, godot_int p_from); -godot_string GDAPI godot_string_rpad(const godot_string *p_self, godot_int p_min_length); -godot_string GDAPI godot_string_rpad_with_custom_character(const godot_string *p_self, godot_int p_min_length, const godot_string *p_character); -godot_real GDAPI godot_string_similarity(const godot_string *p_self, const godot_string *p_string); -godot_string GDAPI godot_string_sprintf(const godot_string *p_self, const godot_array *p_values, godot_bool *p_error); -godot_string GDAPI godot_string_substr(const godot_string *p_self, godot_int p_from, godot_int p_chars); -double GDAPI godot_string_to_float(const godot_string *p_self); -godot_int GDAPI godot_string_to_int(const godot_string *p_self); - -godot_string GDAPI godot_string_camelcase_to_underscore(const godot_string *p_self); -godot_string GDAPI godot_string_camelcase_to_underscore_lowercased(const godot_string *p_self); -godot_string GDAPI godot_string_capitalize(const godot_string *p_self); - -double GDAPI godot_string_char_to_float(const char *p_what); -double GDAPI godot_string_wchar_to_float(const wchar_t *p_str, const wchar_t **r_end); - -godot_int GDAPI godot_string_char_to_int(const char *p_what); -godot_int GDAPI godot_string_wchar_to_int(const wchar_t *p_str); - -godot_int GDAPI godot_string_char_to_int_with_len(const char *p_what, godot_int p_len); -godot_int GDAPI godot_string_wchar_to_int_with_len(const wchar_t *p_str, int p_len); - -godot_int GDAPI godot_string_get_slice_count(const godot_string *p_self, const godot_string *p_splitter); -godot_string GDAPI godot_string_get_slice(const godot_string *p_self, const godot_string *p_splitter, godot_int p_slice); -godot_string GDAPI godot_string_get_slicec(const godot_string *p_self, godot_char_type p_splitter, godot_int p_slice); - -godot_packed_string_array GDAPI godot_string_split(const godot_string *p_self, const godot_string *p_splitter); -godot_packed_string_array GDAPI godot_string_split_allow_empty(const godot_string *p_self, const godot_string *p_splitter); -godot_packed_string_array GDAPI godot_string_split_with_maxsplit(const godot_string *p_self, const godot_string *p_splitter, const godot_bool p_allow_empty, const godot_int p_maxsplit); - -godot_packed_string_array GDAPI godot_string_rsplit(const godot_string *p_self, const godot_string *p_splitter); -godot_packed_string_array GDAPI godot_string_rsplit_allow_empty(const godot_string *p_self, const godot_string *p_splitter); -godot_packed_string_array GDAPI godot_string_rsplit_with_maxsplit(const godot_string *p_self, const godot_string *p_splitter, const godot_bool p_allow_empty, const godot_int p_maxsplit); - -godot_packed_float32_array GDAPI godot_string_split_floats(const godot_string *p_self, const godot_string *p_splitter); -godot_packed_float32_array GDAPI godot_string_split_floats_allow_empty(const godot_string *p_self, const godot_string *p_splitter); -godot_packed_float32_array GDAPI godot_string_split_floats_mk(const godot_string *p_self, const godot_packed_string_array *p_splitters); -godot_packed_float32_array GDAPI godot_string_split_floats_mk_allow_empty(const godot_string *p_self, const godot_packed_string_array *p_splitters); -godot_packed_int32_array GDAPI godot_string_split_ints(const godot_string *p_self, const godot_string *p_splitter); -godot_packed_int32_array GDAPI godot_string_split_ints_allow_empty(const godot_string *p_self, const godot_string *p_splitter); -godot_packed_int32_array GDAPI godot_string_split_ints_mk(const godot_string *p_self, const godot_packed_string_array *p_splitters); -godot_packed_int32_array GDAPI godot_string_split_ints_mk_allow_empty(const godot_string *p_self, const godot_packed_string_array *p_splitters); - -godot_packed_string_array GDAPI godot_string_split_spaces(const godot_string *p_self); - -godot_char_type GDAPI godot_string_char_lowercase(godot_char_type p_char); -godot_char_type GDAPI godot_string_char_uppercase(godot_char_type p_char); -godot_string GDAPI godot_string_to_lower(const godot_string *p_self); -godot_string GDAPI godot_string_to_upper(const godot_string *p_self); - -godot_string GDAPI godot_string_get_basename(const godot_string *p_self); -godot_string GDAPI godot_string_get_extension(const godot_string *p_self); -godot_string GDAPI godot_string_left(const godot_string *p_self, godot_int p_pos); -godot_char_type GDAPI godot_string_ord_at(const godot_string *p_self, godot_int p_idx); -godot_string GDAPI godot_string_plus_file(const godot_string *p_self, const godot_string *p_file); -godot_string GDAPI godot_string_right(const godot_string *p_self, godot_int p_pos); -godot_string GDAPI godot_string_repeat(const godot_string *p_self, godot_int p_count); -godot_string GDAPI godot_string_strip_edges(const godot_string *p_self, godot_bool p_left, godot_bool p_right); -godot_string GDAPI godot_string_strip_escapes(const godot_string *p_self); - -void GDAPI godot_string_erase(godot_string *p_self, godot_int p_pos, godot_int p_chars); - -godot_char_string GDAPI godot_string_ascii(const godot_string *p_self); -godot_char_string GDAPI godot_string_latin1(const godot_string *p_self); - -godot_char_string GDAPI godot_string_utf8(const godot_string *p_self); -godot_bool GDAPI godot_string_parse_utf8(godot_string *p_self, const char *p_utf8); -godot_bool GDAPI godot_string_parse_utf8_with_len(godot_string *p_self, const char *p_utf8, godot_int p_len); - -godot_char16_string GDAPI godot_string_utf16(const godot_string *p_self); -godot_bool GDAPI godot_string_parse_utf16(godot_string *p_self, const char16_t *p_utf16); -godot_bool GDAPI godot_string_parse_utf16_with_len(godot_string *p_self, const char16_t *p_utf16, godot_int p_len); - -uint32_t GDAPI godot_string_hash(const godot_string *p_self); -uint64_t GDAPI godot_string_hash64(const godot_string *p_self); - -uint32_t GDAPI godot_string_hash_chars(const char *p_cstr); -uint32_t GDAPI godot_string_hash_chars_with_len(const char *p_cstr, godot_int p_len); -uint32_t GDAPI godot_string_hash_wide_chars(const wchar_t *p_str); -uint32_t GDAPI godot_string_hash_wide_chars_with_len(const wchar_t *p_str, godot_int p_len); - -godot_packed_byte_array GDAPI godot_string_md5_buffer(const godot_string *p_self); -godot_string GDAPI godot_string_md5_text(const godot_string *p_self); -godot_packed_byte_array GDAPI godot_string_sha1_buffer(const godot_string *p_self); -godot_string GDAPI godot_string_sha1_text(const godot_string *p_self); -godot_packed_byte_array GDAPI godot_string_sha256_buffer(const godot_string *p_self); -godot_string GDAPI godot_string_sha256_text(const godot_string *p_self); - -godot_bool godot_string_empty(const godot_string *p_self); - -// path functions -godot_string GDAPI godot_string_get_base_dir(const godot_string *p_self); -godot_string GDAPI godot_string_get_file(const godot_string *p_self); -godot_string GDAPI godot_string_humanize_size(size_t p_size); -godot_bool GDAPI godot_string_is_abs_path(const godot_string *p_self); -godot_bool GDAPI godot_string_is_rel_path(const godot_string *p_self); -godot_bool GDAPI godot_string_is_resource_file(const godot_string *p_self); -godot_string GDAPI godot_string_path_to(const godot_string *p_self, const godot_string *p_path); -godot_string GDAPI godot_string_path_to_file(const godot_string *p_self, const godot_string *p_path); -godot_string GDAPI godot_string_simplify_path(const godot_string *p_self); - -godot_string GDAPI godot_string_c_escape(const godot_string *p_self); -godot_string GDAPI godot_string_c_escape_multiline(const godot_string *p_self); -godot_string GDAPI godot_string_c_unescape(const godot_string *p_self); -godot_string GDAPI godot_string_http_escape(const godot_string *p_self); -godot_string GDAPI godot_string_http_unescape(const godot_string *p_self); -godot_string GDAPI godot_string_json_escape(const godot_string *p_self); -godot_string GDAPI godot_string_xml_escape(const godot_string *p_self); -godot_string GDAPI godot_string_xml_escape_with_quotes(const godot_string *p_self); -godot_string GDAPI godot_string_xml_unescape(const godot_string *p_self); - -godot_string GDAPI godot_string_percent_decode(const godot_string *p_self); -godot_string GDAPI godot_string_percent_encode(const godot_string *p_self); -godot_string GDAPI godot_string_join(const godot_string *p_self, const godot_packed_string_array *p_parts); - -godot_bool GDAPI godot_string_is_valid_filename(const godot_string *p_self); -godot_bool GDAPI godot_string_is_valid_float(const godot_string *p_self); -godot_bool GDAPI godot_string_is_valid_hex_number(const godot_string *p_self, godot_bool p_with_prefix); -godot_bool GDAPI godot_string_is_valid_html_color(const godot_string *p_self); -godot_bool GDAPI godot_string_is_valid_identifier(const godot_string *p_self); -godot_bool GDAPI godot_string_is_valid_integer(const godot_string *p_self); -godot_bool GDAPI godot_string_is_valid_ip_address(const godot_string *p_self); - -godot_string GDAPI godot_string_dedent(const godot_string *p_self); -godot_string GDAPI godot_string_trim_prefix(const godot_string *p_self, const godot_string *p_prefix); -godot_string GDAPI godot_string_trim_suffix(const godot_string *p_self, const godot_string *p_suffix); -godot_string GDAPI godot_string_lstrip(const godot_string *p_self, const godot_string *p_chars); -godot_string GDAPI godot_string_rstrip(const godot_string *p_self, const godot_string *p_chars); - -void GDAPI godot_string_destroy(godot_string *p_self); - #ifdef __cplusplus } #endif diff --git a/modules/gdnative/include/gdnative/string_name.h b/modules/gdnative/include/gdnative/string_name.h index f2555ab98f..346f626e81 100644 --- a/modules/gdnative/include/gdnative/string_name.h +++ b/modules/gdnative/include/gdnative/string_name.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -47,30 +47,14 @@ typedef struct { } godot_string_name; #endif -// reduce extern "C" nesting for VS2013 -#ifdef __cplusplus -} -#endif - #include <gdnative/gdnative.h> -#ifdef __cplusplus -extern "C" { -#endif - -void GDAPI godot_string_name_new(godot_string_name *r_dest, const godot_string *p_name); -void GDAPI godot_string_name_new_data(godot_string_name *r_dest, const char *p_name); - -godot_string GDAPI godot_string_name_get_name(const godot_string_name *p_self); - -uint32_t GDAPI godot_string_name_get_hash(const godot_string_name *p_self); -const void GDAPI *godot_string_name_get_data_unique_pointer(const godot_string_name *p_self); - -godot_bool GDAPI godot_string_name_operator_equal(const godot_string_name *p_self, const godot_string_name *p_other); -godot_bool GDAPI godot_string_name_operator_less(const godot_string_name *p_self, const godot_string_name *p_other); - +void GDAPI godot_string_name_new(godot_string_name *r_dest); +void GDAPI godot_string_name_new_copy(godot_string_name *r_dest, const godot_string_name *p_src); void GDAPI godot_string_name_destroy(godot_string_name *p_self); +void GDAPI godot_string_name_new_with_latin1_chars(godot_string_name *r_dest, const char *p_contents); + #ifdef __cplusplus } #endif diff --git a/modules/gdnative/include/gdnative/transform.h b/modules/gdnative/include/gdnative/transform.h index bc51438b17..e67862d140 100644 --- a/modules/gdnative/include/gdnative/transform.h +++ b/modules/gdnative/include/gdnative/transform.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -35,9 +35,9 @@ extern "C" { #endif -#include <stdint.h> +#include <gdnative/math_defs.h> -#define GODOT_TRANSFORM_SIZE 48 +#define GODOT_TRANSFORM_SIZE (sizeof(godot_real_t) * 12) #ifndef GODOT_CORE_API_GODOT_TRANSFORM_TYPE_DEFINED #define GODOT_CORE_API_GODOT_TRANSFORM_TYPE_DEFINED @@ -46,63 +46,9 @@ typedef struct { } godot_transform; #endif -// reduce extern "C" nesting for VS2013 -#ifdef __cplusplus -} -#endif - -#include <gdnative/basis.h> #include <gdnative/gdnative.h> -#include <gdnative/variant.h> -#include <gdnative/vector3.h> - -#ifdef __cplusplus -extern "C" { -#endif - -void GDAPI godot_transform_new_with_axis_origin(godot_transform *r_dest, const godot_vector3 *p_x_axis, const godot_vector3 *p_y_axis, const godot_vector3 *p_z_axis, const godot_vector3 *p_origin); -void GDAPI godot_transform_new(godot_transform *r_dest, const godot_basis *p_basis, const godot_vector3 *p_origin); -void GDAPI godot_transform_new_with_quat(godot_transform *r_dest, const godot_quat *p_quat); - -godot_basis GDAPI godot_transform_get_basis(const godot_transform *p_self); -void GDAPI godot_transform_set_basis(godot_transform *p_self, const godot_basis *p_v); - -godot_vector3 GDAPI godot_transform_get_origin(const godot_transform *p_self); -void GDAPI godot_transform_set_origin(godot_transform *p_self, const godot_vector3 *p_v); - -godot_string GDAPI godot_transform_as_string(const godot_transform *p_self); - -godot_transform GDAPI godot_transform_inverse(const godot_transform *p_self); - -godot_transform GDAPI godot_transform_affine_inverse(const godot_transform *p_self); - -godot_transform GDAPI godot_transform_orthonormalized(const godot_transform *p_self); - -godot_transform GDAPI godot_transform_rotated(const godot_transform *p_self, const godot_vector3 *p_axis, const godot_real p_phi); - -godot_transform GDAPI godot_transform_scaled(const godot_transform *p_self, const godot_vector3 *p_scale); - -godot_transform GDAPI godot_transform_translated(const godot_transform *p_self, const godot_vector3 *p_ofs); - -godot_transform GDAPI godot_transform_looking_at(const godot_transform *p_self, const godot_vector3 *p_target, const godot_vector3 *p_up); - -godot_plane GDAPI godot_transform_xform_plane(const godot_transform *p_self, const godot_plane *p_v); - -godot_plane GDAPI godot_transform_xform_inv_plane(const godot_transform *p_self, const godot_plane *p_v); - -void GDAPI godot_transform_new_identity(godot_transform *r_dest); - -godot_bool GDAPI godot_transform_operator_equal(const godot_transform *p_self, const godot_transform *p_b); - -godot_transform GDAPI godot_transform_operator_multiply(const godot_transform *p_self, const godot_transform *p_b); - -godot_vector3 GDAPI godot_transform_xform_vector3(const godot_transform *p_self, const godot_vector3 *p_v); - -godot_vector3 GDAPI godot_transform_xform_inv_vector3(const godot_transform *p_self, const godot_vector3 *p_v); - -godot_aabb GDAPI godot_transform_xform_aabb(const godot_transform *p_self, const godot_aabb *p_v); -godot_aabb GDAPI godot_transform_xform_inv_aabb(const godot_transform *p_self, const godot_aabb *p_v); +void GDAPI godot_transform_new(godot_transform *p_self); #ifdef __cplusplus } diff --git a/modules/gdnative/include/gdnative/transform2d.h b/modules/gdnative/include/gdnative/transform2d.h index 6b414ca7b2..4a2bca7cfc 100644 --- a/modules/gdnative/include/gdnative/transform2d.h +++ b/modules/gdnative/include/gdnative/transform2d.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -35,9 +35,9 @@ extern "C" { #endif -#include <stdint.h> +#include <gdnative/math_defs.h> -#define GODOT_TRANSFORM2D_SIZE 24 +#define GODOT_TRANSFORM2D_SIZE (sizeof(godot_real_t) * 6) #ifndef GODOT_CORE_API_GODOT_TRANSFORM2D_TYPE_DEFINED #define GODOT_CORE_API_GODOT_TRANSFORM2D_TYPE_DEFINED @@ -46,61 +46,11 @@ typedef struct { } godot_transform2d; #endif -// reduce extern "C" nesting for VS2013 -#ifdef __cplusplus -} -#endif - #include <gdnative/gdnative.h> -#include <gdnative/variant.h> -#include <gdnative/vector2.h> - -#ifdef __cplusplus -extern "C" { -#endif - -void GDAPI godot_transform2d_new(godot_transform2d *r_dest, const godot_real p_rot, const godot_vector2 *p_pos); -void GDAPI godot_transform2d_new_axis_origin(godot_transform2d *r_dest, const godot_vector2 *p_x_axis, const godot_vector2 *p_y_axis, const godot_vector2 *p_origin); - -godot_string GDAPI godot_transform2d_as_string(const godot_transform2d *p_self); - -godot_transform2d GDAPI godot_transform2d_inverse(const godot_transform2d *p_self); - -godot_transform2d GDAPI godot_transform2d_affine_inverse(const godot_transform2d *p_self); - -godot_real GDAPI godot_transform2d_get_rotation(const godot_transform2d *p_self); - -godot_vector2 GDAPI godot_transform2d_get_origin(const godot_transform2d *p_self); - -godot_vector2 GDAPI godot_transform2d_get_scale(const godot_transform2d *p_self); - -godot_transform2d GDAPI godot_transform2d_orthonormalized(const godot_transform2d *p_self); - -godot_transform2d GDAPI godot_transform2d_rotated(const godot_transform2d *p_self, const godot_real p_phi); - -godot_transform2d GDAPI godot_transform2d_scaled(const godot_transform2d *p_self, const godot_vector2 *p_scale); - -godot_transform2d GDAPI godot_transform2d_translated(const godot_transform2d *p_self, const godot_vector2 *p_offset); - -godot_vector2 GDAPI godot_transform2d_xform_vector2(const godot_transform2d *p_self, const godot_vector2 *p_v); - -godot_vector2 GDAPI godot_transform2d_xform_inv_vector2(const godot_transform2d *p_self, const godot_vector2 *p_v); - -godot_vector2 GDAPI godot_transform2d_basis_xform_vector2(const godot_transform2d *p_self, const godot_vector2 *p_v); - -godot_vector2 GDAPI godot_transform2d_basis_xform_inv_vector2(const godot_transform2d *p_self, const godot_vector2 *p_v); - -godot_transform2d GDAPI godot_transform2d_interpolate_with(const godot_transform2d *p_self, const godot_transform2d *p_m, const godot_real p_c); - -godot_bool GDAPI godot_transform2d_operator_equal(const godot_transform2d *p_self, const godot_transform2d *p_b); - -godot_transform2d GDAPI godot_transform2d_operator_multiply(const godot_transform2d *p_self, const godot_transform2d *p_b); - -void GDAPI godot_transform2d_new_identity(godot_transform2d *r_dest); - -godot_rect2 GDAPI godot_transform2d_xform_rect2(const godot_transform2d *p_self, const godot_rect2 *p_v); -godot_rect2 GDAPI godot_transform2d_xform_inv_rect2(const godot_transform2d *p_self, const godot_rect2 *p_v); +void GDAPI godot_transform2d_new(godot_transform2d *p_self); +godot_vector2 GDAPI *godot_transform2d_operator_index(godot_transform2d *p_self, godot_int p_index); +const godot_vector2 GDAPI *godot_transform2d_operator_index_const(const godot_transform2d *p_self, godot_int p_index); #ifdef __cplusplus } diff --git a/modules/gdnative/include/gdnative/variant.h b/modules/gdnative/include/gdnative/variant.h index 2e803d602b..329a6faf51 100644 --- a/modules/gdnative/include/gdnative/variant.h +++ b/modules/gdnative/include/gdnative/variant.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -35,16 +35,8 @@ extern "C" { #endif -#include <stdint.h> - -#define GODOT_VARIANT_SIZE (16 + sizeof(int64_t)) - -#ifndef GODOT_CORE_API_GODOT_VARIANT_TYPE_DEFINED -#define GODOT_CORE_API_GODOT_VARIANT_TYPE_DEFINED -typedef struct { - uint8_t _dont_touch_that[GODOT_VARIANT_SIZE]; -} godot_variant; -#endif +#include <gdnative/math_defs.h> +#include <gdnative/variant_struct.h> typedef enum godot_variant_type { GODOT_VARIANT_TYPE_NIL, @@ -146,10 +138,35 @@ typedef enum godot_variant_operator { GODOT_VARIANT_OP_MAX, } godot_variant_operator; -// reduce extern "C" nesting for VS2013 -#ifdef __cplusplus -} -#endif +typedef enum godot_variant_utility_function_type { + GODOT_UTILITY_FUNC_TYPE_MATH, + GODOT_UTILITY_FUNC_TYPE_RANDOM, + GODOT_UTILITY_FUNC_TYPE_GENERAL, +} godot_variant_utility_function_type; + +// Types for function pointers. +typedef void (*godot_validated_operator_evaluator)(const godot_variant *p_left, const godot_variant *p_right, godot_variant *r_result); +typedef void (*godot_ptr_operator_evaluator)(const void *p_left, const void *p_right, void *r_result); +typedef void (*godot_validated_builtin_method)(godot_variant *p_base, const godot_variant **p_args, int p_argument_count, godot_variant *r_return); +typedef void (*godot_ptr_builtin_method)(void *p_base, const void **p_args, void *r_return, int p_argument_count); +typedef void (*godot_validated_constructor)(godot_variant *p_base, const godot_variant **p_args); +typedef void (*godot_ptr_constructor)(void *p_base, const void **p_args); +typedef void (*godot_validated_setter)(godot_variant *p_base, const godot_variant *p_value); +typedef void (*godot_validated_getter)(const godot_variant *p_base, godot_variant *r_value); +typedef void (*godot_ptr_setter)(void *p_base, const void *p_value); +typedef void (*godot_ptr_getter)(const void *p_base, void *r_value); +typedef void (*godot_validated_indexed_setter)(godot_variant *p_base, godot_int p_index, const godot_variant *p_value, bool *r_oob); +typedef void (*godot_validated_indexed_getter)(const godot_variant *p_base, godot_int p_index, godot_variant *r_value, bool *r_oob); +typedef void (*godot_ptr_indexed_setter)(void *p_base, godot_int p_index, const void *p_value); +typedef void (*godot_ptr_indexed_getter)(const void *p_base, godot_int p_index, void *r_value); +typedef void (*godot_validated_keyed_setter)(godot_variant *p_base, const godot_variant *p_key, const godot_variant *p_value, bool *r_valid); +typedef void (*godot_validated_keyed_getter)(const godot_variant *p_base, const godot_variant *p_key, godot_variant *r_value, bool *r_valid); +typedef bool (*godot_validated_keyed_checker)(const godot_variant *p_base, const godot_variant *p_key, bool *r_valid); +typedef void (*godot_ptr_keyed_setter)(void *p_base, const void *p_key, const void *p_value); +typedef void (*godot_ptr_keyed_getter)(const void *p_base, const void *p_key, void *r_value); +typedef bool (*godot_ptr_keyed_checker)(const godot_variant *p_base, const godot_variant *p_key); +typedef void (*godot_validated_utility_function)(godot_variant *r_return, const godot_variant **p_arguments, int p_argument_count); +typedef void (*godot_ptr_utility_function)(void *r_return, const void **p_arguments, int p_argument_count); #include <gdnative/aabb.h> #include <gdnative/array.h> @@ -163,6 +180,7 @@ typedef enum godot_variant_operator { #include <gdnative/quat.h> #include <gdnative/rect2.h> #include <gdnative/rid.h> +#include <gdnative/signal.h> #include <gdnative/string.h> #include <gdnative/string_name.h> #include <gdnative/transform.h> @@ -173,22 +191,15 @@ typedef enum godot_variant_operator { #include <gdnative/gdnative.h> -#ifdef __cplusplus -extern "C" { -#endif - -godot_variant_type GDAPI godot_variant_get_type(const godot_variant *p_v); +// Memory. void GDAPI godot_variant_new_copy(godot_variant *r_dest, const godot_variant *p_src); void GDAPI godot_variant_new_nil(godot_variant *r_dest); - void GDAPI godot_variant_new_bool(godot_variant *r_dest, const godot_bool p_b); -void GDAPI godot_variant_new_uint(godot_variant *r_dest, const uint64_t p_i); -void GDAPI godot_variant_new_int(godot_variant *r_dest, const int64_t p_i); -void GDAPI godot_variant_new_real(godot_variant *r_dest, const double p_r); +void GDAPI godot_variant_new_int(godot_variant *r_dest, const godot_int p_i); +void GDAPI godot_variant_new_float(godot_variant *r_dest, const godot_float p_f); void GDAPI godot_variant_new_string(godot_variant *r_dest, const godot_string *p_s); -void GDAPI godot_variant_new_string_name(godot_variant *r_dest, const godot_string_name *p_s); void GDAPI godot_variant_new_vector2(godot_variant *r_dest, const godot_vector2 *p_v2); void GDAPI godot_variant_new_vector2i(godot_variant *r_dest, const godot_vector2i *p_v2); void GDAPI godot_variant_new_rect2(godot_variant *r_dest, const godot_rect2 *p_rect2); @@ -202,11 +213,12 @@ void GDAPI godot_variant_new_aabb(godot_variant *r_dest, const godot_aabb *p_aab void GDAPI godot_variant_new_basis(godot_variant *r_dest, const godot_basis *p_basis); void GDAPI godot_variant_new_transform(godot_variant *r_dest, const godot_transform *p_trans); void GDAPI godot_variant_new_color(godot_variant *r_dest, const godot_color *p_color); +void GDAPI godot_variant_new_string_name(godot_variant *r_dest, const godot_string_name *p_s); void GDAPI godot_variant_new_node_path(godot_variant *r_dest, const godot_node_path *p_np); void GDAPI godot_variant_new_rid(godot_variant *r_dest, const godot_rid *p_rid); +void GDAPI godot_variant_new_object(godot_variant *r_dest, const godot_object *p_obj); void GDAPI godot_variant_new_callable(godot_variant *r_dest, const godot_callable *p_callable); void GDAPI godot_variant_new_signal(godot_variant *r_dest, const godot_signal *p_signal); -void GDAPI godot_variant_new_object(godot_variant *r_dest, const godot_object *p_obj); void GDAPI godot_variant_new_dictionary(godot_variant *r_dest, const godot_dictionary *p_dict); void GDAPI godot_variant_new_array(godot_variant *r_dest, const godot_array *p_arr); void GDAPI godot_variant_new_packed_byte_array(godot_variant *r_dest, const godot_packed_byte_array *p_pba); @@ -220,11 +232,9 @@ void GDAPI godot_variant_new_packed_vector3_array(godot_variant *r_dest, const g void GDAPI godot_variant_new_packed_color_array(godot_variant *r_dest, const godot_packed_color_array *p_pca); godot_bool GDAPI godot_variant_as_bool(const godot_variant *p_self); -uint64_t GDAPI godot_variant_as_uint(const godot_variant *p_self); -int64_t GDAPI godot_variant_as_int(const godot_variant *p_self); -double GDAPI godot_variant_as_real(const godot_variant *p_self); +godot_int GDAPI godot_variant_as_int(const godot_variant *p_self); +godot_float GDAPI godot_variant_as_float(const godot_variant *p_self); godot_string GDAPI godot_variant_as_string(const godot_variant *p_self); -godot_string_name GDAPI godot_variant_as_string_name(const godot_variant *p_self); godot_vector2 GDAPI godot_variant_as_vector2(const godot_variant *p_self); godot_vector2i GDAPI godot_variant_as_vector2i(const godot_variant *p_self); godot_rect2 GDAPI godot_variant_as_rect2(const godot_variant *p_self); @@ -238,11 +248,12 @@ godot_aabb GDAPI godot_variant_as_aabb(const godot_variant *p_self); godot_basis GDAPI godot_variant_as_basis(const godot_variant *p_self); godot_transform GDAPI godot_variant_as_transform(const godot_variant *p_self); godot_color GDAPI godot_variant_as_color(const godot_variant *p_self); +godot_string_name GDAPI godot_variant_as_string_name(const godot_variant *p_self); godot_node_path GDAPI godot_variant_as_node_path(const godot_variant *p_self); godot_rid GDAPI godot_variant_as_rid(const godot_variant *p_self); +godot_object GDAPI *godot_variant_as_object(const godot_variant *p_self); godot_callable GDAPI godot_variant_as_callable(const godot_variant *p_self); godot_signal GDAPI godot_variant_as_signal(const godot_variant *p_self); -godot_object GDAPI *godot_variant_as_object(const godot_variant *p_self); godot_dictionary GDAPI godot_variant_as_dictionary(const godot_variant *p_self); godot_array GDAPI godot_variant_as_array(const godot_variant *p_self); godot_packed_byte_array GDAPI godot_variant_as_packed_byte_array(const godot_variant *p_self); @@ -255,24 +266,153 @@ godot_packed_vector2_array GDAPI godot_variant_as_packed_vector2_array(const god godot_packed_vector3_array GDAPI godot_variant_as_packed_vector3_array(const godot_variant *p_self); godot_packed_color_array GDAPI godot_variant_as_packed_color_array(const godot_variant *p_self); -godot_variant GDAPI godot_variant_call(godot_variant *p_self, const godot_string *p_method, const godot_variant **p_args, const godot_int p_argcount, godot_variant_call_error *r_error); - -godot_bool GDAPI godot_variant_has_method(const godot_variant *p_self, const godot_string *p_method); - -godot_bool GDAPI godot_variant_operator_equal(const godot_variant *p_self, const godot_variant *p_other); -godot_bool GDAPI godot_variant_operator_less(const godot_variant *p_self, const godot_variant *p_other); +void GDAPI godot_variant_destroy(godot_variant *p_self); -uint32_t GDAPI godot_variant_hash(const godot_variant *p_self); +// Dynamic interaction. + +void GDAPI godot_variant_call(godot_variant *p_self, const godot_string_name *p_method, const godot_variant **p_args, const godot_int p_argument_count, godot_variant *r_return, godot_variant_call_error *r_error); +void GDAPI godot_variant_call_with_cstring(godot_variant *p_self, const char *p_method, const godot_variant **p_args, const godot_int p_argument_count, godot_variant *r_return, godot_variant_call_error *r_error); +void GDAPI godot_variant_evaluate(godot_variant_operator p_op, const godot_variant *p_a, const godot_variant *p_b, godot_variant *r_return, bool *r_valid); +void GDAPI godot_variant_set(godot_variant *p_self, const godot_variant *p_key, const godot_variant *p_value, bool *r_valid); +void GDAPI godot_variant_set_named(godot_variant *p_self, const godot_string_name *p_name, const godot_variant *p_value, bool *r_valid); +void GDAPI godot_variant_set_named_with_cstring(godot_variant *p_self, const char *p_name, const godot_variant *p_value, bool *r_valid); +void GDAPI godot_variant_set_keyed(godot_variant *p_self, const godot_variant *p_key, const godot_variant *p_value, bool *r_valid); +void GDAPI godot_variant_set_indexed(godot_variant *p_self, godot_int p_index, const godot_variant *p_value, bool *r_valid, bool *r_oob); +godot_variant GDAPI godot_variant_get(const godot_variant *p_self, const godot_variant *p_key, bool *r_valid); +godot_variant GDAPI godot_variant_get_named(const godot_variant *p_self, const godot_string_name *p_key, bool *r_valid); +godot_variant GDAPI godot_variant_get_named_with_cstring(const godot_variant *p_self, const char *p_key, bool *r_valid); +godot_variant GDAPI godot_variant_get_keyed(const godot_variant *p_self, const godot_variant *p_key, bool *r_valid); +godot_variant GDAPI godot_variant_get_indexed(const godot_variant *p_self, godot_int p_index, bool *r_valid, bool *r_oob); +/// Iteration. +bool GDAPI godot_variant_iter_init(const godot_variant *p_self, godot_variant *r_iter, bool *r_valid); +bool GDAPI godot_variant_iter_next(const godot_variant *p_self, godot_variant *r_iter, bool *r_valid); +godot_variant GDAPI godot_variant_iter_get(const godot_variant *p_self, godot_variant *r_iter, bool *r_valid); + +/// Variant functions. godot_bool GDAPI godot_variant_hash_compare(const godot_variant *p_self, const godot_variant *p_other); - godot_bool GDAPI godot_variant_booleanize(const godot_variant *p_self); - -void GDAPI godot_variant_destroy(godot_variant *p_self); - -// GDNative core 1.1 - -godot_string GDAPI godot_variant_get_operator_name(godot_variant_operator p_op); -void GDAPI godot_variant_evaluate(godot_variant_operator p_op, const godot_variant *p_a, const godot_variant *p_b, godot_variant *r_ret, godot_bool *r_valid); +void GDAPI godot_variant_blend(const godot_variant *p_a, const godot_variant *p_b, float p_c, godot_variant *r_dst); +void GDAPI godot_variant_interpolate(const godot_variant *p_a, const godot_variant *p_b, float p_c, godot_variant *r_dst); +godot_variant GDAPI godot_variant_duplicate(const godot_variant *p_self, godot_bool p_deep); +godot_string GDAPI godot_variant_stringify(const godot_variant *p_self); + +// Discovery API. + +/// Operators. +godot_validated_operator_evaluator GDAPI godot_variant_get_validated_operator_evaluator(godot_variant_operator p_operator, godot_variant_type p_type_a, godot_variant_type p_type_b); +godot_ptr_operator_evaluator GDAPI godot_variant_get_ptr_operator_evaluator(godot_variant_operator p_operator, godot_variant_type p_type_a, godot_variant_type p_type_b); +godot_variant_type GDAPI godot_variant_get_operator_return_type(godot_variant_operator p_operator, godot_variant_type p_type_a, godot_variant_type p_type_b); +godot_string GDAPI godot_variant_get_operator_name(godot_variant_operator p_operator); + +/// Built-in methods. +bool GDAPI godot_variant_has_builtin_method(godot_variant_type p_type, const godot_string_name *p_method); +bool GDAPI godot_variant_has_builtin_method_with_cstring(godot_variant_type p_type, const char *p_method); +godot_validated_builtin_method GDAPI godot_variant_get_validated_builtin_method(godot_variant_type p_type, const godot_string_name *p_method); +godot_validated_builtin_method GDAPI godot_variant_get_validated_builtin_method_with_cstring(godot_variant_type p_type, const char *p_method); +godot_ptr_builtin_method GDAPI godot_variant_get_ptr_builtin_method(godot_variant_type p_type, const godot_string_name *p_method); +godot_ptr_builtin_method GDAPI godot_variant_get_ptr_builtin_method_with_cstring(godot_variant_type p_type, const char *p_method); +int GDAPI godot_variant_get_builtin_method_argument_count(godot_variant_type p_type, const godot_string_name *p_method); +int GDAPI godot_variant_get_builtin_method_argument_count_with_cstring(godot_variant_type p_type, const char *p_method); +godot_variant_type GDAPI godot_variant_get_builtin_method_argument_type(godot_variant_type p_type, const godot_string_name *p_method, int p_argument); +godot_variant_type GDAPI godot_variant_get_builtin_method_argument_type_with_cstring(godot_variant_type p_type, const char *p_method, int p_argument); +godot_string GDAPI godot_variant_get_builtin_method_argument_name(godot_variant_type p_type, const godot_string_name *p_method, int p_argument); +godot_string GDAPI godot_variant_get_builtin_method_argument_name_with_cstring(godot_variant_type p_type, const char *p_method, int p_argument); +bool GDAPI godot_variant_has_builtin_method_return_value(godot_variant_type p_type, const godot_string_name *p_method); +bool GDAPI godot_variant_has_builtin_method_return_value_with_cstring(godot_variant_type p_type, const char *p_method); +godot_variant_type GDAPI godot_variant_get_builtin_method_return_type(godot_variant_type p_type, const godot_string_name *p_method); +godot_variant_type GDAPI godot_variant_get_builtin_method_return_type_with_cstring(godot_variant_type p_type, const char *p_method); +bool GDAPI godot_variant_is_builtin_method_const(godot_variant_type p_type, const godot_string_name *p_method); +bool GDAPI godot_variant_is_builtin_method_const_with_cstring(godot_variant_type p_type, const char *p_method); +bool GDAPI godot_variant_is_builtin_method_vararg(godot_variant_type p_type, const godot_string_name *p_method); +bool GDAPI godot_variant_is_builtin_method_vararg_with_cstring(godot_variant_type p_type, const char *p_method); +int GDAPI godot_variant_get_builtin_method_count(godot_variant_type p_type); +void GDAPI godot_variant_get_builtin_method_list(godot_variant_type p_type, godot_string_name *r_list); + +/// Constructors. +int GDAPI godot_variant_get_constructor_count(godot_variant_type p_type); +godot_validated_constructor GDAPI godot_variant_get_validated_constructor(godot_variant_type p_type, int p_constructor); +godot_ptr_constructor GDAPI godot_variant_get_ptr_constructor(godot_variant_type p_type, int p_constructor); +int GDAPI godot_variant_get_constructor_argument_count(godot_variant_type p_type, int p_constructor); +godot_variant_type GDAPI godot_variant_get_constructor_argument_type(godot_variant_type p_type, int p_constructor, int p_argument); +godot_string GDAPI godot_variant_get_constructor_argument_name(godot_variant_type p_type, int p_constructor, int p_argument); +void GDAPI godot_variant_construct(godot_variant_type p_type, godot_variant *p_base, const godot_variant **p_args, int p_argument_count, godot_variant_call_error *r_error); + +/// Properties. +godot_variant_type GDAPI godot_variant_get_member_type(godot_variant_type p_type, const godot_string_name *p_member); +godot_variant_type GDAPI godot_variant_get_member_type_with_cstring(godot_variant_type p_type, const char *p_member); +int GDAPI godot_variant_get_member_count(godot_variant_type p_type); +void GDAPI godot_variant_get_member_list(godot_variant_type p_type, godot_string_name *r_list); +godot_validated_setter GDAPI godot_variant_get_validated_setter(godot_variant_type p_type, const godot_string_name *p_member); +godot_validated_setter GDAPI godot_variant_get_validated_setter_with_cstring(godot_variant_type p_type, const char *p_member); +godot_validated_getter GDAPI godot_variant_get_validated_getter(godot_variant_type p_type, const godot_string_name *p_member); +godot_validated_getter GDAPI godot_variant_get_validated_getter_with_cstring(godot_variant_type p_type, const char *p_member); +godot_ptr_setter GDAPI godot_variant_get_ptr_setter(godot_variant_type p_type, const godot_string_name *p_member); +godot_ptr_setter GDAPI godot_variant_get_ptr_setter_with_cstring(godot_variant_type p_type, const char *p_member); +godot_ptr_getter GDAPI godot_variant_get_ptr_getter(godot_variant_type p_type, const godot_string_name *p_member); +godot_ptr_getter GDAPI godot_variant_get_ptr_getter_with_cstring(godot_variant_type p_type, const char *p_member); + +/// Indexing. +bool GDAPI godot_variant_has_indexing(godot_variant_type p_type); +godot_variant_type GDAPI godot_variant_get_indexed_element_type(godot_variant_type p_type); +godot_validated_indexed_setter GDAPI godot_variant_get_validated_indexed_setter(godot_variant_type p_type); +godot_validated_indexed_getter GDAPI godot_variant_get_validated_indexed_getter(godot_variant_type p_type); +godot_ptr_indexed_setter GDAPI godot_variant_get_ptr_indexed_setter(godot_variant_type p_type); +godot_ptr_indexed_getter GDAPI godot_variant_get_ptr_indexed_getter(godot_variant_type p_type); +uint64_t GDAPI godot_variant_get_indexed_size(const godot_variant *p_self); + +/// Keying. +bool GDAPI godot_variant_is_keyed(godot_variant_type p_type); +godot_validated_keyed_setter GDAPI godot_variant_get_validated_keyed_setter(godot_variant_type p_type); +godot_validated_keyed_getter GDAPI godot_variant_get_validated_keyed_getter(godot_variant_type p_type); +godot_validated_keyed_checker GDAPI godot_variant_get_validated_keyed_checker(godot_variant_type p_type); +godot_ptr_keyed_setter GDAPI godot_variant_get_ptr_keyed_setter(godot_variant_type p_type); +godot_ptr_keyed_getter GDAPI godot_variant_get_ptr_keyed_getter(godot_variant_type p_type); +godot_ptr_keyed_checker GDAPI godot_variant_get_ptr_keyed_checker(godot_variant_type p_type); + +/// Constants. +int GDAPI godot_variant_get_constants_count(godot_variant_type p_type); +void GDAPI godot_variant_get_constants_list(godot_variant_type p_type, godot_string_name *r_list); +bool GDAPI godot_variant_has_constant(godot_variant_type p_type, const godot_string_name *p_constant); +bool GDAPI godot_variant_has_constant_with_cstring(godot_variant_type p_type, const char *p_constant); +godot_variant GDAPI godot_variant_get_constant_value(godot_variant_type p_type, const godot_string_name *p_constant); +godot_variant GDAPI godot_variant_get_constant_value_with_cstring(godot_variant_type p_type, const char *p_constant); + +/// Utilities. +bool GDAPI godot_variant_has_utility_function(const godot_string_name *p_function); +bool GDAPI godot_variant_has_utility_function_with_cstring(const char *p_function); +void GDAPI godot_variant_call_utility_function(const godot_string_name *p_function, godot_variant *r_ret, const godot_variant **p_args, int p_argument_count, godot_variant_call_error *r_error); +void GDAPI godot_variant_call_utility_function_with_cstring(const char *p_function, godot_variant *r_ret, const godot_variant **p_args, int p_argument_count, godot_variant_call_error *r_error); +godot_ptr_utility_function GDAPI godot_variant_get_ptr_utility_function(const godot_string_name *p_function); +godot_ptr_utility_function GDAPI godot_variant_get_ptr_utility_function_with_cstring(const char *p_function); +godot_validated_utility_function GDAPI godot_variant_get_validated_utility_function(const godot_string_name *p_function); +godot_validated_utility_function GDAPI godot_variant_get_validated_utility_function_with_cstring(const char *p_function); +godot_variant_utility_function_type GDAPI godot_variant_get_utility_function_type(const godot_string_name *p_function); +godot_variant_utility_function_type GDAPI godot_variant_get_utility_function_type_with_cstring(const char *p_function); +int GDAPI godot_variant_get_utility_function_argument_count(const godot_string_name *p_function); +int GDAPI godot_variant_get_utility_function_argument_count_with_cstring(const char *p_function); +godot_variant_type GDAPI godot_variant_get_utility_function_argument_type(const godot_string_name *p_function, int p_argument); +godot_variant_type GDAPI godot_variant_get_utility_function_argument_type_with_cstring(const char *p_function, int p_argument); +godot_string GDAPI godot_variant_get_utility_function_argument_name(const godot_string_name *p_function, int p_argument); +godot_string GDAPI godot_variant_get_utility_function_argument_name_with_cstring(const char *p_function, int p_argument); +bool GDAPI godot_variant_has_utility_function_return_value(const godot_string_name *p_function); +bool GDAPI godot_variant_has_utility_function_return_value_with_cstring(const char *p_function); +godot_variant_type GDAPI godot_variant_get_utility_function_return_type(const godot_string_name *p_function); +godot_variant_type GDAPI godot_variant_get_utility_function_return_type_with_cstring(const char *p_function); +bool GDAPI godot_variant_is_utility_function_vararg(const godot_string_name *p_function); +bool GDAPI godot_variant_is_utility_function_vararg_with_cstring(const char *p_function); +int GDAPI godot_variant_get_utility_function_count(); +void GDAPI godot_variant_get_utility_function_list(godot_string_name *r_functions); + +// Introspection. + +godot_variant_type GDAPI godot_variant_get_type(const godot_variant *p_self); +bool GDAPI godot_variant_has_method(const godot_variant *p_self, const godot_string_name *p_method); +bool GDAPI godot_variant_has_member(godot_variant_type p_type, const godot_string_name *p_member); +bool GDAPI godot_variant_has_key(const godot_variant *p_self, const godot_variant *p_key, bool *r_valid); + +godot_string GDAPI godot_variant_get_type_name(godot_variant_type p_type); +bool GDAPI godot_variant_can_convert(godot_variant_type p_from, godot_variant_type p_to); +bool GDAPI godot_variant_can_convert_strict(godot_variant_type p_from, godot_variant_type p_to); #ifdef __cplusplus } diff --git a/modules/gamecenter/game_center_module.cpp b/modules/gdnative/include/gdnative/variant_struct.h index 6c5157345f..321c76c206 100644 --- a/modules/gamecenter/game_center_module.cpp +++ b/modules/gdnative/include/gdnative/variant_struct.h @@ -1,12 +1,12 @@ /*************************************************************************/ -/* game_center_module.cpp */ +/* variant_struct.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -28,21 +28,26 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "game_center_module.h" +#ifndef GODOT_VARIANT_STRUCT_H +#define GODOT_VARIANT_STRUCT_H -#include "core/config/engine.h" +#ifdef __cplusplus +extern "C" { +#endif -#include "game_center.h" +#include <gdnative/math_defs.h> -GameCenter *game_center; +#define GODOT_VARIANT_SIZE (sizeof(godot_real_t) * 4 + sizeof(int64_t)) -void register_gamecenter_types() { - game_center = memnew(GameCenter); - Engine::get_singleton()->add_singleton(Engine::Singleton("GameCenter", game_center)); -} +#ifndef GODOT_CORE_API_GODOT_VARIANT_TYPE_DEFINED +#define GODOT_CORE_API_GODOT_VARIANT_TYPE_DEFINED +typedef struct { + uint8_t _dont_touch_that[GODOT_VARIANT_SIZE]; +} godot_variant; +#endif -void unregister_gamecenter_types() { - if (game_center) { - memdelete(game_center); - } +#ifdef __cplusplus } +#endif + +#endif diff --git a/modules/gdnative/include/gdnative/vector2.h b/modules/gdnative/include/gdnative/vector2.h index 35b02c5a75..5ebb705ba4 100644 --- a/modules/gdnative/include/gdnative/vector2.h +++ b/modules/gdnative/include/gdnative/vector2.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -35,9 +35,9 @@ extern "C" { #endif -#include <stdint.h> +#include <gdnative/math_defs.h> -#define GODOT_VECTOR2_SIZE 8 +#define GODOT_VECTOR2_SIZE (sizeof(godot_real_t) * 2) #ifndef GODOT_CORE_API_GODOT_VECTOR2_TYPE_DEFINED #define GODOT_CORE_API_GODOT_VECTOR2_TYPE_DEFINED @@ -46,7 +46,7 @@ typedef struct { } godot_vector2; #endif -#define GODOT_VECTOR2I_SIZE 8 +#define GODOT_VECTOR2I_SIZE (sizeof(int32_t) * 2) #ifndef GODOT_CORE_API_GODOT_VECTOR2I_TYPE_DEFINED #define GODOT_CORE_API_GODOT_VECTOR2I_TYPE_DEFINED @@ -55,140 +55,14 @@ typedef struct { } godot_vector2i; #endif -// reduce extern "C" nesting for VS2013 -#ifdef __cplusplus -} -#endif - #include <gdnative/gdnative.h> -#ifdef __cplusplus -extern "C" { -#endif - -// Vector2 - -void GDAPI godot_vector2_new(godot_vector2 *r_dest, const godot_real p_x, const godot_real p_y); - -godot_string GDAPI godot_vector2_as_string(const godot_vector2 *p_self); - -godot_vector2i GDAPI godot_vector2_as_vector2i(const godot_vector2 *p_self); - -godot_vector2 GDAPI godot_vector2_normalized(const godot_vector2 *p_self); - -godot_real GDAPI godot_vector2_length(const godot_vector2 *p_self); - -godot_real GDAPI godot_vector2_angle(const godot_vector2 *p_self); - -godot_real GDAPI godot_vector2_length_squared(const godot_vector2 *p_self); - -godot_bool GDAPI godot_vector2_is_normalized(const godot_vector2 *p_self); - -godot_vector2 GDAPI godot_vector2_direction_to(const godot_vector2 *p_self, const godot_vector2 *p_b); - -godot_real GDAPI godot_vector2_distance_to(const godot_vector2 *p_self, const godot_vector2 *p_to); - -godot_real GDAPI godot_vector2_distance_squared_to(const godot_vector2 *p_self, const godot_vector2 *p_to); - -godot_real GDAPI godot_vector2_angle_to(const godot_vector2 *p_self, const godot_vector2 *p_to); - -godot_real GDAPI godot_vector2_angle_to_point(const godot_vector2 *p_self, const godot_vector2 *p_to); - -godot_vector2 GDAPI godot_vector2_lerp(const godot_vector2 *p_self, const godot_vector2 *p_b, const godot_real p_t); - -godot_vector2 GDAPI godot_vector2_cubic_interpolate(const godot_vector2 *p_self, const godot_vector2 *p_b, const godot_vector2 *p_pre_a, const godot_vector2 *p_post_b, const godot_real p_t); - -godot_vector2 GDAPI godot_vector2_move_toward(const godot_vector2 *p_self, const godot_vector2 *p_to, const godot_real p_delta); - -godot_vector2 GDAPI godot_vector2_rotated(const godot_vector2 *p_self, const godot_real p_phi); - -godot_vector2 GDAPI godot_vector2_tangent(const godot_vector2 *p_self); - -godot_vector2 GDAPI godot_vector2_floor(const godot_vector2 *p_self); - -godot_vector2 GDAPI godot_vector2_sign(const godot_vector2 *p_self); - -godot_vector2 GDAPI godot_vector2_snapped(const godot_vector2 *p_self, const godot_vector2 *p_by); - -godot_real GDAPI godot_vector2_aspect(const godot_vector2 *p_self); - -godot_real GDAPI godot_vector2_dot(const godot_vector2 *p_self, const godot_vector2 *p_with); - -godot_vector2 GDAPI godot_vector2_slide(const godot_vector2 *p_self, const godot_vector2 *p_n); - -godot_vector2 GDAPI godot_vector2_bounce(const godot_vector2 *p_self, const godot_vector2 *p_n); - -godot_vector2 GDAPI godot_vector2_reflect(const godot_vector2 *p_self, const godot_vector2 *p_n); - -godot_vector2 GDAPI godot_vector2_abs(const godot_vector2 *p_self); - -godot_vector2 GDAPI godot_vector2_clamped(const godot_vector2 *p_self, const godot_real p_length); - -godot_vector2 GDAPI godot_vector2_operator_add(const godot_vector2 *p_self, const godot_vector2 *p_b); - -godot_vector2 GDAPI godot_vector2_operator_subtract(const godot_vector2 *p_self, const godot_vector2 *p_b); - -godot_vector2 GDAPI godot_vector2_operator_multiply_vector(const godot_vector2 *p_self, const godot_vector2 *p_b); - -godot_vector2 GDAPI godot_vector2_operator_multiply_scalar(const godot_vector2 *p_self, const godot_real p_b); - -godot_vector2 GDAPI godot_vector2_operator_divide_vector(const godot_vector2 *p_self, const godot_vector2 *p_b); - -godot_vector2 GDAPI godot_vector2_operator_divide_scalar(const godot_vector2 *p_self, const godot_real p_b); - -godot_bool GDAPI godot_vector2_operator_equal(const godot_vector2 *p_self, const godot_vector2 *p_b); - -godot_bool GDAPI godot_vector2_operator_less(const godot_vector2 *p_self, const godot_vector2 *p_b); - -godot_vector2 GDAPI godot_vector2_operator_neg(const godot_vector2 *p_self); - -void GDAPI godot_vector2_set_x(godot_vector2 *p_self, const godot_real p_x); - -void GDAPI godot_vector2_set_y(godot_vector2 *p_self, const godot_real p_y); - -godot_real GDAPI godot_vector2_get_x(const godot_vector2 *p_self); - -godot_real GDAPI godot_vector2_get_y(const godot_vector2 *p_self); - -// Vector2i - -void GDAPI godot_vector2i_new(godot_vector2i *r_dest, const godot_int p_x, const godot_int p_y); - -godot_string GDAPI godot_vector2i_as_string(const godot_vector2i *p_self); - -godot_vector2 GDAPI godot_vector2i_as_vector2(const godot_vector2i *p_self); - -godot_real GDAPI godot_vector2i_aspect(const godot_vector2i *p_self); - -godot_vector2i GDAPI godot_vector2i_abs(const godot_vector2i *p_self); - -godot_vector2i GDAPI godot_vector2i_sign(const godot_vector2i *p_self); - -godot_vector2i GDAPI godot_vector2i_operator_add(const godot_vector2i *p_self, const godot_vector2i *p_b); - -godot_vector2i GDAPI godot_vector2i_operator_subtract(const godot_vector2i *p_self, const godot_vector2i *p_b); - -godot_vector2i GDAPI godot_vector2i_operator_multiply_vector(const godot_vector2i *p_self, const godot_vector2i *p_b); - -godot_vector2i GDAPI godot_vector2i_operator_multiply_scalar(const godot_vector2i *p_self, const godot_int p_b); - -godot_vector2i GDAPI godot_vector2i_operator_divide_vector(const godot_vector2i *p_self, const godot_vector2i *p_b); - -godot_vector2i GDAPI godot_vector2i_operator_divide_scalar(const godot_vector2i *p_self, const godot_int p_b); - -godot_bool GDAPI godot_vector2i_operator_equal(const godot_vector2i *p_self, const godot_vector2i *p_b); - -godot_bool GDAPI godot_vector2i_operator_less(const godot_vector2i *p_self, const godot_vector2i *p_b); - -godot_vector2i GDAPI godot_vector2i_operator_neg(const godot_vector2i *p_self); - -void GDAPI godot_vector2i_set_x(godot_vector2i *p_self, const godot_int p_x); - -void GDAPI godot_vector2i_set_y(godot_vector2i *p_self, const godot_int p_y); - -godot_int GDAPI godot_vector2i_get_x(const godot_vector2i *p_self); - -godot_int GDAPI godot_vector2i_get_y(const godot_vector2i *p_self); +void GDAPI godot_vector2_new(godot_vector2 *p_self); +void GDAPI godot_vector2i_new(godot_vector2i *p_self); +godot_real_t GDAPI *godot_vector2_operator_index(godot_vector2 *p_self, godot_int p_index); +const godot_real_t GDAPI *godot_vector2_operator_index_const(const godot_vector2 *p_self, godot_int p_index); +int32_t GDAPI *godot_vector2i_operator_index(godot_vector2i *p_self, godot_int p_index); +const int32_t GDAPI *godot_vector2i_operator_index_const(const godot_vector2i *p_self, godot_int p_index); #ifdef __cplusplus } diff --git a/modules/gdnative/include/gdnative/vector3.h b/modules/gdnative/include/gdnative/vector3.h index 5127b8789b..d37ebd3cc9 100644 --- a/modules/gdnative/include/gdnative/vector3.h +++ b/modules/gdnative/include/gdnative/vector3.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -35,9 +35,9 @@ extern "C" { #endif -#include <stdint.h> +#include <gdnative/math_defs.h> -#define GODOT_VECTOR3_SIZE 12 +#define GODOT_VECTOR3_SIZE (sizeof(godot_real_t) * 3) #ifndef GODOT_CORE_API_GODOT_VECTOR3_TYPE_DEFINED #define GODOT_CORE_API_GODOT_VECTOR3_TYPE_DEFINED @@ -46,7 +46,7 @@ typedef struct { } godot_vector3; #endif -#define GODOT_VECTOR3I_SIZE 12 +#define GODOT_VECTOR3I_SIZE (sizeof(int32_t) * 3) #ifndef GODOT_CORE_API_GODOT_VECTOR3I_TYPE_DEFINED #define GODOT_CORE_API_GODOT_VECTOR3I_TYPE_DEFINED @@ -55,145 +55,14 @@ typedef struct { } godot_vector3i; #endif -// reduce extern "C" nesting for VS2013 -#ifdef __cplusplus -} -#endif - -#include <gdnative/basis.h> #include <gdnative/gdnative.h> -#ifdef __cplusplus -extern "C" { -#endif - -typedef enum { - GODOT_VECTOR3_AXIS_X, - GODOT_VECTOR3_AXIS_Y, - GODOT_VECTOR3_AXIS_Z, -} godot_vector3_axis; - -// Vector3 - -void GDAPI godot_vector3_new(godot_vector3 *r_dest, const godot_real p_x, const godot_real p_y, const godot_real p_z); - -godot_string GDAPI godot_vector3_as_string(const godot_vector3 *p_self); - -godot_vector3i GDAPI godot_vector3_as_vector3i(const godot_vector3 *p_self); - -godot_int GDAPI godot_vector3_min_axis(const godot_vector3 *p_self); - -godot_int GDAPI godot_vector3_max_axis(const godot_vector3 *p_self); - -godot_real GDAPI godot_vector3_length(const godot_vector3 *p_self); - -godot_real GDAPI godot_vector3_length_squared(const godot_vector3 *p_self); - -godot_bool GDAPI godot_vector3_is_normalized(const godot_vector3 *p_self); - -godot_vector3 GDAPI godot_vector3_normalized(const godot_vector3 *p_self); - -godot_vector3 GDAPI godot_vector3_inverse(const godot_vector3 *p_self); - -godot_vector3 GDAPI godot_vector3_snapped(const godot_vector3 *p_self, const godot_vector3 *p_by); - -godot_vector3 GDAPI godot_vector3_rotated(const godot_vector3 *p_self, const godot_vector3 *p_axis, const godot_real p_phi); - -godot_vector3 GDAPI godot_vector3_lerp(const godot_vector3 *p_self, const godot_vector3 *p_b, const godot_real p_t); - -godot_vector3 GDAPI godot_vector3_cubic_interpolate(const godot_vector3 *p_self, const godot_vector3 *p_b, const godot_vector3 *p_pre_a, const godot_vector3 *p_post_b, const godot_real p_t); - -godot_vector3 GDAPI godot_vector3_move_toward(const godot_vector3 *p_self, const godot_vector3 *p_to, const godot_real p_delta); - -godot_real GDAPI godot_vector3_dot(const godot_vector3 *p_self, const godot_vector3 *p_b); - -godot_vector3 GDAPI godot_vector3_cross(const godot_vector3 *p_self, const godot_vector3 *p_b); - -godot_basis GDAPI godot_vector3_outer(const godot_vector3 *p_self, const godot_vector3 *p_b); - -godot_basis GDAPI godot_vector3_to_diagonal_matrix(const godot_vector3 *p_self); - -godot_vector3 GDAPI godot_vector3_abs(const godot_vector3 *p_self); - -godot_vector3 GDAPI godot_vector3_sign(const godot_vector3 *p_self); - -godot_vector3 GDAPI godot_vector3_floor(const godot_vector3 *p_self); - -godot_vector3 GDAPI godot_vector3_ceil(const godot_vector3 *p_self); - -godot_vector3 GDAPI godot_vector3_direction_to(const godot_vector3 *p_self, const godot_vector3 *p_b); - -godot_real GDAPI godot_vector3_distance_to(const godot_vector3 *p_self, const godot_vector3 *p_b); - -godot_real GDAPI godot_vector3_distance_squared_to(const godot_vector3 *p_self, const godot_vector3 *p_b); - -godot_real GDAPI godot_vector3_angle_to(const godot_vector3 *p_self, const godot_vector3 *p_to); - -godot_vector3 GDAPI godot_vector3_slide(const godot_vector3 *p_self, const godot_vector3 *p_n); - -godot_vector3 GDAPI godot_vector3_bounce(const godot_vector3 *p_self, const godot_vector3 *p_n); - -godot_vector3 GDAPI godot_vector3_reflect(const godot_vector3 *p_self, const godot_vector3 *p_n); - -godot_vector3 GDAPI godot_vector3_operator_add(const godot_vector3 *p_self, const godot_vector3 *p_b); - -godot_vector3 GDAPI godot_vector3_operator_subtract(const godot_vector3 *p_self, const godot_vector3 *p_b); - -godot_vector3 GDAPI godot_vector3_operator_multiply_vector(const godot_vector3 *p_self, const godot_vector3 *p_b); - -godot_vector3 GDAPI godot_vector3_operator_multiply_scalar(const godot_vector3 *p_self, const godot_real p_b); - -godot_vector3 GDAPI godot_vector3_operator_divide_vector(const godot_vector3 *p_self, const godot_vector3 *p_b); - -godot_vector3 GDAPI godot_vector3_operator_divide_scalar(const godot_vector3 *p_self, const godot_real p_b); - -godot_bool GDAPI godot_vector3_operator_equal(const godot_vector3 *p_self, const godot_vector3 *p_b); - -godot_bool GDAPI godot_vector3_operator_less(const godot_vector3 *p_self, const godot_vector3 *p_b); - -godot_vector3 GDAPI godot_vector3_operator_neg(const godot_vector3 *p_self); - -void GDAPI godot_vector3_set_axis(godot_vector3 *p_self, const godot_vector3_axis p_axis, const godot_real p_val); - -godot_real GDAPI godot_vector3_get_axis(const godot_vector3 *p_self, const godot_vector3_axis p_axis); - -// Vector3i - -void GDAPI godot_vector3i_new(godot_vector3i *r_dest, const godot_int p_x, const godot_int p_y, const godot_int p_z); - -godot_string GDAPI godot_vector3i_as_string(const godot_vector3i *p_self); - -godot_vector3 GDAPI godot_vector3i_as_vector3(const godot_vector3i *p_self); - -godot_int GDAPI godot_vector3i_min_axis(const godot_vector3i *p_self); - -godot_int GDAPI godot_vector3i_max_axis(const godot_vector3i *p_self); - -godot_vector3i GDAPI godot_vector3i_abs(const godot_vector3i *p_self); - -godot_vector3i GDAPI godot_vector3i_sign(const godot_vector3i *p_self); - -godot_vector3i GDAPI godot_vector3i_operator_add(const godot_vector3i *p_self, const godot_vector3i *p_b); - -godot_vector3i GDAPI godot_vector3i_operator_subtract(const godot_vector3i *p_self, const godot_vector3i *p_b); - -godot_vector3i GDAPI godot_vector3i_operator_multiply_vector(const godot_vector3i *p_self, const godot_vector3i *p_b); - -godot_vector3i GDAPI godot_vector3i_operator_multiply_scalar(const godot_vector3i *p_self, const godot_int p_b); - -godot_vector3i GDAPI godot_vector3i_operator_divide_vector(const godot_vector3i *p_self, const godot_vector3i *p_b); - -godot_vector3i GDAPI godot_vector3i_operator_divide_scalar(const godot_vector3i *p_self, const godot_int p_b); - -godot_bool GDAPI godot_vector3i_operator_equal(const godot_vector3i *p_self, const godot_vector3i *p_b); - -godot_bool GDAPI godot_vector3i_operator_less(const godot_vector3i *p_self, const godot_vector3i *p_b); - -godot_vector3i GDAPI godot_vector3i_operator_neg(const godot_vector3i *p_self); - -void GDAPI godot_vector3i_set_axis(godot_vector3i *p_self, const godot_vector3_axis p_axis, const godot_int p_val); - -godot_int GDAPI godot_vector3i_get_axis(const godot_vector3i *p_self, const godot_vector3_axis p_axis); +void GDAPI godot_vector3_new(godot_vector3 *p_self); +void GDAPI godot_vector3i_new(godot_vector3i *p_self); +godot_real_t GDAPI *godot_vector3_operator_index(godot_vector3 *p_self, godot_int p_index); +const godot_real_t GDAPI *godot_vector3_operator_index_const(const godot_vector3 *p_self, godot_int p_index); +int32_t GDAPI *godot_vector3i_operator_index(godot_vector3i *p_self, godot_int p_index); +const int32_t GDAPI *godot_vector3i_operator_index_const(const godot_vector3i *p_self, godot_int p_index); #ifdef __cplusplus } diff --git a/modules/gdnative/include/nativescript/godot_nativescript.h b/modules/gdnative/include/nativescript/godot_nativescript.h index cc12d58037..73b1738b03 100644 --- a/modules/gdnative/include/nativescript/godot_nativescript.h +++ b/modules/gdnative/include/nativescript/godot_nativescript.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gdnative/include/net/godot_net.h b/modules/gdnative/include/net/godot_net.h index 42804112f2..2fa576a5bf 100644 --- a/modules/gdnative/include/net/godot_net.h +++ b/modules/gdnative/include/net/godot_net.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gdnative/include/net/godot_webrtc.h b/modules/gdnative/include/net/godot_webrtc.h index 15e2df85cc..25aa72dae1 100644 --- a/modules/gdnative/include/net/godot_webrtc.h +++ b/modules/gdnative/include/net/godot_webrtc.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gdnative/include/pluginscript/godot_pluginscript.h b/modules/gdnative/include/pluginscript/godot_pluginscript.h index e4b1fd5eb0..cbd65e3772 100644 --- a/modules/gdnative/include/pluginscript/godot_pluginscript.h +++ b/modules/gdnative/include/pluginscript/godot_pluginscript.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gdnative/include/text/godot_text.h b/modules/gdnative/include/text/godot_text.h index 6885f2463d..ef60633a3d 100644 --- a/modules/gdnative/include/text/godot_text.h +++ b/modules/gdnative/include/text/godot_text.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -79,6 +79,10 @@ typedef struct { float (*font_get_descent)(void *, godot_rid *, int); float (*font_get_underline_position)(void *, godot_rid *, int); float (*font_get_underline_thickness)(void *, godot_rid *, int); + int (*font_get_spacing_space)(void *, godot_rid *); + void (*font_set_spacing_space)(void *, godot_rid *, int); + int (*font_get_spacing_glyph)(void *, godot_rid *); + void (*font_set_spacing_glyph)(void *, godot_rid *, int); void (*font_set_antialiased)(void *, godot_rid *, bool); bool (*font_get_antialiased)(void *, godot_rid *); godot_dictionary (*font_get_feature_list)(void *, godot_rid *); @@ -175,8 +179,8 @@ void GDAPI godot_glyph_set_flags(godot_glyph *p_self, godot_int p_flags); godot_vector2 GDAPI godot_glyph_get_offset(const godot_glyph *p_self); void GDAPI godot_glyph_set_offset(godot_glyph *p_self, const godot_vector2 *p_offset); -godot_real GDAPI godot_glyph_get_advance(const godot_glyph *p_self); -void GDAPI godot_glyph_set_advance(godot_glyph *p_self, godot_real p_advance); +godot_float GDAPI godot_glyph_get_advance(const godot_glyph *p_self); +void GDAPI godot_glyph_set_advance(godot_glyph *p_self, godot_float p_advance); godot_rid GDAPI godot_glyph_get_font(const godot_glyph *p_self); void GDAPI godot_glyph_set_font(godot_glyph *p_self, godot_rid *p_font); @@ -218,7 +222,7 @@ godot_glyph GDAPI godot_packed_glyph_array_get(const godot_packed_glyph_array *p godot_int GDAPI godot_packed_glyph_array_size(const godot_packed_glyph_array *p_self); -godot_bool GDAPI godot_packed_glyph_array_empty(const godot_packed_glyph_array *p_self); +godot_bool GDAPI godot_packed_glyph_array_is_empty(const godot_packed_glyph_array *p_self); void GDAPI godot_packed_glyph_array_destroy(godot_packed_glyph_array *p_self); diff --git a/modules/gdnative/include/videodecoder/godot_videodecoder.h b/modules/gdnative/include/videodecoder/godot_videodecoder.h index 16c92abd22..dc2cf5ec07 100644 --- a/modules/gdnative/include/videodecoder/godot_videodecoder.h +++ b/modules/gdnative/include/videodecoder/godot_videodecoder.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -49,11 +49,11 @@ typedef struct const char *(*get_plugin_name)(); const char **(*get_supported_extensions)(int *count); godot_bool (*open_file)(void *, void *); // data struct, and a FileAccess pointer - godot_real (*get_length)(const void *); - godot_real (*get_playback_position)(const void *); - void (*seek)(void *, godot_real); + godot_float (*get_length)(const void *); + godot_float (*get_playback_position)(const void *); + void (*seek)(void *, godot_float); void (*set_audio_track)(void *, godot_int); - void (*update)(void *, godot_real); + void (*update)(void *, godot_float); godot_packed_byte_array *(*get_videoframe)(void *); godot_int (*get_audioframe)(void *, float *, int); godot_int (*get_channels)(const void *); diff --git a/modules/gdnative/include/xr/godot_xr.h b/modules/gdnative/include/xr/godot_xr.h index 22f7f021c4..7eaf1c7ec3 100644 --- a/modules/gdnative/include/xr/godot_xr.h +++ b/modules/gdnative/include/xr/godot_xr.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -58,7 +58,7 @@ typedef struct { void (*uninitialize)(void *); godot_vector2 (*get_render_targetsize)(const void *); godot_transform (*get_transform_for_eye)(void *, godot_int, godot_transform *); - void (*fill_projection_for_eye)(void *, godot_real *, godot_int, godot_real, godot_real, godot_real); + void (*fill_projection_for_eye)(void *, godot_float *, godot_int, godot_float, godot_float, godot_float); void (*commit_for_eye)(void *, godot_int, godot_rid *, godot_rect2 *); void (*process)(void *); godot_int (*get_external_texture_for_eye)(void *, godot_int); @@ -69,7 +69,7 @@ typedef struct { void GDAPI godot_xr_register_interface(const godot_xr_interface_gdnative *p_interface); // helper functions to access XRServer data -godot_real GDAPI godot_xr_get_worldscale(); +godot_float GDAPI godot_xr_get_worldscale(); godot_transform GDAPI godot_xr_get_reference_frame(); // helper functions for rendering @@ -81,8 +81,8 @@ godot_int GDAPI godot_xr_add_controller(char *p_device_name, godot_int p_hand, g void GDAPI godot_xr_remove_controller(godot_int p_controller_id); void GDAPI godot_xr_set_controller_transform(godot_int p_controller_id, godot_transform *p_transform, godot_bool p_tracks_orientation, godot_bool p_tracks_position); void GDAPI godot_xr_set_controller_button(godot_int p_controller_id, godot_int p_button, godot_bool p_is_pressed); -void GDAPI godot_xr_set_controller_axis(godot_int p_controller_id, godot_int p_axis, godot_real p_value, godot_bool p_can_be_negative); -godot_real GDAPI godot_xr_get_controller_rumble(godot_int p_controller_id); +void GDAPI godot_xr_set_controller_axis(godot_int p_controller_id, godot_int p_axis, godot_float p_value, godot_bool p_can_be_negative); +godot_float GDAPI godot_xr_get_controller_rumble(godot_int p_controller_id); #ifdef __cplusplus } diff --git a/modules/gdnative/nativescript/api_generator.cpp b/modules/gdnative/nativescript/api_generator.cpp index 6f2f9bfea9..3e75478cd8 100644 --- a/modules/gdnative/nativescript/api_generator.cpp +++ b/modules/gdnative/nativescript/api_generator.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -36,6 +36,7 @@ #include "core/core_constants.h" #include "core/object/class_db.h" #include "core/os/file_access.h" +#include "core/string/string_builder.h" #include "core/templates/pair.h" // helper stuff @@ -65,14 +66,14 @@ struct MethodAPI { Map<int, Variant> default_arguments; - int argument_count; - bool has_varargs; - bool is_editor; - bool is_noscript; - bool is_const; - bool is_reverse; - bool is_virtual; - bool is_from_script; + int argument_count = 0; + bool has_varargs = false; + bool is_editor = false; + bool is_noscript = false; + bool is_const = false; + bool is_reverse = false; + bool is_virtual = false; + bool is_from_script = false; }; struct PropertyAPI { @@ -80,12 +81,14 @@ struct PropertyAPI { String getter; String setter; String type; - int index; + int index = 0; }; struct ConstantAPI { String constant_name; - int constant_value; + int constant_value = 0; + Variant builtin_constant_value; // For builtin types; + String builtin_constant_type; // For builtin types; }; struct SignalAPI { @@ -100,23 +103,35 @@ struct EnumAPI { List<Pair<int, String>> values; }; +struct OperatorAPI { // For builtin types; + String name; + int oper = Variant::OP_MAX; + String other_type; + String return_type; +}; + struct ClassAPI { String class_name; String super_class_name; - ClassDB::APIType api_type; + ClassDB::APIType api_type = ClassDB::API_NONE; - bool is_singleton; + bool is_singleton = false; String singleton_name; - bool is_instanciable; + bool is_instantiable = false; // @Unclear - bool is_reference; + bool is_reference = false; + bool has_indexing = false; // For builtin types. + String indexed_type; // For builtin types. + bool is_keyed = false; // For builtin types. List<MethodAPI> methods; + List<MethodAPI> constructors; // For builtin types. List<PropertyAPI> properties; List<ConstantAPI> constants; List<SignalAPI> signals_; List<EnumAPI> enums; + List<OperatorAPI> operators; // For builtin types. }; static String get_type_name(const PropertyInfo &info) { @@ -127,7 +142,7 @@ static String get_type_name(const PropertyInfo &info) { return info.class_name; } if (info.hint == PROPERTY_HINT_RESOURCE_TYPE) { - return info.hint_string; + return info.class_name; } if (info.type == Variant::NIL && (info.usage & PROPERTY_USAGE_NIL_IS_VARIANT)) { return "Variant"; @@ -180,13 +195,34 @@ List<ClassAPI> generate_c_api_classes() { global_constants_api.api_type = ClassDB::API_CORE; global_constants_api.is_singleton = true; global_constants_api.singleton_name = "CoreConstants"; - global_constants_api.is_instanciable = false; + global_constants_api.is_instantiable = false; const int constants_count = CoreConstants::get_global_constant_count(); + + Map<StringName, EnumAPI> enum_api_map; for (int i = 0; i < constants_count; ++i) { - ConstantAPI constant_api; - constant_api.constant_name = CoreConstants::get_global_constant_name(i); - constant_api.constant_value = CoreConstants::get_global_constant_value(i); - global_constants_api.constants.push_back(constant_api); + StringName enum_name = CoreConstants::get_global_constant_enum(i); + String name = String(CoreConstants::get_global_constant_name(i)); + int value = CoreConstants::get_global_constant_value(i); + + if (enum_name == StringName()) { + ConstantAPI constant_api; + constant_api.constant_name = name; + constant_api.constant_value = value; + global_constants_api.constants.push_back(constant_api); + } else { + EnumAPI enum_api; + if (enum_api_map.has(enum_name)) { + enum_api = enum_api_map[enum_name]; + } else { + enum_api.name = String(enum_name); + } + enum_api.values.push_back(Pair(value, name)); + + enum_api_map[enum_name] = enum_api; + } + } + for (const Map<StringName, EnumAPI>::Element *E = enum_api_map.front(); E; E = E->next()) { + global_constants_api.enums.push_back(E->get()); } global_constants_api.constants.sort_custom<ConstantAPIComparator>(); api.push_back(global_constants_api); @@ -195,6 +231,10 @@ List<ClassAPI> generate_c_api_classes() { for (List<StringName>::Element *e = classes.front(); e != nullptr; e = e->next()) { StringName class_name = e->get(); + if (!ClassDB::is_class_exposed(class_name)) { + continue; + } + ClassAPI class_api; class_api.api_type = ClassDB::get_api_type(e->get()); class_api.class_name = class_name; @@ -209,7 +249,7 @@ List<ClassAPI> generate_c_api_classes() { class_api.singleton_name = name; } } - class_api.is_instanciable = !class_api.is_singleton && ClassDB::can_instance(class_name); + class_api.is_instantiable = !class_api.is_singleton && ClassDB::can_instance(class_name); { List<StringName> inheriters; @@ -290,12 +330,14 @@ List<ClassAPI> generate_c_api_classes() { property_api.type = p->get().name.get_slice(":", 1); property_api.name = p->get().name.get_slice(":", 0); } else { - property_api.type = get_type_name(p->get()); + MethodInfo minfo; + ClassDB::get_method_info(class_name, property_api.getter, &minfo, true, false); + property_api.type = get_type_name(minfo.return_val); } property_api.index = ClassDB::get_property_index(class_name, p->get().name); - if (!property_api.setter.empty() || !property_api.getter.empty()) { + if (!property_api.setter.is_empty() || !property_api.getter.is_empty()) { class_api.properties.push_back(property_api); } } @@ -352,7 +394,7 @@ List<ClassAPI> generate_c_api_classes() { arg_type = arg_info.name.get_slice(":", 1); arg_name = arg_info.name.get_slice(":", 0); } else if (arg_info.hint == PROPERTY_HINT_RESOURCE_TYPE) { - arg_type = arg_info.hint_string; + arg_type = arg_info.class_name; } else if (arg_info.type == Variant::NIL) { arg_type = "Variant"; } else if (arg_info.type == Variant::OBJECT) { @@ -402,6 +444,192 @@ List<ClassAPI> generate_c_api_classes() { } /* + * Reads the builtin Variant API to a list + */ +List<ClassAPI> generate_c_builtin_api_types() { + List<ClassAPI> api; + + // Special class for the utility methods. + { + ClassAPI utility_api; + utility_api.class_name = "Utilities"; + utility_api.is_instantiable = false; + + List<StringName> utility_functions; + Variant::get_utility_function_list(&utility_functions); + for (const List<StringName>::Element *E = utility_functions.front(); E; E = E->next()) { + const StringName &function_name = E->get(); + + MethodAPI function_api; + function_api.method_name = function_name; + function_api.has_varargs = Variant::is_utility_function_vararg(function_name); + function_api.argument_count = function_api.has_varargs ? 0 : Variant::get_utility_function_argument_count(function_name); + function_api.is_const = Variant::get_utility_function_type(function_name) == Variant::UTILITY_FUNC_TYPE_MATH; + + for (int i = 0; i < function_api.argument_count; i++) { + function_api.argument_names.push_back(Variant::get_utility_function_argument_name(function_name, i)); + Variant::Type arg_type = Variant::get_utility_function_argument_type(function_name, i); + function_api.argument_types.push_back(arg_type == Variant::NIL ? "Variant" : Variant::get_type_name(arg_type)); + } + + if (Variant::has_utility_function_return_value(function_name)) { + Variant::Type ret_type = Variant::get_utility_function_return_type(function_name); + function_api.return_type = ret_type == Variant::NIL ? "Variant" : Variant::get_type_name(ret_type); + } else { + function_api.return_type = "void"; + } + + utility_api.methods.push_back(function_api); + } + + api.push_back(utility_api); + } + + for (int t = 0; t < Variant::VARIANT_MAX; t++) { + Variant::Type type = (Variant::Type)t; + + ClassAPI class_api; + class_api.class_name = Variant::get_type_name(type); + class_api.is_instantiable = true; + class_api.has_indexing = Variant::has_indexing(type); + class_api.indexed_type = Variant::get_type_name(Variant::get_indexed_element_type(type)); + class_api.is_keyed = Variant::is_keyed(type); + // Types that are passed by reference. + switch (type) { + case Variant::OBJECT: + case Variant::DICTIONARY: + case Variant::ARRAY: + case Variant::PACKED_BYTE_ARRAY: + case Variant::PACKED_INT32_ARRAY: + case Variant::PACKED_INT64_ARRAY: + case Variant::PACKED_FLOAT32_ARRAY: + case Variant::PACKED_FLOAT64_ARRAY: + case Variant::PACKED_STRING_ARRAY: + case Variant::PACKED_VECTOR2_ARRAY: + case Variant::PACKED_VECTOR3_ARRAY: + case Variant::PACKED_COLOR_ARRAY: + class_api.is_reference = true; + break; + default: + class_api.is_reference = false; + break; + } + + // Methods. + + List<StringName> methods; + Variant::get_builtin_method_list(type, &methods); + for (const List<StringName>::Element *E = methods.front(); E; E = E->next()) { + const StringName &method_name = E->get(); + + MethodAPI method_api; + + method_api.method_name = method_name; + method_api.argument_count = Variant::get_builtin_method_argument_count(type, method_name); + method_api.has_varargs = Variant::is_builtin_method_vararg(type, method_name); + method_api.is_const = Variant::is_builtin_method_const(type, method_name); + + for (int i = 0; i < method_api.argument_count; i++) { + method_api.argument_names.push_back(Variant::get_builtin_method_argument_name(type, method_name, i)); + Variant::Type arg_type = Variant::get_builtin_method_argument_type(type, method_name, i); + method_api.argument_types.push_back(arg_type == Variant::NIL ? "Variant" : Variant::get_type_name(arg_type)); + } + + Vector<Variant> default_arguments = Variant::get_builtin_method_default_arguments(type, method_name); + + int default_start = method_api.argument_names.size() - default_arguments.size(); + + for (int i = 0; i < default_arguments.size(); i++) { + method_api.default_arguments[default_start + i] = default_arguments[i]; + } + + if (Variant::has_builtin_method_return_value(type, method_name)) { + Variant::Type ret_type = Variant::get_builtin_method_return_type(type, method_name); + method_api.return_type = ret_type == Variant::NIL ? "Variant" : Variant::get_type_name(ret_type); + } else { + method_api.return_type = "void"; + } + + class_api.methods.push_back(method_api); + } + + // Constructors. + + for (int c = 0; c < Variant::get_constructor_count(type); c++) { + MethodAPI constructor_api; + + constructor_api.method_name = Variant::get_type_name(type); + constructor_api.argument_count = Variant::get_constructor_argument_count(type, c); + constructor_api.return_type = Variant::get_type_name(type); + + for (int i = 0; i < constructor_api.argument_count; i++) { + constructor_api.argument_names.push_back(Variant::get_constructor_argument_name(type, c, i)); + Variant::Type arg_type = Variant::get_constructor_argument_type(type, c, i); + constructor_api.argument_types.push_back(arg_type == Variant::NIL ? "Variant" : Variant::get_type_name(arg_type)); + } + + class_api.constructors.push_back(constructor_api); + } + + // Constants. + + List<StringName> constants; + Variant::get_constants_for_type(type, &constants); + for (const List<StringName>::Element *E = constants.front(); E; E = E->next()) { + const StringName &constant_name = E->get(); + ConstantAPI constant_api; + + constant_api.constant_name = constant_name; + constant_api.builtin_constant_value = Variant::get_constant_value(type, constant_name); + constant_api.builtin_constant_type = Variant::get_type_name(constant_api.builtin_constant_value.get_type()); + + class_api.constants.push_back(constant_api); + } + + // Members. + + List<StringName> members; + Variant::get_member_list(type, &members); + for (const List<StringName>::Element *E = members.front(); E; E = E->next()) { + const StringName &member_name = E->get(); + + PropertyAPI member_api; + member_api.name = member_name; + Variant::Type member_type = Variant::get_member_type(type, member_name); + member_api.type = member_type == Variant::NIL ? "Variant" : Variant::get_type_name(member_type); + + class_api.properties.push_back(member_api); + } + + // Operators. + + for (int op = 0; op < Variant::OP_MAX; op++) { + Variant::Operator oper = (Variant::Operator)op; + + for (int ot = 0; ot < Variant::VARIANT_MAX; ot++) { + Variant::Type other_type = (Variant::Type)ot; + + if (!Variant::get_validated_operator_evaluator(oper, type, other_type)) { + continue; + } + + OperatorAPI oper_api; + oper_api.name = Variant::get_operator_name(oper); + oper_api.oper = oper; + oper_api.other_type = Variant::get_type_name(other_type); + oper_api.return_type = Variant::get_type_name(Variant::get_operator_return_type(oper, type, other_type)); + + class_api.operators.push_back(oper_api); + } + } + + api.push_back(class_api); + } + + return api; +} + +/* * Generates the JSON source from the API in p_api */ static List<String> generate_c_api_json(const List<ClassAPI> &p_api) { @@ -421,9 +649,8 @@ static List<String> generate_c_api_json(const List<ClassAPI> &p_api) { source.push_back(String("\t\t\"api_type\": \"") + (api.api_type == ClassDB::API_CORE ? "core" : (api.api_type == ClassDB::API_EDITOR ? "tools" : "none")) + "\",\n"); source.push_back(String("\t\t\"singleton\": ") + (api.is_singleton ? "true" : "false") + ",\n"); source.push_back("\t\t\"singleton_name\": \"" + api.singleton_name + "\",\n"); - source.push_back(String("\t\t\"instanciable\": ") + (api.is_instanciable ? "true" : "false") + ",\n"); + source.push_back(String("\t\t\"instantiable\": ") + (api.is_instantiable ? "true" : "false") + ",\n"); source.push_back(String("\t\t\"is_reference\": ") + (api.is_reference ? "true" : "false") + ",\n"); - // @Unclear source.push_back("\t\t\"constants\": {\n"); for (List<ConstantAPI>::Element *e = api.constants.front(); e; e = e->next()) { @@ -508,6 +735,165 @@ static List<String> generate_c_api_json(const List<ClassAPI> &p_api) { return source; } +static int indent_level = 0; + +static void append_indented(StringBuilder &p_source, const String &p_text) { + for (int i = 0; i < indent_level; i++) { + p_source.append("\t"); + } + p_source.append(p_text); + p_source.append("\n"); +} + +static void append_indented(StringBuilder &p_source, const char *p_text) { + for (int i = 0; i < indent_level; i++) { + p_source.append("\t"); + } + p_source.append(p_text); + p_source.append("\n"); +} + +static void write_builtin_method(StringBuilder &p_source, const MethodAPI &p_method) { + append_indented(p_source, vformat(R"("name": "%s",)", p_method.method_name)); + append_indented(p_source, vformat(R"("return_type": "%s",)", p_method.return_type)); + append_indented(p_source, vformat(R"("is_const": %s,)", p_method.is_const ? "true" : "false")); + append_indented(p_source, vformat(R"("has_varargs": %s,)", p_method.has_varargs ? "true" : "false")); + + append_indented(p_source, R"("arguments": [)"); + indent_level++; + for (int i = 0; i < p_method.argument_count; i++) { + append_indented(p_source, "{"); + indent_level++; + + append_indented(p_source, vformat(R"("name": "%s",)", p_method.argument_names[i])); + append_indented(p_source, vformat(R"("type": "%s",)", p_method.argument_types[i])); + append_indented(p_source, vformat(R"("has_default_value": %s,)", p_method.default_arguments.has(i) ? "true" : "false")); + append_indented(p_source, vformat(R"("default_value": "%s")", p_method.default_arguments.has(i) ? p_method.default_arguments[i].operator String() : "")); + + indent_level--; + append_indented(p_source, i < p_method.argument_count - 1 ? "}," : "}"); + } + indent_level--; + append_indented(p_source, "]"); +} + +static List<String> generate_c_builtin_api_json(const List<ClassAPI> &p_api) { + StringBuilder source; + + source.append("[\n"); + + indent_level = 1; + + for (const List<ClassAPI>::Element *C = p_api.front(); C; C = C->next()) { + const ClassAPI &class_api = C->get(); + append_indented(source, "{"); + indent_level++; + + append_indented(source, vformat(R"("name": "%s",)", class_api.class_name)); + append_indented(source, vformat(R"("is_instantiable": %s,)", class_api.is_instantiable ? "true" : "false")); + append_indented(source, vformat(R"("is_reference": %s,)", class_api.is_reference ? "true" : "false")); + append_indented(source, vformat(R"("has_indexing": %s,)", class_api.has_indexing ? "true" : "false")); + append_indented(source, vformat(R"("indexed_type": "%s",)", class_api.has_indexing && class_api.indexed_type == "Nil" ? "Variant" : class_api.indexed_type)); + append_indented(source, vformat(R"("is_keyed": %s,)", class_api.is_keyed ? "true" : "false")); + + // Constructors. + append_indented(source, R"("constructors": [)"); + indent_level++; + for (const List<MethodAPI>::Element *E = class_api.constructors.front(); E; E = E->next()) { + const MethodAPI &constructor = E->get(); + append_indented(source, "{"); + indent_level++; + + write_builtin_method(source, constructor); + + indent_level--; + append_indented(source, E->next() ? "}," : "}"); + } + indent_level--; + append_indented(source, "],"); + + // Constants. + append_indented(source, R"("constants": [)"); + indent_level++; + for (const List<ConstantAPI>::Element *E = class_api.constants.front(); E; E = E->next()) { + const ConstantAPI &constant = E->get(); + append_indented(source, "{"); + indent_level++; + + append_indented(source, vformat(R"("name": "%s",)", constant.constant_name)); + append_indented(source, vformat(R"("type": "%s",)", constant.builtin_constant_type)); + append_indented(source, vformat(R"("value": "%s")", constant.builtin_constant_value.operator String())); + + indent_level--; + append_indented(source, E->next() ? "}," : "}"); + } + indent_level--; + append_indented(source, "],"); + + // Methods. + append_indented(source, R"("methods": [)"); + indent_level++; + for (const List<MethodAPI>::Element *E = class_api.methods.front(); E; E = E->next()) { + const MethodAPI &method = E->get(); + append_indented(source, "{"); + indent_level++; + + write_builtin_method(source, method); + + indent_level--; + append_indented(source, E->next() ? "}," : "}"); + } + indent_level--; + append_indented(source, "],"); + + // Members. + append_indented(source, R"("members": [)"); + indent_level++; + for (const List<PropertyAPI>::Element *E = class_api.properties.front(); E; E = E->next()) { + const PropertyAPI &member = E->get(); + append_indented(source, "{"); + indent_level++; + + append_indented(source, vformat(R"("name": "%s",)", member.name)); + append_indented(source, vformat(R"("type": "%s")", member.type)); + + indent_level--; + append_indented(source, E->next() ? "}," : "}"); + } + indent_level--; + append_indented(source, "],"); + + // Operators. + append_indented(source, R"("operators": [)"); + indent_level++; + for (const List<OperatorAPI>::Element *E = class_api.operators.front(); E; E = E->next()) { + const OperatorAPI &oper = E->get(); + append_indented(source, "{"); + indent_level++; + + append_indented(source, vformat(R"("name": "%s",)", oper.name)); + append_indented(source, vformat(R"("operator": %d,)", oper.oper)); + append_indented(source, vformat(R"("other_type": "%s",)", oper.other_type)); + append_indented(source, vformat(R"("return_type": "%s")", oper.return_type)); + + indent_level--; + append_indented(source, E->next() ? "}," : "}"); + } + indent_level--; + append_indented(source, "]"); + + indent_level--; + append_indented(source, C->next() ? "}," : "}"); + } + + indent_level--; + source.append("]\n"); + + List<String> result; + result.push_back(source.as_string()); + return result; +} + #endif /* @@ -526,3 +912,19 @@ Error generate_c_api(const String &p_path) { return save_file(p_path, json_source); #endif } +/* + * Saves the builtin Godot API to a JSON file located at + * p_path + */ +Error generate_c_builtin_api(const String &p_path) { +#ifndef TOOLS_ENABLED + return ERR_BUG; +#else + + List<ClassAPI> api = generate_c_builtin_api_types(); + + List<String> json_source = generate_c_builtin_api_json(api); + + return save_file(p_path, json_source); +#endif +} diff --git a/modules/gdnative/nativescript/api_generator.h b/modules/gdnative/nativescript/api_generator.h index 8555af5215..611abb2a2d 100644 --- a/modules/gdnative/nativescript/api_generator.h +++ b/modules/gdnative/nativescript/api_generator.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -35,5 +35,6 @@ #include "core/typedefs.h" Error generate_c_api(const String &p_path); +Error generate_c_builtin_api(const String &p_path); #endif // API_GENERATOR_H diff --git a/modules/gdnative/nativescript/godot_nativescript.cpp b/modules/gdnative/nativescript/godot_nativescript.cpp index 411acbe1ad..b2abf8b8ae 100644 --- a/modules/gdnative/nativescript/godot_nativescript.cpp +++ b/modules/gdnative/nativescript/godot_nativescript.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gdnative/nativescript/nativescript.cpp b/modules/gdnative/nativescript/nativescript.cpp index 0939cfd06a..1bdbb0b03b 100644 --- a/modules/gdnative/nativescript/nativescript.cpp +++ b/modules/gdnative/nativescript/nativescript.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -717,7 +717,7 @@ String NativeScript::get_property_documentation(const StringName &p_path) const } Variant NativeScript::_new(const Variant **p_args, int p_argcount, Callable::CallError &r_error) { - if (lib_path.empty() || class_name.empty() || library.is_null()) { + if (lib_path.is_empty() || class_name.is_empty() || library.is_null()) { r_error.error = Callable::CallError::CALL_ERROR_INSTANCE_IS_NULL; return Variant(); } @@ -1196,13 +1196,6 @@ void NativeScriptLanguage::_unload_stuff(bool p_reload) { NativeScriptLanguage::NativeScriptLanguage() { NativeScriptLanguage::singleton = this; -#ifndef NO_THREADS - has_objects_to_register = false; -#endif - -#ifdef DEBUG_ENABLED - profiling = false; -#endif _init_call_type = "nativescript_init"; _init_call_name = "nativescript_init"; @@ -1257,6 +1250,15 @@ void NativeScriptLanguage::init() { } exit(0); } + + E = args.find("--gdnative-generate-json-builtin-api"); + + if (E && E->next()) { + if (generate_c_builtin_api(E->next()->get()) != OK) { + ERR_PRINT("Failed to generate C builtin API\n"); + } + exit(0); + } #endif #ifdef TOOLS_ENABLED @@ -1668,7 +1670,7 @@ void NativeScriptLanguage::defer_init_library(Ref<GDNativeLibrary> lib, NativeSc MutexLock lock(mutex); libs_to_init.insert(lib); scripts_to_register.insert(script); - has_objects_to_register = true; + has_objects_to_register.set(); } #endif @@ -1724,6 +1726,12 @@ void NativeScriptLanguage::unregister_script(NativeScript *script) { S->get().erase(script); if (S->get().size() == 0) { library_script_users.erase(S); + + Map<String, Ref<GDNative>>::Element *G = library_gdnatives.find(script->lib_path); + if (G && G->get()->get_library()->is_reloadable()) { + G->get()->terminate(); + library_gdnatives.erase(G); + } } } #ifndef NO_THREADS @@ -1751,7 +1759,7 @@ void NativeScriptLanguage::call_libraries_cb(const StringName &name) { void NativeScriptLanguage::frame() { #ifndef NO_THREADS - if (has_objects_to_register) { + if (has_objects_to_register.is_set()) { MutexLock lock(mutex); for (Set<Ref<GDNativeLibrary>>::Element *L = libs_to_init.front(); L; L = L->next()) { init_library(L->get()); @@ -1761,7 +1769,7 @@ void NativeScriptLanguage::frame() { register_script(S->get()); } scripts_to_register.clear(); - has_objects_to_register = false; + has_objects_to_register.clear(); } #endif @@ -1800,7 +1808,7 @@ bool NativeScriptLanguage::handles_global_class_type(const String &p_type) const } String NativeScriptLanguage::get_global_class_name(const String &p_path, String *r_base_type, String *r_icon_path) const { - if (!p_path.empty()) { + if (!p_path.is_empty()) { Ref<NativeScript> script = ResourceLoader::load(p_path, "NativeScript"); if (script.is_valid()) { if (r_base_type) { @@ -1932,7 +1940,7 @@ void NativeReloadNode::_notification(int p_what) { #endif } -RES ResourceFormatLoaderNativeScript::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, bool p_no_cache) { +RES ResourceFormatLoaderNativeScript::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, CacheMode p_no_cache) { return ResourceFormatLoaderText::singleton->load(p_path, p_original_path, r_error); } diff --git a/modules/gdnative/nativescript/nativescript.h b/modules/gdnative/nativescript/nativescript.h index e91d9b7bfb..d6ba2bbec1 100644 --- a/modules/gdnative/nativescript/nativescript.h +++ b/modules/gdnative/nativescript/nativescript.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -40,6 +40,7 @@ #include "core/os/thread_safe.h" #include "core/templates/oa_hash_map.h" #include "core/templates/ordered_hash_map.h" +#include "core/templates/safe_refcount.h" #include "core/templates/self_list.h" #include "scene/main/node.h" @@ -51,8 +52,8 @@ struct NativeScriptDesc { struct Method { godot_nativescript_instance_method method; MethodInfo info; - int rpc_mode; - uint16_t rpc_method_id; + int rpc_mode = 0; + uint16_t rpc_method_id = 0; String documentation; }; @@ -61,7 +62,7 @@ struct NativeScriptDesc { godot_nativescript_property_get_func getter; PropertyInfo info; Variant default_value; - int rset_mode; + int rset_mode = 0; uint16_t rset_property_id; String documentation; }; @@ -78,7 +79,7 @@ struct NativeScriptDesc { Map<StringName, Signal> signals_; // QtCreator doesn't like the name signals StringName base; StringName base_native_type; - NativeScriptDesc *base_data; + NativeScriptDesc *base_data = nullptr; godot_nativescript_instance_create_func create_func; godot_nativescript_instance_destroy_func destroy_func; @@ -86,7 +87,7 @@ struct NativeScriptDesc { const void *type_tag = nullptr; - bool is_tool; + bool is_tool = false; inline NativeScriptDesc() { zeromem(&create_func, sizeof(godot_nativescript_instance_create_func)); @@ -254,7 +255,7 @@ class NativeScriptLanguage : public ScriptLanguage { private: static NativeScriptLanguage *singleton; - int lang_idx; + int lang_idx = 0; void _unload_stuff(bool p_reload = false); @@ -262,7 +263,7 @@ private: #ifndef NO_THREADS Set<Ref<GDNativeLibrary>> libs_to_init; Set<NativeScript *> scripts_to_register; - volatile bool has_objects_to_register; // so that we don't lock mutex every frame - it's rarely needed + SafeFlag has_objects_to_register; // so that we don't lock mutex every frame - it's rarely needed void defer_init_library(Ref<GDNativeLibrary> lib, NativeScript *script); #endif @@ -279,19 +280,19 @@ private: struct ProfileData { StringName signature; - uint64_t call_count; - uint64_t self_time; - uint64_t total_time; - uint64_t frame_call_count; - uint64_t frame_self_time; - uint64_t frame_total_time; - uint64_t last_frame_call_count; - uint64_t last_frame_self_time; - uint64_t last_frame_total_time; + uint64_t call_count = 0; + uint64_t self_time = 0; + uint64_t total_time = 0; + uint64_t frame_call_count = 0; + uint64_t frame_self_time = 0; + uint64_t frame_total_time = 0; + uint64_t last_frame_call_count = 0; + uint64_t last_frame_self_time = 0; + uint64_t last_frame_total_time = 0; }; Map<StringName, ProfileData> profile_data; - bool profiling; + bool profiling = false; public: // These two maps must only be touched on the main thread @@ -402,7 +403,7 @@ public: class ResourceFormatLoaderNativeScript : public ResourceFormatLoader { public: - virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr, bool p_no_cache = false); + virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr, CacheMode p_cache_mode = CACHE_MODE_REUSE); virtual void get_recognized_extensions(List<String> *p_extensions) const; virtual bool handles_type(const String &p_type) const; virtual String get_resource_type(const String &p_path) const; diff --git a/modules/gdnative/nativescript/register_types.cpp b/modules/gdnative/nativescript/register_types.cpp index ac8c7ab2fd..0353ab2092 100644 --- a/modules/gdnative/nativescript/register_types.cpp +++ b/modules/gdnative/nativescript/register_types.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gdnative/nativescript/register_types.h b/modules/gdnative/nativescript/register_types.h index 088bf38dd5..d12ac9eda3 100644 --- a/modules/gdnative/nativescript/register_types.h +++ b/modules/gdnative/nativescript/register_types.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gdnative/net/multiplayer_peer_gdnative.cpp b/modules/gdnative/net/multiplayer_peer_gdnative.cpp index 997eec6425..8b5fc8db5c 100644 --- a/modules/gdnative/net/multiplayer_peer_gdnative.cpp +++ b/modules/gdnative/net/multiplayer_peer_gdnative.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gdnative/net/multiplayer_peer_gdnative.h b/modules/gdnative/net/multiplayer_peer_gdnative.h index 64d764029f..593b2534dd 100644 --- a/modules/gdnative/net/multiplayer_peer_gdnative.h +++ b/modules/gdnative/net/multiplayer_peer_gdnative.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gdnative/net/packet_peer_gdnative.cpp b/modules/gdnative/net/packet_peer_gdnative.cpp index 6bb21cb48d..3bcdfed8ff 100644 --- a/modules/gdnative/net/packet_peer_gdnative.cpp +++ b/modules/gdnative/net/packet_peer_gdnative.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gdnative/net/packet_peer_gdnative.h b/modules/gdnative/net/packet_peer_gdnative.h index 00de8f7f4c..29013f9367 100644 --- a/modules/gdnative/net/packet_peer_gdnative.h +++ b/modules/gdnative/net/packet_peer_gdnative.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gdnative/net/register_types.cpp b/modules/gdnative/net/register_types.cpp index 4e48a43210..645c43b7e3 100644 --- a/modules/gdnative/net/register_types.cpp +++ b/modules/gdnative/net/register_types.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gdnative/net/register_types.h b/modules/gdnative/net/register_types.h index 70b266f9b9..c99c6f6fbf 100644 --- a/modules/gdnative/net/register_types.h +++ b/modules/gdnative/net/register_types.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gdnative/net/stream_peer_gdnative.cpp b/modules/gdnative/net/stream_peer_gdnative.cpp index 9dcb184115..72ab72323d 100644 --- a/modules/gdnative/net/stream_peer_gdnative.cpp +++ b/modules/gdnative/net/stream_peer_gdnative.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gdnative/net/stream_peer_gdnative.h b/modules/gdnative/net/stream_peer_gdnative.h index 302fb48012..dd5abceb83 100644 --- a/modules/gdnative/net/stream_peer_gdnative.h +++ b/modules/gdnative/net/stream_peer_gdnative.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gdnative/net/webrtc_gdnative.cpp b/modules/gdnative/net/webrtc_gdnative.cpp index d8c3ddc5f8..76ccbad009 100644 --- a/modules/gdnative/net/webrtc_gdnative.cpp +++ b/modules/gdnative/net/webrtc_gdnative.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gdnative/pluginscript/pluginscript_instance.cpp b/modules/gdnative/pluginscript/pluginscript_instance.cpp index 0942fb40a8..432aa80325 100644 --- a/modules/gdnative/pluginscript/pluginscript_instance.cpp +++ b/modules/gdnative/pluginscript/pluginscript_instance.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gdnative/pluginscript/pluginscript_instance.h b/modules/gdnative/pluginscript/pluginscript_instance.h index 76ff9f7097..536eb550e0 100644 --- a/modules/gdnative/pluginscript/pluginscript_instance.h +++ b/modules/gdnative/pluginscript/pluginscript_instance.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -44,10 +44,10 @@ class PluginScriptInstance : public ScriptInstance { private: Ref<PluginScript> _script; - Object *_owner; + Object *_owner = nullptr; Variant _owner_variant; - godot_pluginscript_instance_data *_data; - const godot_pluginscript_instance_desc *_desc; + godot_pluginscript_instance_data *_data = nullptr; + const godot_pluginscript_instance_desc *_desc = nullptr; public: _FORCE_INLINE_ Object *get_owner() { return _owner; } diff --git a/modules/gdnative/pluginscript/pluginscript_language.cpp b/modules/gdnative/pluginscript/pluginscript_language.cpp index df685e716f..3ed1dcaca9 100644 --- a/modules/gdnative/pluginscript/pluginscript_language.cpp +++ b/modules/gdnative/pluginscript/pluginscript_language.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -407,7 +407,7 @@ bool PluginScriptLanguage::handles_global_class_type(const String &p_type) const } String PluginScriptLanguage::get_global_class_name(const String &p_path, String *r_base_type, String *r_icon_path) const { - if (!p_path.empty()) { + if (!p_path.is_empty()) { Ref<PluginScript> script = ResourceLoader::load(p_path, "PluginScript"); if (script.is_valid()) { if (r_base_type) { diff --git a/modules/gdnative/pluginscript/pluginscript_language.h b/modules/gdnative/pluginscript/pluginscript_language.h index 7548eba4a0..226b039265 100644 --- a/modules/gdnative/pluginscript/pluginscript_language.h +++ b/modules/gdnative/pluginscript/pluginscript_language.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gdnative/pluginscript/pluginscript_loader.cpp b/modules/gdnative/pluginscript/pluginscript_loader.cpp index 4feee4f4a5..f2165cd225 100644 --- a/modules/gdnative/pluginscript/pluginscript_loader.cpp +++ b/modules/gdnative/pluginscript/pluginscript_loader.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -39,7 +39,7 @@ ResourceFormatLoaderPluginScript::ResourceFormatLoaderPluginScript(PluginScriptL _language = language; } -RES ResourceFormatLoaderPluginScript::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, bool p_no_cache) { +RES ResourceFormatLoaderPluginScript::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, CacheMode p_cache_mode) { if (r_error) { *r_error = ERR_FILE_CANT_OPEN; } diff --git a/modules/gdnative/pluginscript/pluginscript_loader.h b/modules/gdnative/pluginscript/pluginscript_loader.h index 7d80f4c733..e5d665c186 100644 --- a/modules/gdnative/pluginscript/pluginscript_loader.h +++ b/modules/gdnative/pluginscript/pluginscript_loader.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -43,7 +43,7 @@ class ResourceFormatLoaderPluginScript : public ResourceFormatLoader { public: ResourceFormatLoaderPluginScript(PluginScriptLanguage *language); - virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr, bool p_no_cache = false); + virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr, CacheMode p_cache_mode = CACHE_MODE_REUSE); virtual void get_recognized_extensions(List<String> *p_extensions) const; virtual bool handles_type(const String &p_type) const; virtual String get_resource_type(const String &p_path) const; diff --git a/modules/gdnative/pluginscript/pluginscript_script.cpp b/modules/gdnative/pluginscript/pluginscript_script.cpp index d69ab2fcb7..31e6a81975 100644 --- a/modules/gdnative/pluginscript/pluginscript_script.cpp +++ b/modules/gdnative/pluginscript/pluginscript_script.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gdnative/pluginscript/pluginscript_script.h b/modules/gdnative/pluginscript/pluginscript_script.h index 12d93cc407..1c86f2056d 100644 --- a/modules/gdnative/pluginscript/pluginscript_script.h +++ b/modules/gdnative/pluginscript/pluginscript_script.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gdnative/pluginscript/register_types.cpp b/modules/gdnative/pluginscript/register_types.cpp index b354c23a9e..b94538b2f7 100644 --- a/modules/gdnative/pluginscript/register_types.cpp +++ b/modules/gdnative/pluginscript/register_types.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gdnative/pluginscript/register_types.h b/modules/gdnative/pluginscript/register_types.h index c6a64b4f40..2118f668e9 100644 --- a/modules/gdnative/pluginscript/register_types.h +++ b/modules/gdnative/pluginscript/register_types.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gdnative/register_types.cpp b/modules/gdnative/register_types.cpp index b88bf58256..31f4fecb19 100644 --- a/modules/gdnative/register_types.cpp +++ b/modules/gdnative/register_types.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gdnative/register_types.h b/modules/gdnative/register_types.h index b5c182f8b7..662c638442 100644 --- a/modules/gdnative/register_types.h +++ b/modules/gdnative/register_types.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gdnative/tests/test_string.h b/modules/gdnative/tests/test_string.h deleted file mode 100644 index 2b1aa5bf28..0000000000 --- a/modules/gdnative/tests/test_string.h +++ /dev/null @@ -1,1979 +0,0 @@ -/*************************************************************************/ -/* test_string.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef TEST_GDNATIVE_STRING_H -#define TEST_GDNATIVE_STRING_H - -namespace TestGDNativeString { - -#include "gdnative/string.h" - -#include "tests/test_macros.h" - -int u32scmp(const char32_t *l, const char32_t *r) { - for (; *l == *r && *l && *r; l++, r++) - ; - return *l - *r; -} - -TEST_CASE("[GDNative String] Construct from Latin-1 char string") { - godot_string s; - - godot_string_new_with_latin1_chars(&s, "Hello"); - CHECK(u32scmp(godot_string_get_data(&s), U"Hello") == 0); - godot_string_destroy(&s); - - godot_string_new_with_latin1_chars_and_len(&s, "Hello", 3); - CHECK(u32scmp(godot_string_get_data(&s), U"Hel") == 0); - godot_string_destroy(&s); -} - -TEST_CASE("[GDNative String] Construct from wchar_t string") { - godot_string s; - - godot_string_new_with_wide_chars(&s, L"Give me"); - CHECK(u32scmp(godot_string_get_data(&s), U"Give me") == 0); - godot_string_destroy(&s); - - godot_string_new_with_wide_chars_and_len(&s, L"Give me", 3); - CHECK(u32scmp(godot_string_get_data(&s), U"Giv") == 0); - godot_string_destroy(&s); -} - -TEST_CASE("[GDNative String] Construct from UTF-8 char string") { - static const char32_t u32str[] = { 0x0045, 0x0020, 0x304A, 0x360F, 0x3088, 0x3046, 0x1F3A4, 0 }; - static const char32_t u32str_short[] = { 0x0045, 0x0020, 0x304A, 0 }; - static const uint8_t u8str[] = { 0x45, 0x20, 0xE3, 0x81, 0x8A, 0xE3, 0x98, 0x8F, 0xE3, 0x82, 0x88, 0xE3, 0x81, 0x86, 0xF0, 0x9F, 0x8E, 0xA4, 0 }; - - godot_string s; - - godot_string_new_with_utf8_chars(&s, (const char *)u8str); - CHECK(u32scmp(godot_string_get_data(&s), u32str) == 0); - godot_string_destroy(&s); - - godot_string_new_with_utf8_chars_and_len(&s, (const char *)u8str, 5); - CHECK(u32scmp(godot_string_get_data(&s), u32str_short) == 0); - godot_string_destroy(&s); - - godot_string_new_with_utf32_chars(&s, u32str); - godot_char_string cs = godot_string_utf8(&s); - godot_string_parse_utf8(&s, godot_char_string_get_data(&cs)); - CHECK(u32scmp(godot_string_get_data(&s), u32str) == 0); - godot_string_destroy(&s); - godot_char_string_destroy(&cs); - - godot_string_new_with_utf32_chars(&s, u32str); - cs = godot_string_utf8(&s); - godot_string_parse_utf8_with_len(&s, godot_char_string_get_data(&cs), godot_char_string_length(&cs)); - CHECK(u32scmp(godot_string_get_data(&s), u32str) == 0); - godot_string_destroy(&s); - godot_char_string_destroy(&cs); -} - -TEST_CASE("[GDNative String] Construct from UTF-8 string with BOM") { - static const char32_t u32str[] = { 0x0045, 0x0020, 0x304A, 0x360F, 0x3088, 0x3046, 0x1F3A4, 0 }; - static const char32_t u32str_short[] = { 0x0045, 0x0020, 0x304A, 0 }; - static const uint8_t u8str[] = { 0xEF, 0xBB, 0xBF, 0x45, 0x20, 0xE3, 0x81, 0x8A, 0xE3, 0x98, 0x8F, 0xE3, 0x82, 0x88, 0xE3, 0x81, 0x86, 0xF0, 0x9F, 0x8E, 0xA4, 0 }; - - godot_string s; - - godot_string_new_with_utf8_chars(&s, (const char *)u8str); - CHECK(u32scmp(godot_string_get_data(&s), u32str) == 0); - godot_string_destroy(&s); - - godot_string_new_with_utf8_chars_and_len(&s, (const char *)u8str, 8); - CHECK(u32scmp(godot_string_get_data(&s), u32str_short) == 0); - godot_string_destroy(&s); -} - -TEST_CASE("[GDNative String] Construct from UTF-16 string") { - static const char32_t u32str[] = { 0x0045, 0x0020, 0x1F3A4, 0x360F, 0x3088, 0x3046, 0x1F3A4, 0 }; - static const char32_t u32str_short[] = { 0x0045, 0x0020, 0x1F3A4, 0 }; - static const char16_t u16str[] = { 0x0045, 0x0020, 0xD83C, 0xDFA4, 0x360F, 0x3088, 0x3046, 0xD83C, 0xDFA4, 0 }; - - godot_string s; - - godot_string_new_with_utf16_chars(&s, u16str); - CHECK(u32scmp(godot_string_get_data(&s), u32str) == 0); - godot_string_destroy(&s); - - godot_string_new_with_utf16_chars_and_len(&s, u16str, 4); - CHECK(u32scmp(godot_string_get_data(&s), u32str_short) == 0); - godot_string_destroy(&s); - - godot_string_new_with_utf32_chars(&s, u32str); - godot_char16_string cs = godot_string_utf16(&s); - godot_string_parse_utf16(&s, godot_char16_string_get_data(&cs)); - CHECK(u32scmp(godot_string_get_data(&s), u32str) == 0); - godot_string_destroy(&s); - godot_char16_string_destroy(&cs); - - godot_string_new_with_utf32_chars(&s, u32str); - cs = godot_string_utf16(&s); - godot_string_parse_utf16_with_len(&s, godot_char16_string_get_data(&cs), godot_char16_string_length(&cs)); - CHECK(u32scmp(godot_string_get_data(&s), u32str) == 0); - godot_string_destroy(&s); - godot_char16_string_destroy(&cs); -} - -TEST_CASE("[GDNative String] Construct from UTF-16 string with BOM ") { - static const char32_t u32str[] = { 0x0045, 0x0020, 0x1F3A4, 0x360F, 0x3088, 0x3046, 0x1F3A4, 0 }; - static const char32_t u32str_short[] = { 0x0045, 0x0020, 0x1F3A4, 0 }; - static const char16_t u16str[] = { 0xFEFF, 0x0045, 0x0020, 0xD83C, 0xDFA4, 0x360F, 0x3088, 0x3046, 0xD83C, 0xDFA4, 0 }; - static const char16_t u16str_swap[] = { 0xFFFE, 0x4500, 0x2000, 0x3CD8, 0xA4DF, 0x0F36, 0x8830, 0x4630, 0x3CD8, 0xA4DF, 0 }; - - godot_string s; - - godot_string_new_with_utf16_chars(&s, u16str); - CHECK(u32scmp(godot_string_get_data(&s), u32str) == 0); - godot_string_destroy(&s); - - godot_string_new_with_utf16_chars(&s, u16str_swap); - CHECK(u32scmp(godot_string_get_data(&s), u32str) == 0); - godot_string_destroy(&s); - - godot_string_new_with_utf16_chars_and_len(&s, u16str, 5); - CHECK(u32scmp(godot_string_get_data(&s), u32str_short) == 0); - godot_string_destroy(&s); - - godot_string_new_with_utf16_chars_and_len(&s, u16str_swap, 5); - CHECK(u32scmp(godot_string_get_data(&s), u32str_short) == 0); - godot_string_destroy(&s); -} - -TEST_CASE("[GDNative String] Construct string copy") { - godot_string s, t; - - godot_string_new_with_latin1_chars(&s, "Hello"); - godot_string_new_copy(&t, &s); - CHECK(u32scmp(godot_string_get_data(&t), U"Hello") == 0); - godot_string_destroy(&t); - godot_string_destroy(&s); -} - -TEST_CASE("[GDNative String] Construct empty string") { - godot_string s; - - godot_string_new(&s); - CHECK(u32scmp(godot_string_get_data(&s), U"") == 0); - godot_string_destroy(&s); -} - -TEST_CASE("[GDNative String] ASCII/Latin-1") { - godot_string s; - godot_string_new_with_utf32_chars(&s, U"Primero Leche"); - - godot_char_string cs = godot_string_ascii(&s); - CHECK(strcmp(godot_char_string_get_data(&cs), "Primero Leche") == 0); - godot_char_string_destroy(&cs); - - cs = godot_string_latin1(&s); - CHECK(strcmp(godot_char_string_get_data(&cs), "Primero Leche") == 0); - godot_char_string_destroy(&cs); - - godot_string_destroy(&s); -} - -TEST_CASE("[GDNative String] Comparisons (equal)") { - godot_string s, t; - - godot_string_new_with_latin1_chars(&s, "Test Compare"); - godot_string_new_with_latin1_chars(&t, "Test Compare"); - CHECK(godot_string_operator_equal(&s, &t)); - godot_string_destroy(&s); - godot_string_destroy(&t); -} - -TEST_CASE("[GDNative String] Comparisons (operator <)") { - godot_string s, t; - - godot_string_new_with_latin1_chars(&s, "Bees"); - - godot_string_new_with_latin1_chars(&t, "Elephant"); - CHECK(godot_string_operator_less(&s, &t)); - godot_string_destroy(&t); - - godot_string_new_with_latin1_chars(&t, "Amber"); - CHECK(!godot_string_operator_less(&s, &t)); - godot_string_destroy(&t); - - godot_string_new_with_latin1_chars(&t, "Beatrix"); - CHECK(!godot_string_operator_less(&s, &t)); - godot_string_destroy(&t); - - godot_string_destroy(&s); -} - -TEST_CASE("[GDNative String] Concatenation (operator +)") { - godot_string s, t, x; - - godot_string_new_with_latin1_chars(&s, "Hel"); - godot_string_new_with_latin1_chars(&t, "lo"); - x = godot_string_operator_plus(&s, &t); - CHECK(u32scmp(godot_string_get_data(&x), U"Hello") == 0); - godot_string_destroy(&x); - godot_string_destroy(&s); - godot_string_destroy(&t); -} - -TEST_CASE("[GDNative String] Testing size and length of string") { - godot_string s; - - godot_string_new_with_latin1_chars(&s, "Mellon"); - CHECK(godot_string_length(&s) == 6); - godot_string_destroy(&s); - - godot_string_new_with_latin1_chars(&s, "Mellon1"); - CHECK(godot_string_length(&s) == 7); - godot_string_destroy(&s); -} - -TEST_CASE("[GDNative String] Testing for empty string") { - godot_string s; - - godot_string_new_with_latin1_chars(&s, "Mellon"); - CHECK(!godot_string_empty(&s)); - godot_string_destroy(&s); - - godot_string_new_with_latin1_chars(&s, ""); - CHECK(godot_string_empty(&s)); - godot_string_destroy(&s); -} - -TEST_CASE("[GDNative String] Test chr") { - godot_string s; - - s = godot_string_chr('H'); - CHECK(u32scmp(godot_string_get_data(&s), U"H") == 0); - godot_string_destroy(&s); - - s = godot_string_chr(0x3012); - CHECK(godot_string_operator_index_const(&s, 0) == 0x3012); - godot_string_destroy(&s); - - ERR_PRINT_OFF - s = godot_string_chr(0xd812); - CHECK(godot_string_operator_index_const(&s, 0) == 0xfffd); // Unpaired UTF-16 surrogate - godot_string_destroy(&s); - - s = godot_string_chr(0x20d812); - CHECK(godot_string_operator_index_const(&s, 0) == 0xfffd); // Outside UTF-32 range - godot_string_destroy(&s); - ERR_PRINT_ON -} - -TEST_CASE("[GDNative String] Operator []") { - godot_string s; - - godot_string_new_with_latin1_chars(&s, "Hello"); - CHECK(*godot_string_operator_index(&s, 1) == 'e'); - CHECK(godot_string_operator_index_const(&s, 0) == 'H'); - CHECK(godot_string_ord_at(&s, 0) == 'H'); - godot_string_destroy(&s); -} - -TEST_CASE("[GDNative String] Case function test") { - godot_string s, t; - - godot_string_new_with_latin1_chars(&s, "MoMoNgA"); - - t = godot_string_to_upper(&s); - CHECK(u32scmp(godot_string_get_data(&t), U"MOMONGA") == 0); - godot_string_destroy(&t); - - t = godot_string_to_lower(&s); - CHECK(u32scmp(godot_string_get_data(&t), U"momonga") == 0); - godot_string_destroy(&t); - - godot_string_destroy(&s); -} - -TEST_CASE("[GDNative String] Case compare function test") { - godot_string s, t; - - godot_string_new_with_latin1_chars(&s, "MoMoNgA"); - godot_string_new_with_latin1_chars(&t, "momonga"); - - CHECK(godot_string_casecmp_to(&s, &t) != 0); - CHECK(godot_string_nocasecmp_to(&s, &t) == 0); - - godot_string_destroy(&s); - godot_string_destroy(&t); -} - -TEST_CASE("[GDNative String] Natural compare function test") { - godot_string s, t; - - godot_string_new_with_latin1_chars(&s, "img2.png"); - godot_string_new_with_latin1_chars(&t, "img10.png"); - - CHECK(godot_string_nocasecmp_to(&s, &t) > 0); - CHECK(godot_string_naturalnocasecmp_to(&s, &t) < 0); - - godot_string_destroy(&s); - godot_string_destroy(&t); -} - -TEST_CASE("[GDNative String] hex_encode_buffer") { - static const uint8_t u8str[] = { 0x45, 0xE3, 0x81, 0x8A, 0x8F, 0xE3 }; - godot_string s = godot_string_hex_encode_buffer(u8str, 6); - CHECK(u32scmp(godot_string_get_data(&s), U"45e3818a8fe3") == 0); - godot_string_destroy(&s); -} - -TEST_CASE("[GDNative String] Substr") { - godot_string s, t; - godot_string_new_with_latin1_chars(&s, "Killer Baby"); - t = godot_string_substr(&s, 3, 4); - CHECK(u32scmp(godot_string_get_data(&t), U"ler ") == 0); - godot_string_destroy(&t); - godot_string_destroy(&s); -} - -TEST_CASE("[GDNative String] Find") { - godot_string s, t; - godot_string_new_with_latin1_chars(&s, "Pretty Woman Woman"); - - godot_string_new_with_latin1_chars(&t, "Revenge of the Monster Truck"); - CHECK(godot_string_find(&s, &t) == -1); - godot_string_destroy(&t); - - godot_string_new_with_latin1_chars(&t, "tty"); - CHECK(godot_string_find(&s, &t) == 3); - godot_string_destroy(&t); - - godot_string_new_with_latin1_chars(&t, "Wo"); - CHECK(godot_string_find_from(&s, &t, 9) == 13); - godot_string_destroy(&t); - - godot_string_new_with_latin1_chars(&t, "man"); - CHECK(godot_string_rfind(&s, &t) == 15); - godot_string_destroy(&t); - - godot_string_destroy(&s); -} - -TEST_CASE("[GDNative String] Find no case") { - godot_string s, t; - godot_string_new_with_latin1_chars(&s, "Pretty Whale Whale"); - - godot_string_new_with_latin1_chars(&t, "WHA"); - CHECK(godot_string_findn(&s, &t) == 7); - godot_string_destroy(&t); - - godot_string_new_with_latin1_chars(&t, "WHA"); - CHECK(godot_string_findn_from(&s, &t, 9) == 13); - godot_string_destroy(&t); - - godot_string_new_with_latin1_chars(&t, "WHA"); - CHECK(godot_string_rfindn(&s, &t) == 13); - godot_string_destroy(&t); - - godot_string_new_with_latin1_chars(&t, "Revenge of the Monster SawFish"); - CHECK(godot_string_findn(&s, &t) == -1); - godot_string_destroy(&t); - - godot_string_destroy(&s); -} - -TEST_CASE("[GDNative String] Find MK") { - godot_packed_string_array keys; - godot_packed_string_array_new(&keys); - -#define PUSH_KEY(x) \ - { \ - godot_string t; \ - godot_string_new_with_latin1_chars(&t, x); \ - godot_packed_string_array_push_back(&keys, &t); \ - godot_string_destroy(&t); \ - } - - PUSH_KEY("sty") - PUSH_KEY("tty") - PUSH_KEY("man") - - godot_string s; - godot_string_new_with_latin1_chars(&s, "Pretty Woman"); - godot_int key = 0; - - CHECK(godot_string_findmk(&s, &keys) == 3); - CHECK(godot_string_findmk_from_in_place(&s, &keys, 0, &key) == 3); - CHECK(key == 1); - - CHECK(godot_string_findmk_from(&s, &keys, 5) == 9); - CHECK(godot_string_findmk_from_in_place(&s, &keys, 5, &key) == 9); - CHECK(key == 2); - - godot_string_destroy(&s); - godot_packed_string_array_destroy(&keys); - -#undef PUSH_KEY -} - -TEST_CASE("[GDNative String] Find and replace") { - godot_string s, c, w; - godot_string_new_with_latin1_chars(&s, "Happy Birthday, Anna!"); - godot_string_new_with_latin1_chars(&c, "Birthday"); - godot_string_new_with_latin1_chars(&w, "Halloween"); - godot_string t = godot_string_replace(&s, &c, &w); - CHECK(u32scmp(godot_string_get_data(&t), U"Happy Halloween, Anna!") == 0); - godot_string_destroy(&s); - godot_string_destroy(&c); - godot_string_destroy(&w); - - godot_string_new_with_latin1_chars(&c, "H"); - godot_string_new_with_latin1_chars(&w, "W"); - s = godot_string_replace_first(&t, &c, &w); - godot_string_destroy(&t); - godot_string_destroy(&c); - godot_string_destroy(&w); - - CHECK(u32scmp(godot_string_get_data(&s), U"Wappy Halloween, Anna!") == 0); - godot_string_destroy(&s); -} - -TEST_CASE("[GDNative String] Insertion") { - godot_string s, t, r, u; - godot_string_new_with_latin1_chars(&s, "Who is Frederic?"); - godot_string_new_with_latin1_chars(&t, "?"); - godot_string_new_with_latin1_chars(&r, " Chopin"); - - u = godot_string_insert(&s, godot_string_find(&s, &t), &r); - CHECK(u32scmp(godot_string_get_data(&u), U"Who is Frederic Chopin?") == 0); - - godot_string_destroy(&s); - godot_string_destroy(&t); - godot_string_destroy(&r); - godot_string_destroy(&u); -} - -TEST_CASE("[GDNative String] Number to string") { - godot_string s; - s = godot_string_num(3.141593); - CHECK(u32scmp(godot_string_get_data(&s), U"3.141593") == 0); - godot_string_destroy(&s); - - s = godot_string_num_with_decimals(3.141593, 3); - CHECK(u32scmp(godot_string_get_data(&s), U"3.142") == 0); - godot_string_destroy(&s); - - s = godot_string_num_real(3.141593); - CHECK(u32scmp(godot_string_get_data(&s), U"3.141593") == 0); - godot_string_destroy(&s); - - s = godot_string_num_scientific(30000000); - CHECK(u32scmp(godot_string_get_data(&s), U"3e+07") == 0); - godot_string_destroy(&s); - - s = godot_string_num_int64(3141593, 10); - CHECK(u32scmp(godot_string_get_data(&s), U"3141593") == 0); - godot_string_destroy(&s); - - s = godot_string_num_int64(0xA141593, 16); - CHECK(u32scmp(godot_string_get_data(&s), U"a141593") == 0); - godot_string_destroy(&s); - - s = godot_string_num_int64_capitalized(0xA141593, 16, true); - CHECK(u32scmp(godot_string_get_data(&s), U"A141593") == 0); - godot_string_destroy(&s); -} - -TEST_CASE("[GDNative String] String to integer") { - static const wchar_t *wnums[4] = { L"1237461283", L"- 22", L"0", L" - 1123412" }; - static const char *nums[4] = { "1237461283", "- 22", "0", " - 1123412" }; - static const int num[4] = { 1237461283, -22, 0, -1123412 }; - - for (int i = 0; i < 4; i++) { - godot_string s; - godot_string_new_with_latin1_chars(&s, nums[i]); - CHECK(godot_string_to_int(&s) == num[i]); - godot_string_destroy(&s); - - CHECK(godot_string_char_to_int(nums[i]) == num[i]); - CHECK(godot_string_wchar_to_int(wnums[i]) == num[i]); - } -} - -TEST_CASE("[GDNative String] Hex to integer") { - static const char *nums[4] = { "0xFFAE", "22", "0", "AADDAD" }; - static const int64_t num[4] = { 0xFFAE, 0x22, 0, 0xAADDAD }; - static const bool wo_prefix[4] = { false, true, true, true }; - static const bool w_prefix[4] = { true, false, true, false }; - - for (int i = 0; i < 4; i++) { - godot_string s; - godot_string_new_with_latin1_chars(&s, nums[i]); - CHECK((godot_string_hex_to_int_with_prefix(&s) == num[i]) == w_prefix[i]); - CHECK((godot_string_hex_to_int(&s) == num[i]) == wo_prefix[i]); - godot_string_destroy(&s); - } -} - -TEST_CASE("[GDNative String] String to float") { - static const wchar_t *wnums[4] = { L"-12348298412.2", L"0.05", L"2.0002", L" -0.0001" }; - static const char *nums[4] = { "-12348298412.2", "0.05", "2.0002", " -0.0001" }; - static const double num[4] = { -12348298412.2, 0.05, 2.0002, -0.0001 }; - - for (int i = 0; i < 4; i++) { - godot_string s; - godot_string_new_with_latin1_chars(&s, nums[i]); - CHECK(!(ABS(godot_string_to_float(&s) - num[i]) > 0.00001)); - godot_string_destroy(&s); - - CHECK(!(ABS(godot_string_char_to_float(nums[i]) - num[i]) > 0.00001)); - CHECK(!(ABS(godot_string_wchar_to_float(wnums[i], nullptr) - num[i]) > 0.00001)); - } -} - -TEST_CASE("[GDNative String] CamelCase to underscore") { - godot_string s, t; - godot_string_new_with_latin1_chars(&s, "TestTestStringGD"); - - t = godot_string_camelcase_to_underscore(&s); - CHECK(u32scmp(godot_string_get_data(&t), U"Test_Test_String_GD") == 0); - godot_string_destroy(&t); - - t = godot_string_camelcase_to_underscore_lowercased(&s); - CHECK(u32scmp(godot_string_get_data(&t), U"test_test_string_gd") == 0); - godot_string_destroy(&t); - - godot_string_destroy(&s); -} - -TEST_CASE("[GDNative String] Slicing") { - godot_string s, c; - godot_string_new_with_latin1_chars(&s, "Mars,Jupiter,Saturn,Uranus"); - godot_string_new_with_latin1_chars(&c, ","); - - const char32_t *slices[4] = { U"Mars", U"Jupiter", U"Saturn", U"Uranus" }; - for (int i = 0; i < godot_string_get_slice_count(&s, &c); i++) { - godot_string t; - t = godot_string_get_slice(&s, &c, i); - CHECK(u32scmp(godot_string_get_data(&t), slices[i]) == 0); - godot_string_destroy(&t); - - t = godot_string_get_slicec(&s, U',', i); - CHECK(u32scmp(godot_string_get_data(&t), slices[i]) == 0); - godot_string_destroy(&t); - } - - godot_string_destroy(&c); - godot_string_destroy(&s); -} - -TEST_CASE("[GDNative String] Splitting") { - godot_string s, c; - godot_string_new_with_latin1_chars(&s, "Mars,Jupiter,Saturn,Uranus"); - godot_string_new_with_latin1_chars(&c, ","); - - godot_packed_string_array l; - - const char32_t *slices_l[3] = { U"Mars", U"Jupiter", U"Saturn,Uranus" }; - const char32_t *slices_r[3] = { U"Mars,Jupiter", U"Saturn", U"Uranus" }; - - l = godot_string_split_with_maxsplit(&s, &c, true, 2); - CHECK(godot_packed_string_array_size(&l) == 3); - for (int i = 0; i < godot_packed_string_array_size(&l); i++) { - godot_string t = godot_packed_string_array_get(&l, i); - CHECK(u32scmp(godot_string_get_data(&t), slices_l[i]) == 0); - godot_string_destroy(&t); - } - godot_packed_string_array_destroy(&l); - - l = godot_string_rsplit_with_maxsplit(&s, &c, true, 2); - CHECK(godot_packed_string_array_size(&l) == 3); - for (int i = 0; i < godot_packed_string_array_size(&l); i++) { - godot_string t = godot_packed_string_array_get(&l, i); - CHECK(u32scmp(godot_string_get_data(&t), slices_r[i]) == 0); - godot_string_destroy(&t); - } - godot_packed_string_array_destroy(&l); - godot_string_destroy(&s); - - godot_string_new_with_latin1_chars(&s, "Mars Jupiter Saturn Uranus"); - const char32_t *slices_s[4] = { U"Mars", U"Jupiter", U"Saturn", U"Uranus" }; - l = godot_string_split_spaces(&s); - for (int i = 0; i < godot_packed_string_array_size(&l); i++) { - godot_string t = godot_packed_string_array_get(&l, i); - CHECK(u32scmp(godot_string_get_data(&t), slices_s[i]) == 0); - godot_string_destroy(&t); - } - godot_packed_string_array_destroy(&l); - godot_string_destroy(&s); - - godot_string c1, c2; - godot_string_new_with_latin1_chars(&c1, ";"); - godot_string_new_with_latin1_chars(&c2, " "); - - godot_string_new_with_latin1_chars(&s, "1.2;2.3 4.5"); - const double slices_d[3] = { 1.2, 2.3, 4.5 }; - - godot_packed_float32_array lf = godot_string_split_floats_allow_empty(&s, &c1); - CHECK(godot_packed_float32_array_size(&lf) == 2); - for (int i = 0; i < godot_packed_float32_array_size(&lf); i++) { - CHECK(ABS(godot_packed_float32_array_get(&lf, i) - slices_d[i]) <= 0.00001); - } - godot_packed_float32_array_destroy(&lf); - - godot_packed_string_array keys; - godot_packed_string_array_new(&keys); - godot_packed_string_array_push_back(&keys, &c1); - godot_packed_string_array_push_back(&keys, &c2); - - lf = godot_string_split_floats_mk_allow_empty(&s, &keys); - CHECK(godot_packed_float32_array_size(&lf) == 3); - for (int i = 0; i < godot_packed_float32_array_size(&lf); i++) { - CHECK(ABS(godot_packed_float32_array_get(&lf, i) - slices_d[i]) <= 0.00001); - } - godot_packed_float32_array_destroy(&lf); - - godot_string_destroy(&s); - godot_string_new_with_latin1_chars(&s, "1;2 4"); - const int slices_i[3] = { 1, 2, 4 }; - - godot_packed_int32_array li = godot_string_split_ints_allow_empty(&s, &c1); - CHECK(godot_packed_int32_array_size(&li) == 2); - for (int i = 0; i < godot_packed_int32_array_size(&li); i++) { - CHECK(godot_packed_int32_array_get(&li, i) == slices_i[i]); - } - godot_packed_int32_array_destroy(&li); - - li = godot_string_split_ints_mk_allow_empty(&s, &keys); - CHECK(godot_packed_int32_array_size(&li) == 3); - for (int i = 0; i < godot_packed_int32_array_size(&li); i++) { - CHECK(godot_packed_int32_array_get(&li, i) == slices_i[i]); - } - godot_packed_int32_array_destroy(&li); - - godot_string_destroy(&s); - godot_string_destroy(&c); - godot_string_destroy(&c1); - godot_string_destroy(&c2); - godot_packed_string_array_destroy(&keys); -} - -TEST_CASE("[GDNative String] Erasing") { - godot_string s, t; - godot_string_new_with_latin1_chars(&s, "Josephine is such a cute girl!"); - godot_string_new_with_latin1_chars(&t, "cute "); - - godot_string_erase(&s, godot_string_find(&s, &t), godot_string_length(&t)); - - CHECK(u32scmp(godot_string_get_data(&s), U"Josephine is such a girl!") == 0); - - godot_string_destroy(&s); - godot_string_destroy(&t); -} - -struct test_27_data { - char const *data; - char const *part; - bool expected; -}; - -TEST_CASE("[GDNative String] Begins with") { - test_27_data tc[] = { - { "res://foobar", "res://", true }, - { "res", "res://", false }, - { "abc", "abc", true } - }; - size_t count = sizeof(tc) / sizeof(tc[0]); - bool state = true; - for (size_t i = 0; state && i < count; ++i) { - godot_string s; - godot_string_new_with_latin1_chars(&s, tc[i].data); - - state = godot_string_begins_with_char_array(&s, tc[i].part) == tc[i].expected; - if (state) { - godot_string t; - godot_string_new_with_latin1_chars(&t, tc[i].part); - state = godot_string_begins_with(&s, &t) == tc[i].expected; - godot_string_destroy(&t); - } - godot_string_destroy(&s); - - CHECK(state); - if (!state) { - break; - } - }; - CHECK(state); -} - -TEST_CASE("[GDNative String] Ends with") { - test_27_data tc[] = { - { "res://foobar", "foobar", true }, - { "res", "res://", false }, - { "abc", "abc", true } - }; - size_t count = sizeof(tc) / sizeof(tc[0]); - bool state = true; - for (size_t i = 0; state && i < count; ++i) { - godot_string s; - godot_string_new_with_latin1_chars(&s, tc[i].data); - - state = godot_string_ends_with_char_array(&s, tc[i].part) == tc[i].expected; - if (state) { - godot_string t; - godot_string_new_with_latin1_chars(&t, tc[i].part); - state = godot_string_ends_with(&s, &t) == tc[i].expected; - godot_string_destroy(&t); - } - godot_string_destroy(&s); - - CHECK(state); - if (!state) { - break; - } - }; - CHECK(state); -} - -TEST_CASE("[GDNative String] format") { - godot_string value_format, t; - godot_string_new_with_latin1_chars(&value_format, "red=\"$red\" green=\"$green\" blue=\"$blue\" alpha=\"$alpha\""); - - godot_variant key_v, val_v; - godot_dictionary value_dictionary; - godot_dictionary_new(&value_dictionary); - - godot_string_new_with_latin1_chars(&t, "red"); - godot_variant_new_string(&key_v, &t); - godot_string_destroy(&t); - godot_variant_new_int(&val_v, 10); - godot_dictionary_set(&value_dictionary, &key_v, &val_v); - godot_variant_destroy(&key_v); - godot_variant_destroy(&val_v); - - godot_string_new_with_latin1_chars(&t, "green"); - godot_variant_new_string(&key_v, &t); - godot_string_destroy(&t); - godot_variant_new_int(&val_v, 20); - godot_dictionary_set(&value_dictionary, &key_v, &val_v); - godot_variant_destroy(&key_v); - godot_variant_destroy(&val_v); - - godot_string_new_with_latin1_chars(&t, "blue"); - godot_variant_new_string(&key_v, &t); - godot_string_destroy(&t); - godot_string_new_with_latin1_chars(&t, "bla"); - godot_variant_new_string(&val_v, &t); - godot_string_destroy(&t); - godot_dictionary_set(&value_dictionary, &key_v, &val_v); - godot_variant_destroy(&key_v); - godot_variant_destroy(&val_v); - - godot_string_new_with_latin1_chars(&t, "alpha"); - godot_variant_new_string(&key_v, &t); - godot_string_destroy(&t); - godot_variant_new_real(&val_v, 0.4); - godot_dictionary_set(&value_dictionary, &key_v, &val_v); - godot_variant_destroy(&key_v); - godot_variant_destroy(&val_v); - - godot_variant dict_v; - godot_variant_new_dictionary(&dict_v, &value_dictionary); - godot_string s = godot_string_format_with_custom_placeholder(&value_format, &dict_v, "$_"); - - CHECK(u32scmp(godot_string_get_data(&s), U"red=\"10\" green=\"20\" blue=\"bla\" alpha=\"0.4\"") == 0); - - godot_dictionary_destroy(&value_dictionary); - godot_string_destroy(&s); - godot_variant_destroy(&dict_v); - godot_string_destroy(&value_format); -} - -TEST_CASE("[GDNative String] sprintf") { - //godot_string GDAPI (const godot_string *p_self, const godot_array *p_values, godot_bool *p_error); - godot_string format, output; - godot_array args; - bool error; - -#define ARRAY_PUSH_STRING(x) \ - { \ - godot_variant v; \ - godot_string t; \ - godot_string_new_with_latin1_chars(&t, x); \ - godot_variant_new_string(&v, &t); \ - godot_string_destroy(&t); \ - godot_array_push_back(&args, &v); \ - godot_variant_destroy(&v); \ - } - -#define ARRAY_PUSH_INT(x) \ - { \ - godot_variant v; \ - godot_variant_new_int(&v, x); \ - godot_array_push_back(&args, &v); \ - godot_variant_destroy(&v); \ - } - -#define ARRAY_PUSH_REAL(x) \ - { \ - godot_variant v; \ - godot_variant_new_real(&v, x); \ - godot_array_push_back(&args, &v); \ - godot_variant_destroy(&v); \ - } - - godot_array_new(&args); - - // %% - godot_string_new_with_latin1_chars(&format, "fish %% frog"); - godot_array_clear(&args); - output = godot_string_sprintf(&format, &args, &error); - REQUIRE(error == false); - CHECK(u32scmp(godot_string_get_data(&output), U"fish % frog") == 0); - godot_string_destroy(&format); - godot_string_destroy(&output); - //////// INTS - - // Int - godot_string_new_with_latin1_chars(&format, "fish %d frog"); - godot_array_clear(&args); - ARRAY_PUSH_INT(5); - output = godot_string_sprintf(&format, &args, &error); - REQUIRE(error == false); - CHECK(u32scmp(godot_string_get_data(&output), U"fish 5 frog") == 0); - godot_string_destroy(&format); - godot_string_destroy(&output); - - // Int left padded with zeroes. - godot_string_new_with_latin1_chars(&format, "fish %05d frog"); - godot_array_clear(&args); - ARRAY_PUSH_INT(5); - output = godot_string_sprintf(&format, &args, &error); - REQUIRE(error == false); - CHECK(u32scmp(godot_string_get_data(&output), U"fish 00005 frog") == 0); - godot_string_destroy(&format); - godot_string_destroy(&output); - - // Int left padded with spaces. - godot_string_new_with_latin1_chars(&format, "fish %5d frog"); - godot_array_clear(&args); - ARRAY_PUSH_INT(5); - output = godot_string_sprintf(&format, &args, &error); - REQUIRE(error == false); - CHECK(u32scmp(godot_string_get_data(&output), U"fish 5 frog") == 0); - godot_string_destroy(&format); - godot_string_destroy(&output); - - // Int right padded with spaces. - godot_string_new_with_latin1_chars(&format, "fish %-5d frog"); - godot_array_clear(&args); - ARRAY_PUSH_INT(5); - output = godot_string_sprintf(&format, &args, &error); - REQUIRE(error == false); - CHECK(u32scmp(godot_string_get_data(&output), U"fish 5 frog") == 0); - godot_string_destroy(&format); - godot_string_destroy(&output); - - // Int with sign (positive). - godot_string_new_with_latin1_chars(&format, "fish %+d frog"); - godot_array_clear(&args); - ARRAY_PUSH_INT(5); - output = godot_string_sprintf(&format, &args, &error); - REQUIRE(error == false); - CHECK(u32scmp(godot_string_get_data(&output), U"fish +5 frog") == 0); - godot_string_destroy(&format); - godot_string_destroy(&output); - - // Negative int. - godot_string_new_with_latin1_chars(&format, "fish %d frog"); - godot_array_clear(&args); - ARRAY_PUSH_INT(-5); - output = godot_string_sprintf(&format, &args, &error); - REQUIRE(error == false); - CHECK(u32scmp(godot_string_get_data(&output), U"fish -5 frog") == 0); - godot_string_destroy(&format); - godot_string_destroy(&output); - - // Hex (lower) - godot_string_new_with_latin1_chars(&format, "fish %x frog"); - godot_array_clear(&args); - ARRAY_PUSH_INT(45); - output = godot_string_sprintf(&format, &args, &error); - REQUIRE(error == false); - CHECK(u32scmp(godot_string_get_data(&output), U"fish 2d frog") == 0); - godot_string_destroy(&format); - godot_string_destroy(&output); - - // Hex (upper) - godot_string_new_with_latin1_chars(&format, "fish %X frog"); - godot_array_clear(&args); - ARRAY_PUSH_INT(45); - output = godot_string_sprintf(&format, &args, &error); - REQUIRE(error == false); - CHECK(u32scmp(godot_string_get_data(&output), U"fish 2D frog") == 0); - godot_string_destroy(&format); - godot_string_destroy(&output); - - // Octal - godot_string_new_with_latin1_chars(&format, "fish %o frog"); - godot_array_clear(&args); - ARRAY_PUSH_INT(99); - output = godot_string_sprintf(&format, &args, &error); - REQUIRE(error == false); - CHECK(u32scmp(godot_string_get_data(&output), U"fish 143 frog") == 0); - godot_string_destroy(&format); - godot_string_destroy(&output); - ////// REALS - - // Real - godot_string_new_with_latin1_chars(&format, "fish %f frog"); - godot_array_clear(&args); - ARRAY_PUSH_REAL(99.99); - output = godot_string_sprintf(&format, &args, &error); - REQUIRE(error == false); - CHECK(u32scmp(godot_string_get_data(&output), U"fish 99.990000 frog") == 0); - godot_string_destroy(&format); - godot_string_destroy(&output); - - // Real left-padded - godot_string_new_with_latin1_chars(&format, "fish %11f frog"); - godot_array_clear(&args); - ARRAY_PUSH_REAL(99.99); - output = godot_string_sprintf(&format, &args, &error); - REQUIRE(error == false); - CHECK(u32scmp(godot_string_get_data(&output), U"fish 99.990000 frog") == 0); - godot_string_destroy(&format); - godot_string_destroy(&output); - - // Real right-padded - godot_string_new_with_latin1_chars(&format, "fish %-11f frog"); - godot_array_clear(&args); - ARRAY_PUSH_REAL(99.99); - output = godot_string_sprintf(&format, &args, &error); - REQUIRE(error == false); - CHECK(u32scmp(godot_string_get_data(&output), U"fish 99.990000 frog") == 0); - godot_string_destroy(&format); - godot_string_destroy(&output); - - // Real given int. - godot_string_new_with_latin1_chars(&format, "fish %f frog"); - godot_array_clear(&args); - ARRAY_PUSH_REAL(99); - output = godot_string_sprintf(&format, &args, &error); - REQUIRE(error == false); - CHECK(u32scmp(godot_string_get_data(&output), U"fish 99.000000 frog") == 0); - godot_string_destroy(&format); - godot_string_destroy(&output); - - // Real with sign (positive). - godot_string_new_with_latin1_chars(&format, "fish %+f frog"); - godot_array_clear(&args); - ARRAY_PUSH_REAL(99.99); - output = godot_string_sprintf(&format, &args, &error); - REQUIRE(error == false); - CHECK(u32scmp(godot_string_get_data(&output), U"fish +99.990000 frog") == 0); - godot_string_destroy(&format); - godot_string_destroy(&output); - - // Real with 1 decimals. - godot_string_new_with_latin1_chars(&format, "fish %.1f frog"); - godot_array_clear(&args); - ARRAY_PUSH_REAL(99.99); - output = godot_string_sprintf(&format, &args, &error); - REQUIRE(error == false); - CHECK(u32scmp(godot_string_get_data(&output), U"fish 100.0 frog") == 0); - godot_string_destroy(&format); - godot_string_destroy(&output); - - // Real with 12 decimals. - godot_string_new_with_latin1_chars(&format, "fish %.12f frog"); - godot_array_clear(&args); - ARRAY_PUSH_REAL(99.99); - output = godot_string_sprintf(&format, &args, &error); - REQUIRE(error == false); - CHECK(u32scmp(godot_string_get_data(&output), U"fish 99.990000000000 frog") == 0); - godot_string_destroy(&format); - godot_string_destroy(&output); - - // Real with no decimals. - godot_string_new_with_latin1_chars(&format, "fish %.f frog"); - godot_array_clear(&args); - ARRAY_PUSH_REAL(99.99); - output = godot_string_sprintf(&format, &args, &error); - REQUIRE(error == false); - CHECK(u32scmp(godot_string_get_data(&output), U"fish 100 frog") == 0); - godot_string_destroy(&format); - godot_string_destroy(&output); - - /////// Strings. - - // String - godot_string_new_with_latin1_chars(&format, "fish %s frog"); - godot_array_clear(&args); - ARRAY_PUSH_STRING("cheese"); - output = godot_string_sprintf(&format, &args, &error); - REQUIRE(error == false); - CHECK(u32scmp(godot_string_get_data(&output), U"fish cheese frog") == 0); - godot_string_destroy(&format); - godot_string_destroy(&output); - - // String left-padded - godot_string_new_with_latin1_chars(&format, "fish %10s frog"); - godot_array_clear(&args); - ARRAY_PUSH_STRING("cheese"); - output = godot_string_sprintf(&format, &args, &error); - REQUIRE(error == false); - CHECK(u32scmp(godot_string_get_data(&output), U"fish cheese frog") == 0); - godot_string_destroy(&format); - godot_string_destroy(&output); - - // String right-padded - godot_string_new_with_latin1_chars(&format, "fish %-10s frog"); - godot_array_clear(&args); - ARRAY_PUSH_STRING("cheese"); - output = godot_string_sprintf(&format, &args, &error); - REQUIRE(error == false); - CHECK(u32scmp(godot_string_get_data(&output), U"fish cheese frog") == 0); - godot_string_destroy(&format); - godot_string_destroy(&output); - - ///// Characters - - // Character as string. - godot_string_new_with_latin1_chars(&format, "fish %c frog"); - godot_array_clear(&args); - ARRAY_PUSH_STRING("A"); - output = godot_string_sprintf(&format, &args, &error); - REQUIRE(error == false); - CHECK(u32scmp(godot_string_get_data(&output), U"fish A frog") == 0); - godot_string_destroy(&format); - godot_string_destroy(&output); - - // Character as int. - godot_string_new_with_latin1_chars(&format, "fish %c frog"); - godot_array_clear(&args); - ARRAY_PUSH_INT(65); - output = godot_string_sprintf(&format, &args, &error); - REQUIRE(error == false); - CHECK(u32scmp(godot_string_get_data(&output), U"fish A frog") == 0); - godot_string_destroy(&format); - godot_string_destroy(&output); - - ///// Dynamic width - - // String dynamic width - godot_string_new_with_latin1_chars(&format, "fish %*s frog"); - godot_array_clear(&args); - ARRAY_PUSH_INT(10); - ARRAY_PUSH_STRING("cheese"); - output = godot_string_sprintf(&format, &args, &error); - REQUIRE(error == false); - REQUIRE(u32scmp(godot_string_get_data(&output), U"fish cheese frog") == 0); - godot_string_destroy(&format); - godot_string_destroy(&output); - - // Int dynamic width - godot_string_new_with_latin1_chars(&format, "fish %*d frog"); - godot_array_clear(&args); - ARRAY_PUSH_INT(10); - ARRAY_PUSH_INT(99); - output = godot_string_sprintf(&format, &args, &error); - REQUIRE(error == false); - REQUIRE(u32scmp(godot_string_get_data(&output), U"fish 99 frog") == 0); - godot_string_destroy(&format); - godot_string_destroy(&output); - - // Float dynamic width - godot_string_new_with_latin1_chars(&format, "fish %*.*f frog"); - godot_array_clear(&args); - ARRAY_PUSH_INT(10); - ARRAY_PUSH_INT(3); - ARRAY_PUSH_REAL(99.99); - output = godot_string_sprintf(&format, &args, &error); - REQUIRE(error == false); - CHECK(u32scmp(godot_string_get_data(&output), U"fish 99.990 frog") == 0); - godot_string_destroy(&format); - godot_string_destroy(&output); - - ///// Errors - - // More formats than arguments. - godot_string_new_with_latin1_chars(&format, "fish %s %s frog"); - godot_array_clear(&args); - ARRAY_PUSH_STRING("cheese"); - output = godot_string_sprintf(&format, &args, &error); - REQUIRE(error); - CHECK(u32scmp(godot_string_get_data(&output), U"not enough arguments for format string") == 0); - godot_string_destroy(&format); - godot_string_destroy(&output); - - // More arguments than formats. - godot_string_new_with_latin1_chars(&format, "fish %s frog"); - godot_array_clear(&args); - ARRAY_PUSH_STRING("hello"); - ARRAY_PUSH_STRING("cheese"); - output = godot_string_sprintf(&format, &args, &error); - REQUIRE(error); - CHECK(u32scmp(godot_string_get_data(&output), U"not all arguments converted during string formatting") == 0); - godot_string_destroy(&format); - godot_string_destroy(&output); - - // Incomplete format. - godot_string_new_with_latin1_chars(&format, "fish %10"); - godot_array_clear(&args); - ARRAY_PUSH_STRING("cheese"); - output = godot_string_sprintf(&format, &args, &error); - REQUIRE(error); - CHECK(u32scmp(godot_string_get_data(&output), U"incomplete format") == 0); - godot_string_destroy(&format); - godot_string_destroy(&output); - - // Bad character in format string - godot_string_new_with_latin1_chars(&format, "fish %&f frog"); - godot_array_clear(&args); - ARRAY_PUSH_STRING("cheese"); - output = godot_string_sprintf(&format, &args, &error); - REQUIRE(error); - CHECK(u32scmp(godot_string_get_data(&output), U"unsupported format character") == 0); - godot_string_destroy(&format); - godot_string_destroy(&output); - - // Too many decimals. - godot_string_new_with_latin1_chars(&format, "fish %2.2.2f frog"); - godot_array_clear(&args); - ARRAY_PUSH_REAL(99.99); - output = godot_string_sprintf(&format, &args, &error); - REQUIRE(error); - CHECK(u32scmp(godot_string_get_data(&output), U"too many decimal points in format") == 0); - godot_string_destroy(&format); - godot_string_destroy(&output); - - // * not a number - godot_string_new_with_latin1_chars(&format, "fish %*f frog"); - godot_array_clear(&args); - ARRAY_PUSH_STRING("cheese"); - ARRAY_PUSH_REAL(99.99); - output = godot_string_sprintf(&format, &args, &error); - REQUIRE(error); - CHECK(u32scmp(godot_string_get_data(&output), U"* wants number") == 0); - godot_string_destroy(&format); - godot_string_destroy(&output); - - // Character too long. - godot_string_new_with_latin1_chars(&format, "fish %c frog"); - godot_array_clear(&args); - ARRAY_PUSH_STRING("sc"); - output = godot_string_sprintf(&format, &args, &error); - REQUIRE(error); - CHECK(u32scmp(godot_string_get_data(&output), U"%c requires number or single-character string") == 0); - godot_string_destroy(&format); - godot_string_destroy(&output); - - // Character bad type. - godot_string_new_with_latin1_chars(&format, "fish %c frog"); - godot_array_clear(&args); - godot_array t; - godot_array_new(&t); - godot_variant v; - godot_variant_new_array(&v, &t); - godot_array_destroy(&t); - godot_array_push_back(&args, &v); - godot_variant_destroy(&v); - output = godot_string_sprintf(&format, &args, &error); - REQUIRE(error); - CHECK(u32scmp(godot_string_get_data(&output), U"%c requires number or single-character string") == 0); - godot_string_destroy(&format); - godot_string_destroy(&output); - - godot_array_destroy(&args); -#undef ARRAY_PUSH_INT -#undef ARRAY_PUSH_REAL -#undef ARRAY_PUSH_STRING -} - -TEST_CASE("[GDNative String] is_numeric") { -#define IS_NUM_TEST(x, r) \ - { \ - godot_string t; \ - godot_string_new_with_latin1_chars(&t, x); \ - CHECK(godot_string_is_numeric(&t) == r); \ - godot_string_destroy(&t); \ - } - - IS_NUM_TEST("12", true); - IS_NUM_TEST("1.2", true); - IS_NUM_TEST("AF", false); - IS_NUM_TEST("-12", true); - IS_NUM_TEST("-1.2", true); - -#undef IS_NUM_TEST -} - -TEST_CASE("[GDNative String] pad") { - godot_string s, c; - godot_string_new_with_latin1_chars(&s, "test"); - godot_string_new_with_latin1_chars(&c, "x"); - - godot_string l = godot_string_lpad_with_custom_character(&s, 10, &c); - CHECK(u32scmp(godot_string_get_data(&l), U"xxxxxxtest") == 0); - godot_string_destroy(&l); - - godot_string r = godot_string_rpad_with_custom_character(&s, 10, &c); - CHECK(u32scmp(godot_string_get_data(&r), U"testxxxxxx") == 0); - godot_string_destroy(&r); - - godot_string_destroy(&s); - godot_string_destroy(&c); - - godot_string_new_with_latin1_chars(&s, "10.10"); - c = godot_string_pad_decimals(&s, 4); - CHECK(u32scmp(godot_string_get_data(&c), U"10.1000") == 0); - godot_string_destroy(&c); - c = godot_string_pad_zeros(&s, 4); - CHECK(u32scmp(godot_string_get_data(&c), U"0010.10") == 0); - godot_string_destroy(&c); - - godot_string_destroy(&s); -} - -TEST_CASE("[GDNative String] is_subsequence_of") { - godot_string a, t; - godot_string_new_with_latin1_chars(&a, "is subsequence of"); - - godot_string_new_with_latin1_chars(&t, "sub"); - CHECK(godot_string_is_subsequence_of(&t, &a)); - godot_string_destroy(&t); - - godot_string_new_with_latin1_chars(&t, "Sub"); - CHECK(!godot_string_is_subsequence_of(&t, &a)); - godot_string_destroy(&t); - - godot_string_new_with_latin1_chars(&t, "Sub"); - CHECK(godot_string_is_subsequence_ofi(&t, &a)); - godot_string_destroy(&t); - - godot_string_destroy(&a); -} - -TEST_CASE("[GDNative String] match") { - godot_string s, t; - godot_string_new_with_latin1_chars(&s, "*.png"); - - godot_string_new_with_latin1_chars(&t, "img1.png"); - CHECK(godot_string_match(&t, &s)); - godot_string_destroy(&t); - - godot_string_new_with_latin1_chars(&t, "img1.jpeg"); - CHECK(!godot_string_match(&t, &s)); - godot_string_destroy(&t); - - godot_string_new_with_latin1_chars(&t, "img1.Png"); - CHECK(!godot_string_match(&t, &s)); - CHECK(godot_string_matchn(&t, &s)); - godot_string_destroy(&t); - - godot_string_destroy(&s); -} - -TEST_CASE("[GDNative String] IPVX address to string") { - godot_string ip; - - godot_string_new_with_latin1_chars(&ip, "192.168.0.1"); - CHECK(godot_string_is_valid_ip_address(&ip)); - godot_string_destroy(&ip); - - godot_string_new_with_latin1_chars(&ip, "192.368.0.1"); - CHECK(!godot_string_is_valid_ip_address(&ip)); - godot_string_destroy(&ip); - - godot_string_new_with_latin1_chars(&ip, "2001:0db8:85a3:0000:0000:8a2e:0370:7334"); - CHECK(godot_string_is_valid_ip_address(&ip)); - godot_string_destroy(&ip); - - godot_string_new_with_latin1_chars(&ip, "2001:0db8:85j3:0000:0000:8a2e:0370:7334"); - CHECK(!godot_string_is_valid_ip_address(&ip)); - godot_string_destroy(&ip); - - godot_string_new_with_latin1_chars(&ip, "2001:0db8:85f345:0000:0000:8a2e:0370:7334"); - CHECK(!godot_string_is_valid_ip_address(&ip)); - godot_string_destroy(&ip); - - godot_string_new_with_latin1_chars(&ip, "2001:0db8::0:8a2e:370:7334"); - CHECK(godot_string_is_valid_ip_address(&ip)); - godot_string_destroy(&ip); - - godot_string_new_with_latin1_chars(&ip, "::ffff:192.168.0.1"); - CHECK(godot_string_is_valid_ip_address(&ip)); - godot_string_destroy(&ip); -} - -TEST_CASE("[GDNative String] Capitalize against many strings") { -#define CAP_TEST(i, o) \ - godot_string_new_with_latin1_chars(&input, i); \ - godot_string_new_with_latin1_chars(&output, o); \ - test = godot_string_capitalize(&input); \ - CHECK(u32scmp(godot_string_get_data(&output), godot_string_get_data(&test)) == 0); \ - godot_string_destroy(&input); \ - godot_string_destroy(&output); \ - godot_string_destroy(&test); - - godot_string input, output, test; - - CAP_TEST("bytes2var", "Bytes 2 Var"); - CAP_TEST("linear2db", "Linear 2 Db"); - CAP_TEST("vector3", "Vector 3"); - CAP_TEST("sha256", "Sha 256"); - CAP_TEST("2db", "2 Db"); - CAP_TEST("PascalCase", "Pascal Case"); - CAP_TEST("PascalPascalCase", "Pascal Pascal Case"); - CAP_TEST("snake_case", "Snake Case"); - CAP_TEST("snake_snake_case", "Snake Snake Case"); - CAP_TEST("sha256sum", "Sha 256 Sum"); - CAP_TEST("cat2dog", "Cat 2 Dog"); - CAP_TEST("function(name)", "Function(name)"); - CAP_TEST("snake_case_function(snake_case_arg)", "Snake Case Function(snake Case Arg)"); - CAP_TEST("snake_case_function( snake_case_arg )", "Snake Case Function( Snake Case Arg )"); - -#undef CAP_TEST -} - -TEST_CASE("[GDNative String] lstrip and rstrip") { -#define LSTRIP_TEST(x, y, z) \ - { \ - godot_string xx, yy, zz, rr; \ - godot_string_new_with_latin1_chars(&xx, x); \ - godot_string_new_with_latin1_chars(&yy, y); \ - godot_string_new_with_latin1_chars(&zz, z); \ - rr = godot_string_lstrip(&xx, &yy); \ - state = state && (u32scmp(godot_string_get_data(&rr), godot_string_get_data(&zz)) == 0); \ - godot_string_destroy(&xx); \ - godot_string_destroy(&yy); \ - godot_string_destroy(&zz); \ - godot_string_destroy(&rr); \ - } - -#define RSTRIP_TEST(x, y, z) \ - { \ - godot_string xx, yy, zz, rr; \ - godot_string_new_with_latin1_chars(&xx, x); \ - godot_string_new_with_latin1_chars(&yy, y); \ - godot_string_new_with_latin1_chars(&zz, z); \ - rr = godot_string_rstrip(&xx, &yy); \ - state = state && (u32scmp(godot_string_get_data(&rr), godot_string_get_data(&zz)) == 0); \ - godot_string_destroy(&xx); \ - godot_string_destroy(&yy); \ - godot_string_destroy(&zz); \ - godot_string_destroy(&rr); \ - } - -#define LSTRIP_UTF8_TEST(x, y, z) \ - { \ - godot_string xx, yy, zz, rr; \ - godot_string_new_with_utf8_chars(&xx, x); \ - godot_string_new_with_utf8_chars(&yy, y); \ - godot_string_new_with_utf8_chars(&zz, z); \ - rr = godot_string_lstrip(&xx, &yy); \ - state = state && (u32scmp(godot_string_get_data(&rr), godot_string_get_data(&zz)) == 0); \ - godot_string_destroy(&xx); \ - godot_string_destroy(&yy); \ - godot_string_destroy(&zz); \ - godot_string_destroy(&rr); \ - } - -#define RSTRIP_UTF8_TEST(x, y, z) \ - { \ - godot_string xx, yy, zz, rr; \ - godot_string_new_with_utf8_chars(&xx, x); \ - godot_string_new_with_utf8_chars(&yy, y); \ - godot_string_new_with_utf8_chars(&zz, z); \ - rr = godot_string_rstrip(&xx, &yy); \ - state = state && (u32scmp(godot_string_get_data(&rr), godot_string_get_data(&zz)) == 0); \ - godot_string_destroy(&xx); \ - godot_string_destroy(&yy); \ - godot_string_destroy(&zz); \ - godot_string_destroy(&rr); \ - } - - bool state = true; - - // strip none - LSTRIP_TEST("abc", "", "abc"); - RSTRIP_TEST("abc", "", "abc"); - // strip one - LSTRIP_TEST("abc", "a", "bc"); - RSTRIP_TEST("abc", "c", "ab"); - // strip lots - LSTRIP_TEST("bababbababccc", "ab", "ccc"); - RSTRIP_TEST("aaabcbcbcbbcbbc", "cb", "aaa"); - // strip empty string - LSTRIP_TEST("", "", ""); - RSTRIP_TEST("", "", ""); - // strip to empty string - LSTRIP_TEST("abcabcabc", "bca", ""); - RSTRIP_TEST("abcabcabc", "bca", ""); - // don't strip wrong end - LSTRIP_TEST("abc", "c", "abc"); - LSTRIP_TEST("abca", "a", "bca"); - RSTRIP_TEST("abc", "a", "abc"); - RSTRIP_TEST("abca", "a", "abc"); - // in utf-8 "¿" (\u00bf) has the same first byte as "µ" (\u00b5) - // and the same second as "ÿ" (\u00ff) - LSTRIP_UTF8_TEST("¿", "µÿ", "¿"); - RSTRIP_UTF8_TEST("¿", "µÿ", "¿"); - LSTRIP_UTF8_TEST("µ¿ÿ", "µÿ", "¿ÿ"); - RSTRIP_UTF8_TEST("µ¿ÿ", "µÿ", "µ¿"); - - // the above tests repeated with additional superfluous strip chars - - // strip none - LSTRIP_TEST("abc", "qwjkl", "abc"); - RSTRIP_TEST("abc", "qwjkl", "abc"); - // strip one - LSTRIP_TEST("abc", "qwajkl", "bc"); - RSTRIP_TEST("abc", "qwcjkl", "ab"); - // strip lots - LSTRIP_TEST("bababbababccc", "qwabjkl", "ccc"); - RSTRIP_TEST("aaabcbcbcbbcbbc", "qwcbjkl", "aaa"); - // strip empty string - LSTRIP_TEST("", "qwjkl", ""); - RSTRIP_TEST("", "qwjkl", ""); - // strip to empty string - LSTRIP_TEST("abcabcabc", "qwbcajkl", ""); - RSTRIP_TEST("abcabcabc", "qwbcajkl", ""); - // don't strip wrong end - LSTRIP_TEST("abc", "qwcjkl", "abc"); - LSTRIP_TEST("abca", "qwajkl", "bca"); - RSTRIP_TEST("abc", "qwajkl", "abc"); - RSTRIP_TEST("abca", "qwajkl", "abc"); - // in utf-8 "¿" (\u00bf) has the same first byte as "µ" (\u00b5) - // and the same second as "ÿ" (\u00ff) - LSTRIP_UTF8_TEST("¿", "qwaµÿjkl", "¿"); - RSTRIP_UTF8_TEST("¿", "qwaµÿjkl", "¿"); - LSTRIP_UTF8_TEST("µ¿ÿ", "qwaµÿjkl", "¿ÿ"); - RSTRIP_UTF8_TEST("µ¿ÿ", "qwaµÿjkl", "µ¿"); - - CHECK(state); - -#undef LSTRIP_TEST -#undef RSTRIP_TEST -#undef LSTRIP_UTF8_TEST -#undef RSTRIP_UTF8_TEST -} - -TEST_CASE("[GDNative String] Cyrillic to_lower()") { - godot_string upper, lower, test; - godot_string_new_with_utf8_chars(&upper, "АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ"); - godot_string_new_with_utf8_chars(&lower, "абвгдеёжзийклмнопрстуфхцчшщъыьэюя"); - - test = godot_string_to_lower(&upper); - - CHECK((u32scmp(godot_string_get_data(&test), godot_string_get_data(&lower)) == 0)); - - godot_string_destroy(&upper); - godot_string_destroy(&lower); - godot_string_destroy(&test); -} - -TEST_CASE("[GDNative String] Count and countn functionality") { -#define COUNT_TEST(x, y, r) \ - { \ - godot_string s, t; \ - godot_string_new_with_latin1_chars(&s, x); \ - godot_string_new_with_latin1_chars(&t, y); \ - state = state && (godot_string_count(&s, &t, 0, 0) == r); \ - godot_string_destroy(&s); \ - godot_string_destroy(&t); \ - } - -#define COUNTR_TEST(x, y, a, b, r) \ - { \ - godot_string s, t; \ - godot_string_new_with_latin1_chars(&s, x); \ - godot_string_new_with_latin1_chars(&t, y); \ - state = state && (godot_string_count(&s, &t, a, b) == r); \ - godot_string_destroy(&s); \ - godot_string_destroy(&t); \ - } - -#define COUNTN_TEST(x, y, r) \ - { \ - godot_string s, t; \ - godot_string_new_with_latin1_chars(&s, x); \ - godot_string_new_with_latin1_chars(&t, y); \ - state = state && (godot_string_countn(&s, &t, 0, 0) == r); \ - godot_string_destroy(&s); \ - godot_string_destroy(&t); \ - } - -#define COUNTNR_TEST(x, y, a, b, r) \ - { \ - godot_string s, t; \ - godot_string_new_with_latin1_chars(&s, x); \ - godot_string_new_with_latin1_chars(&t, y); \ - state = state && (godot_string_countn(&s, &t, a, b) == r); \ - godot_string_destroy(&s); \ - godot_string_destroy(&t); \ - } - bool state = true; - - COUNT_TEST("", "Test", 0); - COUNT_TEST("Test", "", 0); - COUNT_TEST("Test", "test", 0); - COUNT_TEST("Test", "TEST", 0); - COUNT_TEST("TEST", "TEST", 1); - COUNT_TEST("Test", "Test", 1); - COUNT_TEST("aTest", "Test", 1); - COUNT_TEST("Testa", "Test", 1); - COUNT_TEST("TestTestTest", "Test", 3); - COUNT_TEST("TestTestTest", "TestTest", 1); - COUNT_TEST("TestGodotTestGodotTestGodot", "Test", 3); - - COUNTR_TEST("TestTestTestTest", "Test", 4, 8, 1); - COUNTR_TEST("TestTestTestTest", "Test", 4, 12, 2); - COUNTR_TEST("TestTestTestTest", "Test", 4, 16, 3); - COUNTR_TEST("TestTestTestTest", "Test", 4, 0, 3); - - COUNTN_TEST("Test", "test", 1); - COUNTN_TEST("Test", "TEST", 1); - COUNTN_TEST("testTest-Testatest", "tEst", 4); - COUNTNR_TEST("testTest-TeStatest", "tEsT", 4, 16, 2); - - CHECK(state); - -#undef COUNT_TEST -#undef COUNTR_TEST -#undef COUNTN_TEST -#undef COUNTNR_TEST -} - -TEST_CASE("[GDNative String] Bigrams") { - godot_string s, t; - godot_string_new_with_latin1_chars(&s, "abcd"); - godot_packed_string_array bigr = godot_string_bigrams(&s); - godot_string_destroy(&s); - - CHECK(godot_packed_string_array_size(&bigr) == 3); - - t = godot_packed_string_array_get(&bigr, 0); - CHECK(u32scmp(godot_string_get_data(&t), U"ab") == 0); - godot_string_destroy(&t); - - t = godot_packed_string_array_get(&bigr, 1); - CHECK(u32scmp(godot_string_get_data(&t), U"bc") == 0); - godot_string_destroy(&t); - - t = godot_packed_string_array_get(&bigr, 2); - CHECK(u32scmp(godot_string_get_data(&t), U"cd") == 0); - godot_string_destroy(&t); - - godot_packed_string_array_destroy(&bigr); -} - -TEST_CASE("[GDNative String] c-escape/unescape") { - godot_string s; - godot_string_new_with_latin1_chars(&s, "\\1\a2\b\f3\n45\r6\t7\v8\'9\?0\""); - godot_string t = godot_string_c_escape(&s); - godot_string u = godot_string_c_unescape(&t); - CHECK(u32scmp(godot_string_get_data(&u), godot_string_get_data(&s)) == 0); - godot_string_destroy(&u); - godot_string_destroy(&t); - godot_string_destroy(&s); -} - -TEST_CASE("[GDNative String] dedent") { - godot_string s, t; - godot_string_new_with_latin1_chars(&s, " aaa\n bbb"); - godot_string_new_with_latin1_chars(&t, "aaa\nbbb"); - godot_string u = godot_string_dedent(&s); - CHECK(u32scmp(godot_string_get_data(&u), godot_string_get_data(&t)) == 0); - godot_string_destroy(&u); - godot_string_destroy(&t); - godot_string_destroy(&s); -} - -TEST_CASE("[GDNative String] Path functions") { - static const char *path[4] = { "C:\\Godot\\project\\test.tscn", "/Godot/project/test.xscn", "../Godot/project/test.scn", "Godot\\test.doc" }; - static const char *base_dir[4] = { "C:\\Godot\\project", "/Godot/project", "../Godot/project", "Godot" }; - static const char *base_name[4] = { "C:\\Godot\\project\\test", "/Godot/project/test", "../Godot/project/test", "Godot\\test" }; - static const char *ext[4] = { "tscn", "xscn", "scn", "doc" }; - static const char *file[4] = { "test.tscn", "test.xscn", "test.scn", "test.doc" }; - static const bool abs[4] = { true, true, false, false }; - - for (int i = 0; i < 4; i++) { - godot_string s, t, u, f; - godot_string_new_with_latin1_chars(&s, path[i]); - - t = godot_string_get_base_dir(&s); - godot_string_new_with_latin1_chars(&u, base_dir[i]); - CHECK(u32scmp(godot_string_get_data(&u), godot_string_get_data(&t)) == 0); - godot_string_destroy(&u); - godot_string_destroy(&t); - - t = godot_string_get_basename(&s); - godot_string_new_with_latin1_chars(&u, base_name[i]); - CHECK(u32scmp(godot_string_get_data(&u), godot_string_get_data(&t)) == 0); - godot_string_destroy(&u); - godot_string_destroy(&t); - - t = godot_string_get_extension(&s); - godot_string_new_with_latin1_chars(&u, ext[i]); - CHECK(u32scmp(godot_string_get_data(&u), godot_string_get_data(&t)) == 0); - godot_string_destroy(&u); - godot_string_destroy(&t); - - t = godot_string_get_file(&s); - godot_string_new_with_latin1_chars(&u, file[i]); - CHECK(u32scmp(godot_string_get_data(&u), godot_string_get_data(&t)) == 0); - godot_string_destroy(&u); - godot_string_destroy(&t); - - godot_string s_simp; - s_simp = godot_string_simplify_path(&s); - t = godot_string_get_base_dir(&s_simp); - godot_string_new_with_latin1_chars(&u, file[i]); - f = godot_string_plus_file(&t, &u); - CHECK(u32scmp(godot_string_get_data(&f), godot_string_get_data(&s_simp)) == 0); - godot_string_destroy(&f); - godot_string_destroy(&u); - godot_string_destroy(&t); - godot_string_destroy(&s_simp); - - CHECK(godot_string_is_abs_path(&s) == abs[i]); - CHECK(godot_string_is_rel_path(&s) != abs[i]); - - godot_string_destroy(&s); - } - - static const char *file_name[3] = { "test.tscn", "test://.xscn", "?tes*t.scn" }; - static const bool valid[3] = { true, false, false }; - for (int i = 0; i < 3; i++) { - godot_string s; - godot_string_new_with_latin1_chars(&s, file_name[i]); - CHECK(godot_string_is_valid_filename(&s) == valid[i]); - godot_string_destroy(&s); - } -} - -TEST_CASE("[GDNative String] hash") { - godot_string a, b, c; - godot_string_new_with_latin1_chars(&a, "Test"); - godot_string_new_with_latin1_chars(&b, "Test"); - godot_string_new_with_latin1_chars(&c, "West"); - CHECK(godot_string_hash(&a) == godot_string_hash(&b)); - CHECK(godot_string_hash(&a) != godot_string_hash(&c)); - - CHECK(godot_string_hash64(&a) == godot_string_hash64(&b)); - CHECK(godot_string_hash64(&a) != godot_string_hash64(&c)); - - godot_string_destroy(&a); - godot_string_destroy(&b); - godot_string_destroy(&c); -} - -TEST_CASE("[GDNative String] http_escape/unescape") { - godot_string s, t, u; - godot_string_new_with_latin1_chars(&s, "Godot Engine:'docs'"); - godot_string_new_with_latin1_chars(&t, "Godot%20Engine%3A%27docs%27"); - - u = godot_string_http_escape(&s); - CHECK(u32scmp(godot_string_get_data(&u), godot_string_get_data(&t)) == 0); - godot_string_destroy(&u); - - u = godot_string_http_unescape(&t); - CHECK(u32scmp(godot_string_get_data(&u), godot_string_get_data(&s)) == 0); - godot_string_destroy(&u); - - godot_string_destroy(&s); - godot_string_destroy(&t); -} - -TEST_CASE("[GDNative String] percent_encode/decode") { - godot_string s, t, u; - godot_string_new_with_latin1_chars(&s, "Godot Engine:'docs'"); - godot_string_new_with_latin1_chars(&t, "Godot%20Engine%3a%27docs%27"); - - u = godot_string_percent_encode(&s); - CHECK(u32scmp(godot_string_get_data(&u), godot_string_get_data(&t)) == 0); - godot_string_destroy(&u); - - u = godot_string_percent_decode(&t); - CHECK(u32scmp(godot_string_get_data(&u), godot_string_get_data(&s)) == 0); - godot_string_destroy(&u); - - godot_string_destroy(&s); - godot_string_destroy(&t); -} - -TEST_CASE("[GDNative String] xml_escape/unescape") { - godot_string s, t, u; - godot_string_new_with_latin1_chars(&s, "\"Test\" <test@test&'test'>"); - - t = godot_string_xml_escape_with_quotes(&s); - u = godot_string_xml_unescape(&t); - CHECK(u32scmp(godot_string_get_data(&u), godot_string_get_data(&s)) == 0); - godot_string_destroy(&u); - godot_string_destroy(&t); - - t = godot_string_xml_escape(&s); - u = godot_string_xml_unescape(&t); - CHECK(u32scmp(godot_string_get_data(&u), godot_string_get_data(&s)) == 0); - godot_string_destroy(&u); - godot_string_destroy(&t); - - godot_string_destroy(&s); -} - -TEST_CASE("[GDNative String] Strip escapes") { - godot_string s, t, u; - godot_string_new_with_latin1_chars(&s, "\t\tTest Test\r\n Test"); - godot_string_new_with_latin1_chars(&t, "Test Test Test"); - - u = godot_string_strip_escapes(&s); - CHECK(u32scmp(godot_string_get_data(&u), godot_string_get_data(&t)) == 0); - godot_string_destroy(&u); - - godot_string_destroy(&t); - godot_string_destroy(&s); -} - -TEST_CASE("[GDNative String] Strip edges") { - godot_string s, t, u; - godot_string_new_with_latin1_chars(&s, "\t Test Test "); - - godot_string_new_with_latin1_chars(&t, "Test Test "); - u = godot_string_strip_edges(&s, true, false); - CHECK(u32scmp(godot_string_get_data(&u), godot_string_get_data(&t)) == 0); - godot_string_destroy(&u); - godot_string_destroy(&t); - - godot_string_new_with_latin1_chars(&t, "\t Test Test"); - u = godot_string_strip_edges(&s, false, true); - CHECK(u32scmp(godot_string_get_data(&u), godot_string_get_data(&t)) == 0); - godot_string_destroy(&u); - godot_string_destroy(&t); - - godot_string_new_with_latin1_chars(&t, "Test Test"); - u = godot_string_strip_edges(&s, true, true); - CHECK(u32scmp(godot_string_get_data(&u), godot_string_get_data(&t)) == 0); - godot_string_destroy(&u); - godot_string_destroy(&t); - - godot_string_destroy(&s); -} - -TEST_CASE("[GDNative String] Similarity") { - godot_string a, b, c; - godot_string_new_with_latin1_chars(&a, "Test"); - godot_string_new_with_latin1_chars(&b, "West"); - godot_string_new_with_latin1_chars(&c, "Toad"); - - CHECK(godot_string_similarity(&a, &b) > godot_string_similarity(&a, &c)); - - godot_string_destroy(&a); - godot_string_destroy(&b); - godot_string_destroy(&c); -} - -TEST_CASE("[GDNative String] Trim") { - godot_string s, t, u, p; - godot_string_new_with_latin1_chars(&s, "aaaTestbbb"); - - godot_string_new_with_latin1_chars(&p, "aaa"); - godot_string_new_with_latin1_chars(&t, "Testbbb"); - u = godot_string_trim_prefix(&s, &p); - CHECK(u32scmp(godot_string_get_data(&u), godot_string_get_data(&t)) == 0); - godot_string_destroy(&u); - godot_string_destroy(&t); - godot_string_destroy(&p); - - godot_string_new_with_latin1_chars(&p, "bbb"); - godot_string_new_with_latin1_chars(&t, "aaaTest"); - u = godot_string_trim_suffix(&s, &p); - CHECK(u32scmp(godot_string_get_data(&u), godot_string_get_data(&t)) == 0); - godot_string_destroy(&u); - godot_string_destroy(&t); - godot_string_destroy(&p); - - godot_string_new_with_latin1_chars(&p, "Test"); - u = godot_string_trim_suffix(&s, &p); - CHECK(u32scmp(godot_string_get_data(&u), godot_string_get_data(&s)) == 0); - godot_string_destroy(&u); - godot_string_destroy(&p); - - godot_string_destroy(&s); -} - -TEST_CASE("[GDNative String] Right/Left") { - godot_string s, t, u; - godot_string_new_with_latin1_chars(&s, "aaaTestbbb"); - // ^ - - godot_string_new_with_latin1_chars(&t, "tbbb"); - u = godot_string_right(&s, 6); - CHECK(u32scmp(godot_string_get_data(&u), godot_string_get_data(&t)) == 0); - godot_string_destroy(&u); - godot_string_destroy(&t); - - godot_string_new_with_latin1_chars(&t, "aaaTes"); - u = godot_string_left(&s, 6); - CHECK(u32scmp(godot_string_get_data(&u), godot_string_get_data(&t)) == 0); - godot_string_destroy(&u); - godot_string_destroy(&t); - - godot_string_destroy(&s); -} - -TEST_CASE("[GDNative String] Repeat") { - godot_string t, u; - godot_string_new_with_latin1_chars(&t, "ab"); - - u = godot_string_repeat(&t, 4); - CHECK(u32scmp(godot_string_get_data(&u), U"abababab") == 0); - godot_string_destroy(&u); - - godot_string_destroy(&t); -} - -TEST_CASE("[GDNative String] SHA1/SHA256/MD5") { - godot_string s, t, sha1, sha256, md5; - godot_string_new_with_latin1_chars(&s, "Godot"); - godot_string_new_with_latin1_chars(&sha1, "a1e91f39b9fce6a9998b14bdbe2aa2b39dc2d201"); - static uint8_t sha1_buf[20] = { - 0xA1, 0xE9, 0x1F, 0x39, 0xB9, 0xFC, 0xE6, 0xA9, 0x99, 0x8B, 0x14, 0xBD, 0xBE, 0x2A, 0xA2, 0xB3, - 0x9D, 0xC2, 0xD2, 0x01 - }; - godot_string_new_with_latin1_chars(&sha256, "2a02b2443f7985d89d09001086ae3dcfa6eb0f55c6ef170715d42328e16e6cb8"); - static uint8_t sha256_buf[32] = { - 0x2A, 0x02, 0xB2, 0x44, 0x3F, 0x79, 0x85, 0xD8, 0x9D, 0x09, 0x00, 0x10, 0x86, 0xAE, 0x3D, 0xCF, - 0xA6, 0xEB, 0x0F, 0x55, 0xC6, 0xEF, 0x17, 0x07, 0x15, 0xD4, 0x23, 0x28, 0xE1, 0x6E, 0x6C, 0xB8 - }; - godot_string_new_with_latin1_chars(&md5, "4a336d087aeb0390da10ee2ea7cb87f8"); - static uint8_t md5_buf[16] = { - 0x4A, 0x33, 0x6D, 0x08, 0x7A, 0xEB, 0x03, 0x90, 0xDA, 0x10, 0xEE, 0x2E, 0xA7, 0xCB, 0x87, 0xF8 - }; - - godot_packed_byte_array buf = godot_string_sha1_buffer(&s); - CHECK(memcmp(sha1_buf, godot_packed_byte_array_ptr(&buf), 20) == 0); - godot_packed_byte_array_destroy(&buf); - - t = godot_string_sha1_text(&s); - CHECK(u32scmp(godot_string_get_data(&t), godot_string_get_data(&sha1)) == 0); - godot_string_destroy(&t); - - buf = godot_string_sha256_buffer(&s); - CHECK(memcmp(sha256_buf, godot_packed_byte_array_ptr(&buf), 32) == 0); - godot_packed_byte_array_destroy(&buf); - - t = godot_string_sha256_text(&s); - CHECK(u32scmp(godot_string_get_data(&t), godot_string_get_data(&sha256)) == 0); - godot_string_destroy(&t); - - buf = godot_string_md5_buffer(&s); - CHECK(memcmp(md5_buf, godot_packed_byte_array_ptr(&buf), 16) == 0); - godot_packed_byte_array_destroy(&buf); - - t = godot_string_md5_text(&s); - CHECK(u32scmp(godot_string_get_data(&t), godot_string_get_data(&md5)) == 0); - godot_string_destroy(&t); - - godot_string_destroy(&s); - godot_string_destroy(&sha1); - godot_string_destroy(&sha256); - godot_string_destroy(&md5); -} - -TEST_CASE("[GDNative String] Join") { - godot_string s, t, u; - godot_string_new_with_latin1_chars(&s, ", "); - - godot_packed_string_array parts; - godot_packed_string_array_new(&parts); - godot_string_new_with_latin1_chars(&t, "One"); - godot_packed_string_array_push_back(&parts, &t); - godot_string_destroy(&t); - godot_string_new_with_latin1_chars(&t, "B"); - godot_packed_string_array_push_back(&parts, &t); - godot_string_destroy(&t); - godot_string_new_with_latin1_chars(&t, "C"); - godot_packed_string_array_push_back(&parts, &t); - godot_string_destroy(&t); - - godot_string_new_with_latin1_chars(&u, "One, B, C"); - t = godot_string_join(&s, &parts); - CHECK(u32scmp(godot_string_get_data(&u), godot_string_get_data(&t)) == 0); - godot_string_destroy(&u); - godot_string_destroy(&t); - - godot_string_destroy(&s); - godot_packed_string_array_destroy(&parts); -} - -TEST_CASE("[GDNative String] Is_*") { - static const char *data[12] = { "-30", "100", "10.1", "10,1", "1e2", "1e-2", "1e2e3", "0xAB", "AB", "Test1", "1Test", "Test*1" }; - static bool isnum[12] = { true, true, true, false, false, false, false, false, false, false, false, false }; - static bool isint[12] = { true, true, false, false, false, false, false, false, false, false, false, false }; - static bool ishex[12] = { true, true, false, false, true, false, true, false, true, false, false, false }; - static bool ishex_p[12] = { false, false, false, false, false, false, false, true, false, false, false, false }; - static bool isflt[12] = { true, true, true, false, true, true, false, false, false, false, false, false }; - static bool isid[12] = { false, false, false, false, false, false, false, false, true, true, false, false }; - - for (int i = 0; i < 12; i++) { - godot_string s; - godot_string_new_with_latin1_chars(&s, data[i]); - CHECK(godot_string_is_numeric(&s) == isnum[i]); - CHECK(godot_string_is_valid_integer(&s) == isint[i]); - CHECK(godot_string_is_valid_hex_number(&s, false) == ishex[i]); - CHECK(godot_string_is_valid_hex_number(&s, true) == ishex_p[i]); - CHECK(godot_string_is_valid_float(&s) == isflt[i]); - CHECK(godot_string_is_valid_identifier(&s) == isid[i]); - godot_string_destroy(&s); - } -} - -TEST_CASE("[GDNative String] humanize_size") { - godot_string s; - - s = godot_string_humanize_size(1000); - CHECK(u32scmp(godot_string_get_data(&s), U"1000 B") == 0); - godot_string_destroy(&s); - - s = godot_string_humanize_size(1025); - CHECK(u32scmp(godot_string_get_data(&s), U"1.00 KiB") == 0); - godot_string_destroy(&s); - - s = godot_string_humanize_size(1025300); - CHECK(u32scmp(godot_string_get_data(&s), U"1001.2 KiB") == 0); - godot_string_destroy(&s); - - s = godot_string_humanize_size(100523550); - CHECK(u32scmp(godot_string_get_data(&s), U"95.86 MiB") == 0); - godot_string_destroy(&s); - - s = godot_string_humanize_size(5345555000); - CHECK(u32scmp(godot_string_get_data(&s), U"4.97 GiB") == 0); - godot_string_destroy(&s); -} -} // namespace TestGDNativeString - -#endif // TEST_GDNATIVE_STRING_H diff --git a/modules/gdnative/tests/test_variant.h b/modules/gdnative/tests/test_variant.h new file mode 100644 index 0000000000..aeceb6e68f --- /dev/null +++ b/modules/gdnative/tests/test_variant.h @@ -0,0 +1,205 @@ +/*************************************************************************/ +/* test_variant.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 TEST_GDNATIVE_VARIANT_H +#define TEST_GDNATIVE_VARIANT_H + +#include <gdnative/gdnative.h> +#include <gdnative/variant.h> + +#include "tests/test_macros.h" + +namespace TestGDNativeVariant { + +TEST_CASE("[GDNative Variant] New Variant with copy") { + godot_variant src; + godot_variant_new_int(&src, 42); + + godot_variant copy; + godot_variant_new_copy(©, &src); + + CHECK(godot_variant_as_int(©) == 42); + CHECK(godot_variant_get_type(©) == GODOT_VARIANT_TYPE_INT); + + godot_variant_destroy(&src); + godot_variant_destroy(©); +} + +TEST_CASE("[GDNative Variant] New Variant with Nil") { + godot_variant val; + godot_variant_new_nil(&val); + + CHECK(godot_variant_get_type(&val) == GODOT_VARIANT_TYPE_NIL); + + godot_variant_destroy(&val); +} + +TEST_CASE("[GDNative Variant] New Variant with bool") { + godot_variant val; + godot_variant_new_bool(&val, true); + + CHECK(godot_variant_as_bool(&val)); + CHECK(godot_variant_get_type(&val) == GODOT_VARIANT_TYPE_BOOL); + + godot_variant_destroy(&val); +} + +TEST_CASE("[GDNative Variant] New Variant with float") { + godot_variant val; + godot_variant_new_float(&val, 4.2); + + CHECK(godot_variant_as_float(&val) == 4.2); + CHECK(godot_variant_get_type(&val) == GODOT_VARIANT_TYPE_FLOAT); + + godot_variant_destroy(&val); +} + +TEST_CASE("[GDNative Variant] New Variant with String") { + String str = "something"; + + godot_variant val; + godot_variant_new_string(&val, (godot_string *)&str); + godot_string gd_str = godot_variant_as_string(&val); + String *result = (String *)&gd_str; + + CHECK(*result == String("something")); + CHECK(godot_variant_get_type(&val) == GODOT_VARIANT_TYPE_STRING); + + godot_variant_destroy(&val); + godot_string_destroy(&gd_str); +} + +TEST_CASE("[GDNative Variant] Variant call") { + String str("something"); + godot_variant self; + godot_variant_new_string(&self, (godot_string *)&str); + + godot_variant ret; + + godot_string_name method; + godot_string_name_new_with_latin1_chars(&method, "is_valid_identifier"); + + godot_variant_call_error error; + godot_variant_call(&self, &method, NULL, 0, &ret, &error); + + CHECK(godot_variant_get_type(&ret) == GODOT_VARIANT_TYPE_BOOL); + CHECK(godot_variant_as_bool(&ret)); + + godot_variant_destroy(&ret); + godot_variant_destroy(&self); + godot_string_name_destroy(&method); +} + +TEST_CASE("[GDNative Variant] Variant evaluate") { + godot_variant one; + godot_variant_new_int(&one, 1); + godot_variant two; + godot_variant_new_int(&two, 2); + + godot_variant three; + godot_variant_new_nil(&three); + bool valid = false; + + godot_variant_evaluate(GODOT_VARIANT_OP_ADD, &one, &two, &three, &valid); + + CHECK(godot_variant_get_type(&three) == GODOT_VARIANT_TYPE_INT); + CHECK(godot_variant_as_int(&three) == 3); + CHECK(valid); + + godot_variant_destroy(&one); + godot_variant_destroy(&two); + godot_variant_destroy(&three); +} + +TEST_CASE("[GDNative Variant] Variant set/get named") { + godot_string_name x; + godot_string_name_new_with_latin1_chars(&x, "x"); + + Vector2 vec(0, 0); + godot_variant self; + godot_variant_new_vector2(&self, (godot_vector2 *)&vec); + + godot_variant set; + godot_variant_new_float(&set, 1.0); + + bool set_valid = false; + godot_variant_set_named(&self, &x, &set, &set_valid); + + bool get_valid = false; + godot_variant get = godot_variant_get_named(&self, &x, &get_valid); + + CHECK(get_valid); + CHECK(set_valid); + CHECK(godot_variant_get_type(&get) == GODOT_VARIANT_TYPE_FLOAT); + CHECK(godot_variant_as_float(&get) == 1.0); + + godot_string_name_destroy(&x); + godot_variant_destroy(&self); + godot_variant_destroy(&set); + godot_variant_destroy(&get); +} + +TEST_CASE("[GDNative Variant] Get utility function argument name") { + godot_string_name function; + godot_string_name_new_with_latin1_chars(&function, "pow"); + + godot_string arg_name = godot_variant_get_utility_function_argument_name(&function, 0); + + String *arg_name_str = (String *)&arg_name; + + CHECK(*arg_name_str == "base"); + + godot_string_destroy(&arg_name); + godot_string_name_destroy(&function); +} + +TEST_CASE("[GDNative Variant] Get utility function list") { + int count = godot_variant_get_utility_function_count(); + + godot_string_name *c_list = (godot_string_name *)godot_alloc(count * sizeof(godot_string_name)); + godot_variant_get_utility_function_list(c_list); + + List<StringName> cpp_list; + Variant::get_utility_function_list(&cpp_list); + + godot_string_name *cur = c_list; + + for (const List<StringName>::Element *E = cpp_list.front(); E; E = E->next()) { + const StringName &cpp_name = E->get(); + StringName *c_name = (StringName *)cur++; + + CHECK(*c_name == cpp_name); + } + + godot_free(c_list); +} +} // namespace TestGDNativeVariant + +#endif // TEST_GDNATIVE_VARIANT_H diff --git a/modules/gdnative/text/register_types.cpp b/modules/gdnative/text/register_types.cpp index e1d4547aa0..67385d2fbf 100644 --- a/modules/gdnative/text/register_types.cpp +++ b/modules/gdnative/text/register_types.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gdnative/text/register_types.h b/modules/gdnative/text/register_types.h index 027653e58e..cd4f2a3089 100644 --- a/modules/gdnative/text/register_types.h +++ b/modules/gdnative/text/register_types.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gdnative/text/text_server_gdnative.cpp b/modules/gdnative/text/text_server_gdnative.cpp index cb87adafe8..7584568dd8 100644 --- a/modules/gdnative/text/text_server_gdnative.cpp +++ b/modules/gdnative/text/text_server_gdnative.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -138,6 +138,26 @@ float TextServerGDNative::font_get_underline_thickness(RID p_font, int p_size) c return interface->font_get_underline_thickness(data, (godot_rid *)&p_font, p_size); } +int TextServerGDNative::font_get_spacing_space(RID p_font) const { + ERR_FAIL_COND_V(interface == nullptr, 0); + return interface->font_get_spacing_space(data, (godot_rid *)&p_font); +} + +void TextServerGDNative::font_set_spacing_space(RID p_font, int p_value) { + ERR_FAIL_COND(interface == nullptr); + interface->font_set_spacing_space(data, (godot_rid *)&p_font, p_value); +} + +int TextServerGDNative::font_get_spacing_glyph(RID p_font) const { + ERR_FAIL_COND_V(interface == nullptr, 0); + return interface->font_get_spacing_glyph(data, (godot_rid *)&p_font); +} + +void TextServerGDNative::font_set_spacing_glyph(RID p_font, int p_value) { + ERR_FAIL_COND(interface == nullptr); + interface->font_set_spacing_glyph(data, (godot_rid *)&p_font, p_value); +} + void TextServerGDNative::font_set_antialiased(RID p_font, bool p_antialiased) { ERR_FAIL_COND(interface == nullptr); interface->font_set_antialiased(data, (godot_rid *)&p_font, p_antialiased); @@ -703,12 +723,12 @@ void GDAPI godot_glyph_set_offset(godot_glyph *p_self, const godot_vector2 *p_of self->y_off = offset->y; } -godot_real GDAPI godot_glyph_get_advance(const godot_glyph *p_self) { +godot_float GDAPI godot_glyph_get_advance(const godot_glyph *p_self) { const TextServer::Glyph *self = (const TextServer::Glyph *)p_self; return self->advance; } -void GDAPI godot_glyph_set_advance(godot_glyph *p_self, godot_real p_advance) { +void GDAPI godot_glyph_set_advance(godot_glyph *p_self, godot_float p_advance) { TextServer::Glyph *self = (TextServer::Glyph *)p_self; self->advance = p_advance; } @@ -839,9 +859,9 @@ godot_int GDAPI godot_packed_glyph_array_size(const godot_packed_glyph_array *p_ return self->size(); } -godot_bool GDAPI godot_packed_glyph_array_empty(const godot_packed_glyph_array *p_self) { +godot_bool GDAPI godot_packed_glyph_array_is_empty(const godot_packed_glyph_array *p_self) { const Vector<TextServer::Glyph> *self = (const Vector<TextServer::Glyph> *)p_self; - return self->empty(); + return self->is_empty(); } void GDAPI godot_packed_glyph_array_destroy(godot_packed_glyph_array *p_self) { diff --git a/modules/gdnative/text/text_server_gdnative.h b/modules/gdnative/text/text_server_gdnative.h index 959302aaf4..9783b65431 100644 --- a/modules/gdnative/text/text_server_gdnative.h +++ b/modules/gdnative/text/text_server_gdnative.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -72,6 +72,12 @@ public: virtual float font_get_underline_position(RID p_font, int p_size) const override; virtual float font_get_underline_thickness(RID p_font, int p_size) const override; + virtual int font_get_spacing_space(RID p_font) const override; + virtual void font_set_spacing_space(RID p_font, int p_value) override; + + virtual int font_get_spacing_glyph(RID p_font) const override; + virtual void font_set_spacing_glyph(RID p_font, int p_value) override; + virtual void font_set_antialiased(RID p_font, bool p_antialiased) override; virtual bool font_get_antialiased(RID p_font) const override; diff --git a/modules/gdnative/videodecoder/register_types.cpp b/modules/gdnative/videodecoder/register_types.cpp index 8ee1c8d183..394831daeb 100644 --- a/modules/gdnative/videodecoder/register_types.cpp +++ b/modules/gdnative/videodecoder/register_types.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gdnative/videodecoder/register_types.h b/modules/gdnative/videodecoder/register_types.h index b1a83d4071..809225c925 100644 --- a/modules/gdnative/videodecoder/register_types.h +++ b/modules/gdnative/videodecoder/register_types.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gdnative/videodecoder/video_stream_gdnative.cpp b/modules/gdnative/videodecoder/video_stream_gdnative.cpp index 61e882f2fe..f2fb0a2fdc 100644 --- a/modules/gdnative/videodecoder/video_stream_gdnative.cpp +++ b/modules/gdnative/videodecoder/video_stream_gdnative.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -250,7 +250,7 @@ void VideoStreamPlaybackGDNative::play() { playing = true; - delay_compensation = ProjectSettings::get_singleton()->get("audio/video_delay_compensation_ms"); + delay_compensation = ProjectSettings::get_singleton()->get("audio/video/video_delay_compensation_ms"); delay_compensation /= 1000.0; } @@ -360,7 +360,7 @@ void VideoStreamGDNative::set_audio_track(int p_track) { /* --- NOTE ResourceFormatLoaderVideoStreamGDNative starts here. ----- */ -RES ResourceFormatLoaderVideoStreamGDNative::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, bool p_no_cache) { +RES ResourceFormatLoaderVideoStreamGDNative::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, CacheMode p_cache_mode) { FileAccess *f = FileAccess::open(p_path, FileAccess::READ); if (!f) { if (r_error) { diff --git a/modules/gdnative/videodecoder/video_stream_gdnative.h b/modules/gdnative/videodecoder/video_stream_gdnative.h index 408d4a2454..140888cd4b 100644 --- a/modules/gdnative/videodecoder/video_stream_gdnative.h +++ b/modules/gdnative/videodecoder/video_stream_gdnative.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -118,7 +118,7 @@ class VideoStreamPlaybackGDNative : public VideoStreamPlayback { AudioMixCallback mix_callback = nullptr; int num_channels = -1; - float time = 0; + float time = 0.0; bool seek_backward = false; int mix_rate = 0; double delay_compensation = 0; @@ -196,7 +196,7 @@ public: class ResourceFormatLoaderVideoStreamGDNative : public ResourceFormatLoader { public: - virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr, bool p_no_cache = false); + virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr, CacheMode p_cache_mode = CACHE_MODE_REUSE); virtual void get_recognized_extensions(List<String> *p_extensions) const; virtual bool handles_type(const String &p_type) const; virtual String get_resource_type(const String &p_path) const; diff --git a/modules/gdnative/xr/register_types.cpp b/modules/gdnative/xr/register_types.cpp index da3a7dc4b8..b60a04f470 100644 --- a/modules/gdnative/xr/register_types.cpp +++ b/modules/gdnative/xr/register_types.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gdnative/xr/register_types.h b/modules/gdnative/xr/register_types.h index 2501d28651..4e7469abe9 100644 --- a/modules/gdnative/xr/register_types.h +++ b/modules/gdnative/xr/register_types.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gdnative/xr/xr_interface_gdnative.cpp b/modules/gdnative/xr/xr_interface_gdnative.cpp index d1d575db62..5bbf70174c 100644 --- a/modules/gdnative/xr/xr_interface_gdnative.cpp +++ b/modules/gdnative/xr/xr_interface_gdnative.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -190,7 +190,7 @@ CameraMatrix XRInterfaceGDNative::get_projection_for_eye(XRInterface::Eyes p_eye ERR_FAIL_COND_V(interface == nullptr, CameraMatrix()); - interface->fill_projection_for_eye(data, (godot_real *)cm.matrix, (godot_int)p_eye, p_aspect, p_z_near, p_z_far); + interface->fill_projection_for_eye(data, (godot_float *)cm.matrix, (godot_int)p_eye, p_aspect, p_z_near, p_z_far); return cm; } @@ -234,7 +234,7 @@ void GDAPI godot_xr_register_interface(const godot_xr_interface_gdnative *p_inte XRServer::get_singleton()->add_interface(new_interface); } -godot_real GDAPI godot_xr_get_worldscale() { +godot_float GDAPI godot_xr_get_worldscale() { XRServer *xr_server = XRServer::get_singleton(); ERR_FAIL_NULL_V(xr_server, 1.0); @@ -249,7 +249,7 @@ godot_transform GDAPI godot_xr_get_reference_frame() { if (xr_server != nullptr) { *reference_frame_ptr = xr_server->get_reference_frame(); } else { - godot_transform_new_identity(&reference_frame); + memnew_placement(&reference_frame, Transform); } return reference_frame; @@ -387,7 +387,7 @@ void GDAPI godot_xr_set_controller_button(godot_int p_controller_id, godot_int p } } -void GDAPI godot_xr_set_controller_axis(godot_int p_controller_id, godot_int p_axis, godot_real p_value, godot_bool p_can_be_negative) { +void GDAPI godot_xr_set_controller_axis(godot_int p_controller_id, godot_int p_axis, godot_float p_value, godot_bool p_can_be_negative) { XRServer *xr_server = XRServer::get_singleton(); ERR_FAIL_NULL(xr_server); @@ -406,7 +406,7 @@ void GDAPI godot_xr_set_controller_axis(godot_int p_controller_id, godot_int p_a } } -godot_real GDAPI godot_xr_get_controller_rumble(godot_int p_controller_id) { +godot_float GDAPI godot_xr_get_controller_rumble(godot_int p_controller_id) { XRServer *xr_server = XRServer::get_singleton(); ERR_FAIL_NULL_V(xr_server, 0.0); diff --git a/modules/gdnative/xr/xr_interface_gdnative.h b/modules/gdnative/xr/xr_interface_gdnative.h index de96487397..84bd8fc731 100644 --- a/modules/gdnative/xr/xr_interface_gdnative.h +++ b/modules/gdnative/xr/xr_interface_gdnative.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gdnavigation/gd_navigation_server.cpp b/modules/gdnavigation/gd_navigation_server.cpp index c80cdcfeab..4f61ad5040 100644 --- a/modules/gdnavigation/gd_navigation_server.cpp +++ b/modules/gdnavigation/gd_navigation_server.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gdnavigation/gd_navigation_server.h b/modules/gdnavigation/gd_navigation_server.h index c00d60ced7..92f4ccfdd5 100644 --- a/modules/gdnavigation/gd_navigation_server.h +++ b/modules/gdnavigation/gd_navigation_server.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gdnavigation/nav_map.cpp b/modules/gdnavigation/nav_map.cpp index c8c1b422e8..2646a4cc0c 100644 --- a/modules/gdnavigation/nav_map.cpp +++ b/modules/gdnavigation/nav_map.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gdnavigation/nav_map.h b/modules/gdnavigation/nav_map.h index 892755f3f9..bffc1fbc1a 100644 --- a/modules/gdnavigation/nav_map.h +++ b/modules/gdnavigation/nav_map.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gdnavigation/nav_region.cpp b/modules/gdnavigation/nav_region.cpp index 51fba67cc3..383b0f15a6 100644 --- a/modules/gdnavigation/nav_region.cpp +++ b/modules/gdnavigation/nav_region.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gdnavigation/nav_region.h b/modules/gdnavigation/nav_region.h index 731855bfb5..954780033b 100644 --- a/modules/gdnavigation/nav_region.h +++ b/modules/gdnavigation/nav_region.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gdnavigation/nav_rid.h b/modules/gdnavigation/nav_rid.h index b727fceb04..a0a60a3643 100644 --- a/modules/gdnavigation/nav_rid.h +++ b/modules/gdnavigation/nav_rid.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gdnavigation/nav_utils.h b/modules/gdnavigation/nav_utils.h index 40e54df553..d257a95ef1 100644 --- a/modules/gdnavigation/nav_utils.h +++ b/modules/gdnavigation/nav_utils.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -51,7 +51,7 @@ union PointKey { int64_t z : 21; }; - uint64_t key; + uint64_t key = 0; bool operator<(const PointKey &p_key) const { return key < p_key.key; } }; @@ -86,8 +86,6 @@ struct Edge { /// The other `Polygon` at this edge id has this `Polygon`. int other_edge = -1; - - Edge() {} }; struct Polygon { @@ -111,8 +109,6 @@ struct Connection { int A_edge = -1; Polygon *B = nullptr; int B_edge = -1; - - Connection() {} }; struct NavigationPoly { @@ -141,12 +137,12 @@ struct NavigationPoly { }; struct FreeEdge { - bool is_free; - Polygon *poly; - uint32_t edge_id; + bool is_free = false; + Polygon *poly = nullptr; + uint32_t edge_id = 0; Vector3 edge_center; Vector3 edge_dir; - float edge_len_squared; + float edge_len_squared = 0.0; }; } // namespace gd diff --git a/modules/gdnavigation/navigation_mesh_editor_plugin.cpp b/modules/gdnavigation/navigation_mesh_editor_plugin.cpp index 648f4f7cdd..aa9248d2a1 100644 --- a/modules/gdnavigation/navigation_mesh_editor_plugin.cpp +++ b/modules/gdnavigation/navigation_mesh_editor_plugin.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -142,7 +142,7 @@ void NavigationMeshEditorPlugin::make_visible(bool p_visible) { NavigationMeshEditorPlugin::NavigationMeshEditorPlugin(EditorNode *p_node) { editor = p_node; navigation_mesh_editor = memnew(NavigationMeshEditor); - editor->get_viewport()->add_child(navigation_mesh_editor); + editor->get_main_control()->add_child(navigation_mesh_editor); add_control_to_container(CONTAINER_SPATIAL_EDITOR_MENU, navigation_mesh_editor->bake_hbox); navigation_mesh_editor->hide(); navigation_mesh_editor->bake_hbox->hide(); diff --git a/modules/gdnavigation/navigation_mesh_editor_plugin.h b/modules/gdnavigation/navigation_mesh_editor_plugin.h index f09182fff4..c39269865b 100644 --- a/modules/gdnavigation/navigation_mesh_editor_plugin.h +++ b/modules/gdnavigation/navigation_mesh_editor_plugin.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gdnavigation/navigation_mesh_generator.cpp b/modules/gdnavigation/navigation_mesh_generator.cpp index 3310123ca9..a7d4e79148 100644 --- a/modules/gdnavigation/navigation_mesh_generator.cpp +++ b/modules/gdnavigation/navigation_mesh_generator.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -151,7 +151,7 @@ void NavigationMeshGenerator::_parse_geometry(Transform p_accumulated_transform, if (Object::cast_to<CSGShape3D>(p_node) && p_generate_from != NavigationMesh::PARSED_GEOMETRY_STATIC_COLLIDERS) { CSGShape3D *csg_shape = Object::cast_to<CSGShape3D>(p_node); Array meshes = csg_shape->get_meshes(); - if (!meshes.empty()) { + if (!meshes.is_empty()) { Ref<Mesh> mesh = meshes[1]; if (mesh.is_valid()) { _add_mesh(mesh, p_accumulated_transform * csg_shape->get_transform(), p_verticies, p_indices); @@ -178,7 +178,7 @@ void NavigationMeshGenerator::_parse_geometry(Transform p_accumulated_transform, if (box) { Ref<BoxMesh> box_mesh; box_mesh.instance(); - box_mesh->set_size(box->get_extents() * 2.0); + box_mesh->set_size(box->get_size()); mesh = box_mesh; } diff --git a/modules/gdnavigation/navigation_mesh_generator.h b/modules/gdnavigation/navigation_mesh_generator.h index c5f7b2ab81..88ccdb1c41 100644 --- a/modules/gdnavigation/navigation_mesh_generator.h +++ b/modules/gdnavigation/navigation_mesh_generator.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gdnavigation/register_types.cpp b/modules/gdnavigation/register_types.cpp index 1ae19ebe47..8443d3d242 100644 --- a/modules/gdnavigation/register_types.cpp +++ b/modules/gdnavigation/register_types.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gdnavigation/register_types.h b/modules/gdnavigation/register_types.h index cdbff1b937..c2bb08c649 100644 --- a/modules/gdnavigation/register_types.h +++ b/modules/gdnavigation/register_types.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gdnavigation/rvo_agent.cpp b/modules/gdnavigation/rvo_agent.cpp index 1e1bdbd07d..21e43d08c1 100644 --- a/modules/gdnavigation/rvo_agent.cpp +++ b/modules/gdnavigation/rvo_agent.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gdnavigation/rvo_agent.h b/modules/gdnavigation/rvo_agent.h index de36508edb..369cb1f9a3 100644 --- a/modules/gdnavigation/rvo_agent.h +++ b/modules/gdnavigation/rvo_agent.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -53,7 +53,7 @@ class RvoAgent : public NavRid { NavMap *map = nullptr; RVO::Agent agent; AvoidanceComputedCallback callback; - uint32_t map_update_id; + uint32_t map_update_id = 0; public: RvoAgent(); diff --git a/modules/gdscript/doc_classes/@GDScript.xml b/modules/gdscript/doc_classes/@GDScript.xml index 4ed129b3ff..9e974b6fdc 100644 --- a/modules/gdscript/doc_classes/@GDScript.xml +++ b/modules/gdscript/doc_classes/@GDScript.xml @@ -32,59 +32,6 @@ [/codeblock] </description> </method> - <method name="ColorN"> - <return type="Color"> - </return> - <argument index="0" name="name" type="String"> - </argument> - <argument index="1" name="alpha" type="float" default="1.0"> - </argument> - <description> - Returns a color according to the standardized [code]name[/code] with [code]alpha[/code] ranging from 0 to 1. - [codeblock] - red = ColorN("red", 1) - [/codeblock] - Supported color names are the same as the constants defined in [Color]. - </description> - </method> - <method name="abs"> - <return type="float"> - </return> - <argument index="0" name="s" type="float"> - </argument> - <description> - Returns the absolute value of parameter [code]s[/code] (i.e. positive value). - [codeblock] - a = abs(-1) # a is 1 - [/codeblock] - </description> - </method> - <method name="acos"> - <return type="float"> - </return> - <argument index="0" name="s" type="float"> - </argument> - <description> - Returns the arc cosine of [code]s[/code] in radians. Use to get the angle of cosine [code]s[/code]. - [codeblock] - # c is 0.523599 or 30 degrees if converted with rad2deg(s) - c = acos(0.866025) - [/codeblock] - </description> - </method> - <method name="asin"> - <return type="float"> - </return> - <argument index="0" name="s" type="float"> - </argument> - <description> - Returns the arc sine of [code]s[/code] in radians. Use to get the angle of sine [code]s[/code]. - [codeblock] - # s is 0.523599 or 30 degrees if converted with rad2deg(s) - s = asin(0.5) - [/codeblock] - </description> - </method> <method name="assert"> <return type="void"> </return> @@ -93,7 +40,7 @@ <argument index="1" name="message" type="String" default=""""> </argument> <description> - Asserts that the [code]condition[/code] is [code]true[/code]. If the [code]condition[/code] is [code]false[/code], an error is generated. When running from the editor, the running project will also be paused until you resume it. This can be used as a stronger form of [method push_error] for reporting errors to project developers or add-on users. + Asserts that the [code]condition[/code] is [code]true[/code]. If the [code]condition[/code] is [code]false[/code], an error is generated. When running from the editor, the running project will also be paused until you resume it. This can be used as a stronger form of [method @GlobalScope.push_error] for reporting errors to project developers or add-on users. [b]Note:[/b] For performance reasons, the code inside [method assert] is only executed in debug builds or when running the project from the editor. Don't include code that has side effects in an [method assert] call. Otherwise, the project will behave differently when exported in release mode. The optional [code]message[/code] argument, if given, is shown in addition to the generic "Assertion failed" message. You can use this to provide additional details about why the assertion failed. [codeblock] @@ -106,75 +53,10 @@ [/codeblock] </description> </method> - <method name="atan"> - <return type="float"> - </return> - <argument index="0" name="s" type="float"> - </argument> - <description> - Returns the arc tangent of [code]s[/code] in radians. Use it to get the angle from an angle's tangent in trigonometry: [code]atan(tan(angle)) == angle[/code]. - The method cannot know in which quadrant the angle should fall. See [method atan2] if you have both [code]y[/code] and [code]x[/code]. - [codeblock] - a = atan(0.5) # a is 0.463648 - [/codeblock] - </description> - </method> - <method name="atan2"> - <return type="float"> - </return> - <argument index="0" name="y" type="float"> - </argument> - <argument index="1" name="x" type="float"> - </argument> - <description> - Returns the arc tangent of [code]y/x[/code] in radians. Use to get the angle of tangent [code]y/x[/code]. To compute the value, the method takes into account the sign of both arguments in order to determine the quadrant. - Important note: The Y coordinate comes first, by convention. - [codeblock] - a = atan2(0, -1) # a is 3.141593 - [/codeblock] - </description> - </method> - <method name="bytes2var"> - <return type="Variant"> - </return> - <argument index="0" name="bytes" type="PackedByteArray"> - </argument> - <argument index="1" name="allow_objects" type="bool" default="false"> - </argument> - <description> - Decodes a byte array back to a value. When [code]allow_objects[/code] is [code]true[/code] decoding objects is allowed. - [b]WARNING:[/b] Deserialized object can contain code which gets executed. Do not use this option if the serialized object comes from untrusted sources to avoid potential security threats (remote code execution). - </description> - </method> - <method name="cartesian2polar"> - <return type="Vector2"> - </return> - <argument index="0" name="x" type="float"> - </argument> - <argument index="1" name="y" type="float"> - </argument> - <description> - Converts a 2D point expressed in the cartesian coordinate system (X and Y axis) to the polar coordinate system (a distance from the origin and an angle). - </description> - </method> - <method name="ceil"> - <return type="float"> - </return> - <argument index="0" name="s" type="float"> - </argument> - <description> - Rounds [code]s[/code] upward (towards positive infinity), returning the smallest whole number that is not less than [code]s[/code]. - [codeblock] - a = ceil(1.45) # a is 2.0 - a = ceil(1.001) # a is 2.0 - [/codeblock] - See also [method floor], [method round], [method stepify], and [int]. - </description> - </method> <method name="char"> <return type="String"> </return> - <argument index="0" name="code" type="int"> + <argument index="0" name="char" type="int"> </argument> <description> Returns a character as a String of the given Unicode code point (which is compatible with ASCII code). @@ -183,25 +65,6 @@ a = char(65 + 32) # a is "a" a = char(8364) # a is "€" [/codeblock] - This is the inverse of [method ord]. - </description> - </method> - <method name="clamp"> - <return type="float"> - </return> - <argument index="0" name="value" type="float"> - </argument> - <argument index="1" name="min" type="float"> - </argument> - <argument index="2" name="max" type="float"> - </argument> - <description> - Clamps [code]value[/code] and returns a value not less than [code]min[/code] and not more than [code]max[/code]. - [codeblock] - a = clamp(1000, 1, 20) # a is 20 - a = clamp(-10, 1, 20) # a is 1 - a = clamp(15, 1, 20) # a is 15 - [/codeblock] </description> </method> <method name="convert"> @@ -223,159 +86,15 @@ [/codeblock] </description> </method> - <method name="cos"> - <return type="float"> - </return> - <argument index="0" name="s" type="float"> - </argument> - <description> - Returns the cosine of angle [code]s[/code] in radians. - [codeblock] - a = cos(TAU) # a is 1.0 - a = cos(PI) # a is -1.0 - [/codeblock] - </description> - </method> - <method name="cosh"> - <return type="float"> - </return> - <argument index="0" name="s" type="float"> - </argument> - <description> - Returns the hyperbolic cosine of [code]s[/code] in radians. - [codeblock] - print(cosh(1)) # Prints 1.543081 - [/codeblock] - </description> - </method> - <method name="db2linear"> - <return type="float"> - </return> - <argument index="0" name="db" type="float"> - </argument> - <description> - Converts from decibels to linear energy (audio). - </description> - </method> - <method name="dectime"> - <return type="float"> - </return> - <argument index="0" name="value" type="float"> - </argument> - <argument index="1" name="amount" type="float"> - </argument> - <argument index="2" name="step" type="float"> - </argument> - <description> - Returns the result of [code]value[/code] decreased by [code]step[/code] * [code]amount[/code]. - [codeblock] - a = dectime(60, 10, 0.1)) # a is 59.0 - [/codeblock] - </description> - </method> - <method name="deg2rad"> - <return type="float"> - </return> - <argument index="0" name="deg" type="float"> - </argument> - <description> - Converts an angle expressed in degrees to radians. - [codeblock] - r = deg2rad(180) # r is 3.141593 - [/codeblock] - </description> - </method> <method name="dict2inst"> <return type="Object"> </return> - <argument index="0" name="dict" type="Dictionary"> + <argument index="0" name="dictionary" type="Dictionary"> </argument> <description> Converts a dictionary (previously created with [method inst2dict]) back to an instance. Useful for deserializing. </description> </method> - <method name="ease"> - <return type="float"> - </return> - <argument index="0" name="s" type="float"> - </argument> - <argument index="1" name="curve" type="float"> - </argument> - <description> - Easing function, based on exponent. The curve values are: 0 is constant, 1 is linear, 0 to 1 is ease-in, 1+ is ease out. Negative values are in-out/out in. - </description> - </method> - <method name="exp"> - <return type="float"> - </return> - <argument index="0" name="s" type="float"> - </argument> - <description> - The natural exponential function. It raises the mathematical constant [b]e[/b] to the power of [code]s[/code] and returns it. - [b]e[/b] has an approximate value of 2.71828, and can be obtained with [code]exp(1)[/code]. - For exponents to other bases use the method [method pow]. - [codeblock] - a = exp(2) # Approximately 7.39 - [/codeblock] - </description> - </method> - <method name="floor"> - <return type="float"> - </return> - <argument index="0" name="s" type="float"> - </argument> - <description> - Rounds [code]s[/code] downward (towards negative infinity), returning the largest whole number that is not more than [code]s[/code]. - [codeblock] - a = floor(2.45) # a is 2.0 - a = floor(2.99) # a is 2.0 - a = floor(-2.99) # a is -3.0 - [/codeblock] - See also [method ceil], [method round], [method stepify], and [int]. - [b]Note:[/b] This method returns a float. If you need an integer and [code]s[/code] is a non-negative number, you can use [code]int(s)[/code] directly. - </description> - </method> - <method name="fmod"> - <return type="float"> - </return> - <argument index="0" name="a" type="float"> - </argument> - <argument index="1" name="b" type="float"> - </argument> - <description> - Returns the floating-point remainder of [code]a/b[/code], keeping the sign of [code]a[/code]. - [codeblock] - r = fmod(7, 5.5) # r is 1.5 - [/codeblock] - For the integer remainder operation, use the % operator. - </description> - </method> - <method name="fposmod"> - <return type="float"> - </return> - <argument index="0" name="a" type="float"> - </argument> - <argument index="1" name="b" type="float"> - </argument> - <description> - Returns the floating-point modulus of [code]a/b[/code] that wraps equally in positive and negative. - [codeblock] - for i in 7: - var x = 0.5 * i - 1.5 - print("%4.1f %4.1f %4.1f" % [x, fmod(x, 1.5), fposmod(x, 1.5)]) - [/codeblock] - Produces: - [codeblock] - -1.5 -0.0 0.0 - -1.0 -1.0 0.5 - -0.5 -0.5 1.0 - 0.0 0.0 0.0 - 0.5 0.5 0.5 - 1.0 1.0 1.0 - 1.5 0.0 0.0 - [/codeblock] - </description> - </method> <method name="get_stack"> <return type="Array"> </return> @@ -397,22 +116,10 @@ [/codeblock] </description> </method> - <method name="hash"> - <return type="int"> - </return> - <argument index="0" name="var" type="Variant"> - </argument> - <description> - Returns the integer hash of the variable passed. - [codeblock] - print(hash("a")) # Prints 177670 - [/codeblock] - </description> - </method> <method name="inst2dict"> <return type="Dictionary"> </return> - <argument index="0" name="inst" type="Object"> + <argument index="0" name="instance" type="Object"> </argument> <description> Returns the passed instance converted to a dictionary (useful for serializing). @@ -430,92 +137,6 @@ [/codeblock] </description> </method> - <method name="instance_from_id"> - <return type="Object"> - </return> - <argument index="0" name="instance_id" type="int"> - </argument> - <description> - Returns the Object that corresponds to [code]instance_id[/code]. All Objects have a unique instance ID. - [codeblock] - var foo = "bar" - func _ready(): - var id = get_instance_id() - var inst = instance_from_id(id) - print(inst.foo) # Prints bar - [/codeblock] - </description> - </method> - <method name="inverse_lerp"> - <return type="float"> - </return> - <argument index="0" name="from" type="float"> - </argument> - <argument index="1" name="to" type="float"> - </argument> - <argument index="2" name="weight" type="float"> - </argument> - <description> - Returns a normalized value considering the given range. This is the opposite of [method lerp]. - [codeblock] - var middle = lerp(20, 30, 0.75) - # `middle` is now 27.5. - # Now, we pretend to have forgotten the original ratio and want to get it back. - var ratio = inverse_lerp(20, 30, 27.5) - # `ratio` is now 0.75. - [/codeblock] - </description> - </method> - <method name="is_equal_approx"> - <return type="bool"> - </return> - <argument index="0" name="a" type="float"> - </argument> - <argument index="1" name="b" type="float"> - </argument> - <description> - Returns [code]true[/code] if [code]a[/code] and [code]b[/code] are approximately equal to each other. - Here, approximately equal means that [code]a[/code] and [code]b[/code] are within a small internal epsilon of each other, which scales with the magnitude of the numbers. - Infinity values of the same sign are considered equal. - </description> - </method> - <method name="is_inf"> - <return type="bool"> - </return> - <argument index="0" name="s" type="float"> - </argument> - <description> - Returns whether [code]s[/code] is an infinity value (either positive infinity or negative infinity). - </description> - </method> - <method name="is_instance_valid"> - <return type="bool"> - </return> - <argument index="0" name="instance" type="Object"> - </argument> - <description> - Returns whether [code]instance[/code] is a valid object (e.g. has not been deleted from memory). - </description> - </method> - <method name="is_nan"> - <return type="bool"> - </return> - <argument index="0" name="s" type="float"> - </argument> - <description> - Returns whether [code]s[/code] is a NaN ("Not a Number" or invalid) value. - </description> - </method> - <method name="is_zero_approx"> - <return type="bool"> - </return> - <argument index="0" name="s" type="float"> - </argument> - <description> - Returns [code]true[/code] if [code]s[/code] is zero or almost zero. - This method is faster than using [method is_equal_approx] with one value as zero. - </description> - </method> <method name="len"> <return type="int"> </return> @@ -530,63 +151,6 @@ [/codeblock] </description> </method> - <method name="lerp"> - <return type="Variant"> - </return> - <argument index="0" name="from" type="Variant"> - </argument> - <argument index="1" name="to" type="Variant"> - </argument> - <argument index="2" name="weight" type="float"> - </argument> - <description> - Linearly interpolates between two values by a normalized value. This is the opposite of [method inverse_lerp]. - 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]lerp[/code] method). - [codeblock] - lerp(0, 4, 0.75) # Returns 3.0 - lerp(Vector2(1, 5), Vector2(3, 2), 0.5) # Returns Vector2(2, 3.5) - [/codeblock] - </description> - </method> - <method name="lerp_angle"> - <return type="float"> - </return> - <argument index="0" name="from" type="float"> - </argument> - <argument index="1" name="to" type="float"> - </argument> - <argument index="2" name="weight" type="float"> - </argument> - <description> - Linearly interpolates between two angles (in radians) by a normalized value. - Similar to [method lerp], but interpolates correctly when the angles wrap around [constant @GDScript.TAU]. - [codeblock] - extends Sprite - var elapsed = 0.0 - func _process(delta): - var min_angle = deg2rad(0.0) - var max_angle = deg2rad(90.0) - rotation = lerp_angle(min_angle, max_angle, elapsed) - elapsed += delta - [/codeblock] - </description> - </method> - <method name="linear2db"> - <return type="float"> - </return> - <argument index="0" name="nrg" type="float"> - </argument> - <description> - Converts from linear energy to decibels (audio). This can be used to implement volume sliders that behave as expected (since volume isn't linear). Example: - [codeblock] - # "Slider" refers to a node that inherits Range such as HSlider or VSlider. - # Its range must be configured to go from 0 to 1. - # Change the bus name if you'd like to change the volume of a specific bus only. - AudioServer.set_bus_volume_db(AudioServer.get_bus_index("Master"), linear2db($Slider.value)) - [/codeblock] - </description> - </method> <method name="load"> <return type="Resource"> </return> @@ -603,172 +167,6 @@ This method is a simplified version of [method ResourceLoader.load], which can be used for more advanced scenarios. </description> </method> - <method name="log"> - <return type="float"> - </return> - <argument index="0" name="s" type="float"> - </argument> - <description> - Natural logarithm. The amount of time needed to reach a certain level of continuous growth. - [b]Note:[/b] This is not the same as the "log" function on most calculators, which uses a base 10 logarithm. - [codeblock] - log(10) # Returns 2.302585 - [/codeblock] - [b]Note:[/b] The logarithm of [code]0[/code] returns [code]-inf[/code], while negative values return [code]-nan[/code]. - </description> - </method> - <method name="max"> - <return type="float"> - </return> - <argument index="0" name="a" type="float"> - </argument> - <argument index="1" name="b" type="float"> - </argument> - <description> - Returns the maximum of two values. - [codeblock] - max(1, 2) # Returns 2 - max(-3.99, -4) # Returns -3.99 - [/codeblock] - </description> - </method> - <method name="min"> - <return type="float"> - </return> - <argument index="0" name="a" type="float"> - </argument> - <argument index="1" name="b" type="float"> - </argument> - <description> - Returns the minimum of two values. - [codeblock] - min(1, 2) # Returns 1 - min(-3.99, -4) # Returns -4 - [/codeblock] - </description> - </method> - <method name="move_toward"> - <return type="float"> - </return> - <argument index="0" name="from" type="float"> - </argument> - <argument index="1" name="to" type="float"> - </argument> - <argument index="2" name="delta" type="float"> - </argument> - <description> - Moves [code]from[/code] toward [code]to[/code] by the [code]delta[/code] value. - Use a negative [code]delta[/code] value to move away. - [codeblock] - move_toward(5, 10, 4) # Returns 9 - move_toward(10, 5, 4) # Returns 6 - move_toward(10, 5, -1.5) # Returns 11.5 - [/codeblock] - </description> - </method> - <method name="nearest_po2"> - <return type="int"> - </return> - <argument index="0" name="value" type="int"> - </argument> - <description> - Returns the nearest equal or larger power of 2 for integer [code]value[/code]. - In other words, returns the smallest value [code]a[/code] where [code]a = pow(2, n)[/code] such that [code]value <= a[/code] for some non-negative integer [code]n[/code]. - [codeblock] - nearest_po2(3) # Returns 4 - nearest_po2(4) # Returns 4 - nearest_po2(5) # Returns 8 - - nearest_po2(0) # Returns 0 (this may not be what you expect) - nearest_po2(-1) # Returns 0 (this may not be what you expect) - [/codeblock] - [b]WARNING:[/b] Due to the way it is implemented, this function returns [code]0[/code] rather than [code]1[/code] for non-positive values of [code]value[/code] (in reality, 1 is the smallest integer power of 2). - </description> - </method> - <method name="ord"> - <return type="int"> - </return> - <argument index="0" name="char" type="String"> - </argument> - <description> - Returns an integer representing the Unicode code point of the given Unicode character [code]char[/code]. - [codeblock] - a = ord("A") # a is 65 - a = ord("a") # a is 97 - a = ord("€") # a is 8364 - [/codeblock] - This is the inverse of [method char]. - </description> - </method> - <method name="parse_json"> - <return type="Variant"> - </return> - <argument index="0" name="json" type="String"> - </argument> - <description> - Parse JSON text to a Variant. (Use [method typeof] to check if the Variant's type is what you expect.) - [b]Note:[/b] The JSON specification does not define integer or float types, but only a [i]number[/i] type. Therefore, parsing a JSON text will convert all numerical values to [float] types. - [b]Note:[/b] JSON objects do not preserve key order like Godot dictionaries, thus, you should not rely on keys being in a certain order if a dictionary is constructed from JSON. In contrast, JSON arrays retain the order of their elements: - [codeblock] - var p = JSON.parse('["hello", "world", "!"]') - if typeof(p.result) == TYPE_ARRAY: - print(p.result[0]) # Prints "hello" - else: - push_error("Unexpected results.") - [/codeblock] - See also [JSON] for an alternative way to parse JSON text. - </description> - </method> - <method name="polar2cartesian"> - <return type="Vector2"> - </return> - <argument index="0" name="r" type="float"> - </argument> - <argument index="1" name="th" type="float"> - </argument> - <description> - Converts a 2D point expressed in the polar coordinate system (a distance from the origin [code]r[/code] and an angle [code]th[/code]) to the cartesian coordinate system (X and Y axis). - </description> - </method> - <method name="posmod"> - <return type="int"> - </return> - <argument index="0" name="a" type="int"> - </argument> - <argument index="1" name="b" type="int"> - </argument> - <description> - Returns the integer modulus of [code]a/b[/code] that wraps equally in positive and negative. - [codeblock] - for i in range(-3, 4): - print("%2d %2d %2d" % [i, i % 3, posmod(i, 3)]) - [/codeblock] - Produces: - [codeblock] - -3 0 0 - -2 -2 1 - -1 -1 2 - 0 0 0 - 1 1 1 - 2 2 2 - 3 0 0 - [/codeblock] - </description> - </method> - <method name="pow"> - <return type="float"> - </return> - <argument index="0" name="base" type="float"> - </argument> - <argument index="1" name="exp" type="float"> - </argument> - <description> - Returns the result of [code]base[/code] raised to the power of [code]exp[/code]. - [codeblock] - pow(2, 5) # Returns 32.0 - [/codeblock] - </description> - </method> <method name="preload"> <return type="Resource"> </return> @@ -783,23 +181,11 @@ [/codeblock] </description> </method> - <method name="print" qualifiers="vararg"> - <return type="void"> - </return> - <description> - Converts one or more arguments to strings in the best way possible and prints them to the console. - [codeblock] - a = [1, 2, 3] - print("a", "=", a) # Prints a=[1, 2, 3] - [/codeblock] - [b]Note:[/b] Consider using [method push_error] and [method push_warning] to print error and warning messages instead of [method print]. This distinguishes them from print messages used for debugging purposes, while also displaying a stack trace when an error or warning is printed. - </description> - </method> <method name="print_debug" qualifiers="vararg"> <return type="void"> </return> <description> - Like [method print], but prints only when used in debug mode. + Like [method @GlobalScope.print], but prints only when used in debug mode. </description> </method> <method name="print_stack"> @@ -813,158 +199,6 @@ [/codeblock] </description> </method> - <method name="printerr" qualifiers="vararg"> - <return type="void"> - </return> - <description> - Prints one or more arguments to strings in the best way possible to standard error line. - [codeblock] - printerr("prints to stderr") - [/codeblock] - </description> - </method> - <method name="printraw" qualifiers="vararg"> - <return type="void"> - </return> - <description> - Prints one or more arguments to strings in the best way possible to console. No newline is added at the end. - [codeblock] - printraw("A") - printraw("B") - # Prints AB - [/codeblock] - [b]Note:[/b] Due to limitations with Godot's built-in console, this only prints to the terminal. If you need to print in the editor, use another method, such as [method print]. - </description> - </method> - <method name="prints" qualifiers="vararg"> - <return type="void"> - </return> - <description> - Prints one or more arguments to the console with a space between each argument. - [codeblock] - prints("A", "B", "C") # Prints A B C - [/codeblock] - </description> - </method> - <method name="printt" qualifiers="vararg"> - <return type="void"> - </return> - <description> - Prints one or more arguments to the console with a tab between each argument. - [codeblock] - printt("A", "B", "C") # Prints A B C - [/codeblock] - </description> - </method> - <method name="push_error"> - <return type="void"> - </return> - <argument index="0" name="message" type="String"> - </argument> - <description> - Pushes an error message to Godot's built-in debugger and to the OS terminal. - [codeblock] - push_error("test error") # Prints "test error" to debugger and terminal as error call - [/codeblock] - [b]Note:[/b] Errors printed this way will not pause project execution. To print an error message and pause project execution in debug builds, use [code]assert(false, "test error")[/code] instead. - </description> - </method> - <method name="push_warning"> - <return type="void"> - </return> - <argument index="0" name="message" type="String"> - </argument> - <description> - Pushes a warning message to Godot's built-in debugger and to the OS terminal. - [codeblock] - push_warning("test warning") # Prints "test warning" to debugger and terminal as warning call - [/codeblock] - </description> - </method> - <method name="rad2deg"> - <return type="float"> - </return> - <argument index="0" name="rad" type="float"> - </argument> - <description> - Converts an angle expressed in radians to degrees. - [codeblock] - rad2deg(0.523599) # Returns 30.0 - [/codeblock] - </description> - </method> - <method name="rand_seed"> - <return type="Array"> - </return> - <argument index="0" name="seed" type="int"> - </argument> - <description> - Random from seed: pass a [code]seed[/code], and an array with both number and new seed is returned. "Seed" here refers to the internal state of the pseudo random number generator. The internal state of the current implementation is 64 bits. - </description> - </method> - <method name="randf"> - <return type="float"> - </return> - <description> - Returns a random floating point value on the interval [code][0, 1][/code]. - [codeblock] - randf() # Returns e.g. 0.375671 - [/codeblock] - </description> - </method> - <method name="randf_range"> - <return type="float"> - </return> - <argument index="0" name="from" type="float"> - </argument> - <argument index="1" name="to" type="float"> - </argument> - <description> - Random range, any floating point value between [code]from[/code] and [code]to[/code]. - [codeblock] - prints(randf_range(-10, 10), randf_range(-10, 10)) # Prints e.g. -3.844535 7.45315 - [/codeblock] - </description> - </method> - <method name="randi"> - <return type="int"> - </return> - <description> - Returns a random unsigned 32 bit integer. Use remainder to obtain a random value in the interval [code][0, N - 1][/code] (where N is smaller than 2^32). - [codeblock] - randi() # Returns random integer between 0 and 2^32 - 1 - randi() % 20 # Returns random integer between 0 and 19 - randi() % 100 # Returns random integer between 0 and 99 - randi() % 100 + 1 # Returns random integer between 1 and 100 - [/codeblock] - </description> - </method> - <method name="randi_range"> - <return type="int"> - </return> - <argument index="0" name="from" type="int"> - </argument> - <argument index="1" name="to" type="int"> - </argument> - <description> - Random range, any 32-bit integer value between [code]from[/code] and [code]to[/code] (inclusive). If [code]to[/code] is lesser than [code]from[/code] they are swapped. - [codeblock] - print(randi_range(0, 1)) # Prints 0 or 1 - print(randi_range(-10, 1000)) # Prints any number from -10 to 1000 - [/codeblock] - </description> - </method> - <method name="randomize"> - <return type="void"> - </return> - <description> - Randomizes the seed (or the internal state) of the random number generator. Current implementation reseeds using a number based on time. - [codeblock] - func _ready(): - randomize() - [/codeblock] - </description> - </method> <method name="range" qualifiers="vararg"> <return type="Array"> </return> @@ -983,157 +217,6 @@ [/codeblock] </description> </method> - <method name="range_lerp"> - <return type="float"> - </return> - <argument index="0" name="value" type="float"> - </argument> - <argument index="1" name="istart" type="float"> - </argument> - <argument index="2" name="istop" type="float"> - </argument> - <argument index="3" name="ostart" type="float"> - </argument> - <argument index="4" name="ostop" type="float"> - </argument> - <description> - Maps a [code]value[/code] from range [code][istart, istop][/code] to [code][ostart, ostop][/code]. - [codeblock] - range_lerp(75, 0, 100, -1, 1) # Returns 0.5 - [/codeblock] - </description> - </method> - <method name="round"> - <return type="float"> - </return> - <argument index="0" name="s" type="float"> - </argument> - <description> - Rounds [code]s[/code] to the nearest whole number, with halfway cases rounded away from zero. - [codeblock] - a = round(2.49) # a is 2.0 - a = round(2.5) # a is 3.0 - a = round(2.51) # a is 3.0 - [/codeblock] - See also [method floor], [method ceil], [method stepify], and [int]. - </description> - </method> - <method name="seed"> - <return type="void"> - </return> - <argument index="0" name="seed" type="int"> - </argument> - <description> - Sets seed for the random number generator. - [codeblock] - my_seed = "Godot Rocks" - seed(my_seed.hash()) - [/codeblock] - </description> - </method> - <method name="sign"> - <return type="float"> - </return> - <argument index="0" name="s" type="float"> - </argument> - <description> - Returns the sign of [code]s[/code]: -1 or 1. Returns 0 if [code]s[/code] is 0. - [codeblock] - sign(-6) # Returns -1 - sign(0) # Returns 0 - sign(6) # Returns 1 - [/codeblock] - </description> - </method> - <method name="sin"> - <return type="float"> - </return> - <argument index="0" name="s" type="float"> - </argument> - <description> - Returns the sine of angle [code]s[/code] in radians. - [codeblock] - sin(0.523599) # Returns 0.5 - [/codeblock] - </description> - </method> - <method name="sinh"> - <return type="float"> - </return> - <argument index="0" name="s" type="float"> - </argument> - <description> - Returns the hyperbolic sine of [code]s[/code]. - [codeblock] - a = log(2.0) # Returns 0.693147 - sinh(a) # Returns 0.75 - [/codeblock] - </description> - </method> - <method name="smoothstep"> - <return type="float"> - </return> - <argument index="0" name="from" type="float"> - </argument> - <argument index="1" name="to" type="float"> - </argument> - <argument index="2" name="s" type="float"> - </argument> - <description> - Returns the result of smoothly interpolating the value of [code]s[/code] between [code]0[/code] and [code]1[/code], based on the where [code]s[/code] lies with respect to the edges [code]from[/code] and [code]to[/code]. - The return value is [code]0[/code] if [code]s <= from[/code], and [code]1[/code] if [code]s >= to[/code]. If [code]s[/code] lies between [code]from[/code] and [code]to[/code], the returned value follows an S-shaped curve that maps [code]s[/code] between [code]0[/code] and [code]1[/code]. - This S-shaped curve is the cubic Hermite interpolator, given by [code]f(s) = 3*s^2 - 2*s^3[/code]. - [codeblock] - smoothstep(0, 2, -5.0) # Returns 0.0 - smoothstep(0, 2, 0.5) # Returns 0.15625 - smoothstep(0, 2, 1.0) # Returns 0.5 - smoothstep(0, 2, 2.0) # Returns 1.0 - [/codeblock] - </description> - </method> - <method name="sqrt"> - <return type="float"> - </return> - <argument index="0" name="s" type="float"> - </argument> - <description> - Returns the square root of [code]s[/code], where [code]s[/code] is a non-negative number. - [codeblock] - sqrt(9) # Returns 3 - [/codeblock] - [b]Note:[/b]Negative values of [code]s[/code] return NaN. If you need negative inputs, use [code]System.Numerics.Complex[/code] in C#. - </description> - </method> - <method name="step_decimals"> - <return type="int"> - </return> - <argument index="0" name="step" type="float"> - </argument> - <description> - Returns the position of the first non-zero digit, after the decimal point. Note that the maximum return value is 10, which is a design decision in the implementation. - [codeblock] - n = step_decimals(5) # n is 0 - n = step_decimals(1.0005) # n is 4 - n = step_decimals(0.000000005) # n is 9 - [/codeblock] - </description> - </method> - <method name="stepify"> - <return type="float"> - </return> - <argument index="0" name="s" type="float"> - </argument> - <argument index="1" name="step" type="float"> - </argument> - <description> - Snaps float value [code]s[/code] to a given [code]step[/code]. This can also be used to round a floating point number to an arbitrary number of decimals. - [codeblock] - stepify(100, 32) # Returns 96.0 - stepify(3.14159, 0.01) # Returns 3.14 - [/codeblock] - See also [method ceil], [method floor], [method round], and [int]. - </description> - </method> <method name="str" qualifiers="vararg"> <return type="String"> </return> @@ -1147,200 +230,12 @@ [/codeblock] </description> </method> - <method name="str2var"> - <return type="Variant"> - </return> - <argument index="0" name="string" type="String"> - </argument> - <description> - Converts a formatted string that was returned by [method var2str] to the original value. - [codeblock] - a = '{ "a": 1, "b": 2 }' - b = str2var(a) - print(b["a"]) # Prints 1 - [/codeblock] - </description> - </method> - <method name="tan"> - <return type="float"> - </return> - <argument index="0" name="s" type="float"> - </argument> - <description> - Returns the tangent of angle [code]s[/code] in radians. - [codeblock] - tan(deg2rad(45)) # Returns 1 - [/codeblock] - </description> - </method> - <method name="tanh"> - <return type="float"> - </return> - <argument index="0" name="s" type="float"> - </argument> - <description> - Returns the hyperbolic tangent of [code]s[/code]. - [codeblock] - a = log(2.0) # a is 0.693147 - b = tanh(a) # b is 0.6 - [/codeblock] - </description> - </method> - <method name="to_json"> - <return type="String"> - </return> - <argument index="0" name="var" type="Variant"> - </argument> - <description> - Converts a [Variant] [code]var[/code] to JSON text and return the result. Useful for serializing data to store or send over the network. - [codeblock] - # Both numbers below are integers. - a = { "a": 1, "b": 2 } - b = to_json(a) - print(b) # {"a":1, "b":2} - # Both numbers above are floats, even if they display without any decimal places. - [/codeblock] - [b]Note:[/b] The JSON specification does not define integer or float types, but only a [i]number[/i] type. Therefore, converting a [Variant] to JSON text will convert all numerical values to [float] types. - See also [JSON] for an alternative way to convert a [Variant] to JSON text. - </description> - </method> <method name="type_exists"> <return type="bool"> </return> - <argument index="0" name="type" type="String"> - </argument> - <description> - Returns whether the given class exists in [ClassDB]. - [codeblock] - type_exists("Sprite2D") # Returns true - type_exists("Variant") # Returns false - [/codeblock] - </description> - </method> - <method name="typeof"> - <return type="int"> - </return> - <argument index="0" name="what" type="Variant"> - </argument> - <description> - Returns the internal type of the given Variant object, using the [enum Variant.Type] values. - [codeblock] - p = parse_json('["a", "b", "c"]') - if typeof(p) == TYPE_ARRAY: - print(p[0]) # Prints a - else: - print("unexpected results") - [/codeblock] - </description> - </method> - <method name="validate_json"> - <return type="String"> - </return> - <argument index="0" name="json" type="String"> - </argument> - <description> - Checks that [code]json[/code] is valid JSON data. Returns an empty string if valid, or an error message otherwise. - [codeblock] - j = to_json([1, 2, 3]) - v = validate_json(j) - if not v: - print("Valid JSON.") - else: - push_error("Invalid JSON: " + v) - [/codeblock] - </description> - </method> - <method name="var2bytes"> - <return type="PackedByteArray"> - </return> - <argument index="0" name="var" type="Variant"> - </argument> - <argument index="1" name="full_objects" type="bool" default="false"> - </argument> - <description> - Encodes a variable value to a byte array. When [code]full_objects[/code] is [code]true[/code] encoding objects is allowed (and can potentially include code). - </description> - </method> - <method name="var2str"> - <return type="String"> - </return> - <argument index="0" name="var" type="Variant"> - </argument> - <description> - Converts a Variant [code]var[/code] to a formatted string that can later be parsed using [method str2var]. - [codeblock] - a = { "a": 1, "b": 2 } - print(var2str(a)) - [/codeblock] - prints - [codeblock] - { - "a": 1, - "b": 2 - } - [/codeblock] - </description> - </method> - <method name="weakref"> - <return type="WeakRef"> - </return> - <argument index="0" name="obj" type="Object"> - </argument> - <description> - Returns a weak reference to an object. - A weak reference to an object is not enough to keep the object alive: when the only remaining references to a referent are weak references, garbage collection is free to destroy the referent and reuse its memory for something else. However, until the object is actually destroyed the weak reference may return the object even if there are no strong references to it. - </description> - </method> - <method name="wrapf"> - <return type="float"> - </return> - <argument index="0" name="value" type="float"> - </argument> - <argument index="1" name="min" type="float"> - </argument> - <argument index="2" name="max" type="float"> + <argument index="0" name="type" type="StringName"> </argument> <description> - Wraps float [code]value[/code] between [code]min[/code] and [code]max[/code]. - Usable for creating loop-alike behavior or infinite surfaces. - [codeblock] - # Infinite loop between 5.0 and 9.9 - value = wrapf(value + 0.1, 5.0, 10.0) - [/codeblock] - [codeblock] - # Infinite rotation (in radians) - angle = wrapf(angle + 0.1, 0.0, TAU) - [/codeblock] - [codeblock] - # Infinite rotation (in radians) - angle = wrapf(angle + 0.1, -PI, PI) - [/codeblock] - [b]Note:[/b] If [code]min[/code] is [code]0[/code], this is equivalent to [method fposmod], so prefer using that instead. - [code]wrapf[/code] is more flexible than using the [method fposmod] approach by giving the user control over the minimum value. - </description> - </method> - <method name="wrapi"> - <return type="int"> - </return> - <argument index="0" name="value" type="int"> - </argument> - <argument index="1" name="min" type="int"> - </argument> - <argument index="2" name="max" type="int"> - </argument> - <description> - Wraps integer [code]value[/code] between [code]min[/code] and [code]max[/code]. - Usable for creating loop-alike behavior or infinite surfaces. - [codeblock] - # Infinite loop between 5 and 9 - frame = wrapi(frame + 1, 5, 10) - [/codeblock] - [codeblock] - # result is -2 - var result = wrapi(-6, -5, -1) - [/codeblock] - [b]Note:[/b] If [code]min[/code] is [code]0[/code], this is equivalent to [method posmod], so prefer using that instead. - [code]wrapi[/code] is more flexible than using the [method posmod] approach by giving the user control over the minimum value. </description> </method> </methods> diff --git a/modules/gdscript/editor/gdscript_highlighter.cpp b/modules/gdscript/editor/gdscript_highlighter.cpp index 7f7410a92c..ccc942d86b 100644 --- a/modules/gdscript/editor/gdscript_highlighter.cpp +++ b/modules/gdscript/editor/gdscript_highlighter.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -269,19 +269,21 @@ Dictionary GDScriptSyntaxHighlighter::_get_line_syntax_highlighting(int p_line) col = keywords[word]; } else if (member_keywords.has(word)) { col = member_keywords[word]; + } + + if (col != Color()) { for (int k = j - 1; k >= 0; k--) { if (str[k] == '.') { - col = Color(); //member indexing not allowed + col = Color(); // keyword & member indexing not allowed break; } else if (str[k] > 32) { break; } } - } - - if (col != Color()) { - in_keyword = true; - keyword_color = col; + if (col != Color()) { + in_keyword = true; + keyword_color = col; + } } } diff --git a/modules/gdscript/editor/gdscript_highlighter.h b/modules/gdscript/editor/gdscript_highlighter.h index e38647eaab..1b57cb1923 100644 --- a/modules/gdscript/editor/gdscript_highlighter.h +++ b/modules/gdscript/editor/gdscript_highlighter.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gdscript/editor/gdscript_translation_parser_plugin.cpp b/modules/gdscript/editor/gdscript_translation_parser_plugin.cpp index 944ed859f5..9d0d91162c 100644 --- a/modules/gdscript/editor/gdscript_translation_parser_plugin.cpp +++ b/modules/gdscript/editor/gdscript_translation_parser_plugin.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -44,7 +44,7 @@ Error GDScriptEditorTranslationParserPlugin::parse_file(const String &p_path, Ve // Search strings in AssignmentNode -> text = "__", hint_tooltip = "__" etc. Error err; - RES loaded_res = ResourceLoader::load(p_path, "", false, &err); + RES loaded_res = ResourceLoader::load(p_path, "", ResourceFormatLoader::CACHE_MODE_REUSE, &err); if (err) { ERR_PRINT("Failed to load " + p_path); return err; diff --git a/modules/gdscript/editor/gdscript_translation_parser_plugin.h b/modules/gdscript/editor/gdscript_translation_parser_plugin.h index d763df01f5..fcf438422a 100644 --- a/modules/gdscript/editor/gdscript_translation_parser_plugin.h +++ b/modules/gdscript/editor/gdscript_translation_parser_plugin.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -39,8 +39,8 @@ class GDScriptEditorTranslationParserPlugin : public EditorTranslationParserPlugin { GDCLASS(GDScriptEditorTranslationParserPlugin, EditorTranslationParserPlugin); - Vector<String> *ids; - Vector<Vector<String>> *ids_ctx_plural; + Vector<String> *ids = nullptr; + Vector<Vector<String>> *ids_ctx_plural = nullptr; // List of patterns used for extracting translation strings. StringName tr_func = "tr"; diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index 8fa2de7063..a129b73c1a 100644 --- a/modules/gdscript/gdscript.cpp +++ b/modules/gdscript/gdscript.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -219,7 +219,7 @@ StringName GDScript::get_instance_base_type() const { } struct _GDScriptMemberSort { - int index; + int index = 0; StringName name; _FORCE_INLINE_ bool operator<(const _GDScriptMemberSort &p_member) const { return index < p_member.index; } }; @@ -425,7 +425,7 @@ void GDScript::_update_doc() { _clear_doc(); doc.script_path = "\"" + get_path().get_slice("://", 1) + "\""; - if (!name.empty()) { + if (!name.is_empty()) { doc.name = name; } else { doc.name = doc.script_path; @@ -793,10 +793,10 @@ Error GDScript::reload(bool p_keep_state) { { String source_path = path; - if (source_path.empty()) { + if (source_path.is_empty()) { source_path = get_path(); } - if (!source_path.empty()) { + if (!source_path.is_empty()) { MutexLock lock(GDScriptCache::singleton->lock); if (!GDScriptCache::singleton->shallow_gdscript_cache.has(source_path)) { GDScriptCache::singleton->shallow_gdscript_cache[source_path] = this; @@ -812,7 +812,7 @@ Error GDScript::reload(bool p_keep_state) { GDScriptLanguage::get_singleton()->debug_break_parse(get_path(), parser.get_errors().front()->get().line, "Parser Error: " + parser.get_errors().front()->get().message); } // TODO: Show all error messages. - _err_print_error("GDScript::reload", path.empty() ? "built-in" : (const char *)path.utf8().get_data(), parser.get_errors().front()->get().line, ("Parse Error: " + parser.get_errors().front()->get().message).utf8().get_data(), ERR_HANDLER_SCRIPT); + _err_print_error("GDScript::reload", path.is_empty() ? "built-in" : (const char *)path.utf8().get_data(), parser.get_errors().front()->get().line, ("Parse Error: " + parser.get_errors().front()->get().message).utf8().get_data(), ERR_HANDLER_SCRIPT); ERR_FAIL_V(ERR_PARSE_ERROR); } @@ -826,7 +826,7 @@ Error GDScript::reload(bool p_keep_state) { const List<GDScriptParser::ParserError>::Element *e = parser.get_errors().front(); while (e != nullptr) { - _err_print_error("GDScript::reload", path.empty() ? "built-in" : (const char *)path.utf8().get_data(), e->get().line, ("Parse Error: " + e->get().message).utf8().get_data(), ERR_HANDLER_SCRIPT); + _err_print_error("GDScript::reload", path.is_empty() ? "built-in" : (const char *)path.utf8().get_data(), e->get().line, ("Parse Error: " + e->get().message).utf8().get_data(), ERR_HANDLER_SCRIPT); e = e->next(); } ERR_FAIL_V(ERR_PARSE_ERROR); @@ -846,7 +846,7 @@ Error GDScript::reload(bool p_keep_state) { if (EngineDebugger::is_active()) { GDScriptLanguage::get_singleton()->debug_break_parse(get_path(), compiler.get_error_line(), "Parser Error: " + compiler.get_error()); } - _err_print_error("GDScript::reload", path.empty() ? "built-in" : (const char *)path.utf8().get_data(), compiler.get_error_line(), ("Compile Error: " + compiler.get_error()).utf8().get_data(), ERR_HANDLER_SCRIPT); + _err_print_error("GDScript::reload", path.is_empty() ? "built-in" : (const char *)path.utf8().get_data(), compiler.get_error_line(), ("Compile Error: " + compiler.get_error()).utf8().get_data(), ERR_HANDLER_SCRIPT); ERR_FAIL_V(ERR_COMPILATION_FAILED); } else { return err; @@ -1162,17 +1162,6 @@ String GDScript::_get_gdscript_reference_class_name(const GDScript *p_gdscript) GDScript::GDScript() : script_list(this) { - valid = false; - subclass_count = 0; - initializer = nullptr; - _base = nullptr; - _owner = nullptr; - tool = false; -#ifdef TOOLS_ENABLED - source_changed_cache = false; - placeholder_fallback_enabled = false; -#endif - #ifdef DEBUG_ENABLED { MutexLock lock(GDScriptLanguage::get_singleton()->lock); @@ -2151,7 +2140,7 @@ String GDScriptLanguage::get_global_class_name(const String &p_path, String *r_b if (err == OK) { const GDScriptParser::ClassNode *c = parser.get_tree(); if (r_icon_path) { - if (c->icon_path.empty() || c->icon_path.is_abs_path()) { + if (c->icon_path.is_empty() || c->icon_path.is_abs_path()) { *r_icon_path = c->icon_path; } else if (c->icon_path.is_rel_path()) { *r_icon_path = p_path.get_base_dir().plus_file(c->icon_path).simplify_path(); @@ -2163,7 +2152,7 @@ String GDScriptLanguage::get_global_class_name(const String &p_path, String *r_b GDScriptParser subparser; while (subclass) { if (subclass->extends_used) { - if (!subclass->extends_path.empty()) { + if (!subclass->extends_path.is_empty()) { if (subclass->extends.size() == 0) { get_global_class_name(subclass->extends_path, r_base_type); subclass = nullptr; @@ -2177,7 +2166,7 @@ String GDScriptLanguage::get_global_class_name(const String &p_path, String *r_b } String subsource = subfile->get_as_utf8_string(); - if (subsource.empty()) { + if (subsource.is_empty()) { break; } String subpath = subclass->extends_path; @@ -2327,7 +2316,7 @@ Ref<GDScript> GDScriptLanguage::get_orphan_subclass(const String &p_qualified_na /*************** RESOURCE ***************/ -RES ResourceFormatLoaderGDScript::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, bool p_no_cache) { +RES ResourceFormatLoaderGDScript::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, CacheMode p_cache_mode) { if (r_error) { *r_error = ERR_FILE_CANT_OPEN; } @@ -2374,7 +2363,7 @@ void ResourceFormatLoaderGDScript::get_dependencies(const String &p_path, List<S ERR_FAIL_COND_MSG(!file, "Cannot open file '" + p_path + "'."); String source = file->get_as_utf8_string(); - if (source.empty()) { + if (source.is_empty()) { return; } diff --git a/modules/gdscript/gdscript.h b/modules/gdscript/gdscript.h index 11c449c5f2..12c909fd4f 100644 --- a/modules/gdscript/gdscript.h +++ b/modules/gdscript/gdscript.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -57,11 +57,11 @@ public: class GDScript : public Script { GDCLASS(GDScript, Script); - bool tool; - bool valid; + bool tool = false; + bool valid = false; struct MemberInfo { - int index; + int index = 0; StringName setter; StringName getter; MultiplayerAPI::RPCMode rpc_mode; @@ -77,8 +77,8 @@ class GDScript : public Script { Ref<GDScriptNativeClass> native; Ref<GDScript> base; - GDScript *_base; //fast pointer access - GDScript *_owner; //for subclasses + GDScript *_base = nullptr; //fast pointer access + GDScript *_owner = nullptr; //for subclasses Set<StringName> members; //members are just indices to the instanced script. Map<StringName, Variant> constants; @@ -97,8 +97,8 @@ class GDScript : public Script { Map<StringName, Variant> member_default_values_cache; Ref<GDScript> base_cache; Set<ObjectID> inheriters_cache; - bool source_changed_cache; - bool placeholder_fallback_enabled; + bool source_changed_cache = false; + bool placeholder_fallback_enabled = false; void _update_exports_values(Map<StringName, Variant> &values, List<PropertyInfo> &propnames); DocData::ClassDoc doc; @@ -121,7 +121,7 @@ class GDScript : public Script { GDScriptFunction *implicit_initializer = nullptr; GDScriptFunction *initializer = nullptr; //direct pointer to new , faster to locate - int subclass_count; + int subclass_count = 0; Set<Object *> instances; //exported members String source; @@ -529,7 +529,7 @@ public: class ResourceFormatLoaderGDScript : public ResourceFormatLoader { public: - virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr, bool p_no_cache = false); + virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr, CacheMode p_cache_mode = CACHE_MODE_REUSE); virtual void get_recognized_extensions(List<String> *p_extensions) const; virtual bool handles_type(const String &p_type) const; virtual String get_resource_type(const String &p_path) const; diff --git a/modules/gdscript/gdscript_analyzer.cpp b/modules/gdscript/gdscript_analyzer.cpp index 19951ff17d..a6138cc564 100644 --- a/modules/gdscript/gdscript_analyzer.cpp +++ b/modules/gdscript/gdscript_analyzer.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -60,7 +60,7 @@ static const char *underscore_classes[] = { nullptr, }; static StringName get_real_class_name(const StringName &p_source) { - if (underscore_map.empty()) { + if (underscore_map.is_empty()) { const char **class_name = underscore_classes; while (*class_name != nullptr) { underscore_map[*class_name] = String("_") + *class_name; @@ -209,7 +209,7 @@ Error GDScriptAnalyzer::resolve_inheritance(GDScriptParser::ClassNode *p_class, int extends_index = 0; - if (!p_class->extends_path.empty()) { + if (!p_class->extends_path.is_empty()) { Ref<GDScriptParserRef> parser = get_parser_for(p_class->extends_path); if (parser.is_null()) { push_error(vformat(R"(Could not resolve super class path "%s".)", p_class->extends_path), p_class); @@ -224,7 +224,7 @@ Error GDScriptAnalyzer::resolve_inheritance(GDScriptParser::ClassNode *p_class, base = parser->get_parser()->head->get_datatype(); } else { - if (p_class->extends.empty()) { + if (p_class->extends.is_empty()) { return ERR_PARSE_ERROR; } const StringName &name = p_class->extends[extends_index++]; @@ -376,7 +376,7 @@ GDScriptParser::DataType GDScriptAnalyzer::resolve_datatype(GDScriptParser::Type result.type_source = result.ANNOTATED_EXPLICIT; result.builtin_type = Variant::OBJECT; - if (p_type->type_chain.empty()) { + if (p_type->type_chain.is_empty()) { // void. result.kind = GDScriptParser::DataType::BUILTIN; result.builtin_type = Variant::NIL; @@ -1163,24 +1163,26 @@ void GDScriptAnalyzer::resolve_variable(GDScriptParser::VariableNode *p_variable void GDScriptAnalyzer::resolve_constant(GDScriptParser::ConstantNode *p_constant) { GDScriptParser::DataType type; - reduce_expression(p_constant->initializer); - if (p_constant->initializer->type == GDScriptParser::Node::ARRAY) { - const_fold_array(static_cast<GDScriptParser::ArrayNode *>(p_constant->initializer)); - } else if (p_constant->initializer->type == GDScriptParser::Node::DICTIONARY) { - const_fold_dictionary(static_cast<GDScriptParser::DictionaryNode *>(p_constant->initializer)); - } + if (p_constant->initializer != nullptr) { + reduce_expression(p_constant->initializer); + if (p_constant->initializer->type == GDScriptParser::Node::ARRAY) { + const_fold_array(static_cast<GDScriptParser::ArrayNode *>(p_constant->initializer)); + } else if (p_constant->initializer->type == GDScriptParser::Node::DICTIONARY) { + const_fold_dictionary(static_cast<GDScriptParser::DictionaryNode *>(p_constant->initializer)); + } - if (!p_constant->initializer->is_constant) { - push_error(vformat(R"(Assigned value for constant "%s" isn't a constant expression.)", p_constant->identifier->name), p_constant->initializer); - } + if (!p_constant->initializer->is_constant) { + push_error(vformat(R"(Assigned value for constant "%s" isn't a constant expression.)", p_constant->identifier->name), p_constant->initializer); + } - type = p_constant->initializer->get_datatype(); + type = p_constant->initializer->get_datatype(); #ifdef DEBUG_ENABLED - if (p_constant->initializer->type == GDScriptParser::Node::CALL && type.kind == GDScriptParser::DataType::BUILTIN && type.builtin_type == Variant::NIL) { - parser->push_warning(p_constant->initializer, GDScriptWarning::VOID_ASSIGNMENT, static_cast<GDScriptParser::CallNode *>(p_constant->initializer)->function_name); - } + if (p_constant->initializer->type == GDScriptParser::Node::CALL && type.kind == GDScriptParser::DataType::BUILTIN && type.builtin_type == Variant::NIL) { + parser->push_warning(p_constant->initializer, GDScriptWarning::VOID_ASSIGNMENT, static_cast<GDScriptParser::CallNode *>(p_constant->initializer)->function_name); + } #endif + } if (p_constant->datatype_specifier != nullptr) { GDScriptParser::DataType explicit_type = resolve_datatype(p_constant->datatype_specifier); @@ -1215,7 +1217,10 @@ void GDScriptAnalyzer::resolve_constant(GDScriptParser::ConstantNode *p_constant void GDScriptAnalyzer::resolve_assert(GDScriptParser::AssertNode *p_assert) { reduce_expression(p_assert->condition); if (p_assert->message != nullptr) { - reduce_literal(p_assert->message); + reduce_expression(p_assert->message); + if (!p_assert->message->is_constant || p_assert->message->reduced_value.get_type() != Variant::STRING) { + push_error(R"(Expected constant string for assert error message.)", p_assert->message); + } } p_assert->set_datatype(p_assert->condition->get_datatype()); @@ -1752,6 +1757,8 @@ void GDScriptAnalyzer::reduce_call(GDScriptParser::CallNode *p_call, bool is_awa // Those are stored by reference so not suited for compile-time construction. // Because in this case they would be the same reference in all constructed values. case Variant::OBJECT: + case Variant::DICTIONARY: + case Variant::ARRAY: case Variant::PACKED_BYTE_ARRAY: case Variant::PACKED_INT32_ARRAY: case Variant::PACKED_INT64_ARRAY: @@ -2029,14 +2036,14 @@ void GDScriptAnalyzer::reduce_call(GDScriptParser::CallNode *p_call, bool is_awa push_error(vformat(R"*(Name "%s" called as a function but is a "%s".)*", p_call->function_name, callee_datatype.to_string()), p_call->callee); } #ifdef DEBUG_ENABLED - } else if (!is_self) { + } else if (!is_self && !(base_type.is_hard_type() && base_type.kind == GDScriptParser::DataType::BUILTIN)) { parser->push_warning(p_call, GDScriptWarning::UNSAFE_METHOD_ACCESS, p_call->function_name, base_type.to_string()); mark_node_unsafe(p_call); #endif } } } - if (!found && is_self) { + if (!found && (is_self || (base_type.is_hard_type() && base_type.kind == GDScriptParser::DataType::BUILTIN))) { String base_name = is_self && !p_call->is_super ? "self" : base_type.to_string(); push_error(vformat(R"*(Function "%s()" not found in base %s.)*", p_call->function_name, base_name), p_call->is_super ? p_call : p_call->callee); } @@ -3402,12 +3409,12 @@ Error GDScriptAnalyzer::resolve_inheritance() { Error GDScriptAnalyzer::resolve_interface() { resolve_class_interface(parser->head); - return parser->errors.empty() ? OK : ERR_PARSE_ERROR; + return parser->errors.is_empty() ? OK : ERR_PARSE_ERROR; } Error GDScriptAnalyzer::resolve_body() { resolve_class_body(parser->head); - return parser->errors.empty() ? OK : ERR_PARSE_ERROR; + return parser->errors.is_empty() ? OK : ERR_PARSE_ERROR; } Error GDScriptAnalyzer::resolve_program() { @@ -3422,7 +3429,7 @@ Error GDScriptAnalyzer::resolve_program() { } depended_parsers[E->get()]->raise_status(GDScriptParserRef::FULLY_SOLVED); } - return parser->errors.empty() ? OK : ERR_PARSE_ERROR; + return parser->errors.is_empty() ? OK : ERR_PARSE_ERROR; } Error GDScriptAnalyzer::analyze() { diff --git a/modules/gdscript/gdscript_analyzer.h b/modules/gdscript/gdscript_analyzer.h index 9925167856..dab5b032a3 100644 --- a/modules/gdscript/gdscript_analyzer.h +++ b/modules/gdscript/gdscript_analyzer.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gdscript/gdscript_byte_codegen.cpp b/modules/gdscript/gdscript_byte_codegen.cpp index a5d96077d9..58c6b31a77 100644 --- a/modules/gdscript/gdscript_byte_codegen.cpp +++ b/modules/gdscript/gdscript_byte_codegen.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -899,6 +899,17 @@ void GDScriptByteCodeGenerator::write_call_self(const Address &p_target, const S append(p_function_name); } +void GDScriptByteCodeGenerator::write_call_self_async(const Address &p_target, const StringName &p_function_name, const Vector<Address> &p_arguments) { + append(GDScriptFunction::OPCODE_CALL_ASYNC, 2 + p_arguments.size()); + for (int i = 0; i < p_arguments.size(); i++) { + append(p_arguments[i]); + } + append(GDScriptFunction::ADDR_TYPE_SELF << GDScriptFunction::ADDR_BITS); + append(p_target); + append(p_arguments.size()); + append(p_function_name); +} + void GDScriptByteCodeGenerator::write_call_script_function(const Address &p_target, const Address &p_base, const StringName &p_function_name, const Vector<Address> &p_arguments) { append(p_target.mode == Address::NIL ? GDScriptFunction::OPCODE_CALL : GDScriptFunction::OPCODE_CALL_RETURN, 2 + p_arguments.size()); for (int i = 0; i < p_arguments.size(); i++) { diff --git a/modules/gdscript/gdscript_byte_codegen.h b/modules/gdscript/gdscript_byte_codegen.h index 21576b08a4..1e66af269a 100644 --- a/modules/gdscript/gdscript_byte_codegen.h +++ b/modules/gdscript/gdscript_byte_codegen.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -441,6 +441,7 @@ public: virtual void write_call_method_bind(const Address &p_target, const Address &p_base, MethodBind *p_method, const Vector<Address> &p_arguments) override; virtual void write_call_ptrcall(const Address &p_target, const Address &p_base, MethodBind *p_method, const Vector<Address> &p_arguments) override; virtual void write_call_self(const Address &p_target, const StringName &p_function_name, const Vector<Address> &p_arguments) override; + virtual void write_call_self_async(const Address &p_target, const StringName &p_function_name, const Vector<Address> &p_arguments) override; virtual void write_call_script_function(const Address &p_target, const Address &p_base, const StringName &p_function_name, const Vector<Address> &p_arguments) override; virtual void write_construct(const Address &p_target, Variant::Type p_type, const Vector<Address> &p_arguments) override; virtual void write_construct_array(const Address &p_target, const Vector<Address> &p_arguments) override; diff --git a/modules/gdscript/gdscript_cache.cpp b/modules/gdscript/gdscript_cache.cpp index 95d24a8b08..113d36be98 100644 --- a/modules/gdscript/gdscript_cache.cpp +++ b/modules/gdscript/gdscript_cache.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gdscript/gdscript_cache.h b/modules/gdscript/gdscript_cache.h index 90c5884985..d1d2a2abbf 100644 --- a/modules/gdscript/gdscript_cache.h +++ b/modules/gdscript/gdscript_cache.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gdscript/gdscript_codegen.h b/modules/gdscript/gdscript_codegen.h index e776007bd7..d72bd12033 100644 --- a/modules/gdscript/gdscript_codegen.h +++ b/modules/gdscript/gdscript_codegen.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -133,6 +133,7 @@ public: virtual void write_call_method_bind(const Address &p_target, const Address &p_base, MethodBind *p_method, const Vector<Address> &p_arguments) = 0; virtual void write_call_ptrcall(const Address &p_target, const Address &p_base, MethodBind *p_method, const Vector<Address> &p_arguments) = 0; virtual void write_call_self(const Address &p_target, const StringName &p_function_name, const Vector<Address> &p_arguments) = 0; + virtual void write_call_self_async(const Address &p_target, const StringName &p_function_name, const Vector<Address> &p_arguments) = 0; virtual void write_call_script_function(const Address &p_target, const Address &p_base, const StringName &p_function_name, const Vector<Address> &p_arguments) = 0; virtual void write_construct(const Address &p_target, Variant::Type p_type, const Vector<Address> &p_arguments) = 0; virtual void write_construct_array(const Address &p_target, const Vector<Address> &p_arguments) = 0; diff --git a/modules/gdscript/gdscript_compiler.cpp b/modules/gdscript/gdscript_compiler.cpp index af6991041e..b491440d4c 100644 --- a/modules/gdscript/gdscript_compiler.cpp +++ b/modules/gdscript/gdscript_compiler.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -107,7 +107,7 @@ GDScriptDataType GDScriptCompiler::_gdtype_from_datatype(const GDScriptParser::D // Locate class by constructing the path to it and following that path GDScriptParser::ClassNode *class_type = p_datatype.class_type; if (class_type) { - if (class_type->fqcn.begins_with(main_script->path) || (!main_script->name.empty() && class_type->fqcn.begins_with(main_script->name))) { + if (class_type->fqcn.begins_with(main_script->path) || (!main_script->name.is_empty() && class_type->fqcn.begins_with(main_script->name))) { // Local class. List<StringName> names; while (class_type->outer) { @@ -494,9 +494,17 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_expression(CodeGen &code } else if ((codegen.function_node && codegen.function_node->is_static) || call->function_name == "new") { GDScriptCodeGenerator::Address self; self.mode = GDScriptCodeGenerator::Address::CLASS; - gen->write_call(result, self, call->function_name, arguments); + if (within_await) { + gen->write_call_async(result, self, call->function_name, arguments); + } else { + gen->write_call(result, self, call->function_name, arguments); + } } else { - gen->write_call_self(result, call->function_name, arguments); + if (within_await) { + gen->write_call_self_async(result, call->function_name, arguments); + } else { + gen->write_call_self(result, call->function_name, arguments); + } } } else if (callee->type == GDScriptParser::Node::SUBSCRIPT) { const GDScriptParser::SubscriptNode *subscript = static_cast<const GDScriptParser::SubscriptNode *>(call->callee); @@ -2231,7 +2239,7 @@ Error GDScriptCompiler::_parse_class_level(GDScript *p_script, const GDScriptPar } p_script->_signals[name] = parameters_names; #ifdef TOOLS_ENABLED - if (!signal->doc_description.empty()) { + if (!signal->doc_description.is_empty()) { p_script->doc_signals[name] = signal->doc_description; } #endif diff --git a/modules/gdscript/gdscript_compiler.h b/modules/gdscript/gdscript_compiler.h index 157c801f56..651391f972 100644 --- a/modules/gdscript/gdscript_compiler.h +++ b/modules/gdscript/gdscript_compiler.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -133,8 +133,8 @@ class GDScriptCompiler { Error _parse_class_level(GDScript *p_script, const GDScriptParser::ClassNode *p_class, bool p_keep_state); Error _parse_class_blocks(GDScript *p_script, const GDScriptParser::ClassNode *p_class, bool p_keep_state); void _make_scripts(GDScript *p_script, const GDScriptParser::ClassNode *p_class, bool p_keep_state); - int err_line; - int err_column; + int err_line = 0; + int err_column = 0; StringName source; String error; bool within_await = false; diff --git a/modules/gdscript/gdscript_disassembler.cpp b/modules/gdscript/gdscript_disassembler.cpp index 5938cfd7b2..17cb5e3c96 100644 --- a/modules/gdscript/gdscript_disassembler.cpp +++ b/modules/gdscript/gdscript_disassembler.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp index 2181d17cf0..b17971cf93 100644 --- a/modules/gdscript/gdscript_editor.cpp +++ b/modules/gdscript/gdscript_editor.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -123,10 +123,10 @@ static void get_function_names_recursively(const GDScriptParser::ClassNode *p_cl for (int i = 0; i < p_class->members.size(); i++) { if (p_class->members[i].type == GDScriptParser::ClassNode::Member::FUNCTION) { const GDScriptParser::FunctionNode *function = p_class->members[i].function; - r_funcs[function->start_line] = p_prefix.empty() ? String(function->identifier->name) : p_prefix + "." + String(function->identifier->name); + r_funcs[function->start_line] = p_prefix.is_empty() ? String(function->identifier->name) : p_prefix + "." + String(function->identifier->name); } else if (p_class->members[i].type == GDScriptParser::ClassNode::Member::CLASS) { String new_prefix = p_class->members[i].m_class->identifier->name; - get_function_names_recursively(p_class->members[i].m_class, p_prefix.empty() ? new_prefix : p_prefix + "." + new_prefix, r_funcs); + get_function_names_recursively(p_class->members[i].m_class, p_prefix.is_empty() ? new_prefix : p_prefix + "." + new_prefix, r_funcs); } } } @@ -476,7 +476,7 @@ String GDScriptLanguage::make_function(const String &p_class, const String &p_na s += p_args[i].get_slice(":", 0); if (th) { String type = p_args[i].get_slice(":", 1); - if (!type.empty() && type != "var") { + if (!type.is_empty() && type != "var") { s += ": " + type; } } @@ -2345,7 +2345,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c GDScriptParser::DataType base_type; bool _static = false; const GDScriptParser::CallNode *call = static_cast<const GDScriptParser::CallNode *>(p_call); - GDScriptParser::Node::Type callee_type = GDScriptParser::Node::NONE; + GDScriptParser::Node::Type callee_type = call->get_callee_type(); GDScriptCompletionIdentifier connect_base; @@ -2511,7 +2511,7 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_path break; } - if (!type.enumeration.empty()) { + if (!type.enumeration.is_empty()) { _find_enumeration_candidates(completion_context, type.enumeration, options); r_forced = options.size() > 0; } else { diff --git a/modules/gdscript/gdscript_function.cpp b/modules/gdscript/gdscript_function.cpp index 32372439c5..c6c9a439df 100644 --- a/modules/gdscript/gdscript_function.cpp +++ b/modules/gdscript/gdscript_function.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -77,14 +77,14 @@ int GDScriptFunction::get_max_stack_size() const { } struct _GDFKC { - int order; + int order = 0; List<int> pos; }; struct _GDFKCS { - int order; + int order = 0; StringName id; - int pos; + int pos = 0; bool operator<(const _GDFKCS &p_r) const { return order < p_r.order; @@ -114,7 +114,7 @@ void GDScriptFunction::debug_get_stack_member_state(int p_line, List<Pair<String ERR_CONTINUE(!sdmap.has(sd.identifier)); sdmap[sd.identifier].pos.pop_back(); - if (sdmap[sd.identifier].pos.empty()) { + if (sdmap[sd.identifier].pos.is_empty()) { sdmap.erase(sd.identifier); } } @@ -294,7 +294,6 @@ void GDScriptFunctionState::_bind_methods() { GDScriptFunctionState::GDScriptFunctionState() : scripts_list(this), instances_list(this) { - function = nullptr; } GDScriptFunctionState::~GDScriptFunctionState() { diff --git a/modules/gdscript/gdscript_function.h b/modules/gdscript/gdscript_function.h index b669870b51..e64630a743 100644 --- a/modules/gdscript/gdscript_function.h +++ b/modules/gdscript/gdscript_function.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -420,19 +420,19 @@ private: public: struct CallState { - GDScript *script; - GDScriptInstance *instance; + GDScript *script = nullptr; + GDScriptInstance *instance = nullptr; #ifdef DEBUG_ENABLED StringName function_name; String script_path; #endif Vector<uint8_t> stack; - int stack_size; + int stack_size = 0; Variant self; - uint32_t alloca_size; - int ip; - int line; - int defarg; + uint32_t alloca_size = 0; + int ip = 0; + int line = 0; + int defarg = 0; Variant result; }; @@ -488,7 +488,7 @@ public: class GDScriptFunctionState : public Reference { GDCLASS(GDScriptFunctionState, Reference); friend class GDScriptFunction; - GDScriptFunction *function; + GDScriptFunction *function = nullptr; GDScriptFunction::CallState state; Variant _signal_callback(const Variant **p_args, int p_argcount, Callable::CallError &r_error); Ref<GDScriptFunctionState> first_state; diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp index 2c735049b6..a77fb14064 100644 --- a/modules/gdscript/gdscript_parser.cpp +++ b/modules/gdscript/gdscript_parser.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -47,7 +47,7 @@ static HashMap<StringName, Variant::Type> builtin_types; Variant::Type GDScriptParser::get_builtin_type(const StringName &p_type) { - if (builtin_types.empty()) { + if (builtin_types.is_empty()) { builtin_types["bool"] = Variant::BOOL; builtin_types["int"] = Variant::INT; builtin_types["float"] = Variant::FLOAT; @@ -177,16 +177,16 @@ void GDScriptParser::push_error(const String &p_message, const Node *p_origin) { void GDScriptParser::push_warning(const Node *p_source, GDScriptWarning::Code p_code, const String &p_symbol1, const String &p_symbol2, const String &p_symbol3, const String &p_symbol4) { ERR_FAIL_COND(p_source == nullptr); Vector<String> symbols; - if (!p_symbol1.empty()) { + if (!p_symbol1.is_empty()) { symbols.push_back(p_symbol1); } - if (!p_symbol2.empty()) { + if (!p_symbol2.is_empty()) { symbols.push_back(p_symbol2); } - if (!p_symbol3.empty()) { + if (!p_symbol3.is_empty()) { symbols.push_back(p_symbol3); } - if (!p_symbol4.empty()) { + if (!p_symbol4.is_empty()) { symbols.push_back(p_symbol4); } push_warning(p_source, p_code, symbols); @@ -284,7 +284,7 @@ void GDScriptParser::pop_completion_call() { if (!for_completion) { return; } - ERR_FAIL_COND_MSG(completion_call_stack.empty(), "Trying to pop empty completion call stack"); + ERR_FAIL_COND_MSG(completion_call_stack.is_empty(), "Trying to pop empty completion call stack"); completion_call_stack.pop_back(); } @@ -292,7 +292,7 @@ void GDScriptParser::set_last_completion_call_arg(int p_argument) { if (!for_completion || passed_cursor) { return; } - ERR_FAIL_COND_MSG(completion_call_stack.empty(), "Trying to set argument on empty completion call stack"); + ERR_FAIL_COND_MSG(completion_call_stack.is_empty(), "Trying to set argument on empty completion call stack"); completion_call_stack.back()->get().argument = p_argument; } @@ -358,7 +358,7 @@ Error GDScriptParser::parse(const String &p_source_code, const String &p_script_ } #endif - if (errors.empty()) { + if (errors.is_empty()) { return OK; } else { return ERR_PARSE_ERROR; @@ -369,7 +369,7 @@ GDScriptTokenizer::Token GDScriptParser::advance() { if (current.type == GDScriptTokenizer::Token::TK_EOF) { ERR_FAIL_COND_V_MSG(current.type == GDScriptTokenizer::Token::TK_EOF, current, "GDScript parser bug: Trying to advance past the end of stream."); } - if (for_completion && !completion_call_stack.empty()) { + if (for_completion && !completion_call_stack.is_empty()) { if (completion_call.call == nullptr && tokenizer.is_past_cursor()) { completion_call = completion_call_stack.back()->get(); passed_cursor = true; @@ -500,7 +500,7 @@ void GDScriptParser::parse_program() { // Order here doesn't matter, but there should be only one of each at most. switch (current.type) { case GDScriptTokenizer::Token::CLASS_NAME: - if (!annotation_stack.empty()) { + if (!annotation_stack.is_empty()) { push_error(R"("class_name" should be used before annotations.)"); } advance(); @@ -511,7 +511,7 @@ void GDScriptParser::parse_program() { } break; case GDScriptTokenizer::Token::EXTENDS: - if (!annotation_stack.empty()) { + if (!annotation_stack.is_empty()) { push_error(R"("extends" should be used before annotations.)"); } advance(); @@ -675,7 +675,7 @@ void GDScriptParser::parse_class_member(T *(GDScriptParser::*p_parse_function)() #endif // TOOLS_ENABLED // Consume annotations. - while (!annotation_stack.empty()) { + while (!annotation_stack.is_empty()) { AnnotationNode *last_annotation = annotation_stack.back()->get(); if (last_annotation->applies_to(p_target)) { last_annotation->apply(this, member); @@ -976,6 +976,8 @@ GDScriptParser::ConstantNode *GDScriptParser::parse_constant() { push_error(R"(Expected initializer expression for constant.)"); return nullptr; } + } else { + return nullptr; } end_statement("constant declaration"); @@ -1501,12 +1503,9 @@ GDScriptParser::AssertNode *GDScriptParser::parse_assert() { if (match(GDScriptTokenizer::Token::COMMA)) { // Error message. - if (consume(GDScriptTokenizer::Token::LITERAL, R"(Expected error message for assert after ",".)")) { - assert->message = parse_literal(); - if (assert->message->value.get_type() != Variant::STRING) { - push_error(R"(Expected string for assert error message.)"); - } - } else { + assert->message = parse_expression(false); + if (assert->message == nullptr) { + push_error(R"(Expected error message for assert after ",".)"); return nullptr; } } @@ -1698,7 +1697,7 @@ GDScriptParser::MatchBranchNode *GDScriptParser::parse_match_branch() { branch->patterns.push_back(pattern); } while (match(GDScriptTokenizer::Token::COMMA)); - if (branch->patterns.empty()) { + if (branch->patterns.is_empty()) { push_error(R"(No pattern found for "match" branch.)"); } @@ -2751,7 +2750,7 @@ String GDScriptParser::get_doc_comment(int p_line, bool p_single_line) { } String line_join = (in_codeblock) ? "\n" : " "; - doc = (doc.empty()) ? doc_line : doc + line_join + doc_line; + doc = (doc.is_empty()) ? doc_line : doc + line_join + doc_line; line++; } @@ -2845,7 +2844,7 @@ void GDScriptParser::get_class_doc_comment(int p_line, String &p_brief, String & mode = TUTORIALS; in_codeblock = false; - } else if (striped_line.empty()) { + } else if (striped_line.is_empty()) { continue; } else { // Tutorial docs are single line, we need a @tag after it. @@ -2919,8 +2918,8 @@ GDScriptParser::ParseRule *GDScriptParser::get_rule(GDScriptTokenizer::Token::Ty { nullptr, &GDScriptParser::parse_binary_operator, PREC_BIT_SHIFT }, // LESS_LESS, { nullptr, &GDScriptParser::parse_binary_operator, PREC_BIT_SHIFT }, // GREATER_GREATER, // Math - { &GDScriptParser::parse_unary_operator, &GDScriptParser::parse_binary_operator, PREC_ADDITION }, // PLUS, - { &GDScriptParser::parse_unary_operator, &GDScriptParser::parse_binary_operator, PREC_SUBTRACTION }, // MINUS, + { &GDScriptParser::parse_unary_operator, &GDScriptParser::parse_binary_operator, PREC_ADDITION_SUBTRACTION }, // PLUS, + { &GDScriptParser::parse_unary_operator, &GDScriptParser::parse_binary_operator, PREC_ADDITION_SUBTRACTION }, // MINUS, { nullptr, &GDScriptParser::parse_binary_operator, PREC_FACTOR }, // STAR, { nullptr, &GDScriptParser::parse_binary_operator, PREC_FACTOR }, // SLASH, { nullptr, &GDScriptParser::parse_binary_operator, PREC_FACTOR }, // PERCENT, @@ -3280,11 +3279,11 @@ String GDScriptParser::DataType::to_string() const { return script_type->get_class_name().operator String(); } String name = script_type->get_name(); - if (!name.empty()) { + if (!name.is_empty()) { return name; } name = script_path; - if (!name.empty()) { + if (!name.is_empty()) { return name; } return native_type.operator String(); @@ -3329,7 +3328,7 @@ void GDScriptParser::TreePrinter::decrease_indent() { } void GDScriptParser::TreePrinter::push_line(const String &p_line) { - if (!p_line.empty()) { + if (!p_line.is_empty()) { push_text(p_line); } printed += "\n"; @@ -3538,7 +3537,7 @@ void GDScriptParser::TreePrinter::print_class(ClassNode *p_class) { if (p_class->extends_used) { bool first = true; push_text(" Extends "); - if (!p_class->extends_path.empty()) { + if (!p_class->extends_path.is_empty()) { push_text(vformat(R"("%s")", p_class->extends_path)); first = false; } @@ -4000,7 +3999,7 @@ void GDScriptParser::TreePrinter::print_ternary_op(TernaryOpNode *p_ternary_op) } void GDScriptParser::TreePrinter::print_type(TypeNode *p_type) { - if (p_type->type_chain.empty()) { + if (p_type->type_chain.is_empty()) { push_text("Void"); } else { for (int i = 0; i < p_type->type_chain.size(); i++) { @@ -4120,7 +4119,7 @@ void GDScriptParser::TreePrinter::print_tree(const GDScriptParser &p_parser) { if (p_parser.is_tool()) { push_line("@tool"); } - if (!p_parser.get_tree()->icon_path.empty()) { + if (!p_parser.get_tree()->icon_path.is_empty()) { push_text(R"(@icon (")"); push_text(p_parser.get_tree()->icon_path); push_line("\")"); diff --git a/modules/gdscript/gdscript_parser.h b/modules/gdscript/gdscript_parser.h index 4cecdc6970..d59b68b602 100644 --- a/modules/gdscript/gdscript_parser.h +++ b/modules/gdscript/gdscript_parser.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -286,7 +286,7 @@ public: struct AssertNode : public Node { ExpressionNode *condition = nullptr; - LiteralNode *message = nullptr; + ExpressionNode *message = nullptr; AssertNode() { type = ASSERT; @@ -351,7 +351,7 @@ public: OP_COMP_GREATER_EQUAL, }; - OpType operation; + OpType operation = OpType::OP_ADDITION; Variant::Operator variant_op = Variant::OP_MAX; ExpressionNode *left_operand = nullptr; ExpressionNode *right_operand = nullptr; @@ -753,7 +753,7 @@ public: struct MatchBranchNode : public Node { Vector<PatternNode *> patterns; - SuiteNode *block; + SuiteNode *block = nullptr; bool has_wildcard = false; MatchBranchNode() { @@ -1001,7 +1001,7 @@ public: OP_LOGIC_NOT, }; - OpType operation; + OpType operation = OP_POSITIVE; Variant::Operator variant_op = Variant::OP_MAX; ExpressionNode *operand = nullptr; @@ -1172,8 +1172,7 @@ private: PREC_BIT_XOR, PREC_BIT_AND, PREC_BIT_SHIFT, - PREC_SUBTRACTION, - PREC_ADDITION, + PREC_ADDITION_SUBTRACTION, PREC_FACTOR, PREC_SIGN, PREC_BIT_NOT, diff --git a/modules/gdscript/gdscript_tokenizer.cpp b/modules/gdscript/gdscript_tokenizer.cpp index ac43105254..315b8ee3b4 100644 --- a/modules/gdscript/gdscript_tokenizer.cpp +++ b/modules/gdscript/gdscript_tokenizer.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -221,7 +221,7 @@ String GDScriptTokenizer::get_token_name(Token::Type p_token_type) { void GDScriptTokenizer::set_source_code(const String &p_source_code) { source = p_source_code; - if (source.empty()) { + if (source.is_empty()) { _source = U""; } else { _source = source.ptr(); @@ -287,7 +287,7 @@ void GDScriptTokenizer::push_paren(char32_t p_char) { } bool GDScriptTokenizer::pop_paren(char32_t p_expected) { - if (paren_stack.empty()) { + if (paren_stack.is_empty()) { return false; } char32_t actual = paren_stack.back()->get(); @@ -405,7 +405,7 @@ void GDScriptTokenizer::push_error(const Token &p_error) { } GDScriptTokenizer::Token GDScriptTokenizer::make_paren_error(char32_t p_paren) { - if (paren_stack.empty()) { + if (paren_stack.is_empty()) { return make_error(vformat("Closing \"%c\" doesn't have an opening counterpart.", p_paren)); } Token error = make_error(vformat("Closing \"%c\" doesn't match the opening \"%c\".", p_paren, paren_stack.back()->get())); diff --git a/modules/gdscript/gdscript_tokenizer.h b/modules/gdscript/gdscript_tokenizer.h index f236c86f9f..bea4b14019 100644 --- a/modules/gdscript/gdscript_tokenizer.h +++ b/modules/gdscript/gdscript_tokenizer.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -178,7 +178,6 @@ public: } Token() { - type = EMPTY; } }; @@ -230,7 +229,7 @@ private: _FORCE_INLINE_ bool _is_at_end() { return position >= length; } _FORCE_INLINE_ char32_t _peek(int p_offset = 0) { return position + p_offset >= 0 && position + p_offset < length ? _current[p_offset] : '\0'; } int indent_level() const { return indent_stack.size(); } - bool has_error() const { return !error_stack.empty(); } + bool has_error() const { return !error_stack.is_empty(); } Token pop_error(); char32_t _advance(); void _skip_whitespace(); diff --git a/modules/gdscript/gdscript_utility_functions.cpp b/modules/gdscript/gdscript_utility_functions.cpp index b1780446d0..348d221352 100644 --- a/modules/gdscript/gdscript_utility_functions.cpp +++ b/modules/gdscript/gdscript_utility_functions.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gdscript/gdscript_utility_functions.h b/modules/gdscript/gdscript_utility_functions.h index 50867438d9..c6d3718844 100644 --- a/modules/gdscript/gdscript_utility_functions.h +++ b/modules/gdscript/gdscript_utility_functions.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gdscript/gdscript_vm.cpp b/modules/gdscript/gdscript_vm.cpp index b8e1791467..4e098d7a6d 100644 --- a/modules/gdscript/gdscript_vm.cpp +++ b/modules/gdscript/gdscript_vm.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -476,11 +476,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a } if (p_instance) { - if (p_instance->base_ref && static_cast<Reference *>(p_instance->owner)->is_referenced()) { - self = REF(static_cast<Reference *>(p_instance->owner)); - } else { - self = p_instance->owner; - } + self = p_instance->owner; script = p_instance->script.ptr(); } else { script = _script; @@ -2282,7 +2278,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a VariantInternal::initialize(counter, Variant::INT); *VariantInternal::get_int(counter) = 0; - if (!str->empty()) { + if (!str->is_empty()) { GET_INSTRUCTION_ARG(iterator, 2); VariantInternal::initialize(iterator, Variant::STRING); *VariantInternal::get_string(iterator) = str->substr(0, 1); @@ -2306,10 +2302,10 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a Dictionary *dict = VariantInternal::get_dictionary(container); const Variant *next = dict->next(nullptr); - *counter = *next; - if (!dict->empty()) { + if (!dict->is_empty()) { GET_INSTRUCTION_ARG(iterator, 2); + *counter = *next; *iterator = *next; // Skip regular iterate. @@ -2334,7 +2330,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a VariantInternal::initialize(counter, Variant::INT); *VariantInternal::get_int(counter) = 0; - if (!array->empty()) { + if (!array->is_empty()) { GET_INSTRUCTION_ARG(iterator, 2); *iterator = array->get(0); @@ -2357,7 +2353,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a Vector<m_elem_type> *array = VariantInternal::m_get_func(container); \ VariantInternal::initialize(counter, Variant::INT); \ *VariantInternal::get_int(counter) = 0; \ - if (!array->empty()) { \ + if (!array->is_empty()) { \ GET_INSTRUCTION_ARG(iterator, 2); \ VariantInternal::initialize(iterator, Variant::m_var_ret_type); \ m_ret_type *it = VariantInternal::m_ret_get_func(iterator); \ @@ -2781,7 +2777,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a GET_INSTRUCTION_ARG(message, 1); message_str = *message; } - if (message_str.empty()) { + if (message_str.is_empty()) { err_text = "Assertion failed."; } else { err_text = "Assertion failed: " + message_str; diff --git a/modules/gdscript/gdscript_warning.cpp b/modules/gdscript/gdscript_warning.cpp index 56704d3e0a..ad41b60a4e 100644 --- a/modules/gdscript/gdscript_warning.cpp +++ b/modules/gdscript/gdscript_warning.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gdscript/gdscript_warning.h b/modules/gdscript/gdscript_warning.h index e0857703d8..4b295b5eb8 100644 --- a/modules/gdscript/gdscript_warning.h +++ b/modules/gdscript/gdscript_warning.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gdscript/language_server/gdscript_extend_parser.cpp b/modules/gdscript/language_server/gdscript_extend_parser.cpp index bd2d170e52..e63b6ab20e 100644 --- a/modules/gdscript/language_server/gdscript_extend_parser.cpp +++ b/modules/gdscript/language_server/gdscript_extend_parser.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -147,7 +147,7 @@ void ExtendGDScriptParser::parse_class_symbol(const GDScriptParser::ClassNode *p r_symbol.script_path = path; r_symbol.children.clear(); r_symbol.name = p_class->identifier != nullptr ? String(p_class->identifier->name) : String(); - if (r_symbol.name.empty()) { + if (r_symbol.name.is_empty()) { r_symbol.name = path.get_file(); } r_symbol.kind = lsp::SymbolKind::Class; @@ -215,9 +215,9 @@ void ExtendGDScriptParser::parse_class_symbol(const GDScriptParser::ClassNode *p String value_text; if (default_value.get_type() == Variant::OBJECT) { RES res = default_value; - if (res.is_valid() && !res->get_path().empty()) { + if (res.is_valid() && !res->get_path().is_empty()) { value_text = "preload(\"" + res->get_path() + "\")"; - if (symbol.documentation.empty()) { + if (symbol.documentation.is_empty()) { if (Map<String, ExtendGDScriptParser *>::Element *S = GDScriptLanguageProtocol::get_singleton()->get_workspace()->scripts.find(res->get_path())) { symbol.documentation = S->get()->class_symbol.documentation; } @@ -228,7 +228,7 @@ void ExtendGDScriptParser::parse_class_symbol(const GDScriptParser::ClassNode *p } else { value_text = JSON::print(default_value); } - if (!value_text.empty()) { + if (!value_text.is_empty()) { symbol.detail += " = " + value_text; } @@ -453,7 +453,7 @@ String ExtendGDScriptParser::get_text_for_lookup_symbol(const lsp::Position &p_c String line = lines[i]; String first_part = line.substr(0, p_cursor.character); String last_part = line.substr(p_cursor.character + 1, lines[i].length()); - if (!p_symbol.empty()) { + if (!p_symbol.is_empty()) { String left_cursor_text; for (int c = p_cursor.character - 1; c >= 0; c--) { left_cursor_text = line.substr(c, p_cursor.character - c); @@ -589,7 +589,7 @@ const lsp::DocumentSymbol *ExtendGDScriptParser::get_symbol_defined_at_line(int } const lsp::DocumentSymbol *ExtendGDScriptParser::get_member_symbol(const String &p_name, const String &p_subclass) const { - if (p_subclass.empty()) { + if (p_subclass.is_empty()) { const lsp::DocumentSymbol *const *ptr = members.getptr(p_name); if (ptr) { return *ptr; @@ -611,7 +611,7 @@ const List<lsp::DocumentLink> &ExtendGDScriptParser::get_document_links() const } const Array &ExtendGDScriptParser::get_member_completions() { - if (member_completions.empty()) { + if (member_completions.is_empty()) { const String *name = members.next(nullptr); while (name) { const lsp::DocumentSymbol *symbol = members.get(*name); diff --git a/modules/gdscript/language_server/gdscript_extend_parser.h b/modules/gdscript/language_server/gdscript_extend_parser.h index bb02d3dc99..28b9b3c82a 100644 --- a/modules/gdscript/language_server/gdscript_extend_parser.h +++ b/modules/gdscript/language_server/gdscript_extend_parser.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gdscript/language_server/gdscript_language_protocol.cpp b/modules/gdscript/language_server/gdscript_language_protocol.cpp index 729be237ec..912c9a174e 100644 --- a/modules/gdscript/language_server/gdscript_language_protocol.cpp +++ b/modules/gdscript/language_server/gdscript_language_protocol.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -96,7 +96,7 @@ Error GDScriptLanguageProtocol::LSPeer::handle_data() { // Response String output = GDScriptLanguageProtocol::get_singleton()->process_message(msg); - if (!output.empty()) { + if (!output.is_empty()) { res_queue.push_back(output.utf8()); } } @@ -105,7 +105,7 @@ Error GDScriptLanguageProtocol::LSPeer::handle_data() { Error GDScriptLanguageProtocol::LSPeer::send_data() { int sent = 0; - if (!res_queue.empty()) { + if (!res_queue.is_empty()) { CharString c_res = res_queue[0]; if (res_sent < c_res.size()) { Error err = connection->put_partial_data((const uint8_t *)c_res.get_data() + res_sent, c_res.size() - res_sent - 1, sent); @@ -141,7 +141,7 @@ void GDScriptLanguageProtocol::on_client_disconnected(const int &p_client_id) { String GDScriptLanguageProtocol::process_message(const String &p_text) { String ret = process_string(p_text); - if (ret.empty()) { + if (ret.is_empty()) { return ret; } else { return format_output(ret); @@ -163,7 +163,7 @@ void GDScriptLanguageProtocol::_bind_methods() { ClassDB::bind_method(D_METHOD("initialized", "params"), &GDScriptLanguageProtocol::initialized); ClassDB::bind_method(D_METHOD("on_client_connected"), &GDScriptLanguageProtocol::on_client_connected); ClassDB::bind_method(D_METHOD("on_client_disconnected"), &GDScriptLanguageProtocol::on_client_disconnected); - ClassDB::bind_method(D_METHOD("notify_client", "method", "params"), &GDScriptLanguageProtocol::notify_client, DEFVAL(Variant()), DEFVAL(-1)); + ClassDB::bind_method(D_METHOD("notify_client", "method", "params", "client_id"), &GDScriptLanguageProtocol::notify_client, DEFVAL(Variant()), DEFVAL(-1)); ClassDB::bind_method(D_METHOD("is_smart_resolve_enabled"), &GDScriptLanguageProtocol::is_smart_resolve_enabled); ClassDB::bind_method(D_METHOD("get_text_document"), &GDScriptLanguageProtocol::get_text_document); ClassDB::bind_method(D_METHOD("get_workspace"), &GDScriptLanguageProtocol::get_workspace); diff --git a/modules/gdscript/language_server/gdscript_language_protocol.h b/modules/gdscript/language_server/gdscript_language_protocol.h index cf5242e8c5..8b08ae0655 100644 --- a/modules/gdscript/language_server/gdscript_language_protocol.h +++ b/modules/gdscript/language_server/gdscript_language_protocol.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gdscript/language_server/gdscript_language_server.cpp b/modules/gdscript/language_server/gdscript_language_server.cpp index 3387d262f8..98ada9de4d 100644 --- a/modules/gdscript/language_server/gdscript_language_server.cpp +++ b/modules/gdscript/language_server/gdscript_language_server.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -36,12 +36,6 @@ #include "editor/editor_node.h" GDScriptLanguageServer::GDScriptLanguageServer() { - thread = nullptr; - thread_running = false; - started = false; - - use_thread = false; - port = 6008; _EDITOR_DEF("network/language_server/remote_port", port); _EDITOR_DEF("network/language_server/enable_smart_resolve", true); _EDITOR_DEF("network/language_server/show_native_symbols_in_editor", false); @@ -87,9 +81,8 @@ void GDScriptLanguageServer::start() { if (protocol.start(port, IP_Address("127.0.0.1")) == OK) { EditorNode::get_log()->add_message("--- GDScript language server started ---", EditorLog::MSG_TYPE_EDITOR); if (use_thread) { - ERR_FAIL_COND(thread != nullptr); thread_running = true; - thread = Thread::create(GDScriptLanguageServer::thread_main, this); + thread.start(GDScriptLanguageServer::thread_main, this); } set_process_internal(!use_thread); started = true; @@ -98,11 +91,9 @@ void GDScriptLanguageServer::start() { void GDScriptLanguageServer::stop() { if (use_thread) { - ERR_FAIL_COND(nullptr == thread); + ERR_FAIL_COND(!thread.is_started()); thread_running = false; - Thread::wait_to_finish(thread); - memdelete(thread); - thread = nullptr; + thread.wait_to_finish(); } protocol.stop(); started = false; diff --git a/modules/gdscript/language_server/gdscript_language_server.h b/modules/gdscript/language_server/gdscript_language_server.h index 228d29bf42..29c5ddd70e 100644 --- a/modules/gdscript/language_server/gdscript_language_server.h +++ b/modules/gdscript/language_server/gdscript_language_server.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -40,11 +40,11 @@ class GDScriptLanguageServer : public EditorPlugin { GDScriptLanguageProtocol protocol; - Thread *thread; - bool thread_running; - bool started; - bool use_thread; - int port; + Thread thread; + bool thread_running = false; + bool started = false; + bool use_thread = false; + int port = 6008; static void thread_main(void *p_userdata); private: diff --git a/modules/gdscript/language_server/gdscript_text_document.cpp b/modules/gdscript/language_server/gdscript_text_document.cpp index c6fe3169dc..9f2373bf56 100644 --- a/modules/gdscript/language_server/gdscript_text_document.cpp +++ b/modules/gdscript/language_server/gdscript_text_document.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -147,7 +147,7 @@ Array GDScriptTextDocument::completion(const Dictionary &p_params) { List<ScriptCodeCompletionOption> options; GDScriptLanguageProtocol::get_singleton()->get_workspace()->completion(params, &options); - if (!options.empty()) { + if (!options.is_empty()) { int i = 0; arr.resize(options.size()); @@ -257,7 +257,7 @@ Dictionary GDScriptTextDocument::resolve(const Dictionary &p_params) { if ((item.kind == lsp::CompletionItemKind::Method || item.kind == lsp::CompletionItemKind::Function) && !item.label.ends_with("):")) { item.insertText = item.label + "("; - if (symbol && symbol->children.empty()) { + if (symbol && symbol->children.is_empty()) { item.insertText += ")"; } } else if (item.kind == lsp::CompletionItemKind::Event) { @@ -341,7 +341,7 @@ Variant GDScriptTextDocument::declaration(const Dictionary &p_params) { params.load(p_params); List<const lsp::DocumentSymbol *> symbols; Array arr = this->find_symbols(params, symbols); - if (arr.empty() && !symbols.empty() && !symbols.front()->get()->native_class.empty()) { // Find a native symbol + if (arr.is_empty() && !symbols.is_empty() && !symbols.front()->get()->native_class.is_empty()) { // Find a native symbol const lsp::DocumentSymbol *symbol = symbols.front()->get(); if (GDScriptLanguageProtocol::get_singleton()->is_goto_native_symbols_enabled()) { String id; @@ -425,7 +425,7 @@ Array GDScriptTextDocument::find_symbols(const lsp::TextDocumentPositionParams & GDScriptLanguageProtocol::get_singleton()->get_workspace()->resolve_related_symbols(p_location, list); for (List<const lsp::DocumentSymbol *>::Element *E = list.front(); E; E = E->next()) { if (const lsp::DocumentSymbol *s = E->get()) { - if (!s->uri.empty()) { + if (!s->uri.is_empty()) { lsp::Location location; location.uri = s->uri; location.range = s->range; diff --git a/modules/gdscript/language_server/gdscript_text_document.h b/modules/gdscript/language_server/gdscript_text_document.h index 2a5755bec6..792e601bc1 100644 --- a/modules/gdscript/language_server/gdscript_text_document.h +++ b/modules/gdscript/language_server/gdscript_text_document.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gdscript/language_server/gdscript_workspace.cpp b/modules/gdscript/language_server/gdscript_workspace.cpp index 60668e7b31..69cad1a335 100644 --- a/modules/gdscript/language_server/gdscript_workspace.cpp +++ b/modules/gdscript/language_server/gdscript_workspace.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -80,7 +80,7 @@ const lsp::DocumentSymbol *GDScriptWorkspace::get_native_symbol(const String &p_ if (const Map<StringName, lsp::DocumentSymbol>::Element *E = native_symbols.find(class_name)) { const lsp::DocumentSymbol &class_symbol = E->value(); - if (p_member.empty()) { + if (p_member.is_empty()) { return &class_symbol; } else { for (int i = 0; i < class_symbol.children.size(); i++) { @@ -171,7 +171,7 @@ ExtendGDScriptParser *GDScriptWorkspace::get_parse_result(const String &p_path) Array GDScriptWorkspace::symbol(const Dictionary &p_params) { String query = p_params["query"]; Array arr; - if (!query.empty()) { + if (!query.is_empty()) { for (Map<String, ExtendGDScriptParser *>::Element *E = scripts.front(); E; E = E->next()) { Vector<lsp::DocumentedSymbolInformation> script_symbols; E->get()->get_symbols().symbol_tree_as_list(E->key(), script_symbols); @@ -199,7 +199,7 @@ Error GDScriptWorkspace::initialize() { class_symbol.native_class = class_name; class_symbol.kind = lsp::SymbolKind::Class; class_symbol.detail = String("<Native> class ") + class_name; - if (!class_data.inherits.empty()) { + if (!class_data.inherits.is_empty()) { class_symbol.detail += " extends " + class_data.inherits; } class_symbol.documentation = class_data.brief_description + "\n" + class_data.description; @@ -263,7 +263,7 @@ Error GDScriptWorkspace::initialize() { symbol_arg.kind = lsp::SymbolKind::Variable; symbol_arg.detail = arg.type; - if (!arg_default_value_started && !arg.default_value.empty()) { + if (!arg_default_value_started && !arg.default_value.is_empty()) { arg_default_value_started = true; } String arg_str = arg.name + ": " + arg.type; @@ -278,11 +278,11 @@ Error GDScriptWorkspace::initialize() { symbol.children.push_back(symbol_arg); } if (data.qualifiers.find("vararg") != -1) { - params += params.empty() ? "..." : ", ..."; + params += params.is_empty() ? "..." : ", ..."; } String return_type = data.return_type; - if (return_type.empty()) { + if (return_type.is_empty()) { return_type = "void"; } symbol.detail = "func " + class_name + "." + data.name + "(" + params + ") -> " + return_type; @@ -350,7 +350,7 @@ Error GDScriptWorkspace::parse_local_script(const String &p_path) { String GDScriptWorkspace::get_file_path(const String &p_uri) const { String path = p_uri; path = path.replace(root_uri + "/", "res://"); - path = path.http_unescape(); + path = path.uri_decode(); return path; } @@ -448,13 +448,13 @@ const lsp::DocumentSymbol *GDScriptWorkspace::resolve_symbol(const lsp::TextDocu } lsp::Position pos = p_doc_pos.position; - if (symbol_identifier.empty()) { + if (symbol_identifier.is_empty()) { Vector2i offset; symbol_identifier = parser->get_identifier_under_position(p_doc_pos.position, offset); pos.character += offset.y; } - if (!symbol_identifier.empty()) { + if (!symbol_identifier.is_empty()) { if (ScriptServer::is_global_class(symbol_identifier)) { String class_path = ScriptServer::get_global_class_path(symbol_identifier); symbol = get_script_symbol(class_path); @@ -474,7 +474,7 @@ const lsp::DocumentSymbol *GDScriptWorkspace::resolve_symbol(const lsp::TextDocu } else { String member = ret.class_member; - if (member.empty() && symbol_identifier != ret.class_name) { + if (member.is_empty() && symbol_identifier != ret.class_name) { member = symbol_identifier; } symbol = get_native_symbol(ret.class_name, member); @@ -529,7 +529,7 @@ void GDScriptWorkspace::resolve_related_symbols(const lsp::TextDocumentPositionP const lsp::DocumentSymbol *GDScriptWorkspace::resolve_native_symbol(const lsp::NativeSymbolInspectParams &p_params) { if (Map<StringName, lsp::DocumentSymbol>::Element *E = native_symbols.find(p_params.native_class)) { const lsp::DocumentSymbol &symbol = E->get(); - if (p_params.symbol_name.empty() || p_params.symbol_name == symbol.name) { + if (p_params.symbol_name.is_empty() || p_params.symbol_name == symbol.name) { return &symbol; } diff --git a/modules/gdscript/language_server/gdscript_workspace.h b/modules/gdscript/language_server/gdscript_workspace.h index fc244c6357..7fd8bfcf20 100644 --- a/modules/gdscript/language_server/gdscript_workspace.h +++ b/modules/gdscript/language_server/gdscript_workspace.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gdscript/language_server/lsp.hpp b/modules/gdscript/language_server/lsp.hpp index 1029c53bbf..96744a15d7 100644 --- a/modules/gdscript/language_server/lsp.hpp +++ b/modules/gdscript/language_server/lsp.hpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -547,7 +547,7 @@ struct TextDocumentItem { * The version number of this document (it will increase after each * change, including undo/redo). */ - int version; + int version = 0; /** * The content of the opened text document. @@ -584,7 +584,7 @@ struct TextDocumentContentChangeEvent { /** * The length of the range that got replaced. */ - int rangeLength; + int rangeLength = 0; /** * The new text of the range/document. @@ -656,12 +656,12 @@ struct Diagnostic { * The diagnostic's severity. Can be omitted. If omitted it is up to the * client to interpret diagnostics as error, warning, info or hint. */ - int severity; + int severity = 0; /** * The diagnostic's code, which might appear in the user interface. */ - int code; + int code = 0; /** * A human-readable string describing the source of this @@ -687,7 +687,7 @@ struct Diagnostic { dict["severity"] = severity; dict["message"] = message; dict["source"] = source; - if (!relatedInformation.empty()) { + if (!relatedInformation.is_empty()) { Array arr; arr.resize(relatedInformation.size()); for (int i = 0; i < relatedInformation.size(); i++) { @@ -833,7 +833,7 @@ struct CompletionItem { * an icon is chosen by the editor. The standardized set * of available values is defined in `CompletionItemKind`. */ - int kind; + int kind = 0; /** * A human-readable string with additional information @@ -891,7 +891,7 @@ struct CompletionItem { * The format of the insert text. The format applies to both the `insertText` property * and the `newText` property of a provided `textEdit`. */ - int insertTextFormat; + int insertTextFormat = 0; /** * An edit which is applied to a document when selecting this completion. When an edit is provided the value of @@ -1003,7 +1003,7 @@ struct CompletionList { * This list it not complete. Further typing should result in recomputing * this list. */ - bool isIncomplete; + bool isIncomplete = false; /** * The completion items. @@ -1191,7 +1191,7 @@ struct DocumentSymbol { void symbol_tree_as_list(const String &p_uri, Vector<DocumentedSymbolInformation> &r_list, const String &p_container = "", bool p_join_name = false) const { DocumentedSymbolInformation si; - if (p_join_name && !p_container.empty()) { + if (p_join_name && !p_container.is_empty()) { si.name = p_container + ">" + name; } else { si.name = name; diff --git a/modules/gdscript/register_types.cpp b/modules/gdscript/register_types.cpp index 0c4996e9bb..e90475a60e 100644 --- a/modules/gdscript/register_types.cpp +++ b/modules/gdscript/register_types.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gdscript/register_types.h b/modules/gdscript/register_types.h index 18e57c1211..ce1c03d1d0 100644 --- a/modules/gdscript/register_types.h +++ b/modules/gdscript/register_types.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gdscript/tests/test_gdscript.cpp b/modules/gdscript/tests/test_gdscript.cpp index 643c2f10a2..898ac653f5 100644 --- a/modules/gdscript/tests/test_gdscript.cpp +++ b/modules/gdscript/tests/test_gdscript.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -239,7 +239,7 @@ void init_autoloads() { void test(TestType p_type) { List<String> cmdlargs = OS::get_singleton()->get_cmdline_args(); - if (cmdlargs.empty()) { + if (cmdlargs.is_empty()) { return; } diff --git a/modules/gdscript/tests/test_gdscript.h b/modules/gdscript/tests/test_gdscript.h index 6182629802..bbda46cdad 100644 --- a/modules/gdscript/tests/test_gdscript.h +++ b/modules/gdscript/tests/test_gdscript.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/glslang/register_types.cpp b/modules/glslang/register_types.cpp index 3238e0108e..545aa68747 100644 --- a/modules/glslang/register_types.cpp +++ b/modules/glslang/register_types.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -53,7 +53,7 @@ static Vector<uint8_t> _compile_shader_glsl(RenderingDevice::ShaderStage p_stage int ClientInputSemanticsVersion = 100; // maps to, say, #define VULKAN 100 glslang::EShTargetClientVersion VulkanClientVersion = glslang::EShTargetVulkan_1_0; - glslang::EShTargetLanguageVersion TargetVersion = glslang::EShTargetSpv_1_0; + glslang::EShTargetLanguageVersion TargetVersion = glslang::EShTargetSpv_1_3; glslang::TShader::ForbidIncluder includer; glslang::TShader shader(stages[p_stage]); diff --git a/modules/glslang/register_types.h b/modules/glslang/register_types.h index 2437e2b27a..a1264b77c9 100644 --- a/modules/glslang/register_types.h +++ b/modules/glslang/register_types.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gltf/editor_scene_exporter_gltf_plugin.cpp b/modules/gltf/editor_scene_exporter_gltf_plugin.cpp index 0680b124b4..4cdaccde6f 100644 --- a/modules/gltf/editor_scene_exporter_gltf_plugin.cpp +++ b/modules/gltf/editor_scene_exporter_gltf_plugin.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -82,7 +82,7 @@ void SceneExporterGLTFPlugin::convert_scene_to_gltf2() { return; } String filename = String(root->get_filename().get_file().get_basename()); - if (filename.empty()) { + if (filename.is_empty()) { filename = root->get_name(); } file_export_lib->set_current_file(filename + String(".gltf")); diff --git a/modules/gltf/editor_scene_exporter_gltf_plugin.h b/modules/gltf/editor_scene_exporter_gltf_plugin.h index 1a8910d866..d952894c16 100644 --- a/modules/gltf/editor_scene_exporter_gltf_plugin.h +++ b/modules/gltf/editor_scene_exporter_gltf_plugin.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gltf/editor_scene_importer_gltf.cpp b/modules/gltf/editor_scene_importer_gltf.cpp index 51cb3a6d2e..6ea722a216 100644 --- a/modules/gltf/editor_scene_importer_gltf.cpp +++ b/modules/gltf/editor_scene_importer_gltf.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gltf/editor_scene_importer_gltf.h b/modules/gltf/editor_scene_importer_gltf.h index 3da987493c..db961e591d 100644 --- a/modules/gltf/editor_scene_importer_gltf.h +++ b/modules/gltf/editor_scene_importer_gltf.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gltf/gltf_accessor.cpp b/modules/gltf/gltf_accessor.cpp index 9267c58598..daeb084916 100644 --- a/modules/gltf/gltf_accessor.cpp +++ b/modules/gltf/gltf_accessor.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gltf/gltf_accessor.h b/modules/gltf/gltf_accessor.h index 7317928848..949a601730 100644 --- a/modules/gltf/gltf_accessor.h +++ b/modules/gltf/gltf_accessor.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gltf/gltf_animation.cpp b/modules/gltf/gltf_animation.cpp index 85ba117627..889a8e8870 100644 --- a/modules/gltf/gltf_animation.cpp +++ b/modules/gltf/gltf_animation.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gltf/gltf_animation.h b/modules/gltf/gltf_animation.h index 37fd1a2007..a494e6bd67 100644 --- a/modules/gltf/gltf_animation.h +++ b/modules/gltf/gltf_animation.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gltf/gltf_buffer_view.cpp b/modules/gltf/gltf_buffer_view.cpp index edfdad40bb..ba38a11c4c 100644 --- a/modules/gltf/gltf_buffer_view.cpp +++ b/modules/gltf/gltf_buffer_view.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gltf/gltf_buffer_view.h b/modules/gltf/gltf_buffer_view.h index 0b0c8af173..63af5e7c0d 100644 --- a/modules/gltf/gltf_buffer_view.h +++ b/modules/gltf/gltf_buffer_view.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gltf/gltf_camera.cpp b/modules/gltf/gltf_camera.cpp index e5cfc1cbb1..efa7c5d6d7 100644 --- a/modules/gltf/gltf_camera.cpp +++ b/modules/gltf/gltf_camera.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gltf/gltf_camera.h b/modules/gltf/gltf_camera.h index 7e167af7be..bf94b80bef 100644 --- a/modules/gltf/gltf_camera.h +++ b/modules/gltf/gltf_camera.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -38,8 +38,8 @@ class GLTFCamera : public Resource { private: bool perspective = true; - float fov_size = 75; - float zfar = 4000; + float fov_size = 75.0; + float zfar = 4000.0; float znear = 0.05; protected: diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp index 675f5002f7..4868347a74 100644 --- a/modules/gltf/gltf_document.cpp +++ b/modules/gltf/gltf_document.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -29,6 +29,9 @@ /*************************************************************************/ #include "gltf_document.h" +#include "core/error/error_list.h" +#include "core/error/error_macros.h" +#include "core/variant/variant.h" #include "gltf_accessor.h" #include "gltf_animation.h" #include "gltf_camera.h" @@ -54,8 +57,12 @@ #include "core/version_hash.gen.h" #include "drivers/png/png_driver_common.h" #include "editor/import/resource_importer_scene.h" +#ifdef MODULE_CSG_ENABLED #include "modules/csg/csg_shape.h" +#endif // MODULE_CSG_ENABLED +#ifdef MODULE_GRIDMAP_ENABLED #include "modules/gridmap/grid_map.h" +#endif // MODULE_GRIDMAP_ENABLED #include "modules/regex/regex.h" #include "scene/2d/node_2d.h" #include "scene/3d/bone_attachment_3d.h" @@ -178,7 +185,7 @@ Error GLTFDocument::serialize(Ref<GLTFState> state, Node *p_root, const String & } uint64_t elapsed = OS::get_singleton()->get_ticks_usec() - begin_time; float elapsed_sec = double(elapsed) / 1000000.0; - elapsed_sec = Math::stepify(elapsed_sec, 0.01f); + elapsed_sec = Math::snapped(elapsed_sec, 0.01f); print_line("glTF: Export time elapsed seconds " + rtos(elapsed_sec).pad_decimals(2)); return OK; @@ -204,7 +211,7 @@ Error GLTFDocument::_serialize_scenes(Ref<GLTFState> state) { if (state->nodes.size()) { Dictionary s; - if (!state->scene_name.empty()) { + if (!state->scene_name.is_empty()) { s["name"] = state->scene_name; } @@ -395,7 +402,7 @@ Error GLTFDocument::_serialize_nodes(Ref<GLTFState> state) { Ref<GLTFNode> n = state->nodes[i]; Dictionary extensions; node["extensions"] = extensions; - if (!n->get_name().empty()) { + if (!n->get_name().is_empty()) { node["name"] = n->get_name(); } if (n->camera != -1) { @@ -493,7 +500,7 @@ String GLTFDocument::_sanitize_bone_name(const String &name) { String GLTFDocument::_gen_unique_bone_name(Ref<GLTFState> state, const GLTFSkeletonIndex skel_i, const String &p_name) { String s_name = _sanitize_bone_name(p_name); - if (s_name.empty()) { + if (s_name.is_empty()) { s_name = "bone"; } String name; @@ -802,7 +809,9 @@ Error GLTFDocument::_encode_buffer_views(Ref<GLTFState> state) { } Error GLTFDocument::_parse_buffer_views(Ref<GLTFState> state) { - ERR_FAIL_COND_V(!state->json.has("bufferViews"), ERR_FILE_CORRUPT); + if (!state->json.has("bufferViews")) { + return OK; + } const Array &buffers = state->json["bufferViews"]; for (GLTFBufferViewIndex i = 0; i < buffers.size(); i++) { const Dictionary &d = buffers[i]; @@ -846,6 +855,7 @@ Error GLTFDocument::_encode_accessors(Ref<GLTFState> state) { d["count"] = accessor->count; d["type"] = _get_accessor_type_name(accessor->type); d["byteOffset"] = accessor->byte_offset; + d["normalized"] = accessor->normalized; d["max"] = accessor->max; d["min"] = accessor->min; d["bufferView"] = accessor->buffer_view; //optional because it may be sparse... @@ -938,7 +948,9 @@ GLTFDocument::GLTFType GLTFDocument::_get_type_from_str(const String &p_string) } Error GLTFDocument::_parse_accessors(Ref<GLTFState> state) { - ERR_FAIL_COND_V(!state->json.has("accessors"), ERR_FILE_CORRUPT); + if (!state->json.has("accessors")) { + return OK; + } const Array &accessors = state->json["accessors"]; for (GLTFAccessorIndex i = 0; i < accessors.size(); i++) { const Dictionary &d = accessors[i]; @@ -961,6 +973,10 @@ Error GLTFDocument::_parse_accessors(Ref<GLTFState> state) { accessor->byte_offset = d["byteOffset"]; } + if (d.has("normalized")) { + accessor->normalized = d["normalized"]; + } + if (d.has("max")) { accessor->max = d["max"]; } @@ -1455,7 +1471,7 @@ GLTFAccessorIndex GLTFDocument::_encode_accessor_as_ints(Ref<GLTFState> state, c Vector<double> type_min; type_min.resize(element_count); for (int i = 0; i < p_attribs.size(); i++) { - attribs.write[i] = Math::stepify(p_attribs[i], 1.0); + attribs.write[i] = Math::snapped(p_attribs[i], 1.0); if (i == 0) { for (int32_t type_i = 0; type_i < element_count; type_i++) { type_max.write[type_i] = attribs[(i * element_count) + type_i]; @@ -1547,8 +1563,8 @@ GLTFAccessorIndex GLTFDocument::_encode_accessor_as_vec2(Ref<GLTFState> state, c for (int i = 0; i < p_attribs.size(); i++) { Vector2 attrib = p_attribs[i]; - attribs.write[(i * element_count) + 0] = Math::stepify(attrib.x, CMP_NORMALIZE_TOLERANCE); - attribs.write[(i * element_count) + 1] = Math::stepify(attrib.y, CMP_NORMALIZE_TOLERANCE); + attribs.write[(i * element_count) + 0] = Math::snapped(attrib.x, CMP_NORMALIZE_TOLERANCE); + attribs.write[(i * element_count) + 1] = Math::snapped(attrib.y, CMP_NORMALIZE_TOLERANCE); _calc_accessor_min_max(i, element_count, type_max, attribs, type_min); } @@ -1593,10 +1609,10 @@ GLTFAccessorIndex GLTFDocument::_encode_accessor_as_color(Ref<GLTFState> state, type_min.resize(element_count); for (int i = 0; i < p_attribs.size(); i++) { Color attrib = p_attribs[i]; - attribs.write[(i * element_count) + 0] = Math::stepify(attrib.r, CMP_NORMALIZE_TOLERANCE); - attribs.write[(i * element_count) + 1] = Math::stepify(attrib.g, CMP_NORMALIZE_TOLERANCE); - attribs.write[(i * element_count) + 2] = Math::stepify(attrib.b, CMP_NORMALIZE_TOLERANCE); - attribs.write[(i * element_count) + 3] = Math::stepify(attrib.a, CMP_NORMALIZE_TOLERANCE); + attribs.write[(i * element_count) + 0] = Math::snapped(attrib.r, CMP_NORMALIZE_TOLERANCE); + attribs.write[(i * element_count) + 1] = Math::snapped(attrib.g, CMP_NORMALIZE_TOLERANCE); + attribs.write[(i * element_count) + 2] = Math::snapped(attrib.b, CMP_NORMALIZE_TOLERANCE); + attribs.write[(i * element_count) + 3] = Math::snapped(attrib.a, CMP_NORMALIZE_TOLERANCE); _calc_accessor_min_max(i, element_count, type_max, attribs, type_min); } @@ -1658,10 +1674,10 @@ GLTFAccessorIndex GLTFDocument::_encode_accessor_as_weights(Ref<GLTFState> state type_min.resize(element_count); for (int i = 0; i < p_attribs.size(); i++) { Color attrib = p_attribs[i]; - attribs.write[(i * element_count) + 0] = Math::stepify(attrib.r, CMP_NORMALIZE_TOLERANCE); - attribs.write[(i * element_count) + 1] = Math::stepify(attrib.g, CMP_NORMALIZE_TOLERANCE); - attribs.write[(i * element_count) + 2] = Math::stepify(attrib.b, CMP_NORMALIZE_TOLERANCE); - attribs.write[(i * element_count) + 3] = Math::stepify(attrib.a, CMP_NORMALIZE_TOLERANCE); + attribs.write[(i * element_count) + 0] = Math::snapped(attrib.r, CMP_NORMALIZE_TOLERANCE); + attribs.write[(i * element_count) + 1] = Math::snapped(attrib.g, CMP_NORMALIZE_TOLERANCE); + attribs.write[(i * element_count) + 2] = Math::snapped(attrib.b, CMP_NORMALIZE_TOLERANCE); + attribs.write[(i * element_count) + 3] = Math::snapped(attrib.a, CMP_NORMALIZE_TOLERANCE); _calc_accessor_min_max(i, element_count, type_max, attribs, type_min); } @@ -1707,10 +1723,10 @@ GLTFAccessorIndex GLTFDocument::_encode_accessor_as_joints(Ref<GLTFState> state, type_min.resize(element_count); for (int i = 0; i < p_attribs.size(); i++) { Color attrib = p_attribs[i]; - attribs.write[(i * element_count) + 0] = Math::stepify(attrib.r, CMP_NORMALIZE_TOLERANCE); - attribs.write[(i * element_count) + 1] = Math::stepify(attrib.g, CMP_NORMALIZE_TOLERANCE); - attribs.write[(i * element_count) + 2] = Math::stepify(attrib.b, CMP_NORMALIZE_TOLERANCE); - attribs.write[(i * element_count) + 3] = Math::stepify(attrib.a, CMP_NORMALIZE_TOLERANCE); + attribs.write[(i * element_count) + 0] = Math::snapped(attrib.r, CMP_NORMALIZE_TOLERANCE); + attribs.write[(i * element_count) + 1] = Math::snapped(attrib.g, CMP_NORMALIZE_TOLERANCE); + attribs.write[(i * element_count) + 2] = Math::snapped(attrib.b, CMP_NORMALIZE_TOLERANCE); + attribs.write[(i * element_count) + 3] = Math::snapped(attrib.a, CMP_NORMALIZE_TOLERANCE); _calc_accessor_min_max(i, element_count, type_max, attribs, type_min); } ERR_FAIL_COND_V(attribs.size() % element_count != 0, -1); @@ -1754,10 +1770,10 @@ GLTFAccessorIndex GLTFDocument::_encode_accessor_as_quats(Ref<GLTFState> state, type_min.resize(element_count); for (int i = 0; i < p_attribs.size(); i++) { Quat quat = p_attribs[i]; - attribs.write[(i * element_count) + 0] = Math::stepify(quat.x, CMP_NORMALIZE_TOLERANCE); - attribs.write[(i * element_count) + 1] = Math::stepify(quat.y, CMP_NORMALIZE_TOLERANCE); - attribs.write[(i * element_count) + 2] = Math::stepify(quat.z, CMP_NORMALIZE_TOLERANCE); - attribs.write[(i * element_count) + 3] = Math::stepify(quat.w, CMP_NORMALIZE_TOLERANCE); + attribs.write[(i * element_count) + 0] = Math::snapped(quat.x, CMP_NORMALIZE_TOLERANCE); + attribs.write[(i * element_count) + 1] = Math::snapped(quat.y, CMP_NORMALIZE_TOLERANCE); + attribs.write[(i * element_count) + 2] = Math::snapped(quat.z, CMP_NORMALIZE_TOLERANCE); + attribs.write[(i * element_count) + 3] = Math::snapped(quat.w, CMP_NORMALIZE_TOLERANCE); _calc_accessor_min_max(i, element_count, type_max, attribs, type_min); } @@ -1821,7 +1837,7 @@ GLTFAccessorIndex GLTFDocument::_encode_accessor_as_floats(Ref<GLTFState> state, type_min.resize(element_count); for (int i = 0; i < p_attribs.size(); i++) { - attribs.write[i] = Math::stepify(p_attribs[i], CMP_NORMALIZE_TOLERANCE); + attribs.write[i] = Math::snapped(p_attribs[i], CMP_NORMALIZE_TOLERANCE); _calc_accessor_min_max(i, element_count, type_max, attribs, type_min); } @@ -1866,9 +1882,9 @@ GLTFAccessorIndex GLTFDocument::_encode_accessor_as_vec3(Ref<GLTFState> state, c type_min.resize(element_count); for (int i = 0; i < p_attribs.size(); i++) { Vector3 attrib = p_attribs[i]; - attribs.write[(i * element_count) + 0] = Math::stepify(attrib.x, CMP_NORMALIZE_TOLERANCE); - attribs.write[(i * element_count) + 1] = Math::stepify(attrib.y, CMP_NORMALIZE_TOLERANCE); - attribs.write[(i * element_count) + 2] = Math::stepify(attrib.z, CMP_NORMALIZE_TOLERANCE); + attribs.write[(i * element_count) + 0] = Math::snapped(attrib.x, CMP_NORMALIZE_TOLERANCE); + attribs.write[(i * element_count) + 1] = Math::snapped(attrib.y, CMP_NORMALIZE_TOLERANCE); + attribs.write[(i * element_count) + 2] = Math::snapped(attrib.z, CMP_NORMALIZE_TOLERANCE); _calc_accessor_min_max(i, element_count, type_max, attribs, type_min); } @@ -1915,27 +1931,27 @@ GLTFAccessorIndex GLTFDocument::_encode_accessor_as_xform(Ref<GLTFState> state, Basis basis = attrib.get_basis(); Vector3 axis_0 = basis.get_axis(Vector3::AXIS_X); - attribs.write[i * element_count + 0] = Math::stepify(axis_0.x, CMP_NORMALIZE_TOLERANCE); - attribs.write[i * element_count + 1] = Math::stepify(axis_0.y, CMP_NORMALIZE_TOLERANCE); - attribs.write[i * element_count + 2] = Math::stepify(axis_0.z, CMP_NORMALIZE_TOLERANCE); + attribs.write[i * element_count + 0] = Math::snapped(axis_0.x, CMP_NORMALIZE_TOLERANCE); + attribs.write[i * element_count + 1] = Math::snapped(axis_0.y, CMP_NORMALIZE_TOLERANCE); + attribs.write[i * element_count + 2] = Math::snapped(axis_0.z, CMP_NORMALIZE_TOLERANCE); attribs.write[i * element_count + 3] = 0.0; Vector3 axis_1 = basis.get_axis(Vector3::AXIS_Y); - attribs.write[i * element_count + 4] = Math::stepify(axis_1.x, CMP_NORMALIZE_TOLERANCE); - attribs.write[i * element_count + 5] = Math::stepify(axis_1.y, CMP_NORMALIZE_TOLERANCE); - attribs.write[i * element_count + 6] = Math::stepify(axis_1.z, CMP_NORMALIZE_TOLERANCE); + attribs.write[i * element_count + 4] = Math::snapped(axis_1.x, CMP_NORMALIZE_TOLERANCE); + attribs.write[i * element_count + 5] = Math::snapped(axis_1.y, CMP_NORMALIZE_TOLERANCE); + attribs.write[i * element_count + 6] = Math::snapped(axis_1.z, CMP_NORMALIZE_TOLERANCE); attribs.write[i * element_count + 7] = 0.0; Vector3 axis_2 = basis.get_axis(Vector3::AXIS_Z); - attribs.write[i * element_count + 8] = Math::stepify(axis_2.x, CMP_NORMALIZE_TOLERANCE); - attribs.write[i * element_count + 9] = Math::stepify(axis_2.y, CMP_NORMALIZE_TOLERANCE); - attribs.write[i * element_count + 10] = Math::stepify(axis_2.z, CMP_NORMALIZE_TOLERANCE); + attribs.write[i * element_count + 8] = Math::snapped(axis_2.x, CMP_NORMALIZE_TOLERANCE); + attribs.write[i * element_count + 9] = Math::snapped(axis_2.y, CMP_NORMALIZE_TOLERANCE); + attribs.write[i * element_count + 10] = Math::snapped(axis_2.z, CMP_NORMALIZE_TOLERANCE); attribs.write[i * element_count + 11] = 0.0; Vector3 origin = attrib.get_origin(); - attribs.write[i * element_count + 12] = Math::stepify(origin.x, CMP_NORMALIZE_TOLERANCE); - attribs.write[i * element_count + 13] = Math::stepify(origin.y, CMP_NORMALIZE_TOLERANCE); - attribs.write[i * element_count + 14] = Math::stepify(origin.z, CMP_NORMALIZE_TOLERANCE); + attribs.write[i * element_count + 12] = Math::snapped(origin.x, CMP_NORMALIZE_TOLERANCE); + attribs.write[i * element_count + 13] = Math::snapped(origin.y, CMP_NORMALIZE_TOLERANCE); + attribs.write[i * element_count + 14] = Math::snapped(origin.z, CMP_NORMALIZE_TOLERANCE); attribs.write[i * element_count + 15] = 1.0; _calc_accessor_min_max(i, element_count, type_max, attribs, type_min); @@ -2194,33 +2210,81 @@ Error GLTFDocument::_serialize_meshes(Ref<GLTFState> state) { } } { - Array a = array[Mesh::ARRAY_BONES]; - if (a.size()) { - const int ret_size = a.size() / 4; + const Array &a = array[Mesh::ARRAY_BONES]; + const Vector<Vector3> &vertex_array = array[Mesh::ARRAY_VERTEX]; + if ((a.size() / JOINT_GROUP_SIZE) == vertex_array.size()) { + const int ret_size = a.size() / JOINT_GROUP_SIZE; Vector<Color> attribs; attribs.resize(ret_size); { for (int array_i = 0; array_i < attribs.size(); array_i++) { - int32_t joint_0 = a[(array_i * 4) + 0]; - int32_t joint_1 = a[(array_i * 4) + 1]; - int32_t joint_2 = a[(array_i * 4) + 2]; - int32_t joint_3 = a[(array_i * 4) + 3]; + int32_t joint_0 = a[(array_i * JOINT_GROUP_SIZE) + 0]; + int32_t joint_1 = a[(array_i * JOINT_GROUP_SIZE) + 1]; + int32_t joint_2 = a[(array_i * JOINT_GROUP_SIZE) + 2]; + int32_t joint_3 = a[(array_i * JOINT_GROUP_SIZE) + 3]; attribs.write[array_i] = Color(joint_0, joint_1, joint_2, joint_3); } } attributes["JOINTS_0"] = _encode_accessor_as_joints(state, attribs, true); + } else if ((a.size() / (JOINT_GROUP_SIZE * 2)) >= vertex_array.size()) { + int32_t vertex_count = vertex_array.size(); + Vector<Color> joints_0; + joints_0.resize(vertex_count); + Vector<Color> joints_1; + joints_1.resize(vertex_count); + int32_t weights_8_count = JOINT_GROUP_SIZE * 2; + for (int32_t vertex_i = 0; vertex_i < vertex_count; vertex_i++) { + Color joint_0; + joint_0.r = a[vertex_i * weights_8_count + 0]; + joint_0.g = a[vertex_i * weights_8_count + 1]; + joint_0.b = a[vertex_i * weights_8_count + 2]; + joint_0.a = a[vertex_i * weights_8_count + 3]; + joints_0.write[vertex_i] = joint_0; + Color joint_1; + joint_1.r = a[vertex_i * weights_8_count + 4]; + joint_1.g = a[vertex_i * weights_8_count + 5]; + joint_1.b = a[vertex_i * weights_8_count + 6]; + joint_1.a = a[vertex_i * weights_8_count + 7]; + joints_1.write[vertex_i] = joint_1; + } + attributes["JOINTS_0"] = _encode_accessor_as_joints(state, joints_0, true); + attributes["JOINTS_1"] = _encode_accessor_as_joints(state, joints_1, true); } } { - Array a = array[Mesh::ARRAY_WEIGHTS]; - if (a.size()) { - const int ret_size = a.size() / 4; + const Array &a = array[Mesh::ARRAY_WEIGHTS]; + const Vector<Vector3> &vertex_array = array[Mesh::ARRAY_VERTEX]; + if ((a.size() / JOINT_GROUP_SIZE) == vertex_array.size()) { + const int ret_size = a.size() / JOINT_GROUP_SIZE; Vector<Color> attribs; attribs.resize(ret_size); for (int i = 0; i < ret_size; i++) { - attribs.write[i] = Color(a[(i * 4) + 0], a[(i * 4) + 1], a[(i * 4) + 2], a[(i * 4) + 3]); + attribs.write[i] = Color(a[(i * JOINT_GROUP_SIZE) + 0], a[(i * JOINT_GROUP_SIZE) + 1], a[(i * JOINT_GROUP_SIZE) + 2], a[(i * JOINT_GROUP_SIZE) + 3]); } attributes["WEIGHTS_0"] = _encode_accessor_as_weights(state, attribs, true); + } else if ((a.size() / (JOINT_GROUP_SIZE * 2)) >= vertex_array.size()) { + int32_t vertex_count = vertex_array.size(); + Vector<Color> weights_0; + weights_0.resize(vertex_count); + Vector<Color> weights_1; + weights_1.resize(vertex_count); + int32_t weights_8_count = JOINT_GROUP_SIZE * 2; + for (int32_t vertex_i = 0; vertex_i < vertex_count; vertex_i++) { + Color weight_0; + weight_0.r = a[vertex_i * weights_8_count + 0]; + weight_0.g = a[vertex_i * weights_8_count + 1]; + weight_0.b = a[vertex_i * weights_8_count + 2]; + weight_0.a = a[vertex_i * weights_8_count + 3]; + weights_0.write[vertex_i] = weight_0; + Color weight_1; + weight_1.r = a[vertex_i * weights_8_count + 4]; + weight_1.g = a[vertex_i * weights_8_count + 5]; + weight_1.b = a[vertex_i * weights_8_count + 6]; + weight_1.a = a[vertex_i * weights_8_count + 7]; + weights_1.write[vertex_i] = weight_1; + } + attributes["WEIGHTS_0"] = _encode_accessor_as_weights(state, weights_0, true); + attributes["WEIGHTS_1"] = _encode_accessor_as_weights(state, weights_1, true); } } { @@ -2327,7 +2391,7 @@ Error GLTFDocument::_serialize_meshes(Ref<GLTFState> state) { e["targetNames"] = target_names; for (int j = 0; j < target_names.size(); j++) { - real_t weight = 0; + real_t weight = 0.0; if (j < state->meshes.write[gltf_mesh_i]->get_blend_weights().size()) { weight = state->meshes.write[gltf_mesh_i]->get_blend_weights()[j]; } @@ -2423,10 +2487,29 @@ Error GLTFDocument::_parse_meshes(Ref<GLTFState> state) { array[Mesh::ARRAY_COLOR] = _decode_accessor_as_color(state, a["COLOR_0"], true); has_vertex_color = true; } - if (a.has("JOINTS_0")) { + if (a.has("JOINTS_0") && !a.has("JOINTS_1")) { array[Mesh::ARRAY_BONES] = _decode_accessor_as_ints(state, a["JOINTS_0"], true); + } else if (a.has("JOINTS_0") && a.has("JOINTS_1")) { + PackedInt32Array joints_0 = _decode_accessor_as_ints(state, a["JOINTS_0"], true); + PackedInt32Array joints_1 = _decode_accessor_as_ints(state, a["JOINTS_1"], true); + ERR_FAIL_COND_V(joints_0.size() != joints_0.size(), ERR_INVALID_DATA); + int32_t weight_8_count = JOINT_GROUP_SIZE * 2; + int32_t vertex_count = joints_0.size() / JOINT_GROUP_SIZE; + Vector<int> joints; + joints.resize(vertex_count * weight_8_count); + for (int32_t vertex_i = 0; vertex_i < vertex_count; vertex_i++) { + joints.write[vertex_i * weight_8_count + 0] = joints_0[vertex_i * JOINT_GROUP_SIZE + 0]; + joints.write[vertex_i * weight_8_count + 1] = joints_0[vertex_i * JOINT_GROUP_SIZE + 1]; + joints.write[vertex_i * weight_8_count + 2] = joints_0[vertex_i * JOINT_GROUP_SIZE + 2]; + joints.write[vertex_i * weight_8_count + 3] = joints_0[vertex_i * JOINT_GROUP_SIZE + 3]; + joints.write[vertex_i * weight_8_count + 4] = joints_1[vertex_i * JOINT_GROUP_SIZE + 0]; + joints.write[vertex_i * weight_8_count + 5] = joints_1[vertex_i * JOINT_GROUP_SIZE + 1]; + joints.write[vertex_i * weight_8_count + 6] = joints_1[vertex_i * JOINT_GROUP_SIZE + 2]; + joints.write[vertex_i * weight_8_count + 7] = joints_1[vertex_i * JOINT_GROUP_SIZE + 3]; + } + array[Mesh::ARRAY_BONES] = joints; } - if (a.has("WEIGHTS_0")) { + if (a.has("WEIGHTS_0") && !a.has("WEIGHTS_1")) { Vector<float> weights = _decode_accessor_as_floats(state, a["WEIGHTS_0"], true); { //gltf does not seem to normalize the weights for some reason.. int wc = weights.size(); @@ -2447,6 +2530,51 @@ Error GLTFDocument::_parse_meshes(Ref<GLTFState> state) { } } array[Mesh::ARRAY_WEIGHTS] = weights; + } else if (a.has("WEIGHTS_0") && a.has("WEIGHTS_1")) { + Vector<float> weights_0 = _decode_accessor_as_floats(state, a["WEIGHTS_0"], true); + Vector<float> weights_1 = _decode_accessor_as_floats(state, a["WEIGHTS_1"], true); + Vector<float> weights; + ERR_FAIL_COND_V(weights_0.size() != weights_1.size(), ERR_INVALID_DATA); + int32_t weight_8_count = JOINT_GROUP_SIZE * 2; + int32_t vertex_count = weights_0.size() / JOINT_GROUP_SIZE; + weights.resize(vertex_count * weight_8_count); + for (int32_t vertex_i = 0; vertex_i < vertex_count; vertex_i++) { + weights.write[vertex_i * weight_8_count + 0] = weights_0[vertex_i * JOINT_GROUP_SIZE + 0]; + weights.write[vertex_i * weight_8_count + 1] = weights_0[vertex_i * JOINT_GROUP_SIZE + 1]; + weights.write[vertex_i * weight_8_count + 2] = weights_0[vertex_i * JOINT_GROUP_SIZE + 2]; + weights.write[vertex_i * weight_8_count + 3] = weights_0[vertex_i * JOINT_GROUP_SIZE + 3]; + weights.write[vertex_i * weight_8_count + 4] = weights_1[vertex_i * JOINT_GROUP_SIZE + 0]; + weights.write[vertex_i * weight_8_count + 5] = weights_1[vertex_i * JOINT_GROUP_SIZE + 1]; + weights.write[vertex_i * weight_8_count + 6] = weights_1[vertex_i * JOINT_GROUP_SIZE + 2]; + weights.write[vertex_i * weight_8_count + 7] = weights_1[vertex_i * JOINT_GROUP_SIZE + 3]; + } + { //gltf does not seem to normalize the weights for some reason.. + int wc = weights.size(); + float *w = weights.ptrw(); + + for (int k = 0; k < wc; k += weight_8_count) { + float total = 0.0; + total += w[k + 0]; + total += w[k + 1]; + total += w[k + 2]; + total += w[k + 3]; + total += w[k + 4]; + total += w[k + 5]; + total += w[k + 6]; + total += w[k + 7]; + if (total > 0.0) { + w[k + 0] /= total; + w[k + 1] /= total; + w[k + 2] /= total; + w[k + 3] /= total; + w[k + 4] /= total; + w[k + 5] /= total; + w[k + 6] /= total; + w[k + 7] /= total; + } + } + } + array[Mesh::ARRAY_WEIGHTS] = weights; } if (p.has("indices")) { @@ -2487,6 +2615,9 @@ Error GLTFDocument::_parse_meshes(Ref<GLTFState> state) { //must generate mikktspace tangents.. ergh.. Ref<SurfaceTool> st; st.instance(); + if (a.has("JOINTS_0") && a.has("JOINTS_1")) { + st->set_skin_weight_count(SurfaceTool::SKIN_8_WEIGHTS); + } st->create_from_triangle_arrays(array); st->generate_tangents(); array = st->commit_to_arrays(); @@ -2603,6 +2734,9 @@ Error GLTFDocument::_parse_meshes(Ref<GLTFState> state) { if (generate_tangents) { Ref<SurfaceTool> st; st.instance(); + if (a.has("JOINTS_0") && a.has("JOINTS_1")) { + st->set_skin_weight_count(SurfaceTool::SKIN_8_WEIGHTS); + } st->create_from_triangle_arrays(array_copy); st->deindex(); st->generate_tangents(); @@ -2644,6 +2778,9 @@ Error GLTFDocument::_parse_meshes(Ref<GLTFState> state) { if (d.has("weights")) { const Array &weights = d["weights"]; for (int j = 0; j < weights.size(); j++) { + if (j >= blend_weights.size()) { + break; + } blend_weights.write[j] = weights[j]; } mesh->set_blend_weights(blend_weights); @@ -2698,7 +2835,7 @@ Error GLTFDocument::_serialize_images(Ref<GLTFState> state, const String &p_path d["mimeType"] = "image/png"; } else { String name = state->images[i]->get_name(); - if (name.empty()) { + if (name.is_empty()) { name = itos(i); } name = _gen_unique_name(state, name); @@ -2780,7 +2917,7 @@ Error GLTFDocument::_parse_images(Ref<GLTFState> state, const String &p_base_pat data_ptr = data.ptr(); data_size = data.size(); // mimeType is optional, but if we have it defined in the URI, let's use it. - if (mimetype.empty()) { + if (mimetype.is_empty()) { if (uri.begins_with("data:image/png;base64")) { mimetype = "image/png"; } else if (uri.begins_with("data:image/jpeg;base64")) { @@ -2789,27 +2926,36 @@ Error GLTFDocument::_parse_images(Ref<GLTFState> state, const String &p_base_pat } } else { // Relative path to an external image file. uri = p_base_path.plus_file(uri).replace("\\", "/"); // Fix for Windows. - // The spec says that if mimeType is defined, we should enforce it. - // So we should only rely on ResourceLoader::load if mimeType is not defined, - // otherwise we should use the same logic as for buffers. - if (mimetype == "image/png" || mimetype == "image/jpeg") { - // Load data buffer and rely on PNG and JPEG-specific logic below to load the image. - // This makes it possible to load a file with a wrong extension but correct MIME type, - // e.g. "foo.jpg" containing PNG data and with MIME type "image/png". ResourceLoader would fail. + // ResourceLoader will rely on the file extension to use the relevant loader. + // The spec says that if mimeType is defined, it should take precedence (e.g. + // there could be a `.png` image which is actually JPEG), but there's no easy + // API for that in Godot, so we'd have to load as a buffer (i.e. embedded in + // the material), so we do this only as fallback. + Ref<Texture2D> texture = ResourceLoader::load(uri); + if (texture.is_valid()) { + state->images.push_back(texture); + continue; + } else if (mimetype == "image/png" || mimetype == "image/jpeg") { + // Fallback to loading as byte array. + // This enables us to support the spec's requirement that we honor mimetype + // regardless of file URI. data = FileAccess::get_file_as_array(uri); - ERR_FAIL_COND_V_MSG(data.size() == 0, ERR_PARSE_ERROR, "glTF: Couldn't load image file as an array: " + uri); + if (data.size() == 0) { + WARN_PRINT(vformat("glTF: Image index '%d' couldn't be loaded as a buffer of MIME type '%s' from URI: %s. Skipping it.", i, mimetype, uri)); + state->images.push_back(Ref<Texture2D>()); // Placeholder to keep count. + continue; + } data_ptr = data.ptr(); data_size = data.size(); } else { - // Good old ResourceLoader will rely on file extension. - Ref<Texture2D> texture = ResourceLoader::load(uri); - state->images.push_back(texture); + WARN_PRINT(vformat("glTF: Image index '%d' couldn't be loaded from URI: %s. Skipping it.", i, uri)); + state->images.push_back(Ref<Texture2D>()); // Placeholder to keep count. continue; } } } else if (d.has("bufferView")) { // Handles the third bullet point from the spec (bufferView). - ERR_FAIL_COND_V_MSG(mimetype.empty(), ERR_FILE_CORRUPT, + ERR_FAIL_COND_V_MSG(mimetype.is_empty(), ERR_FILE_CORRUPT, vformat("glTF: Image index '%d' specifies 'bufferView' but no 'mimeType', which is invalid.", i)); const GLTFBufferViewIndex bvi = d["bufferView"]; @@ -2931,7 +3077,7 @@ Error GLTFDocument::_serialize_materials(Ref<GLTFState> state) { materials.push_back(d); continue; } - if (!material->get_name().empty()) { + if (!material->get_name().is_empty()) { d["name"] = _gen_unique_name(state, material->get_name()); } { @@ -4066,7 +4212,7 @@ Error GLTFDocument::_create_skeletons(Ref<GLTFState> state) { // a sorted order, and DEPTH FIRST bones.sort(); - while (!bones.empty()) { + while (!bones.is_empty()) { const GLTFNodeIndex node_i = bones.front()->get(); bones.pop_front(); @@ -4091,7 +4237,7 @@ Error GLTFDocument::_create_skeletons(Ref<GLTFState> state) { const int bone_index = skeleton->get_bone_count(); - if (node->get_name().empty()) { + if (node->get_name().is_empty()) { node->set_name("bone"); } @@ -4148,7 +4294,7 @@ Error GLTFDocument::_create_skins(Ref<GLTFState> state) { skin.instance(); // Some skins don't have IBM's! What absolute monsters! - const bool has_ibms = !gltf_skin->inverse_binds.empty(); + const bool has_ibms = !gltf_skin->inverse_binds.is_empty(); for (int joint_i = 0; joint_i < gltf_skin->joints_original.size(); ++joint_i) { GLTFNodeIndex node = gltf_skin->joints_original[joint_i]; @@ -4176,7 +4322,7 @@ Error GLTFDocument::_create_skins(Ref<GLTFState> state) { // Create unique names now, after removing duplicates for (GLTFSkinIndex skin_i = 0; skin_i < state->skins.size(); ++skin_i) { Ref<Skin> skin = state->skins.write[skin_i]->godot_skin; - if (skin->get_name().empty()) { + if (skin->get_name().is_empty()) { // Make a unique name, no gltf node represents this skin skin->set_name(_gen_unique_name(state, "Skin")); } @@ -4442,7 +4588,7 @@ Error GLTFDocument::_serialize_animations(Ref<GLTFState> state) { continue; } - if (!gltf_animation->get_name().empty()) { + if (!gltf_animation->get_name().is_empty()) { d["name"] = gltf_animation->get_name(); } Array channels; @@ -4702,7 +4848,7 @@ void GLTFDocument::_assign_scene_names(Ref<GLTFState> state) { if (n->skeleton >= 0) continue; - if (n->get_name().empty()) { + if (n->get_name().is_empty()) { if (n->mesh >= 0) { n->set_name(_gen_unique_name(state, "Mesh")); } else if (n->camera >= 0) { @@ -4883,12 +5029,12 @@ GLTFCameraIndex GLTFDocument::_convert_camera(Ref<GLTFState> state, Camera3D *p_ if (p_camera->get_projection() == Camera3D::Projection::PROJECTION_PERSPECTIVE) { c->set_perspective(true); c->set_fov_size(p_camera->get_fov()); - c->set_zfar(p_camera->get_zfar()); - c->set_znear(p_camera->get_znear()); + c->set_zfar(p_camera->get_far()); + c->set_znear(p_camera->get_near()); } else { c->set_fov_size(p_camera->get_fov()); - c->set_zfar(p_camera->get_zfar()); - c->set_znear(p_camera->get_znear()); + c->set_zfar(p_camera->get_far()); + c->set_znear(p_camera->get_near()); } GLTFCameraIndex camera_index = state->cameras.size(); state->cameras.push_back(c); @@ -4959,7 +5105,6 @@ Node3D *GLTFDocument::_generate_spatial(Ref<GLTFState> state, Node *scene_parent } void GLTFDocument::_convert_scene_node(Ref<GLTFState> state, Node *p_current, Node *p_root, const GLTFNodeIndex p_gltf_parent, const GLTFNodeIndex p_gltf_root) { bool retflag = true; - Node3D *spatial = cast_to<Node3D>(p_current); _check_visibility(p_current, retflag); if (retflag) { return; @@ -4968,9 +5113,11 @@ void GLTFDocument::_convert_scene_node(Ref<GLTFState> state, Node *p_current, No gltf_node.instance(); gltf_node->set_name(_gen_unique_name(state, p_current->get_name())); if (cast_to<Node3D>(p_current)) { + Node3D *spatial = cast_to<Node3D>(p_current); _convert_spatial(state, spatial, gltf_node); } if (cast_to<MeshInstance3D>(p_current)) { + Node3D *spatial = cast_to<Node3D>(p_current); _convert_mesh_to_gltf(p_current, state, spatial, gltf_node); } else if (cast_to<BoneAttachment3D>(p_current)) { _convert_bone_attachment_to_gltf(p_current, state, gltf_node, retflag); @@ -4982,18 +5129,22 @@ void GLTFDocument::_convert_scene_node(Ref<GLTFState> state, Node *p_current, No return; } else if (cast_to<MultiMeshInstance3D>(p_current)) { _convert_mult_mesh_instance_to_gltf(p_current, p_gltf_parent, p_gltf_root, gltf_node, state, p_root); +#ifdef MODULE_CSG_ENABLED } else if (cast_to<CSGShape3D>(p_current)) { if (p_current->get_parent() && cast_to<CSGShape3D>(p_current)->is_root_shape()) { _convert_csg_shape_to_gltf(p_current, p_gltf_parent, gltf_node, state); } +#endif // MODULE_CSG_ENABLED +#ifdef MODULE_GRIDMAP_ENABLED } else if (cast_to<GridMap>(p_current)) { _convert_grid_map_to_gltf(p_current, p_gltf_parent, p_gltf_root, gltf_node, state, p_root); +#endif // MODULE_GRIDMAP_ENABLED } else if (cast_to<Camera3D>(p_current)) { Camera3D *camera = Object::cast_to<Camera3D>(p_current); - _convert_camera_to_gltf(camera, state, spatial, gltf_node); + _convert_camera_to_gltf(camera, state, camera, gltf_node); } else if (cast_to<Light3D>(p_current)) { Light3D *light = Object::cast_to<Light3D>(p_current); - _convert_light_to_gltf(light, state, spatial, gltf_node); + _convert_light_to_gltf(light, state, light, gltf_node); } else if (cast_to<AnimationPlayer>(p_current)) { AnimationPlayer *animation_player = Object::cast_to<AnimationPlayer>(p_current); _convert_animation_player_to_gltf(animation_player, state, p_gltf_parent, p_gltf_root, gltf_node, p_current, p_root); @@ -5012,6 +5163,7 @@ void GLTFDocument::_convert_scene_node(Ref<GLTFState> state, Node *p_current, No } } +#ifdef MODULE_CSG_ENABLED void GLTFDocument::_convert_csg_shape_to_gltf(Node *p_current, GLTFNodeIndex p_gltf_parent, Ref<GLTFNode> gltf_node, Ref<GLTFState> state) { CSGShape3D *csg = Object::cast_to<CSGShape3D>(p_current); csg->call("_update_shape"); @@ -5038,6 +5190,7 @@ void GLTFDocument::_convert_csg_shape_to_gltf(Node *p_current, GLTFNodeIndex p_g gltf_node->xform = csg->get_meshes()[0]; gltf_node->set_name(_gen_unique_name(state, csg->get_name())); } +#endif // MODULE_CSG_ENABLED void GLTFDocument::_create_gltf_node(Ref<GLTFState> state, Node *p_scene_parent, GLTFNodeIndex current_node_i, GLTFNodeIndex p_parent_node_index, GLTFNodeIndex p_root_gltf_node, Ref<GLTFNode> gltf_node) { @@ -5087,6 +5240,7 @@ void GLTFDocument::_convert_light_to_gltf(Light3D *light, Ref<GLTFState> state, } } +#ifdef MODULE_GRIDMAP_ENABLED void GLTFDocument::_convert_grid_map_to_gltf(Node *p_scene_parent, const GLTFNodeIndex &p_parent_node_index, const GLTFNodeIndex &p_root_node_index, Ref<GLTFNode> gltf_node, Ref<GLTFState> state, Node *p_root_node) { GridMap *grid_map = Object::cast_to<GridMap>(p_scene_parent); ERR_FAIL_COND(!grid_map); @@ -5118,6 +5272,7 @@ void GLTFDocument::_convert_grid_map_to_gltf(Node *p_scene_parent, const GLTFNod new_gltf_node->set_name(_gen_unique_name(state, grid_map->get_mesh_library()->get_item_name(cell))); } } +#endif // MODULE_GRIDMAP_ENABLED void GLTFDocument::_convert_mult_mesh_instance_to_gltf(Node *p_scene_parent, const GLTFNodeIndex &p_parent_node_index, const GLTFNodeIndex &p_root_node_index, Ref<GLTFNode> gltf_node, Ref<GLTFState> state, Node *p_root_node) { MultiMeshInstance3D *multi_mesh_instance = Object::cast_to<MultiMeshInstance3D>(p_scene_parent); @@ -5133,8 +5288,7 @@ void GLTFDocument::_convert_mult_mesh_instance_to_gltf(Node *p_scene_parent, con transform.origin = Vector3(xform_2d.get_origin().x, 0, xform_2d.get_origin().y); real_t rotation = xform_2d.get_rotation(); - Quat quat; - quat.set_axis_angle(Vector3(0, 1, 0), rotation); + Quat quat(Vector3(0, 1, 0), rotation); Size2 scale = xform_2d.get_scale(); transform.basis.set_quat_scale(quat, Vector3(scale.x, 0, scale.y)); @@ -5402,7 +5556,7 @@ void GLTFDocument::_import_animation(Ref<GLTFState> state, AnimationPlayer *ap, Ref<GLTFAnimation> anim = state->animations[index]; String name = anim->get_name(); - if (name.empty()) { + if (name.is_empty()) { // No node represent these, and they are not in the hierarchy, so just make a unique name name = _gen_unique_name(state, "Animation"); } @@ -5415,7 +5569,7 @@ void GLTFDocument::_import_animation(Ref<GLTFState> state, AnimationPlayer *ap, animation->set_loop(true); } - float length = 0; + float length = 0.0; for (Map<int, GLTFAnimation::Track>::Element *track_i = anim->get_tracks().front(); track_i; track_i = track_i->next()) { const GLTFAnimation::Track &track = track_i->get(); @@ -5647,7 +5801,7 @@ void GLTFDocument::_convert_mesh_instances(Ref<GLTFState> state) { Ref<GLTFSkeleton> gltf_skeleton = state->skeletons.write[skeleton_gltf_i]; for (int32_t bind_i = 0; bind_i < skin->get_bind_count(); bind_i++) { String godot_bone_name = skin->get_bind_name(bind_i); - if (godot_bone_name.empty()) { + if (godot_bone_name.is_empty()) { int32_t bone = skin->get_bind_bone(bind_i); godot_bone_name = skeleton->get_bone_name(bone); } @@ -5886,14 +6040,12 @@ GLTFAnimation::Track GLTFDocument::_convert_animation_track(Ref<GLTFState> state p_track.rotation_track.interpolation = gltf_interpolation; for (int32_t key_i = 0; key_i < key_count; key_i++) { - Quat rotation; Vector3 rotation_degrees = p_animation->track_get_key_value(p_track_i, key_i); Vector3 rotation_radian; rotation_radian.x = Math::deg2rad(rotation_degrees.x); rotation_radian.y = Math::deg2rad(rotation_degrees.y); rotation_radian.z = Math::deg2rad(rotation_degrees.z); - rotation.set_euler(rotation_radian); - p_track.rotation_track.values.write[key_i] = rotation; + p_track.rotation_track.values.write[key_i] = Quat(rotation_radian); } } else if (path.find(":scale") != -1) { p_track.scale_track.times = times; @@ -6145,18 +6297,22 @@ void GLTFDocument::_convert_animation(Ref<GLTFState> state, AnimationPlayer *ap, } } } else if (String(orig_track_path).find(":") == -1) { - const Node *node = ap->get_parent()->get_node_or_null(orig_track_path); - for (Map<GLTFNodeIndex, Node *>::Element *scene_node_i = state->scene_nodes.front(); scene_node_i; scene_node_i = scene_node_i->next()) { - if (scene_node_i->get() == node) { - GLTFNodeIndex node_index = scene_node_i->key(); - Map<int, GLTFAnimation::Track>::Element *node_track_i = gltf_animation->get_tracks().find(node_index); - GLTFAnimation::Track track; - if (node_track_i) { - track = node_track_i->get(); + ERR_CONTINUE(!ap->get_parent()); + for (int32_t node_i = 0; node_i < ap->get_parent()->get_child_count(); node_i++) { + const Node *child = ap->get_parent()->get_child(node_i); + const Node *node = child->get_node_or_null(orig_track_path); + for (Map<GLTFNodeIndex, Node *>::Element *scene_node_i = state->scene_nodes.front(); scene_node_i; scene_node_i = scene_node_i->next()) { + if (scene_node_i->get() == node) { + GLTFNodeIndex node_index = scene_node_i->key(); + Map<int, GLTFAnimation::Track>::Element *node_track_i = gltf_animation->get_tracks().find(node_index); + GLTFAnimation::Track track; + if (node_track_i) { + track = node_track_i->get(); + } + track = _convert_animation_track(state, track, animation, Transform(), track_i, node_index); + gltf_animation->get_tracks().insert(node_index, track); + break; } - track = _convert_animation_track(state, track, animation, Transform(), track_i, node_index); - gltf_animation->get_tracks().insert(node_index, track); - break; } } } diff --git a/modules/gltf/gltf_document.h b/modules/gltf/gltf_document.h index 0f4772cd26..ddf307e6a7 100644 --- a/modules/gltf/gltf_document.h +++ b/modules/gltf/gltf_document.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -34,6 +34,7 @@ #include "editor/import/resource_importer_scene.h" #include "editor/import/scene_importer_mesh_node_3d.h" #include "gltf_animation.h" +#include "modules/modules_enabled.gen.h" #include "scene/2d/node_2d.h" #include "scene/3d/bone_attachment_3d.h" #include "scene/3d/light_3d.h" @@ -71,6 +72,7 @@ class GLTFDocument : public Resource { friend class GLTFSkeleton; public: + const int32_t JOINT_GROUP_SIZE = 4; enum GLTFType { TYPE_SCALAR, TYPE_VEC2, @@ -376,7 +378,9 @@ public: const GLTFNodeIndex p_gltf_current, const GLTFNodeIndex p_gltf_root); +#ifdef MODULE_CSG_ENABLED void _convert_csg_shape_to_gltf(Node *p_current, GLTFNodeIndex p_gltf_parent, Ref<GLTFNode> gltf_node, Ref<GLTFState> state); +#endif // MODULE_CSG_ENABLED void _create_gltf_node(Ref<GLTFState> state, Node *p_scene_parent, @@ -394,12 +398,14 @@ public: void _convert_camera_to_gltf(Camera3D *camera, Ref<GLTFState> state, Node3D *spatial, Ref<GLTFNode> gltf_node); +#ifdef MODULE_GRIDMAP_ENABLED void _convert_grid_map_to_gltf( Node *p_scene_parent, const GLTFNodeIndex &p_parent_node_index, const GLTFNodeIndex &p_root_node_index, Ref<GLTFNode> gltf_node, Ref<GLTFState> state, Node *p_root_node); +#endif // MODULE_GRIDMAP_ENABLED void _convert_mult_mesh_instance_to_gltf( Node *p_scene_parent, const GLTFNodeIndex &p_parent_node_index, diff --git a/modules/gltf/gltf_light.cpp b/modules/gltf/gltf_light.cpp index da0e504474..95cca9cf71 100644 --- a/modules/gltf/gltf_light.cpp +++ b/modules/gltf/gltf_light.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gltf/gltf_light.h b/modules/gltf/gltf_light.h index 966ef5dd44..a859ca1833 100644 --- a/modules/gltf/gltf_light.h +++ b/modules/gltf/gltf_light.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gltf/gltf_mesh.cpp b/modules/gltf/gltf_mesh.cpp index 09995faab3..8c10e42c89 100644 --- a/modules/gltf/gltf_mesh.cpp +++ b/modules/gltf/gltf_mesh.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gltf/gltf_mesh.h b/modules/gltf/gltf_mesh.h index 5fb3069ad2..0fc750fc9f 100644 --- a/modules/gltf/gltf_mesh.h +++ b/modules/gltf/gltf_mesh.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gltf/gltf_node.cpp b/modules/gltf/gltf_node.cpp index 2fbd3f85d4..777c6fbd9a 100644 --- a/modules/gltf/gltf_node.cpp +++ b/modules/gltf/gltf_node.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gltf/gltf_node.h b/modules/gltf/gltf_node.h index b96e700ec2..ce8aff8944 100644 --- a/modules/gltf/gltf_node.h +++ b/modules/gltf/gltf_node.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gltf/gltf_skeleton.cpp b/modules/gltf/gltf_skeleton.cpp index 35671335d3..739779d3bd 100644 --- a/modules/gltf/gltf_skeleton.cpp +++ b/modules/gltf/gltf_skeleton.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gltf/gltf_skeleton.h b/modules/gltf/gltf_skeleton.h index 6263fa3c5d..d6986eb35a 100644 --- a/modules/gltf/gltf_skeleton.h +++ b/modules/gltf/gltf_skeleton.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gltf/gltf_skin.cpp b/modules/gltf/gltf_skin.cpp index 1b94b9d106..5a61e5778c 100644 --- a/modules/gltf/gltf_skin.cpp +++ b/modules/gltf/gltf_skin.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -142,7 +142,7 @@ void GLTFSkin::set_joint_i_to_name(Dictionary p_joint_i_to_name) { joint_i_to_name = Map<int, StringName>(); Array keys = p_joint_i_to_name.keys(); for (int i = 0; i < keys.size(); i++) { - joint_i_to_name[keys[i]] = joint_i_to_name[keys[i]]; + joint_i_to_name[keys[i]] = p_joint_i_to_name[keys[i]]; } } diff --git a/modules/gltf/gltf_skin.h b/modules/gltf/gltf_skin.h index 09e1a37a55..7cc09d85bc 100644 --- a/modules/gltf/gltf_skin.h +++ b/modules/gltf/gltf_skin.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gltf/gltf_spec_gloss.cpp b/modules/gltf/gltf_spec_gloss.cpp index 7f27805d62..70b182da52 100644 --- a/modules/gltf/gltf_spec_gloss.cpp +++ b/modules/gltf/gltf_spec_gloss.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gltf/gltf_spec_gloss.h b/modules/gltf/gltf_spec_gloss.h index e06c6c14f3..3cc6fb09ed 100644 --- a/modules/gltf/gltf_spec_gloss.h +++ b/modules/gltf/gltf_spec_gloss.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gltf/gltf_state.cpp b/modules/gltf/gltf_state.cpp index 403ae26bd3..eedc743330 100644 --- a/modules/gltf/gltf_state.cpp +++ b/modules/gltf/gltf_state.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gltf/gltf_state.h b/modules/gltf/gltf_state.h index f21472ad1b..4ce5aa9491 100644 --- a/modules/gltf/gltf_state.h +++ b/modules/gltf/gltf_state.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gltf/gltf_texture.cpp b/modules/gltf/gltf_texture.cpp index 55434a5047..0482c1064e 100644 --- a/modules/gltf/gltf_texture.cpp +++ b/modules/gltf/gltf_texture.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gltf/gltf_texture.h b/modules/gltf/gltf_texture.h index 5e0c9c307b..e1d0407fb4 100644 --- a/modules/gltf/gltf_texture.h +++ b/modules/gltf/gltf_texture.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gltf/register_types.cpp b/modules/gltf/register_types.cpp index bd5775af34..dc995c9249 100644 --- a/modules/gltf/register_types.cpp +++ b/modules/gltf/register_types.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -60,9 +60,10 @@ static void _editor_init() { void register_gltf_types() { #ifndef _3D_DISABLED #ifdef TOOLS_ENABLED - ClassDB::register_class<EditorSceneImporterGLTF>(); ClassDB::APIType prev_api = ClassDB::get_current_api(); ClassDB::set_current_api(ClassDB::API_EDITOR); + ClassDB::register_class<EditorSceneImporterGLTF>(); + ClassDB::register_class<GLTFMesh>(); EditorPlugins::add_by_type<SceneExporterGLTFPlugin>(); ClassDB::set_current_api(prev_api); EditorNode::add_init_callback(_editor_init); @@ -75,7 +76,6 @@ void register_gltf_types() { ClassDB::register_class<GLTFTexture>(); ClassDB::register_class<GLTFSkeleton>(); ClassDB::register_class<GLTFSkin>(); - ClassDB::register_class<GLTFMesh>(); ClassDB::register_class<GLTFCamera>(); ClassDB::register_class<GLTFLight>(); ClassDB::register_class<GLTFState>(); diff --git a/modules/gltf/register_types.h b/modules/gltf/register_types.h index ffbc586ade..fefacb1106 100644 --- a/modules/gltf/register_types.h +++ b/modules/gltf/register_types.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gridmap/doc_classes/GridMap.xml b/modules/gridmap/doc_classes/GridMap.xml index 4dccb03369..134aadb75e 100644 --- a/modules/gridmap/doc_classes/GridMap.xml +++ b/modules/gridmap/doc_classes/GridMap.xml @@ -8,6 +8,7 @@ GridMaps use a [MeshLibrary] which contains a list of tiles. Each tile is a mesh with materials plus optional collision and navigation shapes. A GridMap contains a collection of cells. Each grid cell refers to a tile in the [MeshLibrary]. All cells in the map have the same dimensions. Internally, a GridMap is split into a sparse collection of octants for efficient rendering and physics processing. Every octant has the same dimensions and can contain several cells. + [b]Note:[/b] GridMap doesn't extend [VisualInstance3D] and therefore can't be hidden or cull masked based on [member VisualInstance3D.layers]. If you make a light not affect the first layer, the whole GridMap won't be lit by the light in question. </description> <tutorials> <link title="Using gridmaps">https://docs.godotengine.org/en/latest/tutorials/3d/using_gridmaps.html</link> diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cpp index 633b209f0f..e7c252dc53 100644 --- a/modules/gridmap/grid_map.cpp +++ b/modules/gridmap/grid_map.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -189,7 +189,6 @@ void GridMap::set_mesh_library(const Ref<MeshLibrary> &p_mesh_library) { } _recreate_octant_data(); - _change_notify("mesh_library"); } Ref<MeshLibrary> GridMap::get_mesh_library() const { @@ -286,7 +285,8 @@ void GridMap::set_cell_item(const Vector3i &p_position, int p_item, int p_rot) { //create octant because it does not exist Octant *g = memnew(Octant); g->dirty = true; - g->static_body = PhysicsServer3D::get_singleton()->body_create(PhysicsServer3D::BODY_MODE_STATIC); + g->static_body = PhysicsServer3D::get_singleton()->body_create(); + PhysicsServer3D::get_singleton()->body_set_mode(g->static_body, PhysicsServer3D::BODY_MODE_STATIC); PhysicsServer3D::get_singleton()->body_attach_object_instance_id(g->static_body, get_instance_id()); PhysicsServer3D::get_singleton()->body_set_collision_layer(g->static_body, collision_layer); PhysicsServer3D::get_singleton()->body_set_collision_mask(g->static_body, collision_mask); @@ -491,7 +491,7 @@ bool GridMap::_octant_update(const OctantKey &p_key) { Octant::MultimeshInstance mmi; RID mm = RS::get_singleton()->multimesh_create(); - RS::get_singleton()->multimesh_allocate(mm, E->get().size(), RS::MULTIMESH_TRANSFORM_3D); + RS::get_singleton()->multimesh_allocate_data(mm, E->get().size(), RS::MULTIMESH_TRANSFORM_3D); RS::get_singleton()->multimesh_set_mesh(mm, mesh_library->get_item_mesh(E->key())->get_rid()); int idx = 0; @@ -700,8 +700,6 @@ void GridMap::_update_visibility() { return; } - _change_notify("visible"); - for (Map<OctantKey, Octant *>::Element *e = octant_map.front(); e; e = e->next()) { Octant *octant = e->value(); for (int i = 0; i < octant->multimesh_instances.size(); i++) { @@ -1046,26 +1044,7 @@ RID GridMap::get_bake_mesh_instance(int p_idx) { } GridMap::GridMap() { - collision_layer = 1; - collision_mask = 1; - - cell_size = Vector3(2, 2, 2); - octant_size = 8; - awaiting_update = false; - _in_tree = false; - center_x = true; - center_y = true; - center_z = true; - - clip = false; - clip_floor = 0; - clip_axis = Vector3::AXIS_Z; - clip_above = true; - cell_scale = 1.0; - - navigation = nullptr; set_notify_transform(true); - recreating_octants = false; } GridMap::~GridMap() { diff --git a/modules/gridmap/grid_map.h b/modules/gridmap/grid_map.h index ca7429ea26..e5ec4bb602 100644 --- a/modules/gridmap/grid_map.h +++ b/modules/gridmap/grid_map.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -53,7 +53,7 @@ class GridMap : public Node3D { int16_t y; int16_t z; }; - uint64_t key; + uint64_t key = 0; _FORCE_INLINE_ bool operator<(const IndexKey &p_key) const { return key < p_key.key; @@ -68,7 +68,7 @@ class GridMap : public Node3D { y = (int16_t)p_vector.y; z = (int16_t)p_vector.z; } - IndexKey() { key = 0; } + IndexKey() {} }; /** @@ -80,13 +80,7 @@ class GridMap : public Node3D { unsigned int rot : 5; unsigned int layer : 8; }; - uint32_t cell; - - Cell() { - item = 0; - rot = 0; - layer = 0; - } + uint32_t cell = 0; }; /** @@ -103,7 +97,7 @@ class GridMap : public Node3D { RID instance; RID multimesh; struct Item { - int index; + int index = 0; Transform transform; IndexKey key; }; @@ -116,7 +110,7 @@ class GridMap : public Node3D { RID collision_debug; RID collision_debug_instance; - bool dirty; + bool dirty = false; RID static_body; Map<IndexKey, NavMesh> navmesh_ids; }; @@ -129,35 +123,37 @@ class GridMap : public Node3D { int16_t empty; }; - uint64_t key; + uint64_t key = 0; _FORCE_INLINE_ bool operator<(const OctantKey &p_key) const { return key < p_key.key; } //OctantKey(const IndexKey& p_k, int p_item) { indexkey=p_k.key; item=p_item; } - OctantKey() { key = 0; } + OctantKey() {} }; - uint32_t collision_layer; - uint32_t collision_mask; + uint32_t collision_layer = 1; + uint32_t collision_mask = 1; Transform last_transform; - bool _in_tree; - Vector3 cell_size; - int octant_size; - bool center_x, center_y, center_z; - float cell_scale; - Navigation3D *navigation; + bool _in_tree = false; + Vector3 cell_size = Vector3(2, 2, 2); + int octant_size = 8; + bool center_x = true; + bool center_y = true; + bool center_z = true; + float cell_scale = 1.0; + Navigation3D *navigation = nullptr; - bool clip; - bool clip_above; - int clip_floor; + bool clip = false; + bool clip_above = true; + int clip_floor = 0; - bool recreating_octants; + bool recreating_octants = false; - Vector3::Axis clip_axis; + Vector3::Axis clip_axis = Vector3::AXIS_Z; Ref<MeshLibrary> mesh_library; @@ -167,10 +163,10 @@ class GridMap : public Node3D { void _recreate_octant_data(); struct BakeLight { - RS::LightType type; + RS::LightType type = RS::LightType::LIGHT_DIRECTIONAL; Vector3 pos; Vector3 dir; - float param[RS::LIGHT_PARAM_MAX]; + float param[RS::LIGHT_PARAM_MAX] = {}; }; _FORCE_INLINE_ Vector3 _octant_get_offset(const OctantKey &p_key) const { @@ -183,7 +179,7 @@ class GridMap : public Node3D { bool _octant_update(const OctantKey &p_key); void _octant_clean_up(const OctantKey &p_key); void _octant_transform(const OctantKey &p_key); - bool awaiting_update; + bool awaiting_update = false; void _queue_octants_dirty(); void _update_octants_callback(); diff --git a/modules/gridmap/grid_map_editor_plugin.cpp b/modules/gridmap/grid_map_editor_plugin.cpp index d4fbecd60f..da9cdb9bc5 100644 --- a/modules/gridmap/grid_map_editor_plugin.cpp +++ b/modules/gridmap/grid_map_editor_plugin.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -724,7 +724,7 @@ bool GridMapEditor::forward_spatial_input_event(Camera3D *p_camera, const Ref<In return true; } else { selected_palette = -1; - mesh_library_palette->unselect_all(); + mesh_library_palette->deselect_all(); update_palette(); _update_cursor_instance(); return true; @@ -769,7 +769,7 @@ bool GridMapEditor::forward_spatial_input_event(Camera3D *p_camera, const Ref<In struct _CGMEItemSort { String name; - int id; + int id = 0; _FORCE_INLINE_ bool operator<(const _CGMEItemSort &r_it) const { return name < r_it.name; } }; @@ -1151,7 +1151,6 @@ void GridMapEditor::_bind_methods() { } GridMapEditor::GridMapEditor(EditorNode *p_editor) { - input_action = INPUT_NONE; editor = p_editor; undo_redo = p_editor->get_undo_redo(); @@ -1173,7 +1172,7 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) { floor->set_min(-32767); floor->set_max(32767); floor->set_step(1); - floor->get_line_edit()->add_theme_constant_override("minimum_spaces", 16); + floor->get_line_edit()->add_theme_constant_override("minimum_character_width", 16); spatial_editor_hb->add_child(floor); floor->connect("value_changed", callable_mp(this, &GridMapEditor::_floor_changed)); @@ -1234,7 +1233,6 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) { settings_pick_distance->set_value(EDITOR_DEF("editors/grid_map/pick_distance", 5000.0)); settings_vbc->add_margin_child(TTR("Pick Distance:"), settings_pick_distance); - clip_mode = CLIP_DISABLED; options->get_popup()->connect("id_pressed", callable_mp(this, &GridMapEditor::_menu_option)); HBoxContainer *hb = memnew(HBoxContainer); @@ -1275,8 +1273,6 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) { EDITOR_DEF("editors/grid_map/preview_size", 64); - display_mode = DISPLAY_THUMBNAIL; - mesh_library_palette = memnew(ItemList); add_child(mesh_library_palette); mesh_library_palette->set_v_size_flags(SIZE_EXPAND_FILL); @@ -1296,11 +1292,6 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) { edit_floor[1] = -1; edit_floor[2] = -1; - cursor_visible = false; - selected_palette = -1; - lock_view = false; - cursor_rot = 0; - selection_mesh = RenderingServer::get_singleton()->mesh_create(); paste_mesh = RenderingServer::get_singleton()->mesh_create(); @@ -1418,8 +1409,6 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) { } _set_selection(false); - updating = false; - accumulated_floor_delta = 0.0; indicator_mat.instance(); indicator_mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); diff --git a/modules/gridmap/grid_map_editor_plugin.h b/modules/gridmap/grid_map_editor_plugin.h index 69c8d999fd..6c7f0bedf6 100644 --- a/modules/gridmap/grid_map_editor_plugin.h +++ b/modules/gridmap/grid_map_editor_plugin.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -65,11 +65,11 @@ class GridMapEditor : public VBoxContainer { }; UndoRedo *undo_redo; - InputAction input_action; + InputAction input_action = INPUT_NONE; Panel *panel; MenuButton *options; SpinBox *floor; - double accumulated_floor_delta; + double accumulated_floor_delta = 0.0; Button *mode_thumbnail; Button *mode_list; LineEdit *search_box; @@ -82,19 +82,19 @@ class GridMapEditor : public VBoxContainer { struct SetItem { Vector3i position; - int new_value; - int new_orientation; - int old_value; - int old_orientation; + int new_value = 0; + int new_orientation = 0; + int old_value = 0; + int old_orientation = 0; }; List<SetItem> set_items; GridMap *node = nullptr; MeshLibrary *last_mesh_library; - ClipMode clip_mode; + ClipMode clip_mode = CLIP_DISABLED; - bool lock_view; + bool lock_view = false; Transform grid_xform; Transform edit_grid_xform; Vector3::Axis edit_axis; @@ -112,9 +112,9 @@ class GridMapEditor : public VBoxContainer { RID paste_instance; struct ClipboardItem { - int cell_item; + int cell_item = 0; Vector3 grid_offset; - int orientation; + int orientation = 0; RID instance; }; @@ -125,14 +125,14 @@ class GridMapEditor : public VBoxContainer { Ref<StandardMaterial3D> outer_mat; Ref<StandardMaterial3D> selection_floor_mat; - bool updating; + bool updating = false; struct Selection { Vector3 click; Vector3 current; Vector3 begin; Vector3 end; - bool active; + bool active = false; } selection; Selection last_selection; @@ -141,18 +141,18 @@ class GridMapEditor : public VBoxContainer { Vector3 current; Vector3 begin; Vector3 end; - int orientation; + int orientation = 0; }; PasteIndicator paste_indicator; - bool cursor_visible; + bool cursor_visible = false; Transform cursor_transform; Vector3 cursor_origin; - int display_mode; - int selected_palette; - int cursor_rot; + int display_mode = DISPLAY_THUMBNAIL; + int selected_palette = -1; + int cursor_rot = 0; enum Menu { MENU_OPTION_NEXT_LEVEL, diff --git a/modules/gridmap/register_types.cpp b/modules/gridmap/register_types.cpp index ab384fa942..5680664213 100644 --- a/modules/gridmap/register_types.cpp +++ b/modules/gridmap/register_types.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/gridmap/register_types.h b/modules/gridmap/register_types.h index c0e3c39ca8..b977f4c5da 100644 --- a/modules/gridmap/register_types.h +++ b/modules/gridmap/register_types.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/hdr/image_loader_hdr.cpp b/modules/hdr/image_loader_hdr.cpp index af3741bae9..9d6a399eff 100644 --- a/modules/hdr/image_loader_hdr.cpp +++ b/modules/hdr/image_loader_hdr.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/hdr/image_loader_hdr.h b/modules/hdr/image_loader_hdr.h index ef8e116616..33fcdd1245 100644 --- a/modules/hdr/image_loader_hdr.h +++ b/modules/hdr/image_loader_hdr.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/hdr/register_types.cpp b/modules/hdr/register_types.cpp index e749928f60..5a4a1993e0 100644 --- a/modules/hdr/register_types.cpp +++ b/modules/hdr/register_types.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/hdr/register_types.h b/modules/hdr/register_types.h index 02441516ec..c85bc84dce 100644 --- a/modules/hdr/register_types.h +++ b/modules/hdr/register_types.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/icloud/SCsub b/modules/icloud/SCsub deleted file mode 100644 index 805a484600..0000000000 --- a/modules/icloud/SCsub +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env python - -Import("env") -Import("env_modules") - -env_icloud = env_modules.Clone() - -# (iOS) Enable module support -env_icloud.Append(CCFLAGS=["-fmodules", "-fcxx-modules"]) - -# (iOS) Build as separate static library -modules_sources = [] -env_icloud.add_source_files(modules_sources, "*.cpp") -env_icloud.add_source_files(modules_sources, "*.mm") -mod_lib = env_modules.add_library("#bin/libgodot_icloud_module" + env["LIBSUFFIX"], modules_sources) diff --git a/modules/icloud/config.py b/modules/icloud/config.py deleted file mode 100644 index e68603fc93..0000000000 --- a/modules/icloud/config.py +++ /dev/null @@ -1,6 +0,0 @@ -def can_build(env, platform): - return platform == "iphone" - - -def configure(env): - pass diff --git a/modules/icloud/icloud.gdip b/modules/icloud/icloud.gdip deleted file mode 100644 index 9f81be8a34..0000000000 --- a/modules/icloud/icloud.gdip +++ /dev/null @@ -1,17 +0,0 @@ -[config] -name="iCloud" -binary="icloud_lib.a" - -initialization="register_icloud_types" -deinitialization="unregister_icloud_types" - -[dependencies] -linked=[] -embedded=[] -system=[] - -capabilities=[] - -files=[] - -[plist] diff --git a/modules/icloud/icloud.h b/modules/icloud/icloud.h deleted file mode 100644 index 35eede0bf9..0000000000 --- a/modules/icloud/icloud.h +++ /dev/null @@ -1,60 +0,0 @@ -/*************************************************************************/ -/* icloud.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef ICLOUD_H -#define ICLOUD_H - -#include "core/object/class_db.h" - -class ICloud : public Object { - GDCLASS(ICloud, Object); - - static ICloud *instance; - static void _bind_methods(); - - List<Variant> pending_events; - -public: - Error remove_key(String p_param); - Array set_key_values(Dictionary p_params); - Variant get_key_value(String p_param); - Error synchronize_key_values(); - Variant get_all_key_values(); - - int get_pending_event_count(); - Variant pop_pending_event(); - - static ICloud *get_singleton(); - - ICloud(); - ~ICloud(); -}; - -#endif diff --git a/modules/icloud/icloud.mm b/modules/icloud/icloud.mm deleted file mode 100644 index 8a8ddbefe9..0000000000 --- a/modules/icloud/icloud.mm +++ /dev/null @@ -1,345 +0,0 @@ -/*************************************************************************/ -/* icloud.mm */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include "icloud.h" - -#import "platform/iphone/app_delegate.h" - -#import <Foundation/Foundation.h> - -ICloud *ICloud::instance = NULL; - -void ICloud::_bind_methods() { - ClassDB::bind_method(D_METHOD("remove_key"), &ICloud::remove_key); - - ClassDB::bind_method(D_METHOD("set_key_values"), &ICloud::set_key_values); - ClassDB::bind_method(D_METHOD("get_key_value"), &ICloud::get_key_value); - - ClassDB::bind_method(D_METHOD("synchronize_key_values"), &ICloud::synchronize_key_values); - ClassDB::bind_method(D_METHOD("get_all_key_values"), &ICloud::get_all_key_values); - - ClassDB::bind_method(D_METHOD("get_pending_event_count"), &ICloud::get_pending_event_count); - ClassDB::bind_method(D_METHOD("pop_pending_event"), &ICloud::pop_pending_event); -}; - -int ICloud::get_pending_event_count() { - return pending_events.size(); -}; - -Variant ICloud::pop_pending_event() { - Variant front = pending_events.front()->get(); - pending_events.pop_front(); - - return front; -}; - -ICloud *ICloud::get_singleton() { - return instance; -}; - -//convert from apple's abstract type to godot's abstract type.... -Variant nsobject_to_variant(NSObject *object) { - if ([object isKindOfClass:[NSString class]]) { - const char *str = [(NSString *)object UTF8String]; - return String::utf8(str != NULL ? str : ""); - } else if ([object isKindOfClass:[NSData class]]) { - PackedByteArray ret; - NSData *data = (NSData *)object; - if ([data length] > 0) { - ret.resize([data length]); - { - // PackedByteArray::Write w = ret.write(); - copymem((void *)ret.ptr(), [data bytes], [data length]); - } - } - return ret; - } else if ([object isKindOfClass:[NSArray class]]) { - Array result; - NSArray *array = (NSArray *)object; - for (NSUInteger i = 0; i < [array count]; ++i) { - NSObject *value = [array objectAtIndex:i]; - result.push_back(nsobject_to_variant(value)); - } - return result; - } else if ([object isKindOfClass:[NSDictionary class]]) { - Dictionary result; - NSDictionary *dic = (NSDictionary *)object; - - NSArray *keys = [dic allKeys]; - int count = [keys count]; - for (int i = 0; i < count; ++i) { - NSObject *k = [keys objectAtIndex:i]; - NSObject *v = [dic objectForKey:k]; - - result[nsobject_to_variant(k)] = nsobject_to_variant(v); - } - return result; - } else if ([object isKindOfClass:[NSNumber class]]) { - //Every type except numbers can reliably identify its type. The following is comparing to the *internal* representation, which isn't guaranteed to match the type that was used to create it, and is not advised, particularly when dealing with potential platform differences (ie, 32/64 bit) - //To avoid errors, we'll cast as broadly as possible, and only return int or float. - //bool, char, int, uint, longlong -> int - //float, double -> float - NSNumber *num = (NSNumber *)object; - if (strcmp([num objCType], @encode(BOOL)) == 0) { - return Variant((int)[num boolValue]); - } else if (strcmp([num objCType], @encode(char)) == 0) { - return Variant((int)[num charValue]); - } else if (strcmp([num objCType], @encode(int)) == 0) { - return Variant([num intValue]); - } else if (strcmp([num objCType], @encode(unsigned int)) == 0) { - return Variant((int)[num unsignedIntValue]); - } else if (strcmp([num objCType], @encode(long long)) == 0) { - return Variant((int)[num longValue]); - } else if (strcmp([num objCType], @encode(float)) == 0) { - return Variant([num floatValue]); - } else if (strcmp([num objCType], @encode(double)) == 0) { - return Variant((float)[num doubleValue]); - } else { - return Variant(); - } - } else if ([object isKindOfClass:[NSDate class]]) { - //this is a type that icloud supports...but how did you submit it in the first place? - //I guess this is a type that *might* show up, if you were, say, trying to make your game - //compatible with existing cloud data written by another engine's version of your game - WARN_PRINT("NSDate unsupported, returning null Variant"); - return Variant(); - } else if ([object isKindOfClass:[NSNull class]] or object == nil) { - return Variant(); - } else { - WARN_PRINT("Trying to convert unknown NSObject type to Variant"); - return Variant(); - } -} - -NSObject *variant_to_nsobject(Variant v) { - if (v.get_type() == Variant::STRING) { - return [[NSString alloc] initWithUTF8String:((String)v).utf8().get_data()]; - } else if (v.get_type() == Variant::FLOAT) { - return [NSNumber numberWithDouble:(double)v]; - } else if (v.get_type() == Variant::INT) { - return [NSNumber numberWithLongLong:(long)(int)v]; - } else if (v.get_type() == Variant::BOOL) { - return [NSNumber numberWithBool:BOOL((bool)v)]; - } else if (v.get_type() == Variant::DICTIONARY) { - NSMutableDictionary *result = [[NSMutableDictionary alloc] init]; - Dictionary dic = v; - Array keys = dic.keys(); - for (int i = 0; i < keys.size(); ++i) { - NSString *key = [[NSString alloc] initWithUTF8String:((String)(keys[i])).utf8().get_data()]; - NSObject *value = variant_to_nsobject(dic[keys[i]]); - - if (key == NULL || value == NULL) { - return NULL; - } - - [result setObject:value forKey:key]; - } - return result; - } else if (v.get_type() == Variant::ARRAY) { - NSMutableArray *result = [[NSMutableArray alloc] init]; - Array arr = v; - for (int i = 0; i < arr.size(); ++i) { - NSObject *value = variant_to_nsobject(arr[i]); - if (value == NULL) { - //trying to add something unsupported to the array. cancel the whole array - return NULL; - } - [result addObject:value]; - } - return result; - } else if (v.get_type() == Variant::PACKED_BYTE_ARRAY) { - PackedByteArray arr = v; - // PackedByteArray::Read r = arr.read(); - NSData *result = [NSData dataWithBytes:arr.ptr() length:arr.size()]; - return result; - } - WARN_PRINT(String("Could not add unsupported type to iCloud: '" + Variant::get_type_name(v.get_type()) + "'").utf8().get_data()); - return NULL; -} - -Error ICloud::remove_key(String p_param) { - NSString *key = [[NSString alloc] initWithUTF8String:p_param.utf8().get_data()]; - - NSUbiquitousKeyValueStore *store = [NSUbiquitousKeyValueStore defaultStore]; - - if (![[store dictionaryRepresentation] objectForKey:key]) { - return ERR_INVALID_PARAMETER; - } - - [store removeObjectForKey:key]; - return OK; -} - -//return an array of the keys that could not be set -Array ICloud::set_key_values(Dictionary p_params) { - Array keys = p_params.keys(); - - Array error_keys; - - for (int i = 0; i < keys.size(); ++i) { - String variant_key = keys[i]; - Variant variant_value = p_params[variant_key]; - - NSString *key = [[NSString alloc] initWithUTF8String:variant_key.utf8().get_data()]; - if (key == NULL) { - error_keys.push_back(variant_key); - continue; - } - - NSObject *value = variant_to_nsobject(variant_value); - - if (value == NULL) { - error_keys.push_back(variant_key); - continue; - } - - NSUbiquitousKeyValueStore *store = [NSUbiquitousKeyValueStore defaultStore]; - [store setObject:value forKey:key]; - } - - return error_keys; -} - -Variant ICloud::get_key_value(String p_param) { - NSString *key = [[NSString alloc] initWithUTF8String:p_param.utf8().get_data()]; - NSUbiquitousKeyValueStore *store = [NSUbiquitousKeyValueStore defaultStore]; - - if (![[store dictionaryRepresentation] objectForKey:key]) { - return Variant(); - } - - Variant result = nsobject_to_variant([[store dictionaryRepresentation] objectForKey:key]); - - return result; -} - -Variant ICloud::get_all_key_values() { - Dictionary result; - - NSUbiquitousKeyValueStore *store = [NSUbiquitousKeyValueStore defaultStore]; - NSDictionary *store_dictionary = [store dictionaryRepresentation]; - - NSArray *keys = [store_dictionary allKeys]; - int count = [keys count]; - for (int i = 0; i < count; ++i) { - NSString *k = [keys objectAtIndex:i]; - NSObject *v = [store_dictionary objectForKey:k]; - - const char *str = [k UTF8String]; - if (str != NULL) { - result[String::utf8(str)] = nsobject_to_variant(v); - } - } - - return result; -} - -Error ICloud::synchronize_key_values() { - NSUbiquitousKeyValueStore *store = [NSUbiquitousKeyValueStore defaultStore]; - BOOL result = [store synchronize]; - if (result == YES) { - return OK; - } else { - return FAILED; - } -} - -/* -Error ICloud::initial_sync() { - //you sometimes have to write something to the store to get it to download new data. go apple! - NSUbiquitousKeyValueStore *store = [NSUbiquitousKeyValueStore defaultStore]; - if ([store boolForKey:@"isb"]) - { - [store setBool:NO forKey:@"isb"]; - } - else - { - [store setBool:YES forKey:@"isb"]; - } - return synchronize(); -} - -*/ -ICloud::ICloud() { - ERR_FAIL_COND(instance != NULL); - instance = this; - //connected = false; - - [[NSNotificationCenter defaultCenter] - addObserverForName:NSUbiquitousKeyValueStoreDidChangeExternallyNotification - object:[NSUbiquitousKeyValueStore defaultStore] - queue:nil - usingBlock:^(NSNotification *notification) { - NSDictionary *userInfo = [notification userInfo]; - NSInteger change = [[userInfo objectForKey:NSUbiquitousKeyValueStoreChangeReasonKey] integerValue]; - - Dictionary ret; - ret["type"] = "key_value_changed"; - - //PackedStringArray result_keys; - //Array result_values; - Dictionary keyValues; - String reason = ""; - - if (change == NSUbiquitousKeyValueStoreServerChange) { - reason = "server"; - } else if (change == NSUbiquitousKeyValueStoreInitialSyncChange) { - reason = "initial_sync"; - } else if (change == NSUbiquitousKeyValueStoreQuotaViolationChange) { - reason = "quota_violation"; - } else if (change == NSUbiquitousKeyValueStoreAccountChange) { - reason = "account"; - } - - ret["reason"] = reason; - - NSUbiquitousKeyValueStore *store = [NSUbiquitousKeyValueStore defaultStore]; - - NSArray *keys = [userInfo objectForKey:NSUbiquitousKeyValueStoreChangedKeysKey]; - for (NSString *key in keys) { - const char *str = [key UTF8String]; - if (str == NULL) { - continue; - } - - NSObject *object = [store objectForKey:key]; - - //figure out what kind of object it is - Variant value = nsobject_to_variant(object); - - keyValues[String::utf8(str)] = value; - } - - ret["changed_values"] = keyValues; - pending_events.push_back(ret); - }]; -} - -ICloud::~ICloud() {} diff --git a/modules/icloud/icloud_module.h b/modules/icloud/icloud_module.h deleted file mode 100644 index 7fd057525e..0000000000 --- a/modules/icloud/icloud_module.h +++ /dev/null @@ -1,32 +0,0 @@ -/*************************************************************************/ -/* icloud_module.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -void register_icloud_types(); -void unregister_icloud_types(); diff --git a/modules/inappstore/SCsub b/modules/inappstore/SCsub deleted file mode 100644 index cee6a256d5..0000000000 --- a/modules/inappstore/SCsub +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env python - -Import("env") -Import("env_modules") - -env_inappstore = env_modules.Clone() - -# (iOS) Enable module support -env_inappstore.Append(CCFLAGS=["-fmodules", "-fcxx-modules"]) - -# (iOS) Build as separate static library -modules_sources = [] -env_inappstore.add_source_files(modules_sources, "*.cpp") -env_inappstore.add_source_files(modules_sources, "*.mm") -mod_lib = env_modules.add_library("#bin/libgodot_inappstore_module" + env["LIBSUFFIX"], modules_sources) diff --git a/modules/inappstore/config.py b/modules/inappstore/config.py deleted file mode 100644 index e68603fc93..0000000000 --- a/modules/inappstore/config.py +++ /dev/null @@ -1,6 +0,0 @@ -def can_build(env, platform): - return platform == "iphone" - - -def configure(env): - pass diff --git a/modules/inappstore/in_app_store.h b/modules/inappstore/in_app_store.h deleted file mode 100644 index c8e5d17cec..0000000000 --- a/modules/inappstore/in_app_store.h +++ /dev/null @@ -1,77 +0,0 @@ -/*************************************************************************/ -/* in_app_store.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef IN_APP_STORE_H -#define IN_APP_STORE_H - -#include "core/object/class_db.h" - -#ifdef __OBJC__ -@class GodotProductsDelegate; -@class GodotTransactionsObserver; - -typedef GodotProductsDelegate InAppStoreProductDelegate; -typedef GodotTransactionsObserver InAppStoreTransactionObserver; -#else -typedef void InAppStoreProductDelegate; -typedef void InAppStoreTransactionObserver; -#endif - -class InAppStore : public Object { - GDCLASS(InAppStore, Object); - - static InAppStore *instance; - static void _bind_methods(); - - List<Variant> pending_events; - - InAppStoreProductDelegate *products_request_delegate; - InAppStoreTransactionObserver *transactions_observer; - -public: - Error request_product_info(Dictionary p_params); - Error restore_purchases(); - Error purchase(Dictionary p_params); - - int get_pending_event_count(); - Variant pop_pending_event(); - void finish_transaction(String product_id); - void set_auto_finish_transaction(bool b); - - void _post_event(Variant p_event); - void _record_purchase(String product_id); - - static InAppStore *get_singleton(); - - InAppStore(); - ~InAppStore(); -}; - -#endif diff --git a/modules/inappstore/in_app_store.mm b/modules/inappstore/in_app_store.mm deleted file mode 100644 index 62977318c1..0000000000 --- a/modules/inappstore/in_app_store.mm +++ /dev/null @@ -1,411 +0,0 @@ -/*************************************************************************/ -/* in_app_store.mm */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include "in_app_store.h" - -#import <Foundation/Foundation.h> -#import <StoreKit/StoreKit.h> - -InAppStore *InAppStore::instance = NULL; - -@interface SKProduct (LocalizedPrice) - -@property(nonatomic, readonly) NSString *localizedPrice; - -@end - -//----------------------------------// -// SKProduct extension -//----------------------------------// -@implementation SKProduct (LocalizedPrice) - -- (NSString *)localizedPrice { - NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init]; - [numberFormatter setFormatterBehavior:NSNumberFormatterBehavior10_4]; - [numberFormatter setNumberStyle:NSNumberFormatterCurrencyStyle]; - [numberFormatter setLocale:self.priceLocale]; - NSString *formattedString = [numberFormatter stringFromNumber:self.price]; - return formattedString; -} - -@end - -@interface GodotProductsDelegate : NSObject <SKProductsRequestDelegate> - -@property(nonatomic, strong) NSMutableArray *loadedProducts; -@property(nonatomic, strong) NSMutableArray *pendingRequests; - -- (void)performRequestWithProductIDs:(NSSet *)productIDs; -- (Error)purchaseProductWithProductID:(NSString *)productID; -- (void)reset; - -@end - -@implementation GodotProductsDelegate - -- (instancetype)init { - self = [super init]; - - if (self) { - [self godot_commonInit]; - } - - return self; -} - -- (void)godot_commonInit { - self.loadedProducts = [NSMutableArray new]; - self.pendingRequests = [NSMutableArray new]; -} - -- (void)performRequestWithProductIDs:(NSSet *)productIDs { - SKProductsRequest *request = [[SKProductsRequest alloc] initWithProductIdentifiers:productIDs]; - - request.delegate = self; - [self.pendingRequests addObject:request]; - [request start]; -} - -- (Error)purchaseProductWithProductID:(NSString *)productID { - SKProduct *product = nil; - - NSLog(@"searching for product!"); - - if (self.loadedProducts) { - for (SKProduct *storedProduct in self.loadedProducts) { - if ([storedProduct.productIdentifier isEqualToString:productID]) { - product = storedProduct; - break; - } - } - } - - if (!product) { - return ERR_INVALID_PARAMETER; - } - - NSLog(@"product found!"); - - SKPayment *payment = [SKPayment paymentWithProduct:product]; - [[SKPaymentQueue defaultQueue] addPayment:payment]; - - NSLog(@"purchase sent!"); - - return OK; -} - -- (void)reset { - [self.loadedProducts removeAllObjects]; - [self.pendingRequests removeAllObjects]; -} - -- (void)request:(SKRequest *)request didFailWithError:(NSError *)error { - [self.pendingRequests removeObject:request]; - - Dictionary ret; - ret["type"] = "product_info"; - ret["result"] = "error"; - ret["error"] = String::utf8([error.localizedDescription UTF8String]); - - InAppStore::get_singleton()->_post_event(ret); -} - -- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response { - [self.pendingRequests removeObject:request]; - - NSArray *products = response.products; - [self.loadedProducts addObjectsFromArray:products]; - - Dictionary ret; - ret["type"] = "product_info"; - ret["result"] = "ok"; - PackedStringArray titles; - PackedStringArray descriptions; - PackedFloat32Array prices; - PackedStringArray ids; - PackedStringArray localized_prices; - PackedStringArray currency_codes; - - for (NSUInteger i = 0; i < [products count]; i++) { - SKProduct *product = [products objectAtIndex:i]; - - const char *str = [product.localizedTitle UTF8String]; - titles.push_back(String::utf8(str != NULL ? str : "")); - - str = [product.localizedDescription UTF8String]; - descriptions.push_back(String::utf8(str != NULL ? str : "")); - prices.push_back([product.price doubleValue]); - ids.push_back(String::utf8([product.productIdentifier UTF8String])); - localized_prices.push_back(String::utf8([product.localizedPrice UTF8String])); - currency_codes.push_back(String::utf8([[[product priceLocale] objectForKey:NSLocaleCurrencyCode] UTF8String])); - } - - ret["titles"] = titles; - ret["descriptions"] = descriptions; - ret["prices"] = prices; - ret["ids"] = ids; - ret["localized_prices"] = localized_prices; - ret["currency_codes"] = currency_codes; - - PackedStringArray invalid_ids; - - for (NSString *ipid in response.invalidProductIdentifiers) { - invalid_ids.push_back(String::utf8([ipid UTF8String])); - } - - ret["invalid_ids"] = invalid_ids; - - InAppStore::get_singleton()->_post_event(ret); -} - -@end - -@interface GodotTransactionsObserver : NSObject <SKPaymentTransactionObserver> - -@property(nonatomic, assign) BOOL shouldAutoFinishTransactions; -@property(nonatomic, strong) NSMutableDictionary *pendingTransactions; - -- (void)finishTransactionWithProductID:(NSString *)productID; -- (void)reset; - -@end - -@implementation GodotTransactionsObserver - -- (instancetype)init { - self = [super init]; - - if (self) { - [self godot_commonInit]; - } - - return self; -} - -- (void)godot_commonInit { - self.pendingTransactions = [NSMutableDictionary new]; -} - -- (void)finishTransactionWithProductID:(NSString *)productID { - SKPaymentTransaction *transaction = self.pendingTransactions[productID]; - - if (transaction) { - [[SKPaymentQueue defaultQueue] finishTransaction:transaction]; - } - - self.pendingTransactions[productID] = nil; -} - -- (void)reset { - [self.pendingTransactions removeAllObjects]; -} - -- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions { - printf("transactions updated!\n"); - for (SKPaymentTransaction *transaction in transactions) { - switch (transaction.transactionState) { - case SKPaymentTransactionStatePurchased: { - printf("status purchased!\n"); - String pid = String::utf8([transaction.payment.productIdentifier UTF8String]); - String transactionId = String::utf8([transaction.transactionIdentifier UTF8String]); - InAppStore::get_singleton()->_record_purchase(pid); - Dictionary ret; - ret["type"] = "purchase"; - ret["result"] = "ok"; - ret["product_id"] = pid; - ret["transaction_id"] = transactionId; - - NSData *receipt = nil; - int sdk_version = [[[UIDevice currentDevice] systemVersion] intValue]; - - NSBundle *bundle = [NSBundle mainBundle]; - // Get the transaction receipt file path location in the app bundle. - NSURL *receiptFileURL = [bundle appStoreReceiptURL]; - - // Read in the contents of the transaction file. - receipt = [NSData dataWithContentsOfURL:receiptFileURL]; - - NSString *receipt_to_send = nil; - - if (receipt != nil) { - receipt_to_send = [receipt base64EncodedStringWithOptions:0]; - } - Dictionary receipt_ret; - receipt_ret["receipt"] = String::utf8(receipt_to_send != nil ? [receipt_to_send UTF8String] : ""); - receipt_ret["sdk"] = sdk_version; - ret["receipt"] = receipt_ret; - - InAppStore::get_singleton()->_post_event(ret); - - if (self.shouldAutoFinishTransactions) { - [[SKPaymentQueue defaultQueue] finishTransaction:transaction]; - } else { - self.pendingTransactions[transaction.payment.productIdentifier] = transaction; - } - - } break; - case SKPaymentTransactionStateFailed: { - printf("status transaction failed!\n"); - String pid = String::utf8([transaction.payment.productIdentifier UTF8String]); - Dictionary ret; - ret["type"] = "purchase"; - ret["result"] = "error"; - ret["product_id"] = pid; - ret["error"] = String::utf8([transaction.error.localizedDescription UTF8String]); - InAppStore::get_singleton()->_post_event(ret); - [[SKPaymentQueue defaultQueue] finishTransaction:transaction]; - } break; - case SKPaymentTransactionStateRestored: { - printf("status transaction restored!\n"); - String pid = String::utf8([transaction.originalTransaction.payment.productIdentifier UTF8String]); - InAppStore::get_singleton()->_record_purchase(pid); - Dictionary ret; - ret["type"] = "restore"; - ret["result"] = "ok"; - ret["product_id"] = pid; - InAppStore::get_singleton()->_post_event(ret); - [[SKPaymentQueue defaultQueue] finishTransaction:transaction]; - } break; - default: { - printf("status default %i!\n", (int)transaction.transactionState); - } break; - } - } -} - -@end - -void InAppStore::_bind_methods() { - ClassDB::bind_method(D_METHOD("request_product_info"), &InAppStore::request_product_info); - ClassDB::bind_method(D_METHOD("restore_purchases"), &InAppStore::restore_purchases); - ClassDB::bind_method(D_METHOD("purchase"), &InAppStore::purchase); - - ClassDB::bind_method(D_METHOD("get_pending_event_count"), &InAppStore::get_pending_event_count); - ClassDB::bind_method(D_METHOD("pop_pending_event"), &InAppStore::pop_pending_event); - ClassDB::bind_method(D_METHOD("finish_transaction"), &InAppStore::finish_transaction); - ClassDB::bind_method(D_METHOD("set_auto_finish_transaction"), &InAppStore::set_auto_finish_transaction); -} - -Error InAppStore::request_product_info(Dictionary p_params) { - ERR_FAIL_COND_V(!p_params.has("product_ids"), ERR_INVALID_PARAMETER); - - PackedStringArray pids = p_params["product_ids"]; - printf("************ request product info! %i\n", pids.size()); - - NSMutableArray *array = [[NSMutableArray alloc] initWithCapacity:pids.size()]; - for (int i = 0; i < pids.size(); i++) { - printf("******** adding %s to product list\n", pids[i].utf8().get_data()); - NSString *pid = [[NSString alloc] initWithUTF8String:pids[i].utf8().get_data()]; - [array addObject:pid]; - }; - - NSSet *products = [[NSSet alloc] initWithArray:array]; - - [products_request_delegate performRequestWithProductIDs:products]; - - return OK; -} - -Error InAppStore::restore_purchases() { - printf("restoring purchases!\n"); - [[SKPaymentQueue defaultQueue] restoreCompletedTransactions]; - - return OK; -} - -Error InAppStore::purchase(Dictionary p_params) { - ERR_FAIL_COND_V(![SKPaymentQueue canMakePayments], ERR_UNAVAILABLE); - if (![SKPaymentQueue canMakePayments]) { - return ERR_UNAVAILABLE; - } - - printf("purchasing!\n"); - Dictionary params = p_params; - ERR_FAIL_COND_V(!params.has("product_id"), ERR_INVALID_PARAMETER); - - NSString *pid = [[NSString alloc] initWithUTF8String:String(params["product_id"]).utf8().get_data()]; - - return [products_request_delegate purchaseProductWithProductID:pid]; -} - -int InAppStore::get_pending_event_count() { - return pending_events.size(); -} - -Variant InAppStore::pop_pending_event() { - Variant front = pending_events.front()->get(); - pending_events.pop_front(); - - return front; -} - -void InAppStore::_post_event(Variant p_event) { - pending_events.push_back(p_event); -} - -void InAppStore::_record_purchase(String product_id) { - String skey = "purchased/" + product_id; - NSString *key = [[NSString alloc] initWithUTF8String:skey.utf8().get_data()]; - [[NSUserDefaults standardUserDefaults] setBool:YES forKey:key]; - [[NSUserDefaults standardUserDefaults] synchronize]; -} - -InAppStore *InAppStore::get_singleton() { - return instance; -} - -InAppStore::InAppStore() { - ERR_FAIL_COND(instance != NULL); - instance = this; - - products_request_delegate = [[GodotProductsDelegate alloc] init]; - transactions_observer = [[GodotTransactionsObserver alloc] init]; - - [[SKPaymentQueue defaultQueue] addTransactionObserver:transactions_observer]; -} - -void InAppStore::finish_transaction(String product_id) { - NSString *prod_id = [NSString stringWithCString:product_id.utf8().get_data() encoding:NSUTF8StringEncoding]; - - [transactions_observer finishTransactionWithProductID:prod_id]; -} - -void InAppStore::set_auto_finish_transaction(bool b) { - transactions_observer.shouldAutoFinishTransactions = b; -} - -InAppStore::~InAppStore() { - [products_request_delegate reset]; - [transactions_observer reset]; - - products_request_delegate = nil; - [[SKPaymentQueue defaultQueue] removeTransactionObserver:transactions_observer]; - transactions_observer = nil; -} diff --git a/modules/inappstore/in_app_store_module.h b/modules/inappstore/in_app_store_module.h deleted file mode 100644 index 44673e58bc..0000000000 --- a/modules/inappstore/in_app_store_module.h +++ /dev/null @@ -1,32 +0,0 @@ -/*************************************************************************/ -/* in_app_store_module.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -void register_inappstore_types(); -void unregister_inappstore_types(); diff --git a/modules/inappstore/inappstore.gdip b/modules/inappstore/inappstore.gdip deleted file mode 100644 index 7a5efb8ad3..0000000000 --- a/modules/inappstore/inappstore.gdip +++ /dev/null @@ -1,17 +0,0 @@ -[config] -name="InAppStore" -binary="inappstore_lib.a" - -initialization="register_inappstore_types" -deinitialization="unregister_inappstore_types" - -[dependencies] -linked=[] -embedded=[] -system=["StoreKit.framework"] - -capabilities=[] - -files=[] - -[plist] diff --git a/modules/jpg/image_loader_jpegd.cpp b/modules/jpg/image_loader_jpegd.cpp index e5f041c618..7daf6a3a57 100644 --- a/modules/jpg/image_loader_jpegd.cpp +++ b/modules/jpg/image_loader_jpegd.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/jpg/image_loader_jpegd.h b/modules/jpg/image_loader_jpegd.h index 9aebaad9e3..be265b280c 100644 --- a/modules/jpg/image_loader_jpegd.h +++ b/modules/jpg/image_loader_jpegd.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/jpg/register_types.cpp b/modules/jpg/register_types.cpp index b31746f769..a6ae96635f 100644 --- a/modules/jpg/register_types.cpp +++ b/modules/jpg/register_types.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/jpg/register_types.h b/modules/jpg/register_types.h index 52cd378b3a..577e9b06f7 100644 --- a/modules/jpg/register_types.h +++ b/modules/jpg/register_types.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/jsonrpc/jsonrpc.cpp b/modules/jsonrpc/jsonrpc.cpp index 320da182f8..306c0ff087 100644 --- a/modules/jsonrpc/jsonrpc.cpp +++ b/modules/jsonrpc/jsonrpc.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -151,7 +151,7 @@ Variant JSONRPC::process_action(const Variant &p_action, bool p_process_arr_elem } String JSONRPC::process_string(const String &p_input) { - if (p_input.empty()) { + if (p_input.is_empty()) { return String(); } diff --git a/modules/jsonrpc/jsonrpc.h b/modules/jsonrpc/jsonrpc.h index c2acf84515..9fd016602d 100644 --- a/modules/jsonrpc/jsonrpc.h +++ b/modules/jsonrpc/jsonrpc.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/jsonrpc/register_types.cpp b/modules/jsonrpc/register_types.cpp index e6affaee41..d6b565ba84 100644 --- a/modules/jsonrpc/register_types.cpp +++ b/modules/jsonrpc/register_types.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/jsonrpc/register_types.h b/modules/jsonrpc/register_types.h index 854d73a21f..6a21a12444 100644 --- a/modules/jsonrpc/register_types.h +++ b/modules/jsonrpc/register_types.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/lightmapper_rd/lightmapper_rd.cpp b/modules/lightmapper_rd/lightmapper_rd.cpp index 66995382e7..61ebabdfb6 100644 --- a/modules/lightmapper_rd/lightmapper_rd.cpp +++ b/modules/lightmapper_rd/lightmapper_rd.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -40,8 +40,8 @@ //#define DEBUG_TEXTURES void LightmapperRD::add_mesh(const MeshData &p_mesh) { - ERR_FAIL_COND(p_mesh.albedo_on_uv2.is_null() || p_mesh.albedo_on_uv2->empty()); - ERR_FAIL_COND(p_mesh.emission_on_uv2.is_null() || p_mesh.emission_on_uv2->empty()); + ERR_FAIL_COND(p_mesh.albedo_on_uv2.is_null() || p_mesh.albedo_on_uv2->is_empty()); + ERR_FAIL_COND(p_mesh.emission_on_uv2.is_null() || p_mesh.emission_on_uv2->is_empty()); ERR_FAIL_COND(p_mesh.albedo_on_uv2->get_width() != p_mesh.emission_on_uv2->get_width()); ERR_FAIL_COND(p_mesh.albedo_on_uv2->get_height() != p_mesh.emission_on_uv2->get_height()); ERR_FAIL_COND(p_mesh.points.size() == 0); @@ -93,8 +93,8 @@ void LightmapperRD::add_spot_light(bool p_static, const Vector3 &p_position, con l.direction[2] = p_direction.z; l.range = p_range; l.attenuation = p_attenuation; - l.spot_angle = Math::deg2rad(p_spot_angle); - l.spot_attenuation = p_spot_attenuation; + l.cos_spot_angle = Math::cos(Math::deg2rad(p_spot_angle)); + l.inv_spot_attenuation = 1.0f / p_spot_attenuation; l.color[0] = p_color.r; l.color[1] = p_color.g; l.color[2] = p_color.b; @@ -1225,23 +1225,23 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d switch (p_quality) { case BAKE_QUALITY_LOW: { - push_constant.ray_count = GLOBAL_GET("rendering/gpu_lightmapper/quality/low_quality_ray_count"); + push_constant.ray_count = GLOBAL_GET("rendering/lightmapping/bake_quality/low_quality_ray_count"); } break; case BAKE_QUALITY_MEDIUM: { - push_constant.ray_count = GLOBAL_GET("rendering/gpu_lightmapper/quality/medium_quality_ray_count"); + push_constant.ray_count = GLOBAL_GET("rendering/lightmapping/bake_quality/medium_quality_ray_count"); } break; case BAKE_QUALITY_HIGH: { - push_constant.ray_count = GLOBAL_GET("rendering/gpu_lightmapper/quality/high_quality_ray_count"); + push_constant.ray_count = GLOBAL_GET("rendering/lightmapping/bake_quality/high_quality_ray_count"); } break; case BAKE_QUALITY_ULTRA: { - push_constant.ray_count = GLOBAL_GET("rendering/gpu_lightmapper/quality/ultra_quality_ray_count"); + push_constant.ray_count = GLOBAL_GET("rendering/lightmapping/bake_quality/ultra_quality_ray_count"); } break; } push_constant.ray_count = CLAMP(push_constant.ray_count, 16, 8192); - int max_region_size = nearest_power_of_2_templated(int(GLOBAL_GET("rendering/gpu_lightmapper/performance/region_size"))); - int max_rays = GLOBAL_GET("rendering/gpu_lightmapper/performance/max_rays_per_pass"); + int max_region_size = nearest_power_of_2_templated(int(GLOBAL_GET("rendering/lightmapping/bake_performance/region_size"))); + int max_rays = GLOBAL_GET("rendering/lightmapping/bake_performance/max_rays_per_pass"); int x_regions = (atlas_size.width - 1) / max_region_size + 1; int y_regions = (atlas_size.height - 1) / max_region_size + 1; @@ -1347,23 +1347,23 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d switch (p_quality) { case BAKE_QUALITY_LOW: { - push_constant.ray_count = GLOBAL_GET("rendering/gpu_lightmapper/quality/low_quality_probe_ray_count"); + push_constant.ray_count = GLOBAL_GET("rendering/lightmapping/bake_quality/low_quality_probe_ray_count"); } break; case BAKE_QUALITY_MEDIUM: { - push_constant.ray_count = GLOBAL_GET("rendering/gpu_lightmapper/quality/medium_quality_probe_ray_count"); + push_constant.ray_count = GLOBAL_GET("rendering/lightmapping/bake_quality/medium_quality_probe_ray_count"); } break; case BAKE_QUALITY_HIGH: { - push_constant.ray_count = GLOBAL_GET("rendering/gpu_lightmapper/quality/high_quality_probe_ray_count"); + push_constant.ray_count = GLOBAL_GET("rendering/lightmapping/bake_quality/high_quality_probe_ray_count"); } break; case BAKE_QUALITY_ULTRA: { - push_constant.ray_count = GLOBAL_GET("rendering/gpu_lightmapper/quality/ultra_quality_probe_ray_count"); + push_constant.ray_count = GLOBAL_GET("rendering/lightmapping/bake_quality/ultra_quality_probe_ray_count"); } break; } push_constant.atlas_size[0] = probe_positions.size(); push_constant.ray_count = CLAMP(push_constant.ray_count, 16, 8192); - int max_rays = GLOBAL_GET("rendering/gpu_lightmapper/performance/max_rays_per_probe_pass"); + int max_rays = GLOBAL_GET("rendering/lightmapping/bake_performance/max_rays_per_probe_pass"); int ray_iterations = (push_constant.ray_count - 1) / max_rays + 1; for (int i = 0; i < ray_iterations; i++) { @@ -1436,7 +1436,7 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d dst[j + 3] = src[j + 3]; } } - rd->texture_update(light_accum_tex, i, ds, true); + rd->texture_update(light_accum_tex, i, ds); } } } @@ -1537,7 +1537,7 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d { //pre copy for (int i = 0; i < atlas_slices * (p_bake_sh ? 4 : 1); i++) { - rd->texture_copy(light_accum_tex, light_accum_tex2, Vector3(), Vector3(), Vector3(atlas_size.width, atlas_size.height, 1), 0, 0, i, i, true); + rd->texture_copy(light_accum_tex, light_accum_tex2, Vector3(), Vector3(), Vector3(atlas_size.width, atlas_size.height, 1), 0, 0, i, i); } Vector<RID> framebuffers; diff --git a/modules/lightmapper_rd/lightmapper_rd.h b/modules/lightmapper_rd/lightmapper_rd.h index e17b5473a8..f2a826a447 100644 --- a/modules/lightmapper_rd/lightmapper_rd.h +++ b/modules/lightmapper_rd/lightmapper_rd.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -46,18 +46,18 @@ class LightmapperRD : public Lightmapper { }; struct Light { - float position[3]; + float position[3] = {}; uint32_t type = LIGHT_TYPE_DIRECTIONAL; - float direction[3]; - float energy; - float color[3]; - float size; - float range; - float attenuation; - float spot_angle; - float spot_attenuation; - uint32_t static_bake; - uint32_t pad[3]; + float direction[3] = {}; + float energy = 0.0; + float color[3] = {}; + float size = 0.0; + float range = 0.0; + float attenuation = 0.0; + float cos_spot_angle = 0.0; + float inv_spot_attenuation = 0.0; + uint32_t static_bake = 0; + uint32_t pad[3] = {}; bool operator<(const Light &p_light) const { return type < p_light.type; @@ -65,10 +65,10 @@ class LightmapperRD : public Lightmapper { }; struct Vertex { - float position[3]; - float normal_z; - float uv[2]; - float normal_xy[2]; + float position[3] = {}; + float normal_z = 0.0; + float uv[2] = {}; + float normal_xy[2] = {}; bool operator==(const Vertex &p_vtx) const { return (position[0] == p_vtx.position[0]) && @@ -102,7 +102,7 @@ class LightmapperRD : public Lightmapper { }; struct Probe { - float position[4]; + float position[4] = {}; }; Vector<Probe> probe_positions; @@ -158,15 +158,15 @@ class LightmapperRD : public Lightmapper { }; struct Box { - float min_bounds[3]; - float pad0; - float max_bounds[3]; - float pad1; + float min_bounds[3] = {}; + float pad0 = 0.0; + float max_bounds[3] = {}; + float pad1 = 0.0; }; struct Triangle { - uint32_t indices[3]; - uint32_t slice; + uint32_t indices[3] = {}; + uint32_t slice = 0; bool operator<(const Triangle &p_triangle) const { return slice < p_triangle.slice; } @@ -177,8 +177,8 @@ class LightmapperRD : public Lightmapper { Vector<Light> lights; struct TriangleSort { - uint32_t cell_index; - uint32_t triangle_index; + uint32_t cell_index = 0; + uint32_t triangle_index = 0; bool operator<(const TriangleSort &p_triangle_sort) const { return cell_index < p_triangle_sort.cell_index; //sorting by triangle index in this case makes no sense } @@ -187,44 +187,44 @@ class LightmapperRD : public Lightmapper { void _plot_triangle_into_triangle_index_list(int p_size, const Vector3i &p_ofs, const AABB &p_bounds, const Vector3 p_points[], uint32_t p_triangle_index, LocalVector<TriangleSort> &triangles, uint32_t p_grid_size); struct RasterPushConstant { - float atlas_size[2]; - float uv_offset[2]; - float to_cell_size[3]; - uint32_t base_triangle; - float to_cell_offset[3]; - float bias; - int32_t grid_size[3]; - uint32_t pad2; + float atlas_size[2] = {}; + float uv_offset[2] = {}; + float to_cell_size[3] = {}; + uint32_t base_triangle = 0; + float to_cell_offset[3] = {}; + float bias = 0.0; + int32_t grid_size[3] = {}; + uint32_t pad2 = 0; }; struct RasterSeamsPushConstant { - uint32_t base_index; - uint32_t slice; - float uv_offset[2]; - uint32_t debug; - float blend; - uint32_t pad[2]; + uint32_t base_index = 0; + uint32_t slice = 0; + float uv_offset[2] = {}; + uint32_t debug = 0; + float blend = 0.0; + uint32_t pad[2] = {}; }; struct PushConstant { - int32_t atlas_size[2]; - uint32_t ray_count; - uint32_t ray_to; + int32_t atlas_size[2] = {}; + uint32_t ray_count = 0; + uint32_t ray_to = 0; - float world_size[3]; - float bias; + float world_size[3] = {}; + float bias = 0.0; - float to_cell_offset[3]; - uint32_t ray_from; + float to_cell_offset[3] = {}; + uint32_t ray_from = 0; - float to_cell_size[3]; - uint32_t light_count; + float to_cell_size[3] = {}; + uint32_t light_count = 0; - int32_t grid_size; - int32_t atlas_slice; - int32_t region_ofs[2]; + int32_t grid_size = 0; + int32_t atlas_slice = 0; + int32_t region_ofs[2] = {}; - float environment_xform[12]; + float environment_xform[12] = {}; }; Vector<Ref<Image>> bake_textures; diff --git a/modules/lightmapper_rd/lm_common_inc.glsl b/modules/lightmapper_rd/lm_common_inc.glsl index 0ff455936e..f8a0cd16de 100644 --- a/modules/lightmapper_rd/lm_common_inc.glsl +++ b/modules/lightmapper_rd/lm_common_inc.glsl @@ -56,8 +56,8 @@ struct Light { float range; float attenuation; - float spot_angle; - float spot_attenuation; + float cos_spot_angle; + float inv_spot_attenuation; bool static_bake; uint pad[3]; diff --git a/modules/lightmapper_rd/lm_compute.glsl b/modules/lightmapper_rd/lm_compute.glsl index 56976bd623..eb9d817f99 100644 --- a/modules/lightmapper_rd/lm_compute.glsl +++ b/modules/lightmapper_rd/lm_compute.glsl @@ -249,6 +249,15 @@ float quick_hash(vec2 pos) { return fract(sin(dot(pos * 19.19, vec2(49.5791, 97.413))) * 49831.189237); } +float get_omni_attenuation(float distance, float inv_range, float decay) { + float nd = distance * inv_range; + nd *= nd; + nd *= nd; // nd^4 + nd = max(1.0 - nd, 0.0); + nd *= nd; // nd^2 + return nd * pow(max(distance, 0.0001), -decay); +} + void main() { #ifdef MODE_LIGHT_PROBES int probe_index = int(gl_GlobalInvocationID.x); @@ -300,17 +309,20 @@ void main() { d /= lights.data[i].range; - attenuation = pow(max(1.0 - d, 0.0), lights.data[i].attenuation); + attenuation = get_omni_attenuation(d, 1.0 / lights.data[i].range, lights.data[i].attenuation); if (lights.data[i].type == LIGHT_TYPE_SPOT) { vec3 rel = normalize(position - light_pos); - float angle = acos(dot(rel, lights.data[i].direction)); - if (angle > lights.data[i].spot_angle) { + float cos_spot_angle = lights.data[i].cos_spot_angle; + float cos_angle = dot(rel, lights.data[i].direction); + + if (cos_angle < cos_spot_angle) { continue; //invisible, dont try } - float d = clamp(angle / lights.data[i].spot_angle, 0, 1); - attenuation *= pow(1.0 - d, lights.data[i].spot_attenuation); + float scos = max(cos_angle, cos_spot_angle); + float spot_rim = max(0.0001, (1.0 - scos) / (1.0 - cos_spot_angle)); + attenuation *= 1.0 - pow(spot_rim, lights.data[i].inv_spot_attenuation); } } diff --git a/modules/lightmapper_rd/register_types.cpp b/modules/lightmapper_rd/register_types.cpp index b16adaf5d6..191bb3d765 100644 --- a/modules/lightmapper_rd/register_types.cpp +++ b/modules/lightmapper_rd/register_types.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -41,18 +41,18 @@ static Lightmapper *create_lightmapper_rd() { #endif void register_lightmapper_rd_types() { - GLOBAL_DEF("rendering/gpu_lightmapper/quality/low_quality_ray_count", 16); - GLOBAL_DEF("rendering/gpu_lightmapper/quality/medium_quality_ray_count", 64); - GLOBAL_DEF("rendering/gpu_lightmapper/quality/high_quality_ray_count", 256); - GLOBAL_DEF("rendering/gpu_lightmapper/quality/ultra_quality_ray_count", 1024); - GLOBAL_DEF("rendering/gpu_lightmapper/performance/max_rays_per_pass", 32); - GLOBAL_DEF("rendering/gpu_lightmapper/performance/region_size", 512); + GLOBAL_DEF("rendering/lightmapping/bake_quality/low_quality_ray_count", 16); + GLOBAL_DEF("rendering/lightmapping/bake_quality/medium_quality_ray_count", 64); + GLOBAL_DEF("rendering/lightmapping/bake_quality/high_quality_ray_count", 256); + GLOBAL_DEF("rendering/lightmapping/bake_quality/ultra_quality_ray_count", 1024); + GLOBAL_DEF("rendering/lightmapping/bake_performance/max_rays_per_pass", 32); + GLOBAL_DEF("rendering/lightmapping/bake_performance/region_size", 512); - GLOBAL_DEF("rendering/gpu_lightmapper/quality/low_quality_probe_ray_count", 64); - GLOBAL_DEF("rendering/gpu_lightmapper/quality/medium_quality_probe_ray_count", 256); - GLOBAL_DEF("rendering/gpu_lightmapper/quality/high_quality_probe_ray_count", 512); - GLOBAL_DEF("rendering/gpu_lightmapper/quality/ultra_quality_probe_ray_count", 2048); - GLOBAL_DEF("rendering/gpu_lightmapper/performance/max_rays_per_probe_pass", 64); + GLOBAL_DEF("rendering/lightmapping/bake_quality/low_quality_probe_ray_count", 64); + GLOBAL_DEF("rendering/lightmapping/bake_quality/medium_quality_probe_ray_count", 256); + GLOBAL_DEF("rendering/lightmapping/bake_quality/high_quality_probe_ray_count", 512); + GLOBAL_DEF("rendering/lightmapping/bake_quality/ultra_quality_probe_ray_count", 2048); + GLOBAL_DEF("rendering/lightmapping/bake_performance/max_rays_per_probe_pass", 64); #ifndef _3D_DISABLED ClassDB::register_class<LightmapperRD>(); Lightmapper::create_gpu = create_lightmapper_rd; diff --git a/modules/lightmapper_rd/register_types.h b/modules/lightmapper_rd/register_types.h index b0e15a927f..622d6e37a7 100644 --- a/modules/lightmapper_rd/register_types.h +++ b/modules/lightmapper_rd/register_types.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/mbedtls/SCsub b/modules/mbedtls/SCsub index 4fcbe8fb43..4fcbe8fb43 100755..100644 --- a/modules/mbedtls/SCsub +++ b/modules/mbedtls/SCsub diff --git a/modules/mbedtls/config.py b/modules/mbedtls/config.py index d22f9454ed..d22f9454ed 100755..100644 --- a/modules/mbedtls/config.py +++ b/modules/mbedtls/config.py diff --git a/modules/mbedtls/crypto_mbedtls.cpp b/modules/mbedtls/crypto_mbedtls.cpp index 4ea38ebd60..73931b0365 100644 --- a/modules/mbedtls/crypto_mbedtls.cpp +++ b/modules/mbedtls/crypto_mbedtls.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -205,7 +205,7 @@ Error HMACContextMbedTLS::start(HashingContext::HashType p_hash_type, PackedByte ERR_FAIL_COND_V_MSG(ctx != nullptr, ERR_FILE_ALREADY_IN_USE, "HMACContext already started."); // HMAC keys can be any size. - ERR_FAIL_COND_V_MSG(p_key.empty(), ERR_INVALID_PARAMETER, "Key must not be empty."); + ERR_FAIL_COND_V_MSG(p_key.is_empty(), ERR_INVALID_PARAMETER, "Key must not be empty."); hash_type = p_hash_type; mbedtls_md_type_t ht = CryptoMbedTLS::md_type_from_hashtype(p_hash_type, hash_len); @@ -224,7 +224,7 @@ Error HMACContextMbedTLS::start(HashingContext::HashType p_hash_type, PackedByte Error HMACContextMbedTLS::update(PackedByteArray p_data) { ERR_FAIL_COND_V_MSG(ctx == nullptr, ERR_INVALID_DATA, "Start must be called before update."); - ERR_FAIL_COND_V_MSG(p_data.empty(), ERR_INVALID_PARAMETER, "Src must not be empty."); + ERR_FAIL_COND_V_MSG(p_data.is_empty(), ERR_INVALID_PARAMETER, "Src must not be empty."); int ret = mbedtls_md_hmac_update((mbedtls_md_context_t *)ctx, (const uint8_t *)p_data.ptr(), (size_t)p_data.size()); return ret ? FAILED : OK; diff --git a/modules/mbedtls/crypto_mbedtls.h b/modules/mbedtls/crypto_mbedtls.h index 990f8ae578..5ced4d136c 100644 --- a/modules/mbedtls/crypto_mbedtls.h +++ b/modules/mbedtls/crypto_mbedtls.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/mbedtls/dtls_server_mbedtls.cpp b/modules/mbedtls/dtls_server_mbedtls.cpp index d9961b026f..5d895d8579 100644 --- a/modules/mbedtls/dtls_server_mbedtls.cpp +++ b/modules/mbedtls/dtls_server_mbedtls.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/mbedtls/dtls_server_mbedtls.h b/modules/mbedtls/dtls_server_mbedtls.h index d93553bf7f..9f0c9670e7 100644 --- a/modules/mbedtls/dtls_server_mbedtls.h +++ b/modules/mbedtls/dtls_server_mbedtls.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/mbedtls/packet_peer_mbed_dtls.cpp b/modules/mbedtls/packet_peer_mbed_dtls.cpp index 8206d739ae..8a6cdfb131 100644 --- a/modules/mbedtls/packet_peer_mbed_dtls.cpp +++ b/modules/mbedtls/packet_peer_mbed_dtls.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -246,7 +246,6 @@ int PacketPeerMbedDTLS::get_max_packet_size() const { PacketPeerMbedDTLS::PacketPeerMbedDTLS() { ssl_ctx.instance(); - status = STATUS_DISCONNECTED; } PacketPeerMbedDTLS::~PacketPeerMbedDTLS() { diff --git a/modules/mbedtls/packet_peer_mbed_dtls.h b/modules/mbedtls/packet_peer_mbed_dtls.h index b958fa3b95..6554c74a21 100755..100644 --- a/modules/mbedtls/packet_peer_mbed_dtls.h +++ b/modules/mbedtls/packet_peer_mbed_dtls.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -44,7 +44,7 @@ private: uint8_t packet_buffer[PACKET_BUFFER_SIZE]; - Status status; + Status status = STATUS_DISCONNECTED; String hostname; Ref<PacketPeerUDP> base; diff --git a/modules/mbedtls/register_types.cpp b/modules/mbedtls/register_types.cpp index 59abbac8ec..e483030b94 100644 --- a/modules/mbedtls/register_types.cpp +++ b/modules/mbedtls/register_types.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/mbedtls/register_types.h b/modules/mbedtls/register_types.h index 90c81b1682..46ffb8522b 100755..100644 --- a/modules/mbedtls/register_types.h +++ b/modules/mbedtls/register_types.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/mbedtls/ssl_context_mbedtls.cpp b/modules/mbedtls/ssl_context_mbedtls.cpp index a2200e0644..cbb532587f 100644 --- a/modules/mbedtls/ssl_context_mbedtls.cpp +++ b/modules/mbedtls/ssl_context_mbedtls.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -76,7 +76,6 @@ void CookieContextMbedTLS::clear() { } CookieContextMbedTLS::CookieContextMbedTLS() { - inited = false; } CookieContextMbedTLS::~CookieContextMbedTLS() { @@ -205,7 +204,6 @@ mbedtls_ssl_context *SSLContextMbedTLS::get_context() { } SSLContextMbedTLS::SSLContextMbedTLS() { - inited = false; } SSLContextMbedTLS::~SSLContextMbedTLS() { diff --git a/modules/mbedtls/ssl_context_mbedtls.h b/modules/mbedtls/ssl_context_mbedtls.h index 96703a7eb7..30632018a8 100644 --- a/modules/mbedtls/ssl_context_mbedtls.h +++ b/modules/mbedtls/ssl_context_mbedtls.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -50,7 +50,7 @@ class CookieContextMbedTLS : public Reference { friend class SSLContextMbedTLS; protected: - bool inited; + bool inited = false; mbedtls_entropy_context entropy; mbedtls_ctr_drbg_context ctr_drbg; mbedtls_ssl_cookie_ctx cookie_ctx; @@ -65,7 +65,7 @@ public: class SSLContextMbedTLS : public Reference { protected: - bool inited; + bool inited = false; static PackedByteArray _read_file(String p_path); diff --git a/modules/mbedtls/stream_peer_mbedtls.cpp b/modules/mbedtls/stream_peer_mbedtls.cpp index e9a610b7ee..d7597aa435 100644 --- a/modules/mbedtls/stream_peer_mbedtls.cpp +++ b/modules/mbedtls/stream_peer_mbedtls.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -274,7 +274,6 @@ int StreamPeerMbedTLS::get_available_bytes() const { StreamPeerMbedTLS::StreamPeerMbedTLS() { ssl_ctx.instance(); - status = STATUS_DISCONNECTED; } StreamPeerMbedTLS::~StreamPeerMbedTLS() { diff --git a/modules/mbedtls/stream_peer_mbedtls.h b/modules/mbedtls/stream_peer_mbedtls.h index 68b03ae995..b89d7fb238 100755..100644 --- a/modules/mbedtls/stream_peer_mbedtls.h +++ b/modules/mbedtls/stream_peer_mbedtls.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -36,7 +36,7 @@ class StreamPeerMbedTLS : public StreamPeerSSL { private: - Status status; + Status status = STATUS_DISCONNECTED; String hostname; Ref<StreamPeer> base; diff --git a/modules/mbedtls/tests/test_crypto_mbedtls.cpp b/modules/mbedtls/tests/test_crypto_mbedtls.cpp index c5a27aa794..4217497082 100644 --- a/modules/mbedtls/tests/test_crypto_mbedtls.cpp +++ b/modules/mbedtls/tests/test_crypto_mbedtls.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/mbedtls/tests/test_crypto_mbedtls.h b/modules/mbedtls/tests/test_crypto_mbedtls.h index 7b1e062239..b798717e52 100644 --- a/modules/mbedtls/tests/test_crypto_mbedtls.h +++ b/modules/mbedtls/tests/test_crypto_mbedtls.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/meshoptimizer/register_types.cpp b/modules/meshoptimizer/register_types.cpp index 26c8c6ab72..a03310f518 100644 --- a/modules/meshoptimizer/register_types.cpp +++ b/modules/meshoptimizer/register_types.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -35,9 +35,13 @@ void register_meshoptimizer_types() { SurfaceTool::optimize_vertex_cache_func = meshopt_optimizeVertexCache; SurfaceTool::simplify_func = meshopt_simplify; + SurfaceTool::simplify_scale_func = meshopt_simplifyScale; + SurfaceTool::simplify_sloppy_func = meshopt_simplifySloppy; } void unregister_meshoptimizer_types() { SurfaceTool::optimize_vertex_cache_func = nullptr; SurfaceTool::simplify_func = nullptr; + SurfaceTool::simplify_scale_func = nullptr; + SurfaceTool::simplify_sloppy_func = nullptr; } diff --git a/modules/meshoptimizer/register_types.h b/modules/meshoptimizer/register_types.h index 42b3a76a85..5b15503acd 100644 --- a/modules/meshoptimizer/register_types.h +++ b/modules/meshoptimizer/register_types.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/minimp3/audio_stream_mp3.cpp b/modules/minimp3/audio_stream_mp3.cpp index b20c043e0c..b128b81000 100644 --- a/modules/minimp3/audio_stream_mp3.cpp +++ b/modules/minimp3/audio_stream_mp3.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -120,7 +120,10 @@ AudioStreamPlaybackMP3::~AudioStreamPlaybackMP3() { Ref<AudioStreamPlayback> AudioStreamMP3::instance_playback() { Ref<AudioStreamPlaybackMP3> mp3s; - ERR_FAIL_COND_V(data == nullptr, mp3s); + ERR_FAIL_COND_V_MSG(data == nullptr, mp3s, + "This AudioStreamMP3 does not have an audio file assigned " + "to it. AudioStreamMP3 should not be created from the " + "inspector or with `.new()`. Instead, load an audio file."); mp3s.instance(); mp3s->mp3_stream = Ref<AudioStreamMP3>(this); @@ -156,7 +159,8 @@ void AudioStreamMP3::set_data(const Vector<uint8_t> &p_data) { const uint8_t *src_datar = p_data.ptr(); mp3dec_ex_t mp3d; - mp3dec_ex_open_buf(&mp3d, src_datar, src_data_len, MP3D_SEEK_TO_SAMPLE); + int err = mp3dec_ex_open_buf(&mp3d, src_datar, src_data_len, MP3D_SEEK_TO_SAMPLE); + ERR_FAIL_COND(err != 0); channels = mp3d.info.channels; sample_rate = mp3d.info.hz; diff --git a/modules/minimp3/audio_stream_mp3.h b/modules/minimp3/audio_stream_mp3.h index 8d67190ac5..ce001fc418 100644 --- a/modules/minimp3/audio_stream_mp3.h +++ b/modules/minimp3/audio_stream_mp3.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -78,11 +78,11 @@ class AudioStreamMP3 : public AudioStream { void *data = nullptr; uint32_t data_len = 0; - float sample_rate = 1; + float sample_rate = 1.0; int channels = 1; - float length = 0; + float length = 0.0; bool loop = false; - float loop_offset = 0; + float loop_offset = 0.0; void clear_data(); protected: diff --git a/modules/minimp3/register_types.cpp b/modules/minimp3/register_types.cpp index 2c648b8efe..4ab4c743d6 100644 --- a/modules/minimp3/register_types.cpp +++ b/modules/minimp3/register_types.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/minimp3/register_types.h b/modules/minimp3/register_types.h index 0d841e4987..96227c272e 100644 --- a/modules/minimp3/register_types.h +++ b/modules/minimp3/register_types.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/minimp3/resource_importer_mp3.cpp b/modules/minimp3/resource_importer_mp3.cpp index 82e536a755..afd26fb79e 100644 --- a/modules/minimp3/resource_importer_mp3.cpp +++ b/modules/minimp3/resource_importer_mp3.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/minimp3/resource_importer_mp3.h b/modules/minimp3/resource_importer_mp3.h index c1e8315e21..71b51887a2 100644 --- a/modules/minimp3/resource_importer_mp3.h +++ b/modules/minimp3/resource_importer_mp3.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/mobile_vr/mobile_vr_interface.cpp b/modules/mobile_vr/mobile_vr_interface.cpp index a2fb443ef0..25b110dc62 100644 --- a/modules/mobile_vr/mobile_vr_interface.cpp +++ b/modules/mobile_vr/mobile_vr_interface.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -448,19 +448,7 @@ void MobileVRInterface::process() { }; }; -MobileVRInterface::MobileVRInterface() { - initialized = false; - - // Just set some defaults for these. At some point we need to look at adding a lookup table for common device + headset combos and/or support reading cardboard QR codes - eye_height = 1.85; - intraocular_dist = 6.0; - display_width = 14.5; - display_to_lens = 4.0; - oversample = 1.5; - k1 = 0.215; - k2 = 0.215; - last_ticks = 0; -}; +MobileVRInterface::MobileVRInterface() {} MobileVRInterface::~MobileVRInterface() { // and make sure we cleanup if we haven't already diff --git a/modules/mobile_vr/mobile_vr_interface.h b/modules/mobile_vr/mobile_vr_interface.h index 9b03fff777..d28c2196af 100644 --- a/modules/mobile_vr/mobile_vr_interface.h +++ b/modules/mobile_vr/mobile_vr_interface.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -51,19 +51,21 @@ class MobileVRInterface : public XRInterface { GDCLASS(MobileVRInterface, XRInterface); private: - bool initialized; + bool initialized = false; Basis orientation; - float eye_height; - uint64_t last_ticks; - real_t intraocular_dist; - real_t display_width; - real_t display_to_lens; - real_t oversample; + // Just set some defaults for these. At some point we need to look at adding a lookup table for common device + headset combos and/or support reading cardboard QR codes + float eye_height = 1.85; + uint64_t last_ticks = 0; + + real_t intraocular_dist = 6.0; + real_t display_width = 14.5; + real_t display_to_lens = 4.0; + real_t oversample = 1.5; //@TODO not yet used, these are needed in our distortion shader... - real_t k1; - real_t k2; + real_t k1 = 0.215; + real_t k2 = 0.215; /* logic for processing our sensor data, this was originally in our positional tracker logic but I think @@ -73,9 +75,9 @@ private: Vector3 scale_magneto(const Vector3 &p_magnetometer); Basis combine_acc_mag(const Vector3 &p_grav, const Vector3 &p_magneto); - int mag_count; - bool has_gyro; - bool sensor_first; + int mag_count = 0; + bool has_gyro = false; + bool sensor_first = false; Vector3 last_accerometer_data; Vector3 last_magnetometer_data; Vector3 mag_current_min; diff --git a/modules/mobile_vr/register_types.cpp b/modules/mobile_vr/register_types.cpp index 0bb555e780..e7d33ba8a7 100644 --- a/modules/mobile_vr/register_types.cpp +++ b/modules/mobile_vr/register_types.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/mobile_vr/register_types.h b/modules/mobile_vr/register_types.h index 33f608b6ed..9f20f252a4 100644 --- a/modules/mobile_vr/register_types.h +++ b/modules/mobile_vr/register_types.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/mono/class_db_api_json.cpp b/modules/mono/class_db_api_json.cpp index e3119a8da7..553c6eca53 100644 --- a/modules/mono/class_db_api_json.cpp +++ b/modules/mono/class_db_api_json.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -71,7 +71,7 @@ void class_db_api_to_json(const String &p_output_file, ClassDB::APIType p_api) { while ((k = t->method_map.next(k))) { String name = k->operator String(); - ERR_CONTINUE(name.empty()); + ERR_CONTINUE(name.is_empty()); if (name[0] == '_') { continue; // Ignore non-virtual methods that start with an underscore @@ -122,7 +122,7 @@ void class_db_api_to_json(const String &p_output_file, ClassDB::APIType p_api) { method_dict["hint_flags"] = mb->get_hint_flags(); } - if (!methods.empty()) { + if (!methods.is_empty()) { class_dict["methods"] = methods; } } @@ -149,7 +149,7 @@ void class_db_api_to_json(const String &p_output_file, ClassDB::APIType p_api) { constant_dict["value"] = t->constant_map[F->get()]; } - if (!constants.empty()) { + if (!constants.is_empty()) { class_dict["constants"] = constants; } } @@ -184,7 +184,7 @@ void class_db_api_to_json(const String &p_output_file, ClassDB::APIType p_api) { } } - if (!signals.empty()) { + if (!signals.is_empty()) { class_dict["signals"] = signals; } } @@ -214,7 +214,7 @@ void class_db_api_to_json(const String &p_output_file, ClassDB::APIType p_api) { property_dict["getter"] = psg->getter; } - if (!properties.empty()) { + if (!properties.is_empty()) { class_dict["property_setget"] = properties; } } @@ -233,7 +233,7 @@ void class_db_api_to_json(const String &p_output_file, ClassDB::APIType p_api) { property_dict["usage"] = F->get().usage; } - if (!property_list.empty()) { + if (!property_list.is_empty()) { class_dict["property_list"] = property_list; } } diff --git a/modules/mono/class_db_api_json.h b/modules/mono/class_db_api_json.h index 6b7f5a4d88..6698a6260f 100644 --- a/modules/mono/class_db_api_json.h +++ b/modules/mono/class_db_api_json.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index 63ac0956f4..25cc64393a 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -346,14 +346,18 @@ Ref<Script> CSharpLanguage::get_template(const String &p_class_name, const Strin "// }\n" "}\n"; - String base_class_name = get_base_class_name(p_base_class_name, p_class_name); + // Replaces all spaces in p_class_name with underscores to prevent + // erronous C# Script templates from being generated when the object name + // has spaces in it. + String class_name_no_spaces = p_class_name.replace(" ", "_"); + String base_class_name = get_base_class_name(p_base_class_name, class_name_no_spaces); script_template = script_template.replace("%BASE%", base_class_name) - .replace("%CLASS%", p_class_name); + .replace("%CLASS%", class_name_no_spaces); Ref<CSharpScript> script; script.instance(); script->set_source_code(script_template); - script->set_name(p_class_name); + script->set_name(class_name_no_spaces); return script; } @@ -364,9 +368,10 @@ bool CSharpLanguage::is_using_templates() { void CSharpLanguage::make_template(const String &p_class_name, const String &p_base_class_name, Ref<Script> &p_script) { String src = p_script->get_source_code(); - String base_class_name = get_base_class_name(p_base_class_name, p_class_name); + String class_name_no_spaces = p_class_name.replace(" ", "_"); + String base_class_name = get_base_class_name(p_base_class_name, class_name_no_spaces); src = src.replace("%BASE%", base_class_name) - .replace("%CLASS%", p_class_name) + .replace("%CLASS%", class_name_no_spaces) .replace("%TS%", _get_indentation()); p_script->set_source_code(src); } @@ -395,7 +400,7 @@ bool CSharpLanguage::supports_builtin_mode() const { #ifdef TOOLS_ENABLED static String variant_type_to_managed_name(const String &p_var_type_name) { - if (p_var_type_name.empty()) { + if (p_var_type_name.is_empty()) { return "object"; } @@ -757,7 +762,7 @@ bool CSharpLanguage::is_assembly_reloading_needed() { String appname = ProjectSettings::get_singleton()->get("application/config/name"); String appname_safe = OS::get_singleton()->get_safe_dir_name(appname); - if (appname_safe.empty()) { + if (appname_safe.is_empty()) { appname_safe = "UnnamedProject"; } @@ -854,7 +859,7 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) { to_reload.push_back(script); - if (script->get_path().empty()) { + if (script->get_path().is_empty()) { script->tied_class_name_for_reload = script->script_class->get_name_for_lookup(); script->tied_class_namespace_for_reload = script->script_class->get_namespace(); } @@ -971,7 +976,7 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) { #endif script->signals_invalidated = true; - if (!script->get_path().empty()) { + if (!script->get_path().is_empty()) { script->reload(p_soft_reload); if (!script->valid) { @@ -1441,7 +1446,7 @@ Map<Object *, CSharpScriptBinding>::Element *CSharpLanguage::insert_script_bindi void CSharpLanguage::free_instance_binding_data(void *p_data) { if (GDMono::get_singleton() == nullptr) { #ifdef DEBUG_ENABLED - CRASH_COND(!script_bindings.empty()); + CRASH_COND(!script_bindings.is_empty()); #endif // Mono runtime finalized, all the gchandle bindings were already released return; @@ -2599,7 +2604,7 @@ void CSharpScript::load_script_signals(GDMonoClass *p_class, GDMonoClass *p_nati MonoCustomAttrInfo *event_attrs = mono_custom_attrs_from_event(top->get_mono_ptr(), raw_event); if (event_attrs) { if (mono_custom_attrs_has_attr(event_attrs, CACHED_CLASS(SignalAttribute)->get_mono_ptr())) { - const char *event_name = mono_event_get_name(raw_event); + String event_name = String::utf8(mono_event_get_name(raw_event)); found_event_signals.push_back(StringName(event_name)); } @@ -2803,7 +2808,7 @@ int CSharpScript::_try_get_member_export_hint(IMonoClassMember *p_member, Manage name_only_hint_string += ","; } - String enum_field_name = mono_field_get_name(field); + String enum_field_name = String::utf8(mono_field_get_name(field)); r_hint_string += enum_field_name; name_only_hint_string += enum_field_name; @@ -3123,7 +3128,7 @@ CSharpInstance *CSharpScript::_create_instance(const Variant **p_args, int p_arg ERR_FAIL_COND_V_MSG(p_argcount == 0, nullptr, "Cannot create script instance. The class '" + script_class->get_full_name() + "' does not define a parameterless constructor." + - (get_path().empty() ? String() : " Path: '" + get_path() + "'.")); + (get_path().is_empty() ? String() : " Path: '" + get_path() + "'.")); ERR_FAIL_V_MSG(nullptr, "Constructor not found."); } @@ -3278,7 +3283,7 @@ bool CSharpScript::instance_has(const Object *p_this) const { } bool CSharpScript::has_source_code() const { - return !source.empty(); + return !source.is_empty(); } String CSharpScript::get_source_code() const { @@ -3579,9 +3584,9 @@ Error CSharpScript::load_source_code(const String &p_path) { ERR_FAIL_COND_V_MSG(ferr != OK, ferr, ferr == ERR_INVALID_DATA ? - "Script '" + p_path + "' contains invalid unicode (UTF-8), so it was not loaded." + "Script '" + p_path + "' contains invalid unicode (UTF-8), so it was not loaded." " Please ensure that scripts are saved in valid UTF-8 unicode." : - "Failed to read file: '" + p_path + "'."); + "Failed to read file: '" + p_path + "'."); #ifdef TOOLS_ENABLED source_changed_cache = true; @@ -3593,7 +3598,7 @@ Error CSharpScript::load_source_code(const String &p_path) { void CSharpScript::_update_name() { String path = get_path(); - if (!path.empty()) { + if (!path.is_empty()) { name = get_path().get_file().get_basename(); } } @@ -3639,7 +3644,7 @@ void CSharpScript::get_members(Set<StringName> *p_members) { /*************** RESOURCE ***************/ -RES ResourceFormatLoaderCSharpScript::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, bool p_no_cache) { +RES ResourceFormatLoaderCSharpScript::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, CacheMode p_cache_mode) { if (r_error) { *r_error = ERR_FILE_CANT_OPEN; } diff --git a/modules/mono/csharp_script.h b/modules/mono/csharp_script.h index f482cc21f0..a31135cd32 100644 --- a/modules/mono/csharp_script.h +++ b/modules/mono/csharp_script.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -542,7 +542,7 @@ public: class ResourceFormatLoaderCSharpScript : public ResourceFormatLoader { public: - RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr, bool p_no_cache = false) override; + RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr, CacheMode p_cache_mode = CACHE_MODE_REUSE) override; void get_recognized_extensions(List<String> *p_extensions) const override; bool handles_type(const String &p_type) const override; String get_resource_type(const String &p_path) const override; diff --git a/modules/mono/editor/GodotTools/GodotTools/Build/MsBuildFinder.cs b/modules/mono/editor/GodotTools/GodotTools/Build/MsBuildFinder.cs index e2feb66e35..774c49e705 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Build/MsBuildFinder.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Build/MsBuildFinder.cs @@ -86,7 +86,7 @@ namespace GodotTools.Build { case BuildTool.DotnetCli: { - string dotnetCliPath = OS.PathWhich("dotnet"); + string dotnetCliPath = FindBuildEngineOnUnix("dotnet"); if (!string.IsNullOrEmpty(dotnetCliPath)) return (dotnetCliPath, BuildTool.DotnetCli); GD.PushError($"Cannot find executable for '{BuildManager.PropNameDotnetCli}'. Fallback to MSBuild from Mono."); @@ -122,7 +122,11 @@ namespace GodotTools.Build if (OS.IsMacOS) { result.Add("/Library/Frameworks/Mono.framework/Versions/Current/bin/"); + result.Add("/opt/local/bin/"); result.Add("/usr/local/var/homebrew/linked/mono/bin/"); + result.Add("/usr/local/bin/"); + result.Add("/usr/local/bin/dotnet/"); + result.Add("/usr/local/share/dotnet/"); } result.Add("/opt/novell/mono/bin/"); @@ -181,7 +185,7 @@ namespace GodotTools.Build var outputArray = new Godot.Collections.Array<string>(); int exitCode = Godot.OS.Execute(vsWherePath, vsWhereArgs, - blocking: true, output: (Godot.Collections.Array)outputArray); + output: (Godot.Collections.Array)outputArray); if (exitCode != 0) return string.Empty; diff --git a/modules/mono/editor/GodotTools/GodotTools/Export/AotBuilder.cs b/modules/mono/editor/GodotTools/GodotTools/Export/AotBuilder.cs index 5bb8d444c2..5bb8d444c2 100755..100644 --- a/modules/mono/editor/GodotTools/GodotTools/Export/AotBuilder.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Export/AotBuilder.cs diff --git a/modules/mono/editor/GodotTools/GodotTools/Export/XcodeHelper.cs b/modules/mono/editor/GodotTools/GodotTools/Export/XcodeHelper.cs index 219b7a698a..93ef837a83 100755..100644 --- a/modules/mono/editor/GodotTools/GodotTools/Export/XcodeHelper.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Export/XcodeHelper.cs @@ -27,7 +27,7 @@ namespace GodotTools.Export { var outputWrapper = new Godot.Collections.Array(); - int exitCode = Godot.OS.Execute("xcode-select", new string[] { "--print-path" }, blocking: true, output: outputWrapper); + int exitCode = Godot.OS.Execute("xcode-select", new string[] { "--print-path" }, output: outputWrapper); if (exitCode == 0) { diff --git a/modules/mono/editor/GodotTools/GodotTools/Ides/Rider/RiderPathManager.cs b/modules/mono/editor/GodotTools/GodotTools/Ides/Rider/RiderPathManager.cs index 16f91a0925..ed25cdaa63 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Ides/Rider/RiderPathManager.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Ides/Rider/RiderPathManager.cs @@ -104,7 +104,7 @@ namespace GodotTools.Ides.Rider if (line >= 0) { args.Add("--line"); - args.Add(line.ToString()); + args.Add((line + 1).ToString()); // https://github.com/JetBrains/godot-support/issues/61 } args.Add(scriptPath); try diff --git a/modules/mono/editor/bindings_generator.cpp b/modules/mono/editor/bindings_generator.cpp index ad7e5d4200..ea1a2053df 100644 --- a/modules/mono/editor/bindings_generator.cpp +++ b/modules/mono/editor/bindings_generator.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -181,7 +181,7 @@ static String snake_to_camel_case(const String &p_identifier, bool p_input_is_up String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterface *p_itype) { // Based on the version in EditorHelp - if (p_bbcode.empty()) { + if (p_bbcode.is_empty()) { return String(); } @@ -365,7 +365,7 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf xml_output.append("</c>"); } else if (link_tag == "enum") { StringName search_cname = !target_itype ? target_cname : - StringName(target_itype->name + "." + (String)target_cname); + StringName(target_itype->name + "." + (String)target_cname); const Map<StringName, TypeInterface>::Element *enum_match = enum_types.find(search_cname); @@ -644,7 +644,7 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf } int BindingsGenerator::_determine_enum_prefix(const EnumInterface &p_ienum) { - CRASH_COND(p_ienum.constants.empty()); + CRASH_COND(p_ienum.constants.is_empty()); const ConstantInterface &front_iconstant = p_ienum.constants.front()->get(); Vector<String> front_parts = front_iconstant.name.split("_", /* p_allow_empty: */ true); @@ -819,7 +819,7 @@ void BindingsGenerator::_generate_global_constants(StringBuilder &p_output) { p_output.append(";"); } - if (!global_constants.empty()) { + if (!global_constants.is_empty()) { p_output.append("\n"); } @@ -830,7 +830,7 @@ void BindingsGenerator::_generate_global_constants(StringBuilder &p_output) { for (List<EnumInterface>::Element *E = global_enums.front(); E; E = E->next()) { const EnumInterface &ienum = E->get(); - CRASH_COND(ienum.constants.empty()); + CRASH_COND(ienum.constants.is_empty()); String enum_proxy_name = ienum.cname.operator String(); @@ -1283,7 +1283,7 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str for (const List<EnumInterface>::Element *E = itype.enums.front(); E; E = E->next()) { const EnumInterface &ienum = E->get(); - ERR_FAIL_COND_V(ienum.constants.empty(), ERR_BUG); + ERR_FAIL_COND_V(ienum.constants.is_empty(), ERR_BUG); output.append(MEMBER_BEGIN "public enum "); output.append(ienum.cname.operator String()); @@ -1479,6 +1479,12 @@ Error BindingsGenerator::_generate_cs_property(const BindingsGenerator::TypeInte ERR_FAIL_COND_V_MSG(prop_itype->is_singleton, ERR_BUG, "Property type is a singleton: '" + p_itype.name + "." + String(p_iprop.cname) + "'."); + if (p_itype.api_type == ClassDB::API_CORE) { + ERR_FAIL_COND_V_MSG(prop_itype->api_type == ClassDB::API_EDITOR, ERR_BUG, + "Property '" + p_itype.name + "." + String(p_iprop.cname) + "' has type '" + prop_itype->name + + "' from the editor API. Core API cannot have dependencies on the editor API."); + } + if (p_iprop.prop_doc && p_iprop.prop_doc->description.size()) { String xml_summary = bbcode_to_xml(fix_doc_description(p_iprop.prop_doc->description), &p_itype); Vector<String> summary_lines = xml_summary.length() ? xml_summary.split("\n") : Vector<String>(); @@ -1575,6 +1581,12 @@ Error BindingsGenerator::_generate_cs_method(const BindingsGenerator::TypeInterf ERR_FAIL_COND_V_MSG(return_type->is_singleton, ERR_BUG, "Method return type is a singleton: '" + p_itype.name + "." + p_imethod.name + "'."); + if (p_itype.api_type == ClassDB::API_CORE) { + ERR_FAIL_COND_V_MSG(return_type->api_type == ClassDB::API_EDITOR, ERR_BUG, + "Method '" + p_itype.name + "." + p_imethod.name + "' has return type '" + return_type->name + + "' from the editor API. Core API cannot have dependencies on the editor API."); + } + String method_bind_field = "__method_bind_" + itos(p_method_bind_count); String arguments_sig; @@ -1593,6 +1605,12 @@ Error BindingsGenerator::_generate_cs_method(const BindingsGenerator::TypeInterf ERR_FAIL_COND_V_MSG(arg_type->is_singleton, ERR_BUG, "Argument type is a singleton: '" + iarg.name + "' of method '" + p_itype.name + "." + p_imethod.name + "'."); + if (p_itype.api_type == ClassDB::API_CORE) { + ERR_FAIL_COND_V_MSG(arg_type->api_type == ClassDB::API_EDITOR, ERR_BUG, + "Argument '" + iarg.name + "' of method '" + p_itype.name + "." + p_imethod.name + "' has type '" + + arg_type->name + "' from the editor API. Core API cannot have dependencies on the editor API."); + } + if (iarg.default_argument.size()) { CRASH_COND_MSG(!_arg_default_value_is_assignable_to_type(iarg.def_param_value, *arg_type), "Invalid default value for parameter '" + iarg.name + "' of method '" + p_itype.name + "." + p_imethod.name + "'."); @@ -1661,14 +1679,14 @@ Error BindingsGenerator::_generate_cs_method(const BindingsGenerator::TypeInterf cs_in_statements += def_arg; cs_in_statements += ";\n" INDENT3; - icall_params += arg_type->cs_in.empty() ? arg_in : sformat(arg_type->cs_in, arg_in); + icall_params += arg_type->cs_in.is_empty() ? arg_in : sformat(arg_type->cs_in, arg_in); // Apparently the name attribute must not include the @ String param_tag_name = iarg.name.begins_with("@") ? iarg.name.substr(1, iarg.name.length()) : iarg.name; default_args_doc.append(MEMBER_BEGIN "/// <param name=\"" + param_tag_name + "\">If the parameter is null, then the default value is " + def_arg + "</param>"); } else { - icall_params += arg_type->cs_in.empty() ? iarg.name : sformat(arg_type->cs_in, iarg.name); + icall_params += arg_type->cs_in.is_empty() ? iarg.name : sformat(arg_type->cs_in, iarg.name); } } @@ -1714,7 +1732,7 @@ Error BindingsGenerator::_generate_cs_method(const BindingsGenerator::TypeInterf } if (p_imethod.is_deprecated) { - if (p_imethod.deprecation_message.empty()) { + if (p_imethod.deprecation_message.is_empty()) { WARN_PRINT("An empty deprecation message is discouraged. Method: '" + p_imethod.proxy_name + "'."); } @@ -1782,7 +1800,7 @@ Error BindingsGenerator::_generate_cs_method(const BindingsGenerator::TypeInterf if (return_type->cname == name_cache.type_void) { p_output.append(im_call + "(" + icall_params + ");\n"); - } else if (return_type->cs_out.empty()) { + } else if (return_type->cs_out.is_empty()) { p_output.append("return " + im_call + "(" + icall_params + ");\n"); } else { p_output.append(sformat(return_type->cs_out, im_call, icall_params, return_type->cs_type, return_type->im_type_out)); @@ -1806,7 +1824,13 @@ Error BindingsGenerator::_generate_cs_signal(const BindingsGenerator::TypeInterf const TypeInterface *arg_type = _get_type_or_placeholder(iarg.type); ERR_FAIL_COND_V_MSG(arg_type->is_singleton, ERR_BUG, - "Argument type is a singleton: '" + iarg.name + "' of signal" + p_itype.name + "." + p_isignal.name + "'."); + "Argument type is a singleton: '" + iarg.name + "' of signal '" + p_itype.name + "." + p_isignal.name + "'."); + + if (p_itype.api_type == ClassDB::API_CORE) { + ERR_FAIL_COND_V_MSG(arg_type->api_type == ClassDB::API_EDITOR, ERR_BUG, + "Argument '" + iarg.name + "' of signal '" + p_itype.name + "." + p_isignal.name + "' has type '" + + arg_type->name + "' from the editor API. Core API cannot have dependencies on the editor API."); + } // Add the current arguments to the signature @@ -1839,7 +1863,7 @@ Error BindingsGenerator::_generate_cs_signal(const BindingsGenerator::TypeInterf } if (p_isignal.is_deprecated) { - if (p_isignal.deprecation_message.empty()) { + if (p_isignal.deprecation_message.is_empty()) { WARN_PRINT("An empty deprecation message is discouraged. Signal: '" + p_isignal.proxy_name + "'."); } @@ -2263,7 +2287,7 @@ Error BindingsGenerator::_generate_glue_method(const BindingsGenerator::TypeInte } if (!ret_void) { - if (return_type->c_out.empty()) { + if (return_type->c_out.is_empty()) { p_output.append("\treturn " C_LOCAL_RET ";\n"); } else if (return_type->ret_as_byref_arg) { p_output.append(sformat(return_type->c_out, return_type->c_type_out, C_LOCAL_RET, return_type->name, "arg_ret")); @@ -2585,7 +2609,7 @@ bool BindingsGenerator::_populate_object_type_interfaces() { int argc = method_info.arguments.size(); - if (method_info.name.empty()) { + if (method_info.name.is_empty()) { continue; } diff --git a/modules/mono/editor/bindings_generator.h b/modules/mono/editor/bindings_generator.h index 0cc1bb5f46..b18dfb0ec4 100644 --- a/modules/mono/editor/bindings_generator.h +++ b/modules/mono/editor/bindings_generator.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/mono/editor/code_completion.cpp b/modules/mono/editor/code_completion.cpp index 2d37b1306c..bbfba83e6f 100644 --- a/modules/mono/editor/code_completion.cpp +++ b/modules/mono/editor/code_completion.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -150,7 +150,7 @@ PackedStringArray get_code_completion(CompletionKind p_kind, const String &p_scr List<String> directories; directories.push_back(dir_access->get_current_dir()); - while (!directories.empty()) { + while (!directories.is_empty()) { dir_access->change_dir(directories.back()->get()); directories.pop_back(); diff --git a/modules/mono/editor/code_completion.h b/modules/mono/editor/code_completion.h index e38768612b..7f7521672b 100644 --- a/modules/mono/editor/code_completion.h +++ b/modules/mono/editor/code_completion.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/mono/editor/editor_internal_calls.cpp b/modules/mono/editor/editor_internal_calls.cpp index f9be19bbe2..667e4a3879 100644 --- a/modules/mono/editor/editor_internal_calls.cpp +++ b/modules/mono/editor/editor_internal_calls.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -195,7 +195,7 @@ int32_t godot_icall_ScriptClassParser_ParseFile(MonoString *p_filepath, MonoObje } } else { String error_str = scp.get_error(); - if (!error_str.empty()) { + if (!error_str.is_empty()) { *r_error_str = GDMonoMarshal::mono_string_from_godot(error_str); } } diff --git a/modules/mono/editor/editor_internal_calls.h b/modules/mono/editor/editor_internal_calls.h index ef4e639161..24080cd867 100644 --- a/modules/mono/editor/editor_internal_calls.h +++ b/modules/mono/editor/editor_internal_calls.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/mono/editor/godotsharp_export.cpp b/modules/mono/editor/godotsharp_export.cpp index b006eed69f..4b858c0e82 100644 --- a/modules/mono/editor/godotsharp_export.cpp +++ b/modules/mono/editor/godotsharp_export.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/mono/editor/godotsharp_export.h b/modules/mono/editor/godotsharp_export.h index 586d4e5a0c..0e9d689618 100644 --- a/modules/mono/editor/godotsharp_export.h +++ b/modules/mono/editor/godotsharp_export.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/mono/editor/script_class_parser.cpp b/modules/mono/editor/script_class_parser.cpp index 70940c279e..e81cbe4ebd 100644 --- a/modules/mono/editor/script_class_parser.cpp +++ b/modules/mono/editor/script_class_parser.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -735,9 +735,9 @@ Error ScriptClassParser::parse_file(const String &p_filepath) { ERR_FAIL_COND_V_MSG(ferr != OK, ferr, ferr == ERR_INVALID_DATA ? - "File '" + p_filepath + "' contains invalid unicode (UTF-8), so it was not loaded." + "File '" + p_filepath + "' contains invalid unicode (UTF-8), so it was not loaded." " Please ensure that scripts are saved in valid UTF-8 unicode." : - "Failed to read file: '" + p_filepath + "'."); + "Failed to read file: '" + p_filepath + "'."); run_dummy_preprocessor(source, p_filepath); diff --git a/modules/mono/editor/script_class_parser.h b/modules/mono/editor/script_class_parser.h index deb6061191..75a46bb4e5 100644 --- a/modules/mono/editor/script_class_parser.h +++ b/modules/mono/editor/script_class_parser.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Color.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Color.cs index 90141928ca..0c333d06ef 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Color.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Color.cs @@ -104,7 +104,7 @@ namespace Godot /// <summary> /// The HSV hue of this color, on the range 0 to 1. /// </summary> - /// <value>Getting is a long process, refer to the source code for details. Setting uses <see cref="FromHsv"/>.</value> + /// <value>Getting is a long process, refer to the source code for details. Setting uses <see cref="FromHSV"/>.</value> public float h { get @@ -145,14 +145,14 @@ namespace Godot } set { - this = FromHsv(value, s, v, a); + this = FromHSV(value, s, v, a); } } /// <summary> /// The HSV saturation of this color, on the range 0 to 1. /// </summary> - /// <value>Getting is equivalent to the ratio between the min and max RGB value. Setting uses <see cref="FromHsv"/>.</value> + /// <value>Getting is equivalent to the ratio between the min and max RGB value. Setting uses <see cref="FromHSV"/>.</value> public float s { get @@ -166,14 +166,14 @@ namespace Godot } set { - this = FromHsv(h, value, v, a); + this = FromHSV(h, value, v, a); } } /// <summary> /// The HSV value (brightness) of this color, on the range 0 to 1. /// </summary> - /// <value>Getting is equivalent to using `Max()` on the RGB components. Setting uses <see cref="FromHsv"/>.</value> + /// <value>Getting is equivalent to using `Max()` on the RGB components. Setting uses <see cref="FromHSV"/>.</value> public float v { get @@ -182,7 +182,7 @@ namespace Godot } set { - this = FromHsv(h, s, value, a); + this = FromHSV(h, s, value, a); } } @@ -455,7 +455,7 @@ namespace Godot /// </summary> /// <param name="includeAlpha">Whether or not to include alpha. If false, the color is RGB instead of RGBA.</param> /// <returns>A string for the HTML hexadecimal representation of this color.</returns> - public string ToHtml(bool includeAlpha = true) + public string ToHTML(bool includeAlpha = true) { var txt = string.Empty; @@ -532,18 +532,50 @@ namespace Godot } /// <summary> + /// Constructs a color either from an HTML color code or from a + /// standardized color name. Supported + /// color names are the same as the <see cref="Colors"/> constants. + /// </summary> + /// <param name="code">The HTML color code or color name to construct from.</param> + public Color(string code) + { + if (HtmlIsValid(code)) + { + this = FromHTML(code); + } + else + { + this = Named(code); + } + } + + /// <summary> + /// Constructs a color either from an HTML color code or from a + /// standardized color name, with `alpha` on the range of 0 to 1. Supported + /// color names are the same as the <see cref="Colors"/> constants. + /// </summary> + /// <param name="code">The HTML color code or color name to construct from.</param> + /// <param name="alpha">The alpha (transparency) value, typically on the range of 0 to 1.</param> + public Color(string code, float alpha) + { + this = new Color(code); + a = alpha; + } + + /// <summary> /// Constructs a color from the HTML hexadecimal color string in RGBA format. /// </summary> /// <param name="rgba">A string for the HTML hexadecimal representation of this color.</param> - public Color(string rgba) + private static Color FromHTML(string rgba) { + Color c; if (rgba.Length == 0) { - r = 0f; - g = 0f; - b = 0f; - a = 1.0f; - return; + c.r = 0f; + c.g = 0f; + c.b = 0f; + c.a = 1.0f; + return c; } if (rgba[0] == '#') @@ -577,47 +609,48 @@ namespace Godot throw new ArgumentOutOfRangeException("Invalid color code. Length is " + rgba.Length + " but a length of 6 or 8 is expected: " + rgba); } - a = 1.0f; + c.a = 1.0f; if (isShorthand) { - r = ParseCol4(rgba, 0) / 15f; - g = ParseCol4(rgba, 1) / 15f; - b = ParseCol4(rgba, 2) / 15f; + c.r = ParseCol4(rgba, 0) / 15f; + c.g = ParseCol4(rgba, 1) / 15f; + c.b = ParseCol4(rgba, 2) / 15f; if (alpha) { - a = ParseCol4(rgba, 3) / 15f; + c.a = ParseCol4(rgba, 3) / 15f; } } else { - r = ParseCol8(rgba, 0) / 255f; - g = ParseCol8(rgba, 2) / 255f; - b = ParseCol8(rgba, 4) / 255f; + c.r = ParseCol8(rgba, 0) / 255f; + c.g = ParseCol8(rgba, 2) / 255f; + c.b = ParseCol8(rgba, 4) / 255f; if (alpha) { - a = ParseCol8(rgba, 6) / 255f; + c.a = ParseCol8(rgba, 6) / 255f; } } - if (r < 0) + if (c.r < 0) { throw new ArgumentOutOfRangeException("Invalid color code. Red part is not valid hexadecimal: " + rgba); } - if (g < 0) + if (c.g < 0) { throw new ArgumentOutOfRangeException("Invalid color code. Green part is not valid hexadecimal: " + rgba); } - if (b < 0) + if (c.b < 0) { throw new ArgumentOutOfRangeException("Invalid color code. Blue part is not valid hexadecimal: " + rgba); } - if (a < 0) + if (c.a < 0) { throw new ArgumentOutOfRangeException("Invalid color code. Alpha part is not valid hexadecimal: " + rgba); } + return c; } /// <summary> @@ -640,9 +673,8 @@ namespace Godot /// the constants defined in <see cref="Colors"/>. /// </summary> /// <param name="name">The name of the color.</param> - /// <param name="alpha">The alpha (transparency) component represented on the range of 0 to 1. Default: 1.</param> /// <returns>The constructed color.</returns> - public static Color ColorN(string name, float alpha = 1f) + private static Color Named(string name) { name = name.Replace(" ", String.Empty); name = name.Replace("-", String.Empty); @@ -656,9 +688,7 @@ namespace Godot throw new ArgumentOutOfRangeException($"Invalid Color Name: {name}"); } - Color color = Colors.namedColors[name]; - color.a = alpha; - return color; + return Colors.namedColors[name]; } /// <summary> @@ -671,11 +701,11 @@ namespace Godot /// <param name="value">The HSV value (brightness), typically on the range of 0 to 1.</param> /// <param name="alpha">The alpha (transparency) value, typically on the range of 0 to 1.</param> /// <returns>The constructed color.</returns> - public static Color FromHsv(float hue, float saturation, float value, float alpha = 1.0f) + public static Color FromHSV(float hue, float saturation, float value, float alpha = 1.0f) { if (saturation == 0) { - // acp_hromatic (grey) + // Achromatic (grey) return new Color(value, value, value, alpha); } @@ -715,7 +745,7 @@ namespace Godot /// <param name="hue">Output parameter for the HSV hue.</param> /// <param name="saturation">Output parameter for the HSV saturation.</param> /// <param name="value">Output parameter for the HSV value.</param> - public void ToHsv(out float hue, out float saturation, out float value) + public void ToHSV(out float hue, out float saturation, out float value) { float max = (float)Mathf.Max(r, Mathf.Max(g, b)); float min = (float)Mathf.Min(r, Mathf.Min(g, b)); @@ -803,7 +833,8 @@ namespace Godot } // Check if each hex digit is valid. - for (int i = 0; i < len; i++) { + for (int i = 0; i < len; i++) + { if (ParseCol4(color, i) == -1) { return false; diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Extensions/ResourceLoaderExtensions.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Extensions/ResourceLoaderExtensions.cs index 5f64c09a89..74fa05d1fd 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Extensions/ResourceLoaderExtensions.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Extensions/ResourceLoaderExtensions.cs @@ -2,7 +2,7 @@ namespace Godot { public static partial class ResourceLoader { - public static T Load<T>(string path, string typeHint = null, bool noCache = false) where T : class + public static T Load<T>(string path, string typeHint = null, CacheMode noCache = CacheMode.Reuse) where T : class { return (T)(object)Load(path, typeHint, noCache); } diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Mathf.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Mathf.cs index 6eecc262d6..c3f372d415 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Mathf.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Mathf.cs @@ -618,10 +618,10 @@ namespace Godot /// This can also be used to round a floating point /// number to an arbitrary number of decimals. /// </summary> - /// <param name="s">The value to stepify.</param> + /// <param name="s">The value to snap.</param> /// <param name="step">The step size to snap to.</param> /// <returns></returns> - public static real_t Stepify(real_t s, real_t step) + public static real_t Snapped(real_t s, real_t step) { if (step != 0f) { diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2.cs index f7703c77cc..868c3536fe 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2.cs @@ -52,7 +52,7 @@ namespace Godot } /// <summary> - /// The area of this rect. + /// The area of this Rect2. /// </summary> /// <value>Equivalent to <see cref="GetArea()"/>.</value> public real_t Area @@ -64,7 +64,7 @@ namespace Godot /// Returns a Rect2 with equivalent position and size, modified so that /// the top-left corner is the origin and width and height are positive. /// </summary> - /// <returns>The modified rect.</returns> + /// <returns>The modified Rect2.</returns> public Rect2 Abs() { Vector2 end = End; @@ -74,10 +74,11 @@ namespace Godot /// <summary> /// Returns the intersection of this Rect2 and `b`. + /// If the rectangles do not intersect, an empty Rect2 is returned. /// </summary> - /// <param name="b">The other rect.</param> - /// <returns>The clipped rect.</returns> - public Rect2 Clip(Rect2 b) + /// <param name="b">The other Rect2.</param> + /// <returns>The intersection of this Rect2 and `b`, or an empty Rect2 if they do not intersect.</returns> + public Rect2 Intersection(Rect2 b) { var newRect = b; @@ -101,8 +102,8 @@ namespace Godot /// <summary> /// Returns true if this Rect2 completely encloses another one. /// </summary> - /// <param name="b">The other rect that may be enclosed.</param> - /// <returns>A bool for whether or not this rect encloses `b`.</returns> + /// <param name="b">The other Rect2 that may be enclosed.</param> + /// <returns>A bool for whether or not this Rect2 encloses `b`.</returns> public bool Encloses(Rect2 b) { return b._position.x >= _position.x && b._position.y >= _position.y && @@ -114,7 +115,7 @@ namespace Godot /// Returns this Rect2 expanded to include a given point. /// </summary> /// <param name="to">The point to include.</param> - /// <returns>The expanded rect.</returns> + /// <returns>The expanded Rect2.</returns> public Rect2 Expand(Vector2 to) { var expanded = this; @@ -156,10 +157,10 @@ namespace Godot } /// <summary> - /// Returns a copy of the Rect2 grown a given amount of units towards all the sides. + /// Returns a copy of the Rect2 grown by the specified amount on all sides. /// </summary> /// <param name="by">The amount to grow by.</param> - /// <returns>The grown rect.</returns> + /// <returns>The grown Rect2.</returns> public Rect2 Grow(real_t by) { var g = this; @@ -173,13 +174,13 @@ namespace Godot } /// <summary> - /// Returns a copy of the Rect2 grown a given amount of units towards each direction individually. + /// Returns a copy of the Rect2 grown by the specified amount on each side individually. /// </summary> - /// <param name="left">The amount to grow by on the left.</param> - /// <param name="top">The amount to grow by on the top.</param> - /// <param name="right">The amount to grow by on the right.</param> - /// <param name="bottom">The amount to grow by on the bottom.</param> - /// <returns>The grown rect.</returns> + /// <param name="left">The amount to grow by on the left side.</param> + /// <param name="top">The amount to grow by on the top side.</param> + /// <param name="right">The amount to grow by on the right side.</param> + /// <param name="bottom">The amount to grow by on the bottom side.</param> + /// <returns>The grown Rect2.</returns> public Rect2 GrowIndividual(real_t left, real_t top, real_t right, real_t bottom) { var g = this; @@ -193,19 +194,19 @@ namespace Godot } /// <summary> - /// Returns a copy of the Rect2 grown a given amount of units towards the <see cref="Margin"/> direction. + /// Returns a copy of the Rect2 grown by the specified amount on the specified Side. /// </summary> - /// <param name="margin">The direction to grow in.</param> + /// <param name="side">The side to grow.</param> /// <param name="by">The amount to grow by.</param> - /// <returns>The grown rect.</returns> - public Rect2 GrowMargin(Margin margin, real_t by) + /// <returns>The grown Rect2.</returns> + public Rect2 GrowSide(Side side, real_t by) { var g = this; - g = g.GrowIndividual(Margin.Left == margin ? by : 0, - Margin.Top == margin ? by : 0, - Margin.Right == margin ? by : 0, - Margin.Bottom == margin ? by : 0); + g = g.GrowIndividual(Side.Left == side ? by : 0, + Side.Top == side ? by : 0, + Side.Right == side ? by : 0, + Side.Bottom == side ? by : 0); return g; } @@ -213,7 +214,7 @@ namespace Godot /// <summary> /// Returns true if the Rect2 is flat or empty, or false otherwise. /// </summary> - /// <returns>A bool for whether or not the rect has area.</returns> + /// <returns>A bool for whether or not the Rect2 has area.</returns> public bool HasNoArea() { return _size.x <= 0 || _size.y <= 0; @@ -223,7 +224,7 @@ namespace Godot /// Returns true if the Rect2 contains a point, or false otherwise. /// </summary> /// <param name="point">The point to check.</param> - /// <returns>A bool for whether or not the rect contains `point`.</returns> + /// <returns>A bool for whether or not the Rect2 contains `point`.</returns> public bool HasPoint(Vector2 point) { if (point.x < _position.x) @@ -246,7 +247,7 @@ namespace Godot /// If `includeBorders` is true, they will also be considered overlapping /// if their borders touch, even without intersection. /// </summary> - /// <param name="b">The other rect to check for intersections with.</param> + /// <param name="b">The other Rect2 to check for intersections with.</param> /// <param name="includeBorders">Whether or not to consider borders.</param> /// <returns>A bool for whether or not they are intersecting.</returns> public bool Intersects(Rect2 b, bool includeBorders = false) @@ -296,8 +297,8 @@ namespace Godot /// <summary> /// Returns a larger Rect2 that contains this Rect2 and `b`. /// </summary> - /// <param name="b">The other rect.</param> - /// <returns>The merged rect.</returns> + /// <param name="b">The other Rect2.</param> + /// <returns>The merged Rect2.</returns> public Rect2 Merge(Rect2 b) { Rect2 newRect; @@ -387,11 +388,11 @@ namespace Godot } /// <summary> - /// Returns true if this rect and `other` are approximately equal, by running + /// Returns true if this Rect2 and `other` are approximately equal, by running /// <see cref="Vector2.IsEqualApprox(Vector2)"/> on each component. /// </summary> - /// <param name="other">The other rect to compare.</param> - /// <returns>Whether or not the rects are approximately equal.</returns> + /// <param name="other">The other Rect2 to compare.</param> + /// <returns>Whether or not the Rect2s are approximately equal.</returns> public bool IsEqualApprox(Rect2 other) { return _position.IsEqualApprox(other._position) && _size.IsEqualApprox(other.Size); diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2i.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2i.cs index 8f71c00d76..c27af74866 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2i.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2i.cs @@ -47,7 +47,7 @@ namespace Godot } /// <summary> - /// The area of this rect. + /// The area of this Rect2i. /// </summary> /// <value>Equivalent to <see cref="GetArea()"/>.</value> public int Area @@ -59,7 +59,7 @@ namespace Godot /// Returns a Rect2i with equivalent position and size, modified so that /// the top-left corner is the origin and width and height are positive. /// </summary> - /// <returns>The modified rect.</returns> + /// <returns>The modified Rect2i.</returns> public Rect2i Abs() { Vector2i end = End; @@ -69,10 +69,11 @@ namespace Godot /// <summary> /// Returns the intersection of this Rect2i and `b`. + /// If the rectangles do not intersect, an empty Rect2i is returned. /// </summary> - /// <param name="b">The other rect.</param> - /// <returns>The clipped rect.</returns> - public Rect2i Clip(Rect2i b) + /// <param name="b">The other Rect2i.</param> + /// <returns>The intersection of this Rect2i and `b`, or an empty Rect2i if they do not intersect.</returns> + public Rect2i Intersection(Rect2i b) { var newRect = b; @@ -96,8 +97,8 @@ namespace Godot /// <summary> /// Returns true if this Rect2i completely encloses another one. /// </summary> - /// <param name="b">The other rect that may be enclosed.</param> - /// <returns>A bool for whether or not this rect encloses `b`.</returns> + /// <param name="b">The other Rect2i that may be enclosed.</param> + /// <returns>A bool for whether or not this Rect2i encloses `b`.</returns> public bool Encloses(Rect2i b) { return b._position.x >= _position.x && b._position.y >= _position.y && @@ -109,7 +110,7 @@ namespace Godot /// Returns this Rect2i expanded to include a given point. /// </summary> /// <param name="to">The point to include.</param> - /// <returns>The expanded rect.</returns> + /// <returns>The expanded Rect2i.</returns> public Rect2i Expand(Vector2i to) { var expanded = this; @@ -151,10 +152,10 @@ namespace Godot } /// <summary> - /// Returns a copy of the Rect2i grown a given amount of units towards all the sides. + /// Returns a copy of the Rect2i grown by the specified amount on all sides. /// </summary> /// <param name="by">The amount to grow by.</param> - /// <returns>The grown rect.</returns> + /// <returns>The grown Rect2i.</returns> public Rect2i Grow(int by) { var g = this; @@ -168,13 +169,13 @@ namespace Godot } /// <summary> - /// Returns a copy of the Rect2i grown a given amount of units towards each direction individually. + /// Returns a copy of the Rect2i grown by the specified amount on each side individually. /// </summary> - /// <param name="left">The amount to grow by on the left.</param> - /// <param name="top">The amount to grow by on the top.</param> - /// <param name="right">The amount to grow by on the right.</param> - /// <param name="bottom">The amount to grow by on the bottom.</param> - /// <returns>The grown rect.</returns> + /// <param name="left">The amount to grow by on the left side.</param> + /// <param name="top">The amount to grow by on the top side.</param> + /// <param name="right">The amount to grow by on the right side.</param> + /// <param name="bottom">The amount to grow by on the bottom side.</param> + /// <returns>The grown Rect2i.</returns> public Rect2i GrowIndividual(int left, int top, int right, int bottom) { var g = this; @@ -188,37 +189,37 @@ namespace Godot } /// <summary> - /// Returns a copy of the Rect2i grown a given amount of units towards the <see cref="Margin"/> direction. + /// Returns a copy of the Rect2i grown by the specified amount on the specified Side. /// </summary> - /// <param name="margin">The direction to grow in.</param> + /// <param name="side">The side to grow.</param> /// <param name="by">The amount to grow by.</param> - /// <returns>The grown rect.</returns> - public Rect2i GrowMargin(Margin margin, int by) + /// <returns>The grown Rect2i.</returns> + public Rect2i GrowSide(Side side, int by) { var g = this; - g = g.GrowIndividual(Margin.Left == margin ? by : 0, - Margin.Top == margin ? by : 0, - Margin.Right == margin ? by : 0, - Margin.Bottom == margin ? by : 0); + g = g.GrowIndividual(Side.Left == side ? by : 0, + Side.Top == side ? by : 0, + Side.Right == side ? by : 0, + Side.Bottom == side ? by : 0); return g; } /// <summary> - /// Returns true if the Rect2 is flat or empty, or false otherwise. + /// Returns true if the Rect2i is flat or empty, or false otherwise. /// </summary> - /// <returns>A bool for whether or not the rect has area.</returns> + /// <returns>A bool for whether or not the Rect2i has area.</returns> public bool HasNoArea() { return _size.x <= 0 || _size.y <= 0; } /// <summary> - /// Returns true if the Rect2 contains a point, or false otherwise. + /// Returns true if the Rect2i contains a point, or false otherwise. /// </summary> /// <param name="point">The point to check.</param> - /// <returns>A bool for whether or not the rect contains `point`.</returns> + /// <returns>A bool for whether or not the Rect2i contains `point`.</returns> public bool HasPoint(Vector2i point) { if (point.x < _position.x) @@ -241,7 +242,7 @@ namespace Godot /// If `includeBorders` is true, they will also be considered overlapping /// if their borders touch, even without intersection. /// </summary> - /// <param name="b">The other rect to check for intersections with.</param> + /// <param name="b">The other Rect2i to check for intersections with.</param> /// <param name="includeBorders">Whether or not to consider borders.</param> /// <returns>A bool for whether or not they are intersecting.</returns> public bool Intersects(Rect2i b, bool includeBorders = false) @@ -273,10 +274,10 @@ namespace Godot } /// <summary> - /// Returns a larger Rect2i that contains this Rect2 and `b`. + /// Returns a larger Rect2i that contains this Rect2i and `b`. /// </summary> - /// <param name="b">The other rect.</param> - /// <returns>The merged rect.</returns> + /// <param name="b">The other Rect2i.</param> + /// <returns>The merged Rect2i.</returns> public Rect2i Merge(Rect2i b) { Rect2i newRect; diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs index 0700f197ff..98efa89ef0 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs @@ -97,6 +97,36 @@ namespace Godot return b; } + /// <summary> + /// Converts a string containing a binary number into an integer. + /// Binary strings can either be prefixed with `0b` or not, + /// and they can also start with a `-` before the optional prefix. + /// </summary> + /// <param name="instance">The string to convert.</param> + /// <returns>The converted string.</returns> + public static int BinToInt(this string instance) + { + if (instance.Length == 0) + { + return 0; + } + + int sign = 1; + + if (instance[0] == '-') + { + sign = -1; + instance = instance.Substring(1); + } + + if (instance.StartsWith("0b")) + { + instance = instance.Substring(2); + } + + return sign * Convert.ToInt32(instance, 2);; + } + // <summary> // Return the amount of substrings in string. // </summary> @@ -432,24 +462,24 @@ namespace Godot } // <summary> - // Hash the string and return a 32 bits integer. + // Hash the string and return a 32 bits unsigned integer. // </summary> - public static int Hash(this string instance) + public static uint Hash(this string instance) { - int index = 0; - int hashv = 5381; - int c; + uint hash = 5381; - while ((c = instance[index++]) != 0) - hashv = (hashv << 5) + hashv + c; // hash * 33 + c + foreach(uint c in instance) + { + hash = (hash << 5) + hash + c; // hash * 33 + c + } - return hashv; + return hash; } /// <summary> /// Returns a hexadecimal representation of this byte as a string. /// </summary> - /// <param name="bytes">The byte to encode.</param> + /// <param name="b">The byte to encode.</param> /// <returns>The hexadecimal representation of this byte.</returns> internal static string HexEncode(this byte b) { @@ -493,11 +523,20 @@ namespace Godot return ret; } - // <summary> - // Convert a string containing an hexadecimal number into an int. - // </summary> + /// <summary> + /// Converts a string containing a hexadecimal number into an integer. + /// Hexadecimal strings can either be prefixed with `0x` or not, + /// and they can also start with a `-` before the optional prefix. + /// </summary> + /// <param name="instance">The string to convert.</param> + /// <returns>The converted string.</returns> public static int HexToInt(this string instance) { + if (instance.Length == 0) + { + return 0; + } + int sign = 1; if (instance[0] == '-') @@ -506,10 +545,12 @@ namespace Godot instance = instance.Substring(1); } - if (!instance.StartsWith("0x")) - return 0; + if (instance.StartsWith("0x")) + { + instance = instance.Substring(2); + } - return sign * int.Parse(instance.Substring(2), NumberStyles.HexNumber); + return sign * int.Parse(instance, NumberStyles.HexNumber); } // <summary> @@ -892,22 +933,6 @@ namespace Godot } // <summary> - // Decode a percent-encoded string. See [method percent_encode]. - // </summary> - public static string PercentDecode(this string instance) - { - return Uri.UnescapeDataString(instance); - } - - // <summary> - // Percent-encode a string. This is meant to encode parameters in a URL when sending a HTTP GET request and bodies of form-urlencoded POST request. - // </summary> - public static string PercentEncode(this string instance) - { - return Uri.EscapeDataString(instance); - } - - // <summary> // If the string is a path, this concatenates [code]file[/code] at the end of the string as a subpath. E.g. [code]"this/is".plus_file("path") == "this/is/path"[/code]. // </summary> public static string PlusFile(this string instance, string file) @@ -1169,6 +1194,33 @@ namespace Godot return Encoding.UTF8.GetBytes(instance); } + /// <summary> + /// Decodes a string in URL encoded format. This is meant to + /// decode parameters in a URL when receiving an HTTP request. + /// This mostly wraps around `System.Uri.UnescapeDataString()`, + /// but also handles `+`. + /// See <see cref="URIEncode"/> for encoding. + /// </summary> + /// <param name="instance">The string to decode.</param> + /// <returns>The unescaped string.</returns> + public static string URIDecode(this string instance) + { + return Uri.UnescapeDataString(instance.Replace("+", "%20")); + } + + /// <summary> + /// Encodes a string to URL friendly format. This is meant to + /// encode parameters in a URL when sending an HTTP request. + /// This wraps around `System.Uri.EscapeDataString()`. + /// See <see cref="URIDecode"/> for decoding. + /// </summary> + /// <param name="instance">The string to encode.</param> + /// <returns>The escaped string.</returns> + public static string URIEncode(this string instance) + { + return Uri.EscapeDataString(instance); + } + // <summary> // Return a copy of the string with special characters escaped using the XML standard. // </summary> diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs index b74dd6f4f4..6279ea1ace 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs @@ -511,7 +511,7 @@ namespace Godot /// <returns>The snapped vector.</returns> public Vector2 Snapped(Vector2 step) { - return new Vector2(Mathf.Stepify(x, step.x), Mathf.Stepify(y, step.y)); + return new Vector2(Mathf.Snapped(x, step.x), Mathf.Snapped(y, step.y)); } /// <summary> diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs index 07f5b3c38e..3b895bbbf6 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs @@ -111,10 +111,10 @@ namespace Godot } /// <summary> - /// Returns the minimum angle to the given vector, in radians. + /// Returns the unsigned minimum angle to the given vector, in radians. /// </summary> /// <param name="to">The other vector to compare this vector to.</param> - /// <returns>The angle between the two vectors, in radians.</returns> + /// <returns>The unsigned angle between the two vectors, in radians.</returns> public real_t AngleTo(Vector3 to) { return Mathf.Atan2(Cross(to).Length(), Dot(to)); @@ -469,6 +469,23 @@ namespace Godot } /// <summary> + /// Returns the signed angle to the given vector, in radians. + /// The sign of the angle is positive in a counter-clockwise + /// direction and negative in a clockwise direction when viewed + /// from the side specified by the `axis`. + /// </summary> + /// <param name="to">The other vector to compare this vector to.</param> + /// <param name="axis">The reference axis to use for the angle sign.</param> + /// <returns>The signed angle between the two vectors, in radians.</returns> + public real_t SignedAngleTo(Vector3 to, Vector3 axis) + { + Vector3 crossTo = Cross(to); + real_t unsignedAngle = Mathf.Atan2(crossTo.Length(), Dot(to)); + real_t sign = crossTo.Dot(axis); + return (sign < 0) ? -unsignedAngle : unsignedAngle; + } + + /// <summary> /// Returns the result of the spherical linear interpolation between /// this vector and `to` by amount `weight`. /// @@ -513,9 +530,9 @@ namespace Godot { return new Vector3 ( - Mathf.Stepify(x, step.x), - Mathf.Stepify(y, step.y), - Mathf.Stepify(z, step.z) + Mathf.Snapped(x, step.x), + Mathf.Snapped(y, step.y), + Mathf.Snapped(z, step.z) ); } diff --git a/modules/mono/glue/arguments_vector.h b/modules/mono/glue/arguments_vector.h index ab48904571..9ba6a05ac6 100644 --- a/modules/mono/glue/arguments_vector.h +++ b/modules/mono/glue/arguments_vector.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/mono/glue/base_object_glue.cpp b/modules/mono/glue/base_object_glue.cpp index afcc75395b..34a96eba17 100644 --- a/modules/mono/glue/base_object_glue.cpp +++ b/modules/mono/glue/base_object_glue.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/mono/glue/collections_glue.cpp b/modules/mono/glue/collections_glue.cpp index dedb5b9f75..191f863350 100644 --- a/modules/mono/glue/collections_glue.cpp +++ b/modules/mono/glue/collections_glue.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/mono/glue/gd_glue.cpp b/modules/mono/glue/gd_glue.cpp index a4566b82fb..a2ff868f65 100644 --- a/modules/mono/glue/gd_glue.cpp +++ b/modules/mono/glue/gd_glue.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/mono/glue/glue_header.h b/modules/mono/glue/glue_header.h index f4263e286e..3db52d7c30 100644 --- a/modules/mono/glue/glue_header.h +++ b/modules/mono/glue/glue_header.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/mono/glue/nodepath_glue.cpp b/modules/mono/glue/nodepath_glue.cpp index 9405360c6c..4ddb94e1a8 100644 --- a/modules/mono/glue/nodepath_glue.cpp +++ b/modules/mono/glue/nodepath_glue.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/mono/glue/rid_glue.cpp b/modules/mono/glue/rid_glue.cpp index 410a98aa84..f464e63a81 100644 --- a/modules/mono/glue/rid_glue.cpp +++ b/modules/mono/glue/rid_glue.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/mono/glue/scene_tree_glue.cpp b/modules/mono/glue/scene_tree_glue.cpp index 88695201a3..5a6fd69db8 100644 --- a/modules/mono/glue/scene_tree_glue.cpp +++ b/modules/mono/glue/scene_tree_glue.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -48,7 +48,7 @@ Array *godot_icall_SceneTree_get_nodes_in_group_Generic(SceneTree *ptr, StringNa ptr->get_nodes_in_group(*group, &nodes); // No need to bother if the group is empty - if (!nodes.empty()) { + if (!nodes.is_empty()) { MonoType *elem_type = mono_reflection_type_get_type(refltype); MonoClass *mono_class = mono_class_from_mono_type(elem_type); GDMonoClass *klass = GDMono::get_singleton()->get_class(mono_class); diff --git a/modules/mono/glue/string_glue.cpp b/modules/mono/glue/string_glue.cpp index d71d175418..18a9221f89 100644 --- a/modules/mono/glue/string_glue.cpp +++ b/modules/mono/glue/string_glue.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/mono/glue/string_name_glue.cpp b/modules/mono/glue/string_name_glue.cpp index fc2bf32b95..f537896559 100644 --- a/modules/mono/glue/string_name_glue.cpp +++ b/modules/mono/glue/string_name_glue.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/mono/godotsharp_defs.h b/modules/mono/godotsharp_defs.h index 7d57d0fac3..273dba52f9 100644 --- a/modules/mono/godotsharp_defs.h +++ b/modules/mono/godotsharp_defs.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/mono/godotsharp_dirs.cpp b/modules/mono/godotsharp_dirs.cpp index 093a935288..a39a6fe381 100644 --- a/modules/mono/godotsharp_dirs.cpp +++ b/modules/mono/godotsharp_dirs.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -146,7 +146,7 @@ private: String appname = ProjectSettings::get_singleton()->get("application/config/name"); String appname_safe = OS::get_singleton()->get_safe_dir_name(appname); - if (appname_safe.empty()) { + if (appname_safe.is_empty()) { appname_safe = "UnnamedProject"; } diff --git a/modules/mono/godotsharp_dirs.h b/modules/mono/godotsharp_dirs.h index 85be506c28..3a3c6f980e 100644 --- a/modules/mono/godotsharp_dirs.h +++ b/modules/mono/godotsharp_dirs.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/mono/managed_callable.cpp b/modules/mono/managed_callable.cpp index dbe9c7fc5d..6d868b527c 100644 --- a/modules/mono/managed_callable.cpp +++ b/modules/mono/managed_callable.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/mono/managed_callable.h b/modules/mono/managed_callable.h index bde1b41781..c620eee60d 100644 --- a/modules/mono/managed_callable.h +++ b/modules/mono/managed_callable.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/mono/mono_gc_handle.cpp b/modules/mono/mono_gc_handle.cpp index 16a6875406..8583065016 100644 --- a/modules/mono/mono_gc_handle.cpp +++ b/modules/mono/mono_gc_handle.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/mono/mono_gc_handle.h b/modules/mono/mono_gc_handle.h index b85dc70af3..f435aab3dd 100644 --- a/modules/mono/mono_gc_handle.h +++ b/modules/mono/mono_gc_handle.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/mono/mono_gd/android_mono_config.h b/modules/mono/mono_gd/android_mono_config.h index 9e304939b2..9d7cfe1b7c 100644 --- a/modules/mono/mono_gd/android_mono_config.h +++ b/modules/mono/mono_gd/android_mono_config.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/mono/mono_gd/gd_mono.cpp b/modules/mono/mono_gd/gd_mono.cpp index 772961291c..43a39a4966 100644 --- a/modules/mono/mono_gd/gd_mono.cpp +++ b/modules/mono/mono_gd/gd_mono.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -142,7 +142,7 @@ void gd_mono_debug_init() { int da_timeout = GLOBAL_DEF("mono/debugger_agent/wait_timeout", 3000); if (Engine::get_singleton()->is_editor_hint() || - ProjectSettings::get_singleton()->get_resource_path().empty() || + ProjectSettings::get_singleton()->get_resource_path().is_empty() || Main::is_project_manager()) { if (da_args.size() == 0) { return; @@ -297,7 +297,7 @@ void GDMono::determine_mono_dirs(String &r_assembly_rootdir, String &r_config_di } #ifdef WINDOWS_ENABLED - if (r_assembly_rootdir.empty() || r_config_dir.empty()) { + if (r_assembly_rootdir.is_empty() || r_config_dir.is_empty()) { ERR_PRINT("Cannot find Mono in the registry."); // Assertion: if they are not set, then they weren't found in the registry CRASH_COND(mono_reg_info.assembly_dir.length() > 0 || mono_reg_info.config_dir.length() > 0); @@ -360,7 +360,7 @@ void GDMono::initialize() { #ifndef TOOLS_ENABLED // Exported games that don't use C# must still work. They likely don't ship with mscorlib. // We only initialize the Mono runtime if we can find mscorlib. Otherwise it would crash. - if (GDMonoAssembly::find_assembly("mscorlib.dll").empty()) { + if (GDMonoAssembly::find_assembly("mscorlib.dll").is_empty()) { print_verbose("Mono: Skipping runtime initialization because 'mscorlib.dll' could not be found"); return; } @@ -593,8 +593,8 @@ ApiAssemblyInfo::Version ApiAssemblyInfo::Version::get_from_loaded_assembly(GDMo ApiAssemblyInfo::Version api_assembly_version; const char *nativecalls_name = p_api_type == ApiAssemblyInfo::API_CORE ? - BINDINGS_CLASS_NATIVECALLS : - BINDINGS_CLASS_NATIVECALLS_EDITOR; + BINDINGS_CLASS_NATIVECALLS : + BINDINGS_CLASS_NATIVECALLS_EDITOR; GDMonoClass *nativecalls_klass = p_api_assembly->get_class(BINDINGS_NAMESPACE, nativecalls_name); @@ -757,11 +757,11 @@ String GDMono::update_api_assemblies_from_prebuilt(const String &p_config, const #define FAIL_REASON(m_out_of_sync, m_prebuilt_exists) \ ( \ (m_out_of_sync ? \ - String("The assembly is invalidated ") : \ - String("The assembly was not found ")) + \ + String("The assembly is invalidated ") : \ + String("The assembly was not found ")) + \ (m_prebuilt_exists ? \ - String("and the prebuilt assemblies are missing.") : \ - String("and we failed to copy the prebuilt assemblies."))) + String("and the prebuilt assemblies are missing.") : \ + String("and we failed to copy the prebuilt assemblies."))) String dst_assemblies_dir = GodotSharpDirs::get_res_assemblies_base_dir().plus_file(p_config); @@ -820,8 +820,8 @@ bool GDMono::_load_core_api_assembly(LoadedApiAssembly &r_loaded_api_assembly, c // If running the project manager, load it from the prebuilt API directory String assembly_dir = !Main::is_project_manager() ? - GodotSharpDirs::get_res_assemblies_base_dir().plus_file(p_config) : - GodotSharpDirs::get_data_editor_prebuilt_api_dir().plus_file(p_config); + GodotSharpDirs::get_res_assemblies_base_dir().plus_file(p_config) : + GodotSharpDirs::get_data_editor_prebuilt_api_dir().plus_file(p_config); String assembly_path = assembly_dir.plus_file(CORE_API_ASSEMBLY_NAME ".dll"); @@ -853,8 +853,8 @@ bool GDMono::_load_editor_api_assembly(LoadedApiAssembly &r_loaded_api_assembly, // If running the project manager, load it from the prebuilt API directory String assembly_dir = !Main::is_project_manager() ? - GodotSharpDirs::get_res_assemblies_base_dir().plus_file(p_config) : - GodotSharpDirs::get_data_editor_prebuilt_api_dir().plus_file(p_config); + GodotSharpDirs::get_res_assemblies_base_dir().plus_file(p_config) : + GodotSharpDirs::get_data_editor_prebuilt_api_dir().plus_file(p_config); String assembly_path = assembly_dir.plus_file(EDITOR_API_ASSEMBLY_NAME ".dll"); @@ -944,7 +944,7 @@ void GDMono::_load_api_assemblies() { // 2. Update the API assemblies String update_error = update_api_assemblies_from_prebuilt("Debug", &core_api_assembly.out_of_sync, &editor_api_assembly.out_of_sync); - CRASH_COND_MSG(!update_error.empty(), update_error); + CRASH_COND_MSG(!update_error.is_empty(), update_error); // 3. Load the scripts domain again Error domain_load_err = _load_scripts_domain(); @@ -998,7 +998,7 @@ bool GDMono::_load_project_assembly() { String appname = ProjectSettings::get_singleton()->get("application/config/name"); String appname_safe = OS::get_singleton()->get_safe_dir_name(appname); - if (appname_safe.empty()) { + if (appname_safe.is_empty()) { appname_safe = "UnnamedProject"; } diff --git a/modules/mono/mono_gd/gd_mono.h b/modules/mono/mono_gd/gd_mono.h index 969296c44d..5accc21f8e 100644 --- a/modules/mono/mono_gd/gd_mono.h +++ b/modules/mono/mono_gd/gd_mono.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/mono/mono_gd/gd_mono_assembly.cpp b/modules/mono/mono_gd/gd_mono_assembly.cpp index 33628b3ce3..1fe06bfbee 100644 --- a/modules/mono/mono_gd/gd_mono_assembly.cpp +++ b/modules/mono/mono_gd/gd_mono_assembly.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -48,20 +48,20 @@ Vector<String> GDMonoAssembly::search_dirs; void GDMonoAssembly::fill_search_dirs(Vector<String> &r_search_dirs, const String &p_custom_config, const String &p_custom_bcl_dir) { String framework_dir; - if (!p_custom_bcl_dir.empty()) { + if (!p_custom_bcl_dir.is_empty()) { framework_dir = p_custom_bcl_dir; } else if (mono_assembly_getrootdir()) { framework_dir = String::utf8(mono_assembly_getrootdir()).plus_file("mono").plus_file("4.5"); } - if (!framework_dir.empty()) { + if (!framework_dir.is_empty()) { r_search_dirs.push_back(framework_dir); r_search_dirs.push_back(framework_dir.plus_file("Facades")); } #if !defined(TOOLS_ENABLED) String data_game_assemblies_dir = GodotSharpDirs::get_data_game_assemblies_dir(); - if (!data_game_assemblies_dir.empty()) { + if (!data_game_assemblies_dir.is_empty()) { r_search_dirs.push_back(data_game_assemblies_dir); } #endif @@ -72,7 +72,7 @@ void GDMonoAssembly::fill_search_dirs(Vector<String> &r_search_dirs, const Strin r_search_dirs.push_back(GodotSharpDirs::get_res_temp_assemblies_dir()); } - if (p_custom_config.empty()) { + if (p_custom_config.is_empty()) { r_search_dirs.push_back(GodotSharpDirs::get_res_assemblies_dir()); } else { String api_config = p_custom_config == "ExportRelease" ? "Release" : "Debug"; @@ -230,7 +230,7 @@ void GDMonoAssembly::initialize() { MonoAssembly *GDMonoAssembly::_real_load_assembly_from(const String &p_path, bool p_refonly, MonoAssemblyName *p_aname) { Vector<uint8_t> data = FileAccess::get_file_as_array(p_path); - ERR_FAIL_COND_V_MSG(data.empty(), nullptr, "Could read the assembly in the specified location"); + ERR_FAIL_COND_V_MSG(data.is_empty(), nullptr, "Could read the assembly in the specified location"); String image_filename; @@ -379,8 +379,8 @@ GDMonoClass *GDMonoAssembly::get_class(MonoClass *p_mono_class) { return match->value(); } - StringName namespace_name = mono_class_get_namespace(p_mono_class); - StringName class_name = mono_class_get_name(p_mono_class); + StringName namespace_name = String::utf8(mono_class_get_namespace(p_mono_class)); + StringName class_name = String::utf8(mono_class_get_name(p_mono_class)); GDMonoClass *wrapped_class = memnew(GDMonoClass(namespace_name, class_name, p_mono_class, this)); @@ -423,7 +423,7 @@ GDMonoClass *GDMonoAssembly::get_object_derived_class(const StringName &p_class) match = current; } - while (!nested_classes.empty()) { + while (!nested_classes.is_empty()) { GDMonoClass *current_nested = nested_classes.front()->get(); nested_classes.pop_front(); diff --git a/modules/mono/mono_gd/gd_mono_assembly.h b/modules/mono/mono_gd/gd_mono_assembly.h index fc10480e07..350fcf3210 100644 --- a/modules/mono/mono_gd/gd_mono_assembly.h +++ b/modules/mono/mono_gd/gd_mono_assembly.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/mono/mono_gd/gd_mono_cache.cpp b/modules/mono/mono_gd/gd_mono_cache.cpp index 3f51c6523b..aea467660f 100644 --- a/modules/mono/mono_gd/gd_mono_cache.cpp +++ b/modules/mono/mono_gd/gd_mono_cache.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/mono/mono_gd/gd_mono_cache.h b/modules/mono/mono_gd/gd_mono_cache.h index 9dfa5769be..fb75cb4b1c 100644 --- a/modules/mono/mono_gd/gd_mono_cache.h +++ b/modules/mono/mono_gd/gd_mono_cache.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/mono/mono_gd/gd_mono_class.cpp b/modules/mono/mono_gd/gd_mono_class.cpp index b734f52e4e..f9fddd931b 100644 --- a/modules/mono/mono_gd/gd_mono_class.cpp +++ b/modules/mono/mono_gd/gd_mono_class.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -177,7 +177,7 @@ void GDMonoClass::fetch_methods_with_godot_api_checks(GDMonoClass *p_native_base void *iter = nullptr; MonoMethod *raw_method = nullptr; while ((raw_method = mono_class_get_methods(get_mono_ptr(), &iter)) != nullptr) { - StringName name = mono_method_get_name(raw_method); + StringName name = String::utf8(mono_method_get_name(raw_method)); // get_method implicitly fetches methods and adds them to this->methods GDMonoMethod *method = get_method(raw_method, name); @@ -319,7 +319,7 @@ GDMonoMethod *GDMonoClass::get_method(MonoMethod *p_raw_method) { MonoMethodSignature *sig = mono_method_signature(p_raw_method); int params_count = mono_signature_get_param_count(sig); - StringName method_name = mono_method_get_name(p_raw_method); + StringName method_name = String::utf8(mono_method_get_name(p_raw_method)); return get_method(p_raw_method, method_name, params_count); } @@ -392,7 +392,7 @@ const Vector<GDMonoField *> &GDMonoClass::get_all_fields() { void *iter = nullptr; MonoClassField *raw_field = nullptr; while ((raw_field = mono_class_get_fields(mono_class, &iter)) != nullptr) { - StringName name = mono_field_get_name(raw_field); + StringName name = String::utf8(mono_field_get_name(raw_field)); Map<StringName, GDMonoField *>::Element *match = fields.find(name); @@ -441,7 +441,7 @@ const Vector<GDMonoProperty *> &GDMonoClass::get_all_properties() { void *iter = nullptr; MonoProperty *raw_property = nullptr; while ((raw_property = mono_class_get_properties(mono_class, &iter)) != nullptr) { - StringName name = mono_property_get_name(raw_property); + StringName name = String::utf8(mono_property_get_name(raw_property)); Map<StringName, GDMonoProperty *>::Element *match = properties.find(name); @@ -468,14 +468,14 @@ const Vector<GDMonoClass *> &GDMonoClass::get_all_delegates() { MonoClass *raw_class = nullptr; while ((raw_class = mono_class_get_nested_types(mono_class, &iter)) != nullptr) { if (mono_class_is_delegate(raw_class)) { - StringName name = mono_class_get_name(raw_class); + StringName name = String::utf8(mono_class_get_name(raw_class)); Map<StringName, GDMonoClass *>::Element *match = delegates.find(name); if (match) { delegates_list.push_back(match->get()); } else { - GDMonoClass *delegate = memnew(GDMonoClass(mono_class_get_namespace(raw_class), mono_class_get_name(raw_class), raw_class, assembly)); + GDMonoClass *delegate = memnew(GDMonoClass(String::utf8(mono_class_get_namespace(raw_class)), String::utf8(mono_class_get_name(raw_class)), raw_class, assembly)); delegates.insert(name, delegate); delegates_list.push_back(delegate); } @@ -492,7 +492,7 @@ const Vector<GDMonoMethod *> &GDMonoClass::get_all_methods() { void *iter = nullptr; MonoMethod *raw_method = nullptr; while ((raw_method = mono_class_get_methods(get_mono_ptr(), &iter)) != nullptr) { - method_list.push_back(memnew(GDMonoMethod(mono_method_get_name(raw_method), raw_method))); + method_list.push_back(memnew(GDMonoMethod(String::utf8(mono_method_get_name(raw_method)), raw_method))); } method_list_fetched = true; diff --git a/modules/mono/mono_gd/gd_mono_class.h b/modules/mono/mono_gd/gd_mono_class.h index b93dfec30a..daea75bae8 100644 --- a/modules/mono/mono_gd/gd_mono_class.h +++ b/modules/mono/mono_gd/gd_mono_class.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/mono/mono_gd/gd_mono_field.cpp b/modules/mono/mono_gd/gd_mono_field.cpp index 61d7f64a2a..1d4d52dfce 100644 --- a/modules/mono/mono_gd/gd_mono_field.cpp +++ b/modules/mono/mono_gd/gd_mono_field.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -509,7 +509,7 @@ IMonoClassMember::Visibility GDMonoField::get_visibility() { GDMonoField::GDMonoField(MonoClassField *p_mono_field, GDMonoClass *p_owner) { owner = p_owner; mono_field = p_mono_field; - name = mono_field_get_name(mono_field); + name = String::utf8(mono_field_get_name(mono_field)); MonoType *field_type = mono_field_get_type(mono_field); type.type_encoding = mono_type_get_type(field_type); MonoClass *field_type_class = mono_class_from_mono_type(field_type); diff --git a/modules/mono/mono_gd/gd_mono_field.h b/modules/mono/mono_gd/gd_mono_field.h index 5b40b439f9..ed5078c673 100644 --- a/modules/mono/mono_gd/gd_mono_field.h +++ b/modules/mono/mono_gd/gd_mono_field.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/mono/mono_gd/gd_mono_header.h b/modules/mono/mono_gd/gd_mono_header.h index ffb56e7cec..483030610f 100644 --- a/modules/mono/mono_gd/gd_mono_header.h +++ b/modules/mono/mono_gd/gd_mono_header.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/mono/mono_gd/gd_mono_internals.cpp b/modules/mono/mono_gd/gd_mono_internals.cpp index 82f916e8c5..65e2680905 100644 --- a/modules/mono/mono_gd/gd_mono_internals.cpp +++ b/modules/mono/mono_gd/gd_mono_internals.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/mono/mono_gd/gd_mono_internals.h b/modules/mono/mono_gd/gd_mono_internals.h index 0fd6250785..34d2d35b2d 100644 --- a/modules/mono/mono_gd/gd_mono_internals.h +++ b/modules/mono/mono_gd/gd_mono_internals.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/mono/mono_gd/gd_mono_log.cpp b/modules/mono/mono_gd/gd_mono_log.cpp index 7584e7ff0d..dafd36c36b 100644 --- a/modules/mono/mono_gd/gd_mono_log.cpp +++ b/modules/mono/mono_gd/gd_mono_log.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -189,8 +189,6 @@ void GDMonoLog::initialize() { GDMonoLog::GDMonoLog() { singleton = this; - - log_level_id = -1; } GDMonoLog::~GDMonoLog() { diff --git a/modules/mono/mono_gd/gd_mono_log.h b/modules/mono/mono_gd/gd_mono_log.h index 3a52316060..f7a53156ab 100644 --- a/modules/mono/mono_gd/gd_mono_log.h +++ b/modules/mono/mono_gd/gd_mono_log.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -46,9 +46,9 @@ class GDMonoLog { #ifdef GD_MONO_LOG_ENABLED - int log_level_id; + int log_level_id = -1; - FileAccess *log_file; + FileAccess *log_file = nullptr; String log_file_path; bool _try_create_logs_dir(const String &p_logs_dir); diff --git a/modules/mono/mono_gd/gd_mono_marshal.cpp b/modules/mono/mono_gd/gd_mono_marshal.cpp index 64b350f270..359f6bba4d 100644 --- a/modules/mono/mono_gd/gd_mono_marshal.cpp +++ b/modules/mono/mono_gd/gd_mono_marshal.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -1204,7 +1204,7 @@ Variant mono_object_to_variant_impl(MonoObject *p_obj, const ManagedType &p_type if (GDMonoUtils::Marshal::type_is_system_generic_list(reftype)) { MonoReflectionType *elem_reftype = nullptr; GDMonoUtils::Marshal::array_get_element_type(reftype, &elem_reftype); - return system_generic_list_to_Array(p_obj, p_type.type_class, elem_reftype); + return system_generic_list_to_Array_variant(p_obj, p_type.type_class, elem_reftype); } } break; } @@ -1333,15 +1333,22 @@ MonoObject *Array_to_system_generic_list(const Array &p_array, GDMonoClass *p_cl return mono_object; } -Array system_generic_list_to_Array(MonoObject *p_obj, GDMonoClass *p_class, [[maybe_unused]] MonoReflectionType *p_elem_reftype) { +Variant system_generic_list_to_Array_variant(MonoObject *p_obj, GDMonoClass *p_class, [[maybe_unused]] MonoReflectionType *p_elem_reftype) { GDMonoMethod *to_array = p_class->get_method("ToArray", 0); CRASH_COND(to_array == nullptr); MonoException *exc = nullptr; - MonoArray *mono_array = (MonoArray *)to_array->invoke_raw(p_obj, nullptr, &exc); + MonoObject *array = to_array->invoke_raw(p_obj, nullptr, &exc); UNHANDLED_EXCEPTION(exc); - return mono_array_to_Array(mono_array); + ERR_FAIL_NULL_V(array, Variant()); + + ManagedType type = ManagedType::from_class(mono_object_get_class(array)); + + bool result_is_array = type.type_encoding != MONO_TYPE_SZARRAY && type.type_encoding != MONO_TYPE_ARRAY; + ERR_FAIL_COND_V(result_is_array, Variant()); + + return mono_object_to_variant(array, type); } MonoArray *Array_to_mono_array(const Array &p_array) { @@ -1677,8 +1684,8 @@ Callable managed_to_callable(const M_Callable &p_managed_callable) { return Callable(managed_callable); } else { Object *target = p_managed_callable.target ? - unbox<Object *>(CACHED_FIELD(GodotObject, ptr)->get_value(p_managed_callable.target)) : - nullptr; + unbox<Object *>(CACHED_FIELD(GodotObject, ptr)->get_value(p_managed_callable.target)) : + nullptr; StringName *method_ptr = unbox<StringName *>(CACHED_FIELD(StringName, ptr)->get_value(p_managed_callable.method_string_name)); StringName method = method_ptr ? *method_ptr : StringName(); return Callable(target, method); @@ -1723,8 +1730,8 @@ M_Callable callable_to_managed(const Callable &p_callable) { Signal managed_to_signal_info(const M_SignalInfo &p_managed_signal) { Object *owner = p_managed_signal.owner ? - unbox<Object *>(CACHED_FIELD(GodotObject, ptr)->get_value(p_managed_signal.owner)) : - nullptr; + unbox<Object *>(CACHED_FIELD(GodotObject, ptr)->get_value(p_managed_signal.owner)) : + nullptr; StringName *name_ptr = unbox<StringName *>(CACHED_FIELD(StringName, ptr)->get_value(p_managed_signal.name_string_name)); StringName name = name_ptr ? *name_ptr : StringName(); return Signal(owner, name); diff --git a/modules/mono/mono_gd/gd_mono_marshal.h b/modules/mono/mono_gd/gd_mono_marshal.h index 6d8227f8b4..668809ae5d 100644 --- a/modules/mono/mono_gd/gd_mono_marshal.h +++ b/modules/mono/mono_gd/gd_mono_marshal.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -140,7 +140,7 @@ MonoObject *Dictionary_to_system_generic_dict(const Dictionary &p_dict, GDMonoCl Dictionary system_generic_dict_to_Dictionary(MonoObject *p_obj, GDMonoClass *p_class, MonoReflectionType *p_key_reftype, MonoReflectionType *p_value_reftype); MonoObject *Array_to_system_generic_list(const Array &p_array, GDMonoClass *p_class, MonoReflectionType *p_elem_reftype); -Array system_generic_list_to_Array(MonoObject *p_obj, GDMonoClass *p_class, MonoReflectionType *p_elem_reftype); +Variant system_generic_list_to_Array_variant(MonoObject *p_obj, GDMonoClass *p_class, MonoReflectionType *p_elem_reftype); // Array diff --git a/modules/mono/mono_gd/gd_mono_method.cpp b/modules/mono/mono_gd/gd_mono_method.cpp index 1d87726234..67aabcde10 100644 --- a/modules/mono/mono_gd/gd_mono_method.cpp +++ b/modules/mono/mono_gd/gd_mono_method.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/mono/mono_gd/gd_mono_method.h b/modules/mono/mono_gd/gd_mono_method.h index 115bd998fa..c08ffe904b 100644 --- a/modules/mono/mono_gd/gd_mono_method.h +++ b/modules/mono/mono_gd/gd_mono_method.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/mono/mono_gd/gd_mono_method_thunk.h b/modules/mono/mono_gd/gd_mono_method_thunk.h index 01f3ae342a..091d26df1d 100644 --- a/modules/mono/mono_gd/gd_mono_method_thunk.h +++ b/modules/mono/mono_gd/gd_mono_method_thunk.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/mono/mono_gd/gd_mono_property.cpp b/modules/mono/mono_gd/gd_mono_property.cpp index 1027c08a4a..5391b7775e 100644 --- a/modules/mono/mono_gd/gd_mono_property.cpp +++ b/modules/mono/mono_gd/gd_mono_property.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -40,7 +40,7 @@ GDMonoProperty::GDMonoProperty(MonoProperty *p_mono_property, GDMonoClass *p_owner) { owner = p_owner; mono_property = p_mono_property; - name = mono_property_get_name(mono_property); + name = String::utf8(mono_property_get_name(mono_property)); MonoMethod *prop_method = mono_property_get_get_method(mono_property); diff --git a/modules/mono/mono_gd/gd_mono_property.h b/modules/mono/mono_gd/gd_mono_property.h index 611ac293e4..af7a2c02e5 100644 --- a/modules/mono/mono_gd/gd_mono_property.h +++ b/modules/mono/mono_gd/gd_mono_property.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/mono/mono_gd/gd_mono_utils.cpp b/modules/mono/mono_gd/gd_mono_utils.cpp index 05fd57255c..6e0a263c7f 100644 --- a/modules/mono/mono_gd/gd_mono_utils.cpp +++ b/modules/mono/mono_gd/gd_mono_utils.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/mono/mono_gd/gd_mono_utils.h b/modules/mono/mono_gd/gd_mono_utils.h index 5370b1c6fc..9e024418e1 100644 --- a/modules/mono/mono_gd/gd_mono_utils.h +++ b/modules/mono/mono_gd/gd_mono_utils.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/mono/mono_gd/gd_mono_wasm_m2n.cpp b/modules/mono/mono_gd/gd_mono_wasm_m2n.cpp index f4c964c6eb..a477c55456 100644 --- a/modules/mono/mono_gd/gd_mono_wasm_m2n.cpp +++ b/modules/mono/mono_gd/gd_mono_wasm_m2n.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/mono/mono_gd/gd_mono_wasm_m2n.h b/modules/mono/mono_gd/gd_mono_wasm_m2n.h index 68a14f15f4..159a2ed7b6 100644 --- a/modules/mono/mono_gd/gd_mono_wasm_m2n.h +++ b/modules/mono/mono_gd/gd_mono_wasm_m2n.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/mono/mono_gd/i_mono_class_member.h b/modules/mono/mono_gd/i_mono_class_member.h index 2e8e01c80e..36e14ba27c 100644 --- a/modules/mono/mono_gd/i_mono_class_member.h +++ b/modules/mono/mono_gd/i_mono_class_member.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/mono/mono_gd/managed_type.cpp b/modules/mono/mono_gd/managed_type.cpp index 3e971efece..0acfafe841 100644 --- a/modules/mono/mono_gd/managed_type.cpp +++ b/modules/mono/mono_gd/managed_type.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/mono/mono_gd/managed_type.h b/modules/mono/mono_gd/managed_type.h index 491a2f3d20..0456a9a864 100644 --- a/modules/mono/mono_gd/managed_type.h +++ b/modules/mono/mono_gd/managed_type.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/mono/mono_gd/support/android_support.cpp b/modules/mono/mono_gd/support/android_support.cpp index bc2ae03299..cba29d63cd 100644 --- a/modules/mono/mono_gd/support/android_support.cpp +++ b/modules/mono/mono_gd/support/android_support.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -109,7 +109,7 @@ bool jni_exception_check(JNIEnv *p_env) { String app_native_lib_dir_cache; String determine_app_native_lib_dir() { - JNIEnv *env = ThreadAndroid::get_env(); + JNIEnv *env = get_jni_env(); ScopedLocalRef<jclass> activityThreadClass(env, env->FindClass("android/app/ActivityThread")); jmethodID currentActivityThread = env->GetStaticMethodID(activityThreadClass, "currentActivityThread", "()Landroid/app/ActivityThread;"); @@ -134,7 +134,7 @@ String determine_app_native_lib_dir() { } String get_app_native_lib_dir() { - if (app_native_lib_dir_cache.empty()) + if (app_native_lib_dir_cache.is_empty()) app_native_lib_dir_cache = determine_app_native_lib_dir(); return app_native_lib_dir_cache; } @@ -253,7 +253,7 @@ int32_t get_build_version_sdk_int() { // android.os.Build.VERSION.SDK_INT if (build_version_sdk_int == 0) { - JNIEnv *env = ThreadAndroid::get_env(); + JNIEnv *env = get_jni_env(); jclass versionClass = env->FindClass("android/os/Build$VERSION"); ERR_FAIL_NULL_V(versionClass, 0); @@ -281,7 +281,7 @@ MonoBoolean _gd_mono_init_cert_store() { // return false; // } - JNIEnv *env = ThreadAndroid::get_env(); + JNIEnv *env = get_jni_env(); ScopedLocalRef<jclass> keyStoreClass(env, env->FindClass("java/security/KeyStore")); @@ -322,7 +322,7 @@ MonoArray *_gd_mono_android_cert_store_lookup(MonoString *p_alias) { return nullptr; } - JNIEnv *env = ThreadAndroid::get_env(); + JNIEnv *env = get_jni_env(); ScopedLocalRef<jstring> js_alias(env, env->NewStringUTF(alias_utf8)); mono_free(alias_utf8); @@ -380,7 +380,7 @@ void cleanup() { if (godot_dl_handle) gd_mono_android_dlclose(godot_dl_handle, nullptr); - JNIEnv *env = ThreadAndroid::get_env(); + JNIEnv *env = get_jni_env(); if (certStore) { env->DeleteGlobalRef(certStore); @@ -437,7 +437,7 @@ GD_PINVOKE_EXPORT mono_bool _monodroid_get_network_interface_up_state(const char *r_is_up = 0; - JNIEnv *env = ThreadAndroid::get_env(); + JNIEnv *env = get_jni_env(); jclass networkInterfaceClass = env->FindClass("java/net/NetworkInterface"); ERR_FAIL_NULL_V(networkInterfaceClass, 0); @@ -469,7 +469,7 @@ GD_PINVOKE_EXPORT mono_bool _monodroid_get_network_interface_supports_multicast( *r_supports_multicast = 0; - JNIEnv *env = ThreadAndroid::get_env(); + JNIEnv *env = get_jni_env(); jclass networkInterfaceClass = env->FindClass("java/net/NetworkInterface"); ERR_FAIL_NULL_V(networkInterfaceClass, 0); @@ -507,7 +507,7 @@ static void interop_get_active_network_dns_servers(char **r_dns_servers, int *dn CRASH_COND(get_build_version_sdk_int() < 23); #endif - JNIEnv *env = ThreadAndroid::get_env(); + JNIEnv *env = get_jni_env(); GodotJavaWrapper *godot_java = ((OS_Android *)OS::get_singleton())->get_godot_java(); jobject activity = godot_java->get_activity(); @@ -648,7 +648,7 @@ GD_PINVOKE_EXPORT const char *_monodroid_timezone_get_default_id() { // // TimeZone.getDefault().getID() - JNIEnv *env = ThreadAndroid::get_env(); + JNIEnv *env = get_jni_env(); ScopedLocalRef<jclass> timeZoneClass(env, env->FindClass("java/util/TimeZone")); ERR_FAIL_NULL_V(timeZoneClass, nullptr); diff --git a/modules/mono/mono_gd/support/android_support.h b/modules/mono/mono_gd/support/android_support.h index df51100bef..0c5dd2764c 100755..100644 --- a/modules/mono/mono_gd/support/android_support.h +++ b/modules/mono/mono_gd/support/android_support.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/mono/mono_gd/support/ios_support.h b/modules/mono/mono_gd/support/ios_support.h index 48cef890d6..28a8806d0e 100755..100644 --- a/modules/mono/mono_gd/support/ios_support.h +++ b/modules/mono/mono_gd/support/ios_support.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/mono/mono_gd/support/ios_support.mm b/modules/mono/mono_gd/support/ios_support.mm index e6e09c4146..cdee04edcf 100644 --- a/modules/mono/mono_gd/support/ios_support.mm +++ b/modules/mono/mono_gd/support/ios_support.mm @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/mono/register_types.cpp b/modules/mono/register_types.cpp index f5c1bda18b..80eb47bfd4 100644 --- a/modules/mono/register_types.cpp +++ b/modules/mono/register_types.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/mono/register_types.h b/modules/mono/register_types.h index e30d9a8abd..1a2ff004b5 100644 --- a/modules/mono/register_types.h +++ b/modules/mono/register_types.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/mono/signal_awaiter_utils.cpp b/modules/mono/signal_awaiter_utils.cpp index f220abfb4c..3aaf726fc8 100644 --- a/modules/mono/signal_awaiter_utils.cpp +++ b/modules/mono/signal_awaiter_utils.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/mono/signal_awaiter_utils.h b/modules/mono/signal_awaiter_utils.h index 18d1e43e14..4c77f8cfed 100644 --- a/modules/mono/signal_awaiter_utils.h +++ b/modules/mono/signal_awaiter_utils.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/mono/utils/macros.h b/modules/mono/utils/macros.h index 60c9b9718a..4a220d89c8 100644 --- a/modules/mono/utils/macros.h +++ b/modules/mono/utils/macros.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/mono/utils/mono_reg_utils.cpp b/modules/mono/utils/mono_reg_utils.cpp index 9902744743..bb1265e959 100644 --- a/modules/mono/utils/mono_reg_utils.cpp +++ b/modules/mono/utils/mono_reg_utils.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -173,7 +173,7 @@ String find_msbuild_tools_path() { String output; int exit_code; - OS::get_singleton()->execute(vswhere_path, vswhere_args, true, nullptr, &output, &exit_code); + OS::get_singleton()->execute(vswhere_path, vswhere_args, &output, &exit_code); if (exit_code == 0) { Vector<String> lines = output.split("\n"); @@ -188,7 +188,7 @@ String find_msbuild_tools_path() { if (key == "installationPath") { String val = line.substr(sep_idx + 1, line.length()).strip_edges(); - ERR_BREAK(val.empty()); + ERR_BREAK(val.is_empty()); if (!val.ends_with("\\")) { val += "\\"; diff --git a/modules/mono/utils/mono_reg_utils.h b/modules/mono/utils/mono_reg_utils.h index cc3f1cb035..0e617761ea 100644 --- a/modules/mono/utils/mono_reg_utils.h +++ b/modules/mono/utils/mono_reg_utils.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/mono/utils/osx_utils.cpp b/modules/mono/utils/osx_utils.cpp index 41be198bcf..f4216c8129 100644 --- a/modules/mono/utils/osx_utils.cpp +++ b/modules/mono/utils/osx_utils.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/mono/utils/osx_utils.h b/modules/mono/utils/osx_utils.h index 92faead0fb..6704f19077 100644 --- a/modules/mono/utils/osx_utils.h +++ b/modules/mono/utils/osx_utils.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/mono/utils/path_utils.cpp b/modules/mono/utils/path_utils.cpp index a24097924e..93d44628ac 100644 --- a/modules/mono/utils/path_utils.cpp +++ b/modules/mono/utils/path_utils.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -136,7 +136,7 @@ String realpath(const String &p_path) { } String join(const String &p_a, const String &p_b) { - if (p_a.empty()) { + if (p_a.is_empty()) { return p_b; } @@ -165,7 +165,7 @@ String relative_to_impl(const String &p_path, const String &p_relative_to) { } else { String base_dir = p_relative_to.get_base_dir(); - if (base_dir.length() <= 2 && (base_dir.empty() || base_dir.ends_with(":"))) { + if (base_dir.length() <= 2 && (base_dir.is_empty() || base_dir.ends_with(":"))) { return p_path; } diff --git a/modules/mono/utils/path_utils.h b/modules/mono/utils/path_utils.h index c19cb3bc8b..82b8f95f49 100644 --- a/modules/mono/utils/path_utils.h +++ b/modules/mono/utils/path_utils.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/mono/utils/string_utils.cpp b/modules/mono/utils/string_utils.cpp index d70004657c..43de77005e 100644 --- a/modules/mono/utils/string_utils.cpp +++ b/modules/mono/utils/string_utils.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/mono/utils/string_utils.h b/modules/mono/utils/string_utils.h index 99f3548f31..3290cb38b9 100644 --- a/modules/mono/utils/string_utils.h +++ b/modules/mono/utils/string_utils.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/ogg/register_types.cpp b/modules/ogg/register_types.cpp index 73c691397c..b23ea65378 100644 --- a/modules/ogg/register_types.cpp +++ b/modules/ogg/register_types.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/ogg/register_types.h b/modules/ogg/register_types.h index 849d27bb06..49d5ed9c80 100644 --- a/modules/ogg/register_types.h +++ b/modules/ogg/register_types.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/opensimplex/doc_classes/NoiseTexture.xml b/modules/opensimplex/doc_classes/NoiseTexture.xml index c06f3096de..7df261d2ba 100644 --- a/modules/opensimplex/doc_classes/NoiseTexture.xml +++ b/modules/opensimplex/doc_classes/NoiseTexture.xml @@ -5,7 +5,7 @@ </brief_description> <description> Uses an [OpenSimplexNoise] to fill the texture data. You can specify the texture size but keep in mind that larger textures will take longer to generate and seamless noise only works with square sized textures. - NoiseTexture can also generate normalmap textures. + NoiseTexture can also generate normal map textures. The class uses [Thread]s to generate the texture data internally, so [method Texture2D.get_data] may return [code]null[/code] if the generation process has not completed yet. In that case, you need to wait for the texture to be generated before accessing the data: [codeblock] var texture = preload("res://noise.tres") @@ -18,7 +18,7 @@ <methods> </methods> <members> - <member name="as_normalmap" type="bool" setter="set_as_normalmap" getter="is_normalmap" default="false"> + <member name="as_normal_map" type="bool" setter="set_as_normal_map" getter="is_normal_map" default="false"> If [code]true[/code], the resulting texture contains a normal map created from the original noise interpreted as a bump map. </member> <member name="bump_strength" type="float" setter="set_bump_strength" getter="get_bump_strength" default="8.0"> diff --git a/modules/opensimplex/doc_classes/OpenSimplexNoise.xml b/modules/opensimplex/doc_classes/OpenSimplexNoise.xml index 9fe4c9c249..dcda5c2324 100644 --- a/modules/opensimplex/doc_classes/OpenSimplexNoise.xml +++ b/modules/opensimplex/doc_classes/OpenSimplexNoise.xml @@ -32,7 +32,7 @@ <argument index="1" name="height" type="int"> </argument> <description> - Generate a noise image with the requested [code]width[/code] and [code]height[/code], based on the current noise parameters. + Generate a noise image in [constant Image.FORMAT_L8] format with the requested [code]width[/code] and [code]height[/code], based on the current noise parameters. </description> </method> <method name="get_noise_1d" qualifiers="const"> @@ -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] × [code]size[/code]). + Generate a tileable noise image in [constant Image.FORMAT_L8] format, 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/noise_texture.cpp b/modules/opensimplex/noise_texture.cpp index 1181e69cd3..f5d401b058 100644 --- a/modules/opensimplex/noise_texture.cpp +++ b/modules/opensimplex/noise_texture.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -33,16 +33,6 @@ #include "core/core_string_names.h" NoiseTexture::NoiseTexture() { - update_queued = false; - noise_thread = nullptr; - regen_queued = false; - first_time = true; - - size = Vector2i(512, 512); - seamless = false; - as_normalmap = false; - bump_strength = 8.0; - noise = Ref<OpenSimplexNoise>(); _queue_update(); @@ -52,10 +42,7 @@ NoiseTexture::~NoiseTexture() { if (texture.is_valid()) { RS::get_singleton()->free(texture); } - if (noise_thread) { - Thread::wait_to_finish(noise_thread); - memdelete(noise_thread); - } + noise_thread.wait_to_finish(); } void NoiseTexture::_bind_methods() { @@ -68,8 +55,8 @@ void NoiseTexture::_bind_methods() { ClassDB::bind_method(D_METHOD("set_seamless", "seamless"), &NoiseTexture::set_seamless); ClassDB::bind_method(D_METHOD("get_seamless"), &NoiseTexture::get_seamless); - ClassDB::bind_method(D_METHOD("set_as_normalmap", "as_normalmap"), &NoiseTexture::set_as_normalmap); - ClassDB::bind_method(D_METHOD("is_normalmap"), &NoiseTexture::is_normalmap); + ClassDB::bind_method(D_METHOD("set_as_normal_map", "as_normal_map"), &NoiseTexture::set_as_normal_map); + ClassDB::bind_method(D_METHOD("is_normal_map"), &NoiseTexture::is_normal_map); ClassDB::bind_method(D_METHOD("set_bump_strength", "bump_strength"), &NoiseTexture::set_bump_strength); ClassDB::bind_method(D_METHOD("get_bump_strength"), &NoiseTexture::get_bump_strength); @@ -81,14 +68,14 @@ void NoiseTexture::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "width", PROPERTY_HINT_RANGE, "1,2048,1,or_greater"), "set_width", "get_width"); ADD_PROPERTY(PropertyInfo(Variant::INT, "height", PROPERTY_HINT_RANGE, "1,2048,1,or_greater"), "set_height", "get_height"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "seamless"), "set_seamless", "get_seamless"); - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "as_normalmap"), "set_as_normalmap", "is_normalmap"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "as_normal_map"), "set_as_normal_map", "is_normal_map"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "bump_strength", PROPERTY_HINT_RANGE, "0,32,0.1,or_greater"), "set_bump_strength", "get_bump_strength"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "noise", PROPERTY_HINT_RESOURCE_TYPE, "OpenSimplexNoise"), "set_noise", "get_noise"); } void NoiseTexture::_validate_property(PropertyInfo &property) const { if (property.name == "bump_strength") { - if (!as_normalmap) { + if (!as_normal_map) { property.usage = PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL; } } @@ -109,11 +96,9 @@ void NoiseTexture::_set_texture_data(const Ref<Image> &p_image) { void NoiseTexture::_thread_done(const Ref<Image> &p_image) { _set_texture_data(p_image); - Thread::wait_to_finish(noise_thread); - memdelete(noise_thread); - noise_thread = nullptr; + noise_thread.wait_to_finish(); if (regen_queued) { - noise_thread = Thread::create(_thread_function, this); + noise_thread.start(_thread_function, this); regen_queued = false; } } @@ -148,8 +133,8 @@ Ref<Image> NoiseTexture::_generate_texture() { image = ref_noise->get_image(size.x, size.y); } - if (as_normalmap) { - image->bumpmap_to_normalmap(bump_strength); + if (as_normal_map) { + image->bump_map_to_normal_map(bump_strength); } return image; @@ -165,8 +150,8 @@ void NoiseTexture::_update_texture() { use_thread = false; #endif if (use_thread) { - if (!noise_thread) { - noise_thread = Thread::create(_thread_function, this); + if (!noise_thread.is_started()) { + noise_thread.start(_thread_function, this); regen_queued = false; } else { regen_queued = true; @@ -225,17 +210,17 @@ bool NoiseTexture::get_seamless() { return seamless; } -void NoiseTexture::set_as_normalmap(bool p_as_normalmap) { - if (p_as_normalmap == as_normalmap) { +void NoiseTexture::set_as_normal_map(bool p_as_normal_map) { + if (p_as_normal_map == as_normal_map) { return; } - as_normalmap = p_as_normalmap; + as_normal_map = p_as_normal_map; _queue_update(); - _change_notify(); + notify_property_list_changed(); } -bool NoiseTexture::is_normalmap() { - return as_normalmap; +bool NoiseTexture::is_normal_map() { + return as_normal_map; } void NoiseTexture::set_bump_strength(float p_bump_strength) { @@ -243,7 +228,7 @@ void NoiseTexture::set_bump_strength(float p_bump_strength) { return; } bump_strength = p_bump_strength; - if (as_normalmap) { + if (as_normal_map) { _queue_update(); } } diff --git a/modules/opensimplex/noise_texture.h b/modules/opensimplex/noise_texture.h index 73960ba85f..e89479d962 100644 --- a/modules/opensimplex/noise_texture.h +++ b/modules/opensimplex/noise_texture.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -45,20 +45,20 @@ class NoiseTexture : public Texture2D { private: Ref<Image> data; - Thread *noise_thread; + Thread noise_thread; - bool first_time; - bool update_queued; - bool regen_queued; + bool first_time = true; + bool update_queued = false; + bool regen_queued = false; mutable RID texture; - uint32_t flags; + uint32_t flags = 0; Ref<OpenSimplexNoise> noise; - Vector2i size; - bool seamless; - bool as_normalmap; - float bump_strength; + Vector2i size = Vector2i(512, 512); + bool seamless = false; + bool as_normal_map = false; + float bump_strength = 8.0; void _thread_done(const Ref<Image> &p_image); static void _thread_function(void *p_ud); @@ -82,8 +82,8 @@ public: void set_seamless(bool p_seamless); bool get_seamless(); - void set_as_normalmap(bool p_as_normalmap); - bool is_normalmap(); + void set_as_normal_map(bool p_as_normal_map); + bool is_normal_map(); void set_bump_strength(float p_bump_strength); float get_bump_strength(); diff --git a/modules/opensimplex/open_simplex_noise.cpp b/modules/opensimplex/open_simplex_noise.cpp index aded4d2a07..3773946112 100644 --- a/modules/opensimplex/open_simplex_noise.cpp +++ b/modules/opensimplex/open_simplex_noise.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -33,12 +33,6 @@ #include "core/core_string_names.h" OpenSimplexNoise::OpenSimplexNoise() { - seed = 0; - persistence = 0.5; - octaves = 3; - period = 64; - lacunarity = 2.0; - _init_seeds(); } @@ -104,7 +98,7 @@ void OpenSimplexNoise::set_lacunarity(float p_lacunarity) { Ref<Image> OpenSimplexNoise::get_image(int p_width, int p_height) const { Vector<uint8_t> data; - data.resize(p_width * p_height * 4); + data.resize(p_width * p_height); uint8_t *wd8 = data.ptrw(); @@ -112,21 +106,17 @@ Ref<Image> OpenSimplexNoise::get_image(int p_width, int p_height) const { for (int j = 0; j < p_width; j++) { float v = get_noise_2d(j, i); v = v * 0.5 + 0.5; // Normalize [0..1] - uint8_t value = uint8_t(CLAMP(v * 255.0, 0, 255)); - wd8[(i * p_width + j) * 4 + 0] = value; - wd8[(i * p_width + j) * 4 + 1] = value; - wd8[(i * p_width + j) * 4 + 2] = value; - wd8[(i * p_width + j) * 4 + 3] = 255; + wd8[(i * p_width + j)] = uint8_t(CLAMP(v * 255.0, 0, 255)); } } - Ref<Image> image = memnew(Image(p_width, p_height, false, Image::FORMAT_RGBA8, data)); + Ref<Image> image = memnew(Image(p_width, p_height, false, Image::FORMAT_L8, data)); return image; } Ref<Image> OpenSimplexNoise::get_seamless_image(int p_size) const { Vector<uint8_t> data; - data.resize(p_size * p_size * 4); + data.resize(p_size * p_size); uint8_t *wd8 = data.ptrw(); @@ -135,10 +125,10 @@ Ref<Image> OpenSimplexNoise::get_seamless_image(int p_size) const { float ii = (float)i / (float)p_size; float jj = (float)j / (float)p_size; - ii *= 2.0 * Math_PI; - jj *= 2.0 * Math_PI; + ii *= Math_TAU; + jj *= Math_TAU; - float radius = p_size / (2.0 * Math_PI); + float radius = p_size / Math_TAU; float x = radius * Math::sin(jj); float y = radius * Math::cos(jj); @@ -147,15 +137,11 @@ Ref<Image> OpenSimplexNoise::get_seamless_image(int p_size) const { float v = get_noise_4d(x, y, z, w); v = v * 0.5 + 0.5; // Normalize [0..1] - uint8_t value = uint8_t(CLAMP(v * 255.0, 0, 255)); - wd8[(i * p_size + j) * 4 + 0] = value; - wd8[(i * p_size + j) * 4 + 1] = value; - wd8[(i * p_size + j) * 4 + 2] = value; - wd8[(i * p_size + j) * 4 + 3] = 255; + wd8[(i * p_size + j)] = uint8_t(CLAMP(v * 255.0, 0, 255)); } } - Ref<Image> image = memnew(Image(p_size, p_size, false, Image::FORMAT_RGBA8, data)); + Ref<Image> image = memnew(Image(p_size, p_size, false, Image::FORMAT_L8, data)); return image; } diff --git a/modules/opensimplex/open_simplex_noise.h b/modules/opensimplex/open_simplex_noise.h index d9bf05115d..847c157409 100644 --- a/modules/opensimplex/open_simplex_noise.h +++ b/modules/opensimplex/open_simplex_noise.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -37,22 +37,22 @@ #include "thirdparty/misc/open-simplex-noise.h" -// The maximum number of octaves allowed. Note that these are statically allocated. -// Higher values become exponentially slower, so this shouldn't be set too high -// to avoid freezing the editor for long periods of time. -#define MAX_OCTAVES 9 - class OpenSimplexNoise : public Resource { GDCLASS(OpenSimplexNoise, Resource); OBJ_SAVE_TYPE(OpenSimplexNoise); + // The maximum number of octaves allowed. Note that these are statically allocated. + // Higher values become exponentially slower, so this shouldn't be set too high + // to avoid freezing the editor for long periods of time. + static const int MAX_OCTAVES = 9; + osn_context contexts[MAX_OCTAVES]; - int seed; - float persistence; // Controls details, value in [0,1]. Higher increases grain, lower increases smoothness. - int octaves; // Number of noise layers - float period; // Distance above which we start to see similarities. The higher, the longer "hills" will be on a terrain. - float lacunarity; // Controls period change across octaves. 2 is usually a good value to address all detail levels. + int seed = 0; + float persistence = 0.5; // Controls details, value in [0,1]. Higher increases grain, lower increases smoothness. + int octaves = 3; // Number of noise layers + float period = 64.0; // Distance above which we start to see similarities. The higher, the longer "hills" will be on a terrain. + float lacunarity = 2.0; // Controls period change across octaves. 2 is usually a good value to address all detail levels. public: OpenSimplexNoise(); diff --git a/modules/opensimplex/register_types.cpp b/modules/opensimplex/register_types.cpp index fef90cdce3..e9735a2cc8 100644 --- a/modules/opensimplex/register_types.cpp +++ b/modules/opensimplex/register_types.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/opensimplex/register_types.h b/modules/opensimplex/register_types.h index 51c6815eae..d72e37e3a3 100644 --- a/modules/opensimplex/register_types.h +++ b/modules/opensimplex/register_types.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/opus/register_types.cpp b/modules/opus/register_types.cpp index a4329e142c..02874a9a4b 100644 --- a/modules/opus/register_types.cpp +++ b/modules/opus/register_types.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/opus/register_types.h b/modules/opus/register_types.h index ad6e083c82..af889cf809 100644 --- a/modules/opus/register_types.h +++ b/modules/opus/register_types.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/pvr/image_compress_pvrtc.cpp b/modules/pvr/image_compress_pvrtc.cpp index 6695a539d0..d2d8976694 100644 --- a/modules/pvr/image_compress_pvrtc.cpp +++ b/modules/pvr/image_compress_pvrtc.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/pvr/image_compress_pvrtc.h b/modules/pvr/image_compress_pvrtc.h index fde65f4bbe..985076ce4d 100644 --- a/modules/pvr/image_compress_pvrtc.h +++ b/modules/pvr/image_compress_pvrtc.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/pvr/register_types.cpp b/modules/pvr/register_types.cpp index 9bfc334d76..aeac564c93 100644 --- a/modules/pvr/register_types.cpp +++ b/modules/pvr/register_types.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/pvr/register_types.h b/modules/pvr/register_types.h index 8318996a46..74fcfe2ce4 100644 --- a/modules/pvr/register_types.h +++ b/modules/pvr/register_types.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/pvr/texture_loader_pvr.cpp b/modules/pvr/texture_loader_pvr.cpp index c9cbb1935a..83f032ca2b 100644 --- a/modules/pvr/texture_loader_pvr.cpp +++ b/modules/pvr/texture_loader_pvr.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -46,7 +46,7 @@ enum PVRFLags { PVR_VFLIP = 0x00010000 }; -RES ResourceFormatPVR::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, bool p_no_cache) { +RES ResourceFormatPVR::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, CacheMode p_cache_mode) { if (r_error) { *r_error = ERR_CANT_OPEN; } @@ -153,7 +153,7 @@ RES ResourceFormatPVR::load(const String &p_path, const String &p_original_path, } Ref<Image> image = memnew(Image(width, height, mipmaps, format, data)); - ERR_FAIL_COND_V(image->empty(), RES()); + ERR_FAIL_COND_V(image->is_empty(), RES()); Ref<ImageTexture> texture = memnew(ImageTexture); texture->create_from_image(image); @@ -207,7 +207,7 @@ ResourceFormatPVR::ResourceFormatPVR() { struct PVRTCBlock { //blocks are 64 bits - uint32_t data[2]; + uint32_t data[2] = {}; }; _FORCE_INLINE_ bool is_po2(uint32_t p_input) { diff --git a/modules/pvr/texture_loader_pvr.h b/modules/pvr/texture_loader_pvr.h index 07ef129689..26071ce30f 100644 --- a/modules/pvr/texture_loader_pvr.h +++ b/modules/pvr/texture_loader_pvr.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -36,7 +36,7 @@ class ResourceFormatPVR : public ResourceFormatLoader { public: - virtual RES load(const String &p_path, const String &p_original_path, Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr, bool p_no_cache = false); + virtual RES load(const String &p_path, const String &p_original_path, Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr, CacheMode p_cache_mode = CACHE_MODE_REUSE); virtual void get_recognized_extensions(List<String> *p_extensions) const; virtual bool handles_type(const String &p_type) const; virtual String get_resource_type(const String &p_path) const; diff --git a/modules/regex/doc_classes/RegEx.xml b/modules/regex/doc_classes/RegEx.xml index 312275842a..b21f5d1e7a 100644 --- a/modules/regex/doc_classes/RegEx.xml +++ b/modules/regex/doc_classes/RegEx.xml @@ -39,8 +39,8 @@ var regex = RegEx.new() regex.compile("\\S+") # Negated whitespace character class. var results = [] - for match in regex.search_all("One Two \n\tThree"): - results.push_back(match.get_string()) + for result in regex.search_all("One Two \n\tThree"): + results.push_back(result.get_string()) # The `results` array now contains "One", "Two", "Three". [/codeblock] [b]Note:[/b] Godot's regex implementation is based on the [url=https://www.pcre.org/]PCRE2[/url] library. You can view the full pattern reference [url=https://www.pcre.org/current/doc/html/pcre2pattern.html]here[/url]. diff --git a/modules/regex/regex.cpp b/modules/regex/regex.cpp index c10a276eae..6bae12e7e6 100644 --- a/modules/regex/regex.cpp +++ b/modules/regex/regex.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -365,12 +365,10 @@ Array RegEx::get_names() const { RegEx::RegEx() { general_ctx = pcre2_general_context_create_32(&_regex_malloc, &_regex_free, nullptr); - code = nullptr; } RegEx::RegEx(const String &p_pattern) { general_ctx = pcre2_general_context_create_32(&_regex_malloc, &_regex_free, nullptr); - code = nullptr; compile(p_pattern); } diff --git a/modules/regex/regex.h b/modules/regex/regex.h index 5b4798b65a..f5773042fb 100644 --- a/modules/regex/regex.h +++ b/modules/regex/regex.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -42,8 +42,8 @@ class RegExMatch : public Reference { GDCLASS(RegExMatch, Reference); struct Range { - int start; - int end; + int start = 0; + int end = 0; }; String subject; @@ -72,7 +72,7 @@ class RegEx : public Reference { GDCLASS(RegEx, Reference); void *general_ctx; - void *code; + void *code = nullptr; String pattern; void _pattern_info(uint32_t what, void *where) const; diff --git a/modules/regex/register_types.cpp b/modules/regex/register_types.cpp index d470fcdaeb..82f3eaf707 100644 --- a/modules/regex/register_types.cpp +++ b/modules/regex/register_types.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/regex/register_types.h b/modules/regex/register_types.h index cf377cdf5f..fe94cde954 100644 --- a/modules/regex/register_types.h +++ b/modules/regex/register_types.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/regex/tests/test_regex.h b/modules/regex/tests/test_regex.h index 4b9e7e18eb..c2d303b435 100644 --- a/modules/regex/tests/test_regex.h +++ b/modules/regex/tests/test_regex.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/register_module_types.h b/modules/register_module_types.h index acd9fc7c97..2cff8c54c4 100644 --- a/modules/register_module_types.h +++ b/modules/register_module_types.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/squish/image_compress_squish.cpp b/modules/squish/image_compress_squish.cpp index c510779317..cce08034df 100644 --- a/modules/squish/image_compress_squish.cpp +++ b/modules/squish/image_compress_squish.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/squish/image_compress_squish.h b/modules/squish/image_compress_squish.h index 11b9e1c833..301d30fcf1 100644 --- a/modules/squish/image_compress_squish.h +++ b/modules/squish/image_compress_squish.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/squish/register_types.cpp b/modules/squish/register_types.cpp index ad28aff058..451e9d8e93 100644 --- a/modules/squish/register_types.cpp +++ b/modules/squish/register_types.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/squish/register_types.h b/modules/squish/register_types.h index ab56c54d4a..0f87d64333 100644 --- a/modules/squish/register_types.h +++ b/modules/squish/register_types.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp b/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp index 346833ab9c..6732078efc 100644 --- a/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp +++ b/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -47,7 +47,7 @@ void AudioStreamPlaybackOGGVorbis::_mix_internal(AudioFrame *p_buffer, int p_fra int mixed = stb_vorbis_get_samples_float_interleaved(ogg_stream, 2, buffer, todo * 2); if (vorbis_stream->channels == 1 && mixed > 0) { //mix mono to stereo - for (int i = start_buffer; i < mixed; i++) { + for (int i = start_buffer; i < start_buffer + mixed; i++) { p_buffer[i].r = p_buffer[i].l; } } @@ -124,7 +124,10 @@ AudioStreamPlaybackOGGVorbis::~AudioStreamPlaybackOGGVorbis() { Ref<AudioStreamPlayback> AudioStreamOGGVorbis::instance_playback() { Ref<AudioStreamPlaybackOGGVorbis> ovs; - ERR_FAIL_COND_V(data == nullptr, ovs); + ERR_FAIL_COND_V_MSG(data == nullptr, ovs, + "This AudioStreamOGGVorbis does not have an audio file assigned " + "to it. AudioStreamOGGVorbis should not be created from the " + "inspector or with `.new()`. Instead, load an audio file."); ovs.instance(); ovs->vorbis_stream = Ref<AudioStreamOGGVorbis>(this); @@ -260,16 +263,7 @@ void AudioStreamOGGVorbis::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "loop_offset"), "set_loop_offset", "get_loop_offset"); } -AudioStreamOGGVorbis::AudioStreamOGGVorbis() { - data = nullptr; - data_len = 0; - length = 0; - sample_rate = 1; - channels = 1; - loop_offset = 0; - decode_mem_size = 0; - loop = false; -} +AudioStreamOGGVorbis::AudioStreamOGGVorbis() {} AudioStreamOGGVorbis::~AudioStreamOGGVorbis() { clear_data(); diff --git a/modules/stb_vorbis/audio_stream_ogg_vorbis.h b/modules/stb_vorbis/audio_stream_ogg_vorbis.h index 5070f2a078..2bd70a2722 100644 --- a/modules/stb_vorbis/audio_stream_ogg_vorbis.h +++ b/modules/stb_vorbis/audio_stream_ogg_vorbis.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -41,11 +41,11 @@ class AudioStreamOGGVorbis; class AudioStreamPlaybackOGGVorbis : public AudioStreamPlaybackResampled { GDCLASS(AudioStreamPlaybackOGGVorbis, AudioStreamPlaybackResampled); - stb_vorbis *ogg_stream; + stb_vorbis *ogg_stream = nullptr; stb_vorbis_alloc ogg_alloc; - uint32_t frames_mixed; - bool active; - int loops; + uint32_t frames_mixed = 0; + bool active = false; + int loops = 0; friend class AudioStreamOGGVorbis; @@ -76,15 +76,15 @@ class AudioStreamOGGVorbis : public AudioStream { friend class AudioStreamPlaybackOGGVorbis; - void *data; - uint32_t data_len; + void *data = nullptr; + uint32_t data_len = 0; - int decode_mem_size; - float sample_rate; - int channels; - float length; - bool loop; - float loop_offset; + int decode_mem_size = 0; + float sample_rate = 1.0; + int channels = 1; + float length = 0.0; + bool loop = false; + float loop_offset = 0.0; void clear_data(); protected: diff --git a/modules/stb_vorbis/register_types.cpp b/modules/stb_vorbis/register_types.cpp index 13c26fc8cc..6f7eb53bc8 100644 --- a/modules/stb_vorbis/register_types.cpp +++ b/modules/stb_vorbis/register_types.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/stb_vorbis/register_types.h b/modules/stb_vorbis/register_types.h index f5a1dd31bc..d36d87606c 100644 --- a/modules/stb_vorbis/register_types.h +++ b/modules/stb_vorbis/register_types.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/stb_vorbis/resource_importer_ogg_vorbis.cpp b/modules/stb_vorbis/resource_importer_ogg_vorbis.cpp index d68d050d34..ec1c30783a 100644 --- a/modules/stb_vorbis/resource_importer_ogg_vorbis.cpp +++ b/modules/stb_vorbis/resource_importer_ogg_vorbis.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/stb_vorbis/resource_importer_ogg_vorbis.h b/modules/stb_vorbis/resource_importer_ogg_vorbis.h index 47f0039328..60fe3381fb 100644 --- a/modules/stb_vorbis/resource_importer_ogg_vorbis.h +++ b/modules/stb_vorbis/resource_importer_ogg_vorbis.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/svg/image_loader_svg.cpp b/modules/svg/image_loader_svg.cpp index 8ca4452ac9..6ce3e4b4b3 100644 --- a/modules/svg/image_loader_svg.cpp +++ b/modules/svg/image_loader_svg.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/svg/image_loader_svg.h b/modules/svg/image_loader_svg.h index 8e478a40ce..e64175b172 100644 --- a/modules/svg/image_loader_svg.h +++ b/modules/svg/image_loader_svg.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/svg/register_types.cpp b/modules/svg/register_types.cpp index 9fbefd2cfe..1a611184d2 100644 --- a/modules/svg/register_types.cpp +++ b/modules/svg/register_types.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/svg/register_types.h b/modules/svg/register_types.h index a3d914e0cb..106ac9056f 100644 --- a/modules/svg/register_types.h +++ b/modules/svg/register_types.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/text_server_adv/bitmap_font_adv.cpp b/modules/text_server_adv/bitmap_font_adv.cpp index b905b7dabb..df771301e6 100644 --- a/modules/text_server_adv/bitmap_font_adv.cpp +++ b/modules/text_server_adv/bitmap_font_adv.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -36,7 +36,7 @@ struct hb_bmp_font_t { BitmapFontDataAdvanced *face = nullptr; - float font_size = 0; + float font_size = 0.0; bool unref = false; /* Whether to destroy bm_face when done. */ }; @@ -340,7 +340,7 @@ Error BitmapFontDataAdvanced::load_from_file(const String &p_filename, int p_bas char_map[idx] = c; } else if (type == "kerning") { KerningPairKey kpk; - float k = 0; + float k = 0.0; if (keys.has("first")) { kpk.A = keys["first"].to_int(); } @@ -540,7 +540,7 @@ Vector2 BitmapFontDataAdvanced::draw_glyph(RID p_canvas, int p_size, const Vecto ERR_FAIL_COND_V(c == nullptr, Vector2()); ERR_FAIL_COND_V(c->texture_idx < -1 || c->texture_idx >= textures.size(), Vector2()); if (c->texture_idx != -1) { - Point2 cpos = p_pos; + Point2i cpos = p_pos; cpos += c->align * (float(p_size) / float(base_size)); cpos.y -= ascent * (float(p_size) / float(base_size)); if (RenderingServer::get_singleton() != nullptr) { diff --git a/modules/text_server_adv/bitmap_font_adv.h b/modules/text_server_adv/bitmap_font_adv.h index cb1a726f76..c314f1b087 100644 --- a/modules/text_server_adv/bitmap_font_adv.h +++ b/modules/text_server_adv/bitmap_font_adv.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/text_server_adv/dynamic_font_adv.cpp b/modules/text_server_adv/dynamic_font_adv.cpp index 99d78a5299..fd47f58480 100644 --- a/modules/text_server_adv/dynamic_font_adv.cpp +++ b/modules/text_server_adv/dynamic_font_adv.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -55,7 +55,7 @@ DynamicFontDataAdvanced::DataAtSize *DynamicFontDataAdvanced::get_data_for_size( fds = E->get(); } else { if (font_mem == nullptr && font_path != String()) { - if (!font_mem_cache.empty()) { + if (!font_mem_cache.is_empty()) { font_mem = font_mem_cache.ptr(); font_mem_size = font_mem_cache.size(); } else { @@ -124,8 +124,8 @@ DynamicFontDataAdvanced::DataAtSize *DynamicFontDataAdvanced::get_data_for_size( fds->size = p_size; fds->ascent = (fds->face->size->metrics.ascender / 64.0) / oversampling * fds->scale_color_font; fds->descent = (-fds->face->size->metrics.descender / 64.0) / oversampling * fds->scale_color_font; - fds->underline_position = -fds->face->underline_position / 64.0 / oversampling * fds->scale_color_font; - fds->underline_thickness = fds->face->underline_thickness / 64.0 / oversampling * fds->scale_color_font; + fds->underline_position = (-FT_MulFix(fds->face->underline_position, fds->face->size->metrics.y_scale) / 64.0) / oversampling * fds->scale_color_font; + fds->underline_thickness = (FT_MulFix(fds->face->underline_thickness, fds->face->size->metrics.y_scale) / 64.0) / oversampling * fds->scale_color_font; //Load os2 TTF pable fds->os2 = (TT_OS2 *)FT_Get_Sfnt_Table(fds->face, FT_SFNT_OS2); @@ -171,7 +171,7 @@ DynamicFontDataAdvanced::DataAtSize *DynamicFontDataAdvanced::get_data_for_size( } FT_Set_Var_Design_Coordinates(fds->face, coords.size(), coords.ptrw()); - hb_font_set_variations(fds->hb_handle, hb_vars.empty() ? nullptr : &hb_vars[0], hb_vars.size()); + hb_font_set_variations(fds->hb_handle, hb_vars.is_empty() ? nullptr : &hb_vars[0], hb_vars.size()); FT_Done_MM_Var(library, amaster); } @@ -946,7 +946,7 @@ Vector2 DynamicFontDataAdvanced::draw_glyph(RID p_canvas, int p_size, const Vect ERR_FAIL_COND_V(ch.texture_idx < -1 || ch.texture_idx >= fds->textures.size(), Vector2()); if (ch.texture_idx != -1) { - Point2 cpos = p_pos; + Point2i cpos = p_pos; cpos += ch.align; Color modulate = p_color; if (FT_HAS_COLOR(fds->face)) { @@ -977,7 +977,7 @@ Vector2 DynamicFontDataAdvanced::draw_glyph_outline(RID p_canvas, int p_size, in ERR_FAIL_COND_V(ch.texture_idx < -1 || ch.texture_idx >= fds->textures.size(), Vector2()); if (ch.texture_idx != -1) { - Point2 cpos = p_pos; + Point2i cpos = p_pos; cpos += ch.align; Color modulate = p_color; if (FT_HAS_COLOR(fds->face)) { diff --git a/modules/text_server_adv/dynamic_font_adv.h b/modules/text_server_adv/dynamic_font_adv.h index f9d6735c32..cd538cb8e1 100644 --- a/modules/text_server_adv/dynamic_font_adv.h +++ b/modules/text_server_adv/dynamic_font_adv.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -74,14 +74,11 @@ private: uint32_t size : 16; uint32_t outline_size : 16; }; - uint32_t key; + uint32_t key = 0; }; bool operator<(CacheID right) const { return key < right.key; } - CacheID() { - key = 0; - } }; struct DataAtSize { @@ -91,10 +88,10 @@ private: int size = 0; float scale_color_font = 1.f; - float ascent = 0; - float descent = 0; - float underline_position = 0; - float underline_thickness = 0; + float ascent = 0.0; + float descent = 0.0; + float underline_position = 0.0; + float underline_thickness = 0.0; Vector<CharTexture> textures; HashMap<uint32_t, Character> glyph_map; diff --git a/modules/text_server_adv/font_adv.h b/modules/text_server_adv/font_adv.h index 88b327f57b..2bb09c11ad 100644 --- a/modules/text_server_adv/font_adv.h +++ b/modules/text_server_adv/font_adv.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -39,6 +39,8 @@ struct FontDataAdvanced { Map<String, bool> lang_support_overrides; Map<String, bool> script_support_overrides; bool valid = false; + int spacing_space = 0; + int spacing_glyph = 0; virtual void clear_cache() = 0; @@ -58,6 +60,18 @@ struct FontDataAdvanced { virtual float get_underline_position(int p_size) const = 0; virtual float get_underline_thickness(int p_size) const = 0; + virtual int get_spacing_space() const { return spacing_space; }; + virtual void set_spacing_space(int p_value) { + spacing_space = p_value; + clear_cache(); + }; + + virtual int get_spacing_glyph() const { return spacing_glyph; }; + virtual void set_spacing_glyph(int p_value) { + spacing_glyph = p_value; + clear_cache(); + }; + virtual void set_antialiased(bool p_antialiased) = 0; virtual bool get_antialiased() const = 0; diff --git a/modules/text_server_adv/icu_data/icudata_stub.cpp b/modules/text_server_adv/icu_data/icudata_stub.cpp index 13f0ac0c50..187001f33a 100644 --- a/modules/text_server_adv/icu_data/icudata_stub.cpp +++ b/modules/text_server_adv/icu_data/icudata_stub.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/text_server_adv/register_types.cpp b/modules/text_server_adv/register_types.cpp index 68117e0380..abefa83b9b 100644 --- a/modules/text_server_adv/register_types.cpp +++ b/modules/text_server_adv/register_types.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/text_server_adv/register_types.h b/modules/text_server_adv/register_types.h index 8319ddfd5d..ddd1190f40 100644 --- a/modules/text_server_adv/register_types.h +++ b/modules/text_server_adv/register_types.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/text_server_adv/script_iterator.cpp b/modules/text_server_adv/script_iterator.cpp index 60a617c3a7..8f23bb9e02 100644 --- a/modules/text_server_adv/script_iterator.cpp +++ b/modules/text_server_adv/script_iterator.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/text_server_adv/script_iterator.h b/modules/text_server_adv/script_iterator.h index 4523aa2767..896a0e5c15 100644 --- a/modules/text_server_adv/script_iterator.h +++ b/modules/text_server_adv/script_iterator.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -45,9 +45,9 @@ class ScriptIterator { public: struct ScriptRange { - int start; - int end; - hb_script_t script; + int start = 0; + int end = 0; + hb_script_t script = HB_SCRIPT_COMMON; }; Vector<ScriptRange> script_ranges; diff --git a/modules/text_server_adv/text_server_adv.cpp b/modules/text_server_adv/text_server_adv.cpp index 3a706286e5..1e015db210 100644 --- a/modules/text_server_adv/text_server_adv.cpp +++ b/modules/text_server_adv/text_server_adv.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -171,7 +171,7 @@ bool TextServerAdvanced::load_support_data(const String &p_filename) { } #else if (icu_data == nullptr) { - String filename = (p_filename.empty()) ? String("res://") + _MKSTR(ICU_DATA_NAME) : p_filename; + String filename = (p_filename.is_empty()) ? String("res://") + _MKSTR(ICU_DATA_NAME) : p_filename; FileAccess *f = FileAccess::open(filename, FileAccess::READ); if (!f) { @@ -601,6 +601,34 @@ float TextServerAdvanced::font_get_underline_thickness(RID p_font, int p_size) c return fd->get_underline_thickness(p_size); } +int TextServerAdvanced::font_get_spacing_space(RID p_font) const { + _THREAD_SAFE_METHOD_ + const FontDataAdvanced *fd = font_owner.getornull(p_font); + ERR_FAIL_COND_V(!fd, 0); + return fd->get_spacing_space(); +} + +void TextServerAdvanced::font_set_spacing_space(RID p_font, int p_value) { + _THREAD_SAFE_METHOD_ + FontDataAdvanced *fd = font_owner.getornull(p_font); + ERR_FAIL_COND(!fd); + fd->set_spacing_space(p_value); +} + +int TextServerAdvanced::font_get_spacing_glyph(RID p_font) const { + _THREAD_SAFE_METHOD_ + const FontDataAdvanced *fd = font_owner.getornull(p_font); + ERR_FAIL_COND_V(!fd, 0); + return fd->get_spacing_glyph(); +} + +void TextServerAdvanced::font_set_spacing_glyph(RID p_font, int p_value) { + _THREAD_SAFE_METHOD_ + FontDataAdvanced *fd = font_owner.getornull(p_font); + ERR_FAIL_COND(!fd); + fd->set_spacing_glyph(p_value); +} + void TextServerAdvanced::font_set_antialiased(RID p_font, bool p_antialiased) { _THREAD_SAFE_METHOD_ FontDataAdvanced *fd = font_owner.getornull(p_font); @@ -1061,7 +1089,7 @@ bool TextServerAdvanced::shaped_text_add_string(RID p_shaped, const String &p_te ERR_FAIL_COND_V(!sd, false); ERR_FAIL_COND_V(p_size <= 0, false); - if (p_text.empty()) { + if (p_text.is_empty()) { return true; } @@ -1602,11 +1630,18 @@ bool TextServerAdvanced::shaped_text_update_breaks(RID p_shaped) { HashMap<int, bool> breaks; UErrorCode err = U_ZERO_ERROR; - for (int i = 0; i < sd->spans.size(); i++) { - UBreakIterator *bi = ubrk_open(UBRK_LINE, sd->spans[i].language.ascii().get_data(), data + _convert_pos_inv(sd, sd->spans[i].start), _convert_pos_inv(sd, sd->spans[i].end - sd->spans[i].start), &err); + int i = 0; + while (i < sd->spans.size()) { + String language = sd->spans[i].language; + int r_start = sd->spans[i].start; + while (i + 1 < sd->spans.size() && language == sd->spans[i + 1].language) { + i++; + } + int r_end = sd->spans[i].end; + UBreakIterator *bi = ubrk_open(UBRK_LINE, language.ascii().get_data(), data + _convert_pos_inv(sd, r_start), _convert_pos_inv(sd, r_end - r_start), &err); if (U_FAILURE(err)) { //No data loaded - use fallback. - for (int j = sd->spans[i].start; j < sd->spans[i].end; j++) { + for (int j = r_start; j < r_end; j++) { char32_t c = sd->text[j - sd->start]; if (is_whitespace(c)) { breaks[j] = false; @@ -1617,8 +1652,8 @@ bool TextServerAdvanced::shaped_text_update_breaks(RID p_shaped) { } } else { while (ubrk_next(bi) != UBRK_DONE) { - int pos = _convert_pos(sd, ubrk_current(bi)) + sd->spans[i].start - 1; - if (pos != sd->spans[i].end) { + int pos = _convert_pos(sd, ubrk_current(bi)) + r_start - 1; + if (pos != r_end) { if ((ubrk_getRuleStatus(bi) >= UBRK_LINE_HARD) && (ubrk_getRuleStatus(bi) < UBRK_LINE_HARD_LIMIT)) { breaks[pos] = true; } else if ((ubrk_getRuleStatus(bi) >= UBRK_LINE_SOFT) && (ubrk_getRuleStatus(bi) < UBRK_LINE_SOFT_LIMIT)) { @@ -1628,6 +1663,7 @@ bool TextServerAdvanced::shaped_text_update_breaks(RID p_shaped) { } } ubrk_close(bi); + i++; } sd->sort_valid = false; @@ -1636,7 +1672,7 @@ bool TextServerAdvanced::shaped_text_update_breaks(RID p_shaped) { const char32_t *ch = sd->text.ptr(); Glyph *sd_glyphs = sd->glyphs.ptrw(); - for (int i = 0; i < sd_size; i++) { + for (i = 0; i < sd_size; i++) { if (sd_glyphs[i].count > 0) { char32_t c = ch[sd_glyphs[i].start - sd->start]; if (c == 0xfffc) { @@ -1984,7 +2020,7 @@ void TextServerAdvanced::_shape_run(ShapedTextDataAdvanced *p_sd, int32_t p_star ftrs.push_back(feature); } } - hb_shape(hb_font, p_sd->hb_buffer, ftrs.empty() ? nullptr : &ftrs[0], ftrs.size()); + hb_shape(hb_font, p_sd->hb_buffer, ftrs.is_empty() ? nullptr : &ftrs[0], ftrs.size()); unsigned int glyph_count = 0; hb_glyph_info_t *glyph_info = hb_buffer_get_glyph_infos(p_sd->hb_buffer, &glyph_count); @@ -2041,6 +2077,11 @@ void TextServerAdvanced::_shape_run(ShapedTextDataAdvanced *p_sd, int32_t p_star gl.x_off = Math::round(glyph_pos[i].x_offset / (64.0 / fd->get_font_scale(fs))); gl.y_off = -Math::round(glyph_pos[i].y_offset / (64.0 / fd->get_font_scale(fs))); } + if (fd->get_spacing_space() && is_whitespace(p_sd->text[glyph_info[i].cluster])) { + gl.advance += fd->get_spacing_space(); + } else { + gl.advance += fd->get_spacing_glyph(); + } if (p_sd->preserve_control) { last_cluster_valid = last_cluster_valid && ((glyph_info[i].codepoint != 0) || is_whitespace(p_sd->text[glyph_info[i].cluster]) || is_linebreak(p_sd->text[glyph_info[i].cluster])); @@ -2131,7 +2172,7 @@ bool TextServerAdvanced::shaped_text_shape(RID p_shaped) { sd->script_iter = memnew(ScriptIterator(sd->text, 0, sd->text.length())); } - if (sd->bidi_override.empty()) { + if (sd->bidi_override.is_empty()) { sd->bidi_override.push_back(Vector2i(0, sd->end)); } diff --git a/modules/text_server_adv/text_server_adv.h b/modules/text_server_adv/text_server_adv.h index 8c26554158..c5ebe61bc3 100644 --- a/modules/text_server_adv/text_server_adv.h +++ b/modules/text_server_adv/text_server_adv.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -134,6 +134,12 @@ public: virtual float font_get_underline_position(RID p_font, int p_size) const override; virtual float font_get_underline_thickness(RID p_font, int p_size) const override; + virtual int font_get_spacing_space(RID p_font) const override; + virtual void font_set_spacing_space(RID p_font, int p_value) override; + + virtual int font_get_spacing_glyph(RID p_font) const override; + virtual void font_set_spacing_glyph(RID p_font, int p_value) override; + virtual void font_set_antialiased(RID p_font, bool p_antialiased) override; virtual bool font_get_antialiased(RID p_font) const override; diff --git a/modules/text_server_fb/bitmap_font_fb.cpp b/modules/text_server_fb/bitmap_font_fb.cpp index 99cbccb69a..c9a9cc6eba 100644 --- a/modules/text_server_fb/bitmap_font_fb.cpp +++ b/modules/text_server_fb/bitmap_font_fb.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -148,7 +148,7 @@ Error BitmapFontDataFallback::load_from_file(const String &p_filename, int p_bas char_map[idx] = c; } else if (type == "kerning") { KerningPairKey kpk; - float k = 0; + float k = 0.0; if (keys.has("first")) { kpk.A = keys["first"].to_int(); } @@ -321,7 +321,7 @@ Vector2 BitmapFontDataFallback::draw_glyph(RID p_canvas, int p_size, const Vecto ERR_FAIL_COND_V(c == nullptr, Vector2()); ERR_FAIL_COND_V(c->texture_idx < -1 || c->texture_idx >= textures.size(), Vector2()); if (c->texture_idx != -1) { - Point2 cpos = p_pos; + Point2i cpos = p_pos; cpos += c->align * (float(p_size) / float(base_size)); cpos.y -= ascent * (float(p_size) / float(base_size)); diff --git a/modules/text_server_fb/bitmap_font_fb.h b/modules/text_server_fb/bitmap_font_fb.h index 73e6d8f791..33401b85fa 100644 --- a/modules/text_server_fb/bitmap_font_fb.h +++ b/modules/text_server_fb/bitmap_font_fb.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/text_server_fb/dynamic_font_fb.cpp b/modules/text_server_fb/dynamic_font_fb.cpp index ca9e5b580b..6836d2b9e2 100644 --- a/modules/text_server_fb/dynamic_font_fb.cpp +++ b/modules/text_server_fb/dynamic_font_fb.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -54,7 +54,7 @@ DynamicFontDataFallback::DataAtSize *DynamicFontDataFallback::get_data_for_size( fds = E->get(); } else { if (font_mem == nullptr && font_path != String()) { - if (!font_mem_cache.empty()) { + if (!font_mem_cache.is_empty()) { font_mem = font_mem_cache.ptr(); font_mem_size = font_mem_cache.size(); } else { @@ -124,8 +124,9 @@ DynamicFontDataFallback::DataAtSize *DynamicFontDataFallback::get_data_for_size( fds->size = p_size; fds->ascent = (fds->face->size->metrics.ascender / 64.0) / oversampling * fds->scale_color_font; fds->descent = (-fds->face->size->metrics.descender / 64.0) / oversampling * fds->scale_color_font; - fds->underline_position = -fds->face->underline_position / 64.0 / oversampling * fds->scale_color_font; - fds->underline_thickness = fds->face->underline_thickness / 64.0 / oversampling * fds->scale_color_font; + fds->underline_position = (-FT_MulFix(fds->face->underline_position, fds->face->size->metrics.y_scale) / 64.0) / oversampling * fds->scale_color_font; + fds->underline_thickness = (FT_MulFix(fds->face->underline_thickness, fds->face->size->metrics.y_scale) / 64.0) / oversampling * fds->scale_color_font; + if (p_outline_size != 0) { size_cache_outline[id] = fds; } else { @@ -626,7 +627,7 @@ Vector2 DynamicFontDataFallback::draw_glyph(RID p_canvas, int p_size, const Vect ERR_FAIL_COND_V(ch.texture_idx < -1 || ch.texture_idx >= fds->textures.size(), Vector2()); if (ch.texture_idx != -1) { - Point2 cpos = p_pos; + Point2i cpos = p_pos; cpos += ch.align; Color modulate = p_color; @@ -658,7 +659,7 @@ Vector2 DynamicFontDataFallback::draw_glyph_outline(RID p_canvas, int p_size, in ERR_FAIL_COND_V(ch.texture_idx < -1 || ch.texture_idx >= fds->textures.size(), Vector2()); if (ch.texture_idx != -1) { - Point2 cpos = p_pos; + Point2i cpos = p_pos; cpos += ch.align; Color modulate = p_color; diff --git a/modules/text_server_fb/dynamic_font_fb.h b/modules/text_server_fb/dynamic_font_fb.h index 6ac8cb52a8..81b18f6af3 100644 --- a/modules/text_server_fb/dynamic_font_fb.h +++ b/modules/text_server_fb/dynamic_font_fb.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -70,14 +70,11 @@ private: uint32_t size : 16; uint32_t outline_size : 16; }; - uint32_t key; + uint32_t key = 0; }; bool operator<(CacheID right) const { return key < right.key; } - CacheID() { - key = 0; - } }; struct DataAtSize { @@ -86,10 +83,10 @@ private: int size = 0; float scale_color_font = 1.f; - float ascent = 0; - float descent = 0; - float underline_position = 0; - float underline_thickness = 0; + float ascent = 0.0; + float descent = 0.0; + float underline_position = 0.0; + float underline_thickness = 0.0; Vector<CharTexture> textures; HashMap<char32_t, Character> char_map; diff --git a/modules/text_server_fb/font_fb.h b/modules/text_server_fb/font_fb.h index d2ce2661a1..7fccbe06b5 100644 --- a/modules/text_server_fb/font_fb.h +++ b/modules/text_server_fb/font_fb.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -37,6 +37,8 @@ struct FontDataFallback { Map<String, bool> lang_support_overrides; Map<String, bool> script_support_overrides; bool valid = false; + int spacing_space = 0; + int spacing_glyph = 0; virtual void clear_cache() = 0; @@ -50,6 +52,18 @@ struct FontDataFallback { virtual float get_underline_position(int p_size) const = 0; virtual float get_underline_thickness(int p_size) const = 0; + virtual int get_spacing_space() const { return spacing_space; }; + virtual void set_spacing_space(int p_value) { + spacing_space = p_value; + clear_cache(); + }; + + virtual int get_spacing_glyph() const { return spacing_glyph; }; + virtual void set_spacing_glyph(int p_value) { + spacing_glyph = p_value; + clear_cache(); + }; + virtual void set_antialiased(bool p_antialiased) = 0; virtual bool get_antialiased() const = 0; diff --git a/modules/text_server_fb/register_types.cpp b/modules/text_server_fb/register_types.cpp index ad4d2d47ab..87cbd2ac2c 100644 --- a/modules/text_server_fb/register_types.cpp +++ b/modules/text_server_fb/register_types.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/text_server_fb/register_types.h b/modules/text_server_fb/register_types.h index 58f8436c67..c854db92e5 100644 --- a/modules/text_server_fb/register_types.h +++ b/modules/text_server_fb/register_types.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/text_server_fb/text_server_fb.cpp b/modules/text_server_fb/text_server_fb.cpp index 675d0e5d4d..5cbe0f8277 100644 --- a/modules/text_server_fb/text_server_fb.cpp +++ b/modules/text_server_fb/text_server_fb.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -179,6 +179,34 @@ float TextServerFallback::font_get_underline_thickness(RID p_font, int p_size) c return fd->get_underline_thickness(p_size); } +int TextServerFallback::font_get_spacing_space(RID p_font) const { + _THREAD_SAFE_METHOD_ + const FontDataFallback *fd = font_owner.getornull(p_font); + ERR_FAIL_COND_V(!fd, 0); + return fd->get_spacing_space(); +} + +void TextServerFallback::font_set_spacing_space(RID p_font, int p_value) { + _THREAD_SAFE_METHOD_ + FontDataFallback *fd = font_owner.getornull(p_font); + ERR_FAIL_COND(!fd); + fd->set_spacing_space(p_value); +} + +int TextServerFallback::font_get_spacing_glyph(RID p_font) const { + _THREAD_SAFE_METHOD_ + const FontDataFallback *fd = font_owner.getornull(p_font); + ERR_FAIL_COND_V(!fd, 0); + return fd->get_spacing_glyph(); +} + +void TextServerFallback::font_set_spacing_glyph(RID p_font, int p_value) { + _THREAD_SAFE_METHOD_ + FontDataFallback *fd = font_owner.getornull(p_font); + ERR_FAIL_COND(!fd); + fd->set_spacing_glyph(p_value); +} + void TextServerFallback::font_set_antialiased(RID p_font, bool p_antialiased) { _THREAD_SAFE_METHOD_ FontDataFallback *fd = font_owner.getornull(p_font); @@ -550,7 +578,7 @@ bool TextServerFallback::shaped_text_add_string(RID p_shaped, const String &p_te ERR_FAIL_COND_V(!sd, false); ERR_FAIL_COND_V(p_size <= 0, false); - if (p_text.empty()) { + if (p_text.is_empty()) { return true; } @@ -573,7 +601,7 @@ bool TextServerFallback::shaped_text_add_string(RID p_shaped, const String &p_te span.fonts.push_back(p_fonts[i]); } } - ERR_FAIL_COND_V(span.fonts.empty(), false); + ERR_FAIL_COND_V(span.fonts.is_empty(), false); span.font_size = p_size; span.language = p_language; @@ -1184,6 +1212,11 @@ bool TextServerFallback::shaped_text_shape(RID p_shaped) { sd->descent = MAX(sd->descent, Math::round(fd->get_advance(gl.index, gl.font_size).x * 0.5)); } } + if (fd->get_spacing_space() && is_whitespace(sd->text[j])) { + gl.advance += fd->get_spacing_space(); + } else { + gl.advance += fd->get_spacing_glyph(); + } sd->upos = MAX(sd->upos, fd->get_underline_position(gl.font_size)); sd->uthk = MAX(sd->uthk, fd->get_underline_thickness(gl.font_size)); diff --git a/modules/text_server_fb/text_server_fb.h b/modules/text_server_fb/text_server_fb.h index 56bb1f7bf9..c14a444872 100644 --- a/modules/text_server_fb/text_server_fb.h +++ b/modules/text_server_fb/text_server_fb.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -89,6 +89,12 @@ public: virtual float font_get_underline_position(RID p_font, int p_size) const override; virtual float font_get_underline_thickness(RID p_font, int p_size) const override; + virtual int font_get_spacing_space(RID p_font) const override; + virtual void font_set_spacing_space(RID p_font, int p_value) override; + + virtual int font_get_spacing_glyph(RID p_font) const override; + virtual void font_set_spacing_glyph(RID p_font, int p_value) override; + virtual void font_set_antialiased(RID p_font, bool p_antialiased) override; virtual bool font_get_antialiased(RID p_font) const override; diff --git a/modules/tga/image_loader_tga.cpp b/modules/tga/image_loader_tga.cpp index aa8b3122f4..ef53661557 100644 --- a/modules/tga/image_loader_tga.cpp +++ b/modules/tga/image_loader_tga.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -56,6 +56,10 @@ Error ImageLoaderTGA::decode_tga_rle(const uint8_t *p_compressed_buffer, size_t compressed_pos += 1; count = (c & 0x7f) + 1; + if (output_pos + count * p_pixel_size > output_pos) { + return ERR_PARSE_ERROR; + } + if (c & 0x80) { for (size_t i = 0; i < p_pixel_size; i++) { pixels_w[i] = p_compressed_buffer[compressed_pos]; @@ -79,7 +83,7 @@ Error ImageLoaderTGA::decode_tga_rle(const uint8_t *p_compressed_buffer, size_t return OK; } -Error ImageLoaderTGA::convert_to_image(Ref<Image> p_image, const uint8_t *p_buffer, const tga_header_s &p_header, const uint8_t *p_palette, const bool p_is_monochrome) { +Error ImageLoaderTGA::convert_to_image(Ref<Image> p_image, const uint8_t *p_buffer, const tga_header_s &p_header, const uint8_t *p_palette, const bool p_is_monochrome, size_t p_output_size) { #define TGA_PUT_PIXEL(r, g, b, a) \ int image_data_ofs = ((y * width) + x); \ image_data_w[image_data_ofs * 4 + 0] = r; \ @@ -130,6 +134,9 @@ Error ImageLoaderTGA::convert_to_image(Ref<Image> p_image, const uint8_t *p_buff if (p_is_monochrome) { while (y != y_end) { while (x != x_end) { + if (i > p_output_size) { + return ERR_PARSE_ERROR; + } uint8_t shade = p_buffer[i]; TGA_PUT_PIXEL(shade, shade, shade, 0xff) @@ -143,6 +150,9 @@ Error ImageLoaderTGA::convert_to_image(Ref<Image> p_image, const uint8_t *p_buff } else { while (y != y_end) { while (x != x_end) { + if (i > p_output_size) { + return ERR_PARSE_ERROR; + } uint8_t index = p_buffer[i]; uint8_t r = 0x00; uint8_t g = 0x00; @@ -171,6 +181,10 @@ Error ImageLoaderTGA::convert_to_image(Ref<Image> p_image, const uint8_t *p_buff } else if (p_header.pixel_depth == 24) { while (y != y_end) { while (x != x_end) { + if (i + 2 > p_output_size) { + return ERR_PARSE_ERROR; + } + uint8_t r = p_buffer[i + 2]; uint8_t g = p_buffer[i + 1]; uint8_t b = p_buffer[i + 0]; @@ -186,6 +200,10 @@ Error ImageLoaderTGA::convert_to_image(Ref<Image> p_image, const uint8_t *p_buff } else if (p_header.pixel_depth == 32) { while (y != y_end) { while (x != x_end) { + if (i + 3 > p_output_size) { + return ERR_PARSE_ERROR; + } + uint8_t a = p_buffer[i + 3]; uint8_t r = p_buffer[i + 2]; uint8_t g = p_buffer[i + 1]; @@ -279,7 +297,7 @@ Error ImageLoaderTGA::load_image(Ref<Image> p_image, FileAccess *f, bool p_force const uint8_t *src_image_r = src_image.ptr(); const size_t pixel_size = tga_header.pixel_depth >> 3; - const size_t buffer_size = (tga_header.image_width * tga_header.image_height) * pixel_size; + size_t buffer_size = (tga_header.image_width * tga_header.image_height) * pixel_size; Vector<uint8_t> uncompressed_buffer; uncompressed_buffer.resize(buffer_size); @@ -297,11 +315,12 @@ Error ImageLoaderTGA::load_image(Ref<Image> p_image, FileAccess *f, bool p_force } } else { buffer = src_image_r; + buffer_size = src_image_len; }; if (err == OK) { const uint8_t *palette_r = palette.ptr(); - err = convert_to_image(p_image, buffer, tga_header, palette_r, is_monochrome); + err = convert_to_image(p_image, buffer, tga_header, palette_r, is_monochrome, buffer_size); } } diff --git a/modules/tga/image_loader_tga.h b/modules/tga/image_loader_tga.h index 6b3d33e7ef..cb2ce07edd 100644 --- a/modules/tga/image_loader_tga.h +++ b/modules/tga/image_loader_tga.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -57,23 +57,23 @@ class ImageLoaderTGA : public ImageFormatLoader { }; struct tga_header_s { - uint8_t id_length; - uint8_t color_map_type; + uint8_t id_length = 0; + uint8_t color_map_type = 0; tga_type_e image_type; - uint16_t first_color_entry; - uint16_t color_map_length; - uint8_t color_map_depth; + uint16_t first_color_entry = 0; + uint16_t color_map_length = 0; + uint8_t color_map_depth = 0; - uint16_t x_origin; - uint16_t y_origin; - uint16_t image_width; - uint16_t image_height; - uint8_t pixel_depth; - uint8_t image_descriptor; + uint16_t x_origin = 0; + uint16_t y_origin = 0; + uint16_t image_width = 0; + uint16_t image_height = 0; + uint8_t pixel_depth = 0; + uint8_t image_descriptor = 0; }; static Error decode_tga_rle(const uint8_t *p_compressed_buffer, size_t p_pixel_size, uint8_t *p_uncompressed_buffer, size_t p_output_size); - static Error convert_to_image(Ref<Image> p_image, const uint8_t *p_buffer, const tga_header_s &p_header, const uint8_t *p_palette, const bool p_is_monochrome); + static Error convert_to_image(Ref<Image> p_image, const uint8_t *p_buffer, const tga_header_s &p_header, const uint8_t *p_palette, const bool p_is_monochrome, size_t p_output_size); public: virtual Error load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear, float p_scale); diff --git a/modules/tga/register_types.cpp b/modules/tga/register_types.cpp index 320f748083..9e5fe124ef 100644 --- a/modules/tga/register_types.cpp +++ b/modules/tga/register_types.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/tga/register_types.h b/modules/tga/register_types.h index 94a77d295e..0dcd750250 100644 --- a/modules/tga/register_types.h +++ b/modules/tga/register_types.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/theora/register_types.cpp b/modules/theora/register_types.cpp index 0676cab5c5..0218b8c7a4 100644 --- a/modules/theora/register_types.cpp +++ b/modules/theora/register_types.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/theora/register_types.h b/modules/theora/register_types.h index 4f0670b2c7..654d70e417 100644 --- a/modules/theora/register_types.h +++ b/modules/theora/register_types.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/theora/video_stream_theora.cpp b/modules/theora/video_stream_theora.cpp index 4f33f58ed1..c5f6dc0d99 100644 --- a/modules/theora/video_stream_theora.cpp +++ b/modules/theora/video_stream_theora.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -140,9 +140,7 @@ void VideoStreamPlaybackTheora::clear() { #ifdef THEORA_USE_THREAD_STREAMING thread_exit = true; thread_sem->post(); //just in case - Thread::wait_to_finish(thread); - memdelete(thread); - thread = nullptr; + thread.wait_to_finish(); ring_buffer.clear(); #endif @@ -181,7 +179,7 @@ void VideoStreamPlaybackTheora::set_file(const String &p_file) { int read = file->get_buffer(read_buffer.ptr(), to_read); ring_buffer.write(read_buffer.ptr(), read); - thread = Thread::create(_streaming_thread, this); + thread.start(_streaming_thread, this); #endif @@ -556,7 +554,7 @@ void VideoStreamPlaybackTheora::play() { } playing = true; - delay_compensation = ProjectSettings::get_singleton()->get("audio/video_delay_compensation_ms"); + delay_compensation = ProjectSettings::get_singleton()->get("audio/video/video_delay_compensation_ms"); delay_compensation /= 1000.0; }; @@ -647,31 +645,13 @@ void VideoStreamPlaybackTheora::_streaming_thread(void *ud) { #endif VideoStreamPlaybackTheora::VideoStreamPlaybackTheora() { - file = nullptr; - theora_p = 0; - vorbis_p = 0; - videobuf_ready = 0; - playing = false; - frames_pending = 0; - videobuf_time = 0; - paused = false; - - buffering = false; texture = Ref<ImageTexture>(memnew(ImageTexture)); - mix_callback = nullptr; - mix_udata = nullptr; - audio_track = 0; - delay_compensation = 0; - audio_frames_wrote = 0; #ifdef THEORA_USE_THREAD_STREAMING int rb_power = nearest_shift(RB_SIZE_KB * 1024); ring_buffer.resize(rb_power); read_buffer.resize(RB_SIZE_KB * 1024); thread_sem = Semaphore::create(); - thread = nullptr; - thread_exit = false; - thread_eof = false; #endif }; @@ -697,7 +677,7 @@ void VideoStreamTheora::_bind_methods() { //////////// -RES ResourceFormatLoaderTheora::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, bool p_no_cache) { +RES ResourceFormatLoaderTheora::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, CacheMode p_cache_mode) { FileAccess *f = FileAccess::open(p_path, FileAccess::READ); if (!f) { if (r_error) { diff --git a/modules/theora/video_stream_theora.h b/modules/theora/video_stream_theora.h index 867f464038..2685a8a013 100644 --- a/modules/theora/video_stream_theora.h +++ b/modules/theora/video_stream_theora.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -36,6 +36,7 @@ #include "core/os/semaphore.h" #include "core/os/thread.h" #include "core/templates/ring_buffer.h" +#include "core/templates/safe_refcount.h" #include "scene/resources/video_stream.h" #include "servers/audio_server.h" @@ -52,12 +53,12 @@ class VideoStreamPlaybackTheora : public VideoStreamPlayback { }; //Image frames[MAX_FRAMES]; - Image::Format format; + Image::Format format = Image::Format::FORMAT_L8; Vector<uint8_t> frame_data; - int frames_pending; - FileAccess *file; + int frames_pending = 0; + FileAccess *file = nullptr; String file_name; - int audio_frames_wrote; + int audio_frames_wrote = 0; Point2i size; int buffer_data(); @@ -65,8 +66,8 @@ class VideoStreamPlaybackTheora : public VideoStreamPlayback { void video_write(); float get_time() const; - bool theora_eos; - bool vorbis_eos; + bool theora_eos = false; + bool vorbis_eos = false; ogg_sync_state oy; ogg_page og; @@ -74,33 +75,33 @@ class VideoStreamPlaybackTheora : public VideoStreamPlayback { ogg_stream_state to; th_info ti; th_comment tc; - th_dec_ctx *td; + th_dec_ctx *td = nullptr; vorbis_info vi; vorbis_dsp_state vd; vorbis_block vb; vorbis_comment vc; th_pixel_fmt px_fmt; - double videobuf_time; - int pp_inc; + double videobuf_time = 0; + int pp_inc = 0; - int theora_p; - int vorbis_p; - int pp_level_max; - int pp_level; - int videobuf_ready; + int theora_p = 0; + int vorbis_p = 0; + int pp_level_max = 0; + int pp_level = 0; + int videobuf_ready = 0; - bool playing; - bool buffering; + bool playing = false; + bool buffering = false; - double last_update_time; - double time; - double delay_compensation; + double last_update_time = 0; + double time = 0; + double delay_compensation = 0; Ref<ImageTexture> texture; AudioMixCallback mix_callback; - void *mix_udata; - bool paused; + void *mix_udata = nullptr; + bool paused = false; #ifdef THEORA_USE_THREAD_STREAMING @@ -110,16 +111,16 @@ class VideoStreamPlaybackTheora : public VideoStreamPlayback { RingBuffer<uint8_t> ring_buffer; Vector<uint8_t> read_buffer; - bool thread_eof; + bool thread_eof = false; Semaphore *thread_sem; - Thread *thread; - volatile bool thread_exit; + Thread thread; + SafeFlag thread_exit; static void _streaming_thread(void *ud); #endif - int audio_track; + int audio_track = 0; protected: void clear(); @@ -185,7 +186,7 @@ public: class ResourceFormatLoaderTheora : public ResourceFormatLoader { public: - virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr, bool p_no_cache = false); + virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr, CacheMode p_cache_mode = CACHE_MODE_REUSE); virtual void get_recognized_extensions(List<String> *p_extensions) const; virtual bool handles_type(const String &p_type) const; virtual String get_resource_type(const String &p_path) const; diff --git a/modules/tinyexr/image_loader_tinyexr.cpp b/modules/tinyexr/image_loader_tinyexr.cpp index 75dc16c39a..47214e6974 100644 --- a/modules/tinyexr/image_loader_tinyexr.cpp +++ b/modules/tinyexr/image_loader_tinyexr.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/tinyexr/image_loader_tinyexr.h b/modules/tinyexr/image_loader_tinyexr.h index ff040b0915..34390fccb0 100644 --- a/modules/tinyexr/image_loader_tinyexr.h +++ b/modules/tinyexr/image_loader_tinyexr.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/tinyexr/image_saver_tinyexr.cpp b/modules/tinyexr/image_saver_tinyexr.cpp index 420619bd5f..f747763248 100644 --- a/modules/tinyexr/image_saver_tinyexr.cpp +++ b/modules/tinyexr/image_saver_tinyexr.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/tinyexr/image_saver_tinyexr.h b/modules/tinyexr/image_saver_tinyexr.h index c7154bcfc7..e5060ef11c 100644 --- a/modules/tinyexr/image_saver_tinyexr.h +++ b/modules/tinyexr/image_saver_tinyexr.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/tinyexr/register_types.cpp b/modules/tinyexr/register_types.cpp index 9d0fb8729e..ecbabc4951 100644 --- a/modules/tinyexr/register_types.cpp +++ b/modules/tinyexr/register_types.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/tinyexr/register_types.h b/modules/tinyexr/register_types.h index 9739488312..e401f37066 100644 --- a/modules/tinyexr/register_types.h +++ b/modules/tinyexr/register_types.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/upnp/register_types.cpp b/modules/upnp/register_types.cpp index e66bc9d11a..a5ee39517f 100644 --- a/modules/upnp/register_types.cpp +++ b/modules/upnp/register_types.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/upnp/register_types.h b/modules/upnp/register_types.h index 0c71db9ffa..768031c4d9 100644 --- a/modules/upnp/register_types.h +++ b/modules/upnp/register_types.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/upnp/upnp.cpp b/modules/upnp/upnp.cpp index 988bf3017d..cff13251ce 100644 --- a/modules/upnp/upnp.cpp +++ b/modules/upnp/upnp.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -36,7 +36,7 @@ #include <stdlib.h> bool UPNP::is_common_device(const String &dev) const { - return dev.empty() || + return dev.is_empty() || dev.find("InternetGatewayDevice") >= 0 || dev.find("WANIPConnection") >= 0 || dev.find("WANPPPConnection") >= 0 || @@ -76,7 +76,7 @@ int UPNP::discover(int timeout, int ttl, const String &device_filter) { struct UPNPDev *dev = devlist; while (dev) { - if (device_filter.empty() || strstr(dev->st, device_filter.utf8().get_data())) { + if (device_filter.is_empty() || strstr(dev->st, device_filter.utf8().get_data())) { add_device_to_list(dev, devlist); } @@ -393,9 +393,6 @@ void UPNP::_bind_methods() { } UPNP::UPNP() { - discover_multicast_if = ""; - discover_local_port = 0; - discover_ipv6 = false; } UPNP::~UPNP() { diff --git a/modules/upnp/upnp.h b/modules/upnp/upnp.h index 81d770ec4c..a0cca96bc8 100644 --- a/modules/upnp/upnp.h +++ b/modules/upnp/upnp.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -41,9 +41,9 @@ class UPNP : public Reference { GDCLASS(UPNP, Reference); private: - String discover_multicast_if; - int discover_local_port; - bool discover_ipv6; + String discover_multicast_if = ""; + int discover_local_port = 0; + bool discover_ipv6 = false; Vector<Ref<UPNPDevice>> devices; diff --git a/modules/upnp/upnp_device.cpp b/modules/upnp/upnp_device.cpp index 40eb6106a0..ddc66d593c 100644 --- a/modules/upnp/upnp_device.cpp +++ b/modules/upnp/upnp_device.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -65,7 +65,7 @@ int UPNPDevice::add_port_mapping(int port, int port_internal, String desc, Strin itos(port).utf8().get_data(), itos(port_internal).utf8().get_data(), igd_our_addr.utf8().get_data(), - desc.empty() ? nullptr : desc.utf8().get_data(), + desc.is_empty() ? nullptr : desc.utf8().get_data(), proto.utf8().get_data(), nullptr, // Remote host, always nullptr as IGDs don't support it duration > 0 ? itos(duration).utf8().get_data() : nullptr); diff --git a/modules/upnp/upnp_device.h b/modules/upnp/upnp_device.h index 53d621c90a..126e761a56 100644 --- a/modules/upnp/upnp_device.h +++ b/modules/upnp/upnp_device.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/vhacd/register_types.cpp b/modules/vhacd/register_types.cpp index 40c5e47440..daad39bdfb 100644 --- a/modules/vhacd/register_types.cpp +++ b/modules/vhacd/register_types.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/vhacd/register_types.h b/modules/vhacd/register_types.h index d02a990901..24ad9378f4 100644 --- a/modules/vhacd/register_types.h +++ b/modules/vhacd/register_types.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/visual_script/doc_classes/VisualScript.xml b/modules/visual_script/doc_classes/VisualScript.xml index 088d84d2ec..5112ea43a7 100644 --- a/modules/visual_script/doc_classes/VisualScript.xml +++ b/modules/visual_script/doc_classes/VisualScript.xml @@ -26,23 +26,23 @@ </return> <argument index="0" name="name" type="StringName"> </argument> + <argument index="1" name="func_node_id" type="int"> + </argument> <description> - Add a function with the specified name to the VisualScript. + Add a function with the specified name to the VisualScript, and assign the root [VisualScriptFunction] node's id as [code]func_node_id[/code]. </description> </method> <method name="add_node"> <return type="void"> </return> - <argument index="0" name="func" type="StringName"> - </argument> - <argument index="1" name="id" type="int"> + <argument index="0" name="id" type="int"> </argument> - <argument index="2" name="node" type="VisualScriptNode"> + <argument index="1" name="node" type="VisualScriptNode"> </argument> - <argument index="3" name="position" type="Vector2" default="Vector2( 0, 0 )"> + <argument index="2" name="position" type="Vector2" default="Vector2( 0, 0 )"> </argument> <description> - Add a node to a function of the VisualScript. + Add a node to the VisualScript. </description> </method> <method name="add_variable"> @@ -157,15 +157,13 @@ <method name="data_connect"> <return type="void"> </return> - <argument index="0" name="func" type="StringName"> - </argument> - <argument index="1" name="from_node" type="int"> + <argument index="0" name="from_node" type="int"> </argument> - <argument index="2" name="from_port" type="int"> + <argument index="1" name="from_port" type="int"> </argument> - <argument index="3" name="to_node" type="int"> + <argument index="2" name="to_node" type="int"> </argument> - <argument index="4" name="to_port" type="int"> + <argument index="3" name="to_port" type="int"> </argument> <description> Connect two data ports. The value of [code]from_node[/code]'s [code]from_port[/code] would be fed into [code]to_node[/code]'s [code]to_port[/code]. @@ -174,15 +172,13 @@ <method name="data_disconnect"> <return type="void"> </return> - <argument index="0" name="func" type="StringName"> + <argument index="0" name="from_node" type="int"> </argument> - <argument index="1" name="from_node" type="int"> + <argument index="1" name="from_port" type="int"> </argument> - <argument index="2" name="from_port" type="int"> + <argument index="2" name="to_node" type="int"> </argument> - <argument index="3" name="to_node" type="int"> - </argument> - <argument index="4" name="to_port" type="int"> + <argument index="3" name="to_port" type="int"> </argument> <description> Disconnect two data ports previously connected with [method data_connect]. @@ -197,37 +193,31 @@ Returns the id of a function's entry point node. </description> </method> - <method name="get_function_scroll" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <description> - Returns the position of the center of the screen for a given function. - </description> - </method> <method name="get_node" qualifiers="const"> <return type="VisualScriptNode"> </return> - <argument index="0" name="func" type="StringName"> - </argument> - <argument index="1" name="id" type="int"> + <argument index="0" name="id" type="int"> </argument> <description> - Returns a node given its id and its function. + Returns a node given its id. </description> </method> <method name="get_node_position" qualifiers="const"> <return type="Vector2"> </return> - <argument index="0" name="func" type="StringName"> - </argument> - <argument index="1" name="id" type="int"> + <argument index="0" name="id" type="int"> </argument> <description> Returns a node's position in pixels. </description> </method> + <method name="get_scroll" qualifiers="const"> + <return type="Vector2"> + </return> + <description> + Returns the current position of the center of the screen. + </description> + </method> <method name="get_variable_default_value" qualifiers="const"> <return type="Variant"> </return> @@ -267,15 +257,13 @@ <method name="has_data_connection" qualifiers="const"> <return type="bool"> </return> - <argument index="0" name="func" type="StringName"> - </argument> - <argument index="1" name="from_node" type="int"> + <argument index="0" name="from_node" type="int"> </argument> - <argument index="2" name="from_port" type="int"> + <argument index="1" name="from_port" type="int"> </argument> - <argument index="3" name="to_node" type="int"> + <argument index="2" name="to_node" type="int"> </argument> - <argument index="4" name="to_port" type="int"> + <argument index="3" name="to_port" type="int"> </argument> <description> Returns whether the specified data ports are connected. @@ -293,9 +281,7 @@ <method name="has_node" qualifiers="const"> <return type="bool"> </return> - <argument index="0" name="func" type="StringName"> - </argument> - <argument index="1" name="id" type="int"> + <argument index="0" name="id" type="int"> </argument> <description> Returns whether a node exists with the given id. @@ -304,13 +290,11 @@ <method name="has_sequence_connection" qualifiers="const"> <return type="bool"> </return> - <argument index="0" name="func" type="StringName"> - </argument> - <argument index="1" name="from_node" type="int"> + <argument index="0" name="from_node" type="int"> </argument> - <argument index="2" name="from_output" type="int"> + <argument index="1" name="from_output" type="int"> </argument> - <argument index="3" name="to_node" type="int"> + <argument index="2" name="to_node" type="int"> </argument> <description> Returns whether the specified sequence ports are connected. @@ -346,12 +330,10 @@ <method name="remove_node"> <return type="void"> </return> - <argument index="0" name="func" type="StringName"> - </argument> - <argument index="1" name="id" type="int"> + <argument index="0" name="id" type="int"> </argument> <description> - Remove a specific node. + Remove the node with the specified id. </description> </method> <method name="remove_variable"> @@ -399,13 +381,11 @@ <method name="sequence_connect"> <return type="void"> </return> - <argument index="0" name="func" type="StringName"> + <argument index="0" name="from_node" type="int"> </argument> - <argument index="1" name="from_node" type="int"> + <argument index="1" name="from_output" type="int"> </argument> - <argument index="2" name="from_output" type="int"> - </argument> - <argument index="3" name="to_node" type="int"> + <argument index="2" name="to_node" type="int"> </argument> <description> Connect two sequence ports. The execution will flow from of [code]from_node[/code]'s [code]from_output[/code] into [code]to_node[/code]. @@ -415,29 +395,16 @@ <method name="sequence_disconnect"> <return type="void"> </return> - <argument index="0" name="func" type="StringName"> - </argument> - <argument index="1" name="from_node" type="int"> + <argument index="0" name="from_node" type="int"> </argument> - <argument index="2" name="from_output" type="int"> + <argument index="1" name="from_output" type="int"> </argument> - <argument index="3" name="to_node" type="int"> + <argument index="2" name="to_node" type="int"> </argument> <description> Disconnect two sequence ports previously connected with [method sequence_connect]. </description> </method> - <method name="set_function_scroll"> - <return type="void"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="ofs" type="Vector2"> - </argument> - <description> - Position the center of the screen for a function. - </description> - </method> <method name="set_instance_base_type"> <return type="void"> </return> @@ -450,14 +417,21 @@ <method name="set_node_position"> <return type="void"> </return> - <argument index="0" name="func" type="StringName"> + <argument index="0" name="id" type="int"> </argument> - <argument index="1" name="id" type="int"> + <argument index="1" name="position" type="Vector2"> </argument> - <argument index="2" name="position" type="Vector2"> + <description> + Set the node position in the VisualScript graph. + </description> + </method> + <method name="set_scroll"> + <return type="void"> + </return> + <argument index="0" name="ofs" type="Vector2"> </argument> <description> - Position a node on the screen. + Set the screen center to the given position. </description> </method> <method name="set_variable_default_value"> @@ -496,9 +470,7 @@ </methods> <signals> <signal name="node_ports_changed"> - <argument index="0" name="function" type="String"> - </argument> - <argument index="1" name="id" type="int"> + <argument index="0" name="id" type="int"> </argument> <description> Emitted when the ports of a node are changed. diff --git a/modules/visual_script/doc_classes/VisualScriptBuiltinFunc.xml b/modules/visual_script/doc_classes/VisualScriptBuiltinFunc.xml index 000fbd0140..219ffd01d3 100644 --- a/modules/visual_script/doc_classes/VisualScriptBuiltinFunc.xml +++ b/modules/visual_script/doc_classes/VisualScriptBuiltinFunc.xml @@ -92,7 +92,7 @@ <constant name="MATH_STEP_DECIMALS" value="24" enum="BuiltinFunc"> Return the number of digit places after the decimal that the first non-zero digit occurs. </constant> - <constant name="MATH_STEPIFY" value="25" enum="BuiltinFunc"> + <constant name="MATH_SNAPPED" value="25" enum="BuiltinFunc"> Return the input snapped to a given step. </constant> <constant name="MATH_LERP" value="26" enum="BuiltinFunc"> @@ -202,24 +202,20 @@ <constant name="BYTES_TO_VAR" value="62" enum="BuiltinFunc"> Deserialize a [Variant] from a [PackedByteArray] serialized using [constant VAR_TO_BYTES]. </constant> - <constant name="COLORN" value="63" enum="BuiltinFunc"> - Return the [Color] with the given name and alpha ranging from 0 to 1. - [b]Note:[/b] Names are defined in [code]color_names.inc[/code]. - </constant> - <constant name="MATH_SMOOTHSTEP" value="64" enum="BuiltinFunc"> + <constant name="MATH_SMOOTHSTEP" value="63" enum="BuiltinFunc"> 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="MATH_POSMOD" value="65" enum="BuiltinFunc"> + <constant name="MATH_POSMOD" value="64" enum="BuiltinFunc"> </constant> - <constant name="MATH_LERP_ANGLE" value="66" enum="BuiltinFunc"> + <constant name="MATH_LERP_ANGLE" value="65" enum="BuiltinFunc"> </constant> - <constant name="TEXT_ORD" value="67" enum="BuiltinFunc"> + <constant name="TEXT_ORD" value="66" enum="BuiltinFunc"> </constant> - <constant name="FUNC_MAX" value="68" enum="BuiltinFunc"> + <constant name="FUNC_MAX" value="67" enum="BuiltinFunc"> Represents the size of the [enum BuiltinFunc] enum. </constant> </constants> diff --git a/modules/visual_script/register_types.cpp b/modules/visual_script/register_types.cpp index 0172f29923..4c7b66e368 100644 --- a/modules/visual_script/register_types.cpp +++ b/modules/visual_script/register_types.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/visual_script/register_types.h b/modules/visual_script/register_types.h index c18c2930b1..b02a93ebc1 100644 --- a/modules/visual_script/register_types.h +++ b/modules/visual_script/register_types.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/visual_script/visual_script.cpp b/modules/visual_script/visual_script.cpp index f9ef184579..2517b17168 100644 --- a/modules/visual_script/visual_script.cpp +++ b/modules/visual_script/visual_script.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -36,7 +36,7 @@ #include "scene/main/node.h" #include "visual_script_nodes.h" -//used by editor, this is not really saved +// Used by editor, this is not really saved. void VisualScriptNode::set_breakpoint(bool p_breakpoint) { breakpoint = p_breakpoint; } @@ -55,8 +55,8 @@ void VisualScriptNode::set_default_input_value(int p_port, const Variant &p_valu default_input_values[p_port] = p_value; #ifdef TOOLS_ENABLED - for (Set<VisualScript *>::Element *E = scripts_used.front(); E; E = E->next()) { - E->get()->set_edited(true); + if (script_used.is_valid()) { + script_used->set_edited(true); } #endif } @@ -73,14 +73,14 @@ void VisualScriptNode::_set_default_input_values(Array p_values) { void VisualScriptNode::validate_input_default_values() { default_input_values.resize(MAX(default_input_values.size(), get_input_value_port_count())); //let it grow as big as possible, we don't want to lose values on resize - //actually validate on save + // Actually validate on save. for (int i = 0; i < get_input_value_port_count(); i++) { Variant::Type expected = get_input_value_port_info(i).type; if (expected == Variant::NIL || expected == default_input_values[i].get_type()) { continue; } else { - //not the same, reconvert + // Not the same, reconvert. Callable::CallError ce; Variant existing = default_input_values[i]; const Variant *existingp = &existing; @@ -94,7 +94,7 @@ void VisualScriptNode::validate_input_default_values() { } Array VisualScriptNode::_get_default_input_values() const { - //validate on save, since on load there is little info about this + // Validate on save, since on load there is little info about this. Array values = default_input_values; values.resize(get_input_value_port_count()); @@ -118,6 +118,8 @@ void VisualScriptNode::_bind_methods() { } VisualScriptNode::TypeGuess VisualScriptNode::guess_output_type(TypeGuess *p_inputs, int p_output) const { + ERR_FAIL_COND_V(get_output_value_port_count() <= p_output, TypeGuess()); + PropertyInfo pinfo = get_output_value_port_info(p_output); TypeGuess tg; @@ -131,15 +133,10 @@ VisualScriptNode::TypeGuess VisualScriptNode::guess_output_type(TypeGuess *p_inp } Ref<VisualScript> VisualScriptNode::get_visual_script() const { - if (scripts_used.size()) { - return Ref<VisualScript>(scripts_used.front()->get()); - } - - return Ref<VisualScript>(); + return script_used; } VisualScriptNode::VisualScriptNode() { - breakpoint = false; } //////////////// @@ -147,8 +144,6 @@ VisualScriptNode::VisualScriptNode() { ///////////////////// VisualScriptNodeInstance::VisualScriptNodeInstance() { - sequence_outputs = nullptr; - input_ports = nullptr; } VisualScriptNodeInstance::~VisualScriptNodeInstance() { @@ -165,13 +160,15 @@ VisualScriptNodeInstance::~VisualScriptNodeInstance() { } } -void VisualScript::add_function(const StringName &p_name) { +void VisualScript::add_function(const StringName &p_name, int p_func_node_id) { ERR_FAIL_COND(instances.size()); ERR_FAIL_COND(!String(p_name).is_valid_identifier()); ERR_FAIL_COND(functions.has(p_name)); + ERR_FAIL_COND(variables.has(p_name)); + ERR_FAIL_COND(custom_signals.has(p_name)); functions[p_name] = Function(); - functions[p_name].scroll = Vector2(-50, -100); + functions[p_name].func_id = p_func_node_id; } bool VisualScript::has_function(const StringName &p_name) const { @@ -182,11 +179,7 @@ void VisualScript::remove_function(const StringName &p_name) { ERR_FAIL_COND(instances.size()); ERR_FAIL_COND(!functions.has(p_name)); - for (Map<int, Function::NodeData>::Element *E = functions[p_name].nodes.front(); E; E = E->next()) { - E->get().node->disconnect("ports_changed", callable_mp(this, &VisualScript::_node_ports_changed)); - E->get().node->scripts_used.erase(this); - } - + // Let the editor handle the node removal. functions.erase(p_name); } @@ -207,53 +200,36 @@ void VisualScript::rename_function(const StringName &p_name, const StringName &p functions.erase(p_name); } -void VisualScript::set_function_scroll(const StringName &p_name, const Vector2 &p_scroll) { - ERR_FAIL_COND(!functions.has(p_name)); - functions[p_name].scroll = p_scroll; +void VisualScript::set_scroll(const Vector2 &p_scroll) { + scroll = p_scroll; } -Vector2 VisualScript::get_function_scroll(const StringName &p_name) const { - ERR_FAIL_COND_V(!functions.has(p_name), Vector2()); - return functions[p_name].scroll; +Vector2 VisualScript::get_scroll() const { + return scroll; } void VisualScript::get_function_list(List<StringName> *r_functions) const { - for (const Map<StringName, Function>::Element *E = functions.front(); E; E = E->next()) { - r_functions->push_back(E->key()); - } - - r_functions->sort_custom<StringName::AlphCompare>(); + functions.get_key_list(r_functions); + // r_functions->sort_custom<StringName::AlphCompare>(); // Don't force sorting. } int VisualScript::get_function_node_id(const StringName &p_name) const { ERR_FAIL_COND_V(!functions.has(p_name), -1); - return functions[p_name].function_id; + return functions[p_name].func_id; } void VisualScript::_node_ports_changed(int p_id) { - StringName function; - - for (Map<StringName, Function>::Element *E = functions.front(); E; E = E->next()) { - if (E->get().nodes.has(p_id)) { - function = E->key(); - break; - } - } - - ERR_FAIL_COND(function == StringName()); - - Function &func = functions[function]; - Ref<VisualScriptNode> vsn = func.nodes[p_id].node; + Ref<VisualScriptNode> vsn = nodes[p_id].node; vsn->validate_input_default_values(); - //must revalidate all the functions + // Must revalidate all the functions. { List<SequenceConnection> to_remove; - for (Set<SequenceConnection>::Element *E = func.sequence_connections.front(); E; E = E->next()) { + for (Set<SequenceConnection>::Element *E = sequence_connections.front(); E; E = E->next()) { if (E->get().from_node == p_id && E->get().from_output >= vsn->get_output_sequence_port_count()) { to_remove.push_back(E->get()); } @@ -263,7 +239,7 @@ void VisualScript::_node_ports_changed(int p_id) { } while (to_remove.size()) { - func.sequence_connections.erase(to_remove.front()->get()); + sequence_connections.erase(to_remove.front()->get()); to_remove.pop_front(); } } @@ -271,7 +247,7 @@ void VisualScript::_node_ports_changed(int p_id) { { List<DataConnection> to_remove; - for (Set<DataConnection>::Element *E = func.data_connections.front(); E; E = E->next()) { + for (Set<DataConnection>::Element *E = data_connections.front(); E; E = E->next()) { if (E->get().from_node == p_id && E->get().from_port >= vsn->get_output_value_port_count()) { to_remove.push_back(E->get()); } @@ -281,63 +257,47 @@ void VisualScript::_node_ports_changed(int p_id) { } while (to_remove.size()) { - func.data_connections.erase(to_remove.front()->get()); + data_connections.erase(to_remove.front()->get()); to_remove.pop_front(); } } #ifdef TOOLS_ENABLED - set_edited(true); //something changed, let's set as edited - emit_signal("node_ports_changed", function, p_id); + set_edited(true); // Something changed, let's set as edited. + emit_signal("node_ports_changed", p_id); #endif } -void VisualScript::add_node(const StringName &p_func, int p_id, const Ref<VisualScriptNode> &p_node, const Point2 &p_pos) { +void VisualScript::add_node(int p_id, const Ref<VisualScriptNode> &p_node, const Point2 &p_pos) { ERR_FAIL_COND(instances.size()); - ERR_FAIL_COND(!functions.has(p_func)); - - for (Map<StringName, Function>::Element *E = functions.front(); E; E = E->next()) { - ERR_FAIL_COND(E->get().nodes.has(p_id)); //id can exist only one in script, even for different functions - } + ERR_FAIL_COND(nodes.has(p_id)); // ID can exist only one in script. - Function &func = functions[p_func]; - - if (Object::cast_to<VisualScriptFunction>(*p_node)) { - //the function indeed - ERR_FAIL_COND_MSG(func.function_id >= 0, "A function node has already been set here."); - - func.function_id = p_id; - } - - Function::NodeData nd; + NodeData nd; nd.node = p_node; nd.pos = p_pos; Ref<VisualScriptNode> vsn = p_node; vsn->connect("ports_changed", callable_mp(this, &VisualScript::_node_ports_changed), varray(p_id)); - vsn->scripts_used.insert(this); - vsn->validate_input_default_values(); // Validate when fully loaded + vsn->script_used = Ref<VisualScript>(this); + vsn->validate_input_default_values(); // Validate when fully loaded. - func.nodes[p_id] = nd; + nodes[p_id] = nd; } -void VisualScript::remove_node(const StringName &p_func, int p_id) { +void VisualScript::remove_node(int p_id) { ERR_FAIL_COND(instances.size()); - ERR_FAIL_COND(!functions.has(p_func)); - Function &func = functions[p_func]; - - ERR_FAIL_COND(!func.nodes.has(p_id)); + ERR_FAIL_COND(!nodes.has(p_id)); { List<SequenceConnection> to_remove; - for (Set<SequenceConnection>::Element *E = func.sequence_connections.front(); E; E = E->next()) { + for (Set<SequenceConnection>::Element *E = sequence_connections.front(); E; E = E->next()) { if (E->get().from_node == p_id || E->get().to_node == p_id) { to_remove.push_back(E->get()); } } while (to_remove.size()) { - func.sequence_connections.erase(to_remove.front()->get()); + sequence_connections.erase(to_remove.front()->get()); to_remove.pop_front(); } } @@ -345,122 +305,88 @@ void VisualScript::remove_node(const StringName &p_func, int p_id) { { List<DataConnection> to_remove; - for (Set<DataConnection>::Element *E = func.data_connections.front(); E; E = E->next()) { + for (Set<DataConnection>::Element *E = data_connections.front(); E; E = E->next()) { if (E->get().from_node == p_id || E->get().to_node == p_id) { to_remove.push_back(E->get()); } } while (to_remove.size()) { - func.data_connections.erase(to_remove.front()->get()); + data_connections.erase(to_remove.front()->get()); to_remove.pop_front(); } } - if (Object::cast_to<VisualScriptFunction>(func.nodes[p_id].node.ptr())) { - func.function_id = -1; //revert to invalid - } + nodes[p_id].node->disconnect("ports_changed", callable_mp(this, &VisualScript::_node_ports_changed)); + nodes[p_id].node->script_used.unref(); - func.nodes[p_id].node->disconnect("ports_changed", callable_mp(this, &VisualScript::_node_ports_changed)); - func.nodes[p_id].node->scripts_used.erase(this); - - func.nodes.erase(p_id); + nodes.erase(p_id); } -bool VisualScript::has_node(const StringName &p_func, int p_id) const { - ERR_FAIL_COND_V(!functions.has(p_func), false); - const Function &func = functions[p_func]; - - return func.nodes.has(p_id); +bool VisualScript::has_node(int p_id) const { + return nodes.has(p_id); } -Ref<VisualScriptNode> VisualScript::get_node(const StringName &p_func, int p_id) const { - ERR_FAIL_COND_V(!functions.has(p_func), Ref<VisualScriptNode>()); - const Function &func = functions[p_func]; - - ERR_FAIL_COND_V(!func.nodes.has(p_id), Ref<VisualScriptNode>()); +Ref<VisualScriptNode> VisualScript::get_node(int p_id) const { + ERR_FAIL_COND_V(!nodes.has(p_id), Ref<VisualScriptNode>()); - return func.nodes[p_id].node; + return nodes[p_id].node; } -void VisualScript::set_node_position(const StringName &p_func, int p_id, const Point2 &p_pos) { +void VisualScript::set_node_position(int p_id, const Point2 &p_pos) { ERR_FAIL_COND(instances.size()); - ERR_FAIL_COND(!functions.has(p_func)); - Function &func = functions[p_func]; - - ERR_FAIL_COND(!func.nodes.has(p_id)); - func.nodes[p_id].pos = p_pos; + ERR_FAIL_COND(!nodes.has(p_id)); + nodes[p_id].pos = p_pos; } -Point2 VisualScript::get_node_position(const StringName &p_func, int p_id) const { - ERR_FAIL_COND_V(!functions.has(p_func), Point2()); - const Function &func = functions[p_func]; - - ERR_FAIL_COND_V(!func.nodes.has(p_id), Point2()); - return func.nodes[p_id].pos; +Point2 VisualScript::get_node_position(int p_id) const { + ERR_FAIL_COND_V(!nodes.has(p_id), Point2()); + return nodes[p_id].pos; } -void VisualScript::get_node_list(const StringName &p_func, List<int> *r_nodes) const { - ERR_FAIL_COND(!functions.has(p_func)); - const Function &func = functions[p_func]; - - for (const Map<int, Function::NodeData>::Element *E = func.nodes.front(); E; E = E->next()) { - r_nodes->push_back(E->key()); - } +void VisualScript::get_node_list(List<int> *r_nodes) const { + nodes.get_key_list(r_nodes); } -void VisualScript::sequence_connect(const StringName &p_func, int p_from_node, int p_from_output, int p_to_node) { +void VisualScript::sequence_connect(int p_from_node, int p_from_output, int p_to_node) { ERR_FAIL_COND(instances.size()); - ERR_FAIL_COND(!functions.has(p_func)); - Function &func = functions[p_func]; SequenceConnection sc; sc.from_node = p_from_node; sc.from_output = p_from_output; sc.to_node = p_to_node; - ERR_FAIL_COND(func.sequence_connections.has(sc)); + ERR_FAIL_COND(sequence_connections.has(sc)); - func.sequence_connections.insert(sc); + sequence_connections.insert(sc); } -void VisualScript::sequence_disconnect(const StringName &p_func, int p_from_node, int p_from_output, int p_to_node) { - ERR_FAIL_COND(!functions.has(p_func)); - Function &func = functions[p_func]; - +void VisualScript::sequence_disconnect(int p_from_node, int p_from_output, int p_to_node) { SequenceConnection sc; sc.from_node = p_from_node; sc.from_output = p_from_output; sc.to_node = p_to_node; - ERR_FAIL_COND(!func.sequence_connections.has(sc)); + ERR_FAIL_COND(!sequence_connections.has(sc)); - func.sequence_connections.erase(sc); + sequence_connections.erase(sc); } -bool VisualScript::has_sequence_connection(const StringName &p_func, int p_from_node, int p_from_output, int p_to_node) const { - ERR_FAIL_COND_V(!functions.has(p_func), false); - const Function &func = functions[p_func]; - +bool VisualScript::has_sequence_connection(int p_from_node, int p_from_output, int p_to_node) const { SequenceConnection sc; sc.from_node = p_from_node; sc.from_output = p_from_output; sc.to_node = p_to_node; - return func.sequence_connections.has(sc); + return sequence_connections.has(sc); } -void VisualScript::get_sequence_connection_list(const StringName &p_func, List<SequenceConnection> *r_connection) const { - ERR_FAIL_COND(!functions.has(p_func)); - const Function &func = functions[p_func]; - - for (const Set<SequenceConnection>::Element *E = func.sequence_connections.front(); E; E = E->next()) { +void VisualScript::get_sequence_connection_list(List<SequenceConnection> *r_connection) const { + for (const Set<SequenceConnection>::Element *E = sequence_connections.front(); E; E = E->next()) { r_connection->push_back(E->get()); } } -void VisualScript::data_connect(const StringName &p_func, int p_from_node, int p_from_port, int p_to_node, int p_to_port) { +void VisualScript::data_connect(int p_from_node, int p_from_port, int p_to_node, int p_to_port) { ERR_FAIL_COND(instances.size()); - ERR_FAIL_COND(!functions.has(p_func)); - Function &func = functions[p_func]; DataConnection dc; dc.from_node = p_from_node; @@ -468,72 +394,55 @@ void VisualScript::data_connect(const StringName &p_func, int p_from_node, int p dc.to_node = p_to_node; dc.to_port = p_to_port; - ERR_FAIL_COND(func.data_connections.has(dc)); + ERR_FAIL_COND(data_connections.has(dc)); - func.data_connections.insert(dc); + data_connections.insert(dc); } -void VisualScript::data_disconnect(const StringName &p_func, int p_from_node, int p_from_port, int p_to_node, int p_to_port) { - ERR_FAIL_COND(!functions.has(p_func)); - Function &func = functions[p_func]; - +void VisualScript::data_disconnect(int p_from_node, int p_from_port, int p_to_node, int p_to_port) { DataConnection dc; dc.from_node = p_from_node; dc.from_port = p_from_port; dc.to_node = p_to_node; dc.to_port = p_to_port; - ERR_FAIL_COND(!func.data_connections.has(dc)); + ERR_FAIL_COND(!data_connections.has(dc)); - func.data_connections.erase(dc); + data_connections.erase(dc); } -bool VisualScript::has_data_connection(const StringName &p_func, int p_from_node, int p_from_port, int p_to_node, int p_to_port) const { - ERR_FAIL_COND_V(!functions.has(p_func), false); - const Function &func = functions[p_func]; - +bool VisualScript::has_data_connection(int p_from_node, int p_from_port, int p_to_node, int p_to_port) const { DataConnection dc; dc.from_node = p_from_node; dc.from_port = p_from_port; dc.to_node = p_to_node; dc.to_port = p_to_port; - return func.data_connections.has(dc); + return data_connections.has(dc); } -bool VisualScript::is_input_value_port_connected(const StringName &p_func, int p_node, int p_port) const { - ERR_FAIL_COND_V(!functions.has(p_func), false); - const Function &func = functions[p_func]; - - for (const Set<DataConnection>::Element *E = func.data_connections.front(); E; E = E->next()) { +bool VisualScript::is_input_value_port_connected(int p_node, int p_port) const { + for (const Set<DataConnection>::Element *E = data_connections.front(); E; E = E->next()) { if (E->get().to_node == p_node && E->get().to_port == p_port) { return true; } } - return false; } -bool VisualScript::get_input_value_port_connection_source(const StringName &p_func, int p_node, int p_port, int *r_node, int *r_port) const { - ERR_FAIL_COND_V(!functions.has(p_func), false); - const Function &func = functions[p_func]; - - for (const Set<DataConnection>::Element *E = func.data_connections.front(); E; E = E->next()) { +bool VisualScript::get_input_value_port_connection_source(int p_node, int p_port, int *r_node, int *r_port) const { + for (const Set<DataConnection>::Element *E = data_connections.front(); E; E = E->next()) { if (E->get().to_node == p_node && E->get().to_port == p_port) { *r_node = E->get().from_node; *r_port = E->get().from_port; return true; } } - return false; } -void VisualScript::get_data_connection_list(const StringName &p_func, List<DataConnection> *r_connection) const { - ERR_FAIL_COND(!functions.has(p_func)); - const Function &func = functions[p_func]; - - for (const Set<DataConnection>::Element *E = func.data_connections.front(); E; E = E->next()) { +void VisualScript::get_data_connection_list(List<DataConnection> *r_connection) const { + for (const Set<DataConnection>::Element *E = data_connections.front(); E; E = E->next()) { r_connection->push_back(E->get()); } } @@ -653,11 +562,8 @@ Dictionary VisualScript::_get_variable_info(const StringName &p_name) const { } void VisualScript::get_variable_list(List<StringName> *r_variables) const { - for (Map<StringName, Variable>::Element *E = variables.front(); E; E = E->next()) { - r_variables->push_back(E->key()); - } - - r_variables->sort_custom<StringName::AlphCompare>(); + variables.get_key_list(r_variables); + // r_variables->sort_custom<StringName::AlphCompare>(); // Don't force it. } void VisualScript::set_instance_base_type(const StringName &p_type) { @@ -680,24 +586,19 @@ void VisualScript::rename_variable(const StringName &p_name, const StringName &p variables[p_new_name] = variables[p_name]; variables.erase(p_name); - - List<StringName> funcs; - get_function_list(&funcs); - for (List<StringName>::Element *F = funcs.front(); F; F = F->next()) { // loop through all the functions - List<int> ids; - get_node_list(F->get(), &ids); - for (List<int>::Element *E = ids.front(); E; E = E->next()) { - Ref<VisualScriptVariableGet> nodeget = get_node(F->get(), E->get()); - if (nodeget.is_valid()) { - if (nodeget->get_variable() == p_name) { - nodeget->set_variable(p_new_name); - } - } else { - Ref<VisualScriptVariableSet> nodeset = get_node(F->get(), E->get()); - if (nodeset.is_valid()) { - if (nodeset->get_variable() == p_name) { - nodeset->set_variable(p_new_name); - } + List<int> ids; + get_node_list(&ids); + for (List<int>::Element *E = ids.front(); E; E = E->next()) { + Ref<VisualScriptVariableGet> nodeget = get_node(E->get()); + if (nodeget.is_valid()) { + if (nodeget->get_variable() == p_name) { + nodeget->set_variable(p_new_name); + } + } else { + Ref<VisualScriptVariableSet> nodeset = get_node(E->get()); + if (nodeset.is_valid()) { + if (nodeset->get_variable() == p_name) { + nodeset->set_variable(p_new_name); } } } @@ -808,23 +709,24 @@ void VisualScript::get_custom_signal_list(List<StringName> *r_custom_signals) co } int VisualScript::get_available_id() const { - int max_id = 0; - for (Map<StringName, Function>::Element *E = functions.front(); E; E = E->next()) { - if (E->get().nodes.empty()) { - continue; + // This is infinitely increasing, + // so one might want to implement a better solution, + // if the there is a case for huge number of nodes to be added to visual script. + List<int> nds; + nodes.get_key_list(&nds); + int max = -1; + for (const List<int>::Element *E = nds.front(); E; E = E->next()) { + if (E->get() > max) { + max = E->get(); } - - int last_id = E->get().nodes.back()->key(); - max_id = MAX(max_id, last_id + 1); } - - return max_id; + return (max + 1); } ///////////////////////////////// bool VisualScript::can_instance() const { - return true; //ScriptServer::is_scripting_enabled(); + return true; // ScriptServer::is_scripting_enabled(); } StringName VisualScript::get_instance_base_type() const { @@ -832,7 +734,7 @@ StringName VisualScript::get_instance_base_type() const { } Ref<Script> VisualScript::get_base_script() const { - return Ref<Script>(); // no inheritance in visual script + return Ref<Script>(); // No inheritance in visual script. } #ifdef TOOLS_ENABLED @@ -842,20 +744,23 @@ void VisualScript::_placeholder_erased(PlaceHolderScriptInstance *p_placeholder) void VisualScript::_update_placeholders() { if (placeholders.size() == 0) { - return; //no bother if no placeholders + return; // No bother if no placeholders. } List<PropertyInfo> pinfo; Map<StringName, Variant> values; - for (Map<StringName, Variable>::Element *E = variables.front(); E; E = E->next()) { - if (!E->get()._export) { + List<StringName> keys; + variables.get_key_list(&keys); + + for (List<StringName>::Element *E = keys.front(); E; E = E->next()) { + if (!variables[E->get()]._export) { continue; } - PropertyInfo p = E->get().info; - p.name = String(E->key()); + PropertyInfo p = variables[E->get()].info; + p.name = String(E->get()); pinfo.push_back(p); - values[p.name] = E->get().default_value; + values[p.name] = variables[E->get()].default_value; } for (Set<PlaceHolderScriptInstance *>::Element *E = placeholders.front(); E; E = E->next()) { @@ -875,17 +780,18 @@ ScriptInstance *VisualScript::instance_create(Object *p_this) { List<PropertyInfo> pinfo; Map<StringName, Variant> values; - for (Map<StringName, Variable>::Element *E = variables.front(); E; E = E->next()) { - if (!E->get()._export) { + List<StringName> keys; + variables.get_key_list(&keys); + + for (const List<StringName>::Element *E = keys.front(); E; E = E->next()) { + if (!variables[E->get()]._export) continue; - } - PropertyInfo p = E->get().info; - p.name = String(E->key()); + PropertyInfo p = variables[E->get()].info; + p.name = String(E->get()); pinfo.push_back(p); - values[p.name] = E->get().default_value; + values[p.name] = variables[E->get()].default_value; } - sins->update(pinfo, values); return sins; @@ -928,7 +834,7 @@ bool VisualScript::is_tool() const { } bool VisualScript::is_valid() const { - return true; //always valid + return true; // Always valid. } ScriptLanguage *VisualScript::get_language() const { @@ -964,11 +870,14 @@ bool VisualScript::get_property_default_value(const StringName &p_property, Vari } void VisualScript::get_script_method_list(List<MethodInfo> *p_list) const { - for (Map<StringName, Function>::Element *E = functions.front(); E; E = E->next()) { + List<StringName> funcs; + functions.get_key_list(&funcs); + + for (List<StringName>::Element *E = funcs.front(); E; E = E->next()) { MethodInfo mi; - mi.name = E->key(); - if (E->get().function_id >= 0) { - Ref<VisualScriptFunction> func = E->get().nodes[E->get().function_id].node; + mi.name = E->get(); + if (functions[E->get()].func_id >= 0) { + Ref<VisualScriptFunction> func = nodes[functions[E->get()].func_id].node; if (func.is_valid()) { for (int i = 0; i < func->get_argument_count(); i++) { PropertyInfo arg; @@ -988,15 +897,15 @@ bool VisualScript::has_method(const StringName &p_method) const { } MethodInfo VisualScript::get_method_info(const StringName &p_method) const { - const Map<StringName, Function>::Element *E = functions.find(p_method); - if (!E) { + const Function funct = functions[p_method]; + if (funct.func_id == -1) { return MethodInfo(); } MethodInfo mi; - mi.name = E->key(); - if (E->get().function_id >= 0) { - Ref<VisualScriptFunction> func = E->get().nodes[E->get().function_id].node; + mi.name = p_method; + if (funct.func_id >= 0) { + Ref<VisualScriptFunction> func = nodes[funct.func_id].node; if (func.is_valid()) { for (int i = 0; i < func->get_argument_count(); i++) { PropertyInfo arg; @@ -1028,28 +937,18 @@ void VisualScript::get_script_property_list(List<PropertyInfo> *p_list) const { } int VisualScript::get_member_line(const StringName &p_member) const { -#ifdef TOOLS_ENABLED - if (has_function(p_member)) { - for (Map<int, Function::NodeData>::Element *E = functions[p_member].nodes.front(); E; E = E->next()) { - if (Object::cast_to<VisualScriptFunction>(E->get().node.ptr())) { - return E->key(); - } - } - } -#endif - return -1; + return functions[p_member].func_id; // will be -1 if not found } #ifdef TOOLS_ENABLED bool VisualScript::are_subnodes_edited() const { - for (const Map<StringName, Function>::Element *E = functions.front(); E; E = E->next()) { - for (const Map<int, Function::NodeData>::Element *F = E->get().nodes.front(); F; F = F->next()) { - if (F->get().node->is_edited()) { - return true; - } + List<int> keys; + nodes.get_key_list(&keys); + for (const List<int>::Element *F = keys.front(); F; F = F->next()) { + if (nodes[F->get()].node->is_edited()) { + return true; } } - return false; } #endif @@ -1140,85 +1039,41 @@ void VisualScript::_set_data(const Dictionary &p_data) { Array funcs = d["functions"]; functions.clear(); - Vector2 last_pos = Vector2(-100 * funcs.size(), -100 * funcs.size()); // this is the center of the last fn box - Vector2 last_size = Vector2(0.0, 0.0); - for (int i = 0; i < funcs.size(); i++) { Dictionary func = funcs[i]; - - StringName name = func["name"]; - //int id=func["function_id"]; - add_function(name); - - set_function_scroll(name, func["scroll"]); - - Array nodes = func["nodes"]; - - if (!d.has("vs_unify") && nodes.size() > 0) { - Vector2 top_left = nodes[1]; - Vector2 bottom_right = nodes[1]; - - for (int j = 0; j < nodes.size(); j += 3) { - Point2 pos = nodes[j + 1]; - if (pos.y > top_left.y) { - top_left.y = pos.y; - } - if (pos.y < bottom_right.y) { - bottom_right.y = pos.y; - } - if (pos.x > bottom_right.x) { - bottom_right.x = pos.x; - } - if (pos.x < top_left.x) { - top_left.x = pos.x; - } - } - - Vector2 size = Vector2(bottom_right.x - top_left.x, top_left.y - bottom_right.y); - - Vector2 offset = last_pos + (last_size / 2.0) + (size / 2.0); // dunno I might just keep it in one axis but diagonal feels better.... - - last_pos = offset; - last_size = size; - - for (int j = 0; j < nodes.size(); j += 3) { - add_node(name, nodes[j], nodes[j + 2], offset + nodes[j + 1]); // also add an additional buffer if you want to - } - - } else { - for (int j = 0; j < nodes.size(); j += 3) { - add_node(name, nodes[j], nodes[j + 2], nodes[j + 1]); - } + add_function(func["name"], func["function_id"]); + } + { + Array nodes = d["nodes"]; + for (int i = 0; i < nodes.size(); i += 3) { + add_node(nodes[i], nodes[i + 2], nodes[i + 1]); } - Array sequence_connections = func["sequence_connections"]; + Array sequence_connections = d["sequence_connections"]; for (int j = 0; j < sequence_connections.size(); j += 3) { - sequence_connect(name, sequence_connections[j + 0], sequence_connections[j + 1], sequence_connections[j + 2]); + sequence_connect(sequence_connections[j + 0], sequence_connections[j + 1], sequence_connections[j + 2]); } - Array data_connections = func["data_connections"]; - + Array data_connections = d["data_connections"]; for (int j = 0; j < data_connections.size(); j += 4) { - data_connect(name, data_connections[j + 0], data_connections[j + 1], data_connections[j + 2], data_connections[j + 3]); + data_connect(data_connections[j + 0], data_connections[j + 1], data_connections[j + 2], data_connections[j + 3]); } } + is_tool_script = d["is_tool_script"]; + scroll = d["scroll"]; - if (d.has("is_tool_script")) { - is_tool_script = d["is_tool_script"]; - } else { - is_tool_script = false; - } - - // Takes all the rpc methods + // Takes all the rpc methods. rpc_functions.clear(); rpc_variables.clear(); - for (Map<StringName, Function>::Element *E = functions.front(); E; E = E->next()) { - if (E->get().function_id >= 0 && E->get().nodes.find(E->get().function_id)) { - Ref<VisualScriptFunction> vsf = E->get().nodes[E->get().function_id].node; + List<StringName> fns; + functions.get_key_list(&fns); + for (const List<StringName>::Element *E = fns.front(); E; E = E->next()) { + if (functions[E->get()].func_id >= 0 && nodes.has(functions[E->get()].func_id)) { + Ref<VisualScriptFunction> vsf = nodes[functions[E->get()].func_id].node; if (vsf.is_valid()) { if (vsf->get_rpc_mode() != MultiplayerAPI::RPC_MODE_DISABLED) { ScriptNetData nd; - nd.name = E->key(); + nd.name = E->get(); nd.mode = vsf->get_rpc_mode(); if (rpc_functions.find(nd) == -1) { rpc_functions.push_back(nd); @@ -1228,8 +1083,6 @@ void VisualScript::_set_data(const Dictionary &p_data) { } } - // Visual script doesn't have rset :( - // Sort so we are 100% that they are always the same. rpc_functions.sort_custom<SortNetData>(); } @@ -1237,12 +1090,15 @@ void VisualScript::_set_data(const Dictionary &p_data) { Dictionary VisualScript::_get_data() const { Dictionary d; d["base_type"] = base_type; + Array vars; - for (const Map<StringName, Variable>::Element *E = variables.front(); E; E = E->next()) { - Dictionary var = _get_variable_info(E->key()); - var["name"] = E->key(); //make sure it's the right one - var["default_value"] = E->get().default_value; - var["export"] = E->get()._export; + List<StringName> var_names; + variables.get_key_list(&var_names); + for (const List<StringName>::Element *E = var_names.front(); E; E = E->next()) { + Dictionary var = _get_variable_info(E->get()); + var["name"] = E->get(); // Make sure it's the right one. + var["default_value"] = variables[E->get()].default_value; + var["export"] = variables[E->get()]._export; vars.push_back(var); } d["variables"] = vars; @@ -1264,78 +1120,73 @@ Dictionary VisualScript::_get_data() const { d["signals"] = sigs; Array funcs; - - for (const Map<StringName, Function>::Element *E = functions.front(); E; E = E->next()) { + List<StringName> func_names; + functions.get_key_list(&func_names); + for (const List<StringName>::Element *E = func_names.front(); E; E = E->next()) { Dictionary func; - func["name"] = E->key(); - func["function_id"] = E->get().function_id; - func["scroll"] = E->get().scroll; - - Array nodes; - - for (const Map<int, Function::NodeData>::Element *F = E->get().nodes.front(); F; F = F->next()) { - nodes.push_back(F->key()); - nodes.push_back(F->get().pos); - nodes.push_back(F->get().node); - } - - func["nodes"] = nodes; - - Array sequence_connections; - - for (const Set<SequenceConnection>::Element *F = E->get().sequence_connections.front(); F; F = F->next()) { - sequence_connections.push_back(F->get().from_node); - sequence_connections.push_back(F->get().from_output); - sequence_connections.push_back(F->get().to_node); - } - - func["sequence_connections"] = sequence_connections; - - Array data_connections; + func["name"] = E->get(); + func["function_id"] = functions[E->get()].func_id; + funcs.push_back(func); + } + d["functions"] = funcs; - for (const Set<DataConnection>::Element *F = E->get().data_connections.front(); F; F = F->next()) { - data_connections.push_back(F->get().from_node); - data_connections.push_back(F->get().from_port); - data_connections.push_back(F->get().to_node); - data_connections.push_back(F->get().to_port); - } + Array nds; + List<int> node_ids; + nodes.get_key_list(&node_ids); + for (const List<int>::Element *F = node_ids.front(); F; F = F->next()) { + nds.push_back(F->get()); + nds.push_back(nodes[F->get()].pos); + nds.push_back(nodes[F->get()].node); + } + d["nodes"] = nds; - func["data_connections"] = data_connections; + Array seqconns; + for (const Set<SequenceConnection>::Element *F = sequence_connections.front(); F; F = F->next()) { + seqconns.push_back(F->get().from_node); + seqconns.push_back(F->get().from_output); + seqconns.push_back(F->get().to_node); + } + d["sequence_connections"] = seqconns; - funcs.push_back(func); + Array dataconns; + for (const Set<DataConnection>::Element *F = data_connections.front(); F; F = F->next()) { + dataconns.push_back(F->get().from_node); + dataconns.push_back(F->get().from_port); + dataconns.push_back(F->get().to_node); + dataconns.push_back(F->get().to_port); } + d["data_connections"] = dataconns; - d["functions"] = funcs; d["is_tool_script"] = is_tool_script; - d["vs_unify"] = true; + d["scroll"] = scroll; return d; } void VisualScript::_bind_methods() { - ClassDB::bind_method(D_METHOD("add_function", "name"), &VisualScript::add_function); + ClassDB::bind_method(D_METHOD("add_function", "name", "func_node_id"), &VisualScript::add_function); ClassDB::bind_method(D_METHOD("has_function", "name"), &VisualScript::has_function); ClassDB::bind_method(D_METHOD("remove_function", "name"), &VisualScript::remove_function); ClassDB::bind_method(D_METHOD("rename_function", "name", "new_name"), &VisualScript::rename_function); - ClassDB::bind_method(D_METHOD("set_function_scroll", "name", "ofs"), &VisualScript::set_function_scroll); - ClassDB::bind_method(D_METHOD("get_function_scroll", "name"), &VisualScript::get_function_scroll); + ClassDB::bind_method(D_METHOD("set_scroll", "ofs"), &VisualScript::set_scroll); + ClassDB::bind_method(D_METHOD("get_scroll"), &VisualScript::get_scroll); - ClassDB::bind_method(D_METHOD("add_node", "func", "id", "node", "position"), &VisualScript::add_node, DEFVAL(Point2())); - ClassDB::bind_method(D_METHOD("remove_node", "func", "id"), &VisualScript::remove_node); + ClassDB::bind_method(D_METHOD("add_node", "id", "node", "position"), &VisualScript::add_node, DEFVAL(Point2())); + ClassDB::bind_method(D_METHOD("remove_node", "id"), &VisualScript::remove_node); ClassDB::bind_method(D_METHOD("get_function_node_id", "name"), &VisualScript::get_function_node_id); - ClassDB::bind_method(D_METHOD("get_node", "func", "id"), &VisualScript::get_node); - ClassDB::bind_method(D_METHOD("has_node", "func", "id"), &VisualScript::has_node); - ClassDB::bind_method(D_METHOD("set_node_position", "func", "id", "position"), &VisualScript::set_node_position); - ClassDB::bind_method(D_METHOD("get_node_position", "func", "id"), &VisualScript::get_node_position); + ClassDB::bind_method(D_METHOD("get_node", "id"), &VisualScript::get_node); + ClassDB::bind_method(D_METHOD("has_node", "id"), &VisualScript::has_node); + ClassDB::bind_method(D_METHOD("set_node_position", "id", "position"), &VisualScript::set_node_position); + ClassDB::bind_method(D_METHOD("get_node_position", "id"), &VisualScript::get_node_position); - ClassDB::bind_method(D_METHOD("sequence_connect", "func", "from_node", "from_output", "to_node"), &VisualScript::sequence_connect); - ClassDB::bind_method(D_METHOD("sequence_disconnect", "func", "from_node", "from_output", "to_node"), &VisualScript::sequence_disconnect); - ClassDB::bind_method(D_METHOD("has_sequence_connection", "func", "from_node", "from_output", "to_node"), &VisualScript::has_sequence_connection); + ClassDB::bind_method(D_METHOD("sequence_connect", "from_node", "from_output", "to_node"), &VisualScript::sequence_connect); + ClassDB::bind_method(D_METHOD("sequence_disconnect", "from_node", "from_output", "to_node"), &VisualScript::sequence_disconnect); + ClassDB::bind_method(D_METHOD("has_sequence_connection", "from_node", "from_output", "to_node"), &VisualScript::has_sequence_connection); - ClassDB::bind_method(D_METHOD("data_connect", "func", "from_node", "from_port", "to_node", "to_port"), &VisualScript::data_connect); - ClassDB::bind_method(D_METHOD("data_disconnect", "func", "from_node", "from_port", "to_node", "to_port"), &VisualScript::data_disconnect); - ClassDB::bind_method(D_METHOD("has_data_connection", "func", "from_node", "from_port", "to_node", "to_port"), &VisualScript::has_data_connection); + ClassDB::bind_method(D_METHOD("data_connect", "from_node", "from_port", "to_node", "to_port"), &VisualScript::data_connect); + ClassDB::bind_method(D_METHOD("data_disconnect", "from_node", "from_port", "to_node", "to_port"), &VisualScript::data_disconnect); + ClassDB::bind_method(D_METHOD("has_data_connection", "from_node", "from_port", "to_node", "to_port"), &VisualScript::has_data_connection); ClassDB::bind_method(D_METHOD("add_variable", "name", "default_value", "export"), &VisualScript::add_variable, DEFVAL(Variant()), DEFVAL(false)); ClassDB::bind_method(D_METHOD("has_variable", "name"), &VisualScript::has_variable); @@ -1371,7 +1222,7 @@ void VisualScript::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "_set_data", "_get_data"); - ADD_SIGNAL(MethodInfo("node_ports_changed", PropertyInfo(Variant::STRING, "function"), PropertyInfo(Variant::INT, "id"))); + ADD_SIGNAL(MethodInfo("node_ports_changed", PropertyInfo(Variant::INT, "id"))); } VisualScript::VisualScript() { @@ -1380,16 +1231,12 @@ VisualScript::VisualScript() { } bool VisualScript::inherits_script(const Ref<Script> &p_script) const { - return this == p_script.ptr(); //there is no inheritance in visual scripts, so this is enough -} - -StringName VisualScript::get_default_func() const { - return StringName("f_312843592"); + return this == p_script.ptr(); // There is no inheritance in visual scripts, so this is enough. } -Set<int> VisualScript::get_output_sequence_ports_connected(const String &edited_func, int from_node) { +Set<int> VisualScript::get_output_sequence_ports_connected(int from_node) { List<VisualScript::SequenceConnection> *sc = memnew(List<VisualScript::SequenceConnection>); - get_sequence_connection_list(edited_func, sc); + get_sequence_connection_list(sc); Set<int> connected; for (List<VisualScript::SequenceConnection>::Element *E = sc->front(); E; E = E->next()) { if (E->get().from_node == from_node) { @@ -1401,8 +1248,11 @@ Set<int> VisualScript::get_output_sequence_ports_connected(const String &edited_ } VisualScript::~VisualScript() { - while (!functions.empty()) { - remove_function(functions.front()->key()); + // Remove all nodes and stuff that hold data refs. + List<int> nds; + nodes.get_key_list(&nds); + for (const List<int>::Element *E = nds.front(); E; E = E->next()) { + remove_node(E->get()); } } @@ -1430,20 +1280,21 @@ bool VisualScriptInstance::get(const StringName &p_name, Variant &r_ret) const { } void VisualScriptInstance::get_property_list(List<PropertyInfo> *p_properties) const { - for (const Map<StringName, VisualScript::Variable>::Element *E = script->variables.front(); E; E = E->next()) { - if (!E->get()._export) { + List<StringName> vars; + script->variables.get_key_list(&vars); + for (const List<StringName>::Element *E = vars.front(); E; E = E->next()) { + if (!script->variables[E->get()]._export) { continue; } - PropertyInfo p = E->get().info; - p.name = String(E->key()); + PropertyInfo p = script->variables[E->get()].info; + p.name = String(E->get()); p.usage |= PROPERTY_USAGE_SCRIPT_VARIABLE; p_properties->push_back(p); } } Variant::Type VisualScriptInstance::get_property_type(const StringName &p_name, bool *r_is_valid) const { - const Map<StringName, VisualScript::Variable>::Element *E = script->variables.find(p_name); - if (!E) { + if (!script->variables.has(p_name)) { if (r_is_valid) { *r_is_valid = false; } @@ -1454,19 +1305,17 @@ Variant::Type VisualScriptInstance::get_property_type(const StringName &p_name, *r_is_valid = true; } - return E->get().info.type; + return script->variables[p_name].info.type; } void VisualScriptInstance::get_method_list(List<MethodInfo> *p_list) const { - for (const Map<StringName, VisualScript::Function>::Element *E = script->functions.front(); E; E = E->next()) { - if (E->key() == script->get_default_func()) { - continue; - } - + List<StringName> fns; + script->functions.get_key_list(&fns); + for (const List<StringName>::Element *E = fns.front(); E; E = E->next()) { MethodInfo mi; - mi.name = E->key(); - if (E->get().function_id >= 0 && E->get().nodes.has(E->get().function_id)) { - Ref<VisualScriptFunction> vsf = E->get().nodes[E->get().function_id].node; + mi.name = E->get(); + if (script->functions[E->get()].func_id >= 0 && script->nodes.has(script->functions[E->get()].func_id)) { + Ref<VisualScriptFunction> vsf = script->nodes[script->functions[E->get()].func_id].node; if (vsf.is_valid()) { for (int i = 0; i < vsf->get_argument_count(); i++) { PropertyInfo arg; @@ -1476,21 +1325,16 @@ void VisualScriptInstance::get_method_list(List<MethodInfo> *p_list) const { mi.arguments.push_back(arg); } - if (!vsf->is_sequenced()) { //assumed constant if not sequenced + if (!vsf->is_sequenced()) { // Assumed constant if not sequenced. mi.flags |= METHOD_FLAG_CONST; } } } - p_list->push_back(mi); } } bool VisualScriptInstance::has_method(const StringName &p_method) const { - if (p_method == script->get_default_func()) { - return false; - } - return script->functions.has(p_method); } @@ -1506,7 +1350,7 @@ void VisualScriptInstance::_dependency_step(VisualScriptNodeInstance *node, int pass_stack[node->pass_idx] = p_pass; - if (!node->dependencies.empty()) { + if (!node->dependencies.is_empty()) { int dc = node->dependencies.size(); VisualScriptNodeInstance **deps = node->dependencies.ptrw(); @@ -1522,10 +1366,10 @@ void VisualScriptInstance::_dependency_step(VisualScriptNodeInstance *node, int int index = node->input_ports[i] & VisualScriptNodeInstance::INPUT_MASK; if (node->input_ports[i] & VisualScriptNodeInstance::INPUT_DEFAULT_VALUE_BIT) { - //is a default value (unassigned input port) + // Is a default value (unassigned input port). input_args[i] = &default_values[index]; } else { - //regular temporary in stack + // Rregular temporary in stack. input_args[i] = &variant_stack[index]; } } @@ -1536,7 +1380,7 @@ void VisualScriptInstance::_dependency_step(VisualScriptNodeInstance *node, int Variant *working_mem = node->working_mem_idx >= 0 ? &variant_stack[node->working_mem_idx] : (Variant *)nullptr; node->step(input_args, output_args, VisualScriptNodeInstance::START_MODE_BEGIN_SEQUENCE, working_mem, r_error, error_str); - //ignore return + // Ignore return. if (r_error.error != Callable::CallError::CALL_OK) { *r_error_node = node; } @@ -1547,7 +1391,7 @@ Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p ERR_FAIL_COND_V(!F, Variant()); Function *f = &F->get(); - //this call goes separate, so it can e yielded and suspended + // This call goes separate, so it can e yielded and suspended. Variant *variant_stack = (Variant *)p_stack; bool *sequence_bits = (bool *)(variant_stack + f->max_stack); const Variant **input_args = (const Variant **)(sequence_bits + f->node_count); @@ -1573,27 +1417,27 @@ Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p #endif while (true) { - p_pass++; //increment pass + p_pass++; // Increment pass. current_node_id = node->get_id(); VSDEBUG("==========AT NODE: " + itos(current_node_id) + " base: " + node->get_base_node()->get_class_name()); VSDEBUG("AT STACK POS: " + itos(flow_stack_pos)); - //setup working mem + // Setup working mem. working_mem = node->working_mem_idx >= 0 ? &variant_stack[node->working_mem_idx] : (Variant *)nullptr; VSDEBUG("WORKING MEM: " + itos(node->working_mem_idx)); if (current_node_id == f->node) { - //if function node, set up function arguments from beginning of stack + // If function node, set up function arguments from beginning of stack. for (int i = 0; i < f->argument_count; i++) { input_args[i] = &variant_stack[i]; } } else { - //run dependencies first + // Run dependencies first. - if (!node->dependencies.empty()) { + if (!node->dependencies.is_empty()) { int dc = node->dependencies.size(); VisualScriptNodeInstance **deps = node->dependencies.ptrw(); @@ -1608,18 +1452,18 @@ Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p } if (!error) { - //setup input pointers normally + // Setup input pointers normally. VSDEBUG("INPUT PORTS: " + itos(node->input_port_count)); for (int i = 0; i < node->input_port_count; i++) { int index = node->input_ports[i] & VisualScriptNodeInstance::INPUT_MASK; if (node->input_ports[i] & VisualScriptNodeInstance::INPUT_DEFAULT_VALUE_BIT) { - //is a default value (unassigned input port) + // Is a default value (unassigned input port). input_args[i] = &default_values[index]; VSDEBUG("\tPORT " + itos(i) + " DEFAULT VAL"); } else { - //regular temporary in stack + // Regular temporary in stack. input_args[i] = &variant_stack[index]; VSDEBUG("PORT " + itos(i) + " AT STACK " + itos(index)); } @@ -1631,7 +1475,7 @@ Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p break; } - //setup output pointers + // Setup output pointers. VSDEBUG("OUTPUT PORTS: " + itos(node->output_port_count)); for (int i = 0; i < node->output_port_count; i++) { @@ -1639,15 +1483,15 @@ Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p VSDEBUG("PORT " + itos(i) + " AT STACK " + itos(node->output_ports[i])); } - //do step + // Do step. VisualScriptNodeInstance::StartMode start_mode; { if (p_resuming_yield) { start_mode = VisualScriptNodeInstance::START_MODE_RESUME_YIELD; - p_resuming_yield = false; // should resume only the first time + p_resuming_yield = false; // Should resume only the first time. } else if (flow_stack && (flow_stack[flow_stack_pos] & VisualScriptNodeInstance::FLOW_STACK_PUSHED_BIT)) { - //if there is a push bit, it means we are continuing a sequence + // If there is a push bit, it means we are continuing a sequence. start_mode = VisualScriptNodeInstance::START_MODE_CONTINUE_SEQUENCE; } else { start_mode = VisualScriptNodeInstance::START_MODE_BEGIN_SEQUENCE; @@ -1659,13 +1503,13 @@ Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p int ret = node->step(input_args, output_args, start_mode, working_mem, r_error, error_str); if (r_error.error != Callable::CallError::CALL_OK) { - //use error from step + // Use error from step. error = true; break; } if (ret & VisualScriptNodeInstance::STEP_YIELD_BIT) { - //yielded! + // Yielded! if (node->get_working_memory_size() == 0) { r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD; error_str = RTR("A node yielded without working memory, please read the docs on how to yield properly!"); @@ -1681,7 +1525,7 @@ Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p break; } - //step 1, capture all state + // Step 1, capture all state. state->instance_id = get_owner_ptr()->get_instance_id(); state->script_id = get_script()->get_instance_id(); state->instance = this; @@ -1693,11 +1537,11 @@ Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p state->stack.resize(p_stack_size); state->pass = p_pass; copymem(state->stack.ptrw(), p_stack, p_stack_size); - //step 2, run away, return directly + // Step 2, run away, return directly. r_error.error = Callable::CallError::CALL_OK; #ifdef DEBUG_ENABLED - //will re-enter later, so exiting + // Will re-enter later, so exiting. if (EngineDebugger::is_active()) { VisualScriptLanguage::singleton->exit_function(); } @@ -1742,18 +1586,18 @@ Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p error_str = RTR("Return value must be assigned to first element of node working memory! Fix your node please."); error = true; } else { - //assign from working memory, first element + // Assign from working memory, first element. return_value = *working_mem; } VSDEBUG("EXITING FUNCTION - VALUE " + String(return_value)); - break; //exit function requested, bye + break; // Exit function requested, bye } - VisualScriptNodeInstance *next = nullptr; //next node + VisualScriptNodeInstance *next = nullptr; // Next node. if ((ret == output || ret & VisualScriptNodeInstance::STEP_FLAG_PUSH_STACK_BIT) && node->sequence_output_count) { - //if no exit bit was set, and has sequence outputs, guess next node + // If no exit bit was set, and has sequence outputs, guess next node. if (output >= node->sequence_output_count) { r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD; error_str = RTR("Node returned an invalid sequence output: ") + itos(output); @@ -1766,21 +1610,21 @@ Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p } if (flow_stack) { - //update flow stack pos (may have changed) + // Update flow stack pos (may have changed). flow_stack[flow_stack_pos] = current_node_id; - //add stack push bit if requested + // Add stack push bit if requested. if (ret & VisualScriptNodeInstance::STEP_FLAG_PUSH_STACK_BIT) { flow_stack[flow_stack_pos] |= VisualScriptNodeInstance::FLOW_STACK_PUSHED_BIT; - sequence_bits[node->sequence_index] = true; //remember sequence bit + sequence_bits[node->sequence_index] = true; // Remember sequence bit. VSDEBUG("NEXT SEQ - FLAG BIT"); } else { - sequence_bits[node->sequence_index] = false; //forget sequence bit + sequence_bits[node->sequence_index] = false; // Forget sequence bit. VSDEBUG("NEXT SEQ - NORMAL"); } if (ret & VisualScriptNodeInstance::STEP_FLAG_GO_BACK_BIT) { - //go back request + // Go back request. if (flow_stack_pos > 0) { flow_stack_pos--; @@ -1788,20 +1632,20 @@ Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p VSDEBUG("NEXT IS GO BACK"); } else { VSDEBUG("NEXT IS GO BACK, BUT NO NEXT SO EXIT"); - break; //simply exit without value or error + break; // Simply exit without value or error. } } else if (next) { if (sequence_bits[next->sequence_index]) { - // what happened here is that we are entering a node that is in the middle of doing a sequence (pushed stack) from the front + // What happened here is that we are entering a node that is in the middle of doing a sequence (pushed stack) from the front // because each node has a working memory, we can't really do a sub-sequence // as a result, the sequence will be restarted and the stack will roll back to find where this node - // started the sequence + // started the sequence. bool found = false; for (int i = flow_stack_pos; i >= 0; i--) { if ((flow_stack[i] & VisualScriptNodeInstance::FLOW_STACK_MASK) == next->get_id()) { - flow_stack_pos = i; //roll back and remove bit + flow_stack_pos = i; // Roll back and remove bit. flow_stack[i] = next->get_id(); sequence_bits[next->sequence_index] = false; found = true; @@ -1819,7 +1663,7 @@ Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p VSDEBUG("RE-ENTERED A LOOP, RETURNED STACK POS TO - " + itos(flow_stack_pos)); } else { - // check for stack overflow + // Check for stack overflow. if (flow_stack_pos + 1 >= flow_max) { r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD; error_str = RTR("Stack overflow with stack depth: ") + itos(output); @@ -1836,7 +1680,7 @@ Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p } } else { - //no next node, try to go back in stack to pushed bit + // No next node, try to go back in stack to pushed bit. bool found = false; @@ -1852,22 +1696,22 @@ Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p if (!found) { VSDEBUG("NO NEXT NODE, NO GO BACK, EXITING"); - break; //done, couldn't find a push stack bit + break; // Done, couldn't find a push stack bit. } VSDEBUG("NO NEXT NODE, GO BACK TO: " + itos(flow_stack_pos)); } } else { - node = next; //stackless mode, simply assign next node + node = next; // Stackless mode, simply assign next node. } } if (error) { - //error - // function, file, line, error, explanation + // Error + // Function, file, line, error, explanation. String err_file = script->get_path(); String err_func = p_method; - int err_line = current_node_id; //not a line but it works as one + int err_line = current_node_id; // Not a line but it works as one. if (node && (r_error.error != Callable::CallError::CALL_ERROR_INVALID_METHOD || error_str == String())) { if (error_str != String()) { @@ -1906,7 +1750,7 @@ Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p } #endif - //clean up variant stack + // Clean up variant stack. for (int i = 0; i < f->max_stack; i++) { variant_stack[i].~Variant(); } @@ -1954,7 +1798,7 @@ Variant VisualScriptInstance::call(const StringName &p_method, const Variant **p int *pass_stack = flow_stack ? (int *)(flow_stack + flow_max) : (int *)nullptr; for (int i = 0; i < f->node_count; i++) { - sequence_bits[i] = false; //all starts as false + sequence_bits[i] = false; // All starts as false. } zeromem(pass_stack, f->pass_stack_size * sizeof(int)); @@ -1988,12 +1832,12 @@ Variant VisualScriptInstance::call(const StringName &p_method, const Variant **p return Variant(); } - //allocate variant stack + // Allocate variant stack. for (int i = 0; i < f->max_stack; i++) { memnew_placement(&variant_stack[i], Variant); } - //allocate function arguments (must be copied for yield to work properly) + // Allocate function arguments (must be copied for yield to work properly). for (int i = 0; i < p_argcount; i++) { variant_stack[i] = *p_args[i]; } @@ -2002,12 +1846,12 @@ Variant VisualScriptInstance::call(const StringName &p_method, const Variant **p } void VisualScriptInstance::notification(int p_notification) { - //do nothing as this is called using virtual + // Do nothing as this is called using virtual. Variant what = p_notification; const Variant *whatp = &what; Callable::CallError ce; - call(VisualScriptLanguage::singleton->notification, &whatp, 1, ce); //do as call + call(VisualScriptLanguage::singleton->notification, &whatp, 1, ce); // Do as call. } String VisualScriptInstance::to_string(bool *r_valid) { @@ -2086,7 +1930,7 @@ void VisualScriptInstance::create(const Ref<VisualScript> &p_script, Object *p_o max_output_args = 0; if (Object::cast_to<Node>(p_owner)) { - //turn on these if they exist and base is a node + // Turn on these if they exist and base is a node. Node *node = Object::cast_to<Node>(p_owner); if (p_script->functions.has("_process")) { node->set_process(true); @@ -2105,190 +1949,236 @@ void VisualScriptInstance::create(const Ref<VisualScript> &p_script, Object *p_o } } - for (const Map<StringName, VisualScript::Variable>::Element *E = script->variables.front(); E; E = E->next()) { - variables[E->key()] = E->get().default_value; - } - - for (const Map<StringName, VisualScript::Function>::Element *E = script->functions.front(); E; E = E->next()) { - if (E->key() == script->get_default_func()) { - continue; - } - - Function function; - function.node = E->get().function_id; - function.max_stack = 0; - function.flow_stack_size = 0; - function.pass_stack_size = 0; - function.node_count = 0; - - Map<StringName, int> local_var_indices; - - if (function.node < 0) { - VisualScriptLanguage::singleton->debug_break_parse(get_script()->get_path(), 0, "No start node in function: " + String(E->key())); - - ERR_CONTINUE(function.node < 0); + // Setup variables. + { + List<StringName> keys; + script->variables.get_key_list(&keys); + for (const List<StringName>::Element *E = keys.front(); E; E = E->next()) { + variables[E->get()] = script->variables[E->get()].default_value; } + } - { - Ref<VisualScriptFunction> func_node = script->get_node(E->key(), E->get().function_id); - - if (func_node.is_null()) { - VisualScriptLanguage::singleton->debug_break_parse(get_script()->get_path(), 0, "No VisualScriptFunction typed start node in function: " + String(E->key())); + // Setup functions from sequence trees. + { + List<StringName> keys; + script->functions.get_key_list(&keys); + for (const List<StringName>::Element *E = keys.front(); E; E = E->next()) { + const VisualScript::Function vsfn = p_script->functions[E->get()]; + Function function; + function.node = vsfn.func_id; + function.max_stack = 0; + function.flow_stack_size = 0; + function.pass_stack_size = 0; + function.node_count = 0; + + Map<StringName, int> local_var_indices; + + if (function.node < 0) { + VisualScriptLanguage::singleton->debug_break_parse(get_script()->get_path(), 0, "No start node in function: " + String(E->get())); + ERR_CONTINUE(function.node < 0); } - ERR_CONTINUE(!func_node.is_valid()); - - function.argument_count = func_node->get_argument_count(); - function.max_stack += function.argument_count; - function.flow_stack_size = func_node->is_stack_less() ? 0 : func_node->get_stack_size(); - max_input_args = MAX(max_input_args, function.argument_count); - } - - //multiple passes are required to set up this complex thing.. - - //first create the nodes - for (const Map<int, VisualScript::Function::NodeData>::Element *F = E->get().nodes.front(); F; F = F->next()) { - Ref<VisualScriptNode> node = F->get().node; - - VisualScriptNodeInstance *instance = node->instance(this); //create instance - ERR_FAIL_COND(!instance); + { + Ref<VisualScriptFunction> func_node = script->get_node(vsfn.func_id); - instance->base = node.ptr(); + if (func_node.is_null()) { + VisualScriptLanguage::singleton->debug_break_parse(get_script()->get_path(), 0, "No VisualScriptFunction typed start node in function: " + String(E->get())); + } - instance->id = F->key(); - instance->input_port_count = node->get_input_value_port_count(); - instance->input_ports = nullptr; - instance->output_port_count = node->get_output_value_port_count(); - instance->output_ports = nullptr; - instance->sequence_output_count = node->get_output_sequence_port_count(); - instance->sequence_index = function.node_count++; - instance->sequence_outputs = nullptr; - instance->pass_idx = -1; + ERR_CONTINUE(!func_node.is_valid()); - if (instance->input_port_count) { - instance->input_ports = memnew_arr(int, instance->input_port_count); - for (int i = 0; i < instance->input_port_count; i++) { - instance->input_ports[i] = -1; //if not assigned, will become default value - } + function.argument_count = func_node->get_argument_count(); + function.max_stack += function.argument_count; + function.flow_stack_size = func_node->is_stack_less() ? 0 : func_node->get_stack_size(); + max_input_args = MAX(max_input_args, function.argument_count); } - - if (instance->output_port_count) { - instance->output_ports = memnew_arr(int, instance->output_port_count); - for (int i = 0; i < instance->output_port_count; i++) { - instance->output_ports[i] = -1; //if not assigned, will output to trash + // Function nodes graphs. + Set<VisualScript::SequenceConnection> seqconns; + Set<VisualScript::DataConnection> dataconns; + Set<int> node_ids; + node_ids.insert(function.node); + { + List<int> nd_queue; + nd_queue.push_back(function.node); + while (!nd_queue.is_empty()) { + for (const Set<VisualScript::SequenceConnection>::Element *F = script->sequence_connections.front(); F; F = F->next()) { + if (nd_queue.front()->get() == F->get().from_node && !node_ids.has(F->get().to_node)) { + nd_queue.push_back(F->get().to_node); + node_ids.insert(F->get().to_node); + } + if (nd_queue.front()->get() == F->get().from_node && !seqconns.has(F->get())) { + seqconns.insert(F->get()); + } + } + nd_queue.pop_front(); } - } - - if (instance->sequence_output_count) { - instance->sequence_outputs = memnew_arr(VisualScriptNodeInstance *, instance->sequence_output_count); - for (int i = 0; i < instance->sequence_output_count; i++) { - instance->sequence_outputs[i] = nullptr; //if it remains null, flow ends here + HashMap<int, HashMap<int, Pair<int, int>>> dc_lut; // :: to -> to_port -> (from, from_port) + for (const Set<VisualScript::DataConnection>::Element *F = script->data_connections.front(); F; F = F->next()) { + dc_lut[F->get().to_node][F->get().to_port] = Pair<int, int>(F->get().from_node, F->get().from_port); + } + for (const Set<int>::Element *F = node_ids.front(); F; F = F->next()) { + nd_queue.push_back(F->get()); + } + List<int> dc_keys; + while (!nd_queue.is_empty()) { + int ky = nd_queue.front()->get(); + dc_lut[ky].get_key_list(&dc_keys); + for (const List<int>::Element *F = dc_keys.front(); F; F = F->next()) { + VisualScript::DataConnection dc; + dc.from_node = dc_lut[ky][F->get()].first; + dc.from_port = dc_lut[ky][F->get()].second; + dc.to_node = ky; + dc.to_port = F->get(); + dataconns.insert(dc); + nd_queue.push_back(dc.from_node); + node_ids.insert(dc.from_node); + } + dc_keys.clear(); // Necessary as get_key_list does a push_back not a set. + nd_queue.pop_front(); } } - if (Object::cast_to<VisualScriptLocalVar>(node.ptr()) || Object::cast_to<VisualScriptLocalVarSet>(*node)) { - //working memory is shared only for this node, for the same variables - Ref<VisualScriptLocalVar> vslv = node; - - StringName var_name; + //Multiple passes are required to set up this complex thing.. + //First create the nodes. + for (const Set<int>::Element *F = node_ids.front(); F; F = F->next()) { + Ref<VisualScriptNode> node = script->nodes[F->get()].node; + + VisualScriptNodeInstance *instance = node->instance(this); // Create instance. + ERR_FAIL_COND(!instance); + + instance->base = node.ptr(); + + instance->id = F->get(); + instance->input_port_count = node->get_input_value_port_count(); + instance->input_ports = NULL; + instance->output_port_count = node->get_output_value_port_count(); + instance->output_ports = NULL; + instance->sequence_output_count = node->get_output_sequence_port_count(); + instance->sequence_index = function.node_count++; + instance->sequence_outputs = NULL; + instance->pass_idx = -1; + + if (instance->input_port_count) { + instance->input_ports = memnew_arr(int, instance->input_port_count); + for (int i = 0; i < instance->input_port_count; i++) { + instance->input_ports[i] = -1; // If not assigned, will become default value. + } + } - if (Object::cast_to<VisualScriptLocalVar>(*node)) { - var_name = String(Object::cast_to<VisualScriptLocalVar>(*node)->get_var_name()).strip_edges(); - } else { - var_name = String(Object::cast_to<VisualScriptLocalVarSet>(*node)->get_var_name()).strip_edges(); + if (instance->output_port_count) { + instance->output_ports = memnew_arr(int, instance->output_port_count); + for (int i = 0; i < instance->output_port_count; i++) { + instance->output_ports[i] = -1; // If not assigned, will output to trash. + } } - if (!local_var_indices.has(var_name)) { - local_var_indices[var_name] = function.max_stack; - function.max_stack++; + if (instance->sequence_output_count) { + instance->sequence_outputs = memnew_arr(VisualScriptNodeInstance *, instance->sequence_output_count); + for (int i = 0; i < instance->sequence_output_count; i++) { + instance->sequence_outputs[i] = NULL; // If it remains null, flow ends here. + } } - instance->working_mem_idx = local_var_indices[var_name]; + if (Object::cast_to<VisualScriptLocalVar>(node.ptr()) || Object::cast_to<VisualScriptLocalVarSet>(*node)) { + // Working memory is shared only for this node, for the same variables. + Ref<VisualScriptLocalVar> vslv = node; - } else if (instance->get_working_memory_size()) { - instance->working_mem_idx = function.max_stack; - function.max_stack += instance->get_working_memory_size(); - } else { - instance->working_mem_idx = -1; //no working mem - } + StringName var_name; - max_input_args = MAX(max_input_args, instance->input_port_count); - max_output_args = MAX(max_output_args, instance->output_port_count); + if (Object::cast_to<VisualScriptLocalVar>(*node)) + var_name = String(Object::cast_to<VisualScriptLocalVar>(*node)->get_var_name()).strip_edges(); + else + var_name = String(Object::cast_to<VisualScriptLocalVarSet>(*node)->get_var_name()).strip_edges(); - instances[F->key()] = instance; - } + if (!local_var_indices.has(var_name)) { + local_var_indices[var_name] = function.max_stack; + function.max_stack++; + } - function.trash_pos = function.max_stack++; //create pos for trash + instance->working_mem_idx = local_var_indices[var_name]; - //second pass, do data connections + } else if (instance->get_working_memory_size()) { + instance->working_mem_idx = function.max_stack; + function.max_stack += instance->get_working_memory_size(); + } else { + instance->working_mem_idx = -1; //no working mem + } - for (const Set<VisualScript::DataConnection>::Element *F = E->get().data_connections.front(); F; F = F->next()) { - VisualScript::DataConnection dc = F->get(); - ERR_CONTINUE(!instances.has(dc.from_node)); - VisualScriptNodeInstance *from = instances[dc.from_node]; - ERR_CONTINUE(!instances.has(dc.to_node)); - VisualScriptNodeInstance *to = instances[dc.to_node]; - ERR_CONTINUE(dc.from_port >= from->output_port_count); - ERR_CONTINUE(dc.to_port >= to->input_port_count); + max_input_args = MAX(max_input_args, instance->input_port_count); + max_output_args = MAX(max_output_args, instance->output_port_count); - if (from->output_ports[dc.from_port] == -1) { - int stack_pos = function.max_stack++; - from->output_ports[dc.from_port] = stack_pos; + instances[F->get()] = instance; } - if (from->get_sequence_output_count() == 0 && to->dependencies.find(from) == -1) { - //if the node we are reading from has no output sequence, we must call step() before reading from it. - if (from->pass_idx == -1) { - from->pass_idx = function.pass_stack_size; - function.pass_stack_size++; + function.trash_pos = function.max_stack++; // create pos for trash + + // Second pass, do data connections. + for (const Set<VisualScript::DataConnection>::Element *F = dataconns.front(); F; F = F->next()) { + VisualScript::DataConnection dc = F->get(); + ERR_CONTINUE(!instances.has(dc.from_node)); + VisualScriptNodeInstance *from = instances[dc.from_node]; + ERR_CONTINUE(!instances.has(dc.to_node)); + VisualScriptNodeInstance *to = instances[dc.to_node]; + ERR_CONTINUE(dc.from_port >= from->output_port_count); + ERR_CONTINUE(dc.to_port >= to->input_port_count); + + if (from->output_ports[dc.from_port] == -1) { + int stack_pos = function.max_stack++; + from->output_ports[dc.from_port] = stack_pos; } - to->dependencies.push_back(from); - } - to->input_ports[dc.to_port] = from->output_ports[dc.from_port]; //read from wherever the stack is - } - - //third pass, do sequence connections + if (from->get_sequence_output_count() == 0 && to->dependencies.find(from) == -1) { + // If the node we are reading from has no output sequence, we must call step() before reading from it. + if (from->pass_idx == -1) { + from->pass_idx = function.pass_stack_size; + function.pass_stack_size++; + } + to->dependencies.push_back(from); + } - for (const Set<VisualScript::SequenceConnection>::Element *F = E->get().sequence_connections.front(); F; F = F->next()) { - VisualScript::SequenceConnection sc = F->get(); - ERR_CONTINUE(!instances.has(sc.from_node)); - VisualScriptNodeInstance *from = instances[sc.from_node]; - ERR_CONTINUE(!instances.has(sc.to_node)); - VisualScriptNodeInstance *to = instances[sc.to_node]; - ERR_CONTINUE(sc.from_output >= from->sequence_output_count); + to->input_ports[dc.to_port] = from->output_ports[dc.from_port]; // Read from wherever the stack is. + } - from->sequence_outputs[sc.from_output] = to; - } + // Third pass, do sequence connections. + for (const Set<VisualScript::SequenceConnection>::Element *F = seqconns.front(); F; F = F->next()) { + VisualScript::SequenceConnection sc = F->get(); + ERR_CONTINUE(!instances.has(sc.from_node)); + VisualScriptNodeInstance *from = instances[sc.from_node]; + ERR_CONTINUE(!instances.has(sc.to_node)); + VisualScriptNodeInstance *to = instances[sc.to_node]; + ERR_CONTINUE(sc.from_output >= from->sequence_output_count); - //fourth pass: - // 1) unassigned input ports to default values - // 2) connect unassigned output ports to trash + from->sequence_outputs[sc.from_output] = to; + } - for (const Map<int, VisualScript::Function::NodeData>::Element *F = E->get().nodes.front(); F; F = F->next()) { - ERR_CONTINUE(!instances.has(F->key())); + //fourth pass: + // 1) unassigned input ports to default values + // 2) connect unassigned output ports to trash + for (const Set<int>::Element *F = node_ids.front(); F; F = F->next()) { + ERR_CONTINUE(!instances.has(F->get())); - Ref<VisualScriptNode> node = F->get().node; - VisualScriptNodeInstance *instance = instances[F->key()]; + Ref<VisualScriptNode> node = script->nodes[F->get()].node; + VisualScriptNodeInstance *instance = instances[F->get()]; - // connect to default values - for (int i = 0; i < instance->input_port_count; i++) { - if (instance->input_ports[i] == -1) { - //unassigned, connect to default val - instance->input_ports[i] = default_values.size() | VisualScriptNodeInstance::INPUT_DEFAULT_VALUE_BIT; - default_values.push_back(node->get_default_input_value(i)); + // Connect to default values. + for (int i = 0; i < instance->input_port_count; i++) { + if (instance->input_ports[i] == -1) { + // Unassigned, connect to default val. + instance->input_ports[i] = default_values.size() | VisualScriptNodeInstance::INPUT_DEFAULT_VALUE_BIT; + default_values.push_back(node->get_default_input_value(i)); + } } - } - // connect to trash - for (int i = 0; i < instance->output_port_count; i++) { - if (instance->output_ports[i] == -1) { - instance->output_ports[i] = function.trash_pos; //trash is same for all + // Connect to trash. + for (int i = 0; i < instance->output_port_count; i++) { + if (instance->output_ports[i] == -1) { + instance->output_ports[i] = function.trash_pos; //trash is same for all + } } } - } - functions[E->key()] = function; + functions[E->get()] = function; + } } } @@ -2354,7 +2244,7 @@ Variant VisualScriptFunctionState::_signal_callback(const Variant **p_args, int Variant *working_mem = ((Variant *)stack.ptr()) + working_mem_index; - *working_mem = args; //arguments go to working mem. + *working_mem = args; // Arguments go to working mem. Variant ret = instance->_call_internal(function, stack.ptrw(), stack.size(), node, flow_stack_pos, pass, true, r_error); function = StringName(); //invalidate @@ -2388,7 +2278,7 @@ Variant VisualScriptFunctionState::resume(Array p_args) { Variant *working_mem = ((Variant *)stack.ptr()) + working_mem_index; - *working_mem = p_args; //arguments go to working mem. + *working_mem = p_args; // Arguments go to working mem. Variant ret = instance->_call_internal(function, stack.ptrw(), stack.size(), node, flow_stack_pos, pass, true, r_error); function = StringName(); //invalidate @@ -2498,7 +2388,7 @@ void VisualScriptLanguage::add_global_constant(const StringName &p_variable, con /* DEBUGGER FUNCTIONS */ bool VisualScriptLanguage::debug_break_parse(const String &p_file, int p_node, const String &p_error) { - //break because of parse error + // Break because of parse error. if (EngineDebugger::is_active() && Thread::get_caller_id() == Thread::get_main_id()) { _debug_parse_err_node = p_node; @@ -2666,7 +2556,7 @@ void VisualScriptLanguage::debug_get_stack_level_members(int p_level, List<Strin } void VisualScriptLanguage::debug_get_globals(List<String> *p_locals, List<Variant> *p_values, int p_max_subitems, int p_max_depth) { - //no globals are really reachable in gdscript + // No globals are really reachable in gdscript. } String VisualScriptLanguage::debug_parse_stack_level_expression(int p_level, const String &p_expression, int p_max_subitems, int p_max_depth) { @@ -2730,19 +2620,13 @@ void VisualScriptLanguage::get_registered_node_names(List<String> *r_names) { } VisualScriptLanguage::VisualScriptLanguage() { - notification = "_notification"; - _step = "_step"; - _subcall = "_subcall"; singleton = this; - _debug_parse_err_node = -1; - _debug_parse_err_file = ""; - _debug_call_stack_pos = 0; int dmcs = GLOBAL_DEF("debug/settings/visual_script/max_call_stack", 1024); ProjectSettings::get_singleton()->set_custom_property_info("debug/settings/visual_script/max_call_stack", PropertyInfo(Variant::INT, "debug/settings/visual_script/max_call_stack", PROPERTY_HINT_RANGE, "1024,4096,1,or_greater")); //minimum is 1024 if (EngineDebugger::is_active()) { - //debugging enabled! + // Debugging enabled! _debug_max_call_stack = dmcs; _call_stack = memnew_arr(CallLevel, _debug_max_call_stack + 1); diff --git a/modules/visual_script/visual_script.h b/modules/visual_script/visual_script.h index 59bdfb2fc3..72362e0ef4 100644 --- a/modules/visual_script/visual_script.h +++ b/modules/visual_script/visual_script.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -46,10 +46,10 @@ class VisualScriptNode : public Resource { friend class VisualScript; - Set<VisualScript *> scripts_used; + Ref<VisualScript> script_used; Array default_input_values; - bool breakpoint; + bool breakpoint = false; void _set_default_input_values(Array p_values); Array _get_default_input_values() const; @@ -83,20 +83,16 @@ public: virtual String get_text() const; virtual String get_category() const = 0; - //used by editor, this is not really saved + // Used by editor, this is not really saved. void set_breakpoint(bool p_breakpoint); bool is_breakpoint() const; virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) = 0; struct TypeGuess { - Variant::Type type; + Variant::Type type = Variant::NIL; StringName gdclass; Ref<Script> script; - - TypeGuess() { - type = Variant::NIL; - } }; virtual TypeGuess guess_output_type(TypeGuess *p_inputs, int p_output) const; @@ -106,27 +102,27 @@ public: class VisualScriptNodeInstance { friend class VisualScriptInstance; - friend class VisualScriptLanguage; //for debugger + friend class VisualScriptLanguage; // For debugger. - enum { //input argument addressing + enum { // Input argument addressing. INPUT_SHIFT = 1 << 24, INPUT_MASK = INPUT_SHIFT - 1, INPUT_DEFAULT_VALUE_BIT = INPUT_SHIFT, // from unassigned input port, using default value (edited by user) }; - int id; - int sequence_index; - VisualScriptNodeInstance **sequence_outputs; - int sequence_output_count; + int id = 0; + int sequence_index = 0; + VisualScriptNodeInstance **sequence_outputs = nullptr; + int sequence_output_count = 0; Vector<VisualScriptNodeInstance *> dependencies; - int *input_ports; - int input_port_count; - int *output_ports; - int output_port_count; - int working_mem_idx; - int pass_idx; + int *input_ports = nullptr; + int input_port_count = 0; + int *output_ports = nullptr; + int output_port_count = 0; + int working_mem_idx = 0; + int pass_idx = 0; - VisualScriptNode *base; + VisualScriptNode *base = nullptr; public: enum StartMode { @@ -138,13 +134,13 @@ public: enum { STEP_SHIFT = 1 << 24, STEP_MASK = STEP_SHIFT - 1, - STEP_FLAG_PUSH_STACK_BIT = STEP_SHIFT, //push bit to stack - STEP_FLAG_GO_BACK_BIT = STEP_SHIFT << 1, //go back to previous node - STEP_NO_ADVANCE_BIT = STEP_SHIFT << 2, //do not advance past this node - STEP_EXIT_FUNCTION_BIT = STEP_SHIFT << 3, //return from function - STEP_YIELD_BIT = STEP_SHIFT << 4, //yield (will find VisualScriptFunctionState state in first working memory) + STEP_FLAG_PUSH_STACK_BIT = STEP_SHIFT, // push bit to stack + STEP_FLAG_GO_BACK_BIT = STEP_SHIFT << 1, // go back to previous node + STEP_NO_ADVANCE_BIT = STEP_SHIFT << 2, // do not advance past this node + STEP_EXIT_FUNCTION_BIT = STEP_SHIFT << 3, // return from function + STEP_YIELD_BIT = STEP_SHIFT << 4, // yield (will find VisualScriptFunctionState state in first working memory) - FLOW_STACK_PUSHED_BIT = 1 << 30, //in flow stack, means bit was pushed (must go back here if end of sequence) + FLOW_STACK_PUSHED_BIT = 1 << 30, // in flow stack, means bit was pushed (must go back here if end of sequence) FLOW_STACK_MASK = FLOW_STACK_PUSHED_BIT - 1 }; @@ -157,7 +153,7 @@ public: virtual int get_working_memory_size() const { return 0; } - virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) = 0; //do a step, return which sequence port to go out + virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) = 0; // Do a step, return which sequence port to go out. Ref<VisualScriptNode> get_base_node() { return Ref<VisualScriptNode>(base); } @@ -178,7 +174,7 @@ public: uint64_t from_output : 16; uint64_t to_node : 24; }; - uint64_t id; + uint64_t id = 0; }; bool operator<(const SequenceConnection &p_connection) const { @@ -194,7 +190,7 @@ public: uint64_t to_node : 24; uint64_t to_port : 8; }; - uint64_t id; + uint64_t id = 0; }; bool operator<(const DataConnection &p_connection) const { @@ -208,37 +204,35 @@ private: StringName base_type; struct Argument { String name; - Variant::Type type; + Variant::Type type = Variant::Type::NIL; }; - struct Function { - struct NodeData { - Point2 pos; - Ref<VisualScriptNode> node; - }; - - Map<int, NodeData> nodes; - - Set<SequenceConnection> sequence_connections; + struct NodeData { + Point2 pos; + Ref<VisualScriptNode> node; + }; - Set<DataConnection> data_connections; + HashMap<int, NodeData> nodes; // Can be a sparse map. - int function_id; + Set<SequenceConnection> sequence_connections; + Set<DataConnection> data_connections; - Vector2 scroll; + Vector2 scroll; - Function() { function_id = -1; } + struct Function { + int func_id; + Function() { func_id = -1; } }; struct Variable { PropertyInfo info; Variant default_value; - bool _export; - // add getter & setter options here + bool _export = false; + // Add getter & setter options here. }; - Map<StringName, Function> functions; - Map<StringName, Variable> variables; + HashMap<StringName, Function> functions; + HashMap<StringName, Variable> variables; Map<StringName, Vector<Argument>> custom_signals; Vector<ScriptNetData> rpc_functions; Vector<ScriptNetData> rpc_variables; @@ -249,7 +243,7 @@ private: #ifdef TOOLS_ENABLED Set<PlaceHolderScriptInstance *> placeholders; - //void _update_placeholder(PlaceHolderScriptInstance *p_placeholder); + // void _update_placeholder(PlaceHolderScriptInstance *p_placeholder); virtual void _placeholder_erased(PlaceHolderScriptInstance *p_placeholder) override; void _update_placeholders(); #endif @@ -267,37 +261,38 @@ protected: public: bool inherits_script(const Ref<Script> &p_script) const override; - // TODO: Remove it in future when breaking changes are acceptable - StringName get_default_func() const; - void add_function(const StringName &p_name); + void set_scroll(const Vector2 &p_scroll); + Vector2 get_scroll() const; + + void add_function(const StringName &p_name, int p_func_node_id); bool has_function(const StringName &p_name) const; void remove_function(const StringName &p_name); void rename_function(const StringName &p_name, const StringName &p_new_name); - void set_function_scroll(const StringName &p_name, const Vector2 &p_scroll); - Vector2 get_function_scroll(const StringName &p_name) const; void get_function_list(List<StringName> *r_functions) const; int get_function_node_id(const StringName &p_name) const; void set_tool_enabled(bool p_enabled); - void add_node(const StringName &p_func, int p_id, const Ref<VisualScriptNode> &p_node, const Point2 &p_pos = Point2()); - void remove_node(const StringName &p_func, int p_id); - bool has_node(const StringName &p_func, int p_id) const; - Ref<VisualScriptNode> get_node(const StringName &p_func, int p_id) const; - void set_node_position(const StringName &p_func, int p_id, const Point2 &p_pos); - Point2 get_node_position(const StringName &p_func, int p_id) const; - void get_node_list(const StringName &p_func, List<int> *r_nodes) const; - - void sequence_connect(const StringName &p_func, int p_from_node, int p_from_output, int p_to_node); - void sequence_disconnect(const StringName &p_func, int p_from_node, int p_from_output, int p_to_node); - bool has_sequence_connection(const StringName &p_func, int p_from_node, int p_from_output, int p_to_node) const; - void get_sequence_connection_list(const StringName &p_func, List<SequenceConnection> *r_connection) const; - - void data_connect(const StringName &p_func, int p_from_node, int p_from_port, int p_to_node, int p_to_port); - void data_disconnect(const StringName &p_func, int p_from_node, int p_from_port, int p_to_node, int p_to_port); - bool has_data_connection(const StringName &p_func, int p_from_node, int p_from_port, int p_to_node, int p_to_port) const; - void get_data_connection_list(const StringName &p_func, List<DataConnection> *r_connection) const; - bool is_input_value_port_connected(const StringName &p_func, int p_node, int p_port) const; - bool get_input_value_port_connection_source(const StringName &p_func, int p_node, int p_port, int *r_node, int *r_port) const; + void add_node(int p_id, const Ref<VisualScriptNode> &p_node, const Point2 &p_pos = Point2()); + void remove_node(int p_id); + bool has_node(int p_id) const; + Ref<VisualScriptNode> get_node(int p_id) const; + void set_node_position(int p_id, const Point2 &p_pos); + Point2 get_node_position(int p_id) const; + void get_node_list(List<int> *r_nodes) const; + + void sequence_connect(int p_from_node, int p_from_output, int p_to_node); + void sequence_disconnect(int p_from_node, int p_from_output, int p_to_node); + bool has_sequence_connection(int p_from_node, int p_from_output, int p_to_node) const; + void get_sequence_connection_list(List<SequenceConnection> *r_connection) const; + Set<int> get_output_sequence_ports_connected(int from_node); + + void data_connect(int p_from_node, int p_from_port, int p_to_node, int p_to_port); + void data_disconnect(int p_from_node, int p_from_port, int p_to_node, int p_to_port); + bool has_data_connection(int p_from_node, int p_from_port, int p_to_node, int p_to_port) const; + void get_data_connection_list(List<DataConnection> *r_connection) const; + + bool is_input_value_port_connected(int p_node, int p_port) const; + bool get_input_value_port_connection_source(int p_node, int p_port, int *r_node, int *r_port) const; void add_variable(const StringName &p_name, const Variant &p_default_value = Variant(), bool p_export = false); bool has_variable(const StringName &p_name) const; @@ -389,35 +384,35 @@ public: }; class VisualScriptInstance : public ScriptInstance { - Object *owner; + Object *owner = nullptr; Ref<VisualScript> script; - Map<StringName, Variant> variables; //using variable path, not script + Map<StringName, Variant> variables; // Using variable path, not script. Map<int, VisualScriptNodeInstance *> instances; struct Function { - int node; - int max_stack; - int trash_pos; - int flow_stack_size; - int pass_stack_size; - int node_count; - int argument_count; + int node = 0; + int max_stack = 0; + int trash_pos = 0; + int flow_stack_size = 0; + int pass_stack_size = 0; + int node_count = 0; + int argument_count = 0; }; Map<StringName, Function> functions; Vector<Variant> default_values; - int max_input_args, max_output_args; + int max_input_args = 0; + int max_output_args = 0; StringName source; void _dependency_step(VisualScriptNodeInstance *node, int p_pass, int *pass_stack, const Variant **input_args, Variant **output_args, Variant *variant_stack, Callable::CallError &r_error, String &error_str, VisualScriptNodeInstance **r_error_node); Variant _call_internal(const StringName &p_method, void *p_stack, int p_stack_size, VisualScriptNodeInstance *p_node, int p_flow_stack_pos, int p_pass, bool p_resuming_yield, Callable::CallError &r_error); - //Map<StringName,Function> functions; - friend class VisualScriptFunctionState; //for yield - friend class VisualScriptLanguage; //for debugger + friend class VisualScriptFunctionState; // For yield. + friend class VisualScriptLanguage; // For debugger. public: virtual bool set(const StringName &p_name, const Variant &p_value); virtual bool get(const StringName &p_name, Variant &r_ret) const; @@ -481,14 +476,14 @@ class VisualScriptFunctionState : public Reference { ObjectID instance_id; ObjectID script_id; - VisualScriptInstance *instance; + VisualScriptInstance *instance = nullptr; StringName function; Vector<uint8_t> stack; - int working_mem_index; - int variant_stack_size; - VisualScriptNodeInstance *node; - int flow_stack_pos; - int pass; + int working_mem_index = 0; + int variant_stack_size = 0; + VisualScriptNodeInstance *node = nullptr; + int flow_stack_pos = 0; + int pass = 0; Variant _signal_callback(const Variant **p_args, int p_argcount, Callable::CallError &r_error); @@ -509,25 +504,25 @@ class VisualScriptLanguage : public ScriptLanguage { Map<String, VisualScriptNodeRegisterFunc> register_funcs; struct CallLevel { - Variant *stack; - Variant **work_mem; - const StringName *function; - VisualScriptInstance *instance; - int *current_id; + Variant *stack = nullptr; + Variant **work_mem = nullptr; + const StringName *function = nullptr; + VisualScriptInstance *instance = nullptr; + int *current_id = nullptr; }; - int _debug_parse_err_node; - String _debug_parse_err_file; + int _debug_parse_err_node = -1; + String _debug_parse_err_file = ""; String _debug_error; - int _debug_call_stack_pos; + int _debug_call_stack_pos = 0; int _debug_max_call_stack; CallLevel *_call_stack; public: - StringName notification; + StringName notification = "_notification"; StringName _get_output_port_unsequenced; - StringName _step; - StringName _subcall; + StringName _step = "_step"; + StringName _subcall = "_subcall"; static VisualScriptLanguage *singleton; @@ -538,7 +533,7 @@ public: _FORCE_INLINE_ void enter_function(VisualScriptInstance *p_instance, const StringName *p_function, Variant *p_stack, Variant **p_work_mem, int *current_id) { if (Thread::get_main_id() != Thread::get_caller_id()) { - return; //no support for other threads than main for now + return; // No support for other threads than main for now. } if (EngineDebugger::get_script_debugger()->get_lines_left() > 0 && EngineDebugger::get_script_debugger()->get_depth() >= 0) { @@ -546,7 +541,7 @@ public: } if (_debug_call_stack_pos >= _debug_max_call_stack) { - //stack overflow + // Stack overflow. _debug_error = "Stack Overflow (Stack Size: " + itos(_debug_max_call_stack) + ")"; EngineDebugger::get_script_debugger()->debug(this); return; @@ -562,7 +557,7 @@ public: _FORCE_INLINE_ void exit_function() { if (Thread::get_main_id() != Thread::get_caller_id()) { - return; //no support for other threads than main for now + return; // No support for other threads than main for now. } if (EngineDebugger::get_script_debugger()->get_lines_left() > 0 && EngineDebugger::get_script_debugger()->get_depth() >= 0) { @@ -640,7 +635,7 @@ public: ~VisualScriptLanguage(); }; -//aid for registering +// Aid for registering. template <class T> static Ref<VisualScriptNode> create_node_generic(const String &p_name) { Ref<T> node; diff --git a/modules/visual_script/visual_script_builtin_funcs.cpp b/modules/visual_script/visual_script_builtin_funcs.cpp index fe0c399f8d..7ca14fbca8 100644 --- a/modules/visual_script/visual_script_builtin_funcs.cpp +++ b/modules/visual_script/visual_script_builtin_funcs.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -63,7 +63,7 @@ const char *VisualScriptBuiltinFunc::func_name[VisualScriptBuiltinFunc::FUNC_MAX "is_inf", "ease", "step_decimals", - "stepify", + "snapped", "lerp", "inverse_lerp", "range_lerp", @@ -101,7 +101,6 @@ const char *VisualScriptBuiltinFunc::func_name[VisualScriptBuiltinFunc::FUNC_MAX "str2var", "var2bytes", "bytes2var", - "color_named", "smoothstep", "posmod", "lerp_angle", @@ -192,7 +191,7 @@ int VisualScriptBuiltinFunc::get_func_argument_count(BuiltinFunc p_func) { case MATH_POSMOD: case MATH_POW: case MATH_EASE: - case MATH_STEPIFY: + case MATH_SNAPPED: case MATH_RANDF_RANGE: case MATH_RANDI_RANGE: case MATH_POLAR2CARTESIAN: @@ -200,7 +199,6 @@ int VisualScriptBuiltinFunc::get_func_argument_count(BuiltinFunc p_func) { case LOGIC_MAX: case LOGIC_MIN: case TYPE_CONVERT: - case COLORN: return 2; case MATH_LERP: case MATH_LERP_ANGLE: @@ -309,7 +307,7 @@ PropertyInfo VisualScriptBuiltinFunc::get_input_value_port_info(int p_idx) const case MATH_STEP_DECIMALS: { return PropertyInfo(Variant::FLOAT, "step"); } break; - case MATH_STEPIFY: { + case MATH_SNAPPED: { if (p_idx == 0) { return PropertyInfo(Variant::FLOAT, "s"); } else { @@ -476,13 +474,6 @@ PropertyInfo VisualScriptBuiltinFunc::get_input_value_port_info(int p_idx) const return PropertyInfo(Variant::BOOL, "allow_objects"); } } break; - case COLORN: { - if (p_idx == 0) { - return PropertyInfo(Variant::STRING, "name"); - } else { - return PropertyInfo(Variant::FLOAT, "alpha"); - } - } break; case FUNC_MAX: { } } @@ -537,7 +528,7 @@ PropertyInfo VisualScriptBuiltinFunc::get_output_value_port_info(int p_idx) cons case MATH_STEP_DECIMALS: { t = Variant::INT; } break; - case MATH_STEPIFY: + case MATH_SNAPPED: case MATH_LERP: case MATH_LERP_ANGLE: case MATH_INVERSE_LERP: @@ -635,9 +626,6 @@ PropertyInfo VisualScriptBuiltinFunc::get_output_value_port_info(int p_idx) cons t = Variant::BOOL; } } break; - case COLORN: { - t = Variant::COLOR; - } break; case FUNC_MAX: { } } @@ -659,7 +647,7 @@ String VisualScriptBuiltinFunc::get_caption() const { void VisualScriptBuiltinFunc::set_func(BuiltinFunc p_which) { ERR_FAIL_INDEX(p_which, FUNC_MAX); func = p_which; - _change_notify(); + notify_property_list_changed(); ports_changed_notify(); } @@ -805,10 +793,10 @@ void VisualScriptBuiltinFunc::exec_func(BuiltinFunc p_func, const Variant **p_in VALIDATE_ARG_NUM(0); *r_return = Math::step_decimals((double)*p_inputs[0]); } break; - case VisualScriptBuiltinFunc::MATH_STEPIFY: { + case VisualScriptBuiltinFunc::MATH_SNAPPED: { VALIDATE_ARG_NUM(0); VALIDATE_ARG_NUM(1); - *r_return = Math::stepify((double)*p_inputs[0], (double)*p_inputs[1]); + *r_return = Math::snapped((double)*p_inputs[0], (double)*p_inputs[1]); } break; case VisualScriptBuiltinFunc::MATH_LERP: { VALIDATE_ARG_NUM(0); @@ -1176,15 +1164,6 @@ void VisualScriptBuiltinFunc::exec_func(BuiltinFunc p_func, const Variant **p_in *r_return = ret; } break; - case VisualScriptBuiltinFunc::COLORN: { - VALIDATE_ARG_NUM(1); - - Color color = Color::named(*p_inputs[0]); - color.a = *p_inputs[1]; - - *r_return = String(color); - - } break; default: { } } @@ -1254,7 +1233,7 @@ void VisualScriptBuiltinFunc::_bind_methods() { BIND_ENUM_CONSTANT(MATH_ISINF); BIND_ENUM_CONSTANT(MATH_EASE); BIND_ENUM_CONSTANT(MATH_STEP_DECIMALS); - BIND_ENUM_CONSTANT(MATH_STEPIFY); + BIND_ENUM_CONSTANT(MATH_SNAPPED); BIND_ENUM_CONSTANT(MATH_LERP); BIND_ENUM_CONSTANT(MATH_INVERSE_LERP); BIND_ENUM_CONSTANT(MATH_RANGE_LERP); @@ -1292,7 +1271,6 @@ void VisualScriptBuiltinFunc::_bind_methods() { BIND_ENUM_CONSTANT(STR_TO_VAR); BIND_ENUM_CONSTANT(VAR_TO_BYTES); BIND_ENUM_CONSTANT(BYTES_TO_VAR); - BIND_ENUM_CONSTANT(COLORN); BIND_ENUM_CONSTANT(MATH_SMOOTHSTEP); BIND_ENUM_CONSTANT(MATH_POSMOD); BIND_ENUM_CONSTANT(MATH_LERP_ANGLE); @@ -1344,7 +1322,7 @@ void register_visual_script_builtin_func_node() { VisualScriptLanguage::singleton->add_register_func("functions/built_in/ease", create_builtin_func_node<VisualScriptBuiltinFunc::MATH_EASE>); VisualScriptLanguage::singleton->add_register_func("functions/built_in/step_decimals", create_builtin_func_node<VisualScriptBuiltinFunc::MATH_STEP_DECIMALS>); - VisualScriptLanguage::singleton->add_register_func("functions/built_in/stepify", create_builtin_func_node<VisualScriptBuiltinFunc::MATH_STEPIFY>); + VisualScriptLanguage::singleton->add_register_func("functions/built_in/snapped", create_builtin_func_node<VisualScriptBuiltinFunc::MATH_SNAPPED>); VisualScriptLanguage::singleton->add_register_func("functions/built_in/lerp", create_builtin_func_node<VisualScriptBuiltinFunc::MATH_LERP>); VisualScriptLanguage::singleton->add_register_func("functions/built_in/lerp_angle", create_builtin_func_node<VisualScriptBuiltinFunc::MATH_LERP_ANGLE>); VisualScriptLanguage::singleton->add_register_func("functions/built_in/inverse_lerp", create_builtin_func_node<VisualScriptBuiltinFunc::MATH_INVERSE_LERP>); @@ -1388,5 +1366,4 @@ void register_visual_script_builtin_func_node() { VisualScriptLanguage::singleton->add_register_func("functions/built_in/str2var", create_builtin_func_node<VisualScriptBuiltinFunc::STR_TO_VAR>); VisualScriptLanguage::singleton->add_register_func("functions/built_in/var2bytes", create_builtin_func_node<VisualScriptBuiltinFunc::VAR_TO_BYTES>); VisualScriptLanguage::singleton->add_register_func("functions/built_in/bytes2var", create_builtin_func_node<VisualScriptBuiltinFunc::BYTES_TO_VAR>); - VisualScriptLanguage::singleton->add_register_func("functions/built_in/color_named", create_builtin_func_node<VisualScriptBuiltinFunc::COLORN>); } diff --git a/modules/visual_script/visual_script_builtin_funcs.h b/modules/visual_script/visual_script_builtin_funcs.h index 361b445e30..1fafaf1d98 100644 --- a/modules/visual_script/visual_script_builtin_funcs.h +++ b/modules/visual_script/visual_script_builtin_funcs.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -63,7 +63,7 @@ public: MATH_ISINF, MATH_EASE, MATH_STEP_DECIMALS, - MATH_STEPIFY, + MATH_SNAPPED, MATH_LERP, MATH_INVERSE_LERP, MATH_RANGE_LERP, @@ -101,7 +101,6 @@ public: STR_TO_VAR, VAR_TO_BYTES, BYTES_TO_VAR, - COLORN, MATH_SMOOTHSTEP, MATH_POSMOD, MATH_LERP_ANGLE, diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp index 19de5d4adc..fcd55b3049 100644 --- a/modules/visual_script/visual_script_editor.cpp +++ b/modules/visual_script/visual_script_editor.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -61,7 +61,7 @@ protected: } void _sig_changed() { - _change_notify(); + notify_property_list_changed(); emit_signal("changed"); } @@ -172,7 +172,7 @@ protected: public: void edit(const StringName &p_sig) { sig = p_sig; - _change_notify(); + notify_property_list_changed(); } VisualScriptEditorSignalEdit() { undo_redo = nullptr; } @@ -195,11 +195,10 @@ protected: } void _var_changed() { - _change_notify(); + notify_property_list_changed(); emit_signal("changed"); } void _var_value_changed() { - _change_notify("value"); //so the whole tree is not redrawn, makes editing smoother in general emit_signal("changed"); } @@ -227,6 +226,19 @@ protected: undo_redo->create_action(TTR("Set Variable Type")); undo_redo->add_do_method(script.ptr(), "set_variable_info", var, dc); undo_redo->add_undo_method(script.ptr(), "set_variable_info", var, d); + + // Setting the default value. + Variant::Type type = (Variant::Type)(int)p_value; + if (type != Variant::NIL) { + Variant default_value; + Callable::CallError ce; + Variant::construct(type, default_value, nullptr, 0, ce); + if (ce.error == Callable::CallError::CALL_OK) { + undo_redo->add_do_method(script.ptr(), "set_variable_default_value", var, default_value); + undo_redo->add_undo_method(script.ptr(), "set_variable_default_value", var, dc["value"]); + } + } + undo_redo->add_do_method(this, "_var_changed"); undo_redo->add_undo_method(this, "_var_changed"); undo_redo->commit_action(); @@ -309,7 +321,7 @@ protected: } p_list->push_back(PropertyInfo(Variant::INT, "type", PROPERTY_HINT_ENUM, argt)); p_list->push_back(PropertyInfo(script->get_variable_info(var).type, "value", script->get_variable_info(var).hint, script->get_variable_info(var).hint_string, PROPERTY_USAGE_DEFAULT)); - // Update this when PropertyHint changes + // Update this when PropertyHint changes. p_list->push_back(PropertyInfo(Variant::INT, "hint", PROPERTY_HINT_ENUM, "None,Range,ExpRange,Enum,ExpEasing,Length,SpriteFrame,KeyAccel,Flags,Layers2dRender,Layers2dPhysics,Layer3dRender,Layer3dPhysics,File,Dir,GlobalFile,GlobalDir,ResourceType,MultilineText,PlaceholderText,ColorNoAlpha,ImageCompressLossy,ImageCompressLossLess,ObjectId,String,NodePathToEditedNode,MethodOfVariantType,MethodOfBaseType,MethodOfInstance,MethodOfScript,PropertyOfVariantType,PropertyOfBaseType,PropertyOfInstance,PropertyOfScript,ObjectTooBig,NodePathValidTypes")); p_list->push_back(PropertyInfo(Variant::STRING, "hint_string")); p_list->push_back(PropertyInfo(Variant::BOOL, "export")); @@ -318,7 +330,7 @@ protected: public: void edit(const StringName &p_var) { var = p_var; - _change_notify(); + notify_property_list_changed(); } VisualScriptEditorVariableEdit() { undo_redo = nullptr; } @@ -546,39 +558,29 @@ static Color _color_from_type(Variant::Type p_type, bool dark_theme = true) { void VisualScriptEditor::_update_graph_connections() { graph->clear_connections(); - List<StringName> funcs; - script->get_function_list(&funcs); + List<VisualScript::SequenceConnection> sequence_conns; + script->get_sequence_connection_list(&sequence_conns); - if (funcs.size() <= 0) { - updating_graph = false; - return; + for (List<VisualScript::SequenceConnection>::Element *E = sequence_conns.front(); E; E = E->next()) { + graph->connect_node(itos(E->get().from_node), E->get().from_output, itos(E->get().to_node), 0); } - for (List<StringName>::Element *F = funcs.front(); F; F = F->next()) { - List<VisualScript::SequenceConnection> sequence_conns; - script->get_sequence_connection_list(F->get(), &sequence_conns); - - for (List<VisualScript::SequenceConnection>::Element *E = sequence_conns.front(); E; E = E->next()) { - graph->connect_node(itos(E->get().from_node), E->get().from_output, itos(E->get().to_node), 0); - } - - List<VisualScript::DataConnection> data_conns; - script->get_data_connection_list(F->get(), &data_conns); + List<VisualScript::DataConnection> data_conns; + script->get_data_connection_list(&data_conns); - for (List<VisualScript::DataConnection>::Element *E = data_conns.front(); E; E = E->next()) { - VisualScript::DataConnection dc = E->get(); + for (List<VisualScript::DataConnection>::Element *E = data_conns.front(); E; E = E->next()) { + VisualScript::DataConnection dc = E->get(); - Ref<VisualScriptNode> from_node = script->get_node(F->get(), E->get().from_node); - Ref<VisualScriptNode> to_node = script->get_node(F->get(), E->get().to_node); + Ref<VisualScriptNode> from_node = script->get_node(E->get().from_node); + Ref<VisualScriptNode> to_node = script->get_node(E->get().to_node); - if (to_node->has_input_sequence_port()) { - dc.to_port++; - } + if (to_node->has_input_sequence_port()) { + dc.to_port++; + } - dc.from_port += from_node->get_output_sequence_port_count(); + dc.from_port += from_node->get_output_sequence_port_count(); - graph->connect_node(itos(E->get().from_node), dc.from_port, itos(E->get().to_node), dc.to_port); - } + graph->connect_node(itos(E->get().from_node), dc.from_port, itos(E->get().to_node), dc.to_port); } } @@ -605,17 +607,6 @@ void VisualScriptEditor::_update_graph(int p_only_id) { } } } - - List<StringName> funcs; - script->get_function_list(&funcs); - - if (funcs.size() <= 0) { - graph->hide(); - select_func_text->show(); - updating_graph = false; - return; - } - graph->show(); select_func_text->hide(); @@ -655,348 +646,351 @@ void VisualScriptEditor::_update_graph(int p_only_id) { }; Ref<Texture2D> seq_port = Control::get_theme_icon("VisualShaderPort", "EditorIcons"); + List<int> node_ids; + script->get_node_list(&node_ids); - for (List<StringName>::Element *F = funcs.front(); F; F = F->next()) { // loop through all the functions - - List<int> ids; - script->get_node_list(F->get(), &ids); - StringName editor_icons = "EditorIcons"; + List<int> ids; + script->get_node_list(&ids); + StringName editor_icons = "EditorIcons"; - for (List<int>::Element *E = ids.front(); E; E = E->next()) { - if (p_only_id >= 0 && p_only_id != E->get()) { - continue; - } + for (List<int>::Element *E = ids.front(); E; E = E->next()) { + if (p_only_id >= 0 && p_only_id != E->get()) { + continue; + } - Ref<VisualScriptNode> node = script->get_node(F->get(), E->get()); - Vector2 pos = script->get_node_position(F->get(), E->get()); + Ref<VisualScriptNode> node = script->get_node(E->get()); + Vector2 pos = script->get_node_position(E->get()); - GraphNode *gnode = memnew(GraphNode); - gnode->set_title(node->get_caption()); - gnode->set_position_offset(pos * EDSCALE); - if (error_line == E->get()) { - gnode->set_overlay(GraphNode::OVERLAY_POSITION); - } else if (node->is_breakpoint()) { - gnode->set_overlay(GraphNode::OVERLAY_BREAKPOINT); - } + GraphNode *gnode = memnew(GraphNode); + gnode->set_title(node->get_caption()); + gnode->set_position_offset(pos * EDSCALE); + if (error_line == E->get()) { + gnode->set_overlay(GraphNode::OVERLAY_POSITION); + } else if (node->is_breakpoint()) { + gnode->set_overlay(GraphNode::OVERLAY_BREAKPOINT); + } - gnode->set_meta("__vnode", node); - gnode->set_name(itos(E->get())); - gnode->connect("dragged", callable_mp(this, &VisualScriptEditor::_node_moved), varray(E->get())); - gnode->connect("close_request", callable_mp(this, &VisualScriptEditor::_remove_node), varray(E->get()), CONNECT_DEFERRED); + gnode->set_meta("__vnode", node); + gnode->set_name(itos(E->get())); + gnode->connect("dragged", callable_mp(this, &VisualScriptEditor::_node_moved), varray(E->get())); + gnode->connect("close_request", callable_mp(this, &VisualScriptEditor::_remove_node), varray(E->get()), CONNECT_DEFERRED); - if (E->get() != script->get_function_node_id(F->get())) { - //function can't be erased + { + Ref<VisualScriptFunction> v = node; + if (!v.is_valid()) { gnode->set_show_close_button(true); } + } - bool has_gnode_text = false; + bool has_gnode_text = false; - Ref<VisualScriptLists> nd_list = node; - bool is_vslist = nd_list.is_valid(); - if (is_vslist) { - HBoxContainer *hbnc = memnew(HBoxContainer); + Ref<VisualScriptLists> nd_list = node; + bool is_vslist = nd_list.is_valid(); + if (is_vslist) { + HBoxContainer *hbnc = memnew(HBoxContainer); + if (nd_list->is_input_port_editable()) { + has_gnode_text = true; + Button *btn = memnew(Button); + btn->set_text(TTR("Add Input Port")); + hbnc->add_child(btn); + btn->connect("pressed", callable_mp(this, &VisualScriptEditor::_add_input_port), varray(E->get()), CONNECT_DEFERRED); + } + if (nd_list->is_output_port_editable()) { if (nd_list->is_input_port_editable()) { - has_gnode_text = true; - Button *btn = memnew(Button); - btn->set_text(TTR("Add Input Port")); - hbnc->add_child(btn); - btn->connect("pressed", callable_mp(this, &VisualScriptEditor::_add_input_port), varray(E->get()), CONNECT_DEFERRED); - } - if (nd_list->is_output_port_editable()) { - if (nd_list->is_input_port_editable()) { - hbnc->add_spacer(); - } - has_gnode_text = true; - Button *btn = memnew(Button); - btn->set_text(TTR("Add Output Port")); - hbnc->add_child(btn); - btn->connect("pressed", callable_mp(this, &VisualScriptEditor::_add_output_port), varray(E->get()), CONNECT_DEFERRED); + hbnc->add_spacer(); } - gnode->add_child(hbnc); - } else if (Object::cast_to<VisualScriptExpression>(node.ptr())) { has_gnode_text = true; - LineEdit *line_edit = memnew(LineEdit); - line_edit->set_text(node->get_text()); - line_edit->set_expand_to_text_length(true); - line_edit->add_theme_font_override("font", get_theme_font("source", "EditorFonts")); - line_edit->add_theme_font_size_override("font_size", get_theme_font_size("source_size", "EditorFonts")); - gnode->add_child(line_edit); - line_edit->connect("text_changed", callable_mp(this, &VisualScriptEditor::_expression_text_changed), varray(E->get())); - } else { - String text = node->get_text(); - if (!text.empty()) { - has_gnode_text = true; - Label *label = memnew(Label); - label->set_text(text); - gnode->add_child(label); - } + Button *btn = memnew(Button); + btn->set_text(TTR("Add Output Port")); + hbnc->add_child(btn); + btn->connect("pressed", callable_mp(this, &VisualScriptEditor::_add_output_port), varray(E->get()), CONNECT_DEFERRED); } - - if (Object::cast_to<VisualScriptComment>(node.ptr())) { - Ref<VisualScriptComment> vsc = node; - gnode->set_comment(true); - gnode->set_resizable(true); - gnode->set_custom_minimum_size(vsc->get_size() * EDSCALE); - gnode->connect("resize_request", callable_mp(this, &VisualScriptEditor::_comment_node_resized), varray(E->get())); + gnode->add_child(hbnc); + } else if (Object::cast_to<VisualScriptExpression>(node.ptr())) { + has_gnode_text = true; + LineEdit *line_edit = memnew(LineEdit); + line_edit->set_text(node->get_text()); + line_edit->set_expand_to_text_length(true); + line_edit->add_theme_font_override("font", get_theme_font("source", "EditorFonts")); + gnode->add_child(line_edit); + line_edit->connect("text_changed", callable_mp(this, &VisualScriptEditor::_expression_text_changed), varray(E->get())); + } else { + String text = node->get_text(); + if (!text.is_empty()) { + has_gnode_text = true; + Label *label = memnew(Label); + label->set_text(text); + gnode->add_child(label); } + } - if (node_styles.has(node->get_category())) { - Ref<StyleBoxFlat> sbf = node_styles[node->get_category()]; - if (gnode->is_comment()) { - sbf = EditorNode::get_singleton()->get_theme_base()->get_theme()->get_stylebox("comment", "GraphNode"); - } + if (Object::cast_to<VisualScriptComment>(node.ptr())) { + Ref<VisualScriptComment> vsc = node; + gnode->set_comment(true); + gnode->set_resizable(true); + gnode->set_custom_minimum_size(vsc->get_size() * EDSCALE); + gnode->connect("resize_request", callable_mp(this, &VisualScriptEditor::_comment_node_resized), varray(E->get())); + } - Color c = sbf->get_border_color(); - Color ic = c; - c.a = 1; - if (EditorSettings::get_singleton()->get("interface/theme/use_graph_node_headers")) { - Color mono_color; - if (((c.r + c.g + c.b) / 3) < 0.7) { - mono_color = Color(1.0, 1.0, 1.0); - ic = Color(0.0, 0.0, 0.0, 0.7); - } else { - mono_color = Color(0.0, 0.0, 0.0); - ic = Color(1.0, 1.0, 1.0, 0.7); - } - mono_color.a = 0.85; - c = mono_color; + if (node_styles.has(node->get_category())) { + Ref<StyleBoxFlat> sbf = node_styles[node->get_category()]; + if (gnode->is_comment()) { + sbf = EditorNode::get_singleton()->get_theme_base()->get_theme()->get_stylebox("comment", "GraphNode"); + } + + Color c = sbf->get_border_color(); + Color ic = c; + c.a = 1; + if (EditorSettings::get_singleton()->get("interface/theme/use_graph_node_headers")) { + Color mono_color; + if (((c.r + c.g + c.b) / 3) < 0.7) { + mono_color = Color(1.0, 1.0, 1.0); + ic = Color(0.0, 0.0, 0.0, 0.7); + } else { + mono_color = Color(0.0, 0.0, 0.0); + ic = Color(1.0, 1.0, 1.0, 0.7); } - gnode->add_theme_color_override("title_color", c); - c.a = 0.7; - gnode->add_theme_color_override("close_color", c); - gnode->add_theme_color_override("resizer_color", ic); - gnode->add_theme_style_override("frame", sbf); + mono_color.a = 0.85; + c = mono_color; } + gnode->add_theme_color_override("title_color", c); + c.a = 0.7; + gnode->add_theme_color_override("close_color", c); + gnode->add_theme_color_override("resizer_color", ic); + gnode->add_theme_style_override("frame", sbf); + } - const Color mono_color = get_theme_color("mono_color", "Editor"); + const Color mono_color = get_theme_color("mono_color", "Editor"); - int slot_idx = 0; + int slot_idx = 0; - bool single_seq_output = node->get_output_sequence_port_count() == 1 && node->get_output_sequence_port_text(0) == String(); - if ((node->has_input_sequence_port() || single_seq_output) || has_gnode_text) { - // IF has_gnode_text is true BUT we have no sequence ports to draw (in here), - // we still draw the disabled default ones to shift up the slots by one, - // so the slots DON'T start with the content text. + bool single_seq_output = node->get_output_sequence_port_count() == 1 && node->get_output_sequence_port_text(0) == String(); + if ((node->has_input_sequence_port() || single_seq_output) || has_gnode_text) { + // IF has_gnode_text is true BUT we have no sequence ports to draw (in here), + // we still draw the disabled default ones to shift up the slots by one, + // so the slots DON'T start with the content text. - // IF has_gnode_text is false, but we DO want to draw default sequence ports, - // we draw a dummy text to take up the position of the sequence nodes, so all the other ports are still aligned correctly. - if (!has_gnode_text) { - Label *dummy = memnew(Label); - dummy->set_text(" "); - gnode->add_child(dummy); - } - gnode->set_slot(0, node->has_input_sequence_port(), TYPE_SEQUENCE, mono_color, single_seq_output, TYPE_SEQUENCE, mono_color, seq_port, seq_port); - slot_idx++; + // IF has_gnode_text is false, but we DO want to draw default sequence ports, + // we draw a dummy text to take up the position of the sequence nodes, so all the other ports are still aligned correctly. + if (!has_gnode_text) { + Label *dummy = memnew(Label); + dummy->set_text(" "); + gnode->add_child(dummy); } + gnode->set_slot(0, node->has_input_sequence_port(), TYPE_SEQUENCE, mono_color, single_seq_output, TYPE_SEQUENCE, mono_color, seq_port, seq_port); + slot_idx++; + } - int mixed_seq_ports = 0; + int mixed_seq_ports = 0; - if (!single_seq_output) { - if (node->has_mixed_input_and_sequence_ports()) { - mixed_seq_ports = node->get_output_sequence_port_count(); - } else { - for (int i = 0; i < node->get_output_sequence_port_count(); i++) { - Label *text2 = memnew(Label); - text2->set_text(node->get_output_sequence_port_text(i)); - text2->set_align(Label::ALIGN_RIGHT); - gnode->add_child(text2); - gnode->set_slot(slot_idx, false, 0, Color(), true, TYPE_SEQUENCE, mono_color, seq_port, seq_port); - slot_idx++; - } + if (!single_seq_output) { + if (node->has_mixed_input_and_sequence_ports()) { + mixed_seq_ports = node->get_output_sequence_port_count(); + } else { + for (int i = 0; i < node->get_output_sequence_port_count(); i++) { + Label *text2 = memnew(Label); + text2->set_text(node->get_output_sequence_port_text(i)); + text2->set_align(Label::ALIGN_RIGHT); + gnode->add_child(text2); + gnode->set_slot(slot_idx, false, 0, Color(), true, TYPE_SEQUENCE, mono_color, seq_port, seq_port); + slot_idx++; } } + } - for (int i = 0; i < MAX(node->get_output_value_port_count(), MAX(mixed_seq_ports, node->get_input_value_port_count())); i++) { - bool left_ok = false; - Variant::Type left_type = Variant::NIL; - String left_name; + for (int i = 0; i < MAX(node->get_output_value_port_count(), MAX(mixed_seq_ports, node->get_input_value_port_count())); i++) { + bool left_ok = false; + Variant::Type left_type = Variant::NIL; + String left_name; - if (i < node->get_input_value_port_count()) { - PropertyInfo pi = node->get_input_value_port_info(i); - left_ok = true; - left_type = pi.type; - left_name = pi.name; - } + if (i < node->get_input_value_port_count()) { + PropertyInfo pi = node->get_input_value_port_info(i); + left_ok = true; + left_type = pi.type; + left_name = pi.name; + } - bool right_ok = false; - Variant::Type right_type = Variant::NIL; - String right_name; + bool right_ok = false; + Variant::Type right_type = Variant::NIL; + String right_name; - if (i >= mixed_seq_ports && i < node->get_output_value_port_count() + mixed_seq_ports) { - PropertyInfo pi = node->get_output_value_port_info(i - mixed_seq_ports); - right_ok = true; - right_type = pi.type; - right_name = pi.name; + if (i >= mixed_seq_ports && i < node->get_output_value_port_count() + mixed_seq_ports) { + PropertyInfo pi = node->get_output_value_port_info(i - mixed_seq_ports); + right_ok = true; + right_type = pi.type; + right_name = pi.name; + } + VBoxContainer *vbc = memnew(VBoxContainer); + HBoxContainer *hbc = memnew(HBoxContainer); + HBoxContainer *hbc2 = memnew(HBoxContainer); + vbc->add_child(hbc); + vbc->add_child(hbc2); + if (left_ok) { + Ref<Texture2D> t; + if (left_type >= 0 && left_type < Variant::VARIANT_MAX) { + t = type_icons[left_type]; + } + if (t.is_valid()) { + TextureRect *tf = memnew(TextureRect); + tf->set_texture(t); + tf->set_stretch_mode(TextureRect::STRETCH_KEEP_CENTERED); + hbc->add_child(tf); } - VBoxContainer *vbc = memnew(VBoxContainer); - HBoxContainer *hbc = memnew(HBoxContainer); - HBoxContainer *hbc2 = memnew(HBoxContainer); - vbc->add_child(hbc); - vbc->add_child(hbc2); - if (left_ok) { - Ref<Texture2D> t; - if (left_type >= 0 && left_type < Variant::VARIANT_MAX) { - t = type_icons[left_type]; - } - if (t.is_valid()) { - TextureRect *tf = memnew(TextureRect); - tf->set_texture(t); - tf->set_stretch_mode(TextureRect::STRETCH_KEEP_CENTERED); - hbc->add_child(tf); - } - - if (is_vslist) { - if (nd_list->is_input_port_name_editable()) { - LineEdit *name_box = memnew(LineEdit); - hbc->add_child(name_box); - name_box->set_custom_minimum_size(Size2(60 * EDSCALE, 0)); - name_box->set_text(left_name); - name_box->set_expand_to_text_length(true); - name_box->connect("resized", callable_mp(this, &VisualScriptEditor::_update_node_size), varray(E->get())); - name_box->connect("focus_exited", callable_mp(this, &VisualScriptEditor::_port_name_focus_out), varray(name_box, E->get(), i, true)); - } else { - hbc->add_child(memnew(Label(left_name))); - } - - if (nd_list->is_input_port_type_editable()) { - OptionButton *opbtn = memnew(OptionButton); - for (int j = Variant::NIL; j < Variant::VARIANT_MAX; j++) { - opbtn->add_item(Variant::get_type_name(Variant::Type(j))); - } - opbtn->select(left_type); - opbtn->set_custom_minimum_size(Size2(100 * EDSCALE, 0)); - hbc->add_child(opbtn); - opbtn->connect("item_selected", callable_mp(this, &VisualScriptEditor::_change_port_type), varray(E->get(), i, true), CONNECT_DEFERRED); - } - Button *rmbtn = memnew(Button); - rmbtn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Remove", "EditorIcons")); - hbc->add_child(rmbtn); - rmbtn->connect("pressed", callable_mp(this, &VisualScriptEditor::_remove_input_port), varray(E->get(), i), CONNECT_DEFERRED); + if (is_vslist) { + if (nd_list->is_input_port_name_editable()) { + LineEdit *name_box = memnew(LineEdit); + hbc->add_child(name_box); + name_box->set_custom_minimum_size(Size2(60 * EDSCALE, 0)); + name_box->set_text(left_name); + name_box->set_expand_to_text_length(true); + name_box->connect("resized", callable_mp(this, &VisualScriptEditor::_update_node_size), varray(E->get())); + name_box->connect("focus_exited", callable_mp(this, &VisualScriptEditor::_port_name_focus_out), varray(name_box, E->get(), i, true)); } else { hbc->add_child(memnew(Label(left_name))); } - if (left_type != Variant::NIL && !script->is_input_value_port_connected(F->get(), E->get(), i)) { - PropertyInfo pi = node->get_input_value_port_info(i); - Button *button = memnew(Button); - Variant value = node->get_default_input_value(i); - if (value.get_type() != left_type) { - //different type? for now convert - //not the same, reconvert - Callable::CallError ce; - const Variant *existingp = &value; - Variant::construct(left_type, value, &existingp, 1, ce); - } - - if (left_type == Variant::COLOR) { - button->set_custom_minimum_size(Size2(30, 0) * EDSCALE); - button->connect("draw", callable_mp(this, &VisualScriptEditor::_draw_color_over_button), varray(button, value)); - } else if (left_type == Variant::OBJECT && Ref<Resource>(value).is_valid()) { - Ref<Resource> res = value; - Array arr; - arr.push_back(button->get_instance_id()); - arr.push_back(String(value)); - EditorResourcePreview::get_singleton()->queue_edited_resource_preview(res, this, "_button_resource_previewed", arr); - - } else if (pi.type == Variant::INT && pi.hint == PROPERTY_HINT_ENUM) { - button->set_text(pi.hint_string.get_slice(",", value)); - } else { - button->set_text(value); + if (nd_list->is_input_port_type_editable()) { + OptionButton *opbtn = memnew(OptionButton); + for (int j = Variant::NIL; j < Variant::VARIANT_MAX; j++) { + opbtn->add_item(Variant::get_type_name(Variant::Type(j))); } - button->connect("pressed", callable_mp(this, &VisualScriptEditor::_default_value_edited), varray(button, E->get(), i)); - hbc2->add_child(button); + opbtn->select(left_type); + opbtn->set_custom_minimum_size(Size2(100 * EDSCALE, 0)); + hbc->add_child(opbtn); + opbtn->connect("item_selected", callable_mp(this, &VisualScriptEditor::_change_port_type), varray(E->get(), i, true), CONNECT_DEFERRED); } + + Button *rmbtn = memnew(Button); + rmbtn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Remove", "EditorIcons")); + hbc->add_child(rmbtn); + rmbtn->connect("pressed", callable_mp(this, &VisualScriptEditor::_remove_input_port), varray(E->get(), i), CONNECT_DEFERRED); } else { - Control *c = memnew(Control); - c->set_custom_minimum_size(Size2(10, 0) * EDSCALE); - hbc->add_child(c); + hbc->add_child(memnew(Label(left_name))); } - hbc->add_spacer(); - hbc2->add_spacer(); + if (left_type != Variant::NIL && !script->is_input_value_port_connected(E->get(), i)) { + PropertyInfo pi = node->get_input_value_port_info(i); + Button *button = memnew(Button); + Variant value = node->get_default_input_value(i); + if (value.get_type() != left_type) { + //different type? for now convert + //not the same, reconvert + Callable::CallError ce; + const Variant *existingp = &value; + Variant::construct(left_type, value, &existingp, 1, ce); + } - if (i < mixed_seq_ports) { - Label *text2 = memnew(Label); - text2->set_text(node->get_output_sequence_port_text(i)); - text2->set_align(Label::ALIGN_RIGHT); - hbc->add_child(text2); + if (left_type == Variant::COLOR) { + button->set_custom_minimum_size(Size2(30, 0) * EDSCALE); + button->connect("draw", callable_mp(this, &VisualScriptEditor::_draw_color_over_button), varray(button, value)); + } else if (left_type == Variant::OBJECT && Ref<Resource>(value).is_valid()) { + Ref<Resource> res = value; + Array arr; + arr.push_back(button->get_instance_id()); + arr.push_back(String(value)); + EditorResourcePreview::get_singleton()->queue_edited_resource_preview(res, this, "_button_resource_previewed", arr); + + } else if (pi.type == Variant::INT && pi.hint == PROPERTY_HINT_ENUM) { + button->set_text(pi.hint_string.get_slice(",", value)); + } else { + button->set_text(value); + } + button->connect("pressed", callable_mp(this, &VisualScriptEditor::_default_value_edited), varray(button, E->get(), i)); + hbc2->add_child(button); } + } else { + Control *c = memnew(Control); + c->set_custom_minimum_size(Size2(10, 0) * EDSCALE); + hbc->add_child(c); + } - if (right_ok) { - if (is_vslist) { - Button *rmbtn = memnew(Button); - rmbtn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Remove", "EditorIcons")); - hbc->add_child(rmbtn); - rmbtn->connect("pressed", callable_mp(this, &VisualScriptEditor::_remove_output_port), varray(E->get(), i), CONNECT_DEFERRED); - - if (nd_list->is_output_port_type_editable()) { - OptionButton *opbtn = memnew(OptionButton); - for (int j = Variant::NIL; j < Variant::VARIANT_MAX; j++) { - opbtn->add_item(Variant::get_type_name(Variant::Type(j))); - } - opbtn->select(right_type); - opbtn->set_custom_minimum_size(Size2(100 * EDSCALE, 0)); - hbc->add_child(opbtn); - opbtn->connect("item_selected", callable_mp(this, &VisualScriptEditor::_change_port_type), varray(E->get(), i, false), CONNECT_DEFERRED); - } + hbc->add_spacer(); + hbc2->add_spacer(); - if (nd_list->is_output_port_name_editable()) { - LineEdit *name_box = memnew(LineEdit); - hbc->add_child(name_box); - name_box->set_custom_minimum_size(Size2(60 * EDSCALE, 0)); - name_box->set_text(right_name); - name_box->set_expand_to_text_length(true); - name_box->connect("resized", callable_mp(this, &VisualScriptEditor::_update_node_size), varray(E->get())); - name_box->connect("focus_exited", callable_mp(this, &VisualScriptEditor::_port_name_focus_out), varray(name_box, E->get(), i, false)); - } else { - hbc->add_child(memnew(Label(right_name))); + if (i < mixed_seq_ports) { + Label *text2 = memnew(Label); + text2->set_text(node->get_output_sequence_port_text(i)); + text2->set_align(Label::ALIGN_RIGHT); + hbc->add_child(text2); + } + + if (right_ok) { + if (is_vslist) { + Button *rmbtn = memnew(Button); + rmbtn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Remove", "EditorIcons")); + hbc->add_child(rmbtn); + rmbtn->connect("pressed", callable_mp(this, &VisualScriptEditor::_remove_output_port), varray(E->get(), i), CONNECT_DEFERRED); + + if (nd_list->is_output_port_type_editable()) { + OptionButton *opbtn = memnew(OptionButton); + for (int j = Variant::NIL; j < Variant::VARIANT_MAX; j++) { + opbtn->add_item(Variant::get_type_name(Variant::Type(j))); } - } else { - hbc->add_child(memnew(Label(right_name))); + opbtn->select(right_type); + opbtn->set_custom_minimum_size(Size2(100 * EDSCALE, 0)); + hbc->add_child(opbtn); + opbtn->connect("item_selected", callable_mp(this, &VisualScriptEditor::_change_port_type), varray(E->get(), i, false), CONNECT_DEFERRED); } - Ref<Texture2D> t; - if (right_type >= 0 && right_type < Variant::VARIANT_MAX) { - t = type_icons[right_type]; - } - if (t.is_valid()) { - TextureRect *tf = memnew(TextureRect); - tf->set_texture(t); - tf->set_stretch_mode(TextureRect::STRETCH_KEEP_CENTERED); - hbc->add_child(tf); + if (nd_list->is_output_port_name_editable()) { + LineEdit *name_box = memnew(LineEdit); + hbc->add_child(name_box); + name_box->set_custom_minimum_size(Size2(60 * EDSCALE, 0)); + name_box->set_text(right_name); + name_box->set_expand_to_text_length(true); + name_box->connect("resized", callable_mp(this, &VisualScriptEditor::_update_node_size), varray(E->get())); + name_box->connect("focus_exited", callable_mp(this, &VisualScriptEditor::_port_name_focus_out), varray(name_box, E->get(), i, false)); + } else { + hbc->add_child(memnew(Label(right_name))); } - } - - gnode->add_child(vbc); - - bool dark_theme = get_theme_constant("dark_theme", "Editor"); - if (i < mixed_seq_ports) { - gnode->set_slot(slot_idx, left_ok, left_type, _color_from_type(left_type, dark_theme), true, TYPE_SEQUENCE, mono_color, Ref<Texture2D>(), seq_port); } else { - gnode->set_slot(slot_idx, left_ok, left_type, _color_from_type(left_type, dark_theme), right_ok, right_type, _color_from_type(right_type, dark_theme)); + hbc->add_child(memnew(Label(right_name))); } - slot_idx++; + Ref<Texture2D> t; + if (right_type >= 0 && right_type < Variant::VARIANT_MAX) { + t = type_icons[right_type]; + } + if (t.is_valid()) { + TextureRect *tf = memnew(TextureRect); + tf->set_texture(t); + tf->set_stretch_mode(TextureRect::STRETCH_KEEP_CENTERED); + hbc->add_child(tf); + } } - graph->add_child(gnode); + gnode->add_child(vbc); - if (gnode->is_comment()) { - graph->move_child(gnode, 0); + bool dark_theme = get_theme_constant("dark_theme", "Editor"); + if (i < mixed_seq_ports) { + gnode->set_slot(slot_idx, left_ok, left_type, _color_from_type(left_type, dark_theme), true, TYPE_SEQUENCE, mono_color, Ref<Texture2D>(), seq_port); + } else { + gnode->set_slot(slot_idx, left_ok, left_type, _color_from_type(left_type, dark_theme), right_ok, right_type, _color_from_type(right_type, dark_theme)); } + + slot_idx++; + } + + graph->add_child(gnode); + + if (gnode->is_comment()) { + graph->move_child(gnode, 0); } } + _update_graph_connections(); - // use default_func instead of default_func for now I think that should be good stop gap solution to ensure not breaking anything - graph->call_deferred("set_scroll_ofs", script->get_function_scroll(default_func) * EDSCALE); + + float graph_minimap_opacity = EditorSettings::get_singleton()->get("editors/visual_editors/minimap_opacity"); + graph->set_minimap_opacity(graph_minimap_opacity); + + // Use default_func instead of default_func for now I think that should be good stop gap solution to ensure not breaking anything. + graph->call_deferred("set_scroll_ofs", script->get_scroll() * EDSCALE); updating_graph = false; } void VisualScriptEditor::_change_port_type(int p_select, int p_id, int p_port, bool is_input) { - StringName func = _get_function_of_node(p_id); - - Ref<VisualScriptLists> vsn = script->get_node(func, p_id); + Ref<VisualScriptLists> vsn = script->get_node(p_id); if (!vsn.is_valid()) { return; } @@ -1015,14 +1009,12 @@ void VisualScriptEditor::_change_port_type(int p_select, int p_id, int p_port, b void VisualScriptEditor::_update_node_size(int p_id) { Node *node = graph->get_node(itos(p_id)); if (Object::cast_to<Control>(node)) { - Object::cast_to<Control>(node)->set_size(Vector2(1, 1)); //shrink if text is smaller + Object::cast_to<Control>(node)->set_size(Vector2(1, 1)); // Shrink if text is smaller. } } void VisualScriptEditor::_port_name_focus_out(const Node *p_name_box, int p_id, int p_port, bool is_input) { - StringName func = _get_function_of_node(p_id); - - Ref<VisualScriptLists> vsn = script->get_node(func, p_id); + Ref<VisualScriptLists> vsn = script->get_node(p_id); if (!vsn.is_valid()) { return; } @@ -1063,11 +1055,8 @@ void VisualScriptEditor::_update_members() { List<StringName> func_names; script->get_function_list(&func_names); + func_names.sort_custom<StringName::AlphCompare>(); for (List<StringName>::Element *E = func_names.front(); E; E = E->next()) { - if (E->get() == default_func) { - continue; - } - TreeItem *ti = members->create_item(functions); ti->set_text(0, E->get()); ti->set_selectable(0, true); @@ -1200,7 +1189,7 @@ void VisualScriptEditor::_member_selected() { #endif if (held_ctrl) { ERR_FAIL_COND(!script->has_function(selected)); - _center_on_node(selected, script->get_function_node_id(selected)); + _center_on_node(script->get_function_node_id(selected)); } } } @@ -1243,8 +1232,8 @@ void VisualScriptEditor::_member_edited() { int node_id = script->get_function_node_id(name); Ref<VisualScriptFunction> func; - if (script->has_node(name, node_id)) { - func = script->get_node(name, node_id); + if (script->has_node(node_id)) { + func = script->get_node(node_id); } undo_redo->create_action(TTR("Rename Function")); undo_redo->add_do_method(script.ptr(), "rename_function", name, new_name); @@ -1254,21 +1243,17 @@ void VisualScriptEditor::_member_edited() { undo_redo->add_undo_method(func.ptr(), "set_name", name); } - // also fix all function calls - List<StringName> flst; - script->get_function_list(&flst); - for (List<StringName>::Element *E = flst.front(); E; E = E->next()) { - List<int> lst; - script->get_node_list(E->get(), &lst); - for (List<int>::Element *F = lst.front(); F; F = F->next()) { - Ref<VisualScriptFunctionCall> fncall = script->get_node(E->get(), F->get()); - if (!fncall.is_valid()) { - continue; - } - if (fncall->get_function() == name) { - undo_redo->add_do_method(fncall.ptr(), "set_function", new_name); - undo_redo->add_undo_method(fncall.ptr(), "set_function", name); - } + // Also fix all function calls. + List<int> lst; + script->get_node_list(&lst); + for (List<int>::Element *F = lst.front(); F; F = F->next()) { + Ref<VisualScriptFunctionCall> fncall = script->get_node(F->get()); + if (!fncall.is_valid()) { + continue; + } + if (fncall->get_function() == name) { + undo_redo->add_do_method(fncall.ptr(), "set_function", new_name); + undo_redo->add_undo_method(fncall.ptr(), "set_function", name); } } @@ -1280,7 +1265,7 @@ void VisualScriptEditor::_member_edited() { undo_redo->add_undo_method(this, "emit_signal", "edited_script_changed"); undo_redo->commit_action(); - return; //or crash because it will become invalid + return; // Or crash because it will become invalid. } if (ti->get_parent() == root->get_children()->get_next()) { @@ -1296,7 +1281,7 @@ void VisualScriptEditor::_member_edited() { undo_redo->add_undo_method(this, "emit_signal", "edited_script_changed"); undo_redo->commit_action(); - return; //or crash because it will become invalid + return; // Or crash because it will become invalid. } if (ti->get_parent() == root->get_children()->get_next()->get_next()) { @@ -1310,7 +1295,7 @@ void VisualScriptEditor::_member_edited() { undo_redo->add_undo_method(this, "emit_signal", "edited_script_changed"); undo_redo->commit_action(); - return; //or crash because it will become invalid + return; // Or crash because it will become invalid. } } @@ -1344,10 +1329,13 @@ void VisualScriptEditor::_create_function() { func_node->add_argument(arg_type, arg_name); } + int func_node_id = script->get_available_id(); + undo_redo->create_action(TTR("Add Function")); - undo_redo->add_do_method(script.ptr(), "add_function", name); - undo_redo->add_do_method(script.ptr(), "add_node", name, script->get_available_id(), func_node, ofs); + undo_redo->add_do_method(script.ptr(), "add_function", name, func_node_id); undo_redo->add_undo_method(script.ptr(), "remove_function", name); + undo_redo->add_do_method(script.ptr(), "add_node", func_node_id, func_node, ofs); + undo_redo->add_undo_method(script.ptr(), "remove_node", func_node_id); undo_redo->add_do_method(this, "_update_members"); undo_redo->add_undo_method(this, "_update_members"); undo_redo->add_do_method(this, "_update_graph"); @@ -1431,11 +1419,12 @@ void VisualScriptEditor::_member_button(Object *p_item, int p_column, int p_butt if (ti->get_parent() == root) { //main buttons if (ti == root->get_children()) { - //add function, this one uses menu + // Add function, this one uses menu. if (p_button == 1) { + // Ensure script base exists otherwise use custom base type. + ERR_FAIL_COND(script.is_null()); new_virtual_method_select->select_method_from_base_type(script->get_instance_base_type(), String(), true); - return; } else if (p_button == 0) { String name = _validate_name("new_function"); @@ -1445,11 +1434,13 @@ void VisualScriptEditor::_member_button(Object *p_item, int p_column, int p_butt Ref<VisualScriptFunction> func_node; func_node.instance(); func_node->set_name(name); + int fn_id = script->get_available_id(); undo_redo->create_action(TTR("Add Function")); - undo_redo->add_do_method(script.ptr(), "add_function", name); - undo_redo->add_do_method(script.ptr(), "add_node", name, script->get_available_id(), func_node, ofs); + undo_redo->add_do_method(script.ptr(), "add_function", name, fn_id); + undo_redo->add_do_method(script.ptr(), "add_node", fn_id, func_node, ofs); undo_redo->add_undo_method(script.ptr(), "remove_function", name); + undo_redo->add_do_method(script.ptr(), "remove_node", fn_id); undo_redo->add_do_method(this, "_update_members"); undo_redo->add_undo_method(this, "_update_members"); undo_redo->add_do_method(this, "_update_graph"); @@ -1461,11 +1452,11 @@ void VisualScriptEditor::_member_button(Object *p_item, int p_column, int p_butt _update_graph(); } - return; //or crash because it will become invalid + return; // Or crash because it will become invalid. } if (ti == root->get_children()->get_next()) { - //add variable + // Add variable. String name = _validate_name("new_variable"); selected = name; @@ -1477,11 +1468,11 @@ void VisualScriptEditor::_member_button(Object *p_item, int p_column, int p_butt undo_redo->add_do_method(this, "emit_signal", "edited_script_changed"); undo_redo->add_undo_method(this, "emit_signal", "edited_script_changed"); undo_redo->commit_action(); - return; //or crash because it will become invalid + return; // Or crash because it will become invalid. } if (ti == root->get_children()->get_next()->get_next()) { - //add variable + // Add variable. String name = _validate_name("new_signal"); selected = name; @@ -1493,7 +1484,7 @@ void VisualScriptEditor::_member_button(Object *p_item, int p_column, int p_butt undo_redo->add_do_method(this, "emit_signal", "edited_script_changed"); undo_redo->add_undo_method(this, "emit_signal", "edited_script_changed"); undo_redo->commit_action(); - return; //or crash because it will become invalid + return; // Or crash because it will become invalid. } } else if (ti->get_parent() == root->get_children()) { selected = ti->get_text(0); @@ -1505,9 +1496,7 @@ void VisualScriptEditor::_member_button(Object *p_item, int p_column, int p_butt } void VisualScriptEditor::_add_input_port(int p_id) { - StringName func = _get_function_of_node(p_id); - - Ref<VisualScriptLists> vsn = script->get_node(func, p_id); + Ref<VisualScriptLists> vsn = script->get_node(p_id); if (!vsn.is_valid()) { return; } @@ -1527,9 +1516,7 @@ void VisualScriptEditor::_add_input_port(int p_id) { } void VisualScriptEditor::_add_output_port(int p_id) { - StringName func = _get_function_of_node(p_id); - - Ref<VisualScriptLists> vsn = script->get_node(func, p_id); + Ref<VisualScriptLists> vsn = script->get_node(p_id); if (!vsn.is_valid()) { return; } @@ -1549,9 +1536,7 @@ void VisualScriptEditor::_add_output_port(int p_id) { } void VisualScriptEditor::_remove_input_port(int p_id, int p_port) { - StringName func = _get_function_of_node(p_id); - - Ref<VisualScriptLists> vsn = script->get_node(func, p_id); + Ref<VisualScriptLists> vsn = script->get_node(p_id); if (!vsn.is_valid()) { return; } @@ -1561,17 +1546,17 @@ void VisualScriptEditor::_remove_input_port(int p_id, int p_port) { undo_redo->create_action(TTR("Remove Input Port"), UndoRedo::MERGE_ENDS); int conn_from = -1, conn_port = -1; - script->get_input_value_port_connection_source(func, p_id, p_port, &conn_from, &conn_port); + script->get_input_value_port_connection_source(p_id, p_port, &conn_from, &conn_port); if (conn_from != -1) { - undo_redo->add_do_method(script.ptr(), "data_disconnect", func, conn_from, conn_port, p_id, p_port); + undo_redo->add_do_method(script.ptr(), "data_disconnect", conn_from, conn_port, p_id, p_port); } undo_redo->add_do_method(vsn.ptr(), "remove_input_data_port", p_port); undo_redo->add_do_method(this, "_update_graph", p_id); if (conn_from != -1) { - undo_redo->add_undo_method(script.ptr(), "data_connect", func, conn_from, conn_port, p_id, p_port); + undo_redo->add_undo_method(script.ptr(), "data_connect", conn_from, conn_port, p_id, p_port); } undo_redo->add_undo_method(vsn.ptr(), "add_input_data_port", vsn->get_input_value_port_info(p_port).type, vsn->get_input_value_port_info(p_port).name, p_port); @@ -1583,9 +1568,7 @@ void VisualScriptEditor::_remove_input_port(int p_id, int p_port) { } void VisualScriptEditor::_remove_output_port(int p_id, int p_port) { - StringName func = _get_function_of_node(p_id); - - Ref<VisualScriptLists> vsn = script->get_node(func, p_id); + Ref<VisualScriptLists> vsn = script->get_node(p_id); if (!vsn.is_valid()) { return; } @@ -1595,12 +1578,12 @@ void VisualScriptEditor::_remove_output_port(int p_id, int p_port) { undo_redo->create_action(TTR("Remove Output Port"), UndoRedo::MERGE_ENDS); List<VisualScript::DataConnection> data_connections; - script->get_data_connection_list(func, &data_connections); + script->get_data_connection_list(&data_connections); HashMap<int, Set<int>> conn_map; for (const List<VisualScript::DataConnection>::Element *E = data_connections.front(); E; E = E->next()) { if (E->get().from_node == p_id && E->get().from_port == p_port) { - // push into the connections map + // Push into the connections map. if (!conn_map.has(E->get().to_node)) { conn_map.set(E->get().to_node, Set<int>()); } @@ -1615,7 +1598,7 @@ void VisualScriptEditor::_remove_output_port(int p_id, int p_port) { conn_map.get_key_list(&keys); for (const List<int>::Element *E = keys.front(); E; E = E->next()) { for (const Set<int>::Element *F = conn_map[E->get()].front(); F; F = F->next()) { - undo_redo->add_undo_method(script.ptr(), "data_connect", func, p_id, p_port, E->get(), F->get()); + undo_redo->add_undo_method(script.ptr(), "data_connect", p_id, p_port, E->get(), F->get()); } } @@ -1628,9 +1611,7 @@ void VisualScriptEditor::_remove_output_port(int p_id, int p_port) { } void VisualScriptEditor::_expression_text_changed(const String &p_text, int p_id) { - StringName func = _get_function_of_node(p_id); - - Ref<VisualScriptExpression> vse = script->get_node(func, p_id); + Ref<VisualScriptExpression> vse = script->get_node(p_id); if (!vse.is_valid()) { return; } @@ -1646,7 +1627,7 @@ void VisualScriptEditor::_expression_text_changed(const String &p_text, int p_id Node *node = graph->get_node(itos(p_id)); if (Object::cast_to<Control>(node)) { - Object::cast_to<Control>(node)->set_size(Vector2(1, 1)); //shrink if text is smaller + Object::cast_to<Control>(node)->set_size(Vector2(1, 1)); // Shrink if text is smaller. } updating_graph = false; @@ -1666,19 +1647,14 @@ Vector2 VisualScriptEditor::_get_available_pos(bool centered, Vector2 ofs) const while (true) { bool exists = false; - List<StringName> all_fn; - script->get_function_list(&all_fn); - for (List<StringName>::Element *F = all_fn.front(); F; F = F->next()) { - StringName curr_fn = F->get(); - List<int> existing; - script->get_node_list(curr_fn, &existing); - for (List<int>::Element *E = existing.front(); E; E = E->next()) { - Point2 pos = script->get_node_position(curr_fn, E->get()); - if (pos.distance_to(ofs) < 50) { - ofs += Vector2(graph->get_snap(), graph->get_snap()); - exists = true; - break; - } + List<int> existing; + script->get_node_list(&existing); + for (List<int>::Element *E = existing.front(); E; E = E->next()) { + Point2 pos = script->get_node_position(E->get()); + if (pos.distance_to(ofs) < 50) { + ofs += Vector2(graph->get_snap(), graph->get_snap()); + exists = true; + break; } } if (exists) { @@ -1710,7 +1686,7 @@ String VisualScriptEditor::_validate_name(const String &p_name) const { } void VisualScriptEditor::_on_nodes_delete() { - // delete all the selected nodes + // Delete all the selected nodes. List<int> to_erase; @@ -1723,7 +1699,7 @@ void VisualScriptEditor::_on_nodes_delete() { } } - if (to_erase.empty()) { + if (to_erase.is_empty()) { return; } @@ -1732,26 +1708,24 @@ void VisualScriptEditor::_on_nodes_delete() { for (List<int>::Element *F = to_erase.front(); F; F = F->next()) { int cr_node = F->get(); - StringName func = _get_function_of_node(cr_node); - - undo_redo->add_do_method(script.ptr(), "remove_node", func, cr_node); - undo_redo->add_undo_method(script.ptr(), "add_node", func, cr_node, script->get_node(func, cr_node), script->get_node_position(func, cr_node)); + undo_redo->add_do_method(script.ptr(), "remove_node", cr_node); + undo_redo->add_undo_method(script.ptr(), "add_node", cr_node, script->get_node(cr_node), script->get_node_position(cr_node)); List<VisualScript::SequenceConnection> sequence_conns; - script->get_sequence_connection_list(func, &sequence_conns); + script->get_sequence_connection_list(&sequence_conns); for (List<VisualScript::SequenceConnection>::Element *E = sequence_conns.front(); E; E = E->next()) { if (E->get().from_node == cr_node || E->get().to_node == cr_node) { - undo_redo->add_undo_method(script.ptr(), "sequence_connect", func, E->get().from_node, E->get().from_output, E->get().to_node); + undo_redo->add_undo_method(script.ptr(), "sequence_connect", E->get().from_node, E->get().from_output, E->get().to_node); } } List<VisualScript::DataConnection> data_conns; - script->get_data_connection_list(func, &data_conns); + script->get_data_connection_list(&data_conns); for (List<VisualScript::DataConnection>::Element *E = data_conns.front(); E; E = E->next()) { if (E->get().from_node == F->get() || E->get().to_node == F->get()) { - undo_redo->add_undo_method(script.ptr(), "data_connect", func, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); + undo_redo->add_undo_method(script.ptr(), "data_connect", E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); } } } @@ -1763,7 +1737,6 @@ void VisualScriptEditor::_on_nodes_delete() { void VisualScriptEditor::_on_nodes_duplicate() { Set<int> to_duplicate; - List<StringName> funcs; for (int i = 0; i < graph->get_child_count(); i++) { GraphNode *gn = Object::cast_to<GraphNode>(graph->get_child(i)); @@ -1771,12 +1744,11 @@ void VisualScriptEditor::_on_nodes_duplicate() { if (gn->is_selected() && gn->is_close_button_visible()) { int id = gn->get_name().operator String().to_int(); to_duplicate.insert(id); - funcs.push_back(_get_function_of_node(id)); } } } - if (to_duplicate.empty()) { + if (to_duplicate.is_empty()) { return; } @@ -1787,9 +1759,8 @@ void VisualScriptEditor::_on_nodes_duplicate() { HashMap<int, int> remap; for (Set<int>::Element *F = to_duplicate.front(); F; F = F->next()) { - // duplicate from the specific function but place it into the default func as it would lack the connections - StringName func = _get_function_of_node(F->get()); - Ref<VisualScriptNode> node = script->get_node(func, F->get()); + // Duplicate from the specific function but place it into the default func as it would lack the connections. + Ref<VisualScriptNode> node = script->get_node(F->get()); Ref<VisualScriptNode> dupe = node->duplicate(true); @@ -1797,25 +1768,23 @@ void VisualScriptEditor::_on_nodes_duplicate() { remap.set(F->get(), new_id); to_select.insert(new_id); - undo_redo->add_do_method(script.ptr(), "add_node", default_func, new_id, dupe, script->get_node_position(func, F->get()) + Vector2(20, 20)); - undo_redo->add_undo_method(script.ptr(), "remove_node", default_func, new_id); + undo_redo->add_do_method(script.ptr(), "add_node", new_id, dupe, script->get_node_position(F->get()) + Vector2(20, 20)); + undo_redo->add_undo_method(script.ptr(), "remove_node", new_id); } - for (List<StringName>::Element *F = funcs.front(); F; F = F->next()) { - List<VisualScript::SequenceConnection> seqs; - script->get_sequence_connection_list(F->get(), &seqs); - for (List<VisualScript::SequenceConnection>::Element *E = seqs.front(); E; E = E->next()) { - if (to_duplicate.has(E->get().from_node) && to_duplicate.has(E->get().to_node)) { - undo_redo->add_do_method(script.ptr(), "sequence_connect", default_func, remap[E->get().from_node], E->get().from_output, remap[E->get().to_node]); - } + List<VisualScript::SequenceConnection> seqs; + script->get_sequence_connection_list(&seqs); + for (List<VisualScript::SequenceConnection>::Element *E = seqs.front(); E; E = E->next()) { + if (to_duplicate.has(E->get().from_node) && to_duplicate.has(E->get().to_node)) { + undo_redo->add_do_method(script.ptr(), "sequence_connect", remap[E->get().from_node], E->get().from_output, remap[E->get().to_node]); } + } - List<VisualScript::DataConnection> data; - script->get_data_connection_list(F->get(), &data); - for (List<VisualScript::DataConnection>::Element *E = data.front(); E; E = E->next()) { - if (to_duplicate.has(E->get().from_node) && to_duplicate.has(E->get().to_node)) { - undo_redo->add_do_method(script.ptr(), "data_connect", default_func, remap[E->get().from_node], E->get().from_port, remap[E->get().to_node], E->get().to_port); - } + List<VisualScript::DataConnection> data; + script->get_data_connection_list(&data); + for (List<VisualScript::DataConnection>::Element *E = data.front(); E; E = E->next()) { + if (to_duplicate.has(E->get().from_node) && to_duplicate.has(E->get().to_node)) { + undo_redo->add_do_method(script.ptr(), "data_connect", remap[E->get().from_node], E->get().from_port, remap[E->get().to_node], E->get().to_port); } } @@ -1833,7 +1802,7 @@ void VisualScriptEditor::_on_nodes_duplicate() { } if (to_select.size()) { - EditorNode::get_singleton()->push_item(script->get_node(default_func, to_select.front()->get()).ptr()); + EditorNode::get_singleton()->push_item(script->get_node(to_select.front()->get()).ptr()); } } @@ -1846,7 +1815,7 @@ void VisualScriptEditor::_generic_search(String p_base_type, Vector2 pos, bool n new_connect_node_select->select_from_visual_script(p_base_type, false, false); // neither connecting nor reset text - // ensure that the dialog fits inside the graph + // Ensure that the dialog fits inside the graph. Size2 bounds = graph->get_global_position() + graph->get_size() - new_connect_node_select->get_size(); pos.x = pos.x > bounds.x ? bounds.x : pos.x; pos.y = pos.y > bounds.y ? bounds.y : pos.y; @@ -1907,7 +1876,7 @@ void VisualScriptEditor::_members_gui_input(const Ref<InputEvent> &p_event) { if (btn.is_valid() && btn->is_doubleclick()) { TreeItem *ti = members->get_selected(); if (ti && ti->get_parent() == members->get_root()->get_children()) { // to check if it's a function - _center_on_node(ti->get_metadata(0), script->get_function_node_id(ti->get_metadata(0))); + _center_on_node(script->get_function_node_id(ti->get_metadata(0))); } } } @@ -1925,8 +1894,8 @@ void VisualScriptEditor::_rename_function(const String &name, const String &new_ int node_id = script->get_function_node_id(name); Ref<VisualScriptFunction> func; - if (script->has_node(name, node_id)) { - func = script->get_node(name, node_id); + if (script->has_node(node_id)) { + func = script->get_node(node_id); } undo_redo->create_action(TTR("Rename Function")); undo_redo->add_do_method(script.ptr(), "rename_function", name, new_name); @@ -1936,21 +1905,17 @@ void VisualScriptEditor::_rename_function(const String &name, const String &new_ undo_redo->add_undo_method(func.ptr(), "set_name", name); } - // also fix all function calls - List<StringName> flst; - script->get_function_list(&flst); - for (List<StringName>::Element *E = flst.front(); E; E = E->next()) { - List<int> lst; - script->get_node_list(E->get(), &lst); - for (List<int>::Element *F = lst.front(); F; F = F->next()) { - Ref<VisualScriptFunctionCall> fncall = script->get_node(E->get(), F->get()); - if (!fncall.is_valid()) { - continue; - } - if (fncall->get_function() == name) { - undo_redo->add_do_method(fncall.ptr(), "set_function", new_name); - undo_redo->add_undo_method(fncall.ptr(), "set_function", name); - } + // Also fix all function calls. + List<int> lst; + script->get_node_list(&lst); + for (List<int>::Element *F = lst.front(); F; F = F->next()) { + Ref<VisualScriptFunctionCall> fncall = script->get_node(F->get()); + if (!fncall.is_valid()) { + continue; + } + if (fncall->get_function() == name) { + undo_redo->add_do_method(fncall.ptr(), "set_function", new_name); + undo_redo->add_undo_method(fncall.ptr(), "set_function", name); } } @@ -2103,7 +2068,7 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da ofs /= EDSCALE; - int new_id = _create_new_node_from_name(d["node_type"], ofs, default_func); + int new_id = _create_new_node_from_name(d["node_type"], ofs); Node *node = graph->get_node(itos(new_id)); if (node) { @@ -2142,8 +2107,8 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da int new_id = script->get_available_id(); undo_redo->create_action(TTR("Add Node")); - undo_redo->add_do_method(script.ptr(), "add_node", default_func, new_id, vnode, ofs); - undo_redo->add_undo_method(script.ptr(), "remove_node", default_func, new_id); + undo_redo->add_do_method(script.ptr(), "add_node", new_id, vnode, ofs); + undo_redo->add_undo_method(script.ptr(), "remove_node", new_id); undo_redo->add_do_method(this, "_update_graph"); undo_redo->add_undo_method(this, "_update_graph"); undo_redo->commit_action(); @@ -2171,11 +2136,11 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da int new_id = script->get_available_id(); undo_redo->create_action(TTR("Add Node")); - undo_redo->add_do_method(script.ptr(), "add_node", default_func, new_id, vnode, ofs); + undo_redo->add_do_method(script.ptr(), "add_node", new_id, vnode, ofs); undo_redo->add_do_method(vnode.ptr(), "set_base_type", script->get_instance_base_type()); undo_redo->add_do_method(vnode.ptr(), "set_function", d["function"]); - undo_redo->add_undo_method(script.ptr(), "remove_node", default_func, new_id); + undo_redo->add_undo_method(script.ptr(), "remove_node", new_id); undo_redo->add_do_method(this, "_update_graph"); undo_redo->add_undo_method(this, "_update_graph"); undo_redo->commit_action(); @@ -2203,8 +2168,8 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da int new_id = script->get_available_id(); undo_redo->create_action(TTR("Add Node")); - undo_redo->add_do_method(script.ptr(), "add_node", default_func, new_id, vnode, ofs); - undo_redo->add_undo_method(script.ptr(), "remove_node", default_func, new_id); + undo_redo->add_do_method(script.ptr(), "add_node", new_id, vnode, ofs); + undo_redo->add_undo_method(script.ptr(), "remove_node", new_id); undo_redo->add_do_method(this, "_update_graph"); undo_redo->add_undo_method(this, "_update_graph"); undo_redo->commit_action(); @@ -2232,8 +2197,8 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da int new_id = script->get_available_id(); undo_redo->create_action(TTR("Add Preload Node")); - undo_redo->add_do_method(script.ptr(), "add_node", default_func, new_id, prnode, ofs); - undo_redo->add_undo_method(script.ptr(), "remove_node", default_func, new_id); + undo_redo->add_do_method(script.ptr(), "add_node", new_id, prnode, ofs); + undo_redo->add_undo_method(script.ptr(), "remove_node", new_id); undo_redo->add_do_method(this, "_update_graph"); undo_redo->add_undo_method(this, "_update_graph"); undo_redo->commit_action(); @@ -2272,8 +2237,8 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da prnode.instance(); prnode->set_preload(res); - undo_redo->add_do_method(script.ptr(), "add_node", default_func, new_id, prnode, ofs); - undo_redo->add_undo_method(script.ptr(), "remove_node", default_func, new_id); + undo_redo->add_do_method(script.ptr(), "add_node", new_id, prnode, ofs); + undo_redo->add_undo_method(script.ptr(), "remove_node", new_id); new_ids.push_back(new_id); new_id++; ofs += Vector2(20, 20) * EDSCALE; @@ -2339,7 +2304,7 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da scene_node->set_node_path(sn->get_path_to(node)); n = scene_node; } else { - // ! Doesn't work properly + // ! Doesn't work properly. Ref<VisualScriptFunctionCall> call; call.instance(); call->set_call_mode(VisualScriptFunctionCall::CALL_MODE_NODE_PATH); @@ -2350,8 +2315,8 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da selecting_method_id = base_id; } - undo_redo->add_do_method(script.ptr(), "add_node", default_func, base_id, n, ofs); - undo_redo->add_undo_method(script.ptr(), "remove_node", default_func, base_id); + undo_redo->add_do_method(script.ptr(), "add_node", base_id, n, ofs); + undo_redo->add_undo_method(script.ptr(), "remove_node", base_id); base_id++; ofs += Vector2(25, 25); @@ -2420,13 +2385,13 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da vnode = pget; } - undo_redo->add_do_method(script.ptr(), "add_node", default_func, base_id, vnode, ofs); + undo_redo->add_do_method(script.ptr(), "add_node", base_id, vnode, ofs); undo_redo->add_do_method(vnode.ptr(), "set_property", d["property"]); if (!use_get) { undo_redo->add_do_method(vnode.ptr(), "set_default_input_value", 0, d["value"]); } - undo_redo->add_undo_method(script.ptr(), "remove_node", default_func, base_id); + undo_redo->add_undo_method(script.ptr(), "remove_node", base_id); undo_redo->add_do_method(this, "_update_graph"); undo_redo->add_undo_method(this, "_update_graph"); @@ -2465,12 +2430,12 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da } vnode = pget; } - undo_redo->add_do_method(script.ptr(), "add_node", default_func, base_id, vnode, ofs); + undo_redo->add_do_method(script.ptr(), "add_node", base_id, vnode, ofs); undo_redo->add_do_method(vnode.ptr(), "set_property", d["property"]); if (!use_get) { undo_redo->add_do_method(vnode.ptr(), "set_default_input_value", 0, d["value"]); } - undo_redo->add_undo_method(script.ptr(), "remove_node", default_func, base_id); + undo_redo->add_undo_method(script.ptr(), "remove_node", base_id); undo_redo->add_do_method(this, "_update_graph"); undo_redo->add_undo_method(this, "_update_graph"); @@ -2480,7 +2445,7 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da } void VisualScriptEditor::_selected_method(const String &p_method, const String &p_type, const bool p_connecting) { - Ref<VisualScriptFunctionCall> vsfc = script->get_node(default_func, selecting_method_id); + Ref<VisualScriptFunctionCall> vsfc = script->get_node(selecting_method_id); if (!vsfc.is_valid()) { return; } @@ -2538,14 +2503,6 @@ void VisualScriptEditor::set_edited_resource(const RES &p_res) { script->connect("node_ports_changed", callable_mp(this, &VisualScriptEditor::_node_ports_changed)); - default_func = script->get_default_func(); - - if (!script->has_function(default_func)) // this is the supposed default function - { - script->add_function(default_func); - script->set_edited(true); //so that if a function was added it's saved - } - _update_graph(); call_deferred("_update_members"); } @@ -2566,7 +2523,7 @@ String VisualScriptEditor::get_name() { if (script->get_path().find("local://") == -1 && script->get_path().find("::") == -1) { name = script->get_path().get_file(); if (is_unsaved()) { - if (script->get_path().empty()) { + if (script->get_path().is_empty()) { name = TTR("[unsaved]"); } name += "(*)"; @@ -2588,13 +2545,12 @@ bool VisualScriptEditor::is_unsaved() { bool unsaved = script->is_edited() || script->are_subnodes_edited() || - script->get_path().empty(); // In memory. + script->get_path().is_empty(); // In memory. return unsaved; } Variant VisualScriptEditor::get_edit_state() { Dictionary d; - d["function"] = default_func; d["scroll"] = graph->get_scroll_ofs(); d["zoom"] = graph->get_zoom(); d["using_snap"] = graph->is_using_snap(); @@ -2604,9 +2560,6 @@ Variant VisualScriptEditor::get_edit_state() { void VisualScriptEditor::set_edit_state(const Variant &p_state) { Dictionary d = p_state; - if (d.has("function")) { - selected = default_func; - } _update_graph(); _update_members(); @@ -2625,11 +2578,11 @@ void VisualScriptEditor::set_edit_state(const Variant &p_state) { } } -void VisualScriptEditor::_center_on_node(const StringName &p_func, int p_id) { +void VisualScriptEditor::_center_on_node(int p_id) { Node *n = graph->get_node(itos(p_id)); GraphNode *gn = Object::cast_to<GraphNode>(n); - // clear selection + // Clear selection. for (int i = 0; i < graph->get_child_count(); i++) { GraphNode *gnd = Object::cast_to<GraphNode>(graph->get_child(i)); if (gnd) { @@ -2641,13 +2594,13 @@ void VisualScriptEditor::_center_on_node(const StringName &p_func, int p_id) { gn->set_selected(true); Vector2 new_scroll = gn->get_position_offset() - graph->get_size() * 0.5 + gn->get_size() * 0.5; graph->set_scroll_ofs(new_scroll); - script->set_function_scroll(p_func, new_scroll / EDSCALE); + script->set_scroll(new_scroll / EDSCALE); script->set_edited(true); } } void VisualScriptEditor::goto_line(int p_line, bool p_with_error) { - p_line += 1; //add one because script lines begin from 0. + p_line += 1; // Add one because script lines begin from 0. if (p_with_error) { error_line = p_line; @@ -2656,7 +2609,7 @@ void VisualScriptEditor::goto_line(int p_line, bool p_with_error) { List<StringName> functions; script->get_function_list(&functions); for (List<StringName>::Element *E = functions.front(); E; E = E->next()) { - if (script->has_node(E->get(), p_line)) { + if (script->has_node(p_line)) { _update_graph(); _update_members(); @@ -2703,11 +2656,11 @@ Array VisualScriptEditor::get_breakpoints() { script->get_function_list(&functions); for (List<StringName>::Element *E = functions.front(); E; E = E->next()) { List<int> nodes; - script->get_node_list(E->get(), &nodes); + script->get_node_list(&nodes); for (List<int>::Element *F = nodes.front(); F; F = F->next()) { - Ref<VisualScriptNode> vsn = script->get_node(E->get(), F->get()); + Ref<VisualScriptNode> vsn = script->get_node(F->get()); if (vsn->is_breakpoint()) { - breakpoints.push_back(F->get() - 1); //subtract 1 because breakpoints in text start from zero + breakpoints.push_back(F->get() - 1); // Subtract 1 because breakpoints in text start from zero. } } } @@ -2718,7 +2671,7 @@ void VisualScriptEditor::add_callback(const String &p_function, PackedStringArra if (script->has_function(p_function)) { _update_members(); _update_graph(); - _center_on_node(p_function, script->get_function_node_id(p_function)); + _center_on_node(script->get_function_node_id(p_function)); return; } @@ -2742,15 +2695,15 @@ void VisualScriptEditor::add_callback(const String &p_function, PackedStringArra func->add_argument(type, name); } - + int fn_id = script->get_available_id(); func->set_name(p_function); - script->add_function(p_function); - script->add_node(p_function, script->get_available_id(), func); + script->add_function(p_function, fn_id); + script->add_node(fn_id, func); _update_members(); _update_graph(); - _center_on_node(p_function, script->get_function_node_id(p_function)); + _center_on_node(script->get_function_node_id(p_function)); } bool VisualScriptEditor::show_members_overview() { @@ -2844,8 +2797,8 @@ void VisualScriptEditor::_end_node_move() { undo_redo->commit_action(); } -void VisualScriptEditor::_move_node(const StringName &p_func, int p_id, const Vector2 &p_to) { - if (!script->has_function(p_func)) { +void VisualScriptEditor::_move_node(int p_id, const Vector2 &p_to) { + if (!script->has_node(p_id)) { return; } @@ -2855,51 +2808,35 @@ void VisualScriptEditor::_move_node(const StringName &p_func, int p_id, const Ve Object::cast_to<GraphNode>(node)->set_position_offset(p_to); } - script->set_node_position(p_func, p_id, p_to / EDSCALE); -} - -StringName VisualScriptEditor::_get_function_of_node(int p_id) const { - List<StringName> funcs; - script->get_function_list(&funcs); - for (List<StringName>::Element *E = funcs.front(); E; E = E->next()) { - if (script->has_node(E->get(), p_id)) { - return E->get(); - } - } - - return ""; // this is passed to avoid crash and is tested against later + script->set_node_position(p_id, p_to / EDSCALE); } void VisualScriptEditor::_node_moved(Vector2 p_from, Vector2 p_to, int p_id) { - StringName func = _get_function_of_node(p_id); - - undo_redo->add_do_method(this, "_move_node", func, p_id, p_to); - undo_redo->add_undo_method(this, "_move_node", func, p_id, p_from); + undo_redo->add_do_method(this, "_move_node", p_id, p_to); + undo_redo->add_undo_method(this, "_move_node", p_id, p_from); } void VisualScriptEditor::_remove_node(int p_id) { undo_redo->create_action(TTR("Remove VisualScript Node")); - StringName func = _get_function_of_node(p_id); - - undo_redo->add_do_method(script.ptr(), "remove_node", func, p_id); - undo_redo->add_undo_method(script.ptr(), "add_node", func, p_id, script->get_node(func, p_id), script->get_node_position(func, p_id)); + undo_redo->add_do_method(script.ptr(), "remove_node", p_id); + undo_redo->add_undo_method(script.ptr(), "add_node", p_id, script->get_node(p_id), script->get_node_position(p_id)); List<VisualScript::SequenceConnection> sequence_conns; - script->get_sequence_connection_list(func, &sequence_conns); + script->get_sequence_connection_list(&sequence_conns); for (List<VisualScript::SequenceConnection>::Element *E = sequence_conns.front(); E; E = E->next()) { if (E->get().from_node == p_id || E->get().to_node == p_id) { - undo_redo->add_undo_method(script.ptr(), "sequence_connect", func, E->get().from_node, E->get().from_output, E->get().to_node); + undo_redo->add_undo_method(script.ptr(), "sequence_connect", E->get().from_node, E->get().from_output, E->get().to_node); } } List<VisualScript::DataConnection> data_conns; - script->get_data_connection_list(func, &data_conns); + script->get_data_connection_list(&data_conns); for (List<VisualScript::DataConnection>::Element *E = data_conns.front(); E; E = E->next()) { if (E->get().from_node == p_id || E->get().to_node == p_id) { - undo_redo->add_undo_method(script.ptr(), "data_connect", func, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); + undo_redo->add_undo_method(script.ptr(), "data_connect", E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); } } @@ -2909,13 +2846,13 @@ void VisualScriptEditor::_remove_node(int p_id) { undo_redo->commit_action(); } -void VisualScriptEditor::_node_ports_changed(const String &p_func, int p_id) { +void VisualScriptEditor::_node_ports_changed(int p_id) { _update_graph(p_id); } -bool VisualScriptEditor::node_has_sequence_connections(const StringName &p_func, int p_id) { +bool VisualScriptEditor::node_has_sequence_connections(int p_id) { List<VisualScript::SequenceConnection> sequence_conns; - script->get_sequence_connection_list(p_func, &sequence_conns); + script->get_sequence_connection_list(&sequence_conns); for (List<VisualScript::SequenceConnection>::Element *E = sequence_conns.front(); E; E = E->next()) { int from = E->get().from_node; @@ -2930,9 +2867,7 @@ bool VisualScriptEditor::node_has_sequence_connections(const StringName &p_func, } void VisualScriptEditor::_graph_connected(const String &p_from, int p_from_slot, const String &p_to, int p_to_slot) { - StringName from_func = _get_function_of_node(p_from.to_int()); - - Ref<VisualScriptNode> from_node = script->get_node(from_func, p_from.to_int()); + Ref<VisualScriptNode> from_node = script->get_node(p_from.to_int()); ERR_FAIL_COND(!from_node.is_valid()); bool from_seq; @@ -2942,9 +2877,7 @@ void VisualScriptEditor::_graph_connected(const String &p_from, int p_from_slot, return; //can't connect this, it's invalid } - StringName to_func = _get_function_of_node(p_to.to_int()); - - Ref<VisualScriptNode> to_node = script->get_node(to_func, p_to.to_int()); + Ref<VisualScriptNode> to_node = script->get_node(p_to.to_int()); ERR_FAIL_COND(!to_node.is_valid()); bool to_seq; @@ -2956,56 +2889,23 @@ void VisualScriptEditor::_graph_connected(const String &p_from, int p_from_slot, ERR_FAIL_COND(from_seq != to_seq); - // Do all the checks here - StringName func; // this the func where we store the one the nodes at the end of the resolution on having multiple nodes + // Do all the checks here. + StringName func; // This the func where we store the one the nodes at the end of the resolution on having multiple nodes. undo_redo->create_action(TTR("Connect Nodes")); - if (from_func == to_func) { - func = to_func; - } else if (from_seq) { - // this is a sequence connection - _move_nodes_with_rescan(to_func, from_func, p_to.to_int()); // this function moves the nodes from func1 to func2 - func = from_func; - } else { - if (node_has_sequence_connections(to_func, p_to.to_int())) { - if (node_has_sequence_connections(from_func, p_from.to_int())) { - ERR_PRINT("Trying to connect between different sequence node trees"); - return; - } else { - _move_nodes_with_rescan(from_func, to_func, p_from.to_int()); - func = to_func; - } - } else if (node_has_sequence_connections(from_func, p_from.to_int())) { - if (from_func == default_func) { - _move_nodes_with_rescan(from_func, to_func, p_from.to_int()); - func = to_func; - } else { - _move_nodes_with_rescan(to_func, from_func, p_to.to_int()); - func = from_func; - } - } else { - if (to_func == default_func) { - _move_nodes_with_rescan(to_func, from_func, p_to.to_int()); - func = from_func; - } else { - _move_nodes_with_rescan(from_func, to_func, p_from.to_int()); - func = to_func; - } - } - } - if (from_seq) { - undo_redo->add_do_method(script.ptr(), "sequence_connect", func, p_from.to_int(), from_port, p_to.to_int()); - // this undo error on undo after move can't be removed without painful gymnastics - undo_redo->add_undo_method(script.ptr(), "sequence_disconnect", func, p_from.to_int(), from_port, p_to.to_int()); + undo_redo->add_do_method(script.ptr(), "sequence_connect", p_from.to_int(), from_port, p_to.to_int()); + // This undo error on undo after move can't be removed without painful gymnastics + undo_redo->add_undo_method(script.ptr(), "sequence_disconnect", p_from.to_int(), from_port, p_to.to_int()); + undo_redo->add_do_method(this, "_update_graph"); + undo_redo->add_undo_method(this, "_update_graph"); } else { bool converted = false; - int conv_node = -1; Ref<VisualScriptOperator> oper = to_node; if (oper.is_valid() && oper->get_typed() == Variant::NIL) { - // it's an operator Node and if the type is already nil + // It's an operator Node and if the type is already nil if (from_node->get_output_value_port_info(from_port).type != Variant::NIL) { oper->set_typed(from_node->get_output_value_port_info(from_port).type); } @@ -3013,106 +2913,36 @@ void VisualScriptEditor::_graph_connected(const String &p_from, int p_from_slot, Ref<VisualScriptOperator> operf = from_node; if (operf.is_valid() && operf->get_typed() == Variant::NIL) { - // it's an operator Node and if the type is already nil + // It's an operator Node and if the type is already nil if (to_node->get_input_value_port_info(to_port).type != Variant::NIL) { operf->set_typed(to_node->get_input_value_port_info(to_port).type); } } - Variant::Type to_type = to_node->get_input_value_port_info(to_port).type; - Variant::Type from_type = from_node->get_output_value_port_info(from_port).type; - - if (to_type != Variant::NIL && from_type != Variant::NIL && to_type != from_type) { - // add a constructor node between the ports - bool exceptions = false; // true if there are any exceptions - exceptions = exceptions || (to_type == Variant::INT && from_type == Variant::FLOAT); - exceptions = exceptions || (to_type == Variant::FLOAT && from_type == Variant::INT); - if (Variant::can_convert(from_type, to_type) && !exceptions) { - MethodInfo mi; - mi.name = Variant::get_type_name(to_type); - PropertyInfo pi; - pi.name = "from"; - pi.type = from_type; - mi.arguments.push_back(pi); - mi.return_val.type = to_type; - // we know that this is allowed so create a new constructor node - Ref<VisualScriptConstructor> constructor; - constructor.instance(); - constructor->set_constructor_type(to_type); - constructor->set_constructor(mi); - // add the new constructor node - - GraphNode *gn = Object::cast_to<GraphNode>(graph->get_node(p_from)); - GraphNode *gn2 = Object::cast_to<GraphNode>(graph->get_node(p_to)); - if (gn && gn2) { - Vector2 from_node_size = gn->get_rect().get_size(); - Vector2 to_node_size = gn2->get_rect().get_size(); - Vector2 to_node_pos = script->get_node_position(func, p_to.to_int()); - Vector2 from_node_pos = script->get_node_position(func, p_from.to_int()); - Vector2 new_to_node_pos = from_node_pos; - Vector2 constructor_pos; - if ((to_node_pos.x - from_node_pos.x) < 0) { - // to is behind from node - if (to_node_pos.x > (from_node_pos.x - to_node_size.x - 240)) { - new_to_node_pos.x = from_node_pos.x - to_node_size.x - 240; // approx size of constructor node + padding - } else { - new_to_node_pos.x = to_node_pos.x; - } - new_to_node_pos.y = to_node_pos.y; - constructor_pos.x = from_node_pos.x - 210; - constructor_pos.y = to_node_pos.y; - } else { - // to is ahead of from node - if (to_node_pos.x < (from_node_size.x + from_node_pos.x + 240)) { - new_to_node_pos.x = from_node_size.x + from_node_pos.x + 240; // approx size of constructor node + padding - } else { - new_to_node_pos.x = to_node_pos.x; - } - new_to_node_pos.y = to_node_pos.y; - constructor_pos.x = from_node_size.x + from_node_pos.x + 10; - constructor_pos.y = to_node_pos.y; - } - undo_redo->add_do_method(this, "_move_node", func, p_to.to_int(), new_to_node_pos); - undo_redo->add_undo_method(this, "_move_node", func, p_to.to_int(), to_node_pos); - conv_node = script->get_available_id(); - undo_redo->add_do_method(script.ptr(), "add_node", func, conv_node, constructor, _get_available_pos(false, constructor_pos)); - undo_redo->add_undo_method(script.ptr(), "remove_node", func, conv_node); - converted = true; - } - } - } - - // disconnect current, and connect the new one - if (script->is_input_value_port_connected(func, p_to.to_int(), to_port)) { + // Disconnect current, and connect the new one + if (script->is_input_value_port_connected(p_to.to_int(), to_port)) { if (can_swap && data_disconnect_node == p_to.to_int()) { int conn_from; int conn_port; - script->get_input_value_port_connection_source(func, p_to.to_int(), to_port, &conn_from, &conn_port); - undo_redo->add_do_method(script.ptr(), "data_disconnect", func, conn_from, conn_port, p_to.to_int(), to_port); - undo_redo->add_do_method(script.ptr(), "data_connect", func, conn_from, conn_port, data_disconnect_node, data_disconnect_port); - undo_redo->add_undo_method(script.ptr(), "data_disconnect", func, conn_from, conn_port, data_disconnect_node, data_disconnect_port); - undo_redo->add_undo_method(script.ptr(), "data_connect", func, conn_from, conn_port, p_to.to_int(), to_port); + script->get_input_value_port_connection_source(p_to.to_int(), to_port, &conn_from, &conn_port); + undo_redo->add_do_method(script.ptr(), "data_disconnect", conn_from, conn_port, p_to.to_int(), to_port); + undo_redo->add_do_method(script.ptr(), "data_connect", conn_from, conn_port, data_disconnect_node, data_disconnect_port); + undo_redo->add_undo_method(script.ptr(), "data_disconnect", conn_from, conn_port, data_disconnect_node, data_disconnect_port); + undo_redo->add_undo_method(script.ptr(), "data_connect", conn_from, conn_port, p_to.to_int(), to_port); can_swap = false; // swapped } else { int conn_from; int conn_port; - script->get_input_value_port_connection_source(func, p_to.to_int(), to_port, &conn_from, &conn_port); - undo_redo->add_do_method(script.ptr(), "data_disconnect", func, conn_from, conn_port, p_to.to_int(), to_port); - undo_redo->add_undo_method(script.ptr(), "data_connect", func, conn_from, conn_port, p_to.to_int(), to_port); + script->get_input_value_port_connection_source(p_to.to_int(), to_port, &conn_from, &conn_port); + undo_redo->add_do_method(script.ptr(), "data_disconnect", conn_from, conn_port, p_to.to_int(), to_port); + undo_redo->add_undo_method(script.ptr(), "data_connect", conn_from, conn_port, p_to.to_int(), to_port); } } if (!converted) { - undo_redo->add_do_method(script.ptr(), "data_connect", func, p_from.to_int(), from_port, p_to.to_int(), to_port); - undo_redo->add_undo_method(script.ptr(), "data_disconnect", func, p_from.to_int(), from_port, p_to.to_int(), to_port); - } else { - // this is noice - undo_redo->add_do_method(script.ptr(), "data_connect", func, p_from.to_int(), from_port, conv_node, 0); - undo_redo->add_do_method(script.ptr(), "data_connect", func, conv_node, 0, p_to.to_int(), to_port); - // I don't think this is needed but gonna leave it here for now... until I need to finalise it all - undo_redo->add_undo_method(script.ptr(), "data_disconnect", func, p_from.to_int(), from_port, conv_node, 0); - undo_redo->add_undo_method(script.ptr(), "data_disconnect", func, conv_node, 0, p_to.to_int(), to_port); + undo_redo->add_do_method(script.ptr(), "data_connect", p_from.to_int(), from_port, p_to.to_int(), to_port); + undo_redo->add_undo_method(script.ptr(), "data_disconnect", p_from.to_int(), from_port, p_to.to_int(), to_port); } - //update nodes in graph + // Update nodes in graph if (!converted) { undo_redo->add_do_method(this, "_update_graph", p_from.to_int()); undo_redo->add_do_method(this, "_update_graph", p_to.to_int()); @@ -3124,34 +2954,28 @@ void VisualScriptEditor::_graph_connected(const String &p_from, int p_from_slot, } } - undo_redo->add_do_method(this, "_update_graph_connections"); - undo_redo->add_undo_method(this, "_update_graph_connections"); - undo_redo->commit_action(); } void VisualScriptEditor::_graph_disconnected(const String &p_from, int p_from_slot, const String &p_to, int p_to_slot) { - StringName func = _get_function_of_node(p_from.to_int()); - ERR_FAIL_COND(func != _get_function_of_node(p_to.to_int())); - - Ref<VisualScriptNode> from_node = script->get_node(func, p_from.to_int()); + Ref<VisualScriptNode> from_node = script->get_node(p_from.to_int()); ERR_FAIL_COND(!from_node.is_valid()); bool from_seq; int from_port; if (!_get_out_slot(from_node, p_from_slot, from_port, from_seq)) { - return; //can't connect this, it's invalid + return; // Can't connect this, it's invalid. } - Ref<VisualScriptNode> to_node = script->get_node(func, p_to.to_int()); + Ref<VisualScriptNode> to_node = script->get_node(p_to.to_int()); ERR_FAIL_COND(!to_node.is_valid()); bool to_seq; int to_port; if (!_get_in_slot(to_node, p_to_slot, to_port, to_seq)) { - return; //can't connect this, it's invalid + return; // Can't connect this, it's invalid. } ERR_FAIL_COND(from_seq != to_seq); @@ -3159,248 +2983,27 @@ void VisualScriptEditor::_graph_disconnected(const String &p_from, int p_from_sl undo_redo->create_action(TTR("Disconnect Nodes")); if (from_seq) { - undo_redo->add_do_method(script.ptr(), "sequence_disconnect", func, p_from.to_int(), from_port, p_to.to_int()); - undo_redo->add_undo_method(script.ptr(), "sequence_connect", func, p_from.to_int(), from_port, p_to.to_int()); + undo_redo->add_do_method(script.ptr(), "sequence_disconnect", p_from.to_int(), from_port, p_to.to_int()); + undo_redo->add_undo_method(script.ptr(), "sequence_connect", p_from.to_int(), from_port, p_to.to_int()); + undo_redo->add_do_method(this, "_update_graph"); + undo_redo->add_undo_method(this, "_update_graph"); } else { can_swap = true; data_disconnect_node = p_to.to_int(); data_disconnect_port = to_port; - undo_redo->add_do_method(script.ptr(), "data_disconnect", func, p_from.to_int(), from_port, p_to.to_int(), to_port); - undo_redo->add_undo_method(script.ptr(), "data_connect", func, p_from.to_int(), from_port, p_to.to_int(), to_port); - //update relevant nodes in the graph + undo_redo->add_do_method(script.ptr(), "data_disconnect", p_from.to_int(), from_port, p_to.to_int(), to_port); + undo_redo->add_undo_method(script.ptr(), "data_connect", p_from.to_int(), from_port, p_to.to_int(), to_port); + // Update relevant nodes in the graph. undo_redo->add_do_method(this, "_update_graph", p_from.to_int()); undo_redo->add_do_method(this, "_update_graph", p_to.to_int()); undo_redo->add_undo_method(this, "_update_graph", p_from.to_int()); undo_redo->add_undo_method(this, "_update_graph", p_to.to_int()); } - undo_redo->add_do_method(this, "_update_graph_connections"); - undo_redo->add_undo_method(this, "_update_graph_connections"); undo_redo->commit_action(); } -void VisualScriptEditor::_move_nodes_with_rescan(const StringName &p_func_from, const StringName &p_func_to, int p_id) { - Set<int> nodes_to_move; - HashMap<int, Map<int, int>> seqconns_to_move; // from => List(outp, to) - HashMap<int, Map<int, Pair<int, int>>> dataconns_to_move; // to => List(inp_p => from, outp) - - nodes_to_move.insert(p_id); - Set<int> sequence_connections; - { - List<VisualScript::SequenceConnection> sequence_conns; - script->get_sequence_connection_list(p_func_from, &sequence_conns); - - HashMap<int, Map<int, int>> seqcons; // from => List(out_p => to) - - for (List<VisualScript::SequenceConnection>::Element *E = sequence_conns.front(); E; E = E->next()) { - int from = E->get().from_node; - int to = E->get().to_node; - int out_p = E->get().from_output; - if (!seqcons.has(from)) { - seqcons.set(from, Map<int, int>()); - } - seqcons[from].insert(out_p, to); - sequence_connections.insert(to); - sequence_connections.insert(from); - } - - int conn = p_id; - List<int> stack; - HashMap<int, Set<int>> seen; // from, outp - while (seqcons.has(conn)) { - for (auto E = seqcons[conn].front(); E; E = E->next()) { - if (seen.has(conn) && seen[conn].has(E->key())) { - if (!E->next()) { - if (stack.size() > 0) { - conn = stack.back()->get(); - stack.pop_back(); - break; - } - conn = -101; - break; - } - continue; - } - if (!seen.has(conn)) { - seen.set(conn, Set<int>()); - } - seen[conn].insert(E->key()); - stack.push_back(conn); - if (!seqconns_to_move.has(conn)) { - seqconns_to_move.set(conn, Map<int, int>()); - } - seqconns_to_move[conn].insert(E->key(), E->get()); - conn = E->get(); - nodes_to_move.insert(conn); - break; - } - if (!seqcons.has(conn) && stack.size() > 0) { - conn = stack.back()->get(); - stack.pop_back(); - } - } - } - - { - List<VisualScript::DataConnection> data_connections; - script->get_data_connection_list(p_func_from, &data_connections); - int func_from_node_id = script->get_function_node_id(p_func_from); - - HashMap<int, Map<int, Pair<int, int>>> connections; - - for (List<VisualScript::DataConnection>::Element *E = data_connections.front(); E; E = E->next()) { - int from = E->get().from_node; - int to = E->get().to_node; - int out_p = E->get().from_port; - int in_p = E->get().to_port; - - // skip if the from_node is a function node - if (from == func_from_node_id) { - continue; - } - - if (!connections.has(to)) { - connections.set(to, Map<int, Pair<int, int>>()); - } - connections[to].insert(in_p, Pair<int, int>(from, out_p)); - } - - // go through the HashMap and do all sorts of crazy ass stuff now... - Set<int> nodes_to_be_added; - for (Set<int>::Element *F = nodes_to_move.front(); F; F = F->next()) { - HashMap<int, Set<int>> seen; - List<int> stack; - int id = F->get(); - while (connections.has(id)) { - for (auto E = connections[id].front(); E; E = E->next()) { - if (seen.has(id) && seen[id].has(E->key())) { - if (!E->next()) { - if (stack.size() > 0) { - id = stack.back()->get(); - stack.pop_back(); - break; - } - id = -11; // I assume ids can't be negative should confirm it... - break; - } - continue; - } - - if (sequence_connections.has(E->get().first)) { - if (!nodes_to_move.has(E->get().first)) { - if (stack.size() > 0) { - id = stack.back()->get(); - stack.pop_back(); - break; - } - id = -11; // I assume ids can't be negative should confirm it... - break; - } - } - - if (!seen.has(id)) { - seen.set(id, Set<int>()); - } - seen[id].insert(E->key()); - stack.push_back(id); - if (!dataconns_to_move.has(id)) { - dataconns_to_move.set(id, Map<int, Pair<int, int>>()); - } - dataconns_to_move[id].insert(E->key(), Pair<int, int>(E->get().first, E->get().second)); - id = E->get().first; - nodes_to_be_added.insert(id); - break; - } - if (!connections.has(id) && stack.size() > 0) { - id = stack.back()->get(); - stack.pop_back(); - } - } - } - for (Set<int>::Element *E = nodes_to_be_added.front(); E; E = E->next()) { - nodes_to_move.insert(E->get()); - } - } - - // * this is primarily for the sake of the having proper undo - List<VisualScript::SequenceConnection> seqext; - List<VisualScript::DataConnection> dataext; - - List<VisualScript::SequenceConnection> seq_connections; - script->get_sequence_connection_list(p_func_from, &seq_connections); - - for (List<VisualScript::SequenceConnection>::Element *E = seq_connections.front(); E; E = E->next()) { - if (!nodes_to_move.has(E->get().from_node) && nodes_to_move.has(E->get().to_node)) { - seqext.push_back(E->get()); - } else if (nodes_to_move.has(E->get().from_node) && !nodes_to_move.has(E->get().to_node)) { - seqext.push_back(E->get()); - } - } - - List<VisualScript::DataConnection> data_connections; - script->get_data_connection_list(p_func_from, &data_connections); - - for (List<VisualScript::DataConnection>::Element *E = data_connections.front(); E; E = E->next()) { - if (!nodes_to_move.has(E->get().from_node) && nodes_to_move.has(E->get().to_node)) { - dataext.push_back(E->get()); - } else if (nodes_to_move.has(E->get().from_node) && !nodes_to_move.has(E->get().to_node)) { - dataext.push_back(E->get()); - } - } - - // undo_redo->create_action("Rescan Functions"); - - for (Set<int>::Element *E = nodes_to_move.front(); E; E = E->next()) { - int id = E->get(); - - undo_redo->add_do_method(script.ptr(), "remove_node", p_func_from, id); - undo_redo->add_do_method(script.ptr(), "add_node", p_func_to, id, script->get_node(p_func_from, id), script->get_node_position(p_func_from, id)); - - undo_redo->add_undo_method(script.ptr(), "remove_node", p_func_to, id); - undo_redo->add_undo_method(script.ptr(), "add_node", p_func_from, id, script->get_node(p_func_from, id), script->get_node_position(p_func_from, id)); - } - - List<int> skeys; - seqconns_to_move.get_key_list(&skeys); - for (List<int>::Element *E = skeys.front(); E; E = E->next()) { - int from_node = E->get(); - for (Map<int, int>::Element *F = seqconns_to_move[from_node].front(); F; F = F->next()) { - int from_port = F->key(); - int to_node = F->get(); - undo_redo->add_do_method(script.ptr(), "sequence_connect", p_func_to, from_node, from_port, to_node); - undo_redo->add_undo_method(script.ptr(), "sequence_connect", p_func_from, from_node, from_port, to_node); - } - } - - List<int> keys; - dataconns_to_move.get_key_list(&keys); - for (List<int>::Element *E = keys.front(); E; E = E->next()) { - int to_node = E->get(); // to_node - for (Map<int, Pair<int, int>>::Element *F = dataconns_to_move[E->get()].front(); F; F = F->next()) { - int inp_p = F->key(); - Pair<int, int> fro = F->get(); - - undo_redo->add_do_method(script.ptr(), "data_connect", p_func_to, fro.first, fro.second, to_node, inp_p); - undo_redo->add_undo_method(script.ptr(), "data_connect", p_func_from, fro.first, fro.second, to_node, inp_p); - } - } - - // this to have proper undo operations - for (List<VisualScript::SequenceConnection>::Element *E = seqext.front(); E; E = E->next()) { - undo_redo->add_undo_method(script.ptr(), "sequence_connect", p_func_from, E->get().from_node, E->get().from_output, E->get().to_node); - } - for (List<VisualScript::DataConnection>::Element *E = dataext.front(); E; E = E->next()) { - undo_redo->add_undo_method(script.ptr(), "data_connect", p_func_from, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); - } - // this doesn't need do methods as they are handled by the subsequent do calls implicitly - - undo_redo->add_do_method(this, "_update_graph"); - undo_redo->add_undo_method(this, "_update_graph"); - - // undo_redo->commit_action(); -} - void VisualScriptEditor::_graph_connect_to_empty(const String &p_from, int p_from_slot, const Vector2 &p_release_pos) { Node *node = graph->get_node(p_from); GraphNode *gn = Object::cast_to<GraphNode>(node); @@ -3408,23 +3011,22 @@ void VisualScriptEditor::_graph_connect_to_empty(const String &p_from, int p_fro return; } - StringName func = _get_function_of_node(p_from.to_int()); - - Ref<VisualScriptNode> vsn = script->get_node(func, p_from.to_int()); + Ref<VisualScriptNode> vsn = script->get_node(p_from.to_int()); if (!vsn.is_valid()) { return; } + if (vsn->get_output_value_port_count()) - port_action_pos = p_release_pos; + port_action_pos = p_release_pos; if (p_from_slot < vsn->get_output_sequence_port_count()) { port_action_node = p_from.to_int(); port_action_output = p_from_slot; - _port_action_menu(CREATE_ACTION, func); + _port_action_menu(CREATE_ACTION); } else { port_action_output = p_from_slot - vsn->get_output_sequence_port_count(); port_action_node = p_from.to_int(); - _port_action_menu(CREATE_CALL_SET_GET, func); + _port_action_menu(CREATE_CALL_SET_GET); } } @@ -3438,9 +3040,7 @@ VisualScriptNode::TypeGuess VisualScriptEditor::_guess_output_type(int p_port_ac visited_nodes.insert(p_port_action_node); - StringName func = _get_function_of_node(p_port_action_node); - - Ref<VisualScriptNode> node = script->get_node(func, p_port_action_node); + Ref<VisualScriptNode> node = script->get_node(p_port_action_node); if (!node.is_valid()) { return tg; @@ -3454,11 +3054,11 @@ VisualScriptNode::TypeGuess VisualScriptEditor::_guess_output_type(int p_port_ac g.type = pi.type; if (g.type == Variant::NIL || g.type == Variant::OBJECT) { - //any or object input, must further guess what this is + // Any or object input, must further guess what this is. int from_node; int from_port; - if (script->get_input_value_port_connection_source(func, p_port_action_node, i, &from_node, &from_port)) { + if (script->get_input_value_port_connection_source(p_port_action_node, i, &from_node, &from_port)) { g = _guess_output_type(from_node, from_port, visited_nodes); } else { Variant defval = node->get_default_input_value(i); @@ -3480,7 +3080,7 @@ VisualScriptNode::TypeGuess VisualScriptEditor::_guess_output_type(int p_port_ac return node->guess_output_type(in_guesses.ptrw(), p_port_action_output); } -void VisualScriptEditor::_port_action_menu(int p_option, const StringName &func) { +void VisualScriptEditor::_port_action_menu(int p_option) { Vector2 ofs = graph->get_scroll_ofs() + port_action_pos; if (graph->is_using_snap()) { int snap = graph->get_snap(); @@ -3503,8 +3103,8 @@ void VisualScriptEditor::_port_action_menu(int p_option, const StringName &func) n->set_base_type("Object"); } String type_string; - if (script->get_node(func, port_action_node)->get_output_value_port_count() > 0) { - type_string = script->get_node(func, port_action_node)->get_output_value_port_info(port_action_output).hint_string; + if (script->get_node(port_action_node)->get_output_value_port_count() > 0) { + type_string = script->get_node(port_action_node)->get_output_value_port_info(port_action_output).hint_string; } if (tg.type == Variant::OBJECT) { if (tg.script.is_valid()) { @@ -3519,7 +3119,7 @@ void VisualScriptEditor::_port_action_menu(int p_option, const StringName &func) } else { new_connect_node_select->select_from_basic_type(tg.type); } - // ensure that the dialog fits inside the graph + // Ensure that the dialog fits inside the graph. Vector2 pos = mouse_up_position; Size2 bounds = graph->get_global_position() + graph->get_size() - new_connect_node_select->get_size(); pos.x = pos.x > bounds.x ? bounds.x : pos.x; @@ -3529,8 +3129,8 @@ void VisualScriptEditor::_port_action_menu(int p_option, const StringName &func) case CREATE_ACTION: { VisualScriptNode::TypeGuess tg = _guess_output_type(port_action_node, port_action_output, vn); PropertyInfo property_info; - if (script->get_node(func, port_action_node)->get_output_value_port_count() > 0) { - property_info = script->get_node(func, port_action_node)->get_output_value_port_info(port_action_output); + if (script->get_node(port_action_node)->get_output_value_port_count() > 0) { + property_info = script->get_node(port_action_node)->get_output_value_port_info(port_action_output); } if (tg.type == Variant::OBJECT) { if (property_info.type == Variant::OBJECT && property_info.hint_string != String()) { @@ -3543,7 +3143,7 @@ void VisualScriptEditor::_port_action_menu(int p_option, const StringName &func) } else { new_connect_node_select->select_from_action(Variant::get_type_name(tg.type)); } - // ensure that the dialog fits inside the graph + // Ensure that the dialog fits inside the graph. Vector2 pos = mouse_up_position; Size2 bounds = graph->get_global_position() + graph->get_size() - new_connect_node_select->get_size(); pos.x = pos.x > bounds.x ? bounds.x : pos.x; @@ -3572,9 +3172,8 @@ void VisualScriptEditor::connect_data(Ref<VisualScriptNode> vnode_old, Ref<Visua if (port >= value_count) { port = 0; } - StringName func = _get_function_of_node(port_action_node); - undo_redo->add_do_method(script.ptr(), "data_connect", func, port_action_node, port, new_id, 0); - undo_redo->add_undo_method(script.ptr(), "data_disconnect", func, port_action_node, port, new_id, 0); + undo_redo->add_do_method(script.ptr(), "data_connect", port_action_node, port, new_id, 0); + undo_redo->add_undo_method(script.ptr(), "data_disconnect", port_action_node, port, new_id, 0); undo_redo->commit_action(); } @@ -3591,17 +3190,16 @@ void VisualScriptEditor::_selected_connect_node(const String &p_text, const Stri bool port_node_exists = true; - StringName func = _get_function_of_node(port_action_node); - if (func == StringName()) { - func = default_func; - port_node_exists = false; - } + // if (func == StringName()) { + // func = default_func; + // port_node_exists = false; + // } if (p_category == "visualscript") { Ref<VisualScriptNode> vnode_new = VisualScriptLanguage::singleton->create_node_from_name(p_text); Ref<VisualScriptNode> vnode_old; - if (port_node_exists) { - vnode_old = script->get_node(func, port_action_node); + if (port_node_exists && p_connecting) { + vnode_old = script->get_node(port_action_node); } int new_id = script->get_available_id(); @@ -3624,13 +3222,13 @@ void VisualScriptEditor::_selected_connect_node(const String &p_text, const Stri } undo_redo->create_action(TTR("Add Node")); - undo_redo->add_do_method(script.ptr(), "add_node", func, new_id, vnode_new, ofs); + undo_redo->add_do_method(script.ptr(), "add_node", new_id, vnode_new, ofs); if (vnode_old.is_valid() && p_connecting) { connect_seq(vnode_old, vnode_new, new_id); connect_data(vnode_old, vnode_new, new_id); } - undo_redo->add_undo_method(script.ptr(), "remove_node", func, new_id); + undo_redo->add_undo_method(script.ptr(), "remove_node", new_id); undo_redo->add_do_method(this, "_update_graph"); undo_redo->add_undo_method(this, "_update_graph"); undo_redo->commit_action(); @@ -3687,8 +3285,8 @@ void VisualScriptEditor::_selected_connect_node(const String &p_text, const Stri int new_id = script->get_available_id(); undo_redo->create_action(TTR("Add Node")); - undo_redo->add_do_method(script.ptr(), "add_node", func, new_id, vnode, ofs); - undo_redo->add_undo_method(script.ptr(), "remove_node", func, new_id); + undo_redo->add_do_method(script.ptr(), "add_node", new_id, vnode, ofs); + undo_redo->add_undo_method(script.ptr(), "remove_node", new_id); undo_redo->add_do_method(this, "_update_graph", new_id); undo_redo->add_undo_method(this, "_update_graph", new_id); undo_redo->commit_action(); @@ -3699,7 +3297,7 @@ void VisualScriptEditor::_selected_connect_node(const String &p_text, const Stri port_action_new_node = new_id; - Ref<VisualScriptNode> vsn = script->get_node(func, port_action_new_node); + Ref<VisualScriptNode> vsn = script->get_node(port_action_new_node); if (Object::cast_to<VisualScriptFunctionCall>(vsn.ptr())) { Ref<VisualScriptFunctionCall> vsfc = vsn; @@ -3713,10 +3311,9 @@ void VisualScriptEditor::_selected_connect_node(const String &p_text, const Stri vsfc->set_base_type(String("")); if (tg.gdclass != StringName()) { vsfc->set_base_type(tg.gdclass); - - } else if (script->get_node(func, port_action_node).is_valid()) { - PropertyHint hint = script->get_node(func, port_action_node)->get_output_value_port_info(port_action_output).hint; - String base_type = script->get_node(func, port_action_node)->get_output_value_port_info(port_action_output).hint_string; + } else if (script->get_node(port_action_node).is_valid()) { + PropertyHint hint = script->get_node(port_action_node)->get_output_value_port_info(port_action_output).hint; + String base_type = script->get_node(port_action_node)->get_output_value_port_info(port_action_output).hint_string; if (base_type != String() && hint == PROPERTY_HINT_TYPE_STRING) { vsfc->set_base_type(base_type); @@ -3749,9 +3346,9 @@ void VisualScriptEditor::_selected_connect_node(const String &p_text, const Stri if (tg.gdclass != StringName()) { vsp->set_base_type(tg.gdclass); - } else if (script->get_node(func, port_action_node).is_valid()) { - PropertyHint hint = script->get_node(func, port_action_node)->get_output_value_port_info(port_action_output).hint; - String base_type = script->get_node(func, port_action_node)->get_output_value_port_info(port_action_output).hint_string; + } else if (script->get_node(port_action_node).is_valid()) { + PropertyHint hint = script->get_node(port_action_node)->get_output_value_port_info(port_action_output).hint; + String base_type = script->get_node(port_action_node)->get_output_value_port_info(port_action_output).hint_string; if (base_type != String() && hint == PROPERTY_HINT_TYPE_STRING) { vsp->set_base_type(base_type); @@ -3779,9 +3376,9 @@ void VisualScriptEditor::_selected_connect_node(const String &p_text, const Stri if (tg.gdclass != StringName()) { vsp->set_base_type(tg.gdclass); - } else if (script->get_node(func, port_action_node).is_valid()) { - PropertyHint hint = script->get_node(func, port_action_node)->get_output_value_port_info(port_action_output).hint; - String base_type = script->get_node(func, port_action_node)->get_output_value_port_info(port_action_output).hint_string; + } else if (script->get_node(port_action_node).is_valid()) { + PropertyHint hint = script->get_node(port_action_node)->get_output_value_port_info(port_action_output).hint; + String base_type = script->get_node(port_action_node)->get_output_value_port_info(port_action_output).hint_string; if (base_type != String() && hint == PROPERTY_HINT_TYPE_STRING) { vsp->set_base_type(base_type); } @@ -3799,16 +3396,13 @@ void VisualScriptEditor::_selected_connect_node(const String &p_text, const Stri } } if (port_node_exists) { - Ref<VisualScriptNode> vnode_old = script->get_node(func, port_action_node); + Ref<VisualScriptNode> vnode_old = script->get_node(port_action_node); if (vnode_old.is_valid() && p_connecting) { connect_seq(vnode_old, vnode, port_action_new_node); connect_data(vnode_old, vnode, port_action_new_node); } } _update_graph(port_action_new_node); - if (port_node_exists) { - _update_graph_connections(); - } } void VisualScriptEditor::connect_seq(Ref<VisualScriptNode> vnode_old, Ref<VisualScriptNode> vnode_new, int new_id) { @@ -3827,29 +3421,27 @@ void VisualScriptEditor::connect_seq(Ref<VisualScriptNode> vnode_old, Ref<Visual return; } - StringName func = _get_function_of_node(port_action_node); - undo_redo->create_action(TTR("Connect Node Sequence")); int pass_port = -vnode_old->get_output_sequence_port_count() + 1; int return_port = port_action_output - 1; if (vnode_old->get_output_value_port_info(port_action_output).name == String("pass") && - !script->get_output_sequence_ports_connected(func, port_action_node).has(pass_port)) { - undo_redo->add_do_method(script.ptr(), "sequence_connect", func, port_action_node, pass_port, new_id); - undo_redo->add_undo_method(script.ptr(), "sequence_disconnect", func, port_action_node, pass_port, new_id); + !script->get_output_sequence_ports_connected(port_action_node).has(pass_port)) { + undo_redo->add_do_method(script.ptr(), "sequence_connect", port_action_node, pass_port, new_id); + undo_redo->add_undo_method(script.ptr(), "sequence_disconnect", port_action_node, pass_port, new_id); } else if (vnode_old->get_output_value_port_info(port_action_output).name == String("return") && - !script->get_output_sequence_ports_connected(func, port_action_node).has(return_port)) { - undo_redo->add_do_method(script.ptr(), "sequence_connect", func, port_action_node, return_port, new_id); - undo_redo->add_undo_method(script.ptr(), "sequence_disconnect", func, port_action_node, return_port, new_id); + !script->get_output_sequence_ports_connected(port_action_node).has(return_port)) { + undo_redo->add_do_method(script.ptr(), "sequence_connect", port_action_node, return_port, new_id); + undo_redo->add_undo_method(script.ptr(), "sequence_disconnect", port_action_node, return_port, new_id); } else { for (int port = 0; port < vnode_old->get_output_sequence_port_count(); port++) { int count = vnode_old->get_output_sequence_port_count(); - if (port_action_output < count && !script->get_output_sequence_ports_connected(func, port_action_node).has(port_action_output)) { - undo_redo->add_do_method(script.ptr(), "sequence_connect", func, port_action_node, port_action_output, new_id); - undo_redo->add_undo_method(script.ptr(), "sequence_disconnect", func, port_action_node, port_action_output, new_id); + if (port_action_output < count && !script->get_output_sequence_ports_connected(port_action_node).has(port_action_output)) { + undo_redo->add_do_method(script.ptr(), "sequence_connect", port_action_node, port_action_output, new_id); + undo_redo->add_undo_method(script.ptr(), "sequence_disconnect", port_action_node, port_action_output, new_id); break; - } else if (!script->get_output_sequence_ports_connected(func, port_action_node).has(port)) { - undo_redo->add_do_method(script.ptr(), "sequence_connect", func, port_action_node, port, new_id); - undo_redo->add_undo_method(script.ptr(), "sequence_disconnect", func, port_action_node, port, new_id); + } else if (!script->get_output_sequence_ports_connected(port_action_node).has(port)) { + undo_redo->add_do_method(script.ptr(), "sequence_connect", port_action_node, port, new_id); + undo_redo->add_undo_method(script.ptr(), "sequence_disconnect", port_action_node, port, new_id); break; } } @@ -3884,9 +3476,9 @@ void VisualScriptEditor::_selected_new_virtual_method(const String &p_text, cons Ref<VisualScriptFunction> func_node; func_node.instance(); func_node->set_name(name); - + int fn_id = script->get_available_id(); undo_redo->create_action(TTR("Add Function")); - undo_redo->add_do_method(script.ptr(), "add_function", name); + undo_redo->add_do_method(script.ptr(), "add_function", name, fn_id); for (int i = 0; i < minfo.arguments.size(); i++) { func_node->add_argument(minfo.arguments[i].type, minfo.arguments[i].name, -1, minfo.arguments[i].hint, minfo.arguments[i].hint_string); @@ -3894,14 +3486,17 @@ void VisualScriptEditor::_selected_new_virtual_method(const String &p_text, cons Vector2 ofs = _get_available_pos(); - undo_redo->add_do_method(script.ptr(), "add_node", name, script->get_available_id(), func_node, ofs); + undo_redo->add_do_method(script.ptr(), "add_node", fn_id, func_node, ofs); + undo_redo->add_undo_method(script.ptr(), "remove_node", fn_id); if (minfo.return_val.type != Variant::NIL || minfo.return_val.usage & PROPERTY_USAGE_NIL_IS_VARIANT) { Ref<VisualScriptReturn> ret_node; ret_node.instance(); ret_node->set_return_type(minfo.return_val.type); ret_node->set_enable_return_value(true); ret_node->set_name(name); - undo_redo->add_do_method(script.ptr(), "add_node", name, script->get_available_id() + 1, ret_node, _get_available_pos(false, ofs + Vector2(500, 0))); + int nid = script->get_available_id() + 1; + undo_redo->add_do_method(script.ptr(), "add_node", nid, ret_node, _get_available_pos(false, ofs + Vector2(500, 0))); + undo_redo->add_undo_method(script.ptr(), "remove_node", nid); } undo_redo->add_undo_method(script.ptr(), "remove_function", name); @@ -3916,21 +3511,16 @@ void VisualScriptEditor::_selected_new_virtual_method(const String &p_text, cons } void VisualScriptEditor::_cancel_connect_node() { - // ensure the cancel is done + // Ensure the cancel is done. port_action_new_node = -1; } -int VisualScriptEditor::_create_new_node_from_name(const String &p_text, const Vector2 &p_point, const StringName &p_func) { - StringName func = default_func; - if (p_func != StringName()) { - func = p_func; - } - +int VisualScriptEditor::_create_new_node_from_name(const String &p_text, const Vector2 &p_point) { Ref<VisualScriptNode> vnode = VisualScriptLanguage::singleton->create_node_from_name(p_text); int new_id = script->get_available_id(); undo_redo->create_action(TTR("Add Node")); - undo_redo->add_do_method(script.ptr(), "add_node", func, new_id, vnode, p_point); - undo_redo->add_undo_method(script.ptr(), "remove_node", func, new_id); + undo_redo->add_do_method(script.ptr(), "add_node", new_id, vnode, p_point); + undo_redo->add_undo_method(script.ptr(), "remove_node", new_id); undo_redo->add_do_method(this, "_update_graph"); undo_redo->add_undo_method(this, "_update_graph"); undo_redo->commit_action(); @@ -3938,7 +3528,7 @@ int VisualScriptEditor::_create_new_node_from_name(const String &p_text, const V } void VisualScriptEditor::_default_value_changed() { - Ref<VisualScriptNode> vsn = script->get_node(_get_function_of_node(editing_id), editing_id); + Ref<VisualScriptNode> vsn = script->get_node(editing_id); if (vsn.is_null()) { return; } @@ -3953,7 +3543,7 @@ void VisualScriptEditor::_default_value_changed() { } void VisualScriptEditor::_default_value_edited(Node *p_button, int p_id, int p_input_port) { - Ref<VisualScriptNode> vsn = script->get_node(_get_function_of_node(p_id), p_id); + Ref<VisualScriptNode> vsn = script->get_node(p_id); if (vsn.is_null()) { return; } @@ -3972,15 +3562,15 @@ void VisualScriptEditor::_default_value_edited(Node *p_button, int p_id, int p_i if (pinfo.type == Variant::NODE_PATH) { Node *edited_scene = get_tree()->get_edited_scene_root(); - if (edited_scene) { // Fixing an old crash bug ( Visual Script Crashes on editing NodePath with an empty scene open) + if (edited_scene) { // Fixing an old crash bug ( Visual Script Crashes on editing NodePath with an empty scene open). Node *script_node = _find_script_node(edited_scene, edited_scene, script); if (script_node) { - //pick a node relative to the script, IF the script exists + // Pick a node relative to the script, IF the script exists. pinfo.hint = PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE; pinfo.hint_string = script_node->get_path(); } else { - //pick a path relative to edited scene + // Pick a path relative to edited scene. pinfo.hint = PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE; pinfo.hint_string = get_tree()->get_edited_scene_root()->get_path(); } @@ -4078,11 +3668,8 @@ void VisualScriptEditor::_graph_ofs_changed(const Vector2 &p_ofs) { updating_graph = true; - // Just use the default func for all the properties that need to be handled for drawing rather than adding to the Visual Script Class - if (script->has_function(default_func)) { - script->set_function_scroll(default_func, graph->get_scroll_ofs() / EDSCALE); - script->set_edited(true); - } + script->set_scroll(graph->get_scroll_ofs() / EDSCALE); + script->set_edited(true); updating_graph = false; } @@ -4090,10 +3677,7 @@ void VisualScriptEditor::_comment_node_resized(const Vector2 &p_new_size, int p_ if (updating_graph) { return; } - - StringName func = _get_function_of_node(p_node); - - Ref<VisualScriptComment> vsc = script->get_node(func, p_node); + Ref<VisualScriptComment> vsc = script->get_node(p_node); if (vsc.is_null()) { return; } @@ -4104,16 +3688,23 @@ void VisualScriptEditor::_comment_node_resized(const Vector2 &p_new_size, int p_ return; } + Vector2 new_size = p_new_size; + if (graph->is_using_snap()) { + Vector2 snap = Vector2(graph->get_snap(), graph->get_snap()); + Vector2 min_size = (gn->get_minimum_size() + (snap * 0.5)).snapped(snap); + new_size = new_size.snapped(snap).max(min_size); + } + updating_graph = true; graph->set_block_minimum_size_adjust(true); //faster resize undo_redo->create_action(TTR("Resize Comment"), UndoRedo::MERGE_ENDS); - undo_redo->add_do_method(vsc.ptr(), "set_size", p_new_size / EDSCALE); + undo_redo->add_do_method(vsc.ptr(), "set_size", new_size / EDSCALE); undo_redo->add_undo_method(vsc.ptr(), "set_size", vsc->get_size()); undo_redo->commit_action(); - gn->set_custom_minimum_size(p_new_size); + gn->set_custom_minimum_size(new_size); gn->set_size(Size2(1, 1)); graph->set_block_minimum_size_adjust(false); updating_graph = false; @@ -4131,8 +3722,7 @@ void VisualScriptEditor::_menu_option(int p_what) { if (gn) { if (gn->is_selected()) { int id = String(gn->get_name()).to_int(); - StringName func = _get_function_of_node(id); - Ref<VisualScriptNode> vsn = script->get_node(func, id); + Ref<VisualScriptNode> vsn = script->get_node(id); if (vsn.is_valid()) { vsn->set_breakpoint(!vsn->is_breakpoint()); reselect.push_back(gn->get_name()); @@ -4154,58 +3744,47 @@ void VisualScriptEditor::_menu_option(int p_what) { } break; case EDIT_COPY_NODES: case EDIT_CUT_NODES: { - if (!script->has_function(default_func)) { - break; - } - clipboard->nodes.clear(); clipboard->data_connections.clear(); clipboard->sequence_connections.clear(); - Set<String> funcs; for (int i = 0; i < graph->get_child_count(); i++) { GraphNode *gn = Object::cast_to<GraphNode>(graph->get_child(i)); if (gn) { if (gn->is_selected()) { - int id = String(gn->get_name()).to_int(); - StringName func = _get_function_of_node(id); - Ref<VisualScriptNode> node = script->get_node(func, id); + int id = gn->get_name().operator String().to_int(); + Ref<VisualScriptNode> node = script->get_node(id); if (Object::cast_to<VisualScriptFunction>(*node)) { EditorNode::get_singleton()->show_warning(TTR("Can't copy the function node.")); return; } if (node.is_valid()) { clipboard->nodes[id] = node->duplicate(true); - clipboard->nodes_positions[id] = script->get_node_position(func, id); - funcs.insert(String(func)); + clipboard->nodes_positions[id] = script->get_node_position(id); } } } } - if (clipboard->nodes.empty()) { + if (clipboard->nodes.is_empty()) { break; } - for (Set<String>::Element *F = funcs.front(); F; F = F->next()) { - List<VisualScript::SequenceConnection> sequence_connections; - - script->get_sequence_connection_list(F->get(), &sequence_connections); + List<VisualScript::SequenceConnection> sequence_connections; + script->get_sequence_connection_list(&sequence_connections); - for (List<VisualScript::SequenceConnection>::Element *E = sequence_connections.front(); E; E = E->next()) { - if (clipboard->nodes.has(E->get().from_node) && clipboard->nodes.has(E->get().to_node)) { - clipboard->sequence_connections.insert(E->get()); - } + for (List<VisualScript::SequenceConnection>::Element *E = sequence_connections.front(); E; E = E->next()) { + if (clipboard->nodes.has(E->get().from_node) && clipboard->nodes.has(E->get().to_node)) { + clipboard->sequence_connections.insert(E->get()); } + } - List<VisualScript::DataConnection> data_connections; - - script->get_data_connection_list(F->get(), &data_connections); + List<VisualScript::DataConnection> data_connections; + script->get_data_connection_list(&data_connections); - for (List<VisualScript::DataConnection>::Element *E = data_connections.front(); E; E = E->next()) { - if (clipboard->nodes.has(E->get().from_node) && clipboard->nodes.has(E->get().to_node)) { - clipboard->data_connections.insert(E->get()); - } + for (List<VisualScript::DataConnection>::Element *E = data_connections.front(); E; E = E->next()) { + if (clipboard->nodes.has(E->get().from_node) && clipboard->nodes.has(E->get().to_node)) { + clipboard->data_connections.insert(E->get()); } } if (p_what == EDIT_CUT_NODES) { @@ -4214,11 +3793,7 @@ void VisualScriptEditor::_menu_option(int p_what) { } break; case EDIT_PASTE_NODES: { - if (!script->has_function(default_func)) { - break; - } - - if (clipboard->nodes.empty()) { + if (clipboard->nodes.is_empty()) { EditorNode::get_singleton()->show_warning(TTR("Clipboard is empty!")); break; } @@ -4233,15 +3808,11 @@ void VisualScriptEditor::_menu_option(int p_what) { Set<Vector2> existing_positions; { - List<StringName> functions; - script->get_function_list(&functions); - for (List<StringName>::Element *F = functions.front(); F; F = F->next()) { - List<int> nodes; - script->get_node_list(F->get(), &nodes); - for (List<int>::Element *E = nodes.front(); E; E = E->next()) { - Vector2 pos = script->get_node_position(F->get(), E->get()).snapped(Vector2(2, 2)); - existing_positions.insert(pos); - } + List<int> nodes; + script->get_node_list(&nodes); + for (List<int>::Element *E = nodes.front(); E; E = E->next()) { + Vector2 pos = script->get_node_position(E->get()).snapped(Vector2(2, 2)); + existing_positions.insert(pos); } } @@ -4259,18 +3830,18 @@ void VisualScriptEditor::_menu_option(int p_what) { paste_pos += Vector2(20, 20) * EDSCALE; } - undo_redo->add_do_method(script.ptr(), "add_node", default_func, new_id, node, paste_pos); - undo_redo->add_undo_method(script.ptr(), "remove_node", default_func, new_id); + undo_redo->add_do_method(script.ptr(), "add_node", new_id, node, paste_pos); + undo_redo->add_undo_method(script.ptr(), "remove_node", new_id); } for (Set<VisualScript::SequenceConnection>::Element *E = clipboard->sequence_connections.front(); E; E = E->next()) { - undo_redo->add_do_method(script.ptr(), "sequence_connect", default_func, remap[E->get().from_node], E->get().from_output, remap[E->get().to_node]); - undo_redo->add_undo_method(script.ptr(), "sequence_disconnect", default_func, remap[E->get().from_node], E->get().from_output, remap[E->get().to_node]); + undo_redo->add_do_method(script.ptr(), "sequence_connect", remap[E->get().from_node], E->get().from_output, remap[E->get().to_node]); + undo_redo->add_undo_method(script.ptr(), "sequence_disconnect", remap[E->get().from_node], E->get().from_output, remap[E->get().to_node]); } for (Set<VisualScript::DataConnection>::Element *E = clipboard->data_connections.front(); E; E = E->next()) { - undo_redo->add_do_method(script.ptr(), "data_connect", default_func, remap[E->get().from_node], E->get().from_port, remap[E->get().to_node], E->get().to_port); - undo_redo->add_undo_method(script.ptr(), "data_disconnect", default_func, remap[E->get().from_node], E->get().from_port, remap[E->get().to_node], E->get().to_port); + undo_redo->add_do_method(script.ptr(), "data_connect", remap[E->get().from_node], E->get().from_port, remap[E->get().to_node], E->get().to_port); + undo_redo->add_undo_method(script.ptr(), "data_disconnect", remap[E->get().from_node], E->get().from_port, remap[E->get().to_node], E->get().to_port); } undo_redo->add_do_method(this, "_update_graph"); @@ -4287,7 +3858,7 @@ void VisualScriptEditor::_menu_option(int p_what) { } } break; case EDIT_CREATE_FUNCTION: { - StringName function = ""; + // Create Function. Map<int, Ref<VisualScriptNode>> nodes; Set<int> selections; for (int i = 0; i < graph->get_child_count(); i++) { @@ -4295,20 +3866,14 @@ void VisualScriptEditor::_menu_option(int p_what) { if (gn) { if (gn->is_selected()) { int id = String(gn->get_name()).to_int(); - StringName func = _get_function_of_node(id); - Ref<VisualScriptNode> node = script->get_node(func, id); + Ref<VisualScriptNode> node = script->get_node(id); if (Object::cast_to<VisualScriptFunction>(*node)) { EditorNode::get_singleton()->show_warning(TTR("Can't create function with a function node.")); return; } if (node.is_valid()) { - if (func != function && function != StringName("")) { - EditorNode::get_singleton()->show_warning(TTR("Can't create function of nodes from nodes of multiple functions.")); - return; - } nodes.insert(id, node); selections.insert(id); - function = func; } } } @@ -4327,7 +3892,7 @@ void VisualScriptEditor::_menu_option(int p_what) { int start_node = -1; Set<int> end_nodes; if (nodes.size() == 1) { - Ref<VisualScriptNode> nd = script->get_node(function, nodes.front()->key()); + Ref<VisualScriptNode> nd = script->get_node(nodes.front()->key()); if (nd.is_valid() && nd->has_input_sequence_port()) { start_node = nodes.front()->key(); } else { @@ -4336,29 +3901,29 @@ void VisualScriptEditor::_menu_option(int p_what) { } } else { List<VisualScript::SequenceConnection> seqs; - script->get_sequence_connection_list(function, &seqs); + script->get_sequence_connection_list(&seqs); if (seqs.size() == 0) { - // in case there are no sequence connections - // select the top most node cause that's probably how - // the user wants to connect the nodes + // In case there are no sequence connections, + // select the top most node cause that's probably how, + // the user wants to connect the nodes. int top_nd = -1; Vector2 top; for (Map<int, Ref<VisualScriptNode>>::Element *E = nodes.front(); E; E = E->next()) { - Ref<VisualScriptNode> nd = script->get_node(function, E->key()); + Ref<VisualScriptNode> nd = script->get_node(E->key()); if (nd.is_valid() && nd->has_input_sequence_port()) { if (top_nd < 0) { top_nd = E->key(); - top = script->get_node_position(function, top_nd); + top = script->get_node_position(top_nd); } - Vector2 pos = script->get_node_position(function, E->key()); + Vector2 pos = script->get_node_position(E->key()); if (top.y > pos.y) { top_nd = E->key(); top = pos; } } } - Ref<VisualScriptNode> nd = script->get_node(function, top_nd); + Ref<VisualScriptNode> nd = script->get_node(top_nd); if (nd.is_valid() && nd->has_input_sequence_port()) { start_node = top_nd; } else { @@ -4366,7 +3931,7 @@ void VisualScriptEditor::_menu_option(int p_what) { return; } } else { - // pick the node with input sequence + // Pick the node with input sequence. Set<int> nodes_from; Set<int> nodes_to; for (List<VisualScript::SequenceConnection>::Element *E = seqs.front(); E; E = E->next()) { @@ -4387,13 +3952,13 @@ void VisualScriptEditor::_menu_option(int p_what) { nodes_to.insert(E->get().to_node); } - // to use to add return nodes + // To use to add return nodes. _get_ends(start_node, seqs, selections, end_nodes); if (start_node == -1) { - // if we still don't have a start node then - // run through the nodes and select the first tree node - // ie node without any input sequence but output sequence + // If we still don't have a start node then, + // run through the nodes and select the first tree node, + // ie node without any input sequence but output sequence. for (Set<int>::Element *E = nodes_from.front(); E; E = E->next()) { if (!nodes_to.has(E->get())) { start_node = E->get(); @@ -4404,20 +3969,20 @@ void VisualScriptEditor::_menu_option(int p_what) { } if (start_node == -1) { - return; // this should not happen, but just in case something goes wrong + return; // This should not happen, but just in case something goes wrong. } List<Variant::Type> inputs; // input types List<Pair<int, int>> input_connections; { List<VisualScript::DataConnection> dats; - script->get_data_connection_list(function, &dats); + script->get_data_connection_list(&dats); for (List<VisualScript::DataConnection>::Element *E = dats.front(); E; E = E->next()) { if (nodes.has(E->get().from_node) && nodes.has(E->get().to_node)) { datamove.insert(E->get()); } else if (!nodes.has(E->get().from_node) && nodes.has(E->get().to_node)) { - // add all these as inputs for the Function - Ref<VisualScriptNode> node = script->get_node(function, E->get().to_node); + // Add all these as inputs for the Function. + Ref<VisualScriptNode> node = script->get_node(E->get().to_node); if (node.is_valid()) { dataext.insert(E->get()); PropertyInfo pi = node->get_input_value_port_info(E->get().to_port); @@ -4429,59 +3994,55 @@ void VisualScriptEditor::_menu_option(int p_what) { } } } - - String new_fn = _validate_name("new_function"); - - Vector2 ofs = _get_available_pos(false, script->get_node_position(function, start_node) - Vector2(80, 150)); - - Ref<VisualScriptFunction> func_node; - func_node.instance(); - func_node->set_name(new_fn); - - undo_redo->create_action(TTR("Create Function")); - - undo_redo->add_do_method(script.ptr(), "add_function", new_fn); int fn_id = script->get_available_id(); - undo_redo->add_do_method(script.ptr(), "add_node", new_fn, fn_id, func_node, ofs); - undo_redo->add_undo_method(script.ptr(), "remove_function", new_fn); - undo_redo->add_do_method(this, "_update_members"); - undo_redo->add_undo_method(this, "_update_members"); - undo_redo->add_do_method(this, "emit_signal", "edited_script_changed"); - undo_redo->add_undo_method(this, "emit_signal", "edited_script_changed"); - - // Move the nodes + { + String new_fn = _validate_name("new_function"); - for (Map<int, Ref<VisualScriptNode>>::Element *E = nodes.front(); E; E = E->next()) { - undo_redo->add_do_method(script.ptr(), "remove_node", function, E->key()); - undo_redo->add_do_method(script.ptr(), "add_node", new_fn, E->key(), E->get(), script->get_node_position(function, E->key())); + Vector2 ofs = _get_available_pos(false, script->get_node_position(start_node) - Vector2(80, 150)); - // undo_redo->add_undo_method(script.ptr(), "remove_node", new_fn, E->key()); not needed cause we already remove the function :P - undo_redo->add_undo_method(script.ptr(), "add_node", function, E->key(), E->get(), script->get_node_position(function, E->key())); - } + Ref<VisualScriptFunction> func_node; + func_node.instance(); + func_node->set_name(new_fn); - for (Set<VisualScript::SequenceConnection>::Element *E = seqmove.front(); E; E = E->next()) { - undo_redo->add_do_method(script.ptr(), "sequence_connect", new_fn, E->get().from_node, E->get().from_output, E->get().to_node); - undo_redo->add_undo_method(script.ptr(), "sequence_connect", function, E->get().from_node, E->get().from_output, E->get().to_node); - } + undo_redo->create_action(TTR("Create Function")); - for (Set<VisualScript::DataConnection>::Element *E = datamove.front(); E; E = E->next()) { - undo_redo->add_do_method(script.ptr(), "data_connect", new_fn, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); - undo_redo->add_undo_method(script.ptr(), "data_connect", function, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); + undo_redo->add_do_method(script.ptr(), "add_function", new_fn, fn_id); + undo_redo->add_do_method(script.ptr(), "add_node", fn_id, func_node, ofs); + undo_redo->add_undo_method(script.ptr(), "remove_function", new_fn); + undo_redo->add_undo_method(script.ptr(), "remove_node", fn_id); + undo_redo->add_do_method(this, "_update_members"); + undo_redo->add_undo_method(this, "_update_members"); + undo_redo->add_do_method(this, "emit_signal", "edited_script_changed"); + undo_redo->add_undo_method(this, "emit_signal", "edited_script_changed"); + // Might make the system more intelligent by checking port from info. + int i = 0; + List<Pair<int, int>>::Element *F = input_connections.front(); + for (List<Variant::Type>::Element *E = inputs.front(); E && F; E = E->next(), F = F->next()) { + func_node->add_argument(E->get(), "arg_" + String::num_int64(i), i); + undo_redo->add_do_method(script.ptr(), "data_connect", fn_id, i, F->get().first, F->get().second); + i++; // increment i + } + // Ensure Preview Selection is of newly created function node. + if (selections.size()) { + EditorNode::get_singleton()->push_item(func_node.ptr()); + } } + // Move the nodes. - // Add undo for external connections as well so that it's easier to revert back and forth - // these didn't require do methods as it's already handled internally by other do calls + // Handles reconnection of sequence connections on undo, start here in case of issues. for (Set<VisualScript::SequenceConnection>::Element *E = seqext.front(); E; E = E->next()) { - undo_redo->add_undo_method(script.ptr(), "sequence_connect", function, E->get().from_node, E->get().from_output, E->get().to_node); + undo_redo->add_do_method(script.ptr(), "sequence_disconnect", E->get().from_node, E->get().from_output, E->get().to_node); + undo_redo->add_undo_method(script.ptr(), "sequence_connect", E->get().from_node, E->get().from_output, E->get().to_node); } for (Set<VisualScript::DataConnection>::Element *E = dataext.front(); E; E = E->next()) { - undo_redo->add_undo_method(script.ptr(), "data_connect", function, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); + undo_redo->add_do_method(script.ptr(), "data_disconnect", E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); + undo_redo->add_undo_method(script.ptr(), "data_connect", E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); } - // I don't really think we need support for non sequenced functions at this moment - undo_redo->add_do_method(script.ptr(), "sequence_connect", new_fn, fn_id, 0, start_node); + // I don't really think we need support for non sequenced functions at this moment. + undo_redo->add_do_method(script.ptr(), "sequence_connect", fn_id, 0, start_node); - // end nodes are mapped to the return nodes with data connections if possible + // Could fail with the new changes, start here when searching for bugs in create function shortcut. int m = 1; for (Set<int>::Element *G = end_nodes.front(); G; G = G->next()) { Ref<VisualScriptReturn> ret_node; @@ -4489,36 +4050,27 @@ void VisualScriptEditor::_menu_option(int p_what) { int ret_id = fn_id + (m++); selections.insert(ret_id); - Vector2 ofsi = _get_available_pos(false, script->get_node_position(function, G->get()) + Vector2(80, -100)); - undo_redo->add_do_method(script.ptr(), "add_node", new_fn, ret_id, ret_node, ofsi); - undo_redo->add_undo_method(script.ptr(), "remove_node", new_fn, ret_id); + Vector2 ofsi = _get_available_pos(false, script->get_node_position(G->get()) + Vector2(80, -100)); + undo_redo->add_do_method(script.ptr(), "add_node", ret_id, ret_node, ofsi); + undo_redo->add_undo_method(script.ptr(), "remove_node", ret_id); - undo_redo->add_do_method(script.ptr(), "sequence_connect", new_fn, G->get(), 0, ret_id); - // add data outputs from each of the end_nodes - Ref<VisualScriptNode> vsn = script->get_node(function, G->get()); + undo_redo->add_do_method(script.ptr(), "sequence_connect", G->get(), 0, ret_id); + // Add data outputs from each of the end_nodes. + Ref<VisualScriptNode> vsn = script->get_node(G->get()); if (vsn.is_valid() && vsn->get_output_value_port_count() > 0) { ret_node->set_enable_return_value(true); - // use the zeroth data port cause that's the likely one that is planned to be used + // Use the zeroth data port cause that's the likely one that is planned to be used. ret_node->set_return_type(vsn->get_output_value_port_info(0).type); - undo_redo->add_do_method(script.ptr(), "data_connect", new_fn, G->get(), 0, ret_id, 0); + undo_redo->add_do_method(script.ptr(), "data_connect", G->get(), 0, ret_id, 0); } } - // * might make the system more intelligent by checking port from info. - int i = 0; - List<Pair<int, int>>::Element *F = input_connections.front(); - for (List<Variant::Type>::Element *E = inputs.front(); E && F; E = E->next(), F = F->next()) { - func_node->add_argument(E->get(), "arg_" + String::num_int64(i), i); - undo_redo->add_do_method(script.ptr(), "data_connect", new_fn, fn_id, i, F->get().first, F->get().second); - i++; // increment i - } - undo_redo->add_do_method(this, "_update_graph"); undo_redo->add_undo_method(this, "_update_graph"); undo_redo->commit_action(); - // make sure all Nodes get marked for selection so that they can be moved together + // Make sure all Nodes get marked for selection so that they can be moved together. selections.insert(fn_id); for (int k = 0; k < graph->get_child_count(); k++) { GraphNode *gn = Object::cast_to<GraphNode>(graph->get_child(k)); @@ -4528,11 +4080,6 @@ void VisualScriptEditor::_menu_option(int p_what) { } } - // Ensure Preview Selection is of newly created function node - if (selections.size()) { - EditorNode::get_singleton()->push_item(func_node.ptr()); - } - } break; case REFRESH_GRAPH: { _update_graph(); @@ -4540,16 +4087,16 @@ void VisualScriptEditor::_menu_option(int p_what) { } } -// this is likely going to be very slow and I am not sure if I should keep it -// but I hope that it will not be a problem considering that we won't be creating functions so frequently -// and cyclic connections would be a problem but hopefully we won't let them get to this point +// This is likely going to be very slow and I am not sure if I should keep it, +// but I hope that it will not be a problem considering that we won't be creating functions so frequently, +// and cyclic connections would be a problem but hopefully we won't let them get to this point. void VisualScriptEditor::_get_ends(int p_node, const List<VisualScript::SequenceConnection> &p_seqs, const Set<int> &p_selected, Set<int> &r_end_nodes) { for (const List<VisualScript::SequenceConnection>::Element *E = p_seqs.front(); E; E = E->next()) { int from = E->get().from_node; int to = E->get().to_node; if (from == p_node && p_selected.has(to)) { - // this is an interior connection move forward to the to node + // This is an interior connection move forward to the to node. _get_ends(to, p_seqs, p_selected, r_end_nodes); } else if (from == p_node && !p_selected.has(to)) { r_end_nodes.insert(from); @@ -4609,34 +4156,29 @@ void VisualScriptEditor::_member_option(int p_option) { switch (member_type) { case MEMBER_FUNCTION: { if (p_option == MEMBER_REMOVE) { - //delete the function + // Delete the function. String name = member_name; - + List<String> lst; + int fn_node = script->get_function_node_id(name); undo_redo->create_action(TTR("Remove Function")); undo_redo->add_do_method(script.ptr(), "remove_function", name); - undo_redo->add_undo_method(script.ptr(), "add_function", name); - List<int> nodes; - script->get_node_list(name, &nodes); - for (List<int>::Element *E = nodes.front(); E; E = E->next()) { - undo_redo->add_undo_method(script.ptr(), "add_node", name, E->get(), script->get_node(name, E->get()), script->get_node_position(name, E->get())); - } - - List<VisualScript::SequenceConnection> seq_connections; - - script->get_sequence_connection_list(name, &seq_connections); - - for (List<VisualScript::SequenceConnection>::Element *E = seq_connections.front(); E; E = E->next()) { - undo_redo->add_undo_method(script.ptr(), "sequence_connect", name, E->get().from_node, E->get().from_output, E->get().to_node); + undo_redo->add_do_method(script.ptr(), "remove_node", fn_node); + undo_redo->add_undo_method(script.ptr(), "add_function", name, fn_node); + undo_redo->add_undo_method(script.ptr(), "add_node", fn_node, script->get_node(fn_node), script->get_node_position(fn_node)); + List<VisualScript::SequenceConnection> seqcons; + script->get_sequence_connection_list(&seqcons); + for (const List<VisualScript::SequenceConnection>::Element *E = seqcons.front(); E; E = E->next()) { + if (E->get().from_node == fn_node) { + undo_redo->add_undo_method(script.ptr(), "sequence_connect", fn_node, E->get().from_output, E->get().to_node); + } } - - List<VisualScript::DataConnection> data_connections; - - script->get_data_connection_list(name, &data_connections); - - for (List<VisualScript::DataConnection>::Element *E = data_connections.front(); E; E = E->next()) { - undo_redo->add_undo_method(script.ptr(), "data_connect", name, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); + List<VisualScript::DataConnection> datcons; + script->get_data_connection_list(&datcons); + for (const List<VisualScript::DataConnection>::Element *E = datcons.front(); E; E = E->next()) { + if (E->get().from_node == fn_node) { + undo_redo->add_undo_method(script.ptr(), "data_connect", fn_node, E->get().from_port, E->get().to_node, E->get().to_port); + } } - undo_redo->add_do_method(this, "_update_members"); undo_redo->add_undo_method(this, "_update_members"); undo_redo->add_do_method(this, "_update_graph"); @@ -4732,13 +4274,13 @@ VisualScriptEditor::VisualScriptEditor() { edit_menu->set_shortcut_context(this); edit_menu->set_text(TTR("Edit")); edit_menu->set_switch_on_hover(true); - edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("visual_script_editor/delete_selected"), EDIT_DELETE_NODES); + edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("ui_graph_delete"), EDIT_DELETE_NODES); edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("visual_script_editor/toggle_breakpoint"), EDIT_TOGGLE_BREAKPOINT); edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("visual_script_editor/find_node_type"), EDIT_FIND_NODE_TYPE); edit_menu->get_popup()->add_separator(); - edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("visual_script_editor/copy_nodes"), EDIT_COPY_NODES); - edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("visual_script_editor/cut_nodes"), EDIT_CUT_NODES); - edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("visual_script_editor/paste_nodes"), EDIT_PASTE_NODES); + edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("ui_copy"), EDIT_COPY_NODES); + edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("ui_cut"), EDIT_CUT_NODES); + edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("ui_paste"), EDIT_PASTE_NODES); edit_menu->get_popup()->add_separator(); edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("visual_script_editor/create_function"), EDIT_CREATE_FUNCTION); edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("visual_script_editor/refresh_nodes"), REFRESH_GRAPH); @@ -4794,6 +4336,8 @@ VisualScriptEditor::VisualScriptEditor() { graph->connect("duplicate_nodes_request", callable_mp(this, &VisualScriptEditor::_on_nodes_duplicate)); graph->connect("gui_input", callable_mp(this, &VisualScriptEditor::_graph_gui_input)); graph->set_drag_forwarding(this); + float graph_minimap_opacity = EditorSettings::get_singleton()->get("editors/visual_editors/minimap_opacity"); + graph->set_minimap_opacity(graph_minimap_opacity); graph->hide(); graph->connect("scroll_offset_changed", callable_mp(this, &VisualScriptEditor::_graph_ofs_changed)); @@ -4976,12 +4520,8 @@ void VisualScriptEditor::free_clipboard() { static void register_editor_callback() { ScriptEditor::register_create_script_editor_function(create_editor); - ED_SHORTCUT("visual_script_editor/delete_selected", TTR("Delete Selected"), KEY_DELETE); ED_SHORTCUT("visual_script_editor/toggle_breakpoint", TTR("Toggle Breakpoint"), KEY_F9); ED_SHORTCUT("visual_script_editor/find_node_type", TTR("Find Node Type"), KEY_MASK_CMD + KEY_F); - ED_SHORTCUT("visual_script_editor/copy_nodes", TTR("Copy Nodes"), KEY_MASK_CMD + KEY_C); - ED_SHORTCUT("visual_script_editor/cut_nodes", TTR("Cut Nodes"), KEY_MASK_CMD + KEY_X); - ED_SHORTCUT("visual_script_editor/paste_nodes", TTR("Paste Nodes"), KEY_MASK_CMD + KEY_V); ED_SHORTCUT("visual_script_editor/create_function", TTR("Make Function"), KEY_MASK_CMD + KEY_G); ED_SHORTCUT("visual_script_editor/refresh_nodes", TTR("Refresh Graph"), KEY_MASK_CMD + KEY_R); ED_SHORTCUT("visual_script_editor/edit_member", TTR("Edit Member"), KEY_MASK_CMD + KEY_E); diff --git a/modules/visual_script/visual_script_editor.h b/modules/visual_script/visual_script_editor.h index 5610e6b1b4..bb6f194286 100644 --- a/modules/visual_script/visual_script_editor.h +++ b/modules/visual_script/visual_script_editor.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -136,8 +136,6 @@ class VisualScriptEditor : public ScriptEditorBase { }; HashMap<StringName, Ref<StyleBox>> node_styles; - StringName edited_func; - StringName default_func; void _update_graph_connections(); void _update_graph(int p_only_id = -1); @@ -176,7 +174,7 @@ class VisualScriptEditor : public ScriptEditorBase { Vector2 mouse_up_position; - void _port_action_menu(int p_option, const StringName &p_func); + void _port_action_menu(int p_option); void connect_data(Ref<VisualScriptNode> vnode_old, Ref<VisualScriptNode> vnode, int new_id); @@ -184,13 +182,13 @@ class VisualScriptEditor : public ScriptEditorBase { void connect_seq(Ref<VisualScriptNode> vnode_old, Ref<VisualScriptNode> vnode_new, int new_id); void _cancel_connect_node(); - int _create_new_node_from_name(const String &p_text, const Vector2 &p_point, const StringName &p_func = StringName()); + int _create_new_node_from_name(const String &p_text, const Vector2 &p_point); void _selected_new_virtual_method(const String &p_text, const String &p_category, const bool p_connecting); int error_line; void _node_selected(Node *p_node); - void _center_on_node(const StringName &p_func, int p_id); + void _center_on_node(int p_id); void _node_filter_changed(const String &p_text); void _change_base_type_callback(); @@ -201,7 +199,7 @@ class VisualScriptEditor : public ScriptEditorBase { void _begin_node_move(); void _end_node_move(); - void _move_node(const StringName &p_func, int p_id, const Vector2 &p_to); + void _move_node(int p_id, const Vector2 &p_to); void _get_ends(int p_node, const List<VisualScript::SequenceConnection> &p_seqs, const Set<int> &p_selected, Set<int> &r_end_nodes); @@ -211,7 +209,7 @@ class VisualScriptEditor : public ScriptEditorBase { void _graph_disconnected(const String &p_from, int p_from_slot, const String &p_to, int p_to_slot); void _graph_connect_to_empty(const String &p_from, int p_from_slot, const Vector2 &p_release_pos); - void _node_ports_changed(const String &p_func, int p_id); + void _node_ports_changed(int p_id); void _node_create(); void _update_available_nodes(); @@ -228,10 +226,8 @@ class VisualScriptEditor : public ScriptEditorBase { void _port_name_focus_out(const Node *p_name_box, int p_id, int p_port, bool is_input); Vector2 _get_available_pos(bool centered = true, Vector2 ofs = Vector2()) const; - StringName _get_function_of_node(int p_id) const; - void _move_nodes_with_rescan(const StringName &p_func_from, const StringName &p_func_to, int p_id); - bool node_has_sequence_connections(const StringName &p_func, int p_id); + bool node_has_sequence_connections(int p_id); void _generic_search(String p_base_type = "", Vector2 pos = Vector2(), bool node_centered = false); diff --git a/modules/visual_script/visual_script_expression.cpp b/modules/visual_script/visual_script_expression.cpp index 10a18dfd5e..f673cbb06d 100644 --- a/modules/visual_script/visual_script_expression.cpp +++ b/modules/visual_script/visual_script_expression.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -63,7 +63,7 @@ bool VisualScriptExpression::_set(const StringName &p_name, const Variant &p_val } expression_dirty = true; ports_changed_notify(); - _change_notify(); + notify_property_list_changed(); return true; } @@ -1506,13 +1506,20 @@ VisualScriptNodeInstance *VisualScriptExpression::instance(VisualScriptInstance return instance; } +void VisualScriptExpression::reset_state() { + if (nodes) { + memdelete(nodes); + nodes = nullptr; + root = nullptr; + } + + error_str = String(); + error_set = false; + str_ofs = 0; + inputs.clear(); +} + VisualScriptExpression::VisualScriptExpression() { - output_type = Variant::NIL; - expression_dirty = true; - error_set = true; - root = nullptr; - nodes = nullptr; - sequenced = false; } VisualScriptExpression::~VisualScriptExpression() { diff --git a/modules/visual_script/visual_script_expression.h b/modules/visual_script/visual_script_expression.h index 2b3b25842d..c35075ea53 100644 --- a/modules/visual_script/visual_script_expression.h +++ b/modules/visual_script/visual_script_expression.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -39,20 +39,18 @@ class VisualScriptExpression : public VisualScriptNode { friend class VisualScriptNodeInstanceExpression; struct Input { - Variant::Type type; + Variant::Type type = Variant::NIL; String name; - - Input() { type = Variant::NIL; } }; Vector<Input> inputs; - Variant::Type output_type; + Variant::Type output_type = Variant::NIL; String expression; - bool sequenced; - int str_ofs; - bool expression_dirty; + bool sequenced = false; + int str_ofs = 0; + bool expression_dirty = true; bool _compile_expression(); @@ -114,7 +112,7 @@ class VisualScriptExpression : public VisualScriptNode { Error _get_token(Token &r_token); String error_str; - bool error_set; + bool error_set = true; struct ENode { enum Type { @@ -131,11 +129,10 @@ class VisualScriptExpression : public VisualScriptNode { TYPE_CALL }; - ENode *next; + ENode *next = nullptr; - Type type; + Type type = Type::TYPE_SELF; - ENode() { next = nullptr; } virtual ~ENode() { if (next) { memdelete(next); @@ -144,17 +141,17 @@ class VisualScriptExpression : public VisualScriptNode { }; struct Expression { - bool is_op; + bool is_op = false; union { Variant::Operator op; - ENode *node; + ENode *node = nullptr; }; }; ENode *_parse_expression(); struct InputNode : public ENode { - int index; + int index = 0; InputNode() { type = TYPE_INPUT; } @@ -168,9 +165,9 @@ class VisualScriptExpression : public VisualScriptNode { }; struct OperatorNode : public ENode { - Variant::Operator op; + Variant::Operator op = Variant::Operator::OP_ADD; - ENode *nodes[2]; + ENode *nodes[2] = { nullptr, nullptr }; OperatorNode() { type = TYPE_OPERATOR; @@ -184,8 +181,8 @@ class VisualScriptExpression : public VisualScriptNode { }; struct IndexNode : public ENode { - ENode *base; - ENode *index; + ENode *base = nullptr; + ENode *index = nullptr; IndexNode() { type = TYPE_INDEX; @@ -193,7 +190,7 @@ class VisualScriptExpression : public VisualScriptNode { }; struct NamedIndexNode : public ENode { - ENode *base; + ENode *base = nullptr; StringName name; NamedIndexNode() { @@ -202,7 +199,7 @@ class VisualScriptExpression : public VisualScriptNode { }; struct ConstructorNode : public ENode { - Variant::Type data_type; + Variant::Type data_type = Variant::Type::NIL; Vector<ENode *> arguments; ConstructorNode() { @@ -211,7 +208,7 @@ class VisualScriptExpression : public VisualScriptNode { }; struct CallNode : public ENode { - ENode *base; + ENode *base = nullptr; StringName method; Vector<ENode *> arguments; @@ -235,7 +232,7 @@ class VisualScriptExpression : public VisualScriptNode { }; struct BuiltinFuncNode : public ENode { - VisualScriptBuiltinFunc::BuiltinFunc func; + VisualScriptBuiltinFunc::BuiltinFunc func = VisualScriptBuiltinFunc::BuiltinFunc::BYTES_TO_VAR; Vector<ENode *> arguments; BuiltinFuncNode() { type = TYPE_BUILTIN_FUNC; @@ -250,8 +247,8 @@ class VisualScriptExpression : public VisualScriptNode { return node; } - ENode *root; - ENode *nodes; + ENode *root = nullptr; + ENode *nodes = nullptr; protected: bool _set(const StringName &p_name, const Variant &p_value); @@ -259,6 +256,8 @@ protected: void _get_property_list(List<PropertyInfo> *p_list) const; public: + virtual void reset_state() override; + virtual int get_output_sequence_port_count() const override; virtual bool has_input_sequence_port() const override; diff --git a/modules/visual_script/visual_script_flow_control.cpp b/modules/visual_script/visual_script_flow_control.cpp index 36c756fc58..e2a8323509 100644 --- a/modules/visual_script/visual_script_flow_control.cpp +++ b/modules/visual_script/visual_script_flow_control.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -628,7 +628,7 @@ VisualScriptNodeInstance *VisualScriptSwitch::instance(VisualScriptInstance *p_i bool VisualScriptSwitch::_set(const StringName &p_name, const Variant &p_value) { if (String(p_name) == "case_count") { case_values.resize(p_value); - _change_notify(); + notify_property_list_changed(); ports_changed_notify(); return true; } @@ -638,7 +638,7 @@ bool VisualScriptSwitch::_set(const StringName &p_name, const Variant &p_value) ERR_FAIL_INDEX_V(idx, case_values.size(), false); case_values.write[idx].type = Variant::Type(int(p_value)); - _change_notify(); + notify_property_list_changed(); ports_changed_notify(); return true; @@ -677,6 +677,10 @@ void VisualScriptSwitch::_get_property_list(List<PropertyInfo> *p_list) const { } } +void VisualScriptSwitch::reset_state() { + case_values.clear(); +} + void VisualScriptSwitch::_bind_methods() { } @@ -733,7 +737,7 @@ void VisualScriptTypeCast::set_base_type(const StringName &p_type) { } base_type = p_type; - _change_notify(); + notify_property_list_changed(); ports_changed_notify(); } @@ -747,7 +751,7 @@ void VisualScriptTypeCast::set_base_script(const String &p_path) { } script = p_path; - _change_notify(); + notify_property_list_changed(); ports_changed_notify(); } diff --git a/modules/visual_script/visual_script_flow_control.h b/modules/visual_script/visual_script_flow_control.h index 1d0d6d103b..d9c4dedafd 100644 --- a/modules/visual_script/visual_script_flow_control.h +++ b/modules/visual_script/visual_script_flow_control.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -202,6 +202,8 @@ protected: static void _bind_methods(); public: + virtual void reset_state() override; + virtual int get_output_sequence_port_count() const override; virtual bool has_input_sequence_port() const override; diff --git a/modules/visual_script/visual_script_func_nodes.cpp b/modules/visual_script/visual_script_func_nodes.cpp index b2aa42ef97..b5aacb0506 100644 --- a/modules/visual_script/visual_script_func_nodes.cpp +++ b/modules/visual_script/visual_script_func_nodes.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -281,7 +281,7 @@ void VisualScriptFunctionCall::set_basic_type(Variant::Type p_type) { } basic_type = p_type; - _change_notify(); + notify_property_list_changed(); ports_changed_notify(); } @@ -295,7 +295,7 @@ void VisualScriptFunctionCall::set_base_type(const StringName &p_type) { } base_type = p_type; - _change_notify(); + notify_property_list_changed(); ports_changed_notify(); } @@ -309,7 +309,7 @@ void VisualScriptFunctionCall::set_base_script(const String &p_path) { } base_script = p_path; - _change_notify(); + notify_property_list_changed(); ports_changed_notify(); } @@ -328,7 +328,7 @@ void VisualScriptFunctionCall::set_singleton(const StringName &p_type) { base_type = obj->get_class(); } - _change_notify(); + notify_property_list_changed(); ports_changed_notify(); } @@ -425,7 +425,7 @@ void VisualScriptFunctionCall::set_function(const StringName &p_type) { _update_method_cache(); } - _change_notify(); + notify_property_list_changed(); ports_changed_notify(); } @@ -439,7 +439,7 @@ void VisualScriptFunctionCall::set_base_path(const NodePath &p_type) { } base_path = p_type; - _change_notify(); + notify_property_list_changed(); ports_changed_notify(); } @@ -453,7 +453,7 @@ void VisualScriptFunctionCall::set_call_mode(CallMode p_mode) { } call_mode = p_mode; - _change_notify(); + notify_property_list_changed(); ports_changed_notify(); } @@ -476,7 +476,7 @@ void VisualScriptFunctionCall::set_rpc_call_mode(VisualScriptFunctionCall::RPCCa } rpc_call_mode = p_mode; ports_changed_notify(); - _change_notify(); + notify_property_list_changed(); } VisualScriptFunctionCall::RPCCallMode VisualScriptFunctionCall::get_rpc_call_mode() const { @@ -1067,7 +1067,7 @@ void VisualScriptPropertySet::set_basic_type(Variant::Type p_type) { } basic_type = p_type; - _change_notify(); + notify_property_list_changed(); _update_base_type(); ports_changed_notify(); } @@ -1082,7 +1082,7 @@ void VisualScriptPropertySet::set_base_type(const StringName &p_type) { } base_type = p_type; - _change_notify(); + notify_property_list_changed(); ports_changed_notify(); } @@ -1096,7 +1096,7 @@ void VisualScriptPropertySet::set_base_script(const String &p_path) { } base_script = p_path; - _change_notify(); + notify_property_list_changed(); ports_changed_notify(); } @@ -1191,7 +1191,7 @@ void VisualScriptPropertySet::set_property(const StringName &p_type) { property = p_type; index = StringName(); _update_cache(); - _change_notify(); + notify_property_list_changed(); ports_changed_notify(); } @@ -1206,7 +1206,7 @@ void VisualScriptPropertySet::set_base_path(const NodePath &p_type) { base_path = p_type; _update_base_type(); - _change_notify(); + notify_property_list_changed(); ports_changed_notify(); } @@ -1221,7 +1221,7 @@ void VisualScriptPropertySet::set_call_mode(CallMode p_mode) { call_mode = p_mode; _update_base_type(); - _change_notify(); + notify_property_list_changed(); ports_changed_notify(); } @@ -1243,7 +1243,7 @@ void VisualScriptPropertySet::set_index(const StringName &p_type) { } index = p_type; _update_cache(); - _change_notify(); + notify_property_list_changed(); ports_changed_notify(); } @@ -1259,7 +1259,7 @@ void VisualScriptPropertySet::set_assign_op(AssignOp p_op) { assign_op = p_op; _update_cache(); - _change_notify(); + notify_property_list_changed(); ports_changed_notify(); } @@ -1760,7 +1760,7 @@ void VisualScriptPropertyGet::set_base_type(const StringName &p_type) { } base_type = p_type; - _change_notify(); + notify_property_list_changed(); ports_changed_notify(); } @@ -1774,7 +1774,7 @@ void VisualScriptPropertyGet::set_base_script(const String &p_path) { } base_script = p_path; - _change_notify(); + notify_property_list_changed(); ports_changed_notify(); } @@ -1871,7 +1871,7 @@ void VisualScriptPropertyGet::set_property(const StringName &p_type) { property = p_type; _update_cache(); - _change_notify(); + notify_property_list_changed(); ports_changed_notify(); } @@ -1885,7 +1885,7 @@ void VisualScriptPropertyGet::set_base_path(const NodePath &p_type) { } base_path = p_type; - _change_notify(); + notify_property_list_changed(); _update_base_type(); ports_changed_notify(); } @@ -1900,7 +1900,7 @@ void VisualScriptPropertyGet::set_call_mode(CallMode p_mode) { } call_mode = p_mode; - _change_notify(); + notify_property_list_changed(); _update_base_type(); ports_changed_notify(); } @@ -1915,7 +1915,7 @@ void VisualScriptPropertyGet::set_basic_type(Variant::Type p_type) { } basic_type = p_type; - _change_notify(); + notify_property_list_changed(); ports_changed_notify(); } @@ -1937,7 +1937,7 @@ void VisualScriptPropertyGet::set_index(const StringName &p_type) { } index = p_type; _update_cache(); - _change_notify(); + notify_property_list_changed(); ports_changed_notify(); } @@ -2261,7 +2261,7 @@ void VisualScriptEmitSignal::set_signal(const StringName &p_type) { name = p_type; - _change_notify(); + notify_property_list_changed(); ports_changed_notify(); } diff --git a/modules/visual_script/visual_script_func_nodes.h b/modules/visual_script/visual_script_func_nodes.h index 8372df561f..2ff9b7a981 100644 --- a/modules/visual_script/visual_script_func_nodes.h +++ b/modules/visual_script/visual_script_func_nodes.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/visual_script/visual_script_nodes.cpp b/modules/visual_script/visual_script_nodes.cpp index edec270adc..fed6637acb 100644 --- a/modules/visual_script/visual_script_nodes.cpp +++ b/modules/visual_script/visual_script_nodes.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -57,7 +57,7 @@ bool VisualScriptFunction::_set(const StringName &p_name, const Variant &p_value arguments.write[i].type = Variant::NIL; } ports_changed_notify(); - _change_notify(); + notify_property_list_changed(); return true; } if (String(p_name).begins_with("argument_")) { @@ -303,6 +303,14 @@ VisualScriptNodeInstance *VisualScriptFunction::instance(VisualScriptInstance *p return instance; } +void VisualScriptFunction::reset_state() { + arguments.clear(); + stack_size = 256; + stack_less = false; + sequenced = true; + rpc_mode = MultiplayerAPI::RPC_MODE_DISABLED; +} + VisualScriptFunction::VisualScriptFunction() { stack_size = 256; stack_less = false; @@ -312,7 +320,7 @@ VisualScriptFunction::VisualScriptFunction() { void VisualScriptFunction::set_stack_less(bool p_enable) { stack_less = p_enable; - _change_notify(); + notify_property_list_changed(); } bool VisualScriptFunction::is_stack_less() const { @@ -421,7 +429,7 @@ bool VisualScriptLists::_set(const StringName &p_name, const Variant &p_value) { inputports.write[i].type = Variant::NIL; } ports_changed_notify(); - _change_notify(); + notify_property_list_changed(); return true; } if (String(p_name).begins_with("input_") && is_input_port_editable()) { @@ -457,7 +465,7 @@ bool VisualScriptLists::_set(const StringName &p_name, const Variant &p_value) { outputports.write[i].type = Variant::NIL; } ports_changed_notify(); - _change_notify(); + notify_property_list_changed(); return true; } if (String(p_name).begins_with("output_") && is_output_port_editable()) { @@ -578,7 +586,7 @@ void VisualScriptLists::add_input_data_port(Variant::Type p_type, const String & } ports_changed_notify(); - _change_notify(); + notify_property_list_changed(); } void VisualScriptLists::set_input_data_port_type(int p_idx, Variant::Type p_type) { @@ -590,7 +598,7 @@ void VisualScriptLists::set_input_data_port_type(int p_idx, Variant::Type p_type inputports.write[p_idx].type = p_type; ports_changed_notify(); - _change_notify(); + notify_property_list_changed(); } void VisualScriptLists::set_input_data_port_name(int p_idx, const String &p_name) { @@ -602,7 +610,7 @@ void VisualScriptLists::set_input_data_port_name(int p_idx, const String &p_name inputports.write[p_idx].name = p_name; ports_changed_notify(); - _change_notify(); + notify_property_list_changed(); } void VisualScriptLists::remove_input_data_port(int p_argidx) { @@ -615,7 +623,7 @@ void VisualScriptLists::remove_input_data_port(int p_argidx) { inputports.remove(p_argidx); ports_changed_notify(); - _change_notify(); + notify_property_list_changed(); } // output data port interaction @@ -634,7 +642,7 @@ void VisualScriptLists::add_output_data_port(Variant::Type p_type, const String } ports_changed_notify(); - _change_notify(); + notify_property_list_changed(); } void VisualScriptLists::set_output_data_port_type(int p_idx, Variant::Type p_type) { @@ -646,7 +654,7 @@ void VisualScriptLists::set_output_data_port_type(int p_idx, Variant::Type p_typ outputports.write[p_idx].type = p_type; ports_changed_notify(); - _change_notify(); + notify_property_list_changed(); } void VisualScriptLists::set_output_data_port_name(int p_idx, const String &p_name) { @@ -658,7 +666,7 @@ void VisualScriptLists::set_output_data_port_name(int p_idx, const String &p_nam outputports.write[p_idx].name = p_name; ports_changed_notify(); - _change_notify(); + notify_property_list_changed(); } void VisualScriptLists::remove_output_data_port(int p_argidx) { @@ -671,7 +679,7 @@ void VisualScriptLists::remove_output_data_port(int p_argidx) { outputports.remove(p_argidx); ports_changed_notify(); - _change_notify(); + notify_property_list_changed(); } // sequences @@ -687,6 +695,13 @@ bool VisualScriptLists::is_sequenced() const { return sequenced; } +void VisualScriptLists::reset_state() { + inputports.clear(); + outputports.clear(); + sequenced = false; + flags = 0; +} + VisualScriptLists::VisualScriptLists() { // initialize sequenced = false; @@ -1433,7 +1448,7 @@ void VisualScriptConstant::set_constant_type(Variant::Type p_type) { Callable::CallError ce; Variant::construct(type, value, nullptr, 0, ce); ports_changed_notify(); - _change_notify(); + notify_property_list_changed(); } Variant::Type VisualScriptConstant::get_constant_type() const { @@ -1764,7 +1779,7 @@ String VisualScriptGlobalConstant::get_caption() const { void VisualScriptGlobalConstant::set_global_constant(int p_which) { index = p_which; - _change_notify(); + notify_property_list_changed(); ports_changed_notify(); } @@ -1850,7 +1865,7 @@ String VisualScriptClassConstant::get_caption() const { void VisualScriptClassConstant::set_class_constant(const StringName &p_which) { name = p_which; - _change_notify(); + notify_property_list_changed(); ports_changed_notify(); } @@ -1876,7 +1891,7 @@ void VisualScriptClassConstant::set_base_type(const StringName &p_which) { } else { name = ""; } - _change_notify(); + notify_property_list_changed(); ports_changed_notify(); } @@ -1983,7 +1998,7 @@ String VisualScriptBasicTypeConstant::get_text() const { void VisualScriptBasicTypeConstant::set_basic_type_constant(const StringName &p_which) { name = p_which; - _change_notify(); + notify_property_list_changed(); ports_changed_notify(); } @@ -2010,7 +2025,7 @@ void VisualScriptBasicTypeConstant::set_basic_type(Variant::Type p_which) { } else { name = ""; } - _change_notify(); + notify_property_list_changed(); ports_changed_notify(); } @@ -2140,7 +2155,7 @@ String VisualScriptMathConstant::get_caption() const { void VisualScriptMathConstant::set_math_constant(MathConstant p_which) { constant = p_which; - _change_notify(); + notify_property_list_changed(); ports_changed_notify(); } @@ -2233,7 +2248,7 @@ String VisualScriptEngineSingleton::get_caption() const { void VisualScriptEngineSingleton::set_singleton(const String &p_string) { singleton = p_string; - _change_notify(); + notify_property_list_changed(); ports_changed_notify(); } @@ -2342,7 +2357,7 @@ String VisualScriptSceneNode::get_caption() const { void VisualScriptSceneNode::set_node_path(const NodePath &p_path) { path = p_path; - _change_notify(); + notify_property_list_changed(); ports_changed_notify(); } @@ -2620,7 +2635,7 @@ String VisualScriptResourcePath::get_caption() const { void VisualScriptResourcePath::set_resource_path(const String &p_path) { path = p_path; - _change_notify(); + notify_property_list_changed(); ports_changed_notify(); } @@ -3748,7 +3763,7 @@ void VisualScriptDeconstruct::set_deconstruct_type(Variant::Type p_type) { type = p_type; _update_elements(); ports_changed_notify(); - _change_notify(); //to make input appear/disappear + notify_property_list_changed(); //to make input appear/disappear } Variant::Type VisualScriptDeconstruct::get_deconstruct_type() const { diff --git a/modules/visual_script/visual_script_nodes.h b/modules/visual_script/visual_script_nodes.h index b6061f8838..7392443e4e 100644 --- a/modules/visual_script/visual_script_nodes.h +++ b/modules/visual_script/visual_script_nodes.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -99,6 +99,8 @@ public: virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) override; + virtual void reset_state() override; + VisualScriptFunction(); }; @@ -134,6 +136,8 @@ protected: static void _bind_methods(); public: + virtual void reset_state() override; + virtual bool is_output_port_editable() const; virtual bool is_output_port_name_editable() const; virtual bool is_output_port_type_editable() const; diff --git a/modules/visual_script/visual_script_property_selector.cpp b/modules/visual_script/visual_script_property_selector.cpp index dbb76e19ac..862cac5c67 100644 --- a/modules/visual_script/visual_script_property_selector.cpp +++ b/modules/visual_script/visual_script_property_selector.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -358,7 +358,7 @@ void VisualScriptPropertySelector::get_visual_node_names(const String &root_filt continue; } - bool in_modifier = p_modifiers.empty(); + bool in_modifier = p_modifiers.is_empty(); for (Set<String>::Element *F = p_modifiers.front(); F && in_modifier; F = F->next()) { if (E->get().findn(F->get()) != -1) { in_modifier = true; diff --git a/modules/visual_script/visual_script_property_selector.h b/modules/visual_script/visual_script_property_selector.h index cc49b2863d..7a87f3d3ee 100644 --- a/modules/visual_script/visual_script_property_selector.h +++ b/modules/visual_script/visual_script_property_selector.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/visual_script/visual_script_yield_nodes.cpp b/modules/visual_script/visual_script_yield_nodes.cpp index dd07cc45a7..25fabd7b87 100644 --- a/modules/visual_script/visual_script_yield_nodes.cpp +++ b/modules/visual_script/visual_script_yield_nodes.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -152,7 +152,7 @@ void VisualScriptYield::set_yield_mode(YieldMode p_mode) { } yield_mode = p_mode; ports_changed_notify(); - _change_notify(); + notify_property_list_changed(); } VisualScriptYield::YieldMode VisualScriptYield::get_yield_mode() { @@ -359,7 +359,7 @@ void VisualScriptYieldSignal::set_base_type(const StringName &p_type) { base_type = p_type; - _change_notify(); + notify_property_list_changed(); ports_changed_notify(); } @@ -374,7 +374,7 @@ void VisualScriptYieldSignal::set_signal(const StringName &p_type) { signal = p_type; - _change_notify(); + notify_property_list_changed(); ports_changed_notify(); } @@ -389,7 +389,7 @@ void VisualScriptYieldSignal::set_base_path(const NodePath &p_type) { base_path = p_type; - _change_notify(); + notify_property_list_changed(); ports_changed_notify(); } @@ -404,7 +404,7 @@ void VisualScriptYieldSignal::set_call_mode(CallMode p_mode) { call_mode = p_mode; - _change_notify(); + notify_property_list_changed(); ports_changed_notify(); } diff --git a/modules/visual_script/visual_script_yield_nodes.h b/modules/visual_script/visual_script_yield_nodes.h index 7a72211027..cc7ce0a1c6 100644 --- a/modules/visual_script/visual_script_yield_nodes.h +++ b/modules/visual_script/visual_script_yield_nodes.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/vorbis/register_types.cpp b/modules/vorbis/register_types.cpp index 8874b3887b..d3e77ea629 100644 --- a/modules/vorbis/register_types.cpp +++ b/modules/vorbis/register_types.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/vorbis/register_types.h b/modules/vorbis/register_types.h index 7fa0dfdeef..1497e6f5e4 100644 --- a/modules/vorbis/register_types.h +++ b/modules/vorbis/register_types.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/webm/register_types.cpp b/modules/webm/register_types.cpp index 6248787879..82157a71c9 100644 --- a/modules/webm/register_types.cpp +++ b/modules/webm/register_types.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/webm/register_types.h b/modules/webm/register_types.h index 6a02e3a87a..d090fe745b 100644 --- a/modules/webm/register_types.h +++ b/modules/webm/register_types.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/webm/video_stream_webm.cpp b/modules/webm/video_stream_webm.cpp index 2128b82e3f..101001cba0 100644 --- a/modules/webm/video_stream_webm.cpp +++ b/modules/webm/video_stream_webm.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -156,7 +156,7 @@ void VideoStreamPlaybackWebm::stop() { void VideoStreamPlaybackWebm::play() { stop(); - delay_compensation = ProjectSettings::get_singleton()->get("audio/video_delay_compensation_ms"); + delay_compensation = ProjectSettings::get_singleton()->get("audio/video/video_delay_compensation_ms"); delay_compensation /= 1000.0; playing = true; @@ -429,7 +429,7 @@ void VideoStreamWebm::set_audio_track(int p_track) { //////////// -RES ResourceFormatLoaderWebm::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, bool p_no_cache) { +RES ResourceFormatLoaderWebm::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, CacheMode p_cache_mode) { FileAccess *f = FileAccess::open(p_path, FileAccess::READ); if (!f) { if (r_error) { diff --git a/modules/webm/video_stream_webm.h b/modules/webm/video_stream_webm.h index 25675cb248..60e02ab38b 100644 --- a/modules/webm/video_stream_webm.h +++ b/modules/webm/video_stream_webm.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -126,7 +126,7 @@ public: class ResourceFormatLoaderWebm : public ResourceFormatLoader { public: - virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr, bool p_no_cache = false); + virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr, CacheMode p_cache_mode = CACHE_MODE_REUSE); virtual void get_recognized_extensions(List<String> *p_extensions) const; virtual bool handles_type(const String &p_type) const; virtual String get_resource_type(const String &p_path) const; diff --git a/modules/webp/image_loader_webp.cpp b/modules/webp/image_loader_webp.cpp index b169687f25..b304c4824f 100644 --- a/modules/webp/image_loader_webp.cpp +++ b/modules/webp/image_loader_webp.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -39,7 +39,7 @@ #include <webp/encode.h> static Vector<uint8_t> _webp_lossy_pack(const Ref<Image> &p_image, float p_quality) { - ERR_FAIL_COND_V(p_image.is_null() || p_image->empty(), Vector<uint8_t>()); + ERR_FAIL_COND_V(p_image.is_null() || p_image->is_empty(), Vector<uint8_t>()); Ref<Image> img = p_image->duplicate(); if (img->detect_alpha()) { diff --git a/modules/webp/image_loader_webp.h b/modules/webp/image_loader_webp.h index 49a7407600..9ea3056a19 100644 --- a/modules/webp/image_loader_webp.h +++ b/modules/webp/image_loader_webp.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/webp/register_types.cpp b/modules/webp/register_types.cpp index 0788b06309..ea9af72418 100644 --- a/modules/webp/register_types.cpp +++ b/modules/webp/register_types.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/webp/register_types.h b/modules/webp/register_types.h index d574d7be1d..59d6894bf6 100644 --- a/modules/webp/register_types.h +++ b/modules/webp/register_types.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/webrtc/library_godot_webrtc.js b/modules/webrtc/library_godot_webrtc.js index 9f029407d2..404a116716 100644 --- a/modules/webrtc/library_godot_webrtc.js +++ b/modules/webrtc/library_godot_webrtc.js @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/webrtc/register_types.cpp b/modules/webrtc/register_types.cpp index 0e830f0540..ecfaed9089 100644 --- a/modules/webrtc/register_types.cpp +++ b/modules/webrtc/register_types.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/webrtc/register_types.h b/modules/webrtc/register_types.h index 8f5b9e8452..710ee88a28 100644 --- a/modules/webrtc/register_types.h +++ b/modules/webrtc/register_types.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/webrtc/webrtc_data_channel.cpp b/modules/webrtc/webrtc_data_channel.cpp index cd9e77aff8..004112f992 100644 --- a/modules/webrtc/webrtc_data_channel.cpp +++ b/modules/webrtc/webrtc_data_channel.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/webrtc/webrtc_data_channel.h b/modules/webrtc/webrtc_data_channel.h index 1407f1e3bd..20affc513f 100644 --- a/modules/webrtc/webrtc_data_channel.h +++ b/modules/webrtc/webrtc_data_channel.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/webrtc/webrtc_data_channel_gdnative.cpp b/modules/webrtc/webrtc_data_channel_gdnative.cpp index 67ad2c07ce..d4cf464c7c 100644 --- a/modules/webrtc/webrtc_data_channel_gdnative.cpp +++ b/modules/webrtc/webrtc_data_channel_gdnative.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/webrtc/webrtc_data_channel_gdnative.h b/modules/webrtc/webrtc_data_channel_gdnative.h index 03396d207d..7e02a32046 100644 --- a/modules/webrtc/webrtc_data_channel_gdnative.h +++ b/modules/webrtc/webrtc_data_channel_gdnative.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/webrtc/webrtc_data_channel_js.cpp b/modules/webrtc/webrtc_data_channel_js.cpp index 3a63001a56..dfbec80c86 100644 --- a/modules/webrtc/webrtc_data_channel_js.cpp +++ b/modules/webrtc/webrtc_data_channel_js.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -182,16 +182,9 @@ bool WebRTCDataChannelJS::is_negotiated() const { } WebRTCDataChannelJS::WebRTCDataChannelJS() { - queue_count = 0; - _was_string = false; - _write_mode = WRITE_MODE_BINARY; - _js_id = 0; } WebRTCDataChannelJS::WebRTCDataChannelJS(int js_id) { - queue_count = 0; - _was_string = false; - _write_mode = WRITE_MODE_BINARY; _js_id = js_id; godot_js_rtc_datachannel_connect(js_id, this, &_on_open, &_on_message, &_on_error, &_on_close); diff --git a/modules/webrtc/webrtc_data_channel_js.h b/modules/webrtc/webrtc_data_channel_js.h index e251760019..db58ebccff 100644 --- a/modules/webrtc/webrtc_data_channel_js.h +++ b/modules/webrtc/webrtc_data_channel_js.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -42,16 +42,16 @@ private: String _label; String _protocol; - bool _was_string; - WriteMode _write_mode; + bool _was_string = false; + WriteMode _write_mode = WRITE_MODE_BINARY; enum { PACKET_BUFFER_SIZE = 65536 - 5 // 4 bytes for the size, 1 for for type }; - int _js_id; + int _js_id = 0; RingBuffer<uint8_t> in_buffer; - int queue_count; + int queue_count = 0; uint8_t packet_buffer[PACKET_BUFFER_SIZE]; static void _on_open(void *p_obj); diff --git a/modules/webrtc/webrtc_multiplayer.cpp b/modules/webrtc/webrtc_multiplayer.cpp index e0c0cad68c..741cad5640 100644 --- a/modules/webrtc/webrtc_multiplayer.cpp +++ b/modules/webrtc/webrtc_multiplayer.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/webrtc/webrtc_multiplayer.h b/modules/webrtc/webrtc_multiplayer.h index fb37bd7722..6b4ae6fcc8 100644 --- a/modules/webrtc/webrtc_multiplayer.h +++ b/modules/webrtc/webrtc_multiplayer.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/webrtc/webrtc_peer_connection.cpp b/modules/webrtc/webrtc_peer_connection.cpp index 670924bca2..3e2938bf7d 100644 --- a/modules/webrtc/webrtc_peer_connection.cpp +++ b/modules/webrtc/webrtc_peer_connection.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/webrtc/webrtc_peer_connection.h b/modules/webrtc/webrtc_peer_connection.h index 7366c3d0e8..ae75864489 100644 --- a/modules/webrtc/webrtc_peer_connection.h +++ b/modules/webrtc/webrtc_peer_connection.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/webrtc/webrtc_peer_connection_gdnative.cpp b/modules/webrtc/webrtc_peer_connection_gdnative.cpp index aaa45d3a54..dcf78dfb73 100644 --- a/modules/webrtc/webrtc_peer_connection_gdnative.cpp +++ b/modules/webrtc/webrtc_peer_connection_gdnative.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/webrtc/webrtc_peer_connection_gdnative.h b/modules/webrtc/webrtc_peer_connection_gdnative.h index 846b65c466..578af0202f 100644 --- a/modules/webrtc/webrtc_peer_connection_gdnative.h +++ b/modules/webrtc/webrtc_peer_connection_gdnative.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/webrtc/webrtc_peer_connection_js.cpp b/modules/webrtc/webrtc_peer_connection_js.cpp index ad9b46a8af..8879f7d6ec 100644 --- a/modules/webrtc/webrtc_peer_connection_js.cpp +++ b/modules/webrtc/webrtc_peer_connection_js.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/webrtc/webrtc_peer_connection_js.h b/modules/webrtc/webrtc_peer_connection_js.h index e33dd5f259..0272e67f6f 100644 --- a/modules/webrtc/webrtc_peer_connection_js.h +++ b/modules/webrtc/webrtc_peer_connection_js.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/websocket/editor_debugger_server_websocket.cpp b/modules/websocket/editor_debugger_server_websocket.cpp index 8eb975b323..b02d212c42 100644 --- a/modules/websocket/editor_debugger_server_websocket.cpp +++ b/modules/websocket/editor_debugger_server_websocket.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/websocket/editor_debugger_server_websocket.h b/modules/websocket/editor_debugger_server_websocket.h index 861f389aab..2f73b98c3d 100644 --- a/modules/websocket/editor_debugger_server_websocket.h +++ b/modules/websocket/editor_debugger_server_websocket.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/websocket/emws_client.cpp b/modules/websocket/emws_client.cpp index d6e00a26af..25b6d6ef0e 100644 --- a/modules/websocket/emws_client.cpp +++ b/modules/websocket/emws_client.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -140,11 +140,7 @@ Error EMWSClient::set_buffers(int p_in_buffer, int p_in_packets, int p_out_buffe } EMWSClient::EMWSClient() { - _in_buf_size = DEF_BUF_SHIFT; - _in_pkt_size = DEF_PKT_SHIFT; - _is_connecting = false; _peer = Ref<EMWSPeer>(memnew(EMWSPeer)); - _js_id = 0; } EMWSClient::~EMWSClient() { diff --git a/modules/websocket/emws_client.h b/modules/websocket/emws_client.h index 0123c37457..2ab7dc83d0 100644 --- a/modules/websocket/emws_client.h +++ b/modules/websocket/emws_client.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -41,10 +41,10 @@ class EMWSClient : public WebSocketClient { GDCIIMPL(EMWSClient, WebSocketClient); private: - int _js_id; - bool _is_connecting; - int _in_buf_size; - int _in_pkt_size; + int _js_id = 0; + bool _is_connecting = false; + int _in_buf_size = DEF_BUF_SHIFT; + int _in_pkt_size = DEF_PKT_SHIFT; static void _esws_on_connect(void *obj, char *proto); static void _esws_on_message(void *obj, const uint8_t *p_data, int p_data_size, int p_is_string); diff --git a/modules/websocket/emws_peer.cpp b/modules/websocket/emws_peer.cpp index 5dcfba5567..5e75e10d68 100644 --- a/modules/websocket/emws_peer.cpp +++ b/modules/websocket/emws_peer.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -106,8 +106,6 @@ void EMWSPeer::set_no_delay(bool p_enabled) { } EMWSPeer::EMWSPeer() { - peer_sock = -1; - write_mode = WRITE_MODE_BINARY; close(); }; diff --git a/modules/websocket/emws_peer.h b/modules/websocket/emws_peer.h index 2291a32bbc..abe5bf2bdb 100644 --- a/modules/websocket/emws_peer.h +++ b/modules/websocket/emws_peer.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -56,12 +56,12 @@ class EMWSPeer : public WebSocketPeer { GDCIIMPL(EMWSPeer, WebSocketPeer); private: - int peer_sock; - WriteMode write_mode; + int peer_sock = -1; + WriteMode write_mode = WRITE_MODE_BINARY; Vector<uint8_t> _packet_buffer; PacketBuffer<uint8_t> _in_buffer; - uint8_t _is_string; + uint8_t _is_string = 0; public: Error read_msg(const uint8_t *p_data, uint32_t p_size, bool p_is_string); diff --git a/modules/websocket/emws_server.cpp b/modules/websocket/emws_server.cpp index 9d43283d3e..a35d84f372 100644 --- a/modules/websocket/emws_server.cpp +++ b/modules/websocket/emws_server.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/websocket/emws_server.h b/modules/websocket/emws_server.h index 1ce17855fe..4179b20ffe 100644 --- a/modules/websocket/emws_server.h +++ b/modules/websocket/emws_server.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/websocket/library_godot_websocket.js b/modules/websocket/library_godot_websocket.js index cf2c00a6a6..b182d1ecde 100644 --- a/modules/websocket/library_godot_websocket.js +++ b/modules/websocket/library_godot_websocket.js @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/websocket/packet_buffer.h b/modules/websocket/packet_buffer.h index 18b47b8d50..ed756363cf 100644 --- a/modules/websocket/packet_buffer.h +++ b/modules/websocket/packet_buffer.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/websocket/register_types.cpp b/modules/websocket/register_types.cpp index 8979a09619..5a02509c4a 100644 --- a/modules/websocket/register_types.cpp +++ b/modules/websocket/register_types.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/websocket/register_types.h b/modules/websocket/register_types.h index bb7be57ab3..3884db67b7 100644 --- a/modules/websocket/register_types.h +++ b/modules/websocket/register_types.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/websocket/remote_debugger_peer_websocket.cpp b/modules/websocket/remote_debugger_peer_websocket.cpp index 9a72e460e2..c9591cc564 100644 --- a/modules/websocket/remote_debugger_peer_websocket.cpp +++ b/modules/websocket/remote_debugger_peer_websocket.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/websocket/remote_debugger_peer_websocket.h b/modules/websocket/remote_debugger_peer_websocket.h index bb03e5e892..03c60fb480 100644 --- a/modules/websocket/remote_debugger_peer_websocket.h +++ b/modules/websocket/remote_debugger_peer_websocket.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/websocket/websocket_client.cpp b/modules/websocket/websocket_client.cpp index 8feaa9af5a..425013f811 100644 --- a/modules/websocket/websocket_client.cpp +++ b/modules/websocket/websocket_client.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -33,7 +33,6 @@ GDCINULL(WebSocketClient); WebSocketClient::WebSocketClient() { - verify_ssl = true; } WebSocketClient::~WebSocketClient() { diff --git a/modules/websocket/websocket_client.h b/modules/websocket/websocket_client.h index 2966dc480b..0225c9b3d3 100644 --- a/modules/websocket/websocket_client.h +++ b/modules/websocket/websocket_client.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -42,7 +42,7 @@ class WebSocketClient : public WebSocketMultiplayerPeer { protected: Ref<WebSocketPeer> _peer; - bool verify_ssl; + bool verify_ssl = true; Ref<X509Certificate> ssl_cert; static void _bind_methods(); diff --git a/modules/websocket/websocket_macros.h b/modules/websocket/websocket_macros.h index cf4545b435..d04909c97d 100644 --- a/modules/websocket/websocket_macros.h +++ b/modules/websocket/websocket_macros.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/websocket/websocket_multiplayer_peer.cpp b/modules/websocket/websocket_multiplayer_peer.cpp index fa2fe891a5..011cb86535 100644 --- a/modules/websocket/websocket_multiplayer_peer.cpp +++ b/modules/websocket/websocket_multiplayer_peer.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -33,15 +33,6 @@ #include "core/os/os.h" WebSocketMultiplayerPeer::WebSocketMultiplayerPeer() { - _is_multiplayer = false; - _peer_id = 0; - _target_peer = 0; - _refusing = false; - - _current_packet.source = 0; - _current_packet.destination = 0; - _current_packet.size = 0; - _current_packet.data = nullptr; } WebSocketMultiplayerPeer::~WebSocketMultiplayerPeer() { diff --git a/modules/websocket/websocket_multiplayer_peer.h b/modules/websocket/websocket_multiplayer_peer.h index 54daae23a6..48a6607d89 100644 --- a/modules/websocket/websocket_multiplayer_peer.h +++ b/modules/websocket/websocket_multiplayer_peer.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -55,20 +55,20 @@ protected: }; struct Packet { - int source; - int destination; - uint8_t *data; - uint32_t size; + int source = 0; + int destination = 0; + uint8_t *data = nullptr; + uint32_t size = 0; }; List<Packet> _incoming_packets; Map<int, Ref<WebSocketPeer>> _peer_map; Packet _current_packet; - bool _is_multiplayer; - int _target_peer; - int _peer_id; - int _refusing; + bool _is_multiplayer = false; + int _target_peer = 0; + int _peer_id = 0; + int _refusing = false; static void _bind_methods(); diff --git a/modules/websocket/websocket_peer.cpp b/modules/websocket/websocket_peer.cpp index 30a5972330..e77fdcfed2 100644 --- a/modules/websocket/websocket_peer.cpp +++ b/modules/websocket/websocket_peer.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/websocket/websocket_peer.h b/modules/websocket/websocket_peer.h index 729fdfd340..2ba83637f9 100644 --- a/modules/websocket/websocket_peer.h +++ b/modules/websocket/websocket_peer.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/websocket/websocket_server.cpp b/modules/websocket/websocket_server.cpp index b20b925dec..f57e8d959c 100644 --- a/modules/websocket/websocket_server.cpp +++ b/modules/websocket/websocket_server.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/websocket/websocket_server.h b/modules/websocket/websocket_server.h index 34ae52a1ee..3fbd5e3b95 100644 --- a/modules/websocket/websocket_server.h +++ b/modules/websocket/websocket_server.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ diff --git a/modules/websocket/wsl_client.cpp b/modules/websocket/wsl_client.cpp index a2b81438df..a075ae3982 100644 --- a/modules/websocket/wsl_client.cpp +++ b/modules/websocket/wsl_client.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -337,11 +337,6 @@ Error WSLClient::set_buffers(int p_in_buffer, int p_in_packets, int p_out_buffer } WSLClient::WSLClient() { - _in_buf_size = DEF_BUF_SHIFT; - _in_pkt_size = DEF_PKT_SHIFT; - _out_buf_size = DEF_BUF_SHIFT; - _out_pkt_size = DEF_PKT_SHIFT; - _peer.instance(); _tcp.instance(); disconnect_from_host(); diff --git a/modules/websocket/wsl_client.h b/modules/websocket/wsl_client.h index 0141ea93ea..e7c91ed333 100644 --- a/modules/websocket/wsl_client.h +++ b/modules/websocket/wsl_client.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -44,27 +44,27 @@ class WSLClient : public WebSocketClient { GDCIIMPL(WSLClient, WebSocketClient); private: - int _in_buf_size; - int _in_pkt_size; - int _out_buf_size; - int _out_pkt_size; + int _in_buf_size = DEF_BUF_SHIFT; + int _in_pkt_size = DEF_PKT_SHIFT; + int _out_buf_size = DEF_BUF_SHIFT; + int _out_pkt_size = DEF_PKT_SHIFT; Ref<WSLPeer> _peer; Ref<StreamPeerTCP> _tcp; Ref<StreamPeer> _connection; CharString _request; - int _requested; + int _requested = 0; uint8_t _resp_buf[WSL_MAX_HEADER_SIZE]; - int _resp_pos; + int _resp_pos = 0; String _response; String _key; String _host; Vector<String> _protocols; - bool _use_ssl; + bool _use_ssl = false; void _do_handshake(); bool _verify_headers(String &r_protocol); diff --git a/modules/websocket/wsl_peer.cpp b/modules/websocket/wsl_peer.cpp index bf1ba43f8a..dbbf86d0da 100644 --- a/modules/websocket/wsl_peer.cpp +++ b/modules/websocket/wsl_peer.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -329,10 +329,6 @@ void WSLPeer::invalidate() { } WSLPeer::WSLPeer() { - _data = nullptr; - _is_string = 0; - close_code = -1; - write_mode = WRITE_MODE_BINARY; } WSLPeer::~WSLPeer() { diff --git a/modules/websocket/wsl_peer.h b/modules/websocket/wsl_peer.h index 35ac18615a..5e6a7e8554 100644 --- a/modules/websocket/wsl_peer.h +++ b/modules/websocket/wsl_peer.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -48,29 +48,17 @@ class WSLPeer : public WebSocketPeer { public: struct PeerData { - bool polling; - bool destroy; - bool valid; - bool is_server; - bool closing; - void *obj; - void *peer; + bool polling = false; + bool destroy = false; + bool valid = false; + bool is_server = false; + bool closing = false; + void *obj = nullptr; + void *peer = nullptr; Ref<StreamPeer> conn; Ref<StreamPeerTCP> tcp; - int id; - wslay_event_context_ptr ctx; - - PeerData() { - polling = false; - destroy = false; - valid = false; - is_server = false; - id = 1; - ctx = nullptr; - obj = nullptr; - closing = false; - peer = nullptr; - } + int id = 1; + wslay_event_context_ptr ctx = nullptr; }; static String compute_key_response(String p_key); @@ -80,17 +68,17 @@ private: static bool _wsl_poll(struct PeerData *p_data); static void _wsl_destroy(struct PeerData **p_data); - struct PeerData *_data; - uint8_t _is_string; + struct PeerData *_data = nullptr; + uint8_t _is_string = 0; // Our packet info is just a boolean (is_string), using uint8_t for it. PacketBuffer<uint8_t> _in_buffer; Vector<uint8_t> _packet_buffer; - WriteMode write_mode; + WriteMode write_mode = WRITE_MODE_BINARY; public: - int close_code; + int close_code = -1; String close_reason; void poll(); // Used by client and server. diff --git a/modules/websocket/wsl_server.cpp b/modules/websocket/wsl_server.cpp index 9a05967e4e..437eb2061b 100644 --- a/modules/websocket/wsl_server.cpp +++ b/modules/websocket/wsl_server.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -34,15 +34,6 @@ #include "core/config/project_settings.h" #include "core/os/os.h" -WSLServer::PendingPeer::PendingPeer() { - use_ssl = false; - time = 0; - has_request = false; - response_sent = 0; - req_pos = 0; - memset(req_buf, 0, sizeof(req_buf)); -} - bool WSLServer::PendingPeer::_parse_request(const Vector<String> p_protocols) { Vector<String> psa = String((char *)req_buf).split("\r\n"); int len = psa.size(); @@ -310,10 +301,6 @@ Error WSLServer::set_buffers(int p_in_buffer, int p_in_packets, int p_out_buffer } WSLServer::WSLServer() { - _in_buf_size = DEF_BUF_SHIFT; - _in_pkt_size = DEF_PKT_SHIFT; - _out_buf_size = DEF_BUF_SHIFT; - _out_pkt_size = DEF_PKT_SHIFT; _server.instance(); } diff --git a/modules/websocket/wsl_server.h b/modules/websocket/wsl_server.h index f86de02797..75669e12ee 100644 --- a/modules/websocket/wsl_server.h +++ b/modules/websocket/wsl_server.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -53,26 +53,24 @@ private: public: Ref<StreamPeerTCP> tcp; Ref<StreamPeer> connection; - bool use_ssl; + bool use_ssl = false; - int time; - uint8_t req_buf[WSL_MAX_HEADER_SIZE]; - int req_pos; + int time = 0; + uint8_t req_buf[WSL_MAX_HEADER_SIZE] = {}; + int req_pos = 0; String key; String protocol; - bool has_request; + bool has_request = false; CharString response; - int response_sent; - - PendingPeer(); + int response_sent = 0; Error do_handshake(const Vector<String> p_protocols); }; - int _in_buf_size; - int _in_pkt_size; - int _out_buf_size; - int _out_pkt_size; + int _in_buf_size = DEF_BUF_SHIFT; + int _in_pkt_size = DEF_PKT_SHIFT; + int _out_buf_size = DEF_BUF_SHIFT; + int _out_pkt_size = DEF_PKT_SHIFT; List<Ref<PendingPeer>> _pending; Ref<TCP_Server> _server; diff --git a/modules/webxr/SCsub b/modules/webxr/SCsub new file mode 100644 index 0000000000..0a96af0811 --- /dev/null +++ b/modules/webxr/SCsub @@ -0,0 +1,11 @@ +#!/usr/bin/env python + +Import("env") +Import("env_modules") + +if env["platform"] == "javascript": + env.AddJSLibraries(["native/library_godot_webxr.js"]) + env.AddJSExterns(["native/webxr.externs.js"]) + +env_webxr = env_modules.Clone() +env_webxr.add_source_files(env.modules_sources, "*.cpp") diff --git a/modules/webxr/config.py b/modules/webxr/config.py new file mode 100644 index 0000000000..9efebed4e6 --- /dev/null +++ b/modules/webxr/config.py @@ -0,0 +1,14 @@ +def can_build(env, platform): + return True + + +def configure(env): + pass + + +def get_doc_classes(): + return ["WebXRInterface"] + + +def get_doc_path(): + return "doc_classes" diff --git a/modules/webxr/doc_classes/WebXRInterface.xml b/modules/webxr/doc_classes/WebXRInterface.xml new file mode 100644 index 0000000000..2407d44496 --- /dev/null +++ b/modules/webxr/doc_classes/WebXRInterface.xml @@ -0,0 +1,257 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="WebXRInterface" inherits="XRInterface" version="4.0"> + <brief_description> + AR/VR interface using WebXR. + </brief_description> + <description> + WebXR is an open standard that allows creating VR and AR applications that run in the web browser. + As such, this interface is only available when running in an HTML5 export. + WebXR supports a wide range of devices, from the very capable (like Valve Index, HTC Vive, Oculus Rift and Quest) down to the much less capable (like Google Cardboard, Oculus Go, GearVR, or plain smartphones). + Since WebXR is based on Javascript, it makes extensive use of callbacks, which means that [WebXRInterface] is forced to use signals, where other AR/VR interfaces would instead use functions that return a result immediately. This makes [WebXRInterface] quite a bit more complicated to intialize than other AR/VR interfaces. + Here's the minimum code required to start an immersive VR session: + [codeblock] + extends Node3D + + var webxr_interface + var vr_supported = false + + func _ready(): + # We assume this node has a button as a child. + # This button is for the user to consent to entering immersive VR mode. + $Button.connect("pressed", self, "_on_Button_pressed") + + webxr_interface = XRServer.find_interface("WebXR") + if webxr_interface: + # WebXR uses a lot of asynchronous callbacks, so we connect to various + # signals in order to receive them. + webxr_interface.connect("session_supported", self, "_webxr_session_supported") + webxr_interface.connect("session_started", self, "_webxr_session_started") + webxr_interface.connect("session_ended", self, "_webxr_session_ended") + webxr_interface.connect("session_failed", self, "_webxr_session_failed") + + # This returns immediately - our _webxr_session_supported() method + # (which we connected to the "session_supported" signal above) will + # be called sometime later to let us know if it's supported or not. + webxr_interface.is_session_supported("immersive-vr") + + func _webxr_session_supported(session_mode, supported): + if session_mode == 'immersive-vr': + vr_supported = supported + + func _on_Button_pressed(): + if not vr_supported: + OS.alert("Your browser doesn't support VR") + return + + # We want an immersive VR session, as opposed to AR ('immersive-ar') or a + # simple 3DoF viewer ('viewer'). + webxr_interface.session_mode = 'immersive-vr' + # 'bounded-floor' is room scale, 'local-floor' is a standing or sitting + # experience (it puts you 1.6m above the ground if you have 3DoF headset), + # whereas as 'local' puts you down at the XROrigin. + # This list means it'll first try to request 'bounded-floor', then + # fallback on 'local-floor' and ultimately 'local', if nothing else is + # supported. + webxr_interface.requested_reference_space_types = 'bounded-floor, local-floor, local' + # In order to use 'local-floor' or 'bounded-floor' we must also + # mark the features as required or optional. + webxr_interface.required_features = 'local-floor' + webxr_interface.optional_features = 'bounded-floor' + + # This will return false if we're unable to even request the session, + # however, it can still fail asynchronously later in the process, so we + # only know if it's really succeeded or failed when our + # _webxr_session_started() or _webxr_session_failed() methods are called. + if not webxr_interface.initialize(): + OS.alert("Failed to initialize") + return + + func _webxr_session_started(): + $Button.visible = false + # This tells Godot to start rendering to the headset. + get_viewport().xr = true + # This will be the reference space type you ultimately got, out of the + # types that you requested above. This is useful if you want the game to + # work a little differently in 'bounded-floor' versus 'local-floor'. + print ("Reference space type: " + webxr_interface.reference_space_type) + + func _webxr_session_ended(): + $Button.visible = true + # If the user exits immersive mode, then we tell Godot to render to the web + # page again. + get_viewport().xr = false + + func _webxr_session_failed(message): + OS.alert("Failed to initialize: " + message) + [/codeblock] + There are several ways to handle "controller" input: + - Using [XRController3D] nodes and their [signal XRController3D.button_pressed] and [signal XRController3D.button_released] signals. This is how controllers are typically handled in AR/VR apps in Godot, however, this will only work with advanced VR controllers like the Oculus Touch or Index controllers, for example. The buttons codes are defined by [url=https://immersive-web.github.io/webxr-gamepads-module/#xr-standard-gamepad-mapping]Section 3.3 of the WebXR Gamepads Module[/url]. + - Using [method Node._unhandled_input] and [InputEventJoypadButton] or [InputEventJoypadMotion]. This works the same as normal joypads, except the [member InputEvent.device] starts at 100, so the left controller is 100 and the right controller is 101, and the button codes are also defined by [url=https://immersive-web.github.io/webxr-gamepads-module/#xr-standard-gamepad-mapping]Section 3.3 of the WebXR Gamepads Module[/url]. + - Using the [signal select], [signal squeeze] and related signals. This method will work for both advanced VR controllers, and non-traditional "controllers" like a tap on the screen, a spoken voice command or a button press on the device itself. The [code]controller_id[/code] passed to these signals is the same id as used in [member XRController3D.controller_id]. + You can use one or all of these methods to allow your game or app to support a wider or narrower set of devices and input methods, or to allow more advanced interations with more advanced devices. + </description> + <tutorials> + <link title="How to make a VR game for WebXR with Godot">https://www.snopekgames.com/blog/2020/how-make-vr-game-webxr-godot</link> + </tutorials> + <methods> + <method name="get_controller" qualifiers="const"> + <return type="XRPositionalTracker"> + </return> + <argument index="0" name="controller_id" type="int"> + </argument> + <description> + Gets an [XRPositionalTracker] for the given [code]controller_id[/code]. + In the context of WebXR, a "controller" can be an advanced VR controller like the Oculus Touch or Index controllers, or even a tap on the screen, a spoken voice command or a button press on the device itself. When a non-traditional controller is used, interpret the position and orientation of the [XRPositionalTracker] as a ray pointing at the object the user wishes to interact with. + Use this method to get information about the controller that triggered one of these signals: + - [signal selectstart] + - [signal select] + - [signal selectend] + - [signal squeezestart] + - [signal squeeze] + - [signal squeezestart] + </description> + </method> + <method name="is_session_supported"> + <return type="void"> + </return> + <argument index="0" name="session_mode" type="String"> + </argument> + <description> + Checks if the given [code]session_mode[/code] is supported by the user's browser. + Possible values come from [url=https://developer.mozilla.org/en-US/docs/Web/API/XRSessionMode]WebXR's XRSessionMode[/url], including: [code]"immersive-vr"[/code], [code]"immersive-ar"[/code], and [code]"inline"[/code]. + This method returns nothing, instead it emits the [signal session_supported] signal with the result. + </description> + </method> + </methods> + <members> + <member name="bounds_geometry" type="PackedVector3Array" setter="" getter="get_bounds_geometry"> + The vertices of a polygon which defines the boundaries of the user's play area. + This will only be available if [member reference_space_type] is [code]"bounded-floor"[/code] and only on certain browsers and devices that support it. + The [signal reference_space_reset] signal may indicate when this changes. + </member> + <member name="optional_features" type="String" setter="set_optional_features" getter="get_optional_features"> + A comma-seperated list of optional features used by [method XRInterface.initialize] when setting up the WebXR session. + If a user's browser or device doesn't support one of the given features, initialization will continue, but you won't be able to use the requested feature. + This doesn't have any effect on the interface when already initialized. + Possible values come from [url=https://developer.mozilla.org/en-US/docs/Web/API/XRReferenceSpaceType]WebXR's XRReferenceSpaceType[/url]. If you want to use a particular reference space type, it must be listed in either [member required_features] or [member optional_features]. + </member> + <member name="reference_space_type" type="String" setter="" getter="get_reference_space_type"> + The reference space type (from the list of requested types set in the [member requested_reference_space_types] property), that was ultimately used by [method XRInterface.initialize] when setting up the WebXR session. + Possible values come from [url=https://developer.mozilla.org/en-US/docs/Web/API/XRReferenceSpaceType]WebXR's XRReferenceSpaceType[/url]. If you want to use a particular reference space type, it must be listed in either [member required_features] or [member optional_features]. + </member> + <member name="requested_reference_space_types" type="String" setter="set_requested_reference_space_types" getter="get_requested_reference_space_types"> + A comma-seperated list of reference space types used by [method XRInterface.initialize] when setting up the WebXR session. + The reference space types are requested in order, and the first on supported by the users device or browser will be used. The [member reference_space_type] property contains the reference space type that was ultimately used. + This doesn't have any effect on the interface when already initialized. + Possible values come from [url=https://developer.mozilla.org/en-US/docs/Web/API/XRReferenceSpaceType]WebXR's XRReferenceSpaceType[/url]. If you want to use a particular reference space type, it must be listed in either [member required_features] or [member optional_features]. + </member> + <member name="required_features" type="String" setter="set_required_features" getter="get_required_features"> + A comma-seperated list of required features used by [method XRInterface.initialize] when setting up the WebXR session. + If a user's browser or device doesn't support one of the given features, initialization will fail and [signal session_failed] will be emitted. + This doesn't have any effect on the interface when already initialized. + Possible values come from [url=https://developer.mozilla.org/en-US/docs/Web/API/XRReferenceSpaceType]WebXR's XRReferenceSpaceType[/url]. If you want to use a particular reference space type, it must be listed in either [member required_features] or [member optional_features]. + </member> + <member name="session_mode" type="String" setter="set_session_mode" getter="get_session_mode"> + The session mode used by [method XRInterface.initialize] when setting up the WebXR session. + This doesn't have any effect on the interface when already initialized. + Possible values come from [url=https://developer.mozilla.org/en-US/docs/Web/API/XRSessionMode]WebXR's XRSessionMode[/url], including: [code]"immersive-vr"[/code], [code]"immersive-ar"[/code], and [code]"inline"[/code]. + </member> + <member name="visibility_state" type="String" setter="" getter="get_visibility_state"> + Indicates if the WebXR session's imagery is visible to the user. + Possible values come from [url=https://developer.mozilla.org/en-US/docs/Web/API/XRVisibilityState]WebXR's XRVisibilityState[/url], including [code]"hidden"[/code], [code]"visible"[/code], and [code]"visible-blurred"[/code]. + </member> + </members> + <signals> + <signal name="reference_space_reset"> + <description> + Emitted to indicate that the reference space has been reset or reconfigured. + When (or whether) this is emitted depends on the user's browser or device, but may include when the user has changed the dimensions of their play space (which you may be able to access via [member bounds_geometry]) or pressed/held a button to recenter their position. + See [url=https://developer.mozilla.org/en-US/docs/Web/API/XRReferenceSpace/reset_event]WebXR's XRReferenceSpace reset event[/url] for more information. + </description> + </signal> + <signal name="select"> + <argument index="0" name="controller_id" type="int"> + </argument> + <description> + Emitted after one of the "controllers" has finished its "primary action". + Use [method get_controller] to get more information about the controller. + </description> + </signal> + <signal name="selectend"> + <argument index="0" name="controller_id" type="int"> + </argument> + <description> + Emitted when one of the "controllers" has finished its "primary action". + Use [method get_controller] to get more information about the controller. + </description> + </signal> + <signal name="selectstart"> + <argument index="0" name="controller_id" type="int"> + </argument> + <description> + Emitted when one of the "controllers" has started its "primary action". + Use [method get_controller] to get more information about the controller. + </description> + </signal> + <signal name="session_ended"> + <description> + Emitted when the user ends the WebXR session (which can be done using UI from the browser or device). + At this point, you should do [code]get_viewport().xr = false[/code] to instruct Godot to resume rendering to the screen. + </description> + </signal> + <signal name="session_failed"> + <argument index="0" name="message" type="String"> + </argument> + <description> + Emitted by [method XRInterface.initialize] if the session fails to start. + [code]message[/code] may optionally contain an error message from WebXR, or an empty string if no message is available. + </description> + </signal> + <signal name="session_started"> + <description> + Emitted by [method XRInterface.initialize] if the session is successfully started. + At this point, it's safe to do [code]get_viewport().xr = true[/code] to instruct Godot to start rendering to the AR/VR device. + </description> + </signal> + <signal name="session_supported"> + <argument index="0" name="session_mode" type="String"> + </argument> + <argument index="1" name="supported" type="bool"> + </argument> + <description> + Emitted by [method is_session_supported] to indicate if the given [code]session_mode[/code] is supported or not. + </description> + </signal> + <signal name="squeeze"> + <argument index="0" name="controller_id" type="int"> + </argument> + <description> + Emitted after one of the "controllers" has finished its "primary squeeze action". + Use [method get_controller] to get more information about the controller. + </description> + </signal> + <signal name="squeezeend"> + <argument index="0" name="controller_id" type="int"> + </argument> + <description> + Emitted when one of the "controllers" has finished its "primary squeeze action". + Use [method get_controller] to get more information about the controller. + </description> + </signal> + <signal name="squeezestart"> + <argument index="0" name="controller_id" type="int"> + </argument> + <description> + Emitted when one of the "controllers" has started its "primary squeeze action". + Use [method get_controller] to get more information about the controller. + </description> + </signal> + <signal name="visibility_state_changed"> + <description> + Emitted when [member visibility_state] has changed. + </description> + </signal> + </signals> + <constants> + </constants> +</class> diff --git a/modules/webxr/godot_webxr.h b/modules/webxr/godot_webxr.h new file mode 100644 index 0000000000..41a690f473 --- /dev/null +++ b/modules/webxr/godot_webxr.h @@ -0,0 +1,85 @@ +/*************************************************************************/ +/* godot_webxr.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 GODOT_WEBXR_H +#define GODOT_WEBXR_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "stddef.h" + +typedef void (*GodotWebXRSupportedCallback)(char *p_session_mode, int p_supported); +typedef void (*GodotWebXRStartedCallback)(char *p_reference_space_type); +typedef void (*GodotWebXREndedCallback)(); +typedef void (*GodotWebXRFailedCallback)(char *p_message); +typedef void (*GodotWebXRControllerCallback)(); +typedef void (*GodotWebXRInputEventCallback)(char *p_signal_name, int p_controller_id); +typedef void (*GodotWebXRSimpleEventCallback)(char *p_signal_name); + +extern int godot_webxr_is_supported(); +extern void godot_webxr_is_session_supported(const char *p_session_mode, GodotWebXRSupportedCallback p_callback); + +extern void godot_webxr_initialize( + const char *p_session_mode, + const char *p_required_features, + const char *p_optional_features, + const char *p_requested_reference_space_types, + GodotWebXRStartedCallback p_on_session_started, + GodotWebXREndedCallback p_on_session_ended, + GodotWebXRFailedCallback p_on_session_failed, + GodotWebXRControllerCallback p_on_controller_changed, + GodotWebXRInputEventCallback p_on_input_event, + GodotWebXRSimpleEventCallback p_on_simple_event); +extern void godot_webxr_uninitialize(); + +extern int godot_webxr_get_view_count(); +extern int *godot_webxr_get_render_targetsize(); +extern float *godot_webxr_get_transform_for_eye(int p_eye); +extern float *godot_webxr_get_projection_for_eye(int p_eye); +extern int godot_webxr_get_external_texture_for_eye(int p_eye); +extern void godot_webxr_commit_for_eye(int p_eye); + +extern void godot_webxr_sample_controller_data(); +extern int godot_webxr_get_controller_count(); +extern int godot_webxr_is_controller_connected(int p_controller); +extern float *godot_webxr_get_controller_transform(int p_controller); +extern int *godot_webxr_get_controller_buttons(int p_controller); +extern int *godot_webxr_get_controller_axes(int p_controller); + +extern char *godot_webxr_get_visibility_state(); +extern int *godot_webxr_get_bounds_geometry(); + +#ifdef __cplusplus +} +#endif + +#endif /* GODOT_WEBXR_H */ diff --git a/modules/webxr/native/library_godot_webxr.js b/modules/webxr/native/library_godot_webxr.js new file mode 100644 index 0000000000..8e9ef8a73c --- /dev/null +++ b/modules/webxr/native/library_godot_webxr.js @@ -0,0 +1,672 @@ +/*************************************************************************/ +/* library_godot_webxr.js */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +const GodotWebXR = { + $GodotWebXR__deps: ['$Browser', '$GL', '$GodotRuntime'], + $GodotWebXR: { + gl: null, + + texture_ids: [null, null], + textures: [null, null], + + session: null, + space: null, + frame: null, + pose: null, + + // Monkey-patch the requestAnimationFrame() used by Emscripten for the main + // loop, so that we can swap it out for XRSession.requestAnimationFrame() + // when an XR session is started. + orig_requestAnimationFrame: null, + requestAnimationFrame: (callback) => { + if (GodotWebXR.session && GodotWebXR.space) { + const onFrame = function (time, frame) { + GodotWebXR.frame = frame; + GodotWebXR.pose = frame.getViewerPose(GodotWebXR.space); + callback(time); + GodotWebXR.frame = null; + GodotWebXR.pose = null; + }; + GodotWebXR.session.requestAnimationFrame(onFrame); + } else { + GodotWebXR.orig_requestAnimationFrame(callback); + } + }, + monkeyPatchRequestAnimationFrame: (enable) => { + if (GodotWebXR.orig_requestAnimationFrame === null) { + GodotWebXR.orig_requestAnimationFrame = Browser.requestAnimationFrame; + } + Browser.requestAnimationFrame = enable + ? GodotWebXR.requestAnimationFrame : GodotWebXR.orig_requestAnimationFrame; + }, + pauseResumeMainLoop: () => { + // Once both GodotWebXR.session and GodotWebXR.space are set or + // unset, our monkey-patched requestAnimationFrame() should be + // enabled or disabled. When using the WebXR API Emulator, this + // gets picked up automatically, however, in the Oculus Browser + // on the Quest, we need to pause and resume the main loop. + Browser.pauseAsyncCallbacks(); + Browser.mainLoop.pause(); + window.setTimeout(function () { + Browser.resumeAsyncCallbacks(); + Browser.mainLoop.resume(); + }, 0); + }, + + // Some custom WebGL code for blitting our eye textures to the + // framebuffer we get from WebXR. + shaderProgram: null, + programInfo: null, + buffer: null, + // Vertex shader source. + vsSource: ` + const vec2 scale = vec2(0.5, 0.5); + attribute vec4 aVertexPosition; + + varying highp vec2 vTextureCoord; + + void main () { + gl_Position = aVertexPosition; + vTextureCoord = aVertexPosition.xy * scale + scale; + } + `, + // Fragment shader source. + fsSource: ` + varying highp vec2 vTextureCoord; + + uniform sampler2D uSampler; + + void main() { + gl_FragColor = texture2D(uSampler, vTextureCoord); + } + `, + + initShaderProgram: (gl, vsSource, fsSource) => { + const vertexShader = GodotWebXR.loadShader(gl, gl.VERTEX_SHADER, vsSource); + const fragmentShader = GodotWebXR.loadShader(gl, gl.FRAGMENT_SHADER, fsSource); + + const shaderProgram = gl.createProgram(); + gl.attachShader(shaderProgram, vertexShader); + gl.attachShader(shaderProgram, fragmentShader); + gl.linkProgram(shaderProgram); + + if (!gl.getProgramParameter(shaderProgram, gl.LINK_STATUS)) { + GodotRuntime.error(`Unable to initialize the shader program: ${gl.getProgramInfoLog(shaderProgram)}`); + return null; + } + + return shaderProgram; + }, + loadShader: (gl, type, source) => { + const shader = gl.createShader(type); + gl.shaderSource(shader, source); + gl.compileShader(shader); + + if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) { + GodotRuntime.error(`An error occurred compiling the shader: ${gl.getShaderInfoLog(shader)}`); + gl.deleteShader(shader); + return null; + } + + return shader; + }, + initBuffer: (gl) => { + const positionBuffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, positionBuffer); + const positions = [ + -1.0, -1.0, + 1.0, -1.0, + -1.0, 1.0, + 1.0, 1.0, + ]; + gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(positions), gl.STATIC_DRAW); + return positionBuffer; + }, + blitTexture: (gl, texture) => { + if (GodotWebXR.shaderProgram === null) { + GodotWebXR.shaderProgram = GodotWebXR.initShaderProgram(gl, GodotWebXR.vsSource, GodotWebXR.fsSource); + GodotWebXR.programInfo = { + program: GodotWebXR.shaderProgram, + attribLocations: { + vertexPosition: gl.getAttribLocation(GodotWebXR.shaderProgram, 'aVertexPosition'), + }, + uniformLocations: { + uSampler: gl.getUniformLocation(GodotWebXR.shaderProgram, 'uSampler'), + }, + }; + GodotWebXR.buffer = GodotWebXR.initBuffer(gl); + } + + const orig_program = gl.getParameter(gl.CURRENT_PROGRAM); + gl.useProgram(GodotWebXR.shaderProgram); + + gl.bindBuffer(gl.ARRAY_BUFFER, GodotWebXR.buffer); + gl.vertexAttribPointer(GodotWebXR.programInfo.attribLocations.vertexPosition, 2, gl.FLOAT, false, 0, 0); + gl.enableVertexAttribArray(GodotWebXR.programInfo.attribLocations.vertexPosition); + + gl.activeTexture(gl.TEXTURE0); + gl.bindTexture(gl.TEXTURE_2D, texture); + gl.uniform1i(GodotWebXR.programInfo.uniformLocations.uSampler, 0); + + gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4); + + // Restore state. + gl.bindTexture(gl.TEXTURE_2D, null); + gl.disableVertexAttribArray(GodotWebXR.programInfo.attribLocations.vertexPosition); + gl.bindBuffer(gl.ARRAY_BUFFER, null); + gl.useProgram(orig_program); + }, + + // Holds the controllers list between function calls. + controllers: [], + + // Updates controllers array, where the left hand (or sole tracker) is + // the first element, and the right hand is the second element, and any + // others placed at the 3rd position and up. + sampleControllers: () => { + if (!GodotWebXR.session || !GodotWebXR.frame) { + return; + } + + let other_index = 2; + const controllers = []; + GodotWebXR.session.inputSources.forEach((input_source) => { + if (input_source.targetRayMode === 'tracked-pointer') { + if (input_source.handedness === 'right') { + controllers[1] = input_source; + } else if (input_source.handedness === 'left' || !controllers[0]) { + controllers[0] = input_source; + } + } else { + controllers[other_index++] = input_source; + } + }); + GodotWebXR.controllers = controllers; + }, + + getControllerId: (input_source) => GodotWebXR.controllers.indexOf(input_source), + }, + + godot_webxr_is_supported__proxy: 'sync', + godot_webxr_is_supported__sig: 'i', + godot_webxr_is_supported: function () { + return !!navigator.xr; + }, + + godot_webxr_is_session_supported__proxy: 'sync', + godot_webxr_is_session_supported__sig: 'vii', + godot_webxr_is_session_supported: function (p_session_mode, p_callback) { + const session_mode = GodotRuntime.parseString(p_session_mode); + const cb = GodotRuntime.get_func(p_callback); + if (navigator.xr) { + navigator.xr.isSessionSupported(session_mode).then(function (supported) { + const c_str = GodotRuntime.allocString(session_mode); + cb(c_str, supported ? 1 : 0); + GodotRuntime.free(c_str); + }); + } else { + const c_str = GodotRuntime.allocString(session_mode); + cb(c_str, 0); + GodotRuntime.free(c_str); + } + }, + + godot_webxr_initialize__deps: ['emscripten_webgl_get_current_context'], + godot_webxr_initialize__proxy: 'sync', + godot_webxr_initialize__sig: 'viiiiiiiiii', + godot_webxr_initialize: function (p_session_mode, p_required_features, p_optional_features, p_requested_reference_spaces, p_on_session_started, p_on_session_ended, p_on_session_failed, p_on_controller_changed, p_on_input_event, p_on_simple_event) { + GodotWebXR.monkeyPatchRequestAnimationFrame(true); + + const session_mode = GodotRuntime.parseString(p_session_mode); + const required_features = GodotRuntime.parseString(p_required_features).split(',').map((s) => s.trim()).filter((s) => s !== ''); + const optional_features = GodotRuntime.parseString(p_optional_features).split(',').map((s) => s.trim()).filter((s) => s !== ''); + const requested_reference_space_types = GodotRuntime.parseString(p_requested_reference_spaces).split(',').map((s) => s.trim()); + const onstarted = GodotRuntime.get_func(p_on_session_started); + const onended = GodotRuntime.get_func(p_on_session_ended); + const onfailed = GodotRuntime.get_func(p_on_session_failed); + const oncontroller = GodotRuntime.get_func(p_on_controller_changed); + const oninputevent = GodotRuntime.get_func(p_on_input_event); + const onsimpleevent = GodotRuntime.get_func(p_on_simple_event); + + const session_init = {}; + if (required_features.length > 0) { + session_init['requiredFeatures'] = required_features; + } + if (optional_features.length > 0) { + session_init['optionalFeatures'] = optional_features; + } + + navigator.xr.requestSession(session_mode, session_init).then(function (session) { + GodotWebXR.session = session; + + session.addEventListener('end', function (evt) { + onended(); + }); + + session.addEventListener('inputsourceschange', function (evt) { + let controller_changed = false; + [evt.added, evt.removed].forEach((lst) => { + lst.forEach((input_source) => { + if (input_source.targetRayMode === 'tracked-pointer') { + controller_changed = true; + } + }); + }); + if (controller_changed) { + oncontroller(); + } + }); + + ['selectstart', 'select', 'selectend', 'squeezestart', 'squeeze', 'squeezeend'].forEach((input_event) => { + session.addEventListener(input_event, function (evt) { + const c_str = GodotRuntime.allocString(input_event); + oninputevent(c_str, GodotWebXR.getControllerId(evt.inputSource)); + GodotRuntime.free(c_str); + }); + }); + + session.addEventListener('visibilitychange', function (evt) { + const c_str = GodotRuntime.allocString('visibility_state_changed'); + onsimpleevent(c_str); + GodotRuntime.free(c_str); + }); + + const gl_context_handle = _emscripten_webgl_get_current_context(); // eslint-disable-line no-undef + const gl = GL.getContext(gl_context_handle).GLctx; + GodotWebXR.gl = gl; + + gl.makeXRCompatible().then(function () { + session.updateRenderState({ + baseLayer: new XRWebGLLayer(session, gl), + }); + + function onReferenceSpaceSuccess(reference_space, reference_space_type) { + GodotWebXR.space = reference_space; + + // Using reference_space.addEventListener() crashes when + // using the polyfill with the WebXR Emulator extension, + // so we set the event property instead. + reference_space.onreset = function (evt) { + const c_str = GodotRuntime.allocString('reference_space_reset'); + onsimpleevent(c_str); + GodotRuntime.free(c_str); + }; + + // Now that both GodotWebXR.session and GodotWebXR.space are + // set, we need to pause and resume the main loop for the XR + // main loop to kick in. + GodotWebXR.pauseResumeMainLoop(); + + // Call in setTimeout() so that errors in the onstarted() + // callback don't bubble up here and cause Godot to try the + // next reference space. + window.setTimeout(function () { + const c_str = GodotRuntime.allocString(reference_space_type); + onstarted(c_str); + GodotRuntime.free(c_str); + }, 0); + } + + function requestReferenceSpace() { + const reference_space_type = requested_reference_space_types.shift(); + session.requestReferenceSpace(reference_space_type) + .then((refSpace) => { + onReferenceSpaceSuccess(refSpace, reference_space_type); + }) + .catch(() => { + if (requested_reference_space_types.length === 0) { + const c_str = GodotRuntime.allocString('Unable to get any of the requested reference space types'); + onfailed(c_str); + GodotRuntime.free(c_str); + } else { + requestReferenceSpace(); + } + }); + } + + requestReferenceSpace(); + }).catch(function (error) { + const c_str = GodotRuntime.allocString(`Unable to make WebGL context compatible with WebXR: ${error}`); + onfailed(c_str); + GodotRuntime.free(c_str); + }); + }).catch(function (error) { + const c_str = GodotRuntime.allocString(`Unable to start session: ${error}`); + onfailed(c_str); + GodotRuntime.free(c_str); + }); + }, + + godot_webxr_uninitialize__proxy: 'sync', + godot_webxr_uninitialize__sig: 'v', + godot_webxr_uninitialize: function () { + if (GodotWebXR.session) { + GodotWebXR.session.end() + // Prevent exception when session has already ended. + .catch((e) => { }); + } + + // Clean-up the textures we allocated for each view. + const gl = GodotWebXR.gl; + for (let i = 0; i < GodotWebXR.textures.length; i++) { + const texture = GodotWebXR.textures[i]; + if (texture !== null) { + gl.deleteTexture(texture); + } + GodotWebXR.textures[i] = null; + + const texture_id = GodotWebXR.texture_ids[i]; + if (texture_id !== null) { + GL.textures[texture_id] = null; + } + GodotWebXR.texture_ids[i] = null; + } + + GodotWebXR.session = null; + GodotWebXR.space = null; + GodotWebXR.frame = null; + GodotWebXR.pose = null; + + // Disable the monkey-patched window.requestAnimationFrame() and + // pause/restart the main loop to activate it on all platforms. + GodotWebXR.monkeyPatchRequestAnimationFrame(false); + GodotWebXR.pauseResumeMainLoop(); + }, + + godot_webxr_get_view_count__proxy: 'sync', + godot_webxr_get_view_count__sig: 'i', + godot_webxr_get_view_count: function () { + if (!GodotWebXR.session || !GodotWebXR.pose) { + return 0; + } + return GodotWebXR.pose.views.length; + }, + + godot_webxr_get_render_targetsize__proxy: 'sync', + godot_webxr_get_render_targetsize__sig: 'i', + godot_webxr_get_render_targetsize: function () { + if (!GodotWebXR.session || !GodotWebXR.pose) { + return 0; + } + + const glLayer = GodotWebXR.session.renderState.baseLayer; + const view = GodotWebXR.pose.views[0]; + const viewport = glLayer.getViewport(view); + + const buf = GodotRuntime.malloc(2 * 4); + GodotRuntime.setHeapValue(buf + 0, viewport.width, 'i32'); + GodotRuntime.setHeapValue(buf + 4, viewport.height, 'i32'); + return buf; + }, + + godot_webxr_get_transform_for_eye__proxy: 'sync', + godot_webxr_get_transform_for_eye__sig: 'ii', + godot_webxr_get_transform_for_eye: function (p_eye) { + if (!GodotWebXR.session || !GodotWebXR.pose) { + return 0; + } + + const views = GodotWebXR.pose.views; + let matrix; + if (p_eye === 0) { + matrix = GodotWebXR.pose.transform.matrix; + } else { + matrix = views[p_eye - 1].transform.matrix; + } + const buf = GodotRuntime.malloc(16 * 4); + for (let i = 0; i < 16; i++) { + GodotRuntime.setHeapValue(buf + (i * 4), matrix[i], 'float'); + } + return buf; + }, + + godot_webxr_get_projection_for_eye__proxy: 'sync', + godot_webxr_get_projection_for_eye__sig: 'ii', + godot_webxr_get_projection_for_eye: function (p_eye) { + if (!GodotWebXR.session || !GodotWebXR.pose) { + return 0; + } + + const view_index = (p_eye === 2 /* ARVRInterface::EYE_RIGHT */) ? 1 : 0; + const matrix = GodotWebXR.pose.views[view_index].projectionMatrix; + const buf = GodotRuntime.malloc(16 * 4); + for (let i = 0; i < 16; i++) { + GodotRuntime.setHeapValue(buf + (i * 4), matrix[i], 'float'); + } + return buf; + }, + + godot_webxr_get_external_texture_for_eye__proxy: 'sync', + godot_webxr_get_external_texture_for_eye__sig: 'ii', + godot_webxr_get_external_texture_for_eye: function (p_eye) { + if (!GodotWebXR.session) { + return 0; + } + + const view_index = (p_eye === 2 /* ARVRInterface::EYE_RIGHT */) ? 1 : 0; + if (GodotWebXR.texture_ids[view_index]) { + return GodotWebXR.texture_ids[view_index]; + } + + // Check pose separately and after returning the cached texture id, + // because we won't get a pose in some cases if we lose tracking, and + // we don't want to return 0 just because tracking was lost. + if (!GodotWebXR.pose) { + return 0; + } + + const glLayer = GodotWebXR.session.renderState.baseLayer; + const view = GodotWebXR.pose.views[view_index]; + const viewport = glLayer.getViewport(view); + const gl = GodotWebXR.gl; + + const texture = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_2D, texture); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, viewport.width, viewport.height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); + + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); + gl.bindTexture(gl.TEXTURE_2D, null); + + const texture_id = GL.getNewId(GL.textures); + GL.textures[texture_id] = texture; + GodotWebXR.textures[view_index] = texture; + GodotWebXR.texture_ids[view_index] = texture_id; + return texture_id; + }, + + godot_webxr_commit_for_eye__proxy: 'sync', + godot_webxr_commit_for_eye__sig: 'vi', + godot_webxr_commit_for_eye: function (p_eye) { + if (!GodotWebXR.session || !GodotWebXR.pose) { + return; + } + + const view_index = (p_eye === 2 /* ARVRInterface::EYE_RIGHT */) ? 1 : 0; + const glLayer = GodotWebXR.session.renderState.baseLayer; + const view = GodotWebXR.pose.views[view_index]; + const viewport = glLayer.getViewport(view); + const gl = GodotWebXR.gl; + + const orig_framebuffer = gl.getParameter(gl.FRAMEBUFFER_BINDING); + const orig_viewport = gl.getParameter(gl.VIEWPORT); + + // Bind to WebXR's framebuffer. + gl.bindFramebuffer(gl.FRAMEBUFFER, glLayer.framebuffer); + gl.viewport(viewport.x, viewport.y, viewport.width, viewport.height); + + GodotWebXR.blitTexture(gl, GodotWebXR.textures[view_index]); + + // Restore state. + gl.bindFramebuffer(gl.FRAMEBUFFER, orig_framebuffer); + gl.viewport(orig_viewport[0], orig_viewport[1], orig_viewport[2], orig_viewport[3]); + }, + + godot_webxr_sample_controller_data__proxy: 'sync', + godot_webxr_sample_controller_data__sig: 'v', + godot_webxr_sample_controller_data: function () { + GodotWebXR.sampleControllers(); + }, + + godot_webxr_get_controller_count__proxy: 'sync', + godot_webxr_get_controller_count__sig: 'i', + godot_webxr_get_controller_count: function () { + if (!GodotWebXR.session || !GodotWebXR.frame) { + return 0; + } + return GodotWebXR.controllers.length; + }, + + godot_webxr_is_controller_connected__proxy: 'sync', + godot_webxr_is_controller_connected__sig: 'ii', + godot_webxr_is_controller_connected: function (p_controller) { + if (!GodotWebXR.session || !GodotWebXR.frame) { + return false; + } + return !!GodotWebXR.controllers[p_controller]; + }, + + godot_webxr_get_controller_transform__proxy: 'sync', + godot_webxr_get_controller_transform__sig: 'ii', + godot_webxr_get_controller_transform: function (p_controller) { + if (!GodotWebXR.session || !GodotWebXR.frame) { + return 0; + } + + const controller = GodotWebXR.controllers[p_controller]; + if (!controller) { + return 0; + } + + const frame = GodotWebXR.frame; + const space = GodotWebXR.space; + + const pose = frame.getPose(controller.targetRaySpace, space); + if (!pose) { + // This can mean that the controller lost tracking. + return 0; + } + const matrix = pose.transform.matrix; + + const buf = GodotRuntime.malloc(16 * 4); + for (let i = 0; i < 16; i++) { + GodotRuntime.setHeapValue(buf + (i * 4), matrix[i], 'float'); + } + return buf; + }, + + godot_webxr_get_controller_buttons__proxy: 'sync', + godot_webxr_get_controller_buttons__sig: 'ii', + godot_webxr_get_controller_buttons: function (p_controller) { + if (GodotWebXR.controllers.length === 0) { + return 0; + } + + const controller = GodotWebXR.controllers[p_controller]; + if (!controller || !controller.gamepad) { + return 0; + } + + const button_count = controller.gamepad.buttons.length; + + const buf = GodotRuntime.malloc((button_count + 1) * 4); + GodotRuntime.setHeapValue(buf, button_count, 'i32'); + for (let i = 0; i < button_count; i++) { + GodotRuntime.setHeapValue(buf + 4 + (i * 4), controller.gamepad.buttons[i].value, 'float'); + } + return buf; + }, + + godot_webxr_get_controller_axes__proxy: 'sync', + godot_webxr_get_controller_axes__sig: 'ii', + godot_webxr_get_controller_axes: function (p_controller) { + if (GodotWebXR.controllers.length === 0) { + return 0; + } + + const controller = GodotWebXR.controllers[p_controller]; + if (!controller || !controller.gamepad) { + return 0; + } + + const axes_count = controller.gamepad.axes.length; + + const buf = GodotRuntime.malloc((axes_count + 1) * 4); + GodotRuntime.setHeapValue(buf, axes_count, 'i32'); + for (let i = 0; i < axes_count; i++) { + let value = controller.gamepad.axes[i]; + if (i === 1 || i === 3) { + // Invert the Y-axis on thumbsticks and trackpads, in order to + // match OpenXR and other XR platform SDKs. + value *= -1.0; + } + GodotRuntime.setHeapValue(buf + 4 + (i * 4), value, 'float'); + } + return buf; + }, + + godot_webxr_get_visibility_state__proxy: 'sync', + godot_webxr_get_visibility_state__sig: 'i', + godot_webxr_get_visibility_state: function () { + if (!GodotWebXR.session || !GodotWebXR.session.visibilityState) { + return 0; + } + + return GodotRuntime.allocString(GodotWebXR.session.visibilityState); + }, + + godot_webxr_get_bounds_geometry__proxy: 'sync', + godot_webxr_get_bounds_geometry__sig: 'i', + godot_webxr_get_bounds_geometry: function () { + if (!GodotWebXR.space || !GodotWebXR.space.boundsGeometry) { + return 0; + } + + const point_count = GodotWebXR.space.boundsGeometry.length; + if (point_count === 0) { + return 0; + } + + const buf = GodotRuntime.malloc(((point_count * 3) + 1) * 4); + GodotRuntime.setHeapValue(buf, point_count, 'i32'); + for (let i = 0; i < point_count; i++) { + const point = GodotWebXR.space.boundsGeometry[i]; + GodotRuntime.setHeapValue(buf + ((i * 3) + 1) * 4, point.x, 'float'); + GodotRuntime.setHeapValue(buf + ((i * 3) + 2) * 4, point.y, 'float'); + GodotRuntime.setHeapValue(buf + ((i * 3) + 3) * 4, point.z, 'float'); + } + + return buf; + }, +}; + +autoAddDeps(GodotWebXR, '$GodotWebXR'); +mergeInto(LibraryManager.library, GodotWebXR); diff --git a/modules/webxr/native/webxr.externs.js b/modules/webxr/native/webxr.externs.js new file mode 100644 index 0000000000..03dc05bc83 --- /dev/null +++ b/modules/webxr/native/webxr.externs.js @@ -0,0 +1,499 @@ +/** + * @type {XR} + */ +Navigator.prototype.xr; + +/** + * @constructor + */ +function XRSessionInit() {}; + +/** + * @type {Array<string>} + */ +XRSessionInit.prototype.requiredFeatures; + +/** + * @type {Array<string>} + */ +XRSessionInit.prototype.optionalFeatures; + +/** + * @constructor + */ +function XR() {} + +/** + * @type {?function (Event)} + */ +XR.prototype.ondevicechanged; + +/** + * @param {string} mode + * + * @return {!Promise<boolean>} + */ +XR.prototype.isSessionSupported = function(mode) {} + +/** + * @param {string} mode + * @param {XRSessionInit} options + * + * @return {!Promise<XRSession>} + */ +XR.prototype.requestSession = function(mode, options) {} + +/** + * @constructor + */ +function XRSession() {} + +/** + * @type {XRRenderState} + */ +XRSession.prototype.renderState; + +/** + * @type {Array<XRInputSource>} + */ +XRSession.prototype.inputSources; + +/** + * @type {string} + */ +XRSession.prototype.visibilityState; + +/** + * @type {?function (Event)} + */ +XRSession.prototype.onend; + +/** + * @type {?function (XRInputSourcesChangeEvent)} + */ +XRSession.prototype.oninputsourceschange; + +/** + * @type {?function (XRInputSourceEvent)} + */ +XRSession.prototype.onselectstart; + +/** + * @type {?function (XRInputSourceEvent)} + */ +XRSession.prototype.onselect; + +/** + * @type {?function (XRInputSourceEvent)} + */ +XRSession.prototype.onselectend; + +/** + * @type {?function (XRInputSourceEvent)} + */ +XRSession.prototype.onsqueezestart; + +/** + * @type {?function (XRInputSourceEvent)} + */ +XRSession.prototype.onsqueeze; + +/** + * @type {?function (XRInputSourceEvent)} + */ +XRSession.prototype.onsqueezeend; + +/** + * @type {?function (Event)} + */ +XRSession.prototype.onvisibilitychange; + +/** + * @param {XRRenderStateInit} state + * @return {void} + */ +XRSession.prototype.updateRenderState = function (state) {}; + +/** + * @param {XRFrameRequestCallback} callback + * @return {number} + */ +XRSession.prototype.requestAnimationFrame = function (callback) {}; + +/** + * @param {number} handle + * @return {void} + */ +XRSession.prototype.cancelAnimationFrame = function (handle) {}; + +/** + * @return {Promise<void>} + */ +XRSession.prototype.end = function () {}; + +/** + * @param {string} referenceSpaceType + * @return {Promise<XRReferenceSpace>} + */ +XRSession.prototype.requestReferenceSpace = function (referenceSpaceType) {}; + +/** + * @typedef {function(number, XRFrame): undefined} + */ +var XRFrameRequestCallback; + +/** + * @constructor + */ +function XRRenderStateInit() {} + +/** + * @type {number} + */ +XRRenderStateInit.prototype.depthNear; + +/** + * @type {number} + */ +XRRenderStateInit.prototype.depthFar; + +/** + * @type {number} + */ +XRRenderStateInit.prototype.inlineVerticalFieldOfView; + +/** + * @type {?XRWebGLLayer} + */ +XRRenderStateInit.prototype.baseLayer; + +/** + * @constructor + */ +function XRRenderState() {}; + +/** + * @type {number} + */ +XRRenderState.prototype.depthNear; + +/** + * @type {number} + */ +XRRenderState.prototype.depthFar; + +/** + * @type {?number} + */ +XRRenderState.prototype.inlineVerticalFieldOfView; + +/** + * @type {?XRWebGLLayer} + */ +XRRenderState.prototype.baseLayer; + +/** + * @constructor + */ +function XRFrame() {} + +/** + * @type {XRSession} + */ +XRFrame.prototype.session; + +/** + * @param {XRReferenceSpace} referenceSpace + * @return {?XRViewerPose} + */ +XRFrame.prototype.getViewerPose = function (referenceSpace) {}; + +/** + * + * @param {XRSpace} space + * @param {XRSpace} baseSpace + * @return {XRPose} + */ +XRFrame.prototype.getPose = function (space, baseSpace) {}; + +/** + * @constructor + */ +function XRReferenceSpace() {}; + +/** + * @type {Array<DOMPointReadOnly>} + */ +XRReferenceSpace.prototype.boundsGeometry; + +/** + * @param {XRRigidTransform} originOffset + * @return {XRReferenceSpace} + */ +XRReferenceSpace.prototype.getOffsetReferenceSpace = function(originOffset) {}; + +/** + * @type {?function (Event)} + */ +XRReferenceSpace.prototype.onreset; + +/** + * @constructor + */ +function XRRigidTransform() {}; + +/** + * @type {DOMPointReadOnly} + */ +XRRigidTransform.prototype.position; + +/** + * @type {DOMPointReadOnly} + */ +XRRigidTransform.prototype.orientation; + +/** + * @type {Float32Array} + */ +XRRigidTransform.prototype.matrix; + +/** + * @type {XRRigidTransform} + */ +XRRigidTransform.prototype.inverse; + +/** + * @constructor + */ +function XRView() {} + +/** + * @type {string} + */ +XRView.prototype.eye; + +/** + * @type {Float32Array} + */ +XRView.prototype.projectionMatrix; + +/** + * @type {XRRigidTransform} + */ +XRView.prototype.transform; + +/** + * @constructor + */ +function XRViewerPose() {} + +/** + * @type {Array<XRView>} + */ +XRViewerPose.prototype.views; + +/** + * @constructor + */ +function XRViewport() {} + +/** + * @type {number} + */ +XRViewport.prototype.x; + +/** + * @type {number} + */ +XRViewport.prototype.y; + +/** + * @type {number} + */ +XRViewport.prototype.width; + +/** + * @type {number} + */ +XRViewport.prototype.height; + +/** + * @constructor + */ +function XRWebGLLayerInit() {}; + +/** + * @type {boolean} + */ +XRWebGLLayerInit.prototype.antialias; + +/** + * @type {boolean} + */ +XRWebGLLayerInit.prototype.depth; + +/** + * @type {boolean} + */ +XRWebGLLayerInit.prototype.stencil; + +/** + * @type {boolean} + */ +XRWebGLLayerInit.prototype.alpha; + +/** + * @type {boolean} + */ +XRWebGLLayerInit.prototype.ignoreDepthValues; + +/** + * @type {boolean} + */ +XRWebGLLayerInit.prototype.ignoreDepthValues; + +/** + * @type {number} + */ +XRWebGLLayerInit.prototype.framebufferScaleFactor; + +/** + * @constructor + * + * @param {XRSession} session + * @param {WebGLRenderContext|WebGL2RenderingContext} ctx + * @param {?XRWebGLLayerInit} options + */ +function XRWebGLLayer(session, ctx, options) {} + +/** + * @type {boolean} + */ +XRWebGLLayer.prototype.antialias; + +/** + * @type {boolean} + */ +XRWebGLLayer.prototype.ignoreDepthValues; + +/** + * @type {number} + */ +XRWebGLLayer.prototype.framebufferWidth; + +/** + * @type {number} + */ +XRWebGLLayer.prototype.framebufferHeight; + +/** + * @type {WebGLFramebuffer} + */ +XRWebGLLayer.prototype.framebuffer; + +/** + * @param {XRView} view + * @return {?XRViewport} + */ +XRWebGLLayer.prototype.getViewport = function(view) {}; + +/** + * @param {XRSession} session + * @return {number} + */ +XRWebGLLayer.prototype.getNativeFramebufferScaleFactor = function (session) {}; + +/** + * @constructor + */ +function WebGLRenderingContextBase() {}; + +/** + * @return {Promise<void>} + */ +WebGLRenderingContextBase.prototype.makeXRCompatible = function () {}; + +/** + * @constructor + */ +function XRInputSourcesChangeEvent() {}; + +/** + * @type {Array<XRInputSource>} + */ +XRInputSourcesChangeEvent.prototype.added; + +/** + * @type {Array<XRInputSource>} + */ +XRInputSourcesChangeEvent.prototype.removed; + +/** + * @constructor + */ +function XRInputSourceEvent() {}; + +/** + * @type {XRFrame} + */ +XRInputSourceEvent.prototype.frame; + +/** + * @type {XRInputSource} + */ +XRInputSourceEvent.prototype.inputSource; + +/** + * @constructor + */ +function XRInputSource() {}; + +/** + * @type {Gamepad} + */ +XRInputSource.prototype.gamepad; + +/** + * @type {XRSpace} + */ +XRInputSource.prototype.gripSpace; + +/** + * @type {string} + */ +XRInputSource.prototype.handedness; + +/** + * @type {string} + */ +XRInputSource.prototype.profiles; + +/** + * @type {string} + */ +XRInputSource.prototype.targetRayMode; + +/** + * @type {XRSpace} + */ +XRInputSource.prototype.targetRaySpace; + +/** + * @constructor + */ +function XRSpace() {}; + +/** + * @constructor + */ +function XRPose() {}; + +/** + * @type {XRRigidTransform} + */ +XRPose.prototype.transform; + +/** + * @type {boolean} + */ +XRPose.prototype.emulatedPosition; diff --git a/modules/arkit/arkit_module.cpp b/modules/webxr/register_types.cpp index 87ee3b87a5..8baf7e05b8 100644 --- a/modules/arkit/arkit_module.cpp +++ b/modules/webxr/register_types.cpp @@ -1,12 +1,12 @@ /*************************************************************************/ -/* arkit_module.cpp */ +/* register_types.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -28,18 +28,20 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "arkit_module.h" +#include "register_types.h" -#include "arkit_interface.h" +#include "webxr_interface.h" +#include "webxr_interface_js.h" -void register_arkit_types() { - // does it make sense to register the class? +void register_webxr_types() { + ClassDB::register_virtual_class<WebXRInterface>(); - Ref<ARKitInterface> arkit_interface; - arkit_interface.instance(); - XRServer::get_singleton()->add_interface(arkit_interface); +#ifdef JAVASCRIPT_ENABLED + Ref<WebXRInterfaceJS> webxr; + webxr.instance(); + XRServer::get_singleton()->add_interface(webxr); +#endif } -void unregister_arkit_types() { - // should clean itself up nicely :) +void unregister_webxr_types() { } diff --git a/modules/arkit/arkit_module.h b/modules/webxr/register_types.h index 8aa8175ed5..f0c5a4bd79 100644 --- a/modules/arkit/arkit_module.h +++ b/modules/webxr/register_types.h @@ -1,12 +1,12 @@ /*************************************************************************/ -/* arkit_module.h */ +/* register_types.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -28,10 +28,10 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef ARKIT_REGISTER_TYPES_H -#define ARKIT_REGISTER_TYPES_H +#ifndef WEBXR_REGISTER_TYPES_H +#define WEBXR_REGISTER_TYPES_H -void register_arkit_types(); -void unregister_arkit_types(); +void register_webxr_types(); +void unregister_webxr_types(); -#endif // ARKIT_REGISTER_TYPES_H +#endif // WEBXR_REGISTER_TYPES_H diff --git a/modules/webxr/webxr_interface.cpp b/modules/webxr/webxr_interface.cpp new file mode 100644 index 0000000000..3e8e75bf0e --- /dev/null +++ b/modules/webxr/webxr_interface.cpp @@ -0,0 +1,71 @@ +/*************************************************************************/ +/* webxr_interface.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 "webxr_interface.h" +#include <stdlib.h> + +void WebXRInterface::_bind_methods() { + ClassDB::bind_method(D_METHOD("is_session_supported", "session_mode"), &WebXRInterface::is_session_supported); + ClassDB::bind_method(D_METHOD("set_session_mode", "session_mode"), &WebXRInterface::set_session_mode); + ClassDB::bind_method(D_METHOD("get_session_mode"), &WebXRInterface::get_session_mode); + ClassDB::bind_method(D_METHOD("set_required_features", "required_features"), &WebXRInterface::set_required_features); + ClassDB::bind_method(D_METHOD("get_required_features"), &WebXRInterface::get_required_features); + ClassDB::bind_method(D_METHOD("set_optional_features", "optional_features"), &WebXRInterface::set_optional_features); + ClassDB::bind_method(D_METHOD("get_optional_features"), &WebXRInterface::get_optional_features); + ClassDB::bind_method(D_METHOD("get_reference_space_type"), &WebXRInterface::get_reference_space_type); + ClassDB::bind_method(D_METHOD("set_requested_reference_space_types", "requested_reference_space_types"), &WebXRInterface::set_requested_reference_space_types); + ClassDB::bind_method(D_METHOD("get_requested_reference_space_types"), &WebXRInterface::get_requested_reference_space_types); + ClassDB::bind_method(D_METHOD("get_controller", "controller_id"), &WebXRInterface::get_controller); + ClassDB::bind_method(D_METHOD("get_visibility_state"), &WebXRInterface::get_visibility_state); + ClassDB::bind_method(D_METHOD("get_bounds_geometry"), &WebXRInterface::get_bounds_geometry); + + ADD_PROPERTY(PropertyInfo(Variant::STRING, "session_mode", PROPERTY_HINT_NONE), "set_session_mode", "get_session_mode"); + ADD_PROPERTY(PropertyInfo(Variant::STRING, "required_features", PROPERTY_HINT_NONE), "set_required_features", "get_required_features"); + ADD_PROPERTY(PropertyInfo(Variant::STRING, "optional_features", PROPERTY_HINT_NONE), "set_optional_features", "get_optional_features"); + ADD_PROPERTY(PropertyInfo(Variant::STRING, "requested_reference_space_types", PROPERTY_HINT_NONE), "set_requested_reference_space_types", "get_requested_reference_space_types"); + ADD_PROPERTY(PropertyInfo(Variant::STRING, "reference_space_type", PROPERTY_HINT_NONE), "", "get_reference_space_type"); + ADD_PROPERTY(PropertyInfo(Variant::STRING, "visibility_state", PROPERTY_HINT_NONE), "", "get_visibility_state"); + ADD_PROPERTY(PropertyInfo(Variant::PACKED_VECTOR3_ARRAY, "bounds_geometry", PROPERTY_HINT_NONE), "", "get_bounds_geometry"); + + ADD_SIGNAL(MethodInfo("session_supported", PropertyInfo(Variant::STRING, "session_mode"), PropertyInfo(Variant::BOOL, "supported"))); + ADD_SIGNAL(MethodInfo("session_started")); + ADD_SIGNAL(MethodInfo("session_ended")); + ADD_SIGNAL(MethodInfo("session_failed", PropertyInfo(Variant::STRING, "message"))); + + ADD_SIGNAL(MethodInfo("selectstart", PropertyInfo(Variant::INT, "controller_id"))); + ADD_SIGNAL(MethodInfo("select", PropertyInfo(Variant::INT, "controller_id"))); + ADD_SIGNAL(MethodInfo("selectend", PropertyInfo(Variant::INT, "controller_id"))); + ADD_SIGNAL(MethodInfo("squeezestart", PropertyInfo(Variant::INT, "controller_id"))); + ADD_SIGNAL(MethodInfo("squeeze", PropertyInfo(Variant::INT, "controller_id"))); + ADD_SIGNAL(MethodInfo("squeezeend", PropertyInfo(Variant::INT, "controller_id"))); + + ADD_SIGNAL(MethodInfo("visibility_state_changed")); + ADD_SIGNAL(MethodInfo("reference_space_reset")); +} diff --git a/modules/gamecenter/game_center.h b/modules/webxr/webxr_interface.h index 76fd295460..c5b2dc8d73 100644 --- a/modules/gamecenter/game_center.h +++ b/modules/webxr/webxr_interface.h @@ -1,12 +1,12 @@ /*************************************************************************/ -/* game_center.h */ +/* webxr_interface.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -28,44 +28,38 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef GAME_CENTER_H -#define GAME_CENTER_H +#ifndef WEBXR_INTERFACE_H +#define WEBXR_INTERFACE_H -#include "core/object/class_db.h" +#include "servers/xr/xr_interface.h" +#include "servers/xr/xr_positional_tracker.h" -class GameCenter : public Object { - GDCLASS(GameCenter, Object); +/** + @author David Snopek <david.snopek@snopekgames.com> - static GameCenter *instance; - static void _bind_methods(); - - List<Variant> pending_events; + The WebXR interface is a VR/AR interface that can be used on the web. +*/ - bool authenticated; +class WebXRInterface : public XRInterface { + GDCLASS(WebXRInterface, XRInterface); - void return_connect_error(const char *p_error_description); +protected: + static void _bind_methods(); public: - Error authenticate(); - bool is_authenticated(); - - Error post_score(Dictionary p_score); - Error award_achievement(Dictionary p_params); - void reset_achievements(); - void request_achievements(); - void request_achievement_descriptions(); - Error show_game_center(Dictionary p_params); - Error request_identity_verification_signature(); - - void game_center_closed(); - - int get_pending_event_count(); - Variant pop_pending_event(); - - static GameCenter *get_singleton(); - - GameCenter(); - ~GameCenter(); + virtual void is_session_supported(const String &p_session_mode) = 0; + virtual void set_session_mode(String p_session_mode) = 0; + virtual String get_session_mode() const = 0; + virtual void set_required_features(String p_required_features) = 0; + virtual String get_required_features() const = 0; + virtual void set_optional_features(String p_optional_features) = 0; + virtual String get_optional_features() const = 0; + virtual void set_requested_reference_space_types(String p_requested_reference_space_types) = 0; + virtual String get_requested_reference_space_types() const = 0; + virtual String get_reference_space_type() const = 0; + virtual XRPositionalTracker *get_controller(int p_controller_id) const = 0; + virtual String get_visibility_state() const = 0; + virtual PackedVector3Array get_bounds_geometry() const = 0; }; -#endif +#endif // WEBXR_INTERFACE_H diff --git a/modules/webxr/webxr_interface_js.cpp b/modules/webxr/webxr_interface_js.cpp new file mode 100644 index 0000000000..74789fc98e --- /dev/null +++ b/modules/webxr/webxr_interface_js.cpp @@ -0,0 +1,460 @@ +/*************************************************************************/ +/* webxr_interface_js.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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. */ +/*************************************************************************/ + +#ifdef JAVASCRIPT_ENABLED + +#include "webxr_interface_js.h" +#include "core/input/input.h" +#include "core/os/os.h" +#include "emscripten.h" +#include "godot_webxr.h" +#include <stdlib.h> + +void _emwebxr_on_session_supported(char *p_session_mode, int p_supported) { + XRServer *xr_server = XRServer::get_singleton(); + ERR_FAIL_NULL(xr_server); + + Ref<XRInterface> interface = xr_server->find_interface("WebXR"); + ERR_FAIL_COND(interface.is_null()); + + String session_mode = String(p_session_mode); + interface->emit_signal("session_supported", session_mode, p_supported ? true : false); +} + +void _emwebxr_on_session_started(char *p_reference_space_type) { + XRServer *xr_server = XRServer::get_singleton(); + ERR_FAIL_NULL(xr_server); + + Ref<XRInterface> interface = xr_server->find_interface("WebXR"); + ERR_FAIL_COND(interface.is_null()); + + String reference_space_type = String(p_reference_space_type); + ((WebXRInterfaceJS *)interface.ptr())->_set_reference_space_type(reference_space_type); + interface->emit_signal("session_started"); +} + +void _emwebxr_on_session_ended() { + XRServer *xr_server = XRServer::get_singleton(); + ERR_FAIL_NULL(xr_server); + + Ref<XRInterface> interface = xr_server->find_interface("WebXR"); + ERR_FAIL_COND(interface.is_null()); + + interface->uninitialize(); + interface->emit_signal("session_ended"); +} + +void _emwebxr_on_session_failed(char *p_message) { + XRServer *xr_server = XRServer::get_singleton(); + ERR_FAIL_NULL(xr_server); + + Ref<XRInterface> interface = xr_server->find_interface("WebXR"); + ERR_FAIL_COND(interface.is_null()); + + interface->uninitialize(); + + String message = String(p_message); + interface->emit_signal("session_failed", message); +} + +void _emwebxr_on_controller_changed() { + XRServer *xr_server = XRServer::get_singleton(); + ERR_FAIL_NULL(xr_server); + + Ref<XRInterface> interface = xr_server->find_interface("WebXR"); + ERR_FAIL_COND(interface.is_null()); + + ((WebXRInterfaceJS *)interface.ptr())->_on_controller_changed(); +} + +extern "C" EMSCRIPTEN_KEEPALIVE void _emwebxr_on_input_event(char *p_signal_name, int p_input_source) { + XRServer *xr_server = XRServer::get_singleton(); + ERR_FAIL_NULL(xr_server); + + Ref<XRInterface> interface = xr_server->find_interface("WebXR"); + ERR_FAIL_COND(interface.is_null()); + + StringName signal_name = StringName(p_signal_name); + interface->emit_signal(signal_name, p_input_source + 1); +} + +extern "C" EMSCRIPTEN_KEEPALIVE void _emwebxr_on_simple_event(char *p_signal_name) { + XRServer *xr_server = XRServer::get_singleton(); + ERR_FAIL_NULL(xr_server); + + Ref<XRInterface> interface = xr_server->find_interface("WebXR"); + ERR_FAIL_COND(interface.is_null()); + + StringName signal_name = StringName(p_signal_name); + interface->emit_signal(signal_name); +} + +void WebXRInterfaceJS::is_session_supported(const String &p_session_mode) { + godot_webxr_is_session_supported(p_session_mode.utf8().get_data(), &_emwebxr_on_session_supported); +} + +void WebXRInterfaceJS::set_session_mode(String p_session_mode) { + session_mode = p_session_mode; +} + +String WebXRInterfaceJS::get_session_mode() const { + return session_mode; +} + +void WebXRInterfaceJS::set_required_features(String p_required_features) { + required_features = p_required_features; +} + +String WebXRInterfaceJS::get_required_features() const { + return required_features; +} + +void WebXRInterfaceJS::set_optional_features(String p_optional_features) { + optional_features = p_optional_features; +} + +String WebXRInterfaceJS::get_optional_features() const { + return optional_features; +} + +void WebXRInterfaceJS::set_requested_reference_space_types(String p_requested_reference_space_types) { + requested_reference_space_types = p_requested_reference_space_types; +} + +String WebXRInterfaceJS::get_requested_reference_space_types() const { + return requested_reference_space_types; +} + +void WebXRInterfaceJS::_set_reference_space_type(String p_reference_space_type) { + reference_space_type = p_reference_space_type; +} + +String WebXRInterfaceJS::get_reference_space_type() const { + return reference_space_type; +} + +XRPositionalTracker *WebXRInterfaceJS::get_controller(int p_controller_id) const { + XRServer *xr_server = XRServer::get_singleton(); + ERR_FAIL_NULL_V(xr_server, nullptr); + + return xr_server->find_by_type_and_id(XRServer::TRACKER_CONTROLLER, p_controller_id); +} + +String WebXRInterfaceJS::get_visibility_state() const { + char *c_str = godot_webxr_get_visibility_state(); + if (c_str) { + String visibility_state = String(c_str); + free(c_str); + + return visibility_state; + } + return String(); +} + +PackedVector3Array WebXRInterfaceJS::get_bounds_geometry() const { + PackedVector3Array ret; + + int *js_bounds = godot_webxr_get_bounds_geometry(); + if (js_bounds) { + ret.resize(js_bounds[0]); + for (int i = 0; i < js_bounds[0]; i++) { + float *js_vector3 = ((float *)js_bounds) + (i * 3) + 1; + ret.set(i, Vector3(js_vector3[0], js_vector3[1], js_vector3[2])); + } + free(js_bounds); + } + + return ret; +} + +StringName WebXRInterfaceJS::get_name() const { + return "WebXR"; +}; + +int WebXRInterfaceJS::get_capabilities() const { + return XRInterface::XR_STEREO | XRInterface::XR_MONO; +}; + +bool WebXRInterfaceJS::is_stereo() { + return godot_webxr_get_view_count() == 2; +}; + +bool WebXRInterfaceJS::is_initialized() const { + return (initialized); +}; + +bool WebXRInterfaceJS::initialize() { + XRServer *xr_server = XRServer::get_singleton(); + ERR_FAIL_NULL_V(xr_server, false); + + if (!initialized) { + if (!godot_webxr_is_supported()) { + return false; + } + + if (requested_reference_space_types.size() == 0) { + return false; + } + + // make this our primary interface + xr_server->set_primary_interface(this); + + // Clear render_targetsize to make sure it gets reset to the new size. + // Clearing in uninitialize() doesn't work because a frame can still be + // rendered after it's called, which will fill render_targetsize again. + render_targetsize.width = 0; + render_targetsize.height = 0; + + initialized = true; + + godot_webxr_initialize( + session_mode.utf8().get_data(), + required_features.utf8().get_data(), + optional_features.utf8().get_data(), + requested_reference_space_types.utf8().get_data(), + &_emwebxr_on_session_started, + &_emwebxr_on_session_ended, + &_emwebxr_on_session_failed, + &_emwebxr_on_controller_changed, + &_emwebxr_on_input_event, + &_emwebxr_on_simple_event); + }; + + return true; +}; + +void WebXRInterfaceJS::uninitialize() { + if (initialized) { + XRServer *xr_server = XRServer::get_singleton(); + if (xr_server != NULL) { + // no longer our primary interface + xr_server->clear_primary_interface_if(this); + } + + godot_webxr_uninitialize(); + + reference_space_type = ""; + initialized = false; + }; +}; + +Transform WebXRInterfaceJS::_js_matrix_to_transform(float *p_js_matrix) { + Transform transform; + + transform.basis.elements[0].x = p_js_matrix[0]; + transform.basis.elements[1].x = p_js_matrix[1]; + transform.basis.elements[2].x = p_js_matrix[2]; + transform.basis.elements[0].y = p_js_matrix[4]; + transform.basis.elements[1].y = p_js_matrix[5]; + transform.basis.elements[2].y = p_js_matrix[6]; + transform.basis.elements[0].z = p_js_matrix[8]; + transform.basis.elements[1].z = p_js_matrix[9]; + transform.basis.elements[2].z = p_js_matrix[10]; + transform.origin.x = p_js_matrix[12]; + transform.origin.y = p_js_matrix[13]; + transform.origin.z = p_js_matrix[14]; + + return transform; +} + +Size2 WebXRInterfaceJS::get_render_targetsize() { + if (render_targetsize.width != 0 && render_targetsize.height != 0) { + return render_targetsize; + } + + int *js_size = godot_webxr_get_render_targetsize(); + if (!initialized || js_size == nullptr) { + // As a temporary default (until WebXR is fully initialized), use half the window size. + Size2 temp = DisplayServer::get_singleton()->window_get_size(); + temp.width /= 2.0; + return temp; + } + + render_targetsize.width = js_size[0]; + render_targetsize.height = js_size[1]; + + free(js_size); + + return render_targetsize; +}; + +Transform WebXRInterfaceJS::get_transform_for_eye(XRInterface::Eyes p_eye, const Transform &p_cam_transform) { + Transform transform_for_eye; + + XRServer *xr_server = XRServer::get_singleton(); + ERR_FAIL_NULL_V(xr_server, transform_for_eye); + + float *js_matrix = godot_webxr_get_transform_for_eye(p_eye); + if (!initialized || js_matrix == nullptr) { + transform_for_eye = p_cam_transform; + return transform_for_eye; + } + + transform_for_eye = _js_matrix_to_transform(js_matrix); + free(js_matrix); + + return p_cam_transform * xr_server->get_reference_frame() * transform_for_eye; +}; + +CameraMatrix WebXRInterfaceJS::get_projection_for_eye(XRInterface::Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far) { + CameraMatrix eye; + + float *js_matrix = godot_webxr_get_projection_for_eye(p_eye); + if (!initialized || js_matrix == nullptr) { + return eye; + } + + int k = 0; + for (int i = 0; i < 4; i++) { + for (int j = 0; j < 4; j++) { + eye.matrix[i][j] = js_matrix[k++]; + } + } + + free(js_matrix); + + // Copied from godot_oculus_mobile's ovr_mobile_session.cpp + eye.matrix[2][2] = -(p_z_far + p_z_near) / (p_z_far - p_z_near); + eye.matrix[3][2] = -(2.0f * p_z_far * p_z_near) / (p_z_far - p_z_near); + + return eye; +} + +unsigned int WebXRInterfaceJS::get_external_texture_for_eye(XRInterface::Eyes p_eye) { + if (!initialized) { + return 0; + } + return godot_webxr_get_external_texture_for_eye(p_eye); +} + +void WebXRInterfaceJS::commit_for_eye(XRInterface::Eyes p_eye, RID p_render_target, const Rect2 &p_screen_rect) { + if (!initialized) { + return; + } + godot_webxr_commit_for_eye(p_eye); +}; + +void WebXRInterfaceJS::process() { + if (initialized) { + godot_webxr_sample_controller_data(); + + int controller_count = godot_webxr_get_controller_count(); + if (controller_count == 0) { + return; + } + + for (int i = 0; i < controller_count; i++) { + _update_tracker(i); + } + }; +}; + +void WebXRInterfaceJS::_update_tracker(int p_controller_id) { + XRServer *xr_server = XRServer::get_singleton(); + ERR_FAIL_NULL(xr_server); + + XRPositionalTracker *tracker = xr_server->find_by_type_and_id(XRServer::TRACKER_CONTROLLER, p_controller_id + 1); + if (godot_webxr_is_controller_connected(p_controller_id)) { + if (tracker == nullptr) { + tracker = memnew(XRPositionalTracker); + tracker->set_tracker_type(XRServer::TRACKER_CONTROLLER); + // Controller id's 0 and 1 are always the left and right hands. + if (p_controller_id < 2) { + tracker->set_tracker_name(p_controller_id == 0 ? "Left" : "Right"); + tracker->set_tracker_hand(p_controller_id == 0 ? XRPositionalTracker::TRACKER_HAND_LEFT : XRPositionalTracker::TRACKER_HAND_RIGHT); + } + // Use the ids we're giving to our "virtual" gamepads. + tracker->set_joy_id(p_controller_id + 100); + xr_server->add_tracker(tracker); + } + + Input *input = Input::get_singleton(); + + float *tracker_matrix = godot_webxr_get_controller_transform(p_controller_id); + if (tracker_matrix) { + Transform transform = _js_matrix_to_transform(tracker_matrix); + tracker->set_position(transform.origin); + tracker->set_orientation(transform.basis); + free(tracker_matrix); + } + + int *buttons = godot_webxr_get_controller_buttons(p_controller_id); + if (buttons) { + for (int i = 0; i < buttons[0]; i++) { + input->joy_button(p_controller_id + 100, i, *((float *)buttons + (i + 1))); + } + free(buttons); + } + + int *axes = godot_webxr_get_controller_axes(p_controller_id); + if (axes) { + for (int i = 0; i < axes[0]; i++) { + Input::JoyAxis joy_axis; + joy_axis.min = -1; + joy_axis.value = *((float *)axes + (i + 1)); + input->joy_axis(p_controller_id + 100, i, joy_axis); + } + free(axes); + } + } else if (tracker) { + xr_server->remove_tracker(tracker); + } +} + +void WebXRInterfaceJS::_on_controller_changed() { + // Register "virtual" gamepads with Godot for the ones we get from WebXR. + godot_webxr_sample_controller_data(); + for (int i = 0; i < 2; i++) { + bool controller_connected = godot_webxr_is_controller_connected(i); + if (controllers_state[i] != controller_connected) { + Input::get_singleton()->joy_connection_changed(i + 100, controller_connected, i == 0 ? "Left" : "Right", ""); + controllers_state[i] = controller_connected; + } + } +} + +void WebXRInterfaceJS::notification(int p_what) { + // Nothing to do here. +} + +WebXRInterfaceJS::WebXRInterfaceJS() { + initialized = false; + session_mode = "inline"; + requested_reference_space_types = "local"; +}; + +WebXRInterfaceJS::~WebXRInterfaceJS() { + // and make sure we cleanup if we haven't already + if (initialized) { + uninitialize(); + }; +}; + +#endif // JAVASCRIPT_ENABLED diff --git a/modules/arkit/arkit_interface.h b/modules/webxr/webxr_interface_js.h index 29e09411ff..49299b252f 100644 --- a/modules/arkit/arkit_interface.h +++ b/modules/webxr/webxr_interface_js.h @@ -1,12 +1,12 @@ /*************************************************************************/ -/* arkit_interface.h */ +/* webxr_interface_js.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -28,85 +28,52 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef ARKIT_INTERFACE_H -#define ARKIT_INTERFACE_H +#ifndef WEBXR_INTERFACE_JS_H +#define WEBXR_INTERFACE_JS_H -#include "servers/camera/camera_feed.h" -#include "servers/xr/xr_interface.h" -#include "servers/xr/xr_positional_tracker.h" +#ifdef JAVASCRIPT_ENABLED + +#include "webxr_interface.h" /** - @author Bastiaan Olij <mux213@gmail.com> + @author David Snopek <david.snopek@snopekgames.com> - ARKit interface between iPhone and Godot + The WebXR interface is a VR/AR interface that can be used on the web. */ -// forward declaration for some needed objects -class ARKitShader; - -#ifdef __OBJC__ - -typedef ARAnchor GodotARAnchor; - -#else - -typedef void GodotARAnchor; -#endif - -class ARKitInterface : public XRInterface { - GDCLASS(ARKitInterface, XRInterface); +class WebXRInterfaceJS : public WebXRInterface { + GDCLASS(WebXRInterfaceJS, WebXRInterface); 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; - size_t image_width[2]; - size_t image_height[2]; - Vector<uint8_t> img_data[2]; - - struct anchor_map { - XRPositionalTracker *tracker; - unsigned char uuid[16]; - }; - - ///@TODO should use memory map object from Godot? - unsigned int num_anchors; - unsigned int max_anchors; - anchor_map *anchors; - XRPositionalTracker *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(); + String session_mode; + String required_features; + String optional_features; + String requested_reference_space_types; + String reference_space_type; - bool get_anchor_detection_is_enabled() const override; - void set_anchor_detection_is_enabled(bool p_enable) override; - virtual int get_camera_feed_id() override; + bool controllers_state[2]; + Size2 render_targetsize; - bool get_light_estimation_is_enabled() const; - void set_light_estimation_is_enabled(bool p_enable); + Transform _js_matrix_to_transform(float *p_js_matrix); + void _update_tracker(int p_controller_id); - 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); - - virtual void notification(int p_what) override; +public: + virtual void is_session_supported(const String &p_session_mode) override; + virtual void set_session_mode(String p_session_mode) override; + virtual String get_session_mode() const override; + virtual void set_required_features(String p_required_features) override; + virtual String get_required_features() const override; + virtual void set_optional_features(String p_optional_features) override; + virtual String get_optional_features() const override; + virtual void set_requested_reference_space_types(String p_requested_reference_space_types) override; + virtual String get_requested_reference_space_types() const override; + void _set_reference_space_type(String p_reference_space_type); + virtual String get_reference_space_type() const override; + virtual XRPositionalTracker *get_controller(int p_controller_id) const override; + virtual String get_visibility_state() const override; + virtual PackedVector3Array get_bounds_geometry() const override; virtual StringName get_name() const override; virtual int get_capabilities() const override; @@ -119,16 +86,18 @@ public: virtual bool is_stereo() override; virtual Transform get_transform_for_eye(XRInterface::Eyes p_eye, const Transform &p_cam_transform) override; virtual CameraMatrix get_projection_for_eye(XRInterface::Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far) override; + virtual unsigned int get_external_texture_for_eye(XRInterface::Eyes p_eye) override; virtual void commit_for_eye(XRInterface::Eyes p_eye, RID p_render_target, const Rect2 &p_screen_rect) override; virtual void process() override; + virtual void notification(int p_what) override; - // 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(GodotARAnchor *p_anchor); - void _remove_anchor(GodotARAnchor *p_anchor); + void _on_controller_changed(); - ARKitInterface(); - ~ARKitInterface(); + WebXRInterfaceJS(); + ~WebXRInterfaceJS(); }; -#endif /* !ARKIT_INTERFACE_H */ +#endif // JAVASCRIPT_ENABLED + +#endif // WEBXR_INTERFACE_JS_H diff --git a/modules/xatlas_unwrap/register_types.cpp b/modules/xatlas_unwrap/register_types.cpp index 224038d604..fb4df10904 100644 --- a/modules/xatlas_unwrap/register_types.cpp +++ b/modules/xatlas_unwrap/register_types.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -154,6 +154,7 @@ bool xatlas_mesh_lightmap_unwrap_callback(float p_texel_size, const float *p_ver float h = *r_size_hint_y; if (w == 0 || h == 0) { + xatlas::Destroy(atlas); return false; //could not bake because there is no area } @@ -163,8 +164,8 @@ bool xatlas_mesh_lightmap_unwrap_callback(float p_texel_size, const float *p_ver *r_uvs = (float *)malloc(sizeof(float) * output.vertexCount * 2); *r_indices = (int *)malloc(sizeof(int) * output.indexCount); - float max_x = 0; - float max_y = 0; + float max_x = 0.0; + float max_y = 0.0; for (uint32_t i = 0; i < output.vertexCount; i++) { (*r_vertices)[i] = output.vertexArray[i].xref; (*r_uvs)[i * 2 + 0] = output.vertexArray[i].uv[0] / w; diff --git a/modules/xatlas_unwrap/register_types.h b/modules/xatlas_unwrap/register_types.h index fe924bab96..2ad729f172 100644 --- a/modules/xatlas_unwrap/register_types.h +++ b/modules/xatlas_unwrap/register_types.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ |