summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/bind/core_bind.cpp6
-rw-r--r--doc/classes/@GDScript.xml6
-rw-r--r--doc/classes/Color.xml3
-rw-r--r--doc/classes/KinematicBody.xml2
-rw-r--r--drivers/unix/os_unix.cpp24
-rw-r--r--editor/code_editor.cpp19
-rw-r--r--editor/editor_data.cpp16
-rw-r--r--editor/editor_data.h4
-rw-r--r--editor/editor_fonts.cpp61
-rw-r--r--editor/editor_node.cpp2
-rw-r--r--editor/editor_settings.cpp24
-rw-r--r--editor/editor_settings.h2
-rw-r--r--editor/editor_themes.cpp91
-rw-r--r--editor/import/resource_importer_bitmask.cpp2
-rw-r--r--editor/import/resource_importer_wav.cpp12
-rw-r--r--editor/scene_tree_dock.cpp5
-rw-r--r--editor/script_editor_debugger.cpp5
-rw-r--r--modules/regex/regex.cpp27
-rw-r--r--platform/android/java/src/org/godotengine/godot/Godot.java5
-rw-r--r--platform/android/java/src/org/godotengine/godot/GodotView.java2
-rw-r--r--platform/android/os_android.cpp32
-rw-r--r--platform/iphone/export/export.cpp2
-rw-r--r--platform/osx/export/export.cpp22
-rw-r--r--platform/osx/os_osx.h2
-rw-r--r--platform/osx/os_osx.mm25
-rw-r--r--scene/3d/physics_body.h5
-rw-r--r--scene/3d/vehicle_body.cpp75
-rw-r--r--scene/3d/vehicle_body.h19
28 files changed, 272 insertions, 228 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp
index 2921626f3a..c7b08b8242 100644
--- a/core/bind/core_bind.cpp
+++ b/core/bind/core_bind.cpp
@@ -2466,7 +2466,13 @@ Array _ClassDB::get_method_list(StringName p_class, bool p_no_inheritance) const
Array ret;
for (List<MethodInfo>::Element *E = methods.front(); E; E = E->next()) {
+#ifdef DEBUG_METHODS_ENABLED
ret.push_back(E->get().operator Dictionary());
+#else
+ Dictionary dict;
+ dict["name"] = E->get().name;
+ ret.push_back(dict);
+#endif
}
return ret;
diff --git a/doc/classes/@GDScript.xml b/doc/classes/@GDScript.xml
index cd05c83347..c98a80ca8c 100644
--- a/doc/classes/@GDScript.xml
+++ b/doc/classes/@GDScript.xml
@@ -41,10 +41,12 @@
<argument index="1" name="alpha" type="float">
</argument>
<description>
- Returns color [code]name[/code] with [code]alpha[/code] ranging from 0 to 1. Note: [code]name[/code] is defined in color_names.inc.
+ Returns a color according to the standardised [code]name[/code] with [code]alpha[/code] ranging from 0 to 1.
[codeblock]
- red = ColorN('red')
+ red = ColorN("red", 1)
[/codeblock]
+ Supported color names:
+ "aliceblue", "antiquewhite", "aqua", "aquamarine", "azure", "beige", "bisque", "black", "blanchedalmond", "blue", "blueviolet", "brown", "burlywood", "cadetblue", "chartreuse", "chocolate", "coral", "cornflower", "cornsilk", "crimson", "cyan", "darkblue", "darkcyan", "darkgoldenrod", "darkgray", "darkgreen", "darkkhaki", "darkmagenta", "darkolivegreen", "darkorange", "darkorchid", "darkred", "darksalmon", "darkseagreen", "darkslateblue", "darkslategray", "darkturquoise", "darkviolet", "deeppink", "deepskyblue", "dimgray", "dodgerblue", "firebrick", "floralwhite", "forestgreen", "fuchsia", "gainsboro", "ghostwhite", "gold", "goldenrod", "gray", "webgray", "green", "webgreen", "greenyellow", "honeydew", "hotpink", "indianred", "indigo", "ivory", "khaki", "lavender", "lavenderblush", "lawngreen", "lemonchiffon", "lightblue", "lightcoral", "lightcyan", "lightgoldenrod", "lightgray", "lightgreen", "lightpink", "lightsalmon", "lightseagreen", "lightskyblue", "lightslategray", "lightsteelblue", "lightyellow", "lime", "limegreen", "linen", "magenta", "maroon", "webmaroon", "mediumaquamarine", "mediumblue", "mediumorchid", "mediumpurple", "mediumseagreen", "mediumslateblue", "mediumspringgreen", "mediumturquoise", "mediumvioletred", "midnightblue", "mintcream", "mistyrose", "moccasin", "navajowhite", "navyblue", "oldlace", "olive", "olivedrab", "orange", "orangered", "orchid", "palegoldenrod", "palegreen", "paleturquoise", "palevioletred", "papayawhip", "peachpuff", "peru", "pink", "plum", "powderblue", "purple", "webpurple", "rebeccapurple", "red", "rosybrown", "royalblue", "saddlebrown", "salmon", "sandybrown", "seagreen", "seashell", "sienna", "silver", "skyblue", "slateblue", "slategray", "snow", "springgreen", "steelblue", "tan", "teal", "thistle", "tomato", "turquoise", "violet", "wheat", "white", "whitesmoke", "yellow", "yellowgreen".
</description>
</method>
<method name="abs">
diff --git a/doc/classes/Color.xml b/doc/classes/Color.xml
index 6fa7ed0a86..ef555537a1 100644
--- a/doc/classes/Color.xml
+++ b/doc/classes/Color.xml
@@ -5,6 +5,7 @@
</brief_description>
<description>
A color is represented as red, green and blue (r,g,b) components. Additionally, "a" represents the alpha component, often used for transparency. Values are in floating point and usually range from 0 to 1. Some methods (such as set_modulate(color)) may accept values &gt; 1.
+ You can also create a color from standardised color names with [method @GDScript.ColorN].
</description>
<tutorials>
</tutorials>
@@ -63,7 +64,7 @@
<argument index="0" name="from" type="String">
</argument>
<description>
- Constructs a color from an HTML hexadecimal color string in ARGB or RGB format.
+ Constructs a color from an HTML hexadecimal color string in ARGB or RGB format. See also [method @GDScript.ColorN].
The following string formats are supported:
[code]"#ff00ff00"[/code] - ARGB format with '#'
[code]"ff00ff00"[/code] - ARGB format
diff --git a/doc/classes/KinematicBody.xml b/doc/classes/KinematicBody.xml
index d1dc236d40..92d648537c 100644
--- a/doc/classes/KinematicBody.xml
+++ b/doc/classes/KinematicBody.xml
@@ -82,7 +82,7 @@
<description>
Moves the body along a vector. If the body collides with another, it will slide along the other body rather than stop immediately. If the other body is a [code]KinematicBody[/code] or [RigidBody], it will also be affected by the motion of the other body. You can use this to make moving or rotating platforms, or to make nodes push other nodes.
[code]linear_velocity[/code] is a value in pixels per second. Unlike in for example [method move_and_collide], you should [i]not[/i] multiply it with [code]delta[/code] — this is done by the method.
- [code]floor_normal[/code] is the up direction, used to determine what is a wall and what is a floor or a ceiling. If set to the default value of [code]Vector2(0, 0)[/code], everything is considered a wall. This is useful for topdown games.
+ [code]floor_normal[/code] is the up direction, used to determine what is a wall and what is a floor or a ceiling. If set to the default value of [code]Vector3(0, 0, 0)[/code], everything is considered a wall. This is useful for topdown games.
If the body is standing on a slope and the horizontal speed (relative to the floor's speed) goes below [code]slope_stop_min_velocity[/code], the body will stop completely. This prevents the body from sliding down slopes when you include gravity in [code]linear_velocity[/code]. When set to lower values, the body will not be able to stand still on steep slopes.
If the body collides, it will change direction a maximum of [code]max_bounces[/code] times before it stops.
[code]floor_max_angle[/code] is the maximum angle (in radians) where a slope is still considered a floor (or a ceiling), rather than a wall. The default value equals 45 degrees.
diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp
index 0f30e3afdb..5f45f06c79 100644
--- a/drivers/unix/os_unix.cpp
+++ b/drivers/unix/os_unix.cpp
@@ -53,6 +53,7 @@
#if defined(__FreeBSD__) || defined(__OpenBSD__)
#include <sys/param.h>
+#include <sys/sysctl.h>
#endif
#include "project_settings.h"
#include <assert.h>
@@ -298,17 +299,7 @@ Error OS_Unix::execute(const String &p_path, const List<String> &p_arguments, bo
args.push_back((char *)cs[i].get_data()); // shitty C cast
args.push_back(0);
-#ifdef __FreeBSD__
- if (p_path.find("/") != -1) {
- // exec name contains path so use it
- execv(p_path.utf8().get_data(), &args[0]);
- } else {
- // use program name and search through PATH to find it
- execvp(getprogname(), &args[0]);
- }
-#else
execvp(p_path.utf8().get_data(), &args[0]);
-#endif
// still alive? something failed..
fprintf(stderr, "**ERROR** OS_Unix::execute - Could not create child process while executing: %s\n", p_path.utf8().get_data());
abort();
@@ -462,12 +453,23 @@ String OS_Unix::get_executable_path() const {
return OS::get_executable_path();
}
return b;
-#elif defined(__FreeBSD__) || defined(__OpenBSD__)
+#elif defined(__OpenBSD__)
char resolved_path[MAXPATHLEN];
realpath(OS::get_executable_path().utf8().get_data(), resolved_path);
return String(resolved_path);
+#elif defined(__FreeBSD__)
+ int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 };
+ char buf[MAXPATHLEN];
+ size_t len = sizeof(buf);
+ if (sysctl(mib, 4, buf, &len, NULL, 0) != 0) {
+ WARN_PRINT("Couldn't get executable path from sysctl");
+ return OS::get_executable_path();
+ }
+ String b;
+ b.parse_utf8(buf);
+ return b;
#elif defined(__APPLE__)
char temp_path[1];
uint32_t buff_size = 1;
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp
index feb5bf2a8f..3e079cb3ca 100644
--- a/editor/code_editor.cpp
+++ b/editor/code_editor.cpp
@@ -1034,7 +1034,7 @@ void CodeTextEditor::_reset_zoom() {
Ref<DynamicFont> font = text_editor->get_font("font"); // reset source font size to default
if (font.is_valid()) {
- EditorSettings::get_singleton()->set("interface/editor/source_font_size", 14);
+ EditorSettings::get_singleton()->set("interface/editor/code_font_size", 14);
font->set_size(14);
}
}
@@ -1098,7 +1098,7 @@ bool CodeTextEditor::_add_font_size(int p_delta) {
if (font.is_valid()) {
int new_size = CLAMP(font->get_size() + p_delta, 8 * EDSCALE, 96 * EDSCALE);
if (new_size != font->get_size()) {
- EditorSettings::get_singleton()->set("interface/editor/source_font_size", new_size / EDSCALE);
+ EditorSettings::get_singleton()->set("interface/editor/code_font_size", new_size / EDSCALE);
font->set_size(new_size);
}
@@ -1140,20 +1140,7 @@ void CodeTextEditor::set_error(const String &p_error) {
void CodeTextEditor::_update_font() {
- // FONTS
- String editor_font = EDITOR_DEF("text_editor/theme/font", "");
- bool font_overridden = false;
- if (editor_font != "") {
- Ref<Font> fnt = ResourceLoader::load(editor_font);
- if (fnt.is_valid()) {
- text_editor->add_font_override("font", fnt);
- font_overridden = true;
- }
- }
- if (!font_overridden) {
-
- text_editor->add_font_override("font", get_font("source", "EditorFonts"));
- }
+ text_editor->add_font_override("font", get_font("source", "EditorFonts"));
}
void CodeTextEditor::_on_settings_change() {
diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp
index 9e8521e0fe..374688f2db 100644
--- a/editor/editor_data.cpp
+++ b/editor/editor_data.cpp
@@ -38,7 +38,7 @@
#include "project_settings.h"
#include "scene/resources/packed_scene.h"
-void EditorHistory::_cleanup_history() {
+void EditorHistory::cleanup_history() {
for (int i = 0; i < history.size(); i++) {
@@ -48,8 +48,14 @@ void EditorHistory::_cleanup_history() {
if (!history[i].path[j].ref.is_null())
continue;
- if (ObjectDB::get_instance(history[i].path[j].object))
- continue; //has isntance, try next
+ Object *obj = ObjectDB::get_instance(history[i].path[j].object);
+ if (obj) {
+ Node *n = Object::cast_to<Node>(obj);
+ if (n && n->is_inside_tree())
+ continue;
+ if (!n) // Possibly still alive
+ continue;
+ }
if (j <= history[i].level) {
//before or equal level, complete fail
@@ -152,7 +158,7 @@ bool EditorHistory::is_at_end() const {
bool EditorHistory::next() {
- _cleanup_history();
+ cleanup_history();
if ((current + 1) < history.size())
current++;
@@ -164,7 +170,7 @@ bool EditorHistory::next() {
bool EditorHistory::previous() {
- _cleanup_history();
+ cleanup_history();
if (current > 0)
current--;
diff --git a/editor/editor_data.h b/editor/editor_data.h
index eacde04134..844145853d 100644
--- a/editor/editor_data.h
+++ b/editor/editor_data.h
@@ -70,11 +70,11 @@ class EditorHistory {
Variant value;
};
- void _cleanup_history();
-
void _add_object(ObjectID p_object, const String &p_property, int p_level_change);
public:
+ void cleanup_history();
+
bool is_at_beginning() const;
bool is_at_end() const;
diff --git a/editor/editor_fonts.cpp b/editor/editor_fonts.cpp
index c970ae355b..a58257962a 100644
--- a/editor/editor_fonts.cpp
+++ b/editor/editor_fonts.cpp
@@ -85,10 +85,24 @@ static Ref<BitmapFont> make_font(int p_height, int p_ascent, int p_valign, int p
m_name->set_spacing(DynamicFont::SPACING_BOTTOM, -EDSCALE); \
MAKE_FALLBACKS(m_name);
+#define MAKE_SOURCE_FONT(m_name, m_size) \
+ Ref<DynamicFont> m_name; \
+ m_name.instance(); \
+ m_name->set_size(m_size); \
+ if (CustomFontSource.is_valid()) { \
+ m_name->set_font_data(CustomFontSource); \
+ m_name->add_fallback(dfmono); \
+ } else { \
+ m_name->set_font_data(dfmono); \
+ } \
+ m_name->set_spacing(DynamicFont::SPACING_TOP, -EDSCALE); \
+ m_name->set_spacing(DynamicFont::SPACING_BOTTOM, -EDSCALE); \
+ MAKE_FALLBACKS(m_name);
+
void editor_register_fonts(Ref<Theme> p_theme) {
/* Custom font */
- String custom_font = EditorSettings::get_singleton()->get("interface/editor/custom_font");
+ String custom_font = EditorSettings::get_singleton()->get("interface/editor/main_font");
Ref<DynamicFontData> CustomFont;
if (custom_font.length() > 0) {
CustomFont.instance();
@@ -96,6 +110,15 @@ void editor_register_fonts(Ref<Theme> p_theme) {
CustomFont->set_force_autohinter(true); //just looks better..i think?
}
+ /* Custom source code font */
+
+ String custom_font_source = EditorSettings::get_singleton()->get("interface/editor/code_font");
+ Ref<DynamicFontData> CustomFontSource;
+ if (custom_font_source.length() > 0) {
+ CustomFontSource.instance();
+ CustomFontSource->set_font_path(custom_font_source);
+ }
+
/* Droid Sans */
Ref<DynamicFontData> DefaultFont;
@@ -135,7 +158,7 @@ void editor_register_fonts(Ref<Theme> p_theme) {
dfmono->set_font_ptr(_font_Hack_Regular, _font_Hack_Regular_size);
//dfd->set_force_autohinter(true); //just looks better..i think?
- int default_font_size = int(EditorSettings::get_singleton()->get("interface/editor/font_size")) * EDSCALE;
+ int default_font_size = int(EditorSettings::get_singleton()->get("interface/editor/main_font_size")) * EDSCALE;
MAKE_DEFAULT_FONT(df, default_font_size);
p_theme->set_default_theme_font(df);
@@ -153,41 +176,15 @@ void editor_register_fonts(Ref<Theme> p_theme) {
MAKE_DEFAULT_FONT(df_rulers, 8 * EDSCALE);
p_theme->set_font("rulers", "EditorFonts", df_rulers);
- Ref<DynamicFont> df_code;
- df_code.instance();
- df_code->set_size(int(EditorSettings::get_singleton()->get("interface/editor/source_font_size")) * EDSCALE);
- df_code->set_font_data(dfmono);
- MAKE_FALLBACKS(df_code);
-
+ MAKE_SOURCE_FONT(df_code, int(EditorSettings::get_singleton()->get("interface/editor/code_font_size")) * EDSCALE);
p_theme->set_font("source", "EditorFonts", df_code);
- Ref<DynamicFont> df_doc_code;
- df_doc_code.instance();
- df_doc_code->set_size(int(EDITOR_DEF("text_editor/help/help_source_font_size", 14)) * EDSCALE);
- df_doc_code->set_spacing(DynamicFont::SPACING_TOP, -EDSCALE);
- df_doc_code->set_spacing(DynamicFont::SPACING_BOTTOM, -EDSCALE);
- df_doc_code->set_font_data(dfmono);
- MAKE_FALLBACKS(df_doc_code);
-
+ MAKE_SOURCE_FONT(df_doc_code, int(EDITOR_DEF("text_editor/help/help_source_font_size", 14)) * EDSCALE);
p_theme->set_font("doc_source", "EditorFonts", df_doc_code);
- Ref<DynamicFont> df_output_code;
- df_output_code.instance();
- df_output_code->set_size(int(EDITOR_DEF("run/output/font_size", 13)) * EDSCALE);
- df_output_code->set_spacing(DynamicFont::SPACING_TOP, -EDSCALE);
- df_output_code->set_spacing(DynamicFont::SPACING_BOTTOM, -EDSCALE);
- df_output_code->set_font_data(dfmono);
- MAKE_FALLBACKS(df_output_code);
-
+ MAKE_SOURCE_FONT(df_output_code, int(EDITOR_DEF("run/output/font_size", 13)) * EDSCALE);
p_theme->set_font("output_source", "EditorFonts", df_output_code);
- Ref<DynamicFont> df_text_editor_status_code;
- df_text_editor_status_code.instance();
- df_text_editor_status_code->set_size(14 * EDSCALE);
- df_text_editor_status_code->set_spacing(DynamicFont::SPACING_TOP, -EDSCALE);
- df_text_editor_status_code->set_spacing(DynamicFont::SPACING_BOTTOM, -EDSCALE);
- df_text_editor_status_code->set_font_data(dfmono);
- MAKE_FALLBACKS(df_text_editor_status_code);
-
+ MAKE_SOURCE_FONT(df_text_editor_status_code, 14 * EDSCALE);
p_theme->set_font("status_source", "EditorFonts", df_text_editor_status_code);
}
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index f480883867..2b62faf218 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -1398,7 +1398,7 @@ void EditorNode::_property_editor_forward() {
}
void EditorNode::_property_editor_back() {
- if (editor_history.previous())
+ if (editor_history.previous() || editor_history.get_path_size() == 1)
_edit_current();
}
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index bcdd232260..7081bb925f 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -281,12 +281,14 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
_initial_set("interface/editor/hidpi_mode", 0);
hints["interface/editor/hidpi_mode"] = PropertyInfo(Variant::INT, "interface/editor/hidpi_mode", PROPERTY_HINT_ENUM, "Auto,VeryLoDPI,LoDPI,MidDPI,HiDPI", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
_initial_set("interface/scene_tabs/show_script_button", false);
- _initial_set("interface/editor/font_size", 14);
- hints["interface/editor/font_size"] = PropertyInfo(Variant::INT, "interface/editor/font_size", PROPERTY_HINT_RANGE, "10,40,1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
- _initial_set("interface/editor/source_font_size", 14);
- hints["interface/editor/source_font_size"] = PropertyInfo(Variant::INT, "interface/editor/source_font_size", PROPERTY_HINT_RANGE, "8,96,1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
- _initial_set("interface/editor/custom_font", "");
- hints["interface/editor/custom_font"] = PropertyInfo(Variant::STRING, "interface/editor/custom_font", PROPERTY_HINT_GLOBAL_FILE, "*.ttf,*.otf", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
+ _initial_set("interface/editor/main_font_size", 14);
+ hints["interface/editor/main_font_size"] = PropertyInfo(Variant::INT, "interface/editor/main_font_size", PROPERTY_HINT_RANGE, "10,40,1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
+ _initial_set("interface/editor/code_font_size", 14);
+ hints["interface/editor/code_font_size"] = PropertyInfo(Variant::INT, "interface/editor/code_font_size", PROPERTY_HINT_RANGE, "8,96,1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
+ _initial_set("interface/editor/main_font", "");
+ hints["interface/editor/main_font"] = PropertyInfo(Variant::STRING, "interface/editor/main_font", PROPERTY_HINT_GLOBAL_FILE, "*.ttf,*.otf", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
+ _initial_set("interface/editor/code_font", "");
+ hints["interface/editor/code_font"] = PropertyInfo(Variant::STRING, "interface/editor/code_font", PROPERTY_HINT_GLOBAL_FILE, "*.ttf,*.otf", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
_initial_set("interface/editor/dim_editor_on_dialog_popup", true);
_initial_set("interface/editor/dim_amount", 0.6f);
hints["interface/editor/dim_amount"] = PropertyInfo(Variant::REAL, "interface/editor/dim_amount", PROPERTY_HINT_RANGE, "0,1,0.01", PROPERTY_USAGE_DEFAULT);
@@ -375,8 +377,6 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
hints["text_editor/cursor/caret_blink_speed"] = PropertyInfo(Variant::REAL, "text_editor/cursor/caret_blink_speed", PROPERTY_HINT_RANGE, "0.1, 10, 0.1");
_initial_set("text_editor/cursor/right_click_moves_caret", true);
- _initial_set("text_editor/theme/font", "");
- hints["text_editor/theme/font"] = PropertyInfo(Variant::STRING, "text_editor/theme/font", PROPERTY_HINT_GLOBAL_FILE, "*.font,*.tres,*.res");
_initial_set("text_editor/completion/auto_brace_complete", false);
_initial_set("text_editor/completion/put_callhint_tooltip_below_current_line", true);
_initial_set("text_editor/completion/callhint_tooltip_offset", Vector2());
@@ -992,13 +992,17 @@ void EditorSettings::raise_order(const String &p_setting) {
props[p_setting].order = ++last_order;
}
-void EditorSettings::set_initial_value(const StringName &p_setting, const Variant &p_value) {
+void EditorSettings::set_initial_value(const StringName &p_setting, const Variant &p_value, bool update_current) {
_THREAD_SAFE_METHOD_
if (!props.has(p_setting))
return;
- _initial_set(p_setting, p_value);
+ props[p_setting].initial = p_value;
+ props[p_setting].has_default_value = true;
+ if (update_current) {
+ set(p_setting, p_value);
+ }
}
Variant _EDITOR_DEF(const String &p_setting, const Variant &p_default) {
diff --git a/editor/editor_settings.h b/editor/editor_settings.h
index 5fc49de0a7..914316ee61 100644
--- a/editor/editor_settings.h
+++ b/editor/editor_settings.h
@@ -145,7 +145,7 @@ public:
bool has_setting(const String &p_setting) const;
void erase(const String &p_setting);
void raise_order(const String &p_setting);
- void set_initial_value(const StringName &p_setting, const Variant &p_value);
+ void set_initial_value(const StringName &p_setting, const Variant &p_value, bool update_current = false);
void set_manually(const StringName &p_setting, const Variant &p_value, bool p_emit_signal = false) {
if (p_emit_signal)
_set(p_setting, p_value);
diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp
index 0ebcef8e5e..9fda9d2ff6 100644
--- a/editor/editor_themes.cpp
+++ b/editor/editor_themes.cpp
@@ -1063,38 +1063,67 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
EditorSettings *setting = EditorSettings::get_singleton();
String text_editor_color_theme = setting->get("text_editor/theme/color_theme");
if (text_editor_color_theme == "Adaptive") {
- setting->set_initial_value("text_editor/highlighting/symbol_color", symbol_color);
- setting->set_initial_value("text_editor/highlighting/keyword_color", keyword_color);
- setting->set_initial_value("text_editor/highlighting/base_type_color", basetype_color);
- setting->set_initial_value("text_editor/highlighting/engine_type_color", type_color);
- setting->set_initial_value("text_editor/highlighting/comment_color", comment_color);
- setting->set_initial_value("text_editor/highlighting/string_color", string_color);
- setting->set_initial_value("text_editor/highlighting/background_color", background_color);
- setting->set_initial_value("text_editor/highlighting/completion_background_color", completion_background_color);
- setting->set_initial_value("text_editor/highlighting/completion_selected_color", completion_selected_color);
- setting->set_initial_value("text_editor/highlighting/completion_existing_color", completion_existing_color);
- setting->set_initial_value("text_editor/highlighting/completion_scroll_color", completion_scroll_color);
- setting->set_initial_value("text_editor/highlighting/completion_font_color", completion_font_color);
- setting->set_initial_value("text_editor/highlighting/text_color", text_color);
- setting->set_initial_value("text_editor/highlighting/line_number_color", line_number_color);
- setting->set_initial_value("text_editor/highlighting/caret_color", caret_color);
- setting->set_initial_value("text_editor/highlighting/caret_background_color", caret_background_color);
- setting->set_initial_value("text_editor/highlighting/text_selected_color", text_selected_color);
- setting->set_initial_value("text_editor/highlighting/selection_color", selection_color);
- setting->set_initial_value("text_editor/highlighting/brace_mismatch_color", brace_mismatch_color);
- setting->set_initial_value("text_editor/highlighting/current_line_color", current_line_color);
- setting->set_initial_value("text_editor/highlighting/line_length_guideline_color", line_length_guideline_color);
- setting->set_initial_value("text_editor/highlighting/word_highlighted_color", word_highlighted_color);
- setting->set_initial_value("text_editor/highlighting/number_color", number_color);
- setting->set_initial_value("text_editor/highlighting/function_color", function_color);
- setting->set_initial_value("text_editor/highlighting/member_variable_color", member_variable_color);
- setting->set_initial_value("text_editor/highlighting/mark_color", mark_color);
- setting->set_initial_value("text_editor/highlighting/breakpoint_color", breakpoint_color);
- setting->set_initial_value("text_editor/highlighting/code_folding_color", code_folding_color);
- setting->set_initial_value("text_editor/highlighting/search_result_color", search_result_color);
- setting->set_initial_value("text_editor/highlighting/search_result_border_color", search_result_border_color);
+ setting->set_initial_value("text_editor/highlighting/symbol_color", symbol_color, true);
+ setting->set_initial_value("text_editor/highlighting/keyword_color", keyword_color, true);
+ setting->set_initial_value("text_editor/highlighting/base_type_color", basetype_color, true);
+ setting->set_initial_value("text_editor/highlighting/engine_type_color", type_color, true);
+ setting->set_initial_value("text_editor/highlighting/comment_color", comment_color, true);
+ setting->set_initial_value("text_editor/highlighting/string_color", string_color, true);
+ setting->set_initial_value("text_editor/highlighting/background_color", background_color, true);
+ setting->set_initial_value("text_editor/highlighting/completion_background_color", completion_background_color, true);
+ setting->set_initial_value("text_editor/highlighting/completion_selected_color", completion_selected_color, true);
+ setting->set_initial_value("text_editor/highlighting/completion_existing_color", completion_existing_color, true);
+ setting->set_initial_value("text_editor/highlighting/completion_scroll_color", completion_scroll_color, true);
+ setting->set_initial_value("text_editor/highlighting/completion_font_color", completion_font_color, true);
+ setting->set_initial_value("text_editor/highlighting/text_color", text_color, true);
+ setting->set_initial_value("text_editor/highlighting/line_number_color", line_number_color, true);
+ setting->set_initial_value("text_editor/highlighting/caret_color", caret_color, true);
+ setting->set_initial_value("text_editor/highlighting/caret_background_color", caret_background_color, true);
+ setting->set_initial_value("text_editor/highlighting/text_selected_color", text_selected_color, true);
+ setting->set_initial_value("text_editor/highlighting/selection_color", selection_color, true);
+ setting->set_initial_value("text_editor/highlighting/brace_mismatch_color", brace_mismatch_color, true);
+ setting->set_initial_value("text_editor/highlighting/current_line_color", current_line_color, true);
+ setting->set_initial_value("text_editor/highlighting/line_length_guideline_color", line_length_guideline_color, true);
+ setting->set_initial_value("text_editor/highlighting/word_highlighted_color", word_highlighted_color, true);
+ setting->set_initial_value("text_editor/highlighting/number_color", number_color, true);
+ setting->set_initial_value("text_editor/highlighting/function_color", function_color, true);
+ setting->set_initial_value("text_editor/highlighting/member_variable_color", member_variable_color, true);
+ setting->set_initial_value("text_editor/highlighting/mark_color", mark_color, true);
+ setting->set_initial_value("text_editor/highlighting/breakpoint_color", breakpoint_color, true);
+ setting->set_initial_value("text_editor/highlighting/code_folding_color", code_folding_color, true);
+ setting->set_initial_value("text_editor/highlighting/search_result_color", search_result_color, true);
+ setting->set_initial_value("text_editor/highlighting/search_result_border_color", search_result_border_color, true);
} else if (text_editor_color_theme == "Default") {
- setting->load_text_editor_theme();
+ setting->set_initial_value("text_editor/highlighting/symbol_color", Color::html("badfff"), true);
+ setting->set_initial_value("text_editor/highlighting/keyword_color", Color::html("ffffb3"), true);
+ setting->set_initial_value("text_editor/highlighting/base_type_color", Color::html("a4ffd4"), true);
+ setting->set_initial_value("text_editor/highlighting/engine_type_color", Color::html("83d3ff"), true);
+ setting->set_initial_value("text_editor/highlighting/comment_color", Color::html("676767"), true);
+ setting->set_initial_value("text_editor/highlighting/string_color", Color::html("ef6ebe"), true);
+ setting->set_initial_value("text_editor/highlighting/background_color", Color::html("3b000000"), true);
+ setting->set_initial_value("text_editor/highlighting/completion_background_color", Color::html("2C2A32"), true);
+ setting->set_initial_value("text_editor/highlighting/completion_selected_color", Color::html("434244"), true);
+ setting->set_initial_value("text_editor/highlighting/completion_existing_color", Color::html("21dfdfdf"), true);
+ setting->set_initial_value("text_editor/highlighting/completion_scroll_color", Color::html("ffffff"), true);
+ setting->set_initial_value("text_editor/highlighting/completion_font_color", Color::html("aaaaaa"), true);
+ setting->set_initial_value("text_editor/highlighting/text_color", Color::html("aaaaaa"), true);
+ setting->set_initial_value("text_editor/highlighting/line_number_color", Color::html("66aaaaaa"), true);
+ setting->set_initial_value("text_editor/highlighting/caret_color", Color::html("aaaaaa"), true);
+ setting->set_initial_value("text_editor/highlighting/caret_background_color", Color::html("000000"), true);
+ setting->set_initial_value("text_editor/highlighting/text_selected_color", Color::html("000000"), true);
+ setting->set_initial_value("text_editor/highlighting/selection_color", Color::html("6ca9c2"), true);
+ setting->set_initial_value("text_editor/highlighting/brace_mismatch_color", Color(1, 0.2, 0.2), true);
+ setting->set_initial_value("text_editor/highlighting/current_line_color", Color(0.3, 0.5, 0.8, 0.15), true);
+ setting->set_initial_value("text_editor/highlighting/line_length_guideline_color", Color(0.3, 0.5, 0.8, 0.1), true);
+ setting->set_initial_value("text_editor/highlighting/word_highlighted_color", Color(0.8, 0.9, 0.9, 0.15), true);
+ setting->set_initial_value("text_editor/highlighting/number_color", Color::html("EB9532"), true);
+ setting->set_initial_value("text_editor/highlighting/function_color", Color::html("66a2ce"), true);
+ setting->set_initial_value("text_editor/highlighting/member_variable_color", Color::html("e64e59"), true);
+ setting->set_initial_value("text_editor/highlighting/mark_color", Color(1.0, 0.4, 0.4, 0.4), true);
+ setting->set_initial_value("text_editor/highlighting/breakpoint_color", Color(0.8, 0.8, 0.4, 0.2), true);
+ setting->set_initial_value("text_editor/highlighting/code_folding_color", Color(0.8, 0.8, 0.8, 0.8), true);
+ setting->set_initial_value("text_editor/highlighting/search_result_color", Color(0.05, 0.25, 0.05, 1), true);
+ setting->set_initial_value("text_editor/highlighting/search_result_border_color", Color(0.1, 0.45, 0.1, 1), true);
}
return theme;
diff --git a/editor/import/resource_importer_bitmask.cpp b/editor/import/resource_importer_bitmask.cpp
index 3d2959c598..a5d3959952 100644
--- a/editor/import/resource_importer_bitmask.cpp
+++ b/editor/import/resource_importer_bitmask.cpp
@@ -77,7 +77,7 @@ Error ResourceImporterBitMap::import(const String &p_source_file, const String &
bit = c.a > threshold;
}
- bitmap->set_bit(Vector2(i, j), bit);
+ bitmap->set_bit(Vector2(j, i), bit);
}
}
diff --git a/editor/import/resource_importer_wav.cpp b/editor/import/resource_importer_wav.cpp
index 12aa0bb33c..03155b3a48 100644
--- a/editor/import/resource_importer_wav.cpp
+++ b/editor/import/resource_importer_wav.cpp
@@ -268,9 +268,15 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s
for (int i = 0; i < 10; i++)
file->get_32(); // i wish to know why should i do this... no doc!
- loop = file->get_32() ? AudioStreamSample::LOOP_PING_PONG : AudioStreamSample::LOOP_FORWARD;
- loop_begin = file->get_32();
- loop_end = file->get_32();
+ // only read 0x00 (loop forward) and 0x01 (loop ping-pong) and skip anything else because
+ // it's not supported (loop backward), reserved for future uses or sampler specific
+ // from https://sites.google.com/site/musicgapi/technical-documents/wav-file-format#smpl (loop type values table)
+ int loop_type = file->get_32();
+ if (loop_type == 0x00 || loop_type == 0x01) {
+ loop = loop_type ? AudioStreamSample::LOOP_PING_PONG : AudioStreamSample::LOOP_FORWARD;
+ loop_begin = file->get_32();
+ loop_end = file->get_32();
+ }
}
file->seek(file_pos + chunksize);
}
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp
index 1f732992d5..d8d44a635a 100644
--- a/editor/scene_tree_dock.cpp
+++ b/editor/scene_tree_dock.cpp
@@ -1285,6 +1285,11 @@ void SceneTreeDock::_delete_confirm() {
editor->get_viewport_control()->update();
editor->push_item(NULL);
+
+ // Fixes the EditorHistory from still offering deleted notes
+ EditorHistory *editor_history = EditorNode::get_singleton()->get_editor_history();
+ editor_history->cleanup_history();
+ EditorNode::get_singleton()->call("_prepare_history");
}
void SceneTreeDock::_selection_changed() {
diff --git a/editor/script_editor_debugger.cpp b/editor/script_editor_debugger.cpp
index e993c2fd46..cbf2687d73 100644
--- a/editor/script_editor_debugger.cpp
+++ b/editor/script_editor_debugger.cpp
@@ -1053,6 +1053,8 @@ void ScriptEditorDebugger::_notification(int p_what) {
break;
};
+ const uint64_t until = OS::get_singleton()->get_ticks_msec() + 20;
+
while (ppeer->get_available_packet_count() > 0) {
if (pending_in_queue) {
@@ -1117,6 +1119,9 @@ void ScriptEditorDebugger::_notification(int p_what) {
break;
}
}
+
+ if (OS::get_singleton()->get_ticks_msec() > until)
+ break;
}
} break;
diff --git a/modules/regex/regex.cpp b/modules/regex/regex.cpp
index 9bcbc4c4ea..3fe7e36d45 100644
--- a/modules/regex/regex.cpp
+++ b/modules/regex/regex.cpp
@@ -343,15 +343,20 @@ String RegEx::sub(const String &p_subject, const String &p_replacement, bool p_a
ERR_FAIL_COND_V(!is_valid(), String());
- String output;
- output.resize(p_subject.length());
+ // safety_zone is the number of chars we allocate in addition to the number of chars expected in order to
+ // guard against the PCRE API writing one additional \0 at the end. PCRE's API docs are unclear on whether
+ // PCRE understands outlength in pcre2_substitute() as counting an implicit additional terminating char or
+ // not. always allocating one char more than telling PCRE has us on the safe side.
+ const int safety_zone = 1;
+
+ PCRE2_SIZE olength = p_subject.length() + 1; // space for output string and one terminating \0 character
+ Vector<CharType> output;
+ output.resize(olength + safety_zone);
uint32_t flags = PCRE2_SUBSTITUTE_OVERFLOW_LENGTH;
if (p_all)
flags |= PCRE2_SUBSTITUTE_GLOBAL;
- PCRE2_SIZE olength = output.length();
-
PCRE2_SIZE length = p_subject.length();
if (p_end >= 0 && (uint32_t)p_end < length)
length = p_end;
@@ -363,15 +368,15 @@ String RegEx::sub(const String &p_subject, const String &p_replacement, bool p_a
pcre2_match_context_16 *mctx = pcre2_match_context_create_16(gctx);
PCRE2_SPTR16 s = (PCRE2_SPTR16)p_subject.c_str();
PCRE2_SPTR16 r = (PCRE2_SPTR16)p_replacement.c_str();
- PCRE2_UCHAR16 *o = (PCRE2_UCHAR16 *)output.c_str();
+ PCRE2_UCHAR16 *o = (PCRE2_UCHAR16 *)output.ptrw();
pcre2_match_data_16 *match = pcre2_match_data_create_from_pattern_16(c, gctx);
int res = pcre2_substitute_16(c, s, length, p_offset, flags, match, mctx, r, p_replacement.length(), o, &olength);
if (res == PCRE2_ERROR_NOMEMORY) {
- output.resize(olength);
- o = (PCRE2_UCHAR16 *)output.c_str();
+ output.resize(olength + safety_zone);
+ o = (PCRE2_UCHAR16 *)output.ptrw();
res = pcre2_substitute_16(c, s, length, p_offset, flags, match, mctx, r, p_replacement.length(), o, &olength);
}
@@ -388,15 +393,15 @@ String RegEx::sub(const String &p_subject, const String &p_replacement, bool p_a
pcre2_match_context_32 *mctx = pcre2_match_context_create_32(gctx);
PCRE2_SPTR32 s = (PCRE2_SPTR32)p_subject.c_str();
PCRE2_SPTR32 r = (PCRE2_SPTR32)p_replacement.c_str();
- PCRE2_UCHAR32 *o = (PCRE2_UCHAR32 *)output.c_str();
+ PCRE2_UCHAR32 *o = (PCRE2_UCHAR32 *)output.ptrw();
pcre2_match_data_32 *match = pcre2_match_data_create_from_pattern_32(c, gctx);
int res = pcre2_substitute_32(c, s, length, p_offset, flags, match, mctx, r, p_replacement.length(), o, &olength);
if (res == PCRE2_ERROR_NOMEMORY) {
- output.resize(olength);
- o = (PCRE2_UCHAR32 *)output.c_str();
+ output.resize(olength + safety_zone);
+ o = (PCRE2_UCHAR32 *)output.ptrw();
res = pcre2_substitute_32(c, s, length, p_offset, flags, match, mctx, r, p_replacement.length(), o, &olength);
}
@@ -407,7 +412,7 @@ String RegEx::sub(const String &p_subject, const String &p_replacement, bool p_a
return String();
}
- return output;
+ return String(output.ptr(), olength);
}
bool RegEx::is_valid() const {
diff --git a/platform/android/java/src/org/godotengine/godot/Godot.java b/platform/android/java/src/org/godotengine/godot/Godot.java
index 37f25cc839..b5b0afb9e0 100644
--- a/platform/android/java/src/org/godotengine/godot/Godot.java
+++ b/platform/android/java/src/org/godotengine/godot/Godot.java
@@ -828,7 +828,6 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
//@Override public boolean dispatchTouchEvent (MotionEvent event) {
public boolean gotTouchEvent(final MotionEvent event) {
- super.onTouchEvent(event);
final int evcount = event.getPointerCount();
if (evcount == 0)
return true;
@@ -842,6 +841,7 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
arr[i * 3 + 1] = (int)event.getX(i);
arr[i * 3 + 2] = (int)event.getY(i);
}
+ final int pointer_idx = event.getPointerId(event.getActionIndex());
//System.out.printf("gaction: %d\n",event.getAction());
final int action = event.getAction() & MotionEvent.ACTION_MASK;
@@ -862,13 +862,10 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
*/
} break;
case MotionEvent.ACTION_POINTER_UP: {
- final int indexPointUp = event.getActionIndex();
- final int pointer_idx = event.getPointerId(indexPointUp);
GodotLib.touch(4, pointer_idx, evcount, arr);
//System.out.printf("%d - s.up at: %f,%f\n",pointer_idx, event.getX(pointer_idx),event.getY(pointer_idx));
} break;
case MotionEvent.ACTION_POINTER_DOWN: {
- int pointer_idx = event.getActionIndex();
GodotLib.touch(3, pointer_idx, evcount, arr);
//System.out.printf("%d - s.down at: %f,%f\n",pointer_idx, event.getX(pointer_idx),event.getY(pointer_idx));
} break;
diff --git a/platform/android/java/src/org/godotengine/godot/GodotView.java b/platform/android/java/src/org/godotengine/godot/GodotView.java
index ca4895a2be..0222758c2b 100644
--- a/platform/android/java/src/org/godotengine/godot/GodotView.java
+++ b/platform/android/java/src/org/godotengine/godot/GodotView.java
@@ -110,7 +110,7 @@ public class GodotView extends GLSurfaceView implements InputDeviceListener {
@Override
public boolean onTouchEvent(MotionEvent event) {
-
+ super.onTouchEvent(event);
return activity.gotTouchEvent(event);
};
diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp
index 93272a1000..23811f963a 100644
--- a/platform/android/os_android.cpp
+++ b/platform/android/os_android.cpp
@@ -444,25 +444,27 @@ void OS_Android::process_touch(int p_what, int p_pointer, const Vector<TouchPos>
}
touch.clear();
}
-
} break;
- case 3: { // add tuchi
-
- ERR_FAIL_INDEX(p_pointer, p_points.size());
+ case 3: { // add touch
- TouchPos tp = p_points[p_pointer];
- touch.push_back(tp);
+ for (int i = 0; i < p_points.size(); i++) {
+ if (p_points[i].id == p_pointer) {
+ TouchPos tp = p_points[i];
+ touch.push_back(tp);
- Ref<InputEventScreenTouch> ev;
- ev.instance();
+ Ref<InputEventScreenTouch> ev;
+ ev.instance();
- ev->set_index(tp.id);
- ev->set_pressed(true);
- ev->set_position(tp.pos);
- input->parse_input_event(ev);
+ ev->set_index(tp.id);
+ ev->set_pressed(true);
+ ev->set_position(tp.pos);
+ input->parse_input_event(ev);
+ break;
+ }
+ }
} break;
- case 4: {
+ case 4: { // remove touch
for (int i = 0; i < touch.size(); i++) {
if (touch[i].id == p_pointer) {
@@ -474,10 +476,10 @@ void OS_Android::process_touch(int p_what, int p_pointer, const Vector<TouchPos>
ev->set_position(touch[i].pos);
input->parse_input_event(ev);
touch.remove(i);
- i--;
+
+ break;
}
}
-
} break;
}
}
diff --git a/platform/iphone/export/export.cpp b/platform/iphone/export/export.cpp
index 99d44f3b5e..e3119814f4 100644
--- a/platform/iphone/export/export.cpp
+++ b/platform/iphone/export/export.cpp
@@ -407,7 +407,7 @@ Error EditorExportPlatformIOS::_export_loading_screens(const Ref<EditorExportPre
Error err = da->copy(loading_screen_file, p_dest_dir + info.export_name);
if (err) {
memdelete(da);
- String err_str = String("Failed to export loading screen: ") + loading_screen_file;
+ String err_str = String("Failed to export loading screen (") + info.preset_key + ") from path: " + loading_screen_file;
ERR_PRINT(err_str.utf8().get_data());
return err;
}
diff --git a/platform/osx/export/export.cpp b/platform/osx/export/export.cpp
index 23ca1e3fb9..c4efa1f0ff 100644
--- a/platform/osx/export/export.cpp
+++ b/platform/osx/export/export.cpp
@@ -359,6 +359,11 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p
}
if (err == OK) {
+ print_line("Creating " + tmp_app_path_name + "/Contents/Frameworks");
+ err = tmp_app_path->make_dir_recursive(tmp_app_path_name + "/Contents/Frameworks");
+ }
+
+ if (err == OK) {
print_line("Creating " + tmp_app_path_name + "/Contents/Resources");
err = tmp_app_path->make_dir_recursive(tmp_app_path_name + "/Contents/Resources");
}
@@ -502,10 +507,23 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p
if (use_dmg()) {
String pack_path = tmp_app_path_name + "/Contents/Resources/" + pkg_name + ".pck";
- err = save_pack(p_preset, pack_path);
+ Vector<SharedObject> shared_objects;
+ Error err = save_pack(p_preset, pack_path, &shared_objects);
// see if we can code sign our new package
String identity = p_preset->get("codesign/identity");
+
+ if (err == OK) {
+ DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
+ for (int i = 0; i < shared_objects.size(); i++) {
+ da->copy(shared_objects[i].path, tmp_app_path_name + "/Contents/Frameworks/" + shared_objects[i].path.get_file());
+ if (err == OK && identity != "") {
+ err = _code_sign(p_preset, tmp_app_path_name + "/Contents/Frameworks/" + shared_objects[i].path.get_file());
+ }
+ }
+ memdelete(da);
+ }
+
if (err == OK && identity != "") {
ep.step("Code signing bundle", 2);
@@ -582,7 +600,7 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p
ERR_CONTINUE(file.empty());
zipOpenNewFileInZip(dst_pkg_zip,
- (pkg_name + ".app/Contents/MacOS/").plus_file(shared_objects[i].path.get_file()).utf8().get_data(),
+ (pkg_name + ".app/Contents/Frameworks/").plus_file(shared_objects[i].path.get_file()).utf8().get_data(),
NULL,
NULL,
0,
diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h
index 9423b6e1d6..3648d41604 100644
--- a/platform/osx/os_osx.h
+++ b/platform/osx/os_osx.h
@@ -139,6 +139,8 @@ public:
virtual void alert(const String &p_alert, const String &p_title = "ALERT!");
+ virtual Error open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path = false);
+
virtual void set_cursor_shape(CursorShape p_shape);
virtual void set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot);
diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm
index 19f33c814f..939f75859c 100644
--- a/platform/osx/os_osx.mm
+++ b/platform/osx/os_osx.mm
@@ -39,6 +39,8 @@
#include "servers/visual/visual_server_raster.h"
#include "version_generated.gen.h"
+#include <mach-o/dyld.h>
+
#include <Carbon/Carbon.h>
#import <Cocoa/Cocoa.h>
#include <IOKit/IOCFPlugIn.h>
@@ -49,6 +51,7 @@
#include <os/log.h>
#endif
+#include <dlfcn.h>
#include <fcntl.h>
#include <libproc.h>
#include <stdio.h>
@@ -1262,6 +1265,28 @@ void OS_OSX::alert(const String &p_alert, const String &p_title) {
[window release];
}
+Error OS_OSX::open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path) {
+
+ String path = p_path;
+
+ if (!FileAccess::exists(path)) {
+ //this code exists so gdnative can load .dylib files from within the executable path
+ path = get_executable_path().get_base_dir().plus_file(p_path.get_file());
+ }
+
+ if (!FileAccess::exists(path)) {
+ //this code exists so gdnative can load .dylib files from a standard macOS location
+ path = get_executable_path().get_base_dir().plus_file("../Frameworks").plus_file(p_path.get_file());
+ }
+
+ p_library_handle = dlopen(path.utf8().get_data(), RTLD_NOW);
+ if (!p_library_handle) {
+ ERR_EXPLAIN("Can't open dynamic library: " + p_path + ". Error: " + dlerror());
+ ERR_FAIL_V(ERR_CANT_OPEN);
+ }
+ return OK;
+}
+
void OS_OSX::set_cursor_shape(CursorShape p_shape) {
if (cursor_shape == p_shape)
diff --git a/scene/3d/physics_body.h b/scene/3d/physics_body.h
index 332eb3c740..c7556c0c5f 100644
--- a/scene/3d/physics_body.h
+++ b/scene/3d/physics_body.h
@@ -115,7 +115,7 @@ public:
MODE_KINEMATIC,
};
-private:
+protected:
bool can_sleep;
PhysicsDirectBodyState *state;
Mode mode;
@@ -178,9 +178,8 @@ private:
void _body_exit_tree(ObjectID p_id);
void _body_inout(int p_status, ObjectID p_instance, int p_body_shape, int p_local_shape);
- void _direct_state_changed(Object *p_state);
+ virtual void _direct_state_changed(Object *p_state);
-protected:
void _notification(int p_what);
static void _bind_methods();
diff --git a/scene/3d/vehicle_body.cpp b/scene/3d/vehicle_body.cpp
index bc968b0a5f..aeee51c4b2 100644
--- a/scene/3d/vehicle_body.cpp
+++ b/scene/3d/vehicle_body.cpp
@@ -375,7 +375,7 @@ void VehicleBody::_update_wheel(int p_idx, PhysicsDirectBodyState *s) {
Basis steeringMat(up, steering);
- Basis rotatingMat(right, -wheel.m_rotation);
+ Basis rotatingMat(right, wheel.m_rotation);
/*
if (p_idx==1)
@@ -816,26 +816,24 @@ void VehicleBody::_update_friction(PhysicsDirectBodyState *s) {
void VehicleBody::_direct_state_changed(Object *p_state) {
- PhysicsDirectBodyState *s = Object::cast_to<PhysicsDirectBodyState>(p_state);
+ RigidBody::_direct_state_changed(p_state);
- set_ignore_transform_notification(true);
- set_global_transform(s->get_transform());
- set_ignore_transform_notification(false);
+ state = Object::cast_to<PhysicsDirectBodyState>(p_state);
- float step = s->get_step();
+ float step = state->get_step();
for (int i = 0; i < wheels.size(); i++) {
- _update_wheel(i, s);
+ _update_wheel(i, state);
}
for (int i = 0; i < wheels.size(); i++) {
- _ray_cast(i, s);
- wheels[i]->set_transform(s->get_transform().inverse() * wheels[i]->m_worldTransform);
+ _ray_cast(i, state);
+ wheels[i]->set_transform(state->get_transform().inverse() * wheels[i]->m_worldTransform);
}
- _update_suspension(s);
+ _update_suspension(state);
for (int i = 0; i < wheels.size(); i++) {
@@ -848,21 +846,21 @@ void VehicleBody::_direct_state_changed(Object *p_state) {
suspensionForce = wheel.m_maxSuspensionForce;
}
Vector3 impulse = wheel.m_raycastInfo.m_contactNormalWS * suspensionForce * step;
- Vector3 relpos = wheel.m_raycastInfo.m_contactPointWS - s->get_transform().origin;
+ Vector3 relpos = wheel.m_raycastInfo.m_contactPointWS - state->get_transform().origin;
- s->apply_impulse(relpos, impulse);
+ state->apply_impulse(relpos, impulse);
//getRigidBody()->applyImpulse(impulse, relpos);
}
- _update_friction(s);
+ _update_friction(state);
for (int i = 0; i < wheels.size(); i++) {
VehicleWheel &wheel = *wheels[i];
- Vector3 relpos = wheel.m_raycastInfo.m_hardPointWS - s->get_transform().origin;
- Vector3 vel = s->get_linear_velocity() + (s->get_angular_velocity()).cross(relpos); // * mPos);
+ Vector3 relpos = wheel.m_raycastInfo.m_hardPointWS - state->get_transform().origin;
+ Vector3 vel = state->get_linear_velocity() + (state->get_angular_velocity()).cross(relpos); // * mPos);
if (wheel.m_raycastInfo.m_isInContact) {
- const Transform &chassisWorldTransform = s->get_transform();
+ const Transform &chassisWorldTransform = state->get_transform();
Vector3 fwd(
chassisWorldTransform.basis[0][Vector3::AXIS_Z],
@@ -883,29 +881,8 @@ void VehicleBody::_direct_state_changed(Object *p_state) {
wheel.m_deltaRotation *= real_t(0.99); //damping of rotation when not in contact
}
- linear_velocity = s->get_linear_velocity();
-}
-
-void VehicleBody::set_mass(real_t p_mass) {
-
- mass = p_mass;
- PhysicsServer::get_singleton()->body_set_param(get_rid(), PhysicsServer::BODY_PARAM_MASS, mass);
-}
-
-real_t VehicleBody::get_mass() const {
- return mass;
-}
-
-void VehicleBody::set_friction(real_t p_friction) {
-
- friction = p_friction;
- PhysicsServer::get_singleton()->body_set_param(get_rid(), PhysicsServer::BODY_PARAM_FRICTION, friction);
-}
-
-real_t VehicleBody::get_friction() const {
-
- return friction;
+ state = NULL;
}
void VehicleBody::set_engine_force(float p_engine_force) {
@@ -936,18 +913,8 @@ float VehicleBody::get_steering() const {
return m_steeringValue;
}
-Vector3 VehicleBody::get_linear_velocity() const {
- return linear_velocity;
-}
-
void VehicleBody::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_mass", "mass"), &VehicleBody::set_mass);
- ClassDB::bind_method(D_METHOD("get_mass"), &VehicleBody::get_mass);
-
- ClassDB::bind_method(D_METHOD("set_friction", "friction"), &VehicleBody::set_friction);
- ClassDB::bind_method(D_METHOD("get_friction"), &VehicleBody::get_friction);
-
ClassDB::bind_method(D_METHOD("set_engine_force", "engine_force"), &VehicleBody::set_engine_force);
ClassDB::bind_method(D_METHOD("get_engine_force"), &VehicleBody::get_engine_force);
@@ -957,21 +924,14 @@ void VehicleBody::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_steering", "steering"), &VehicleBody::set_steering);
ClassDB::bind_method(D_METHOD("get_steering"), &VehicleBody::get_steering);
- ClassDB::bind_method(D_METHOD("get_linear_velocity"), &VehicleBody::get_linear_velocity);
-
- ClassDB::bind_method(D_METHOD("_direct_state_changed"), &VehicleBody::_direct_state_changed);
-
ADD_GROUP("Motion", "");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "engine_force", PROPERTY_HINT_RANGE, "0.00,1024.0,0.01"), "set_engine_force", "get_engine_force");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "brake", PROPERTY_HINT_RANGE, "0.0,1.0,0.01"), "set_brake", "get_brake");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "steering", PROPERTY_HINT_RANGE, "-180,180.0,0.01"), "set_steering", "get_steering");
- ADD_GROUP("Mass", "");
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "mass", PROPERTY_HINT_RANGE, "0.01,65536,0.01"), "set_mass", "get_mass");
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "friction", PROPERTY_HINT_RANGE, "0.01,1,0.01"), "set_friction", "get_friction");
}
VehicleBody::VehicleBody() :
- PhysicsBody(PhysicsServer::BODY_MODE_RIGID) {
+ RigidBody() {
m_pitchControl = 0;
m_currentVehicleSpeedKmHour = real_t(0.);
@@ -982,10 +942,11 @@ VehicleBody::VehicleBody() :
friction = 1;
+ state = NULL;
ccd = false;
exclude.insert(get_rid());
- PhysicsServer::get_singleton()->body_set_force_integration_callback(get_rid(), this, "_direct_state_changed");
+ //PhysicsServer::get_singleton()->body_set_force_integration_callback(get_rid(), this, "_direct_state_changed");
set_mass(40);
}
diff --git a/scene/3d/vehicle_body.h b/scene/3d/vehicle_body.h
index 1c7dacf5ac..7810a42e8a 100644
--- a/scene/3d/vehicle_body.h
+++ b/scene/3d/vehicle_body.h
@@ -139,20 +139,13 @@ public:
VehicleWheel();
};
-class VehicleBody : public PhysicsBody {
+class VehicleBody : public RigidBody {
- GDCLASS(VehicleBody, PhysicsBody);
-
- real_t mass;
- real_t friction;
+ GDCLASS(VehicleBody, RigidBody);
float engine_force;
float brake;
- Vector3 linear_velocity;
- Vector3 angular_velocity;
- bool ccd;
-
real_t m_pitchControl;
real_t m_steeringValue;
real_t m_currentVehicleSpeedKmHour;
@@ -192,12 +185,6 @@ class VehicleBody : public PhysicsBody {
void _direct_state_changed(Object *p_state);
public:
- void set_mass(real_t p_mass);
- real_t get_mass() const;
-
- void set_friction(real_t p_friction);
- real_t get_friction() const;
-
void set_engine_force(float p_engine_force);
float get_engine_force() const;
@@ -207,8 +194,6 @@ public:
void set_steering(float p_steering);
float get_steering() const;
- Vector3 get_linear_velocity() const;
-
VehicleBody();
};