summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/SCsub1
-rw-r--r--modules/astcenc/SCsub1
-rw-r--r--modules/basis_universal/SCsub1
-rw-r--r--modules/betsy/SCsub4
-rw-r--r--modules/bmp/SCsub1
-rw-r--r--modules/camera/SCsub11
-rw-r--r--modules/camera/buffer_decoder.cpp212
-rw-r--r--modules/camera/buffer_decoder.h116
-rw-r--r--modules/camera/camera_feed_linux.cpp363
-rw-r--r--modules/camera/camera_feed_linux.h78
-rw-r--r--modules/camera/camera_linux.cpp169
-rw-r--r--modules/camera/camera_linux.h60
-rw-r--r--modules/camera/config.py2
-rw-r--r--modules/camera/register_types.cpp6
-rw-r--r--modules/csg/SCsub1
-rw-r--r--modules/csg/register_types.cpp4
-rw-r--r--modules/cvtt/SCsub1
-rw-r--r--modules/dds/SCsub1
-rw-r--r--modules/enet/SCsub1
-rw-r--r--modules/etcpak/SCsub1
-rw-r--r--modules/fbx/SCsub1
-rw-r--r--modules/freetype/SCsub1
-rw-r--r--modules/gdscript/SCsub1
-rw-r--r--modules/gdscript/editor/script_templates/SCsub1
-rw-r--r--modules/gdscript/gdscript_compiler.cpp7
-rw-r--r--modules/glslang/SCsub1
-rw-r--r--modules/gltf/SCsub1
-rw-r--r--modules/gltf/extensions/SCsub1
-rw-r--r--modules/godot_physics_2d/SCsub3
-rw-r--r--modules/godot_physics_2d/godot_body_pair_2d.cpp12
-rw-r--r--modules/godot_physics_2d/godot_step_2d.cpp4
-rw-r--r--modules/godot_physics_3d/SCsub3
-rw-r--r--modules/godot_physics_3d/godot_body_pair_3d.cpp12
-rw-r--r--modules/godot_physics_3d/godot_step_3d.cpp4
-rw-r--r--modules/godot_physics_3d/joints/SCsub3
-rw-r--r--modules/gridmap/SCsub1
-rw-r--r--modules/hdr/SCsub1
-rw-r--r--modules/interactive_music/SCsub1
-rw-r--r--modules/jpg/SCsub1
-rw-r--r--modules/jsonrpc/SCsub1
-rw-r--r--modules/ktx/SCsub1
-rw-r--r--modules/lightmapper_rd/SCsub1
-rw-r--r--modules/lightmapper_rd/lm_compute.glsl2
-rw-r--r--modules/mbedtls/SCsub1
-rw-r--r--modules/meshoptimizer/SCsub1
-rw-r--r--modules/minimp3/SCsub1
-rw-r--r--modules/mobile_vr/SCsub1
-rw-r--r--modules/mono/SCsub1
-rw-r--r--modules/mono/editor/script_templates/SCsub1
-rw-r--r--modules/mono/mono_gd/gd_mono.cpp2
-rw-r--r--modules/msdfgen/SCsub1
-rw-r--r--modules/multiplayer/SCsub1
-rw-r--r--modules/multiplayer/editor/editor_network_profiler.cpp13
-rw-r--r--modules/navigation/SCsub1
-rw-r--r--modules/noise/SCsub1
-rw-r--r--modules/ogg/SCsub1
-rw-r--r--modules/openxr/SCsub1
-rw-r--r--modules/openxr/action_map/SCsub1
-rw-r--r--modules/openxr/editor/SCsub1
-rw-r--r--modules/openxr/editor/openxr_select_action_dialog.cpp3
-rw-r--r--modules/openxr/editor/openxr_select_interaction_profile_dialog.cpp32
-rw-r--r--modules/openxr/editor/openxr_select_interaction_profile_dialog.h1
-rw-r--r--modules/openxr/extensions/SCsub1
-rw-r--r--modules/openxr/scene/SCsub1
-rw-r--r--modules/raycast/SCsub1
-rw-r--r--modules/regex/SCsub1
-rw-r--r--modules/squish/SCsub1
-rw-r--r--modules/svg/SCsub1
-rw-r--r--modules/text_server_adv/SCsub1
-rw-r--r--modules/text_server_adv/gdextension_build/SConstruct2
-rw-r--r--modules/text_server_fb/SCsub1
-rw-r--r--modules/text_server_fb/gdextension_build/SConstruct2
-rw-r--r--modules/tga/SCsub1
-rw-r--r--modules/theora/SCsub1
-rw-r--r--modules/tinyexr/SCsub1
-rw-r--r--modules/upnp/SCsub1
-rw-r--r--modules/vhacd/SCsub1
-rw-r--r--modules/vorbis/SCsub1
-rw-r--r--modules/webp/SCsub1
-rw-r--r--modules/webrtc/SCsub1
-rw-r--r--modules/websocket/SCsub1
-rw-r--r--modules/webxr/SCsub1
-rw-r--r--modules/xatlas_unwrap/SCsub1
-rw-r--r--modules/zip/SCsub1
84 files changed, 1139 insertions, 48 deletions
diff --git a/modules/SCsub b/modules/SCsub
index e16cc17b67..fea2f2eeb8 100644
--- a/modules/SCsub
+++ b/modules/SCsub
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from misc.utility.scons_hints import *
import os
diff --git a/modules/astcenc/SCsub b/modules/astcenc/SCsub
index 691c74b4a7..23e9fa87fc 100644
--- a/modules/astcenc/SCsub
+++ b/modules/astcenc/SCsub
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from misc.utility.scons_hints import *
Import("env")
Import("env_modules")
diff --git a/modules/basis_universal/SCsub b/modules/basis_universal/SCsub
index 80bfd7e858..0142317e1e 100644
--- a/modules/basis_universal/SCsub
+++ b/modules/basis_universal/SCsub
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from misc.utility.scons_hints import *
Import("env")
Import("env_modules")
diff --git a/modules/betsy/SCsub b/modules/betsy/SCsub
index ed5dcbf58b..2735116cc3 100644
--- a/modules/betsy/SCsub
+++ b/modules/betsy/SCsub
@@ -1,4 +1,6 @@
-# !/ usr / bin / env python
+#!/usr/bin/env python
+from misc.utility.scons_hints import *
+
Import("env")
Import("env_modules")
diff --git a/modules/bmp/SCsub b/modules/bmp/SCsub
index 9d317887c3..cc3684b94b 100644
--- a/modules/bmp/SCsub
+++ b/modules/bmp/SCsub
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from misc.utility.scons_hints import *
Import("env")
Import("env_modules")
diff --git a/modules/camera/SCsub b/modules/camera/SCsub
index 9a6147d433..aed5efd0d2 100644
--- a/modules/camera/SCsub
+++ b/modules/camera/SCsub
@@ -1,14 +1,21 @@
#!/usr/bin/env python
+from misc.utility.scons_hints import *
Import("env")
Import("env_modules")
env_camera = env_modules.Clone()
-if env["platform"] == "windows":
+if env["platform"] in ["windows", "macos", "linuxbsd"]:
env_camera.add_source_files(env.modules_sources, "register_types.cpp")
+
+if env["platform"] == "windows":
env_camera.add_source_files(env.modules_sources, "camera_win.cpp")
elif env["platform"] == "macos":
- env_camera.add_source_files(env.modules_sources, "register_types.cpp")
env_camera.add_source_files(env.modules_sources, "camera_macos.mm")
+
+elif env["platform"] == "linuxbsd":
+ env_camera.add_source_files(env.modules_sources, "camera_linux.cpp")
+ env_camera.add_source_files(env.modules_sources, "camera_feed_linux.cpp")
+ env_camera.add_source_files(env.modules_sources, "buffer_decoder.cpp")
diff --git a/modules/camera/buffer_decoder.cpp b/modules/camera/buffer_decoder.cpp
new file mode 100644
index 0000000000..024a68f080
--- /dev/null
+++ b/modules/camera/buffer_decoder.cpp
@@ -0,0 +1,212 @@
+/**************************************************************************/
+/* buffer_decoder.cpp */
+/**************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/**************************************************************************/
+/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* */
+/* 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 "buffer_decoder.h"
+
+#include "servers/camera/camera_feed.h"
+
+#include <linux/videodev2.h>
+
+BufferDecoder::BufferDecoder(CameraFeed *p_camera_feed) {
+ camera_feed = p_camera_feed;
+ width = camera_feed->get_format().width;
+ height = camera_feed->get_format().height;
+ image.instantiate();
+}
+
+AbstractYuyvBufferDecoder::AbstractYuyvBufferDecoder(CameraFeed *p_camera_feed) :
+ BufferDecoder(p_camera_feed) {
+ switch (camera_feed->get_format().pixel_format) {
+ case V4L2_PIX_FMT_YYUV:
+ component_indexes = new int[4]{ 0, 1, 2, 3 };
+ break;
+ case V4L2_PIX_FMT_YVYU:
+ component_indexes = new int[4]{ 0, 2, 3, 1 };
+ break;
+ case V4L2_PIX_FMT_UYVY:
+ component_indexes = new int[4]{ 1, 3, 0, 2 };
+ break;
+ case V4L2_PIX_FMT_VYUY:
+ component_indexes = new int[4]{ 1, 3, 2, 0 };
+ break;
+ default:
+ component_indexes = new int[4]{ 0, 2, 1, 3 };
+ }
+}
+
+AbstractYuyvBufferDecoder::~AbstractYuyvBufferDecoder() {
+ delete[] component_indexes;
+}
+
+SeparateYuyvBufferDecoder::SeparateYuyvBufferDecoder(CameraFeed *p_camera_feed) :
+ AbstractYuyvBufferDecoder(p_camera_feed) {
+ y_image_data.resize(width * height);
+ cbcr_image_data.resize(width * height);
+ y_image.instantiate();
+ cbcr_image.instantiate();
+}
+
+void SeparateYuyvBufferDecoder::decode(StreamingBuffer p_buffer) {
+ uint8_t *y_dst = (uint8_t *)y_image_data.ptrw();
+ uint8_t *uv_dst = (uint8_t *)cbcr_image_data.ptrw();
+ uint8_t *src = (uint8_t *)p_buffer.start;
+ uint8_t *y0_src = src + component_indexes[0];
+ uint8_t *y1_src = src + component_indexes[1];
+ uint8_t *u_src = src + component_indexes[2];
+ uint8_t *v_src = src + component_indexes[3];
+
+ for (int i = 0; i < width * height; i += 2) {
+ *y_dst++ = *y0_src;
+ *y_dst++ = *y1_src;
+ *uv_dst++ = *u_src;
+ *uv_dst++ = *v_src;
+
+ y0_src += 4;
+ y1_src += 4;
+ u_src += 4;
+ v_src += 4;
+ }
+
+ if (y_image.is_valid()) {
+ y_image->set_data(width, height, false, Image::FORMAT_L8, y_image_data);
+ } else {
+ y_image.instantiate(width, height, false, Image::FORMAT_RGB8, y_image_data);
+ }
+ if (cbcr_image.is_valid()) {
+ cbcr_image->set_data(width, height, false, Image::FORMAT_L8, cbcr_image_data);
+ } else {
+ cbcr_image.instantiate(width, height, false, Image::FORMAT_RGB8, cbcr_image_data);
+ }
+
+ camera_feed->set_YCbCr_imgs(y_image, cbcr_image);
+}
+
+YuyvToGrayscaleBufferDecoder::YuyvToGrayscaleBufferDecoder(CameraFeed *p_camera_feed) :
+ AbstractYuyvBufferDecoder(p_camera_feed) {
+ image_data.resize(width * height);
+}
+
+void YuyvToGrayscaleBufferDecoder::decode(StreamingBuffer p_buffer) {
+ uint8_t *dst = (uint8_t *)image_data.ptrw();
+ uint8_t *src = (uint8_t *)p_buffer.start;
+ uint8_t *y0_src = src + component_indexes[0];
+ uint8_t *y1_src = src + component_indexes[1];
+
+ for (int i = 0; i < width * height; i += 2) {
+ *dst++ = *y0_src;
+ *dst++ = *y1_src;
+
+ y0_src += 4;
+ y1_src += 4;
+ }
+
+ if (image.is_valid()) {
+ image->set_data(width, height, false, Image::FORMAT_L8, image_data);
+ } else {
+ image.instantiate(width, height, false, Image::FORMAT_RGB8, image_data);
+ }
+
+ camera_feed->set_RGB_img(image);
+}
+
+YuyvToRgbBufferDecoder::YuyvToRgbBufferDecoder(CameraFeed *p_camera_feed) :
+ AbstractYuyvBufferDecoder(p_camera_feed) {
+ image_data.resize(width * height * 3);
+}
+
+void YuyvToRgbBufferDecoder::decode(StreamingBuffer p_buffer) {
+ uint8_t *src = (uint8_t *)p_buffer.start;
+ uint8_t *y0_src = src + component_indexes[0];
+ uint8_t *y1_src = src + component_indexes[1];
+ uint8_t *u_src = src + component_indexes[2];
+ uint8_t *v_src = src + component_indexes[3];
+ uint8_t *dst = (uint8_t *)image_data.ptrw();
+
+ for (int i = 0; i < width * height; i += 2) {
+ int u = *u_src;
+ int v = *v_src;
+ int u1 = (((u - 128) << 7) + (u - 128)) >> 6;
+ int rg = (((u - 128) << 1) + (u - 128) + ((v - 128) << 2) + ((v - 128) << 1)) >> 3;
+ int v1 = (((v - 128) << 1) + (v - 128)) >> 1;
+
+ *dst++ = CLAMP(*y0_src + v1, 0, 255);
+ *dst++ = CLAMP(*y0_src - rg, 0, 255);
+ *dst++ = CLAMP(*y0_src + u1, 0, 255);
+
+ *dst++ = CLAMP(*y1_src + v1, 0, 255);
+ *dst++ = CLAMP(*y1_src - rg, 0, 255);
+ *dst++ = CLAMP(*y1_src + u1, 0, 255);
+
+ y0_src += 4;
+ y1_src += 4;
+ u_src += 4;
+ v_src += 4;
+ }
+
+ if (image.is_valid()) {
+ image->set_data(width, height, false, Image::FORMAT_RGB8, image_data);
+ } else {
+ image.instantiate(width, height, false, Image::FORMAT_RGB8, image_data);
+ }
+
+ camera_feed->set_RGB_img(image);
+}
+
+CopyBufferDecoder::CopyBufferDecoder(CameraFeed *p_camera_feed, bool p_rgba) :
+ BufferDecoder(p_camera_feed) {
+ rgba = p_rgba;
+ image_data.resize(width * height * (rgba ? 4 : 2));
+}
+
+void CopyBufferDecoder::decode(StreamingBuffer p_buffer) {
+ uint8_t *dst = (uint8_t *)image_data.ptrw();
+ memcpy(dst, p_buffer.start, p_buffer.length);
+
+ if (image.is_valid()) {
+ image->set_data(width, height, false, rgba ? Image::FORMAT_RGBA8 : Image::FORMAT_LA8, image_data);
+ } else {
+ image.instantiate(width, height, false, rgba ? Image::FORMAT_RGBA8 : Image::FORMAT_LA8, image_data);
+ }
+
+ camera_feed->set_RGB_img(image);
+}
+
+JpegBufferDecoder::JpegBufferDecoder(CameraFeed *p_camera_feed) :
+ BufferDecoder(p_camera_feed) {
+}
+
+void JpegBufferDecoder::decode(StreamingBuffer p_buffer) {
+ image_data.resize(p_buffer.length);
+ uint8_t *dst = (uint8_t *)image_data.ptrw();
+ memcpy(dst, p_buffer.start, p_buffer.length);
+ if (image->load_jpg_from_buffer(image_data) == OK) {
+ camera_feed->set_RGB_img(image);
+ }
+}
diff --git a/modules/camera/buffer_decoder.h b/modules/camera/buffer_decoder.h
new file mode 100644
index 0000000000..97cc66b6da
--- /dev/null
+++ b/modules/camera/buffer_decoder.h
@@ -0,0 +1,116 @@
+/**************************************************************************/
+/* buffer_decoder.h */
+/**************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/**************************************************************************/
+/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* */
+/* 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 BUFFER_DECODER_H
+#define BUFFER_DECODER_H
+
+#include "core/io/image.h"
+#include "core/templates/vector.h"
+
+class CameraFeed;
+
+struct StreamingBuffer {
+ void *start = nullptr;
+ size_t length = 0;
+};
+
+class BufferDecoder {
+protected:
+ CameraFeed *camera_feed = nullptr;
+ Ref<Image> image;
+ int width = 0;
+ int height = 0;
+
+public:
+ virtual void decode(StreamingBuffer p_buffer) = 0;
+
+ BufferDecoder(CameraFeed *p_camera_feed);
+ virtual ~BufferDecoder() {}
+};
+
+class AbstractYuyvBufferDecoder : public BufferDecoder {
+protected:
+ int *component_indexes = nullptr;
+
+public:
+ AbstractYuyvBufferDecoder(CameraFeed *p_camera_feed);
+ ~AbstractYuyvBufferDecoder();
+};
+
+class SeparateYuyvBufferDecoder : public AbstractYuyvBufferDecoder {
+private:
+ Vector<uint8_t> y_image_data;
+ Vector<uint8_t> cbcr_image_data;
+ Ref<Image> y_image;
+ Ref<Image> cbcr_image;
+
+public:
+ SeparateYuyvBufferDecoder(CameraFeed *p_camera_feed);
+ virtual void decode(StreamingBuffer p_buffer) override;
+};
+
+class YuyvToGrayscaleBufferDecoder : public AbstractYuyvBufferDecoder {
+private:
+ Vector<uint8_t> image_data;
+
+public:
+ YuyvToGrayscaleBufferDecoder(CameraFeed *p_camera_feed);
+ virtual void decode(StreamingBuffer p_buffer) override;
+};
+
+class YuyvToRgbBufferDecoder : public AbstractYuyvBufferDecoder {
+private:
+ Vector<uint8_t> image_data;
+
+public:
+ YuyvToRgbBufferDecoder(CameraFeed *p_camera_feed);
+ virtual void decode(StreamingBuffer p_buffer) override;
+};
+
+class CopyBufferDecoder : public BufferDecoder {
+private:
+ Vector<uint8_t> image_data;
+ bool rgba = false;
+
+public:
+ CopyBufferDecoder(CameraFeed *p_camera_feed, bool p_rgba);
+ virtual void decode(StreamingBuffer p_buffer) override;
+};
+
+class JpegBufferDecoder : public BufferDecoder {
+private:
+ Vector<uint8_t> image_data;
+
+public:
+ JpegBufferDecoder(CameraFeed *p_camera_feed);
+ virtual void decode(StreamingBuffer p_buffer) override;
+};
+
+#endif // BUFFER_DECODER_H
diff --git a/modules/camera/camera_feed_linux.cpp b/modules/camera/camera_feed_linux.cpp
new file mode 100644
index 0000000000..9ed8eb0d0a
--- /dev/null
+++ b/modules/camera/camera_feed_linux.cpp
@@ -0,0 +1,363 @@
+/**************************************************************************/
+/* camera_feed_linux.cpp */
+/**************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/**************************************************************************/
+/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* */
+/* 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_feed_linux.h"
+
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <unistd.h>
+
+void CameraFeedLinux::update_buffer_thread_func(void *p_func) {
+ if (p_func) {
+ CameraFeedLinux *camera_feed_linux = (CameraFeedLinux *)p_func;
+ camera_feed_linux->_update_buffer();
+ }
+}
+
+void CameraFeedLinux::_update_buffer() {
+ while (!exit_flag.is_set()) {
+ _read_frame();
+ usleep(10000);
+ }
+}
+
+void CameraFeedLinux::_query_device(const String &p_device_name) {
+ file_descriptor = open(p_device_name.ascii(), O_RDWR | O_NONBLOCK, 0);
+ ERR_FAIL_COND_MSG(file_descriptor == -1, vformat("Cannot open file descriptor for %s. Error: %d.", p_device_name, errno));
+
+ struct v4l2_capability capability;
+ if (ioctl(file_descriptor, VIDIOC_QUERYCAP, &capability) == -1) {
+ ERR_FAIL_MSG(vformat("Cannot query device. Error: %d.", errno));
+ }
+ name = String((char *)capability.card);
+
+ for (int index = 0;; index++) {
+ struct v4l2_fmtdesc fmtdesc;
+ memset(&fmtdesc, 0, sizeof(fmtdesc));
+ fmtdesc.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ fmtdesc.index = index;
+
+ if (ioctl(file_descriptor, VIDIOC_ENUM_FMT, &fmtdesc) == -1) {
+ break;
+ }
+
+ for (int res_index = 0;; res_index++) {
+ struct v4l2_frmsizeenum frmsizeenum;
+ memset(&frmsizeenum, 0, sizeof(frmsizeenum));
+ frmsizeenum.pixel_format = fmtdesc.pixelformat;
+ frmsizeenum.index = res_index;
+
+ if (ioctl(file_descriptor, VIDIOC_ENUM_FRAMESIZES, &frmsizeenum) == -1) {
+ break;
+ }
+
+ for (int framerate_index = 0;; framerate_index++) {
+ struct v4l2_frmivalenum frmivalenum;
+ memset(&frmivalenum, 0, sizeof(frmivalenum));
+ frmivalenum.pixel_format = fmtdesc.pixelformat;
+ frmivalenum.width = frmsizeenum.discrete.width;
+ frmivalenum.height = frmsizeenum.discrete.height;
+ frmivalenum.index = framerate_index;
+
+ if (ioctl(file_descriptor, VIDIOC_ENUM_FRAMEINTERVALS, &frmivalenum) == -1) {
+ if (framerate_index == 0) {
+ _add_format(fmtdesc, frmsizeenum.discrete, -1, 1);
+ }
+ break;
+ }
+
+ _add_format(fmtdesc, frmsizeenum.discrete, frmivalenum.discrete.numerator, frmivalenum.discrete.denominator);
+ }
+ }
+ }
+
+ close(file_descriptor);
+}
+
+void CameraFeedLinux::_add_format(v4l2_fmtdesc p_description, v4l2_frmsize_discrete p_size, int p_frame_numerator, int p_frame_denominator) {
+ FeedFormat feed_format;
+ feed_format.width = p_size.width;
+ feed_format.height = p_size.height;
+ feed_format.format = String((char *)p_description.description);
+ feed_format.frame_numerator = p_frame_numerator;
+ feed_format.frame_denominator = p_frame_denominator;
+ feed_format.pixel_format = p_description.pixelformat;
+ print_verbose(vformat("%s %dx%d@%d/%dfps", (char *)p_description.description, p_size.width, p_size.height, p_frame_denominator, p_frame_numerator));
+ formats.push_back(feed_format);
+}
+
+bool CameraFeedLinux::_request_buffers() {
+ struct v4l2_requestbuffers requestbuffers;
+
+ memset(&requestbuffers, 0, sizeof(requestbuffers));
+ requestbuffers.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ requestbuffers.memory = V4L2_MEMORY_MMAP;
+ requestbuffers.count = 4;
+
+ if (ioctl(file_descriptor, VIDIOC_REQBUFS, &requestbuffers) == -1) {
+ ERR_FAIL_V_MSG(false, vformat("ioctl(VIDIOC_REQBUFS) error: %d.", errno));
+ }
+
+ ERR_FAIL_COND_V_MSG(requestbuffers.count < 2, false, "Not enough buffers granted.");
+
+ buffer_count = requestbuffers.count;
+ buffers = new StreamingBuffer[buffer_count];
+
+ for (unsigned int i = 0; i < buffer_count; i++) {
+ struct v4l2_buffer buffer;
+
+ memset(&buffer, 0, sizeof(buffer));
+ buffer.type = requestbuffers.type;
+ buffer.memory = V4L2_MEMORY_MMAP;
+ buffer.index = i;
+
+ if (ioctl(file_descriptor, VIDIOC_QUERYBUF, &buffer) == -1) {
+ delete[] buffers;
+ ERR_FAIL_V_MSG(false, vformat("ioctl(VIDIOC_QUERYBUF) error: %d.", errno));
+ }
+
+ buffers[i].length = buffer.length;
+ buffers[i].start = mmap(NULL, buffer.length, PROT_READ | PROT_WRITE, MAP_SHARED, file_descriptor, buffer.m.offset);
+
+ if (buffers[i].start == MAP_FAILED) {
+ for (unsigned int b = 0; b < i; b++) {
+ _unmap_buffers(i);
+ }
+ delete[] buffers;
+ ERR_FAIL_V_MSG(false, "Mapping buffers failed.");
+ }
+ }
+
+ return true;
+}
+
+bool CameraFeedLinux::_start_capturing() {
+ for (unsigned int i = 0; i < buffer_count; i++) {
+ struct v4l2_buffer buffer;
+
+ memset(&buffer, 0, sizeof(buffer));
+ buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ buffer.memory = V4L2_MEMORY_MMAP;
+ buffer.index = i;
+
+ if (ioctl(file_descriptor, VIDIOC_QBUF, &buffer) == -1) {
+ ERR_FAIL_V_MSG(false, vformat("ioctl(VIDIOC_QBUF) error: %d.", errno));
+ }
+ }
+
+ enum v4l2_buf_type type;
+ type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+
+ if (ioctl(file_descriptor, VIDIOC_STREAMON, &type) == -1) {
+ ERR_FAIL_V_MSG(false, vformat("ioctl(VIDIOC_STREAMON) error: %d.", errno));
+ }
+
+ return true;
+}
+
+void CameraFeedLinux::_read_frame() {
+ struct v4l2_buffer buffer;
+ memset(&buffer, 0, sizeof(buffer));
+ buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ buffer.memory = V4L2_MEMORY_MMAP;
+
+ if (ioctl(file_descriptor, VIDIOC_DQBUF, &buffer) == -1) {
+ if (errno != EAGAIN) {
+ print_error(vformat("ioctl(VIDIOC_DQBUF) error: %d.", errno));
+ exit_flag.set();
+ }
+ return;
+ }
+
+ buffer_decoder->decode(buffers[buffer.index]);
+
+ if (ioctl(file_descriptor, VIDIOC_QBUF, &buffer) == -1) {
+ print_error(vformat("ioctl(VIDIOC_QBUF) error: %d.", errno));
+ }
+
+ emit_signal(SNAME("frame_changed"));
+}
+
+void CameraFeedLinux::_stop_capturing() {
+ enum v4l2_buf_type type;
+ type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+
+ if (ioctl(file_descriptor, VIDIOC_STREAMOFF, &type) == -1) {
+ print_error(vformat("ioctl(VIDIOC_STREAMOFF) error: %d.", errno));
+ }
+}
+
+void CameraFeedLinux::_unmap_buffers(unsigned int p_count) {
+ for (unsigned int i = 0; i < p_count; i++) {
+ munmap(buffers[i].start, buffers[i].length);
+ }
+}
+
+void CameraFeedLinux::_start_thread() {
+ exit_flag.clear();
+ thread = memnew(Thread);
+ thread->start(CameraFeedLinux::update_buffer_thread_func, this);
+}
+
+String CameraFeedLinux::get_device_name() const {
+ return device_name;
+}
+
+bool CameraFeedLinux::activate_feed() {
+ file_descriptor = open(device_name.ascii(), O_RDWR | O_NONBLOCK, 0);
+ if (_request_buffers() && _start_capturing()) {
+ buffer_decoder = _create_buffer_decoder();
+ _start_thread();
+ return true;
+ }
+ ERR_FAIL_V_MSG(false, "Could not activate feed.");
+}
+
+BufferDecoder *CameraFeedLinux::_create_buffer_decoder() {
+ switch (formats[selected_format].pixel_format) {
+ case V4L2_PIX_FMT_MJPEG:
+ case V4L2_PIX_FMT_JPEG:
+ return memnew(JpegBufferDecoder(this));
+ case V4L2_PIX_FMT_YUYV:
+ case V4L2_PIX_FMT_YYUV:
+ case V4L2_PIX_FMT_YVYU:
+ case V4L2_PIX_FMT_UYVY:
+ case V4L2_PIX_FMT_VYUY: {
+ String output = parameters["output"];
+ if (output == "separate") {
+ return memnew(SeparateYuyvBufferDecoder(this));
+ }
+ if (output == "grayscale") {
+ return memnew(YuyvToGrayscaleBufferDecoder(this));
+ }
+ if (output == "copy") {
+ return memnew(CopyBufferDecoder(this, false));
+ }
+ return memnew(YuyvToRgbBufferDecoder(this));
+ }
+ default:
+ return memnew(CopyBufferDecoder(this, true));
+ }
+}
+
+void CameraFeedLinux::deactivate_feed() {
+ exit_flag.set();
+ thread->wait_to_finish();
+ memdelete(thread);
+ _stop_capturing();
+ _unmap_buffers(buffer_count);
+ delete[] buffers;
+ memdelete(buffer_decoder);
+ for (int i = 0; i < CameraServer::FEED_IMAGES; i++) {
+ RID placeholder = RenderingServer::get_singleton()->texture_2d_placeholder_create();
+ RenderingServer::get_singleton()->texture_replace(texture[i], placeholder);
+ }
+ base_width = 0;
+ base_height = 0;
+ close(file_descriptor);
+
+ emit_signal(SNAME("format_changed"));
+}
+
+Array CameraFeedLinux::get_formats() const {
+ Array result;
+ for (const FeedFormat &format : formats) {
+ Dictionary dictionary;
+ dictionary["width"] = format.width;
+ dictionary["height"] = format.height;
+ dictionary["format"] = format.format;
+ dictionary["frame_numerator"] = format.frame_numerator;
+ dictionary["frame_denominator"] = format.frame_denominator;
+ result.push_back(dictionary);
+ }
+ return result;
+}
+
+CameraFeed::FeedFormat CameraFeedLinux::get_format() const {
+ return formats[selected_format];
+}
+
+bool CameraFeedLinux::set_format(int p_index, const Dictionary &p_parameters) {
+ ERR_FAIL_COND_V_MSG(active, false, "Feed is active.");
+ ERR_FAIL_INDEX_V_MSG(p_index, formats.size(), false, "Invalid format index.");
+
+ parameters = p_parameters.duplicate();
+ selected_format = p_index;
+
+ FeedFormat feed_format = formats[p_index];
+
+ file_descriptor = open(device_name.ascii(), O_RDWR | O_NONBLOCK, 0);
+
+ struct v4l2_format format;
+ memset(&format, 0, sizeof(format));
+ format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ format.fmt.pix.width = feed_format.width;
+ format.fmt.pix.height = feed_format.height;
+ format.fmt.pix.pixelformat = feed_format.pixel_format;
+
+ if (ioctl(file_descriptor, VIDIOC_S_FMT, &format) == -1) {
+ close(file_descriptor);
+ ERR_FAIL_V_MSG(false, vformat("Cannot set format, error: %d.", errno));
+ }
+
+ if (feed_format.frame_numerator > 0) {
+ struct v4l2_streamparm param;
+ memset(&param, 0, sizeof(param));
+
+ param.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ param.parm.capture.capability = V4L2_CAP_TIMEPERFRAME;
+ param.parm.capture.timeperframe.numerator = feed_format.frame_numerator;
+ param.parm.capture.timeperframe.denominator = feed_format.frame_denominator;
+
+ if (ioctl(file_descriptor, VIDIOC_S_PARM, &param) == -1) {
+ close(file_descriptor);
+ ERR_FAIL_V_MSG(false, vformat("Cannot set framerate, error: %d.", errno));
+ }
+ }
+ close(file_descriptor);
+
+ emit_signal(SNAME("format_changed"));
+
+ return true;
+}
+
+CameraFeedLinux::CameraFeedLinux(const String &p_device_name) :
+ CameraFeed() {
+ device_name = p_device_name;
+ _query_device(device_name);
+ set_format(0, Dictionary());
+}
+
+CameraFeedLinux::~CameraFeedLinux() {
+ if (is_active()) {
+ deactivate_feed();
+ }
+}
diff --git a/modules/camera/camera_feed_linux.h b/modules/camera/camera_feed_linux.h
new file mode 100644
index 0000000000..bf29201c99
--- /dev/null
+++ b/modules/camera/camera_feed_linux.h
@@ -0,0 +1,78 @@
+/**************************************************************************/
+/* camera_feed_linux.h */
+/**************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/**************************************************************************/
+/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* */
+/* 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 CAMERA_FEED_LINUX_H
+#define CAMERA_FEED_LINUX_H
+
+#include "buffer_decoder.h"
+
+#include "core/os/thread.h"
+#include "servers/camera/camera_feed.h"
+
+#include <linux/videodev2.h>
+
+struct StreamingBuffer;
+
+class CameraFeedLinux : public CameraFeed {
+private:
+ SafeFlag exit_flag;
+ Thread *thread = nullptr;
+ String device_name;
+ int file_descriptor = -1;
+ StreamingBuffer *buffers = nullptr;
+ unsigned int buffer_count = 0;
+ BufferDecoder *buffer_decoder = nullptr;
+
+ static void update_buffer_thread_func(void *p_func);
+
+ void _update_buffer();
+ void _query_device(const String &p_device_name);
+ void _add_format(v4l2_fmtdesc description, v4l2_frmsize_discrete size, int frame_numerator, int frame_denominator);
+ bool _request_buffers();
+ bool _start_capturing();
+ void _read_frame();
+ void _stop_capturing();
+ void _unmap_buffers(unsigned int p_count);
+ BufferDecoder *_create_buffer_decoder();
+ void _start_thread();
+
+public:
+ String get_device_name() const;
+ bool activate_feed();
+ void deactivate_feed();
+ bool set_format(int p_index, const Dictionary &p_parameters);
+ Array get_formats() const;
+ FeedFormat get_format() const;
+
+ CameraFeedLinux(const String &p_device_name);
+ virtual ~CameraFeedLinux();
+};
+
+#endif // CAMERA_FEED_LINUX_H
diff --git a/modules/camera/camera_linux.cpp b/modules/camera/camera_linux.cpp
new file mode 100644
index 0000000000..0cfb6b7b9e
--- /dev/null
+++ b/modules/camera/camera_linux.cpp
@@ -0,0 +1,169 @@
+/**************************************************************************/
+/* camera_linux.cpp */
+/**************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/**************************************************************************/
+/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* */
+/* 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_linux.h"
+
+#include "camera_feed_linux.h"
+
+#include <dirent.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+void CameraLinux::camera_thread_func(void *p_camera_linux) {
+ if (p_camera_linux) {
+ CameraLinux *camera_linux = (CameraLinux *)p_camera_linux;
+ camera_linux->_update_devices();
+ }
+}
+
+void CameraLinux::_update_devices() {
+ while (!exit_flag.is_set()) {
+ {
+ MutexLock lock(camera_mutex);
+
+ for (int i = feeds.size() - 1; i >= 0; i--) {
+ Ref<CameraFeedLinux> feed = (Ref<CameraFeedLinux>)feeds[i];
+ String device_name = feed->get_device_name();
+ if (!_is_active(device_name)) {
+ remove_feed(feed);
+ }
+ }
+
+ DIR *devices = opendir("/dev");
+
+ if (devices) {
+ struct dirent *device;
+
+ while ((device = readdir(devices)) != nullptr) {
+ if (strncmp(device->d_name, "video", 5) != 0) {
+ continue;
+ }
+ String device_name = String("/dev/") + String(device->d_name);
+ if (!_has_device(device_name)) {
+ _add_device(device_name);
+ }
+ }
+ }
+
+ closedir(devices);
+ }
+
+ usleep(1000000);
+ }
+}
+
+bool CameraLinux::_has_device(const String &p_device_name) {
+ for (int i = 0; i < feeds.size(); i++) {
+ Ref<CameraFeedLinux> feed = (Ref<CameraFeedLinux>)feeds[i];
+ if (feed->get_device_name() == p_device_name) {
+ return true;
+ }
+ }
+ return false;
+}
+
+void CameraLinux::_add_device(const String &p_device_name) {
+ int file_descriptor = _open_device(p_device_name);
+
+ if (file_descriptor != -1) {
+ if (_is_video_capture_device(file_descriptor)) {
+ Ref<CameraFeedLinux> feed = memnew(CameraFeedLinux(p_device_name));
+ add_feed(feed);
+ }
+ }
+
+ close(file_descriptor);
+}
+
+int CameraLinux::_open_device(const String &p_device_name) {
+ struct stat s;
+
+ if (stat(p_device_name.ascii(), &s) == -1) {
+ return -1;
+ }
+
+ if (!S_ISCHR(s.st_mode)) {
+ return -1;
+ }
+
+ return open(p_device_name.ascii(), O_RDWR | O_NONBLOCK, 0);
+}
+
+// TODO any cheaper/cleaner way to check if file descriptor is invalid?
+bool CameraLinux::_is_active(const String &p_device_name) {
+ struct v4l2_capability capability;
+ bool result = false;
+ int file_descriptor = _open_device(p_device_name);
+ if (file_descriptor != -1 && ioctl(file_descriptor, VIDIOC_QUERYCAP, &capability) != -1) {
+ result = true;
+ }
+ close(file_descriptor);
+ return result;
+}
+
+bool CameraLinux::_is_video_capture_device(int p_file_descriptor) {
+ struct v4l2_capability capability;
+
+ if (ioctl(p_file_descriptor, VIDIOC_QUERYCAP, &capability) == -1) {
+ print_verbose("Cannot query device");
+ return false;
+ }
+
+ if (!(capability.capabilities & V4L2_CAP_VIDEO_CAPTURE)) {
+ print_verbose(vformat("%s is no video capture device\n", String((char *)capability.card)));
+ return false;
+ }
+
+ if (!(capability.capabilities & V4L2_CAP_STREAMING)) {
+ print_verbose(vformat("%s does not support streaming", String((char *)capability.card)));
+ return false;
+ }
+
+ return _can_query_format(p_file_descriptor, V4L2_BUF_TYPE_VIDEO_CAPTURE);
+}
+
+bool CameraLinux::_can_query_format(int p_file_descriptor, int p_type) {
+ struct v4l2_format format;
+ memset(&format, 0, sizeof(format));
+ format.type = p_type;
+
+ return ioctl(p_file_descriptor, VIDIOC_G_FMT, &format) != -1;
+}
+
+CameraLinux::CameraLinux() {
+ camera_thread.start(CameraLinux::camera_thread_func, this);
+};
+
+CameraLinux::~CameraLinux() {
+ exit_flag.set();
+ camera_thread.wait_to_finish();
+}
diff --git a/modules/camera/camera_linux.h b/modules/camera/camera_linux.h
new file mode 100644
index 0000000000..66f6aa0ffb
--- /dev/null
+++ b/modules/camera/camera_linux.h
@@ -0,0 +1,60 @@
+/**************************************************************************/
+/* camera_linux.h */
+/**************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/**************************************************************************/
+/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* */
+/* 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 CAMERA_LINUX_H
+#define CAMERA_LINUX_H
+
+#include "core/os/mutex.h"
+#include "core/os/thread.h"
+#include "servers/camera_server.h"
+
+class CameraLinux : public CameraServer {
+private:
+ SafeFlag exit_flag;
+ Thread camera_thread;
+ Mutex camera_mutex;
+
+ static void camera_thread_func(void *p_camera_linux);
+
+ void _update_devices();
+ bool _has_device(const String &p_device_name);
+ void _add_device(const String &p_device_name);
+ void _remove_device(const String &p_device_name);
+ int _open_device(const String &p_device_name);
+ bool _is_active(const String &p_device_name);
+ bool _is_video_capture_device(int p_file_descriptor);
+ bool _can_query_format(int p_file_descriptor, int p_type);
+
+public:
+ CameraLinux();
+ ~CameraLinux();
+};
+
+#endif // CAMERA_LINUX_H
diff --git a/modules/camera/config.py b/modules/camera/config.py
index d2b2542dd9..7b368d2193 100644
--- a/modules/camera/config.py
+++ b/modules/camera/config.py
@@ -1,5 +1,5 @@
def can_build(env, platform):
- return platform == "macos" or platform == "windows"
+ return platform == "macos" or platform == "windows" or platform == "linuxbsd"
def configure(env):
diff --git a/modules/camera/register_types.cpp b/modules/camera/register_types.cpp
index feee6769f8..666ea8ba65 100644
--- a/modules/camera/register_types.cpp
+++ b/modules/camera/register_types.cpp
@@ -30,6 +30,9 @@
#include "register_types.h"
+#if defined(LINUXBSD_ENABLED)
+#include "camera_linux.h"
+#endif
#if defined(WINDOWS_ENABLED)
#include "camera_win.h"
#endif
@@ -42,6 +45,9 @@ void initialize_camera_module(ModuleInitializationLevel p_level) {
return;
}
+#if defined(LINUXBSD_ENABLED)
+ CameraServer::make_default<CameraLinux>();
+#endif
#if defined(WINDOWS_ENABLED)
CameraServer::make_default<CameraWindows>();
#endif
diff --git a/modules/csg/SCsub b/modules/csg/SCsub
index 1cf9974fc1..f71618ab22 100644
--- a/modules/csg/SCsub
+++ b/modules/csg/SCsub
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from misc.utility.scons_hints import *
Import("env")
Import("env_modules")
diff --git a/modules/csg/register_types.cpp b/modules/csg/register_types.cpp
index de949e30d8..19e6be4be1 100644
--- a/modules/csg/register_types.cpp
+++ b/modules/csg/register_types.cpp
@@ -30,8 +30,6 @@
#include "register_types.h"
-#ifndef _3D_DISABLED
-
#include "csg_shape.h"
#ifdef TOOLS_ENABLED
@@ -62,5 +60,3 @@ void uninitialize_csg_module(ModuleInitializationLevel p_level) {
return;
}
}
-
-#endif // _3D_DISABLED
diff --git a/modules/cvtt/SCsub b/modules/cvtt/SCsub
index 1d5a7ff6a3..44e56ab6a7 100644
--- a/modules/cvtt/SCsub
+++ b/modules/cvtt/SCsub
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from misc.utility.scons_hints import *
Import("env")
Import("env_modules")
diff --git a/modules/dds/SCsub b/modules/dds/SCsub
index 06980bd670..d1c67c31ea 100644
--- a/modules/dds/SCsub
+++ b/modules/dds/SCsub
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from misc.utility.scons_hints import *
Import("env")
Import("env_modules")
diff --git a/modules/enet/SCsub b/modules/enet/SCsub
index 580e5a3eb0..0c31638e46 100644
--- a/modules/enet/SCsub
+++ b/modules/enet/SCsub
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from misc.utility.scons_hints import *
Import("env")
Import("env_modules")
diff --git a/modules/etcpak/SCsub b/modules/etcpak/SCsub
index 2d3b69be75..a872e1cd03 100644
--- a/modules/etcpak/SCsub
+++ b/modules/etcpak/SCsub
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from misc.utility.scons_hints import *
Import("env")
Import("env_modules")
diff --git a/modules/fbx/SCsub b/modules/fbx/SCsub
index 6a791094c6..6f9fbba0b4 100644
--- a/modules/fbx/SCsub
+++ b/modules/fbx/SCsub
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from misc.utility.scons_hints import *
Import("env")
Import("env_modules")
diff --git a/modules/freetype/SCsub b/modules/freetype/SCsub
index 2813eaecd5..5edce96680 100644
--- a/modules/freetype/SCsub
+++ b/modules/freetype/SCsub
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from misc.utility.scons_hints import *
Import("env")
Import("env_modules")
diff --git a/modules/gdscript/SCsub b/modules/gdscript/SCsub
index 61accd4fc9..8f50bf9588 100644
--- a/modules/gdscript/SCsub
+++ b/modules/gdscript/SCsub
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from misc.utility.scons_hints import *
Import("env")
Import("env_modules")
diff --git a/modules/gdscript/editor/script_templates/SCsub b/modules/gdscript/editor/script_templates/SCsub
index 5db7e3fc3b..28a27db3fa 100644
--- a/modules/gdscript/editor/script_templates/SCsub
+++ b/modules/gdscript/editor/script_templates/SCsub
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from misc.utility.scons_hints import *
Import("env")
diff --git a/modules/gdscript/gdscript_compiler.cpp b/modules/gdscript/gdscript_compiler.cpp
index eebf282633..f4f445e096 100644
--- a/modules/gdscript/gdscript_compiler.cpp
+++ b/modules/gdscript/gdscript_compiler.cpp
@@ -2629,9 +2629,10 @@ Error GDScriptCompiler::_parse_setter_getter(GDScript *p_script, const GDScriptP
return err;
}
-// Prepares given script, and inner class scripts, for compilation. It populates class members and initializes method
-// RPC info for its base classes first, then for itself, then for inner classes.
-// Warning: this function cannot initiate compilation of other classes, or it will result in cyclic dependency issues.
+// Prepares given script, and inner class scripts, for compilation. It populates class members and
+// initializes method RPC info for its base classes first, then for itself, then for inner classes.
+// WARNING: This function cannot initiate compilation of other classes, or it will result in
+// cyclic dependency issues.
Error GDScriptCompiler::_prepare_compilation(GDScript *p_script, const GDScriptParser::ClassNode *p_class, bool p_keep_state) {
if (parsed_classes.has(p_script)) {
return OK;
diff --git a/modules/glslang/SCsub b/modules/glslang/SCsub
index 3068377e60..b6e3da2316 100644
--- a/modules/glslang/SCsub
+++ b/modules/glslang/SCsub
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from misc.utility.scons_hints import *
Import("env")
Import("env_modules")
diff --git a/modules/gltf/SCsub b/modules/gltf/SCsub
index 9d263cccac..1075116863 100644
--- a/modules/gltf/SCsub
+++ b/modules/gltf/SCsub
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from misc.utility.scons_hints import *
Import("env")
Import("env_modules")
diff --git a/modules/gltf/extensions/SCsub b/modules/gltf/extensions/SCsub
index fdf14300f1..e403cd6fdc 100644
--- a/modules/gltf/extensions/SCsub
+++ b/modules/gltf/extensions/SCsub
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from misc.utility.scons_hints import *
Import("env")
Import("env_modules")
diff --git a/modules/godot_physics_2d/SCsub b/modules/godot_physics_2d/SCsub
index 5d93da5ecf..39eb469978 100644
--- a/modules/godot_physics_2d/SCsub
+++ b/modules/godot_physics_2d/SCsub
@@ -1,5 +1,6 @@
#!/usr/bin/env python
+from misc.utility.scons_hints import *
-Import('env')
+Import("env")
env.add_source_files(env.modules_sources, "*.cpp")
diff --git a/modules/godot_physics_2d/godot_body_pair_2d.cpp b/modules/godot_physics_2d/godot_body_pair_2d.cpp
index 6c2d28dc92..98f11d6c07 100644
--- a/modules/godot_physics_2d/godot_body_pair_2d.cpp
+++ b/modules/godot_physics_2d/godot_body_pair_2d.cpp
@@ -161,11 +161,13 @@ void GodotBodyPair2D::_validate_contacts() {
}
}
-// _test_ccd prevents tunneling by slowing down a high velocity body that is about to collide so that next frame it will be at an appropriate location to collide (i.e. slight overlap)
-// Warning: the way velocity is adjusted down to cause a collision means the momentum will be weaker than it should for a bounce!
-// Process: only proceed if body A's motion is high relative to its size.
-// cast forward along motion vector to see if A is going to enter/pass B's collider next frame, only proceed if it does.
-// adjust the velocity of A down so that it will just slightly intersect the collider instead of blowing right past it.
+// `_test_ccd` prevents tunneling by slowing down a high velocity body that is about to collide so
+// that next frame it will be at an appropriate location to collide (i.e. slight overlap).
+// WARNING: The way velocity is adjusted down to cause a collision means the momentum will be
+// weaker than it should for a bounce!
+// Process: Only proceed if body A's motion is high relative to its size.
+// Cast forward along motion vector to see if A is going to enter/pass B's collider next frame, only proceed if it does.
+// Adjust the velocity of A down so that it will just slightly intersect the collider instead of blowing right past it.
bool GodotBodyPair2D::_test_ccd(real_t p_step, GodotBody2D *p_A, int p_shape_A, const Transform2D &p_xform_A, GodotBody2D *p_B, int p_shape_B, const Transform2D &p_xform_B) {
Vector2 motion = p_A->get_linear_velocity() * p_step;
real_t mlen = motion.length();
diff --git a/modules/godot_physics_2d/godot_step_2d.cpp b/modules/godot_physics_2d/godot_step_2d.cpp
index bbaec8be2b..418b9313e8 100644
--- a/modules/godot_physics_2d/godot_step_2d.cpp
+++ b/modules/godot_physics_2d/godot_step_2d.cpp
@@ -251,14 +251,14 @@ void GodotStep2D::step(GodotSpace2D *p_space, real_t p_delta) {
/* PRE-SOLVE CONSTRAINT ISLANDS */
- // Warning: This doesn't run on threads, because it involves thread-unsafe processing.
+ // WARNING: This doesn't run on threads, because it involves thread-unsafe processing.
for (uint32_t island_index = 0; island_index < island_count; ++island_index) {
_pre_solve_island(constraint_islands[island_index]);
}
/* SOLVE CONSTRAINT ISLANDS */
- // Warning: _solve_island modifies the constraint islands for optimization purpose,
+ // WARNING: `_solve_island` modifies the constraint islands for optimization purpose,
// their content is not reliable after these calls and shouldn't be used anymore.
group_task = WorkerThreadPool::get_singleton()->add_template_group_task(this, &GodotStep2D::_solve_island, nullptr, island_count, -1, true, SNAME("Physics2DConstraintSolveIslands"));
WorkerThreadPool::get_singleton()->wait_for_group_task_completion(group_task);
diff --git a/modules/godot_physics_3d/SCsub b/modules/godot_physics_3d/SCsub
index 41a59cd24e..1502eb39ee 100644
--- a/modules/godot_physics_3d/SCsub
+++ b/modules/godot_physics_3d/SCsub
@@ -1,6 +1,7 @@
#!/usr/bin/env python
+from misc.utility.scons_hints import *
-Import('env')
+Import("env")
env.add_source_files(env.modules_sources, "*.cpp")
diff --git a/modules/godot_physics_3d/godot_body_pair_3d.cpp b/modules/godot_physics_3d/godot_body_pair_3d.cpp
index 84fae73616..d689271ac7 100644
--- a/modules/godot_physics_3d/godot_body_pair_3d.cpp
+++ b/modules/godot_physics_3d/godot_body_pair_3d.cpp
@@ -161,11 +161,13 @@ void GodotBodyPair3D::validate_contacts() {
}
}
-// _test_ccd prevents tunneling by slowing down a high velocity body that is about to collide so that next frame it will be at an appropriate location to collide (i.e. slight overlap)
-// Warning: the way velocity is adjusted down to cause a collision means the momentum will be weaker than it should for a bounce!
-// Process: only proceed if body A's motion is high relative to its size.
-// cast forward along motion vector to see if A is going to enter/pass B's collider next frame, only proceed if it does.
-// adjust the velocity of A down so that it will just slightly intersect the collider instead of blowing right past it.
+// `_test_ccd` prevents tunneling by slowing down a high velocity body that is about to collide so
+// that next frame it will be at an appropriate location to collide (i.e. slight overlap).
+// WARNING: The way velocity is adjusted down to cause a collision means the momentum will be
+// weaker than it should for a bounce!
+// Process: Only proceed if body A's motion is high relative to its size.
+// Cast forward along motion vector to see if A is going to enter/pass B's collider next frame, only proceed if it does.
+// Adjust the velocity of A down so that it will just slightly intersect the collider instead of blowing right past it.
bool GodotBodyPair3D::_test_ccd(real_t p_step, GodotBody3D *p_A, int p_shape_A, const Transform3D &p_xform_A, GodotBody3D *p_B, int p_shape_B, const Transform3D &p_xform_B) {
GodotShape3D *shape_A_ptr = p_A->get_shape(p_shape_A);
diff --git a/modules/godot_physics_3d/godot_step_3d.cpp b/modules/godot_physics_3d/godot_step_3d.cpp
index d09a3b4e6d..b6cec4ba59 100644
--- a/modules/godot_physics_3d/godot_step_3d.cpp
+++ b/modules/godot_physics_3d/godot_step_3d.cpp
@@ -355,14 +355,14 @@ void GodotStep3D::step(GodotSpace3D *p_space, real_t p_delta) {
/* PRE-SOLVE CONSTRAINT ISLANDS */
- // Warning: This doesn't run on threads, because it involves thread-unsafe processing.
+ // WARNING: This doesn't run on threads, because it involves thread-unsafe processing.
for (uint32_t island_index = 0; island_index < island_count; ++island_index) {
_pre_solve_island(constraint_islands[island_index]);
}
/* SOLVE CONSTRAINT ISLANDS */
- // Warning: _solve_island modifies the constraint islands for optimization purpose,
+ // WARNING: `_solve_island` modifies the constraint islands for optimization purpose,
// their content is not reliable after these calls and shouldn't be used anymore.
group_task = WorkerThreadPool::get_singleton()->add_template_group_task(this, &GodotStep3D::_solve_island, nullptr, island_count, -1, true, SNAME("Physics3DConstraintSolveIslands"));
WorkerThreadPool::get_singleton()->wait_for_group_task_completion(group_task);
diff --git a/modules/godot_physics_3d/joints/SCsub b/modules/godot_physics_3d/joints/SCsub
index 5d93da5ecf..39eb469978 100644
--- a/modules/godot_physics_3d/joints/SCsub
+++ b/modules/godot_physics_3d/joints/SCsub
@@ -1,5 +1,6 @@
#!/usr/bin/env python
+from misc.utility.scons_hints import *
-Import('env')
+Import("env")
env.add_source_files(env.modules_sources, "*.cpp")
diff --git a/modules/gridmap/SCsub b/modules/gridmap/SCsub
index 282d772592..d4baa9000e 100644
--- a/modules/gridmap/SCsub
+++ b/modules/gridmap/SCsub
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from misc.utility.scons_hints import *
Import("env")
Import("env_modules")
diff --git a/modules/hdr/SCsub b/modules/hdr/SCsub
index 10629bda3c..739b2caecf 100644
--- a/modules/hdr/SCsub
+++ b/modules/hdr/SCsub
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from misc.utility.scons_hints import *
Import("env")
Import("env_modules")
diff --git a/modules/interactive_music/SCsub b/modules/interactive_music/SCsub
index 2950a30854..f2546747a0 100644
--- a/modules/interactive_music/SCsub
+++ b/modules/interactive_music/SCsub
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from misc.utility.scons_hints import *
Import("env")
Import("env_modules")
diff --git a/modules/jpg/SCsub b/modules/jpg/SCsub
index b840542c1b..2d948d3355 100644
--- a/modules/jpg/SCsub
+++ b/modules/jpg/SCsub
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from misc.utility.scons_hints import *
Import("env")
Import("env_modules")
diff --git a/modules/jsonrpc/SCsub b/modules/jsonrpc/SCsub
index 8ee4f8bfea..923567b138 100644
--- a/modules/jsonrpc/SCsub
+++ b/modules/jsonrpc/SCsub
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from misc.utility.scons_hints import *
Import("env")
Import("env_modules")
diff --git a/modules/ktx/SCsub b/modules/ktx/SCsub
index c4cb732498..f4c394d734 100644
--- a/modules/ktx/SCsub
+++ b/modules/ktx/SCsub
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from misc.utility.scons_hints import *
Import("env")
Import("env_modules")
diff --git a/modules/lightmapper_rd/SCsub b/modules/lightmapper_rd/SCsub
index fe9737b36f..157381ae98 100644
--- a/modules/lightmapper_rd/SCsub
+++ b/modules/lightmapper_rd/SCsub
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from misc.utility.scons_hints import *
Import("env")
Import("env_modules")
diff --git a/modules/lightmapper_rd/lm_compute.glsl b/modules/lightmapper_rd/lm_compute.glsl
index 2c85fff6f3..31b721bb20 100644
--- a/modules/lightmapper_rd/lm_compute.glsl
+++ b/modules/lightmapper_rd/lm_compute.glsl
@@ -485,7 +485,7 @@ void trace_direct_light(vec3 p_position, vec3 p_normal, uint p_light_index, bool
float a = randomize(r_noise) * 2.0 * PI;
float vogel_index = float(total_ray_count - 1 - (i * shadowing_ray_count + j)); // Start from (total_ray_count - 1) so we check the outer points first.
- vec2 light_disk_sample = (get_vogel_disk(vogel_index, a, shadowing_ray_count_sqrt)) * soft_shadowing_disk_size * light_data.shadow_blur;
+ vec2 light_disk_sample = get_vogel_disk(vogel_index, a, shadowing_ray_count_sqrt) * soft_shadowing_disk_size * light_data.shadow_blur;
vec3 light_disk_to_point = normalize(light_to_point + light_disk_sample.x * light_to_point_tan + light_disk_sample.y * light_to_point_bitan);
// Offset the ray origin for AA, offset the light position for soft shadows.
if (trace_ray_any_hit(origin - light_disk_to_point * (bake_params.bias + length(disk_sample)), p_position - light_disk_to_point * dist) == RAY_MISS) {
diff --git a/modules/mbedtls/SCsub b/modules/mbedtls/SCsub
index 90ce98c751..e217ca5ca4 100644
--- a/modules/mbedtls/SCsub
+++ b/modules/mbedtls/SCsub
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from misc.utility.scons_hints import *
Import("env")
Import("env_modules")
diff --git a/modules/meshoptimizer/SCsub b/modules/meshoptimizer/SCsub
index 3f86bb4f00..b335b5db3a 100644
--- a/modules/meshoptimizer/SCsub
+++ b/modules/meshoptimizer/SCsub
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from misc.utility.scons_hints import *
Import("env")
Import("env_modules")
diff --git a/modules/minimp3/SCsub b/modules/minimp3/SCsub
index 09e84f71e9..e9491bb72f 100644
--- a/modules/minimp3/SCsub
+++ b/modules/minimp3/SCsub
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from misc.utility.scons_hints import *
Import("env")
Import("env_modules")
diff --git a/modules/mobile_vr/SCsub b/modules/mobile_vr/SCsub
index e6c43228b4..b237f31209 100644
--- a/modules/mobile_vr/SCsub
+++ b/modules/mobile_vr/SCsub
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from misc.utility.scons_hints import *
Import("env")
Import("env_modules")
diff --git a/modules/mono/SCsub b/modules/mono/SCsub
index d267df938a..f74f0fb9c1 100644
--- a/modules/mono/SCsub
+++ b/modules/mono/SCsub
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from misc.utility.scons_hints import *
import build_scripts.mono_configure as mono_configure
diff --git a/modules/mono/editor/script_templates/SCsub b/modules/mono/editor/script_templates/SCsub
index 01c293c25d..f465374758 100644
--- a/modules/mono/editor/script_templates/SCsub
+++ b/modules/mono/editor/script_templates/SCsub
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from misc.utility.scons_hints import *
Import("env")
diff --git a/modules/mono/mono_gd/gd_mono.cpp b/modules/mono/mono_gd/gd_mono.cpp
index 6abf0193cf..c81aa91fa5 100644
--- a/modules/mono/mono_gd/gd_mono.cpp
+++ b/modules/mono/mono_gd/gd_mono.cpp
@@ -388,7 +388,7 @@ godot_plugins_initialize_fn initialize_hostfxr_and_godot_plugins(bool &r_runtime
String assembly_name = path::get_csharp_project_name();
HostFxrCharString assembly_path = str_to_hostfxr(GodotSharpDirs::get_api_assemblies_dir()
- .path_join(assembly_name + ".dll"));
+ .path_join(assembly_name + ".dll"));
load_assembly_and_get_function_pointer_fn load_assembly_and_get_function_pointer =
initialize_hostfxr_self_contained(get_data(assembly_path));
diff --git a/modules/msdfgen/SCsub b/modules/msdfgen/SCsub
index f4316a74e7..844b0980ac 100644
--- a/modules/msdfgen/SCsub
+++ b/modules/msdfgen/SCsub
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from misc.utility.scons_hints import *
Import("env")
Import("env_modules")
diff --git a/modules/multiplayer/SCsub b/modules/multiplayer/SCsub
index e89038c3e0..97f91c5674 100644
--- a/modules/multiplayer/SCsub
+++ b/modules/multiplayer/SCsub
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from misc.utility.scons_hints import *
Import("env")
Import("env_modules")
diff --git a/modules/multiplayer/editor/editor_network_profiler.cpp b/modules/multiplayer/editor/editor_network_profiler.cpp
index 3a51712c70..f5f20d6931 100644
--- a/modules/multiplayer/editor/editor_network_profiler.cpp
+++ b/modules/multiplayer/editor/editor_network_profiler.cpp
@@ -193,6 +193,9 @@ void EditorNetworkProfiler::_update_button_text() {
}
void EditorNetworkProfiler::started() {
+ _clear_pressed();
+ activate->set_disabled(false);
+
if (EditorSettings::get_singleton()->get_project_metadata("debug_options", "autostart_network_profiler", false)) {
set_profiling(true);
refresh_timer->start();
@@ -200,6 +203,7 @@ void EditorNetworkProfiler::started() {
}
void EditorNetworkProfiler::stopped() {
+ activate->set_disabled(true);
set_profiling(false);
refresh_timer->stop();
}
@@ -218,6 +222,7 @@ void EditorNetworkProfiler::_clear_pressed() {
set_bandwidth(0, 0);
refresh_rpc_data();
refresh_replication_data();
+ clear_button->set_disabled(true);
}
void EditorNetworkProfiler::_autostart_toggled(bool p_toggled_on) {
@@ -235,6 +240,9 @@ void EditorNetworkProfiler::_replication_button_clicked(TreeItem *p_item, int p_
}
void EditorNetworkProfiler::add_rpc_frame_data(const RPCNodeInfo &p_frame) {
+ if (clear_button->is_disabled()) {
+ clear_button->set_disabled(false);
+ }
dirty = true;
if (!rpc_data.has(p_frame.node)) {
rpc_data.insert(p_frame.node, p_frame);
@@ -251,6 +259,9 @@ void EditorNetworkProfiler::add_rpc_frame_data(const RPCNodeInfo &p_frame) {
}
void EditorNetworkProfiler::add_sync_frame_data(const SyncInfo &p_frame) {
+ if (clear_button->is_disabled()) {
+ clear_button->set_disabled(false);
+ }
dirty = true;
if (!sync_data.has(p_frame.synchronizer)) {
sync_data[p_frame.synchronizer] = p_frame;
@@ -292,11 +303,13 @@ EditorNetworkProfiler::EditorNetworkProfiler() {
activate = memnew(Button);
activate->set_toggle_mode(true);
activate->set_text(TTR("Start"));
+ activate->set_disabled(true);
activate->connect(SceneStringName(pressed), callable_mp(this, &EditorNetworkProfiler::_activate_pressed));
hb->add_child(activate);
clear_button = memnew(Button);
clear_button->set_text(TTR("Clear"));
+ clear_button->set_disabled(true);
clear_button->connect(SceneStringName(pressed), callable_mp(this, &EditorNetworkProfiler::_clear_pressed));
hb->add_child(clear_button);
diff --git a/modules/navigation/SCsub b/modules/navigation/SCsub
index 02d3b7487e..ab578252c1 100644
--- a/modules/navigation/SCsub
+++ b/modules/navigation/SCsub
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from misc.utility.scons_hints import *
Import("env")
Import("env_modules")
diff --git a/modules/noise/SCsub b/modules/noise/SCsub
index f309fd2dd4..dcf51b03e3 100644
--- a/modules/noise/SCsub
+++ b/modules/noise/SCsub
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from misc.utility.scons_hints import *
Import("env")
Import("env_modules")
diff --git a/modules/ogg/SCsub b/modules/ogg/SCsub
index f15525648f..fabd4f936a 100644
--- a/modules/ogg/SCsub
+++ b/modules/ogg/SCsub
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from misc.utility.scons_hints import *
Import("env")
Import("env_modules")
diff --git a/modules/openxr/SCsub b/modules/openxr/SCsub
index 77922045eb..dd6a921440 100644
--- a/modules/openxr/SCsub
+++ b/modules/openxr/SCsub
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from misc.utility.scons_hints import *
Import("env")
Import("env_modules")
diff --git a/modules/openxr/action_map/SCsub b/modules/openxr/action_map/SCsub
index 7a493011ec..d659be1d99 100644
--- a/modules/openxr/action_map/SCsub
+++ b/modules/openxr/action_map/SCsub
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from misc.utility.scons_hints import *
Import("env")
Import("env_openxr")
diff --git a/modules/openxr/editor/SCsub b/modules/openxr/editor/SCsub
index ccf67a80d0..39eb469978 100644
--- a/modules/openxr/editor/SCsub
+++ b/modules/openxr/editor/SCsub
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from misc.utility.scons_hints import *
Import("env")
diff --git a/modules/openxr/editor/openxr_select_action_dialog.cpp b/modules/openxr/editor/openxr_select_action_dialog.cpp
index a4ccc98408..89dea09be4 100644
--- a/modules/openxr/editor/openxr_select_action_dialog.cpp
+++ b/modules/openxr/editor/openxr_select_action_dialog.cpp
@@ -66,7 +66,7 @@ void OpenXRSelectActionDialog::_on_select_action(const String p_action) {
void OpenXRSelectActionDialog::open() {
ERR_FAIL_COND(action_map.is_null());
- // out with the old...
+ // Out with the old.
while (main_vb->get_child_count() > 0) {
memdelete(main_vb->get_child(0));
}
@@ -74,6 +74,7 @@ void OpenXRSelectActionDialog::open() {
selected_action = "";
action_buttons.clear();
+ // In with the new.
Array action_sets = action_map->get_action_sets();
for (int i = 0; i < action_sets.size(); i++) {
Ref<OpenXRActionSet> action_set = action_sets[i];
diff --git a/modules/openxr/editor/openxr_select_interaction_profile_dialog.cpp b/modules/openxr/editor/openxr_select_interaction_profile_dialog.cpp
index 53b8cbd401..ee8940f30b 100644
--- a/modules/openxr/editor/openxr_select_interaction_profile_dialog.cpp
+++ b/modules/openxr/editor/openxr_select_interaction_profile_dialog.cpp
@@ -66,15 +66,15 @@ void OpenXRSelectInteractionProfileDialog::_on_select_interaction_profile(const
void OpenXRSelectInteractionProfileDialog::open(PackedStringArray p_do_not_include) {
int available_count = 0;
- // out with the old...
- while (main_vb->get_child_count() > 0) {
- memdelete(main_vb->get_child(0));
+ // Out with the old.
+ while (main_vb->get_child_count() > 1) {
+ memdelete(main_vb->get_child(1));
}
selected_interaction_profile = "";
ip_buttons.clear();
- // in with the new
+ // In with the new.
PackedStringArray interaction_profiles = OpenXRInteractionProfileMetadata::get_singleton()->get_interaction_profile_paths();
for (int i = 0; i < interaction_profiles.size(); i++) {
const String &path = interaction_profiles[i];
@@ -82,6 +82,7 @@ void OpenXRSelectInteractionProfileDialog::open(PackedStringArray p_do_not_inclu
Button *ip_button = memnew(Button);
ip_button->set_flat(true);
ip_button->set_text(OpenXRInteractionProfileMetadata::get_singleton()->get_profile(path)->display_name);
+ ip_button->set_text_alignment(HORIZONTAL_ALIGNMENT_LEFT);
ip_button->connect(SceneStringName(pressed), callable_mp(this, &OpenXRSelectInteractionProfileDialog::_on_select_interaction_profile).bind(path));
main_vb->add_child(ip_button);
@@ -90,23 +91,16 @@ void OpenXRSelectInteractionProfileDialog::open(PackedStringArray p_do_not_inclu
}
}
- if (available_count == 0) {
- // give warning that we have all profiles selected
-
- } else {
- // TODO maybe if we only have one, auto select it?
-
- popup_centered();
- }
+ all_selected->set_visible(available_count == 0);
+ get_cancel_button()->set_visible(available_count > 0);
+ popup_centered();
}
void OpenXRSelectInteractionProfileDialog::ok_pressed() {
- if (selected_interaction_profile == "") {
- return;
+ if (selected_interaction_profile != "") {
+ emit_signal("interaction_profile_selected", selected_interaction_profile);
}
- emit_signal("interaction_profile_selected", selected_interaction_profile);
-
hide();
}
@@ -118,6 +112,10 @@ OpenXRSelectInteractionProfileDialog::OpenXRSelectInteractionProfileDialog() {
add_child(scroll);
main_vb = memnew(VBoxContainer);
- // main_vb->set_h_size_flags(Control::SIZE_EXPAND_FILL);
+ main_vb->set_h_size_flags(Control::SIZE_EXPAND_FILL);
scroll->add_child(main_vb);
+
+ all_selected = memnew(Label);
+ all_selected->set_text(TTR("All interaction profiles have been added to the action map."));
+ main_vb->add_child(all_selected);
}
diff --git a/modules/openxr/editor/openxr_select_interaction_profile_dialog.h b/modules/openxr/editor/openxr_select_interaction_profile_dialog.h
index 1d1615321c..d85e4cd4d6 100644
--- a/modules/openxr/editor/openxr_select_interaction_profile_dialog.h
+++ b/modules/openxr/editor/openxr_select_interaction_profile_dialog.h
@@ -51,6 +51,7 @@ private:
VBoxContainer *main_vb = nullptr;
ScrollContainer *scroll = nullptr;
+ Label *all_selected = nullptr;
protected:
static void _bind_methods();
diff --git a/modules/openxr/extensions/SCsub b/modules/openxr/extensions/SCsub
index 1bd9cfaa22..95b75ccd65 100644
--- a/modules/openxr/extensions/SCsub
+++ b/modules/openxr/extensions/SCsub
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from misc.utility.scons_hints import *
Import("env")
Import("env_openxr")
diff --git a/modules/openxr/scene/SCsub b/modules/openxr/scene/SCsub
index 7a493011ec..d659be1d99 100644
--- a/modules/openxr/scene/SCsub
+++ b/modules/openxr/scene/SCsub
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from misc.utility.scons_hints import *
Import("env")
Import("env_openxr")
diff --git a/modules/raycast/SCsub b/modules/raycast/SCsub
index f3a8e30763..bbf5ff7983 100644
--- a/modules/raycast/SCsub
+++ b/modules/raycast/SCsub
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from misc.utility.scons_hints import *
Import("env")
Import("env_modules")
diff --git a/modules/regex/SCsub b/modules/regex/SCsub
index f5e2dd5dfc..5d70604e76 100644
--- a/modules/regex/SCsub
+++ b/modules/regex/SCsub
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from misc.utility.scons_hints import *
Import("env")
Import("env_modules")
diff --git a/modules/squish/SCsub b/modules/squish/SCsub
index c9e29911d8..d8e7fbc142 100644
--- a/modules/squish/SCsub
+++ b/modules/squish/SCsub
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from misc.utility.scons_hints import *
Import("env")
Import("env_modules")
diff --git a/modules/svg/SCsub b/modules/svg/SCsub
index a32be0e41a..af8f6c14f4 100644
--- a/modules/svg/SCsub
+++ b/modules/svg/SCsub
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from misc.utility.scons_hints import *
Import("env")
Import("env_modules")
diff --git a/modules/text_server_adv/SCsub b/modules/text_server_adv/SCsub
index 4112b81622..304a09515c 100644
--- a/modules/text_server_adv/SCsub
+++ b/modules/text_server_adv/SCsub
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from misc.utility.scons_hints import *
Import("env")
Import("env_modules")
diff --git a/modules/text_server_adv/gdextension_build/SConstruct b/modules/text_server_adv/gdextension_build/SConstruct
index effed1e772..8f4f2cba40 100644
--- a/modules/text_server_adv/gdextension_build/SConstruct
+++ b/modules/text_server_adv/gdextension_build/SConstruct
@@ -1,4 +1,6 @@
#!/usr/bin/env python
+from misc.utility.scons_hints import *
+
import atexit
import sys
import time
diff --git a/modules/text_server_fb/SCsub b/modules/text_server_fb/SCsub
index fc0a8727c6..b56df192c2 100644
--- a/modules/text_server_fb/SCsub
+++ b/modules/text_server_fb/SCsub
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from misc.utility.scons_hints import *
Import("env")
Import("env_modules")
diff --git a/modules/text_server_fb/gdextension_build/SConstruct b/modules/text_server_fb/gdextension_build/SConstruct
index a3c2052040..dc849d5814 100644
--- a/modules/text_server_fb/gdextension_build/SConstruct
+++ b/modules/text_server_fb/gdextension_build/SConstruct
@@ -1,4 +1,6 @@
#!/usr/bin/env python
+from misc.utility.scons_hints import *
+
import atexit
import sys
import time
diff --git a/modules/tga/SCsub b/modules/tga/SCsub
index ccd7d2ee37..c7f58e87f7 100644
--- a/modules/tga/SCsub
+++ b/modules/tga/SCsub
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from misc.utility.scons_hints import *
Import("env")
Import("env_modules")
diff --git a/modules/theora/SCsub b/modules/theora/SCsub
index ca666050dd..be557c1c24 100644
--- a/modules/theora/SCsub
+++ b/modules/theora/SCsub
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from misc.utility.scons_hints import *
Import("env")
Import("env_modules")
diff --git a/modules/tinyexr/SCsub b/modules/tinyexr/SCsub
index bf9242cc16..434e99bf84 100644
--- a/modules/tinyexr/SCsub
+++ b/modules/tinyexr/SCsub
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from misc.utility.scons_hints import *
Import("env")
Import("env_modules")
diff --git a/modules/upnp/SCsub b/modules/upnp/SCsub
index 98c03e9ee9..6657d75cae 100644
--- a/modules/upnp/SCsub
+++ b/modules/upnp/SCsub
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from misc.utility.scons_hints import *
Import("env")
Import("env_modules")
diff --git a/modules/vhacd/SCsub b/modules/vhacd/SCsub
index 1ff4122114..926cc5b16f 100644
--- a/modules/vhacd/SCsub
+++ b/modules/vhacd/SCsub
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from misc.utility.scons_hints import *
Import("env")
Import("env_modules")
diff --git a/modules/vorbis/SCsub b/modules/vorbis/SCsub
index 322314487f..f063d97fee 100644
--- a/modules/vorbis/SCsub
+++ b/modules/vorbis/SCsub
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from misc.utility.scons_hints import *
Import("env")
Import("env_modules")
diff --git a/modules/webp/SCsub b/modules/webp/SCsub
index dde4450c23..a939e2f90e 100644
--- a/modules/webp/SCsub
+++ b/modules/webp/SCsub
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from misc.utility.scons_hints import *
Import("env")
Import("env_modules")
diff --git a/modules/webrtc/SCsub b/modules/webrtc/SCsub
index e315633f55..0c5f2c9dda 100644
--- a/modules/webrtc/SCsub
+++ b/modules/webrtc/SCsub
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from misc.utility.scons_hints import *
Import("env")
Import("env_modules")
diff --git a/modules/websocket/SCsub b/modules/websocket/SCsub
index 8b469fe5be..acaa0d3ceb 100644
--- a/modules/websocket/SCsub
+++ b/modules/websocket/SCsub
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from misc.utility.scons_hints import *
Import("env")
Import("env_modules")
diff --git a/modules/webxr/SCsub b/modules/webxr/SCsub
index 81caa4a279..9fe4e03ea6 100644
--- a/modules/webxr/SCsub
+++ b/modules/webxr/SCsub
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from misc.utility.scons_hints import *
Import("env")
Import("env_modules")
diff --git a/modules/xatlas_unwrap/SCsub b/modules/xatlas_unwrap/SCsub
index aa6bdaea33..ae82a53bd9 100644
--- a/modules/xatlas_unwrap/SCsub
+++ b/modules/xatlas_unwrap/SCsub
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from misc.utility.scons_hints import *
Import("env")
Import("env_modules")
diff --git a/modules/zip/SCsub b/modules/zip/SCsub
index b7710123fd..0bab3ff5f9 100644
--- a/modules/zip/SCsub
+++ b/modules/zip/SCsub
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from misc.utility.scons_hints import *
Import("env")
Import("env_modules")