summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/class_db.cpp26
-rw-r--r--core/class_db.h5
-rw-r--r--core/engine.cpp12
-rw-r--r--core/engine.h5
-rw-r--r--core/input/gamecontrollerdb.txt2
-rw-r--r--core/input/input.cpp173
-rw-r--r--core/input/input.h2
-rw-r--r--core/math/random_number_generator.h18
-rw-r--r--core/math/random_pcg.h4
-rw-r--r--core/os/main_loop.cpp5
-rw-r--r--core/project_settings.cpp27
-rw-r--r--core/script_language.h1
-rw-r--r--core/variant.h11
-rw-r--r--core/variant_call.cpp52
14 files changed, 209 insertions, 134 deletions
diff --git a/core/class_db.cpp b/core/class_db.cpp
index ad85cd0d62..81bc901561 100644
--- a/core/class_db.cpp
+++ b/core/class_db.cpp
@@ -242,21 +242,25 @@ HashMap<StringName, ClassDB::ClassInfo> ClassDB::classes;
HashMap<StringName, StringName> ClassDB::resource_base_extensions;
HashMap<StringName, StringName> ClassDB::compat_classes;
-bool ClassDB::is_parent_class(const StringName &p_class, const StringName &p_inherits) {
- OBJTYPE_RLOCK;
-
+bool ClassDB::_is_parent_class(const StringName &p_class, const StringName &p_inherits) {
StringName inherits = p_class;
while (inherits.operator String().length()) {
if (inherits == p_inherits) {
return true;
}
- inherits = get_parent_class(inherits);
+ inherits = _get_parent_class(inherits);
}
return false;
}
+bool ClassDB::is_parent_class(const StringName &p_class, const StringName &p_inherits) {
+ OBJTYPE_RLOCK;
+
+ return _is_parent_class(p_class, p_inherits);
+}
+
void ClassDB::get_class_list(List<StringName> *p_classes) {
OBJTYPE_RLOCK;
@@ -275,7 +279,7 @@ void ClassDB::get_inheriters_from_class(const StringName &p_class, List<StringNa
const StringName *k = nullptr;
while ((k = classes.next(k))) {
- if (*k != p_class && is_parent_class(*k, p_class)) {
+ if (*k != p_class && _is_parent_class(*k, p_class)) {
p_classes->push_back(*k);
}
}
@@ -287,7 +291,7 @@ void ClassDB::get_direct_inheriters_from_class(const StringName &p_class, List<S
const StringName *k = nullptr;
while ((k = classes.next(k))) {
- if (*k != p_class && get_parent_class(*k) == p_class) {
+ if (*k != p_class && _get_parent_class(*k) == p_class) {
p_classes->push_back(*k);
}
}
@@ -315,14 +319,18 @@ StringName ClassDB::get_compatibility_remapped_class(const StringName &p_class)
return p_class;
}
-StringName ClassDB::get_parent_class(const StringName &p_class) {
- OBJTYPE_RLOCK;
-
+StringName ClassDB::_get_parent_class(const StringName &p_class) {
ClassInfo *ti = classes.getptr(p_class);
ERR_FAIL_COND_V_MSG(!ti, StringName(), "Cannot get class '" + String(p_class) + "'.");
return ti->inherits;
}
+StringName ClassDB::get_parent_class(const StringName &p_class) {
+ OBJTYPE_RLOCK;
+
+ return _get_parent_class(p_class);
+}
+
ClassDB::APIType ClassDB::get_api_type(const StringName &p_class) {
OBJTYPE_RLOCK;
diff --git a/core/class_db.h b/core/class_db.h
index 4734b06c7a..22072066d9 100644
--- a/core/class_db.h
+++ b/core/class_db.h
@@ -164,6 +164,11 @@ public:
static HashMap<StringName, HashMap<StringName, Variant>> default_values;
static Set<StringName> default_values_cached;
+private:
+ // Non-locking variants of get_parent_class and is_parent_class.
+ static StringName _get_parent_class(const StringName &p_class);
+ static bool _is_parent_class(const StringName &p_class, const StringName &p_inherits);
+
public:
// DO NOT USE THIS!!!!!! NEEDS TO BE PUBLIC BUT DO NOT USE NO MATTER WHAT!!!
template <class T>
diff --git a/core/engine.cpp b/core/engine.cpp
index d08cf92ecb..b0037ffb37 100644
--- a/core/engine.cpp
+++ b/core/engine.cpp
@@ -181,6 +181,14 @@ String Engine::get_license_text() const {
return String(GODOT_LICENSE_TEXT);
}
+bool Engine::is_abort_on_gpu_errors_enabled() const {
+ return abort_on_gpu_errors;
+}
+
+bool Engine::is_validation_layers_enabled() const {
+ return use_validation_layers;
+}
+
void Engine::add_singleton(const Singleton &p_singleton) {
singletons.push_back(p_singleton);
singleton_ptrs[p_singleton.name] = p_singleton.ptr;
@@ -208,10 +216,6 @@ Engine *Engine::get_singleton() {
return singleton;
}
-bool Engine::is_abort_on_gpu_errors_enabled() const {
- return abort_on_gpu_errors;
-}
-
Engine::Engine() {
singleton = this;
}
diff --git a/core/engine.h b/core/engine.h
index fef330c0c1..b581c58ec5 100644
--- a/core/engine.h
+++ b/core/engine.h
@@ -60,10 +60,10 @@ private:
float _fps = 1;
int _target_fps = 0;
float _time_scale = 1.0;
- bool _pixel_snap = false;
uint64_t _physics_frames = 0;
float _physics_interpolation_fraction = 0.0f;
bool abort_on_gpu_errors = false;
+ bool use_validation_layers = false;
uint64_t _idle_frames = 0;
bool _in_physics = false;
@@ -109,8 +109,6 @@ public:
bool has_singleton(const String &p_name) const;
Object *get_singleton_object(const String &p_name) const;
- _FORCE_INLINE_ bool get_use_pixel_snap() const { return _pixel_snap; }
-
#ifdef TOOLS_ENABLED
_FORCE_INLINE_ void set_editor_hint(bool p_enabled) { editor_hint = p_enabled; }
_FORCE_INLINE_ bool is_editor_hint() const { return editor_hint; }
@@ -127,6 +125,7 @@ public:
String get_license_text() const;
bool is_abort_on_gpu_errors_enabled() const;
+ bool is_validation_layers_enabled() const;
Engine();
virtual ~Engine() {}
diff --git a/core/input/gamecontrollerdb.txt b/core/input/gamecontrollerdb.txt
index 2a3cb23202..180708cea6 100644
--- a/core/input/gamecontrollerdb.txt
+++ b/core/input/gamecontrollerdb.txt
@@ -338,7 +338,7 @@ xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,
03000000120c0000101e000000000000,ZEROPLUS P4 Wired Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,
# Mac OS X
-030000008f0e00000300000009010000,2In1 USB Joystick,+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Mac OS X,
+030000008f0e00000300000009010000,2In1 USB Joystick,a:b2,b:b1,x:b3,y:b0,back:b8,start:b9,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,platform:Mac OS X,
03000000c82d00000090000001000000,8BitDo FC30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a5,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Mac OS X,
03000000c82d00001038000000010000,8BitDo FC30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Mac OS X,
03000000c82d00000650000001000000,8BitDo M30,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b8,lefttrigger:b9,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:b7,start:b11,x:b3,y:b4,platform:Mac OS X,
diff --git a/core/input/input.cpp b/core/input/input.cpp
index 4d152c1ac4..b0b1d20222 100644
--- a/core/input/input.cpp
+++ b/core/input/input.cpp
@@ -874,7 +874,7 @@ void Input::joy_button(int p_device, int p_button, bool p_pressed) {
}
if (map.type == TYPE_AXIS) {
- _axis_event(p_device, map.index, p_pressed ? 1.0 : 0.0);
+ _axis_event(p_device, map.index, p_pressed ? map.value : 0.0);
}
// no event?
}
@@ -920,55 +920,42 @@ void Input::joy_axis(int p_device, int p_axis, const JoyAxis &p_value) {
return;
}
- JoyEvent map = _get_mapped_axis_event(map_db[joy.mapping], p_axis, p_value);
+ JoyEvent map = _get_mapped_axis_event(map_db[joy.mapping], p_axis, val);
if (map.type == TYPE_BUTTON) {
- if (map.index == JOY_BUTTON_DPAD_UP || map.index == JOY_BUTTON_DPAD_DOWN) {
- bool pressed = p_value.value != 0.0f;
- int button = p_value.value < 0 ? JOY_BUTTON_DPAD_UP : JOY_BUTTON_DPAD_DOWN;
+ bool pressed = map.value > 0.5;
+ if (pressed == joy_buttons_pressed.has(_combine_device(map.index, p_device))) {
+ // Button already pressed or released; so ignore.
+ return;
+ }
+ _button_event(p_device, map.index, pressed);
- if (!pressed) {
- if (joy_buttons_pressed.has(_combine_device(JOY_BUTTON_DPAD_UP, p_device))) {
- _button_event(p_device, JOY_BUTTON_DPAD_UP, false);
- }
+ // Ensure opposite D-Pad button is also released.
+ switch (map.index) {
+ case JOY_BUTTON_DPAD_UP:
if (joy_buttons_pressed.has(_combine_device(JOY_BUTTON_DPAD_DOWN, p_device))) {
_button_event(p_device, JOY_BUTTON_DPAD_DOWN, false);
}
- }
- if (pressed == joy_buttons_pressed.has(_combine_device(button, p_device))) {
- return;
- }
- _button_event(p_device, button, true);
- return;
- }
-
- if (map.index == JOY_BUTTON_DPAD_LEFT || map.index == JOY_BUTTON_DPAD_RIGHT) {
- bool pressed = p_value.value != 0.0f;
- int button = p_value.value < 0 ? JOY_BUTTON_DPAD_LEFT : JOY_BUTTON_DPAD_RIGHT;
-
- if (!pressed) {
- if (joy_buttons_pressed.has(_combine_device(JOY_BUTTON_DPAD_LEFT, p_device))) {
- _button_event(p_device, JOY_BUTTON_DPAD_LEFT, false);
+ break;
+ case JOY_BUTTON_DPAD_DOWN:
+ if (joy_buttons_pressed.has(_combine_device(JOY_BUTTON_DPAD_UP, p_device))) {
+ _button_event(p_device, JOY_BUTTON_DPAD_UP, false);
}
+ break;
+ case JOY_BUTTON_DPAD_LEFT:
if (joy_buttons_pressed.has(_combine_device(JOY_BUTTON_DPAD_RIGHT, p_device))) {
_button_event(p_device, JOY_BUTTON_DPAD_RIGHT, false);
}
- }
- if (pressed == joy_buttons_pressed.has(_combine_device(button, p_device))) {
- return;
- }
- _button_event(p_device, button, true);
- return;
- }
-
- float deadzone = p_value.min == 0 ? 0.5f : 0.0f;
- bool pressed = p_value.value > deadzone;
- if (pressed == joy_buttons_pressed.has(_combine_device(map.index, p_device))) {
- // button already pressed or released, this is an axis bounce value
- return;
+ break;
+ case JOY_BUTTON_DPAD_RIGHT:
+ if (joy_buttons_pressed.has(_combine_device(JOY_BUTTON_DPAD_LEFT, p_device))) {
+ _button_event(p_device, JOY_BUTTON_DPAD_LEFT, false);
+ }
+ break;
+ default:
+ // Nothing to do.
+ break;
}
-
- _button_event(p_device, map.index, pressed);
return;
}
@@ -1007,18 +994,15 @@ void Input::joy_hat(int p_device, int p_val) {
int cur_val = joy_names[p_device].hat_current;
- if ((p_val & HAT_MASK_UP) != (cur_val & HAT_MASK_UP)) {
- _button_event(p_device, map[HAT_UP].index, p_val & HAT_MASK_UP);
- }
-
- if ((p_val & HAT_MASK_RIGHT) != (cur_val & HAT_MASK_RIGHT)) {
- _button_event(p_device, map[HAT_RIGHT].index, p_val & HAT_MASK_RIGHT);
- }
- if ((p_val & HAT_MASK_DOWN) != (cur_val & HAT_MASK_DOWN)) {
- _button_event(p_device, map[HAT_DOWN].index, p_val & HAT_MASK_DOWN);
- }
- if ((p_val & HAT_MASK_LEFT) != (cur_val & HAT_MASK_LEFT)) {
- _button_event(p_device, map[HAT_LEFT].index, p_val & HAT_MASK_LEFT);
+ for (int hat_direction = 0, hat_mask = 1; hat_direction < HAT_MAX; hat_direction++, hat_mask <<= 1) {
+ if ((p_val & hat_mask) != (cur_val & hat_mask)) {
+ if (map[hat_direction].type == TYPE_BUTTON) {
+ _button_event(p_device, map[hat_direction].index, p_val & hat_mask);
+ }
+ if (map[hat_direction].type == TYPE_AXIS) {
+ _axis_event(p_device, map[hat_direction].index, (p_val & hat_mask) ? map[hat_direction].value : 0.0);
+ }
+ }
}
joy_names[p_device].hat_current = p_val;
@@ -1058,6 +1042,19 @@ Input::JoyEvent Input::_get_mapped_button_event(const JoyDeviceMapping &mapping,
return event;
case TYPE_AXIS:
event.index = binding.output.axis.axis;
+ switch (binding.output.axis.range) {
+ case POSITIVE_HALF_AXIS:
+ event.value = 1;
+ break;
+ case NEGATIVE_HALF_AXIS:
+ event.value = -1;
+ break;
+ case FULL_AXIS:
+ // It doesn't make sense for a button to map to a full axis,
+ // but keeping as a default for a trigger with a positive half-axis.
+ event.value = 1;
+ break;
+ }
return event;
default:
ERR_PRINT_ONCE("Joypad button mapping error.");
@@ -1067,14 +1064,14 @@ Input::JoyEvent Input::_get_mapped_button_event(const JoyDeviceMapping &mapping,
return event;
}
-Input::JoyEvent Input::_get_mapped_axis_event(const JoyDeviceMapping &mapping, int p_axis, const JoyAxis &p_value) {
+Input::JoyEvent Input::_get_mapped_axis_event(const JoyDeviceMapping &mapping, int p_axis, float p_value) {
JoyEvent event;
event.type = TYPE_MAX;
for (int i = 0; i < mapping.bindings.size(); i++) {
const JoyBinding binding = mapping.bindings[i];
if (binding.inputType == TYPE_AXIS && binding.input.axis.axis == p_axis) {
- float value = p_value.value;
+ float value = p_value;
if (binding.input.axis.invert) {
value = -value;
}
@@ -1082,26 +1079,40 @@ Input::JoyEvent Input::_get_mapped_axis_event(const JoyDeviceMapping &mapping, i
(binding.input.axis.range == POSITIVE_HALF_AXIS && value > 0) ||
(binding.input.axis.range == NEGATIVE_HALF_AXIS && value < 0)) {
event.type = binding.outputType;
+ float shifted_positive_value = 0;
+ switch (binding.input.axis.range) {
+ case POSITIVE_HALF_AXIS:
+ shifted_positive_value = value;
+ break;
+ case NEGATIVE_HALF_AXIS:
+ shifted_positive_value = value + 1;
+ break;
+ case FULL_AXIS:
+ shifted_positive_value = (value + 1) / 2;
+ break;
+ }
switch (binding.outputType) {
case TYPE_BUTTON:
event.index = binding.output.button;
+ switch (binding.input.axis.range) {
+ case POSITIVE_HALF_AXIS:
+ event.value = shifted_positive_value;
+ break;
+ case NEGATIVE_HALF_AXIS:
+ event.value = 1 - shifted_positive_value;
+ break;
+ case FULL_AXIS:
+ // It doesn't make sense for a full axis to map to a button,
+ // but keeping as a default for a trigger with a positive half-axis.
+ event.value = (shifted_positive_value * 2) - 1;
+ ;
+ break;
+ }
return event;
case TYPE_AXIS:
event.index = binding.output.axis.axis;
event.value = value;
if (binding.output.axis.range != binding.input.axis.range) {
- float shifted_positive_value = 0;
- switch (binding.input.axis.range) {
- case POSITIVE_HALF_AXIS:
- shifted_positive_value = value;
- break;
- case NEGATIVE_HALF_AXIS:
- shifted_positive_value = value + 1;
- break;
- case FULL_AXIS:
- shifted_positive_value = (value + 1) / 2;
- break;
- }
switch (binding.output.axis.range) {
case POSITIVE_HALF_AXIS:
event.value = shifted_positive_value;
@@ -1128,32 +1139,45 @@ void Input::_get_mapped_hat_events(const JoyDeviceMapping &mapping, int p_hat, J
for (int i = 0; i < mapping.bindings.size(); i++) {
const JoyBinding binding = mapping.bindings[i];
if (binding.inputType == TYPE_HAT && binding.input.hat.hat == p_hat) {
- int index;
+ int hat_direction;
switch (binding.input.hat.hat_mask) {
case HAT_MASK_UP:
- index = 0;
+ hat_direction = HAT_UP;
break;
case HAT_MASK_RIGHT:
- index = 1;
+ hat_direction = HAT_RIGHT;
break;
case HAT_MASK_DOWN:
- index = 2;
+ hat_direction = HAT_DOWN;
break;
case HAT_MASK_LEFT:
- index = 3;
+ hat_direction = HAT_LEFT;
break;
default:
ERR_PRINT_ONCE("Joypad button mapping error.");
continue;
}
- r_events[index].type = binding.outputType;
+ r_events[hat_direction].type = binding.outputType;
switch (binding.outputType) {
case TYPE_BUTTON:
- r_events[index].index = binding.output.button;
+ r_events[hat_direction].index = binding.output.button;
break;
case TYPE_AXIS:
- r_events[index].index = binding.output.axis.axis;
+ r_events[hat_direction].index = binding.output.axis.axis;
+ switch (binding.output.axis.range) {
+ case POSITIVE_HALF_AXIS:
+ r_events[hat_direction].value = 1;
+ break;
+ case NEGATIVE_HALF_AXIS:
+ r_events[hat_direction].value = -1;
+ break;
+ case FULL_AXIS:
+ // It doesn't make sense for a hat direction to map to a full axis,
+ // but keeping as a default for a trigger with a positive half-axis.
+ r_events[hat_direction].value = 1;
+ break;
+ }
break;
default:
ERR_PRINT_ONCE("Joypad button mapping error.");
@@ -1213,12 +1237,12 @@ void Input::parse_mapping(String p_mapping) {
JoyAxisRange output_range = FULL_AXIS;
if (output[0] == '+' || output[0] == '-') {
ERR_CONTINUE_MSG(output.length() < 2, String(entry[idx] + "\nInvalid output: " + entry[idx]));
- output = output.right(1);
if (output[0] == '+') {
output_range = POSITIVE_HALF_AXIS;
} else if (output[0] == '-') {
output_range = NEGATIVE_HALF_AXIS;
}
+ output = output.right(1);
}
JoyAxisRange input_range = FULL_AXIS;
@@ -1232,6 +1256,7 @@ void Input::parse_mapping(String p_mapping) {
bool invert_axis = false;
if (input[input.length() - 1] == '~') {
invert_axis = true;
+ input = input.left(input.length() - 1);
}
JoyButtonList output_button = _get_output_button(output);
diff --git a/core/input/input.h b/core/input/input.h
index 775663503b..60e378d72c 100644
--- a/core/input/input.h
+++ b/core/input/input.h
@@ -217,7 +217,7 @@ private:
Vector<JoyDeviceMapping> map_db;
JoyEvent _get_mapped_button_event(const JoyDeviceMapping &mapping, int p_button);
- JoyEvent _get_mapped_axis_event(const JoyDeviceMapping &mapping, int p_axis, const JoyAxis &p_value);
+ JoyEvent _get_mapped_axis_event(const JoyDeviceMapping &mapping, int p_axis, float p_value);
void _get_mapped_hat_events(const JoyDeviceMapping &mapping, int p_hat, JoyEvent r_events[HAT_MAX]);
JoyButtonList _get_output_button(String output);
JoyAxisList _get_output_axis(String output);
diff --git a/core/math/random_number_generator.h b/core/math/random_number_generator.h
index 920308e597..2e7941b345 100644
--- a/core/math/random_number_generator.h
+++ b/core/math/random_number_generator.h
@@ -37,9 +37,9 @@
class RandomNumberGenerator : public Reference {
GDCLASS(RandomNumberGenerator, Reference);
+protected:
RandomPCG randbase;
-protected:
static void _bind_methods();
public:
@@ -58,12 +58,18 @@ public:
_FORCE_INLINE_ real_t randfn(real_t mean = 0.0, real_t deviation = 1.0) { return randbase.randfn(mean, deviation); }
_FORCE_INLINE_ int randi_range(int from, int to) {
- unsigned int ret = randbase.rand();
- if (to < from) {
- return ret % (from - to + 1) + to;
- } else {
- return ret % (to - from + 1) + from;
+ int range;
+ int min;
+ if (to > from) {
+ range = to - from + 1;
+ min = from;
+ } else if (to < from) {
+ range = from - to + 1;
+ min = to;
+ } else { // from == to
+ return from;
}
+ return randbase.rand(range) + min;
}
RandomNumberGenerator() {}
diff --git a/core/math/random_pcg.h b/core/math/random_pcg.h
index 09b13ab74d..dfdae53eed 100644
--- a/core/math/random_pcg.h
+++ b/core/math/random_pcg.h
@@ -81,6 +81,10 @@ public:
current_seed = pcg.state;
return pcg32_random_r(&pcg);
}
+ _FORCE_INLINE_ uint32_t rand(uint32_t bounds) {
+ current_seed = pcg.state;
+ return pcg32_boundedrand_r(&pcg, bounds);
+ }
// Obtaining floating point numbers in [0, 1] range with "good enough" uniformity.
// These functions sample the output of rand() as the fraction part of an infinite binary number,
diff --git a/core/os/main_loop.cpp b/core/os/main_loop.cpp
index 434f6fa300..6651fb80d7 100644
--- a/core/os/main_loop.cpp
+++ b/core/os/main_loop.cpp
@@ -33,11 +33,6 @@
#include "core/script_language.h"
void MainLoop::_bind_methods() {
- ClassDB::bind_method(D_METHOD("init"), &MainLoop::init);
- ClassDB::bind_method(D_METHOD("iteration", "delta"), &MainLoop::iteration);
- ClassDB::bind_method(D_METHOD("idle", "delta"), &MainLoop::idle);
- ClassDB::bind_method(D_METHOD("finish"), &MainLoop::finish);
-
BIND_VMETHOD(MethodInfo("_initialize"));
BIND_VMETHOD(MethodInfo(Variant::BOOL, "_iteration", PropertyInfo(Variant::FLOAT, "delta")));
BIND_VMETHOD(MethodInfo(Variant::BOOL, "_idle", PropertyInfo(Variant::FLOAT, "delta")));
diff --git a/core/project_settings.cpp b/core/project_settings.cpp
index 90f56694c2..3829474626 100644
--- a/core/project_settings.cpp
+++ b/core/project_settings.cpp
@@ -629,19 +629,26 @@ Error ProjectSettings::_load_settings_text(const String &p_path) {
}
Error ProjectSettings::_load_settings_text_or_binary(const String &p_text_path, const String &p_bin_path) {
- // Attempt first to load the text-based project.godot file
- Error err_text = _load_settings_text(p_text_path);
- if (err_text == OK) {
+ // Attempt first to load the binary project.godot file.
+ Error err = _load_settings_binary(p_bin_path);
+ if (err == OK) {
+ return OK;
+ } else if (err != ERR_FILE_NOT_FOUND) {
+ // If the file exists but can't be loaded, we want to know it.
+ ERR_PRINT("Couldn't load file '" + p_bin_path + "', error code " + itos(err) + ".");
+ return err;
+ }
+
+ // Fallback to text-based project.godot file if binary was not found.
+ err = _load_settings_text(p_text_path);
+ if (err == OK) {
return OK;
- } else if (err_text != ERR_FILE_NOT_FOUND) {
- // If the text-based file exists but can't be loaded, we want to know it
- ERR_PRINT("Couldn't load file '" + p_text_path + "', error code " + itos(err_text) + ".");
- return err_text;
+ } else if (err != ERR_FILE_NOT_FOUND) {
+ ERR_PRINT("Couldn't load file '" + p_text_path + "', error code " + itos(err) + ".");
+ return err;
}
- // Fallback to binary project.binary file if text-based was not found
- Error err_bin = _load_settings_binary(p_bin_path);
- return err_bin;
+ return err;
}
int ProjectSettings::get_order(const String &p_name) const {
diff --git a/core/script_language.h b/core/script_language.h
index aa7014ed3e..a94c128932 100644
--- a/core/script_language.h
+++ b/core/script_language.h
@@ -255,6 +255,7 @@ struct ScriptCodeCompletionOption {
String insert_text;
Color font_color;
RES icon;
+ Variant default_value;
ScriptCodeCompletionOption() {}
diff --git a/core/variant.h b/core/variant.h
index 1f3ee8ec74..84e5427b21 100644
--- a/core/variant.h
+++ b/core/variant.h
@@ -415,6 +415,11 @@ public:
static void interpolate(const Variant &a, const Variant &b, float c, Variant &r_dst);
class InternalMethod {
+#ifdef DEBUG_ENABLED
+ protected:
+ StringName method_name;
+ Variant::Type base_type;
+#endif
public:
enum Flags {
FLAG_IS_CONST = 1,
@@ -430,6 +435,12 @@ public:
#ifdef DEBUG_ENABLED
virtual String get_argument_name(int p_arg) const = 0;
+ StringName get_name() const {
+ return method_name;
+ }
+ Variant::Type get_base_type() const {
+ return base_type;
+ }
#endif
virtual Vector<Variant> get_default_arguments() const = 0;
virtual void call(Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, Callable::CallError &r_error) = 0;
diff --git a/core/variant_call.cpp b/core/variant_call.cpp
index 66c1987a58..6ffefccb67 100644
--- a/core/variant_call.cpp
+++ b/core/variant_call.cpp
@@ -111,13 +111,15 @@ struct _VariantCall {
InternalMethod(void (T::*p_method)(P...), const Vector<Variant> &p_default_args
#ifdef DEBUG_ENABLED
,
- const Vector<String> &p_arg_names
+ const Vector<String> &p_arg_names, const StringName &p_method_name, Variant::Type p_base_type
#endif
) {
method = p_method;
default_values = p_default_args;
#ifdef DEBUG_ENABLED
argument_names = p_arg_names;
+ method_name = p_method_name;
+ base_type = p_base_type;
#endif
}
};
@@ -175,13 +177,15 @@ struct _VariantCall {
InternalMethodR(R (T::*p_method)(P...), const Vector<Variant> &p_default_args
#ifdef DEBUG_ENABLED
,
- const Vector<String> &p_arg_names
+ const Vector<String> &p_arg_names, const StringName &p_method_name, Variant::Type p_base_type
#endif
) {
method = p_method;
default_values = p_default_args;
#ifdef DEBUG_ENABLED
argument_names = p_arg_names;
+ method_name = p_method_name;
+ base_type = p_base_type;
#endif
}
};
@@ -238,13 +242,15 @@ struct _VariantCall {
InternalMethodRC(R (T::*p_method)(P...) const, const Vector<Variant> &p_default_args
#ifdef DEBUG_ENABLED
,
- const Vector<String> &p_arg_names
+ const Vector<String> &p_arg_names, const StringName &p_method_name, Variant::Type p_base_type
#endif
) {
method = p_method;
default_values = p_default_args;
#ifdef DEBUG_ENABLED
argument_names = p_arg_names;
+ method_name = p_method_name;
+ base_type = p_base_type;
#endif
}
};
@@ -338,13 +344,15 @@ struct _VariantCall {
InternalMethodRS(R (*p_method)(T *, P...), const Vector<Variant> &p_default_args
#ifdef DEBUG_ENABLED
,
- const Vector<String> &p_arg_names
+ const Vector<String> &p_arg_names, const StringName &p_method_name, Variant::Type p_base_type
#endif
) {
method = p_method;
default_values = p_default_args;
#ifdef DEBUG_ENABLED
argument_names = p_arg_names;
+ method_name = p_method_name;
+ base_type = p_base_type;
#endif
}
};
@@ -397,7 +405,7 @@ struct _VariantCall {
InternalMethodVC(MethodVC p_method, uint32_t p_flags, const Vector<Variant::Type> &p_argument_types, const Variant::Type &p_return_type
#ifdef DEBUG_ENABLED
,
- const Vector<String> &p_arg_names
+ const Vector<String> &p_arg_names, const StringName &p_method_name, Variant::Type p_base_type
#endif
) {
methodvc = p_method;
@@ -406,6 +414,8 @@ struct _VariantCall {
base_flags = p_flags;
#ifdef DEBUG_ENABLED
argument_names = p_arg_names;
+ method_name = p_method_name;
+ base_type = p_base_type;
#endif
}
};
@@ -427,7 +437,7 @@ struct _VariantCall {
ERR_FAIL_COND(type_internal_methods[GetTypeInfo<T>::VARIANT_TYPE].has(p_name));
#endif
#ifdef DEBUG_ENABLED
- Variant::InternalMethod *m = memnew((InternalMethod<T, P...>)(p_method, p_default_args, p_argument_names));
+ Variant::InternalMethod *m = memnew((InternalMethod<T, P...>)(p_method, p_default_args, p_argument_names, p_name, GetTypeInfo<T>::VARIANT_TYPE));
#else
Variant::InternalMethod *m = memnew((InternalMethod<T, P...>)(p_method, p_default_args));
#endif
@@ -449,7 +459,7 @@ struct _VariantCall {
#endif
#ifdef DEBUG_ENABLED
- Variant::InternalMethod *m = memnew((InternalMethodRC<T, R, P...>)(p_method, p_default_args, p_argument_names));
+ Variant::InternalMethod *m = memnew((InternalMethodRC<T, R, P...>)(p_method, p_default_args, p_argument_names, p_name, GetTypeInfo<T>::VARIANT_TYPE));
#else
Variant::InternalMethod *m = memnew((InternalMethodRC<T, R, P...>)(p_method, p_default_args));
#endif
@@ -471,7 +481,7 @@ struct _VariantCall {
#endif
#ifdef DEBUG_ENABLED
- Variant::InternalMethod *m = memnew((InternalMethodR<T, R, P...>)(p_method, p_default_args, p_argument_names));
+ Variant::InternalMethod *m = memnew((InternalMethodR<T, R, P...>)(p_method, p_default_args, p_argument_names, p_name, GetTypeInfo<T>::VARIANT_TYPE));
#else
Variant::InternalMethod *m = memnew((InternalMethodR<T, R, P...>)(p_method, p_default_args));
#endif
@@ -504,7 +514,7 @@ struct _VariantCall {
#endif
#ifdef DEBUG_ENABLED
- Variant::InternalMethod *m = memnew((InternalMethodRS<T, R, P...>)(p_method, p_default_args, p_argument_names));
+ Variant::InternalMethod *m = memnew((InternalMethodRS<T, R, P...>)(p_method, p_default_args, p_argument_names, p_name, GetTypeInfo<T>::VARIANT_TYPE));
#else
Variant::InternalMethod *m = memnew((InternalMethodRS<T, R, P...>)(p_method, p_default_args));
#endif
@@ -527,7 +537,7 @@ struct _VariantCall {
) {
#ifdef DEBUG_ENABLED
- Variant::InternalMethod *m = memnew(InternalMethodVC(p_method, p_flags, p_argument_types, p_return_type, p_argument_names));
+ Variant::InternalMethod *m = memnew(InternalMethodVC(p_method, p_flags, p_argument_types, p_return_type, p_argument_names, p_name, p_type));
#else
Variant::InternalMethod *m = memnew(InternalMethodVC(p_method, p_flags, p_argument_types, p_return_type));
#endif
@@ -1354,7 +1364,7 @@ void register_variant_methods() {
bind_method(String, naturalnocasecmp_to, sarray("to"), varray());
bind_method(String, length, sarray(), varray());
bind_method(String, substr, sarray("from", "len"), varray(-1));
- bind_methodv("find", static_cast<int (String::*)(const String &, int) const>(&String::find), sarray("what", "from"), varray(0));
+ bind_methodv(find, static_cast<int (String::*)(const String &, int) const>(&String::find), sarray("what", "from"), varray(0));
bind_method(String, count, sarray("what", "from", "to"), varray(0, 0));
bind_method(String, countn, sarray("what", "from", "to"), varray(0, 0));
bind_method(String, findn, sarray("what", "from"), varray(0));
@@ -1362,7 +1372,7 @@ void register_variant_methods() {
bind_method(String, rfindn, sarray("what", "from"), varray(-1));
bind_method(String, match, sarray("expr"), varray());
bind_method(String, matchn, sarray("expr"), varray());
- bind_methodv("begins_with", static_cast<bool (String::*)(const String &) const>(&String::begins_with), sarray("text"), varray());
+ bind_methodv(begins_with, static_cast<bool (String::*)(const String &) const>(&String::begins_with), sarray("text"), varray());
bind_method(String, ends_with, sarray("text"), varray());
bind_method(String, is_subsequence_of, sarray("text"), varray());
bind_method(String, is_subsequence_ofi, sarray("text"), varray());
@@ -1370,7 +1380,7 @@ void register_variant_methods() {
bind_method(String, similarity, sarray("text"), varray());
bind_method(String, format, sarray("values", "placeholder"), varray("{_}"));
- bind_methodv("replace", static_cast<String (String::*)(const String &, const String &) const>(&String::replace), sarray("what", "forwhat"), varray());
+ bind_methodv(replace, static_cast<String (String::*)(const String &, const String &) const>(&String::replace), sarray("what", "forwhat"), varray());
bind_method(String, replacen, sarray("what", "forwhat"), varray());
bind_method(String, repeat, sarray("count"), varray());
bind_method(String, insert, sarray("position", "what"), varray());
@@ -1500,7 +1510,7 @@ void register_variant_methods() {
bind_method(Rect2, merge, sarray("b"), varray());
bind_method(Rect2, expand, sarray("to"), varray());
bind_method(Rect2, grow, sarray("by"), varray());
- bind_methodv("grow_margin", &Rect2::grow_margin_bind, sarray("margin", "by"), varray());
+ bind_methodv(grow_margin, &Rect2::grow_margin_bind, sarray("margin", "by"), varray());
bind_method(Rect2, grow_individual, sarray("left", "top", "right", "bottom"), varray());
bind_method(Rect2, abs, sarray(), varray());
@@ -1515,7 +1525,7 @@ void register_variant_methods() {
bind_method(Rect2i, merge, sarray("b"), varray());
bind_method(Rect2i, expand, sarray("to"), varray());
bind_method(Rect2i, grow, sarray("by"), varray());
- bind_methodv("grow_margin", &Rect2i::grow_margin_bind, sarray("margin", "by"), varray());
+ bind_methodv(grow_margin, &Rect2i::grow_margin_bind, sarray("margin", "by"), varray());
bind_method(Rect2i, grow_individual, sarray("left", "top", "right", "bottom"), varray());
bind_method(Rect2i, abs, sarray(), varray());
@@ -1571,9 +1581,9 @@ void register_variant_methods() {
bind_method(Plane, distance_to, sarray("point"), varray());
bind_method(Plane, has_point, sarray("point", "epsilon"), varray(CMP_EPSILON));
bind_method(Plane, project, sarray("point"), varray());
- bind_methodv("intersect_3", &Plane::intersect_3_bind, sarray("b", "c"), varray());
- bind_methodv("intersects_ray", &Plane::intersects_ray_bind, sarray("from", "dir"), varray());
- bind_methodv("intersects_segment", &Plane::intersects_segment_bind, sarray("from", "to"), varray());
+ bind_methodv(intersect_3, &Plane::intersect_3_bind, sarray("b", "c"), varray());
+ bind_methodv(intersects_ray, &Plane::intersects_ray_bind, sarray("from", "dir"), varray());
+ bind_methodv(intersects_segment, &Plane::intersects_segment_bind, sarray("from", "to"), varray());
/* Quaternion */
@@ -1686,7 +1696,7 @@ void register_variant_methods() {
bind_method(Basis, transposed, sarray(), varray());
bind_method(Basis, orthonormalized, sarray(), varray());
bind_method(Basis, determinant, sarray(), varray());
- bind_methodv("rotated", static_cast<Basis (Basis::*)(const Vector3 &, float) const>(&Basis::rotated), sarray("axis", "phi"), varray());
+ bind_methodv(rotated, static_cast<Basis (Basis::*)(const Vector3 &, float) const>(&Basis::rotated), sarray("axis", "phi"), varray());
bind_method(Basis, scaled, sarray("scale"), varray());
bind_method(Basis, get_scale, sarray(), varray());
bind_method(Basis, get_euler, sarray(), varray());
@@ -1724,8 +1734,8 @@ void register_variant_methods() {
bind_method(::AABB, get_shortest_axis_index, sarray(), varray());
bind_method(::AABB, get_shortest_axis_size, sarray(), varray());
bind_method(::AABB, get_endpoint, sarray("idx"), varray());
- bind_methodv("intersects_segment", &AABB::intersects_segment_bind, sarray("from", "to"), varray());
- bind_methodv("intersects_ray", &AABB::intersects_ray_bind, sarray("from", "dir"), varray());
+ bind_methodv(intersects_segment, &AABB::intersects_segment_bind, sarray("from", "to"), varray());
+ bind_methodv(intersects_ray, &AABB::intersects_ray_bind, sarray("from", "dir"), varray());
/* Transform */