diff options
-rw-r--r-- | core/core_bind.cpp | 5 | ||||
-rw-r--r-- | core/core_bind.h | 1 | ||||
-rw-r--r-- | core/os/os.cpp | 4 | ||||
-rw-r--r-- | core/os/os.h | 1 | ||||
-rw-r--r-- | doc/classes/OS.xml | 9 | ||||
-rw-r--r-- | modules/gridmap/doc_classes/GridMap.xml | 7 | ||||
-rw-r--r-- | modules/gridmap/grid_map.cpp | 13 | ||||
-rw-r--r-- | modules/gridmap/grid_map.h | 1 | ||||
-rw-r--r-- | modules/visual_script/visual_script_nodes.cpp | 5 | ||||
-rw-r--r-- | platform/iphone/os_iphone.h | 1 | ||||
-rw-r--r-- | platform/iphone/os_iphone.mm | 10 | ||||
-rw-r--r-- | platform/javascript/javascript_main.cpp | 3 | ||||
-rw-r--r-- | platform/linuxbsd/os_linuxbsd.cpp | 14 | ||||
-rw-r--r-- | platform/linuxbsd/os_linuxbsd.h | 1 | ||||
-rw-r--r-- | platform/osx/os_osx.h | 1 | ||||
-rw-r--r-- | platform/osx/os_osx.mm | 11 | ||||
-rw-r--r-- | platform/windows/os_windows.cpp | 20 | ||||
-rw-r--r-- | platform/windows/os_windows.h | 1 | ||||
-rw-r--r-- | servers/rendering/renderer_rd/renderer_scene_sky_rd.h | 2 |
19 files changed, 103 insertions, 7 deletions
diff --git a/core/core_bind.cpp b/core/core_bind.cpp index b31cc18b7a..810284d5d0 100644 --- a/core/core_bind.cpp +++ b/core/core_bind.cpp @@ -362,6 +362,10 @@ int OS::get_processor_count() const { return ::OS::get_singleton()->get_processor_count(); } +String OS::get_processor_name() const { + return ::OS::get_singleton()->get_processor_name(); +} + bool OS::is_stdout_verbose() const { return ::OS::get_singleton()->is_stdout_verbose(); } @@ -554,6 +558,7 @@ void OS::_bind_methods() { ClassDB::bind_method(D_METHOD("get_low_processor_usage_mode_sleep_usec"), &OS::get_low_processor_usage_mode_sleep_usec); ClassDB::bind_method(D_METHOD("get_processor_count"), &OS::get_processor_count); + ClassDB::bind_method(D_METHOD("get_processor_name"), &OS::get_processor_name); ClassDB::bind_method(D_METHOD("get_executable_path"), &OS::get_executable_path); ClassDB::bind_method(D_METHOD("execute", "path", "arguments", "output", "read_stderr", "open_console"), &OS::execute, DEFVAL(Array()), DEFVAL(false), DEFVAL(false)); diff --git a/core/core_bind.h b/core/core_bind.h index 21a1fc2077..1ed243206b 100644 --- a/core/core_bind.h +++ b/core/core_bind.h @@ -218,6 +218,7 @@ public: bool is_stdout_verbose() const; int get_processor_count() const; + String get_processor_name() const; enum SystemDir { SYSTEM_DIR_DESKTOP, diff --git a/core/os/os.cpp b/core/os/os.cpp index 0032e8e4bc..9558a6978e 100644 --- a/core/os/os.cpp +++ b/core/os/os.cpp @@ -358,6 +358,10 @@ int OS::get_processor_count() const { return 1; } +String OS::get_processor_name() const { + return ""; +} + bool OS::can_use_threads() const { #ifdef NO_THREADS return false; diff --git a/core/os/os.h b/core/os/os.h index 188900a070..808d704b3d 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -302,6 +302,7 @@ public: virtual void set_exit_code(int p_code); virtual int get_processor_count() const; + virtual String get_processor_name() const; virtual int get_default_thread_pool_size() const { return get_processor_count(); } virtual String get_unique_id() const; diff --git a/doc/classes/OS.xml b/doc/classes/OS.xml index 13a19206b3..bc9bfc9676 100644 --- a/doc/classes/OS.xml +++ b/doc/classes/OS.xml @@ -343,7 +343,14 @@ <method name="get_processor_count" qualifiers="const"> <return type="int" /> <description> - Returns the number of threads available on the host machine. + Returns the number of [i]logical[/i] CPU cores available on the host machine. On CPUs with HyperThreading enabled, this number will be greater than the number of [i]physical[/i] CPU cores. + </description> + </method> + <method name="get_processor_name" qualifiers="const"> + <return type="String" /> + <description> + Returns the name of the CPU model on the host machine (e.g. "Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz"). + [b]Note:[/b] This method is only implemented on Windows, macOS, Linux and iOS. On Android, HTML5 and UWP, [method get_processor_name] returns an empty string. </description> </method> <method name="get_static_memory_peak_usage" qualifiers="const"> diff --git a/modules/gridmap/doc_classes/GridMap.xml b/modules/gridmap/doc_classes/GridMap.xml index 2ea9a78970..049d372671 100644 --- a/modules/gridmap/doc_classes/GridMap.xml +++ b/modules/gridmap/doc_classes/GridMap.xml @@ -79,6 +79,13 @@ Returns an array of [Vector3] with the non-empty cell coordinates in the grid map. </description> </method> + <method name="get_used_cells_by_item" qualifiers="const"> + <return type="Array" /> + <argument index="0" name="item" type="int" /> + <description> + Returns an array of all cells with the given item index specified in [code]item[/code]. + </description> + </method> <method name="make_baked_meshes"> <return type="void" /> <argument index="0" name="gen_lightmap_uv" type="bool" default="false" /> diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cpp index 6df7835855..4b72c71a5a 100644 --- a/modules/gridmap/grid_map.cpp +++ b/modules/gridmap/grid_map.cpp @@ -878,6 +878,7 @@ void GridMap::_bind_methods() { ClassDB::bind_method(D_METHOD("clear"), &GridMap::clear); ClassDB::bind_method(D_METHOD("get_used_cells"), &GridMap::get_used_cells); + ClassDB::bind_method(D_METHOD("get_used_cells_by_item", "item"), &GridMap::get_used_cells_by_item); ClassDB::bind_method(D_METHOD("get_meshes"), &GridMap::get_meshes); ClassDB::bind_method(D_METHOD("get_bake_meshes"), &GridMap::get_bake_meshes); @@ -950,6 +951,18 @@ Array GridMap::get_used_cells() const { return a; } +Array GridMap::get_used_cells_by_item(int p_item) const { + Array a; + for (const KeyValue<IndexKey, Cell> &E : cell_map) { + if (E.value.item == p_item) { + Vector3 p(E.key.x, E.key.y, E.key.z); + a.push_back(p); + } + } + + return a; +} + Array GridMap::get_meshes() const { if (mesh_library.is_null()) { return Array(); diff --git a/modules/gridmap/grid_map.h b/modules/gridmap/grid_map.h index 6cdc3b178d..83d5af1324 100644 --- a/modules/gridmap/grid_map.h +++ b/modules/gridmap/grid_map.h @@ -266,6 +266,7 @@ public: float get_cell_scale() const; Array get_used_cells() const; + Array get_used_cells_by_item(int p_item) const; Array get_meshes() const; diff --git a/modules/visual_script/visual_script_nodes.cpp b/modules/visual_script/visual_script_nodes.cpp index e7f4e542c1..e672267b00 100644 --- a/modules/visual_script/visual_script_nodes.cpp +++ b/modules/visual_script/visual_script_nodes.cpp @@ -1784,10 +1784,7 @@ public: virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) { bool valid; - // *p_output[0] points to the same place as *p_inputs[2] so we need a temp to store the value before the change in the next line - Variant temp = *p_inputs[2]; - *p_outputs[0] = *p_inputs[0]; - p_outputs[0]->set(*p_inputs[1], temp, &valid); + ((Variant *)p_inputs[0])->set(*p_inputs[1], *p_inputs[2], &valid); if (!valid) { r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD; diff --git a/platform/iphone/os_iphone.h b/platform/iphone/os_iphone.h index aca6f5fe2b..3281ff0cdb 100644 --- a/platform/iphone/os_iphone.h +++ b/platform/iphone/os_iphone.h @@ -109,6 +109,7 @@ public: virtual String get_locale() const override; virtual String get_unique_id() const override; + virtual String get_processor_name() const override; virtual void vibrate_handheld(int p_duration_ms = 500) override; diff --git a/platform/iphone/os_iphone.mm b/platform/iphone/os_iphone.mm index 8350365d88..9fb6426b21 100644 --- a/platform/iphone/os_iphone.mm +++ b/platform/iphone/os_iphone.mm @@ -45,6 +45,7 @@ #import <AudioToolbox/AudioServices.h> #import <UIKit/UIKit.h> #import <dlfcn.h> +#include <sys/sysctl.h> #if defined(VULKAN_ENABLED) #include "servers/rendering/renderer_rd/renderer_compositor_rd.h" @@ -287,6 +288,15 @@ String OSIPhone::get_unique_id() const { return String::utf8([uuid UTF8String]); } +String OSIPhone::get_processor_name() const { + char buffer[256]; + size_t buffer_len = 256; + if (sysctlbyname("machdep.cpu.brand_string", &buffer, &buffer_len, NULL, 0) == 0) { + return String::utf8(buffer, buffer_len); + } + ERR_FAIL_V_MSG("", String("Couldn't get the CPU model name. Returning an empty string.")); +} + void OSIPhone::vibrate_handheld(int p_duration_ms) { // iOS does not support duration for vibration AudioServicesPlaySystemSound(kSystemSoundID_Vibrate); diff --git a/platform/javascript/javascript_main.cpp b/platform/javascript/javascript_main.cpp index 5c00476a72..307a80feea 100644 --- a/platform/javascript/javascript_main.cpp +++ b/platform/javascript/javascript_main.cpp @@ -28,6 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ +#include "core/config/engine.h" #include "core/io/resource_loader.h" #include "main/main.h" #include "platform/javascript/display_server_javascript.h" @@ -94,7 +95,7 @@ extern EMSCRIPTEN_KEEPALIVE int godot_js_main(int argc, char *argv[]) { Main::start(); os->get_main_loop()->initialize(); #ifdef TOOLS_ENABLED - if (Main::is_project_manager() && FileAccess::exists("/tmp/preload.zip")) { + if (Engine::get_singleton()->is_project_manager_hint() && FileAccess::exists("/tmp/preload.zip")) { PackedStringArray ps; ps.push_back("/tmp/preload.zip"); os->get_main_loop()->emit_signal(SNAME("files_dropped"), ps, -1); diff --git a/platform/linuxbsd/os_linuxbsd.cpp b/platform/linuxbsd/os_linuxbsd.cpp index e95a865636..5e8656c79f 100644 --- a/platform/linuxbsd/os_linuxbsd.cpp +++ b/platform/linuxbsd/os_linuxbsd.cpp @@ -141,6 +141,20 @@ String OS_LinuxBSD::get_unique_id() const { return machine_id; } +String OS_LinuxBSD::get_processor_name() const { + FileAccessRef f = FileAccess::open("/proc/cpuinfo", FileAccess::READ); + ERR_FAIL_COND_V_MSG(!f, "", String("Couldn't open `/proc/cpuinfo` to get the CPU model name. Returning an empty string.")); + + while (!f->eof_reached()) { + const String line = f->get_line(); + if (line.find("model name") != -1) { + return line.split(":")[1].strip_edges(); + } + } + + ERR_FAIL_V_MSG("", String("Couldn't get the CPU model name from `/proc/cpuinfo`. Returning an empty string.")); +} + void OS_LinuxBSD::finalize() { if (main_loop) { memdelete(main_loop); diff --git a/platform/linuxbsd/os_linuxbsd.h b/platform/linuxbsd/os_linuxbsd.h index d97a528ece..d3857e85f8 100644 --- a/platform/linuxbsd/os_linuxbsd.h +++ b/platform/linuxbsd/os_linuxbsd.h @@ -87,6 +87,7 @@ public: virtual Error shell_open(String p_uri) override; virtual String get_unique_id() const override; + virtual String get_processor_name() const override; virtual void alert(const String &p_alert, const String &p_title = "ALERT!") override; diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h index 5bb5b3320e..53c5c8bd90 100644 --- a/platform/osx/os_osx.h +++ b/platform/osx/os_osx.h @@ -102,6 +102,7 @@ public: virtual Error create_instance(const List<String> &p_arguments, ProcessID *r_child_id = nullptr) override; virtual String get_unique_id() const override; + virtual String get_processor_name() const override; virtual bool _check_internal_feature_support(const String &p_feature) override; diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index 9288e658cf..868721e875 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -42,6 +42,8 @@ #include <dlfcn.h> #include <libproc.h> #include <mach-o/dyld.h> +#include <os/log.h> +#include <sys/sysctl.h> _FORCE_INLINE_ String OS_OSX::get_framework_executable(const String &p_path) { // Append framework executable name, or return as is if p_path is not a framework. @@ -72,6 +74,15 @@ void OS_OSX::initialize() { initialize_core(); } +String OS_OSX::get_processor_name() const { + char buffer[256]; + size_t buffer_len = 256; + if (sysctlbyname("machdep.cpu.brand_string", &buffer, &buffer_len, NULL, 0) == 0) { + return String::utf8(buffer, buffer_len); + } + ERR_FAIL_V_MSG("", String("Couldn't get the CPU model name. Returning an empty string.")); +} + void OS_OSX::initialize_core() { OS_Unix::initialize_core(); diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 59f55b5dd2..99c9712834 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -625,6 +625,26 @@ int OS_Windows::get_processor_count() const { return sysinfo.dwNumberOfProcessors; } +String OS_Windows::get_processor_name() const { + const String id = "Hardware\\Description\\System\\CentralProcessor\\0"; + + HKEY hkey; + if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, (LPCWSTR)(id.utf16().get_data()), 0, KEY_QUERY_VALUE, &hkey) != ERROR_SUCCESS) { + ERR_FAIL_V_MSG("", String("Couldn't get the CPU model name. Returning an empty string.")); + } + + WCHAR buffer[256]; + DWORD buffer_len = 256; + DWORD vtype = REG_SZ; + if (RegQueryValueExW(hkey, L"ProcessorNameString", NULL, &vtype, (LPBYTE)buffer, &buffer_len) == ERROR_SUCCESS) { + RegCloseKey(hkey); + return String::utf16((const char16_t *)buffer, buffer_len).strip_edges(); + } else { + RegCloseKey(hkey); + ERR_FAIL_V_MSG("", String("Couldn't get the CPU model name. Returning an empty string.")); + } +} + void OS_Windows::run() { if (!main_loop) return; diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h index bde663a27b..5bfd24327e 100644 --- a/platform/windows/os_windows.h +++ b/platform/windows/os_windows.h @@ -142,6 +142,7 @@ public: virtual String get_locale() const override; virtual int get_processor_count() const override; + virtual String get_processor_name() const override; virtual String get_config_path() const override; virtual String get_data_path() const override; diff --git a/servers/rendering/renderer_rd/renderer_scene_sky_rd.h b/servers/rendering/renderer_rd/renderer_scene_sky_rd.h index 13d24e2508..7b6c813d90 100644 --- a/servers/rendering/renderer_rd/renderer_scene_sky_rd.h +++ b/servers/rendering/renderer_rd/renderer_scene_sky_rd.h @@ -254,7 +254,7 @@ public: int radiance_size = 256; - RS::SkyMode mode = RS::SKY_MODE_AUTOMATIC; + RS::SkyMode mode = RS::SKY_MODE_REALTIME; ReflectionData reflection; bool dirty = false; |