summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--SConstruct5
-rw-r--r--core/bind/core_bind.cpp16
-rw-r--r--core/bind/core_bind.h4
-rw-r--r--core/class_db.cpp22
-rw-r--r--core/class_db.h1
-rw-r--r--core/color.h10
-rw-r--r--core/func_ref.cpp2
-rw-r--r--core/global_constants.cpp2
-rw-r--r--core/input_map.cpp4
-rw-r--r--core/math/matrix3.cpp14
-rw-r--r--core/message_queue.cpp6
-rw-r--r--core/node_path.cpp (renamed from core/path_db.cpp)4
-rw-r--r--core/node_path.h (renamed from core/path_db.h)6
-rw-r--r--core/object.cpp37
-rw-r--r--core/object.h7
-rw-r--r--core/os/keyboard.cpp4
-rw-r--r--core/os/keyboard.h4
-rw-r--r--core/os/memory.cpp40
-rw-r--r--core/os/memory.h12
-rw-r--r--core/os/os.cpp6
-rw-r--r--core/os/os.h4
-rw-r--r--core/os/thread.cpp8
-rw-r--r--core/os/thread.h8
-rw-r--r--core/os/thread_dummy.h2
-rw-r--r--core/project_settings.cpp4
-rw-r--r--core/reference.cpp4
-rw-r--r--core/resource.cpp5
-rw-r--r--core/script_debugger_remote.cpp6
-rw-r--r--core/script_language.cpp33
-rw-r--r--core/undo_redo.cpp12
-rw-r--r--core/variant.cpp2
-rw-r--r--core/variant.h2
-rw-r--r--doc/base/classes.xml77
-rw-r--r--drivers/gles3/rasterizer_canvas_gles3.cpp67
-rw-r--r--drivers/gles3/rasterizer_canvas_gles3.h2
-rw-r--r--drivers/gles3/rasterizer_gles3.cpp1
-rw-r--r--drivers/gles3/rasterizer_scene_gles3.cpp17
-rw-r--r--drivers/gles3/rasterizer_storage_gles3.cpp6
-rw-r--r--drivers/gles3/shaders/scene.glsl2
-rw-r--r--drivers/rtaudio/audio_driver_rtaudio.cpp20
-rw-r--r--drivers/unix/os_unix.cpp2
-rw-r--r--drivers/unix/os_unix.h2
-rw-r--r--drivers/unix/thread_posix.cpp6
-rw-r--r--drivers/unix/thread_posix.h4
-rw-r--r--drivers/windows/thread_windows.cpp6
-rw-r--r--drivers/windows/thread_windows.h4
-rw-r--r--editor/array_property_edit.cpp2
-rw-r--r--editor/asset_library_editor_plugin.cpp10
-rw-r--r--editor/connections_dialog.cpp2
-rw-r--r--editor/editor_data.cpp4
-rw-r--r--editor/editor_file_system.cpp4
-rw-r--r--editor/editor_help.cpp18
-rw-r--r--editor/editor_help.h1
-rw-r--r--editor/editor_log.cpp4
-rw-r--r--editor/editor_name_dialog.cpp4
-rw-r--r--editor/editor_node.cpp7
-rw-r--r--editor/editor_path.cpp2
-rw-r--r--editor/editor_resource_preview.cpp6
-rw-r--r--editor/editor_run.cpp2
-rw-r--r--editor/editor_settings.cpp46
-rw-r--r--editor/editor_themes.cpp24
-rw-r--r--editor/filesystem_dock.cpp4
-rw-r--r--editor/icons/2x/icon_GUI_dropdown.pngbin183 -> 198 bytes
-rw-r--r--editor/icons/icon_GUI_dropdown.pngbin130 -> 136 bytes
-rw-r--r--editor/icons/source/icon_GUI_dropdown.svg22
-rw-r--r--editor/icons/source/icon_connect.svg46
-rw-r--r--editor/import/editor_scene_importer_gltf.cpp2108
-rw-r--r--editor/import/editor_scene_importer_gltf.h304
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp6
-rw-r--r--editor/plugins/item_list_editor_plugin.h8
-rw-r--r--editor/plugins/script_editor_plugin.cpp105
-rw-r--r--editor/plugins/script_text_editor.cpp14
-rw-r--r--editor/plugins/spatial_editor_plugin.cpp55
-rw-r--r--editor/plugins/theme_editor_plugin.cpp2
-rw-r--r--editor/plugins/tile_map_editor_plugin.cpp2
-rw-r--r--editor/project_manager.cpp2
-rw-r--r--editor/project_settings_editor.cpp18
-rw-r--r--editor/property_editor.cpp8
-rw-r--r--editor/property_selector.cpp6
-rw-r--r--editor/resources_dock.cpp2
-rw-r--r--editor/scene_tree_dock.cpp6
-rw-r--r--editor/scene_tree_editor.cpp8
-rw-r--r--editor/script_create_dialog.cpp31
-rw-r--r--editor/spatial_editor_gizmos.cpp2
-rw-r--r--main/input_default.cpp11
-rw-r--r--main/main.cpp3
-rw-r--r--main/performance.cpp4
-rw-r--r--methods.py1
-rw-r--r--misc/scripts/makeargs.py12
-rw-r--r--modules/enet/networked_multiplayer_enet.cpp2
-rw-r--r--modules/gdnative/SCsub3
-rw-r--r--modules/gdnative/gdnative.cpp10
-rw-r--r--modules/gdnative/gdnative.h3
-rw-r--r--modules/gdnative/godot/array.cpp2
-rw-r--r--modules/gdnative/godot/array.h6
-rw-r--r--modules/gdnative/godot/basis.cpp4
-rw-r--r--modules/gdnative/godot/basis.h6
-rw-r--r--modules/gdnative/godot/color.cpp4
-rw-r--r--modules/gdnative/godot/color.h4
-rw-r--r--modules/gdnative/godot/dictionary.cpp3
-rw-r--r--modules/gdnative/godot/dictionary.h6
-rw-r--r--modules/gdnative/godot/gdnative.cpp2
-rw-r--r--modules/gdnative/godot/gdnative.h34
-rw-r--r--modules/gdnative/godot/node_path.cpp6
-rw-r--r--modules/gdnative/godot/node_path.h4
-rw-r--r--modules/gdnative/godot/plane.cpp4
-rw-r--r--modules/gdnative/godot/plane.h4
-rw-r--r--modules/gdnative/godot/pool_arrays.cpp2
-rw-r--r--modules/gdnative/godot/pool_arrays.h10
-rw-r--r--modules/gdnative/godot/quat.cpp4
-rw-r--r--modules/gdnative/godot/quat.h4
-rw-r--r--modules/gdnative/godot/rect2.cpp4
-rw-r--r--modules/gdnative/godot/rect2.h4
-rw-r--r--modules/gdnative/godot/rect3.cpp4
-rw-r--r--modules/gdnative/godot/rect3.h6
-rw-r--r--modules/gdnative/godot/rid.cpp4
-rw-r--r--modules/gdnative/godot/rid.h2
-rw-r--r--modules/gdnative/godot/string.cpp2
-rw-r--r--modules/gdnative/godot/string.h2
-rw-r--r--modules/gdnative/godot/transform.cpp4
-rw-r--r--modules/gdnative/godot/transform.h8
-rw-r--r--modules/gdnative/godot/transform2d.cpp4
-rw-r--r--modules/gdnative/godot/transform2d.h6
-rw-r--r--modules/gdnative/godot/variant.cpp4
-rw-r--r--modules/gdnative/godot/variant.h38
-rw-r--r--modules/gdnative/godot/vector2.cpp4
-rw-r--r--modules/gdnative/godot/vector2.h2
-rw-r--r--modules/gdnative/godot/vector3.cpp4
-rw-r--r--modules/gdnative/godot/vector3.h4
-rw-r--r--modules/gdnative/register_types.cpp22
-rw-r--r--modules/gdscript/gd_editor.cpp4
-rw-r--r--modules/gdscript/gd_function.cpp4
-rw-r--r--modules/gdscript/gd_script.cpp14
-rw-r--r--modules/gdscript/gd_script.h6
-rw-r--r--modules/gridmap/grid_map.cpp2
-rw-r--r--modules/nativescript/nativescript.cpp61
-rw-r--r--modules/nativescript/nativescript.h12
-rw-r--r--modules/nativescript/register_types.cpp12
-rw-r--r--modules/visual_script/visual_script.cpp8
-rw-r--r--modules/visual_script/visual_script.h4
-rw-r--r--modules/visual_script/visual_script_editor.cpp4
-rw-r--r--modules/visual_script/visual_script_func_nodes.cpp20
-rw-r--r--modules/visual_script/visual_script_nodes.cpp2
-rw-r--r--platform/android/SCsub2
-rw-r--r--platform/android/build.gradle.template4
-rw-r--r--platform/android/detect.py28
-rw-r--r--platform/android/export/export.cpp15
-rw-r--r--platform/android/java/gradle.properties17
-rw-r--r--platform/android/java/gradle/wrapper/gradle-wrapper.jarbin49896 -> 53636 bytes
-rw-r--r--platform/android/java/gradle/wrapper/gradle-wrapper.properties5
-rwxr-xr-xplatform/android/java/gradlew10
-rw-r--r--platform/android/java_class_wrapper.cpp12
-rw-r--r--platform/android/java_glue.cpp10
-rw-r--r--platform/android/os_android.cpp4
-rw-r--r--platform/android/os_android.h2
-rw-r--r--platform/android/thread_jandroid.cpp6
-rw-r--r--platform/android/thread_jandroid.h4
-rw-r--r--platform/haiku/key_mapping_haiku.cpp2
-rw-r--r--platform/iphone/app_delegate.mm2
-rw-r--r--platform/iphone/os_iphone.cpp12
-rw-r--r--platform/iphone/os_iphone.h4
-rw-r--r--platform/javascript/dom_keys.h2
-rw-r--r--platform/javascript/os_javascript.cpp121
-rw-r--r--platform/javascript/os_javascript.h5
-rw-r--r--platform/osx/os_osx.h2
-rw-r--r--platform/osx/os_osx.mm57
-rw-r--r--platform/uwp/joypad_uwp.cpp75
-rw-r--r--platform/uwp/joypad_uwp.h8
-rw-r--r--platform/uwp/thread_uwp.cpp6
-rw-r--r--platform/uwp/thread_uwp.h4
-rw-r--r--platform/windows/key_mapping_win.cpp2
-rw-r--r--platform/windows/os_windows.cpp8
-rw-r--r--platform/windows/os_windows.h2
-rw-r--r--platform/x11/key_mapping_x11.cpp4
-rw-r--r--platform/x11/os_x11.cpp4
-rw-r--r--scene/2d/animated_sprite.cpp1
-rw-r--r--scene/2d/area_2d.cpp4
-rw-r--r--scene/2d/camera_2d.cpp2
-rw-r--r--scene/2d/collision_object_2d.cpp4
-rw-r--r--scene/2d/node_2d.cpp4
-rw-r--r--scene/2d/node_2d.h2
-rw-r--r--scene/2d/particles_2d.cpp1
-rw-r--r--scene/2d/physics_body_2d.cpp34
-rw-r--r--scene/2d/physics_body_2d.h3
-rw-r--r--scene/2d/remote_transform_2d.cpp2
-rw-r--r--scene/2d/sprite.cpp4
-rw-r--r--scene/2d/tile_map.cpp17
-rw-r--r--scene/2d/tile_map.h1
-rw-r--r--scene/2d/visibility_notifier_2d.cpp1
-rw-r--r--scene/3d/area.cpp4
-rw-r--r--scene/3d/arvr_nodes.cpp113
-rw-r--r--scene/3d/arvr_nodes.h37
-rw-r--r--scene/3d/collision_object.cpp4
-rw-r--r--scene/3d/physics_body.cpp31
-rw-r--r--scene/3d/physics_body.h2
-rw-r--r--scene/3d/physics_joint.cpp26
-rw-r--r--scene/3d/physics_joint.h8
-rw-r--r--scene/3d/remote_transform.cpp2
-rw-r--r--scene/3d/skeleton.cpp4
-rw-r--r--scene/3d/sprite_3d.cpp4
-rw-r--r--scene/3d/visibility_notifier.cpp2
-rw-r--r--scene/3d/visual_instance.cpp2
-rw-r--r--scene/animation/animation_player.cpp4
-rw-r--r--scene/animation/animation_tree_player.cpp2
-rw-r--r--scene/animation/tween.cpp24
-rw-r--r--scene/gui/base_button.cpp2
-rw-r--r--scene/gui/control.cpp2
-rw-r--r--scene/gui/item_list.cpp8
-rw-r--r--scene/gui/line_edit.cpp4
-rw-r--r--scene/gui/menu_button.cpp2
-rw-r--r--scene/gui/option_button.cpp22
-rw-r--r--scene/gui/option_button.h6
-rw-r--r--scene/gui/popup_menu.cpp16
-rw-r--r--scene/gui/popup_menu.h4
-rw-r--r--scene/gui/tabs.cpp4
-rw-r--r--scene/gui/text_edit.cpp127
-rw-r--r--scene/gui/tree.cpp11
-rw-r--r--scene/main/canvas_layer.cpp2
-rwxr-xr-xscene/main/node.cpp97
-rw-r--r--scene/main/node.h2
-rw-r--r--scene/main/scene_tree.cpp4
-rw-r--r--scene/main/viewport.cpp87
-rw-r--r--scene/register_scene_types.cpp1
-rw-r--r--scene/resources/material.cpp109
-rw-r--r--scene/resources/material.h31
-rw-r--r--scene/resources/packed_scene.cpp3
-rw-r--r--scene/resources/surface_tool.cpp75
-rw-r--r--scene/resources/surface_tool.h3
-rw-r--r--scene/resources/texture.cpp3
-rw-r--r--scene/scene_string_names.cpp8
-rw-r--r--scene/scene_string_names.h4
-rw-r--r--servers/arvr/arvr_positional_tracker.cpp33
-rw-r--r--servers/arvr/arvr_positional_tracker.h8
-rw-r--r--servers/audio_server.cpp8
-rw-r--r--servers/physics/area_sw.h1
-rw-r--r--servers/physics/body_sw.cpp3
-rw-r--r--servers/physics/body_sw.h1
-rw-r--r--servers/physics/joints/pin_joint_sw.h8
-rw-r--r--servers/physics/physics_server_sw.cpp60
-rw-r--r--servers/physics/physics_server_sw.h16
-rw-r--r--servers/physics/space_sw.cpp6
-rw-r--r--servers/physics_2d/area_2d_sw.h1
-rw-r--r--servers/physics_2d/body_2d_sw.h1
-rw-r--r--servers/physics_2d/broad_phase_2d_hash_grid.cpp6
-rw-r--r--servers/physics_2d/physics_2d_server_sw.cpp45
-rw-r--r--servers/physics_2d/physics_2d_server_sw.h8
-rw-r--r--servers/physics_2d/physics_2d_server_wrap_mt.cpp6
-rw-r--r--servers/physics_2d/physics_2d_server_wrap_mt.h18
-rw-r--r--servers/physics_2d_server.cpp8
-rw-r--r--servers/physics_2d_server.h8
-rw-r--r--servers/physics_server.cpp16
-rw-r--r--servers/physics_server.h16
-rw-r--r--servers/server_wrap_mt_common.h126
-rw-r--r--servers/visual/rasterizer.h2
-rw-r--r--servers/visual/visual_server_raster.cpp37
-rw-r--r--servers/visual/visual_server_raster.h13
-rw-r--r--servers/visual/visual_server_scene.cpp2
-rw-r--r--servers/visual/visual_server_scene.h2
-rw-r--r--servers/visual/visual_server_wrap_mt.cpp4
-rw-r--r--servers/visual/visual_server_wrap_mt.h8
-rw-r--r--servers/visual_server.h8
-rw-r--r--thirdparty/misc/base64.h5
262 files changed, 4577 insertions, 1178 deletions
diff --git a/SConstruct b/SConstruct
index 4085f713b7..45765976cd 100644
--- a/SConstruct
+++ b/SConstruct
@@ -461,7 +461,8 @@ screen = sys.stdout
node_count = 0
node_count_max = 0
node_count_interval = 1
-node_count_fname = str(env.Dir('#')) + '/.scons_node_count'
+if ('env' in locals()):
+ node_count_fname = str(env.Dir('#')) + '/.scons_node_count'
def progress_function(node):
global node_count, node_count_max, node_count_interval, node_count_fname
@@ -481,7 +482,7 @@ def progress_finish(target, source, env):
with open(node_count_fname, 'w') as f:
f.write('%d\n' % node_count)
-if (env["progress"] == "yes"):
+if ('env' in locals() and env["progress"] == "yes"):
try:
with open(node_count_fname) as f:
node_count_max = int(f.readline())
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp
index ce08b3f754..3e289eeaf3 100644
--- a/core/bind/core_bind.cpp
+++ b/core/bind/core_bind.cpp
@@ -180,8 +180,8 @@ int _OS::get_mouse_button_state() const {
return OS::get_singleton()->get_mouse_button_state();
}
-String _OS::get_unique_ID() const {
- return OS::get_singleton()->get_unique_ID();
+String _OS::get_unique_id() const {
+ return OS::get_singleton()->get_unique_id();
}
bool _OS::has_touchscreen_ui_hint() const {
@@ -369,9 +369,9 @@ Error _OS::kill(int p_pid) {
return OS::get_singleton()->kill(p_pid);
}
-int _OS::get_process_ID() const {
+int _OS::get_process_id() const {
- return OS::get_singleton()->get_process_ID();
+ return OS::get_singleton()->get_process_id();
};
bool _OS::has_environment(const String &p_var) const {
@@ -800,7 +800,7 @@ void _OS::print_all_textures_by_size() {
img.fmt = fmt;
img.path = E->get()->get_path();
img.vram = Image::get_image_data_size(img.size.width, img.size.height, Image::Format(img.fmt));
- img.id = E->get()->get_instance_ID();
+ img.id = E->get()->get_instance_id();
total += img.vram;
imgs.push_back(img);
}
@@ -1019,7 +1019,7 @@ void _OS::_bind_methods() {
ClassDB::bind_method(D_METHOD("execute", "path", "arguments", "blocking", "output"), &_OS::execute, DEFVAL(Array()));
ClassDB::bind_method(D_METHOD("kill", "pid"), &_OS::kill);
ClassDB::bind_method(D_METHOD("shell_open", "uri"), &_OS::shell_open);
- ClassDB::bind_method(D_METHOD("get_process_ID"), &_OS::get_process_ID);
+ ClassDB::bind_method(D_METHOD("get_process_id"), &_OS::get_process_id);
ClassDB::bind_method(D_METHOD("get_environment", "environment"), &_OS::get_environment);
ClassDB::bind_method(D_METHOD("has_environment", "environment"), &_OS::has_environment);
@@ -1074,7 +1074,7 @@ void _OS::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_data_dir"), &_OS::get_data_dir);
ClassDB::bind_method(D_METHOD("get_system_dir", "dir"), &_OS::get_system_dir);
- ClassDB::bind_method(D_METHOD("get_unique_ID"), &_OS::get_unique_ID);
+ ClassDB::bind_method(D_METHOD("get_unique_id"), &_OS::get_unique_id);
ClassDB::bind_method(D_METHOD("is_ok_left_and_cancel_right"), &_OS::is_ok_left_and_cancel_right);
@@ -2256,7 +2256,7 @@ String _Thread::get_id() const {
if (!thread)
return String();
- return itos(thread->get_ID());
+ return itos(thread->get_id());
}
bool _Thread::is_active() const {
diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h
index ec4fd3f476..e18d663d85 100644
--- a/core/bind/core_bind.h
+++ b/core/bind/core_bind.h
@@ -175,7 +175,7 @@ public:
Error kill(int p_pid);
Error shell_open(String p_uri);
- int get_process_ID() const;
+ int get_process_id() const;
bool has_environment(const String &p_var) const;
String get_environment(const String &p_var) const;
@@ -204,7 +204,7 @@ public:
bool is_debug_build() const;
- String get_unique_ID() const;
+ String get_unique_id() const;
String get_scancode_string(uint32_t p_code) const;
bool is_scancode_unicode(uint32_t p_unicode) const;
diff --git a/core/class_db.cpp b/core/class_db.cpp
index 6b8c290a99..24d71f86b0 100644
--- a/core/class_db.cpp
+++ b/core/class_db.cpp
@@ -937,6 +937,28 @@ bool ClassDB::get_property(Object *p_object, const StringName &p_property, Varia
return false;
}
+int ClassDB::get_property_index(const StringName &p_class, const StringName &p_property, bool *r_is_valid) {
+
+ ClassInfo *type = classes.getptr(p_class);
+ ClassInfo *check = type;
+ while (check) {
+ const PropertySetGet *psg = check->property_setget.getptr(p_property);
+ if (psg) {
+
+ if (r_is_valid)
+ *r_is_valid = true;
+
+ return psg->index;
+ }
+
+ check = check->inherits_ptr;
+ }
+ if (r_is_valid)
+ *r_is_valid = false;
+
+ return -1;
+}
+
Variant::Type ClassDB::get_property_type(const StringName &p_class, const StringName &p_property, bool *r_is_valid) {
ClassInfo *type = classes.getptr(p_class);
diff --git a/core/class_db.h b/core/class_db.h
index 4f00a16e91..02eac0dbbc 100644
--- a/core/class_db.h
+++ b/core/class_db.h
@@ -480,6 +480,7 @@ public:
static bool set_property(Object *p_object, const StringName &p_property, const Variant &p_value, bool *r_valid = NULL);
static bool get_property(Object *p_object, const StringName &p_property, Variant &r_value);
static bool has_property(const StringName &p_class, const StringName &p_property, bool p_no_inheritance = false);
+ static int get_property_index(const StringName &p_class, const StringName &p_property, bool *r_is_valid = NULL);
static Variant::Type get_property_type(const StringName &p_class, const StringName &p_property, bool *r_is_valid = NULL);
static StringName get_property_setter(StringName p_class, const StringName p_property);
static StringName get_property_getter(StringName p_class, const StringName p_property);
diff --git a/core/color.h b/core/color.h
index c83dcda4b4..9074a0e6d6 100644
--- a/core/color.h
+++ b/core/color.h
@@ -140,8 +140,16 @@ struct Color {
b < 0.04045 ? b * (1.0 / 12.92) : Math::pow((b + 0.055) * (1.0 / (1 + 0.055)), 2.4),
a);
}
+ _FORCE_INLINE_ Color to_srgb() const {
- static Color hex(uint32_t p_hex);
+ return Color(
+ r < 0.0031308 ? 12.92 * r : (1.0 + 0.055) * Math::pow(r, 1.0f / 2.4f) - 0.055,
+ g < 0.0031308 ? 12.92 * g : (1.0 + 0.055) * Math::pow(g, 1.0f / 2.4f) - 0.055,
+ b < 0.0031308 ? 12.92 * b : (1.0 + 0.055) * Math::pow(b, 1.0f / 2.4f) - 0.055, a);
+ }
+
+ static Color
+ hex(uint32_t p_hex);
static Color html(const String &p_color);
static bool html_is_valid(const String &p_color);
static Color named(const String &p_name);
diff --git a/core/func_ref.cpp b/core/func_ref.cpp
index 1121c6d3e4..2d74efd822 100644
--- a/core/func_ref.cpp
+++ b/core/func_ref.cpp
@@ -48,7 +48,7 @@ Variant FuncRef::call_func(const Variant **p_args, int p_argcount, Variant::Call
void FuncRef::set_instance(Object *p_obj) {
ERR_FAIL_NULL(p_obj);
- id = p_obj->get_instance_ID();
+ id = p_obj->get_instance_id();
}
void FuncRef::set_function(const StringName &p_func) {
diff --git a/core/global_constants.cpp b/core/global_constants.cpp
index 18071d7748..9e745ecb98 100644
--- a/core/global_constants.cpp
+++ b/core/global_constants.cpp
@@ -67,8 +67,8 @@ static _GlobalConstant _global_constants[] = {
BIND_GLOBAL_CONSTANT(KEY_TAB),
BIND_GLOBAL_CONSTANT(KEY_BACKTAB),
BIND_GLOBAL_CONSTANT(KEY_BACKSPACE),
- BIND_GLOBAL_CONSTANT(KEY_RETURN),
BIND_GLOBAL_CONSTANT(KEY_ENTER),
+ BIND_GLOBAL_CONSTANT(KEY_KP_ENTER),
BIND_GLOBAL_CONSTANT(KEY_INSERT),
BIND_GLOBAL_CONSTANT(KEY_DELETE),
BIND_GLOBAL_CONSTANT(KEY_PAUSE),
diff --git a/core/input_map.cpp b/core/input_map.cpp
index 24d0624e98..85e627f352 100644
--- a/core/input_map.cpp
+++ b/core/input_map.cpp
@@ -219,11 +219,11 @@ void InputMap::load_default() {
add_action("ui_accept");
key.instance();
- key->set_scancode(KEY_RETURN);
+ key->set_scancode(KEY_ENTER);
action_add_event("ui_accept", key);
key.instance();
- key->set_scancode(KEY_ENTER);
+ key->set_scancode(KEY_KP_ENTER);
action_add_event("ui_accept", key);
key.instance();
diff --git a/core/math/matrix3.cpp b/core/math/matrix3.cpp
index b59fecc196..b64f34d977 100644
--- a/core/math/matrix3.cpp
+++ b/core/math/matrix3.cpp
@@ -30,7 +30,7 @@
#include "matrix3.h"
#include "math_funcs.h"
#include "os/copymem.h"
-
+#include "print_string.h"
#define cofac(row1, col1, row2, col2) \
(elements[row1][col1] * elements[row2][col2] - elements[row1][col2] * elements[row2][col1])
@@ -364,8 +364,16 @@ Vector3 Basis::get_euler() const {
euler.y = Math::asin(elements[0][2]);
if (euler.y < Math_PI * 0.5) {
if (euler.y > -Math_PI * 0.5) {
- euler.x = Math::atan2(-elements[1][2], elements[2][2]);
- euler.z = Math::atan2(-elements[0][1], elements[0][0]);
+ //if rotation is Y-only, return a proper -pi,pi range like in x or z for the same case.
+ if (elements[1][0] == 0.0 && elements[0][1] == 0.0 && elements[0][0] < 0.0) {
+ if (euler.y > 0.0)
+ euler.y = Math_PI - euler.y;
+ else
+ euler.y = -(Math_PI + euler.y);
+ } else {
+ euler.x = Math::atan2(-elements[1][2], elements[2][2]);
+ euler.z = Math::atan2(-elements[0][1], elements[0][0]);
+ }
} else {
real_t r = Math::atan2(elements[1][0], elements[1][1]);
diff --git a/core/message_queue.cpp b/core/message_queue.cpp
index 93d0b0730a..564069d8bb 100644
--- a/core/message_queue.cpp
+++ b/core/message_queue.cpp
@@ -153,16 +153,16 @@ Error MessageQueue::push_notification(ObjectID p_id, int p_notification) {
Error MessageQueue::push_call(Object *p_object, const StringName &p_method, VARIANT_ARG_DECLARE) {
- return push_call(p_object->get_instance_ID(), p_method, VARIANT_ARG_PASS);
+ return push_call(p_object->get_instance_id(), p_method, VARIANT_ARG_PASS);
}
Error MessageQueue::push_notification(Object *p_object, int p_notification) {
- return push_notification(p_object->get_instance_ID(), p_notification);
+ return push_notification(p_object->get_instance_id(), p_notification);
}
Error MessageQueue::push_set(Object *p_object, const StringName &p_prop, const Variant &p_value) {
- return push_set(p_object->get_instance_ID(), p_prop, p_value);
+ return push_set(p_object->get_instance_id(), p_prop, p_value);
}
void MessageQueue::statistics() {
diff --git a/core/path_db.cpp b/core/node_path.cpp
index d5c84a2457..ad2eae859d 100644
--- a/core/path_db.cpp
+++ b/core/node_path.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* path_db.cpp */
+/* node_path.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,7 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "path_db.h"
+#include "node_path.h"
#include "print_string.h"
diff --git a/core/path_db.h b/core/node_path.h
index 1aed7535ca..31446ab9b4 100644
--- a/core/path_db.h
+++ b/core/node_path.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* path_db.h */
+/* node_path.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,8 +27,8 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef PATH_DB_H
-#define PATH_DB_H
+#ifndef NODE_PATH_H
+#define NODE_PATH_H
#include "string_db.h"
#include "ustring.h"
diff --git a/core/object.cpp b/core/object.cpp
index 316c624268..de75257ede 100644
--- a/core/object.cpp
+++ b/core/object.cpp
@@ -599,7 +599,7 @@ Variant Object::_call_deferred_bind(const Variant **p_args, int p_argcount, Vari
StringName method = *p_args[0];
- MessageQueue::get_singleton()->push_call(get_instance_ID(), method, &p_args[1], p_argcount - 1);
+ MessageQueue::get_singleton()->push_call(get_instance_id(), method, &p_args[1], p_argcount - 1);
return Variant();
}
@@ -1182,10 +1182,10 @@ Variant Object::_emit_signal(const Variant **p_args, int p_argcount, Variant::Ca
return Variant();
}
-void Object::emit_signal(const StringName &p_name, const Variant **p_args, int p_argcount) {
+Error Object::emit_signal(const StringName &p_name, const Variant **p_args, int p_argcount) {
if (_block_signals)
- return; //no emit, signals blocked
+ return ERR_CANT_AQUIRE_RESOURCE; //no emit, signals blocked
Signal *s = signal_map.getptr(p_name);
if (!s) {
@@ -1194,11 +1194,11 @@ void Object::emit_signal(const StringName &p_name, const Variant **p_args, int p
//check in script
if (!signal_is_valid && !script.is_null() && !Ref<Script>(script)->has_script_signal(p_name)) {
ERR_EXPLAIN("Can't emit non-existing signal " + String("\"") + p_name + "\".");
- ERR_FAIL();
+ ERR_FAIL_V(ERR_UNAVAILABLE);
}
#endif
//not connected? just return
- return;
+ return ERR_UNAVAILABLE;
}
List<_ObjectSignalDisconnectData> disconnect_data;
@@ -1214,6 +1214,8 @@ void Object::emit_signal(const StringName &p_name, const Variant **p_args, int p
Vector<const Variant *> bind_mem;
+ Error err = OK;
+
for (int i = 0; i < ssize; i++) {
const Connection &c = slot_map.getv(i).conn;
@@ -1245,16 +1247,18 @@ void Object::emit_signal(const StringName &p_name, const Variant **p_args, int p
}
if (c.flags & CONNECT_DEFERRED) {
- MessageQueue::get_singleton()->push_call(target->get_instance_ID(), c.method, args, argc, true);
+ MessageQueue::get_singleton()->push_call(target->get_instance_id(), c.method, args, argc, true);
} else {
Variant::CallError ce;
target->call(c.method, args, argc, ce);
+
if (ce.error != Variant::CallError::CALL_OK) {
if (ce.error == Variant::CallError::CALL_ERROR_INVALID_METHOD && !ClassDB::class_exists(target->get_class_name())) {
//most likely object is not initialized yet, do not throw error.
} else {
ERR_PRINTS("Error calling method from signal '" + String(p_name) + "': " + Variant::get_call_error_text(target, c.method, args, argc, ce));
+ err = ERR_METHOD_NOT_FOUND;
}
}
}
@@ -1274,21 +1278,24 @@ void Object::emit_signal(const StringName &p_name, const Variant **p_args, int p
disconnect(dd.signal, dd.target, dd.method);
disconnect_data.pop_front();
}
+
+ return err;
}
-void Object::emit_signal(const StringName &p_name, VARIANT_ARG_DECLARE) {
+Error Object::emit_signal(const StringName &p_name, VARIANT_ARG_DECLARE) {
VARIANT_ARGPTRS;
int argc = 0;
for (int i = 0; i < VARIANT_ARG_MAX; i++) {
+
if (argptr[i]->get_type() == Variant::NIL)
break;
argc++;
}
- emit_signal(p_name, argptr, argc);
+ return emit_signal(p_name, argptr, argc);
}
void Object::_add_user_signal(const String &p_name, const Array &p_args) {
@@ -1471,7 +1478,7 @@ Error Object::connect(const StringName &p_signal, Object *p_to_object, const Str
s = &signal_map[p_signal];
}
- Signal::Target target(p_to_object->get_instance_ID(), p_to_method);
+ Signal::Target target(p_to_object->get_instance_id(), p_to_method);
if (s->slot_map.has(target)) {
ERR_EXPLAIN("Signal '" + p_signal + "'' already connected to given method '" + p_to_method + "' in that object.");
ERR_FAIL_COND_V(s->slot_map.has(target), ERR_INVALID_PARAMETER);
@@ -1509,7 +1516,7 @@ bool Object::is_connected(const StringName &p_signal, Object *p_to_object, const
ERR_FAIL_COND_V(!s, false);
}
- Signal::Target target(p_to_object->get_instance_ID(), p_to_method);
+ Signal::Target target(p_to_object->get_instance_id(), p_to_method);
return s->slot_map.has(target);
//const Map<Signal::Target,Signal::Slot>::Element *E = s->slot_map.find(target);
@@ -1529,7 +1536,7 @@ void Object::disconnect(const StringName &p_signal, Object *p_to_object, const S
ERR_FAIL_COND(s->lock > 0);
}
- Signal::Target target(p_to_object->get_instance_ID(), p_to_method);
+ Signal::Target target(p_to_object->get_instance_id(), p_to_method);
if (!s->slot_map.has(target)) {
ERR_EXPLAIN("Disconnecting nonexistent signal '" + p_signal + "', slot: " + itos(target._id) + ":" + target.method);
@@ -1660,7 +1667,7 @@ void Object::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_property_list"), &Object::_get_property_list_bind);
ClassDB::bind_method(D_METHOD("get_method_list"), &Object::_get_method_list_bind);
ClassDB::bind_method(D_METHOD("notification", "what", "reversed"), &Object::notification, DEFVAL(false));
- ClassDB::bind_method(D_METHOD("get_instance_ID"), &Object::get_instance_ID);
+ ClassDB::bind_method(D_METHOD("get_instance_id"), &Object::get_instance_id);
ClassDB::bind_method(D_METHOD("set_script", "script:Script"), &Object::set_script);
ClassDB::bind_method(D_METHOD("get_script:Script"), &Object::get_script);
@@ -1929,7 +1936,7 @@ ObjectID ObjectDB::instance_counter = 1;
HashMap<Object *, ObjectID, ObjectDB::ObjectPtrHash> ObjectDB::instance_checks;
ObjectID ObjectDB::add_instance(Object *p_object) {
- ERR_FAIL_COND_V(p_object->get_instance_ID() != 0, 0);
+ ERR_FAIL_COND_V(p_object->get_instance_id() != 0, 0);
rw_lock->write_lock();
instances[++instance_counter] = p_object;
@@ -1945,7 +1952,7 @@ void ObjectDB::remove_instance(Object *p_object) {
rw_lock->write_lock();
- instances.erase(p_object->get_instance_ID());
+ instances.erase(p_object->get_instance_id());
#ifdef DEBUG_ENABLED
instance_checks.erase(p_object);
#endif
@@ -2008,7 +2015,7 @@ void ObjectDB::cleanup() {
String node_name;
if (instances[*K]->is_class("Node"))
node_name = " - Node Name: " + String(instances[*K]->call("get_name"));
- if (instances[*K]->is_class("Resoucre"))
+ if (instances[*K]->is_class("Resource"))
node_name = " - Resource Name: " + String(instances[*K]->call("get_name")) + " Path: " + String(instances[*K]->call("get_path"));
print_line("Leaked Instance: " + String(instances[*K]->get_class()) + ":" + itos(*K) + node_name);
}
diff --git a/core/object.h b/core/object.h
index 148a73fbc4..f0147080b4 100644
--- a/core/object.h
+++ b/core/object.h
@@ -105,6 +105,7 @@ enum PropertyUsageFlags {
PROPERTY_USAGE_STORE_IF_NULL = 16384,
PROPERTY_USAGE_ANIMATE_AS_TRIGGER = 32768,
PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED = 65536,
+ PROPERTY_USAGE_SCRIPT_DEFAULT_VALUE = 1 << 17,
PROPERTY_USAGE_DEFAULT = PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_NETWORK,
PROPERTY_USAGE_DEFAULT_INTL = PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_NETWORK | PROPERTY_USAGE_INTERNATIONALIZED,
@@ -533,7 +534,7 @@ public:
bool _is_gpl_reversed() const { return false; }
- _FORCE_INLINE_ ObjectID get_instance_ID() const { return _instance_ID; }
+ _FORCE_INLINE_ ObjectID get_instance_id() const { return _instance_ID; }
// this is used for editors
void add_change_receptor(Object *p_receptor);
@@ -654,8 +655,8 @@ public:
void set_script_and_instance(const RefPtr &p_script, ScriptInstance *p_instance); //some script languages can't control instance creation, so this function eases the process
void add_user_signal(const MethodInfo &p_signal);
- void emit_signal(const StringName &p_name, VARIANT_ARG_LIST);
- void emit_signal(const StringName &p_name, const Variant **p_args, int p_argcount);
+ Error emit_signal(const StringName &p_name, VARIANT_ARG_LIST);
+ Error emit_signal(const StringName &p_name, const Variant **p_args, int p_argcount);
void get_signal_list(List<MethodInfo> *p_signals) const;
void get_signal_connection_list(const StringName &p_signal, List<Connection> *p_connections) const;
void get_all_signal_connections(List<Connection> *p_connections) const;
diff --git a/core/os/keyboard.cpp b/core/os/keyboard.cpp
index e154b1934d..9b3e376ea6 100644
--- a/core/os/keyboard.cpp
+++ b/core/os/keyboard.cpp
@@ -42,8 +42,8 @@ static const _KeyCodeText _keycodes[] = {
{KEY_TAB ,"Tab"},
{KEY_BACKTAB ,"BackTab"},
{KEY_BACKSPACE ,"BackSpace"},
- {KEY_RETURN ,"Return"},
{KEY_ENTER ,"Enter"},
+ {KEY_KP_ENTER ,"Kp Enter"},
{KEY_INSERT ,"Insert"},
{KEY_DELETE ,"Delete"},
{KEY_PAUSE ,"Pause"},
@@ -294,8 +294,8 @@ bool keycode_has_unicode(uint32_t p_keycode) {
case KEY_TAB:
case KEY_BACKTAB:
case KEY_BACKSPACE:
- case KEY_RETURN:
case KEY_ENTER:
+ case KEY_KP_ENTER:
case KEY_INSERT:
case KEY_DELETE:
case KEY_PAUSE:
diff --git a/core/os/keyboard.h b/core/os/keyboard.h
index c6985c887d..1ed93e3540 100644
--- a/core/os/keyboard.h
+++ b/core/os/keyboard.h
@@ -57,8 +57,8 @@ enum KeyList {
KEY_TAB = SPKEY | 0x02,
KEY_BACKTAB = SPKEY | 0x03,
KEY_BACKSPACE = SPKEY | 0x04,
- KEY_RETURN = SPKEY | 0x05,
- KEY_ENTER = SPKEY | 0x06,
+ KEY_ENTER = SPKEY | 0x05,
+ KEY_KP_ENTER = SPKEY | 0x06,
KEY_INSERT = SPKEY | 0x07,
KEY_DELETE = SPKEY | 0x08,
KEY_PAUSE = SPKEY | 0x09,
diff --git a/core/os/memory.cpp b/core/os/memory.cpp
index 069ee48fae..acc960acd9 100644
--- a/core/os/memory.cpp
+++ b/core/os/memory.cpp
@@ -29,6 +29,7 @@
/*************************************************************************/
#include "memory.h"
#include "copymem.h"
+#include "core/safe_refcount.h"
#include "error_macros.h"
#include <stdio.h>
#include <stdlib.h>
@@ -43,14 +44,12 @@ void *operator new(size_t p_size, void *(*p_allocfunc)(size_t p_size)) {
return p_allocfunc(p_size);
}
-#include <stdio.h>
-
#ifdef DEBUG_ENABLED
-size_t Memory::mem_usage = 0;
-size_t Memory::max_usage = 0;
+uint64_t Memory::mem_usage = 0;
+uint64_t Memory::max_usage = 0;
#endif
-size_t Memory::alloc_count = 0;
+uint64_t Memory::alloc_count = 0;
void *Memory::alloc_static(size_t p_bytes, bool p_pad_align) {
@@ -62,10 +61,10 @@ void *Memory::alloc_static(size_t p_bytes, bool p_pad_align) {
void *mem = malloc(p_bytes + (prepad ? PAD_ALIGN : 0));
- alloc_count++;
-
ERR_FAIL_COND_V(!mem, NULL);
+ atomic_increment(&alloc_count);
+
if (prepad) {
uint64_t *s = (uint64_t *)mem;
*s = p_bytes;
@@ -73,10 +72,8 @@ void *Memory::alloc_static(size_t p_bytes, bool p_pad_align) {
uint8_t *s8 = (uint8_t *)mem;
#ifdef DEBUG_ENABLED
- mem_usage += p_bytes;
- if (mem_usage > max_usage) {
- max_usage = mem_usage;
- }
+ atomic_add(&mem_usage, p_bytes);
+ atomic_exchange_if_greater(&max_usage, mem_usage);
#endif
return s8 + PAD_ALIGN;
} else {
@@ -103,8 +100,12 @@ void *Memory::realloc_static(void *p_memory, size_t p_bytes, bool p_pad_align) {
uint64_t *s = (uint64_t *)mem;
#ifdef DEBUG_ENABLED
- mem_usage -= *s;
- mem_usage += p_bytes;
+ if (p_bytes > *s) {
+ atomic_add(&mem_usage, p_bytes - *s);
+ atomic_exchange_if_greater(&max_usage, mem_usage);
+ } else {
+ atomic_sub(&mem_usage, *s - p_bytes);
+ }
#endif
if (p_bytes == 0) {
@@ -144,14 +145,14 @@ void Memory::free_static(void *p_ptr, bool p_pad_align) {
bool prepad = p_pad_align;
#endif
- alloc_count--;
+ atomic_decrement(&alloc_count);
if (prepad) {
mem -= PAD_ALIGN;
uint64_t *s = (uint64_t *)mem;
#ifdef DEBUG_ENABLED
- mem_usage -= *s;
+ atomic_sub(&mem_usage, *s);
#endif
free(mem);
@@ -161,19 +162,20 @@ void Memory::free_static(void *p_ptr, bool p_pad_align) {
}
}
-size_t Memory::get_mem_available() {
+uint64_t Memory::get_mem_available() {
- return 0xFFFFFFFFFFFFF;
+ return -1; // 0xFFFF...
}
-size_t Memory::get_mem_usage() {
+uint64_t Memory::get_mem_usage() {
#ifdef DEBUG_ENABLED
return mem_usage;
#else
return 0;
#endif
}
-size_t Memory::get_mem_max_usage() {
+
+uint64_t Memory::get_mem_max_usage() {
#ifdef DEBUG_ENABLED
return max_usage;
#else
diff --git a/core/os/memory.h b/core/os/memory.h
index b3eb599955..e1d7138ad5 100644
--- a/core/os/memory.h
+++ b/core/os/memory.h
@@ -45,20 +45,20 @@ class Memory {
Memory();
#ifdef DEBUG_ENABLED
- static size_t mem_usage;
- static size_t max_usage;
+ static uint64_t mem_usage;
+ static uint64_t max_usage;
#endif
- static size_t alloc_count;
+ static uint64_t alloc_count;
public:
static void *alloc_static(size_t p_bytes, bool p_pad_align = false);
static void *realloc_static(void *p_memory, size_t p_bytes, bool p_pad_align = false);
static void free_static(void *p_ptr, bool p_pad_align = false);
- static size_t get_mem_available();
- static size_t get_mem_usage();
- static size_t get_mem_max_usage();
+ static uint64_t get_mem_available();
+ static uint64_t get_mem_usage();
+ static uint64_t get_mem_max_usage();
};
class DefaultAllocator {
diff --git a/core/os/os.cpp b/core/os/os.cpp
index 8e4c357195..3a06a3fa8f 100644
--- a/core/os/os.cpp
+++ b/core/os/os.cpp
@@ -129,7 +129,7 @@ String OS::get_executable_path() const {
return _execpath;
}
-int OS::get_process_ID() const {
+int OS::get_process_id() const {
return -1;
};
@@ -175,7 +175,7 @@ static void _OS_printres(Object *p_obj) {
if (!res)
return;
- String str = itos(res->get_instance_ID()) + String(res->get_class()) + ":" + String(res->get_name()) + " - " + res->get_path();
+ String str = itos(res->get_instance_id()) + String(res->get_class()) + ":" + String(res->get_name()) + " - " + res->get_path();
if (_OSPRF)
_OSPRF->store_line(str);
else
@@ -412,7 +412,7 @@ void OS::make_rendering_thread() {
void OS::swap_buffers() {
}
-String OS::get_unique_ID() const {
+String OS::get_unique_id() const {
ERR_FAIL_V("");
}
diff --git a/core/os/os.h b/core/os/os.h
index 703c6a6bcd..8e2257a0e4 100644
--- a/core/os/os.h
+++ b/core/os/os.h
@@ -197,7 +197,7 @@ public:
virtual String get_executable_path() const;
virtual Error execute(const String &p_path, const List<String> &p_arguments, bool p_blocking, ProcessID *r_child_id = NULL, String *r_pipe = NULL, int *r_exitcode = NULL) = 0;
virtual Error kill(const ProcessID &p_pid) = 0;
- virtual int get_process_ID() const;
+ virtual int get_process_id() const;
virtual Error shell_open(String p_uri);
virtual Error set_cwd(const String &p_cwd);
@@ -370,7 +370,7 @@ public:
virtual int get_processor_count() const;
- virtual String get_unique_ID() const;
+ virtual String get_unique_id() const;
virtual Error native_video_play(String p_path, float p_volume, String p_audio_track, String p_subtitle_track);
virtual bool native_video_is_playing() const;
diff --git a/core/os/thread.cpp b/core/os/thread.cpp
index 98f1968629..bd565334c3 100644
--- a/core/os/thread.cpp
+++ b/core/os/thread.cpp
@@ -30,16 +30,16 @@
#include "thread.h"
Thread *(*Thread::create_func)(ThreadCreateCallback, void *, const Settings &) = NULL;
-Thread::ID (*Thread::get_thread_ID_func)() = NULL;
+Thread::ID (*Thread::get_thread_id_func)() = NULL;
void (*Thread::wait_to_finish_func)(Thread *) = NULL;
Error (*Thread::set_name_func)(const String &) = NULL;
Thread::ID Thread::_main_thread_id = 0;
-Thread::ID Thread::get_caller_ID() {
+Thread::ID Thread::get_caller_id() {
- if (get_thread_ID_func)
- return get_thread_ID_func();
+ if (get_thread_id_func)
+ return get_thread_id_func();
return 0;
}
diff --git a/core/os/thread.h b/core/os/thread.h
index 3ad5d4bf2c..1103f67ff2 100644
--- a/core/os/thread.h
+++ b/core/os/thread.h
@@ -58,7 +58,7 @@ public:
protected:
static Thread *(*create_func)(ThreadCreateCallback p_callback, void *, const Settings &);
- static ID (*get_thread_ID_func)();
+ static ID (*get_thread_id_func)();
static void (*wait_to_finish_func)(Thread *);
static Error (*set_name_func)(const String &);
@@ -69,11 +69,11 @@ protected:
Thread();
public:
- virtual ID get_ID() const = 0;
+ virtual ID get_id() const = 0;
static Error set_name(const String &p_name);
- _FORCE_INLINE_ static ID get_main_ID() { return _main_thread_id; } ///< get the ID of the main thread
- static ID get_caller_ID(); ///< get the ID of the caller function ID
+ _FORCE_INLINE_ static ID get_main_id() { return _main_thread_id; } ///< get the ID of the main thread
+ static ID get_caller_id(); ///< get the ID of the caller function ID
static void wait_to_finish(Thread *p_thread); ///< waits until thread is finished, and deallocates it.
static Thread *create(ThreadCreateCallback p_callback, void *p_user, const Settings &p_settings = Settings()); ///< Static function to create a thread, will call p_callback
diff --git a/core/os/thread_dummy.h b/core/os/thread_dummy.h
index 4155103bbf..64941a71f8 100644
--- a/core/os/thread_dummy.h
+++ b/core/os/thread_dummy.h
@@ -39,7 +39,7 @@ class ThreadDummy : public Thread {
static Thread *create(ThreadCreateCallback p_callback, void *p_user, const Settings &p_settings = Settings());
public:
- virtual ID get_ID() const { return 0; };
+ virtual ID get_id() const { return 0; };
static void make_default();
};
diff --git a/core/project_settings.cpp b/core/project_settings.cpp
index b31f78ec20..f6e0d2e991 100644
--- a/core/project_settings.cpp
+++ b/core/project_settings.cpp
@@ -925,10 +925,10 @@ ProjectSettings::ProjectSettings() {
GLOBAL_DEF("application/config/use_shared_user_dir", true);
key.instance();
- key->set_scancode(KEY_RETURN);
+ key->set_scancode(KEY_ENTER);
va.push_back(key);
key.instance();
- key->set_scancode(KEY_ENTER);
+ key->set_scancode(KEY_KP_ENTER);
va.push_back(key);
key.instance();
key->set_scancode(KEY_SPACE);
diff --git a/core/reference.cpp b/core/reference.cpp
index 060608eacb..066dc8059e 100644
--- a/core/reference.cpp
+++ b/core/reference.cpp
@@ -108,12 +108,12 @@ Variant WeakRef::get_ref() const {
}
void WeakRef::set_obj(Object *p_object) {
- ref = p_object ? p_object->get_instance_ID() : 0;
+ ref = p_object ? p_object->get_instance_id() : 0;
}
void WeakRef::set_ref(const REF &p_ref) {
- ref = p_ref.is_valid() ? p_ref->get_instance_ID() : 0;
+ ref = p_ref.is_valid() ? p_ref->get_instance_id() : 0;
}
WeakRef::WeakRef() {
diff --git a/core/resource.cpp b/core/resource.cpp
index 5625784396..9bce343cba 100644
--- a/core/resource.cpp
+++ b/core/resource.cpp
@@ -32,6 +32,7 @@
#include "core_string_names.h"
#include "io/resource_loader.h"
#include "os/file_access.h"
+#include "scene/main/node.h" //only so casting works
#include "script_language.h"
#include <stdio.h>
@@ -227,12 +228,12 @@ RID Resource::get_rid() const {
void Resource::register_owner(Object *p_owner) {
- owners.insert(p_owner->get_instance_ID());
+ owners.insert(p_owner->get_instance_id());
}
void Resource::unregister_owner(Object *p_owner) {
- owners.erase(p_owner->get_instance_ID());
+ owners.erase(p_owner->get_instance_id());
}
void Resource::notify_change_to_owners() {
diff --git a/core/script_debugger_remote.cpp b/core/script_debugger_remote.cpp
index d19fe213f6..fdde08bb32 100644
--- a/core/script_debugger_remote.cpp
+++ b/core/script_debugger_remote.cpp
@@ -95,7 +95,7 @@ static Object *_ScriptDebuggerRemote_find = NULL;
static void _ScriptDebuggerRemote_debug_func(Object *p_obj) {
if (_ScriptDebuggerRemote_find == p_obj) {
- _ScriptDebuggerRemote_found_id = p_obj->get_instance_ID();
+ _ScriptDebuggerRemote_found_id = p_obj->get_instance_id();
}
}
@@ -109,7 +109,7 @@ static ObjectID safe_get_instance_id(const Variant &p_v) {
REF r = p_v;
if (r.is_valid()) {
- return r->get_instance_ID();
+ return r->get_instance_id();
} else {
_ScriptDebuggerRemote_found_id = 0;
@@ -572,7 +572,7 @@ void ScriptDebuggerRemote::_send_object_id(ObjectID p_id) {
ObjectID id2;
Object *obj = var;
if (obj) {
- id2 = obj->get_instance_ID();
+ id2 = obj->get_instance_id();
} else {
id2 = 0;
}
diff --git a/core/script_language.cpp b/core/script_language.cpp
index aeb1573840..bb99e0abae 100644
--- a/core/script_language.cpp
+++ b/core/script_language.cpp
@@ -280,8 +280,23 @@ ScriptDebugger::ScriptDebugger() {
bool PlaceHolderScriptInstance::set(const StringName &p_name, const Variant &p_value) {
if (values.has(p_name)) {
+ Variant defval;
+ if (script->get_property_default_value(p_name, defval)) {
+ if (defval == p_value) {
+ values.erase(p_name);
+ return true;
+ }
+ }
values[p_name] = p_value;
return true;
+ } else {
+ Variant defval;
+ if (script->get_property_default_value(p_name, defval)) {
+ if (defval != p_value) {
+ values[p_name] = p_value;
+ }
+ return true;
+ }
}
return false;
}
@@ -291,12 +306,22 @@ bool PlaceHolderScriptInstance::get(const StringName &p_name, Variant &r_ret) co
r_ret = values[p_name];
return true;
}
+
+ Variant defval;
+ if (script->get_property_default_value(p_name, defval)) {
+ r_ret = defval;
+ return true;
+ }
return false;
}
void PlaceHolderScriptInstance::get_property_list(List<PropertyInfo> *p_properties) const {
for (const List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) {
+ PropertyInfo pinfo = E->get();
+ if (!values.has(pinfo.name)) {
+ pinfo.usage |= PROPERTY_USAGE_SCRIPT_DEFAULT_VALUE;
+ }
p_properties->push_back(E->get());
}
}
@@ -336,6 +361,14 @@ void PlaceHolderScriptInstance::update(const List<PropertyInfo> &p_properties, c
if (!new_values.has(E->key()))
to_remove.push_back(E->key());
+
+ Variant defval;
+ if (script->get_property_default_value(E->key(), defval)) {
+ //remove because it's the same as the default value
+ if (defval == E->get()) {
+ to_remove.push_back(E->key());
+ }
+ }
}
while (to_remove.size()) {
diff --git a/core/undo_redo.cpp b/core/undo_redo.cpp
index b3ac9d274e..637fcd91d4 100644
--- a/core/undo_redo.cpp
+++ b/core/undo_redo.cpp
@@ -110,7 +110,7 @@ void UndoRedo::add_do_method(Object *p_object, const String &p_method, VARIANT_A
ERR_FAIL_COND(action_level <= 0);
ERR_FAIL_COND((current_action + 1) >= actions.size());
Operation do_op;
- do_op.object = p_object->get_instance_ID();
+ do_op.object = p_object->get_instance_id();
if (p_object->cast_to<Resource>())
do_op.resref = Ref<Resource>(p_object->cast_to<Resource>());
@@ -134,7 +134,7 @@ void UndoRedo::add_undo_method(Object *p_object, const String &p_method, VARIANT
return;
Operation undo_op;
- undo_op.object = p_object->get_instance_ID();
+ undo_op.object = p_object->get_instance_id();
if (p_object->cast_to<Resource>())
undo_op.resref = Ref<Resource>(p_object->cast_to<Resource>());
@@ -151,7 +151,7 @@ void UndoRedo::add_do_property(Object *p_object, const String &p_property, const
ERR_FAIL_COND(action_level <= 0);
ERR_FAIL_COND((current_action + 1) >= actions.size());
Operation do_op;
- do_op.object = p_object->get_instance_ID();
+ do_op.object = p_object->get_instance_id();
if (p_object->cast_to<Resource>())
do_op.resref = Ref<Resource>(p_object->cast_to<Resource>());
@@ -170,7 +170,7 @@ void UndoRedo::add_undo_property(Object *p_object, const String &p_property, con
return;
Operation undo_op;
- undo_op.object = p_object->get_instance_ID();
+ undo_op.object = p_object->get_instance_id();
if (p_object->cast_to<Resource>())
undo_op.resref = Ref<Resource>(p_object->cast_to<Resource>());
@@ -184,7 +184,7 @@ void UndoRedo::add_do_reference(Object *p_object) {
ERR_FAIL_COND(action_level <= 0);
ERR_FAIL_COND((current_action + 1) >= actions.size());
Operation do_op;
- do_op.object = p_object->get_instance_ID();
+ do_op.object = p_object->get_instance_id();
if (p_object->cast_to<Resource>())
do_op.resref = Ref<Resource>(p_object->cast_to<Resource>());
@@ -201,7 +201,7 @@ void UndoRedo::add_undo_reference(Object *p_object) {
return;
Operation undo_op;
- undo_op.object = p_object->get_instance_ID();
+ undo_op.object = p_object->get_instance_id();
if (p_object->cast_to<Resource>())
undo_op.resref = Ref<Resource>(p_object->cast_to<Resource>());
diff --git a/core/variant.cpp b/core/variant.cpp
index 0807a33788..51c4b70bdc 100644
--- a/core/variant.cpp
+++ b/core/variant.cpp
@@ -1600,7 +1600,7 @@ Variant::operator String() const {
};
};
#endif
- return "[" + _get_obj().obj->get_class() + ":" + itos(_get_obj().obj->get_instance_ID()) + "]";
+ return "[" + _get_obj().obj->get_class() + ":" + itos(_get_obj().obj->get_instance_id()) + "]";
} else
return "[Object:null]";
diff --git a/core/variant.h b/core/variant.h
index 661d31cf16..95782d9619 100644
--- a/core/variant.h
+++ b/core/variant.h
@@ -42,8 +42,8 @@
#include "io/ip_address.h"
#include "math_2d.h"
#include "matrix3.h"
+#include "node_path.h"
#include "os/power.h"
-#include "path_db.h"
#include "plane.h"
#include "quat.h"
#include "rect3.h"
diff --git a/doc/base/classes.xml b/doc/base/classes.xml
index 70a7dcb651..7dd22d7cb0 100644
--- a/doc/base/classes.xml
+++ b/doc/base/classes.xml
@@ -746,13 +746,16 @@
[AudioServer] singleton
</member>
<member name="ClassDB" type="ClassDB" setter="" getter="" brief="">
+ [ClassDB] singleton
</member>
<member name="Engine" type="Engine" setter="" getter="" brief="">
+ [Engine] singleton
</member>
<member name="Geometry" type="Geometry" setter="" getter="" brief="">
[Geometry] singleton
</member>
<member name="ProjectSettings" type="ProjectSettings" setter="" getter="" brief="">
+ [ProjectSettings] singleton
</member>
<member name="IP" type="IP" setter="" getter="" brief="">
[IP] singleton
@@ -843,10 +846,10 @@
<constant name="KEY_BACKSPACE" value="16777220">
Backspace Key
</constant>
- <constant name="KEY_RETURN" value="16777221">
+ <constant name="KEY_ENTER" value="16777221">
Return Key (On Main Keyboard)
</constant>
- <constant name="KEY_ENTER" value="16777222">
+ <constant name="KEY_KP_ENTER" value="16777222">
Enter Key (On Numpad)
</constant>
<constant name="KEY_INSERT" value="16777223">
@@ -4632,7 +4635,7 @@
<argument index="0" name="from" type="PoolColorArray">
</argument>
<description>
- Construct an array from a [PoolByteArray].
+ Construct an array from a [PoolColorArray].
</description>
</method>
<method name="Array">
@@ -4641,7 +4644,7 @@
<argument index="0" name="from" type="PoolVector3Array">
</argument>
<description>
- Construct an array from a [PoolByteArray].
+ Construct an array from a [PoolVector3Array].
</description>
</method>
<method name="Array">
@@ -4650,7 +4653,7 @@
<argument index="0" name="from" type="PoolVector2Array">
</argument>
<description>
- Construct an array from a [PoolByteArray].
+ Construct an array from a [PoolVector2Array].
</description>
</method>
<method name="Array">
@@ -4677,7 +4680,7 @@
<argument index="0" name="from" type="PoolIntArray">
</argument>
<description>
- Construct an array from a [PoolByteArray].
+ Construct an array from a [PoolIntArray].
</description>
</method>
<method name="Array">
@@ -11516,7 +11519,7 @@
<return type="Rect2">
</return>
<description>
- Return position and size of the Control, relative to the top-left corner of the [i]window[/i] Control. This is a helper (see [method get_global_pos], [method get_size]).
+ Return position and size of the Control, relative to the top-left corner of the [i]window[/i] Control. This is a helper (see [method get_global_position], [method get_size]).
</description>
</method>
<method name="get_h_grow_direction" qualifiers="const">
@@ -11594,7 +11597,7 @@
<return type="Rect2">
</return>
<description>
- Return position and size of the Control, relative to the top-left corner of the parent Control. This is a helper (see [method get_pos], [method get_size]).
+ Return position and size of the Control, relative to the top-left corner of the parent Control. This is a helper (see [method get_position], [method get_size]).
</description>
</method>
<method name="get_rotation" qualifiers="const">
@@ -17915,7 +17918,7 @@
Contains global variables accessible from everywhere.
</brief_description>
<description>
- Contains global variables accessible from everywhere. Use the normal [Object] API, such as "Globals.get(variable)", "Globals.set(variable,value)" or "Globals.has(variable)" to access them. Variables stored in project.godot are also loaded into globals, making this object very useful for reading custom game configuration options.
+ Contains global variables accessible from everywhere. Use the normal [Object] API, such as "ProjectSettings.get(variable)", "ProjectSettings.set(variable,value)" or "ProjectSettings.has(variable)" to access them. Variables stored in project.godot are also loaded into ProjectSettings, making this object very useful for reading custom game configuration options.
</description>
<methods>
<method name="add_property_info">
@@ -17925,7 +17928,7 @@
Add a custom property info to a property. The dictionary must contain: name:[String](the name of the property) and type:[int](see TYPE_* in [@Global Scope]), and optionally hint:[int](see PROPERTY_HINT_* in [@Global Scope]), hint_string:[String].
Example:
[codeblock]
- Globals.set("category/property_name", 0)
+ ProjectSettings.set("category/property_name", 0)
var property_info = {
"name": "category/property_name",
@@ -17934,7 +17937,7 @@
"hint_string": "one,two,three"
}
- Globals.add_property_info(property_info)
+ ProjectSettings.add_property_info(property_info)
[/codeblock]
</description>
</method>
@@ -21642,7 +21645,7 @@
</method>
<method name="load_from_globals">
<description>
- Clear the [InputMap] and load it anew from [Globals].
+ Clear the [InputMap] and load it anew from [ProjectSettings].
</description>
</method>
</methods>
@@ -25089,7 +25092,7 @@
MultiMesh provides low level mesh instancing. If the amount of [Mesh] instances needed goes from hundreds to thousands (and most need to be visible at close proximity) creating such a large amount of [MeshInstance] nodes may affect performance by using too much CPU or video memory.
For this case a MultiMesh becomes very useful, as it can draw thousands of instances with little API overhead.
As a drawback, if the instances are too far away of each other, performance may be reduced as every single instance will always rendered (they are spatially indexed as one, for the whole object).
- Since instances may have any behavior, the Rect3 used for visibility must be provided by the user, or generated with [method generate_aabb].
+ Since instances may have any behavior, the Rect3 used for visibility must be provided by the user.
</description>
<methods>
<method name="get_aabb" qualifiers="const">
@@ -27429,7 +27432,7 @@
<description>
</description>
</method>
- <method name="get_process_ID" qualifiers="const">
+ <method name="get_process_id" qualifiers="const">
<return type="int">
</return>
<description>
@@ -27555,7 +27558,7 @@
<description>
</description>
</method>
- <method name="get_unique_ID" qualifiers="const">
+ <method name="get_unique_id" qualifiers="const">
<return type="String">
</return>
<description>
@@ -28019,7 +28022,7 @@
<return type="Array">
</return>
<description>
- Return the property list, array of dictionaries, dictionaries must contain: name:String, type:int (see TYPE_* enum in globals) and optionally: hint:int (see PROPERTY_HINT_* in globals), hint_string:String, usage:int (see PROPERTY_USAGE_* in globals).
+ Return the property list, array of dictionaries, dictionaries must contain: name:String, type:int (see TYPE_* enum in [@Global Scope]) and optionally: hint:int (see PROPERTY_HINT_* in [@Global Scope]), hint_string:String, usage:int (see PROPERTY_USAGE_* in [@Global Scope]).
</description>
</method>
<method name="_init" qualifiers="virtual">
@@ -28147,7 +28150,7 @@
- "method_name" is a name of method to which signal is connected.
</description>
</method>
- <method name="get_instance_ID" qualifiers="const">
+ <method name="get_instance_id" qualifiers="const">
<return type="int">
</return>
<description>
@@ -28180,7 +28183,7 @@
<return type="Array">
</return>
<description>
- Return the list of properties as an array of dictionaries, dictionaries contain: name:String, type:int (see TYPE_* enum in globals) and optionally: hint:int (see PROPERTY_HINT_* in globals), hint_string:String, usage:int (see PROPERTY_USAGE_* in globals).
+ Return the list of properties as an array of dictionaries, dictionaries contain: name:String, type:int (see TYPE_* enum in [@Global Scope]) and optionally: hint:int (see PROPERTY_HINT_* in [@Global Scope]), hint_string:String, usage:int (see PROPERTY_USAGE_* in [@Global Scope]).
</description>
</method>
<method name="get_script" qualifiers="const">
@@ -28495,7 +28498,7 @@
Clear all the items in the [OptionButton].
</description>
</method>
- <method name="get_item_ID" qualifiers="const">
+ <method name="get_item_id" qualifiers="const">
<return type="int">
</return>
<argument index="0" name="idx" type="int">
@@ -28544,7 +28547,7 @@
Return the current item index
</description>
</method>
- <method name="get_selected_ID" qualifiers="const">
+ <method name="get_selected_id" qualifiers="const">
<return type="int">
</return>
<description>
@@ -28577,7 +28580,7 @@
Select an item by index and make it the current item.
</description>
</method>
- <method name="set_item_ID">
+ <method name="set_item_id">
<argument index="0" name="idx" type="int">
</argument>
<argument index="1" name="id" type="int">
@@ -30912,7 +30915,7 @@
Add a shape to the area, along with a transform matrix. Shapes are usually referenced by their index, so you should track which shape has a given index.
</description>
</method>
- <method name="area_attach_object_instance_ID">
+ <method name="area_attach_object_instance_id">
<argument index="0" name="area" type="RID">
</argument>
<argument index="1" name="id" type="int">
@@ -30935,7 +30938,7 @@
Create an [Area2D].
</description>
</method>
- <method name="area_get_object_instance_ID" qualifiers="const">
+ <method name="area_get_object_instance_id" qualifiers="const">
<return type="int">
</return>
<argument index="0" name="area" type="RID">
@@ -31166,7 +31169,7 @@
Add a positioned impulse to the applied force and torque. Both the force and the offset from the body origin are in global coordinates.
</description>
</method>
- <method name="body_attach_object_instance_ID">
+ <method name="body_attach_object_instance_id">
<argument index="0" name="body" type="RID">
</argument>
<argument index="1" name="id" type="int">
@@ -31238,7 +31241,7 @@
Return the body mode.
</description>
</method>
- <method name="body_get_object_instance_ID" qualifiers="const">
+ <method name="body_get_object_instance_id" qualifiers="const">
<return type="int">
</return>
<argument index="0" name="body" type="RID">
@@ -32656,7 +32659,7 @@
<description>
</description>
</method>
- <method name="area_attach_object_instance_ID">
+ <method name="area_attach_object_instance_id">
<argument index="0" name="area" type="RID">
</argument>
<argument index="1" name="id" type="int">
@@ -32676,7 +32679,7 @@
<description>
</description>
</method>
- <method name="area_get_object_instance_ID" qualifiers="const">
+ <method name="area_get_object_instance_id" qualifiers="const">
<return type="int">
</return>
<argument index="0" name="area" type="RID">
@@ -32884,7 +32887,7 @@
<description>
</description>
</method>
- <method name="body_attach_object_instance_ID">
+ <method name="body_attach_object_instance_id">
<argument index="0" name="body" type="RID">
</argument>
<argument index="1" name="id" type="int">
@@ -32948,7 +32951,7 @@
<description>
</description>
</method>
- <method name="body_get_object_instance_ID" qualifiers="const">
+ <method name="body_get_object_instance_id" qualifiers="const">
<return type="int">
</return>
<argument index="0" name="body" type="RID">
@@ -33398,7 +33401,7 @@
<description>
</description>
</method>
- <method name="pin_joint_get_local_A" qualifiers="const">
+ <method name="pin_joint_get_local_a" qualifiers="const">
<return type="Vector3">
</return>
<argument index="0" name="joint" type="RID">
@@ -33406,7 +33409,7 @@
<description>
</description>
</method>
- <method name="pin_joint_get_local_B" qualifiers="const">
+ <method name="pin_joint_get_local_b" qualifiers="const">
<return type="Vector3">
</return>
<argument index="0" name="joint" type="RID">
@@ -33424,7 +33427,7 @@
<description>
</description>
</method>
- <method name="pin_joint_set_local_A">
+ <method name="pin_joint_set_local_a">
<argument index="0" name="joint" type="RID">
</argument>
<argument index="1" name="local_A" type="Vector3">
@@ -33432,7 +33435,7 @@
<description>
</description>
</method>
- <method name="pin_joint_set_local_B">
+ <method name="pin_joint_set_local_b">
<argument index="0" name="joint" type="RID">
</argument>
<argument index="1" name="local_B" type="Vector3">
@@ -34623,7 +34626,7 @@
<argument index="1" name="to" type="int">
</argument>
<description>
- Returns the slice of the [PoolByteArray] between indices (inclusive) as a new [RawArray]. Any negative index is considered to be from the end of the array.
+ Returns the slice of the [PoolByteArray] between indices (inclusive) as a new [PoolByteArray]. Any negative index is considered to be from the end of the array.
</description>
</method>
</methods>
@@ -35375,7 +35378,7 @@
Clear the popup menu, in effect removing all items.
</description>
</method>
- <method name="get_item_ID" qualifiers="const">
+ <method name="get_item_id" qualifiers="const">
<return type="int">
</return>
<argument index="0" name="idx" type="int">
@@ -35532,7 +35535,7 @@
Sets whether or not the PopupMenu will hide on item selection.
</description>
</method>
- <method name="set_item_ID">
+ <method name="set_item_id">
<argument index="0" name="idx" type="int">
</argument>
<argument index="1" name="id" type="int">
@@ -37280,7 +37283,7 @@
<argument index="0" name="with" type="Rect3">
</argument>
<description>
- Return the intersection between two [Rect3]. An empty AABB (size 0,0,0) is returned on failure.
+ Return the intersection between two [Rect3]. An empty Rect3 (size 0,0,0) is returned on failure.
</description>
</method>
<method name="intersects">
diff --git a/drivers/gles3/rasterizer_canvas_gles3.cpp b/drivers/gles3/rasterizer_canvas_gles3.cpp
index 56d9f2cc47..e6ffa39197 100644
--- a/drivers/gles3/rasterizer_canvas_gles3.cpp
+++ b/drivers/gles3/rasterizer_canvas_gles3.cpp
@@ -941,6 +941,8 @@ void RasterizerGLES2::_canvas_item_setup_shader_params(ShaderMaterial *material,
void RasterizerCanvasGLES3::_copy_texscreen(const Rect2 &p_rect) {
+ glDisable(GL_BLEND);
+
state.canvas_texscreen_used = true;
//blur diffuse into effect mipmaps using separatable convolution
//storage->shaders.copy.set_conditional(CopyShaderGLES3::GAUSSIAN_HORIZONTAL,true);
@@ -1003,12 +1005,16 @@ void RasterizerCanvasGLES3::_copy_texscreen(const Rect2 &p_rect) {
glBindFramebuffer(GL_FRAMEBUFFER, storage->frame.current_rt->fbo); //back to front
glViewport(0, 0, storage->frame.current_rt->width, storage->frame.current_rt->height);
+
state.canvas_shader.bind(); //back to canvas
+ _bind_canvas_texture(state.current_tex, state.current_normal);
if (state.using_texture_rect) {
state.using_texture_rect = false;
_set_texture_rect_mode(state.using_texture_rect, state.using_ninepatch);
}
+
+ glEnable(GL_BLEND);
}
void RasterizerCanvasGLES3::canvas_render_items(Item *p_item_list, int p_z, const Color &p_modulate, Light *p_light) {
@@ -1595,6 +1601,67 @@ void RasterizerCanvasGLES3::draw_generic_textured_rect(const Rect2 &p_rect, cons
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
}
+void RasterizerCanvasGLES3::draw_window_margins(int *black_margin, RID *black_image) {
+
+ Vector2 window_size = OS::get_singleton()->get_window_size();
+ int window_h = window_size.height;
+ int window_w = window_size.width;
+
+ glBindFramebuffer(GL_FRAMEBUFFER, storage->system_fbo);
+ glViewport(0, 0, window_size.width, window_size.height);
+ canvas_begin();
+
+ if (black_image[MARGIN_LEFT].is_valid()) {
+ _bind_canvas_texture(black_image[MARGIN_LEFT], RID());
+ Size2 sz(storage->texture_get_width(black_image[MARGIN_LEFT]), storage->texture_get_height(black_image[MARGIN_LEFT]));
+ draw_generic_textured_rect(Rect2(0, 0, black_margin[MARGIN_LEFT], window_h), Rect2(0, 0, sz.x, sz.y));
+ } else if (black_margin[MARGIN_LEFT]) {
+ glActiveTexture(GL_TEXTURE0);
+ glBindTexture(GL_TEXTURE_2D, storage->resources.black_tex);
+
+ draw_generic_textured_rect(Rect2(0, 0, black_margin[MARGIN_LEFT], window_h), Rect2(0, 0, 1, 1));
+ }
+
+ if (black_image[MARGIN_RIGHT].is_valid()) {
+ _bind_canvas_texture(black_image[MARGIN_RIGHT], RID());
+ Size2 sz(storage->texture_get_width(black_image[MARGIN_RIGHT]), storage->texture_get_height(black_image[MARGIN_RIGHT]));
+ draw_generic_textured_rect(Rect2(window_w - black_margin[MARGIN_RIGHT], 0, black_margin[MARGIN_RIGHT], window_h), Rect2(0, 0, sz.x, sz.y));
+ } else if (black_margin[MARGIN_RIGHT]) {
+ glActiveTexture(GL_TEXTURE0);
+ glBindTexture(GL_TEXTURE_2D, storage->resources.black_tex);
+
+ draw_generic_textured_rect(Rect2(window_w - black_margin[MARGIN_RIGHT], 0, black_margin[MARGIN_RIGHT], window_h), Rect2(0, 0, 1, 1));
+ }
+
+ if (black_image[MARGIN_TOP].is_valid()) {
+ _bind_canvas_texture(black_image[MARGIN_TOP], RID());
+
+ Size2 sz(storage->texture_get_width(black_image[MARGIN_TOP]), storage->texture_get_height(black_image[MARGIN_TOP]));
+ draw_generic_textured_rect(Rect2(0, 0, window_w, black_margin[MARGIN_TOP]), Rect2(0, 0, sz.x, sz.y));
+
+ } else if (black_margin[MARGIN_TOP]) {
+ glActiveTexture(GL_TEXTURE0);
+ glBindTexture(GL_TEXTURE_2D, storage->resources.black_tex);
+
+ draw_generic_textured_rect(Rect2(0, 0, window_w, black_margin[MARGIN_TOP]), Rect2(0, 0, 1, 1));
+ }
+
+ if (black_image[MARGIN_BOTTOM].is_valid()) {
+
+ _bind_canvas_texture(black_image[MARGIN_BOTTOM], RID());
+
+ Size2 sz(storage->texture_get_width(black_image[MARGIN_BOTTOM]), storage->texture_get_height(black_image[MARGIN_BOTTOM]));
+ draw_generic_textured_rect(Rect2(0, window_h - black_margin[MARGIN_BOTTOM], window_w, black_margin[MARGIN_BOTTOM]), Rect2(0, 0, sz.x, sz.y));
+
+ } else if (black_margin[MARGIN_BOTTOM]) {
+
+ glActiveTexture(GL_TEXTURE0);
+ glBindTexture(GL_TEXTURE_2D, storage->resources.black_tex);
+
+ draw_generic_textured_rect(Rect2(0, window_h - black_margin[MARGIN_BOTTOM], window_w, black_margin[MARGIN_BOTTOM]), Rect2(0, 0, 1, 1));
+ }
+}
+
void RasterizerCanvasGLES3::initialize() {
{
diff --git a/drivers/gles3/rasterizer_canvas_gles3.h b/drivers/gles3/rasterizer_canvas_gles3.h
index c0af22b5e8..26003f543f 100644
--- a/drivers/gles3/rasterizer_canvas_gles3.h
+++ b/drivers/gles3/rasterizer_canvas_gles3.h
@@ -138,6 +138,8 @@ public:
void initialize();
void finalize();
+ virtual void draw_window_margins(int *black_margin, RID *black_image);
+
RasterizerCanvasGLES3();
};
diff --git a/drivers/gles3/rasterizer_gles3.cpp b/drivers/gles3/rasterizer_gles3.cpp
index bb7b85e653..3fc5bed80b 100644
--- a/drivers/gles3/rasterizer_gles3.cpp
+++ b/drivers/gles3/rasterizer_gles3.cpp
@@ -83,7 +83,6 @@ static void GLAPIENTRY _gl_debug_print(GLenum source, GLenum type, GLuint id, GL
if (type == _EXT_DEBUG_TYPE_OTHER_ARB)
return;
- print_line("mesege");
char debSource[256], debType[256], debSev[256];
if (source == _EXT_DEBUG_SOURCE_API_ARB)
strcpy(debSource, "OpenGL");
diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp
index cd74c450f5..9dd5b32f41 100644
--- a/drivers/gles3/rasterizer_scene_gles3.cpp
+++ b/drivers/gles3/rasterizer_scene_gles3.cpp
@@ -1561,7 +1561,7 @@ void RasterizerSceneGLES3::_render_geometry(RenderList::Element *e) {
if (!c.normals.empty()) {
glEnableVertexAttribArray(VS::ARRAY_NORMAL);
- glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(Vector3) * vertices, c.normals.ptr());
+ glBufferSubData(GL_ARRAY_BUFFER, buf_ofs, sizeof(Vector3) * vertices, c.normals.ptr());
glVertexAttribPointer(VS::ARRAY_NORMAL, 3, GL_FLOAT, false, sizeof(Vector3) * vertices, ((uint8_t *)NULL) + buf_ofs);
buf_ofs += sizeof(Vector3) * vertices;
@@ -1573,7 +1573,7 @@ void RasterizerSceneGLES3::_render_geometry(RenderList::Element *e) {
if (!c.tangents.empty()) {
glEnableVertexAttribArray(VS::ARRAY_TANGENT);
- glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(Plane) * vertices, c.tangents.ptr());
+ glBufferSubData(GL_ARRAY_BUFFER, buf_ofs, sizeof(Plane) * vertices, c.tangents.ptr());
glVertexAttribPointer(VS::ARRAY_TANGENT, 4, GL_FLOAT, false, sizeof(Plane) * vertices, ((uint8_t *)NULL) + buf_ofs);
buf_ofs += sizeof(Plane) * vertices;
@@ -1585,7 +1585,7 @@ void RasterizerSceneGLES3::_render_geometry(RenderList::Element *e) {
if (!c.colors.empty()) {
glEnableVertexAttribArray(VS::ARRAY_COLOR);
- glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(Color) * vertices, c.colors.ptr());
+ glBufferSubData(GL_ARRAY_BUFFER, buf_ofs, sizeof(Color) * vertices, c.colors.ptr());
glVertexAttribPointer(VS::ARRAY_COLOR, 4, GL_FLOAT, false, sizeof(Color), ((uint8_t *)NULL) + buf_ofs);
buf_ofs += sizeof(Color) * vertices;
@@ -1598,7 +1598,7 @@ void RasterizerSceneGLES3::_render_geometry(RenderList::Element *e) {
if (!c.uvs.empty()) {
glEnableVertexAttribArray(VS::ARRAY_TEX_UV);
- glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(Vector2) * vertices, c.uvs.ptr());
+ glBufferSubData(GL_ARRAY_BUFFER, buf_ofs, sizeof(Vector2) * vertices, c.uvs.ptr());
glVertexAttribPointer(VS::ARRAY_TEX_UV, 2, GL_FLOAT, false, sizeof(Vector2), ((uint8_t *)NULL) + buf_ofs);
buf_ofs += sizeof(Vector2) * vertices;
@@ -1610,7 +1610,7 @@ void RasterizerSceneGLES3::_render_geometry(RenderList::Element *e) {
if (!c.uvs2.empty()) {
glEnableVertexAttribArray(VS::ARRAY_TEX_UV2);
- glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(Vector2) * vertices, c.uvs2.ptr());
+ glBufferSubData(GL_ARRAY_BUFFER, buf_ofs, sizeof(Vector2) * vertices, c.uvs2.ptr());
glVertexAttribPointer(VS::ARRAY_TEX_UV2, 2, GL_FLOAT, false, sizeof(Vector2), ((uint8_t *)NULL) + buf_ofs);
buf_ofs += sizeof(Vector2) * vertices;
@@ -1620,7 +1620,7 @@ void RasterizerSceneGLES3::_render_geometry(RenderList::Element *e) {
}
glEnableVertexAttribArray(VS::ARRAY_VERTEX);
- glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(Vector3) * vertices, c.vertices.ptr());
+ glBufferSubData(GL_ARRAY_BUFFER, buf_ofs, sizeof(Vector3) * vertices, c.vertices.ptr());
glVertexAttribPointer(VS::ARRAY_VERTEX, 3, GL_FLOAT, false, sizeof(Vector3), ((uint8_t *)NULL) + buf_ofs);
glDrawArrays(gl_primitive[c.primitive], 0, c.vertices.size());
}
@@ -3051,6 +3051,11 @@ void RasterizerSceneGLES3::_fill_render_list(InstanceBase **p_cull_result, int p
} break;
case VS::INSTANCE_IMMEDIATE: {
+ RasterizerStorageGLES3::Immediate *immediate = storage->immediate_owner.getptr(inst->base);
+ ERR_CONTINUE(!immediate);
+
+ _add_geometry(immediate, inst, NULL, -1, p_shadow);
+
} break;
case VS::INSTANCE_PARTICLES: {
diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp
index 89bea1e8cc..f7ecc3b158 100644
--- a/drivers/gles3/rasterizer_storage_gles3.cpp
+++ b/drivers/gles3/rasterizer_storage_gles3.cpp
@@ -6902,17 +6902,19 @@ void RasterizerStorageGLES3::initialize() {
config.use_fast_texture_filter = int(ProjectSettings::get_singleton()->get("rendering/quality/filters/use_nearest_mipmap_filter"));
config.use_anisotropic_filter = config.extensions.has("rendering/quality/filters/anisotropic_filter_level");
- config.s3tc_supported = config.extensions.has("GL_EXT_texture_compression_dxt1") || config.extensions.has("GL_EXT_texture_compression_s3tc") || config.extensions.has("WEBGL_compressed_texture_s3tc");
config.etc_supported = config.extensions.has("GL_OES_compressed_ETC1_RGB8_texture");
config.latc_supported = config.extensions.has("GL_EXT_texture_compression_latc");
- config.rgtc_supported = config.extensions.has("GL_EXT_texture_compression_rgtc");
config.bptc_supported = config.extensions.has("GL_ARB_texture_compression_bptc");
#ifdef GLES_OVER_GL
config.hdr_supported = true;
config.etc2_supported = false;
+ config.s3tc_supported = true;
+ config.rgtc_supported = true; //RGTC - core since OpenGL version 3.0
#else
config.etc2_supported = true;
config.hdr_supported = false;
+ config.s3tc_supported = config.extensions.has("GL_EXT_texture_compression_dxt1") || config.extensions.has("GL_EXT_texture_compression_s3tc") || config.extensions.has("WEBGL_compressed_texture_s3tc");
+ config.rgtc_supported = config.extensions.has("GL_EXT_texture_compression_rgtc") || config.extensions.has("GL_ARB_texture_compression_rgtc");
#endif
config.pvrtc_supported = config.extensions.has("GL_IMG_texture_compression_pvrtc");
diff --git a/drivers/gles3/shaders/scene.glsl b/drivers/gles3/shaders/scene.glsl
index 340a1f24d2..efb82441f4 100644
--- a/drivers/gles3/shaders/scene.glsl
+++ b/drivers/gles3/shaders/scene.glsl
@@ -1929,7 +1929,7 @@ FRAGMENT_SHADER_CODE
if (fog_depth_enabled) {
- float fog_z = smoothstep(fog_depth_begin,z_far,-vertex.z);
+ float fog_z = smoothstep(fog_depth_begin,z_far,length(vertex));
fog_amount = pow(fog_z,fog_depth_curve);
if (fog_transmit_enabled) {
diff --git a/drivers/rtaudio/audio_driver_rtaudio.cpp b/drivers/rtaudio/audio_driver_rtaudio.cpp
index da998db66f..3de25c32ad 100644
--- a/drivers/rtaudio/audio_driver_rtaudio.cpp
+++ b/drivers/rtaudio/audio_driver_rtaudio.cpp
@@ -79,7 +79,7 @@ int AudioDriverRtAudio::callback(void *outputBuffer, void *inputBuffer, unsigned
Error AudioDriverRtAudio::init() {
active = false;
- mutex = NULL;
+ mutex = Mutex::create(true);
dac = memnew(RtAudio);
ERR_EXPLAIN("Cannot initialize RtAudio audio driver: No devices present.")
@@ -136,7 +136,6 @@ Error AudioDriverRtAudio::init() {
try {
dac->openStream(&parameters, NULL, RTAUDIO_SINT32, mix_rate, &buffer_size, &callback, this, &options);
- mutex = Mutex::create(true);
active = true;
break;
@@ -162,6 +161,7 @@ Error AudioDriverRtAudio::init() {
try {
dac->closeStream();
+ active = false;
} catch (RtAudioError &e) {
ERR_PRINT(e.what());
ERR_FAIL_V(ERR_UNAVAILABLE);
@@ -212,17 +212,27 @@ void AudioDriverRtAudio::unlock() {
void AudioDriverRtAudio::finish() {
- if (active && dac->isStreamOpen())
+ lock();
+ if (active && dac->isStreamOpen()) {
dac->closeStream();
- if (mutex)
+ active = false;
+ }
+ unlock();
+
+ if (mutex) {
memdelete(mutex);
- if (dac)
+ mutex = NULL;
+ }
+ if (dac) {
memdelete(dac);
+ dac = NULL;
+ }
}
AudioDriverRtAudio::AudioDriverRtAudio() {
mutex = NULL;
+ dac = NULL;
mix_rate = 44100;
speaker_mode = SPEAKER_MODE_STEREO;
}
diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp
index e424590881..0f4e8f757c 100644
--- a/drivers/unix/os_unix.cpp
+++ b/drivers/unix/os_unix.cpp
@@ -415,7 +415,7 @@ Error OS_Unix::kill(const ProcessID &p_pid) {
return ret ? ERR_INVALID_PARAMETER : OK;
}
-int OS_Unix::get_process_ID() const {
+int OS_Unix::get_process_id() const {
return getpid();
};
diff --git a/drivers/unix/os_unix.h b/drivers/unix/os_unix.h
index fdc6d6e28f..6cd0016bb0 100644
--- a/drivers/unix/os_unix.h
+++ b/drivers/unix/os_unix.h
@@ -103,7 +103,7 @@ public:
virtual Error execute(const String &p_path, const List<String> &p_arguments, bool p_blocking, ProcessID *r_child_id = NULL, String *r_pipe = NULL, int *r_exitcode = NULL);
virtual Error kill(const ProcessID &p_pid);
- virtual int get_process_ID() const;
+ virtual int get_process_id() const;
virtual bool has_environment(const String &p_var) const;
virtual String get_environment(const String &p_var) const;
diff --git a/drivers/unix/thread_posix.cpp b/drivers/unix/thread_posix.cpp
index c1559619d7..3b895ff9c1 100644
--- a/drivers/unix/thread_posix.cpp
+++ b/drivers/unix/thread_posix.cpp
@@ -38,7 +38,7 @@
#include "os/memory.h"
-Thread::ID ThreadPosix::get_ID() const {
+Thread::ID ThreadPosix::get_id() const {
return id;
}
@@ -75,7 +75,7 @@ Thread *ThreadPosix::create_func_posix(ThreadCreateCallback p_callback, void *p_
return tr;
}
-Thread::ID ThreadPosix::get_thread_ID_func_posix() {
+Thread::ID ThreadPosix::get_thread_id_func_posix() {
return (ID)pthread_self();
}
@@ -122,7 +122,7 @@ Error ThreadPosix::set_name_func_posix(const String &p_name) {
void ThreadPosix::make_default() {
create_func = create_func_posix;
- get_thread_ID_func = get_thread_ID_func_posix;
+ get_thread_id_func = get_thread_id_func_posix;
wait_to_finish_func = wait_to_finish_func_posix;
set_name_func = set_name_func_posix;
}
diff --git a/drivers/unix/thread_posix.h b/drivers/unix/thread_posix.h
index c0c3e578bb..21e1d290a9 100644
--- a/drivers/unix/thread_posix.h
+++ b/drivers/unix/thread_posix.h
@@ -53,7 +53,7 @@ class ThreadPosix : public Thread {
static void *thread_callback(void *userdata);
static Thread *create_func_posix(ThreadCreateCallback p_callback, void *, const Settings &);
- static ID get_thread_ID_func_posix();
+ static ID get_thread_id_func_posix();
static void wait_to_finish_func_posix(Thread *p_thread);
static Error set_name_func_posix(const String &p_name);
@@ -61,7 +61,7 @@ class ThreadPosix : public Thread {
ThreadPosix();
public:
- virtual ID get_ID() const;
+ virtual ID get_id() const;
static void make_default();
diff --git a/drivers/windows/thread_windows.cpp b/drivers/windows/thread_windows.cpp
index 79077a54c8..01ddf42649 100644
--- a/drivers/windows/thread_windows.cpp
+++ b/drivers/windows/thread_windows.cpp
@@ -33,7 +33,7 @@
#include "os/memory.h"
-Thread::ID ThreadWindows::get_ID() const {
+Thread::ID ThreadWindows::get_id() const {
return id;
}
@@ -72,7 +72,7 @@ Thread *ThreadWindows::create_func_windows(ThreadCreateCallback p_callback, void
return tr;
}
-Thread::ID ThreadWindows::get_thread_ID_func_windows() {
+Thread::ID ThreadWindows::get_thread_id_func_windows() {
return (ID)GetCurrentThreadId(); //must implement
}
@@ -88,7 +88,7 @@ void ThreadWindows::wait_to_finish_func_windows(Thread *p_thread) {
void ThreadWindows::make_default() {
create_func = create_func_windows;
- get_thread_ID_func = get_thread_ID_func_windows;
+ get_thread_id_func = get_thread_id_func_windows;
wait_to_finish_func = wait_to_finish_func_windows;
}
diff --git a/drivers/windows/thread_windows.h b/drivers/windows/thread_windows.h
index 162df08975..143825039c 100644
--- a/drivers/windows/thread_windows.h
+++ b/drivers/windows/thread_windows.h
@@ -52,13 +52,13 @@ class ThreadWindows : public Thread {
static DWORD WINAPI thread_callback(LPVOID userdata);
static Thread *create_func_windows(ThreadCreateCallback p_callback, void *, const Settings &);
- static ID get_thread_ID_func_windows();
+ static ID get_thread_id_func_windows();
static void wait_to_finish_func_windows(Thread *p_thread);
ThreadWindows();
public:
- virtual ID get_ID() const;
+ virtual ID get_id() const;
static void make_default();
diff --git a/editor/array_property_edit.cpp b/editor/array_property_edit.cpp
index 81d5309712..06d7d5fdc8 100644
--- a/editor/array_property_edit.cpp
+++ b/editor/array_property_edit.cpp
@@ -251,7 +251,7 @@ void ArrayPropertyEdit::edit(Object *p_obj, const StringName &p_prop, const Stri
page = 0;
property = p_prop;
- obj = p_obj->get_instance_ID();
+ obj = p_obj->get_instance_id();
default_type = p_deftype;
if (!p_hint_string.empty()) {
diff --git a/editor/asset_library_editor_plugin.cpp b/editor/asset_library_editor_plugin.cpp
index f92b70d0c0..2a22cde2fb 100644
--- a/editor/asset_library_editor_plugin.cpp
+++ b/editor/asset_library_editor_plugin.cpp
@@ -1136,7 +1136,7 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const
item->connect("category_selected", this, "_select_category");
if (r.has("icon_url") && r["icon_url"] != "") {
- _request_image(item->get_instance_ID(), r["icon_url"], IMAGE_QUEUE_ICON, 0);
+ _request_image(item->get_instance_id(), r["icon_url"], IMAGE_QUEUE_ICON, 0);
}
}
} break;
@@ -1173,7 +1173,7 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const
item->connect("category_selected",this,"_category_selected");*/
if (r.has("icon_url") && r["icon_url"] != "") {
- _request_image(description->get_instance_ID(), r["icon_url"], IMAGE_QUEUE_ICON, 0);
+ _request_image(description->get_instance_id(), r["icon_url"], IMAGE_QUEUE_ICON, 0);
}
if (d.has("previews")) {
@@ -1195,12 +1195,12 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const
description->add_preview(i, is_video, video_url);
if (p.has("thumbnail")) {
- _request_image(description->get_instance_ID(), p["thumbnail"], IMAGE_QUEUE_THUMBNAIL, i);
+ _request_image(description->get_instance_id(), p["thumbnail"], IMAGE_QUEUE_THUMBNAIL, i);
}
if (is_video) {
- //_request_image(description->get_instance_ID(),p["link"],IMAGE_QUEUE_SCREENSHOT,i);
+ //_request_image(description->get_instance_id(),p["link"],IMAGE_QUEUE_SCREENSHOT,i);
} else {
- _request_image(description->get_instance_ID(), p["link"], IMAGE_QUEUE_SCREENSHOT, i);
+ _request_image(description->get_instance_id(), p["link"], IMAGE_QUEUE_SCREENSHOT, i);
}
}
}
diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp
index 9762bd2000..47c2cb5536 100644
--- a/editor/connections_dialog.cpp
+++ b/editor/connections_dialog.cpp
@@ -220,7 +220,7 @@ void ConnectDialog::_add_bind() {
if (cdbinds->params.size() >= VARIANT_ARG_MAX)
return;
- Variant::Type vt = (Variant::Type)type_list->get_item_ID(type_list->get_selected());
+ Variant::Type vt = (Variant::Type)type_list->get_item_id(type_list->get_selected());
Variant value;
diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp
index c82e8f1226..c3c3f0d3ca 100644
--- a/editor/editor_data.cpp
+++ b/editor/editor_data.cpp
@@ -183,7 +183,7 @@ ObjectID EditorHistory::get_current() {
if (!obj)
return 0;
- return obj->get_instance_ID();
+ return obj->get_instance_id();
}
int EditorHistory::get_path_size() const {
@@ -208,7 +208,7 @@ ObjectID EditorHistory::get_path_object(int p_index) const {
if (!obj)
return 0;
- return obj->get_instance_ID();
+ return obj->get_instance_id();
}
String EditorHistory::get_path_property(int p_index) const {
diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp
index ed58116304..0fd643d031 100644
--- a/editor/editor_file_system.cpp
+++ b/editor/editor_file_system.cpp
@@ -512,6 +512,8 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess
if (FileAccess::exists(cd.plus_file(f).plus_file("project.godot"))) // skip if another project inside this
continue;
+ if (FileAccess::exists(cd.plus_file(f).plus_file(".gdignore"))) // skip if another project inside this
+ continue;
dirs.push_back(f);
@@ -691,6 +693,8 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir, const
if (FileAccess::exists(cd.plus_file(f).plus_file("project.godot"))) // skip if another project inside this
continue;
+ if (FileAccess::exists(cd.plus_file(f).plus_file(".gdignore"))) // skip if another project inside this
+ continue;
EditorFileSystemDirectory *efd = memnew(EditorFileSystemDirectory);
diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp
index e890082ee1..f80c4ee0e2 100644
--- a/editor/editor_help.cpp
+++ b/editor/editor_help.cpp
@@ -1621,12 +1621,18 @@ void EditorHelp::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_READY: {
-
//forward->set_icon(get_icon("Forward","EditorIcons"));
//back->set_icon(get_icon("Back","EditorIcons"));
_update_doc();
+ } break;
+ case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
+ Ref<StyleBoxFlat> style(memnew(StyleBoxFlat));
+ style->set_bg_color(EditorSettings::get_singleton()->get("text_editor/highlighting/background_color"));
+ background_panel->add_style_override("panel", style);
} break;
+
+ default: break;
}
}
@@ -1695,14 +1701,14 @@ EditorHelp::EditorHelp() {
//class_list->set_selection_enabled(true);
{
- Panel *pc = memnew(Panel);
+ background_panel = memnew(Panel);
Ref<StyleBoxFlat> style(memnew(StyleBoxFlat));
style->set_bg_color(EditorSettings::get_singleton()->get("text_editor/highlighting/background_color"));
- pc->set_v_size_flags(SIZE_EXPAND_FILL);
- pc->add_style_override("panel", style); //get_stylebox("normal","TextEdit"));
- vbc->add_child(pc);
+ background_panel->set_v_size_flags(SIZE_EXPAND_FILL);
+ background_panel->add_style_override("panel", style); //get_stylebox("normal","TextEdit"));
+ vbc->add_child(background_panel);
class_desc = memnew(RichTextLabel);
- pc->add_child(class_desc);
+ background_panel->add_child(class_desc);
class_desc->set_area_as_parent_rect(8);
class_desc->connect("meta_clicked", this, "_class_desc_select");
class_desc->connect("gui_input", this, "_class_desc_input");
diff --git a/editor/editor_help.h b/editor/editor_help.h
index 46d83490f4..de30b543fc 100644
--- a/editor/editor_help.h
+++ b/editor/editor_help.h
@@ -129,6 +129,7 @@ class EditorHelp : public VBoxContainer {
HSplitContainer *h_split;
static DocData *doc;
+ Panel *background_panel;
ConfirmationDialog *search_dialog;
LineEdit *search;
diff --git a/editor/editor_log.cpp b/editor/editor_log.cpp
index 5d13c7c254..addffd6ea3 100644
--- a/editor/editor_log.cpp
+++ b/editor/editor_log.cpp
@@ -36,7 +36,7 @@
void EditorLog::_error_handler(void *p_self, const char *p_func, const char *p_file, int p_line, const char *p_error, const char *p_errorexp, ErrorHandlerType p_type) {
EditorLog *self = (EditorLog *)p_self;
- if (self->current != Thread::get_caller_ID())
+ if (self->current != Thread::get_caller_id())
return;
String err_str;
@@ -204,7 +204,7 @@ EditorLog::EditorLog() {
eh.userdata = this;
add_error_handler(&eh);
- current = Thread::get_caller_ID();
+ current = Thread::get_caller_id();
EditorNode::get_undo_redo()->set_commit_notify_callback(_undo_redo_cbk, this);
}
diff --git a/editor/editor_name_dialog.cpp b/editor/editor_name_dialog.cpp
index 7435e9a9f7..6ebfcbf313 100644
--- a/editor/editor_name_dialog.cpp
+++ b/editor/editor_name_dialog.cpp
@@ -42,8 +42,8 @@ void EditorNameDialog::_line_gui_input(const Ref<InputEvent> &p_event) {
return;
switch (k->get_scancode()) {
- case KEY_ENTER:
- case KEY_RETURN: {
+ case KEY_KP_ENTER:
+ case KEY_ENTER: {
if (get_hide_on_ok())
hide();
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 0cdb981306..730ba3cacc 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -110,6 +110,7 @@
// end
#include "editor_settings.h"
#include "import/editor_import_collada.h"
+#include "import/editor_scene_importer_gltf.h"
#include "io_plugins/editor_bitmask_import_plugin.h"
#include "io_plugins/editor_export_scene.h"
#include "io_plugins/editor_font_import_plugin.h"
@@ -1357,7 +1358,7 @@ void EditorNode::push_item(Object *p_object, const String &p_property) {
return;
}
- uint32_t id = p_object->get_instance_ID();
+ uint32_t id = p_object->get_instance_id();
if (id != editor_history.get_current()) {
if (p_property == "")
@@ -5151,6 +5152,10 @@ EditorNode::EditorNode() {
Ref<EditorOBJImporter> import_obj;
import_obj.instance();
import_scene->add_importer(import_obj);
+
+ Ref<EditorSceneImporterGLTF> import_gltf;
+ import_gltf.instance();
+ import_scene->add_importer(import_gltf);
}
}
diff --git a/editor/editor_path.cpp b/editor/editor_path.cpp
index 8ce4f88590..fdac68ea1f 100644
--- a/editor/editor_path.cpp
+++ b/editor/editor_path.cpp
@@ -63,7 +63,7 @@ void EditorPath::_add_children_to_popup(Object *p_obj, int p_depth) {
int index = popup->get_item_count();
popup->add_icon_item(icon, E->get().name.capitalize(), objects.size());
popup->set_item_h_offset(index, p_depth * 10 * EDSCALE);
- objects.push_back(obj->get_instance_ID());
+ objects.push_back(obj->get_instance_id());
_add_children_to_popup(obj, p_depth + 1);
}
diff --git a/editor/editor_resource_preview.cpp b/editor/editor_resource_preview.cpp
index 89fa004eb1..3d761d7289 100644
--- a/editor/editor_resource_preview.cpp
+++ b/editor/editor_resource_preview.cpp
@@ -295,7 +295,7 @@ void EditorResourcePreview::queue_edited_resource_preview(const Ref<Resource> &p
preview_mutex->lock();
- String path_id = "ID:" + itos(p_res->get_instance_ID());
+ String path_id = "ID:" + itos(p_res->get_instance_id());
if (cache.has(path_id) && cache[path_id].last_hash == p_res->hash_edited_version()) {
@@ -310,7 +310,7 @@ void EditorResourcePreview::queue_edited_resource_preview(const Ref<Resource> &p
//print_line("send to thread "+p_path);
QueueItem item;
item.function = p_receiver_func;
- item.id = p_receiver->get_instance_ID();
+ item.id = p_receiver->get_instance_id();
item.resource = p_res;
item.path = path_id;
item.userdata = p_userdata;
@@ -334,7 +334,7 @@ void EditorResourcePreview::queue_resource_preview(const String &p_path, Object
//print_line("send to thread "+p_path);
QueueItem item;
item.function = p_receiver_func;
- item.id = p_receiver->get_instance_ID();
+ item.id = p_receiver->get_instance_id();
item.path = p_path;
item.userdata = p_userdata;
diff --git a/editor/editor_run.cpp b/editor/editor_run.cpp
index aa97dd237b..4954b1f741 100644
--- a/editor/editor_run.cpp
+++ b/editor/editor_run.cpp
@@ -55,7 +55,7 @@ Error EditorRun::run(const String &p_scene, const String p_custom_args, const Li
}
args.push_back("-epid");
- args.push_back(String::num(OS::get_singleton()->get_process_ID()));
+ args.push_back(String::num(OS::get_singleton()->get_process_id()));
if (debug_collisions) {
args.push_back("-debugcol");
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index 755ac75180..07af60d634 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -216,17 +216,43 @@ Variant _EDITOR_DEF(const String &p_var, const Variant &p_default) {
return p_default;
}
+static Dictionary _get_builtin_script_templates() {
+ Dictionary templates;
+
+ //No Comments
+ templates["no_comments.gd"] =
+ "extends %BASE%\n"
+ "\n"
+ "func _ready():\n"
+ "%TS%pass\n";
+
+ //Empty
+ templates["empty.gd"] =
+ "extends %BASE%"
+ "\n"
+ "\n";
+
+ return templates;
+}
+
static void _create_script_templates(const String &p_path) {
- FileAccess *file = FileAccess::open(p_path.plus_file("no_comments.gd"), FileAccess::WRITE);
- ERR_FAIL_COND(!file);
- String script = String("extends %BASE%\n\nfunc _ready():\n%TS%pass\n");
- file->store_string(script);
- file->close();
- file->reopen(p_path.plus_file("empty.gd"), FileAccess::WRITE);
- script = "extends %BASE%\n\n";
- file->store_string(script);
- file->close();
+ Dictionary templates = _get_builtin_script_templates();
+ List<Variant> keys;
+ templates.get_key_list(&keys);
+ FileAccess *file = FileAccess::create(FileAccess::ACCESS_FILESYSTEM);
+
+ DirAccess *dir = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
+ dir->change_dir(p_path);
+ for (int i = 0; i < keys.size(); i++) {
+ if (!dir->file_exists(keys[i])) {
+ file->reopen(p_path.plus_file((String)keys[i]), FileAccess::WRITE);
+ ERR_FAIL_COND(!file);
+ file->store_string(templates[keys[i]]);
+ file->close();
+ }
+ }
+
memdelete(file);
}
@@ -308,10 +334,10 @@ void EditorSettings::create() {
if (dir->change_dir("script_templates") != OK) {
dir->make_dir("script_templates");
- _create_script_templates(dir->get_current_dir() + "/script_templates");
} else {
dir->change_dir("..");
}
+ _create_script_templates(dir->get_current_dir() + "/script_templates");
if (dir->change_dir("tmp") != OK) {
dir->make_dir("tmp");
diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp
index 6b985c7b4b..807aed4267 100644
--- a/editor/editor_themes.cpp
+++ b/editor/editor_themes.cpp
@@ -143,7 +143,7 @@ Ref<Theme> create_editor_theme() {
Color light_color_1 = base_color.linear_interpolate(Color(1, 1, 1, 1), contrast);
Color light_color_2 = base_color.linear_interpolate(Color(1, 1, 1, 1), contrast * 1.5);
- const int border_width = (border_size % 3) * EDSCALE;
+ const int border_width = CLAMP(border_size, 0, 3) * EDSCALE;
Color title_color_hl = base_color;
if (highlight_tabs)
@@ -163,6 +163,13 @@ Ref<Theme> create_editor_theme() {
theme->set_color("light_color_1", "Editor", light_color_1);
theme->set_color("light_color_2", "Editor", light_color_2);
+ Color success_color = highlight_color.linear_interpolate(Color(0, 1, .8), 0.8);
+ Color warning_color = highlight_color.linear_interpolate(Color(1, 1, .2), 0.8);
+ Color error_color = highlight_color.linear_interpolate(Color(1, .2, .2), 0.8);
+ theme->set_color("success_color", "Editor", success_color);
+ theme->set_color("warning_color", "Editor", warning_color);
+ theme->set_color("error_color", "Editor", error_color);
+
// Checkbox icon
theme->set_icon("checked", "CheckBox", theme->get_icon("GuiChecked", "EditorIcons"));
theme->set_icon("unchecked", "CheckBox", theme->get_icon("GuiUnchecked", "EditorIcons"));
@@ -231,7 +238,7 @@ Ref<Theme> create_editor_theme() {
theme->set_stylebox("panel", "TabContainer", style_content_panel);
theme->set_stylebox("Content", "EditorStyles", style_content_panel_vp);
- Ref<StyleBoxFlat> style_button_type = make_flat_stylebox(dark_color_1, 4, 4, 6, 4);
+ Ref<StyleBoxFlat> style_button_type = make_flat_stylebox(dark_color_1, 6, 4, 6, 4);
style_button_type->set_draw_center(true);
style_button_type->set_border_size(border_width);
style_button_type->set_light_color(light_color_1);
@@ -280,12 +287,12 @@ Ref<Theme> create_editor_theme() {
// PopupMenu
Ref<StyleBoxFlat> style_popup_menu = make_flat_stylebox(dark_color_1, 8, 8, 8, 8);
- style_popup_menu->set_border_size(border_width);
+ style_popup_menu->set_border_size(MAX(EDSCALE, border_width));
style_popup_menu->set_light_color(light_color_1);
style_popup_menu->set_dark_color(light_color_1);
style_popup_menu->set_border_blend(false);
theme->set_stylebox("panel", "PopupMenu", style_popup_menu);
- theme->set_stylebox("separator", "PopupMenu", make_line_stylebox(separator_color, border_width, 8 - border_width));
+ theme->set_stylebox("separator", "PopupMenu", make_line_stylebox(separator_color, MAX(EDSCALE, border_width), 8 - MAX(EDSCALE, border_width)));
// Tree & ItemList background
Ref<StyleBoxFlat> style_tree_bg = make_flat_stylebox(dark_color_1, 2, 4, 2, 4);
@@ -307,8 +314,8 @@ Ref<Theme> create_editor_theme() {
theme->set_icon("arrow_collapsed", "Tree", theme->get_icon("GuiTreeArrowRight", "EditorIcons"));
theme->set_icon("select_arrow", "Tree", theme->get_icon("GuiDropdown", "EditorIcons"));
theme->set_stylebox("bg_focus", "Tree", focus_sbt);
- theme->set_stylebox("custom_button", "Tree", style_button_type);
- theme->set_stylebox("custom_button_pressed", "Tree", style_button_type);
+ theme->set_stylebox("custom_button", "Tree", make_empty_stylebox());
+ theme->set_stylebox("custom_button_pressed", "Tree", make_empty_stylebox());
theme->set_stylebox("custom_button_hover", "Tree", style_button_type);
theme->set_color("custom_button_font_highlight", "Tree", HIGHLIGHT_COLOR_LIGHT);
@@ -424,7 +431,7 @@ Ref<Theme> create_editor_theme() {
// WindowDialog
Ref<StyleBoxFlat> style_window = make_flat_stylebox(dark_color_2, 4, 4, 4, 4);
- style_window->set_border_size(border_width);
+ style_window->set_border_size(MAX(EDSCALE, border_width));
style_window->set_border_blend(false);
style_window->set_light_color(title_color_hl);
style_window->set_dark_color(title_color_hl);
@@ -471,6 +478,9 @@ Ref<Theme> create_editor_theme() {
theme->set_icon("grabber", "VSlider", theme->get_icon("GuiSliderGrabber", "EditorIcons"));
theme->set_icon("grabber_highlight", "VSlider", theme->get_icon("GuiSliderGrabberHl", "EditorIcons"));
+ //RichTextLabel
+ theme->set_stylebox("focus", "RichTextLabel", make_empty_stylebox());
+
// Panel
theme->set_stylebox("panel", "Panel", style_panel);
diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp
index 77ca1a5145..7c5cd48605 100644
--- a/editor/filesystem_dock.cpp
+++ b/editor/filesystem_dock.cpp
@@ -102,7 +102,7 @@ void FileSystemDock::_notification(int p_what) {
case NOTIFICATION_RESIZED: {
- bool new_mode = get_size().height < get_viewport_rect().size.height * 3 / 4;
+ bool new_mode = get_size().height < get_viewport_rect().size.height / 2;
if (new_mode != split_mode) {
@@ -589,7 +589,7 @@ void FileSystemDock::_go_to_dir(const String &p_dir) {
void FileSystemDock::_preview_invalidated(const String &p_path) {
- if (p_path.get_base_dir() == path && search_box->get_text() == String() && file_list_vb->is_visible_in_tree()) {
+ if (display_mode == DISPLAY_THUMBNAILS && p_path.get_base_dir() == path && search_box->get_text() == String() && file_list_vb->is_visible_in_tree()) {
for (int i = 0; i < files->get_item_count(); i++) {
diff --git a/editor/icons/2x/icon_GUI_dropdown.png b/editor/icons/2x/icon_GUI_dropdown.png
index c959378430..78d3352e4e 100644
--- a/editor/icons/2x/icon_GUI_dropdown.png
+++ b/editor/icons/2x/icon_GUI_dropdown.png
Binary files differ
diff --git a/editor/icons/icon_GUI_dropdown.png b/editor/icons/icon_GUI_dropdown.png
index 4bd6544830..d21cdb634e 100644
--- a/editor/icons/icon_GUI_dropdown.png
+++ b/editor/icons/icon_GUI_dropdown.png
Binary files differ
diff --git a/editor/icons/source/icon_GUI_dropdown.svg b/editor/icons/source/icon_GUI_dropdown.svg
index f313b09983..897f63c268 100644
--- a/editor/icons/source/icon_GUI_dropdown.svg
+++ b/editor/icons/source/icon_GUI_dropdown.svg
@@ -9,9 +9,9 @@
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
- width="8"
+ width="14"
height="14"
- viewBox="0 0 8 14"
+ viewBox="0 0 14 14"
id="svg2"
version="1.1"
inkscape:version="0.92+devel unknown"
@@ -28,9 +28,9 @@
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
- inkscape:zoom="45.254834"
- inkscape:cx="1.2944669"
- inkscape:cy="5.9830116"
+ inkscape:zoom="32"
+ inkscape:cx="6.5843041"
+ inkscape:cy="6.8000184"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -72,21 +72,21 @@
id="layer1"
transform="translate(0,-1038.3622)">
<circle
- style="fill:#ffffff;fill-opacity:0.58823532;stroke-width:2;stroke-linejoin:round;stroke-opacity:0.39215686"
+ style="fill:#ffffff;fill-opacity:0.58823529;stroke-width:2;stroke-linejoin:round;stroke-opacity:0.39215686"
id="path4268"
- cx="4.5"
+ cx="7.5"
cy="1040.8622"
r="1.5" />
<circle
r="1.5"
cy="1045.8622"
- cx="4.5"
+ cx="7.5"
id="circle4271"
- style="fill:#ffffff;fill-opacity:0.58823532;stroke-width:2;stroke-linejoin:round;stroke-opacity:0.39215686" />
+ style="fill:#ffffff;fill-opacity:0.58823529;stroke-width:2;stroke-linejoin:round;stroke-opacity:0.39215686" />
<circle
- style="fill:#ffffff;fill-opacity:0.58823532;stroke-width:2;stroke-linejoin:round;stroke-opacity:0.39215686"
+ style="fill:#ffffff;fill-opacity:0.58823529;stroke-width:2;stroke-linejoin:round;stroke-opacity:0.39215686"
id="circle4273"
- cx="4.5"
+ cx="7.5"
cy="1050.8622"
r="1.5" />
</g>
diff --git a/editor/icons/source/icon_connect.svg b/editor/icons/source/icon_connect.svg
index 745d3cc436..15c8b481a1 100644
--- a/editor/icons/source/icon_connect.svg
+++ b/editor/icons/source/icon_connect.svg
@@ -14,7 +14,7 @@
viewBox="0 0 16 16"
id="svg2"
version="1.1"
- inkscape:version="0.91 r13725"
+ inkscape:version="0.92+devel unknown"
inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_add_track.png"
inkscape:export-xdpi="45"
inkscape:export-ydpi="45"
@@ -28,9 +28,9 @@
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
- inkscape:zoom="22.627418"
- inkscape:cx="0.78663326"
- inkscape:cy="12.940707"
+ inkscape:zoom="32.000001"
+ inkscape:cx="13.864856"
+ inkscape:cy="7.2235346"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -46,7 +46,8 @@
inkscape:window-height="1016"
inkscape:window-x="0"
inkscape:window-y="27"
- inkscape:window-maximized="1">
+ inkscape:window-maximized="1"
+ inkscape:document-rotation="0">
<inkscape:grid
type="xygrid"
id="grid3336" />
@@ -68,10 +69,37 @@
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-1036.3622)">
+ <circle
+ style="fill:#e0e0e0;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round"
+ id="path4266"
+ cx="4"
+ cy="1048.3622"
+ r="2" />
<path
- style="fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:3;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
- d="M 7 2 A 2 2 0 0 0 5 4 L 5 7 L 1 7 L 1 9 L 5 9 L 5 12 A 2 2 0 0 0 7 14 L 11 14 L 11 12 L 14 12 L 14 10 L 11 10 L 11 6 L 14 6 L 14 4 L 11 4 L 11 2 L 7 2 z "
- transform="translate(0,1036.3622)"
- id="rect4155" />
+ id="circle4268"
+ style="fill:none;stroke:#e0e0e0;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ sodipodi:type="arc"
+ sodipodi:cx="4"
+ sodipodi:cy="1048.3622"
+ sodipodi:rx="5"
+ sodipodi:ry="5"
+ sodipodi:start="4.712389"
+ sodipodi:end="0"
+ sodipodi:arc-type="arc"
+ d="M 4.0000001,1043.3622 A 5,5 0 0 1 9,1048.3622"
+ sodipodi:open="true" />
+ <path
+ id="circle4270"
+ style="fill:none;stroke:#e0e0e0;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ sodipodi:type="arc"
+ sodipodi:cx="4"
+ sodipodi:cy="1048.3622"
+ sodipodi:rx="9"
+ sodipodi:ry="9"
+ sodipodi:start="4.712389"
+ sodipodi:end="0"
+ sodipodi:open="true"
+ sodipodi:arc-type="arc"
+ d="m 4.0000002,1039.3622 a 9,9 0 0 1 8.9999998,9" />
</g>
</svg>
diff --git a/editor/import/editor_scene_importer_gltf.cpp b/editor/import/editor_scene_importer_gltf.cpp
new file mode 100644
index 0000000000..1c42bcef8a
--- /dev/null
+++ b/editor/import/editor_scene_importer_gltf.cpp
@@ -0,0 +1,2108 @@
+#include "editor_scene_importer_gltf.h"
+#include "io/json.h"
+#include "os/file_access.h"
+#include "os/os.h"
+#include "scene/3d/camera.h"
+#include "scene/3d/mesh_instance.h"
+#include "scene/animation/animation_player.h"
+#include "scene/resources/surface_tool.h"
+#include "thirdparty/misc/base64.h"
+
+uint32_t EditorSceneImporterGLTF::get_import_flags() const {
+
+ return IMPORT_SCENE | IMPORT_ANIMATION;
+}
+void EditorSceneImporterGLTF::get_extensions(List<String> *r_extensions) const {
+
+ r_extensions->push_back("gltf");
+ r_extensions->push_back("glb");
+}
+
+Error EditorSceneImporterGLTF::_parse_json(const String &p_path, GLTFState &state) {
+
+ Error err;
+ FileAccessRef f = FileAccess::open(p_path, FileAccess::READ, &err);
+ if (!f) {
+ return err;
+ }
+
+ Vector<uint8_t> array;
+ array.resize(f->get_len());
+ f->get_buffer(array.ptr(), array.size());
+ String text;
+ text.parse_utf8((const char *)array.ptr(), array.size());
+
+ String err_txt;
+ int err_line;
+ Variant v;
+ err = JSON::parse(text, v, err_txt, err_line);
+ if (err != OK) {
+ _err_print_error("", p_path.utf8().get_data(), err_line, err_txt.utf8().get_data(), ERR_HANDLER_SCRIPT);
+ return err;
+ }
+ state.json = v;
+
+ return OK;
+}
+
+Error EditorSceneImporterGLTF::_parse_glb(const String &p_path, GLTFState &state) {
+
+ Error err;
+ FileAccessRef f = FileAccess::open(p_path, FileAccess::READ, &err);
+ if (!f) {
+ return err;
+ }
+
+ uint32_t magic = f->get_32();
+ ERR_FAIL_COND_V(magic != 0x46546C67, ERR_FILE_UNRECOGNIZED); //glTF
+ uint32_t version = f->get_32();
+ uint32_t length = f->get_32();
+
+ uint32_t chunk_length = f->get_32();
+ uint32_t chunk_type = f->get_32();
+
+ ERR_FAIL_COND_V(chunk_type != 0x4E4F534A, ERR_PARSE_ERROR); //JSON
+ Vector<uint8_t> json_data;
+ json_data.resize(chunk_length);
+ uint32_t len = f->get_buffer(json_data.ptr(), chunk_length);
+ ERR_FAIL_COND_V(len != chunk_length, ERR_FILE_CORRUPT);
+
+ String text;
+ text.parse_utf8((const char *)json_data.ptr(), json_data.size());
+
+ String err_txt;
+ int err_line;
+ Variant v;
+ err = JSON::parse(text, v, err_txt, err_line);
+ if (err != OK) {
+ _err_print_error("", p_path.utf8().get_data(), err_line, err_txt.utf8().get_data(), ERR_HANDLER_SCRIPT);
+ return err;
+ }
+
+ state.json = v;
+
+ //data?
+
+ chunk_length = f->get_32();
+ chunk_type = f->get_32();
+
+ if (f->eof_reached()) {
+ return OK; //all good
+ }
+
+ ERR_FAIL_COND_V(chunk_type != 0x004E4942, ERR_PARSE_ERROR); //BIN
+
+ state.glb_data.resize(chunk_length);
+ len = f->get_buffer(state.glb_data.ptr(), chunk_length);
+ ERR_FAIL_COND_V(len != chunk_length, ERR_FILE_CORRUPT);
+
+ return OK;
+}
+
+static Vector3 _arr_to_vec3(const Array &p_array) {
+ ERR_FAIL_COND_V(p_array.size() != 3, Vector3());
+ return Vector3(p_array[0], p_array[1], p_array[2]);
+}
+
+static Quat _arr_to_quat(const Array &p_array) {
+ ERR_FAIL_COND_V(p_array.size() != 4, Quat());
+ return Quat(p_array[0], p_array[1], p_array[2], p_array[3]);
+}
+
+static Transform _arr_to_xform(const Array &p_array) {
+ ERR_FAIL_COND_V(p_array.size() != 16, Transform());
+
+ Transform xform;
+ xform.basis.set_axis(Vector3::AXIS_X, Vector3(p_array[0], p_array[1], p_array[2]));
+ xform.basis.set_axis(Vector3::AXIS_Y, Vector3(p_array[4], p_array[5], p_array[6]));
+ xform.basis.set_axis(Vector3::AXIS_Z, Vector3(p_array[8], p_array[9], p_array[10]));
+ xform.set_origin(Vector3(p_array[12], p_array[13], p_array[14]));
+
+ return xform;
+}
+
+String EditorSceneImporterGLTF::_gen_unique_name(GLTFState &state, const String &p_name) {
+
+ int index = 1;
+
+ String name;
+ while (true) {
+
+ name = p_name;
+ if (index > 1) {
+ name += " " + itos(index);
+ }
+ if (!state.unique_names.has(name)) {
+ break;
+ }
+ index++;
+ }
+
+ state.unique_names.insert(name);
+
+ return name;
+}
+
+Error EditorSceneImporterGLTF::_parse_scenes(GLTFState &state) {
+
+ ERR_FAIL_COND_V(!state.json.has("scenes"), ERR_FILE_CORRUPT);
+ Array scenes = state.json["scenes"];
+ for (int i = 0; i < 1; i++) { //only first scene is imported
+ Dictionary s = scenes[i];
+ ERR_FAIL_COND_V(!s.has("nodes"), ERR_UNAVAILABLE);
+ Array nodes = s["nodes"];
+ for (int j = 0; j < nodes.size(); j++) {
+ state.root_nodes.push_back(nodes[j]);
+ }
+
+ if (s.has("name")) {
+ state.scene_name = s["name"];
+ }
+ }
+
+ return OK;
+}
+
+Error EditorSceneImporterGLTF::_parse_nodes(GLTFState &state) {
+
+ ERR_FAIL_COND_V(!state.json.has("nodes"), ERR_FILE_CORRUPT);
+ Array nodes = state.json["nodes"];
+ for (int i = 0; i < nodes.size(); i++) {
+
+ GLTFNode *node = memnew(GLTFNode);
+ Dictionary n = nodes[i];
+
+ print_line("node " + itos(i) + ": " + String(Variant(n)));
+ if (n.has("name")) {
+ node->name = n["name"];
+ }
+ if (n.has("camera")) {
+ node->camera = n["camera"];
+ }
+ if (n.has("mesh")) {
+ node->mesh = n["mesh"];
+ }
+ if (n.has("skin")) {
+ node->skin = n["skin"];
+ if (!state.skin_users.has(node->skin)) {
+ state.skin_users[node->skin] = Vector<int>();
+ }
+
+ state.skin_users[node->skin].push_back(i);
+ }
+ if (n.has("matrix")) {
+ node->xform = _arr_to_xform(n["matrix"]);
+
+ } else {
+
+ if (n.has("translation")) {
+ node->translation = _arr_to_vec3(n["translation"]);
+ }
+ if (n.has("rotation")) {
+ node->rotation = _arr_to_quat(n["rotation"]);
+ }
+ if (n.has("scale")) {
+ node->scale = _arr_to_vec3(n["scale"]);
+ }
+
+ node->xform.basis = Basis(node->rotation);
+ node->xform.basis.scale(node->scale);
+ node->xform.origin = node->translation;
+ }
+
+ if (n.has("children")) {
+ Array children = n["children"];
+ for (int i = 0; i < children.size(); i++) {
+ node->children.push_back(children[i]);
+ }
+ }
+
+ state.nodes.push_back(node);
+ }
+
+ //build the hierarchy
+
+ for (int i = 0; i < state.nodes.size(); i++) {
+
+ for (int j = 0; j < state.nodes[i]->children.size(); j++) {
+ int child = state.nodes[i]->children[j];
+ ERR_FAIL_INDEX_V(child, state.nodes.size(), ERR_FILE_CORRUPT);
+ ERR_CONTINUE(state.nodes[child]->parent != -1); //node already has a parent, wtf.
+
+ state.nodes[child]->parent = i;
+ }
+ }
+
+ return OK;
+}
+
+static Vector<uint8_t> _parse_base64_uri(const String &uri) {
+
+ int start = uri.find(",");
+ ERR_FAIL_COND_V(start == -1, Vector<uint8_t>());
+
+ CharString substr = uri.right(start + 1).ascii();
+
+ int strlen = substr.length();
+
+ Vector<uint8_t> buf;
+ buf.resize(strlen / 4 * 3 + 1 + 1);
+
+ int len = base64_decode((char *)buf.ptr(), (char *)substr.get_data(), strlen);
+
+ buf.resize(len);
+
+ return buf;
+}
+
+Error EditorSceneImporterGLTF::_parse_buffers(GLTFState &state, const String &p_base_path) {
+
+ if (!state.json.has("buffers"))
+ return OK;
+
+ Array buffers = state.json["buffers"];
+ for (int i = 0; i < buffers.size(); i++) {
+
+ if (i == 0 && state.glb_data.size()) {
+ state.buffers.push_back(state.glb_data);
+
+ } else {
+ Dictionary buffer = buffers[i];
+ if (buffer.has("uri")) {
+
+ Vector<uint8_t> buffer_data;
+ String uri = buffer["uri"];
+
+ if (uri.findn("data:application/octet-stream;base64") == 0) {
+ //embedded data
+ buffer_data = _parse_base64_uri(uri);
+ } else {
+
+ uri = p_base_path.plus_file(uri).replace("\\", "/"); //fix for windows
+ buffer_data = FileAccess::get_file_as_array(uri);
+ ERR_FAIL_COND_V(buffer.size() == 0, ERR_PARSE_ERROR);
+ }
+
+ ERR_FAIL_COND_V(!buffer.has("byteLength"), ERR_PARSE_ERROR);
+ int byteLength = buffer["byteLength"];
+ ERR_FAIL_COND_V(byteLength < buffer_data.size(), ERR_PARSE_ERROR);
+ state.buffers.push_back(buffer_data);
+ }
+ }
+ }
+
+ print_line("total buffers: " + itos(state.buffers.size()));
+
+ return OK;
+}
+
+Error EditorSceneImporterGLTF::_parse_buffer_views(GLTFState &state) {
+
+ ERR_FAIL_COND_V(!state.json.has("bufferViews"), ERR_FILE_CORRUPT);
+ Array buffers = state.json["bufferViews"];
+ for (int i = 0; i < buffers.size(); i++) {
+
+ Dictionary d = buffers[i];
+
+ GLTFBufferView buffer_view;
+
+ ERR_FAIL_COND_V(!d.has("buffer"), ERR_PARSE_ERROR);
+ buffer_view.buffer = d["buffer"];
+ ERR_FAIL_COND_V(!d.has("byteLength"), ERR_PARSE_ERROR);
+ buffer_view.byte_length = d["byteLength"];
+
+ if (d.has("byteOffset")) {
+ buffer_view.byte_offset = d["byteOffset"];
+ }
+
+ if (d.has("byteStride")) {
+ buffer_view.byte_stride = d["byteStride"];
+ }
+
+ if (d.has("target")) {
+ int target = d["target"];
+ buffer_view.indices = target == ELEMENT_ARRAY_BUFFER;
+ }
+
+ state.buffer_views.push_back(buffer_view);
+ }
+
+ print_line("total buffer views: " + itos(state.buffer_views.size()));
+
+ return OK;
+}
+
+EditorSceneImporterGLTF::GLTFType EditorSceneImporterGLTF::_get_type_from_str(const String &p_string) {
+
+ if (p_string == "SCALAR")
+ return TYPE_SCALAR;
+
+ if (p_string == "VEC2")
+ return TYPE_VEC2;
+ if (p_string == "VEC3")
+ return TYPE_VEC3;
+ if (p_string == "VEC4")
+ return TYPE_VEC4;
+
+ if (p_string == "MAT2")
+ return TYPE_MAT2;
+ if (p_string == "MAT3")
+ return TYPE_MAT3;
+ if (p_string == "MAT4")
+ return TYPE_MAT4;
+
+ ERR_FAIL_V(TYPE_SCALAR);
+}
+
+Error EditorSceneImporterGLTF::_parse_accessors(GLTFState &state) {
+
+ ERR_FAIL_COND_V(!state.json.has("accessors"), ERR_FILE_CORRUPT);
+ Array accessors = state.json["accessors"];
+ for (int i = 0; i < accessors.size(); i++) {
+
+ Dictionary d = accessors[i];
+
+ GLTFAccessor accessor;
+
+ ERR_FAIL_COND_V(!d.has("componentType"), ERR_PARSE_ERROR);
+ accessor.component_type = d["componentType"];
+ ERR_FAIL_COND_V(!d.has("count"), ERR_PARSE_ERROR);
+ accessor.count = d["count"];
+ ERR_FAIL_COND_V(!d.has("type"), ERR_PARSE_ERROR);
+ accessor.type = _get_type_from_str(d["type"]);
+
+ if (d.has("bufferView")) {
+ accessor.buffer_view = d["bufferView"]; //optional because it may be sparse...
+ }
+
+ if (d.has("byteOffset")) {
+ accessor.byte_offset = d["byteOffset"];
+ }
+
+ if (d.has("max")) {
+ accessor.max = d["max"];
+ }
+
+ if (d.has("min")) {
+ accessor.min = d["min"];
+ }
+
+ if (d.has("sparse")) {
+ //eeh..
+
+ Dictionary s = d["sparse"];
+
+ ERR_FAIL_COND_V(!d.has("count"), ERR_PARSE_ERROR);
+ accessor.sparse_count = d["count"];
+ ERR_FAIL_COND_V(!d.has("indices"), ERR_PARSE_ERROR);
+ Dictionary si = d["indices"];
+
+ ERR_FAIL_COND_V(!si.has("bufferView"), ERR_PARSE_ERROR);
+ accessor.sparse_indices_buffer_view = si["bufferView"];
+ ERR_FAIL_COND_V(!si.has("componentType"), ERR_PARSE_ERROR);
+ accessor.sparse_indices_component_type = si["componentType"];
+
+ if (si.has("byteOffset")) {
+ accessor.sparse_indices_byte_offset = si["byteOffset"];
+ }
+
+ ERR_FAIL_COND_V(!d.has("values"), ERR_PARSE_ERROR);
+ Dictionary sv = d["values"];
+
+ ERR_FAIL_COND_V(!sv.has("bufferView"), ERR_PARSE_ERROR);
+ accessor.sparse_values_buffer_view = sv["bufferView"];
+ if (sv.has("byteOffset")) {
+ accessor.sparse_values_byte_offset = sv["byteOffset"];
+ }
+ }
+
+ state.accessors.push_back(accessor);
+ }
+
+ print_line("total accessors: " + itos(state.accessors.size()));
+
+ return OK;
+}
+
+String EditorSceneImporterGLTF::_get_component_type_name(uint32_t p_component) {
+
+ switch (p_component) {
+ case COMPONENT_TYPE_BYTE: return "Byte";
+ case COMPONENT_TYPE_UNSIGNED_BYTE: return "UByte";
+ case COMPONENT_TYPE_SHORT: return "Short";
+ case COMPONENT_TYPE_UNSIGNED_SHORT: return "UShort";
+ case COMPONENT_TYPE_INT: return "Int";
+ case COMPONENT_TYPE_FLOAT: return "Float";
+ }
+
+ return "<Error>";
+}
+
+String EditorSceneImporterGLTF::_get_type_name(GLTFType p_component) {
+
+ static const char *names[] = {
+ "float",
+ "vec2",
+ "vec3",
+ "vec4",
+ "mat2",
+ "mat3",
+ "mat4"
+ };
+
+ return names[p_component];
+}
+
+Error EditorSceneImporterGLTF::_decode_buffer_view(GLTFState &state, int p_buffer_view, double *dst, int skip_every, int skip_bytes, int element_size, int count, GLTFType type, int component_count, int component_type, int component_size, bool normalized, int byte_offset, bool for_vertex) {
+
+ const GLTFBufferView &bv = state.buffer_views[p_buffer_view];
+
+ int stride = bv.byte_stride ? bv.byte_stride : element_size;
+ if (for_vertex && stride % 4) {
+ stride += 4 - (stride % 4); //according to spec must be multiple of 4
+ }
+
+ ERR_FAIL_INDEX_V(bv.buffer, state.buffers.size(), ERR_PARSE_ERROR);
+
+ uint32_t offset = bv.byte_offset + byte_offset;
+ Vector<uint8_t> buffer = state.buffers[bv.buffer]; //copy on write, so no performance hit
+
+ //use to debug
+ print_line("type " + _get_type_name(type) + " component type: " + _get_component_type_name(component_type) + " stride: " + itos(stride) + " amount " + itos(count));
+ print_line("accessor offset" + itos(byte_offset) + " view offset: " + itos(bv.byte_offset) + " total buffer len: " + itos(buffer.size()) + " view len " + itos(bv.byte_length));
+
+ int buffer_end = (stride * (count - 1)) + element_size;
+ ERR_FAIL_COND_V(buffer_end > bv.byte_length, ERR_PARSE_ERROR);
+
+ ERR_FAIL_COND_V((offset + buffer_end) > buffer.size(), ERR_PARSE_ERROR);
+
+ //fill everything as doubles
+
+ for (int i = 0; i < count; i++) {
+
+ const uint8_t *src = &buffer[offset + i * stride];
+
+ for (int j = 0; j < component_count; j++) {
+
+ if (skip_every && j > 0 && (j % skip_every) == 0) {
+ src += skip_bytes;
+ }
+
+ double d = 0;
+
+ switch (component_type) {
+ case COMPONENT_TYPE_BYTE: {
+ int8_t b = int8_t(*src);
+ if (normalized) {
+ d = (double(b) / 128.0);
+ } else {
+ d = double(b);
+ }
+ } break;
+ case COMPONENT_TYPE_UNSIGNED_BYTE: {
+ uint8_t b = *src;
+ if (normalized) {
+ d = (double(b) / 255.0);
+ } else {
+ d = double(b);
+ }
+ } break;
+ case COMPONENT_TYPE_SHORT: {
+ int16_t s = *(int16_t *)src;
+ if (normalized) {
+ d = (double(s) / 32768.0);
+ } else {
+ d = double(s);
+ }
+ } break;
+ case COMPONENT_TYPE_UNSIGNED_SHORT: {
+ uint16_t s = *(uint16_t *)src;
+ if (normalized) {
+ d = (double(s) / 65535.0);
+ } else {
+ d = double(s);
+ }
+
+ } break;
+ case COMPONENT_TYPE_INT: {
+ d = *(int *)src;
+ } break;
+ case COMPONENT_TYPE_FLOAT: {
+ d = *(float *)src;
+ } break;
+ }
+
+ *dst++ = d;
+ src += component_size;
+ }
+ }
+
+ return OK;
+}
+
+int EditorSceneImporterGLTF::_get_component_type_size(int component_type) {
+
+ switch (component_type) {
+ case COMPONENT_TYPE_BYTE: return 1; break;
+ case COMPONENT_TYPE_UNSIGNED_BYTE: return 1; break;
+ case COMPONENT_TYPE_SHORT: return 2; break;
+ case COMPONENT_TYPE_UNSIGNED_SHORT: return 2; break;
+ case COMPONENT_TYPE_INT: return 4; break;
+ case COMPONENT_TYPE_FLOAT: return 4; break;
+ default: { ERR_FAIL_V(0); }
+ }
+ return 0;
+}
+
+Vector<double> EditorSceneImporterGLTF::_decode_accessor(GLTFState &state, int p_accessor, bool p_for_vertex) {
+
+ //spec, for reference:
+ //https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#data-alignment
+
+ ERR_FAIL_INDEX_V(p_accessor, state.accessors.size(), Vector<double>());
+
+ const GLTFAccessor &a = state.accessors[p_accessor];
+
+ int component_count_for_type[7] = {
+ 1, 2, 3, 4, 4, 9, 16
+ };
+
+ int component_count = component_count_for_type[a.type];
+ int component_size = _get_component_type_size(a.component_type);
+ ERR_FAIL_COND_V(component_size == 0, Vector<double>());
+ int element_size = component_count * component_size;
+
+ int skip_every = 0;
+ int skip_bytes = 0;
+ //special case of alignments, as described in spec
+ switch (a.component_type) {
+ case COMPONENT_TYPE_BYTE:
+ case COMPONENT_TYPE_UNSIGNED_BYTE: {
+
+ if (a.type == TYPE_MAT2) {
+ skip_every = 2;
+ skip_bytes = 2;
+ element_size = 8; //override for this case
+ }
+ if (a.type == TYPE_MAT3) {
+ skip_every = 3;
+ skip_bytes = 1;
+ element_size = 12; //override for this case
+ }
+
+ } break;
+ case COMPONENT_TYPE_SHORT:
+ case COMPONENT_TYPE_UNSIGNED_SHORT: {
+ if (a.type == TYPE_MAT3) {
+ skip_every = 6;
+ skip_bytes = 4;
+ element_size = 16; //override for this case
+ }
+ } break;
+ default: {}
+ }
+
+ Vector<double> dst_buffer;
+ dst_buffer.resize(component_count * a.count);
+ double *dst = dst_buffer.ptr();
+
+ if (a.buffer_view >= 0) {
+
+ ERR_FAIL_INDEX_V(a.buffer_view, state.buffer_views.size(), Vector<double>());
+
+ Error err = _decode_buffer_view(state, a.buffer_view, dst, skip_every, skip_bytes, element_size, a.count, a.type, component_count, a.component_type, component_size, a.normalized, a.byte_offset, p_for_vertex);
+ if (err != OK)
+ return Vector<double>();
+
+ } else {
+ //fill with zeros, as bufferview is not defined.
+ for (int i = 0; i < (a.count * component_count); i++) {
+ dst_buffer[i] = 0;
+ }
+ }
+
+ if (a.sparse_count > 0) {
+ // I could not find any file using this, so this code is so far untested
+ Vector<double> indices;
+ indices.resize(a.sparse_count);
+ int indices_component_size = _get_component_type_size(a.sparse_indices_component_type);
+
+ Error err = _decode_buffer_view(state, a.sparse_indices_buffer_view, indices.ptr(), 0, 0, indices_component_size, a.sparse_count, TYPE_SCALAR, 1, a.sparse_indices_component_type, indices_component_size, false, a.sparse_indices_byte_offset, false);
+ if (err != OK)
+ return Vector<double>();
+
+ Vector<double> data;
+ data.resize(component_count * a.sparse_count);
+ err = _decode_buffer_view(state, a.sparse_values_buffer_view, data.ptr(), skip_every, skip_bytes, element_size, a.sparse_count, a.type, component_count, a.component_type, component_size, a.normalized, a.sparse_values_byte_offset, p_for_vertex);
+ if (err != OK)
+ return Vector<double>();
+
+ for (int i = 0; i < indices.size(); i++) {
+ int write_offset = int(indices[i]) * component_count;
+
+ for (int j = 0; j < component_count; j++) {
+ dst[write_offset + j] = data[i * component_count + j];
+ }
+ }
+ }
+
+ return dst_buffer;
+}
+
+PoolVector<int> EditorSceneImporterGLTF::_decode_accessor_as_ints(GLTFState &state, int p_accessor, bool p_for_vertex) {
+
+ Vector<double> attribs = _decode_accessor(state, p_accessor, p_for_vertex);
+ PoolVector<int> ret;
+ if (attribs.size() == 0)
+ return ret;
+ const double *attribs_ptr = attribs.ptr();
+ int ret_size = attribs.size();
+ ret.resize(ret_size);
+ {
+ PoolVector<int>::Write w = ret.write();
+ for (int i = 0; i < ret_size; i++) {
+ w[i] = int(attribs_ptr[i]);
+ }
+ }
+ return ret;
+}
+
+PoolVector<float> EditorSceneImporterGLTF::_decode_accessor_as_floats(GLTFState &state, int p_accessor, bool p_for_vertex) {
+
+ Vector<double> attribs = _decode_accessor(state, p_accessor, p_for_vertex);
+ PoolVector<float> ret;
+ if (attribs.size() == 0)
+ return ret;
+ const double *attribs_ptr = attribs.ptr();
+ int ret_size = attribs.size();
+ ret.resize(ret_size);
+ {
+ PoolVector<float>::Write w = ret.write();
+ for (int i = 0; i < ret_size; i++) {
+ w[i] = float(attribs_ptr[i]);
+ }
+ }
+ return ret;
+}
+
+PoolVector<Vector2> EditorSceneImporterGLTF::_decode_accessor_as_vec2(GLTFState &state, int p_accessor, bool p_for_vertex) {
+
+ Vector<double> attribs = _decode_accessor(state, p_accessor, p_for_vertex);
+ PoolVector<Vector2> ret;
+ if (attribs.size() == 0)
+ return ret;
+ ERR_FAIL_COND_V(attribs.size() % 2 != 0, ret);
+ const double *attribs_ptr = attribs.ptr();
+ int ret_size = attribs.size() / 2;
+ ret.resize(ret_size);
+ {
+ PoolVector<Vector2>::Write w = ret.write();
+ for (int i = 0; i < ret_size; i++) {
+ w[i] = Vector2(attribs_ptr[i * 2 + 0], attribs_ptr[i * 2 + 1]);
+ }
+ }
+ return ret;
+}
+
+PoolVector<Vector3> EditorSceneImporterGLTF::_decode_accessor_as_vec3(GLTFState &state, int p_accessor, bool p_for_vertex) {
+
+ Vector<double> attribs = _decode_accessor(state, p_accessor, p_for_vertex);
+ PoolVector<Vector3> ret;
+ if (attribs.size() == 0)
+ return ret;
+ ERR_FAIL_COND_V(attribs.size() % 3 != 0, ret);
+ const double *attribs_ptr = attribs.ptr();
+ int ret_size = attribs.size() / 3;
+ ret.resize(ret_size);
+ {
+ PoolVector<Vector3>::Write w = ret.write();
+ for (int i = 0; i < ret_size; i++) {
+ w[i] = Vector3(attribs_ptr[i * 3 + 0], attribs_ptr[i * 3 + 1], attribs_ptr[i * 3 + 2]);
+ }
+ }
+ return ret;
+}
+PoolVector<Color> EditorSceneImporterGLTF::_decode_accessor_as_color(GLTFState &state, int p_accessor, bool p_for_vertex) {
+
+ Vector<double> attribs = _decode_accessor(state, p_accessor, p_for_vertex);
+ PoolVector<Color> ret;
+ if (attribs.size() == 0)
+ return ret;
+ ERR_FAIL_COND_V(attribs.size() % 4 != 0, ret);
+ const double *attribs_ptr = attribs.ptr();
+ int ret_size = attribs.size() / 4;
+ ret.resize(ret_size);
+ {
+ PoolVector<Color>::Write w = ret.write();
+ for (int i = 0; i < ret_size; i++) {
+ w[i] = Color(attribs_ptr[i * 4 + 0], attribs_ptr[i * 4 + 1], attribs_ptr[i * 4 + 2], attribs_ptr[i * 4 + 3]);
+ }
+ }
+ return ret;
+}
+Vector<Quat> EditorSceneImporterGLTF::_decode_accessor_as_quat(GLTFState &state, int p_accessor, bool p_for_vertex) {
+
+ Vector<double> attribs = _decode_accessor(state, p_accessor, p_for_vertex);
+ Vector<Quat> ret;
+ if (attribs.size() == 0)
+ return ret;
+ ERR_FAIL_COND_V(attribs.size() % 4 != 0, ret);
+ const double *attribs_ptr = attribs.ptr();
+ int ret_size = attribs.size() / 4;
+ ret.resize(ret_size);
+ {
+ for (int i = 0; i < ret_size; i++) {
+ ret[i] = Quat(attribs_ptr[i * 4 + 0], attribs_ptr[i * 4 + 1], attribs_ptr[i * 4 + 2], attribs_ptr[i * 4 + 3]);
+ }
+ }
+ return ret;
+}
+Vector<Transform2D> EditorSceneImporterGLTF::_decode_accessor_as_xform2d(GLTFState &state, int p_accessor, bool p_for_vertex) {
+
+ Vector<double> attribs = _decode_accessor(state, p_accessor, p_for_vertex);
+ Vector<Transform2D> ret;
+ if (attribs.size() == 0)
+ return ret;
+ ERR_FAIL_COND_V(attribs.size() % 4 != 0, ret);
+ ret.resize(attribs.size() / 4);
+ for (int i = 0; i < ret.size(); i++) {
+ ret[i][0] = Vector2(attribs[i * 4 + 0], attribs[i * 4 + 1]);
+ ret[i][1] = Vector2(attribs[i * 4 + 2], attribs[i * 4 + 3]);
+ }
+ return ret;
+}
+
+Vector<Basis> EditorSceneImporterGLTF::_decode_accessor_as_basis(GLTFState &state, int p_accessor, bool p_for_vertex) {
+
+ Vector<double> attribs = _decode_accessor(state, p_accessor, p_for_vertex);
+ Vector<Basis> ret;
+ if (attribs.size() == 0)
+ return ret;
+ ERR_FAIL_COND_V(attribs.size() % 9 != 0, ret);
+ ret.resize(attribs.size() / 9);
+ for (int i = 0; i < ret.size(); i++) {
+ ret[i].set_axis(0, Vector3(attribs[i * 9 + 0], attribs[i * 9 + 1], attribs[i * 9 + 2]));
+ ret[i].set_axis(1, Vector3(attribs[i * 9 + 3], attribs[i * 9 + 4], attribs[i * 9 + 5]));
+ ret[i].set_axis(2, Vector3(attribs[i * 9 + 6], attribs[i * 9 + 7], attribs[i * 9 + 8]));
+ }
+ return ret;
+}
+Vector<Transform> EditorSceneImporterGLTF::_decode_accessor_as_xform(GLTFState &state, int p_accessor, bool p_for_vertex) {
+
+ Vector<double> attribs = _decode_accessor(state, p_accessor, p_for_vertex);
+ Vector<Transform> ret;
+ if (attribs.size() == 0)
+ return ret;
+ ERR_FAIL_COND_V(attribs.size() % 16 != 0, ret);
+ ret.resize(attribs.size() / 16);
+ for (int i = 0; i < ret.size(); i++) {
+ ret[i].basis.set_axis(0, Vector3(attribs[i * 16 + 0], attribs[i * 16 + 1], attribs[i * 16 + 2]));
+ ret[i].basis.set_axis(1, Vector3(attribs[i * 16 + 4], attribs[i * 16 + 5], attribs[i * 16 + 6]));
+ ret[i].basis.set_axis(2, Vector3(attribs[i * 16 + 8], attribs[i * 16 + 9], attribs[i * 16 + 10]));
+ ret[i].set_origin(Vector3(attribs[i * 16 + 12], attribs[i * 16 + 13], attribs[i * 16 + 14]));
+ }
+ return ret;
+}
+
+Error EditorSceneImporterGLTF::_parse_meshes(GLTFState &state) {
+
+ if (!state.json.has("meshes"))
+ return OK;
+
+ Array meshes = state.json["meshes"];
+ for (int i = 0; i < meshes.size(); i++) {
+
+ Dictionary d = meshes[i];
+
+ GLTFMesh mesh;
+ mesh.mesh.instance();
+
+ ERR_FAIL_COND_V(!d.has("primitives"), ERR_PARSE_ERROR);
+
+ Array primitives = d["primitives"];
+
+ for (int j = 0; j < primitives.size(); j++) {
+
+ Dictionary p = primitives[j];
+
+ Array array;
+ array.resize(Mesh::ARRAY_MAX);
+
+ ERR_FAIL_COND_V(!p.has("attributes"), ERR_PARSE_ERROR);
+
+ Dictionary a = p["attributes"];
+
+ Mesh::PrimitiveType primitive = Mesh::PRIMITIVE_TRIANGLES;
+ if (p.has("mode")) {
+ int mode = p["mode"];
+ ERR_FAIL_INDEX_V(mode, 7, ERR_FILE_CORRUPT);
+ static const Mesh::PrimitiveType primitives[7] = {
+ Mesh::PRIMITIVE_POINTS,
+ Mesh::PRIMITIVE_LINES,
+ Mesh::PRIMITIVE_LINE_LOOP,
+ Mesh::PRIMITIVE_LINE_STRIP,
+ Mesh::PRIMITIVE_TRIANGLES,
+ Mesh::PRIMITIVE_TRIANGLE_STRIP,
+ Mesh::PRIMITIVE_TRIANGLE_FAN,
+ };
+
+ primitive = primitives[mode];
+ }
+
+ if (a.has("POSITION")) {
+ array[Mesh::ARRAY_VERTEX] = _decode_accessor_as_vec3(state, a["POSITION"], true);
+ }
+ if (a.has("NORMAL")) {
+ array[Mesh::ARRAY_NORMAL] = _decode_accessor_as_vec3(state, a["NORMAL"], true);
+ }
+ if (a.has("TANGENT")) {
+ array[Mesh::ARRAY_TANGENT] = _decode_accessor_as_floats(state, a["TANGENT"], true);
+ }
+ if (a.has("TEXCOORD_0")) {
+ array[Mesh::ARRAY_TEX_UV] = _decode_accessor_as_vec2(state, a["TEXCOORD_0"], true);
+ }
+ if (a.has("TEXCOORD_1")) {
+ array[Mesh::ARRAY_TEX_UV2] = _decode_accessor_as_vec2(state, a["TEXCOORD_1"], true);
+ }
+ if (a.has("COLOR_0")) {
+ array[Mesh::ARRAY_COLOR] = _decode_accessor_as_color(state, a["COLOR_0"], true);
+ }
+ if (a.has("JOINTS_0")) {
+ array[Mesh::ARRAY_BONES] = _decode_accessor_as_ints(state, a["JOINTS_0"], true);
+ }
+ if (a.has("WEIGHTS_0")) {
+ PoolVector<float> weights = _decode_accessor_as_floats(state, a["WEIGHTS_0"], true);
+ { //gltf does not seem to normalize the weights for some reason..
+ int wc = weights.size();
+ PoolVector<float>::Write w = weights.write();
+ for (int i = 0; i < wc; i += 4) {
+ float total = 0.0;
+ total += w[i + 0];
+ total += w[i + 1];
+ total += w[i + 2];
+ total += w[i + 3];
+ if (total > 0.0) {
+ w[i + 0] /= total;
+ w[i + 1] /= total;
+ w[i + 2] /= total;
+ w[i + 3] /= total;
+ }
+ }
+ }
+ array[Mesh::ARRAY_WEIGHTS] = weights;
+ }
+
+ if (p.has("indices")) {
+
+ PoolVector<int> indices = _decode_accessor_as_ints(state, p["indices"], false);
+
+ if (primitive == Mesh::PRIMITIVE_TRIANGLES) {
+ //swap around indices, convert ccw to cw for front face
+
+ int is = indices.size();
+ PoolVector<int>::Write w = indices.write();
+ for (int i = 0; i < is; i += 3) {
+ SWAP(w[i + 1], w[i + 2]);
+ }
+ }
+ array[Mesh::ARRAY_INDEX] = indices;
+ } else if (primitive == Mesh::PRIMITIVE_TRIANGLES) {
+ //generate indices because they need to be swapped for CW/CCW
+ PoolVector<Vector3> vertices = array[Mesh::ARRAY_VERTEX];
+ ERR_FAIL_COND_V(vertices.size() == 0, ERR_PARSE_ERROR);
+ PoolVector<int> indices;
+ int vs = vertices.size();
+ indices.resize(vs);
+ {
+ PoolVector<int>::Write w = indices.write();
+ for (int i = 0; i < vs; i += 3) {
+ w[i] = i;
+ w[i + 1] = i + 2;
+ w[i + 2] = i + 1;
+ }
+ }
+ array[Mesh::ARRAY_INDEX] = indices;
+ }
+
+ bool generated_tangents = false;
+ Variant erased_indices;
+
+ if (primitive == Mesh::PRIMITIVE_TRIANGLES && !a.has("TANGENT") && a.has("TEXCOORD_0") && a.has("NORMAL")) {
+ //must generate mikktspace tangents.. ergh..
+ Ref<SurfaceTool> st;
+ st.instance();
+ st->create_from_triangle_arrays(array);
+ if (p.has("targets")) {
+ //morph targets should not be reindexed, as array size might differ
+ //removing indices is the best bet here
+ st->deindex();
+ erased_indices = a[Mesh::ARRAY_INDEX];
+ a[Mesh::ARRAY_INDEX] = Variant();
+ }
+ st->generate_tangents();
+ array = st->commit_to_arrays();
+ generated_tangents = true;
+ }
+
+ Array morphs;
+ //blend shapes
+ if (p.has("targets")) {
+ print_line("has targets!");
+ Array targets = p["targets"];
+
+ if (j == 0) {
+ for (int k = 0; k < targets.size(); k++) {
+ mesh.mesh->add_blend_shape(String("morph_") + itos(k));
+ }
+ }
+
+ for (int k = 0; k < targets.size(); k++) {
+
+ Dictionary t = targets[k];
+
+ Array array_copy;
+ array_copy.resize(Mesh::ARRAY_MAX);
+
+ for (int l = 0; l < Mesh::ARRAY_MAX; l++) {
+ array_copy[l] = array[l];
+ }
+
+ array_copy[Mesh::ARRAY_INDEX] = Variant();
+
+ if (t.has("POSITION")) {
+ array_copy[Mesh::ARRAY_VERTEX] = _decode_accessor_as_vec3(state, t["POSITION"], true);
+ }
+ if (t.has("NORMAL")) {
+ array_copy[Mesh::ARRAY_NORMAL] = _decode_accessor_as_vec3(state, t["NORMAL"], true);
+ }
+ if (t.has("TANGENT")) {
+ PoolVector<Vector3> tangents_v3 = _decode_accessor_as_vec3(state, t["TANGENT"], true);
+ PoolVector<float> tangents_v4;
+ PoolVector<float> src_tangents = array[Mesh::ARRAY_TANGENT];
+ ERR_FAIL_COND_V(src_tangents.size() == 0, ERR_PARSE_ERROR);
+
+ {
+
+ int size4 = src_tangents.size();
+ tangents_v4.resize(size4);
+ PoolVector<float>::Write w4 = tangents_v4.write();
+
+ PoolVector<Vector3>::Read r3 = tangents_v3.read();
+ PoolVector<float>::Read r4 = src_tangents.read();
+
+ for (int l = 0; l < size4 / 4; l++) {
+
+ w4[l * 4 + 0] = r3[l].x;
+ w4[l * 4 + 1] = r3[l].y;
+ w4[l * 4 + 2] = r3[l].z;
+ w4[l * 4 + 3] = r4[l * 4 + 3]; //copy flip value
+ }
+ }
+
+ array_copy[Mesh::ARRAY_TANGENT] = tangents_v4;
+ }
+
+ if (generated_tangents) {
+ Ref<SurfaceTool> st;
+ st.instance();
+ array_copy[Mesh::ARRAY_INDEX] = erased_indices; //needed for tangent generation, erased by deindex
+ st->create_from_triangle_arrays(array_copy);
+ st->deindex();
+ st->generate_tangents();
+ array_copy = st->commit_to_arrays();
+ }
+
+ morphs.push_back(array_copy);
+ }
+ }
+
+ //just add it
+ mesh.mesh->add_surface_from_arrays(primitive, array, morphs);
+
+ if (p.has("material")) {
+ int material = p["material"];
+ ERR_FAIL_INDEX_V(material, state.materials.size(), ERR_FILE_CORRUPT);
+ Ref<Material> mat = state.materials[material];
+
+ mesh.mesh->surface_set_material(mesh.mesh->get_surface_count() - 1, mat);
+ }
+ }
+
+ if (d.has("weights")) {
+ Array weights = d["weights"];
+ ERR_FAIL_COND_V(mesh.mesh->get_blend_shape_count() != weights.size(), ERR_PARSE_ERROR);
+ mesh.blend_weights.resize(weights.size());
+ for (int j = 0; j < weights.size(); j++) {
+ mesh.blend_weights[j] = weights[j];
+ }
+ }
+
+ state.meshes.push_back(mesh);
+ }
+
+ print_line("total meshes: " + itos(state.meshes.size()));
+
+ return OK;
+}
+
+Error EditorSceneImporterGLTF::_parse_images(GLTFState &state, const String &p_base_path) {
+
+ if (!state.json.has("images"))
+ return OK;
+
+ Array images = state.json["images"];
+ for (int i = 0; i < images.size(); i++) {
+
+ Dictionary d = images[i];
+
+ String mimetype;
+ if (d.has("mimeType")) {
+ mimetype = d["mimeType"];
+ }
+
+ Vector<uint8_t> data;
+ const uint8_t *data_ptr = NULL;
+ int data_size = 0;
+
+ if (d.has("uri")) {
+ String uri = d["uri"];
+
+ if (uri.findn("data:application/octet-stream;base64") == 0) {
+ //embedded data
+ data = _parse_base64_uri(uri);
+ data_ptr = data.ptr();
+ data_size = data.size();
+ } else {
+
+ uri = p_base_path.plus_file(uri).replace("\\", "/"); //fix for windows
+ Ref<Texture> texture = ResourceLoader::load(uri);
+ state.images.push_back(texture);
+ continue;
+ }
+ }
+
+ if (d.has("bufferView")) {
+ int bvi = d["bufferView"];
+
+ ERR_FAIL_INDEX_V(bvi, state.buffer_views.size(), ERR_PARAMETER_RANGE_ERROR);
+
+ GLTFBufferView &bv = state.buffer_views[bvi];
+
+ int bi = bv.buffer;
+ ERR_FAIL_INDEX_V(bi, state.buffers.size(), ERR_PARAMETER_RANGE_ERROR);
+
+ ERR_FAIL_COND_V(bv.byte_offset + bv.byte_length > state.buffers[bi].size(), ERR_FILE_CORRUPT);
+
+ data_ptr = &state.buffers[bi][bv.byte_offset];
+ data_size = bv.byte_length;
+ }
+
+ ERR_FAIL_COND_V(mimetype == "", ERR_FILE_CORRUPT);
+
+ if (mimetype.findn("png") != -1) {
+ //is a png
+ Ref<Image> img = Image::_png_mem_loader_func(data_ptr, data_size);
+
+ ERR_FAIL_COND_V(img.is_null(), ERR_FILE_CORRUPT);
+
+ Ref<ImageTexture> t;
+ t.instance();
+ t->create_from_image(img);
+
+ state.images.push_back(t);
+ continue;
+ }
+
+ if (mimetype.findn("jpg") != -1) {
+ //is a jpg
+ Ref<Image> img = Image::_jpg_mem_loader_func(data_ptr, data_size);
+
+ ERR_FAIL_COND_V(img.is_null(), ERR_FILE_CORRUPT);
+
+ Ref<ImageTexture> t;
+ t.instance();
+ t->create_from_image(img);
+
+ state.images.push_back(t);
+
+ continue;
+ }
+
+ ERR_FAIL_V(ERR_FILE_CORRUPT);
+ }
+
+ print_line("total images: " + itos(state.images.size()));
+
+ return OK;
+}
+
+Error EditorSceneImporterGLTF::_parse_textures(GLTFState &state) {
+
+ if (!state.json.has("textures"))
+ return OK;
+
+ Array textures = state.json["textures"];
+ for (int i = 0; i < textures.size(); i++) {
+
+ Dictionary d = textures[i];
+
+ ERR_FAIL_COND_V(!d.has("source"), ERR_PARSE_ERROR);
+
+ GLTFTexture t;
+ t.src_image = d["source"];
+ state.textures.push_back(t);
+ }
+
+ return OK;
+}
+
+Ref<Texture> EditorSceneImporterGLTF::_get_texture(GLTFState &state, int p_texture) {
+ ERR_FAIL_INDEX_V(p_texture, state.textures.size(), Ref<Texture>());
+ int image = state.textures[p_texture].src_image;
+
+ ERR_FAIL_INDEX_V(image, state.images.size(), Ref<Texture>());
+
+ return state.images[image];
+}
+
+Error EditorSceneImporterGLTF::_parse_materials(GLTFState &state) {
+
+ if (!state.json.has("materials"))
+ return OK;
+
+ Array materials = state.json["materials"];
+ for (int i = 0; i < materials.size(); i++) {
+
+ Dictionary d = materials[i];
+
+ Ref<SpatialMaterial> material;
+ material.instance();
+ if (d.has("name")) {
+ material->set_name(d["name"]);
+ }
+
+ if (d.has("pbrMetallicRoughness")) {
+
+ Dictionary mr = d["pbrMetallicRoughness"];
+ if (mr.has("baseColorFactor")) {
+ Array arr = mr["baseColorFactor"];
+ ERR_FAIL_COND_V(arr.size() != 4, ERR_PARSE_ERROR);
+ Color c = Color(arr[0], arr[1], arr[2], arr[3]).to_srgb();
+
+ material->set_albedo(c);
+ }
+
+ if (mr.has("baseColorTexture")) {
+ Dictionary bct = mr["baseColorTexture"];
+ if (bct.has("index")) {
+ material->set_texture(SpatialMaterial::TEXTURE_ALBEDO, _get_texture(state, bct["index"]));
+ }
+ if (!mr.has("baseColorFactor")) {
+ material->set_albedo(Color(1, 1, 1));
+ }
+ }
+
+ if (mr.has("metallicFactor")) {
+
+ material->set_metallic(mr["metallicFactor"]);
+ }
+ if (mr.has("roughnessFactor")) {
+
+ material->set_roughness(mr["roughnessFactor"]);
+ }
+
+ if (mr.has("metallicRoughnessTexture")) {
+ Dictionary bct = mr["metallicRoughnessTexture"];
+ if (bct.has("index")) {
+ Ref<Texture> t = _get_texture(state, bct["index"]);
+ material->set_texture(SpatialMaterial::TEXTURE_METALLIC, t);
+ material->set_metallic_texture_channel(SpatialMaterial::TEXTURE_CHANNEL_RED);
+ material->set_texture(SpatialMaterial::TEXTURE_ROUGHNESS, t);
+ material->set_roughness_texture_channel(SpatialMaterial::TEXTURE_CHANNEL_GREEN);
+ if (!mr.has("metallicFactor")) {
+ material->set_metallic(1);
+ }
+ if (!mr.has("roughnessFactor")) {
+ material->set_roughness(1);
+ }
+ }
+ }
+ }
+
+ if (d.has("normalTexture")) {
+ Dictionary bct = d["normalTexture"];
+ if (bct.has("index")) {
+ material->set_texture(SpatialMaterial::TEXTURE_NORMAL, _get_texture(state, bct["index"]));
+ material->set_feature(SpatialMaterial::FEATURE_NORMAL_MAPPING, true);
+ }
+ if (bct.has("scale")) {
+ material->set_normal_scale(bct["scale"]);
+ }
+ }
+ if (d.has("occlusionTexture")) {
+ Dictionary bct = d["occlusionTexture"];
+ if (bct.has("index")) {
+ material->set_texture(SpatialMaterial::TEXTURE_AMBIENT_OCCLUSION, _get_texture(state, bct["index"]));
+ material->set_feature(SpatialMaterial::FEATURE_AMBIENT_OCCLUSION, true);
+ }
+ }
+
+ if (d.has("emissiveFactor")) {
+ Array arr = d["emissiveFactor"];
+ ERR_FAIL_COND_V(arr.size() != 3, ERR_PARSE_ERROR);
+ Color c = Color(arr[0], arr[1], arr[2]).to_srgb();
+ material->set_feature(SpatialMaterial::FEATURE_EMISSION, true);
+
+ material->set_emission(c);
+ }
+
+ if (d.has("emissiveTexture")) {
+ Dictionary bct = d["emissiveTexture"];
+ if (bct.has("index")) {
+ material->set_texture(SpatialMaterial::TEXTURE_EMISSION, _get_texture(state, bct["index"]));
+ material->set_feature(SpatialMaterial::FEATURE_EMISSION, true);
+ material->set_emission(Color(0, 0, 0));
+ }
+ }
+
+ if (d.has("doubleSided")) {
+ bool ds = d["doubleSided"];
+ if (ds) {
+ material->set_cull_mode(SpatialMaterial::CULL_DISABLED);
+ }
+ }
+
+ if (d.has("alphaMode")) {
+ String am = d["alphaMode"];
+ if (am != "OPAQUE") {
+ material->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
+ }
+ }
+
+ state.materials.push_back(material);
+ }
+
+ print_line("total materials: " + itos(state.materials.size()));
+
+ return OK;
+}
+
+Error EditorSceneImporterGLTF::_parse_skins(GLTFState &state) {
+
+ if (!state.json.has("skins"))
+ return OK;
+
+ Array skins = state.json["skins"];
+ for (int i = 0; i < skins.size(); i++) {
+
+ Dictionary d = skins[i];
+
+ GLTFSkin skin;
+
+ ERR_FAIL_COND_V(!d.has("joints"), ERR_PARSE_ERROR);
+
+ Array joints = d["joints"];
+ Vector<Transform> bind_matrices;
+
+ if (d.has("inverseBindMatrices")) {
+ bind_matrices = _decode_accessor_as_xform(state, d["inverseBindMatrices"], false);
+ ERR_FAIL_COND_V(bind_matrices.size() != joints.size(), ERR_PARSE_ERROR);
+ }
+
+ for (int j = 0; j < joints.size(); j++) {
+ int index = joints[j];
+ ERR_FAIL_INDEX_V(index, state.nodes.size(), ERR_PARSE_ERROR);
+ state.nodes[index]->joint_skin = state.skins.size();
+ state.nodes[index]->joint_bone = j;
+ GLTFSkin::Bone bone;
+ bone.node = index;
+ if (bind_matrices.size()) {
+ bone.inverse_bind = bind_matrices[j];
+ }
+
+ skin.bones.push_back(bone);
+ }
+
+ print_line("skin has skeleton? " + itos(d.has("skeleton")));
+ if (d.has("skeleton")) {
+ int skeleton = d["skeleton"];
+ ERR_FAIL_INDEX_V(skeleton, state.nodes.size(), ERR_PARSE_ERROR);
+ state.nodes[skeleton]->skeleton_skin = state.skins.size();
+ print_line("setting skeleton skin to" + itos(skeleton));
+ skin.skeleton = skeleton;
+ }
+
+ if (d.has("name")) {
+ skin.name = d["name"];
+ }
+
+ //locate the right place to put a Skeleton node
+
+ if (state.skin_users.has(i)) {
+ Vector<int> users = state.skin_users[i];
+ int skin_node = -1;
+ for (int j = 0; j < users.size(); j++) {
+ int user = state.nodes[users[j]]->parent; //always go from parent
+ if (j == 0) {
+ skin_node = user;
+ } else if (skin_node != -1) {
+ bool found = false;
+ while (skin_node >= 0) {
+
+ int cuser = user;
+ while (cuser != -1) {
+ if (cuser == skin_node) {
+ found = true;
+ break;
+ }
+ cuser = state.nodes[skin_node]->parent;
+ }
+ if (found)
+ break;
+ skin_node = state.nodes[skin_node]->parent;
+ }
+
+ if (!found) {
+ skin_node = -1; //just leave where it is
+ }
+
+ //find a common parent
+ }
+ }
+
+ if (skin_node != -1) {
+ for (int j = 0; j < users.size(); j++) {
+ state.nodes[users[j]]->child_of_skeleton = i;
+ }
+
+ state.nodes[skin_node]->skeleton_children.push_back(i);
+ }
+ state.skins.push_back(skin);
+ }
+ }
+ print_line("total skins: " + itos(state.skins.size()));
+
+ //now
+
+ return OK;
+}
+
+Error EditorSceneImporterGLTF::_parse_cameras(GLTFState &state) {
+
+ if (!state.json.has("cameras"))
+ return OK;
+
+ Array cameras = state.json["cameras"];
+
+ for (int i = 0; i < cameras.size(); i++) {
+
+ Dictionary d = cameras[i];
+
+ GLTFCamera camera;
+ ERR_FAIL_COND_V(!d.has("type"), ERR_PARSE_ERROR);
+ String type = d["type"];
+ if (type == "orthographic") {
+
+ camera.perspective = false;
+ if (d.has("orthographic")) {
+ Dictionary og = d["orthographic"];
+ camera.fov_size = og["ymag"];
+ camera.zfar = og["zfar"];
+ camera.znear = og["znear"];
+ } else {
+ camera.fov_size = 10;
+ }
+
+ } else if (type == "perspective") {
+
+ camera.perspective = true;
+ if (d.has("perspective")) {
+ Dictionary ppt = d["perspective"];
+ camera.fov_size = ppt["yfov"];
+ camera.zfar = ppt["zfar"];
+ camera.znear = ppt["znear"];
+ } else {
+ camera.fov_size = 10;
+ }
+ } else {
+ ERR_EXPLAIN("Camera should be in 'orthographic' or 'perspective'");
+ ERR_FAIL_V(ERR_PARSE_ERROR);
+ }
+
+ state.cameras.push_back(camera);
+ }
+
+ print_line("total cameras: " + itos(state.cameras.size()));
+}
+
+Error EditorSceneImporterGLTF::_parse_animations(GLTFState &state) {
+
+ if (!state.json.has("animations"))
+ return OK;
+
+ Array animations = state.json["animations"];
+
+ for (int i = 0; i < animations.size(); i++) {
+
+ Dictionary d = animations[i];
+
+ GLTFAnimation animation;
+
+ if (!d.has("channels") || !d.has("samplers"))
+ continue;
+
+ Array channels = d["channels"];
+ Array samplers = d["samplers"];
+
+ if (d.has("name")) {
+ animation.name = d["name"];
+ }
+
+ for (int j = 0; j < channels.size(); j++) {
+
+ Dictionary c = channels[j];
+ if (!c.has("target"))
+ continue;
+
+ Dictionary t = c["target"];
+ if (!t.has("node") || !t.has("path")) {
+ continue;
+ }
+
+ ERR_FAIL_COND_V(!c.has("sampler"), ERR_PARSE_ERROR);
+ int sampler = c["sampler"];
+ ERR_FAIL_INDEX_V(sampler, samplers.size(), ERR_PARSE_ERROR);
+
+ int node = t["node"];
+ String path = t["path"];
+
+ ERR_FAIL_INDEX_V(node, state.nodes.size(), ERR_PARSE_ERROR);
+
+ GLTFAnimation::Track *track = NULL;
+
+ if (!animation.tracks.has(node)) {
+ animation.tracks[node] = GLTFAnimation::Track();
+ }
+
+ track = &animation.tracks[node];
+
+ Dictionary s = samplers[sampler];
+
+ ERR_FAIL_COND_V(!s.has("input"), ERR_PARSE_ERROR);
+ ERR_FAIL_COND_V(!s.has("output"), ERR_PARSE_ERROR);
+
+ int input = s["input"];
+ int output = s["output"];
+
+ GLTFAnimation::Interpolation interp = GLTFAnimation::INTERP_LINEAR;
+ if (s.has("interpolation")) {
+ String in = s["interpolation"];
+ if (in == "STEP") {
+ interp = GLTFAnimation::INTERP_STEP;
+ } else if (in == "LINEAR") {
+ interp = GLTFAnimation::INTERP_LINEAR;
+ } else if (in == "CATMULLROMSPLINE") {
+ interp = GLTFAnimation::INTERP_CATMULLROMSPLINE;
+ } else if (in == "CUBICSPLINE") {
+ interp = GLTFAnimation::INTERP_CUBIC_SPLINE;
+ }
+ }
+
+ print_line("path: " + path);
+ PoolVector<float> times = _decode_accessor_as_floats(state, input, false);
+ if (path == "translation") {
+ PoolVector<Vector3> translations = _decode_accessor_as_vec3(state, output, false);
+ track->translation_track.interpolation = interp;
+ track->translation_track.times = Variant(times); //convert via variant
+ track->translation_track.values = Variant(translations); //convert via variant
+ } else if (path == "rotation") {
+ Vector<Quat> rotations = _decode_accessor_as_quat(state, output, false);
+ track->rotation_track.interpolation = interp;
+ track->rotation_track.times = Variant(times); //convert via variant
+ track->rotation_track.values = rotations; //convert via variant
+ } else if (path == "scale") {
+ PoolVector<Vector3> scales = _decode_accessor_as_vec3(state, output, false);
+ track->scale_track.interpolation = interp;
+ track->scale_track.times = Variant(times); //convert via variant
+ track->scale_track.values = Variant(scales); //convert via variant
+ } else if (path == "weights") {
+ PoolVector<float> weights = _decode_accessor_as_floats(state, output, false);
+
+ ERR_FAIL_INDEX_V(state.nodes[node]->mesh, state.meshes.size(), ERR_PARSE_ERROR);
+ GLTFMesh *mesh = &state.meshes[state.nodes[node]->mesh];
+ ERR_FAIL_COND_V(mesh->blend_weights.size() == 0, ERR_PARSE_ERROR);
+ int wc = mesh->blend_weights.size();
+
+ track->weight_tracks.resize(wc);
+
+ int wlen = weights.size() / wc;
+ PoolVector<float>::Read r = weights.read();
+ for (int k = 0; k < wc; k++) { //separate tracks, having them together is not such a good idea
+ GLTFAnimation::Channel<float> cf;
+ cf.interpolation = interp;
+ cf.times = Variant(times);
+ Vector<float> wdata;
+ wdata.resize(wlen);
+ for (int l = 0; l < wlen; l++) {
+ wdata[l] = r[l * wc + k];
+ }
+
+ cf.values = wdata;
+ track->weight_tracks[k] = cf;
+ }
+ } else {
+ WARN_PRINTS("Invalid path: " + path);
+ }
+ }
+
+ state.animations.push_back(animation);
+ }
+
+ print_line("total animations: " + itos(state.animations.size()));
+
+ return OK;
+}
+
+void EditorSceneImporterGLTF::_assign_scene_names(GLTFState &state) {
+
+ for (int i = 0; i < state.nodes.size(); i++) {
+ GLTFNode *n = state.nodes[i];
+ if (n->name == "") {
+ if (n->mesh >= 0) {
+ n->name = "Mesh";
+ } else if (n->joint_skin >= 0) {
+ n->name = "Bone";
+ } else {
+ n->name = "Node";
+ }
+ }
+
+ n->name = _gen_unique_name(state, n->name);
+ }
+}
+
+void EditorSceneImporterGLTF::_generate_node(GLTFState &state, int p_node, Node *p_parent, Node *p_owner, Vector<Skeleton *> &skeletons) {
+ ERR_FAIL_INDEX(p_node, state.nodes.size());
+
+ GLTFNode *n = state.nodes[p_node];
+ Spatial *node;
+
+ if (n->mesh >= 0) {
+ ERR_FAIL_INDEX(n->mesh, state.meshes.size());
+ MeshInstance *mi = memnew(MeshInstance);
+ const GLTFMesh &mesh = state.meshes[n->mesh];
+ mi->set_mesh(mesh.mesh);
+ for (int i = 0; i < mesh.blend_weights.size(); i++) {
+ mi->set("blend_shapes/" + mesh.mesh->get_blend_shape_name(i), mesh.blend_weights[i]);
+ }
+
+ node = mi;
+ } else if (n->camera >= 0) {
+ ERR_FAIL_INDEX(n->camera, state.cameras.size());
+ Camera *camera = memnew(Camera);
+
+ const GLTFCamera &c = state.cameras[n->camera];
+ if (c.perspective) {
+ camera->set_perspective(c.fov_size, c.znear, c.znear);
+ } else {
+ camera->set_orthogonal(c.fov_size, c.znear, c.znear);
+ }
+
+ node = camera;
+ } else {
+ node = memnew(Spatial);
+ }
+
+ node->set_name(n->name);
+
+ if (n->child_of_skeleton >= 0) {
+ //move skeleton around and place it on node, as the node _is_ a skeleton.
+ Skeleton *s = skeletons[n->child_of_skeleton];
+ p_parent = s;
+ }
+
+ p_parent->add_child(node);
+ node->set_owner(p_owner);
+ node->set_transform(n->xform);
+
+ n->godot_node = node;
+
+ for (int i = 0; i < n->skeleton_children.size(); i++) {
+
+ Skeleton *s = skeletons[n->skeleton_children[i]];
+ s->get_parent()->remove_child(s);
+ node->add_child(s);
+ s->set_owner(p_owner);
+ }
+
+ for (int i = 0; i < n->children.size(); i++) {
+ if (state.nodes[n->children[i]]->joint_skin >= 0) {
+ _generate_bone(state, n->children[i], skeletons, -1);
+ } else {
+ _generate_node(state, n->children[i], node, p_owner, skeletons);
+ }
+ }
+}
+
+void EditorSceneImporterGLTF::_generate_bone(GLTFState &state, int p_node, Vector<Skeleton *> &skeletons, int p_parent_bone) {
+ ERR_FAIL_INDEX(p_node, state.nodes.size());
+
+ GLTFNode *n = state.nodes[p_node];
+
+ ERR_FAIL_COND(n->joint_skin < 0);
+
+ int bone_index = skeletons[n->joint_skin]->get_bone_count();
+ skeletons[n->joint_skin]->add_bone(n->name);
+ if (p_parent_bone >= 0) {
+ skeletons[n->joint_skin]->set_bone_parent(bone_index, p_parent_bone);
+ }
+ skeletons[n->joint_skin]->set_bone_rest(bone_index, state.skins[n->joint_skin].bones[n->joint_bone].inverse_bind.affine_inverse());
+
+ n->godot_node = skeletons[n->joint_skin];
+ n->godot_bone_index = bone_index;
+
+ for (int i = 0; i < n->children.size(); i++) {
+ ERR_CONTINUE(state.nodes[n->children[i]]->joint_skin < 0);
+ _generate_bone(state, n->children[i], skeletons, bone_index);
+ }
+}
+
+template <class T>
+struct EditorSceneImporterGLTFInterpolate {
+
+ T lerp(const T &a, const T &b, float c) const {
+
+ return a + (b - a) * c;
+ }
+
+ T catmull_rom(const T &p0, const T &p1, const T &p2, const T &p3, float t) {
+
+ float t2 = t * t;
+ float t3 = t2 * t;
+
+ return 0.5f * ((2.0f * p1) + (-p0 + p2) * t + (2.0f * p0 - 5.0f * p1 + 4 * p2 - p3) * t2 + (-p0 + 3.0f * p1 - 3.0f * p2 + p3) * t3);
+ }
+
+ T bezier(T start, T control_1, T control_2, T end, float t) {
+ /* Formula from Wikipedia article on Bezier curves. */
+ real_t omt = (1.0 - t);
+ real_t omt2 = omt * omt;
+ real_t omt3 = omt2 * omt;
+ real_t t2 = t * t;
+ real_t t3 = t2 * t;
+
+ return start * omt3 + control_1 * omt2 * t * 3.0 + control_2 * omt * t2 * 3.0 + end * t3;
+ }
+};
+
+//thank you for existing, partial specialization
+template <>
+struct EditorSceneImporterGLTFInterpolate<Quat> {
+
+ Quat lerp(const Quat &a, const Quat &b, float c) const {
+
+ return a.slerp(b, c);
+ }
+
+ Quat catmull_rom(const Quat &p0, const Quat &p1, const Quat &p2, const Quat &p3, float c) {
+
+ return p1.slerp(p2, c);
+ }
+
+ Quat bezier(Quat start, Quat control_1, Quat control_2, Quat end, float t) {
+ return start.slerp(end, t);
+ }
+};
+
+template <class T>
+T EditorSceneImporterGLTF::_interpolate_track(const Vector<float> &p_times, const Vector<T> &p_values, float p_time, GLTFAnimation::Interpolation p_interp) {
+
+ //could use binary search, worth it?
+ int idx = -1;
+ for (int i = 0; i < p_times.size(); i++) {
+ if (p_times[i] > p_time)
+ break;
+ idx++;
+ }
+
+ EditorSceneImporterGLTFInterpolate<T> interp;
+
+ switch (p_interp) {
+ case GLTFAnimation::INTERP_LINEAR: {
+
+ if (idx == -1) {
+ return p_values[0];
+ } else if (idx >= p_times.size() - 1) {
+ return p_values[p_times.size() - 1];
+ }
+
+ float c = (p_time - p_times[idx]) / (p_times[idx + 1] - p_times[idx]);
+
+ return interp.lerp(p_values[idx], p_values[idx + 1], c);
+
+ } break;
+ case GLTFAnimation::INTERP_STEP: {
+
+ if (idx == -1) {
+ return p_values[0];
+ } else if (idx >= p_times.size() - 1) {
+ return p_values[p_times.size() - 1];
+ }
+
+ return p_values[idx];
+
+ } break;
+ case GLTFAnimation::INTERP_CATMULLROMSPLINE: {
+
+ if (idx == -1) {
+ return p_values[1];
+ } else if (idx >= p_times.size() - 1) {
+ return p_values[1 + p_times.size() - 1];
+ }
+
+ float c = (p_time - p_times[idx]) / (p_times[idx + 1] - p_times[idx]);
+
+ return interp.catmull_rom(p_values[idx - 1], p_values[idx], p_values[idx + 1], p_values[idx + 3], c);
+
+ } break;
+ case GLTFAnimation::INTERP_CUBIC_SPLINE: {
+
+ if (idx == -1) {
+ return p_values[1];
+ } else if (idx >= p_times.size() - 1) {
+ return p_values[(p_times.size() - 1) * 3 + 1];
+ }
+
+ float c = (p_time - p_times[idx]) / (p_times[idx + 1] - p_times[idx]);
+
+ T from = p_values[idx * 3 + 1];
+ T c1 = from + p_values[idx * 3 + 0];
+ T to = p_values[idx * 3 + 3];
+ T c2 = to + p_values[idx * 3 + 2];
+
+ return interp.bezier(from, c1, c2, to, c);
+
+ } break;
+ }
+
+ ERR_FAIL_V(p_values[0]);
+}
+
+void EditorSceneImporterGLTF::_import_animation(GLTFState &state, AnimationPlayer *ap, int index, int bake_fps, Vector<Skeleton *> skeletons) {
+
+ const GLTFAnimation &anim = state.animations[index];
+
+ String name = anim.name;
+ if (name == "") {
+ name = _gen_unique_name(state, "Animation");
+ }
+
+ Ref<Animation> animation;
+ animation.instance();
+ animation->set_name(name);
+
+ for (Map<int, GLTFAnimation::Track>::Element *E = anim.tracks.front(); E; E = E->next()) {
+
+ const GLTFAnimation::Track &track = E->get();
+ //need to find the path
+ NodePath node_path;
+
+ GLTFNode *node = state.nodes[E->key()];
+ ERR_CONTINUE(!node->godot_node);
+
+ if (node->godot_bone_index >= 0) {
+ Skeleton *sk = (Skeleton *)node->godot_node;
+ String path = ap->get_parent()->get_path_to(sk);
+ String bone = sk->get_bone_name(node->godot_bone_index);
+ node_path = path + ":" + bone;
+ } else {
+ node_path = ap->get_parent()->get_path_to(node->godot_node);
+ }
+
+ float length = 0;
+
+ for (int i = 0; i < track.rotation_track.times.size(); i++) {
+ length = MAX(length, track.rotation_track.times[i]);
+ }
+ for (int i = 0; i < track.translation_track.times.size(); i++) {
+ length = MAX(length, track.translation_track.times[i]);
+ }
+ for (int i = 0; i < track.scale_track.times.size(); i++) {
+ length = MAX(length, track.scale_track.times[i]);
+ }
+
+ for (int i = 0; i < track.weight_tracks.size(); i++) {
+ for (int j = 0; j < track.weight_tracks[i].times.size(); j++) {
+ length = MAX(length, track.weight_tracks[i].times[j]);
+ }
+ }
+
+ animation->set_length(length);
+
+ if (track.rotation_track.values.size() || track.translation_track.values.size() || track.scale_track.values.size()) {
+ //make transform track
+ int track_idx = animation->get_track_count();
+ animation->add_track(Animation::TYPE_TRANSFORM);
+ animation->track_set_path(track_idx, node_path);
+ //first determine animation length
+
+ float increment = 1.0 / float(bake_fps);
+ float time = 0.0;
+
+ Vector3 base_pos;
+ Quat base_rot;
+ Vector3 base_scale = Vector3(1, 1, 1);
+
+ if (!track.rotation_track.values.size()) {
+ base_rot = state.nodes[E->key()]->rotation;
+ }
+
+ if (!track.translation_track.values.size()) {
+ base_pos = state.nodes[E->key()]->translation;
+ }
+
+ if (!track.scale_track.values.size()) {
+ base_scale = state.nodes[E->key()]->scale;
+ }
+
+ bool last = false;
+ while (true) {
+
+ Vector3 pos = base_pos;
+ Quat rot = base_rot;
+ Vector3 scale = base_scale;
+
+ if (track.translation_track.times.size()) {
+
+ pos = _interpolate_track<Vector3>(track.translation_track.times, track.translation_track.values, time, track.translation_track.interpolation);
+ }
+
+ if (track.rotation_track.times.size()) {
+
+ rot = _interpolate_track<Quat>(track.rotation_track.times, track.rotation_track.values, time, track.rotation_track.interpolation);
+ }
+
+ if (track.scale_track.times.size()) {
+
+ scale = _interpolate_track<Vector3>(track.scale_track.times, track.scale_track.values, time, track.scale_track.interpolation);
+ }
+
+ if (node->godot_bone_index >= 0) {
+
+ Transform xform;
+ xform.basis = Basis(rot);
+ xform.basis.scale(scale);
+ xform.origin = pos;
+
+ Skeleton *skeleton = skeletons[node->joint_skin];
+ int bone = node->godot_bone_index;
+ xform = skeleton->get_bone_rest(bone).affine_inverse() * xform;
+
+ rot = xform.basis;
+ rot.normalize();
+ scale = xform.basis.get_scale();
+ pos = xform.origin;
+ }
+
+ animation->transform_track_insert_key(track_idx, time, pos, rot, scale);
+
+ if (last) {
+ break;
+ }
+ time += increment;
+ if (time >= length) {
+ last = true;
+ time = length;
+ }
+ }
+ }
+
+ for (int i = 0; i < track.weight_tracks.size(); i++) {
+ ERR_CONTINUE(node->mesh < 0 || node->mesh >= state.meshes.size());
+ const GLTFMesh &mesh = state.meshes[node->mesh];
+ String prop = "blend_shapes/" + mesh.mesh->get_blend_shape_name(i);
+ node_path = String(node_path) + ":" + prop;
+
+ int track_idx = animation->get_track_count();
+ animation->add_track(Animation::TYPE_VALUE);
+ animation->track_set_path(track_idx, node_path);
+
+ if (track.weight_tracks[i].interpolation <= GLTFAnimation::INTERP_STEP) {
+ animation->track_set_interpolation_type(track_idx, track.weight_tracks[i].interpolation == GLTFAnimation::INTERP_STEP ? Animation::INTERPOLATION_NEAREST : Animation::INTERPOLATION_NEAREST);
+ for (int j = 0; j < track.weight_tracks[i].times.size(); j++) {
+ float t = track.weight_tracks[i].times[j];
+ float w = track.weight_tracks[i].values[j];
+ animation->track_insert_key(track_idx, t, w);
+ }
+ } else {
+ //must bake, apologies.
+ float increment = 1.0 / float(bake_fps);
+ float time = 0.0;
+
+ bool last = false;
+ while (true) {
+
+ float value = _interpolate_track<float>(track.weight_tracks[i].times, track.weight_tracks[i].values, time, track.weight_tracks[i].interpolation);
+ if (last) {
+ break;
+ }
+ time += increment;
+ if (time >= length) {
+ last = true;
+ time = length;
+ }
+ }
+ }
+ }
+ }
+
+ ap->add_animation(name, animation);
+}
+
+Spatial *EditorSceneImporterGLTF::_generate_scene(GLTFState &state, int p_bake_fps) {
+
+ Spatial *root = memnew(Spatial);
+ root->set_name(state.scene_name);
+ //generate skeletons
+ Vector<Skeleton *> skeletons;
+ for (int i = 0; i < state.skins.size(); i++) {
+ Skeleton *s = memnew(Skeleton);
+ String name = state.skins[i].name;
+ if (name == "") {
+ name = _gen_unique_name(state, "Skeleton");
+ }
+ s->set_name(name);
+ root->add_child(s);
+ s->set_owner(root);
+ skeletons.push_back(s);
+ }
+ for (int i = 0; i < state.root_nodes.size(); i++) {
+ if (state.nodes[state.root_nodes[i]]->joint_skin >= 0) {
+ _generate_bone(state, state.root_nodes[i], skeletons, -1);
+ } else {
+ _generate_node(state, state.root_nodes[i], root, root, skeletons);
+ }
+ }
+
+ for (int i = 0; i < skeletons.size(); i++) {
+ skeletons[i]->localize_rests();
+ }
+
+ if (state.animations.size()) {
+ AnimationPlayer *ap = memnew(AnimationPlayer);
+ ap->set_name("AnimationPlayer");
+ root->add_child(ap);
+ ap->set_owner(root);
+
+ for (int i = 0; i < state.animations.size(); i++) {
+ _import_animation(state, ap, i, p_bake_fps, skeletons);
+ }
+ }
+
+ return root;
+}
+
+Node *EditorSceneImporterGLTF::import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps, Error *r_err) {
+
+ GLTFState state;
+
+ if (p_path.to_lower().ends_with("glb")) {
+ //binary file
+ //text file
+ Error err = _parse_glb(p_path, state);
+ if (err)
+ return NULL;
+ } else {
+ //text file
+ Error err = _parse_json(p_path, state);
+ if (err)
+ return NULL;
+ }
+
+ ERR_FAIL_COND_V(!state.json.has("asset"), NULL);
+
+ Dictionary asset = state.json["asset"];
+
+ ERR_FAIL_COND_V(!asset.has("version"), NULL);
+
+ String version = asset["version"];
+
+ state.major_version = version.get_slice(".", 0).to_int();
+ state.minor_version = version.get_slice(".", 1).to_int();
+
+ /* STEP 0 PARSE SCENE */
+ Error err = _parse_scenes(state);
+ if (err != OK)
+ return NULL;
+
+ /* STEP 1 PARSE NODES */
+ err = _parse_nodes(state);
+ if (err != OK)
+ return NULL;
+
+ /* STEP 2 PARSE BUFFERS */
+ err = _parse_buffers(state, p_path.get_base_dir());
+ if (err != OK)
+ return NULL;
+
+ /* STEP 3 PARSE BUFFER VIEWS */
+ err = _parse_buffer_views(state);
+ if (err != OK)
+ return NULL;
+
+ /* STEP 4 PARSE ACCESSORS */
+ err = _parse_accessors(state);
+ if (err != OK)
+ return NULL;
+
+ /* STEP 5 PARSE IMAGES */
+ err = _parse_images(state, p_path.get_base_dir());
+ if (err != OK)
+ return NULL;
+
+ /* STEP 6 PARSE TEXTURES */
+ err = _parse_textures(state);
+ if (err != OK)
+ return NULL;
+
+ /* STEP 7 PARSE TEXTURES */
+ err = _parse_materials(state);
+ if (err != OK)
+ return NULL;
+
+ /* STEP 8 PARSE MESHES (we have enough info now) */
+ err = _parse_meshes(state);
+ if (err != OK)
+ return NULL;
+
+ /* STEP 9 PARSE SKINS */
+ err = _parse_skins(state);
+ if (err != OK)
+ return NULL;
+
+ /* STEP 10 PARSE CAMERAS */
+ err = _parse_cameras(state);
+ if (err != OK)
+ return NULL;
+
+ /* STEP 11 PARSE ANIMATIONS */
+ err = _parse_animations(state);
+ if (err != OK)
+ return NULL;
+
+ /* STEP 12 ASSIGN SCENE NAMES */
+ _assign_scene_names(state);
+
+ /* STEP 13 MAKE SCENE! */
+ Spatial *scene = _generate_scene(state, p_bake_fps);
+
+ return scene;
+}
+
+Ref<Animation> EditorSceneImporterGLTF::import_animation(const String &p_path, uint32_t p_flags) {
+
+ return Ref<Animation>();
+}
+
+EditorSceneImporterGLTF::EditorSceneImporterGLTF() {
+}
diff --git a/editor/import/editor_scene_importer_gltf.h b/editor/import/editor_scene_importer_gltf.h
new file mode 100644
index 0000000000..d9479fae6f
--- /dev/null
+++ b/editor/import/editor_scene_importer_gltf.h
@@ -0,0 +1,304 @@
+#ifndef EDITOR_SCENE_IMPORTER_GLTF_H
+#define EDITOR_SCENE_IMPORTER_GLTF_H
+
+#include "editor/import/resource_importer_scene.h"
+#include "scene/3d/skeleton.h"
+#include "scene/3d/spatial.h"
+
+class AnimationPlayer;
+
+class EditorSceneImporterGLTF : public EditorSceneImporter {
+
+ GDCLASS(EditorSceneImporterGLTF, EditorSceneImporter);
+
+ enum {
+ ARRAY_BUFFER = 34962,
+ ELEMENT_ARRAY_BUFFER = 34963,
+
+ TYPE_BYTE = 5120,
+ TYPE_UNSIGNED_BYTE = 5121,
+ TYPE_SHORT = 5122,
+ TYPE_UNSIGNED_SHORT = 5123,
+ TYPE_UNSIGNED_INT = 5125,
+ TYPE_FLOAT = 5126,
+
+ COMPONENT_TYPE_BYTE = 5120,
+ COMPONENT_TYPE_UNSIGNED_BYTE = 5121,
+ COMPONENT_TYPE_SHORT = 5122,
+ COMPONENT_TYPE_UNSIGNED_SHORT = 5123,
+ COMPONENT_TYPE_INT = 5125,
+ COMPONENT_TYPE_FLOAT = 5126,
+
+ };
+
+ String _get_component_type_name(uint32_t p_component);
+ int _get_component_type_size(int component_type);
+
+ enum GLTFType {
+ TYPE_SCALAR,
+ TYPE_VEC2,
+ TYPE_VEC3,
+ TYPE_VEC4,
+ TYPE_MAT2,
+ TYPE_MAT3,
+ TYPE_MAT4,
+ };
+
+ String _get_type_name(GLTFType p_component);
+
+ struct GLTFNode {
+ //matrices need to be transformed to this
+ int parent;
+
+ Transform xform;
+ String name;
+ Node *godot_node;
+ int godot_bone_index;
+
+ int mesh;
+ int camera;
+ int skin;
+ int skeleton_skin;
+ int child_of_skeleton; // put as children of skeleton
+ Vector<int> skeleton_children; //skeleton put as children of this
+
+ int joint_skin;
+ int joint_bone;
+
+ //keep them for animation
+ Vector3 translation;
+ Quat rotation;
+ Vector3 scale;
+
+ Vector<int> children;
+
+ GLTFNode() {
+ godot_node = NULL;
+ godot_bone_index = -1;
+ joint_skin = -1;
+ joint_bone = -1;
+ child_of_skeleton = -1;
+ skeleton_skin = -1;
+ mesh = -1;
+ camera = -1;
+ parent = -1;
+ scale = Vector3(1, 1, 1);
+ }
+ };
+
+ struct GLTFBufferView {
+
+ int buffer;
+ int byte_offset;
+ int byte_length;
+ int byte_stride;
+ bool indices;
+ //matrices need to be transformed to this
+
+ GLTFBufferView() {
+ buffer = 0;
+ byte_offset = 0;
+ byte_length = 0;
+ byte_stride = 0;
+ indices = false;
+ }
+ };
+
+ struct GLTFAccessor {
+
+ int buffer_view;
+ int byte_offset;
+ int component_type;
+ bool normalized;
+ int count;
+ GLTFType type;
+ float min;
+ float max;
+ int sparse_count;
+ int sparse_indices_buffer_view;
+ int sparse_indices_byte_offset;
+ int sparse_indices_component_type;
+ int sparse_values_buffer_view;
+ int sparse_values_byte_offset;
+
+ //matrices need to be transformed to this
+
+ GLTFAccessor() {
+ buffer_view = 0;
+ byte_offset = 0;
+ component_type = 0;
+ normalized = false;
+ count = 0;
+ min = 0;
+ max = 0;
+ sparse_count = 0;
+ sparse_indices_byte_offset = 0;
+ sparse_values_byte_offset = 0;
+ }
+ };
+ struct GLTFTexture {
+ int src_image;
+ };
+
+ struct GLTFSkin {
+
+ String name;
+ struct Bone {
+ Transform inverse_bind;
+ int node;
+ };
+
+ int skeleton;
+ Vector<Bone> bones;
+
+ //matrices need to be transformed to this
+
+ GLTFSkin() {
+ skeleton = -1;
+ }
+ };
+
+ struct GLTFMesh {
+ Ref<ArrayMesh> mesh;
+ Vector<float> blend_weights;
+ };
+
+ struct GLTFCamera {
+
+ bool perspective;
+ float fov_size;
+ float zfar;
+ float znear;
+
+ GLTFCamera() {
+ perspective = true;
+ fov_size = 65;
+ zfar = 500;
+ znear = 0.1;
+ }
+ };
+
+ struct GLTFAnimation {
+
+ enum Interpolation {
+ INTERP_LINEAR,
+ INTERP_STEP,
+ INTERP_CATMULLROMSPLINE,
+ INTERP_CUBIC_SPLINE
+ };
+
+ template <class T>
+ struct Channel {
+ Interpolation interpolation;
+ Vector<float> times;
+ Vector<T> values;
+ };
+
+ struct Track {
+
+ Channel<Vector3> translation_track;
+ Channel<Quat> rotation_track;
+ Channel<Vector3> scale_track;
+ Vector<Channel<float> > weight_tracks;
+ };
+
+ String name;
+
+ Map<int, Track> tracks;
+ };
+
+ struct GLTFState {
+
+ Dictionary json;
+ int major_version;
+ int minor_version;
+ Vector<uint8_t> glb_data;
+
+ Vector<GLTFNode *> nodes;
+ Vector<Vector<uint8_t> > buffers;
+ Vector<GLTFBufferView> buffer_views;
+ Vector<GLTFAccessor> accessors;
+
+ Vector<GLTFMesh> meshes; //meshes are loaded directly, no reason not to.
+ Vector<Ref<Material> > materials;
+
+ String scene_name;
+ Vector<int> root_nodes;
+
+ Vector<GLTFTexture> textures;
+ Vector<Ref<Texture> > images;
+
+ Vector<GLTFSkin> skins;
+ Vector<GLTFCamera> cameras;
+
+ Set<String> unique_names;
+
+ Vector<GLTFAnimation> animations;
+
+ Map<int, Vector<int> > skin_users; //cache skin users
+
+ ~GLTFState() {
+ for (int i = 0; i < nodes.size(); i++) {
+ memdelete(nodes[i]);
+ }
+ }
+ };
+
+ String _gen_unique_name(GLTFState &state, const String &p_name);
+
+ Ref<Texture> _get_texture(GLTFState &state, int p_texture);
+
+ Error _parse_json(const String &p_path, GLTFState &state);
+ Error _parse_glb(const String &p_path, GLTFState &state);
+
+ Error _parse_scenes(GLTFState &state);
+ Error _parse_nodes(GLTFState &state);
+ Error _parse_buffers(GLTFState &state, const String &p_base_path);
+ Error _parse_buffer_views(GLTFState &state);
+ GLTFType _get_type_from_str(const String &p_string);
+ Error _parse_accessors(GLTFState &state);
+ Error _decode_buffer_view(GLTFState &state, int p_buffer_view, double *dst, int skip_every, int skip_bytes, int element_size, int count, GLTFType type, int component_count, int component_type, int component_size, bool normalized, int byte_offset, bool for_vertex);
+ Vector<double> _decode_accessor(GLTFState &state, int p_accessor, bool p_for_vertex);
+ PoolVector<float> _decode_accessor_as_floats(GLTFState &state, int p_accessor, bool p_for_vertex);
+ PoolVector<int> _decode_accessor_as_ints(GLTFState &state, int p_accessor, bool p_for_vertex);
+ PoolVector<Vector2> _decode_accessor_as_vec2(GLTFState &state, int p_accessor, bool p_for_vertex);
+ PoolVector<Vector3> _decode_accessor_as_vec3(GLTFState &state, int p_accessor, bool p_for_vertex);
+ PoolVector<Color> _decode_accessor_as_color(GLTFState &state, int p_accessor, bool p_for_vertex);
+ Vector<Quat> _decode_accessor_as_quat(GLTFState &state, int p_accessor, bool p_for_vertex);
+ Vector<Transform2D> _decode_accessor_as_xform2d(GLTFState &state, int p_accessor, bool p_for_vertex);
+ Vector<Basis> _decode_accessor_as_basis(GLTFState &state, int p_accessor, bool p_for_vertex);
+ Vector<Transform> _decode_accessor_as_xform(GLTFState &state, int p_accessor, bool p_for_vertex);
+
+ void _generate_bone(GLTFState &state, int p_node, Vector<Skeleton *> &skeletons, int p_parent_bone);
+ void _generate_node(GLTFState &state, int p_node, Node *p_parent, Node *p_owner, Vector<Skeleton *> &skeletons);
+ void _import_animation(GLTFState &state, AnimationPlayer *ap, int index, int bake_fps, Vector<Skeleton *> skeletons);
+
+ Spatial *_generate_scene(GLTFState &state, int p_bake_fps);
+
+ Error _parse_meshes(GLTFState &state);
+ Error _parse_images(GLTFState &state, const String &p_base_path);
+ Error _parse_textures(GLTFState &state);
+
+ Error _parse_materials(GLTFState &state);
+
+ Error _parse_skins(GLTFState &state);
+
+ Error _parse_cameras(GLTFState &state);
+
+ Error _parse_animations(GLTFState &state);
+
+ void _assign_scene_names(GLTFState &state);
+
+ template <class T>
+ T _interpolate_track(const Vector<float> &p_times, const Vector<T> &p_values, float p_time, GLTFAnimation::Interpolation p_interp);
+
+public:
+ virtual uint32_t get_import_flags() const;
+ virtual void get_extensions(List<String> *r_extensions) const;
+ virtual Node *import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps = NULL, Error *r_err = NULL);
+ virtual Ref<Animation> import_animation(const String &p_path, uint32_t p_flags);
+
+ EditorSceneImporterGLTF();
+};
+
+#endif // EDITOR_SCENE_IMPORTER_GLTF_H
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index a809a68c23..f5d9da195a 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -385,7 +385,7 @@ void CanvasItemEditor::_add_canvas_item(CanvasItem *p_canvas_item) {
return;
canvas_items.insert(p_canvas_item,p_info);
- p_canvas_item->connect("hide",this,"_visibility_changed",varray(p_canvas_item->get_instance_ID()),CONNECT_ONESHOT);
+ p_canvas_item->connect("hide",this,"_visibility_changed",varray(p_canvas_item->get_instance_id()),CONNECT_ONESHOT);
#endif
}
@@ -2204,7 +2204,7 @@ void CanvasItemEditor::_find_canvas_items_span(Node *p_node, Rect2 &r_rect, cons
if (c->has_meta("_edit_bone_")) {
- ObjectID id = c->get_instance_ID();
+ ObjectID id = c->get_instance_id();
if (!bone_list.has(id)) {
BoneList bone;
bone.bone = id;
@@ -2769,7 +2769,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
pc.pos = n2d->get_position();
pc.rot = n2d->get_rotation();
pc.scale = n2d->get_scale();
- pc.id = n2d->get_instance_ID();
+ pc.id = n2d->get_instance_id();
pose_clipboard.push_back(pc);
}
}
diff --git a/editor/plugins/item_list_editor_plugin.h b/editor/plugins/item_list_editor_plugin.h
index 4fed8e49f5..bc009b3d7a 100644
--- a/editor/plugins/item_list_editor_plugin.h
+++ b/editor/plugins/item_list_editor_plugin.h
@@ -116,8 +116,8 @@ public:
virtual void set_item_enabled(int p_idx, int p_enabled) { ob->set_item_disabled(p_idx, !p_enabled); }
virtual bool is_item_enabled(int p_idx) const { return !ob->is_item_disabled(p_idx); }
- virtual void set_item_id(int p_idx, int p_id) { ob->set_item_ID(p_idx, p_id); }
- virtual int get_item_id(int p_idx) const { return ob->get_item_ID(p_idx); }
+ virtual void set_item_id(int p_idx, int p_id) { ob->set_item_id(p_idx, p_id); }
+ virtual int get_item_id(int p_idx) const { return ob->get_item_id(p_idx); }
virtual void add_item();
virtual int get_item_count() const;
@@ -152,8 +152,8 @@ public:
virtual void set_item_enabled(int p_idx, int p_enabled) { pp->set_item_disabled(p_idx, !p_enabled); }
virtual bool is_item_enabled(int p_idx) const { return !pp->is_item_disabled(p_idx); }
- virtual void set_item_id(int p_idx, int p_id) { pp->set_item_ID(p_idx, p_idx); }
- virtual int get_item_id(int p_idx) const { return pp->get_item_ID(p_idx); }
+ virtual void set_item_id(int p_idx, int p_id) { pp->set_item_id(p_idx, p_idx); }
+ virtual int get_item_id(int p_idx) const { return pp->get_item_id(p_idx); }
virtual void set_item_separator(int p_idx, bool p_separator) { pp->set_item_as_separator(p_idx, p_separator); }
virtual bool is_item_separator(int p_idx) const { return pp->is_item_separator(p_idx); }
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index 77c540b746..1873a3f58b 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -211,9 +211,11 @@ void ScriptEditorQuickOpen::_confirmed() {
void ScriptEditorQuickOpen::_notification(int p_what) {
- if (p_what == NOTIFICATION_ENTER_TREE) {
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE: {
- connect("confirmed", this, "_confirmed");
+ connect("confirmed", this, "_confirmed");
+ } break;
}
}
@@ -1064,58 +1066,73 @@ void ScriptEditor::_tab_changed(int p_which) {
void ScriptEditor::_notification(int p_what) {
- if (p_what == NOTIFICATION_ENTER_TREE) {
-
- editor->connect("play_pressed", this, "_editor_play");
- editor->connect("pause_pressed", this, "_editor_pause");
- editor->connect("stop_pressed", this, "_editor_stop");
- editor->connect("script_add_function_request", this, "_add_callback");
- editor->connect("resource_saved", this, "_res_saved_callback");
- script_list->connect("item_selected", this, "_script_selected");
- members_overview->connect("item_selected", this, "_members_overview_selected");
- script_split->connect("dragged", this, "_script_split_dragged");
- autosave_timer->connect("timeout", this, "_autosave_scripts");
- {
- float autosave_time = EditorSettings::get_singleton()->get("text_editor/files/autosave_interval_secs");
- if (autosave_time > 0) {
- autosave_timer->set_wait_time(autosave_time);
- autosave_timer->start();
- } else {
- autosave_timer->stop();
+ switch (p_what) {
+
+ case NOTIFICATION_ENTER_TREE: {
+
+ editor->connect("play_pressed", this, "_editor_play");
+ editor->connect("pause_pressed", this, "_editor_pause");
+ editor->connect("stop_pressed", this, "_editor_stop");
+ editor->connect("script_add_function_request", this, "_add_callback");
+ editor->connect("resource_saved", this, "_res_saved_callback");
+ script_list->connect("item_selected", this, "_script_selected");
+ members_overview->connect("item_selected", this, "_members_overview_selected");
+ script_split->connect("dragged", this, "_script_split_dragged");
+ autosave_timer->connect("timeout", this, "_autosave_scripts");
+ {
+ float autosave_time = EditorSettings::get_singleton()->get("text_editor/files/autosave_interval_secs");
+ if (autosave_time > 0) {
+ autosave_timer->set_wait_time(autosave_time);
+ autosave_timer->start();
+ } else {
+ autosave_timer->stop();
+ }
}
- }
- EditorSettings::get_singleton()->connect("settings_changed", this, "_editor_settings_changed");
- help_search->set_icon(get_icon("HelpSearch", "EditorIcons"));
- site_search->set_icon(get_icon("Instance", "EditorIcons"));
- class_search->set_icon(get_icon("ClassList", "EditorIcons"));
+ EditorSettings::get_singleton()->connect("settings_changed", this, "_editor_settings_changed");
+ help_search->set_icon(get_icon("HelpSearch", "EditorIcons"));
+ site_search->set_icon(get_icon("Instance", "EditorIcons"));
+ class_search->set_icon(get_icon("ClassList", "EditorIcons"));
- script_forward->set_icon(get_icon("Forward", "EditorIcons"));
- script_back->set_icon(get_icon("Back", "EditorIcons"));
- }
+ script_forward->set_icon(get_icon("Forward", "EditorIcons"));
+ script_back->set_icon(get_icon("Back", "EditorIcons"));
+ } break;
- if (p_what == NOTIFICATION_READY) {
+ case NOTIFICATION_READY: {
- get_tree()->connect("tree_changed", this, "_tree_changed");
- editor->connect("request_help", this, "_request_help");
- editor->connect("request_help_search", this, "_help_search");
- editor->connect("request_help_index", this, "_help_index");
- }
+ get_tree()->connect("tree_changed", this, "_tree_changed");
+ editor->connect("request_help", this, "_request_help");
+ editor->connect("request_help_search", this, "_help_search");
+ editor->connect("request_help_index", this, "_help_index");
+ } break;
- if (p_what == NOTIFICATION_EXIT_TREE) {
+ case NOTIFICATION_EXIT_TREE: {
- editor->disconnect("play_pressed", this, "_editor_play");
- editor->disconnect("pause_pressed", this, "_editor_pause");
- editor->disconnect("stop_pressed", this, "_editor_stop");
- }
+ editor->disconnect("play_pressed", this, "_editor_play");
+ editor->disconnect("pause_pressed", this, "_editor_pause");
+ editor->disconnect("stop_pressed", this, "_editor_stop");
+ } break;
- if (p_what == MainLoop::NOTIFICATION_WM_FOCUS_IN) {
+ case MainLoop::NOTIFICATION_WM_FOCUS_IN: {
- _test_script_times_on_disk();
- _update_modified_scripts_for_external_editor();
- }
+ _test_script_times_on_disk();
+ _update_modified_scripts_for_external_editor();
+ } break;
+
+ case NOTIFICATION_PROCESS: {
+ } break;
- if (p_what == NOTIFICATION_PROCESS) {
+ case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
+
+ tab_container->add_style_override("panel", editor->get_gui_base()->get_stylebox("ScriptPanel", "EditorStyles"));
+
+ Ref<StyleBox> sb = editor->get_gui_base()->get_stylebox("panel", "TabContainer")->duplicate();
+ sb->set_default_margin(MARGIN_TOP, 0);
+ add_style_override("panel", sb);
+ } break;
+
+ default:
+ break;
}
}
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp
index e260b1ea22..62fcc4b489 100644
--- a/editor/plugins/script_text_editor.cpp
+++ b/editor/plugins/script_text_editor.cpp
@@ -456,7 +456,7 @@ String ScriptTextEditor::get_name() {
} else if (script->get_name() != "")
name = script->get_name();
else
- name = script->get_class() + "(" + itos(script->get_instance_ID()) + ")";
+ name = script->get_class() + "(" + itos(script->get_instance_id()) + ")";
return name;
}
@@ -634,7 +634,17 @@ void ScriptTextEditor::_lookup_symbol(const String &p_symbol, int p_row, int p_c
}
ScriptLanguage::LookupResult result;
- if (script->get_language()->lookup_code(code_editor->get_text_edit()->get_text_for_lookup_completion(), p_symbol, script->get_path().get_base_dir(), base, result) == OK) {
+ if (p_symbol.is_resource_file()) {
+ List<String> scene_extensions;
+ ResourceLoader::get_recognized_extensions_for_type("PackedScene", &scene_extensions);
+
+ if (scene_extensions.find(p_symbol.get_extension())) {
+ EditorNode::get_singleton()->load_scene(p_symbol);
+ } else {
+ EditorNode::get_singleton()->load_resource(p_symbol);
+ }
+
+ } else if (script->get_language()->lookup_code(code_editor->get_text_edit()->get_text_for_lookup_completion(), p_symbol, script->get_path().get_base_dir(), base, result) == OK) {
_goto_line(p_row);
diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp
index 2d77bfb2c1..50d2f193ed 100644
--- a/editor/plugins/spatial_editor_plugin.cpp
+++ b/editor/plugins/spatial_editor_plugin.cpp
@@ -57,6 +57,12 @@
#define FREELOOK_MIN_SPEED 0.1
+#define MIN_Z 0.01
+#define MAX_Z 10000
+
+#define MIN_FOV 0.01
+#define MAX_FOV 179
+
void SpatialEditorViewport::_update_camera() {
if (orthogonal) {
//camera->set_orthogonal(size.width*cursor.distance,get_znear(),get_zfar());
@@ -153,26 +159,15 @@ int SpatialEditorViewport::get_selected_count() const {
float SpatialEditorViewport::get_znear() const {
- float val = spatial_editor->get_znear();
- if (val < 0.001)
- val = 0.001;
- return val;
+ return CLAMP(spatial_editor->get_znear(), MIN_Z, MAX_Z);
}
float SpatialEditorViewport::get_zfar() const {
- float val = spatial_editor->get_zfar();
- if (val < 0.001)
- val = 0.001;
- return val;
+ return CLAMP(spatial_editor->get_zfar(), MIN_Z, MAX_Z);
}
float SpatialEditorViewport::get_fov() const {
- float val = spatial_editor->get_fov();
- if (val < 0.001)
- val = 0.001;
- if (val > 89)
- val = 89;
- return val;
+ return CLAMP(spatial_editor->get_fov(), MIN_FOV, MAX_FOV);
}
Transform SpatialEditorViewport::_get_camera_transform() const {
@@ -665,7 +660,7 @@ void SpatialEditorViewport::_list_select(Ref<InputEventMouseButton> b) {
if (selection_results.size() == 1) {
- clicked = selection_results[0].item->get_instance_ID();
+ clicked = selection_results[0].item->get_instance_id();
selection_results.clear();
if (clicked) {
@@ -2166,7 +2161,7 @@ void SpatialEditorViewport::_selection_result_pressed(int p_result) {
if (selection_results.size() <= p_result)
return;
- clicked = selection_results[p_result].item->get_instance_ID();
+ clicked = selection_results[p_result].item->get_instance_id();
if (clicked) {
_select_clicked(clicked_wants_append, true);
@@ -2390,7 +2385,7 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed
view_menu = memnew(MenuButton);
surface->add_child(view_menu);
- view_menu->set_position(Point2(4, 4));
+ view_menu->set_position(Point2(4, 4) * EDSCALE);
view_menu->set_self_modulate(Color(1, 1, 1, 0.5));
view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/top_view"), VIEW_TOP);
view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/bottom_view"), VIEW_BOTTOM);
@@ -2434,8 +2429,8 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed
preview_camera = memnew(Button);
preview_camera->set_toggle_mode(true);
- preview_camera->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_END, 90);
- preview_camera->set_anchor_and_margin(MARGIN_TOP, ANCHOR_BEGIN, 10);
+ preview_camera->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_END, 90 * EDSCALE);
+ preview_camera->set_anchor_and_margin(MARGIN_TOP, ANCHOR_BEGIN, 10 * EDSCALE);
preview_camera->set_text("preview");
surface->add_child(preview_camera);
preview_camera->hide();
@@ -2455,7 +2450,7 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed
selection_menu = memnew(PopupMenu);
add_child(selection_menu);
- selection_menu->set_custom_minimum_size(Vector2(100, 0));
+ selection_menu->set_custom_minimum_size(Size2(100, 0) * EDSCALE);
selection_menu->connect("id_pressed", this, "_selection_result_pressed");
selection_menu->connect("popup_hide", this, "_selection_menu_hide");
@@ -2464,7 +2459,7 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed
viewport->set_as_audio_listener(true);
}
- name = TTR("Top");
+ name = "";
_update_name();
EditorSettings::get_singleton()->connect("settings_changed", this, "update_transform_gizmo_view");
@@ -3039,9 +3034,9 @@ void SpatialEditor::edit(Spatial *p_spatial) {
/*
if (p_spatial) {
_validate_selection();
- if (selected.has(p_spatial->get_instance_ID()) && selected.size()==1)
+ if (selected.has(p_spatial->get_instance_id()) && selected.size()==1)
return;
- _select(p_spatial->get_instance_ID(),false,true);
+ _select(p_spatial->get_instance_id(),false,true);
// should become the selection
}
@@ -3933,27 +3928,27 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
settings_dialog->set_title(TTR("Viewport Settings"));
add_child(settings_dialog);
settings_vbc = memnew(VBoxContainer);
- settings_vbc->set_custom_minimum_size(Size2(200, 0));
+ settings_vbc->set_custom_minimum_size(Size2(200, 0) * EDSCALE);
settings_dialog->add_child(settings_vbc);
//settings_dialog->set_child_rect(settings_vbc);
settings_fov = memnew(SpinBox);
- settings_fov->set_max(179);
- settings_fov->set_min(1);
+ settings_fov->set_max(MAX_FOV);
+ settings_fov->set_min(MIN_FOV);
settings_fov->set_step(0.01);
settings_fov->set_value(EDITOR_DEF("editors/3d/default_fov", 55.0));
settings_vbc->add_margin_child(TTR("Perspective FOV (deg.):"), settings_fov);
settings_znear = memnew(SpinBox);
- settings_znear->set_max(10000);
- settings_znear->set_min(0.1);
+ settings_znear->set_max(MAX_Z);
+ settings_znear->set_min(MIN_Z);
settings_znear->set_step(0.01);
settings_znear->set_value(EDITOR_DEF("editors/3d/default_z_near", 0.1));
settings_vbc->add_margin_child(TTR("View Z-Near:"), settings_znear);
settings_zfar = memnew(SpinBox);
- settings_zfar->set_max(10000);
- settings_zfar->set_min(0.1);
+ settings_zfar->set_max(MAX_Z);
+ settings_zfar->set_min(MIN_Z);
settings_zfar->set_step(0.01);
settings_zfar->set_value(EDITOR_DEF("editors/3d/default_z_far", 1500));
settings_vbc->add_margin_child(TTR("View Z-Far:"), settings_zfar);
diff --git a/editor/plugins/theme_editor_plugin.cpp b/editor/plugins/theme_editor_plugin.cpp
index f5bb9d4a35..d45a3b1312 100644
--- a/editor/plugins/theme_editor_plugin.cpp
+++ b/editor/plugins/theme_editor_plugin.cpp
@@ -104,7 +104,7 @@ struct _TECategory {
Ref<T> item;
StringName name;
- bool operator<(const RefItem<T> &p) const { return item->get_instance_ID() < p.item->get_instance_ID(); }
+ bool operator<(const RefItem<T> &p) const { return item->get_instance_id() < p.item->get_instance_id(); }
};
template <class T>
diff --git a/editor/plugins/tile_map_editor_plugin.cpp b/editor/plugins/tile_map_editor_plugin.cpp
index d12b979121..e7bc8a4dab 100644
--- a/editor/plugins/tile_map_editor_plugin.cpp
+++ b/editor/plugins/tile_map_editor_plugin.cpp
@@ -330,6 +330,8 @@ PoolVector<Vector2> TileMapEditor::_bucket_fill(const Point2i &p_start, bool era
if (id == TileMap::INVALID_CELL)
return PoolVector<Vector2>();
+ } else if (prev_id == TileMap::INVALID_CELL) {
+ return PoolVector<Vector2>();
}
Rect2i r = node->get_item_rect();
diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp
index 82f17b80d5..d5a56f644f 100644
--- a/editor/project_manager.cpp
+++ b/editor/project_manager.cpp
@@ -573,7 +573,7 @@ void ProjectManager::_unhandled_input(const Ref<InputEvent> &p_ev) {
switch (k->get_scancode()) {
- case KEY_RETURN: {
+ case KEY_ENTER: {
_open_project();
} break;
diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp
index 6d23e874df..6238cad14d 100644
--- a/editor/project_settings_editor.cpp
+++ b/editor/project_settings_editor.cpp
@@ -140,7 +140,7 @@ void ProjectSettingsEditor::_action_edited() {
add_at = "input/" + old_name;
message->set_text(TTR("Invalid action (anything goes but '/' or ':')."));
- message->popup_centered(Size2(300, 100));
+ message->popup_centered(Size2(300, 100) * EDSCALE);
return;
}
@@ -152,7 +152,7 @@ void ProjectSettingsEditor::_action_edited() {
add_at = "input/" + old_name;
message->set_text(vformat(TTR("Action '%s' already exists!"), new_name));
- message->popup_centered(Size2(300, 100));
+ message->popup_centered(Size2(300, 100) * EDSCALE);
return;
}
@@ -399,7 +399,7 @@ void ProjectSettingsEditor::_add_item(int p_item, Ref<InputEvent> p_exiting_even
device_index->add_item(TTR("Button 7"));
device_index->add_item(TTR("Button 8"));
device_index->add_item(TTR("Button 9"));
- device_input->popup_centered_minsize(Size2(350, 95));
+ device_input->popup_centered_minsize(Size2(350, 95) * EDSCALE);
Ref<InputEventMouseButton> mb = p_exiting_event;
if (mb.is_valid()) {
@@ -420,7 +420,7 @@ void ProjectSettingsEditor::_add_item(int p_item, Ref<InputEvent> p_exiting_even
String desc = _axis_names[i];
device_index->add_item(TTR("Axis") + " " + itos(i / 2) + " " + (i & 1 ? "+" : "-") + desc);
}
- device_input->popup_centered_minsize(Size2(350, 95));
+ device_input->popup_centered_minsize(Size2(350, 95) * EDSCALE);
Ref<InputEventJoypadMotion> jm = p_exiting_event;
if (jm.is_valid()) {
@@ -441,7 +441,7 @@ void ProjectSettingsEditor::_add_item(int p_item, Ref<InputEvent> p_exiting_even
device_index->add_item(itos(i) + ": " + String(_button_names[i]));
}
- device_input->popup_centered_minsize(Size2(350, 95));
+ device_input->popup_centered_minsize(Size2(350, 95) * EDSCALE);
Ref<InputEventJoypadButton> jb = p_exiting_event;
if (jb.is_valid()) {
@@ -835,13 +835,13 @@ void ProjectSettingsEditor::_action_add() {
String action = action_name->get_text();
if (action.find("/") != -1 || action.find(":") != -1 || action == "") {
message->set_text(TTR("Invalid action (anything goes but '/' or ':')."));
- message->popup_centered(Size2(300, 100));
+ message->popup_centered(Size2(300, 100) * EDSCALE);
return;
}
if (ProjectSettings::get_singleton()->has("input/" + action)) {
message->set_text(vformat(TTR("Action '%s' already exists!"), action));
- message->popup_centered(Size2(300, 100));
+ message->popup_centered(Size2(300, 100) * EDSCALE);
return;
}
@@ -879,7 +879,7 @@ void ProjectSettingsEditor::_save() {
Error err = ProjectSettings::get_singleton()->save();
message->set_text(err != OK ? TTR("Error saving settings.") : TTR("Settings saved OK."));
- message->popup_centered(Size2(300, 100));
+ message->popup_centered(Size2(300, 100) * EDSCALE);
}
void ProjectSettingsEditor::_settings_prop_edited(const String &p_name) {
@@ -1554,7 +1554,7 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
add = memnew(Button);
hbc->add_child(add);
- add->set_custom_minimum_size(Size2(150, 0));
+ add->set_custom_minimum_size(Size2(150, 0) * EDSCALE);
add->set_text(TTR("Add"));
add->connect("pressed", this, "_action_add");
diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp
index 42485317c1..a3a10c6c5a 100644
--- a/editor/property_editor.cpp
+++ b/editor/property_editor.cpp
@@ -2370,7 +2370,7 @@ void PropertyEditor::set_item_text(TreeItem *p_item, int p_type, const String &p
p_item->set_text(1, res->get_path().get_file());
} else if (!res->is_class("Texture")) {
//texture already previews via itself
- EditorResourcePreview::get_singleton()->queue_edited_resource_preview(res, this, "_resource_preview_done", p_item->get_instance_ID());
+ EditorResourcePreview::get_singleton()->queue_edited_resource_preview(res, this, "_resource_preview_done", p_item->get_instance_id());
}
}
@@ -3630,7 +3630,7 @@ void PropertyEditor::update_tree() {
item->set_text(1, res->get_path().get_file());
} else if (!res->is_class("Texture")) {
//texture already previews via itself
- EditorResourcePreview::get_singleton()->queue_edited_resource_preview(res, this, "_resource_preview_done", item->get_instance_ID());
+ EditorResourcePreview::get_singleton()->queue_edited_resource_preview(res, this, "_resource_preview_done", item->get_instance_id());
}
}
@@ -3858,7 +3858,7 @@ void PropertyEditor::_item_edited() {
break;
if (type == Variant::INT)
- _edit_set(name, round(item->get_range(1)), refresh_all);
+ _edit_set(name, int64_t(round(item->get_range(1))), refresh_all);
else
_edit_set(name, item->get_range(1), refresh_all);
} break;
@@ -4586,7 +4586,7 @@ void SectionedPropertyEditor::edit(Object *p_object) {
return;
}
- ObjectID id = p_object->get_instance_ID();
+ ObjectID id = p_object->get_instance_id();
if (obj != id) {
diff --git a/editor/property_selector.cpp b/editor/property_selector.cpp
index c6af993676..bd68eac9f2 100644
--- a/editor/property_selector.cpp
+++ b/editor/property_selector.cpp
@@ -418,7 +418,7 @@ void PropertySelector::select_method_from_script(const Ref<Script> &p_script, co
base_type = p_script->get_instance_base_type();
selected = p_current;
type = Variant::NIL;
- script = p_script->get_instance_ID();
+ script = p_script->get_instance_id();
properties = false;
instance = NULL;
@@ -452,7 +452,7 @@ void PropertySelector::select_method_from_instance(Object *p_instance, const Str
{
Ref<Script> scr = p_instance->get_script();
if (scr.is_valid())
- script = scr->get_instance_ID();
+ script = scr->get_instance_id();
}
properties = false;
instance = NULL;
@@ -485,7 +485,7 @@ void PropertySelector::select_property_from_script(const Ref<Script> &p_script,
base_type = p_script->get_instance_base_type();
selected = p_current;
type = Variant::NIL;
- script = p_script->get_instance_ID();
+ script = p_script->get_instance_id();
properties = true;
instance = NULL;
diff --git a/editor/resources_dock.cpp b/editor/resources_dock.cpp
index d3b68d92e4..db3bf6a352 100644
--- a/editor/resources_dock.cpp
+++ b/editor/resources_dock.cpp
@@ -204,7 +204,7 @@ void ResourcesDock::_update_name(TreeItem *item) {
else if (res->get_path() != "" && res->get_path().find("::") == -1)
item->set_text(0, res->get_path().get_file());
else
- item->set_text(0, res->get_class() + " (" + itos(res->get_instance_ID()) + ")");
+ item->set_text(0, res->get_class() + " (" + itos(res->get_instance_id()) + ")");
}
void ResourcesDock::remove_resource(const Ref<Resource> &p_resource) {
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp
index 47a9185389..ce3b85332f 100644
--- a/editor/scene_tree_dock.cpp
+++ b/editor/scene_tree_dock.cpp
@@ -1369,8 +1369,8 @@ void SceneTreeDock::_delete_confirm() {
editor_data->get_undo_redo().add_undo_reference(n);
ScriptEditorDebugger *sed = ScriptEditor::get_singleton()->get_debugger();
- editor_data->get_undo_redo().add_do_method(sed, "live_debug_remove_and_keep_node", edited_scene->get_path_to(n), n->get_instance_ID());
- editor_data->get_undo_redo().add_undo_method(sed, "live_debug_restore_node", n->get_instance_ID(), edited_scene->get_path_to(n->get_parent()), n->get_index());
+ editor_data->get_undo_redo().add_do_method(sed, "live_debug_remove_and_keep_node", edited_scene->get_path_to(n), n->get_instance_id());
+ editor_data->get_undo_redo().add_undo_method(sed, "live_debug_restore_node", n->get_instance_id(), edited_scene->get_path_to(n->get_parent()), n->get_index());
}
}
editor_data->get_undo_redo().commit_action();
@@ -1824,7 +1824,7 @@ void SceneTreeDock::_add_children_to_popup(Object *p_obj, int p_depth) {
int index = menu->get_item_count();
menu->add_icon_item(icon, E->get().name.capitalize(), EDIT_SUBRESOURCE_BASE + subresources.size());
menu->set_item_h_offset(index, p_depth * 10 * EDSCALE);
- subresources.push_back(obj->get_instance_ID());
+ subresources.push_back(obj->get_instance_id());
_add_children_to_popup(obj, p_depth + 1);
}
diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp
index f35e098065..390d13e64e 100644
--- a/editor/scene_tree_editor.cpp
+++ b/editor/scene_tree_editor.cpp
@@ -411,9 +411,9 @@ void SceneTreeEditor::_update_tree() {
void SceneTreeEditor::_compute_hash(Node *p_node, uint64_t &hash) {
- hash = hash_djb2_one_64(p_node->get_instance_ID(), hash);
+ hash = hash_djb2_one_64(p_node->get_instance_id(), hash);
if (p_node->get_parent())
- hash = hash_djb2_one_64(p_node->get_parent()->get_instance_ID(), hash); //so a reparent still produces a different hash
+ hash = hash_djb2_one_64(p_node->get_parent()->get_instance_id(), hash); //so a reparent still produces a different hash
for (int i = 0; i < p_node->get_child_count(); i++) {
@@ -625,8 +625,8 @@ void SceneTreeEditor::_renamed() {
} else {
undo_redo->create_action(TTR("Rename Node"));
emit_signal("node_prerename", n, new_name);
- undo_redo->add_do_method(this, "_rename_node", n->get_instance_ID(), new_name);
- undo_redo->add_undo_method(this, "_rename_node", n->get_instance_ID(), n->get_name());
+ undo_redo->add_do_method(this, "_rename_node", n->get_instance_id(), new_name);
+ undo_redo->add_undo_method(this, "_rename_node", n->get_instance_id(), n->get_name());
undo_redo->commit_action();
}
}
diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp
index d81161ae94..0748c43b5f 100644
--- a/editor/script_create_dialog.cpp
+++ b/editor/script_create_dialog.cpp
@@ -29,6 +29,7 @@
/*************************************************************************/
#include "script_create_dialog.h"
+#include "editor/editor_node.h"
#include "editor/editor_scale.h"
#include "editor_file_system.h"
#include "io/resource_saver.h"
@@ -229,7 +230,7 @@ void ScriptCreateDialog::_lang_changed(int l) {
List<String> extensions;
// get all possible extensions for script
for (int l = 0; l < language_menu->get_item_count(); l++) {
- language->get_recognized_extensions(&extensions);
+ ScriptServer::get_language(l)->get_recognized_extensions(&extensions);
}
for (List<String>::Element *E = extensions.front(); E; E = E->next()) {
@@ -240,8 +241,11 @@ void ScriptCreateDialog::_lang_changed(int l) {
}
}
}
- file_path->set_text(path);
+ } else {
+ path = "class" + selected_ext;
+ _path_changed(path);
}
+ file_path->set_text(path);
bool use_templates = language->is_using_templates();
template_menu->set_disabled(!use_templates);
@@ -403,9 +407,9 @@ void ScriptCreateDialog::_msg_script_valid(bool valid, const String &p_msg) {
error_label->set_text(TTR(p_msg));
if (valid) {
- error_label->add_color_override("font_color", Color(0, 1.0, 0.8, 0.8));
+ error_label->add_color_override("font_color", get_color("success_color", "Editor"));
} else {
- error_label->add_color_override("font_color", Color(1, 0.2, 0.2, 0.8));
+ error_label->add_color_override("font_color", get_color("error_color", "Editor"));
}
}
@@ -413,9 +417,9 @@ void ScriptCreateDialog::_msg_path_valid(bool valid, const String &p_msg) {
path_error_label->set_text(TTR(p_msg));
if (valid) {
- path_error_label->add_color_override("font_color", Color(0, 1.0, 0.8, 0.8));
+ path_error_label->add_color_override("font_color", get_color("success_color", "Editor"));
} else {
- path_error_label->add_color_override("font_color", Color(1, 0.4, 0.0, 0.8));
+ path_error_label->add_color_override("font_color", get_color("error_color", "Editor"));
}
}
@@ -543,19 +547,6 @@ ScriptCreateDialog::ScriptCreateDialog() {
gc = memnew(GridContainer);
gc->set_columns(2);
- /* Error Stylebox Background */
-
- StyleBoxFlat *sb = memnew(StyleBoxFlat);
- sb->set_bg_color(Color(0, 0, 0, 0.05));
- sb->set_light_color(Color(1, 1, 1, 0.05));
- sb->set_dark_color(Color(1, 1, 1, 0.05));
- sb->set_border_blend(false);
- sb->set_border_size(1);
- sb->set_default_margin(MARGIN_TOP, 10.0 * EDSCALE);
- sb->set_default_margin(MARGIN_BOTTOM, 10.0 * EDSCALE);
- sb->set_default_margin(MARGIN_LEFT, 10.0 * EDSCALE);
- sb->set_default_margin(MARGIN_RIGHT, 10.0 * EDSCALE);
-
/* Error Messages Field */
vb = memnew(VBoxContainer);
@@ -582,7 +573,7 @@ ScriptCreateDialog::ScriptCreateDialog() {
pc = memnew(PanelContainer);
pc->set_h_size_flags(Control::SIZE_FILL);
- pc->add_style_override("panel", sb);
+ pc->add_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_stylebox("bg", "Tree"));
pc->add_child(vb);
/* Margins */
diff --git a/editor/spatial_editor_gizmos.cpp b/editor/spatial_editor_gizmos.cpp
index faf9dee5d0..659a3cf0d2 100644
--- a/editor/spatial_editor_gizmos.cpp
+++ b/editor/spatial_editor_gizmos.cpp
@@ -70,7 +70,7 @@ void EditorSpatialGizmo::redraw() {
void EditorSpatialGizmo::Instance::create_instance(Spatial *p_base) {
instance = VS::get_singleton()->instance_create2(mesh->get_rid(), p_base->get_world()->get_scenario());
- VS::get_singleton()->instance_attach_object_instance_ID(instance, p_base->get_instance_ID());
+ VS::get_singleton()->instance_attach_object_instance_id(instance, p_base->get_instance_id());
if (skeleton.is_valid())
VS::get_singleton()->instance_attach_skeleton(instance, skeleton);
if (extra_margin)
diff --git a/main/input_default.cpp b/main/input_default.cpp
index 3361aa0678..4e2fd6f9d4 100644
--- a/main/input_default.cpp
+++ b/main/input_default.cpp
@@ -453,7 +453,8 @@ void InputDefault::set_mouse_position(const Point2 &p_posf) {
mouse_speed_track.update(p_posf - mouse_pos);
mouse_pos = p_posf;
if (custom_cursor.is_valid()) {
- VisualServer::get_singleton()->cursor_set_pos(get_mouse_position());
+ //removed, please insist that we implement hardware cursors
+ // VisualServer::get_singleton()->cursor_set_pos(get_mouse_position());
}
}
@@ -538,6 +539,7 @@ bool InputDefault::is_emulating_touchscreen() const {
}
void InputDefault::set_custom_mouse_cursor(const RES &p_cursor, const Vector2 &p_hotspot) {
+ /* no longer supported, leaving this for reference to anyone who might want to implement hardware cursors
if (custom_cursor == p_cursor)
return;
@@ -545,7 +547,8 @@ void InputDefault::set_custom_mouse_cursor(const RES &p_cursor, const Vector2 &p
if (p_cursor.is_null()) {
set_mouse_mode(MOUSE_MODE_VISIBLE);
- VisualServer::get_singleton()->cursor_set_visible(false);
+ //removed, please insist us to implement hardare cursors
+ //VisualServer::get_singleton()->cursor_set_visible(false);
} else {
Ref<AtlasTexture> atex = custom_cursor;
Rect2 region = atex.is_valid() ? atex->get_region() : Rect2();
@@ -554,10 +557,11 @@ void InputDefault::set_custom_mouse_cursor(const RES &p_cursor, const Vector2 &p
VisualServer::get_singleton()->cursor_set_texture(custom_cursor->get_rid(), p_hotspot, 0, region);
VisualServer::get_singleton()->cursor_set_pos(get_mouse_position());
}
+ */
}
void InputDefault::set_mouse_in_window(bool p_in_window) {
-
+ /* no longer supported, leaving this for reference to anyone who might want to implement hardware cursors
if (custom_cursor.is_valid()) {
if (p_in_window) {
@@ -568,6 +572,7 @@ void InputDefault::set_mouse_in_window(bool p_in_window) {
VisualServer::get_singleton()->cursor_set_visible(false);
}
}
+ */
}
// from github.com/gabomdq/SDL_GameControllerDB
diff --git a/main/main.cpp b/main/main.cpp
index 8960d85c45..9376d83204 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -203,7 +203,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
MAIN_PRINT("Main: Initialize Globals");
- Thread::_main_thread_id = Thread::get_caller_ID();
+ Thread::_main_thread_id = Thread::get_caller_id();
globals = memnew(ProjectSettings);
input_map = memnew(InputMap);
@@ -1704,6 +1704,7 @@ void Main::cleanup() {
#endif
if (audio_server) {
+ audio_server->finish();
memdelete(audio_server);
}
diff --git a/main/performance.cpp b/main/performance.cpp
index c819e15f71..3d8e21bf33 100644
--- a/main/performance.cpp
+++ b/main/performance.cpp
@@ -117,8 +117,8 @@ float Performance::get_monitor(Monitor p_monitor) const {
case TIME_FIXED_PROCESS: return _fixed_process_time;
case MEMORY_STATIC: return Memory::get_mem_usage();
case MEMORY_DYNAMIC: return MemoryPool::total_memory;
- case MEMORY_STATIC_MAX: return MemoryPool::max_memory;
- case MEMORY_DYNAMIC_MAX: return 0;
+ case MEMORY_STATIC_MAX: return Memory::get_mem_max_usage();
+ case MEMORY_DYNAMIC_MAX: return MemoryPool::max_memory;
case MEMORY_MESSAGE_BUFFER_MAX: return MessageQueue::get_singleton()->get_max_buffer_usage();
case OBJECT_COUNT: return ObjectDB::get_object_count();
case OBJECT_RESOURCE_COUNT: return ResourceCache::get_cached_resource_count();
diff --git a/methods.py b/methods.py
index abd87c07d7..30a1f3caed 100644
--- a/methods.py
+++ b/methods.py
@@ -244,6 +244,7 @@ def build_glsl_header(filename):
fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Color& p_color) { _FU GLfloat col[4]={p_color.r,p_color.g,p_color.b,p_color.a}; glUniform4fv(get_uniform(p_uniform),1,col); }\n\n")
fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Vector2& p_vec2) { _FU GLfloat vec2[2]={p_vec2.x,p_vec2.y}; glUniform2fv(get_uniform(p_uniform),1,vec2); }\n\n")
fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Vector3& p_vec3) { _FU GLfloat vec3[3]={p_vec3.x,p_vec3.y,p_vec3.z}; glUniform3fv(get_uniform(p_uniform),1,vec3); }\n\n")
+ fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Plane& p_plane) { _FU GLfloat plane[4]={p_plane.normal.x,p_plane.normal.y,p_plane.normal.z,p_plane.d}; glUniform4fv(get_uniform(p_uniform),1,plane); }\n\n")
fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, float p_a, float p_b) { _FU glUniform2f(get_uniform(p_uniform),p_a,p_b); }\n\n")
fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, float p_a, float p_b, float p_c) { _FU glUniform3f(get_uniform(p_uniform),p_a,p_b,p_c); }\n\n")
fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, float p_a, float p_b, float p_c, float p_d) { _FU glUniform4f(get_uniform(p_uniform),p_a,p_b,p_c,p_d); }\n\n")
diff --git a/misc/scripts/makeargs.py b/misc/scripts/makeargs.py
index 2cd47ae087..26d9cc5a00 100644
--- a/misc/scripts/makeargs.py
+++ b/misc/scripts/makeargs.py
@@ -2,7 +2,7 @@
text = """
#define FUNC$numR(m_r,m_func,$argt)\\
virtual m_r m_func($argtp) { \\
- if (Thread::get_caller_ID()!=server_thread) {\\
+ if (Thread::get_caller_id()!=server_thread) {\\
m_r ret;\\
command_queue.push_and_ret( visual_server, &VisualServer::m_func,$argp,&ret);\\
return ret;\\
@@ -13,7 +13,7 @@ text = """
#define FUNC$numRC(m_r,m_func,$argt)\\
virtual m_r m_func($argtp) const { \\
- if (Thread::get_caller_ID()!=server_thread) {\\
+ if (Thread::get_caller_id()!=server_thread) {\\
m_r ret;\\
command_queue.push_and_ret( visual_server, &VisualServer::m_func,$argp,&ret);\\
return ret;\\
@@ -25,7 +25,7 @@ text = """
#define FUNC$numS(m_func,$argt)\\
virtual void m_func($argtp) { \\
- if (Thread::get_caller_ID()!=server_thread) {\\
+ if (Thread::get_caller_id()!=server_thread) {\\
command_queue.push_and_sync( visual_server, &VisualServer::m_func,$argp);\\
} else {\\
visual_server->m_func($argp);\\
@@ -34,7 +34,7 @@ text = """
#define FUNC$numSC(m_func,$argt)\\
virtual void m_func($argtp) const { \\
- if (Thread::get_caller_ID()!=server_thread) {\\
+ if (Thread::get_caller_id()!=server_thread) {\\
command_queue.push_and_sync( visual_server, &VisualServer::m_func,$argp);\\
} else {\\
visual_server->m_func($argp);\\
@@ -44,7 +44,7 @@ text = """
#define FUNC$num(m_func,$argt)\\
virtual void m_func($argtp) { \\
- if (Thread::get_caller_ID()!=server_thread) {\\
+ if (Thread::get_caller_id()!=server_thread) {\\
command_queue.push( visual_server, &VisualServer::m_func,$argp);\\
} else {\\
visual_server->m_func($argp);\\
@@ -53,7 +53,7 @@ text = """
#define FUNC$numC(m_func,$argt)\\
virtual void m_func($argtp) const { \\
- if (Thread::get_caller_ID()!=server_thread) {\\
+ if (Thread::get_caller_id()!=server_thread) {\\
command_queue.push( visual_server, &VisualServer::m_func,$argp);\\
} else {\\
visual_server->m_func($argp);\\
diff --git a/modules/enet/networked_multiplayer_enet.cpp b/modules/enet/networked_multiplayer_enet.cpp
index 738bd27ed3..68d5c9e611 100644
--- a/modules/enet/networked_multiplayer_enet.cpp
+++ b/modules/enet/networked_multiplayer_enet.cpp
@@ -508,7 +508,7 @@ uint32_t NetworkedMultiplayerENet::_gen_unique_id() const {
(uint32_t)OS::get_singleton()->get_data_dir().hash64(), hash);
/*
hash = hash_djb2_one_32(
- (uint32_t)OS::get_singleton()->get_unique_ID().hash64(), hash );
+ (uint32_t)OS::get_singleton()->get_unique_id().hash64(), hash );
*/
hash = hash_djb2_one_32(
(uint32_t)((uint64_t)this), hash); //rely on aslr heap
diff --git a/modules/gdnative/SCsub b/modules/gdnative/SCsub
index ac13319a1d..65970d48c1 100644
--- a/modules/gdnative/SCsub
+++ b/modules/gdnative/SCsub
@@ -6,9 +6,8 @@ env.add_source_files(env.modules_sources, "*.cpp")
env.add_source_files(env.modules_sources, "godot/*.cpp")
env.Append(CPPFLAGS=['-DGDAPI_BUILT_IN'])
+env.Append(CPPPATH=['#modules/gdnative/'])
if "platform" in env and env["platform"] == "x11": # there has to be a better solution?
env.Append(LINKFLAGS=["-rdynamic"])
env.use_ptrcall = True
-
-Export('env')
diff --git a/modules/gdnative/gdnative.cpp b/modules/gdnative/gdnative.cpp
index 158f7fd94d..07dba921b1 100644
--- a/modules/gdnative/gdnative.cpp
+++ b/modules/gdnative/gdnative.cpp
@@ -155,7 +155,6 @@ String GDNativeLibrary::get_active_library_path() const {
}
GDNative::GDNative() {
- initialized = false;
native_handle = NULL;
}
@@ -219,6 +218,9 @@ bool GDNative::initialize() {
library_init);
if (err || !library_init) {
+ OS::get_singleton()->close_dynamic_library(native_handle);
+ native_handle = NULL;
+ ERR_PRINT("Failed to obtain godot_gdnative_init symbol");
return false;
}
@@ -272,7 +274,11 @@ bool GDNative::terminate() {
OS::get_singleton()->close_dynamic_library(native_handle);
native_handle = NULL;
- return false;
+ return true;
+}
+
+bool GDNative::is_initialized() {
+ return (native_handle != NULL);
}
void GDNativeCallRegistry::register_native_call_type(StringName p_call_type, native_call_cb p_callback) {
diff --git a/modules/gdnative/gdnative.h b/modules/gdnative/gdnative.h
index dd845cab7a..b03866f432 100644
--- a/modules/gdnative/gdnative.h
+++ b/modules/gdnative/gdnative.h
@@ -35,7 +35,7 @@
#include "os/thread_safe.h"
#include "resource.h"
-#include "godot/gdnative.h"
+#include <godot/gdnative.h>
class GDNativeLibrary : public Resource {
GDCLASS(GDNativeLibrary, Resource)
@@ -117,7 +117,6 @@ class GDNative : public Reference {
GDCLASS(GDNative, Reference)
Ref<GDNativeLibrary> library;
- bool initialized;
// TODO(karroffel): different platforms? WASM????
void *native_handle;
diff --git a/modules/gdnative/godot/array.cpp b/modules/gdnative/godot/array.cpp
index c068eecf8f..97c73dc253 100644
--- a/modules/gdnative/godot/array.cpp
+++ b/modules/gdnative/godot/array.cpp
@@ -27,7 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "array.h"
+#include <godot/array.h>
#include "core/array.h"
#include "core/os/memory.h"
diff --git a/modules/gdnative/godot/array.h b/modules/gdnative/godot/array.h
index cbdbfbdde3..158170ba0e 100644
--- a/modules/gdnative/godot/array.h
+++ b/modules/gdnative/godot/array.h
@@ -46,10 +46,10 @@ typedef struct {
} godot_array;
#endif
-#include "pool_arrays.h"
-#include "variant.h"
+#include <godot/pool_arrays.h>
+#include <godot/variant.h>
-#include "gdnative.h"
+#include <godot/gdnative.h>
void GDAPI godot_array_new(godot_array *r_dest);
void GDAPI godot_array_new_copy(godot_array *r_dest, const godot_array *p_src);
diff --git a/modules/gdnative/godot/basis.cpp b/modules/gdnative/godot/basis.cpp
index 7188215d04..5cf379b7d5 100644
--- a/modules/gdnative/godot/basis.cpp
+++ b/modules/gdnative/godot/basis.cpp
@@ -27,10 +27,10 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "basis.h"
-#include "core/variant.h"
+#include <godot/basis.h>
#include "core/math/matrix3.h"
+#include "core/variant.h"
#ifdef __cplusplus
extern "C" {
diff --git a/modules/gdnative/godot/basis.h b/modules/gdnative/godot/basis.h
index 79b2b45fdd..e96b8b730d 100644
--- a/modules/gdnative/godot/basis.h
+++ b/modules/gdnative/godot/basis.h
@@ -45,9 +45,9 @@ typedef struct {
} godot_basis;
#endif
-#include "gdnative.h"
-#include "quat.h"
-#include "vector3.h"
+#include <godot/gdnative.h>
+#include <godot/quat.h>
+#include <godot/vector3.h>
void GDAPI godot_basis_new_with_rows(godot_basis *r_dest, const godot_vector3 *p_x_axis, const godot_vector3 *p_y_axis, const godot_vector3 *p_z_axis);
void GDAPI godot_basis_new_with_axis_and_angle(godot_basis *r_dest, const godot_vector3 *p_axis, const godot_real p_phi);
diff --git a/modules/gdnative/godot/color.cpp b/modules/gdnative/godot/color.cpp
index eac966ca1f..a5ffee1e0b 100644
--- a/modules/gdnative/godot/color.cpp
+++ b/modules/gdnative/godot/color.cpp
@@ -27,10 +27,10 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "color.h"
-#include "core/variant.h"
+#include <godot/color.h>
#include "core/color.h"
+#include "core/variant.h"
#ifdef __cplusplus
extern "C" {
diff --git a/modules/gdnative/godot/color.h b/modules/gdnative/godot/color.h
index 77e709fbe3..2cd6b48b48 100644
--- a/modules/gdnative/godot/color.h
+++ b/modules/gdnative/godot/color.h
@@ -45,8 +45,8 @@ typedef struct {
} godot_color;
#endif
-#include "gdnative.h"
-#include "string.h"
+#include <godot/gdnative.h>
+#include <godot/string.h>
void GDAPI godot_color_new_rgba(godot_color *r_dest, const godot_real p_r, const godot_real p_g, const godot_real p_b, const godot_real p_a);
void GDAPI godot_color_new_rgb(godot_color *r_dest, const godot_real p_r, const godot_real p_g, const godot_real p_b);
diff --git a/modules/gdnative/godot/dictionary.cpp b/modules/gdnative/godot/dictionary.cpp
index 1c0761edfd..b92c8125bb 100644
--- a/modules/gdnative/godot/dictionary.cpp
+++ b/modules/gdnative/godot/dictionary.cpp
@@ -27,7 +27,8 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "dictionary.h"
+#include <godot/dictionary.h>
+
#include "core/variant.h"
#include "core/dictionary.h"
diff --git a/modules/gdnative/godot/dictionary.h b/modules/gdnative/godot/dictionary.h
index a08deb27df..594b02b4dd 100644
--- a/modules/gdnative/godot/dictionary.h
+++ b/modules/gdnative/godot/dictionary.h
@@ -45,9 +45,9 @@ typedef struct {
} godot_dictionary;
#endif
-#include "array.h"
-#include "gdnative.h"
-#include "variant.h"
+#include <godot/array.h>
+#include <godot/gdnative.h>
+#include <godot/variant.h>
void GDAPI godot_dictionary_new(godot_dictionary *r_dest);
void GDAPI godot_dictionary_new_copy(godot_dictionary *r_dest, const godot_dictionary *p_src);
diff --git a/modules/gdnative/godot/gdnative.cpp b/modules/gdnative/godot/gdnative.cpp
index 29b499ebab..4cda1f4560 100644
--- a/modules/gdnative/godot/gdnative.cpp
+++ b/modules/gdnative/godot/gdnative.cpp
@@ -27,7 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "gdnative.h"
+#include <godot/gdnative.h>
#include "class_db.h"
#include "error_macros.h"
diff --git a/modules/gdnative/godot/gdnative.h b/modules/gdnative/godot/gdnative.h
index b0343272ef..d849999079 100644
--- a/modules/gdnative/godot/gdnative.h
+++ b/modules/gdnative/godot/gdnative.h
@@ -174,72 +174,72 @@ typedef struct godot_pool_color_array godot_pool_color_array;
*/
/////// String
-#include "string.h"
+#include <godot/string.h>
////// Vector2
-#include "vector2.h"
+#include <godot/vector2.h>
////// Rect2
-#include "rect2.h"
+#include <godot/rect2.h>
////// Vector3
-#include "vector3.h"
+#include <godot/vector3.h>
////// Transform2D
-#include "transform2d.h"
+#include <godot/transform2d.h>
/////// Plane
-#include "plane.h"
+#include <godot/plane.h>
/////// Quat
-#include "quat.h"
+#include <godot/quat.h>
/////// Rect3
-#include "rect3.h"
+#include <godot/rect3.h>
/////// Basis
-#include "basis.h"
+#include <godot/basis.h>
/////// Transform
-#include "transform.h"
+#include <godot/transform.h>
/////// Color
-#include "color.h"
+#include <godot/color.h>
/////// NodePath
-#include "node_path.h"
+#include <godot/node_path.h>
/////// RID
-#include "rid.h"
+#include <godot/rid.h>
/////// Dictionary
-#include "dictionary.h"
+#include <godot/dictionary.h>
/////// Array
-#include "array.h"
+#include <godot/array.h>
// single API file for Pool*Array
-#include "pool_arrays.h"
+#include <godot/pool_arrays.h>
void GDAPI godot_object_destroy(godot_object *p_o);
////// Variant
-#include "variant.h"
+#include <godot/variant.h>
////// Singleton API
diff --git a/modules/gdnative/godot/node_path.cpp b/modules/gdnative/godot/node_path.cpp
index a9edbc8352..f4179361be 100644
--- a/modules/gdnative/godot/node_path.cpp
+++ b/modules/gdnative/godot/node_path.cpp
@@ -27,10 +27,10 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "node_path.h"
-#include "core/variant.h"
+#include <godot/node_path.h>
-#include "core/path_db.h"
+#include "core/node_path.h"
+#include "core/variant.h"
#ifdef __cplusplus
extern "C" {
diff --git a/modules/gdnative/godot/node_path.h b/modules/gdnative/godot/node_path.h
index 06955a052e..4d3dc4e0ee 100644
--- a/modules/gdnative/godot/node_path.h
+++ b/modules/gdnative/godot/node_path.h
@@ -45,8 +45,8 @@ typedef struct {
} godot_node_path;
#endif
-#include "gdnative.h"
-#include "string.h"
+#include <godot/gdnative.h>
+#include <godot/string.h>
void GDAPI godot_node_path_new(godot_node_path *r_dest, const godot_string *p_from);
void GDAPI godot_node_path_new_copy(godot_node_path *r_dest, const godot_node_path *p_src);
diff --git a/modules/gdnative/godot/plane.cpp b/modules/gdnative/godot/plane.cpp
index e9e659e5da..5c5b302345 100644
--- a/modules/gdnative/godot/plane.cpp
+++ b/modules/gdnative/godot/plane.cpp
@@ -27,10 +27,10 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "plane.h"
-#include "core/variant.h"
+#include <godot/plane.h>
#include "core/math/plane.h"
+#include "core/variant.h"
#ifdef __cplusplus
extern "C" {
diff --git a/modules/gdnative/godot/plane.h b/modules/gdnative/godot/plane.h
index e9e3b71e03..8519ac60c4 100644
--- a/modules/gdnative/godot/plane.h
+++ b/modules/gdnative/godot/plane.h
@@ -45,8 +45,8 @@ typedef struct {
} godot_plane;
#endif
-#include "gdnative.h"
-#include "vector3.h"
+#include <godot/gdnative.h>
+#include <godot/vector3.h>
void GDAPI godot_plane_new_with_reals(godot_plane *r_dest, const godot_real p_a, const godot_real p_b, const godot_real p_c, const godot_real p_d);
void GDAPI godot_plane_new_with_vectors(godot_plane *r_dest, const godot_vector3 *p_v1, const godot_vector3 *p_v2, const godot_vector3 *p_v3);
diff --git a/modules/gdnative/godot/pool_arrays.cpp b/modules/gdnative/godot/pool_arrays.cpp
index 6a6ee0f126..fa460be8bc 100644
--- a/modules/gdnative/godot/pool_arrays.cpp
+++ b/modules/gdnative/godot/pool_arrays.cpp
@@ -27,7 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "pool_arrays.h"
+#include <godot/pool_arrays.h>
#include "array.h"
#include "core/variant.h"
diff --git a/modules/gdnative/godot/pool_arrays.h b/modules/gdnative/godot/pool_arrays.h
index 1e2916cea9..29517d21ac 100644
--- a/modules/gdnative/godot/pool_arrays.h
+++ b/modules/gdnative/godot/pool_arrays.h
@@ -113,12 +113,12 @@ typedef struct {
} godot_pool_color_array;
#endif
-#include "array.h"
-#include "color.h"
-#include "vector2.h"
-#include "vector3.h"
+#include <godot/array.h>
+#include <godot/color.h>
+#include <godot/vector2.h>
+#include <godot/vector3.h>
-#include "gdnative.h"
+#include <godot/gdnative.h>
// byte
diff --git a/modules/gdnative/godot/quat.cpp b/modules/gdnative/godot/quat.cpp
index 6800f7fc7e..37ee4d6b15 100644
--- a/modules/gdnative/godot/quat.cpp
+++ b/modules/gdnative/godot/quat.cpp
@@ -27,10 +27,10 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "quat.h"
-#include "core/variant.h"
+#include <godot/quat.h>
#include "core/math/quat.h"
+#include "core/variant.h"
#ifdef __cplusplus
extern "C" {
diff --git a/modules/gdnative/godot/quat.h b/modules/gdnative/godot/quat.h
index b86cbacc62..0979653d93 100644
--- a/modules/gdnative/godot/quat.h
+++ b/modules/gdnative/godot/quat.h
@@ -45,8 +45,8 @@ typedef struct {
} godot_quat;
#endif
-#include "gdnative.h"
-#include "vector3.h"
+#include <godot/gdnative.h>
+#include <godot/vector3.h>
void GDAPI godot_quat_new(godot_quat *r_dest, const godot_real p_x, const godot_real p_y, const godot_real p_z, const godot_real p_w);
void GDAPI godot_quat_new_with_axis_angle(godot_quat *r_dest, const godot_vector3 *p_axis, const godot_real p_angle);
diff --git a/modules/gdnative/godot/rect2.cpp b/modules/gdnative/godot/rect2.cpp
index 830d7bb496..023584c4f6 100644
--- a/modules/gdnative/godot/rect2.cpp
+++ b/modules/gdnative/godot/rect2.cpp
@@ -27,10 +27,10 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "rect2.h"
-#include "core/variant.h"
+#include <godot/rect2.h>
#include "core/math/math_2d.h"
+#include "core/variant.h"
#ifdef __cplusplus
extern "C" {
diff --git a/modules/gdnative/godot/rect2.h b/modules/gdnative/godot/rect2.h
index 7b6613d9dd..cb1ddb58cf 100644
--- a/modules/gdnative/godot/rect2.h
+++ b/modules/gdnative/godot/rect2.h
@@ -43,8 +43,8 @@ typedef struct godot_rect2 {
} godot_rect2;
#endif
-#include "gdnative.h"
-#include "vector2.h"
+#include <godot/gdnative.h>
+#include <godot/vector2.h>
void GDAPI godot_rect2_new_with_position_and_size(godot_rect2 *r_dest, const godot_vector2 *p_pos, const godot_vector2 *p_size);
void GDAPI godot_rect2_new(godot_rect2 *r_dest, const godot_real p_x, const godot_real p_y, const godot_real p_width, const godot_real p_height);
diff --git a/modules/gdnative/godot/rect3.cpp b/modules/gdnative/godot/rect3.cpp
index 0fabba5b7b..708d2987f2 100644
--- a/modules/gdnative/godot/rect3.cpp
+++ b/modules/gdnative/godot/rect3.cpp
@@ -27,10 +27,10 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "rect3.h"
-#include "core/variant.h"
+#include <godot/rect3.h>
#include "core/math/rect3.h"
+#include "core/variant.h"
#ifdef __cplusplus
extern "C" {
diff --git a/modules/gdnative/godot/rect3.h b/modules/gdnative/godot/rect3.h
index 638d89f76f..69279351c4 100644
--- a/modules/gdnative/godot/rect3.h
+++ b/modules/gdnative/godot/rect3.h
@@ -45,9 +45,9 @@ typedef struct {
} godot_rect3;
#endif
-#include "gdnative.h"
-#include "plane.h"
-#include "vector3.h"
+#include <godot/gdnative.h>
+#include <godot/plane.h>
+#include <godot/vector3.h>
void GDAPI godot_rect3_new(godot_rect3 *r_dest, const godot_vector3 *p_pos, const godot_vector3 *p_size);
diff --git a/modules/gdnative/godot/rid.cpp b/modules/gdnative/godot/rid.cpp
index 2b724e554d..eb9538e692 100644
--- a/modules/gdnative/godot/rid.cpp
+++ b/modules/gdnative/godot/rid.cpp
@@ -27,11 +27,11 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "rid.h"
-#include "core/variant.h"
+#include <godot/rid.h>
#include "core/resource.h"
#include "core/rid.h"
+#include "core/variant.h"
#ifdef __cplusplus
extern "C" {
diff --git a/modules/gdnative/godot/rid.h b/modules/gdnative/godot/rid.h
index 92e101fd2e..ac5b5383d9 100644
--- a/modules/gdnative/godot/rid.h
+++ b/modules/gdnative/godot/rid.h
@@ -45,7 +45,7 @@ typedef struct {
} godot_rid;
#endif
-#include "gdnative.h"
+#include <godot/gdnative.h>
void GDAPI godot_rid_new(godot_rid *r_dest);
diff --git a/modules/gdnative/godot/string.cpp b/modules/gdnative/godot/string.cpp
index e54ef3655f..3573f266ac 100644
--- a/modules/gdnative/godot/string.cpp
+++ b/modules/gdnative/godot/string.cpp
@@ -27,7 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "string.h"
+#include <godot/string.h>
#include "string_db.h"
#include "ustring.h"
diff --git a/modules/gdnative/godot/string.h b/modules/gdnative/godot/string.h
index d4d6d6c1d0..9013326454 100644
--- a/modules/gdnative/godot/string.h
+++ b/modules/gdnative/godot/string.h
@@ -46,7 +46,7 @@ typedef struct {
} godot_string;
#endif
-#include "gdnative.h"
+#include <godot/gdnative.h>
void GDAPI godot_string_new(godot_string *r_dest);
void GDAPI godot_string_new_copy(godot_string *r_dest, const godot_string *p_src);
diff --git a/modules/gdnative/godot/transform.cpp b/modules/gdnative/godot/transform.cpp
index e566ed0b6e..87fee918bd 100644
--- a/modules/gdnative/godot/transform.cpp
+++ b/modules/gdnative/godot/transform.cpp
@@ -27,10 +27,10 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "transform.h"
-#include "core/variant.h"
+#include <godot/transform.h>
#include "core/math/transform.h"
+#include "core/variant.h"
#ifdef __cplusplus
extern "C" {
diff --git a/modules/gdnative/godot/transform.h b/modules/gdnative/godot/transform.h
index d14190ec49..30b9970f67 100644
--- a/modules/gdnative/godot/transform.h
+++ b/modules/gdnative/godot/transform.h
@@ -45,10 +45,10 @@ typedef struct {
} godot_transform;
#endif
-#include "basis.h"
-#include "gdnative.h"
-#include "variant.h"
-#include "vector3.h"
+#include <godot/basis.h>
+#include <godot/gdnative.h>
+#include <godot/variant.h>
+#include <godot/vector3.h>
void GDAPI godot_transform_new_with_axis_origin(godot_transform *r_dest, const godot_vector3 *p_x_axis, const godot_vector3 *p_y_axis, const godot_vector3 *p_z_axis, const godot_vector3 *p_origin);
void GDAPI godot_transform_new(godot_transform *r_dest, const godot_basis *p_basis, const godot_vector3 *p_origin);
diff --git a/modules/gdnative/godot/transform2d.cpp b/modules/gdnative/godot/transform2d.cpp
index 01db3f7ae0..65f9f8ee32 100644
--- a/modules/gdnative/godot/transform2d.cpp
+++ b/modules/gdnative/godot/transform2d.cpp
@@ -27,10 +27,10 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "transform2d.h"
-#include "core/variant.h"
+#include <godot/transform2d.h>
#include "core/math/math_2d.h"
+#include "core/variant.h"
#ifdef __cplusplus
extern "C" {
diff --git a/modules/gdnative/godot/transform2d.h b/modules/gdnative/godot/transform2d.h
index 7171e528f2..41c8ba982c 100644
--- a/modules/gdnative/godot/transform2d.h
+++ b/modules/gdnative/godot/transform2d.h
@@ -45,9 +45,9 @@ typedef struct {
} godot_transform2d;
#endif
-#include "gdnative.h"
-#include "variant.h"
-#include "vector2.h"
+#include <godot/gdnative.h>
+#include <godot/variant.h>
+#include <godot/vector2.h>
void GDAPI godot_transform2d_new(godot_transform2d *r_dest, const godot_real p_rot, const godot_vector2 *p_pos);
void GDAPI godot_transform2d_new_axis_origin(godot_transform2d *r_dest, const godot_vector2 *p_x_axis, const godot_vector2 *p_y_axis, const godot_vector2 *p_origin);
diff --git a/modules/gdnative/godot/variant.cpp b/modules/gdnative/godot/variant.cpp
index 3469058cfd..d814ef913c 100644
--- a/modules/gdnative/godot/variant.cpp
+++ b/modules/gdnative/godot/variant.cpp
@@ -27,7 +27,8 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "variant.h"
+#include <godot/variant.h>
+
#include "core/variant.h"
#ifdef __cplusplus
@@ -432,7 +433,6 @@ godot_variant GDAPI godot_variant_call(godot_variant *p_self, const godot_string
Variant *dest = (Variant *)&raw_dest;
Variant::CallError error;
memnew_placement_custom(dest, Variant, Variant(self->call(*method, args, p_argcount, error)));
- *dest = self->call(StringName(*method), args, p_argcount, r_error);
if (r_error) {
r_error->error = (godot_variant_call_error_error)error.error;
r_error->argument = error.argument;
diff --git a/modules/gdnative/godot/variant.h b/modules/gdnative/godot/variant.h
index b56d5824fa..1c19d2a25b 100644
--- a/modules/gdnative/godot/variant.h
+++ b/modules/gdnative/godot/variant.h
@@ -99,25 +99,25 @@ typedef struct godot_variant_call_error {
godot_variant_type expected;
} godot_variant_call_error;
-#include "array.h"
-#include "basis.h"
-#include "color.h"
-#include "dictionary.h"
-#include "node_path.h"
-#include "plane.h"
-#include "pool_arrays.h"
-#include "quat.h"
-#include "rect2.h"
-#include "rect3.h"
-#include "rid.h"
-#include "string.h"
-#include "transform.h"
-#include "transform2d.h"
-#include "variant.h"
-#include "vector2.h"
-#include "vector3.h"
-
-#include "gdnative.h"
+#include <godot/array.h>
+#include <godot/basis.h>
+#include <godot/color.h>
+#include <godot/dictionary.h>
+#include <godot/node_path.h>
+#include <godot/plane.h>
+#include <godot/pool_arrays.h>
+#include <godot/quat.h>
+#include <godot/rect2.h>
+#include <godot/rect3.h>
+#include <godot/rid.h>
+#include <godot/string.h>
+#include <godot/transform.h>
+#include <godot/transform2d.h>
+#include <godot/variant.h>
+#include <godot/vector2.h>
+#include <godot/vector3.h>
+
+#include <godot/gdnative.h>
godot_variant_type GDAPI godot_variant_get_type(const godot_variant *p_v);
diff --git a/modules/gdnative/godot/vector2.cpp b/modules/gdnative/godot/vector2.cpp
index 6b40e31a89..05d4b1acc8 100644
--- a/modules/gdnative/godot/vector2.cpp
+++ b/modules/gdnative/godot/vector2.cpp
@@ -27,10 +27,10 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "vector2.h"
-#include "core/variant.h"
+#include <godot/vector2.h>
#include "core/math/math_2d.h"
+#include "core/variant.h"
#ifdef __cplusplus
extern "C" {
diff --git a/modules/gdnative/godot/vector2.h b/modules/gdnative/godot/vector2.h
index 9934ddadbb..9db238b4fd 100644
--- a/modules/gdnative/godot/vector2.h
+++ b/modules/gdnative/godot/vector2.h
@@ -45,7 +45,7 @@ typedef struct {
} godot_vector2;
#endif
-#include "gdnative.h"
+#include <godot/gdnative.h>
void GDAPI godot_vector2_new(godot_vector2 *r_dest, const godot_real p_x, const godot_real p_y);
diff --git a/modules/gdnative/godot/vector3.cpp b/modules/gdnative/godot/vector3.cpp
index 904cdad9d0..fe27e740e2 100644
--- a/modules/gdnative/godot/vector3.cpp
+++ b/modules/gdnative/godot/vector3.cpp
@@ -27,9 +27,9 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "vector3.h"
-#include "core/variant.h"
+#include <godot/vector3.h>
+#include "core/variant.h"
#include "core/vector.h"
#ifdef __cplusplus
diff --git a/modules/gdnative/godot/vector3.h b/modules/gdnative/godot/vector3.h
index b5f8d0f49a..8aba1d9a85 100644
--- a/modules/gdnative/godot/vector3.h
+++ b/modules/gdnative/godot/vector3.h
@@ -45,8 +45,8 @@ typedef struct {
} godot_vector3;
#endif
-#include "basis.h"
-#include "gdnative.h"
+#include <godot/basis.h>
+#include <godot/gdnative.h>
typedef enum {
GODOT_VECTOR3_AXIS_X,
diff --git a/modules/gdnative/register_types.cpp b/modules/gdnative/register_types.cpp
index d180d5aada..da50104e26 100644
--- a/modules/gdnative/register_types.cpp
+++ b/modules/gdnative/register_types.cpp
@@ -76,4 +76,26 @@ void register_gdnative_types() {
void unregister_gdnative_types() {
memdelete(GDNativeCallRegistry::singleton);
+
+ // This is for printing out the sizes of the core types
+
+ /*
+ print_line(String("array:\t") + itos(sizeof(Array)));
+ print_line(String("basis:\t") + itos(sizeof(Basis)));
+ print_line(String("color:\t") + itos(sizeof(Color)));
+ print_line(String("dict:\t" ) + itos(sizeof(Dictionary)));
+ print_line(String("node_path:\t") + itos(sizeof(NodePath)));
+ print_line(String("plane:\t") + itos(sizeof(Plane)));
+ print_line(String("poolarray:\t") + itos(sizeof(PoolByteArray)));
+ print_line(String("quat:\t") + itos(sizeof(Quat)));
+ print_line(String("rect2:\t") + itos(sizeof(Rect2)));
+ print_line(String("rect3:\t") + itos(sizeof(Rect3)));
+ print_line(String("rid:\t") + itos(sizeof(RID)));
+ print_line(String("string:\t") + itos(sizeof(String)));
+ print_line(String("transform:\t") + itos(sizeof(Transform)));
+ print_line(String("transfo2D:\t") + itos(sizeof(Transform2D)));
+ print_line(String("variant:\t") + itos(sizeof(Variant)));
+ print_line(String("vector2:\t") + itos(sizeof(Vector2)));
+ print_line(String("vector3:\t") + itos(sizeof(Vector3)));
+ */
}
diff --git a/modules/gdscript/gd_editor.cpp b/modules/gdscript/gd_editor.cpp
index c88889767c..f8b45af85a 100644
--- a/modules/gdscript/gd_editor.cpp
+++ b/modules/gdscript/gd_editor.cpp
@@ -157,7 +157,7 @@ Script *GDScriptLanguage::create_script() const {
bool GDScriptLanguage::debug_break_parse(const String &p_file, int p_line, const String &p_error) {
//break because of parse error
- if (ScriptDebugger::get_singleton() && Thread::get_caller_ID() == Thread::get_main_ID()) {
+ if (ScriptDebugger::get_singleton() && Thread::get_caller_id() == Thread::get_main_id()) {
_debug_parse_err_line = p_line;
_debug_parse_err_file = p_file;
@@ -171,7 +171,7 @@ bool GDScriptLanguage::debug_break_parse(const String &p_file, int p_line, const
bool GDScriptLanguage::debug_break(const String &p_error, bool p_allow_continue) {
- if (ScriptDebugger::get_singleton() && Thread::get_caller_ID() == Thread::get_main_ID()) {
+ if (ScriptDebugger::get_singleton() && Thread::get_caller_id() == Thread::get_main_id()) {
_debug_parse_err_line = -1;
_debug_parse_err_file = "";
diff --git a/modules/gdscript/gd_function.cpp b/modules/gdscript/gd_function.cpp
index 795371af60..4f8fbd6b46 100644
--- a/modules/gdscript/gd_function.cpp
+++ b/modules/gdscript/gd_function.cpp
@@ -888,8 +888,8 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a
gdfs->state._class = _class;
gdfs->state.ip = ip + ipofs;
gdfs->state.line = line;
- gdfs->state.instance_id = (p_instance && p_instance->get_owner()) ? p_instance->get_owner()->get_instance_ID() : 0;
- gdfs->state.script_id = _class->get_instance_ID();
+ gdfs->state.instance_id = (p_instance && p_instance->get_owner()) ? p_instance->get_owner()->get_instance_id() : 0;
+ gdfs->state.script_id = _class->get_instance_id();
//gdfs->state.result_pos=ip+ipofs-1;
gdfs->state.defarg = defarg;
gdfs->state.instance = p_instance;
diff --git a/modules/gdscript/gd_script.cpp b/modules/gdscript/gd_script.cpp
index fe87433a89..9d304c6d34 100644
--- a/modules/gdscript/gd_script.cpp
+++ b/modules/gdscript/gd_script.cpp
@@ -479,7 +479,7 @@ bool GDScript::_update_exports() {
const GDParser::ClassNode *c = static_cast<const GDParser::ClassNode *>(root);
if (base_cache.is_valid()) {
- base_cache->inheriters_cache.erase(get_instance_ID());
+ base_cache->inheriters_cache.erase(get_instance_id());
base_cache = Ref<GDScript>();
}
@@ -505,7 +505,7 @@ bool GDScript::_update_exports() {
//print_line("parent is: "+bf->get_path());
base_cache = bf;
- bf->inheriters_cache.insert(get_instance_ID());
+ bf->inheriters_cache.insert(get_instance_id());
//bf->_update_exports(p_instances,true,false);
}
@@ -1693,7 +1693,7 @@ void GDScriptLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_so
if (obj->get_script_instance()) {
obj->get_script_instance()->get_property_state(state);
- map[obj->get_instance_ID()] = state;
+ map[obj->get_instance_id()] = state;
obj->set_script(RefPtr());
}
}
@@ -1709,7 +1709,7 @@ void GDScriptLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_so
if (obj->get_script_instance()) {
obj->get_script_instance()->get_property_state(state);
- map[obj->get_instance_ID()] = state;
+ map[obj->get_instance_id()] = state;
obj->set_script(RefPtr());
} else {
// no instance found. Let's remove it so we don't loop forever
@@ -1743,8 +1743,8 @@ void GDScriptLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_so
obj->set_script(scr.get_ref_ptr());
if (!obj->get_script_instance()) {
//failed, save reload state for next time if not saved
- if (!scr->pending_reload_state.has(obj->get_instance_ID())) {
- scr->pending_reload_state[obj->get_instance_ID()] = F->get();
+ if (!scr->pending_reload_state.has(obj->get_instance_id())) {
+ scr->pending_reload_state[obj->get_instance_id()] = F->get();
}
continue;
}
@@ -1753,7 +1753,7 @@ void GDScriptLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_so
obj->get_script_instance()->set(G->get().first, G->get().second);
}
- scr->pending_reload_state.erase(obj->get_instance_ID()); //as it reloaded, remove pending state
+ scr->pending_reload_state.erase(obj->get_instance_id()); //as it reloaded, remove pending state
}
//if instance states were saved, set them!
diff --git a/modules/gdscript/gd_script.h b/modules/gdscript/gd_script.h
index 0add348ca9..17e7b0bc03 100644
--- a/modules/gdscript/gd_script.h
+++ b/modules/gdscript/gd_script.h
@@ -298,7 +298,7 @@ public:
_FORCE_INLINE_ void enter_function(GDInstance *p_instance, GDFunction *p_function, Variant *p_stack, int *p_ip, int *p_line) {
- if (Thread::get_main_ID() != Thread::get_caller_ID())
+ if (Thread::get_main_id() != Thread::get_caller_id())
return; //no support for other threads than main for now
if (ScriptDebugger::get_singleton()->get_lines_left() > 0 && ScriptDebugger::get_singleton()->get_depth() >= 0)
@@ -321,7 +321,7 @@ public:
_FORCE_INLINE_ void exit_function() {
- if (Thread::get_main_ID() != Thread::get_caller_ID())
+ if (Thread::get_main_id() != Thread::get_caller_id())
return; //no support for other threads than main for now
if (ScriptDebugger::get_singleton()->get_lines_left() > 0 && ScriptDebugger::get_singleton()->get_depth() >= 0)
@@ -338,7 +338,7 @@ public:
}
virtual Vector<StackInfo> debug_get_current_stack_info() {
- if (Thread::get_main_ID() != Thread::get_caller_ID())
+ if (Thread::get_main_id() != Thread::get_caller_id())
return Vector<StackInfo>();
Vector<StackInfo> csi;
diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cpp
index 8c2c2ea345..02e62ba3ee 100644
--- a/modules/gridmap/grid_map.cpp
+++ b/modules/gridmap/grid_map.cpp
@@ -345,7 +345,7 @@ void GridMap::set_cell_item(int p_x, int p_y, int p_z, int p_item, int p_rot) {
Octant *g = memnew(Octant);
g->dirty = true;
g->static_body = PhysicsServer::get_singleton()->body_create(PhysicsServer::BODY_MODE_STATIC);
- PhysicsServer::get_singleton()->body_attach_object_instance_ID(g->static_body, get_instance_ID());
+ PhysicsServer::get_singleton()->body_attach_object_instance_id(g->static_body, get_instance_id());
if (is_inside_world())
PhysicsServer::get_singleton()->body_set_space(g->static_body, get_world()->get_space());
diff --git a/modules/nativescript/nativescript.cpp b/modules/nativescript/nativescript.cpp
index e7445e6da9..f00917bcea 100644
--- a/modules/nativescript/nativescript.cpp
+++ b/modules/nativescript/nativescript.cpp
@@ -113,7 +113,7 @@ void NativeScript::set_library(Ref<GDNativeLibrary> p_library) {
lib_path = library->get_active_library_path();
#ifndef NO_THREADS
- if (Thread::get_caller_ID() != Thread::get_main_ID()) {
+ if (Thread::get_caller_id() != Thread::get_main_id()) {
NSL->defer_init_library(p_library, this);
} else
#endif
@@ -213,11 +213,6 @@ ScriptInstance *NativeScript::instance_create(Object *p_this) {
owners_lock->unlock();
#endif
- // try to call _init
- // we don't care if it doesn't exist, so we ignore errors.
- Variant::CallError err;
- call("_init", NULL, 0, err);
-
return nsi;
}
@@ -1057,9 +1052,23 @@ void NativeScriptLanguage::unregister_script(NativeScript *script) {
#endif
}
-#ifndef NO_THREADS
+void NativeScriptLanguage::call_libraries_cb(const StringName &name) {
+ // library_gdnatives is modified only from the main thread, so it's safe not to use mutex here
+ for (Map<String, Ref<GDNative> >::Element *L = library_gdnatives.front(); L; L = L->next()) {
+ if (L->get()->is_initialized()) {
+ L->get()->call_native_raw(
+ _noarg_call_type,
+ name,
+ NULL,
+ 0,
+ NULL,
+ NULL);
+ }
+ }
+}
void NativeScriptLanguage::frame() {
+#ifndef NO_THREADS
if (has_objects_to_register) {
MutexLock lock(mutex);
for (Set<Ref<GDNativeLibrary> >::Element *L = libs_to_init.front(); L; L = L->next()) {
@@ -1072,44 +1081,18 @@ void NativeScriptLanguage::frame() {
scripts_to_register.clear();
has_objects_to_register = false;
}
+#endif
+ call_libraries_cb(_frame_call_name);
}
+#ifndef NO_THREADS
+
void NativeScriptLanguage::thread_enter() {
- Vector<Ref<GDNative> > libs;
- {
- MutexLock lock(mutex);
- for (Map<String, Ref<GDNative> >::Element *L = library_gdnatives.front(); L; L = L->next()) {
- libs.push_back(L->get());
- }
- }
- for (int i = 0; i < libs.size(); ++i) {
- libs[i]->call_native_raw(
- _thread_cb_call_type,
- _thread_enter_call_name,
- NULL,
- 0,
- NULL,
- NULL);
- }
+ call_libraries_cb(_thread_enter_call_name);
}
void NativeScriptLanguage::thread_exit() {
- Vector<Ref<GDNative> > libs;
- {
- MutexLock lock(mutex);
- for (Map<String, Ref<GDNative> >::Element *L = library_gdnatives.front(); L; L = L->next()) {
- libs.push_back(L->get());
- }
- }
- for (int i = 0; i < libs.size(); ++i) {
- libs[i]->call_native_raw(
- _thread_cb_call_type,
- _thread_exit_call_name,
- NULL,
- 0,
- NULL,
- NULL);
- }
+ call_libraries_cb(_thread_exit_call_name);
}
#endif // NO_THREADS
diff --git a/modules/nativescript/nativescript.h b/modules/nativescript/nativescript.h
index 95b4954171..c60effd0c1 100644
--- a/modules/nativescript/nativescript.h
+++ b/modules/nativescript/nativescript.h
@@ -220,7 +220,10 @@ private:
void register_script(NativeScript *script);
void unregister_script(NativeScript *script);
+ void call_libraries_cb(const StringName &name);
+
public:
+ // These two maps must only be touched on the main thread
Map<String, Map<StringName, NativeScriptDesc> > library_classes;
Map<String, Ref<GDNative> > library_gdnatives;
@@ -229,9 +232,14 @@ public:
const StringName _init_call_type = "nativescript_init";
const StringName _init_call_name = "godot_nativescript_init";
- const StringName _thread_cb_call_type = "godot_nativescript_thread_cb";
+ const StringName _noarg_call_type = "nativescript_no_arg";
+
+ const StringName _frame_call_name = "godot_nativescript_frame";
+
+#ifndef NO_THREADS
const StringName _thread_enter_call_name = "godot_nativescript_thread_enter";
const StringName _thread_exit_call_name = "godot_nativescript_thread_exit";
+#endif
NativeScriptLanguage();
~NativeScriptLanguage();
@@ -245,9 +253,9 @@ public:
#ifndef NO_THREADS
virtual void thread_enter();
virtual void thread_exit();
+#endif
virtual void frame();
-#endif
virtual String get_name() const;
virtual void init();
diff --git a/modules/nativescript/register_types.cpp b/modules/nativescript/register_types.cpp
index dfa16d8a2a..c28b982884 100644
--- a/modules/nativescript/register_types.cpp
+++ b/modules/nativescript/register_types.cpp
@@ -62,13 +62,11 @@ void init_call_cb(void *p_handle, godot_string *p_proc_name, void *p_data, int p
fn(args[0]);
}
-#ifndef NO_THREADS
-
typedef void (*native_script_empty_callback)();
-void thread_call_cb(void *p_handle, godot_string *p_proc_name, void *p_data, int p_num_args, void **args, void *r_ret) {
+void noarg_call_cb(void *p_handle, godot_string *p_proc_name, void *p_data, int p_num_args, void **args, void *r_ret) {
if (p_handle == NULL) {
- ERR_PRINT("No valid library handle, can't call nativescript thread enter/exit callback");
+ ERR_PRINT("No valid library handle, can't call nativescript callback");
return;
}
@@ -87,8 +85,6 @@ void thread_call_cb(void *p_handle, godot_string *p_proc_name, void *p_data, int
fn();
}
-#endif // NO_THREADS
-
ResourceFormatLoaderNativeScript *resource_loader_gdns = NULL;
ResourceFormatSaverNativeScript *resource_saver_gdns = NULL;
@@ -100,9 +96,7 @@ void register_nativescript_types() {
ScriptServer::register_language(native_script_language);
GDNativeCallRegistry::singleton->register_native_raw_call_type(native_script_language->_init_call_type, init_call_cb);
-#ifndef NO_THREADS
- GDNativeCallRegistry::singleton->register_native_raw_call_type(native_script_language->_thread_cb_call_type, thread_call_cb);
-#endif
+ GDNativeCallRegistry::singleton->register_native_raw_call_type(native_script_language->_noarg_call_type, noarg_call_cb);
resource_saver_gdns = memnew(ResourceFormatSaverNativeScript);
ResourceSaver::add_resource_format_saver(resource_saver_gdns);
diff --git a/modules/visual_script/visual_script.cpp b/modules/visual_script/visual_script.cpp
index f15abec7e2..376329715b 100644
--- a/modules/visual_script/visual_script.cpp
+++ b/modules/visual_script/visual_script.cpp
@@ -1607,8 +1607,8 @@ Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p
}
//step 1, capture all state
- state->instance_id = get_owner_ptr()->get_instance_ID();
- state->script_id = get_script()->get_instance_ID();
+ state->instance_id = get_owner_ptr()->get_instance_id();
+ state->script_id = get_script()->get_instance_id();
state->instance = this;
state->function = p_method;
state->working_mem_index = node->working_mem_idx;
@@ -2417,7 +2417,7 @@ void VisualScriptLanguage::add_global_constant(const StringName &p_variable, con
bool VisualScriptLanguage::debug_break_parse(const String &p_file, int p_node, const String &p_error) {
//break because of parse error
- if (ScriptDebugger::get_singleton() && Thread::get_caller_ID() == Thread::get_main_ID()) {
+ if (ScriptDebugger::get_singleton() && Thread::get_caller_id() == Thread::get_main_id()) {
_debug_parse_err_node = p_node;
_debug_parse_err_file = p_file;
@@ -2431,7 +2431,7 @@ bool VisualScriptLanguage::debug_break_parse(const String &p_file, int p_node, c
bool VisualScriptLanguage::debug_break(const String &p_error, bool p_allow_continue) {
- if (ScriptDebugger::get_singleton() && Thread::get_caller_ID() == Thread::get_main_ID()) {
+ if (ScriptDebugger::get_singleton() && Thread::get_caller_id() == Thread::get_main_id()) {
_debug_parse_err_node = -1;
_debug_parse_err_file = "";
diff --git a/modules/visual_script/visual_script.h b/modules/visual_script/visual_script.h
index cdd7eded18..63ac5769c6 100644
--- a/modules/visual_script/visual_script.h
+++ b/modules/visual_script/visual_script.h
@@ -509,7 +509,7 @@ public:
_FORCE_INLINE_ void enter_function(VisualScriptInstance *p_instance, const StringName *p_function, Variant *p_stack, Variant **p_work_mem, int *current_id) {
- if (Thread::get_main_ID() != Thread::get_caller_ID())
+ if (Thread::get_main_id() != Thread::get_caller_id())
return; //no support for other threads than main for now
if (ScriptDebugger::get_singleton()->get_lines_left() > 0 && ScriptDebugger::get_singleton()->get_depth() >= 0)
@@ -532,7 +532,7 @@ public:
_FORCE_INLINE_ void exit_function() {
- if (Thread::get_main_ID() != Thread::get_caller_ID())
+ if (Thread::get_main_id() != Thread::get_caller_id())
return; //no support for other threads than main for now
if (ScriptDebugger::get_singleton()->get_lines_left() > 0 && ScriptDebugger::get_singleton()->get_depth() >= 0)
diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp
index 35358d5a1f..a71d38f7a0 100644
--- a/modules/visual_script/visual_script_editor.cpp
+++ b/modules/visual_script/visual_script_editor.cpp
@@ -615,7 +615,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
Ref<Resource> res = value;
Array arr;
- arr.push_back(button->get_instance_ID());
+ arr.push_back(button->get_instance_id());
arr.push_back(String(value));
EditorResourcePreview::get_singleton()->queue_edited_resource_preview(res, this, "_button_resource_previewed", arr);
@@ -1969,7 +1969,7 @@ String VisualScriptEditor::get_name() {
} else if (script->get_name() != "")
name = script->get_name();
else
- name = script->get_class() + "(" + itos(script->get_instance_ID()) + ")";
+ name = script->get_class() + "(" + itos(script->get_instance_id()) + ")";
return name;
}
diff --git a/modules/visual_script/visual_script_func_nodes.cpp b/modules/visual_script/visual_script_func_nodes.cpp
index c438edd21f..3c057cdbd5 100644
--- a/modules/visual_script/visual_script_func_nodes.cpp
+++ b/modules/visual_script/visual_script_func_nodes.cpp
@@ -603,13 +603,13 @@ void VisualScriptFunctionCall::_validate_property(PropertyInfo &property) const
} else if (call_mode == CALL_MODE_SELF && get_visual_script().is_valid()) {
property.hint = PROPERTY_HINT_METHOD_OF_SCRIPT;
- property.hint_string = itos(get_visual_script()->get_instance_ID());
+ property.hint_string = itos(get_visual_script()->get_instance_id());
} else if (call_mode == CALL_MODE_SINGLETON) {
Object *obj = ProjectSettings::get_singleton()->get_singleton_object(singleton);
if (obj) {
property.hint = PROPERTY_HINT_METHOD_OF_INSTANCE;
- property.hint_string = itos(obj->get_instance_ID());
+ property.hint_string = itos(obj->get_instance_id());
} else {
property.hint = PROPERTY_HINT_METHOD_OF_BASE_TYPE;
@@ -631,7 +631,7 @@ void VisualScriptFunctionCall::_validate_property(PropertyInfo &property) const
if (script.is_valid()) {
property.hint = PROPERTY_HINT_METHOD_OF_SCRIPT;
- property.hint_string = itos(script->get_instance_ID());
+ property.hint_string = itos(script->get_instance_id());
}
}
}
@@ -640,7 +640,7 @@ void VisualScriptFunctionCall::_validate_property(PropertyInfo &property) const
Node *node = _get_base_node();
if (node) {
property.hint = PROPERTY_HINT_METHOD_OF_INSTANCE;
- property.hint_string = itos(node->get_instance_ID());
+ property.hint_string = itos(node->get_instance_id());
} else {
property.hint = PROPERTY_HINT_METHOD_OF_BASE_TYPE;
property.hint_string = get_base_type();
@@ -1379,7 +1379,7 @@ void VisualScriptPropertySet::_validate_property(PropertyInfo &property) const {
} else if (call_mode == CALL_MODE_SELF && get_visual_script().is_valid()) {
property.hint = PROPERTY_HINT_PROPERTY_OF_SCRIPT;
- property.hint_string = itos(get_visual_script()->get_instance_ID());
+ property.hint_string = itos(get_visual_script()->get_instance_id());
} else if (call_mode == CALL_MODE_INSTANCE) {
property.hint = PROPERTY_HINT_PROPERTY_OF_BASE_TYPE;
property.hint_string = base_type;
@@ -1396,7 +1396,7 @@ void VisualScriptPropertySet::_validate_property(PropertyInfo &property) const {
if (script.is_valid()) {
property.hint = PROPERTY_HINT_PROPERTY_OF_SCRIPT;
- property.hint_string = itos(script->get_instance_ID());
+ property.hint_string = itos(script->get_instance_id());
}
}
}
@@ -1405,7 +1405,7 @@ void VisualScriptPropertySet::_validate_property(PropertyInfo &property) const {
Node *node = _get_base_node();
if (node) {
property.hint = PROPERTY_HINT_PROPERTY_OF_INSTANCE;
- property.hint_string = itos(node->get_instance_ID());
+ property.hint_string = itos(node->get_instance_id());
} else {
property.hint = PROPERTY_HINT_PROPERTY_OF_BASE_TYPE;
property.hint_string = get_base_type();
@@ -2095,7 +2095,7 @@ void VisualScriptPropertyGet::_validate_property(PropertyInfo &property) const {
} else if (call_mode == CALL_MODE_SELF && get_visual_script().is_valid()) {
property.hint = PROPERTY_HINT_PROPERTY_OF_SCRIPT;
- property.hint_string = itos(get_visual_script()->get_instance_ID());
+ property.hint_string = itos(get_visual_script()->get_instance_id());
} else if (call_mode == CALL_MODE_INSTANCE) {
property.hint = PROPERTY_HINT_PROPERTY_OF_BASE_TYPE;
property.hint_string = base_type;
@@ -2112,7 +2112,7 @@ void VisualScriptPropertyGet::_validate_property(PropertyInfo &property) const {
if (script.is_valid()) {
property.hint = PROPERTY_HINT_PROPERTY_OF_SCRIPT;
- property.hint_string = itos(script->get_instance_ID());
+ property.hint_string = itos(script->get_instance_id());
}
}
}
@@ -2120,7 +2120,7 @@ void VisualScriptPropertyGet::_validate_property(PropertyInfo &property) const {
Node *node = _get_base_node();
if (node) {
property.hint = PROPERTY_HINT_PROPERTY_OF_INSTANCE;
- property.hint_string = itos(node->get_instance_ID());
+ property.hint_string = itos(node->get_instance_id());
} else {
property.hint = PROPERTY_HINT_PROPERTY_OF_BASE_TYPE;
property.hint_string = get_base_type();
diff --git a/modules/visual_script/visual_script_nodes.cpp b/modules/visual_script/visual_script_nodes.cpp
index 69aa10ebca..d5d8b8fe6e 100644
--- a/modules/visual_script/visual_script_nodes.cpp
+++ b/modules/visual_script/visual_script_nodes.cpp
@@ -2798,7 +2798,7 @@ public:
r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
return 0;
}
- *p_outputs[0] = subcall->call(VisualScriptLanguage::singleton->_subcall, p_inputs, input_args, r_error_str);
+ *p_outputs[0] = subcall->call(VisualScriptLanguage::singleton->_subcall, p_inputs, input_args, r_error);
return 0;
}
};
diff --git a/platform/android/SCsub b/platform/android/SCsub
index 7fb3c876be..b124a1a5a8 100644
--- a/platform/android/SCsub
+++ b/platform/android/SCsub
@@ -141,6 +141,8 @@ if env['android_arch'] == 'armv6':
lib_arch_dir = 'armeabi'
elif env['android_arch'] == 'armv7':
lib_arch_dir = 'armeabi-v7a'
+elif env['android_arch'] == 'arm64v8':
+ lib_arch_dir = 'arm64-v8a'
elif env['android_arch'] == 'x86':
lib_arch_dir = 'x86'
else:
diff --git a/platform/android/build.gradle.template b/platform/android/build.gradle.template
index fd0907f820..1df56ce621 100644
--- a/platform/android/build.gradle.template
+++ b/platform/android/build.gradle.template
@@ -3,7 +3,7 @@ buildscript {
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:2.3.1'
+ classpath 'com.android.tools.build:gradle:2.3.3'
$$GRADLE_CLASSPATH$$
}
}
@@ -31,7 +31,7 @@ android {
}
compileSdkVersion 23
- buildToolsVersion "25.0.3"
+ buildToolsVersion "26.0.1"
useLibrary 'org.apache.http.legacy'
packagingOptions {
diff --git a/platform/android/detect.py b/platform/android/detect.py
index fae1df3f27..ad5bfb4949 100644
--- a/platform/android/detect.py
+++ b/platform/android/detect.py
@@ -22,7 +22,7 @@ def get_opts():
return [
('ANDROID_NDK_ROOT', 'Path to the Android NDK', os.environ.get("ANDROID_NDK_ROOT", 0)),
('ndk_platform', 'Target platform (android-<api>, e.g. "android-18")', "android-18"),
- ('android_arch', 'Target architecture (armv7/armv6/x86)', "armv7"),
+ ('android_arch', 'Target architecture (armv7/armv6/arm64v8/x86)', "armv7"),
('android_neon', 'Enable NEON support (armv7 only)', "yes"),
('android_stl', 'Enable Android STL support (for modules)', "no")
]
@@ -89,7 +89,7 @@ def configure(env):
## Architecture
- if env['android_arch'] not in ['armv7', 'armv6', 'x86']:
+ if env['android_arch'] not in ['armv7', 'armv6', 'arm64v8', 'x86']:
env['android_arch'] = 'armv7'
neon_text = ""
@@ -99,18 +99,21 @@ def configure(env):
can_vectorize = True
if env['android_arch'] == 'x86':
+ env['ARCH'] = 'arch-x86'
env.extra_suffix = ".x86" + env.extra_suffix
target_subpath = "x86-4.9"
abi_subpath = "i686-linux-android"
arch_subpath = "x86"
env["x86_libtheora_opt_gcc"] = True
elif env['android_arch'] == 'armv6':
+ env['ARCH'] = 'arch-arm'
env.extra_suffix = ".armv6" + env.extra_suffix
target_subpath = "arm-linux-androideabi-4.9"
abi_subpath = "arm-linux-androideabi"
arch_subpath = "armeabi"
can_vectorize = False
elif env["android_arch"] == "armv7":
+ env['ARCH'] = 'arch-arm'
target_subpath = "arm-linux-androideabi-4.9"
abi_subpath = "arm-linux-androideabi"
arch_subpath = "armeabi-v7a"
@@ -118,6 +121,12 @@ def configure(env):
env.extra_suffix = ".armv7.neon" + env.extra_suffix
else:
env.extra_suffix = ".armv7" + env.extra_suffix
+ elif env["android_arch"] == "arm64v8":
+ env['ARCH'] = 'arch-arm64'
+ target_subpath = "aarch64-linux-android-4.9"
+ abi_subpath = "aarch64-linux-android"
+ arch_subpath = "arm64-v8a"
+ env.extra_suffix = ".armv8" + env.extra_suffix
## Build type
@@ -149,6 +158,8 @@ def configure(env):
elif (sys.platform.startswith('win')):
if (platform.machine().endswith('64')):
host_subpath = "windows-x86_64"
+ if env["android_arch"] == "arm64v8":
+ mt_link = False
else:
mt_link = False
host_subpath = "windows"
@@ -166,11 +177,6 @@ def configure(env):
env['RANLIB'] = tools_path + "/ranlib"
env['AS'] = tools_path + "/as"
- if env['android_arch'] == 'x86':
- env['ARCH'] = 'arch-x86'
- else:
- env['ARCH'] = 'arch-arm'
-
sysroot = env["ANDROID_NDK_ROOT"] + "/platforms/" + env['ndk_platform'] + "/" + env['ARCH']
common_opts = ['-fno-integrated-as', '-gcc-toolchain', gcc_toolchain_path]
@@ -199,6 +205,11 @@ def configure(env):
else:
env.Append(CPPFLAGS=['-mfpu=vfpv3-d16'])
+ elif env["android_arch"] == "arm64v8":
+ target_opts = ['-target', 'aarch64-none-linux-android']
+ env.Append(CPPFLAGS=['-D__ARM_ARCH_8A__'])
+ env.Append(CPPFLAGS=['-mfix-cortex-a53-835769'])
+
env.Append(CPPFLAGS=target_opts)
env.Append(CPPFLAGS=common_opts)
@@ -213,7 +224,8 @@ def configure(env):
## Link flags
env['LINKFLAGS'] = ['-shared', '--sysroot=' + sysroot, '-Wl,--warn-shared-textrel']
- env.Append(LINKFLAGS=string.split('-Wl,--fix-cortex-a8'))
+ if env["android_arch"] == "armv7":
+ env.Append(LINKFLAGS=string.split('-Wl,--fix-cortex-a8'))
env.Append(LINKFLAGS=string.split('-Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now'))
env.Append(LINKFLAGS=string.split('-Wl,-soname,libgodot_android.so -Wl,--gc-sections'))
if mt_link:
diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp
index a722cd1b8c..3c52834d92 100644
--- a/platform/android/export/export.cpp
+++ b/platform/android/export/export.cpp
@@ -219,6 +219,7 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
bool use_32_fb;
bool immersive;
bool export_arm;
+ bool export_arm64;
bool export_x86;
String apk_expansion_salt;
String apk_expansion_pkey;
@@ -319,6 +320,8 @@ bool EditorExportPlatformAndroid::_set(const StringName& p_name, const Variant&
_signed=p_value;
else if (n=="architecture/arm")
export_arm=p_value;
+ else if (n=="architecture/arm64")
+ export_arm64=p_value;
else if (n=="architecture/x86")
export_x86=p_value;
else if (n=="screen/use_32_bits_view")
@@ -392,6 +395,8 @@ bool EditorExportPlatformAndroid::_get(const StringName& p_name,Variant &r_ret)
r_ret=_signed;
else if (n=="architecture/arm")
r_ret=export_arm;
+ else if (n=="architecture/arm64")
+ r_ret=export_arm64;
else if (n=="architecture/x86")
r_ret=export_x86;
else if (n=="screen/use_32_bits_view")
@@ -1164,6 +1169,10 @@ Error EditorExportPlatformAndroid::export_project(const String& p_path, bool p_d
skip=true;
}
+ if (file.match("lib/arm64*/libgodot_android.so") && !export_arm64) {
+ skip = true;
+ }
+
if (file.begins_with("META-INF") && _signed) {
skip=true;
}
@@ -1801,6 +1810,7 @@ EditorExportPlatformAndroid::EditorExportPlatformAndroid() {
immersive=true;
export_arm=true;
+ export_arm64=false;
export_x86=false;
@@ -3176,6 +3186,7 @@ public:
bool export_x86 = p_preset->get("architecture/x86");
bool export_arm = p_preset->get("architecture/arm");
+ bool export_arm64 = p_preset->get("architecture/arm64");
bool use_32_fb = p_preset->get("screen/use_32_bits_view");
bool immersive = p_preset->get("screen/immersive_mode");
@@ -3267,6 +3278,10 @@ public:
skip = true;
}
+ if (file.match("lib/arm64*/libgodot_android.so") && !export_arm64) {
+ skip = true;
+ }
+
if (file.begins_with("META-INF") && _signed) {
skip = true;
}
diff --git a/platform/android/java/gradle.properties b/platform/android/java/gradle.properties
new file mode 100644
index 0000000000..aac7c9b461
--- /dev/null
+++ b/platform/android/java/gradle.properties
@@ -0,0 +1,17 @@
+# Project-wide Gradle settings.
+
+# IDE (e.g. Android Studio) users:
+# Gradle settings configured through the IDE *will override*
+# any settings specified in this file.
+
+# For more details on how to configure your build environment visit
+# http://www.gradle.org/docs/current/userguide/build_environment.html
+
+# Specifies the JVM arguments used for the daemon process.
+# The setting is particularly useful for tweaking memory settings.
+org.gradle.jvmargs=-Xmx1536m
+
+# When configured, Gradle will run in incubating parallel mode.
+# This option should only be used with decoupled projects. More details, visit
+# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
+# org.gradle.parallel=true
diff --git a/platform/android/java/gradle/wrapper/gradle-wrapper.jar b/platform/android/java/gradle/wrapper/gradle-wrapper.jar
index 8c0fb64a86..13372aef5e 100644
--- a/platform/android/java/gradle/wrapper/gradle-wrapper.jar
+++ b/platform/android/java/gradle/wrapper/gradle-wrapper.jar
Binary files differ
diff --git a/platform/android/java/gradle/wrapper/gradle-wrapper.properties b/platform/android/java/gradle/wrapper/gradle-wrapper.properties
index a11cc1b825..ee6901c9d7 100644
--- a/platform/android/java/gradle/wrapper/gradle-wrapper.properties
+++ b/platform/android/java/gradle/wrapper/gradle-wrapper.properties
@@ -1,7 +1,6 @@
-#Fri May 12 08:50:03 KST 2017
+#Sat Jul 29 16:10:03 ICT 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-bin.zip
-org.gradle.jvmargs=-Xmx1536M
+distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
diff --git a/platform/android/java/gradlew b/platform/android/java/gradlew
index 91a7e269e1..9d82f78915 100755
--- a/platform/android/java/gradlew
+++ b/platform/android/java/gradlew
@@ -42,11 +42,6 @@ case "`uname`" in
;;
esac
-# For Cygwin, ensure paths are in UNIX format before anything is touched.
-if $cygwin ; then
- [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
-fi
-
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
@@ -61,9 +56,9 @@ while [ -h "$PRG" ] ; do
fi
done
SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >&-
+cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
-cd "$SAVED" >&-
+cd "$SAVED" >/dev/null
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
@@ -114,6 +109,7 @@ fi
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+ JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
diff --git a/platform/android/java_class_wrapper.cpp b/platform/android/java_class_wrapper.cpp
index 56a27fa0e0..52ff9cd562 100644
--- a/platform/android/java_class_wrapper.cpp
+++ b/platform/android/java_class_wrapper.cpp
@@ -190,7 +190,7 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method,
argv[i].i = *p_args[i];
} break;
case ARG_TYPE_LONG: {
- argv[i].j = *p_args[i];
+ argv[i].j = (int64_t)*p_args[i];
} break;
case ARG_TYPE_FLOAT: {
argv[i].f = *p_args[i];
@@ -350,7 +350,7 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method,
Array arr = *p_args[i];
jlongArray a = env->NewLongArray(arr.size());
for (int j = 0; j < arr.size(); j++) {
- jlong val = arr[j];
+ jlong val = (int64_t)arr[j];
env->SetLongArrayRegion(a, j, 1, &val);
}
argv[i].l = a;
@@ -460,9 +460,9 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method,
case ARG_TYPE_LONG: {
if (method->_static) {
- ret = env->CallStaticLongMethodA(_class, method->method, argv);
+ ret = (int64_t)env->CallStaticLongMethodA(_class, method->method, argv);
} else {
- ret = env->CallLongMethodA(p_instance->instance, method->method, argv);
+ ret = (int64_t)env->CallLongMethodA(p_instance->instance, method->method, argv);
}
} break;
@@ -680,7 +680,7 @@ bool JavaClass::_convert_object_to_variant(JNIEnv *env, jobject obj, Variant &va
} break;
case ARG_TYPE_LONG | ARG_NUMBER_CLASS_BIT: {
- var = env->CallLongMethod(obj, JavaClassWrapper::singleton->Long_longValue);
+ var = (int64_t)env->CallLongMethod(obj, JavaClassWrapper::singleton->Long_longValue);
return true;
} break;
@@ -802,7 +802,7 @@ bool JavaClass::_convert_object_to_variant(JNIEnv *env, jobject obj, Variant &va
jlong val;
env->GetLongArrayRegion((jlongArray)arr, 0, 1, &val);
- ret.push_back(val);
+ ret.push_back((int64_t)val);
}
var = ret;
diff --git a/platform/android/java_glue.cpp b/platform/android/java_glue.cpp
index 0508989d2f..683e1cfb22 100644
--- a/platform/android/java_glue.cpp
+++ b/platform/android/java_glue.cpp
@@ -895,7 +895,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_initialize(JNIEnv *en
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_resize(JNIEnv *env, jobject obj, jint width, jint height, jboolean reload) {
- __android_log_print(ANDROID_LOG_INFO, "godot", "^_^_^_^_^ resize %lld, %i, %i\n", Thread::get_caller_ID(), width, height);
+ __android_log_print(ANDROID_LOG_INFO, "godot", "^_^_^_^_^ resize %lld, %i, %i\n", Thread::get_caller_id(), width, height);
if (os_android)
os_android->set_display_size(Size2(width, height));
@@ -909,7 +909,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_resize(JNIEnv *env, j
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_newcontext(JNIEnv *env, jobject obj, bool p_32_bits) {
- __android_log_print(ANDROID_LOG_INFO, "godot", "^_^_^_^_^ newcontext %lld\n", Thread::get_caller_ID());
+ __android_log_print(ANDROID_LOG_INFO, "godot", "^_^_^_^_^ newcontext %lld\n", Thread::get_caller_id());
if (os_android) {
os_android->set_context_is_16_bits(!p_32_bits);
@@ -995,7 +995,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_step(JNIEnv *env, job
ThreadAndroid::setup_thread();
- //__android_log_print(ANDROID_LOG_INFO,"godot","**STEP EVENT! - %p-%i\n",env,Thread::get_caller_ID());
+ //__android_log_print(ANDROID_LOG_INFO,"godot","**STEP EVENT! - %p-%i\n",env,Thread::get_caller_id());
suspend_mutex->lock();
input_mutex->lock();
@@ -1069,7 +1069,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_step(JNIEnv *env, job
jclass cls = env->FindClass("org/godotengine/godot/Godot");
jmethodID _finish = env->GetMethodID(cls, "forceQuit", "()V");
env->CallVoidMethod(_godot_instance, _finish);
- __android_log_print(ANDROID_LOG_INFO, "godot", "**FINISH REQUEST!!! - %p-%i\n", env, Thread::get_caller_ID());
+ __android_log_print(ANDROID_LOG_INFO, "godot", "**FINISH REQUEST!!! - %p-%i\n", env, Thread::get_caller_id());
}
suspend_mutex->unlock();
@@ -1077,7 +1077,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_step(JNIEnv *env, job
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_touch(JNIEnv *env, jobject obj, jint ev, jint pointer, jint count, jintArray positions) {
- //__android_log_print(ANDROID_LOG_INFO,"godot","**TOUCH EVENT! - %p-%i\n",env,Thread::get_caller_ID());
+ //__android_log_print(ANDROID_LOG_INFO,"godot","**TOUCH EVENT! - %p-%i\n",env,Thread::get_caller_id());
Vector<OS_Android::TouchPos> points;
for (int i = 0; i < count; i++) {
diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp
index ad46ceb43f..e3f982ff94 100644
--- a/platform/android/os_android.cpp
+++ b/platform/android/os_android.cpp
@@ -686,11 +686,11 @@ void OS_Android::set_screen_orientation(ScreenOrientation p_orientation) {
set_screen_orientation_func(p_orientation);
}
-String OS_Android::get_unique_ID() const {
+String OS_Android::get_unique_id() const {
if (get_unique_id_func)
return get_unique_id_func();
- return OS::get_unique_ID();
+ return OS::get_unique_id();
}
Error OS_Android::native_video_play(String p_path, float p_volume) {
diff --git a/platform/android/os_android.h b/platform/android/os_android.h
index 393bc68d8a..54d7e562e0 100644
--- a/platform/android/os_android.h
+++ b/platform/android/os_android.h
@@ -222,7 +222,7 @@ public:
virtual String get_model_name() const;
virtual int get_screen_dpi(int p_screen = 0) const;
- virtual String get_unique_ID() const;
+ virtual String get_unique_id() const;
virtual String get_system_dir(SystemDir p_dir) const;
diff --git a/platform/android/thread_jandroid.cpp b/platform/android/thread_jandroid.cpp
index 401f3cd73b..924ae3fe43 100644
--- a/platform/android/thread_jandroid.cpp
+++ b/platform/android/thread_jandroid.cpp
@@ -32,7 +32,7 @@
#include "os/memory.h"
#include "script_language.h"
-Thread::ID ThreadAndroid::get_ID() const {
+Thread::ID ThreadAndroid::get_id() const {
return id;
}
@@ -66,7 +66,7 @@ Thread *ThreadAndroid::create_func_jandroid(ThreadCreateCallback p_callback, voi
return tr;
}
-Thread::ID ThreadAndroid::get_thread_ID_func_jandroid() {
+Thread::ID ThreadAndroid::get_thread_id_func_jandroid() {
return (ID)pthread_self();
}
@@ -107,7 +107,7 @@ void ThreadAndroid::make_default(JavaVM *p_java_vm) {
java_vm = p_java_vm;
create_func = create_func_jandroid;
- get_thread_ID_func = get_thread_ID_func_jandroid;
+ get_thread_id_func = get_thread_id_func_jandroid;
wait_to_finish_func = wait_to_finish_func_jandroid;
pthread_key_create(&jvm_key, _thread_destroyed);
setup_thread();
diff --git a/platform/android/thread_jandroid.h b/platform/android/thread_jandroid.h
index 6174066968..5267329744 100644
--- a/platform/android/thread_jandroid.h
+++ b/platform/android/thread_jandroid.h
@@ -52,7 +52,7 @@ class ThreadAndroid : public Thread {
static void *thread_callback(void *userdata);
static Thread *create_func_jandroid(ThreadCreateCallback p_callback, void *, const Settings &);
- static ID get_thread_ID_func_jandroid();
+ static ID get_thread_id_func_jandroid();
static void wait_to_finish_func_jandroid(Thread *p_thread);
static void _thread_destroyed(void *value);
@@ -62,7 +62,7 @@ class ThreadAndroid : public Thread {
static JavaVM *java_vm;
public:
- virtual ID get_ID() const;
+ virtual ID get_id() const;
static void make_default(JavaVM *p_java_vm);
static void setup_thread();
diff --git a/platform/haiku/key_mapping_haiku.cpp b/platform/haiku/key_mapping_haiku.cpp
index 9df7b2f047..3db31fa3e4 100644
--- a/platform/haiku/key_mapping_haiku.cpp
+++ b/platform/haiku/key_mapping_haiku.cpp
@@ -83,7 +83,7 @@ static _HaikuTranslatePair _fn_to_keycode[] = {
static _HaikuTranslatePair _hb_to_keycode[] = {
{ KEY_BACKSPACE, B_BACKSPACE },
{ KEY_TAB, B_TAB },
- { KEY_RETURN, B_RETURN },
+ { KEY_ENTER, B_RETURN },
{ KEY_CAPSLOCK, B_CAPS_LOCK },
{ KEY_ESCAPE, B_ESCAPE },
{ KEY_SPACE, B_SPACE },
diff --git a/platform/iphone/app_delegate.mm b/platform/iphone/app_delegate.mm
index da6dfcf53f..362cfd1478 100644
--- a/platform/iphone/app_delegate.mm
+++ b/platform/iphone/app_delegate.mm
@@ -424,7 +424,7 @@ static int frame_count = 0;
}
}
- OSIPhone::get_singleton()->set_unique_ID(String::utf8([uuid UTF8String]));
+ OSIPhone::get_singleton()->set_unique_id(String::utf8([uuid UTF8String]));
}; break;
/*
diff --git a/platform/iphone/os_iphone.cpp b/platform/iphone/os_iphone.cpp
index cb5c022764..b202a993ff 100644
--- a/platform/iphone/os_iphone.cpp
+++ b/platform/iphone/os_iphone.cpp
@@ -83,12 +83,12 @@ void OSIPhone::set_data_dir(String p_dir) {
memdelete(da);
};
-void OSIPhone::set_unique_ID(String p_ID) {
+void OSIPhone::set_unique_id(String p_ID) {
unique_ID = p_ID;
};
-String OSIPhone::get_unique_ID() const {
+String OSIPhone::get_unique_id() const {
return unique_ID;
};
@@ -224,11 +224,9 @@ void OSIPhone::mouse_button(int p_idx, int p_x, int p_y, bool p_pressed, bool p_
Ref<InputEventMouseButton> ev;
ev.instance();
- // swaped it for tilted screen
- //ev->get_pos().x = ev.mouse_button.global_x = video_mode.height - p_y;
- //ev->get_pos().y = ev.mouse_button.global_y = p_x;
- ev->set_position(Vector2(video_mode.height - p_y, p_x));
- ev->set_global_position(Vector2(video_mode.height - p_y, p_x));
+
+ ev->set_position(Vector2(p_x, p_y));
+ ev->set_global_position(Vector2(p_x, p_y));
//mouse_list.pressed[p_idx] = p_pressed;
diff --git a/platform/iphone/os_iphone.h b/platform/iphone/os_iphone.h
index b15e9fdffb..cf2766bb33 100644
--- a/platform/iphone/os_iphone.h
+++ b/platform/iphone/os_iphone.h
@@ -190,8 +190,8 @@ public:
void set_locale(String p_locale);
String get_locale() const;
- void set_unique_ID(String p_ID);
- String get_unique_ID() const;
+ void set_unique_id(String p_ID);
+ String get_unique_id() const;
virtual Error native_video_play(String p_path, float p_volume, String p_audio_track, String p_subtitle_track);
virtual bool native_video_is_playing() const;
diff --git a/platform/javascript/dom_keys.h b/platform/javascript/dom_keys.h
index 979731d157..4b8b764c45 100644
--- a/platform/javascript/dom_keys.h
+++ b/platform/javascript/dom_keys.h
@@ -249,7 +249,7 @@ int dom2godot_scancode(int dom_keycode) {
case DOM_VK_RETURN:
case DOM_VK_ENTER: // unused according to MDN
- return KEY_RETURN;
+ return KEY_ENTER;
case DOM_VK_SHIFT: return KEY_SHIFT;
case DOM_VK_CONTROL: return KEY_CONTROL;
diff --git a/platform/javascript/os_javascript.cpp b/platform/javascript/os_javascript.cpp
index 0708d46196..5513fca809 100644
--- a/platform/javascript/os_javascript.cpp
+++ b/platform/javascript/os_javascript.cpp
@@ -96,30 +96,18 @@ static EM_BOOL _browser_resize_callback(int event_type, const EmscriptenUiEvent
ERR_FAIL_COND_V(event_type != EMSCRIPTEN_EVENT_RESIZE, false);
OS_JavaScript *os = static_cast<OS_JavaScript *>(user_data);
-
- // the order in which _browser_resize_callback and
- // _fullscreen_change_callback are called is browser-dependent,
- // so try adjusting for fullscreen in both
- if (os->is_window_fullscreen() || os->is_window_maximized()) {
-
- OS::VideoMode vm = os->get_video_mode();
- vm.width = ui_event->windowInnerWidth;
- vm.height = ui_event->windowInnerHeight;
- os->set_video_mode(vm);
- emscripten_set_canvas_size(ui_event->windowInnerWidth, ui_event->windowInnerHeight);
- }
+ // The order of the fullscreen change event and the window size change
+ // event varies, even within just one browser, so defer handling
+ os->request_canvas_size_adjustment();
return false;
}
-static Size2 _windowed_size;
-
static EM_BOOL _fullscreen_change_callback(int event_type, const EmscriptenFullscreenChangeEvent *event, void *user_data) {
ERR_FAIL_COND_V(event_type != EMSCRIPTEN_EVENT_FULLSCREENCHANGE, false);
OS_JavaScript *os = static_cast<OS_JavaScript *>(user_data);
String id = String::utf8(event->id);
-
// empty id is canvas
if (id.empty() || id == "canvas") {
@@ -127,18 +115,8 @@ static EM_BOOL _fullscreen_change_callback(int event_type, const EmscriptenFulls
// this event property is the only reliable information on
// browser fullscreen state
vm.fullscreen = event->isFullscreen;
-
- if (event->isFullscreen) {
- vm.width = event->screenWidth;
- vm.height = event->screenHeight;
- os->set_video_mode(vm);
- emscripten_set_canvas_size(vm.width, vm.height);
- } else {
- os->set_video_mode(vm);
- if (!os->is_window_maximized()) {
- os->set_window_size(_windowed_size);
- }
- }
+ os->set_video_mode(vm);
+ os->request_canvas_size_adjustment();
}
return false;
}
@@ -719,14 +697,17 @@ Size2 OS_JavaScript::get_screen_size(int p_screen) const {
void OS_JavaScript::set_window_size(const Size2 p_size) {
- window_maximized = false;
+ windowed_size = p_size;
if (is_window_fullscreen()) {
+ window_maximized = false;
set_window_fullscreen(false);
+ } else if (is_window_maximized()) {
+ set_window_maximized(false);
+ } else {
+ video_mode.width = p_size.x;
+ video_mode.height = p_size.y;
+ emscripten_set_canvas_size(p_size.x, p_size.y);
}
- _windowed_size = p_size;
- video_mode.width = p_size.x;
- video_mode.height = p_size.y;
- emscripten_set_canvas_size(p_size.x, p_size.y);
}
Size2 OS_JavaScript::get_window_size() const {
@@ -739,20 +720,30 @@ Size2 OS_JavaScript::get_window_size() const {
void OS_JavaScript::set_window_maximized(bool p_enabled) {
window_maximized = p_enabled;
- if (p_enabled) {
-
- if (is_window_fullscreen()) {
- // _browser_resize callback will set canvas size
- set_window_fullscreen(false);
- } else {
- /* clang-format off */
- video_mode.width = EM_ASM_INT_V(return window.innerWidth);
- video_mode.height = EM_ASM_INT_V(return window.innerHeight);
- /* clang-format on */
- emscripten_set_canvas_size(video_mode.width, video_mode.height);
- }
- } else {
- set_window_size(_windowed_size);
+ if (is_window_fullscreen()) {
+ set_window_fullscreen(false);
+ return;
+ }
+ // Calling emscripten_enter_soft_fullscreen mutltiple times hides all
+ // page elements except the canvas permanently, so track state
+ if (p_enabled && !soft_fs_enabled) {
+
+ EmscriptenFullscreenStrategy strategy;
+ strategy.scaleMode = EMSCRIPTEN_FULLSCREEN_SCALE_STRETCH;
+ strategy.canvasResolutionScaleMode = EMSCRIPTEN_FULLSCREEN_CANVAS_SCALE_STDDEF;
+ strategy.filteringMode = EMSCRIPTEN_FULLSCREEN_FILTERING_DEFAULT;
+ strategy.canvasResizedCallback = NULL;
+ emscripten_enter_soft_fullscreen(NULL, &strategy);
+ soft_fs_enabled = true;
+ video_mode.width = get_window_size().width;
+ video_mode.height = get_window_size().height;
+ } else if (!p_enabled) {
+
+ emscripten_exit_soft_fullscreen();
+ soft_fs_enabled = false;
+ video_mode.width = windowed_size.width;
+ video_mode.height = windowed_size.height;
+ emscripten_set_canvas_size(video_mode.width, video_mode.height);
}
}
@@ -766,9 +757,17 @@ void OS_JavaScript::set_window_fullscreen(bool p_enable) {
// _browser_resize_callback or _fullscreen_change_callback
EMSCRIPTEN_RESULT result;
if (p_enable) {
- /* clang-format off */
- EM_ASM(Module.requestFullscreen(false, false););
- /* clang-format on */
+ if (window_maximized) {
+ // soft fs during real fs can cause issues
+ set_window_maximized(false);
+ window_maximized = true;
+ }
+ EmscriptenFullscreenStrategy strategy;
+ strategy.scaleMode = EMSCRIPTEN_FULLSCREEN_SCALE_STRETCH;
+ strategy.canvasResolutionScaleMode = EMSCRIPTEN_FULLSCREEN_CANVAS_SCALE_STDDEF;
+ strategy.filteringMode = EMSCRIPTEN_FULLSCREEN_FILTERING_DEFAULT;
+ strategy.canvasResizedCallback = NULL;
+ emscripten_request_fullscreen_strategy(NULL, false, &strategy);
} else {
result = emscripten_exit_fullscreen();
if (result != EMSCRIPTEN_RESULT_SUCCESS) {
@@ -782,6 +781,11 @@ bool OS_JavaScript::is_window_fullscreen() const {
return video_mode.fullscreen;
}
+void OS_JavaScript::request_canvas_size_adjustment() {
+
+ canvas_size_adjustment_requested = true;
+}
+
void OS_JavaScript::get_fullscreen_mode_list(List<VideoMode> *p_list, int p_screen) const {
Size2 screen = get_screen_size();
@@ -841,6 +845,17 @@ bool OS_JavaScript::main_loop_iterate() {
}
}
process_joypads();
+ if (canvas_size_adjustment_requested) {
+
+ if (video_mode.fullscreen || window_maximized) {
+ video_mode.width = get_window_size().width;
+ video_mode.height = get_window_size().height;
+ }
+ if (!video_mode.fullscreen) {
+ set_window_maximized(window_maximized);
+ }
+ canvas_size_adjustment_requested = false;
+ }
return Main::iteration();
}
@@ -857,7 +872,11 @@ void OS_JavaScript::process_accelerometer(const Vector3 &p_accelerometer) {
bool OS_JavaScript::has_touchscreen_ui_hint() const {
- return false; //???
+ /* clang-format off */
+ return EM_ASM_INT_V(
+ return 'ontouchstart' in window;
+ );
+ /* clang-format on */
}
void OS_JavaScript::main_loop_request_quit() {
@@ -980,6 +999,8 @@ OS_JavaScript::OS_JavaScript(const char *p_execpath, GetDataDirFunc p_get_data_d
main_loop = NULL;
gl_extensions = NULL;
window_maximized = false;
+ soft_fs_enabled = false;
+ canvas_size_adjustment_requested = false;
get_data_dir_func = p_get_data_dir_func;
FileAccessUnix::close_notification_func = _close_notification_funcs;
diff --git a/platform/javascript/os_javascript.h b/platform/javascript/os_javascript.h
index 24e96e20dd..13c500b3dc 100644
--- a/platform/javascript/os_javascript.h
+++ b/platform/javascript/os_javascript.h
@@ -59,7 +59,10 @@ class OS_JavaScript : public OS_Unix {
const char *gl_extensions;
InputDefault *input;
+ Vector2 windowed_size;
bool window_maximized;
+ bool soft_fs_enabled;
+ bool canvas_size_adjustment_requested;
VideoMode video_mode;
CursorShape cursor_shape;
MainLoop *main_loop;
@@ -130,6 +133,8 @@ public:
virtual void set_window_fullscreen(bool p_enable);
virtual bool is_window_fullscreen() const;
+ void request_canvas_size_adjustment();
+
virtual String get_name();
virtual MainLoop *get_main_loop() const;
diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h
index cb9dd1dd8e..4b5682518f 100644
--- a/platform/osx/os_osx.h
+++ b/platform/osx/os_osx.h
@@ -136,6 +136,8 @@ public:
virtual String get_name();
+ virtual void print_error(const char *p_function, const char *p_file, int p_line, const char *p_code, const char *p_rationale, ErrorType p_type = ERR_ERROR);
+
virtual void alert(const String &p_alert, const String &p_title = "ALERT!");
virtual void set_cursor_shape(CursorShape p_shape);
diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm
index 4a01532d89..a34f6cc5dd 100644
--- a/platform/osx/os_osx.mm
+++ b/platform/osx/os_osx.mm
@@ -44,6 +44,9 @@
#include <IOKit/IOKitLib.h>
#include <IOKit/hid/IOHIDKeys.h>
#include <IOKit/hid/IOHIDLib.h>
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101200
+#include <os/log.h>
+#endif
#include <fcntl.h>
#include <libproc.h>
@@ -518,7 +521,7 @@ static int translateKey(unsigned int key) {
/* 21 */ KEY_BRACELEFT,
/* 22 */ KEY_I,
/* 23 */ KEY_P,
- /* 24 */ KEY_RETURN,
+ /* 24 */ KEY_ENTER,
/* 25 */ KEY_L,
/* 26 */ KEY_J,
/* 27 */ KEY_APOSTROPHE,
@@ -558,7 +561,7 @@ static int translateKey(unsigned int key) {
/* 49 */ KEY_UNKNOWN, /* VolumeDown */
/* 4a */ KEY_UNKNOWN, /* Mute */
/* 4b */ KEY_KP_DIVIDE,
- /* 4c */ KEY_ENTER,
+ /* 4c */ KEY_KP_ENTER,
/* 4d */ KEY_UNKNOWN,
/* 4e */ KEY_KP_SUBTRACT,
/* 4f */ KEY_UNKNOWN,
@@ -1017,6 +1020,45 @@ String OS_OSX::get_name() {
return "OSX";
}
+void OS_OSX::print_error(const char *p_function, const char *p_file, int p_line, const char *p_code, const char *p_rationale, ErrorType p_type) {
+
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101200
+ if (!_print_error_enabled)
+ return;
+
+ const char *err_details;
+ if (p_rationale && p_rationale[0])
+ err_details = p_rationale;
+ else
+ err_details = p_code;
+
+ switch (p_type) {
+ case ERR_ERROR:
+ os_log_error(OS_LOG_DEFAULT, "ERROR: %{public}s: %{public}s\nAt: %{public}s:%i.", p_function, err_details, p_file, p_line);
+ print("\E[1;31mERROR: %s: \E[0m\E[1m%s\n", p_function, err_details);
+ print("\E[0;31m At: %s:%i.\E[0m\n", p_file, p_line);
+ break;
+ case ERR_WARNING:
+ os_log_info(OS_LOG_DEFAULT, "WARNING: %{public}s: %{public}s\nAt: %{public}s:%i.", p_function, err_details, p_file, p_line);
+ print("\E[1;33mWARNING: %s: \E[0m\E[1m%s\n", p_function, err_details);
+ print("\E[0;33m At: %s:%i.\E[0m\n", p_file, p_line);
+ break;
+ case ERR_SCRIPT:
+ os_log_error(OS_LOG_DEFAULT, "SCRIPT ERROR: %{public}s: %{public}s\nAt: %{public}s:%i.", p_function, err_details, p_file, p_line);
+ print("\E[1;35mSCRIPT ERROR: %s: \E[0m\E[1m%s\n", p_function, err_details);
+ print("\E[0;35m At: %s:%i.\E[0m\n", p_file, p_line);
+ break;
+ case ERR_SHADER:
+ os_log_error(OS_LOG_DEFAULT, "SHADER ERROR: %{public}s: %{public}s\nAt: %{public}s:%i.", p_function, err_details, p_file, p_line);
+ print("\E[1;36mSHADER ERROR: %s: \E[0m\E[1m%s\n", p_function, err_details);
+ print("\E[0;36m At: %s:%i.\E[0m\n", p_file, p_line);
+ break;
+ }
+#else
+ OS_Unix::print_error(p_function, p_file, p_line, p_code, p_rationale, p_type);
+#endif
+}
+
void OS_OSX::alert(const String &p_alert, const String &p_title) {
// Set OS X-compliant variables
NSAlert *window = [[NSAlert alloc] init];
@@ -1081,18 +1123,13 @@ void OS_OSX::warp_mouse_pos(const Point2 &p_to) {
mouse_y = p_to.y;
} else { //set OS position
- /* this code has not been tested, please be a kind soul and fix it if it fails! */
-
//local point in window coords
- NSPoint localPoint = { p_to.x, p_to.y };
-
- NSPoint pointInWindow = [window_view convertPoint:localPoint toView:nil];
- NSRect pointInWindowRect;
- pointInWindowRect.origin = pointInWindow;
+ const NSRect contentRect = [window_view frame];
+ NSRect pointInWindowRect = NSMakeRect(p_to.x / display_scale, contentRect.size.height - (p_to.y / display_scale) - 1, 0, 0);
NSPoint pointOnScreen = [[window_view window] convertRectToScreen:pointInWindowRect].origin;
//point in scren coords
- CGPoint lMouseWarpPos = { pointOnScreen.x, pointOnScreen.y };
+ CGPoint lMouseWarpPos = { pointOnScreen.x, CGDisplayBounds(CGMainDisplayID()).size.height - pointOnScreen.y };
//do the warping
CGEventSourceRef lEventRef = CGEventSourceCreate(kCGEventSourceStateCombinedSessionState);
diff --git a/platform/uwp/joypad_uwp.cpp b/platform/uwp/joypad_uwp.cpp
index 34e36f7b66..f3d4eb99c8 100644
--- a/platform/uwp/joypad_uwp.cpp
+++ b/platform/uwp/joypad_uwp.cpp
@@ -29,6 +29,7 @@
/*************************************************************************/
#include "joypad_uwp.h"
+#include "core/os/os.h"
using namespace Windows::Gaming::Input;
using namespace Windows::Foundation;
@@ -45,27 +46,44 @@ void JoypadUWP::process_controllers() {
for (int i = 0; i < MAX_CONTROLLERS; i++) {
- if (!controllers[i].connected) break;
+ ControllerDevice &joy = controllers[i];
- switch (controllers[i].type) {
+ if (!joy.connected) break;
+
+ switch (joy.type) {
case ControllerType::GAMEPAD_CONTROLLER: {
- GamepadReading reading = ((Gamepad ^)controllers[i].controller_reference)->GetCurrentReading();
+ GamepadReading reading = ((Gamepad ^) joy.controller_reference)->GetCurrentReading();
int button_mask = (int)GamepadButtons::Menu;
for (int j = 0; j < 14; j++) {
- input->joy_button(controllers[i].id, j, (int)reading.Buttons & button_mask);
+ input->joy_button(joy.id, j, (int)reading.Buttons & button_mask);
button_mask *= 2;
}
- input->joy_axis(controllers[i].id, JOY_AXIS_0, axis_correct(reading.LeftThumbstickX));
- input->joy_axis(controllers[i].id, JOY_AXIS_1, axis_correct(reading.LeftThumbstickY, true));
- input->joy_axis(controllers[i].id, JOY_AXIS_2, axis_correct(reading.RightThumbstickX));
- input->joy_axis(controllers[i].id, JOY_AXIS_3, axis_correct(reading.RightThumbstickY, true));
- input->joy_axis(controllers[i].id, JOY_AXIS_4, axis_correct(reading.LeftTrigger, false, true));
- input->joy_axis(controllers[i].id, JOY_AXIS_5, axis_correct(reading.RightTrigger, false, true));
+ input->joy_axis(joy.id, JOY_AXIS_0, axis_correct(reading.LeftThumbstickX));
+ input->joy_axis(joy.id, JOY_AXIS_1, axis_correct(reading.LeftThumbstickY, true));
+ input->joy_axis(joy.id, JOY_AXIS_2, axis_correct(reading.RightThumbstickX));
+ input->joy_axis(joy.id, JOY_AXIS_3, axis_correct(reading.RightThumbstickY, true));
+ input->joy_axis(joy.id, JOY_AXIS_4, axis_correct(reading.LeftTrigger, false, true));
+ input->joy_axis(joy.id, JOY_AXIS_5, axis_correct(reading.RightTrigger, false, true));
+
+ uint64_t timestamp = input->get_joy_vibration_timestamp(joy.id);
+ if (timestamp > joy.ff_timestamp) {
+ Vector2 strength = input->get_joy_vibration_strength(joy.id);
+ float duration = input->get_joy_vibration_duration(joy.id);
+ if (strength.x == 0 && strength.y == 0) {
+ joypad_vibration_stop(i, timestamp);
+ } else {
+ joypad_vibration_start(i, strength.x, strength.y, duration, timestamp);
+ }
+ } else if (joy.vibrating && joy.ff_end_timestamp != 0) {
+ uint64_t current_time = OS::get_singleton()->get_ticks_usec();
+ if (current_time >= joy.ff_end_timestamp)
+ joypad_vibration_stop(i, current_time);
+ }
break;
}
@@ -122,15 +140,7 @@ void JoypadUWP::OnGamepadRemoved(Platform::Object ^ sender, Windows::Gaming::Inp
ERR_FAIL_COND(idx == -1);
- for (int i = idx + 1; i < MAX_CONTROLLERS - 1; i++) {
-
- if (!controllers[i].connected) {
- break;
- }
-
- controllers[i - 1] = controllers[i];
- }
- controllers[MAX_CONTROLLERS - 1] = ControllerDevice();
+ controllers[idx] = ControllerDevice();
input->joy_connection_changed(idx, false, "Xbox Controller");
}
@@ -144,3 +154,30 @@ InputDefault::JoyAxis JoypadUWP::axis_correct(double p_val, bool p_negate, bool
return jx;
}
+
+void JoypadUWP::joypad_vibration_start(int p_device, float p_weak_magnitude, float p_strong_magnitude, float p_duration, uint64_t p_timestamp) {
+ ControllerDevice &joy = controllers[p_device];
+ if (joy.connected) {
+ GamepadVibration vibration;
+ vibration.LeftMotor = p_strong_magnitude;
+ vibration.RightMotor = p_weak_magnitude;
+ ((Gamepad ^) joy.controller_reference)->Vibration = vibration;
+
+ joy.ff_timestamp = p_timestamp;
+ joy.ff_end_timestamp = p_duration == 0 ? 0 : p_timestamp + (uint64_t)(p_duration * 1000000.0);
+ joy.vibrating = true;
+ }
+}
+
+void JoypadUWP::joypad_vibration_stop(int p_device, uint64_t p_timestamp) {
+ ControllerDevice &joy = controllers[p_device];
+ if (joy.connected) {
+ GamepadVibration vibration;
+ vibration.LeftMotor = 0.0;
+ vibration.RightMotor = 0.0;
+ ((Gamepad ^) joy.controller_reference)->Vibration = vibration;
+
+ joy.ff_timestamp = p_timestamp;
+ joy.vibrating = false;
+ }
+}
diff --git a/platform/uwp/joypad_uwp.h b/platform/uwp/joypad_uwp.h
index 7337ffb3ce..c55e1e7ab7 100644
--- a/platform/uwp/joypad_uwp.h
+++ b/platform/uwp/joypad_uwp.h
@@ -62,11 +62,17 @@ private:
int id;
bool connected;
ControllerType type;
+ float ff_timestamp;
+ float ff_end_timestamp;
+ bool vibrating;
ControllerDevice() {
id = -1;
connected = false;
type = ControllerType::GAMEPAD_CONTROLLER;
+ ff_timestamp = 0.0f;
+ ff_end_timestamp = 0.0f;
+ vibrating = false;
}
};
@@ -78,6 +84,8 @@ private:
void OnGamepadRemoved(Platform::Object ^ sender, Windows::Gaming::Input::Gamepad ^ value);
InputDefault::JoyAxis axis_correct(double p_val, bool p_negate = false, bool p_trigger = false) const;
+ void joypad_vibration_start(int p_device, float p_weak_magnitude, float p_strong_magnitude, float p_duration, uint64_t p_timestamp);
+ void joypad_vibration_stop(int p_device, uint64_t p_timestamp);
};
#endif
diff --git a/platform/uwp/thread_uwp.cpp b/platform/uwp/thread_uwp.cpp
index 436941707c..0549a8ed47 100644
--- a/platform/uwp/thread_uwp.cpp
+++ b/platform/uwp/thread_uwp.cpp
@@ -41,7 +41,7 @@ Thread *ThreadUWP::create_func_uwp(ThreadCreateCallback p_callback, void *p_user
return thread;
};
-Thread::ID ThreadUWP::get_thread_ID_func_uwp() {
+Thread::ID ThreadUWP::get_thread_id_func_uwp() {
return std::hash<std::thread::id>()(std::this_thread::get_id());
};
@@ -52,14 +52,14 @@ void ThreadUWP::wait_to_finish_func_uwp(Thread *p_thread) {
tp->thread.join();
};
-Thread::ID ThreadUWP::get_ID() const {
+Thread::ID ThreadUWP::get_id() const {
return std::hash<std::thread::id>()(thread.get_id());
};
void ThreadUWP::make_default() {
create_func = create_func_uwp;
- get_thread_ID_func = get_thread_ID_func_uwp;
+ get_thread_id_func = get_thread_id_func_uwp;
wait_to_finish_func = wait_to_finish_func_uwp;
};
diff --git a/platform/uwp/thread_uwp.h b/platform/uwp/thread_uwp.h
index 0424f0f577..b8cccfb7c3 100644
--- a/platform/uwp/thread_uwp.h
+++ b/platform/uwp/thread_uwp.h
@@ -41,13 +41,13 @@ class ThreadUWP : public Thread {
std::thread thread;
static Thread *create_func_uwp(ThreadCreateCallback p_callback, void *, const Settings &);
- static ID get_thread_ID_func_uwp();
+ static ID get_thread_id_func_uwp();
static void wait_to_finish_func_uwp(Thread *p_thread);
ThreadUWP();
public:
- virtual ID get_ID() const;
+ virtual ID get_id() const;
static void make_default();
diff --git a/platform/windows/key_mapping_win.cpp b/platform/windows/key_mapping_win.cpp
index bffacb3a82..83e2af72b2 100644
--- a/platform/windows/key_mapping_win.cpp
+++ b/platform/windows/key_mapping_win.cpp
@@ -44,7 +44,7 @@ static _WinTranslatePair _vk_to_keycode[] = {
//VK_CLEAR (0x0C)
- { KEY_RETURN, VK_RETURN }, //(0x0D)
+ { KEY_ENTER, VK_RETURN }, //(0x0D)
{ KEY_SHIFT, VK_SHIFT }, //(0x10)
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp
index da14d5c284..f72e5ef595 100644
--- a/platform/windows/os_windows.cpp
+++ b/platform/windows/os_windows.cpp
@@ -807,7 +807,7 @@ void OS_Windows::process_key_events() {
if ((ke.lParam & (1 << 24)) && (ke.wParam == VK_RETURN)) {
// Special case for Numpad Enter key
- k->set_scancode(KEY_ENTER);
+ k->set_scancode(KEY_KP_ENTER);
} else {
k->set_scancode(KeyMappingWindows::get_keysym(ke.wParam));
}
@@ -1192,10 +1192,6 @@ void OS_Windows::finalize() {
main_loop = NULL;
- for (int i = 0; i < get_audio_driver_count(); i++) {
- AudioDriverManager::get_driver(i)->finish();
- }
-
memdelete(joypad);
memdelete(input);
@@ -1952,7 +1948,7 @@ Error OS_Windows::kill(const ProcessID &p_pid) {
return ret != 0 ? OK : FAILED;
};
-int OS_Windows::get_process_ID() const {
+int OS_Windows::get_process_id() const {
return _getpid();
}
diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h
index 6856e7e9b8..beaf5d5e35 100644
--- a/platform/windows/os_windows.h
+++ b/platform/windows/os_windows.h
@@ -247,7 +247,7 @@ public:
virtual Error execute(const String &p_path, const List<String> &p_arguments, bool p_blocking, ProcessID *r_child_id = NULL, String *r_pipe = NULL, int *r_exitcode = NULL);
virtual Error kill(const ProcessID &p_pid);
- virtual int get_process_ID() const;
+ virtual int get_process_id() const;
virtual bool has_environment(const String &p_var) const;
virtual String get_environment(const String &p_var) const;
diff --git a/platform/x11/key_mapping_x11.cpp b/platform/x11/key_mapping_x11.cpp
index 1d7eb1692c..32a9806b22 100644
--- a/platform/x11/key_mapping_x11.cpp
+++ b/platform/x11/key_mapping_x11.cpp
@@ -44,7 +44,7 @@ static _XTranslatePair _xkeysym_to_keycode[] = {
{ XK_Tab, KEY_TAB },
{ XK_ISO_Left_Tab, KEY_BACKTAB },
{ XK_BackSpace, KEY_BACKSPACE },
- { XK_Return, KEY_RETURN },
+ { XK_Return, KEY_ENTER },
{ XK_Insert, KEY_INSERT },
{ XK_Delete, KEY_DELETE },
{ XK_Clear, KEY_DELETE },
@@ -78,7 +78,7 @@ static _XTranslatePair _xkeysym_to_keycode[] = {
{ XK_Help, KEY_HELP },
{ XK_KP_Space, KEY_SPACE },
{ XK_KP_Tab, KEY_TAB },
- { XK_KP_Enter, KEY_ENTER },
+ { XK_KP_Enter, KEY_KP_ENTER },
{ XK_Home, KEY_HOME },
{ XK_Left, KEY_LEFT },
{ XK_Up, KEY_UP },
diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp
index 1dde328eda..ade3a0a0c5 100644
--- a/platform/x11/os_x11.cpp
+++ b/platform/x11/os_x11.cpp
@@ -529,10 +529,6 @@ void OS_X11::finalize() {
memdelete(main_loop);
main_loop = NULL;
- for (int i = 0; i < get_audio_driver_count(); i++) {
- AudioDriverManager::get_driver(i)->finish();
- }
-
/*
if (debugger_connection_console) {
memdelete(debugger_connection_console);
diff --git a/scene/2d/animated_sprite.cpp b/scene/2d/animated_sprite.cpp
index 22649cedd7..b10ee85da5 100644
--- a/scene/2d/animated_sprite.cpp
+++ b/scene/2d/animated_sprite.cpp
@@ -346,6 +346,7 @@ void AnimatedSprite::_notification(int p_what) {
update();
_change_notify("frame");
+ emit_signal(SceneStringNames::get_singleton()->frame_changed);
}
float to_process = MIN(timeout, remaining);
diff --git a/scene/2d/area_2d.cpp b/scene/2d/area_2d.cpp
index 841e2ef7d3..02a0509449 100644
--- a/scene/2d/area_2d.cpp
+++ b/scene/2d/area_2d.cpp
@@ -480,7 +480,7 @@ Array Area2D::get_overlapping_areas() const {
bool Area2D::overlaps_area(Node *p_area) const {
ERR_FAIL_NULL_V(p_area, false);
- const Map<ObjectID, AreaState>::Element *E = area_map.find(p_area->get_instance_ID());
+ const Map<ObjectID, AreaState>::Element *E = area_map.find(p_area->get_instance_id());
if (!E)
return false;
return E->get().in_tree;
@@ -489,7 +489,7 @@ bool Area2D::overlaps_area(Node *p_area) const {
bool Area2D::overlaps_body(Node *p_body) const {
ERR_FAIL_NULL_V(p_body, false);
- const Map<ObjectID, BodyState>::Element *E = body_map.find(p_body->get_instance_ID());
+ const Map<ObjectID, BodyState>::Element *E = body_map.find(p_body->get_instance_id());
if (!E)
return false;
return E->get().in_tree;
diff --git a/scene/2d/camera_2d.cpp b/scene/2d/camera_2d.cpp
index 908c95b50c..93bfc6f705 100644
--- a/scene/2d/camera_2d.cpp
+++ b/scene/2d/camera_2d.cpp
@@ -580,7 +580,7 @@ void Camera2D::set_custom_viewport(Node *p_viewport) {
custom_viewport = p_viewport->cast_to<Viewport>();
if (custom_viewport) {
- custom_viewport_id = custom_viewport->get_instance_ID();
+ custom_viewport_id = custom_viewport->get_instance_id();
} else {
custom_viewport_id = 0;
}
diff --git a/scene/2d/collision_object_2d.cpp b/scene/2d/collision_object_2d.cpp
index eb47682884..45f956ea97 100644
--- a/scene/2d/collision_object_2d.cpp
+++ b/scene/2d/collision_object_2d.cpp
@@ -372,9 +372,9 @@ CollisionObject2D::CollisionObject2D(RID p_rid, bool p_area) {
if (p_area) {
- Physics2DServer::get_singleton()->area_attach_object_instance_ID(rid, get_instance_ID());
+ Physics2DServer::get_singleton()->area_attach_object_instance_id(rid, get_instance_id());
} else {
- Physics2DServer::get_singleton()->body_attach_object_instance_ID(rid, get_instance_ID());
+ Physics2DServer::get_singleton()->body_attach_object_instance_id(rid, get_instance_id());
}
}
diff --git a/scene/2d/node_2d.cpp b/scene/2d/node_2d.cpp
index 0acc85681d..82efe1d7fb 100644
--- a/scene/2d/node_2d.cpp
+++ b/scene/2d/node_2d.cpp
@@ -243,7 +243,7 @@ void Node2D::global_translate(const Vector2 &p_amount) {
set_global_position(get_global_position() + p_amount);
}
-void Node2D::scale(const Size2 &p_amount) {
+void Node2D::apply_scale(const Size2 &p_amount) {
set_scale(get_scale() * p_amount);
}
@@ -429,7 +429,7 @@ void Node2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("move_local_y", "delta", "scaled"), &Node2D::move_y, DEFVAL(false));
ClassDB::bind_method(D_METHOD("translate", "offset"), &Node2D::translate);
ClassDB::bind_method(D_METHOD("global_translate", "offset"), &Node2D::global_translate);
- ClassDB::bind_method(D_METHOD("scale", "ratio"), &Node2D::scale);
+ ClassDB::bind_method(D_METHOD("apply_scale", "ratio"), &Node2D::apply_scale);
ClassDB::bind_method(D_METHOD("set_global_position", "pos"), &Node2D::set_global_position);
ClassDB::bind_method(D_METHOD("get_global_position"), &Node2D::get_global_position);
diff --git a/scene/2d/node_2d.h b/scene/2d/node_2d.h
index 5b3a28d5c3..df9a05ff79 100644
--- a/scene/2d/node_2d.h
+++ b/scene/2d/node_2d.h
@@ -78,7 +78,7 @@ public:
void move_y(float p_delta, bool p_scaled = false);
void translate(const Vector2 &p_amount);
void global_translate(const Vector2 &p_amount);
- void scale(const Size2 &p_amount);
+ void apply_scale(const Size2 &p_amount);
Point2 get_position() const;
float get_rotation() const;
diff --git a/scene/2d/particles_2d.cpp b/scene/2d/particles_2d.cpp
index aa9258c7b4..b56f4f9ad9 100644
--- a/scene/2d/particles_2d.cpp
+++ b/scene/2d/particles_2d.cpp
@@ -396,6 +396,7 @@ Particles2D::Particles2D() {
set_randomness_ratio(0);
set_visibility_rect(Rect2(Vector2(-100, -100), Vector2(200, 200)));
set_use_local_coordinates(true);
+ set_draw_order(DRAW_ORDER_INDEX);
set_speed_scale(1);
h_frames = 1;
v_frames = 1;
diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp
index 8b2653f639..d5527fc9ca 100644
--- a/scene/2d/physics_body_2d.cpp
+++ b/scene/2d/physics_body_2d.cpp
@@ -798,6 +798,40 @@ bool RigidBody2D::is_contact_monitor_enabled() const {
return contact_monitor != NULL;
}
+void RigidBody2D::_notification(int p_what) {
+
+#ifdef TOOLS_ENABLED
+ if (p_what == NOTIFICATION_ENTER_TREE) {
+ if (get_tree()->is_editor_hint()) {
+ set_notify_local_transform(true); //used for warnings and only in editor
+ }
+ }
+
+ if (p_what == NOTIFICATION_LOCAL_TRANSFORM_CHANGED) {
+ if (get_tree()->is_editor_hint()) {
+ update_configuration_warning();
+ }
+ }
+
+#endif
+}
+
+String RigidBody2D::get_configuration_warning() const {
+
+ Transform2D t = get_transform();
+
+ String warning = CollisionObject2D::get_configuration_warning();
+
+ if ((get_mode() == MODE_RIGID || get_mode() == MODE_CHARACTER) && (ABS(t.elements[0].length() - 1.0) > 0.05 || ABS(t.elements[1].length() - 1.0) > 0.05)) {
+ if (warning != String()) {
+ warning += "\n";
+ }
+ warning += TTR("Size changes to RigidBody2D (in character or rigid modes) will be overriden by the physics engine when running.\nChange the size in children collision shapes instead.");
+ }
+
+ return warning;
+}
+
void RigidBody2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_mode", "mode"), &RigidBody2D::set_mode);
diff --git a/scene/2d/physics_body_2d.h b/scene/2d/physics_body_2d.h
index 8c8e4ebc77..54bd263b15 100644
--- a/scene/2d/physics_body_2d.h
+++ b/scene/2d/physics_body_2d.h
@@ -185,6 +185,7 @@ private:
bool _test_motion(const Vector2 &p_motion, float p_margin = 0.08, const Ref<Physics2DTestMotionResult> &p_result = Ref<Physics2DTestMotionResult>());
protected:
+ void _notification(int p_what);
static void _bind_methods();
public:
@@ -253,6 +254,8 @@ public:
Array get_colliding_bodies() const; //function for script
+ virtual String get_configuration_warning() const;
+
RigidBody2D();
~RigidBody2D();
};
diff --git a/scene/2d/remote_transform_2d.cpp b/scene/2d/remote_transform_2d.cpp
index 4298377499..cbd7ac06f5 100644
--- a/scene/2d/remote_transform_2d.cpp
+++ b/scene/2d/remote_transform_2d.cpp
@@ -39,7 +39,7 @@ void RemoteTransform2D::_update_cache() {
return;
}
- cache = node->get_instance_ID();
+ cache = node->get_instance_id();
}
}
diff --git a/scene/2d/sprite.cpp b/scene/2d/sprite.cpp
index ad34dfd63a..01d101a89c 100644
--- a/scene/2d/sprite.cpp
+++ b/scene/2d/sprite.cpp
@@ -237,7 +237,7 @@ void Sprite::set_vframes(int p_amount) {
vframes = p_amount;
update();
item_rect_changed();
- _change_notify("frame");
+ _change_notify();
}
int Sprite::get_vframes() const {
@@ -250,7 +250,7 @@ void Sprite::set_hframes(int p_amount) {
hframes = p_amount;
update();
item_rect_changed();
- _change_notify("frame");
+ _change_notify();
}
int Sprite::get_hframes() const {
diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp
index 9d70b75027..f8bf3edb99 100644
--- a/scene/2d/tile_map.cpp
+++ b/scene/2d/tile_map.cpp
@@ -589,7 +589,7 @@ Map<TileMap::PosKey, TileMap::Quadrant>::Element *TileMap::_create_quadrant(cons
xform.set_origin(q.pos);
//q.canvas_item = VisualServer::get_singleton()->canvas_item_create();
q.body = Physics2DServer::get_singleton()->body_create(use_kinematic ? Physics2DServer::BODY_MODE_KINEMATIC : Physics2DServer::BODY_MODE_STATIC);
- Physics2DServer::get_singleton()->body_attach_object_instance_ID(q.body, get_instance_ID());
+ Physics2DServer::get_singleton()->body_attach_object_instance_id(q.body, get_instance_id());
Physics2DServer::get_singleton()->body_set_collision_layer(q.body, collision_layer);
Physics2DServer::get_singleton()->body_set_collision_mask(q.body, collision_mask);
Physics2DServer::get_singleton()->body_set_param(q.body, Physics2DServer::BODY_PARAM_FRICTION, friction);
@@ -1144,6 +1144,20 @@ Array TileMap::get_used_cells() const {
return a;
}
+Array TileMap::get_used_cells_by_id(int p_id) const {
+
+ Array a;
+ for (Map<PosKey, Cell>::Element *E = tile_map.front(); E; E = E->next()) {
+
+ if (E->value().id == p_id) {
+ Vector2 p(E->key().x, E->key().y);
+ a.push_back(p);
+ }
+ }
+
+ return a;
+}
+
Rect2 TileMap::get_used_rect() { // Not const because of cache
if (used_size_cache_dirty) {
@@ -1262,6 +1276,7 @@ void TileMap::_bind_methods() {
ClassDB::bind_method(D_METHOD("clear"), &TileMap::clear);
ClassDB::bind_method(D_METHOD("get_used_cells"), &TileMap::get_used_cells);
+ ClassDB::bind_method(D_METHOD("get_used_cells_by_id", "id"), &TileMap::get_used_cells_by_id);
ClassDB::bind_method(D_METHOD("get_used_rect"), &TileMap::get_used_rect);
ClassDB::bind_method(D_METHOD("map_to_world", "mappos", "ignore_half_ofs"), &TileMap::map_to_world, DEFVAL(false));
diff --git a/scene/2d/tile_map.h b/scene/2d/tile_map.h
index 3468854a61..082e9d1018 100644
--- a/scene/2d/tile_map.h
+++ b/scene/2d/tile_map.h
@@ -270,6 +270,7 @@ public:
bool is_y_sort_mode_enabled() const;
Array get_used_cells() const;
+ Array get_used_cells_by_id(int p_id) const;
Rect2 get_used_rect(); // Not const because of cache
void set_occluder_light_mask(int p_mask);
diff --git a/scene/2d/visibility_notifier_2d.cpp b/scene/2d/visibility_notifier_2d.cpp
index a37c74cb07..fb71b61d45 100644
--- a/scene/2d/visibility_notifier_2d.cpp
+++ b/scene/2d/visibility_notifier_2d.cpp
@@ -33,6 +33,7 @@
#include "scene/2d/animated_sprite.h"
#include "scene/2d/physics_body_2d.h"
#include "scene/animation/animation_player.h"
+#include "scene/main/viewport.h"
#include "scene/scene_string_names.h"
#include "scene/scene_string_names.h"
diff --git a/scene/3d/area.cpp b/scene/3d/area.cpp
index 59227070b3..c64b807e43 100644
--- a/scene/3d/area.cpp
+++ b/scene/3d/area.cpp
@@ -475,7 +475,7 @@ Array Area::get_overlapping_areas() const {
bool Area::overlaps_area(Node *p_area) const {
ERR_FAIL_NULL_V(p_area, false);
- const Map<ObjectID, AreaState>::Element *E = area_map.find(p_area->get_instance_ID());
+ const Map<ObjectID, AreaState>::Element *E = area_map.find(p_area->get_instance_id());
if (!E)
return false;
return E->get().in_tree;
@@ -484,7 +484,7 @@ bool Area::overlaps_area(Node *p_area) const {
bool Area::overlaps_body(Node *p_body) const {
ERR_FAIL_NULL_V(p_body, false);
- const Map<ObjectID, BodyState>::Element *E = body_map.find(p_body->get_instance_ID());
+ const Map<ObjectID, BodyState>::Element *E = body_map.find(p_body->get_instance_id());
if (!E)
return false;
return E->get().in_tree;
diff --git a/scene/3d/arvr_nodes.cpp b/scene/3d/arvr_nodes.cpp
index 5f2a720748..3c99f7fb3a 100644
--- a/scene/3d/arvr_nodes.cpp
+++ b/scene/3d/arvr_nodes.cpp
@@ -98,6 +98,7 @@ void ARVRController::_notification(int p_what) {
is_active = false;
button_states = 0;
} else {
+ is_active = true;
set_transform(tracker->get_transform(true));
int joy_id = tracker->get_joy_id();
@@ -231,6 +232,118 @@ ARVRController::~ARVRController(){
////////////////////////////////////////////////////////////////////////////////////////////////////
+void ARVRAnchor::_notification(int p_what) {
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE: {
+ set_process_internal(true);
+ }; break;
+ case NOTIFICATION_EXIT_TREE: {
+ set_process_internal(false);
+ }; break;
+ case NOTIFICATION_INTERNAL_PROCESS: {
+ // get our ARVRServer
+ ARVRServer *arvr_server = ARVRServer::get_singleton();
+ ERR_FAIL_NULL(arvr_server);
+
+ // find the tracker for our anchor
+ ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_ANCHOR, anchor_id);
+ if (tracker == NULL) {
+ // this anchor is currently not available
+ is_active = false;
+ } else {
+ is_active = true;
+ Transform transform;
+
+ // we'll need our world_scale
+ real_t world_scale = arvr_server->get_world_scale();
+
+ // get our info from our tracker
+ transform.basis = tracker->get_orientation();
+ transform.origin = tracker->get_position(); // <-- already adjusted to world scale
+
+ // our basis is scaled to the size of the plane the anchor is tracking
+ // extract the size from our basis and reset the scale
+ size = transform.basis.get_scale() * world_scale;
+ transform.basis.set_scale(Vector3(1.0, 1.0, 1.0));
+
+ // apply our reference frame and set our transform
+ set_transform(arvr_server->get_reference_frame() * transform);
+ };
+ }; break;
+ default:
+ break;
+ };
+};
+
+void ARVRAnchor::_bind_methods() {
+
+ ClassDB::bind_method(D_METHOD("set_anchor_id", "anchor_id"), &ARVRAnchor::set_anchor_id);
+ ClassDB::bind_method(D_METHOD("get_anchor_id"), &ARVRAnchor::get_anchor_id);
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "anchor_id"), "set_anchor_id", "get_anchor_id");
+ ClassDB::bind_method(D_METHOD("get_anchor_name"), &ARVRAnchor::get_anchor_name);
+
+ ClassDB::bind_method(D_METHOD("get_is_active"), &ARVRAnchor::get_is_active);
+ ClassDB::bind_method(D_METHOD("get_size"), &ARVRAnchor::get_size);
+};
+
+void ARVRAnchor::set_anchor_id(int p_anchor_id) {
+ // we don't check any bounds here, this anchor may not yet be active and just be a place holder until it is.
+ anchor_id = p_anchor_id;
+};
+
+int ARVRAnchor::get_anchor_id(void) const {
+ return anchor_id;
+};
+
+Vector3 ARVRAnchor::get_size() const {
+ return size;
+};
+
+String ARVRAnchor::get_anchor_name(void) const {
+ // get our ARVRServer
+ ARVRServer *arvr_server = ARVRServer::get_singleton();
+ ERR_FAIL_NULL_V(arvr_server, String());
+
+ ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_ANCHOR, anchor_id);
+ if (tracker == NULL) {
+ return String("Not connected");
+ };
+
+ return tracker->get_name();
+};
+
+bool ARVRAnchor::get_is_active() const {
+ return is_active;
+};
+
+String ARVRAnchor::get_configuration_warning() const {
+ if (!is_visible() || !is_inside_tree())
+ return String();
+
+ // must be child node of ARVROrigin!
+ ARVROrigin *origin = get_parent()->cast_to<ARVROrigin>();
+ if (origin == NULL) {
+ return TTR("ARVRAnchor must have an ARVROrigin node as its parent");
+ };
+
+ if (anchor_id == 0) {
+ return TTR("The anchor id must not be 0 or this anchor will not be bound to an actual anchor");
+ };
+
+ return String();
+};
+
+ARVRAnchor::ARVRAnchor() {
+ anchor_id = 0;
+ is_active = true;
+};
+
+ARVRAnchor::~ARVRAnchor(){
+ // nothing to do here yet for now..
+};
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
String ARVROrigin::get_configuration_warning() const {
if (!is_visible() || !is_inside_tree())
return String();
diff --git a/scene/3d/arvr_nodes.h b/scene/3d/arvr_nodes.h
index 3dab263317..936519126b 100644
--- a/scene/3d/arvr_nodes.h
+++ b/scene/3d/arvr_nodes.h
@@ -39,7 +39,7 @@
**/
/*
- ARVRCamera is a subclass of camera which will register itself with its parent ARVROrigin and as a result is automatically positioned
+ ARVRCamera is a subclass of camera which will register itself with its parent ARVROrigin and as a result is automatically positioned
*/
class ARVRCamera : public Camera {
@@ -56,9 +56,9 @@ public:
};
/*
- ARVRController is a helper node that automatically updates it's position based on tracker data.
+ ARVRController is a helper node that automatically updates it's position based on tracker data.
- It must be a child node of our ARVROrigin node
+ It must be a child node of our ARVROrigin node
*/
class ARVRController : public Spatial {
@@ -92,6 +92,37 @@ public:
};
/*
+ ARVRAnchor is a helper node that automatically updates it's position based on anchor data, it represents a real world location.
+ It must be a child node of our ARVROrigin node
+*/
+
+class ARVRAnchor : public Spatial {
+ GDCLASS(ARVRAnchor, Spatial);
+
+private:
+ int anchor_id;
+ bool is_active;
+ Vector3 size;
+
+protected:
+ void _notification(int p_what);
+ static void _bind_methods();
+
+public:
+ void set_anchor_id(int p_anchor_id);
+ int get_anchor_id(void) const;
+ String get_anchor_name(void) const;
+
+ bool get_is_active() const;
+ Vector3 get_size() const;
+
+ String get_configuration_warning() const;
+
+ ARVRAnchor();
+ ~ARVRAnchor();
+};
+
+/*
ARVROrigin is special spatial node that acts as our origin point mapping our real world center of our tracking volume into our virtual world.
It is this point that you will move around the world as the player 'moves while standing still', i.e. the player moves through teleporting or controller inputs as opposed to physically moving.
diff --git a/scene/3d/collision_object.cpp b/scene/3d/collision_object.cpp
index 5a3d8e013f..2686cd81df 100644
--- a/scene/3d/collision_object.cpp
+++ b/scene/3d/collision_object.cpp
@@ -346,9 +346,9 @@ CollisionObject::CollisionObject(RID p_rid, bool p_area) {
total_subshapes = 0;
if (p_area) {
- PhysicsServer::get_singleton()->area_attach_object_instance_ID(rid, get_instance_ID());
+ PhysicsServer::get_singleton()->area_attach_object_instance_id(rid, get_instance_id());
} else {
- PhysicsServer::get_singleton()->body_attach_object_instance_ID(rid, get_instance_ID());
+ PhysicsServer::get_singleton()->body_attach_object_instance_id(rid, get_instance_id());
}
//set_transform_notify(true);
}
diff --git a/scene/3d/physics_body.cpp b/scene/3d/physics_body.cpp
index 7e599ce2f5..9feed2fe7b 100644
--- a/scene/3d/physics_body.cpp
+++ b/scene/3d/physics_body.cpp
@@ -473,6 +473,21 @@ void RigidBody::_direct_state_changed(Object *p_state) {
}
void RigidBody::_notification(int p_what) {
+
+#ifdef TOOLS_ENABLED
+ if (p_what == NOTIFICATION_ENTER_TREE) {
+ if (get_tree()->is_editor_hint()) {
+ set_notify_local_transform(true); //used for warnings and only in editor
+ }
+ }
+
+ if (p_what == NOTIFICATION_LOCAL_TRANSFORM_CHANGED) {
+ if (get_tree()->is_editor_hint()) {
+ update_configuration_warning();
+ }
+ }
+
+#endif
}
void RigidBody::set_mode(Mode p_mode) {
@@ -747,6 +762,22 @@ Array RigidBody::get_colliding_bodies() const {
return ret;
}
+String RigidBody::get_configuration_warning() const {
+
+ Transform t = get_transform();
+
+ String warning = CollisionObject::get_configuration_warning();
+
+ if ((get_mode() == MODE_RIGID || get_mode() == MODE_CHARACTER) && (ABS(t.basis.get_axis(0).length() - 1.0) > 0.05 || ABS(t.basis.get_axis(1).length() - 1.0) > 0.05 || ABS(t.basis.get_axis(0).length() - 1.0) > 0.05)) {
+ if (warning != String()) {
+ warning += "\n";
+ }
+ warning += TTR("Size changes to RigidBody (in character or rigid modes) will be overriden by the physics engine when running.\nChange the size in children collision shapes instead.");
+ }
+
+ return warning;
+}
+
void RigidBody::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_mode", "mode"), &RigidBody::set_mode);
diff --git a/scene/3d/physics_body.h b/scene/3d/physics_body.h
index f86d7d957f..83811a1d93 100644
--- a/scene/3d/physics_body.h
+++ b/scene/3d/physics_body.h
@@ -252,6 +252,8 @@ public:
void apply_impulse(const Vector3 &p_pos, const Vector3 &p_impulse);
+ virtual String get_configuration_warning() const;
+
RigidBody();
~RigidBody();
};
diff --git a/scene/3d/physics_joint.cpp b/scene/3d/physics_joint.cpp
index 3fb5c828c2..61d496935b 100644
--- a/scene/3d/physics_joint.cpp
+++ b/scene/3d/physics_joint.cpp
@@ -979,9 +979,9 @@ Generic6DOFJoint::Generic6DOFJoint() {
void PhysicsJoint::_set(const String& p_name, const Variant& p_value) {
if (p_name=="body_A")
- set_body_A(p_value);
+ set_body_a(p_value);
else if (p_name=="body_B")
- set_body_B(p_value);
+ set_body_b(p_value);
else if (p_name=="active")
set_active(p_value);
else if (p_name=="no_collision")
@@ -990,9 +990,9 @@ void PhysicsJoint::_set(const String& p_name, const Variant& p_value) {
Variant PhysicsJoint::_get(const String& p_name) const {
if (p_name=="body_A")
- return get_body_A();
+ return get_body_a();
else if (p_name=="body_B")
- return get_body_B();
+ return get_body_b();
else if (p_name=="active")
return is_active();
else if (p_name=="no_collision")
@@ -1034,7 +1034,7 @@ void PhysicsJoint::_notification(int p_what) {
if (indicator.is_valid()) {
indicator_instance=VisualServer::get_singleton()->instance_create(indicator,get_world()->get_scenario());
- VisualServer::get_singleton()->instance_attach_object_instance_ID( indicator_instance,get_instance_ID() );
+ VisualServer::get_singleton()->instance_attach_object_instance_id( indicator_instance,get_instance_id() );
}
} break;
case NOTIFICATION_TRANSFORM_CHANGED: {
@@ -1067,10 +1067,10 @@ RID PhysicsJoint::_get_visual_instance_rid() const {
void PhysicsJoint::_bind_methods() {
ClassDB::bind_method(D_METHOD("_get_visual_instance_rid"),&PhysicsJoint::_get_visual_instance_rid);
- ClassDB::bind_method(D_METHOD("set_body_A","path"),&PhysicsJoint::set_body_A);
- ClassDB::bind_method(D_METHOD("set_body_B"),&PhysicsJoint::set_body_B);
- ClassDB::bind_method(D_METHOD("get_body_A","path"),&PhysicsJoint::get_body_A);
- ClassDB::bind_method(D_METHOD("get_body_B"),&PhysicsJoint::get_body_B);
+ ClassDB::bind_method(D_METHOD("set_body_a","path"),&PhysicsJoint::set_body_a);
+ ClassDB::bind_method(D_METHOD("set_body_b"),&PhysicsJoint::set_body_b);
+ ClassDB::bind_method(D_METHOD("get_body_a","path"),&PhysicsJoint::get_body_a);
+ ClassDB::bind_method(D_METHOD("get_body_b"),&PhysicsJoint::get_body_b);
ClassDB::bind_method(D_METHOD("set_active","active"),&PhysicsJoint::set_active);
ClassDB::bind_method(D_METHOD("is_active"),&PhysicsJoint::is_active);
@@ -1085,14 +1085,14 @@ void PhysicsJoint::_bind_methods() {
}
-void PhysicsJoint::set_body_A(const NodePath& p_path) {
+void PhysicsJoint::set_body_a(const NodePath& p_path) {
_disconnect();
body_A=p_path;
_connect();
_change_notify("body_A");
}
-void PhysicsJoint::set_body_B(const NodePath& p_path) {
+void PhysicsJoint::set_body_b(const NodePath& p_path) {
_disconnect();
body_B=p_path;
@@ -1100,11 +1100,11 @@ void PhysicsJoint::set_body_B(const NodePath& p_path) {
_change_notify("body_B");
}
-NodePath PhysicsJoint::get_body_A() const {
+NodePath PhysicsJoint::get_body_a() const {
return body_A;
}
-NodePath PhysicsJoint::get_body_B() const {
+NodePath PhysicsJoint::get_body_b() const {
return body_B;
}
diff --git a/scene/3d/physics_joint.h b/scene/3d/physics_joint.h
index 2b221e25f2..b834aaf6d2 100644
--- a/scene/3d/physics_joint.h
+++ b/scene/3d/physics_joint.h
@@ -354,10 +354,10 @@ protected:
void _connect();
public:
- void set_body_A(const NodePath& p_path);
- void set_body_B(const NodePath& p_path);
- NodePath get_body_A() const;
- NodePath get_body_B() const;
+ void set_body_a(const NodePath& p_path);
+ void set_body_b(const NodePath& p_path);
+ NodePath get_body_a() const;
+ NodePath get_body_b() const;
void set_active(bool p_active);
bool is_active() const;
diff --git a/scene/3d/remote_transform.cpp b/scene/3d/remote_transform.cpp
index 4dcfb5f94e..492930ea9b 100644
--- a/scene/3d/remote_transform.cpp
+++ b/scene/3d/remote_transform.cpp
@@ -39,7 +39,7 @@ void RemoteTransform::_update_cache() {
return;
}
- cache = node->get_instance_ID();
+ cache = node->get_instance_id();
}
}
diff --git a/scene/3d/skeleton.cpp b/scene/3d/skeleton.cpp
index 71af77c027..ea5d21cd4e 100644
--- a/scene/3d/skeleton.cpp
+++ b/scene/3d/skeleton.cpp
@@ -407,7 +407,7 @@ void Skeleton::bind_child_node_to_bone(int p_bone, Node *p_node) {
ERR_FAIL_NULL(p_node);
ERR_FAIL_INDEX(p_bone, bones.size());
- uint32_t id = p_node->get_instance_ID();
+ uint32_t id = p_node->get_instance_id();
for (List<uint32_t>::Element *E = bones[p_bone].nodes_bound.front(); E; E = E->next()) {
@@ -422,7 +422,7 @@ void Skeleton::unbind_child_node_from_bone(int p_bone, Node *p_node) {
ERR_FAIL_NULL(p_node);
ERR_FAIL_INDEX(p_bone, bones.size());
- uint32_t id = p_node->get_instance_ID();
+ uint32_t id = p_node->get_instance_id();
bones[p_bone].nodes_bound.erase(id);
}
void Skeleton::get_bound_child_nodes_to_bone(int p_bone, List<Node *> *p_bound) const {
diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp
index 78e8e92afc..1b9b58ceb1 100644
--- a/scene/3d/sprite_3d.cpp
+++ b/scene/3d/sprite_3d.cpp
@@ -502,7 +502,7 @@ void Sprite3D::set_vframes(int p_amount) {
ERR_FAIL_COND(p_amount < 1);
vframes = p_amount;
_queue_update();
- _change_notify("frame");
+ _change_notify();
}
int Sprite3D::get_vframes() const {
@@ -514,7 +514,7 @@ void Sprite3D::set_hframes(int p_amount) {
ERR_FAIL_COND(p_amount < 1);
hframes = p_amount;
_queue_update();
- _change_notify("frame");
+ _change_notify();
}
int Sprite3D::get_hframes() const {
diff --git a/scene/3d/visibility_notifier.cpp b/scene/3d/visibility_notifier.cpp
index 5e6561adb7..cc81a4cb56 100644
--- a/scene/3d/visibility_notifier.cpp
+++ b/scene/3d/visibility_notifier.cpp
@@ -29,6 +29,7 @@
/*************************************************************************/
#include "visibility_notifier.h"
+#include "scene/3d/camera.h"
#include "scene/3d/physics_body.h"
#include "scene/animation/animation_player.h"
#include "scene/scene_string_names.h"
@@ -42,6 +43,7 @@ void VisibilityNotifier::_enter_camera(Camera *p_camera) {
emit_signal(SceneStringNames::get_singleton()->screen_entered);
_screen_enter();
}
+
emit_signal(SceneStringNames::get_singleton()->camera_entered, p_camera);
}
diff --git a/scene/3d/visual_instance.cpp b/scene/3d/visual_instance.cpp
index 6f8c38eddd..1a294d016a 100644
--- a/scene/3d/visual_instance.cpp
+++ b/scene/3d/visual_instance.cpp
@@ -149,7 +149,7 @@ void VisualInstance::set_base(const RID &p_base) {
VisualInstance::VisualInstance() {
instance = VisualServer::get_singleton()->instance_create();
- VisualServer::get_singleton()->instance_attach_object_instance_ID(instance, get_instance_ID());
+ VisualServer::get_singleton()->instance_attach_object_instance_id(instance, get_instance_id());
layers = 1;
set_notify_transform(true);
}
diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp
index 543b64bd15..7173a820b4 100644
--- a/scene/animation/animation_player.cpp
+++ b/scene/animation/animation_player.cpp
@@ -247,7 +247,7 @@ void AnimationPlayer::_generate_node_caches(AnimationData *p_anim) {
ERR_EXPLAIN("On Animation: '" + p_anim->name + "', couldn't resolve track: '" + String(a->track_get_path(i)) + "'");
}
ERR_CONTINUE(!child); // couldn't find the child node
- uint32_t id = resource.is_valid() ? resource->get_instance_ID() : child->get_instance_ID();
+ uint32_t id = resource.is_valid() ? resource->get_instance_id() : child->get_instance_id();
int bone_idx = -1;
if (a->track_get_path(i).get_property() && child->cast_to<Skeleton>()) {
@@ -1268,7 +1268,7 @@ void AnimationPlayer::_bind_methods() {
ClassDB::bind_method(D_METHOD("advance", "delta"), &AnimationPlayer::advance);
- ADD_GROUP("Playback", "playback_");
+ ADD_GROUP("Playback Options", "playback_");
ADD_PROPERTY(PropertyInfo(Variant::INT, "playback_process_mode", PROPERTY_HINT_ENUM, "Fixed,Idle"), "set_animation_process_mode", "get_animation_process_mode");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "playback_default_blend_time", PROPERTY_HINT_RANGE, "0,4096,0.01"), "set_default_blend_time", "get_default_blend_time");
ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "root_node"), "set_root", "get_root");
diff --git a/scene/animation/animation_tree_player.cpp b/scene/animation/animation_tree_player.cpp
index 7c2684ba47..6a9c2587d5 100644
--- a/scene/animation/animation_tree_player.cpp
+++ b/scene/animation/animation_tree_player.cpp
@@ -1481,7 +1481,7 @@ AnimationTreePlayer::Track *AnimationTreePlayer::_find_track(const NodePath &p_p
return NULL;
}
- ObjectID id = child->get_instance_ID();
+ ObjectID id = child->get_instance_id();
StringName property;
int bone_idx = -1;
diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp
index ad0b0fbfb2..78d3357bb4 100644
--- a/scene/animation/tween.cpp
+++ b/scene/animation/tween.cpp
@@ -1024,7 +1024,7 @@ bool Tween::interpolate_property(Object *p_object, String p_property, Variant p_
data.finish = false;
data.elapsed = 0;
- data.id = p_object->get_instance_ID();
+ data.id = p_object->get_instance_id();
data.key = p_property;
data.initial_val = p_initial_val;
data.final_val = p_final_val;
@@ -1066,7 +1066,7 @@ bool Tween::interpolate_method(Object *p_object, String p_method, Variant p_init
data.finish = false;
data.elapsed = 0;
- data.id = p_object->get_instance_ID();
+ data.id = p_object->get_instance_id();
data.key = p_method;
data.initial_val = p_initial_val;
data.final_val = p_final_val;
@@ -1103,7 +1103,7 @@ bool Tween::interpolate_callback(Object *p_object, real_t p_duration, String p_c
data.call_deferred = false;
data.elapsed = 0;
- data.id = p_object->get_instance_ID();
+ data.id = p_object->get_instance_id();
data.key = p_callback;
data.duration = p_duration;
data.delay = 0;
@@ -1155,7 +1155,7 @@ bool Tween::interpolate_deferred_callback(Object *p_object, real_t p_duration, S
data.call_deferred = true;
data.elapsed = 0;
- data.id = p_object->get_instance_ID();
+ data.id = p_object->get_instance_id();
data.key = p_callback;
data.duration = p_duration;
data.delay = 0;
@@ -1222,10 +1222,10 @@ bool Tween::follow_property(Object *p_object, String p_property, Variant p_initi
data.finish = false;
data.elapsed = 0;
- data.id = p_object->get_instance_ID();
+ data.id = p_object->get_instance_id();
data.key = p_property;
data.initial_val = p_initial_val;
- data.target_id = p_target->get_instance_ID();
+ data.target_id = p_target->get_instance_id();
data.target_key = p_target_property;
data.duration = p_duration;
data.trans_type = p_trans_type;
@@ -1272,10 +1272,10 @@ bool Tween::follow_method(Object *p_object, String p_method, Variant p_initial_v
data.finish = false;
data.elapsed = 0;
- data.id = p_object->get_instance_ID();
+ data.id = p_object->get_instance_id();
data.key = p_method;
data.initial_val = p_initial_val;
- data.target_id = p_target->get_instance_ID();
+ data.target_id = p_target->get_instance_id();
data.target_key = p_target_method;
data.duration = p_duration;
data.trans_type = p_trans_type;
@@ -1321,9 +1321,9 @@ bool Tween::targeting_property(Object *p_object, String p_property, Object *p_in
data.finish = false;
data.elapsed = 0;
- data.id = p_object->get_instance_ID();
+ data.id = p_object->get_instance_id();
data.key = p_property;
- data.target_id = p_initial->get_instance_ID();
+ data.target_id = p_initial->get_instance_id();
data.target_key = p_initial_property;
data.initial_val = initial_val;
data.final_val = p_final_val;
@@ -1375,9 +1375,9 @@ bool Tween::targeting_method(Object *p_object, String p_method, Object *p_initia
data.finish = false;
data.elapsed = 0;
- data.id = p_object->get_instance_ID();
+ data.id = p_object->get_instance_id();
data.key = p_method;
- data.target_id = p_initial->get_instance_ID();
+ data.target_id = p_initial->get_instance_id();
data.target_key = p_initial_method;
data.initial_val = initial_val;
data.final_val = p_final_val;
diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp
index 9a5f55698e..4d55d8df75 100644
--- a/scene/gui/base_button.cpp
+++ b/scene/gui/base_button.cpp
@@ -508,7 +508,7 @@ void BaseButton::_bind_methods() {
ADD_SIGNAL(MethodInfo("toggled", PropertyInfo(Variant::BOOL, "pressed")));
ADD_PROPERTYNZ(PropertyInfo(Variant::BOOL, "disabled"), "set_disabled", "is_disabled");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "toggle_mode"), "set_toggle_mode", "is_toggle_mode");
- ADD_PROPERTYNZ(PropertyInfo(Variant::BOOL, "is_pressed"), "set_pressed", "is_pressed");
+ ADD_PROPERTYNZ(PropertyInfo(Variant::BOOL, "pressed"), "set_pressed", "is_pressed");
ADD_PROPERTYNO(PropertyInfo(Variant::INT, "action_mode", PROPERTY_HINT_ENUM, "Button Press,Button Release"), "set_action_mode", "get_action_mode");
ADD_PROPERTY(PropertyInfo(Variant::INT, "enabled_focus_mode", PROPERTY_HINT_ENUM, "None,Click,All"), "set_enabled_focus_mode", "get_enabled_focus_mode");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "shortcut", PROPERTY_HINT_RESOURCE_TYPE, "ShortCut"), "set_shortcut", "get_shortcut");
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index ca81b72e89..339b4e079e 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -603,7 +603,7 @@ bool Control::has_point(const Point2 &p_point) const {
void Control::set_drag_forwarding(Control *p_target) {
if (p_target)
- data.drag_owner = p_target->get_instance_ID();
+ data.drag_owner = p_target->get_instance_id();
else
data.drag_owner = 0;
}
diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp
index 97f49da2be..34533375b2 100644
--- a/scene/gui/item_list.cpp
+++ b/scene/gui/item_list.cpp
@@ -431,7 +431,7 @@ void ItemList::_gui_input(const Ref<InputEvent> &p_event) {
if (mb.is_valid() && (mb->get_button_index() == BUTTON_LEFT || (allow_rmb_select && mb->get_button_index() == BUTTON_RIGHT)) && mb->is_pressed()) {
search_string = ""; //any mousepress cancels
- Vector2 pos(mb->get_position().x, mb->get_position().y);
+ Vector2 pos = mb->get_position();
Ref<StyleBox> bg = get_stylebox("bg");
pos -= bg->get_offset();
pos.y += scroll_bar->get_value();
@@ -475,7 +475,7 @@ void ItemList::_gui_input(const Ref<InputEvent> &p_event) {
if (mb->get_button_index() == BUTTON_RIGHT) {
- emit_signal("item_rmb_selected", i, Vector2(mb->get_position().x, mb->get_position().y));
+ emit_signal("item_rmb_selected", i, pos);
}
} else {
@@ -486,7 +486,7 @@ void ItemList::_gui_input(const Ref<InputEvent> &p_event) {
if (items[i].selected && mb->get_button_index() == BUTTON_RIGHT) {
- emit_signal("item_rmb_selected", i, Vector2(mb->get_position().x, mb->get_position().y));
+ emit_signal("item_rmb_selected", i, pos);
} else {
bool selected = !items[i].selected;
@@ -501,7 +501,7 @@ void ItemList::_gui_input(const Ref<InputEvent> &p_event) {
if (mb->get_button_index() == BUTTON_RIGHT) {
- emit_signal("item_rmb_selected", i, Vector2(mb->get_position().x, mb->get_position().y));
+ emit_signal("item_rmb_selected", i, pos);
} else if (/*select_mode==SELECT_SINGLE &&*/ mb->is_doubleclick()) {
emit_signal("item_activated", i);
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp
index f4dd3e92cd..8556ce5db1 100644
--- a/scene/gui/line_edit.cpp
+++ b/scene/gui/line_edit.cpp
@@ -229,8 +229,8 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) {
bool handled = true;
switch (code) {
- case KEY_ENTER:
- case KEY_RETURN: {
+ case KEY_KP_ENTER:
+ case KEY_ENTER: {
emit_signal("text_entered", text);
if (OS::get_singleton()->has_virtual_keyboard())
diff --git a/scene/gui/menu_button.cpp b/scene/gui/menu_button.cpp
index fe76b16460..57aa72b7d0 100644
--- a/scene/gui/menu_button.cpp
+++ b/scene/gui/menu_button.cpp
@@ -55,7 +55,6 @@ void MenuButton::pressed() {
popup->set_size(Size2(size.width, 0));
popup->set_parent_rect(Rect2(Point2(gp - popup->get_global_position()), get_size()));
popup->popup();
- popup->call_deferred("grab_click_focus");
popup->set_invalidate_click_until_motion();
}
@@ -112,6 +111,7 @@ MenuButton::MenuButton() {
popup->hide();
add_child(popup);
popup->set_as_toplevel(true);
+ connect("button_up", popup, "call_deferred", make_binds("grab_click_focus"));
set_process_unhandled_key_input(true);
set_action_mode(ACTION_MODE_BUTTON_PRESS);
}
diff --git a/scene/gui/option_button.cpp b/scene/gui/option_button.cpp
index b842419eab..60874edf38 100644
--- a/scene/gui/option_button.cpp
+++ b/scene/gui/option_button.cpp
@@ -82,7 +82,7 @@ void OptionButton::_selected(int p_which) {
int selid = -1;
for (int i = 0; i < popup->get_item_count(); i++) {
- bool is_clicked = popup->get_item_ID(i) == p_which;
+ bool is_clicked = popup->get_item_id(i) == p_which;
if (is_clicked) {
selid = i;
break;
@@ -129,9 +129,9 @@ void OptionButton::set_item_icon(int p_idx, const Ref<Texture> &p_icon) {
popup->set_item_icon(p_idx, p_icon);
}
-void OptionButton::set_item_ID(int p_idx, int p_ID) {
+void OptionButton::set_item_id(int p_idx, int p_ID) {
- popup->set_item_ID(p_idx, p_ID);
+ popup->set_item_id(p_idx, p_ID);
}
void OptionButton::set_item_metadata(int p_idx, const Variant &p_metadata) {
@@ -154,9 +154,9 @@ Ref<Texture> OptionButton::get_item_icon(int p_idx) const {
return popup->get_item_icon(p_idx);
}
-int OptionButton::get_item_ID(int p_idx) const {
+int OptionButton::get_item_id(int p_idx) const {
- return popup->get_item_ID(p_idx);
+ return popup->get_item_id(p_idx);
}
Variant OptionButton::get_item_metadata(int p_idx) const {
@@ -224,12 +224,12 @@ int OptionButton::get_selected() const {
return current;
}
-int OptionButton::get_selected_ID() const {
+int OptionButton::get_selected_id() const {
int idx = get_selected();
if (idx < 0)
return 0;
- return get_item_ID(current);
+ return get_item_id(current);
}
Variant OptionButton::get_selected_metadata() const {
@@ -252,7 +252,7 @@ Array OptionButton::_get_items() const {
items.push_back(get_item_text(i));
items.push_back(get_item_icon(i));
items.push_back(is_item_disabled(i));
- items.push_back(get_item_ID(i));
+ items.push_back(get_item_id(i));
items.push_back(get_item_metadata(i));
}
@@ -293,11 +293,11 @@ void OptionButton::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_item_text", "idx", "text"), &OptionButton::set_item_text);
ClassDB::bind_method(D_METHOD("set_item_icon", "idx", "texture:Texture"), &OptionButton::set_item_icon);
ClassDB::bind_method(D_METHOD("set_item_disabled", "idx", "disabled"), &OptionButton::set_item_disabled);
- ClassDB::bind_method(D_METHOD("set_item_ID", "idx", "id"), &OptionButton::set_item_ID);
+ ClassDB::bind_method(D_METHOD("set_item_id", "idx", "id"), &OptionButton::set_item_id);
ClassDB::bind_method(D_METHOD("set_item_metadata", "idx", "metadata"), &OptionButton::set_item_metadata);
ClassDB::bind_method(D_METHOD("get_item_text", "idx"), &OptionButton::get_item_text);
ClassDB::bind_method(D_METHOD("get_item_icon:Texture", "idx"), &OptionButton::get_item_icon);
- ClassDB::bind_method(D_METHOD("get_item_ID", "idx"), &OptionButton::get_item_ID);
+ ClassDB::bind_method(D_METHOD("get_item_id", "idx"), &OptionButton::get_item_id);
ClassDB::bind_method(D_METHOD("get_item_metadata:Variant", "idx"), &OptionButton::get_item_metadata);
ClassDB::bind_method(D_METHOD("is_item_disabled", "idx"), &OptionButton::is_item_disabled);
ClassDB::bind_method(D_METHOD("get_item_count"), &OptionButton::get_item_count);
@@ -305,7 +305,7 @@ void OptionButton::_bind_methods() {
ClassDB::bind_method(D_METHOD("clear"), &OptionButton::clear);
ClassDB::bind_method(D_METHOD("select", "idx"), &OptionButton::select);
ClassDB::bind_method(D_METHOD("get_selected"), &OptionButton::get_selected);
- ClassDB::bind_method(D_METHOD("get_selected_ID"), &OptionButton::get_selected_ID);
+ ClassDB::bind_method(D_METHOD("get_selected_id"), &OptionButton::get_selected_id);
ClassDB::bind_method(D_METHOD("get_selected_metadata:Variant"), &OptionButton::get_selected_metadata);
ClassDB::bind_method(D_METHOD("remove_item", "idx"), &OptionButton::remove_item);
ClassDB::bind_method(D_METHOD("_select_int"), &OptionButton::_select_int);
diff --git a/scene/gui/option_button.h b/scene/gui/option_button.h
index 887d199c90..db921b8b97 100644
--- a/scene/gui/option_button.h
+++ b/scene/gui/option_button.h
@@ -62,13 +62,13 @@ public:
void set_item_text(int p_idx, const String &p_text);
void set_item_icon(int p_idx, const Ref<Texture> &p_icon);
- void set_item_ID(int p_idx, int p_ID);
+ void set_item_id(int p_idx, int p_ID);
void set_item_metadata(int p_idx, const Variant &p_metadata);
void set_item_disabled(int p_idx, bool p_disabled);
String get_item_text(int p_idx) const;
Ref<Texture> get_item_icon(int p_idx) const;
- int get_item_ID(int p_idx) const;
+ int get_item_id(int p_idx) const;
Variant get_item_metadata(int p_idx) const;
bool is_item_disabled(int p_idx) const;
@@ -80,7 +80,7 @@ public:
void select(int p_idx);
int get_selected() const;
- int get_selected_ID() const;
+ int get_selected_id() const;
Variant get_selected_metadata() const;
void remove_item(int p_idx);
diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp
index f59a2e06eb..e3f9a09db3 100644
--- a/scene/gui/popup_menu.cpp
+++ b/scene/gui/popup_menu.cpp
@@ -249,8 +249,8 @@ void PopupMenu::_gui_input(const Ref<InputEvent> &p_event) {
}
}
} break;
- case KEY_RETURN:
- case KEY_ENTER: {
+ case KEY_ENTER:
+ case KEY_KP_ENTER: {
if (mouse_over >= 0 && mouse_over < items.size() && !items[mouse_over].separator) {
@@ -647,7 +647,7 @@ void PopupMenu::set_item_checked(int p_idx, bool p_checked) {
update();
}
-void PopupMenu::set_item_ID(int p_idx, int p_ID) {
+void PopupMenu::set_item_id(int p_idx, int p_ID) {
ERR_FAIL_INDEX(p_idx, items.size());
items[p_idx].ID = p_ID;
@@ -737,7 +737,7 @@ bool PopupMenu::is_item_checked(int p_idx) const {
return items[p_idx].checked;
}
-int PopupMenu::get_item_ID(int p_idx) const {
+int PopupMenu::get_item_id(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx, items.size(), 0);
return items[p_idx].ID;
@@ -956,7 +956,7 @@ Array PopupMenu::_get_items() const {
items.push_back(is_item_checked(i));
items.push_back(is_item_disabled(i));
- items.push_back(get_item_ID(i));
+ items.push_back(get_item_id(i));
items.push_back(get_item_accelerator(i));
items.push_back(get_item_metadata(i));
items.push_back(get_item_submenu(i));
@@ -1011,7 +1011,7 @@ void PopupMenu::_set_items(const Array &p_items) {
set_item_as_checkable(idx, checkable);
set_item_checked(idx, checked);
set_item_disabled(idx, disabled);
- set_item_ID(idx, id);
+ set_item_id(idx, id);
set_item_metadata(idx, meta);
set_item_as_separator(idx, sep);
set_item_accelerator(idx, accel);
@@ -1089,7 +1089,7 @@ void PopupMenu::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_item_text", "idx", "text"), &PopupMenu::set_item_text);
ClassDB::bind_method(D_METHOD("set_item_icon", "idx", "icon:Texture"), &PopupMenu::set_item_icon);
ClassDB::bind_method(D_METHOD("set_item_checked", "idx", "checked"), &PopupMenu::set_item_checked);
- ClassDB::bind_method(D_METHOD("set_item_ID", "idx", "id"), &PopupMenu::set_item_ID);
+ ClassDB::bind_method(D_METHOD("set_item_id", "idx", "id"), &PopupMenu::set_item_id);
ClassDB::bind_method(D_METHOD("set_item_accelerator", "idx", "accel"), &PopupMenu::set_item_accelerator);
ClassDB::bind_method(D_METHOD("set_item_metadata", "idx", "metadata"), &PopupMenu::set_item_metadata);
ClassDB::bind_method(D_METHOD("set_item_disabled", "idx", "disabled"), &PopupMenu::set_item_disabled);
@@ -1104,7 +1104,7 @@ void PopupMenu::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_item_text", "idx"), &PopupMenu::get_item_text);
ClassDB::bind_method(D_METHOD("get_item_icon:Texture", "idx"), &PopupMenu::get_item_icon);
ClassDB::bind_method(D_METHOD("is_item_checked", "idx"), &PopupMenu::is_item_checked);
- ClassDB::bind_method(D_METHOD("get_item_ID", "idx"), &PopupMenu::get_item_ID);
+ ClassDB::bind_method(D_METHOD("get_item_id", "idx"), &PopupMenu::get_item_id);
ClassDB::bind_method(D_METHOD("get_item_index", "id"), &PopupMenu::get_item_index);
ClassDB::bind_method(D_METHOD("get_item_accelerator", "idx"), &PopupMenu::get_item_accelerator);
ClassDB::bind_method(D_METHOD("get_item_metadata:Variant", "idx"), &PopupMenu::get_item_metadata);
diff --git a/scene/gui/popup_menu.h b/scene/gui/popup_menu.h
index 6f1a2db363..cbfe7873e6 100644
--- a/scene/gui/popup_menu.h
+++ b/scene/gui/popup_menu.h
@@ -118,7 +118,7 @@ public:
void set_item_text(int p_idx, const String &p_text);
void set_item_icon(int p_idx, const Ref<Texture> &p_icon);
void set_item_checked(int p_idx, bool p_checked);
- void set_item_ID(int p_idx, int p_ID);
+ void set_item_id(int p_idx, int p_ID);
void set_item_accelerator(int p_idx, uint32_t p_accel);
void set_item_metadata(int p_idx, const Variant &p_meta);
void set_item_disabled(int p_idx, bool p_disabled);
@@ -135,7 +135,7 @@ public:
int get_item_idx_from_text(const String &text) const;
Ref<Texture> get_item_icon(int p_idx) const;
bool is_item_checked(int p_idx) const;
- int get_item_ID(int p_idx) const;
+ int get_item_id(int p_idx) const;
int get_item_index(int p_ID) const;
uint32_t get_item_accelerator(int p_idx) const;
Variant get_item_metadata(int p_idx) const;
diff --git a/scene/gui/tabs.cpp b/scene/gui/tabs.cpp
index 24eb19fbc2..a2deef4eea 100644
--- a/scene/gui/tabs.cpp
+++ b/scene/gui/tabs.cpp
@@ -226,7 +226,6 @@ void Tabs::_gui_input(const Ref<InputEvent> &p_event) {
if (found != -1) {
set_current_tab(found);
- emit_signal("tab_changed", found);
}
}
}
@@ -419,6 +418,7 @@ int Tabs::get_tab_count() const {
void Tabs::set_current_tab(int p_current) {
+ if (current == p_current) return;
ERR_FAIL_INDEX(p_current, get_tab_count());
current = p_current;
@@ -426,6 +426,8 @@ void Tabs::set_current_tab(int p_current) {
_change_notify("current_tab");
_update_cache();
update();
+
+ emit_signal("tab_changed", p_current);
}
int Tabs::get_current_tab() const {
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 8baca50d32..a7c31361e8 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -49,6 +49,10 @@ static bool _is_symbol(CharType c) {
return c != '_' && ((c >= '!' && c <= '/') || (c >= ':' && c <= '@') || (c >= '[' && c <= '`') || (c >= '{' && c <= '~') || c == '\t' || c == ' ');
}
+static bool _is_whitespace(CharType c) {
+ return c == '\t' || c == ' ';
+}
+
static bool _is_char(CharType c) {
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_';
@@ -1801,7 +1805,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
return;
}
- if (k->get_scancode() == KEY_ENTER || k->get_scancode() == KEY_RETURN || k->get_scancode() == KEY_TAB) {
+ if (k->get_scancode() == KEY_KP_ENTER || k->get_scancode() == KEY_ENTER || k->get_scancode() == KEY_TAB) {
_confirm_completion();
accept_event();
@@ -1970,8 +1974,8 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
switch (k->get_scancode()) {
- case KEY_ENTER:
- case KEY_RETURN: {
+ case KEY_KP_ENTER:
+ case KEY_ENTER: {
if (readonly)
break;
@@ -2096,45 +2100,43 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
break;
#ifdef APPLE_STYLE_KEYS
- if (k->get_alt()) {
+ if (k->get_alt() && cursor.column > 1) {
#else
if (k->get_alt()) {
scancode_handled = false;
break;
- } else if (k->get_command()) {
+ } else if (k->get_command() && cursor.column > 1) {
#endif
int line = cursor.line;
int column = cursor.column;
- bool prev_char = false;
- bool only_whitespace = true;
-
- while (only_whitespace && line > 0) {
-
- while (column > 0) {
- CharType c = text[line][column - 1];
-
- if (c != '\t' && c != ' ') {
- only_whitespace = false;
- break;
- }
+ // check if we are removing a single whitespace, if so remove it and the next char type
+ // else we just remove the whitespace
+ bool only_whitespace = false;
+ if (_is_whitespace(text[line][column - 1]) && _is_whitespace(text[line][column - 2])) {
+ only_whitespace = true;
+ } else if (_is_whitespace(text[line][column - 1])) {
+ // remove the single whitespace
+ column--;
+ }
- column--;
- }
+ // check if its a text char
+ bool only_char = (_is_text_char(text[line][column - 1]) && !only_whitespace);
- if (only_whitespace) {
- line--;
- column = text[line].length();
- }
- }
+ // if its not whitespace or char then symbol.
+ bool only_symbols = !(only_whitespace || only_char);
while (column > 0) {
- bool ischar = _is_text_char(text[line][column - 1]);
+ bool is_whitespace = _is_whitespace(text[line][column - 1]);
+ bool is_text_char = _is_text_char(text[line][column - 1]);
- if (prev_char && !ischar)
+ if (only_whitespace && !is_whitespace) {
break;
-
- prev_char = ischar;
+ } else if (only_char && !is_text_char) {
+ break;
+ } else if (only_symbols && (is_whitespace || is_text_char)) {
+ break;
+ }
column--;
}
@@ -2356,52 +2358,50 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
int next_column;
#ifdef APPLE_STYLE_KEYS
- if (k->get_alt()) {
+ if (k->get_alt() && cursor.column < curline_len - 1) {
#else
if (k->get_alt()) {
scancode_handled = false;
break;
- } else if (k->get_command()) {
+ } else if (k->get_command() && cursor.column < curline_len - 1) {
#endif
- int last_line = text.size() - 1;
int line = cursor.line;
int column = cursor.column;
- bool prev_char = false;
- bool only_whitespace = true;
-
- while (only_whitespace && line < last_line) {
-
- while (column < text[line].length()) {
- CharType c = text[line][column];
-
- if (c != '\t' && c != ' ') {
- only_whitespace = false;
- break;
- }
-
- column++;
- }
-
- if (only_whitespace) {
- line++;
- column = 0;
- }
+ // check if we are removing a single whitespace, if so remove it and the next char type
+ // else we just remove the whitespace
+ bool only_whitespace = false;
+ if (_is_whitespace(text[line][column]) && _is_whitespace(text[line][column + 1])) {
+ only_whitespace = true;
+ } else if (_is_whitespace(text[line][column])) {
+ // remove the single whitespace
+ column++;
}
- while (column < text[line].length()) {
+ // check if its a text char
+ bool only_char = (_is_text_char(text[line][column]) && !only_whitespace);
- bool ischar = _is_text_char(text[line][column]);
+ // if its not whitespace or char then symbol.
+ bool only_symbols = !(only_whitespace || only_char);
- if (prev_char && !ischar)
+ while (column < curline_len) {
+ bool is_whitespace = _is_whitespace(text[line][column]);
+ bool is_text_char = _is_text_char(text[line][column]);
+
+ if (only_whitespace && !is_whitespace) {
break;
- prev_char = ischar;
+ } else if (only_char && !is_text_char) {
+ break;
+ } else if (only_symbols && (is_whitespace || is_text_char)) {
+ break;
+ }
column++;
}
next_line = line;
next_column = column;
+
} else {
next_column = cursor.column < curline_len ? (cursor.column + 1) : 0;
}
@@ -4353,6 +4353,23 @@ String TextEdit::get_word_at_pos(const Vector2 &p_pos) const {
bool symbol = beg < s.length() && _is_symbol(s[beg]); //not sure if right but most editors behave like this
+ bool inside_quotes = false;
+ int qbegin, qend;
+ for (int i = 0; i < s.length(); i++) {
+ if (s[i] == '"') {
+ if (inside_quotes) {
+ qend = i;
+ inside_quotes = false;
+ if (col >= qbegin && col <= qend) {
+ return s.substr(qbegin, qend - qbegin);
+ }
+ } else {
+ qbegin = i + 1;
+ inside_quotes = true;
+ }
+ }
+ }
+
while (beg > 0 && s[beg - 1] > 32 && (symbol == _is_symbol(s[beg - 1]))) {
beg--;
}
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index 1456ab51c0..0ce29b7472 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -291,7 +291,7 @@ void TreeItem::set_custom_draw(int p_column, Object *p_object, const StringName
ERR_FAIL_INDEX(p_column, cells.size());
ERR_FAIL_NULL(p_object);
- cells[p_column].custom_draw_obj = p_object->get_instance_ID();
+ cells[p_column].custom_draw_obj = p_object->get_instance_id();
cells[p_column].custom_draw_callback = p_callback;
}
@@ -1605,7 +1605,6 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool
int plus = 1;
while (i + plus < columns.size() && !p_item->cells[i + plus].editable && p_item->cells[i + plus].mode == TreeItem::CELL_MODE_STRING && p_item->cells[i + plus].text == "" && p_item->cells[i + plus].icon.is_null()) {
- plus++;
col_width += cache.hseparation;
col_width += get_column_width(i + plus);
plus++;
@@ -1918,8 +1917,8 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool
void Tree::_text_editor_modal_close() {
if (Input::get_singleton()->is_key_pressed(KEY_ESCAPE) ||
- Input::get_singleton()->is_key_pressed(KEY_ENTER) ||
- Input::get_singleton()->is_key_pressed(KEY_RETURN)) {
+ Input::get_singleton()->is_key_pressed(KEY_KP_ENTER) ||
+ Input::get_singleton()->is_key_pressed(KEY_ENTER)) {
return;
}
@@ -2238,8 +2237,8 @@ void Tree::_gui_input(Ref<InputEvent> p_event) {
} break;
case KEY_F2:
- case KEY_RETURN:
- case KEY_ENTER: {
+ case KEY_ENTER:
+ case KEY_KP_ENTER: {
if (selected_item) {
//bring up editor if possible
diff --git a/scene/main/canvas_layer.cpp b/scene/main/canvas_layer.cpp
index 150aee99ba..0ee57bd794 100644
--- a/scene/main/canvas_layer.cpp
+++ b/scene/main/canvas_layer.cpp
@@ -204,7 +204,7 @@ void CanvasLayer::set_custom_viewport(Node *p_viewport) {
custom_viewport = p_viewport->cast_to<Viewport>();
if (custom_viewport) {
- custom_viewport_id = custom_viewport->get_instance_ID();
+ custom_viewport_id = custom_viewport->get_instance_id();
} else {
custom_viewport_id = 0;
}
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index c3849f79df..6999091609 100755
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -77,11 +77,11 @@ void Node::_notification(int p_notification) {
}
if (data.input)
- add_to_group("_vp_input" + itos(get_viewport()->get_instance_ID()));
+ add_to_group("_vp_input" + itos(get_viewport()->get_instance_id()));
if (data.unhandled_input)
- add_to_group("_vp_unhandled_input" + itos(get_viewport()->get_instance_ID()));
+ add_to_group("_vp_unhandled_input" + itos(get_viewport()->get_instance_id()));
if (data.unhandled_key_input)
- add_to_group("_vp_unhandled_key_input" + itos(get_viewport()->get_instance_ID()));
+ add_to_group("_vp_unhandled_key_input" + itos(get_viewport()->get_instance_id()));
get_tree()->node_count++;
@@ -90,11 +90,11 @@ void Node::_notification(int p_notification) {
get_tree()->node_count--;
if (data.input)
- remove_from_group("_vp_input" + itos(get_viewport()->get_instance_ID()));
+ remove_from_group("_vp_input" + itos(get_viewport()->get_instance_id()));
if (data.unhandled_input)
- remove_from_group("_vp_unhandled_input" + itos(get_viewport()->get_instance_ID()));
+ remove_from_group("_vp_unhandled_input" + itos(get_viewport()->get_instance_id()));
if (data.unhandled_key_input)
- remove_from_group("_vp_unhandled_key_input" + itos(get_viewport()->get_instance_ID()));
+ remove_from_group("_vp_unhandled_key_input" + itos(get_viewport()->get_instance_id()));
data.pause_owner = NULL;
if (data.path_cache) {
@@ -705,12 +705,12 @@ void Node::rpcp(int p_peer_id, bool p_unreliable, const StringName &p_method, co
ERR_FAIL_COND(!is_inside_tree());
bool skip_rpc = false;
+ bool call_local_native = false;
+ bool call_local_script = false;
if (p_peer_id == 0 || p_peer_id == get_tree()->get_network_unique_id() || (p_peer_id < 0 && p_peer_id != -get_tree()->get_network_unique_id())) {
//check that send mode can use local call
- bool call_local = false;
-
Map<StringName, RPCMode>::Element *E = data.rpc_methods.find(p_method);
if (E) {
@@ -724,29 +724,22 @@ void Node::rpcp(int p_peer_id, bool p_unreliable, const StringName &p_method, co
} break;
case RPC_MODE_SYNC: {
//call it, sync always results in call
- call_local = true;
+ call_local_native = true;
} break;
case RPC_MODE_MASTER: {
- call_local = is_network_master();
- if (call_local) {
+ call_local_native = is_network_master();
+ if (call_local_native) {
skip_rpc = true; //no other master so..
}
} break;
case RPC_MODE_SLAVE: {
- call_local = !is_network_master();
+ call_local_native = !is_network_master();
} break;
}
}
- if (call_local) {
- Variant::CallError ce;
- call(p_method, p_arg, p_argcount, ce);
- if (ce.error != Variant::CallError::CALL_OK) {
- String error = Variant::get_call_error_text(this, p_method, p_arg, p_argcount, ce);
- error = "rpc() aborted in local call: - " + error;
- ERR_PRINTS(error);
- return;
- }
+ if (call_local_native) {
+ // done below
} else if (get_script_instance()) {
//attempt with script
ScriptInstance::RPCMode rpc_mode = get_script_instance()->get_rpc_mode(p_method);
@@ -761,37 +754,47 @@ void Node::rpcp(int p_peer_id, bool p_unreliable, const StringName &p_method, co
} break;
case ScriptInstance::RPC_MODE_SYNC: {
//call it, sync always results in call
- call_local = true;
+ call_local_script = true;
} break;
case ScriptInstance::RPC_MODE_MASTER: {
- call_local = is_network_master();
- if (call_local) {
+ call_local_script = is_network_master();
+ if (call_local_script) {
skip_rpc = true; //no other master so..
}
} break;
case ScriptInstance::RPC_MODE_SLAVE: {
- call_local = !is_network_master();
+ call_local_script = !is_network_master();
} break;
}
-
- if (call_local) {
- Variant::CallError ce;
- ce.error = Variant::CallError::CALL_OK;
- get_script_instance()->call(p_method, p_arg, p_argcount, ce);
- if (ce.error != Variant::CallError::CALL_OK) {
- String error = Variant::get_call_error_text(this, p_method, p_arg, p_argcount, ce);
- error = "rpc() aborted in script local call: - " + error;
- ERR_PRINTS(error);
- return;
- }
- }
}
}
- if (skip_rpc)
- return;
+ if (!skip_rpc) {
+ get_tree()->_rpc(this, p_peer_id, p_unreliable, false, p_method, p_arg, p_argcount);
+ }
+
+ if (call_local_native) {
+ Variant::CallError ce;
+ call(p_method, p_arg, p_argcount, ce);
+ if (ce.error != Variant::CallError::CALL_OK) {
+ String error = Variant::get_call_error_text(this, p_method, p_arg, p_argcount, ce);
+ error = "rpc() aborted in local call: - " + error;
+ ERR_PRINTS(error);
+ return;
+ }
+ }
- get_tree()->_rpc(this, p_peer_id, p_unreliable, false, p_method, p_arg, p_argcount);
+ if (call_local_script) {
+ Variant::CallError ce;
+ ce.error = Variant::CallError::CALL_OK;
+ get_script_instance()->call(p_method, p_arg, p_argcount, ce);
+ if (ce.error != Variant::CallError::CALL_OK) {
+ String error = Variant::get_call_error_text(this, p_method, p_arg, p_argcount, ce);
+ error = "rpc() aborted in script local call: - " + error;
+ ERR_PRINTS(error);
+ return;
+ }
+ }
}
/******** RSET *********/
@@ -1115,9 +1118,9 @@ void Node::set_process_input(bool p_enable) {
return;
if (p_enable)
- add_to_group("_vp_input" + itos(get_viewport()->get_instance_ID()));
+ add_to_group("_vp_input" + itos(get_viewport()->get_instance_id()));
else
- remove_from_group("_vp_input" + itos(get_viewport()->get_instance_ID()));
+ remove_from_group("_vp_input" + itos(get_viewport()->get_instance_id()));
}
bool Node::is_processing_input() const {
@@ -1133,9 +1136,9 @@ void Node::set_process_unhandled_input(bool p_enable) {
return;
if (p_enable)
- add_to_group("_vp_unhandled_input" + itos(get_viewport()->get_instance_ID()));
+ add_to_group("_vp_unhandled_input" + itos(get_viewport()->get_instance_id()));
else
- remove_from_group("_vp_unhandled_input" + itos(get_viewport()->get_instance_ID()));
+ remove_from_group("_vp_unhandled_input" + itos(get_viewport()->get_instance_id()));
}
bool Node::is_processing_unhandled_input() const {
@@ -1151,9 +1154,9 @@ void Node::set_process_unhandled_key_input(bool p_enable) {
return;
if (p_enable)
- add_to_group("_vp_unhandled_key_input" + itos(get_viewport()->get_instance_ID()));
+ add_to_group("_vp_unhandled_key_input" + itos(get_viewport()->get_instance_id()));
else
- remove_from_group("_vp_unhandled_key_input" + itos(get_viewport()->get_instance_ID()));
+ remove_from_group("_vp_unhandled_key_input" + itos(get_viewport()->get_instance_id()));
}
bool Node::is_processing_unhandled_key_input() const {
@@ -2606,7 +2609,7 @@ static void _Node_debug_sn(Object *p_obj) {
path = n->get_name();
else
path = String(p->get_name()) + "/" + p->get_path_to(n);
- print_line(itos(p_obj->get_instance_ID()) + "- Stray Node: " + path + " (Type: " + n->get_class() + ")");
+ print_line(itos(p_obj->get_instance_id()) + "- Stray Node: " + path + " (Type: " + n->get_class() + ")");
}
void Node::_print_stray_nodes() {
diff --git a/scene/main/node.h b/scene/main/node.h
index 1794cce9f6..0447deccc1 100644
--- a/scene/main/node.h
+++ b/scene/main/node.h
@@ -33,7 +33,7 @@
#include "class_db.h"
#include "map.h"
#include "object.h"
-#include "path_db.h"
+#include "node_path.h"
#include "project_settings.h"
#include "scene/main/scene_tree.h"
#include "script_language.h"
diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp
index 48e6a44745..6aa2c83941 100644
--- a/scene/main/scene_tree.cpp
+++ b/scene/main/scene_tree.cpp
@@ -1106,7 +1106,7 @@ static void _fill_array(Node *p_node, Array &array, int p_level) {
array.push_back(p_level);
array.push_back(p_node->get_name());
array.push_back(p_node->get_class());
- array.push_back(p_node->get_instance_ID());
+ array.push_back(p_node->get_instance_id());
for (int i = 0; i < p_node->get_child_count(); i++) {
_fill_array(p_node->get_child(i), array, p_level + 1);
@@ -1141,7 +1141,7 @@ void SceneTree::queue_delete(Object *p_object) {
_THREAD_SAFE_METHOD_
ERR_FAIL_NULL(p_object);
p_object->_is_queued_for_deletion = true;
- delete_queue.push_back(p_object->get_instance_ID());
+ delete_queue.push_back(p_object->get_instance_id());
}
int SceneTree::get_node_count() const {
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index 76b281ebac..ee9323ca1d 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -2028,6 +2028,89 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
}
}
+ Ref<InputEventScreenTouch> touch_event = p_event;
+ if (touch_event.is_valid()) {
+
+ Size2 pos = touch_event->get_position();
+ if (touch_event->is_pressed()) {
+
+ Control *over = _gui_find_control(pos);
+ if (over) {
+
+ if (!gui.modal_stack.empty()) {
+
+ Control *top = gui.modal_stack.back()->get();
+ if (over != top && !top->is_a_parent_of(over)) {
+
+ return;
+ }
+ }
+ if (over->can_process()) {
+
+ touch_event = touch_event->xformed_by(Transform2D()); //make a copy
+ if (over == gui.mouse_focus) {
+ pos = gui.focus_inv_xform.xform(pos);
+ } else {
+ pos = over->get_global_transform_with_canvas().affine_inverse().xform(pos);
+ }
+ touch_event->set_position(pos);
+ _gui_call_input(over, touch_event);
+ }
+ get_tree()->set_input_as_handled();
+ return;
+ }
+ } else if (gui.mouse_focus) {
+
+ if (gui.mouse_focus->can_process()) {
+
+ touch_event = touch_event->xformed_by(Transform2D()); //make a copy
+ touch_event->set_position(gui.focus_inv_xform.xform(pos));
+
+ _gui_call_input(gui.mouse_focus, touch_event);
+ }
+ get_tree()->set_input_as_handled();
+ return;
+ }
+ }
+
+ Ref<InputEventScreenDrag> drag_event = p_event;
+ if (drag_event.is_valid()) {
+
+ Control *over = gui.mouse_focus;
+ if (!over) {
+ over = _gui_find_control(drag_event->get_position());
+ }
+ if (over) {
+
+ if (!gui.modal_stack.empty()) {
+
+ Control *top = gui.modal_stack.back()->get();
+ if (over != top && !top->is_a_parent_of(over)) {
+
+ return;
+ }
+ }
+ if (over->can_process()) {
+
+ Transform2D localizer = over->get_global_transform_with_canvas().affine_inverse();
+ Size2 pos = localizer.xform(drag_event->get_position());
+ Vector2 speed = localizer.basis_xform(drag_event->get_speed());
+ Vector2 rel = localizer.basis_xform(drag_event->get_relative());
+
+ drag_event = drag_event->xformed_by(Transform2D()); //make a copy
+
+ drag_event->set_speed(speed);
+ drag_event->set_relative(rel);
+ drag_event->set_position(pos);
+
+ _gui_call_input(over, drag_event);
+ }
+
+ get_tree()->set_input_as_handled();
+ return;
+ }
+ }
+
if (mm.is_null() && mb.is_null() && p_event->is_action_type()) {
if (gui.key_focus && !gui.key_focus->is_visible_in_tree()) {
@@ -2303,7 +2386,7 @@ List<Control *>::Element *Viewport::_gui_show_modal(Control *p_control) {
gui.modal_stack.push_back(p_control);
if (gui.key_focus)
- p_control->_modal_set_prev_focus_owner(gui.key_focus->get_instance_ID());
+ p_control->_modal_set_prev_focus_owner(gui.key_focus->get_instance_id());
else
p_control->_modal_set_prev_focus_owner(0);
@@ -2769,7 +2852,7 @@ Viewport::Viewport() {
set_shadow_atlas_quadrant_subdiv(2, SHADOW_ATLAS_QUADRANT_SUBDIV_16);
set_shadow_atlas_quadrant_subdiv(3, SHADOW_ATLAS_QUADRANT_SUBDIV_64);
- String id = itos(get_instance_ID());
+ String id = itos(get_instance_id());
input_group = "_vp_input" + id;
gui_input_group = "_vp_gui_input" + id;
unhandled_input_group = "_vp_unhandled_input" + id;
diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp
index f286bfb81a..3e6d80d314 100644
--- a/scene/register_scene_types.cpp
+++ b/scene/register_scene_types.cpp
@@ -409,6 +409,7 @@ void register_scene_types() {
ClassDB::register_class<Listener>();
ClassDB::register_class<ARVRCamera>();
ClassDB::register_class<ARVRController>();
+ ClassDB::register_class<ARVRAnchor>();
ClassDB::register_class<ARVROrigin>();
ClassDB::register_class<InterpolatedCamera>();
ClassDB::register_class<MeshInstance>();
diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp
index 24ec39afe3..5a79e49240 100644
--- a/scene/resources/material.cpp
+++ b/scene/resources/material.cpp
@@ -234,6 +234,14 @@ void SpatialMaterial::init_shaders() {
shader_names->grow = "grow";
+ shader_names->metallic_texture_channel = "metallic_texture_channel";
+ shader_names->roughness_texture_channel = "roughness_texture_channel";
+ shader_names->ao_texture_channel = "ao_texture_channel";
+ shader_names->clearcoat_texture_channel = "clearcoat_texture_channel";
+ shader_names->rim_texture_channel = "rim_texture_channel";
+ shader_names->depth_texture_channel = "depth_texture_channel";
+ shader_names->refraction_texture_channel = "refraction_texture_channel";
+
shader_names->texture_names[TEXTURE_ALBEDO] = "texture_albedo";
shader_names->texture_names[TEXTURE_METALLIC] = "texture_metallic";
shader_names->texture_names[TEXTURE_ROUGHNESS] = "texture_roughness";
@@ -354,7 +362,9 @@ void SpatialMaterial::_update_shader() {
code += "uniform float roughness : hint_range(0,1);\n";
code += "uniform float point_size : hint_range(0,128);\n";
code += "uniform sampler2D texture_metallic : hint_white;\n";
+ code += "uniform vec4 metallic_texture_channel;\n";
code += "uniform sampler2D texture_roughness : hint_white;\n";
+ code += "uniform vec4 roughness_texture_channel;\n";
if (billboard_mode == BILLBOARD_PARTICLES) {
code += "uniform int particles_anim_h_frames;\n";
code += "uniform int particles_anim_v_frames;\n";
@@ -371,6 +381,7 @@ void SpatialMaterial::_update_shader() {
if (features[FEATURE_REFRACTION]) {
code += "uniform sampler2D texture_refraction;\n";
code += "uniform float refraction : hint_range(-16,16);\n";
+ code += "uniform vec4 refraction_texture_channel;\n";
}
if (features[FEATURE_NORMAL_MAPPING]) {
@@ -393,6 +404,7 @@ void SpatialMaterial::_update_shader() {
}
if (features[FEATURE_AMBIENT_OCCLUSION]) {
code += "uniform sampler2D texture_ambient_occlusion : hint_white;\n";
+ code += "uniform vec4 ao_texture_channel;\n";
}
if (features[FEATURE_DETAIL]) {
@@ -617,15 +629,15 @@ void SpatialMaterial::_update_shader() {
code += "\tALBEDO = albedo.rgb * albedo_tex.rgb;\n";
if (flags[FLAG_UV1_USE_TRIPLANAR]) {
- code += "\tfloat metallic_tex = triplanar_texture(texture_metallic,uv1_power_normal,uv1_world_pos).r;\n";
+ code += "\tfloat metallic_tex = dot(triplanar_texture(texture_metallic,uv1_power_normal,uv1_world_pos),metallic_texture_channel);\n";
} else {
- code += "\tfloat metallic_tex = texture(texture_metallic,base_uv).r;\n";
+ code += "\tfloat metallic_tex = dot(texture(texture_metallic,base_uv),metallic_texture_channel);\n";
}
code += "\tMETALLIC = metallic_tex * metallic;\n";
if (flags[FLAG_UV1_USE_TRIPLANAR]) {
- code += "\tfloat roughness_tex = triplanar_texture(texture_roughness,uv1_power_normal,uv1_world_pos).r;\n";
+ code += "\tfloat roughness_tex = dot(triplanar_texture(texture_roughness,uv1_power_normal,uv1_world_pos),roughness_texture_channel);\n";
} else {
- code += "\tfloat roughness_tex = texture(texture_roughness,base_uv).r;\n";
+ code += "\tfloat roughness_tex = dot(texture(texture_roughness,base_uv),roughness_texture_channel);\n";
}
code += "\tROUGHNESS = roughness_tex * roughness;\n";
code += "\tSPECULAR = specular;\n";
@@ -656,7 +668,7 @@ void SpatialMaterial::_update_shader() {
code += "\tvec3 ref_normal = NORMAL;\n";
}
- code += "\tvec2 ref_ofs = SCREEN_UV - ref_normal.xy * texture(texture_refraction,base_uv).r * refraction;\n";
+ code += "\tvec2 ref_ofs = SCREEN_UV - ref_normal.xy * dot(texture(texture_refraction,base_uv),refraction_texture_channel) * refraction;\n";
code += "\tfloat ref_amount = 1.0 - albedo.a * albedo_tex.a;\n";
code += "\tEMISSION += textureLod(SCREEN_TEXTURE,ref_ofs,ROUGHNESS * 8.0).rgb * ref_amount;\n";
code += "\tALBEDO *= 1.0 - ref_amount;\n";
@@ -699,15 +711,15 @@ void SpatialMaterial::_update_shader() {
if (features[FEATURE_AMBIENT_OCCLUSION]) {
if (flags[FLAG_AO_ON_UV2]) {
if (flags[FLAG_UV2_USE_TRIPLANAR]) {
- code += "\tAO = triplanar_texture(texture_ambient_occlusion,uv2_power_normal,uv2_world_pos).r;\n";
+ code += "\tAO = dot(triplanar_texture(texture_ambient_occlusion,uv2_power_normal,uv2_world_pos),ao_texture_channel);\n";
} else {
- code += "\tAO = texture(texture_ambient_occlusion,base_uv2).r;\n";
+ code += "\tAO = dot(texture(texture_ambient_occlusion,base_uv2),ao_texture_channel);\n";
}
} else {
if (flags[FLAG_UV1_USE_TRIPLANAR]) {
- code += "\tAO = triplanar_texture(texture_ambient_occlusion,uv1_power_normal,uv1_world_pos).r;\n";
+ code += "\tAO = dot(triplanar_texture(texture_ambient_occlusion,uv1_power_normal,uv1_world_pos),ao_texture_channel);\n";
} else {
- code += "\tAO = texture(texture_ambient_occlusion,base_uv).r;\n";
+ code += "\tAO = dot(texture(texture_ambient_occlusion,base_uv),ao_texture_channel);\n";
}
}
}
@@ -1327,6 +1339,58 @@ float SpatialMaterial::get_grow() const {
return grow;
}
+static Plane _get_texture_mask(SpatialMaterial::TextureChannel p_channel) {
+ static const Plane masks[5] = {
+ Plane(1, 0, 0, 0),
+ Plane(0, 1, 0, 0),
+ Plane(0, 0, 1, 0),
+ Plane(0, 0, 0, 1),
+ Plane(0.3333333, 0.3333333, 0.3333333, 0),
+ };
+
+ return masks[p_channel];
+}
+
+void SpatialMaterial::set_metallic_texture_channel(TextureChannel p_channel) {
+
+ metallic_texture_channel = p_channel;
+ VS::get_singleton()->material_set_param(_get_material(), shader_names->metallic_texture_channel, _get_texture_mask(p_channel));
+}
+
+SpatialMaterial::TextureChannel SpatialMaterial::get_metallic_texture_channel() const {
+ return metallic_texture_channel;
+}
+
+void SpatialMaterial::set_roughness_texture_channel(TextureChannel p_channel) {
+
+ roughness_texture_channel = p_channel;
+ VS::get_singleton()->material_set_param(_get_material(), shader_names->roughness_texture_channel, _get_texture_mask(p_channel));
+}
+
+SpatialMaterial::TextureChannel SpatialMaterial::get_roughness_texture_channel() const {
+ return roughness_texture_channel;
+}
+
+void SpatialMaterial::set_ao_texture_channel(TextureChannel p_channel) {
+
+ ao_texture_channel = p_channel;
+ VS::get_singleton()->material_set_param(_get_material(), shader_names->ao_texture_channel, _get_texture_mask(p_channel));
+}
+
+SpatialMaterial::TextureChannel SpatialMaterial::get_ao_texture_channel() const {
+ return ao_texture_channel;
+}
+
+void SpatialMaterial::set_refraction_texture_channel(TextureChannel p_channel) {
+
+ refraction_texture_channel = p_channel;
+ VS::get_singleton()->material_set_param(_get_material(), shader_names->refraction_texture_channel, _get_texture_mask(p_channel));
+}
+
+SpatialMaterial::TextureChannel SpatialMaterial::get_refraction_texture_channel() const {
+ return refraction_texture_channel;
+}
+
void SpatialMaterial::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_albedo", "albedo"), &SpatialMaterial::set_albedo);
@@ -1455,6 +1519,18 @@ void SpatialMaterial::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_grow_enabled", "enable"), &SpatialMaterial::set_grow_enabled);
ClassDB::bind_method(D_METHOD("is_grow_enabled"), &SpatialMaterial::is_grow_enabled);
+ ClassDB::bind_method(D_METHOD("set_metallic_texture_channel", "channel"), &SpatialMaterial::set_metallic_texture_channel);
+ ClassDB::bind_method(D_METHOD("get_metallic_texture_channel"), &SpatialMaterial::get_metallic_texture_channel);
+
+ ClassDB::bind_method(D_METHOD("set_roughness_texture_channel", "channel"), &SpatialMaterial::set_roughness_texture_channel);
+ ClassDB::bind_method(D_METHOD("get_roughness_texture_channel"), &SpatialMaterial::get_roughness_texture_channel);
+
+ ClassDB::bind_method(D_METHOD("set_ao_texture_channel", "channel"), &SpatialMaterial::set_ao_texture_channel);
+ ClassDB::bind_method(D_METHOD("get_ao_texture_channel"), &SpatialMaterial::get_ao_texture_channel);
+
+ ClassDB::bind_method(D_METHOD("set_refraction_texture_channel", "channel"), &SpatialMaterial::set_refraction_texture_channel);
+ ClassDB::bind_method(D_METHOD("get_refraction_texture_channel"), &SpatialMaterial::get_refraction_texture_channel);
+
ADD_GROUP("Flags", "flags_");
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flags_transparent"), "set_feature", "get_feature", FEATURE_TRANSPARENT);
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flags_unshaded"), "set_flag", "get_flag", FLAG_UNSHADED);
@@ -1490,10 +1566,12 @@ void SpatialMaterial::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::REAL, "metallic", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_metallic", "get_metallic");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "metallic_specular", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_specular", "get_specular");
ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "metallic_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", TEXTURE_METALLIC);
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "metallic_texture_channel", PROPERTY_HINT_ENUM, "Red,Green,Blue,Alpha,Gray"), "set_metallic_texture_channel", "get_metallic_texture_channel");
ADD_GROUP("Roughness", "roughness_");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "roughness", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_roughness", "get_roughness");
ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "roughness_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", TEXTURE_ROUGHNESS);
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "roughness_texture_channel", PROPERTY_HINT_ENUM, "Red,Green,Blue,Alpha,Gray"), "set_roughness_texture_channel", "get_roughness_texture_channel");
ADD_GROUP("Emission", "emission_");
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "emission_enabled"), "set_feature", "get_feature", FEATURE_EMISSION);
@@ -1527,6 +1605,7 @@ void SpatialMaterial::_bind_methods() {
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "ao_enabled"), "set_feature", "get_feature", FEATURE_AMBIENT_OCCLUSION);
ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "ao_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", TEXTURE_AMBIENT_OCCLUSION);
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "ao_on_uv2"), "set_flag", "get_flag", FLAG_AO_ON_UV2);
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "ao_texture_channel", PROPERTY_HINT_ENUM, "Red,Green,Blue,Alpha,Gray"), "set_ao_texture_channel", "get_ao_texture_channel");
ADD_GROUP("Depth", "depth_");
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "depth_enabled"), "set_feature", "get_feature", FEATURE_DEPTH_MAPPING);
@@ -1545,6 +1624,7 @@ void SpatialMaterial::_bind_methods() {
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "refraction_enabled"), "set_feature", "get_feature", FEATURE_REFRACTION);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "refraction_scale", PROPERTY_HINT_RANGE, "-1,1,0.01"), "set_refraction", "get_refraction");
ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "refraction_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", TEXTURE_REFRACTION);
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "refraction_texture_channel", PROPERTY_HINT_ENUM, "Red,Green,Blue,Alpha,Gray"), "set_refraction_texture_channel", "get_refraction_texture_channel");
ADD_GROUP("Detail", "detail_");
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "detail_enabled"), "set_feature", "get_feature", FEATURE_DETAIL);
@@ -1638,6 +1718,12 @@ void SpatialMaterial::_bind_methods() {
BIND_CONSTANT(BILLBOARD_ENABLED);
BIND_CONSTANT(BILLBOARD_FIXED_Y);
BIND_CONSTANT(BILLBOARD_PARTICLES);
+
+ BIND_CONSTANT(TEXTURE_CHANNEL_RED);
+ BIND_CONSTANT(TEXTURE_CHANNEL_GREEN);
+ BIND_CONSTANT(TEXTURE_CHANNEL_BLUE);
+ BIND_CONSTANT(TEXTURE_CHANNEL_ALPHA);
+ BIND_CONSTANT(TEXTURE_CHANNEL_GRAYSCALE);
}
SpatialMaterial::SpatialMaterial()
@@ -1672,6 +1758,11 @@ SpatialMaterial::SpatialMaterial()
set_particles_anim_v_frames(1);
set_particles_anim_loop(false);
+ set_metallic_texture_channel(TEXTURE_CHANNEL_RED);
+ set_roughness_texture_channel(TEXTURE_CHANNEL_RED);
+ set_ao_texture_channel(TEXTURE_CHANNEL_RED);
+ set_refraction_texture_channel(TEXTURE_CHANNEL_RED);
+
grow_enabled = false;
set_grow(0.0);
diff --git a/scene/resources/material.h b/scene/resources/material.h
index 7587fc7927..1484b79fc6 100644
--- a/scene/resources/material.h
+++ b/scene/resources/material.h
@@ -190,6 +190,14 @@ public:
BILLBOARD_PARTICLES,
};
+ enum TextureChannel {
+ TEXTURE_CHANNEL_RED,
+ TEXTURE_CHANNEL_GREEN,
+ TEXTURE_CHANNEL_BLUE,
+ TEXTURE_CHANNEL_ALPHA,
+ TEXTURE_CHANNEL_GRAYSCALE
+ };
+
private:
union MaterialKey {
@@ -283,6 +291,14 @@ private:
StringName uv2_blend_sharpness;
StringName grow;
+ StringName metallic_texture_channel;
+ StringName roughness_texture_channel;
+ StringName ao_texture_channel;
+ StringName clearcoat_texture_channel;
+ StringName rim_texture_channel;
+ StringName depth_texture_channel;
+ StringName refraction_texture_channel;
+
StringName texture_names[TEXTURE_MAX];
};
@@ -342,6 +358,11 @@ private:
DiffuseMode diffuse_mode;
BillboardMode billboard_mode;
+ TextureChannel metallic_texture_channel;
+ TextureChannel roughness_texture_channel;
+ TextureChannel ao_texture_channel;
+ TextureChannel refraction_texture_channel;
+
bool features[FEATURE_MAX];
Ref<Texture> textures[TEXTURE_MAX];
@@ -478,6 +499,15 @@ public:
void set_grow(float p_grow);
float get_grow() const;
+ void set_metallic_texture_channel(TextureChannel p_channel);
+ TextureChannel get_metallic_texture_channel() const;
+ void set_roughness_texture_channel(TextureChannel p_channel);
+ TextureChannel get_roughness_texture_channel() const;
+ void set_ao_texture_channel(TextureChannel p_channel);
+ TextureChannel get_ao_texture_channel() const;
+ void set_refraction_texture_channel(TextureChannel p_channel);
+ TextureChannel get_refraction_texture_channel() const;
+
static void init_shaders();
static void finish_shaders();
static void flush_changes();
@@ -496,6 +526,7 @@ VARIANT_ENUM_CAST(SpatialMaterial::Flags)
VARIANT_ENUM_CAST(SpatialMaterial::DiffuseMode)
VARIANT_ENUM_CAST(SpatialMaterial::SpecularMode)
VARIANT_ENUM_CAST(SpatialMaterial::BillboardMode)
+VARIANT_ENUM_CAST(SpatialMaterial::TextureChannel)
//////////////////////
diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp
index 6bf3590c12..648900a5cd 100644
--- a/scene/resources/packed_scene.cpp
+++ b/scene/resources/packed_scene.cpp
@@ -516,6 +516,9 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map
bool isdefault = ((E->get().usage & PROPERTY_USAGE_STORE_IF_NONZERO) && value.is_zero()) || ((E->get().usage & PROPERTY_USAGE_STORE_IF_NONONE) && value.is_one());
+ if (E->get().usage & PROPERTY_USAGE_SCRIPT_DEFAULT_VALUE) {
+ isdefault = true; //is script default value
+ }
/*
if (nd.instance<0 && ((E->get().usage & PROPERTY_USAGE_STORE_IF_NONZERO) && value.is_zero()) || ((E->get().usage & PROPERTY_USAGE_STORE_IF_NONONE) && value.is_one())) {
continue;
diff --git a/scene/resources/surface_tool.cpp b/scene/resources/surface_tool.cpp
index 8478432a04..3932917ebe 100644
--- a/scene/resources/surface_tool.cpp
+++ b/scene/resources/surface_tool.cpp
@@ -224,30 +224,22 @@ void SurfaceTool::add_index(int p_index) {
index_array.push_back(p_index);
}
-Ref<ArrayMesh> SurfaceTool::commit(const Ref<ArrayMesh> &p_existing) {
-
- Ref<ArrayMesh> mesh;
- if (p_existing.is_valid())
- mesh = p_existing;
- else
- mesh.instance();
+Array SurfaceTool::commit_to_arrays() {
int varr_len = vertex_array.size();
- if (varr_len == 0)
- return mesh;
-
- int surface = mesh->get_surface_count();
-
Array a;
a.resize(Mesh::ARRAY_MAX);
for (int i = 0; i < Mesh::ARRAY_MAX; i++) {
- switch (format & (1 << i)) {
+ if (!(format & (1 << i)))
+ continue; //not in format
+
+ switch (i) {
- case Mesh::ARRAY_FORMAT_VERTEX:
- case Mesh::ARRAY_FORMAT_NORMAL: {
+ case Mesh::ARRAY_VERTEX:
+ case Mesh::ARRAY_NORMAL: {
PoolVector<Vector3> array;
array.resize(varr_len);
@@ -273,8 +265,8 @@ Ref<ArrayMesh> SurfaceTool::commit(const Ref<ArrayMesh> &p_existing) {
} break;
- case Mesh::ARRAY_FORMAT_TEX_UV:
- case Mesh::ARRAY_FORMAT_TEX_UV2: {
+ case Mesh::ARRAY_TEX_UV:
+ case Mesh::ARRAY_TEX_UV2: {
PoolVector<Vector2> array;
array.resize(varr_len);
@@ -299,7 +291,7 @@ Ref<ArrayMesh> SurfaceTool::commit(const Ref<ArrayMesh> &p_existing) {
w = PoolVector<Vector2>::Write();
a[i] = array;
} break;
- case Mesh::ARRAY_FORMAT_TANGENT: {
+ case Mesh::ARRAY_TANGENT: {
PoolVector<float> array;
array.resize(varr_len * 4);
@@ -323,7 +315,7 @@ Ref<ArrayMesh> SurfaceTool::commit(const Ref<ArrayMesh> &p_existing) {
a[i] = array;
} break;
- case Mesh::ARRAY_FORMAT_COLOR: {
+ case Mesh::ARRAY_COLOR: {
PoolVector<Color> array;
array.resize(varr_len);
@@ -339,7 +331,7 @@ Ref<ArrayMesh> SurfaceTool::commit(const Ref<ArrayMesh> &p_existing) {
w = PoolVector<Color>::Write();
a[i] = array;
} break;
- case Mesh::ARRAY_FORMAT_BONES: {
+ case Mesh::ARRAY_BONES: {
PoolVector<int> array;
array.resize(varr_len * 4);
@@ -361,7 +353,7 @@ Ref<ArrayMesh> SurfaceTool::commit(const Ref<ArrayMesh> &p_existing) {
a[i] = array;
} break;
- case Mesh::ARRAY_FORMAT_WEIGHTS: {
+ case Mesh::ARRAY_WEIGHTS: {
PoolVector<float> array;
array.resize(varr_len * 4);
@@ -383,7 +375,7 @@ Ref<ArrayMesh> SurfaceTool::commit(const Ref<ArrayMesh> &p_existing) {
a[i] = array;
} break;
- case Mesh::ARRAY_FORMAT_INDEX: {
+ case Mesh::ARRAY_INDEX: {
ERR_CONTINUE(index_array.size() == 0);
@@ -398,6 +390,7 @@ Ref<ArrayMesh> SurfaceTool::commit(const Ref<ArrayMesh> &p_existing) {
}
w = PoolVector<int>::Write();
+
a[i] = array;
} break;
@@ -405,6 +398,26 @@ Ref<ArrayMesh> SurfaceTool::commit(const Ref<ArrayMesh> &p_existing) {
}
}
+ return a;
+}
+
+Ref<ArrayMesh> SurfaceTool::commit(const Ref<ArrayMesh> &p_existing) {
+
+ Ref<ArrayMesh> mesh;
+ if (p_existing.is_valid())
+ mesh = p_existing;
+ else
+ mesh.instance();
+
+ int varr_len = vertex_array.size();
+
+ if (varr_len == 0)
+ return mesh;
+
+ int surface = mesh->get_surface_count();
+
+ Array a = commit_to_arrays();
+
mesh->add_surface_from_arrays(primitive, a);
if (material.is_valid())
mesh->surface_set_material(surface, material);
@@ -459,12 +472,17 @@ void SurfaceTool::deindex() {
vertex_array.push_back(varr[E->get()]);
}
format &= ~Mesh::ARRAY_FORMAT_INDEX;
+ index_array.clear();
}
void SurfaceTool::_create_list(const Ref<Mesh> &p_existing, int p_surface, List<Vertex> *r_vertex, List<int> *r_index, int &lformat) {
Array arr = p_existing->surface_get_arrays(p_surface);
ERR_FAIL_COND(arr.size() != VS::ARRAY_MAX);
+ _create_list_from_arrays(arr, r_vertex, r_index, lformat);
+}
+
+void SurfaceTool::_create_list_from_arrays(Array arr, List<Vertex> *r_vertex, List<int> *r_index, int &lformat) {
PoolVector<Vector3> varr = arr[VS::ARRAY_VERTEX];
PoolVector<Vector3> narr = arr[VS::ARRAY_NORMAL];
@@ -536,7 +554,7 @@ void SurfaceTool::_create_list(const Ref<Mesh> &p_existing, int p_surface, List<
if (lformat & VS::ARRAY_FORMAT_TANGENT) {
Plane p(tarr[i * 4 + 0], tarr[i * 4 + 1], tarr[i * 4 + 2], tarr[i * 4 + 3]);
v.tangent = p.normal;
- v.binormal = p.normal.cross(last_normal).normalized() * p.d;
+ v.binormal = p.normal.cross(v.tangent).normalized() * p.d;
}
if (lformat & VS::ARRAY_FORMAT_COLOR)
v.color = carr[i];
@@ -580,6 +598,13 @@ void SurfaceTool::_create_list(const Ref<Mesh> &p_existing, int p_surface, List<
}
}
+void SurfaceTool::create_from_triangle_arrays(const Array &p_arrays) {
+
+ clear();
+ primitive = Mesh::PRIMITIVE_TRIANGLES;
+ _create_list_from_arrays(p_arrays, &vertex_array, &index_array, format);
+}
+
void SurfaceTool::create_from(const Ref<Mesh> &p_existing, int p_surface) {
clear();
@@ -711,8 +736,9 @@ void SurfaceTool::generate_tangents() {
ERR_FAIL_COND(!res);
format |= Mesh::ARRAY_FORMAT_TANGENT;
- if (indexed)
+ if (indexed) {
index();
+ }
}
void SurfaceTool::generate_normals() {
@@ -784,7 +810,6 @@ void SurfaceTool::generate_normals() {
vertex_hash.clear();
if (E) {
smooth = smooth_groups[count];
- print_line("SMOOTH AT " + itos(count) + ": " + itos(smooth));
}
}
}
diff --git a/scene/resources/surface_tool.h b/scene/resources/surface_tool.h
index 753c3626b8..d02e170b02 100644
--- a/scene/resources/surface_tool.h
+++ b/scene/resources/surface_tool.h
@@ -80,6 +80,7 @@ private:
Vector<float> last_weights;
Plane last_tangent;
+ void _create_list_from_arrays(Array arr, List<Vertex> *r_vertex, List<int> *r_index, int &lformat);
void _create_list(const Ref<Mesh> &p_existing, int p_surface, List<Vertex> *r_vertex, List<int> *r_index, int &lformat);
//mikktspace callbacks
@@ -123,6 +124,8 @@ public:
List<Vertex> &get_vertex_array() { return vertex_array; }
+ void create_from_triangle_arrays(const Array &p_arrays);
+ Array commit_to_arrays();
void create_from(const Ref<Mesh> &p_existing, int p_surface);
void append_from(const Ref<Mesh> &p_existing, int p_surface, const Transform &p_xform);
Ref<ArrayMesh> commit(const Ref<ArrayMesh> &p_existing = Ref<ArrayMesh>());
diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp
index fe7cd0097c..f69c83bf08 100644
--- a/scene/resources/texture.cpp
+++ b/scene/resources/texture.cpp
@@ -73,6 +73,7 @@ void Texture::_bind_methods() {
ClassDB::bind_method(D_METHOD("draw", "canvas_item", "pos", "modulate", "transpose", "normal_map:Texture"), &Texture::draw, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(Variant()));
ClassDB::bind_method(D_METHOD("draw_rect", "canvas_item", "rect", "tile", "modulate", "transpose", "normal_map:Texture"), &Texture::draw_rect, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(Variant()));
ClassDB::bind_method(D_METHOD("draw_rect_region", "canvas_item", "rect", "src_rect", "modulate", "transpose", "normal_map:Texture", "clip_uv"), &Texture::draw_rect_region, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(Variant()), DEFVAL(true));
+ ClassDB::bind_method(D_METHOD("get_data:Image"), &Texture::get_data);
BIND_CONSTANT(FLAG_MIPMAPS);
BIND_CONSTANT(FLAG_REPEAT);
@@ -194,6 +195,7 @@ void ImageTexture::create(int p_width, int p_height, Image::Format p_format, uin
}
void ImageTexture::create_from_image(const Ref<Image> &p_image, uint32_t p_flags) {
+ ERR_FAIL_COND(p_image.is_null());
flags = p_flags;
w = p_image->get_width();
h = p_image->get_height();
@@ -352,7 +354,6 @@ void ImageTexture::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_format"), &ImageTexture::get_format);
ClassDB::bind_method(D_METHOD("load", "path"), &ImageTexture::load);
ClassDB::bind_method(D_METHOD("set_data", "image:Image"), &ImageTexture::set_data);
- ClassDB::bind_method(D_METHOD("get_data:Image", "cube_side"), &ImageTexture::get_data);
ClassDB::bind_method(D_METHOD("set_storage", "mode"), &ImageTexture::set_storage);
ClassDB::bind_method(D_METHOD("get_storage"), &ImageTexture::get_storage);
ClassDB::bind_method(D_METHOD("set_lossy_storage_quality", "quality"), &ImageTexture::set_lossy_storage_quality);
diff --git a/scene/scene_string_names.cpp b/scene/scene_string_names.cpp
index ec71333ded..f247e7cde8 100644
--- a/scene/scene_string_names.cpp
+++ b/scene/scene_string_names.cpp
@@ -142,9 +142,9 @@ SceneStringNames::SceneStringNames() {
h_offset = StaticCString::create("h_offset");
v_offset = StaticCString::create("v_offset");
- transform_pos = StaticCString::create("transform/pos");
- transform_rot = StaticCString::create("transform/rot");
- transform_scale = StaticCString::create("transform/scale");
+ transform_pos = StaticCString::create("position");
+ transform_rot = StaticCString::create("rotation_deg");
+ transform_scale = StaticCString::create("scale");
_update_remote = StaticCString::create("_update_remote");
_update_pairs = StaticCString::create("_update_pairs");
@@ -158,8 +158,6 @@ SceneStringNames::SceneStringNames() {
line_separation = StaticCString::create("line_separation");
- play_play = StaticCString::create("play/play");
-
get_drag_data = StaticCString::create("get_drag_data");
drop_data = StaticCString::create("drop_data");
can_drop_data = StaticCString::create("can_drop_data");
diff --git a/scene/scene_string_names.h b/scene/scene_string_names.h
index 0802a73973..0b70cd36ff 100644
--- a/scene/scene_string_names.h
+++ b/scene/scene_string_names.h
@@ -30,7 +30,7 @@
#ifndef SCENE_STRING_NAMES_H
#define SCENE_STRING_NAMES_H
-#include "path_db.h"
+#include "node_path.h"
#include "string_db.h"
class SceneStringNames {
@@ -173,8 +173,6 @@ public:
StringName _get_minimum_size;
- StringName play_play;
-
StringName _im_update;
StringName _queue_update;
diff --git a/servers/arvr/arvr_positional_tracker.cpp b/servers/arvr/arvr_positional_tracker.cpp
index 4215363d16..9f3d01267b 100644
--- a/servers/arvr/arvr_positional_tracker.cpp
+++ b/servers/arvr/arvr_positional_tracker.cpp
@@ -40,6 +40,13 @@ void ARVRPositionalTracker::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_tracks_position"), &ARVRPositionalTracker::get_tracks_position);
ClassDB::bind_method(D_METHOD("get_position"), &ARVRPositionalTracker::get_position);
ClassDB::bind_method(D_METHOD("get_transform", "adjust_by_reference_frame"), &ARVRPositionalTracker::get_transform);
+
+ // these functions we don't want to expose to normal users but do need to be callable from GDNative
+ ClassDB::bind_method(D_METHOD("_set_type", "type"), &ARVRPositionalTracker::set_type);
+ ClassDB::bind_method(D_METHOD("_set_name", "name"), &ARVRPositionalTracker::set_name);
+ ClassDB::bind_method(D_METHOD("_set_joy_id", "joy_id"), &ARVRPositionalTracker::set_joy_id);
+ ClassDB::bind_method(D_METHOD("_set_orientation", "orientation"), &ARVRPositionalTracker::set_orientation);
+ ClassDB::bind_method(D_METHOD("_set_rw_position", "rw_position"), &ARVRPositionalTracker::set_rw_position);
};
void ARVRPositionalTracker::set_type(ARVRServer::TrackerType p_type) {
@@ -102,14 +109,36 @@ bool ARVRPositionalTracker::get_tracks_position() const {
void ARVRPositionalTracker::set_position(const Vector3 &p_position) {
_THREAD_SAFE_METHOD_
+ ARVRServer *arvr_server = ARVRServer::get_singleton();
+ ERR_FAIL_NULL(arvr_server);
+ real_t world_scale = arvr_server->get_world_scale();
+ ERR_FAIL_COND(world_scale == 0);
+
tracks_position = true; // obviously we have this
- position = p_position;
+ rw_position = p_position / world_scale;
};
Vector3 ARVRPositionalTracker::get_position() const {
_THREAD_SAFE_METHOD_
- return position;
+ ARVRServer *arvr_server = ARVRServer::get_singleton();
+ ERR_FAIL_NULL_V(arvr_server, rw_position);
+ real_t world_scale = arvr_server->get_world_scale();
+
+ return rw_position * world_scale;
+};
+
+void ARVRPositionalTracker::set_rw_position(const Vector3 &p_rw_position) {
+ _THREAD_SAFE_METHOD_
+
+ tracks_position = true; // obviously we have this
+ rw_position = p_rw_position;
+};
+
+Vector3 ARVRPositionalTracker::get_rw_position() const {
+ _THREAD_SAFE_METHOD_
+
+ return rw_position;
};
Transform ARVRPositionalTracker::get_transform(bool p_adjust_by_reference_frame) const {
diff --git a/servers/arvr/arvr_positional_tracker.h b/servers/arvr/arvr_positional_tracker.h
index e8c613b29d..dba203b73c 100644
--- a/servers/arvr/arvr_positional_tracker.h
+++ b/servers/arvr/arvr_positional_tracker.h
@@ -56,7 +56,7 @@ private:
bool tracks_orientation; // do we track orientation?
Basis orientation; // our orientation
bool tracks_position; // do we track position?
- Vector3 position; // our position
+ Vector3 rw_position; // our position "in the real world, so without world_scale applied"
protected:
static void _bind_methods();
@@ -73,8 +73,10 @@ public:
void set_orientation(const Basis &p_orientation);
Basis get_orientation() const;
bool get_tracks_position() const;
- void set_position(const Vector3 &p_position);
- Vector3 get_position() const;
+ void set_position(const Vector3 &p_position); // set position with world_scale applied
+ Vector3 get_position() const; // get position with world_scale applied
+ void set_rw_position(const Vector3 &p_rw_position);
+ Vector3 get_rw_position() const;
Transform get_transform(bool p_adjust_by_reference_frame) const;
diff --git a/servers/audio_server.cpp b/servers/audio_server.cpp
index 5303aea6d0..d5f351454d 100644
--- a/servers/audio_server.cpp
+++ b/servers/audio_server.cpp
@@ -66,7 +66,8 @@ void AudioDriver::audio_server_process(int p_frames, int32_t *p_buffer, bool p_u
void AudioDriver::update_mix_time(int p_frames) {
_mix_amount += p_frames;
- _last_mix_time = OS::get_singleton()->get_ticks_usec();
+ if (OS::get_singleton())
+ _last_mix_time = OS::get_singleton()->get_ticks_usec();
}
double AudioDriver::get_mix_time() const {
@@ -771,10 +772,11 @@ void AudioServer::finish() {
buses.clear();
- if (AudioDriver::get_singleton()) {
- AudioDriver::get_singleton()->finish();
+ for (int i = 0; i < AudioDriverManager::get_driver_count(); i++) {
+ AudioDriverManager::get_driver(i)->finish();
}
}
+
void AudioServer::update() {
}
diff --git a/servers/physics/area_sw.h b/servers/physics/area_sw.h
index 06e58e3d5a..3dae1db13f 100644
--- a/servers/physics/area_sw.h
+++ b/servers/physics/area_sw.h
@@ -154,6 +154,7 @@ public:
_FORCE_INLINE_ void add_constraint(ConstraintSW *p_constraint) { constraints.insert(p_constraint); }
_FORCE_INLINE_ void remove_constraint(ConstraintSW *p_constraint) { constraints.erase(p_constraint); }
_FORCE_INLINE_ const Set<ConstraintSW *> &get_constraints() const { return constraints; }
+ _FORCE_INLINE_ void clear_constraints() { constraints.clear(); }
void set_monitorable(bool p_monitorable);
_FORCE_INLINE_ bool is_monitorable() const { return monitorable; }
diff --git a/servers/physics/body_sw.cpp b/servers/physics/body_sw.cpp
index 1f32c059a8..e065fae2be 100644
--- a/servers/physics/body_sw.cpp
+++ b/servers/physics/body_sw.cpp
@@ -757,7 +757,8 @@ BodySW::BodySW()
contact_count = 0;
gravity_scale = 1.0;
-
+ linear_damp = -1;
+ angular_damp = -1;
area_angular_damp = 0;
area_linear_damp = 0;
diff --git a/servers/physics/body_sw.h b/servers/physics/body_sw.h
index c3e051c2d0..512b868570 100644
--- a/servers/physics/body_sw.h
+++ b/servers/physics/body_sw.h
@@ -194,6 +194,7 @@ public:
_FORCE_INLINE_ void add_constraint(ConstraintSW *p_constraint, int p_pos) { constraint_map[p_constraint] = p_pos; }
_FORCE_INLINE_ void remove_constraint(ConstraintSW *p_constraint) { constraint_map.erase(p_constraint); }
const Map<ConstraintSW *, int> &get_constraint_map() const { return constraint_map; }
+ _FORCE_INLINE_ void clear_constraint_map() { constraint_map.clear(); }
_FORCE_INLINE_ void set_omit_force_integration(bool p_omit_force_integration) { omit_force_integration = p_omit_force_integration; }
_FORCE_INLINE_ bool get_omit_force_integration() const { return omit_force_integration; }
diff --git a/servers/physics/joints/pin_joint_sw.h b/servers/physics/joints/pin_joint_sw.h
index 644c204066..1d580b6c21 100644
--- a/servers/physics/joints/pin_joint_sw.h
+++ b/servers/physics/joints/pin_joint_sw.h
@@ -83,11 +83,11 @@ public:
void set_param(PhysicsServer::PinJointParam p_param, real_t p_value);
real_t get_param(PhysicsServer::PinJointParam p_param) const;
- void set_pos_A(const Vector3 &p_pos) { m_pivotInA = p_pos; }
- void set_pos_B(const Vector3 &p_pos) { m_pivotInB = p_pos; }
+ void set_pos_a(const Vector3 &p_pos) { m_pivotInA = p_pos; }
+ void set_pos_b(const Vector3 &p_pos) { m_pivotInB = p_pos; }
- Vector3 get_pos_A() { return m_pivotInB; }
- Vector3 get_pos_B() { return m_pivotInA; }
+ Vector3 get_pos_a() { return m_pivotInB; }
+ Vector3 get_pos_b() { return m_pivotInA; }
PinJointSW(BodySW *p_body_a, const Vector3 &p_pos_a, BodySW *p_body_b, const Vector3 &p_pos_b);
~PinJointSW();
diff --git a/servers/physics/physics_server_sw.cpp b/servers/physics/physics_server_sw.cpp
index 101bd4b185..c40503c426 100644
--- a/servers/physics/physics_server_sw.cpp
+++ b/servers/physics/physics_server_sw.cpp
@@ -222,12 +222,24 @@ void PhysicsServerSW::area_set_space(RID p_area, RID p_space) {
AreaSW *area = area_owner.get(p_area);
ERR_FAIL_COND(!area);
+
SpaceSW *space = NULL;
if (p_space.is_valid()) {
space = space_owner.get(p_space);
ERR_FAIL_COND(!space);
}
+ if (area->get_space() == space)
+ return; //pointless
+
+ for (Set<ConstraintSW *>::Element *E = area->get_constraints().front(); E; E = E->next()) {
+ RID self = E->get()->get_self();
+ if (!self.is_valid())
+ continue;
+ free(self);
+ }
+ area->clear_constraints();
+
area->set_space(space);
};
@@ -338,7 +350,7 @@ void PhysicsServerSW::area_set_shape_disabled(RID p_area, int p_shape_idx, bool
area->set_shape_as_disabled(p_shape_idx, p_disabled);
}
-void PhysicsServerSW::area_attach_object_instance_ID(RID p_area, ObjectID p_ID) {
+void PhysicsServerSW::area_attach_object_instance_id(RID p_area, ObjectID p_ID) {
if (space_owner.owns(p_area)) {
SpaceSW *space = space_owner.get(p_area);
@@ -348,7 +360,7 @@ void PhysicsServerSW::area_attach_object_instance_ID(RID p_area, ObjectID p_ID)
ERR_FAIL_COND(!area);
area->set_instance_id(p_ID);
}
-ObjectID PhysicsServerSW::area_get_object_instance_ID(RID p_area) const {
+ObjectID PhysicsServerSW::area_get_object_instance_id(RID p_area) const {
if (space_owner.owns(p_area)) {
SpaceSW *space = space_owner.get(p_area);
@@ -426,7 +438,7 @@ void PhysicsServerSW::area_set_monitor_callback(RID p_area, Object *p_receiver,
AreaSW *area = area_owner.get(p_area);
ERR_FAIL_COND(!area);
- area->set_monitor_callback(p_receiver ? p_receiver->get_instance_ID() : 0, p_method);
+ area->set_monitor_callback(p_receiver ? p_receiver->get_instance_id() : 0, p_method);
}
void PhysicsServerSW::area_set_ray_pickable(RID p_area, bool p_enable) {
@@ -450,7 +462,7 @@ void PhysicsServerSW::area_set_area_monitor_callback(RID p_area, Object *p_recei
AreaSW *area = area_owner.get(p_area);
ERR_FAIL_COND(!area);
- area->set_area_monitor_callback(p_receiver ? p_receiver->get_instance_ID() : 0, p_method);
+ area->set_area_monitor_callback(p_receiver ? p_receiver->get_instance_id() : 0, p_method);
}
/* BODY API */
@@ -471,15 +483,23 @@ void PhysicsServerSW::body_set_space(RID p_body, RID p_space) {
BodySW *body = body_owner.get(p_body);
ERR_FAIL_COND(!body);
- SpaceSW *space = NULL;
+ SpaceSW *space = NULL;
if (p_space.is_valid()) {
space = space_owner.get(p_space);
ERR_FAIL_COND(!space);
}
if (body->get_space() == space)
- return; //pointles
+ return; //pointless
+
+ while (body->get_constraint_map().size()) {
+ RID self = body->get_constraint_map().front()->key()->get_self();
+ if (!self.is_valid())
+ continue;
+ free(self);
+ }
+ body->clear_constraint_map();
body->set_space(space);
};
@@ -642,7 +662,7 @@ uint32_t PhysicsServerSW::body_get_collision_mask(RID p_body) const {
return body->get_collision_mask();
}
-void PhysicsServerSW::body_attach_object_instance_ID(RID p_body, uint32_t p_ID) {
+void PhysicsServerSW::body_attach_object_instance_id(RID p_body, uint32_t p_ID) {
BodySW *body = body_owner.get(p_body);
ERR_FAIL_COND(!body);
@@ -650,7 +670,7 @@ void PhysicsServerSW::body_attach_object_instance_ID(RID p_body, uint32_t p_ID)
body->set_instance_id(p_ID);
};
-uint32_t PhysicsServerSW::body_get_object_instance_ID(RID p_body) const {
+uint32_t PhysicsServerSW::body_get_object_instance_id(RID p_body) const {
BodySW *body = body_owner.get(p_body);
ERR_FAIL_COND_V(!body, 0);
@@ -857,7 +877,7 @@ void PhysicsServerSW::body_set_force_integration_callback(RID p_body, Object *p_
BodySW *body = body_owner.get(p_body);
ERR_FAIL_COND(!body);
- body->set_force_integration_callback(p_receiver ? p_receiver->get_instance_ID() : ObjectID(0), p_method, p_udata);
+ body->set_force_integration_callback(p_receiver ? p_receiver->get_instance_id() : ObjectID(0), p_method, p_udata);
}
void PhysicsServerSW::body_set_ray_pickable(RID p_body, bool p_enable) {
@@ -924,38 +944,38 @@ real_t PhysicsServerSW::pin_joint_get_param(RID p_joint, PinJointParam p_param)
return pin_joint->get_param(p_param);
}
-void PhysicsServerSW::pin_joint_set_local_A(RID p_joint, const Vector3 &p_A) {
+void PhysicsServerSW::pin_joint_set_local_a(RID p_joint, const Vector3 &p_A) {
JointSW *joint = joint_owner.get(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_PIN);
PinJointSW *pin_joint = static_cast<PinJointSW *>(joint);
- pin_joint->set_pos_A(p_A);
+ pin_joint->set_pos_a(p_A);
}
-Vector3 PhysicsServerSW::pin_joint_get_local_A(RID p_joint) const {
+Vector3 PhysicsServerSW::pin_joint_get_local_a(RID p_joint) const {
JointSW *joint = joint_owner.get(p_joint);
ERR_FAIL_COND_V(!joint, Vector3());
ERR_FAIL_COND_V(joint->get_type() != JOINT_PIN, Vector3());
PinJointSW *pin_joint = static_cast<PinJointSW *>(joint);
- return pin_joint->get_pos_A();
+ return pin_joint->get_pos_a();
}
-void PhysicsServerSW::pin_joint_set_local_B(RID p_joint, const Vector3 &p_B) {
+void PhysicsServerSW::pin_joint_set_local_b(RID p_joint, const Vector3 &p_B) {
JointSW *joint = joint_owner.get(p_joint);
ERR_FAIL_COND(!joint);
ERR_FAIL_COND(joint->get_type() != JOINT_PIN);
PinJointSW *pin_joint = static_cast<PinJointSW *>(joint);
- pin_joint->set_pos_B(p_B);
+ pin_joint->set_pos_b(p_B);
}
-Vector3 PhysicsServerSW::pin_joint_get_local_B(RID p_joint) const {
+Vector3 PhysicsServerSW::pin_joint_get_local_b(RID p_joint) const {
JointSW *joint = joint_owner.get(p_joint);
ERR_FAIL_COND_V(!joint, Vector3());
ERR_FAIL_COND_V(joint->get_type() != JOINT_PIN, Vector3());
PinJointSW *pin_joint = static_cast<PinJointSW *>(joint);
- return pin_joint->get_pos_B();
+ return pin_joint->get_pos_b();
}
RID PhysicsServerSW::joint_create_hinge(RID p_body_A, const Transform &p_frame_A, RID p_body_B, const Transform &p_frame_B) {
@@ -1329,12 +1349,6 @@ void PhysicsServerSW::free(RID p_rid) {
body->remove_shape(0);
}
- while (body->get_constraint_map().size()) {
- RID self = body->get_constraint_map().front()->key()->get_self();
- ERR_FAIL_COND(!self.is_valid());
- free(self);
- }
-
body_owner.free(p_rid);
memdelete(body);
diff --git a/servers/physics/physics_server_sw.h b/servers/physics/physics_server_sw.h
index 591fe4af46..bae2839b71 100644
--- a/servers/physics/physics_server_sw.h
+++ b/servers/physics/physics_server_sw.h
@@ -121,8 +121,8 @@ public:
virtual void area_set_shape_disabled(RID p_area, int p_shape_idx, bool p_disabled);
- virtual void area_attach_object_instance_ID(RID p_area, ObjectID p_ID);
- virtual ObjectID area_get_object_instance_ID(RID p_area) const;
+ virtual void area_attach_object_instance_id(RID p_area, ObjectID p_ID);
+ virtual ObjectID area_get_object_instance_id(RID p_area) const;
virtual void area_set_param(RID p_area, AreaParameter p_param, const Variant &p_value);
virtual void area_set_transform(RID p_area, const Transform &p_transform);
@@ -165,8 +165,8 @@ public:
virtual void body_remove_shape(RID p_body, int p_shape_idx);
virtual void body_clear_shapes(RID p_body);
- virtual void body_attach_object_instance_ID(RID p_body, uint32_t p_ID);
- virtual uint32_t body_get_object_instance_ID(RID p_body) const;
+ virtual void body_attach_object_instance_id(RID p_body, uint32_t p_ID);
+ virtual uint32_t body_get_object_instance_id(RID p_body) const;
virtual void body_set_enable_continuous_collision_detection(RID p_body, bool p_enable);
virtual bool body_is_continuous_collision_detection_enabled(RID p_body) const;
@@ -226,11 +226,11 @@ public:
virtual void pin_joint_set_param(RID p_joint, PinJointParam p_param, real_t p_value);
virtual real_t pin_joint_get_param(RID p_joint, PinJointParam p_param) const;
- virtual void pin_joint_set_local_A(RID p_joint, const Vector3 &p_A);
- virtual Vector3 pin_joint_get_local_A(RID p_joint) const;
+ virtual void pin_joint_set_local_a(RID p_joint, const Vector3 &p_A);
+ virtual Vector3 pin_joint_get_local_a(RID p_joint) const;
- virtual void pin_joint_set_local_B(RID p_joint, const Vector3 &p_B);
- virtual Vector3 pin_joint_get_local_B(RID p_joint) const;
+ virtual void pin_joint_set_local_b(RID p_joint, const Vector3 &p_B);
+ virtual Vector3 pin_joint_get_local_b(RID p_joint) const;
virtual RID joint_create_hinge(RID p_body_A, const Transform &p_frame_A, RID p_body_B, const Transform &p_frame_B);
virtual RID joint_create_hinge_simple(RID p_body_A, const Vector3 &p_pivot_A, const Vector3 &p_axis_A, RID p_body_B, const Vector3 &p_pivot_B, const Vector3 &p_axis_B);
diff --git a/servers/physics/space_sw.cpp b/servers/physics/space_sw.cpp
index 5679fc8f60..094cfa4656 100644
--- a/servers/physics/space_sw.cpp
+++ b/servers/physics/space_sw.cpp
@@ -34,12 +34,12 @@
_FORCE_INLINE_ static bool _match_object_type_query(CollisionObjectSW *p_object, uint32_t p_collision_layer, uint32_t p_type_mask) {
- if (p_object->get_type() == CollisionObjectSW::TYPE_AREA)
- return p_type_mask & PhysicsDirectSpaceState::TYPE_MASK_AREA;
-
if ((p_object->get_collision_layer() & p_collision_layer) == 0)
return false;
+ if (p_object->get_type() == CollisionObjectSW::TYPE_AREA)
+ return p_type_mask & PhysicsDirectSpaceState::TYPE_MASK_AREA;
+
BodySW *body = static_cast<BodySW *>(p_object);
return (1 << body->get_mode()) & p_type_mask;
diff --git a/servers/physics_2d/area_2d_sw.h b/servers/physics_2d/area_2d_sw.h
index 68b3c61e44..6d74a4b0f6 100644
--- a/servers/physics_2d/area_2d_sw.h
+++ b/servers/physics_2d/area_2d_sw.h
@@ -153,6 +153,7 @@ public:
_FORCE_INLINE_ void add_constraint(Constraint2DSW *p_constraint) { constraints.insert(p_constraint); }
_FORCE_INLINE_ void remove_constraint(Constraint2DSW *p_constraint) { constraints.erase(p_constraint); }
_FORCE_INLINE_ const Set<Constraint2DSW *> &get_constraints() const { return constraints; }
+ _FORCE_INLINE_ void clear_constraints() { constraints.clear(); }
void set_monitorable(bool p_monitorable);
_FORCE_INLINE_ bool is_monitorable() const { return monitorable; }
diff --git a/servers/physics_2d/body_2d_sw.h b/servers/physics_2d/body_2d_sw.h
index 9e5deef3f2..412f2f51cd 100644
--- a/servers/physics_2d/body_2d_sw.h
+++ b/servers/physics_2d/body_2d_sw.h
@@ -181,6 +181,7 @@ public:
_FORCE_INLINE_ void add_constraint(Constraint2DSW *p_constraint, int p_pos) { constraint_map[p_constraint] = p_pos; }
_FORCE_INLINE_ void remove_constraint(Constraint2DSW *p_constraint) { constraint_map.erase(p_constraint); }
const Map<Constraint2DSW *, int> &get_constraint_map() const { return constraint_map; }
+ _FORCE_INLINE_ void clear_constraint_map() { constraint_map.clear(); }
_FORCE_INLINE_ void set_omit_force_integration(bool p_omit_force_integration) { omit_force_integration = p_omit_force_integration; }
_FORCE_INLINE_ bool get_omit_force_integration() const { return omit_force_integration; }
diff --git a/servers/physics_2d/broad_phase_2d_hash_grid.cpp b/servers/physics_2d/broad_phase_2d_hash_grid.cpp
index 5b6c7e2f38..0330bfa9f3 100644
--- a/servers/physics_2d/broad_phase_2d_hash_grid.cpp
+++ b/servers/physics_2d/broad_phase_2d_hash_grid.cpp
@@ -203,9 +203,11 @@ void BroadPhase2DHashGrid::_exit_grid(Element *p_elem, const Rect2 &p_rect, bool
if (sz.width * sz.height > large_object_min_surface) {
//unpair all elements, instead of checking all, just check what is already paired, so we at least save from checking static vs static
- for (Map<Element *, PairData *>::Element *E = p_elem->paired.front(); E; E = E->next()) {
-
+ Map<Element *, PairData *>::Element *E = p_elem->paired.front();
+ while (E) {
+ Map<Element *, PairData *>::Element *next = E->next();
_unpair_attempt(p_elem, E->key());
+ E = next;
}
if (large_elements[p_elem].dec() == 0) {
diff --git a/servers/physics_2d/physics_2d_server_sw.cpp b/servers/physics_2d/physics_2d_server_sw.cpp
index c20d0d14a2..debd38d43a 100644
--- a/servers/physics_2d/physics_2d_server_sw.cpp
+++ b/servers/physics_2d/physics_2d_server_sw.cpp
@@ -286,12 +286,24 @@ void Physics2DServerSW::area_set_space(RID p_area, RID p_space) {
Area2DSW *area = area_owner.get(p_area);
ERR_FAIL_COND(!area);
+
Space2DSW *space = NULL;
if (p_space.is_valid()) {
space = space_owner.get(p_space);
ERR_FAIL_COND(!space);
}
+ if (area->get_space() == space)
+ return; //pointless
+
+ for (Set<Constraint2DSW *>::Element *E = area->get_constraints().front(); E; E = E->next()) {
+ RID self = E->get()->get_self();
+ if (!self.is_valid())
+ continue;
+ free(self);
+ }
+ area->clear_constraints();
+
area->set_space(space);
};
@@ -403,7 +415,7 @@ void Physics2DServerSW::area_clear_shapes(RID p_area) {
area->remove_shape(0);
}
-void Physics2DServerSW::area_attach_object_instance_ID(RID p_area, ObjectID p_ID) {
+void Physics2DServerSW::area_attach_object_instance_id(RID p_area, ObjectID p_ID) {
if (space_owner.owns(p_area)) {
Space2DSW *space = space_owner.get(p_area);
@@ -413,7 +425,7 @@ void Physics2DServerSW::area_attach_object_instance_ID(RID p_area, ObjectID p_ID
ERR_FAIL_COND(!area);
area->set_instance_id(p_ID);
}
-ObjectID Physics2DServerSW::area_get_object_instance_ID(RID p_area) const {
+ObjectID Physics2DServerSW::area_get_object_instance_id(RID p_area) const {
if (space_owner.owns(p_area)) {
Space2DSW *space = space_owner.get(p_area);
@@ -498,7 +510,7 @@ void Physics2DServerSW::area_set_monitor_callback(RID p_area, Object *p_receiver
Area2DSW *area = area_owner.get(p_area);
ERR_FAIL_COND(!area);
- area->set_monitor_callback(p_receiver ? p_receiver->get_instance_ID() : 0, p_method);
+ area->set_monitor_callback(p_receiver ? p_receiver->get_instance_id() : 0, p_method);
}
void Physics2DServerSW::area_set_area_monitor_callback(RID p_area, Object *p_receiver, const StringName &p_method) {
@@ -506,7 +518,7 @@ void Physics2DServerSW::area_set_area_monitor_callback(RID p_area, Object *p_rec
Area2DSW *area = area_owner.get(p_area);
ERR_FAIL_COND(!area);
- area->set_area_monitor_callback(p_receiver ? p_receiver->get_instance_ID() : 0, p_method);
+ area->set_area_monitor_callback(p_receiver ? p_receiver->get_instance_id() : 0, p_method);
}
/* BODY API */
@@ -533,6 +545,17 @@ void Physics2DServerSW::body_set_space(RID p_body, RID p_space) {
ERR_FAIL_COND(!space);
}
+ if (body->get_space() == space)
+ return; //pointless
+
+ while (body->get_constraint_map().size()) {
+ RID self = body->get_constraint_map().front()->key()->get_self();
+ if (!self.is_valid())
+ continue;
+ free(self);
+ }
+ body->clear_constraint_map();
+
body->set_space(space);
};
@@ -683,7 +706,7 @@ Physics2DServerSW::CCDMode Physics2DServerSW::body_get_continuous_collision_dete
return body->get_continuous_collision_detection_mode();
}
-void Physics2DServerSW::body_attach_object_instance_ID(RID p_body, uint32_t p_ID) {
+void Physics2DServerSW::body_attach_object_instance_id(RID p_body, uint32_t p_ID) {
Body2DSW *body = body_owner.get(p_body);
ERR_FAIL_COND(!body);
@@ -691,7 +714,7 @@ void Physics2DServerSW::body_attach_object_instance_ID(RID p_body, uint32_t p_ID
body->set_instance_id(p_ID);
};
-uint32_t Physics2DServerSW::body_get_object_instance_ID(RID p_body) const {
+uint32_t Physics2DServerSW::body_get_object_instance_id(RID p_body) const {
Body2DSW *body = body_owner.get(p_body);
ERR_FAIL_COND_V(!body, 0);
@@ -899,7 +922,7 @@ void Physics2DServerSW::body_set_force_integration_callback(RID p_body, Object *
Body2DSW *body = body_owner.get(p_body);
ERR_FAIL_COND(!body);
- body->set_force_integration_callback(p_receiver ? p_receiver->get_instance_ID() : ObjectID(0), p_method, p_udata);
+ body->set_force_integration_callback(p_receiver ? p_receiver->get_instance_id() : ObjectID(0), p_method, p_udata);
}
bool Physics2DServerSW::body_collide_shape(RID p_body, int p_body_shape, RID p_shape, const Transform2D &p_shape_xform, const Vector2 &p_motion, Vector2 *r_results, int p_result_max, int &r_result_count) {
@@ -1073,19 +1096,13 @@ void Physics2DServerSW::free(RID p_rid) {
_clear_query(body->get_direct_state_query());
*/
- body->set_space(NULL);
+ body_set_space(p_rid, RID());
while (body->get_shape_count()) {
body->remove_shape(0);
}
- while (body->get_constraint_map().size()) {
- RID self = body->get_constraint_map().front()->key()->get_self();
- ERR_FAIL_COND(!self.is_valid());
- free(self);
- }
-
body_owner.free(p_rid);
memdelete(body);
diff --git a/servers/physics_2d/physics_2d_server_sw.h b/servers/physics_2d/physics_2d_server_sw.h
index da72784b6f..830ba91c98 100644
--- a/servers/physics_2d/physics_2d_server_sw.h
+++ b/servers/physics_2d/physics_2d_server_sw.h
@@ -128,8 +128,8 @@ public:
virtual void area_remove_shape(RID p_area, int p_shape_idx);
virtual void area_clear_shapes(RID p_area);
- virtual void area_attach_object_instance_ID(RID p_area, ObjectID p_ID);
- virtual ObjectID area_get_object_instance_ID(RID p_area) const;
+ virtual void area_attach_object_instance_id(RID p_area, ObjectID p_ID);
+ virtual ObjectID area_get_object_instance_id(RID p_area) const;
virtual void area_set_param(RID p_area, AreaParameter p_param, const Variant &p_value);
virtual void area_set_transform(RID p_area, const Transform2D &p_transform);
@@ -172,8 +172,8 @@ public:
virtual void body_set_shape_disabled(RID p_body, int p_shape, bool p_disabled);
virtual void body_set_shape_as_one_way_collision(RID p_body, int p_shape, bool p_enabled);
- virtual void body_attach_object_instance_ID(RID p_body, uint32_t p_ID);
- virtual uint32_t body_get_object_instance_ID(RID p_body) const;
+ virtual void body_attach_object_instance_id(RID p_body, uint32_t p_ID);
+ virtual uint32_t body_get_object_instance_id(RID p_body) const;
virtual void body_set_continuous_collision_detection_mode(RID p_body, CCDMode p_mode);
virtual CCDMode body_get_continuous_collision_detection_mode(RID p_body) const;
diff --git a/servers/physics_2d/physics_2d_server_wrap_mt.cpp b/servers/physics_2d/physics_2d_server_wrap_mt.cpp
index d39231b161..8d19153268 100644
--- a/servers/physics_2d/physics_2d_server_wrap_mt.cpp
+++ b/servers/physics_2d/physics_2d_server_wrap_mt.cpp
@@ -51,7 +51,7 @@ void Physics2DServerWrapMT::_thread_callback(void *_instance) {
void Physics2DServerWrapMT::thread_loop() {
- server_thread = Thread::get_caller_ID();
+ server_thread = Thread::get_caller_id();
OS::get_singleton()->make_rendering_thread();
@@ -169,12 +169,12 @@ Physics2DServerWrapMT::Physics2DServerWrapMT(Physics2DServer *p_contained, bool
damped_spring_joint_pool_max_size = GLOBAL_GET("memory/limits/multithreaded_server/rid_pool_prealloc");
if (!p_create_thread) {
- server_thread = Thread::get_caller_ID();
+ server_thread = Thread::get_caller_id();
} else {
server_thread = 0;
}
- main_thread = Thread::get_caller_ID();
+ main_thread = Thread::get_caller_id();
first_frame = true;
}
diff --git a/servers/physics_2d/physics_2d_server_wrap_mt.h b/servers/physics_2d/physics_2d_server_wrap_mt.h
index 8b6609d119..8058709c06 100644
--- a/servers/physics_2d/physics_2d_server_wrap_mt.h
+++ b/servers/physics_2d/physics_2d_server_wrap_mt.h
@@ -98,7 +98,7 @@ public:
//these work well, but should be used from the main thread only
bool shape_collide(RID p_shape_A, const Transform2D &p_xform_A, const Vector2 &p_motion_A, RID p_shape_B, const Transform2D &p_xform_B, const Vector2 &p_motion_B, Vector2 *r_results, int p_result_max, int &r_result_count) {
- ERR_FAIL_COND_V(main_thread != Thread::get_caller_ID(), false);
+ ERR_FAIL_COND_V(main_thread != Thread::get_caller_id(), false);
return physics_2d_server->shape_collide(p_shape_A, p_xform_A, p_motion_A, p_shape_B, p_xform_B, p_motion_B, r_results, p_result_max, r_result_count);
}
@@ -114,20 +114,20 @@ public:
// this function only works on fixed process, errors and returns null otherwise
Physics2DDirectSpaceState *space_get_direct_state(RID p_space) {
- ERR_FAIL_COND_V(main_thread != Thread::get_caller_ID(), NULL);
+ ERR_FAIL_COND_V(main_thread != Thread::get_caller_id(), NULL);
return physics_2d_server->space_get_direct_state(p_space);
}
FUNC2(space_set_debug_contacts, RID, int);
virtual Vector<Vector2> space_get_contacts(RID p_space) const {
- ERR_FAIL_COND_V(main_thread != Thread::get_caller_ID(), Vector<Vector2>());
+ ERR_FAIL_COND_V(main_thread != Thread::get_caller_id(), Vector<Vector2>());
return physics_2d_server->space_get_contacts(p_space);
}
virtual int space_get_contact_count(RID p_space) const {
- ERR_FAIL_COND_V(main_thread != Thread::get_caller_ID(), 0);
+ ERR_FAIL_COND_V(main_thread != Thread::get_caller_id(), 0);
return physics_2d_server->space_get_contact_count(p_space);
}
@@ -153,8 +153,8 @@ public:
FUNC2(area_remove_shape, RID, int);
FUNC1(area_clear_shapes, RID);
- FUNC2(area_attach_object_instance_ID, RID, ObjectID);
- FUNC1RC(ObjectID, area_get_object_instance_ID, RID);
+ FUNC2(area_attach_object_instance_id, RID, ObjectID);
+ FUNC1RC(ObjectID, area_get_object_instance_id, RID);
FUNC3(area_set_param, RID, AreaParameter, const Variant &);
FUNC2(area_set_transform, RID, const Transform2D &);
@@ -198,8 +198,8 @@ public:
FUNC2(body_remove_shape, RID, int);
FUNC1(body_clear_shapes, RID);
- FUNC2(body_attach_object_instance_ID, RID, uint32_t);
- FUNC1RC(uint32_t, body_get_object_instance_ID, RID);
+ FUNC2(body_attach_object_instance_id, RID, uint32_t);
+ FUNC1RC(uint32_t, body_get_object_instance_id, RID);
FUNC2(body_set_continuous_collision_detection_mode, RID, CCDMode);
FUNC1RC(CCDMode, body_get_continuous_collision_detection_mode, RID);
@@ -249,7 +249,7 @@ public:
bool body_test_motion(RID p_body, const Transform2D &p_from, const Vector2 &p_motion, real_t p_margin = 0.001, MotionResult *r_result = NULL) {
- ERR_FAIL_COND_V(main_thread != Thread::get_caller_ID(), false);
+ ERR_FAIL_COND_V(main_thread != Thread::get_caller_id(), false);
return physics_2d_server->body_test_motion(p_body, p_from, p_motion, p_margin, r_result);
}
diff --git a/servers/physics_2d_server.cpp b/servers/physics_2d_server.cpp
index fb7e89bd9e..aa698f56d8 100644
--- a/servers/physics_2d_server.cpp
+++ b/servers/physics_2d_server.cpp
@@ -514,8 +514,8 @@ void Physics2DServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("area_get_param", "area", "param"), &Physics2DServer::area_get_param);
ClassDB::bind_method(D_METHOD("area_get_transform", "area"), &Physics2DServer::area_get_transform);
- ClassDB::bind_method(D_METHOD("area_attach_object_instance_ID", "area", "id"), &Physics2DServer::area_attach_object_instance_ID);
- ClassDB::bind_method(D_METHOD("area_get_object_instance_ID", "area"), &Physics2DServer::area_get_object_instance_ID);
+ ClassDB::bind_method(D_METHOD("area_attach_object_instance_id", "area", "id"), &Physics2DServer::area_attach_object_instance_id);
+ ClassDB::bind_method(D_METHOD("area_get_object_instance_id", "area"), &Physics2DServer::area_get_object_instance_id);
ClassDB::bind_method(D_METHOD("area_set_monitor_callback", "area", "receiver", "method"), &Physics2DServer::area_set_monitor_callback);
@@ -543,8 +543,8 @@ void Physics2DServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("body_set_shape_disabled", "body", "shape_idx", "disable"), &Physics2DServer::body_set_shape_disabled);
ClassDB::bind_method(D_METHOD("body_set_shape_as_one_way_collision", "body", "shape_idx", "enable"), &Physics2DServer::body_set_shape_as_one_way_collision);
- ClassDB::bind_method(D_METHOD("body_attach_object_instance_ID", "body", "id"), &Physics2DServer::body_attach_object_instance_ID);
- ClassDB::bind_method(D_METHOD("body_get_object_instance_ID", "body"), &Physics2DServer::body_get_object_instance_ID);
+ ClassDB::bind_method(D_METHOD("body_attach_object_instance_id", "body", "id"), &Physics2DServer::body_attach_object_instance_id);
+ ClassDB::bind_method(D_METHOD("body_get_object_instance_id", "body"), &Physics2DServer::body_get_object_instance_id);
ClassDB::bind_method(D_METHOD("body_set_continuous_collision_detection_mode", "body", "mode"), &Physics2DServer::body_set_continuous_collision_detection_mode);
ClassDB::bind_method(D_METHOD("body_get_continuous_collision_detection_mode", "body"), &Physics2DServer::body_get_continuous_collision_detection_mode);
diff --git a/servers/physics_2d_server.h b/servers/physics_2d_server.h
index e396424707..f3acd8df18 100644
--- a/servers/physics_2d_server.h
+++ b/servers/physics_2d_server.h
@@ -334,8 +334,8 @@ public:
virtual void area_set_shape_disabled(RID p_area, int p_shape, bool p_disabled) = 0;
- virtual void area_attach_object_instance_ID(RID p_area, ObjectID p_ID) = 0;
- virtual ObjectID area_get_object_instance_ID(RID p_area) const = 0;
+ virtual void area_attach_object_instance_id(RID p_area, ObjectID p_ID) = 0;
+ virtual ObjectID area_get_object_instance_id(RID p_area) const = 0;
virtual void area_set_param(RID p_area, AreaParameter p_param, const Variant &p_value) = 0;
virtual void area_set_transform(RID p_area, const Transform2D &p_transform) = 0;
@@ -388,8 +388,8 @@ public:
virtual void body_remove_shape(RID p_body, int p_shape_idx) = 0;
virtual void body_clear_shapes(RID p_body) = 0;
- virtual void body_attach_object_instance_ID(RID p_body, uint32_t p_ID) = 0;
- virtual uint32_t body_get_object_instance_ID(RID p_body) const = 0;
+ virtual void body_attach_object_instance_id(RID p_body, uint32_t p_ID) = 0;
+ virtual uint32_t body_get_object_instance_id(RID p_body) const = 0;
enum CCDMode {
CCD_MODE_DISABLED,
diff --git a/servers/physics_server.cpp b/servers/physics_server.cpp
index 6b6db1ff8c..02f8e6e1af 100644
--- a/servers/physics_server.cpp
+++ b/servers/physics_server.cpp
@@ -434,8 +434,8 @@ void PhysicsServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("area_get_param", "area", "param"), &PhysicsServer::area_get_param);
ClassDB::bind_method(D_METHOD("area_get_transform", "area"), &PhysicsServer::area_get_transform);
- ClassDB::bind_method(D_METHOD("area_attach_object_instance_ID", "area", "id"), &PhysicsServer::area_attach_object_instance_ID);
- ClassDB::bind_method(D_METHOD("area_get_object_instance_ID", "area"), &PhysicsServer::area_get_object_instance_ID);
+ ClassDB::bind_method(D_METHOD("area_attach_object_instance_id", "area", "id"), &PhysicsServer::area_attach_object_instance_id);
+ ClassDB::bind_method(D_METHOD("area_get_object_instance_id", "area"), &PhysicsServer::area_get_object_instance_id);
ClassDB::bind_method(D_METHOD("area_set_monitor_callback", "area", "receiver", "method"), &PhysicsServer::area_set_monitor_callback);
@@ -467,8 +467,8 @@ void PhysicsServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("body_remove_shape", "body", "shape_idx"), &PhysicsServer::body_remove_shape);
ClassDB::bind_method(D_METHOD("body_clear_shapes", "body"), &PhysicsServer::body_clear_shapes);
- ClassDB::bind_method(D_METHOD("body_attach_object_instance_ID", "body", "id"), &PhysicsServer::body_attach_object_instance_ID);
- ClassDB::bind_method(D_METHOD("body_get_object_instance_ID", "body"), &PhysicsServer::body_get_object_instance_ID);
+ ClassDB::bind_method(D_METHOD("body_attach_object_instance_id", "body", "id"), &PhysicsServer::body_attach_object_instance_id);
+ ClassDB::bind_method(D_METHOD("body_get_object_instance_id", "body"), &PhysicsServer::body_get_object_instance_id);
ClassDB::bind_method(D_METHOD("body_set_enable_continuous_collision_detection", "body", "enable"), &PhysicsServer::body_set_enable_continuous_collision_detection);
ClassDB::bind_method(D_METHOD("body_is_continuous_collision_detection_enabled", "body"), &PhysicsServer::body_is_continuous_collision_detection_enabled);
@@ -516,11 +516,11 @@ void PhysicsServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("pin_joint_set_param", "joint", "param", "value"), &PhysicsServer::pin_joint_set_param);
ClassDB::bind_method(D_METHOD("pin_joint_get_param", "joint", "param"), &PhysicsServer::pin_joint_get_param);
- ClassDB::bind_method(D_METHOD("pin_joint_set_local_A", "joint", "local_A"), &PhysicsServer::pin_joint_set_local_A);
- ClassDB::bind_method(D_METHOD("pin_joint_get_local_A", "joint"), &PhysicsServer::pin_joint_get_local_A);
+ ClassDB::bind_method(D_METHOD("pin_joint_set_local_a", "joint", "local_A"), &PhysicsServer::pin_joint_set_local_a);
+ ClassDB::bind_method(D_METHOD("pin_joint_get_local_a", "joint"), &PhysicsServer::pin_joint_get_local_a);
- ClassDB::bind_method(D_METHOD("pin_joint_set_local_B", "joint", "local_B"), &PhysicsServer::pin_joint_set_local_B);
- ClassDB::bind_method(D_METHOD("pin_joint_get_local_B", "joint"), &PhysicsServer::pin_joint_get_local_B);
+ ClassDB::bind_method(D_METHOD("pin_joint_set_local_b", "joint", "local_B"), &PhysicsServer::pin_joint_set_local_b);
+ ClassDB::bind_method(D_METHOD("pin_joint_get_local_b", "joint"), &PhysicsServer::pin_joint_get_local_b);
BIND_CONSTANT(PIN_JOINT_BIAS);
BIND_CONSTANT(PIN_JOINT_DAMPING);
diff --git a/servers/physics_server.h b/servers/physics_server.h
index 0f07fca637..b38e14eb0c 100644
--- a/servers/physics_server.h
+++ b/servers/physics_server.h
@@ -328,8 +328,8 @@ public:
virtual void area_set_shape_disabled(RID p_area, int p_shape_idx, bool p_disabled) = 0;
- virtual void area_attach_object_instance_ID(RID p_area, ObjectID p_ID) = 0;
- virtual ObjectID area_get_object_instance_ID(RID p_area) const = 0;
+ virtual void area_attach_object_instance_id(RID p_area, ObjectID p_ID) = 0;
+ virtual ObjectID area_get_object_instance_id(RID p_area) const = 0;
virtual void area_set_param(RID p_area, AreaParameter p_param, const Variant &p_value) = 0;
virtual void area_set_transform(RID p_area, const Transform &p_transform) = 0;
@@ -381,8 +381,8 @@ public:
virtual void body_set_shape_disabled(RID p_body, int p_shape_idx, bool p_disabled) = 0;
- virtual void body_attach_object_instance_ID(RID p_body, uint32_t p_ID) = 0;
- virtual uint32_t body_get_object_instance_ID(RID p_body) const = 0;
+ virtual void body_attach_object_instance_id(RID p_body, uint32_t p_ID) = 0;
+ virtual uint32_t body_get_object_instance_id(RID p_body) const = 0;
virtual void body_set_enable_continuous_collision_detection(RID p_body, bool p_enable) = 0;
virtual bool body_is_continuous_collision_detection_enabled(RID p_body) const = 0;
@@ -508,11 +508,11 @@ public:
virtual void pin_joint_set_param(RID p_joint, PinJointParam p_param, float p_value) = 0;
virtual float pin_joint_get_param(RID p_joint, PinJointParam p_param) const = 0;
- virtual void pin_joint_set_local_A(RID p_joint, const Vector3 &p_A) = 0;
- virtual Vector3 pin_joint_get_local_A(RID p_joint) const = 0;
+ virtual void pin_joint_set_local_a(RID p_joint, const Vector3 &p_A) = 0;
+ virtual Vector3 pin_joint_get_local_a(RID p_joint) const = 0;
- virtual void pin_joint_set_local_B(RID p_joint, const Vector3 &p_B) = 0;
- virtual Vector3 pin_joint_get_local_B(RID p_joint) const = 0;
+ virtual void pin_joint_set_local_b(RID p_joint, const Vector3 &p_B) = 0;
+ virtual Vector3 pin_joint_get_local_b(RID p_joint) const = 0;
enum HingeJointParam {
diff --git a/servers/server_wrap_mt_common.h b/servers/server_wrap_mt_common.h
index e285483e2b..1ffa5ad14c 100644
--- a/servers/server_wrap_mt_common.h
+++ b/servers/server_wrap_mt_common.h
@@ -30,7 +30,7 @@
#define FUNC0R(m_r, m_type) \
virtual m_r m_type() { \
- if (Thread::get_caller_ID() != server_thread) { \
+ if (Thread::get_caller_id() != server_thread) { \
m_r ret; \
command_queue.push_and_ret(server_name, &ServerName::m_type, &ret); \
SYNC_DEBUG \
@@ -55,7 +55,7 @@
} \
} \
virtual RID m_type##_create() { \
- if (Thread::get_caller_ID() != server_thread) { \
+ if (Thread::get_caller_id() != server_thread) { \
RID rid; \
alloc_mutex->lock(); \
if (m_type##_id_pool.size() == 0) { \
@@ -85,7 +85,7 @@
} \
} \
virtual RID m_type##_create(m_arg1 p1) { \
- if (Thread::get_caller_ID() != server_thread) { \
+ if (Thread::get_caller_id() != server_thread) { \
RID rid; \
alloc_mutex->lock(); \
if (m_type##_id_pool.size() == 0) { \
@@ -115,7 +115,7 @@
} \
} \
virtual RID m_type##_create(m_arg1 p1, m_arg2 p2) { \
- if (Thread::get_caller_ID() != server_thread) { \
+ if (Thread::get_caller_id() != server_thread) { \
RID rid; \
alloc_mutex->lock(); \
if (m_type##_id_pool.size() == 0) { \
@@ -145,7 +145,7 @@
} \
} \
virtual RID m_type##_create(m_arg1 p1, m_arg2 p2, m_arg3 p3) { \
- if (Thread::get_caller_ID() != server_thread) { \
+ if (Thread::get_caller_id() != server_thread) { \
RID rid; \
alloc_mutex->lock(); \
if (m_type##_id_pool.size() == 0) { \
@@ -175,7 +175,7 @@
} \
} \
virtual RID m_type##_create(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4) { \
- if (Thread::get_caller_ID() != server_thread) { \
+ if (Thread::get_caller_id() != server_thread) { \
RID rid; \
alloc_mutex->lock(); \
if (m_type##_id_pool.size() == 0) { \
@@ -205,7 +205,7 @@
} \
} \
virtual RID m_type##_create(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5) { \
- if (Thread::get_caller_ID() != server_thread) { \
+ if (Thread::get_caller_id() != server_thread) { \
RID rid; \
alloc_mutex->lock(); \
if (m_type##_id_pool.size() == 0) { \
@@ -223,7 +223,7 @@
#define FUNC0RC(m_r, m_type) \
virtual m_r m_type() const { \
- if (Thread::get_caller_ID() != server_thread) { \
+ if (Thread::get_caller_id() != server_thread) { \
m_r ret; \
command_queue.push_and_ret(server_name, &ServerName::m_type, &ret); \
SYNC_DEBUG \
@@ -235,7 +235,7 @@
#define FUNC0(m_type) \
virtual void m_type() { \
- if (Thread::get_caller_ID() != server_thread) { \
+ if (Thread::get_caller_id() != server_thread) { \
command_queue.push(server_name, &ServerName::m_type); \
} else { \
server_name->m_type(); \
@@ -244,7 +244,7 @@
#define FUNC0C(m_type) \
virtual void m_type() const { \
- if (Thread::get_caller_ID() != server_thread) { \
+ if (Thread::get_caller_id() != server_thread) { \
command_queue.push(server_name, &ServerName::m_type); \
} else { \
server_name->m_type(); \
@@ -253,7 +253,7 @@
#define FUNC0S(m_type) \
virtual void m_type() { \
- if (Thread::get_caller_ID() != server_thread) { \
+ if (Thread::get_caller_id() != server_thread) { \
command_queue.push_and_sync(server_name, &ServerName::m_type); \
} else { \
server_name->m_type(); \
@@ -262,7 +262,7 @@
#define FUNC0SC(m_type) \
virtual void m_type() const { \
- if (Thread::get_caller_ID() != server_thread) { \
+ if (Thread::get_caller_id() != server_thread) { \
command_queue.push_and_sync(server_name, &ServerName::m_type); \
} else { \
server_name->m_type(); \
@@ -273,7 +273,7 @@
#define FUNC1R(m_r, m_type, m_arg1) \
virtual m_r m_type(m_arg1 p1) { \
- if (Thread::get_caller_ID() != server_thread) { \
+ if (Thread::get_caller_id() != server_thread) { \
m_r ret; \
command_queue.push_and_ret(server_name, &ServerName::m_type, p1, &ret); \
SYNC_DEBUG \
@@ -285,7 +285,7 @@
#define FUNC1RC(m_r, m_type, m_arg1) \
virtual m_r m_type(m_arg1 p1) const { \
- if (Thread::get_caller_ID() != server_thread) { \
+ if (Thread::get_caller_id() != server_thread) { \
m_r ret; \
command_queue.push_and_ret(server_name, &ServerName::m_type, p1, &ret); \
SYNC_DEBUG \
@@ -297,7 +297,7 @@
#define FUNC1S(m_type, m_arg1) \
virtual void m_type(m_arg1 p1) { \
- if (Thread::get_caller_ID() != server_thread) { \
+ if (Thread::get_caller_id() != server_thread) { \
command_queue.push_and_sync(server_name, &ServerName::m_type, p1); \
} else { \
server_name->m_type(p1); \
@@ -306,7 +306,7 @@
#define FUNC1SC(m_type, m_arg1) \
virtual void m_type(m_arg1 p1) const { \
- if (Thread::get_caller_ID() != server_thread) { \
+ if (Thread::get_caller_id() != server_thread) { \
command_queue.push_and_sync(server_name, &ServerName::m_type, p1); \
} else { \
server_name->m_type(p1); \
@@ -315,7 +315,7 @@
#define FUNC1(m_type, m_arg1) \
virtual void m_type(m_arg1 p1) { \
- if (Thread::get_caller_ID() != server_thread) { \
+ if (Thread::get_caller_id() != server_thread) { \
command_queue.push(server_name, &ServerName::m_type, p1); \
} else { \
server_name->m_type(p1); \
@@ -324,7 +324,7 @@
#define FUNC1C(m_type, m_arg1) \
virtual void m_type(m_arg1 p1) const { \
- if (Thread::get_caller_ID() != server_thread) { \
+ if (Thread::get_caller_id() != server_thread) { \
command_queue.push(server_name, &ServerName::m_type, p1); \
} else { \
server_name->m_type(p1); \
@@ -333,7 +333,7 @@
#define FUNC2R(m_r, m_type, m_arg1, m_arg2) \
virtual m_r m_type(m_arg1 p1, m_arg2 p2) { \
- if (Thread::get_caller_ID() != server_thread) { \
+ if (Thread::get_caller_id() != server_thread) { \
m_r ret; \
command_queue.push_and_ret(server_name, &ServerName::m_type, p1, p2, &ret); \
SYNC_DEBUG \
@@ -345,7 +345,7 @@
#define FUNC2RC(m_r, m_type, m_arg1, m_arg2) \
virtual m_r m_type(m_arg1 p1, m_arg2 p2) const { \
- if (Thread::get_caller_ID() != server_thread) { \
+ if (Thread::get_caller_id() != server_thread) { \
m_r ret; \
command_queue.push_and_ret(server_name, &ServerName::m_type, p1, p2, &ret); \
SYNC_DEBUG \
@@ -357,7 +357,7 @@
#define FUNC2S(m_type, m_arg1, m_arg2) \
virtual void m_type(m_arg1 p1, m_arg2 p2) { \
- if (Thread::get_caller_ID() != server_thread) { \
+ if (Thread::get_caller_id() != server_thread) { \
command_queue.push_and_sync(server_name, &ServerName::m_type, p1, p2); \
} else { \
server_name->m_type(p1, p2); \
@@ -366,7 +366,7 @@
#define FUNC2SC(m_type, m_arg1, m_arg2) \
virtual void m_type(m_arg1 p1, m_arg2 p2) const { \
- if (Thread::get_caller_ID() != server_thread) { \
+ if (Thread::get_caller_id() != server_thread) { \
command_queue.push_and_sync(server_name, &ServerName::m_type, p1, p2); \
} else { \
server_name->m_type(p1, p2); \
@@ -375,7 +375,7 @@
#define FUNC2(m_type, m_arg1, m_arg2) \
virtual void m_type(m_arg1 p1, m_arg2 p2) { \
- if (Thread::get_caller_ID() != server_thread) { \
+ if (Thread::get_caller_id() != server_thread) { \
command_queue.push(server_name, &ServerName::m_type, p1, p2); \
} else { \
server_name->m_type(p1, p2); \
@@ -384,7 +384,7 @@
#define FUNC2C(m_type, m_arg1, m_arg2) \
virtual void m_type(m_arg1 p1, m_arg2 p2) const { \
- if (Thread::get_caller_ID() != server_thread) { \
+ if (Thread::get_caller_id() != server_thread) { \
command_queue.push(server_name, &ServerName::m_type, p1, p2); \
} else { \
server_name->m_type(p1, p2); \
@@ -393,7 +393,7 @@
#define FUNC3R(m_r, m_type, m_arg1, m_arg2, m_arg3) \
virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3) { \
- if (Thread::get_caller_ID() != server_thread) { \
+ if (Thread::get_caller_id() != server_thread) { \
m_r ret; \
command_queue.push_and_ret(server_name, &ServerName::m_type, p1, p2, p3, &ret); \
SYNC_DEBUG \
@@ -405,7 +405,7 @@
#define FUNC3RC(m_r, m_type, m_arg1, m_arg2, m_arg3) \
virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3) const { \
- if (Thread::get_caller_ID() != server_thread) { \
+ if (Thread::get_caller_id() != server_thread) { \
m_r ret; \
command_queue.push_and_ret(server_name, &ServerName::m_type, p1, p2, p3, &ret); \
return ret; \
@@ -416,7 +416,7 @@
#define FUNC3S(m_type, m_arg1, m_arg2, m_arg3) \
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3) { \
- if (Thread::get_caller_ID() != server_thread) { \
+ if (Thread::get_caller_id() != server_thread) { \
command_queue.push_and_sync(server_name, &ServerName::m_type, p1, p2, p3); \
} else { \
server_name->m_type(p1, p2, p3); \
@@ -425,7 +425,7 @@
#define FUNC3SC(m_type, m_arg1, m_arg2, m_arg3) \
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3) const { \
- if (Thread::get_caller_ID() != server_thread) { \
+ if (Thread::get_caller_id() != server_thread) { \
command_queue.push_and_sync(server_name, &ServerName::m_type, p1, p2, p3); \
} else { \
server_name->m_type(p1, p2, p3); \
@@ -434,7 +434,7 @@
#define FUNC3(m_type, m_arg1, m_arg2, m_arg3) \
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3) { \
- if (Thread::get_caller_ID() != server_thread) { \
+ if (Thread::get_caller_id() != server_thread) { \
command_queue.push(server_name, &ServerName::m_type, p1, p2, p3); \
} else { \
server_name->m_type(p1, p2, p3); \
@@ -443,7 +443,7 @@
#define FUNC3C(m_type, m_arg1, m_arg2, m_arg3) \
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3) const { \
- if (Thread::get_caller_ID() != server_thread) { \
+ if (Thread::get_caller_id() != server_thread) { \
command_queue.push(server_name, &ServerName::m_type, p1, p2, p3); \
} else { \
server_name->m_type(p1, p2, p3); \
@@ -452,7 +452,7 @@
#define FUNC4R(m_r, m_type, m_arg1, m_arg2, m_arg3, m_arg4) \
virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4) { \
- if (Thread::get_caller_ID() != server_thread) { \
+ if (Thread::get_caller_id() != server_thread) { \
m_r ret; \
command_queue.push_and_ret(server_name, &ServerName::m_type, p1, p2, p3, p4, &ret); \
SYNC_DEBUG \
@@ -464,7 +464,7 @@
#define FUNC4RC(m_r, m_type, m_arg1, m_arg2, m_arg3, m_arg4) \
virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4) const { \
- if (Thread::get_caller_ID() != server_thread) { \
+ if (Thread::get_caller_id() != server_thread) { \
m_r ret; \
command_queue.push_and_ret(server_name, &ServerName::m_type, p1, p2, p3, p4, &ret); \
SYNC_DEBUG \
@@ -476,7 +476,7 @@
#define FUNC4S(m_type, m_arg1, m_arg2, m_arg3, m_arg4) \
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4) { \
- if (Thread::get_caller_ID() != server_thread) { \
+ if (Thread::get_caller_id() != server_thread) { \
command_queue.push_and_sync(server_name, &ServerName::m_type, p1, p2, p3, p4); \
} else { \
server_name->m_type(p1, p2, p3, p4); \
@@ -485,7 +485,7 @@
#define FUNC4SC(m_type, m_arg1, m_arg2, m_arg3, m_arg4) \
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4) const { \
- if (Thread::get_caller_ID() != server_thread) { \
+ if (Thread::get_caller_id() != server_thread) { \
command_queue.push_and_sync(server_name, &ServerName::m_type, p1, p2, p3, p4); \
} else { \
server_name->m_type(p1, p2, p3, p4); \
@@ -494,7 +494,7 @@
#define FUNC4(m_type, m_arg1, m_arg2, m_arg3, m_arg4) \
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4) { \
- if (Thread::get_caller_ID() != server_thread) { \
+ if (Thread::get_caller_id() != server_thread) { \
command_queue.push(server_name, &ServerName::m_type, p1, p2, p3, p4); \
} else { \
server_name->m_type(p1, p2, p3, p4); \
@@ -503,7 +503,7 @@
#define FUNC4C(m_type, m_arg1, m_arg2, m_arg3, m_arg4) \
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4) const { \
- if (Thread::get_caller_ID() != server_thread) { \
+ if (Thread::get_caller_id() != server_thread) { \
command_queue.push(server_name, &ServerName::m_type, p1, p2, p3, p4); \
} else { \
server_name->m_type(p1, p2, p3, p4); \
@@ -512,7 +512,7 @@
#define FUNC5R(m_r, m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5) \
virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5) { \
- if (Thread::get_caller_ID() != server_thread) { \
+ if (Thread::get_caller_id() != server_thread) { \
m_r ret; \
command_queue.push_and_ret(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, &ret); \
SYNC_DEBUG \
@@ -524,7 +524,7 @@
#define FUNC5RC(m_r, m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5) \
virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5) const { \
- if (Thread::get_caller_ID() != server_thread) { \
+ if (Thread::get_caller_id() != server_thread) { \
m_r ret; \
command_queue.push_and_ret(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, &ret); \
SYNC_DEBUG \
@@ -536,7 +536,7 @@
#define FUNC5S(m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5) \
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5) { \
- if (Thread::get_caller_ID() != server_thread) { \
+ if (Thread::get_caller_id() != server_thread) { \
command_queue.push_and_sync(server_name, &ServerName::m_type, p1, p2, p3, p4, p5); \
} else { \
server_name->m_type(p1, p2, p3, p4, p5); \
@@ -545,7 +545,7 @@
#define FUNC5SC(m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5) \
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5) const { \
- if (Thread::get_caller_ID() != server_thread) { \
+ if (Thread::get_caller_id() != server_thread) { \
command_queue.push_and_sync(server_name, &ServerName::m_type, p1, p2, p3, p4, p5); \
} else { \
server_name->m_type(p1, p2, p3, p4, p5); \
@@ -554,7 +554,7 @@
#define FUNC5(m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5) \
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5) { \
- if (Thread::get_caller_ID() != server_thread) { \
+ if (Thread::get_caller_id() != server_thread) { \
command_queue.push(server_name, &ServerName::m_type, p1, p2, p3, p4, p5); \
} else { \
server_name->m_type(p1, p2, p3, p4, p5); \
@@ -563,7 +563,7 @@
#define FUNC5C(m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5) \
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5) const { \
- if (Thread::get_caller_ID() != server_thread) { \
+ if (Thread::get_caller_id() != server_thread) { \
command_queue.push(server_name, &ServerName::m_type, p1, p2, p3, p4, p5); \
} else { \
server_name->m_type(p1, p2, p3, p4, p5); \
@@ -572,7 +572,7 @@
#define FUNC6R(m_r, m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6) \
virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6) { \
- if (Thread::get_caller_ID() != server_thread) { \
+ if (Thread::get_caller_id() != server_thread) { \
m_r ret; \
command_queue.push_and_ret(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6, &ret); \
SYNC_DEBUG \
@@ -584,7 +584,7 @@
#define FUNC6RC(m_r, m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6) \
virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6) const { \
- if (Thread::get_caller_ID() != server_thread) { \
+ if (Thread::get_caller_id() != server_thread) { \
m_r ret; \
command_queue.push_and_ret(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6, &ret); \
return ret; \
@@ -595,7 +595,7 @@
#define FUNC6S(m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6) \
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6) { \
- if (Thread::get_caller_ID() != server_thread) { \
+ if (Thread::get_caller_id() != server_thread) { \
command_queue.push_and_sync(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6); \
} else { \
server_name->m_type(p1, p2, p3, p4, p5, p6); \
@@ -604,7 +604,7 @@
#define FUNC6SC(m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6) \
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6) const { \
- if (Thread::get_caller_ID() != server_thread) { \
+ if (Thread::get_caller_id() != server_thread) { \
command_queue.push_and_sync(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6); \
} else { \
server_name->m_type(p1, p2, p3, p4, p5, p6); \
@@ -613,7 +613,7 @@
#define FUNC6(m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6) \
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6) { \
- if (Thread::get_caller_ID() != server_thread) { \
+ if (Thread::get_caller_id() != server_thread) { \
command_queue.push(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6); \
} else { \
server_name->m_type(p1, p2, p3, p4, p5, p6); \
@@ -622,7 +622,7 @@
#define FUNC6C(m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6) \
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6) const { \
- if (Thread::get_caller_ID() != server_thread) { \
+ if (Thread::get_caller_id() != server_thread) { \
command_queue.push(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6); \
} else { \
server_name->m_type(p1, p2, p3, p4, p5, p6); \
@@ -631,7 +631,7 @@
#define FUNC7R(m_r, m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7) \
virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6, m_arg7 p7) { \
- if (Thread::get_caller_ID() != server_thread) { \
+ if (Thread::get_caller_id() != server_thread) { \
m_r ret; \
command_queue.push_and_ret(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6, p7, &ret); \
SYNC_DEBUG \
@@ -643,7 +643,7 @@
#define FUNC7RC(m_r, m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7) \
virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6, m_arg7 p7) const { \
- if (Thread::get_caller_ID() != server_thread) { \
+ if (Thread::get_caller_id() != server_thread) { \
m_r ret; \
command_queue.push_and_ret(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6, p7, &ret); \
SYNC_DEBUG \
@@ -655,7 +655,7 @@
#define FUNC7S(m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7) \
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6, m_arg7 p7) { \
- if (Thread::get_caller_ID() != server_thread) { \
+ if (Thread::get_caller_id() != server_thread) { \
command_queue.push_and_sync(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6, p7); \
} else { \
server_name->m_type(p1, p2, p3, p4, p5, p6, p7); \
@@ -664,7 +664,7 @@
#define FUNC7SC(m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7) \
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6, m_arg7 p7) const { \
- if (Thread::get_caller_ID() != server_thread) { \
+ if (Thread::get_caller_id() != server_thread) { \
command_queue.push_and_sync(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6, p7); \
} else { \
server_name->m_type(p1, p2, p3, p4, p5, p6, p7); \
@@ -673,7 +673,7 @@
#define FUNC7(m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7) \
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6, m_arg7 p7) { \
- if (Thread::get_caller_ID() != server_thread) { \
+ if (Thread::get_caller_id() != server_thread) { \
command_queue.push(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6, p7); \
} else { \
server_name->m_type(p1, p2, p3, p4, p5, p6, p7); \
@@ -682,7 +682,7 @@
#define FUNC7C(m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7) \
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6, m_arg7 p7) const { \
- if (Thread::get_caller_ID() != server_thread) { \
+ if (Thread::get_caller_id() != server_thread) { \
command_queue.push(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6, p7); \
} else { \
server_name->m_type(p1, p2, p3, p4, p5, p6, p7); \
@@ -691,7 +691,7 @@
#define FUNC8R(m_r, m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7, m_arg8) \
virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6, m_arg7 p7, m_arg8 p8) { \
- if (Thread::get_caller_ID() != server_thread) { \
+ if (Thread::get_caller_id() != server_thread) { \
m_r ret; \
command_queue.push_and_ret(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6, p7, p8, &ret); \
SYNC_DEBUG \
@@ -703,7 +703,7 @@
#define FUNC8RC(m_r, m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7, m_arg8) \
virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6, m_arg7 p7, m_arg8 p8) const { \
- if (Thread::get_caller_ID() != server_thread) { \
+ if (Thread::get_caller_id() != server_thread) { \
m_r ret; \
command_queue.push_and_ret(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6, p7, p8, &ret); \
SYNC_DEBUG \
@@ -715,7 +715,7 @@
#define FUNC8S(m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7, m_arg8) \
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6, m_arg7 p7, m_arg8 p8) { \
- if (Thread::get_caller_ID() != server_thread) { \
+ if (Thread::get_caller_id() != server_thread) { \
command_queue.push_and_sync(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6, p7, p8); \
} else { \
server_name->m_type(p1, p2, p3, p4, p5, p6, p7, p8); \
@@ -724,7 +724,7 @@
#define FUNC8SC(m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7, m_arg8) \
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6, m_arg7 p7, m_arg8 p8) const { \
- if (Thread::get_caller_ID() != server_thread) { \
+ if (Thread::get_caller_id() != server_thread) { \
command_queue.push_and_sync(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6, p7, p8); \
} else { \
server_name->m_type(p1, p2, p3, p4, p5, p6, p7, p8); \
@@ -733,7 +733,7 @@
#define FUNC8(m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7, m_arg8) \
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6, m_arg7 p7, m_arg8 p8) { \
- if (Thread::get_caller_ID() != server_thread) { \
+ if (Thread::get_caller_id() != server_thread) { \
command_queue.push(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6, p7, p8); \
} else { \
server_name->m_type(p1, p2, p3, p4, p5, p6, p7, p8); \
@@ -742,7 +742,7 @@
#define FUNC8C(m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7, m_arg8) \
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6, m_arg7 p7, m_arg8 p8) const { \
- if (Thread::get_caller_ID() != server_thread) { \
+ if (Thread::get_caller_id() != server_thread) { \
command_queue.push(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6, p7, p8); \
} else { \
server_name->m_type(p1, p2, p3, p4, p5, p6, p7, p8); \
@@ -751,7 +751,7 @@
#define FUNC9(m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7, m_arg8, m_arg9) \
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6, m_arg7 p7, m_arg8 p8, m_arg9 p9) { \
- if (Thread::get_caller_ID() != server_thread) { \
+ if (Thread::get_caller_id() != server_thread) { \
command_queue.push(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6, p7, p8, p9); \
} else { \
server_name->m_type(p1, p2, p3, p4, p5, p6, p7, p8, p9); \
@@ -760,7 +760,7 @@
#define FUNC10(m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7, m_arg8, m_arg9, m_arg10) \
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6, m_arg7 p7, m_arg8 p8, m_arg9 p9, m_arg10 p10) { \
- if (Thread::get_caller_ID() != server_thread) { \
+ if (Thread::get_caller_id() != server_thread) { \
command_queue.push(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10); \
} else { \
server_name->m_type(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10); \
@@ -769,7 +769,7 @@
#define FUNC11(m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7, m_arg8, m_arg9, m_arg10, m_arg11) \
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6, m_arg7 p7, m_arg8 p8, m_arg9 p9, m_arg10 p10, m_arg11 p11) { \
- if (Thread::get_caller_ID() != server_thread) { \
+ if (Thread::get_caller_id() != server_thread) { \
command_queue.push(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11); \
} else { \
server_name->m_type(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11); \
diff --git a/servers/visual/rasterizer.h b/servers/visual/rasterizer.h
index 9c264ead49..9405f6e012 100644
--- a/servers/visual/rasterizer.h
+++ b/servers/visual/rasterizer.h
@@ -1014,6 +1014,8 @@ public:
virtual void reset_canvas() = 0;
+ virtual void draw_window_margins(int *p_margins, RID *p_margin_textures) = 0;
+
virtual ~RasterizerCanvas() {}
};
diff --git a/servers/visual/visual_server_raster.cpp b/servers/visual/visual_server_raster.cpp
index f17411f11a..cc4fe0809d 100644
--- a/servers/visual/visual_server_raster.cpp
+++ b/servers/visual/visual_server_raster.cpp
@@ -41,23 +41,29 @@
int VisualServerRaster::changes = 0;
-/* CURSOR */
-void VisualServerRaster::cursor_set_rotation(float p_rotation, int p_cursor) {
-}
-void VisualServerRaster::cursor_set_texture(RID p_texture, const Point2 &p_center_offset, int p_cursor, const Rect2 &p_region) {
-}
-void VisualServerRaster::cursor_set_visible(bool p_visible, int p_cursor) {
-}
-void VisualServerRaster::cursor_set_pos(const Point2 &p_pos, int p_cursor) {
-}
-
/* BLACK BARS */
void VisualServerRaster::black_bars_set_margins(int p_left, int p_top, int p_right, int p_bottom) {
+
+ black_margin[MARGIN_LEFT] = p_left;
+ black_margin[MARGIN_TOP] = p_top;
+ black_margin[MARGIN_RIGHT] = p_right;
+ black_margin[MARGIN_BOTTOM] = p_bottom;
}
+
void VisualServerRaster::black_bars_set_images(RID p_left, RID p_top, RID p_right, RID p_bottom) {
+
+ black_image[MARGIN_LEFT] = p_left;
+ black_image[MARGIN_TOP] = p_top;
+ black_image[MARGIN_RIGHT] = p_right;
+ black_image[MARGIN_BOTTOM] = p_bottom;
}
+void VisualServerRaster::_draw_margins() {
+
+ VSG::canvas_render->draw_window_margins(black_margin, black_image);
+};
+
/* FREE */
void VisualServerRaster::free(RID p_rid) {
@@ -78,7 +84,7 @@ void VisualServerRaster::request_frame_drawn_callback(Object *p_where, const Str
ERR_FAIL_NULL(p_where);
FrameDrawnCallbacks fdc;
- fdc.object = p_where->get_instance_ID();
+ fdc.object = p_where->get_instance_id();
fdc.method = p_method;
fdc.param = p_userdata;
@@ -121,6 +127,8 @@ void VisualServerRaster::draw() {
frame_drawn_callbacks.pop_front();
}
+
+ _draw_margins();
}
void VisualServerRaster::sync() {
}
@@ -189,6 +197,9 @@ VisualServerRaster::VisualServerRaster() {
VSG::storage = VSG::rasterizer->get_storage();
VSG::canvas_render = VSG::rasterizer->get_canvas();
VSG::scene_render = VSG::rasterizer->get_scene();
+
+ for (int i = 0; i < 4; i++)
+ black_margin[i] = 0;
}
VisualServerRaster::~VisualServerRaster() {
@@ -2626,14 +2637,14 @@ AABB VisualServerRaster::instance_get_base_aabb(RID p_instance) const {
}
-void VisualServerRaster::instance_attach_object_instance_ID(RID p_instance,uint32_t p_ID) {
+void VisualServerRaster::instance_attach_object_instance_id(RID p_instance,uint32_t p_ID) {
VS_CHANGED;
Instance *instance = instance_owner.get( p_instance );
ERR_FAIL_COND( !instance );
instance->object_ID=p_ID;
}
-uint32_t VisualServerRaster::instance_get_object_instance_ID(RID p_instance) const {
+uint32_t VisualServerRaster::instance_get_object_instance_id(RID p_instance) const {
Instance *instance = instance_owner.get( p_instance );
ERR_FAIL_COND_V( !instance, 0 );
diff --git a/servers/visual/visual_server_raster.h b/servers/visual/visual_server_raster.h
index b13bb904ab..596dd5c10e 100644
--- a/servers/visual/visual_server_raster.h
+++ b/servers/visual/visual_server_raster.h
@@ -61,6 +61,9 @@ class VisualServerRaster : public VisualServer {
bool draw_extra_frame;
RID test_cube;
+ int black_margin[4];
+ RID black_image[4];
+
struct FrameDrawnCallbacks {
ObjectID object;
@@ -584,6 +587,8 @@ class VisualServerRaster : public VisualServer {
#endif
+ void _draw_margins();
+
public:
_FORCE_INLINE_ static void redraw_request() { changes++; }
@@ -998,7 +1003,7 @@ public:
BIND2(instance_set_scenario, RID, RID) // from can be mesh, light, poly, area and portal so far.
BIND2(instance_set_layer_mask, RID, uint32_t)
BIND2(instance_set_transform, RID, const Transform &)
- BIND2(instance_attach_object_instance_ID, RID, ObjectID)
+ BIND2(instance_attach_object_instance_id, RID, ObjectID)
BIND3(instance_set_blend_shape_weight, RID, int, float)
BIND3(instance_set_surface_material, RID, int, RID)
BIND2(instance_set_visible, RID, bool)
@@ -1110,12 +1115,6 @@ public:
BIND2(canvas_occluder_polygon_set_cull_mode, RID, CanvasOccluderPolygonCullMode)
- /* CURSOR */
- virtual void cursor_set_rotation(float p_rotation, int p_cursor = 0); // radians
- virtual void cursor_set_texture(RID p_texture, const Point2 &p_center_offset = Point2(0, 0), int p_cursor = 0, const Rect2 &p_region = Rect2());
- virtual void cursor_set_visible(bool p_visible, int p_cursor = 0);
- virtual void cursor_set_pos(const Point2 &p_pos, int p_cursor = 0);
-
/* BLACK BARS */
virtual void black_bars_set_margins(int p_left, int p_top, int p_right, int p_bottom);
diff --git a/servers/visual/visual_server_scene.cpp b/servers/visual/visual_server_scene.cpp
index 87431a2ce4..56a596de55 100644
--- a/servers/visual/visual_server_scene.cpp
+++ b/servers/visual/visual_server_scene.cpp
@@ -797,7 +797,7 @@ void VisualServerScene::instance_set_transform(RID p_instance, const Transform &
instance->transform = p_transform;
_instance_queue_update(instance, true);
}
-void VisualServerScene::instance_attach_object_instance_ID(RID p_instance, ObjectID p_ID) {
+void VisualServerScene::instance_attach_object_instance_id(RID p_instance, ObjectID p_ID) {
Instance *instance = instance_owner.get(p_instance);
ERR_FAIL_COND(!instance);
diff --git a/servers/visual/visual_server_scene.h b/servers/visual/visual_server_scene.h
index 17b95946b3..a4895382a4 100644
--- a/servers/visual/visual_server_scene.h
+++ b/servers/visual/visual_server_scene.h
@@ -489,7 +489,7 @@ public:
virtual void instance_set_scenario(RID p_instance, RID p_scenario); // from can be mesh, light, poly, area and portal so far.
virtual void instance_set_layer_mask(RID p_instance, uint32_t p_mask);
virtual void instance_set_transform(RID p_instance, const Transform &p_transform);
- virtual void instance_attach_object_instance_ID(RID p_instance, ObjectID p_ID);
+ virtual void instance_attach_object_instance_id(RID p_instance, ObjectID p_ID);
virtual void instance_set_blend_shape_weight(RID p_instance, int p_shape, float p_weight);
virtual void instance_set_surface_material(RID p_instance, int p_surface, RID p_material);
virtual void instance_set_visible(RID p_instance, bool p_visible);
diff --git a/servers/visual/visual_server_wrap_mt.cpp b/servers/visual/visual_server_wrap_mt.cpp
index 525e3dc2f9..827f47a16e 100644
--- a/servers/visual/visual_server_wrap_mt.cpp
+++ b/servers/visual/visual_server_wrap_mt.cpp
@@ -68,7 +68,7 @@ void VisualServerWrapMT::_thread_callback(void *_instance) {
void VisualServerWrapMT::thread_loop() {
- server_thread = Thread::get_caller_ID();
+ server_thread = Thread::get_caller_id();
OS::get_singleton()->make_rendering_thread();
@@ -179,7 +179,7 @@ VisualServerWrapMT::VisualServerWrapMT(VisualServer *p_contained, bool p_create_
pool_max_size = GLOBAL_GET("memory/limits/multithreaded_server/rid_pool_prealloc");
if (!p_create_thread) {
- server_thread = Thread::get_caller_ID();
+ server_thread = Thread::get_caller_id();
} else {
server_thread = 0;
}
diff --git a/servers/visual/visual_server_wrap_mt.h b/servers/visual/visual_server_wrap_mt.h
index e6ce3f6a54..20223f9651 100644
--- a/servers/visual/visual_server_wrap_mt.h
+++ b/servers/visual/visual_server_wrap_mt.h
@@ -430,7 +430,7 @@ public:
FUNC2(instance_set_scenario, RID, RID) // from can be mesh, light, poly, area and portal so far.
FUNC2(instance_set_layer_mask, RID, uint32_t)
FUNC2(instance_set_transform, RID, const Transform &)
- FUNC2(instance_attach_object_instance_ID, RID, ObjectID)
+ FUNC2(instance_attach_object_instance_id, RID, ObjectID)
FUNC3(instance_set_blend_shape_weight, RID, int, float)
FUNC3(instance_set_surface_material, RID, int, RID)
FUNC2(instance_set_visible, RID, bool)
@@ -538,12 +538,6 @@ public:
FUNC2(canvas_occluder_polygon_set_cull_mode, RID, CanvasOccluderPolygonCullMode)
- /* CURSOR */
- FUNC2(cursor_set_rotation, float, int) // radians
- FUNC4(cursor_set_texture, RID, const Point2 &, int, const Rect2 &)
- FUNC2(cursor_set_visible, bool, int)
- FUNC2(cursor_set_pos, const Point2 &, int)
-
/* BLACK BARS */
FUNC4(black_bars_set_margins, int, int, int, int)
diff --git a/servers/visual_server.h b/servers/visual_server.h
index 5c9f4202f9..95a03c1836 100644
--- a/servers/visual_server.h
+++ b/servers/visual_server.h
@@ -727,7 +727,7 @@ public:
virtual void instance_set_scenario(RID p_instance, RID p_scenario) = 0; // from can be mesh, light, poly, area and portal so far.
virtual void instance_set_layer_mask(RID p_instance, uint32_t p_mask) = 0;
virtual void instance_set_transform(RID p_instance, const Transform &p_transform) = 0;
- virtual void instance_attach_object_instance_ID(RID p_instance, ObjectID p_ID) = 0;
+ virtual void instance_attach_object_instance_id(RID p_instance, ObjectID p_ID) = 0;
virtual void instance_set_blend_shape_weight(RID p_instance, int p_shape, float p_weight) = 0;
virtual void instance_set_surface_material(RID p_instance, int p_surface, RID p_material) = 0;
virtual void instance_set_visible(RID p_instance, bool p_visible) = 0;
@@ -875,12 +875,6 @@ public:
};
virtual void canvas_occluder_polygon_set_cull_mode(RID p_occluder_polygon, CanvasOccluderPolygonCullMode p_mode) = 0;
- /* CURSOR */
- virtual void cursor_set_rotation(float p_rotation, int p_cursor = 0) = 0; // radians
- virtual void cursor_set_texture(RID p_texture, const Point2 &p_center_offset = Point2(0, 0), int p_cursor = 0, const Rect2 &p_region = Rect2()) = 0;
- virtual void cursor_set_visible(bool p_visible, int p_cursor = 0) = 0;
- virtual void cursor_set_pos(const Point2 &p_pos, int p_cursor = 0) = 0;
-
/* BLACK BARS */
virtual void black_bars_set_margins(int p_left, int p_top, int p_right, int p_bottom) = 0;
diff --git a/thirdparty/misc/base64.h b/thirdparty/misc/base64.h
index 456ef1811b..4c300382c1 100644
--- a/thirdparty/misc/base64.h
+++ b/thirdparty/misc/base64.h
@@ -11,9 +11,8 @@
extern "C" {
-uint32_t base64_encode (char* to, char* from, uint32_t len);
-uint32_t base64_decode (char* to, char* from, uint32_t len);
-
+uint32_t base64_encode(char *to, char *from, uint32_t len);
+uint32_t base64_decode(char *to, char *from, uint32_t len);
};
#endif /* BASE64_H */