2016-06-18 12:46:12 +00:00
|
|
|
/*************************************************************************/
|
|
|
|
/* core_bind.h */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
2017-08-27 12:16:55 +00:00
|
|
|
/* https://godotengine.org */
|
2016-06-18 12:46:12 +00:00
|
|
|
/*************************************************************************/
|
2021-01-01 19:13:46 +00:00
|
|
|
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
|
2016-06-18 12:46:12 +00:00
|
|
|
/* */
|
|
|
|
/* 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-04 23:50:27 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
#ifndef CORE_BIND_H
|
|
|
|
#define CORE_BIND_H
|
|
|
|
|
2018-09-11 16:13:45 +00:00
|
|
|
#include "core/io/compression.h"
|
2020-11-07 22:33:38 +00:00
|
|
|
#include "core/io/image.h"
|
2018-09-11 16:13:45 +00:00
|
|
|
#include "core/io/resource_loader.h"
|
|
|
|
#include "core/io/resource_saver.h"
|
|
|
|
#include "core/os/dir_access.h"
|
|
|
|
#include "core/os/file_access.h"
|
|
|
|
#include "core/os/os.h"
|
|
|
|
#include "core/os/semaphore.h"
|
|
|
|
#include "core/os/thread.h"
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
class _ResourceLoader : public Object {
|
|
|
|
GDCLASS(_ResourceLoader, Object);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
|
|
|
static _ResourceLoader *singleton;
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
public:
|
2020-02-28 11:27:04 +00:00
|
|
|
enum ThreadLoadStatus {
|
|
|
|
THREAD_LOAD_INVALID_RESOURCE,
|
|
|
|
THREAD_LOAD_IN_PROGRESS,
|
|
|
|
THREAD_LOAD_FAILED,
|
|
|
|
THREAD_LOAD_LOADED
|
|
|
|
};
|
|
|
|
|
2021-02-11 17:18:45 +00:00
|
|
|
enum CacheMode {
|
|
|
|
CACHE_MODE_IGNORE, //resource and subresources do not use path cache, no path is set into resource.
|
|
|
|
CACHE_MODE_REUSE, //resource and subresources use patch cache, reuse existing loaded resources instead of loading from disk when available
|
|
|
|
CACHE_MODE_REPLACE, //resource and and subresource use path cache, but replace existing loaded resources when available with information from disk
|
|
|
|
};
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
static _ResourceLoader *get_singleton() { return singleton; }
|
2020-02-28 11:27:04 +00:00
|
|
|
|
|
|
|
Error load_threaded_request(const String &p_path, const String &p_type_hint = "", bool p_use_sub_threads = false);
|
|
|
|
ThreadLoadStatus load_threaded_get_status(const String &p_path, Array r_progress = Array());
|
|
|
|
RES load_threaded_get(const String &p_path);
|
|
|
|
|
2021-02-11 17:18:45 +00:00
|
|
|
RES load(const String &p_path, const String &p_type_hint = "", CacheMode p_cache_mode = CACHE_MODE_REUSE);
|
2020-02-17 21:06:54 +00:00
|
|
|
Vector<String> get_recognized_extensions_for_type(const String &p_type);
|
2014-02-10 01:10:30 +00:00
|
|
|
void set_abort_on_missing_resources(bool p_abort);
|
2020-02-17 21:06:54 +00:00
|
|
|
PackedStringArray get_dependencies(const String &p_path);
|
2018-08-10 18:57:43 +00:00
|
|
|
bool has_cached(const String &p_path);
|
|
|
|
bool exists(const String &p_path, const String &p_type_hint = "");
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2020-05-12 15:01:17 +00:00
|
|
|
_ResourceLoader() { singleton = this; }
|
2014-02-10 01:10:30 +00:00
|
|
|
};
|
|
|
|
|
2020-02-28 11:27:04 +00:00
|
|
|
VARIANT_ENUM_CAST(_ResourceLoader::ThreadLoadStatus);
|
2021-02-11 17:18:45 +00:00
|
|
|
VARIANT_ENUM_CAST(_ResourceLoader::CacheMode);
|
2020-02-28 11:27:04 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
class _ResourceSaver : public Object {
|
|
|
|
GDCLASS(_ResourceSaver, Object);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
|
|
|
static _ResourceSaver *singleton;
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
public:
|
2014-05-24 04:35:47 +00:00
|
|
|
enum SaverFlags {
|
2017-03-05 15:44:50 +00: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 14:58:44 +00:00
|
|
|
FLAG_REPLACE_SUBRESOURCE_PATHS = 64,
|
2014-05-24 04:35:47 +00:00
|
|
|
};
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
static _ResourceSaver *get_singleton() { return singleton; }
|
|
|
|
|
2019-04-07 16:52:39 +00:00
|
|
|
Error save(const String &p_path, const RES &p_resource, SaverFlags p_flags);
|
2020-02-17 21:06:54 +00:00
|
|
|
Vector<String> get_recognized_extensions(const RES &p_resource);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2020-05-12 15:01:17 +00:00
|
|
|
_ResourceSaver() { singleton = this; }
|
2014-02-10 01:10:30 +00:00
|
|
|
};
|
|
|
|
|
2017-08-20 15:45:01 +00:00
|
|
|
VARIANT_ENUM_CAST(_ResourceSaver::SaverFlags);
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
class MainLoop;
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
class _OS : public Object {
|
|
|
|
GDCLASS(_OS, Object);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
|
|
|
static _OS *singleton;
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
public:
|
2019-02-16 13:40:52 +00:00
|
|
|
enum VideoDriver {
|
|
|
|
VIDEO_DRIVER_GLES2,
|
2019-06-22 16:34:26 +00:00
|
|
|
VIDEO_DRIVER_VULKAN,
|
2019-02-16 13:40:52 +00:00
|
|
|
};
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
enum Weekday {
|
|
|
|
DAY_SUNDAY,
|
|
|
|
DAY_MONDAY,
|
|
|
|
DAY_TUESDAY,
|
|
|
|
DAY_WEDNESDAY,
|
|
|
|
DAY_THURSDAY,
|
|
|
|
DAY_FRIDAY,
|
|
|
|
DAY_SATURDAY
|
|
|
|
};
|
|
|
|
|
|
|
|
enum Month {
|
2019-08-25 21:02:16 +00:00
|
|
|
// Start at 1 to follow Windows SYSTEMTIME structure
|
|
|
|
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms724950(v=vs.85).aspx
|
2016-03-13 02:13:57 +00:00
|
|
|
MONTH_JANUARY = 1,
|
2014-02-10 01:10:30 +00:00
|
|
|
MONTH_FEBRUARY,
|
|
|
|
MONTH_MARCH,
|
|
|
|
MONTH_APRIL,
|
|
|
|
MONTH_MAY,
|
|
|
|
MONTH_JUNE,
|
|
|
|
MONTH_JULY,
|
|
|
|
MONTH_AUGUST,
|
|
|
|
MONTH_SEPTEMBER,
|
|
|
|
MONTH_OCTOBER,
|
|
|
|
MONTH_NOVEMBER,
|
|
|
|
MONTH_DECEMBER
|
|
|
|
};
|
|
|
|
|
2020-02-17 21:06:54 +00:00
|
|
|
virtual PackedStringArray get_connected_midi_inputs();
|
2018-08-04 00:17:33 +00:00
|
|
|
virtual void open_midi_inputs();
|
|
|
|
virtual void close_midi_inputs();
|
2018-07-14 12:11:28 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
void set_low_processor_usage_mode(bool p_enabled);
|
|
|
|
bool is_in_low_processor_usage_mode() const;
|
|
|
|
|
2019-11-08 17:36:06 +00:00
|
|
|
void set_low_processor_usage_mode_sleep_usec(int p_usec);
|
|
|
|
int get_low_processor_usage_mode_sleep_usec() const;
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
String get_executable_path() const;
|
2020-12-18 18:49:13 +00:00
|
|
|
int execute(const String &p_path, const Vector<String> &p_arguments, Array r_output = Array(), bool p_read_stderr = false);
|
|
|
|
int create_process(const String &p_path, const Vector<String> &p_arguments);
|
2014-02-10 01:10:30 +00:00
|
|
|
Error kill(int p_pid);
|
|
|
|
Error shell_open(String p_uri);
|
|
|
|
|
2017-08-07 10:17:31 +00:00
|
|
|
int get_process_id() const;
|
2014-04-05 15:39:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
bool has_environment(const String &p_var) const;
|
|
|
|
String get_environment(const String &p_var) const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
String get_name() const;
|
|
|
|
Vector<String> get_cmdline_args();
|
|
|
|
|
|
|
|
String get_locale() const;
|
2016-07-02 18:52:36 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
String get_model_name() const;
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void dump_memory_to_file(const String &p_file);
|
|
|
|
void dump_resources_to_file(const String &p_file);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void print_resources_in_use(bool p_short = false);
|
|
|
|
void print_all_resources(const String &p_to_file);
|
2014-02-26 13:08:17 +00:00
|
|
|
void print_all_textures_by_size();
|
2017-03-05 15:44:50 +00:00
|
|
|
void print_resources_by_type(const Vector<String> &p_types);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2014-11-02 14:31:01 +00:00
|
|
|
bool is_debug_build() const;
|
|
|
|
|
2017-08-07 10:17:31 +00:00
|
|
|
String get_unique_id() const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2018-04-05 17:59:35 +00:00
|
|
|
String get_keycode_string(uint32_t p_code) const;
|
|
|
|
bool is_keycode_unicode(uint32_t p_unicode) const;
|
|
|
|
int find_keycode_from_string(const String &p_code) const;
|
2015-05-17 16:11:55 +00:00
|
|
|
|
2014-08-02 01:10:38 +00:00
|
|
|
void set_use_file_access_save_and_swap(bool p_enable);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-01-07 17:55:48 +00:00
|
|
|
int get_exit_code() const;
|
|
|
|
void set_exit_code(int p_code);
|
2015-06-06 01:40:56 +00:00
|
|
|
Dictionary get_date(bool utc) const;
|
|
|
|
Dictionary get_time(bool utc) const;
|
2016-03-16 04:17:10 +00:00
|
|
|
Dictionary get_datetime(bool utc) const;
|
2018-08-09 06:19:19 +00:00
|
|
|
Dictionary get_datetime_from_unix_time(int64_t unix_time_val) const;
|
|
|
|
int64_t get_unix_time_from_datetime(Dictionary datetime) const;
|
2015-06-06 03:35:38 +00:00
|
|
|
Dictionary get_time_zone_info() const;
|
2020-05-31 12:19:31 +00:00
|
|
|
double get_unix_time() const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2019-01-30 18:07:46 +00:00
|
|
|
uint64_t get_static_memory_usage() const;
|
|
|
|
uint64_t get_static_memory_peak_usage() const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
void delay_usec(uint32_t p_usec) const;
|
|
|
|
void delay_msec(uint32_t p_msec) const;
|
|
|
|
uint32_t get_ticks_msec() const;
|
2018-06-17 16:10:41 +00:00
|
|
|
uint64_t get_ticks_usec() const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2014-03-14 01:57:24 +00:00
|
|
|
bool can_use_threads() const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-10-02 14:09:24 +00:00
|
|
|
bool is_userfs_persistent() const;
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
bool is_stdout_verbose() const;
|
|
|
|
|
|
|
|
int get_processor_count() const;
|
|
|
|
|
2014-12-02 17:02:41 +00: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,
|
|
|
|
};
|
|
|
|
|
|
|
|
String get_system_dir(SystemDir p_dir) const;
|
|
|
|
|
2017-11-17 14:25:22 +00:00
|
|
|
String get_user_data_dir() const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
Error set_thread_name(const String &p_name);
|
2020-12-27 15:49:46 +00:00
|
|
|
Thread::ID get_thread_caller_id() const;
|
2016-01-31 23:22:38 +00:00
|
|
|
|
2017-10-02 19:38:39 +00:00
|
|
|
bool has_feature(const String &p_feature) const;
|
|
|
|
|
2019-03-05 02:06:37 +00:00
|
|
|
bool request_permission(const String &p_name);
|
2019-10-06 18:17:44 +00:00
|
|
|
bool request_permissions();
|
|
|
|
Vector<String> get_granted_permissions() const;
|
2019-03-05 02:06:37 +00:00
|
|
|
|
2020-05-19 20:34:26 +00:00
|
|
|
int get_tablet_driver_count() const;
|
|
|
|
String get_tablet_driver_name(int p_driver) const;
|
|
|
|
String get_current_tablet_driver() const;
|
|
|
|
void set_current_tablet_driver(const String &p_driver);
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
static _OS *get_singleton() { return singleton; }
|
|
|
|
|
2020-05-12 15:01:17 +00:00
|
|
|
_OS() { singleton = this; }
|
2014-02-10 01:10:30 +00:00
|
|
|
};
|
|
|
|
|
2019-02-16 13:40:52 +00:00
|
|
|
VARIANT_ENUM_CAST(_OS::VideoDriver);
|
2017-08-20 15:45:01 +00:00
|
|
|
VARIANT_ENUM_CAST(_OS::Weekday);
|
|
|
|
VARIANT_ENUM_CAST(_OS::Month);
|
2014-12-02 17:02:41 +00:00
|
|
|
VARIANT_ENUM_CAST(_OS::SystemDir);
|
|
|
|
|
2020-05-25 17:20:45 +00:00
|
|
|
class _Geometry2D : public Object {
|
|
|
|
GDCLASS(_Geometry2D, Object);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2020-05-25 17:20:45 +00:00
|
|
|
static _Geometry2D *singleton;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
protected:
|
2014-02-10 01:10:30 +00:00
|
|
|
static void _bind_methods();
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
public:
|
2020-05-25 17:20:45 +00:00
|
|
|
static _Geometry2D *get_singleton();
|
|
|
|
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 15:44:50 +00:00
|
|
|
bool point_is_inside_triangle(const Vector2 &s, const Vector2 &a, const Vector2 &b, const Vector2 &c) const;
|
|
|
|
|
2019-08-25 21:02:16 +00:00
|
|
|
bool is_point_in_circle(const Vector2 &p_point, const Vector2 &p_circle_pos, real_t p_circle_radius);
|
2017-03-05 15:44:50 +00: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 17:01:42 +00:00
|
|
|
bool is_polygon_clockwise(const Vector<Vector2> &p_polygon);
|
2019-06-26 21:20:22 +00:00
|
|
|
bool is_point_in_polygon(const Point2 &p_point, const Vector<Vector2> &p_polygon);
|
2017-03-05 15:44:50 +00:00
|
|
|
Vector<int> triangulate_polygon(const Vector<Vector2> &p_polygon);
|
2020-05-25 17:20:45 +00:00
|
|
|
Vector<int> triangulate_delaunay(const Vector<Vector2> &p_points);
|
|
|
|
Vector<Point2> convex_hull(const Vector<Point2> &p_points);
|
2017-03-05 15:44:50 +00: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 17:01:42 +00:00
|
|
|
enum PolyBooleanOperation {
|
|
|
|
OPERATION_UNION,
|
|
|
|
OPERATION_DIFFERENCE,
|
|
|
|
OPERATION_INTERSECTION,
|
|
|
|
OPERATION_XOR
|
|
|
|
};
|
2019-08-25 21:02:16 +00:00
|
|
|
// 2D polygon boolean operations.
|
2020-05-25 17:20:45 +00:00
|
|
|
Array merge_polygons(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // Union (add).
|
|
|
|
Array clip_polygons(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // Difference (subtract).
|
|
|
|
Array intersect_polygons(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // Common area (multiply).
|
|
|
|
Array 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 17:01:42 +00:00
|
|
|
|
2019-08-25 21:02:16 +00:00
|
|
|
// 2D polyline vs polygon operations.
|
2020-05-25 17:20:45 +00:00
|
|
|
Array clip_polyline_with_polygon(const Vector<Vector2> &p_polyline, const Vector<Vector2> &p_polygon); // Cut.
|
|
|
|
Array 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 17:01:42 +00:00
|
|
|
|
2019-08-25 21:02:16 +00: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 17:01:42 +00:00
|
|
|
enum PolyJoinType {
|
|
|
|
JOIN_SQUARE,
|
|
|
|
JOIN_ROUND,
|
|
|
|
JOIN_MITER
|
|
|
|
};
|
|
|
|
enum PolyEndType {
|
|
|
|
END_POLYGON,
|
|
|
|
END_JOINED,
|
|
|
|
END_BUTT,
|
|
|
|
END_SQUARE,
|
|
|
|
END_ROUND
|
|
|
|
};
|
2020-05-25 17:20:45 +00:00
|
|
|
Array offset_polygon(const Vector<Vector2> &p_polygon, real_t p_delta, PolyJoinType p_join_type = JOIN_SQUARE);
|
|
|
|
Array 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 17:01:42 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
Dictionary make_atlas(const Vector<Size2> &p_rects);
|
2014-10-03 03:10:51 +00:00
|
|
|
|
2020-05-25 17:20:45 +00:00
|
|
|
_Geometry2D() { singleton = this; }
|
2014-02-10 01:10:30 +00:00
|
|
|
};
|
|
|
|
|
2020-05-25 17:20:45 +00:00
|
|
|
VARIANT_ENUM_CAST(_Geometry2D::PolyBooleanOperation);
|
|
|
|
VARIANT_ENUM_CAST(_Geometry2D::PolyJoinType);
|
|
|
|
VARIANT_ENUM_CAST(_Geometry2D::PolyEndType);
|
|
|
|
|
|
|
|
class _Geometry3D : public Object {
|
|
|
|
GDCLASS(_Geometry3D, Object);
|
|
|
|
|
|
|
|
static _Geometry3D *singleton;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
|
|
|
|
|
|
|
public:
|
|
|
|
static _Geometry3D *get_singleton();
|
|
|
|
Vector<Plane> build_box_planes(const Vector3 &p_extents);
|
|
|
|
Vector<Plane> build_cylinder_planes(float p_radius, float p_height, int p_sides, Vector3::Axis p_axis = Vector3::AXIS_Z);
|
|
|
|
Vector<Plane> build_capsule_planes(float p_radius, float p_height, int p_sides, int p_lats, Vector3::Axis p_axis = Vector3::AXIS_Z);
|
|
|
|
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);
|
|
|
|
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);
|
|
|
|
Vector<Vector3> segment_intersects_convex(const Vector3 &p_from, const Vector3 &p_to, const Vector<Plane> &p_planes);
|
|
|
|
|
|
|
|
Vector<Vector3> clip_polygon(const Vector<Vector3> &p_points, const Plane &p_plane);
|
|
|
|
|
|
|
|
_Geometry3D() { singleton = this; }
|
|
|
|
};
|
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 17:01:42 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
class _File : public Reference {
|
2017-03-05 15:44:50 +00:00
|
|
|
GDCLASS(_File, Reference);
|
2020-05-12 15:01:17 +00:00
|
|
|
|
|
|
|
FileAccess *f = nullptr;
|
|
|
|
bool eswap = false;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
protected:
|
2014-02-10 01:10:30 +00:00
|
|
|
static void _bind_methods();
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
public:
|
|
|
|
enum ModeFlags {
|
|
|
|
READ = 1,
|
|
|
|
WRITE = 2,
|
|
|
|
READ_WRITE = 3,
|
|
|
|
WRITE_READ = 7,
|
2014-02-10 01:10:30 +00:00
|
|
|
};
|
|
|
|
|
2017-06-19 16:28:00 +00:00
|
|
|
enum CompressionMode {
|
|
|
|
COMPRESSION_FASTLZ = Compression::MODE_FASTLZ,
|
|
|
|
COMPRESSION_DEFLATE = Compression::MODE_DEFLATE,
|
2017-07-13 17:41:10 +00:00
|
|
|
COMPRESSION_ZSTD = Compression::MODE_ZSTD,
|
|
|
|
COMPRESSION_GZIP = Compression::MODE_GZIP
|
2017-06-19 16:28:00 +00:00
|
|
|
};
|
|
|
|
|
2019-04-07 16:52:39 +00:00
|
|
|
Error open_encrypted(const String &p_path, ModeFlags p_mode_flags, const Vector<uint8_t> &p_key);
|
|
|
|
Error open_encrypted_pass(const String &p_path, ModeFlags p_mode_flags, const String &p_pass);
|
|
|
|
Error open_compressed(const String &p_path, ModeFlags p_mode_flags, CompressionMode p_compress_mode = COMPRESSION_FASTLZ);
|
2014-04-15 01:43:44 +00:00
|
|
|
|
2019-08-25 21:02:16 +00:00
|
|
|
Error open(const String &p_path, ModeFlags p_mode_flags); // open a file.
|
|
|
|
void close(); // Close a file.
|
|
|
|
bool is_open() const; // True when file is open.
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2019-08-25 21:02:16 +00:00
|
|
|
String get_path() const; // Returns the path for the current open file.
|
|
|
|
String get_path_absolute() const; // Returns the absolute path for the current open file.
|
2018-03-09 14:45:21 +00:00
|
|
|
|
2019-08-25 21:02:16 +00:00
|
|
|
void seek(int64_t p_position); // Seek to a given position.
|
|
|
|
void seek_end(int64_t p_position = 0); // Seek from the end of file.
|
|
|
|
int64_t get_position() const; // Get position in the file.
|
|
|
|
int64_t get_len() const; // Get size of the file.
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2019-08-25 21:02:16 +00:00
|
|
|
bool eof_reached() const; // Reading passed EOF.
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2019-08-25 21:02:16 +00:00
|
|
|
uint8_t get_8() const; // Get a byte.
|
|
|
|
uint16_t get_16() const; // Get 16 bits uint.
|
|
|
|
uint32_t get_32() const; // Get 32 bits uint.
|
|
|
|
uint64_t get_64() const; // Get 64 bits uint.
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
float get_float() const;
|
|
|
|
double get_double() const;
|
|
|
|
real_t get_real() const;
|
|
|
|
|
2019-03-26 15:52:42 +00:00
|
|
|
Variant get_var(bool p_allow_objects = false) const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2020-02-17 21:06:54 +00:00
|
|
|
Vector<uint8_t> get_buffer(int p_length) const; // Get an array of bytes.
|
2014-02-10 01:10:30 +00:00
|
|
|
String get_line() const;
|
2018-11-13 11:53:24 +00:00
|
|
|
Vector<String> get_csv_line(const String &p_delim = ",") const;
|
2014-02-10 01:10:30 +00:00
|
|
|
String get_as_text() const;
|
2017-03-05 15:44:50 +00:00
|
|
|
String get_md5(const String &p_path) const;
|
|
|
|
String get_sha256(const String &p_path) const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2019-08-25 21:02:16 +00:00
|
|
|
/* Use this for files WRITTEN in _big_ endian machines (ie, amiga/mac).
|
2014-02-10 01:10:30 +00:00
|
|
|
* It's not about the current CPU type but file formats.
|
2019-08-25 21:02:16 +00:00
|
|
|
* This flags get reset to false (little endian) on each open.
|
2014-02-10 01:10:30 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
void set_endian_swap(bool p_swap);
|
|
|
|
bool get_endian_swap();
|
|
|
|
|
2019-08-25 21:02:16 +00:00
|
|
|
Error get_error() const; // Get last error.
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2019-08-25 21:02:16 +00:00
|
|
|
void store_8(uint8_t p_dest); // Store a byte.
|
|
|
|
void store_16(uint16_t p_dest); // Store 16 bits uint.
|
|
|
|
void store_32(uint32_t p_dest); // Store 32 bits uint.
|
|
|
|
void store_64(uint64_t p_dest); // Store 64 bits uint.
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
void store_float(float p_dest);
|
|
|
|
void store_double(double p_dest);
|
|
|
|
void store_real(real_t p_real);
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void store_string(const String &p_string);
|
|
|
|
void store_line(const String &p_string);
|
2018-11-13 11:53:24 +00:00
|
|
|
void store_csv_line(const Vector<String> &p_values, const String &p_delim = ",");
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
virtual void store_pascal_string(const String &p_string);
|
2014-03-14 01:57:24 +00:00
|
|
|
virtual String get_pascal_string();
|
|
|
|
|
2020-02-17 21:06:54 +00:00
|
|
|
void store_buffer(const Vector<uint8_t> &p_buffer); // Store an array of bytes.
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2019-03-26 15:52:42 +00:00
|
|
|
void store_var(const Variant &p_var, bool p_full_objects = false);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2019-08-25 21:02:16 +00:00
|
|
|
bool file_exists(const String &p_name) const; // Return true if a file exists.
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
uint64_t get_modified_time(const String &p_file) const;
|
2017-01-23 21:33:02 +00:00
|
|
|
|
2020-05-12 15:01:17 +00:00
|
|
|
_File() {}
|
2014-02-10 01:10:30 +00:00
|
|
|
virtual ~_File();
|
|
|
|
};
|
|
|
|
|
2017-08-20 15:45:01 +00:00
|
|
|
VARIANT_ENUM_CAST(_File::ModeFlags);
|
|
|
|
VARIANT_ENUM_CAST(_File::CompressionMode);
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
class _Directory : public Reference {
|
2017-03-05 15:44:50 +00:00
|
|
|
GDCLASS(_Directory, Reference);
|
2014-02-10 01:10:30 +00:00
|
|
|
DirAccess *d;
|
2020-07-06 06:17:16 +00:00
|
|
|
bool dir_open = false;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
protected:
|
2014-02-10 01:10:30 +00:00
|
|
|
static void _bind_methods();
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
public:
|
|
|
|
Error open(const String &p_path);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2020-07-06 06:17:16 +00:00
|
|
|
bool is_open() const;
|
|
|
|
|
2019-08-25 21:02:16 +00:00
|
|
|
Error list_dir_begin(bool p_skip_navigational = false, bool p_skip_hidden = false); // This starts dir listing.
|
2014-02-10 01:10:30 +00:00
|
|
|
String get_next();
|
|
|
|
bool current_is_dir() const;
|
|
|
|
|
2019-08-25 21:02:16 +00:00
|
|
|
void list_dir_end();
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
int get_drive_count();
|
|
|
|
String get_drive(int p_drive);
|
2017-01-14 16:01:43 +00:00
|
|
|
int get_current_drive();
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2019-08-25 21:02:16 +00:00
|
|
|
Error change_dir(String p_dir); // Can be relative or absolute, return false on success.
|
2020-03-17 13:32:03 +00:00
|
|
|
String get_current_dir(); // Return current dir location.
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
Error make_dir(String p_dir);
|
|
|
|
Error make_dir_recursive(String p_dir);
|
|
|
|
|
|
|
|
bool file_exists(String p_file);
|
2014-05-25 03:34:51 +00:00
|
|
|
bool dir_exists(String p_dir);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
int get_space_left();
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
Error copy(String p_from, String p_to);
|
2014-02-10 01:10:30 +00:00
|
|
|
Error rename(String p_from, String p_to);
|
|
|
|
Error remove(String p_name);
|
|
|
|
|
|
|
|
_Directory();
|
|
|
|
virtual ~_Directory();
|
|
|
|
|
2017-01-16 22:19:43 +00:00
|
|
|
private:
|
2020-11-23 16:38:46 +00:00
|
|
|
bool _list_skip_navigational = false;
|
|
|
|
bool _list_skip_hidden = false;
|
2014-02-10 01:10:30 +00:00
|
|
|
};
|
|
|
|
|
2020-02-24 12:56:22 +00:00
|
|
|
class _Marshalls : public Object {
|
|
|
|
GDCLASS(_Marshalls, Object);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
static _Marshalls *singleton;
|
2016-11-05 16:13:04 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
|
|
|
|
|
|
|
public:
|
2017-03-05 15:44:50 +00:00
|
|
|
static _Marshalls *get_singleton();
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2019-03-26 15:52:42 +00: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 01:10:30 +00:00
|
|
|
|
2020-02-17 21:06:54 +00:00
|
|
|
String raw_to_base64(const Vector<uint8_t> &p_arr);
|
|
|
|
Vector<uint8_t> base64_to_raw(const String &p_str);
|
2015-07-28 10:50:52 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
String utf8_to_base64(const String &p_str);
|
|
|
|
String base64_to_utf8(const String &p_str);
|
2015-07-28 10:50:52 +00:00
|
|
|
|
2016-11-05 16:13:04 +00:00
|
|
|
_Marshalls() { singleton = this; }
|
2020-04-01 23:20:12 +00:00
|
|
|
~_Marshalls() { singleton = nullptr; }
|
2014-02-10 01:10:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class _Mutex : public Reference {
|
2017-03-05 15:44:50 +00:00
|
|
|
GDCLASS(_Mutex, Reference);
|
2020-02-26 10:28:13 +00:00
|
|
|
Mutex mutex;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
static void _bind_methods();
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
public:
|
2014-02-10 01:10:30 +00:00
|
|
|
void lock();
|
|
|
|
Error try_lock();
|
|
|
|
void unlock();
|
|
|
|
};
|
|
|
|
|
|
|
|
class _Semaphore : public Reference {
|
2017-03-05 15:44:50 +00:00
|
|
|
GDCLASS(_Semaphore, Reference);
|
2020-03-03 08:26:42 +00:00
|
|
|
Semaphore semaphore;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
static void _bind_methods();
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
public:
|
2020-03-03 08:26:42 +00:00
|
|
|
void wait();
|
|
|
|
Error try_wait();
|
|
|
|
void post();
|
2014-02-10 01:10:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class _Thread : public Reference {
|
2017-03-05 15:44:50 +00:00
|
|
|
GDCLASS(_Thread, Reference);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
Variant ret;
|
|
|
|
Variant userdata;
|
2020-05-12 15:01:17 +00:00
|
|
|
volatile bool active = false;
|
|
|
|
Object *target_instance = nullptr;
|
2014-02-10 01:10:30 +00:00
|
|
|
StringName target_method;
|
2021-01-19 12:29:41 +00:00
|
|
|
Thread thread;
|
2014-02-10 01:10:30 +00:00
|
|
|
static void _bind_methods();
|
|
|
|
static void _start_func(void *ud);
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
public:
|
2014-02-10 01:10:30 +00:00
|
|
|
enum Priority {
|
|
|
|
PRIORITY_LOW,
|
|
|
|
PRIORITY_NORMAL,
|
2019-04-07 16:52:39 +00:00
|
|
|
PRIORITY_HIGH,
|
|
|
|
PRIORITY_MAX
|
2014-02-10 01:10:30 +00:00
|
|
|
};
|
|
|
|
|
2019-04-07 16:52:39 +00:00
|
|
|
Error start(Object *p_instance, const StringName &p_method, const Variant &p_userdata = Variant(), Priority p_priority = PRIORITY_NORMAL);
|
2014-02-10 01:10:30 +00:00
|
|
|
String get_id() const;
|
|
|
|
bool is_active() const;
|
|
|
|
Variant wait_to_finish();
|
|
|
|
};
|
|
|
|
|
2017-08-20 15:45:01 +00:00
|
|
|
VARIANT_ENUM_CAST(_Thread::Priority);
|
|
|
|
|
2017-01-03 02:03:46 +00:00
|
|
|
class _ClassDB : public Object {
|
2019-03-19 18:35:57 +00:00
|
|
|
GDCLASS(_ClassDB, Object);
|
2017-01-03 02:03:46 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
public:
|
2020-02-17 21:06:54 +00:00
|
|
|
PackedStringArray get_class_list() const;
|
|
|
|
PackedStringArray get_inheriters_from_class(const StringName &p_class) const;
|
2017-03-05 15:44:50 +00:00
|
|
|
StringName get_parent_class(const StringName &p_class) const;
|
2017-01-03 02:03:46 +00:00
|
|
|
bool class_exists(const StringName &p_class) const;
|
2017-03-05 15:44:50 +00:00
|
|
|
bool is_parent_class(const StringName &p_class, const StringName &p_inherits) const;
|
2017-01-03 02:03:46 +00:00
|
|
|
bool can_instance(const StringName &p_class) const;
|
|
|
|
Variant instance(const StringName &p_class) const;
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
bool has_signal(StringName p_class, StringName p_signal) const;
|
|
|
|
Dictionary get_signal(StringName p_class, StringName p_signal) const;
|
|
|
|
Array get_signal_list(StringName p_class, bool p_no_inheritance = false) const;
|
2017-01-03 02:03:46 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
Array get_property_list(StringName p_class, bool p_no_inheritance = false) const;
|
2017-04-09 11:26:48 +00:00
|
|
|
Variant get_property(Object *p_object, const StringName &p_property) const;
|
|
|
|
Error set_property(Object *p_object, const StringName &p_property, const Variant &p_value) const;
|
2017-01-03 02:03:46 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
bool has_method(StringName p_class, StringName p_method, bool p_no_inheritance = false) const;
|
2017-01-03 02:03:46 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
Array get_method_list(StringName p_class, bool p_no_inheritance = false) const;
|
2017-01-03 02:03:46 +00:00
|
|
|
|
2020-02-17 21:06:54 +00:00
|
|
|
PackedStringArray get_integer_constant_list(const StringName &p_class, bool p_no_inheritance = false) const;
|
2017-03-05 15:44:50 +00:00
|
|
|
bool has_integer_constant(const StringName &p_class, const StringName &p_name) const;
|
|
|
|
int get_integer_constant(const StringName &p_class, const StringName &p_name) const;
|
|
|
|
StringName get_category(const StringName &p_node) const;
|
2017-01-03 02:03:46 +00:00
|
|
|
|
|
|
|
bool is_class_enabled(StringName p_class) const;
|
|
|
|
|
2020-05-12 15:01:17 +00:00
|
|
|
_ClassDB() {}
|
|
|
|
~_ClassDB() {}
|
2017-01-03 02:03:46 +00:00
|
|
|
};
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
class _Engine : public Object {
|
|
|
|
GDCLASS(_Engine, Object);
|
2017-01-13 15:51:14 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
|
|
|
static _Engine *singleton;
|
|
|
|
|
|
|
|
public:
|
2017-03-05 15:44:50 +00:00
|
|
|
static _Engine *get_singleton() { return singleton; }
|
2017-01-13 15:51:14 +00:00
|
|
|
void set_iterations_per_second(int p_ips);
|
|
|
|
int get_iterations_per_second() 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-10 23:03:31 +00:00
|
|
|
void set_physics_jitter_fix(float p_threshold);
|
|
|
|
float get_physics_jitter_fix() const;
|
2019-07-01 16:42:02 +00:00
|
|
|
float 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-10 23:03:31 +00:00
|
|
|
|
2017-01-13 15:51:14 +00:00
|
|
|
void set_target_fps(int p_fps);
|
2018-01-12 13:26:21 +00:00
|
|
|
int get_target_fps() const;
|
2017-01-13 15:51:14 +00:00
|
|
|
|
|
|
|
float get_frames_per_second() const;
|
2020-01-13 16:53:10 +00:00
|
|
|
uint64_t get_physics_frames() const;
|
2020-12-22 09:50:29 +00:00
|
|
|
uint64_t get_process_frames() const;
|
2017-01-13 15:51:14 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
int get_frames_drawn();
|
2017-01-13 15:51:14 +00:00
|
|
|
|
|
|
|
void set_time_scale(float p_scale);
|
|
|
|
float get_time_scale();
|
|
|
|
|
|
|
|
MainLoop *get_main_loop() const;
|
|
|
|
|
2017-01-13 17:25:43 +00:00
|
|
|
Dictionary get_version_info() const;
|
2018-05-16 04:54:22 +00:00
|
|
|
Dictionary get_author_info() const;
|
|
|
|
Array get_copyright_info() const;
|
|
|
|
Dictionary get_donor_info() const;
|
|
|
|
Dictionary get_license_info() const;
|
|
|
|
String get_license_text() const;
|
2017-01-13 15:51:14 +00:00
|
|
|
|
2017-09-30 14:19:07 +00:00
|
|
|
bool is_in_physics_frame() const;
|
2017-06-13 15:49:28 +00:00
|
|
|
|
2017-11-13 20:46:57 +00:00
|
|
|
bool has_singleton(const String &p_name) const;
|
|
|
|
Object *get_singleton_object(const String &p_name) const;
|
|
|
|
|
2017-08-13 14:21:45 +00:00
|
|
|
void set_editor_hint(bool p_enabled);
|
|
|
|
bool is_editor_hint() const;
|
|
|
|
|
2020-05-12 15:01:17 +00:00
|
|
|
_Engine() { singleton = this; }
|
2017-01-13 15:51:14 +00:00
|
|
|
};
|
|
|
|
|
2017-09-15 13:40:27 +00:00
|
|
|
class _JSON;
|
|
|
|
|
|
|
|
class JSONParseResult : public Reference {
|
2019-03-19 18:35:57 +00:00
|
|
|
GDCLASS(JSONParseResult, Reference);
|
2017-09-15 13:40:27 +00:00
|
|
|
|
|
|
|
friend class _JSON;
|
|
|
|
|
|
|
|
Error error;
|
|
|
|
String error_string;
|
2020-05-12 15:01:17 +00:00
|
|
|
int error_line = -1;
|
2017-09-15 13:40:27 +00:00
|
|
|
|
|
|
|
Variant result;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
|
|
|
|
|
|
|
public:
|
|
|
|
void set_error(Error p_error);
|
|
|
|
Error get_error() const;
|
|
|
|
|
|
|
|
void set_error_string(const String &p_error_string);
|
|
|
|
String get_error_string() const;
|
|
|
|
|
|
|
|
void set_error_line(int p_error_line);
|
|
|
|
int get_error_line() const;
|
|
|
|
|
|
|
|
void set_result(const Variant &p_result);
|
|
|
|
Variant get_result() const;
|
2019-06-29 19:45:14 +00:00
|
|
|
|
2020-05-12 15:01:17 +00:00
|
|
|
JSONParseResult() {}
|
2017-09-15 13:40:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class _JSON : public Object {
|
2019-03-19 18:35:57 +00:00
|
|
|
GDCLASS(_JSON, Object);
|
2017-09-15 13:40:27 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
|
|
|
static _JSON *singleton;
|
|
|
|
|
|
|
|
public:
|
|
|
|
static _JSON *get_singleton() { return singleton; }
|
|
|
|
|
2017-11-03 07:32:58 +00:00
|
|
|
String print(const Variant &p_value, const String &p_indent = "", bool p_sort_keys = false);
|
2017-09-15 13:40:27 +00:00
|
|
|
Ref<JSONParseResult> parse(const String &p_json);
|
|
|
|
|
2020-05-12 15:01:17 +00:00
|
|
|
_JSON() { singleton = this; }
|
2017-09-15 13:40:27 +00:00
|
|
|
};
|
|
|
|
|
2020-05-18 14:55:49 +00:00
|
|
|
class _EngineDebugger : public Object {
|
|
|
|
GDCLASS(_EngineDebugger, Object);
|
|
|
|
|
|
|
|
class ProfilerCallable {
|
|
|
|
friend class _EngineDebugger;
|
|
|
|
|
|
|
|
Callable callable_toggle;
|
|
|
|
Callable callable_add;
|
|
|
|
Callable callable_tick;
|
|
|
|
|
|
|
|
public:
|
|
|
|
ProfilerCallable() {}
|
|
|
|
|
|
|
|
ProfilerCallable(const Callable &p_toggle, const Callable &p_add, const Callable &p_tick) {
|
|
|
|
callable_toggle = p_toggle;
|
|
|
|
callable_add = p_add;
|
|
|
|
callable_tick = p_tick;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
Map<StringName, Callable> captures;
|
|
|
|
Map<StringName, ProfilerCallable> profilers;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
|
|
|
static _EngineDebugger *singleton;
|
|
|
|
|
|
|
|
public:
|
|
|
|
static _EngineDebugger *get_singleton() { return singleton; }
|
|
|
|
|
|
|
|
bool is_active();
|
|
|
|
|
|
|
|
void register_profiler(const StringName &p_name, const Callable &p_toggle, const Callable &p_add, const Callable &p_tick);
|
|
|
|
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);
|
|
|
|
|
|
|
|
static void call_toggle(void *p_user, bool p_enable, const Array &p_opts);
|
|
|
|
static void call_add(void *p_user, const Array &p_data);
|
|
|
|
static void call_tick(void *p_user, float p_frame_time, float p_idle_time, float p_physics_time, float p_physics_frame_time);
|
|
|
|
static Error call_capture(void *p_user, const String &p_cmd, const Array &p_data, bool &r_captured);
|
|
|
|
|
|
|
|
_EngineDebugger() { singleton = this; }
|
|
|
|
~_EngineDebugger();
|
|
|
|
};
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
#endif // CORE_BIND_H
|