2023-01-05 13:25:55 +01:00
|
|
|
/**************************************************************************/
|
|
|
|
/* core_bind.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. */
|
|
|
|
/**************************************************************************/
|
2018-01-05 00:50:27 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
#ifndef CORE_BIND_H
|
|
|
|
#define CORE_BIND_H
|
|
|
|
|
2022-02-06 01:55:58 +01:00
|
|
|
#include "core/debugger/engine_profiler.h"
|
2020-11-07 23:33:38 +01:00
|
|
|
#include "core/io/image.h"
|
2018-09-11 18:13:45 +02:00
|
|
|
#include "core/io/resource_loader.h"
|
|
|
|
#include "core/io/resource_saver.h"
|
2022-03-26 16:48:43 +01:00
|
|
|
#include "core/object/script_language.h"
|
2018-09-11 18:13:45 +02:00
|
|
|
#include "core/os/os.h"
|
|
|
|
#include "core/os/semaphore.h"
|
|
|
|
#include "core/os/thread.h"
|
2021-02-10 19:22:13 +01:00
|
|
|
#include "core/templates/safe_refcount.h"
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2021-08-13 16:46:14 +02:00
|
|
|
class MainLoop;
|
2022-08-05 03:41:48 +02:00
|
|
|
template <typename T>
|
|
|
|
class TypedArray;
|
2021-08-13 16:46:14 +02:00
|
|
|
|
|
|
|
namespace core_bind {
|
|
|
|
|
|
|
|
class ResourceLoader : public Object {
|
|
|
|
GDCLASS(ResourceLoader, Object);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
2021-08-13 16:46:14 +02:00
|
|
|
static ResourceLoader *singleton;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
public:
|
2020-02-28 12:27:04 +01:00
|
|
|
enum ThreadLoadStatus {
|
|
|
|
THREAD_LOAD_INVALID_RESOURCE,
|
|
|
|
THREAD_LOAD_IN_PROGRESS,
|
|
|
|
THREAD_LOAD_FAILED,
|
|
|
|
THREAD_LOAD_LOADED
|
|
|
|
};
|
|
|
|
|
2021-02-11 18:18:45 +01:00
|
|
|
enum CacheMode {
|
2024-02-22 12:53:19 +01:00
|
|
|
CACHE_MODE_IGNORE,
|
|
|
|
CACHE_MODE_REUSE,
|
|
|
|
CACHE_MODE_REPLACE,
|
|
|
|
CACHE_MODE_IGNORE_DEEP,
|
|
|
|
CACHE_MODE_REPLACE_DEEP,
|
2021-02-11 18:18:45 +01:00
|
|
|
};
|
|
|
|
|
2021-08-13 16:46:14 +02:00
|
|
|
static ResourceLoader *get_singleton() { return singleton; }
|
2020-02-28 12:27:04 +01:00
|
|
|
|
2021-11-07 18:47:53 +01:00
|
|
|
Error load_threaded_request(const String &p_path, const String &p_type_hint = "", bool p_use_sub_threads = false, CacheMode p_cache_mode = CACHE_MODE_REUSE);
|
2024-06-08 01:55:58 +02:00
|
|
|
ThreadLoadStatus load_threaded_get_status(const String &p_path, Array r_progress = ClassDB::default_array_arg);
|
2022-05-03 01:43:50 +02:00
|
|
|
Ref<Resource> load_threaded_get(const String &p_path);
|
2020-02-28 12:27:04 +01:00
|
|
|
|
2022-05-03 01:43:50 +02:00
|
|
|
Ref<Resource> load(const String &p_path, const String &p_type_hint = "", CacheMode p_cache_mode = CACHE_MODE_REUSE);
|
2020-02-17 22:06:54 +01:00
|
|
|
Vector<String> get_recognized_extensions_for_type(const String &p_type);
|
2022-05-15 15:42:27 +02:00
|
|
|
void add_resource_format_loader(Ref<ResourceFormatLoader> p_format_loader, bool p_at_front);
|
|
|
|
void remove_resource_format_loader(Ref<ResourceFormatLoader> p_format_loader);
|
2014-02-10 02:10:30 +01:00
|
|
|
void set_abort_on_missing_resources(bool p_abort);
|
2020-02-17 22:06:54 +01:00
|
|
|
PackedStringArray get_dependencies(const String &p_path);
|
2018-08-10 20:57:43 +02:00
|
|
|
bool has_cached(const String &p_path);
|
2024-05-29 04:38:09 +02:00
|
|
|
Ref<Resource> get_cached_ref(const String &p_path);
|
2018-08-10 20:57:43 +02:00
|
|
|
bool exists(const String &p_path, const String &p_type_hint = "");
|
2021-07-30 18:35:19 +02:00
|
|
|
ResourceUID::ID get_resource_uid(const String &p_path);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2021-08-13 16:46:14 +02:00
|
|
|
ResourceLoader() { singleton = this; }
|
2014-02-10 02:10:30 +01:00
|
|
|
};
|
|
|
|
|
2021-08-13 16:46:14 +02:00
|
|
|
class ResourceSaver : public Object {
|
|
|
|
GDCLASS(ResourceSaver, Object);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
2021-08-13 16:46:14 +02:00
|
|
|
static ResourceSaver *singleton;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
public:
|
2014-05-24 06:35:47 +02:00
|
|
|
enum SaverFlags {
|
2022-02-10 20:11:40 +01:00
|
|
|
FLAG_NONE = 0,
|
2017-03-05 16:44:50 +01:00
|
|
|
FLAG_RELATIVE_PATHS = 1,
|
|
|
|
FLAG_BUNDLE_RESOURCES = 2,
|
|
|
|
FLAG_CHANGE_PATH = 4,
|
|
|
|
FLAG_OMIT_EDITOR_PROPERTIES = 8,
|
|
|
|
FLAG_SAVE_BIG_ENDIAN = 16,
|
|
|
|
FLAG_COMPRESS = 32,
|
2018-10-18 16:58:44 +02:00
|
|
|
FLAG_REPLACE_SUBRESOURCE_PATHS = 64,
|
2014-05-24 06:35:47 +02:00
|
|
|
};
|
|
|
|
|
2021-08-13 16:46:14 +02:00
|
|
|
static ResourceSaver *get_singleton() { return singleton; }
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2022-06-03 01:33:42 +02:00
|
|
|
Error save(const Ref<Resource> &p_resource, const String &p_path, BitField<SaverFlags> p_flags);
|
2022-05-03 01:43:50 +02:00
|
|
|
Vector<String> get_recognized_extensions(const Ref<Resource> &p_resource);
|
2022-05-15 15:42:27 +02:00
|
|
|
void add_resource_format_saver(Ref<ResourceFormatSaver> p_format_saver, bool p_at_front);
|
|
|
|
void remove_resource_format_saver(Ref<ResourceFormatSaver> p_format_saver);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2021-08-13 16:46:14 +02:00
|
|
|
ResourceSaver() { singleton = this; }
|
2014-02-10 02:10:30 +01:00
|
|
|
};
|
|
|
|
|
2021-08-13 16:46:14 +02:00
|
|
|
class OS : public Object {
|
|
|
|
GDCLASS(OS, Object);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2023-05-05 15:23:25 +02:00
|
|
|
mutable HashMap<String, bool> feature_cache;
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
2021-08-13 16:46:14 +02:00
|
|
|
static OS *singleton;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2024-07-16 13:38:01 +02:00
|
|
|
#ifndef DISABLE_DEPRECATED
|
|
|
|
Dictionary _execute_with_pipe_bind_compat_94434(const String &p_path, const Vector<String> &p_arguments);
|
|
|
|
|
|
|
|
static void _bind_compatibility_methods();
|
|
|
|
#endif
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
public:
|
2022-10-11 10:32:13 +02:00
|
|
|
enum RenderingDriver {
|
|
|
|
RENDERING_DRIVER_VULKAN,
|
|
|
|
RENDERING_DRIVER_OPENGL3,
|
2023-01-09 16:56:16 +01:00
|
|
|
RENDERING_DRIVER_D3D12,
|
2024-02-19 19:52:00 +01:00
|
|
|
RENDERING_DRIVER_METAL,
|
2019-02-16 14:40:52 +01:00
|
|
|
};
|
|
|
|
|
2024-06-14 02:30:32 +02:00
|
|
|
PackedByteArray get_entropy(int p_bytes);
|
2024-06-10 15:35:50 +02:00
|
|
|
String get_system_ca_certificates();
|
|
|
|
|
2020-02-17 22:06:54 +01:00
|
|
|
virtual PackedStringArray get_connected_midi_inputs();
|
2018-08-04 02:17:33 +02:00
|
|
|
virtual void open_midi_inputs();
|
|
|
|
virtual void close_midi_inputs();
|
2018-07-14 14:11:28 +02:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
void set_low_processor_usage_mode(bool p_enabled);
|
|
|
|
bool is_in_low_processor_usage_mode() const;
|
|
|
|
|
2019-11-08 18:36:06 +01:00
|
|
|
void set_low_processor_usage_mode_sleep_usec(int p_usec);
|
|
|
|
int get_low_processor_usage_mode_sleep_usec() const;
|
|
|
|
|
2021-09-01 16:47:12 +02:00
|
|
|
void set_delta_smoothing(bool p_enabled);
|
|
|
|
bool is_delta_smoothing_enabled() const;
|
|
|
|
|
2021-07-22 18:23:48 +02:00
|
|
|
void alert(const String &p_alert, const String &p_title = "ALERT!");
|
2021-12-03 20:36:47 +01:00
|
|
|
void crash(const String &p_message);
|
2021-07-22 18:23:48 +02:00
|
|
|
|
2022-07-08 14:38:30 +02:00
|
|
|
Vector<String> get_system_fonts() const;
|
2022-11-21 14:04:01 +01:00
|
|
|
String get_system_font_path(const String &p_font_name, int p_weight = 400, int p_stretch = 100, bool p_italic = false) const;
|
|
|
|
Vector<String> get_system_font_path_for_text(const String &p_font_name, const String &p_text, const String &p_locale = String(), const String &p_script = String(), int p_weight = 400, int p_stretch = 100, bool p_italic = false) const;
|
2014-02-10 02:10:30 +01:00
|
|
|
String get_executable_path() const;
|
2022-12-29 21:06:11 +01:00
|
|
|
String read_string_from_stdin();
|
2024-06-08 01:55:58 +02:00
|
|
|
int execute(const String &p_path, const Vector<String> &p_arguments, Array r_output = ClassDB::default_array_arg, bool p_read_stderr = false, bool p_open_console = false);
|
2024-07-16 13:38:01 +02:00
|
|
|
Dictionary execute_with_pipe(const String &p_path, const Vector<String> &p_arguments, bool p_blocking = true);
|
2021-12-16 14:00:55 +01:00
|
|
|
int create_process(const String &p_path, const Vector<String> &p_arguments, bool p_open_console = false);
|
2021-11-01 10:12:52 +01:00
|
|
|
int create_instance(const Vector<String> &p_arguments);
|
2014-02-10 02:10:30 +01:00
|
|
|
Error kill(int p_pid);
|
2024-01-09 02:36:19 +01:00
|
|
|
Error shell_open(const String &p_uri);
|
|
|
|
Error shell_show_in_file_manager(const String &p_path, bool p_open_folder = true);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2021-08-13 05:36:23 +02:00
|
|
|
bool is_process_running(int p_pid) const;
|
2024-04-07 20:19:46 +02:00
|
|
|
int get_process_exit_code(int p_pid) const;
|
2017-08-07 12:17:31 +02:00
|
|
|
int get_process_id() const;
|
2014-04-05 17:39:30 +02:00
|
|
|
|
2021-05-12 03:12:59 +02:00
|
|
|
void set_restart_on_exit(bool p_restart, const Vector<String> &p_restart_arguments = Vector<String>());
|
|
|
|
bool is_restart_on_exit_set() const;
|
|
|
|
Vector<String> get_restart_on_exit_arguments() const;
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
bool has_environment(const String &p_var) const;
|
|
|
|
String get_environment(const String &p_var) const;
|
2023-01-16 14:26:14 +01:00
|
|
|
void set_environment(const String &p_var, const String &p_value) const;
|
|
|
|
void unset_environment(const String &p_var) const;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
String get_name() const;
|
2022-09-16 11:14:14 +02:00
|
|
|
String get_distribution_name() const;
|
|
|
|
String get_version() const;
|
2014-02-10 02:10:30 +01:00
|
|
|
Vector<String> get_cmdline_args();
|
2022-07-29 15:30:52 +02:00
|
|
|
Vector<String> get_cmdline_user_args();
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2022-10-11 12:39:41 +02:00
|
|
|
Vector<String> get_video_adapter_driver_info() const;
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
String get_locale() const;
|
2021-09-16 09:27:56 +02:00
|
|
|
String get_locale_language() const;
|
2016-07-02 20:52:36 +02:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
String get_model_name() const;
|
|
|
|
|
2014-11-02 15:31:01 +01:00
|
|
|
bool is_debug_build() const;
|
|
|
|
|
2017-08-07 12:17:31 +02:00
|
|
|
String get_unique_id() const;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2021-08-13 23:31:57 +02:00
|
|
|
String get_keycode_string(Key p_code) const;
|
|
|
|
bool is_keycode_unicode(char32_t p_unicode) const;
|
|
|
|
Key find_keycode_from_string(const String &p_code) const;
|
2015-05-17 18:11:55 +02:00
|
|
|
|
2014-08-02 03:10:38 +02:00
|
|
|
void set_use_file_access_save_and_swap(bool p_enable);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2019-01-30 19:07:46 +01:00
|
|
|
uint64_t get_static_memory_usage() const;
|
|
|
|
uint64_t get_static_memory_peak_usage() const;
|
2023-04-03 10:46:29 +02:00
|
|
|
Dictionary get_memory_info() const;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2021-02-18 21:59:09 +01:00
|
|
|
void delay_usec(int p_usec) const;
|
|
|
|
void delay_msec(int p_msec) const;
|
2021-10-26 08:44:50 +02:00
|
|
|
uint64_t get_ticks_msec() const;
|
2018-06-17 18:10:41 +02:00
|
|
|
uint64_t get_ticks_usec() const;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-10-02 16:09:24 +02:00
|
|
|
bool is_userfs_persistent() const;
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
bool is_stdout_verbose() const;
|
|
|
|
|
|
|
|
int get_processor_count() const;
|
2020-12-27 01:50:21 +01:00
|
|
|
String get_processor_name() const;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2014-12-02 18:02:41 +01:00
|
|
|
enum SystemDir {
|
|
|
|
SYSTEM_DIR_DESKTOP,
|
|
|
|
SYSTEM_DIR_DCIM,
|
|
|
|
SYSTEM_DIR_DOCUMENTS,
|
|
|
|
SYSTEM_DIR_DOWNLOADS,
|
|
|
|
SYSTEM_DIR_MOVIES,
|
|
|
|
SYSTEM_DIR_MUSIC,
|
|
|
|
SYSTEM_DIR_PICTURES,
|
|
|
|
SYSTEM_DIR_RINGTONES,
|
|
|
|
};
|
|
|
|
|
2021-07-11 03:39:31 +02:00
|
|
|
String get_system_dir(SystemDir p_dir, bool p_shared_storage = true) const;
|
2014-12-02 18:02:41 +01:00
|
|
|
|
2022-04-26 23:52:20 +02:00
|
|
|
Error move_to_trash(const String &p_path) const;
|
2017-11-17 15:25:22 +01:00
|
|
|
String get_user_data_dir() const;
|
2021-05-07 19:36:32 +02:00
|
|
|
String get_config_dir() const;
|
|
|
|
String get_data_dir() const;
|
|
|
|
String get_cache_dir() const;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
Error set_thread_name(const String &p_name);
|
2023-07-14 17:12:39 +02:00
|
|
|
::Thread::ID get_thread_caller_id() const;
|
|
|
|
::Thread::ID get_main_thread_id() const;
|
2016-02-01 00:22:38 +01:00
|
|
|
|
2017-10-02 21:38:39 +02:00
|
|
|
bool has_feature(const String &p_feature) const;
|
2021-03-30 14:42:50 +02:00
|
|
|
bool is_sandboxed() const;
|
2017-10-02 21:38:39 +02:00
|
|
|
|
2019-03-05 03:06:37 +01:00
|
|
|
bool request_permission(const String &p_name);
|
2019-10-06 20:17:44 +02:00
|
|
|
bool request_permissions();
|
|
|
|
Vector<String> get_granted_permissions() const;
|
2021-03-30 14:42:50 +02:00
|
|
|
void revoke_granted_permissions();
|
2019-03-05 03:06:37 +01:00
|
|
|
|
2021-08-13 16:46:14 +02:00
|
|
|
static OS *get_singleton() { return singleton; }
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2021-08-13 16:46:14 +02:00
|
|
|
OS() { singleton = this; }
|
2014-02-10 02:10:30 +01:00
|
|
|
};
|
|
|
|
|
2021-08-13 16:46:14 +02:00
|
|
|
class Geometry2D : public Object {
|
|
|
|
GDCLASS(Geometry2D, Object);
|
2014-12-02 18:02:41 +01:00
|
|
|
|
2021-08-13 16:46:14 +02:00
|
|
|
static Geometry2D *singleton;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
protected:
|
2014-02-10 02:10:30 +01:00
|
|
|
static void _bind_methods();
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
public:
|
2021-08-13 16:46:14 +02:00
|
|
|
static Geometry2D *get_singleton();
|
2020-05-25 19:20:45 +02:00
|
|
|
Variant segment_intersects_segment(const Vector2 &p_from_a, const Vector2 &p_to_a, const Vector2 &p_from_b, const Vector2 &p_to_b);
|
|
|
|
Variant line_intersects_line(const Vector2 &p_from_a, const Vector2 &p_dir_a, const Vector2 &p_from_b, const Vector2 &p_dir_b);
|
|
|
|
Vector<Vector2> get_closest_points_between_segments(const Vector2 &p1, const Vector2 &q1, const Vector2 &p2, const Vector2 &q2);
|
|
|
|
Vector2 get_closest_point_to_segment(const Vector2 &p_point, const Vector2 &p_a, const Vector2 &p_b);
|
|
|
|
Vector2 get_closest_point_to_segment_uncapped(const Vector2 &p_point, const Vector2 &p_a, const Vector2 &p_b);
|
2017-03-05 16:44:50 +01:00
|
|
|
bool point_is_inside_triangle(const Vector2 &s, const Vector2 &a, const Vector2 &b, const Vector2 &c) const;
|
|
|
|
|
2019-08-25 23:02:16 +02:00
|
|
|
bool is_point_in_circle(const Vector2 &p_point, const Vector2 &p_circle_pos, real_t p_circle_radius);
|
2017-03-05 16:44:50 +01:00
|
|
|
real_t segment_intersects_circle(const Vector2 &p_from, const Vector2 &p_to, const Vector2 &p_circle_pos, real_t p_circle_radius);
|
|
|
|
|
Expose 2D polygon boolean operations in Geometry singleton
Clipper 6.4.2 is used internally to perform polypaths clipping, as well
as inflating/deflating polypaths. The following methods were added:
```
Geometry.merge_polygons_2d(poly_a, poly_b) # union
Geometry.clip_polygons_2d(poly_a, poly_b) # difference
Geometry.intersect_polygons_2d(poly_a, poly_b) # intersection
Geometry.exclude_polygons_2d(poly_a, poly_b) # xor
Geometry.clip_polyline_with_polygon_2d(poly_a, poly_b)
Geometry.intersect_polyline_with_polygon_2d(poly_a, poly_b)
Geometry.offset_polygon_2d(polygon, delta) # inflate/deflate
Geometry.offset_polyline_2d(polyline, delta) # returns polygons
// This one helps to implement CSG-like behaviour:
Geometry.transform_points_2d(points, transform)
```
All the methods return an array of polygons/polylines. The resulting
polygons could possibly be holes which could be checked with
`Geometry.is_polygon_clockwise()` which was exposed to scripting as well.
2019-05-18 19:01:42 +02:00
|
|
|
bool is_polygon_clockwise(const Vector<Vector2> &p_polygon);
|
2019-06-26 23:20:22 +02:00
|
|
|
bool is_point_in_polygon(const Point2 &p_point, const Vector<Vector2> &p_polygon);
|
2017-03-05 16:44:50 +01:00
|
|
|
Vector<int> triangulate_polygon(const Vector<Vector2> &p_polygon);
|
2020-05-25 19:20:45 +02:00
|
|
|
Vector<int> triangulate_delaunay(const Vector<Vector2> &p_points);
|
|
|
|
Vector<Point2> convex_hull(const Vector<Point2> &p_points);
|
2022-09-19 12:09:56 +02:00
|
|
|
TypedArray<PackedVector2Array> decompose_polygon_in_convex(const Vector<Vector2> &p_polygon);
|
2017-03-05 16:44:50 +01:00
|
|
|
|
Expose 2D polygon boolean operations in Geometry singleton
Clipper 6.4.2 is used internally to perform polypaths clipping, as well
as inflating/deflating polypaths. The following methods were added:
```
Geometry.merge_polygons_2d(poly_a, poly_b) # union
Geometry.clip_polygons_2d(poly_a, poly_b) # difference
Geometry.intersect_polygons_2d(poly_a, poly_b) # intersection
Geometry.exclude_polygons_2d(poly_a, poly_b) # xor
Geometry.clip_polyline_with_polygon_2d(poly_a, poly_b)
Geometry.intersect_polyline_with_polygon_2d(poly_a, poly_b)
Geometry.offset_polygon_2d(polygon, delta) # inflate/deflate
Geometry.offset_polyline_2d(polyline, delta) # returns polygons
// This one helps to implement CSG-like behaviour:
Geometry.transform_points_2d(points, transform)
```
All the methods return an array of polygons/polylines. The resulting
polygons could possibly be holes which could be checked with
`Geometry.is_polygon_clockwise()` which was exposed to scripting as well.
2019-05-18 19:01:42 +02:00
|
|
|
enum PolyBooleanOperation {
|
|
|
|
OPERATION_UNION,
|
|
|
|
OPERATION_DIFFERENCE,
|
|
|
|
OPERATION_INTERSECTION,
|
|
|
|
OPERATION_XOR
|
|
|
|
};
|
2019-08-25 23:02:16 +02:00
|
|
|
// 2D polygon boolean operations.
|
2022-08-05 20:35:08 +02:00
|
|
|
TypedArray<PackedVector2Array> merge_polygons(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // Union (add).
|
|
|
|
TypedArray<PackedVector2Array> clip_polygons(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // Difference (subtract).
|
|
|
|
TypedArray<PackedVector2Array> intersect_polygons(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // Common area (multiply).
|
|
|
|
TypedArray<PackedVector2Array> exclude_polygons(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // All but common area (xor).
|
Expose 2D polygon boolean operations in Geometry singleton
Clipper 6.4.2 is used internally to perform polypaths clipping, as well
as inflating/deflating polypaths. The following methods were added:
```
Geometry.merge_polygons_2d(poly_a, poly_b) # union
Geometry.clip_polygons_2d(poly_a, poly_b) # difference
Geometry.intersect_polygons_2d(poly_a, poly_b) # intersection
Geometry.exclude_polygons_2d(poly_a, poly_b) # xor
Geometry.clip_polyline_with_polygon_2d(poly_a, poly_b)
Geometry.intersect_polyline_with_polygon_2d(poly_a, poly_b)
Geometry.offset_polygon_2d(polygon, delta) # inflate/deflate
Geometry.offset_polyline_2d(polyline, delta) # returns polygons
// This one helps to implement CSG-like behaviour:
Geometry.transform_points_2d(points, transform)
```
All the methods return an array of polygons/polylines. The resulting
polygons could possibly be holes which could be checked with
`Geometry.is_polygon_clockwise()` which was exposed to scripting as well.
2019-05-18 19:01:42 +02:00
|
|
|
|
2019-08-25 23:02:16 +02:00
|
|
|
// 2D polyline vs polygon operations.
|
2022-08-05 20:35:08 +02:00
|
|
|
TypedArray<PackedVector2Array> clip_polyline_with_polygon(const Vector<Vector2> &p_polyline, const Vector<Vector2> &p_polygon); // Cut.
|
|
|
|
TypedArray<PackedVector2Array> intersect_polyline_with_polygon(const Vector<Vector2> &p_polyline, const Vector<Vector2> &p_polygon); // Chop.
|
Expose 2D polygon boolean operations in Geometry singleton
Clipper 6.4.2 is used internally to perform polypaths clipping, as well
as inflating/deflating polypaths. The following methods were added:
```
Geometry.merge_polygons_2d(poly_a, poly_b) # union
Geometry.clip_polygons_2d(poly_a, poly_b) # difference
Geometry.intersect_polygons_2d(poly_a, poly_b) # intersection
Geometry.exclude_polygons_2d(poly_a, poly_b) # xor
Geometry.clip_polyline_with_polygon_2d(poly_a, poly_b)
Geometry.intersect_polyline_with_polygon_2d(poly_a, poly_b)
Geometry.offset_polygon_2d(polygon, delta) # inflate/deflate
Geometry.offset_polyline_2d(polyline, delta) # returns polygons
// This one helps to implement CSG-like behaviour:
Geometry.transform_points_2d(points, transform)
```
All the methods return an array of polygons/polylines. The resulting
polygons could possibly be holes which could be checked with
`Geometry.is_polygon_clockwise()` which was exposed to scripting as well.
2019-05-18 19:01:42 +02:00
|
|
|
|
2019-08-25 23:02:16 +02:00
|
|
|
// 2D offset polygons/polylines.
|
Expose 2D polygon boolean operations in Geometry singleton
Clipper 6.4.2 is used internally to perform polypaths clipping, as well
as inflating/deflating polypaths. The following methods were added:
```
Geometry.merge_polygons_2d(poly_a, poly_b) # union
Geometry.clip_polygons_2d(poly_a, poly_b) # difference
Geometry.intersect_polygons_2d(poly_a, poly_b) # intersection
Geometry.exclude_polygons_2d(poly_a, poly_b) # xor
Geometry.clip_polyline_with_polygon_2d(poly_a, poly_b)
Geometry.intersect_polyline_with_polygon_2d(poly_a, poly_b)
Geometry.offset_polygon_2d(polygon, delta) # inflate/deflate
Geometry.offset_polyline_2d(polyline, delta) # returns polygons
// This one helps to implement CSG-like behaviour:
Geometry.transform_points_2d(points, transform)
```
All the methods return an array of polygons/polylines. The resulting
polygons could possibly be holes which could be checked with
`Geometry.is_polygon_clockwise()` which was exposed to scripting as well.
2019-05-18 19:01:42 +02:00
|
|
|
enum PolyJoinType {
|
|
|
|
JOIN_SQUARE,
|
|
|
|
JOIN_ROUND,
|
|
|
|
JOIN_MITER
|
|
|
|
};
|
|
|
|
enum PolyEndType {
|
|
|
|
END_POLYGON,
|
|
|
|
END_JOINED,
|
|
|
|
END_BUTT,
|
|
|
|
END_SQUARE,
|
|
|
|
END_ROUND
|
|
|
|
};
|
2022-08-05 20:35:08 +02:00
|
|
|
TypedArray<PackedVector2Array> offset_polygon(const Vector<Vector2> &p_polygon, real_t p_delta, PolyJoinType p_join_type = JOIN_SQUARE);
|
|
|
|
TypedArray<PackedVector2Array> offset_polyline(const Vector<Vector2> &p_polygon, real_t p_delta, PolyJoinType p_join_type = JOIN_SQUARE, PolyEndType p_end_type = END_SQUARE);
|
Expose 2D polygon boolean operations in Geometry singleton
Clipper 6.4.2 is used internally to perform polypaths clipping, as well
as inflating/deflating polypaths. The following methods were added:
```
Geometry.merge_polygons_2d(poly_a, poly_b) # union
Geometry.clip_polygons_2d(poly_a, poly_b) # difference
Geometry.intersect_polygons_2d(poly_a, poly_b) # intersection
Geometry.exclude_polygons_2d(poly_a, poly_b) # xor
Geometry.clip_polyline_with_polygon_2d(poly_a, poly_b)
Geometry.intersect_polyline_with_polygon_2d(poly_a, poly_b)
Geometry.offset_polygon_2d(polygon, delta) # inflate/deflate
Geometry.offset_polyline_2d(polyline, delta) # returns polygons
// This one helps to implement CSG-like behaviour:
Geometry.transform_points_2d(points, transform)
```
All the methods return an array of polygons/polylines. The resulting
polygons could possibly be holes which could be checked with
`Geometry.is_polygon_clockwise()` which was exposed to scripting as well.
2019-05-18 19:01:42 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
Dictionary make_atlas(const Vector<Size2> &p_rects);
|
2014-10-03 05:10:51 +02:00
|
|
|
|
2021-08-13 16:46:14 +02:00
|
|
|
Geometry2D() { singleton = this; }
|
2014-02-10 02:10:30 +01:00
|
|
|
};
|
|
|
|
|
2021-08-13 16:46:14 +02:00
|
|
|
class Geometry3D : public Object {
|
|
|
|
GDCLASS(Geometry3D, Object);
|
2020-05-25 19:20:45 +02:00
|
|
|
|
2021-08-13 16:46:14 +02:00
|
|
|
static Geometry3D *singleton;
|
2020-05-25 19:20:45 +02:00
|
|
|
|
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
|
|
|
|
|
|
|
public:
|
2021-08-13 16:46:14 +02:00
|
|
|
static Geometry3D *get_singleton();
|
2023-06-30 13:25:03 +02:00
|
|
|
Vector<Vector3> compute_convex_mesh_points(const TypedArray<Plane> &p_planes);
|
2022-08-05 20:35:08 +02:00
|
|
|
TypedArray<Plane> build_box_planes(const Vector3 &p_extents);
|
|
|
|
TypedArray<Plane> build_cylinder_planes(float p_radius, float p_height, int p_sides, Vector3::Axis p_axis = Vector3::AXIS_Z);
|
|
|
|
TypedArray<Plane> build_capsule_planes(float p_radius, float p_height, int p_sides, int p_lats, Vector3::Axis p_axis = Vector3::AXIS_Z);
|
2020-05-25 19:20:45 +02:00
|
|
|
Vector<Vector3> get_closest_points_between_segments(const Vector3 &p1, const Vector3 &p2, const Vector3 &q1, const Vector3 &q2);
|
|
|
|
Vector3 get_closest_point_to_segment(const Vector3 &p_point, const Vector3 &p_a, const Vector3 &p_b);
|
|
|
|
Vector3 get_closest_point_to_segment_uncapped(const Vector3 &p_point, const Vector3 &p_a, const Vector3 &p_b);
|
2023-03-05 22:59:22 +01:00
|
|
|
Vector3 get_triangle_barycentric_coords(const Vector3 &p_point, const Vector3 &p_v0, const Vector3 &p_v1, const Vector3 &p_v2);
|
2020-05-25 19:20:45 +02:00
|
|
|
Variant ray_intersects_triangle(const Vector3 &p_from, const Vector3 &p_dir, const Vector3 &p_v0, const Vector3 &p_v1, const Vector3 &p_v2);
|
|
|
|
Variant segment_intersects_triangle(const Vector3 &p_from, const Vector3 &p_to, const Vector3 &p_v0, const Vector3 &p_v1, const Vector3 &p_v2);
|
|
|
|
|
|
|
|
Vector<Vector3> segment_intersects_sphere(const Vector3 &p_from, const Vector3 &p_to, const Vector3 &p_sphere_pos, real_t p_sphere_radius);
|
|
|
|
Vector<Vector3> segment_intersects_cylinder(const Vector3 &p_from, const Vector3 &p_to, float p_height, float p_radius);
|
2023-04-25 00:21:32 +02:00
|
|
|
Vector<Vector3> segment_intersects_convex(const Vector3 &p_from, const Vector3 &p_to, const TypedArray<Plane> &p_planes);
|
2020-05-25 19:20:45 +02:00
|
|
|
|
|
|
|
Vector<Vector3> clip_polygon(const Vector<Vector3> &p_points, const Plane &p_plane);
|
2023-10-14 15:18:14 +02:00
|
|
|
Vector<int32_t> tetrahedralize_delaunay(const Vector<Vector3> &p_points);
|
2020-05-25 19:20:45 +02:00
|
|
|
|
2021-08-13 16:46:14 +02:00
|
|
|
Geometry3D() { singleton = this; }
|
2020-05-25 19:20:45 +02:00
|
|
|
};
|
Expose 2D polygon boolean operations in Geometry singleton
Clipper 6.4.2 is used internally to perform polypaths clipping, as well
as inflating/deflating polypaths. The following methods were added:
```
Geometry.merge_polygons_2d(poly_a, poly_b) # union
Geometry.clip_polygons_2d(poly_a, poly_b) # difference
Geometry.intersect_polygons_2d(poly_a, poly_b) # intersection
Geometry.exclude_polygons_2d(poly_a, poly_b) # xor
Geometry.clip_polyline_with_polygon_2d(poly_a, poly_b)
Geometry.intersect_polyline_with_polygon_2d(poly_a, poly_b)
Geometry.offset_polygon_2d(polygon, delta) # inflate/deflate
Geometry.offset_polyline_2d(polyline, delta) # returns polygons
// This one helps to implement CSG-like behaviour:
Geometry.transform_points_2d(points, transform)
```
All the methods return an array of polygons/polylines. The resulting
polygons could possibly be holes which could be checked with
`Geometry.is_polygon_clockwise()` which was exposed to scripting as well.
2019-05-18 19:01:42 +02:00
|
|
|
|
2021-08-13 16:46:14 +02:00
|
|
|
class Marshalls : public Object {
|
|
|
|
GDCLASS(Marshalls, Object);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2021-08-13 16:46:14 +02:00
|
|
|
static Marshalls *singleton;
|
2016-11-05 17:13:04 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
|
|
|
|
|
|
|
public:
|
2021-08-13 16:46:14 +02:00
|
|
|
static Marshalls *get_singleton();
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2019-03-26 16:52:42 +01:00
|
|
|
String variant_to_base64(const Variant &p_var, bool p_full_objects = false);
|
|
|
|
Variant base64_to_variant(const String &p_str, bool p_allow_objects = false);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2020-02-17 22:06:54 +01:00
|
|
|
String raw_to_base64(const Vector<uint8_t> &p_arr);
|
|
|
|
Vector<uint8_t> base64_to_raw(const String &p_str);
|
2015-07-28 12:50:52 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
String utf8_to_base64(const String &p_str);
|
|
|
|
String base64_to_utf8(const String &p_str);
|
2015-07-28 12:50:52 +02:00
|
|
|
|
2021-08-13 16:46:14 +02:00
|
|
|
Marshalls() { singleton = this; }
|
|
|
|
~Marshalls() { singleton = nullptr; }
|
2014-02-10 02:10:30 +01:00
|
|
|
};
|
|
|
|
|
2021-08-13 16:46:14 +02:00
|
|
|
class Mutex : public RefCounted {
|
|
|
|
GDCLASS(Mutex, RefCounted);
|
|
|
|
::Mutex mutex;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
static void _bind_methods();
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
public:
|
2014-02-10 02:10:30 +01:00
|
|
|
void lock();
|
2023-01-27 11:04:41 +01:00
|
|
|
bool try_lock();
|
2014-02-10 02:10:30 +01:00
|
|
|
void unlock();
|
|
|
|
};
|
|
|
|
|
2021-08-13 16:46:14 +02:00
|
|
|
class Semaphore : public RefCounted {
|
|
|
|
GDCLASS(Semaphore, RefCounted);
|
|
|
|
::Semaphore semaphore;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2024-08-27 05:12:10 +02:00
|
|
|
protected:
|
2014-02-10 02:10:30 +01:00
|
|
|
static void _bind_methods();
|
2024-08-27 05:12:10 +02:00
|
|
|
#ifndef DISABLE_DEPRECATED
|
|
|
|
void _post_bind_compat_93605();
|
|
|
|
static void _bind_compatibility_methods();
|
|
|
|
#endif // DISABLE_DEPRECATED
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
public:
|
2020-03-03 09:26:42 +01:00
|
|
|
void wait();
|
2023-01-27 11:04:41 +01:00
|
|
|
bool try_wait();
|
2024-08-27 05:12:10 +02:00
|
|
|
void post(int p_count = 1);
|
2014-02-10 02:10:30 +01:00
|
|
|
};
|
|
|
|
|
2021-08-13 16:46:14 +02:00
|
|
|
class Thread : public RefCounted {
|
|
|
|
GDCLASS(Thread, RefCounted);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
protected:
|
|
|
|
Variant ret;
|
2021-10-06 06:28:24 +02:00
|
|
|
SafeFlag running;
|
2021-09-25 15:07:13 +02:00
|
|
|
Callable target_callable;
|
2021-08-13 16:46:14 +02:00
|
|
|
::Thread thread;
|
2014-02-10 02:10:30 +01:00
|
|
|
static void _bind_methods();
|
|
|
|
static void _start_func(void *ud);
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
public:
|
2014-02-10 02:10:30 +01:00
|
|
|
enum Priority {
|
|
|
|
PRIORITY_LOW,
|
|
|
|
PRIORITY_NORMAL,
|
2019-04-07 18:52:39 +02:00
|
|
|
PRIORITY_HIGH,
|
|
|
|
PRIORITY_MAX
|
2014-02-10 02:10:30 +01:00
|
|
|
};
|
|
|
|
|
2022-06-23 02:15:38 +02:00
|
|
|
Error start(const Callable &p_callable, Priority p_priority = PRIORITY_NORMAL);
|
2014-02-10 02:10:30 +01:00
|
|
|
String get_id() const;
|
2021-10-06 06:28:24 +02:00
|
|
|
bool is_started() const;
|
|
|
|
bool is_alive() const;
|
2014-02-10 02:10:30 +01:00
|
|
|
Variant wait_to_finish();
|
2023-06-08 11:33:35 +02:00
|
|
|
|
|
|
|
static void set_thread_safety_checks_enabled(bool p_enabled);
|
2014-02-10 02:10:30 +01:00
|
|
|
};
|
|
|
|
|
2021-08-13 16:46:14 +02:00
|
|
|
namespace special {
|
2017-08-20 17:45:01 +02:00
|
|
|
|
2021-08-13 16:46:14 +02:00
|
|
|
class ClassDB : public Object {
|
|
|
|
GDCLASS(ClassDB, Object);
|
2017-01-03 03:03:46 +01:00
|
|
|
|
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
public:
|
2020-02-17 22:06:54 +01:00
|
|
|
PackedStringArray get_class_list() const;
|
|
|
|
PackedStringArray get_inheriters_from_class(const StringName &p_class) const;
|
2017-03-05 16:44:50 +01:00
|
|
|
StringName get_parent_class(const StringName &p_class) const;
|
2017-01-03 03:03:46 +01:00
|
|
|
bool class_exists(const StringName &p_class) const;
|
2017-03-05 16:44:50 +01:00
|
|
|
bool is_parent_class(const StringName &p_class, const StringName &p_inherits) const;
|
2021-06-18 00:03:09 +02:00
|
|
|
bool can_instantiate(const StringName &p_class) const;
|
|
|
|
Variant instantiate(const StringName &p_class) const;
|
2017-01-03 03:03:46 +01:00
|
|
|
|
2021-08-01 21:47:20 +02:00
|
|
|
bool class_has_signal(const StringName &p_class, const StringName &p_signal) const;
|
|
|
|
Dictionary class_get_signal(const StringName &p_class, const StringName &p_signal) const;
|
|
|
|
TypedArray<Dictionary> class_get_signal_list(const StringName &p_class, bool p_no_inheritance = false) const;
|
2017-01-03 03:03:46 +01:00
|
|
|
|
2021-08-01 21:47:20 +02:00
|
|
|
TypedArray<Dictionary> class_get_property_list(const StringName &p_class, bool p_no_inheritance = false) const;
|
2024-07-27 05:53:13 +02:00
|
|
|
StringName class_get_property_getter(const StringName &p_class, const StringName &p_property);
|
|
|
|
StringName class_get_property_setter(const StringName &p_class, const StringName &p_property);
|
2023-05-12 13:53:15 +02:00
|
|
|
Variant class_get_property(Object *p_object, const StringName &p_property) const;
|
|
|
|
Error class_set_property(Object *p_object, const StringName &p_property, const Variant &p_value) const;
|
2017-01-03 03:03:46 +01:00
|
|
|
|
2024-04-19 19:51:28 +02:00
|
|
|
Variant class_get_property_default_value(const StringName &p_class, const StringName &p_property) const;
|
|
|
|
|
2021-08-01 21:47:20 +02:00
|
|
|
bool class_has_method(const StringName &p_class, const StringName &p_method, bool p_no_inheritance = false) const;
|
2017-01-03 03:03:46 +01:00
|
|
|
|
2024-01-28 15:16:09 +01:00
|
|
|
int class_get_method_argument_count(const StringName &p_class, const StringName &p_method, bool p_no_inheritance = false) const;
|
|
|
|
|
2021-08-01 21:47:20 +02:00
|
|
|
TypedArray<Dictionary> class_get_method_list(const StringName &p_class, bool p_no_inheritance = false) const;
|
2024-08-23 01:56:29 +02:00
|
|
|
Variant class_call_static_method(const Variant **p_arguments, int p_argcount, Callable::CallError &r_call_error);
|
2017-01-03 03:03:46 +01:00
|
|
|
|
2023-05-12 13:53:15 +02:00
|
|
|
PackedStringArray class_get_integer_constant_list(const StringName &p_class, bool p_no_inheritance = false) const;
|
|
|
|
bool class_has_integer_constant(const StringName &p_class, const StringName &p_name) const;
|
|
|
|
int64_t class_get_integer_constant(const StringName &p_class, const StringName &p_name) const;
|
2017-01-03 03:03:46 +01:00
|
|
|
|
2023-05-12 13:53:15 +02:00
|
|
|
bool class_has_enum(const StringName &p_class, const StringName &p_name, bool p_no_inheritance = false) const;
|
|
|
|
PackedStringArray class_get_enum_list(const StringName &p_class, bool p_no_inheritance = false) const;
|
|
|
|
PackedStringArray class_get_enum_constants(const StringName &p_class, const StringName &p_enum, bool p_no_inheritance = false) const;
|
|
|
|
StringName class_get_integer_constant_enum(const StringName &p_class, const StringName &p_name, bool p_no_inheritance = false) const;
|
2021-09-11 14:31:11 +02:00
|
|
|
|
2024-04-08 01:21:19 +02:00
|
|
|
bool is_class_enum_bitfield(const StringName &p_class, const StringName &p_enum, bool p_no_inheritance = false) const;
|
|
|
|
|
2021-08-01 21:47:20 +02:00
|
|
|
bool is_class_enabled(const StringName &p_class) const;
|
2017-01-03 03:03:46 +01:00
|
|
|
|
2024-01-04 00:20:55 +01:00
|
|
|
#ifdef TOOLS_ENABLED
|
|
|
|
virtual void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const override;
|
|
|
|
#endif
|
|
|
|
|
2021-08-13 16:46:14 +02:00
|
|
|
ClassDB() {}
|
|
|
|
~ClassDB() {}
|
2017-01-03 03:03:46 +01:00
|
|
|
};
|
|
|
|
|
2021-08-13 16:46:14 +02:00
|
|
|
} // namespace special
|
|
|
|
|
|
|
|
class Engine : public Object {
|
|
|
|
GDCLASS(Engine, Object);
|
2017-01-13 16:51:14 +01:00
|
|
|
|
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
2021-08-13 16:46:14 +02:00
|
|
|
static Engine *singleton;
|
2017-01-13 16:51:14 +01:00
|
|
|
|
|
|
|
public:
|
2021-08-13 16:46:14 +02:00
|
|
|
static Engine *get_singleton() { return singleton; }
|
2021-08-11 02:35:16 +02:00
|
|
|
void set_physics_ticks_per_second(int p_ips);
|
|
|
|
int get_physics_ticks_per_second() const;
|
2017-01-13 16:51:14 +01:00
|
|
|
|
2022-09-15 18:57:34 +02:00
|
|
|
void set_max_physics_steps_per_frame(int p_max_physics_steps);
|
|
|
|
int get_max_physics_steps_per_frame() const;
|
|
|
|
|
2021-02-02 03:16:37 +01:00
|
|
|
void set_physics_jitter_fix(double p_threshold);
|
|
|
|
double get_physics_jitter_fix() const;
|
|
|
|
double get_physics_interpolation_fraction() const;
|
Add hysteresis to physics timestep count per frame
Add new class _TimerSync to manage timestep calculations.
The new class handles the decisions about simulation progression
previously handled by main::iteration(). It is fed the current timer
ticks and determines how many physics updates are to be run and what
the delta argument to the _process() functions should be.
The new class tries to keep the number of physics updates per frame as
constant as possible from frame to frame. Ideally, it would be N steps
every render frame, but even with perfectly regular rendering, the
general case is that N or N+1 steps are required per frame, for some
fixed N. The best guess for N is stored in typical_physics_steps.
When determining the number of steps to take, no restrictions are
imposed between the choice of typical_physics_steps and
typical_physics_steps+1 steps. Should more or less steps than that be
required, the accumulated remaining time (as before, stored in
time_accum) needs to surpass its boundaries by some minimal threshold.
Once surpassed, typical_physics_steps is updated to allow the new step
count for future updates.
Care is taken that the modified calculation of the number of physics
steps is not observable from game code that only checks the delta
parameters to the _process and _physics_process functions; in addition
to modifying the number of steps, the _process argument is modified as
well to stay in expected bounds. Extra care is taken that the accumulated
steps still sum up to roughly the real elapsed time, up to a maximum
tolerated difference.
To allow the hysteresis code to work correctly on higher refresh
monitors, the number of typical physics steps is not only recorded and
kept consistent for single render frames, but for groups of them.
Currently, up to 12 frames are grouped that way.
The engine parameter physics_jitter_fix controls both the maximum
tolerated difference between wall clock time and summed up _process
arguments and the threshold for changing typical_physics_steps. It is
given in units of the real physics frame slice 1/physics_fps. Set
physics_jitter_fix to 0 to disable the effects of the new code here.
It starts to be effective against the random physics jitter at around
0.02 to 0.05. at values greater than 1 it starts having ill effects on
the engine's ability to react sensibly to dropped frames and framerate
changes.
2018-02-11 00:03:31 +01:00
|
|
|
|
2022-09-22 22:15:07 +02:00
|
|
|
void set_max_fps(int p_fps);
|
|
|
|
int get_max_fps() const;
|
2017-01-13 16:51:14 +01:00
|
|
|
|
2021-02-02 03:16:37 +01:00
|
|
|
double get_frames_per_second() const;
|
2020-01-13 17:53:10 +01:00
|
|
|
uint64_t get_physics_frames() const;
|
2020-12-22 10:50:29 +01:00
|
|
|
uint64_t get_process_frames() const;
|
2017-01-13 16:51:14 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
int get_frames_drawn();
|
2017-01-13 16:51:14 +01:00
|
|
|
|
2021-02-02 03:16:37 +01:00
|
|
|
void set_time_scale(double p_scale);
|
|
|
|
double get_time_scale();
|
2017-01-13 16:51:14 +01:00
|
|
|
|
|
|
|
MainLoop *get_main_loop() const;
|
|
|
|
|
2017-01-13 18:25:43 +01:00
|
|
|
Dictionary get_version_info() const;
|
2018-05-16 06:54:22 +02:00
|
|
|
Dictionary get_author_info() const;
|
2022-08-05 03:41:48 +02:00
|
|
|
TypedArray<Dictionary> get_copyright_info() const;
|
2018-05-16 06:54:22 +02:00
|
|
|
Dictionary get_donor_info() const;
|
|
|
|
Dictionary get_license_info() const;
|
|
|
|
String get_license_text() const;
|
2017-01-13 16:51:14 +01:00
|
|
|
|
2022-07-20 19:05:49 +02:00
|
|
|
String get_architecture_name() const;
|
|
|
|
|
2017-09-30 16:19:07 +02:00
|
|
|
bool is_in_physics_frame() const;
|
2017-06-13 17:49:28 +02:00
|
|
|
|
2021-08-25 00:03:10 +02:00
|
|
|
bool has_singleton(const StringName &p_name) const;
|
|
|
|
Object *get_singleton_object(const StringName &p_name) const;
|
|
|
|
void register_singleton(const StringName &p_name, Object *p_object);
|
|
|
|
void unregister_singleton(const StringName &p_name);
|
|
|
|
Vector<String> get_singleton_list() const;
|
2017-11-13 21:46:57 +01:00
|
|
|
|
2022-10-09 22:03:59 +02:00
|
|
|
Error register_script_language(ScriptLanguage *p_language);
|
|
|
|
Error unregister_script_language(const ScriptLanguage *p_language);
|
2022-03-26 16:48:43 +01:00
|
|
|
int get_script_language_count();
|
|
|
|
ScriptLanguage *get_script_language(int p_index) const;
|
|
|
|
|
2017-08-13 16:21:45 +02:00
|
|
|
void set_editor_hint(bool p_enabled);
|
|
|
|
bool is_editor_hint() const;
|
|
|
|
|
2022-06-26 01:38:20 +02:00
|
|
|
// `set_write_movie_path()` is not exposed to the scripting API as changing it at run-time has no effect.
|
|
|
|
String get_write_movie_path() const;
|
|
|
|
|
2021-05-01 23:09:48 +02:00
|
|
|
void set_print_error_messages(bool p_enabled);
|
|
|
|
bool is_printing_error_messages() const;
|
|
|
|
|
2024-01-03 12:10:11 +01:00
|
|
|
#ifdef TOOLS_ENABLED
|
2024-01-03 18:29:05 +01:00
|
|
|
virtual void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const override;
|
2024-01-03 12:10:11 +01:00
|
|
|
#endif
|
2024-01-03 18:29:05 +01:00
|
|
|
|
2021-08-13 16:46:14 +02:00
|
|
|
Engine() { singleton = this; }
|
2017-01-13 16:51:14 +01:00
|
|
|
};
|
|
|
|
|
2021-08-13 16:46:14 +02:00
|
|
|
class EngineDebugger : public Object {
|
|
|
|
GDCLASS(EngineDebugger, Object);
|
2020-05-18 16:55:49 +02:00
|
|
|
|
2022-05-13 15:04:37 +02:00
|
|
|
HashMap<StringName, Callable> captures;
|
|
|
|
HashMap<StringName, Ref<EngineProfiler>> profilers;
|
2020-05-18 16:55:49 +02:00
|
|
|
|
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
2021-08-13 16:46:14 +02:00
|
|
|
static EngineDebugger *singleton;
|
2020-05-18 16:55:49 +02:00
|
|
|
|
|
|
|
public:
|
2021-08-13 16:46:14 +02:00
|
|
|
static EngineDebugger *get_singleton() { return singleton; }
|
2020-05-18 16:55:49 +02:00
|
|
|
|
|
|
|
bool is_active();
|
|
|
|
|
2022-02-06 01:55:58 +01:00
|
|
|
void register_profiler(const StringName &p_name, Ref<EngineProfiler> p_profiler);
|
2020-05-18 16:55:49 +02:00
|
|
|
void unregister_profiler(const StringName &p_name);
|
|
|
|
bool is_profiling(const StringName &p_name);
|
|
|
|
bool has_profiler(const StringName &p_name);
|
|
|
|
void profiler_add_frame_data(const StringName &p_name, const Array &p_data);
|
|
|
|
void profiler_enable(const StringName &p_name, bool p_enabled, const Array &p_opts = Array());
|
|
|
|
|
|
|
|
void register_message_capture(const StringName &p_name, const Callable &p_callable);
|
|
|
|
void unregister_message_capture(const StringName &p_name);
|
|
|
|
bool has_capture(const StringName &p_name);
|
|
|
|
|
|
|
|
void send_message(const String &p_msg, const Array &p_data);
|
2024-01-02 20:07:10 +01:00
|
|
|
void debug(bool p_can_continue = true, bool p_is_error_breakpoint = false);
|
|
|
|
void script_debug(ScriptLanguage *p_lang, bool p_can_continue = true, bool p_is_error_breakpoint = false);
|
2020-05-18 16:55:49 +02:00
|
|
|
|
|
|
|
static Error call_capture(void *p_user, const String &p_cmd, const Array &p_data, bool &r_captured);
|
|
|
|
|
2024-01-02 20:07:10 +01:00
|
|
|
void line_poll();
|
|
|
|
|
|
|
|
void set_lines_left(int p_lines);
|
|
|
|
int get_lines_left() const;
|
|
|
|
|
|
|
|
void set_depth(int p_depth);
|
|
|
|
int get_depth() const;
|
|
|
|
|
|
|
|
bool is_breakpoint(int p_line, const StringName &p_source) const;
|
|
|
|
bool is_skipping_breakpoints() const;
|
|
|
|
void insert_breakpoint(int p_line, const StringName &p_source);
|
|
|
|
void remove_breakpoint(int p_line, const StringName &p_source);
|
|
|
|
void clear_breakpoints();
|
|
|
|
|
2021-08-13 16:46:14 +02:00
|
|
|
EngineDebugger() { singleton = this; }
|
|
|
|
~EngineDebugger();
|
2020-05-18 16:55:49 +02:00
|
|
|
};
|
|
|
|
|
2021-08-13 16:46:14 +02:00
|
|
|
} // namespace core_bind
|
|
|
|
|
|
|
|
VARIANT_ENUM_CAST(core_bind::ResourceLoader::ThreadLoadStatus);
|
|
|
|
VARIANT_ENUM_CAST(core_bind::ResourceLoader::CacheMode);
|
|
|
|
|
2022-06-24 11:16:37 +02:00
|
|
|
VARIANT_BITFIELD_CAST(core_bind::ResourceSaver::SaverFlags);
|
2021-08-13 16:46:14 +02:00
|
|
|
|
2022-10-11 10:32:13 +02:00
|
|
|
VARIANT_ENUM_CAST(core_bind::OS::RenderingDriver);
|
2021-08-13 16:46:14 +02:00
|
|
|
VARIANT_ENUM_CAST(core_bind::OS::SystemDir);
|
|
|
|
|
|
|
|
VARIANT_ENUM_CAST(core_bind::Geometry2D::PolyBooleanOperation);
|
|
|
|
VARIANT_ENUM_CAST(core_bind::Geometry2D::PolyJoinType);
|
|
|
|
VARIANT_ENUM_CAST(core_bind::Geometry2D::PolyEndType);
|
|
|
|
|
|
|
|
VARIANT_ENUM_CAST(core_bind::Thread::Priority);
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
#endif // CORE_BIND_H
|