summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--DONORS.md2
-rw-r--r--core/array.cpp11
-rw-r--r--core/array.h2
-rw-r--r--core/io/file_access_pack.cpp4
-rw-r--r--core/io/resource_format_binary.cpp4
-rw-r--r--core/io/stream_peer.cpp3
-rw-r--r--core/list.h48
-rw-r--r--core/map.h3
-rw-r--r--core/math/camera_matrix.cpp84
-rw-r--r--core/math/camera_matrix.h1
-rw-r--r--core/math/matrix3.cpp15
-rw-r--r--core/math/matrix3.h2
-rw-r--r--core/math/transform.cpp12
-rw-r--r--core/object.h12
-rw-r--r--core/ordered_hash_map.h6
-rw-r--r--core/project_settings.cpp10
-rw-r--r--core/resource.cpp3
-rw-r--r--core/script_language.h1
-rw-r--r--core/set.h3
-rw-r--r--core/string_buffer.cpp102
-rw-r--r--core/string_buffer.h82
-rw-r--r--core/string_builder.cpp94
-rw-r--r--core/string_builder.h (renamed from scene/gui/button_group.h)61
-rw-r--r--core/type_info.h75
-rw-r--r--core/variant_call.cpp2
-rw-r--r--core/variant_parser.cpp22
-rw-r--r--doc/base/classes.xml1107
-rw-r--r--drivers/gles3/rasterizer_canvas_gles3.cpp4
-rw-r--r--drivers/gles3/rasterizer_scene_gles3.cpp83
-rw-r--r--drivers/gles3/rasterizer_scene_gles3.h7
-rw-r--r--drivers/gles3/rasterizer_storage_gles3.cpp99
-rw-r--r--drivers/gles3/rasterizer_storage_gles3.h6
-rw-r--r--drivers/gles3/shader_compiler_gles3.cpp47
-rw-r--r--drivers/gles3/shaders/canvas.glsl4
-rw-r--r--drivers/gles3/shaders/effect_blur.glsl13
-rw-r--r--drivers/gles3/shaders/scene.glsl41
-rw-r--r--drivers/gles3/shaders/screen_space_reflection.glsl6
-rw-r--r--drivers/gles3/shaders/ssao.glsl21
-rw-r--r--drivers/gles3/shaders/ssao_minify.glsl4
-rw-r--r--drivers/gles3/shaders/subsurf_scattering.glsl126
-rw-r--r--drivers/unix/dir_access_unix.cpp42
-rw-r--r--drivers/unix/file_access_unix.cpp93
-rw-r--r--drivers/windows/file_access_windows.cpp3
-rw-r--r--editor/SCsub60
-rw-r--r--editor/dependency_editor.cpp1
-rw-r--r--editor/editor_about.cpp88
-rw-r--r--editor/editor_about.h1
-rw-r--r--editor/editor_audio_buses.cpp23
-rw-r--r--editor/editor_audio_buses.h1
-rw-r--r--editor/editor_fonts.cpp13
-rw-r--r--editor/editor_help.cpp24
-rw-r--r--editor/editor_log.cpp3
-rw-r--r--editor/editor_node.cpp69
-rw-r--r--editor/editor_node.h3
-rw-r--r--editor/editor_settings.cpp1
-rw-r--r--editor/editor_themes.cpp43
-rw-r--r--editor/fileserver/editor_file_server.cpp2
-rw-r--r--editor/filesystem_dock.cpp2
-rw-r--r--editor/icons/icon_class_list.svg10
-rw-r--r--editor/icons/icon_file_dead.svg7
-rw-r--r--editor/icons/icon_filesystem.svg5
-rw-r--r--editor/icons/icon_key_call.svg5
-rw-r--r--editor/icons/icon_mini_checkerboard.svg4
-rw-r--r--editor/icons/icon_shader_material.svg11
-rw-r--r--editor/import/resource_importer_scene.cpp6
-rw-r--r--editor/import/resource_importer_texture.cpp9
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp107
-rw-r--r--editor/plugins/canvas_item_editor_plugin.h4
-rw-r--r--editor/plugins/collision_polygon_2d_editor_plugin.h1
-rw-r--r--editor/plugins/collision_polygon_editor_plugin.h1
-rw-r--r--editor/plugins/cube_grid_theme_editor_plugin.cpp7
-rw-r--r--editor/plugins/light_occluder_2d_editor_plugin.h1
-rw-r--r--editor/plugins/line_2d_editor_plugin.h1
-rw-r--r--editor/plugins/navigation_polygon_editor_plugin.h1
-rw-r--r--editor/plugins/path_2d_editor_plugin.h1
-rw-r--r--editor/plugins/polygon_2d_editor_plugin.cpp4
-rw-r--r--editor/plugins/polygon_2d_editor_plugin.h1
-rw-r--r--editor/plugins/script_editor_plugin.cpp27
-rw-r--r--editor/plugins/script_text_editor.cpp9
-rw-r--r--editor/plugins/shader_editor_plugin.cpp2
-rw-r--r--editor/plugins/spatial_editor_plugin.cpp319
-rw-r--r--editor/plugins/spatial_editor_plugin.h35
-rw-r--r--editor/plugins/sprite_frames_editor_plugin.cpp14
-rw-r--r--editor/plugins/theme_editor_plugin.h1
-rw-r--r--editor/project_manager.cpp46
-rw-r--r--editor/project_manager.h1
-rw-r--r--editor/project_settings_editor.cpp60
-rw-r--r--editor/project_settings_editor.h4
-rw-r--r--editor/quick_open.cpp52
-rw-r--r--editor/quick_open.h1
-rw-r--r--editor/scene_tree_dock.cpp54
-rw-r--r--editor/settings_config_dialog.cpp2
-rw-r--r--main/main.cpp4
-rw-r--r--misc/dist/html/default.html386
-rw-r--r--misc/dist/html_fs/godotfs.js151
-rw-r--r--modules/etc/image_etc.cpp3
-rw-r--r--modules/gdnative/SCsub12
-rw-r--r--modules/gdnative/gdnative.cpp6
-rw-r--r--modules/gdnative/gdnative.h7
-rw-r--r--modules/gdnative/gdnative/array.cpp (renamed from modules/gdnative/godot/array.cpp)2
-rw-r--r--modules/gdnative/gdnative/basis.cpp (renamed from modules/gdnative/godot/basis.cpp)2
-rw-r--r--modules/gdnative/gdnative/color.cpp (renamed from modules/gdnative/godot/color.cpp)2
-rw-r--r--modules/gdnative/gdnative/dictionary.cpp (renamed from modules/gdnative/godot/dictionary.cpp)2
-rw-r--r--modules/gdnative/gdnative/gdnative.cpp (renamed from modules/gdnative/godot/gdnative.cpp)3
-rw-r--r--modules/gdnative/gdnative/node_path.cpp (renamed from modules/gdnative/godot/node_path.cpp)2
-rw-r--r--modules/gdnative/gdnative/plane.cpp (renamed from modules/gdnative/godot/plane.cpp)2
-rw-r--r--modules/gdnative/gdnative/pool_arrays.cpp (renamed from modules/gdnative/godot/pool_arrays.cpp)2
-rw-r--r--modules/gdnative/gdnative/quat.cpp (renamed from modules/gdnative/godot/quat.cpp)2
-rw-r--r--modules/gdnative/gdnative/rect2.cpp (renamed from modules/gdnative/godot/rect2.cpp)2
-rw-r--r--modules/gdnative/gdnative/rect3.cpp (renamed from modules/gdnative/godot/rect3.cpp)2
-rw-r--r--modules/gdnative/gdnative/rid.cpp (renamed from modules/gdnative/godot/rid.cpp)2
-rw-r--r--modules/gdnative/gdnative/string.cpp (renamed from modules/gdnative/godot/string.cpp)2
-rw-r--r--modules/gdnative/gdnative/transform.cpp (renamed from modules/gdnative/godot/transform.cpp)2
-rw-r--r--modules/gdnative/gdnative/transform2d.cpp (renamed from modules/gdnative/godot/transform2d.cpp)2
-rw-r--r--modules/gdnative/gdnative/variant.cpp (renamed from modules/gdnative/godot/variant.cpp)2
-rw-r--r--modules/gdnative/gdnative/vector2.cpp (renamed from modules/gdnative/godot/vector2.cpp)2
-rw-r--r--modules/gdnative/gdnative/vector3.cpp (renamed from modules/gdnative/godot/vector3.cpp)2
-rw-r--r--modules/gdnative/godot/icon.png.import23
-rw-r--r--modules/gdnative/include/gdnative/array.h (renamed from modules/gdnative/godot/array.h)6
-rw-r--r--modules/gdnative/include/gdnative/basis.h (renamed from modules/gdnative/godot/basis.h)6
-rw-r--r--modules/gdnative/include/gdnative/color.h (renamed from modules/gdnative/godot/color.h)4
-rw-r--r--modules/gdnative/include/gdnative/dictionary.h (renamed from modules/gdnative/godot/dictionary.h)6
-rw-r--r--modules/gdnative/include/gdnative/gdnative.h (renamed from modules/gdnative/godot/gdnative.h)60
-rw-r--r--modules/gdnative/include/gdnative/node_path.h (renamed from modules/gdnative/godot/node_path.h)4
-rw-r--r--modules/gdnative/include/gdnative/plane.h (renamed from modules/gdnative/godot/plane.h)4
-rw-r--r--modules/gdnative/include/gdnative/pool_arrays.h (renamed from modules/gdnative/godot/pool_arrays.h)10
-rw-r--r--modules/gdnative/include/gdnative/quat.h (renamed from modules/gdnative/godot/quat.h)4
-rw-r--r--modules/gdnative/include/gdnative/rect2.h (renamed from modules/gdnative/godot/rect2.h)4
-rw-r--r--modules/gdnative/include/gdnative/rect3.h (renamed from modules/gdnative/godot/rect3.h)6
-rw-r--r--modules/gdnative/include/gdnative/rid.h (renamed from modules/gdnative/godot/rid.h)2
-rw-r--r--modules/gdnative/include/gdnative/string.h (renamed from modules/gdnative/godot/string.h)4
-rw-r--r--modules/gdnative/include/gdnative/transform.h (renamed from modules/gdnative/godot/transform.h)8
-rw-r--r--modules/gdnative/include/gdnative/transform2d.h (renamed from modules/gdnative/godot/transform2d.h)6
-rw-r--r--modules/gdnative/include/gdnative/variant.h (renamed from modules/gdnative/godot/variant.h)38
-rw-r--r--modules/gdnative/include/gdnative/vector2.h (renamed from modules/gdnative/godot/vector2.h)2
-rw-r--r--modules/gdnative/include/gdnative/vector3.h (renamed from modules/gdnative/godot/vector3.h)4
-rw-r--r--modules/gdnative/include/nativescript/godot_nativescript.h (renamed from modules/nativescript/godot_nativescript.h)2
-rw-r--r--modules/gdnative/nativescript/SCsub (renamed from modules/nativescript/SCsub)0
-rw-r--r--modules/gdnative/nativescript/api_generator.cpp (renamed from modules/nativescript/api_generator.cpp)0
-rw-r--r--modules/gdnative/nativescript/api_generator.h (renamed from modules/nativescript/api_generator.h)0
-rw-r--r--modules/gdnative/nativescript/godot_nativescript.cpp (renamed from modules/nativescript/godot_nativescript.cpp)8
-rw-r--r--modules/gdnative/nativescript/nativescript.cpp (renamed from modules/nativescript/nativescript.cpp)59
-rw-r--r--modules/gdnative/nativescript/nativescript.h (renamed from modules/nativescript/nativescript.h)5
-rw-r--r--modules/gdnative/nativescript/register_types.cpp (renamed from modules/nativescript/register_types.cpp)0
-rw-r--r--modules/gdnative/nativescript/register_types.h (renamed from modules/nativescript/register_types.h)0
-rw-r--r--modules/gdnative/register_types.cpp176
-rw-r--r--modules/gdscript/gd_editor.cpp6
-rw-r--r--modules/gdscript/gd_functions.cpp14
-rw-r--r--modules/gdscript/gd_script.h1
-rw-r--r--modules/gridmap/grid_map.cpp22
-rw-r--r--modules/gridmap/grid_map.h1
-rw-r--r--modules/nativescript/config.py8
-rw-r--r--modules/stb_vorbis/audio_stream_ogg_vorbis.cpp6
-rw-r--r--modules/theora/video_stream_theora.cpp3
-rw-r--r--modules/visual_script/visual_script.h1
-rw-r--r--modules/visual_script/visual_script_editor.cpp2
-rw-r--r--platform/javascript/SCsub33
-rw-r--r--platform/javascript/detect.py2
-rw-r--r--platform/javascript/engine.js366
-rw-r--r--platform/javascript/export/export.cpp30
-rw-r--r--platform/javascript/godot_shell.html347
-rw-r--r--platform/javascript/pre_asmjs.js3
-rw-r--r--platform/javascript/pre_wasm.js3
-rw-r--r--platform/windows/context_gl_win.cpp16
-rw-r--r--platform/windows/joypad.cpp4
-rw-r--r--platform/windows/os_windows.cpp11
-rw-r--r--scene/2d/area_2d.cpp8
-rw-r--r--scene/2d/audio_stream_player_2d.cpp11
-rw-r--r--scene/2d/canvas_item.cpp1
-rw-r--r--scene/2d/line_builder.cpp55
-rw-r--r--scene/2d/path_2d.cpp3
-rw-r--r--scene/3d/arvr_nodes.cpp15
-rw-r--r--scene/3d/arvr_nodes.h2
-rw-r--r--scene/3d/audio_stream_player_3d.cpp8
-rw-r--r--scene/3d/bone_attachment.cpp6
-rw-r--r--scene/3d/collision_shape.cpp3
-rw-r--r--scene/3d/gi_probe.cpp34
-rw-r--r--scene/3d/interpolated_camera.cpp4
-rw-r--r--scene/3d/light.cpp20
-rw-r--r--scene/3d/light.h10
-rw-r--r--scene/3d/path.cpp4
-rw-r--r--scene/3d/physics_body.cpp228
-rw-r--r--scene/3d/physics_body.h52
-rw-r--r--scene/audio/audio_player.cpp2
-rw-r--r--scene/gui/base_button.cpp10
-rw-r--r--scene/gui/button_group.cpp168
-rw-r--r--scene/gui/check_box.cpp1
-rw-r--r--scene/gui/control.cpp4
-rw-r--r--scene/gui/file_dialog.cpp4
-rw-r--r--scene/gui/graph_node.cpp20
-rw-r--r--scene/gui/graph_node.h6
-rw-r--r--scene/gui/item_list.cpp16
-rw-r--r--scene/gui/item_list.h4
-rw-r--r--scene/gui/line_edit.cpp2
-rw-r--r--scene/gui/rich_text_label.cpp29
-rw-r--r--scene/gui/rich_text_label.h2
-rw-r--r--scene/gui/text_edit.cpp21
-rw-r--r--scene/gui/tree.cpp8
-rwxr-xr-xscene/main/node.cpp21
-rw-r--r--scene/main/viewport.cpp16
-rw-r--r--scene/main/viewport.h6
-rw-r--r--scene/register_scene_types.cpp2
-rw-r--r--scene/resources/curve.cpp25
-rw-r--r--scene/resources/default_theme/default_theme.cpp1
-rw-r--r--scene/resources/environment.cpp7
-rw-r--r--scene/resources/environment.h1
-rw-r--r--scene/resources/material.cpp13
-rw-r--r--scene/resources/material.h6
-rw-r--r--scene/resources/mesh.cpp4
-rw-r--r--scene/resources/mesh.h3
-rw-r--r--scene/resources/mesh_library.cpp4
-rw-r--r--scene/resources/mesh_library.h2
-rw-r--r--scene/resources/packed_scene.cpp8
-rw-r--r--scene/resources/primitive_meshes.cpp19
-rw-r--r--scene/resources/primitive_meshes.h3
-rw-r--r--servers/arvr/arvr_positional_tracker.cpp14
-rw-r--r--servers/arvr/arvr_positional_tracker.h12
-rw-r--r--servers/arvr_server.cpp8
-rw-r--r--servers/audio_server.cpp3
-rw-r--r--servers/physics/broad_phase_basic.cpp3
-rw-r--r--servers/physics/collision_object_sw.cpp32
-rw-r--r--servers/physics/collision_object_sw.h2
-rw-r--r--servers/physics/physics_server_sw.cpp21
-rw-r--r--servers/physics/physics_server_sw.h4
-rw-r--r--servers/visual/rasterizer.h2
-rw-r--r--servers/visual/shader_language.cpp136
-rw-r--r--servers/visual/shader_language.h22
-rw-r--r--servers/visual/visual_server_raster.h1
-rw-r--r--servers/visual/visual_server_scene.cpp83
-rw-r--r--servers/visual/visual_server_wrap_mt.h1
-rw-r--r--servers/visual_server.cpp23
-rw-r--r--servers/visual_server.h10
232 files changed, 4622 insertions, 2110 deletions
diff --git a/DONORS.md b/DONORS.md
index 09049ede48..57902fb2fc 100644
--- a/DONORS.md
+++ b/DONORS.md
@@ -21,7 +21,7 @@ None so far, but your company could be the first! :)
## Mini sponsors
Arron Washington
- Chrisartguy
+ Chris Phyffer
Christian Uldall Pedersen
Hein-Pieter van Braam
Matthieu Huvé
diff --git a/core/array.cpp b/core/array.cpp
index c35bf5bf0c..2e3fbf858d 100644
--- a/core/array.cpp
+++ b/core/array.cpp
@@ -210,6 +210,17 @@ const Variant &Array::get(int p_idx) const {
return operator[](p_idx);
}
+Array Array::duplicate() const {
+
+ Array new_arr;
+ int element_count = size();
+ new_arr.resize(element_count);
+ for (int i = 0; i < element_count; i++) {
+ new_arr[i] = get(i);
+ }
+
+ return new_arr;
+}
struct _ArrayVariantSort {
_FORCE_INLINE_ bool operator()(const Variant &p_l, const Variant &p_r) const {
diff --git a/core/array.h b/core/array.h
index 777116ab56..8a647dd13b 100644
--- a/core/array.h
+++ b/core/array.h
@@ -84,6 +84,8 @@ public:
Variant pop_back();
Variant pop_front();
+ Array duplicate() const;
+
Array(const Array &p_from);
Array();
~Array();
diff --git a/core/io/file_access_pack.cpp b/core/io/file_access_pack.cpp
index e36ff28220..e511085ac5 100644
--- a/core/io/file_access_pack.cpp
+++ b/core/io/file_access_pack.cpp
@@ -166,9 +166,9 @@ bool PackedSourcePCK::try_open_pack(const String &p_path) {
uint32_t ver_rev = f->get_32();
ERR_EXPLAIN("Pack version unsupported: " + itos(version));
- ERR_FAIL_COND_V(version != PACK_VERSION, ERR_INVALID_DATA);
+ ERR_FAIL_COND_V(version != PACK_VERSION, false);
ERR_EXPLAIN("Pack created with a newer version of the engine: " + itos(ver_major) + "." + itos(ver_minor) + "." + itos(ver_rev));
- ERR_FAIL_COND_V(ver_major > VERSION_MAJOR || (ver_major == VERSION_MAJOR && ver_minor > VERSION_MINOR), ERR_INVALID_DATA);
+ ERR_FAIL_COND_V(ver_major > VERSION_MAJOR || (ver_major == VERSION_MAJOR && ver_minor > VERSION_MINOR), false);
for (int i = 0; i < 16; i++) {
//reserved
diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp
index 084d8ffcab..661eba2106 100644
--- a/core/io/resource_format_binary.cpp
+++ b/core/io/resource_format_binary.cpp
@@ -1814,11 +1814,11 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p
if (skip_editor && F->get().name.begins_with("__editor"))
continue;
- if (F->get().usage & PROPERTY_USAGE_STORAGE) {
+ if ((F->get().usage & PROPERTY_USAGE_STORAGE)) {
Property p;
p.name_idx = get_string_index(F->get().name);
p.value = E->get()->get(F->get().name);
- if ((F->get().usage & PROPERTY_USAGE_STORE_IF_NONZERO && p.value.is_zero()) || (F->get().usage & PROPERTY_USAGE_STORE_IF_NONONE && p.value.is_one()))
+ if (((F->get().usage & PROPERTY_USAGE_STORE_IF_NONZERO) && p.value.is_zero()) || ((F->get().usage & PROPERTY_USAGE_STORE_IF_NONONE) && p.value.is_one()))
continue;
p.pi = F->get();
diff --git a/core/io/stream_peer.cpp b/core/io/stream_peer.cpp
index 1006158003..f4f81f0807 100644
--- a/core/io/stream_peer.cpp
+++ b/core/io/stream_peer.cpp
@@ -446,6 +446,7 @@ Error StreamPeerBuffer::get_data(uint8_t *p_buffer, int p_bytes) {
return OK;
}
+
Error StreamPeerBuffer::get_partial_data(uint8_t *p_buffer, int p_bytes, int &r_received) {
if (pointer + p_bytes > data.size()) {
@@ -463,6 +464,8 @@ Error StreamPeerBuffer::get_partial_data(uint8_t *p_buffer, int p_bytes, int &r_
pointer += r_received;
// FIXME: return what? OK or ERR_*
+ // return OK for now so we don't maybe return garbage
+ return OK;
}
int StreamPeerBuffer::get_available_bytes() const {
diff --git a/core/list.h b/core/list.h
index a67287a9ab..da201e9868 100644
--- a/core/list.h
+++ b/core/list.h
@@ -291,6 +291,54 @@ public:
erase(_data->first);
}
+ Element *insert_after(Element *p_element, const T &p_value) {
+ CRASH_COND(p_element && (!_data || p_element->data != _data));
+
+ if (!p_element) {
+ return push_back(p_value);
+ }
+
+ Element *n = memnew_allocator(Element, A);
+ n->value = (T &)p_value;
+ n->prev_ptr = p_element;
+ n->next_ptr = p_element->next_ptr;
+ n->data = _data;
+
+ if (!p_element->next_ptr) {
+ _data->last = n;
+ }
+
+ p_element->next_ptr = n;
+
+ _data->size_cache++;
+
+ return n;
+ }
+
+ Element *insert_before(Element *p_element, const T &p_value) {
+ CRASH_COND(p_element && (!_data || p_element->data != _data));
+
+ if (!p_element) {
+ return push_back(p_value);
+ }
+
+ Element *n = memnew_allocator(Element, A);
+ n->value = (T &)p_value;
+ n->prev_ptr = p_element->prev_ptr;
+ n->next_ptr = p_element;
+ n->data = _data;
+
+ if (!p_element->prev_ptr) {
+ _data->first = n;
+ }
+
+ p_element->prev_ptr = n;
+
+ _data->size_cache++;
+
+ return n;
+ }
+
/**
* find an element in the list,
*/
diff --git a/core/map.h b/core/map.h
index 75a38a3440..a37d898a9c 100644
--- a/core/map.h
+++ b/core/map.h
@@ -453,8 +453,9 @@ private:
if (!rp)
rp = _data._nil;
Element *node = (rp->left == _data._nil) ? rp->right : rp->left;
+ node->parent = rp->parent;
- if (_data._root == (node->parent = rp->parent)) {
+ if (_data._root == node->parent) {
_data._root->left = node;
} else {
if (rp == rp->parent->left) {
diff --git a/core/math/camera_matrix.cpp b/core/math/camera_matrix.cpp
index 0512cdd798..b7a929c8e0 100644
--- a/core/math/camera_matrix.cpp
+++ b/core/math/camera_matrix.cpp
@@ -265,75 +265,26 @@ void CameraMatrix::get_viewport_size(real_t &r_width, real_t &r_height) const {
bool CameraMatrix::get_endpoints(const Transform &p_transform, Vector3 *p_8points) const {
- const real_t *matrix = (const real_t *)this->matrix;
-
- ///////--- Near Plane ---///////
- Plane near_plane = Plane(matrix[3] + matrix[2],
- matrix[7] + matrix[6],
- matrix[11] + matrix[10],
- -matrix[15] - matrix[14]);
- near_plane.normalize();
-
- ///////--- Far Plane ---///////
- Plane far_plane = Plane(matrix[2] - matrix[3],
- matrix[6] - matrix[7],
- matrix[10] - matrix[11],
- matrix[15] - matrix[14]);
- far_plane.normalize();
-
- ///////--- Right Plane ---///////
- Plane right_plane = Plane(matrix[0] - matrix[3],
- matrix[4] - matrix[7],
- matrix[8] - matrix[11],
- -matrix[15] + matrix[12]);
- right_plane.normalize();
-
- ///////--- Top Plane ---///////
- Plane top_plane = Plane(matrix[1] - matrix[3],
- matrix[5] - matrix[7],
- matrix[9] - matrix[11],
- -matrix[15] + matrix[13]);
- top_plane.normalize();
-
- Vector3 near_endpoint_left, near_endpoint_right;
- Vector3 far_endpoint_left, far_endpoint_right;
-
- bool res = near_plane.intersect_3(right_plane, top_plane, &near_endpoint_right);
- ERR_FAIL_COND_V(!res, false);
-
- res = far_plane.intersect_3(right_plane, top_plane, &far_endpoint_right);
- ERR_FAIL_COND_V(!res, false);
-
- if ((matrix[8] == 0) && (matrix[9] == 0)) {
- near_endpoint_left = near_endpoint_right;
- near_endpoint_left.x = -near_endpoint_left.x;
-
- far_endpoint_left = far_endpoint_right;
- far_endpoint_left.x = -far_endpoint_left.x;
- } else {
- ///////--- Left Plane ---///////
- Plane left_plane = Plane(matrix[0] + matrix[3],
- matrix[4] + matrix[7],
- matrix[8] + matrix[11],
- -matrix[15] - matrix[12]);
- left_plane.normalize();
+ Vector<Plane> planes = get_projection_planes(Transform());
+ const Planes intersections[8][3] = {
+ { PLANE_FAR, PLANE_LEFT, PLANE_TOP },
+ { PLANE_FAR, PLANE_LEFT, PLANE_BOTTOM },
+ { PLANE_FAR, PLANE_RIGHT, PLANE_TOP },
+ { PLANE_FAR, PLANE_RIGHT, PLANE_BOTTOM },
+ { PLANE_NEAR, PLANE_LEFT, PLANE_TOP },
+ { PLANE_NEAR, PLANE_LEFT, PLANE_BOTTOM },
+ { PLANE_NEAR, PLANE_RIGHT, PLANE_TOP },
+ { PLANE_NEAR, PLANE_RIGHT, PLANE_BOTTOM },
+ };
- res = near_plane.intersect_3(left_plane, top_plane, &near_endpoint_left);
- ERR_FAIL_COND_V(!res, false);
+ for (int i = 0; i < 8; i++) {
- res = far_plane.intersect_3(left_plane, top_plane, &far_endpoint_left);
+ Vector3 point;
+ bool res = planes[intersections[i][0]].intersect_3(planes[intersections[i][1]], planes[intersections[i][2]], &point);
ERR_FAIL_COND_V(!res, false);
+ p_8points[i] = p_transform.xform(point);
}
- p_8points[0] = p_transform.xform(Vector3(near_endpoint_right.x, near_endpoint_right.y, near_endpoint_right.z));
- p_8points[1] = p_transform.xform(Vector3(near_endpoint_right.x, -near_endpoint_right.y, near_endpoint_right.z));
- p_8points[2] = p_transform.xform(Vector3(near_endpoint_left.x, near_endpoint_left.y, near_endpoint_left.z));
- p_8points[3] = p_transform.xform(Vector3(near_endpoint_left.x, -near_endpoint_left.y, near_endpoint_left.z));
- p_8points[4] = p_transform.xform(Vector3(far_endpoint_right.x, far_endpoint_right.y, far_endpoint_right.z));
- p_8points[5] = p_transform.xform(Vector3(far_endpoint_right.x, -far_endpoint_right.y, far_endpoint_right.z));
- p_8points[6] = p_transform.xform(Vector3(far_endpoint_left.x, far_endpoint_left.y, far_endpoint_left.z));
- p_8points[7] = p_transform.xform(Vector3(far_endpoint_left.x, -far_endpoint_left.y, far_endpoint_left.z));
-
return true;
}
@@ -610,6 +561,11 @@ int CameraMatrix::get_pixels_per_meter(int p_for_pixel_width) const {
return int((result.x * 0.5 + 0.5) * p_for_pixel_width);
}
+bool CameraMatrix::is_orthogonal() const {
+
+ return matrix[3][3] == 1.0;
+}
+
real_t CameraMatrix::get_fov() const {
const real_t *matrix = (const real_t *)this->matrix;
diff --git a/core/math/camera_matrix.h b/core/math/camera_matrix.h
index 175d0cdb1b..3145d73356 100644
--- a/core/math/camera_matrix.h
+++ b/core/math/camera_matrix.h
@@ -69,6 +69,7 @@ struct CameraMatrix {
real_t get_z_near() const;
real_t get_aspect() const;
real_t get_fov() const;
+ bool is_orthogonal() const;
Vector<Plane> get_projection_planes(const Transform &p_transform) const;
diff --git a/core/math/matrix3.cpp b/core/math/matrix3.cpp
index 9732a1ff37..4051de7afb 100644
--- a/core/math/matrix3.cpp
+++ b/core/math/matrix3.cpp
@@ -234,7 +234,22 @@ Basis Basis::scaled(const Vector3 &p_scale) const {
return m;
}
+void Basis::set_scale(const Vector3 &p_scale) {
+
+ set_axis(0, get_axis(0).normalized() * p_scale.x);
+ set_axis(1, get_axis(1).normalized() * p_scale.y);
+ set_axis(2, get_axis(2).normalized() * p_scale.z);
+}
+
Vector3 Basis::get_scale() const {
+
+ return Vector3(
+ Vector3(elements[0][0], elements[1][0], elements[2][0]).length(),
+ Vector3(elements[0][1], elements[1][1], elements[2][1]).length(),
+ Vector3(elements[0][2], elements[1][2], elements[2][2]).length());
+}
+
+Vector3 Basis::get_signed_scale() const {
// FIXME: We are assuming M = R.S (R is rotation and S is scaling), and use polar decomposition to extract R and S.
// A polar decomposition is M = O.P, where O is an orthogonal matrix (meaning rotation and reflection) and
// P is a positive semi-definite matrix (meaning it contains absolute values of scaling along its diagonal).
diff --git a/core/math/matrix3.h b/core/math/matrix3.h
index 9c9080ac46..23429888e0 100644
--- a/core/math/matrix3.h
+++ b/core/math/matrix3.h
@@ -97,7 +97,9 @@ public:
void scale(const Vector3 &p_scale);
Basis scaled(const Vector3 &p_scale) const;
+ void set_scale(const Vector3 &p_scale);
Vector3 get_scale() const;
+ Vector3 get_signed_scale() const;
// transposed dot products
_FORCE_INLINE_ real_t tdotx(const Vector3 &v) const {
diff --git a/core/math/transform.cpp b/core/math/transform.cpp
index 60df69a509..638a39ab73 100644
--- a/core/math/transform.cpp
+++ b/core/math/transform.cpp
@@ -118,17 +118,17 @@ Transform Transform::interpolate_with(const Transform &p_transform, real_t p_c)
/* not sure if very "efficient" but good enough? */
- Vector3 src_scale = basis.get_scale();
- Quat src_rot = basis;
+ Vector3 src_scale = basis.get_signed_scale();
+ Quat src_rot = basis.orthonormalized();
Vector3 src_loc = origin;
- Vector3 dst_scale = p_transform.basis.get_scale();
+ Vector3 dst_scale = p_transform.basis.get_signed_scale();
Quat dst_rot = p_transform.basis;
Vector3 dst_loc = p_transform.origin;
- Transform dst;
- dst.basis = src_rot.slerp(dst_rot, p_c);
- dst.basis.scale(src_scale.linear_interpolate(dst_scale, p_c));
+ Transform dst; //this could be made faster by using a single function in Basis..
+ dst.basis = src_rot.slerp(dst_rot, p_c).normalized();
+ dst.basis.set_scale(src_scale.linear_interpolate(dst_scale, p_c));
dst.origin = src_loc.linear_interpolate(dst_loc, p_c);
return dst;
diff --git a/core/object.h b/core/object.h
index 6e1ed4308e..644e2b8270 100644
--- a/core/object.h
+++ b/core/object.h
@@ -567,12 +567,6 @@ public:
template <class T>
static T *cast_to(Object *p_object) {
-#ifdef DEBUG_ENABLED
- // TODO there are some legitimate reasons to pass NULL as p_object.
- // we need to figure out how to deal with that in debug mode.
- // This code will return NULL for a NULL input in release mode also.
- ERR_FAIL_COND_V(p_object == NULL, NULL);
-#endif
#ifndef NO_SAFE_CAST
return dynamic_cast<T *>(p_object);
#else
@@ -587,12 +581,6 @@ public:
template <class T>
static const T *cast_to(const Object *p_object) {
-#ifdef DEBUG_ENABLED
- // TODO there are some legitimate reasons to pass NULL as p_object.
- // we need to figure out how to deal with that in debug mode.
- // This code will return NULL for a NULL input in release mode also.
- ERR_FAIL_COND_V(p_object == NULL, NULL);
-#endif
#ifndef NO_SAFE_CAST
return dynamic_cast<const T *>(p_object);
#else
diff --git a/core/ordered_hash_map.h b/core/ordered_hash_map.h
index 3e619d2b2e..9e95f963e1 100644
--- a/core/ordered_hash_map.h
+++ b/core/ordered_hash_map.h
@@ -55,8 +55,8 @@ public:
friend class OrderedHashMap<K, V, Hasher, Comparator, MIN_HASH_TABLE_POWER, RELATIONSHIP>;
typename InternalList::Element *list_element;
- typename InternalList::Element *next_element;
typename InternalList::Element *prev_element;
+ typename InternalList::Element *next_element;
Element(typename InternalList::Element *p_element) {
list_element = p_element;
@@ -69,7 +69,7 @@ public:
public:
_FORCE_INLINE_ Element()
- : list_element(NULL), next_element(NULL), prev_element(NULL) {
+ : list_element(NULL), prev_element(NULL), next_element(NULL) {
}
Element next() const {
@@ -312,4 +312,4 @@ bool operator!=(const typename OrderedHashMap<K, V, Hasher, Comparator, MIN_HASH
return (first.list_element != second.list_element);
}
-#endif // ORDERED_HASH_MAP_H \ No newline at end of file
+#endif // ORDERED_HASH_MAP_H
diff --git a/core/project_settings.cpp b/core/project_settings.cpp
index a74917162b..23e4961138 100644
--- a/core/project_settings.cpp
+++ b/core/project_settings.cpp
@@ -114,7 +114,15 @@ String ProjectSettings::globalize_path(const String &p_path) const {
return p_path.replace("res:/", resource_path);
};
return p_path.replace("res://", "");
- };
+ } else if (p_path.begins_with("user://")) {
+
+ String data_dir = OS::get_singleton()->get_data_dir();
+ if (data_dir != "") {
+
+ return p_path.replace("user:/", data_dir);
+ };
+ return p_path.replace("user://", "");
+ }
return p_path;
}
diff --git a/core/resource.cpp b/core/resource.cpp
index 37d42226b4..78e20bada4 100644
--- a/core/resource.cpp
+++ b/core/resource.cpp
@@ -69,12 +69,11 @@ void Resource::set_path(const String &p_path, bool p_take_over) {
ResourceCache::resources.get(p_path)->set_name("");
ResourceCache::lock->write_unlock();
} else {
- ERR_EXPLAIN("Another resource is loaded from path: " + p_path);
-
ResourceCache::lock->read_lock();
bool exists = ResourceCache::resources.has(p_path);
ResourceCache::lock->read_unlock();
+ ERR_EXPLAIN("Another resource is loaded from path: " + p_path);
ERR_FAIL_COND(exists);
}
}
diff --git a/core/script_language.h b/core/script_language.h
index 342d8c8072..2261737f9a 100644
--- a/core/script_language.h
+++ b/core/script_language.h
@@ -206,6 +206,7 @@ public:
virtual int find_function(const String &p_function, const String &p_code) const = 0;
virtual String make_function(const String &p_class, const String &p_name, const PoolStringArray &p_args) const = 0;
virtual Error open_in_external_editor(const Ref<Script> &p_script, int p_line, int p_col) { return ERR_UNAVAILABLE; }
+ virtual bool overrides_external_editor() { return false; }
virtual Error complete_code(const String &p_code, const String &p_base_path, Object *p_owner, List<String> *r_options, bool &r_force, String &r_call_hint) { return ERR_UNAVAILABLE; }
diff --git a/core/set.h b/core/set.h
index 317e180869..f68d78cea1 100644
--- a/core/set.h
+++ b/core/set.h
@@ -438,8 +438,9 @@ private:
if (!rp)
rp = _data._nil;
Element *node = (rp->left == _data._nil) ? rp->right : rp->left;
+ node->parent = rp->parent;
- if (_data._root == (node->parent = rp->parent)) {
+ if (_data._root == node->parent) {
_data._root->left = node;
} else {
if (rp == rp->parent->left) {
diff --git a/core/string_buffer.cpp b/core/string_buffer.cpp
new file mode 100644
index 0000000000..195068f887
--- /dev/null
+++ b/core/string_buffer.cpp
@@ -0,0 +1,102 @@
+/*************************************************************************/
+/* string_buffer.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+#include "string_buffer.h"
+
+#include <string.h>
+
+StringBuffer &StringBuffer::append(CharType p_char) {
+ reserve(string_length + 2);
+ current_buffer_ptr()[string_length++] = p_char;
+ return *this;
+}
+
+StringBuffer &StringBuffer::append(const String &p_string) {
+ return append(p_string.c_str());
+}
+
+StringBuffer &StringBuffer::append(const char *p_str) {
+ int len = strlen(p_str);
+ reserve(string_length + len + 1);
+
+ CharType *buf = current_buffer_ptr();
+ for (const char *c_ptr = p_str; c_ptr; ++c_ptr) {
+ buf[string_length++] = *c_ptr;
+ }
+ return *this;
+}
+
+StringBuffer &StringBuffer::append(const CharType *p_str, int p_clip_to_len) {
+ int len = 0;
+ while ((p_clip_to_len < 0 || len < p_clip_to_len) && p_str[len]) {
+ ++len;
+ }
+ reserve(string_length + len + 1);
+ memcpy(&(current_buffer_ptr()[string_length]), p_str, len * sizeof(CharType));
+ string_length += len;
+
+ return *this;
+}
+
+StringBuffer &StringBuffer::reserve(int p_size) {
+ if (p_size < SHORT_BUFFER_SIZE || p_size < buffer.size())
+ return *this;
+
+ bool need_copy = string_length > 0 && buffer.empty();
+ buffer.resize(next_power_of_2(p_size));
+ if (need_copy) {
+ memcpy(buffer.ptr(), short_buffer, string_length * sizeof(CharType));
+ }
+
+ return *this;
+}
+
+int StringBuffer::length() const {
+ return string_length;
+}
+
+String StringBuffer::as_string() {
+ current_buffer_ptr()[string_length] = '\0';
+ if (buffer.empty()) {
+ return String(short_buffer);
+ } else {
+ buffer.resize(string_length + 1);
+ return buffer;
+ }
+}
+
+double StringBuffer::as_double() {
+ current_buffer_ptr()[string_length] = '\0';
+ return String::to_double(current_buffer_ptr());
+}
+
+int64_t StringBuffer::as_int() {
+ current_buffer_ptr()[string_length] = '\0';
+ return String::to_int(current_buffer_ptr());
+}
diff --git a/core/string_buffer.h b/core/string_buffer.h
new file mode 100644
index 0000000000..3f36249148
--- /dev/null
+++ b/core/string_buffer.h
@@ -0,0 +1,82 @@
+/*************************************************************************/
+/* string_buffer.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+#ifndef STRING_BUFFER_H
+#define STRING_BUFFER_H
+
+#include "ustring.h"
+
+class StringBuffer {
+ static const int SHORT_BUFFER_SIZE = 64;
+
+ CharType short_buffer[SHORT_BUFFER_SIZE];
+ String buffer;
+ int string_length = 0;
+
+ _FORCE_INLINE_ CharType *current_buffer_ptr() {
+ return static_cast<Vector<CharType> &>(buffer).empty() ? short_buffer : buffer.ptr();
+ }
+
+public:
+ StringBuffer &append(CharType p_char);
+ StringBuffer &append(const String &p_string);
+ StringBuffer &append(const char *p_str);
+ StringBuffer &append(const CharType *p_str, int p_clip_to_len = -1);
+
+ _FORCE_INLINE_ void operator+=(CharType p_char) {
+ append(p_char);
+ }
+
+ _FORCE_INLINE_ void operator+=(const String &p_string) {
+ append(p_string);
+ }
+
+ _FORCE_INLINE_ void operator+=(const char *p_str) {
+ append(p_str);
+ }
+
+ _FORCE_INLINE_ void operator+=(const CharType *p_str) {
+ append(p_str);
+ }
+
+ StringBuffer &reserve(int p_size);
+
+ int length() const;
+
+ String as_string();
+
+ double as_double();
+ int64_t as_int();
+
+ _FORCE_INLINE_ operator String() {
+ return as_string();
+ }
+};
+
+#endif
diff --git a/core/string_builder.cpp b/core/string_builder.cpp
new file mode 100644
index 0000000000..18c710ed2d
--- /dev/null
+++ b/core/string_builder.cpp
@@ -0,0 +1,94 @@
+/*************************************************************************/
+/* string_builder.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+#include "string_builder.h"
+
+#include <string.h>
+
+StringBuilder &StringBuilder::append(const String &p_string) {
+
+ strings.push_back(p_string);
+ appended_strings.push_back(-1);
+
+ string_length += p_string.length();
+
+ return *this;
+}
+
+StringBuilder &StringBuilder::append(const char *p_cstring) {
+
+ int32_t len = strlen(p_cstring);
+
+ c_strings.push_back(p_cstring);
+ appended_strings.push_back(len);
+
+ string_length += len;
+
+ return *this;
+}
+
+String StringBuilder::as_string() const {
+
+ CharType *buffer = memnew_arr(CharType, string_length);
+
+ int current_position = 0;
+
+ int godot_string_elem = 0;
+ int c_string_elem = 0;
+
+ for (int i = 0; i < appended_strings.size(); i++) {
+ if (appended_strings[i] == -1) {
+ // Godot string
+ const String &s = strings[godot_string_elem];
+
+ memcpy(buffer + current_position, s.ptr(), s.length() * sizeof(CharType));
+
+ current_position += s.length();
+
+ godot_string_elem++;
+ } else {
+
+ const char *s = c_strings[c_string_elem];
+
+ for (int32_t j = 0; j < appended_strings[i]; j++) {
+ buffer[current_position + j] = s[j];
+ }
+
+ current_position += appended_strings[i];
+
+ c_string_elem++;
+ }
+ }
+
+ String final_string = String(buffer, string_length);
+
+ memdelete_arr(buffer);
+
+ return final_string;
+}
diff --git a/scene/gui/button_group.h b/core/string_builder.h
index 6ebc0575d2..7cf2f07872 100644
--- a/scene/gui/button_group.h
+++ b/core/string_builder.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* button_group.h */
+/* string_builder.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,42 +27,53 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef BUTTON_GROUP_H
-#define BUTTON_GROUP_H
+#ifndef STRING_BUILDER_H
+#define STRING_BUILDER_H
-#include "scene/gui/box_container.h"
+#include "core/ustring.h"
-#if 0
-class BaseButton;
+#include "core/vector.h"
-class ButtonGroup : public BoxContainer {
+class StringBuilder {
- GDCLASS(ButtonGroup,BoxContainer);
+ uint32_t string_length = 0;
+ Vector<String> strings;
+ Vector<const char *> c_strings;
- Set<BaseButton*> buttons;
+ // -1 means it's a Godot String
+ // a natural number means C string.
+ Vector<int32_t> appended_strings;
+public:
+ StringBuilder &append(const String &p_string);
+ StringBuilder &append(const char *p_cstring);
- Array _get_button_list() const;
- void _pressed(Object *p_button);
+ _FORCE_INLINE_ StringBuilder &operator+(const String &p_string) {
+ return append(p_string);
+ }
-protected:
-friend class BaseButton;
+ _FORCE_INLINE_ StringBuilder &operator+(const char *p_cstring) {
+ return append(p_cstring);
+ }
- void _add_button(BaseButton *p_button);
- void _remove_button(BaseButton *p_button);
+ _FORCE_INLINE_ void operator+=(const String &p_string) {
+ append(p_string);
+ }
- static void _bind_methods();
-public:
+ _FORCE_INLINE_ void operator+=(const char *p_cstring) {
+ append(p_cstring);
+ }
+
+ _FORCE_INLINE_ int num_strings_appended() const {
+ return appended_strings.size();
+ }
- void get_button_list(List<BaseButton*> *p_buttons) const;
- BaseButton *get_pressed_button() const;
- BaseButton *get_focused_button() const;
- void set_pressed_button(BaseButton *p_button);
- int get_pressed_button_index() const;
+ String as_string() const;
- ButtonGroup();
+ _FORCE_INLINE_ operator String() const {
+ return as_string();
+ }
};
-#endif
-#endif // BUTTON_GROUP_H
+#endif // STRING_BUILDER_H
diff --git a/core/type_info.h b/core/type_info.h
index da6047450c..9fb80af0eb 100644
--- a/core/type_info.h
+++ b/core/type_info.h
@@ -39,28 +39,27 @@ struct TypeInherits {
template <class T, typename = void>
struct GetTypeInfo {
- enum { VARIANT_TYPE = Variant::NIL };
-
+ static const Variant::Type VARIANT_TYPE = Variant::NIL;
static inline PropertyInfo get_class_info() {
ERR_PRINT("GetTypeInfo fallback. Bug!");
return PropertyInfo(); // Not "Nil", this is an error
}
};
-#define MAKE_TYPE_INFO(m_type, m_var_type) \
- template <> \
- struct GetTypeInfo<m_type> { \
- enum { VARIANT_TYPE = m_var_type }; \
- static inline PropertyInfo get_class_info() { \
- return PropertyInfo((Variant::Type)VARIANT_TYPE, String()); \
- } \
- }; \
- template <> \
- struct GetTypeInfo<const m_type &> { \
- enum { VARIANT_TYPE = m_var_type }; \
- static inline PropertyInfo get_class_info() { \
- return PropertyInfo((Variant::Type)VARIANT_TYPE, String()); \
- } \
+#define MAKE_TYPE_INFO(m_type, m_var_type) \
+ template <> \
+ struct GetTypeInfo<m_type> { \
+ static const Variant::Type VARIANT_TYPE = m_var_type; \
+ static inline PropertyInfo get_class_info() { \
+ return PropertyInfo(VARIANT_TYPE, String()); \
+ } \
+ }; \
+ template <> \
+ struct GetTypeInfo<const m_type &> { \
+ static const Variant::Type VARIANT_TYPE = m_var_type; \
+ static inline PropertyInfo get_class_info() { \
+ return PropertyInfo(VARIANT_TYPE, String()); \
+ } \
};
MAKE_TYPE_INFO(bool, Variant::BOOL)
@@ -108,14 +107,14 @@ MAKE_TYPE_INFO(BSP_Tree, Variant::DICTIONARY)
//for RefPtr
template <>
struct GetTypeInfo<RefPtr> {
- enum { VARIANT_TYPE = Variant::OBJECT };
+ static const Variant::Type VARIANT_TYPE = Variant::OBJECT;
static inline PropertyInfo get_class_info() {
return PropertyInfo(Variant::OBJECT, String(), PROPERTY_HINT_RESOURCE_TYPE, "Reference");
}
};
template <>
struct GetTypeInfo<const RefPtr &> {
- enum { VARIANT_TYPE = Variant::OBJECT };
+ static const Variant::Type VARIANT_TYPE = Variant::OBJECT;
static inline PropertyInfo get_class_info() {
return PropertyInfo(Variant::OBJECT, String(), PROPERTY_HINT_RESOURCE_TYPE, "Reference");
}
@@ -124,7 +123,7 @@ struct GetTypeInfo<const RefPtr &> {
//for variant
template <>
struct GetTypeInfo<Variant> {
- enum { VARIANT_TYPE = Variant::NIL };
+ static const Variant::Type VARIANT_TYPE = Variant::NIL;
static inline PropertyInfo get_class_info() {
return PropertyInfo(Variant::NIL, String(), PROPERTY_HINT_NONE, String(), PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_NIL_IS_VARIANT);
}
@@ -132,26 +131,26 @@ struct GetTypeInfo<Variant> {
template <>
struct GetTypeInfo<const Variant &> {
- enum { VARIANT_TYPE = Variant::NIL };
+ static const Variant::Type VARIANT_TYPE = Variant::NIL;
static inline PropertyInfo get_class_info() {
return PropertyInfo(Variant::NIL, String(), PROPERTY_HINT_NONE, String(), PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_NIL_IS_VARIANT);
}
};
-#define MAKE_TEMPLATE_TYPE_INFO(m_template, m_type, m_var_type) \
- template <> \
- struct GetTypeInfo<m_template<m_type> > { \
- enum { VARIANT_TYPE = m_var_type }; \
- static inline PropertyInfo get_class_info() { \
- return PropertyInfo((Variant::Type)VARIANT_TYPE, String()); \
- } \
- }; \
- template <> \
- struct GetTypeInfo<const m_template<m_type> &> { \
- enum { VARIANT_TYPE = m_var_type }; \
- static inline PropertyInfo get_class_info() { \
- return PropertyInfo((Variant::Type)VARIANT_TYPE, String()); \
- } \
+#define MAKE_TEMPLATE_TYPE_INFO(m_template, m_type, m_var_type) \
+ template <> \
+ struct GetTypeInfo<m_template<m_type> > { \
+ static const Variant::Type VARIANT_TYPE = m_var_type; \
+ static inline PropertyInfo get_class_info() { \
+ return PropertyInfo(VARIANT_TYPE, String()); \
+ } \
+ }; \
+ template <> \
+ struct GetTypeInfo<const m_template<m_type> &> { \
+ static const Variant::Type VARIANT_TYPE = m_var_type; \
+ static inline PropertyInfo get_class_info() { \
+ return PropertyInfo(VARIANT_TYPE, String()); \
+ } \
};
MAKE_TEMPLATE_TYPE_INFO(Vector, uint8_t, Variant::POOL_BYTE_ARRAY)
@@ -171,8 +170,7 @@ MAKE_TEMPLATE_TYPE_INFO(PoolVector, Face3, Variant::POOL_VECTOR3_ARRAY)
template <typename T>
struct GetTypeInfo<T *, typename EnableIf<TypeInherits<Object, T>::value>::type> {
- enum { VARIANT_TYPE = Variant::OBJECT };
-
+ static const Variant::Type VARIANT_TYPE = Variant::OBJECT;
static inline PropertyInfo get_class_info() {
return PropertyInfo(StringName(T::get_class_static()));
}
@@ -180,8 +178,7 @@ struct GetTypeInfo<T *, typename EnableIf<TypeInherits<Object, T>::value>::type>
template <typename T>
struct GetTypeInfo<const T *, typename EnableIf<TypeInherits<Object, T>::value>::type> {
- enum { VARIANT_TYPE = Variant::OBJECT };
-
+ static const Variant::Type VARIANT_TYPE = Variant::OBJECT;
static inline PropertyInfo get_class_info() {
return PropertyInfo(StringName(T::get_class_static()));
}
@@ -190,7 +187,7 @@ struct GetTypeInfo<const T *, typename EnableIf<TypeInherits<Object, T>::value>:
#define TEMPL_MAKE_ENUM_TYPE_INFO(m_enum, m_impl) \
template <> \
struct GetTypeInfo<m_impl> { \
- enum { VARIANT_TYPE = Variant::INT }; \
+ static const Variant::Type VARIANT_TYPE = Variant::INT; \
static inline PropertyInfo get_class_info() { \
return PropertyInfo(Variant::INT, String(), PROPERTY_HINT_NONE, String(), PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_CLASS_IS_ENUM, String(#m_enum).replace("::", ".")); \
} \
diff --git a/core/variant_call.cpp b/core/variant_call.cpp
index ad15f8f5cb..dc1c24d234 100644
--- a/core/variant_call.cpp
+++ b/core/variant_call.cpp
@@ -481,6 +481,7 @@ struct _VariantCall {
VCALL_LOCALMEM1(Array, erase);
VCALL_LOCALMEM0(Array, sort);
VCALL_LOCALMEM2(Array, sort_custom);
+ VCALL_LOCALMEM0R(Array, duplicate);
VCALL_LOCALMEM0(Array, invert);
static void _call_PoolByteArray_get_string_from_ascii(Variant &r_ret, Variant &p_self, const Variant **p_args) {
@@ -1575,6 +1576,7 @@ void register_variant_methods() {
ADDFUNC0(ARRAY, NIL, Array, sort, varray());
ADDFUNC2(ARRAY, NIL, Array, sort_custom, OBJECT, "obj", STRING, "func", varray());
ADDFUNC0(ARRAY, NIL, Array, invert, varray());
+ ADDFUNC0(ARRAY, ARRAY, Array, duplicate, varray());
ADDFUNC0(POOL_BYTE_ARRAY, INT, PoolByteArray, size, varray());
ADDFUNC2(POOL_BYTE_ARRAY, NIL, PoolByteArray, set, INT, "idx", INT, "byte", varray());
diff --git a/core/variant_parser.cpp b/core/variant_parser.cpp
index 65c7b7cfec..d60d10cd3a 100644
--- a/core/variant_parser.cpp
+++ b/core/variant_parser.cpp
@@ -29,6 +29,7 @@
/*************************************************************************/
#include "variant_parser.h"
+#include "core/string_buffer.h"
#include "io/resource_loader.h"
#include "os/input_event.h"
#include "os/keyboard.h"
@@ -176,14 +177,15 @@ Error VariantParser::get_token(Stream *p_stream, Token &r_token, int &line, Stri
};
case '#': {
- String color_str = "#";
+ StringBuffer color_str;
+ color_str += '#';
while (true) {
CharType ch = p_stream->get_char();
if (p_stream->is_eof()) {
r_token.type = TK_EOF;
return OK;
} else if ((ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'f') || (ch >= 'A' && ch <= 'F')) {
- color_str += String::chr(ch);
+ color_str += ch;
} else {
p_stream->saved = ch;
@@ -191,7 +193,7 @@ Error VariantParser::get_token(Stream *p_stream, Token &r_token, int &line, Stri
}
}
- r_token.value = Color::html(color_str);
+ r_token.value = Color::html(color_str.as_string());
r_token.type = TK_COLOR;
return OK;
};
@@ -296,7 +298,7 @@ Error VariantParser::get_token(Stream *p_stream, Token &r_token, int &line, Stri
if (cchar == '-' || (cchar >= '0' && cchar <= '9')) {
//a number
- String num;
+ StringBuffer num;
#define READING_SIGN 0
#define READING_INT 1
#define READING_DEC 2
@@ -359,7 +361,7 @@ Error VariantParser::get_token(Stream *p_stream, Token &r_token, int &line, Stri
if (reading == READING_DONE)
break;
- num += String::chr(c);
+ num += c;
c = p_stream->get_char();
}
@@ -368,19 +370,19 @@ Error VariantParser::get_token(Stream *p_stream, Token &r_token, int &line, Stri
r_token.type = TK_NUMBER;
if (is_float)
- r_token.value = num.to_double();
+ r_token.value = num.as_double();
else
- r_token.value = num.to_int();
+ r_token.value = num.as_int();
return OK;
} else if ((cchar >= 'A' && cchar <= 'Z') || (cchar >= 'a' && cchar <= 'z') || cchar == '_') {
- String id;
+ StringBuffer id;
bool first = true;
while ((cchar >= 'A' && cchar <= 'Z') || (cchar >= 'a' && cchar <= 'z') || cchar == '_' || (!first && cchar >= '0' && cchar <= '9')) {
- id += String::chr(cchar);
+ id += cchar;
cchar = p_stream->get_char();
first = false;
}
@@ -388,7 +390,7 @@ Error VariantParser::get_token(Stream *p_stream, Token &r_token, int &line, Stri
p_stream->saved = cchar;
r_token.type = TK_IDENTIFIER;
- r_token.value = id;
+ r_token.value = id.as_string();
return OK;
} else {
r_err_str = "Unexpected character.";
diff --git a/doc/base/classes.xml b/doc/base/classes.xml
index e04ccc724d..90ca2e5b79 100644
--- a/doc/base/classes.xml
+++ b/doc/base/classes.xml
@@ -31,6 +31,7 @@
<argument index="1" name="alpha" type="float">
</argument>
<description>
+ Make a color from color name (color_names.inc) and alpha ranging from 0 to 1.
</description>
</method>
<method name="abs">
@@ -113,6 +114,7 @@
<argument index="0" name="ascii" type="int">
</argument>
<description>
+ Returns a character as String of the given ASCII code.
</description>
</method>
<method name="clamp">
@@ -309,6 +311,10 @@
<argument index="2" name="value" type="float">
</argument>
<description>
+ Returns a normalized value considering the given range.
+ [codeblock]
+ inverse_lerp(3, 5, 4) # return 0.5
+ [/codeblock]
</description>
</method>
<method name="is_inf">
@@ -335,6 +341,7 @@
<argument index="0" name="var" type="Variant">
</argument>
<description>
+ Returns the length of the given Variant if applicable. It will return character count of a String, element count of an Array, etc.
</description>
</method>
<method name="lerp">
@@ -551,6 +558,10 @@
<argument index="4" name="ostop" type="float">
</argument>
<description>
+ Maps a value from range [istart, istop] to [ostart, ostop].
+ [codeblock]
+ range_lerp(75, 0, 100, -1, 1) # returns 0.5
+ [/codeblock]
</description>
</method>
<method name="round">
@@ -667,6 +678,11 @@
<argument index="0" name="type" type="String">
</argument>
<description>
+ Returns whether the given class is exist in [ClassDB].
+ [codeblock]
+ type_exists("Sprite") # returns true
+ type_exists("Variant") # returns false
+ [/codeblock]
</description>
</method>
<method name="typeof">
@@ -753,6 +769,7 @@
</methods>
<members>
<member name="ARVRServer" type="ARVRServer" setter="" getter="" brief="">
+ [ARVRServer] singleton
</member>
<member name="AudioServer" type="AudioServer" setter="" getter="" brief="">
[AudioServer] singleton
@@ -1944,18 +1961,25 @@
Variable is of type [Array].
</constant>
<constant name="TYPE_RAW_ARRAY" value="20">
+ Variable is of type [PoolByteArray].
</constant>
<constant name="TYPE_INT_ARRAY" value="21">
+ Variable is of type [PoolIntArray].
</constant>
<constant name="TYPE_REAL_ARRAY" value="22">
+ Variable is of type [PoolRealArray].
</constant>
<constant name="TYPE_STRING_ARRAY" value="23">
+ Variable is of type [PoolStringArray].
</constant>
<constant name="TYPE_VECTOR2_ARRAY" value="24">
+ Variable is of type [PoolVector2Array].
</constant>
<constant name="TYPE_VECTOR3_ARRAY" value="25">
+ Variable is of type [PoolVector3Array].
</constant>
<constant name="TYPE_COLOR_ARRAY" value="26">
+ Variable is of type [PoolColorArray].
</constant>
<constant name="TYPE_MAX" value="27">
</constant>
@@ -3477,6 +3501,7 @@
<argument index="0" name="idx" type="int">
</argument>
<description>
+ Return the update mode of a value track.
</description>
</method>
<method name="value_track_set_update_mode">
@@ -3487,6 +3512,7 @@
<argument index="1" name="mode" type="int" enum="Animation.UpdateMode">
</argument>
<description>
+ Set the update mode (UPDATE_*) of a value track.
</description>
</method>
</methods>
@@ -3510,10 +3536,13 @@
Cubic interpolation.
</constant>
<constant name="UPDATE_CONTINUOUS" value="0">
+ Update between keyframes.
</constant>
<constant name="UPDATE_DISCRETE" value="1">
+ Update at the keyframes and hold the value.
</constant>
<constant name="UPDATE_TRIGGER" value="2">
+ Update at the keyframes.
</constant>
</constants>
</class>
@@ -3551,6 +3580,7 @@
<argument index="0" name="anim_from" type="String">
</argument>
<description>
+ Return the name of the next animation in the queue.
</description>
</method>
<method name="animation_set_next">
@@ -3561,6 +3591,7 @@
<argument index="1" name="anim_to" type="String">
</argument>
<description>
+ Set the name of an animation that will be played after.
</description>
</method>
<method name="clear_caches">
@@ -3933,6 +3964,7 @@
<argument index="0" name="id" type="String">
</argument>
<description>
+ Returns an animation given its name.
</description>
</method>
<method name="animation_node_get_master_animation" qualifiers="const">
@@ -3986,6 +4018,7 @@
<argument index="2" name="dst_input_idx" type="int">
</argument>
<description>
+ Returns whether node [code]id[/code] and [code]dst_id[/code] are connected at the specified slot.
</description>
</method>
<method name="blend2_node_get_amount" qualifiers="const">
@@ -3994,6 +4027,7 @@
<argument index="0" name="id" type="String">
</argument>
<description>
+ Returns the blend amount of a Blend2 node given its name.
</description>
</method>
<method name="blend2_node_set_amount">
@@ -4004,6 +4038,7 @@
<argument index="1" name="blend" type="float">
</argument>
<description>
+ Sets the blend amount of a Blend2 node given its name and value.
</description>
</method>
<method name="blend2_node_set_filter_path">
@@ -4024,6 +4059,7 @@
<argument index="0" name="id" type="String">
</argument>
<description>
+ Returns the blend amount of a Blend3 node given its name.
</description>
</method>
<method name="blend3_node_set_amount">
@@ -4034,6 +4070,7 @@
<argument index="1" name="blend" type="float">
</argument>
<description>
+ Sets the blend amount of a Blend3 node given its name and value.
</description>
</method>
<method name="blend4_node_get_amount" qualifiers="const">
@@ -4042,6 +4079,7 @@
<argument index="0" name="id" type="String">
</argument>
<description>
+ Returns the blend amount of a Blend4 node given its name.
</description>
</method>
<method name="blend4_node_set_amount">
@@ -4052,6 +4090,7 @@
<argument index="1" name="blend" type="Vector2">
</argument>
<description>
+ Sets the blend amount of a Blend4 node given its name and value.
</description>
</method>
<method name="connect_nodes">
@@ -4064,6 +4103,7 @@
<argument index="2" name="dst_input_idx" type="int">
</argument>
<description>
+ Connects node [code]id[/code] to [code]dst_id[/code] at the specified input slot.
</description>
</method>
<method name="disconnect_nodes">
@@ -4074,12 +4114,14 @@
<argument index="1" name="dst_input_idx" type="int">
</argument>
<description>
+ Disconnects nodes connected to [code]id[/code] at the specified input slot.
</description>
</method>
<method name="get_animation_process_mode" qualifiers="const">
<return type="int" enum="AnimationTreePlayer.AnimationProcessMode">
</return>
<description>
+ Returns playback process mode of this AnimationTreePlayer.
</description>
</method>
<method name="get_base_path" qualifiers="const">
@@ -4098,12 +4140,14 @@
<return type="PoolStringArray">
</return>
<description>
+ Returns a PoolStringArray containing the name of all nodes.
</description>
</method>
<method name="is_active" qualifiers="const">
<return type="bool">
</return>
<description>
+ Returns whether this AnimationTreePlayer is active.
</description>
</method>
<method name="mix_node_get_amount" qualifiers="const">
@@ -4112,6 +4156,7 @@
<argument index="0" name="id" type="String">
</argument>
<description>
+ Returns mix amount of a Mix node given its name.
</description>
</method>
<method name="mix_node_set_amount">
@@ -4122,6 +4167,7 @@
<argument index="1" name="ratio" type="float">
</argument>
<description>
+ Sets mix amount of a Mix node given its name and value.
</description>
</method>
<method name="node_exists" qualifiers="const">
@@ -4159,6 +4205,7 @@
<argument index="0" name="id" type="String">
</argument>
<description>
+ Returns position of a node in the graph given its name.
</description>
</method>
<method name="node_get_type" qualifiers="const">
@@ -4189,6 +4236,7 @@
<argument index="1" name="screen_pos" type="Vector2">
</argument>
<description>
+ Sets position of a node in the graph given its name and position.
</description>
</method>
<method name="oneshot_node_get_autorestart_delay" qualifiers="const">
@@ -4197,6 +4245,7 @@
<argument index="0" name="id" type="String">
</argument>
<description>
+ Returns autostart delay of a OneShot node given its name.
</description>
</method>
<method name="oneshot_node_get_autorestart_random_delay" qualifiers="const">
@@ -4205,6 +4254,7 @@
<argument index="0" name="id" type="String">
</argument>
<description>
+ Returns autostart random delay of a OneShot node given its name.
</description>
</method>
<method name="oneshot_node_get_fadein_time" qualifiers="const">
@@ -4213,6 +4263,7 @@
<argument index="0" name="id" type="String">
</argument>
<description>
+ Returns fade in time of a OneShot node given its name.
</description>
</method>
<method name="oneshot_node_get_fadeout_time" qualifiers="const">
@@ -4221,6 +4272,7 @@
<argument index="0" name="id" type="String">
</argument>
<description>
+ Returns fade out time of a OneShot node given its name.
</description>
</method>
<method name="oneshot_node_has_autorestart" qualifiers="const">
@@ -4229,6 +4281,7 @@
<argument index="0" name="id" type="String">
</argument>
<description>
+ Returns whether a OneShot node will auto restart given its name.
</description>
</method>
<method name="oneshot_node_is_active" qualifiers="const">
@@ -4237,6 +4290,7 @@
<argument index="0" name="id" type="String">
</argument>
<description>
+ Returns whether a OneShot node is active given its name.
</description>
</method>
<method name="oneshot_node_set_autorestart">
@@ -4247,6 +4301,7 @@
<argument index="1" name="enable" type="bool">
</argument>
<description>
+ Sets autorestart property of a OneShot node given its name and value.
</description>
</method>
<method name="oneshot_node_set_autorestart_delay">
@@ -4257,6 +4312,7 @@
<argument index="1" name="delay_sec" type="float">
</argument>
<description>
+ Sets autorestart delay of a OneShot node given its name and value in seconds.
</description>
</method>
<method name="oneshot_node_set_autorestart_random_delay">
@@ -4267,6 +4323,7 @@
<argument index="1" name="rand_sec" type="float">
</argument>
<description>
+ Sets autorestart random delay of a OneShot node given its name and value in seconds.
</description>
</method>
<method name="oneshot_node_set_fadein_time">
@@ -4277,6 +4334,7 @@
<argument index="1" name="time_sec" type="float">
</argument>
<description>
+ Sets fade in time of a OneShot node given its name and value in seconds.
</description>
</method>
<method name="oneshot_node_set_fadeout_time">
@@ -4287,6 +4345,7 @@
<argument index="1" name="time_sec" type="float">
</argument>
<description>
+ Sets fade out time of a OneShot node given its name and value in seconds.
</description>
</method>
<method name="oneshot_node_set_filter_path">
@@ -4307,6 +4366,7 @@
<argument index="0" name="id" type="String">
</argument>
<description>
+ Starts a OneShot node given its name.
</description>
</method>
<method name="oneshot_node_stop">
@@ -4315,6 +4375,7 @@
<argument index="0" name="id" type="String">
</argument>
<description>
+ Stops a OneShot node given its name.
</description>
</method>
<method name="recompute_caches">
@@ -4335,6 +4396,7 @@
<return type="void">
</return>
<description>
+ Resets this AnimationTreePlayer.
</description>
</method>
<method name="set_active">
@@ -4343,6 +4405,7 @@
<argument index="0" name="enabled" type="bool">
</argument>
<description>
+ Sets whether this AnimationTreePlayer is active. AnimationTreePlayer will start processing if set to active.
</description>
</method>
<method name="set_animation_process_mode">
@@ -4351,6 +4414,7 @@
<argument index="0" name="mode" type="int" enum="AnimationTreePlayer.AnimationProcessMode">
</argument>
<description>
+ Sets process mode (ANIMATION_PROCESS_*) of this AnimationTreePlayer.
</description>
</method>
<method name="set_base_path">
@@ -4359,6 +4423,7 @@
<argument index="0" name="path" type="NodePath">
</argument>
<description>
+ Sets base path of this AnimationTreePlayer.
</description>
</method>
<method name="set_master_player">
@@ -4375,6 +4440,7 @@
<argument index="0" name="id" type="String">
</argument>
<description>
+ Returns time scale value of a TimeScale node given its name.
</description>
</method>
<method name="timescale_node_set_scale">
@@ -4385,6 +4451,7 @@
<argument index="1" name="scale" type="float">
</argument>
<description>
+ Sets time scale value of a TimeScale node given its name and value.
</description>
</method>
<method name="timeseek_node_seek">
@@ -4395,6 +4462,7 @@
<argument index="1" name="pos_sec" type="float">
</argument>
<description>
+ Sets time seek value of a TimeSeek node given its name and value.
</description>
</method>
<method name="transition_node_delete_input">
@@ -4490,24 +4558,34 @@
</members>
<constants>
<constant name="NODE_OUTPUT" value="0">
+ Output node.
</constant>
<constant name="NODE_ANIMATION" value="1">
+ Animation node.
</constant>
<constant name="NODE_ONESHOT" value="2">
+ OneShot node.
</constant>
<constant name="NODE_MIX" value="3">
+ Mix node.
</constant>
<constant name="NODE_BLEND2" value="4">
+ Blend2 node.
</constant>
<constant name="NODE_BLEND3" value="5">
+ Blend3 node.
</constant>
<constant name="NODE_BLEND4" value="6">
+ Blend4 node.
</constant>
<constant name="NODE_TIMESCALE" value="7">
+ TimeScale node.
</constant>
<constant name="NODE_TIMESEEK" value="8">
+ TimeSeek node.
</constant>
<constant name="NODE_TRANSITION" value="9">
+ Transition node.
</constant>
</constants>
</class>
@@ -5005,10 +5083,10 @@
</class>
<class name="Area2D" inherits="CollisionObject2D" category="Core">
<brief_description>
- General purpose area detection and influence for 2D physics.
+ 2D area that detects nodes that enter or exit it. Can override 2D physics properties within range.
</brief_description>
<description>
- General purpose area detection for 2D physics. Areas can be used for detection of objects that enter/exit them, as well as overriding space parameters (changing gravity, damping, etc). For this, use any space override different from AREA_SPACE_OVERRIDE_DISABLE and point gravity at the center of mass.
+ 2D area that detects nodes that enter or exit it. Change the 'space_override' property SPACE_OVERRIDE_* to override physics parameters for nodes like [Rigidbody2D]. E.g. gravity, damping... See [CollisionObject2D] for usage.
</description>
<methods>
<method name="get_angular_damp" qualifiers="const">
@@ -5037,14 +5115,14 @@
<argument index="0" name="bit" type="int">
</argument>
<description>
- Return an individual bit on the layer mask.
+ Return an individual bit on the layer mask. Describes whether other areas will collide with this one on the given layer.
</description>
</method>
<method name="get_collision_mask" qualifiers="const">
<return type="int">
</return>
<description>
- Return the physics layers this area can scan for collisions.
+ Return the physics layers this area will scan to determine collisions.
</description>
</method>
<method name="get_collision_mask_bit" qualifiers="const">
@@ -5053,7 +5131,7 @@
<argument index="0" name="bit" type="int">
</argument>
<description>
- Return an individual bit on the collision mask.
+ Return an individual bit on the collision mask. Describes whether this area will collide with others on the given layer.
</description>
</method>
<method name="get_gravity" qualifiers="const">
@@ -5088,14 +5166,14 @@
<return type="Array">
</return>
<description>
- Return a list of the areas that are totally or partially inside this area.
+ Returns a list of the [Area2D]s that intersect with this area.
</description>
</method>
<method name="get_overlapping_bodies" qualifiers="const">
<return type="Array">
</return>
<description>
- Return a list of the bodies ([PhysicsBody2D]) that are totally or partially inside this area.
+ Return a list of the [PhysicsBody2D]s that intersect with this area.
</description>
</method>
<method name="get_priority" qualifiers="const">
@@ -5317,33 +5395,50 @@
</method>
</methods>
<members>
- <member name="angular_damp" type="float" setter="set_angular_damp" getter="get_angular_damp" brief="">
+ <member name="angular_damp" type="float" setter="set_angular_damp" getter="get_angular_damp" brief="rate of spin loss">
+ The rate at which objects stop spinning in this area. Represents the amount of speed lost per second. If 1.0, physics bodies in the area stop rotating immediately. If 0.0, they never slow down. Does not incorporate external forces. The physics-update's rate affects 'angular_damp'.
</member>
- <member name="audio_bus_name" type="String" setter="set_audio_bus" getter="get_audio_bus" brief="">
+ <member name="audio_bus_name" type="String" setter="set_audio_bus" getter="get_audio_bus" brief="name of audio bus">
+ The name of the Area2D's audio bus.
</member>
- <member name="audio_bus_override" type="bool" setter="set_audio_bus_override" getter="is_overriding_audio_bus" brief="">
+ <member name="audio_bus_override" type="bool" setter="set_audio_bus_override" getter="is_overriding_audio_bus" brief="Whether to override audio bus">
+ If [code]true[/code], overrides the default audio bus with the Area2D's. Defaults to [code]false[/code].
</member>
- <member name="collision_layer" type="int" setter="set_collision_layer" getter="get_collision_layer" brief="">
+ <member name="collision_layer" type="int" setter="set_collision_layer" getter="get_collision_layer" brief="others-collide-with-this layers">
+ The physics layer this Area2D is in.
+ Collidable objects can exist in any of 32 different layers. These layers are not visual, but more of a tagging system instead. A collidable can use these layers/tags to select with which objects it can collide, using [method set_collision_mask].
+ A contact is detected if object A is in any of the layers that object B scans, or object B is in any layers that object A scans.
</member>
- <member name="collision_mask" type="int" setter="set_collision_mask" getter="get_collision_mask" brief="">
+ <member name="collision_mask" type="int" setter="set_collision_mask" getter="get_collision_mask" brief="this-collides-with-others layers">
+ The physics layers this Area2D scans to determine collision detections.
</member>
- <member name="gravity" type="float" setter="set_gravity" getter="get_gravity" brief="">
+ <member name="gravity" type="float" setter="set_gravity" getter="get_gravity" brief="internal gravity intensity">
+ The gravity intensity within the Area2D (ranges -1024 to 1024). This is useful to alter the force of gravity without altering its direction.
+ This value multiplies the gravity vector, whether it is the given vector ([method set_gravity_vector]), or a calculated one (when using a center of gravity).
</member>
- <member name="gravity_distance_scale" type="float" setter="set_gravity_distance_scale" getter="get_gravity_distance_scale" brief="">
+ <member name="gravity_distance_scale" type="float" setter="set_gravity_distance_scale" getter="get_gravity_distance_scale" brief="gravity drop rate">
+ The falloff factor for point gravity. The greater this value is, the faster the strength of gravity decreases with the square of distance.
</member>
- <member name="gravity_point" type="bool" setter="set_gravity_is_point" getter="is_gravity_a_point" brief="">
+ <member name="gravity_point" type="bool" setter="set_gravity_is_point" getter="is_gravity_a_point" brief="is gravity a point?">
+ If [code]true[/code], calculates gravity from a particular point during a space override (see [method set_space_override_mode]). If a point, [Vector2] position is set with [method set_gravity_vector]. Defaults to [code]false[/code].
</member>
- <member name="gravity_vec" type="Vector2" setter="set_gravity_vector" getter="get_gravity_vector" brief="">
+ <member name="gravity_vec" type="Vector2" setter="set_gravity_vector" getter="get_gravity_vector" brief="gravity non-normalized vector or center-point">
+ The gravitational direction/strength as a vector (not normalized). If gravity is a point (see [method is_gravity_a_point]), this will be the attraction center.
</member>
- <member name="linear_damp" type="float" setter="set_linear_damp" getter="get_linear_damp" brief="">
+ <member name="linear_damp" type="float" setter="set_linear_damp" getter="get_linear_damp" brief="rate of movement loss">
+ The rate at which objects stop spinning in this area. Represents the amount of speed lost per second. If 1.0, physics bodies in the area stop rotating immediately. If 0.0, they never slow down. Does not incorporate external forces. The physics-update's rate affects 'angular_damp'.
</member>
- <member name="monitorable" type="bool" setter="set_monitorable" getter="is_monitorable" brief="">
+ <member name="monitorable" type="bool" setter="set_monitorable" getter="is_monitorable" brief="others cannot detect this?">
+ If [code]true[/code], other monitoring areas can detect this Area2D (is it undetectable at the moment?). Defaults to [code]true[/code].
</member>
- <member name="monitoring" type="bool" setter="set_monitoring" getter="is_monitoring" brief="">
+ <member name="monitoring" type="bool" setter="set_monitoring" getter="is_monitoring" brief="this cannot detect others?">
+ If [code]true[/code], this detects bodies/areas entering/exiting it (can it detect others at the moment?). Defaults to [code]true[/code].
</member>
- <member name="priority" type="float" setter="set_priority" getter="get_priority" brief="">
+ <member name="priority" type="float" setter="set_priority" getter="get_priority" brief="(high) process before others (low)">
+ The processing order for this priority. Ranges from 0 to 128. Defaults to 0. Higher priorities are processed first.
</member>
- <member name="space_override" type="int" setter="set_space_override_mode" getter="get_space_override_mode" brief="" enum="Area2D.SpaceOverride">
+ <member name="space_override" type="int" setter="set_space_override_mode" getter="get_space_override_mode" brief="how to override gravity/damping" enum="Area2D.SpaceOverride">
+ How to override gravity and damping calculations within this Area2D, if at all. Consult the SPACE_OVERRIDE_* constants for available options.
</member>
</members>
<signals>
@@ -5429,6 +5524,11 @@
</signal>
</signals>
<constants>
+ <constant name="SPACE_OVERRIDE_DISABLED" value="0" enum="Area2D.SpaceOverride">This area does not affect gravity/damp. These are areas that exist only to detect collisions and objects entering or exiting them.</constant>
+ <constant name="SPACE_OVERRIDE_COMBINE" value="1" enum="Area2D.SpaceOverride">This area adds its gravity/damp values to whatever has been calculated so far. This way, many overlapping areas can combine their physics to make interesting effects.</constant>
+ <constant name="SPACE_OVERRIDE_COMBINE_REPLACE" value="2" enum="Area2D.SpaceOverride">This area adds its gravity/damp values to whatever has been calculated so far. Then stops taking into account the rest of the areas, even the default one.</constant>
+ <constant name="SPACE_OVERRIDE_REPLACE" value="3" enum="Area2D.SpaceOverride">This area replaces any gravity/damp, even the default one, and stops taking into account the rest of the areas.</constant>
+ <constant name="SPACE_OVERRIDE_REPLACE_COMBINE" value="4" enum="Area2D.SpaceOverride">This area replaces any gravity/damp calculated so far, but keeps calculating the rest of the areas, down to the default one.</constant>
</constants>
</class>
<class name="Array" category="Built-In Types">
@@ -5670,7 +5770,7 @@
<argument index="1" name="func" type="String">
</argument>
<description>
- Sort the array using a custom method. The arguments are an object that holds the method and the name of such method. The custom method receives two arguments (a pair of elements from the array) and must return true if the first argument is less than the second, and return false otherwise.
+ Sort the array using a custom method. The arguments are an object that holds the method and the name of such method. The custom method receives two arguments (a pair of elements from the array) and must return true if the first argument is less than the second, and return false otherwise. Note: you cannot randomize the return value as the heapsort algorithm expects a deterministic result. Doing so will result in unexpected behavior.
</description>
</method>
</methods>
@@ -8947,8 +9047,10 @@
</class>
<class name="BitMap" inherits="Resource" category="Core">
<brief_description>
+ Boolean matrix.
</brief_description>
<description>
+ A two-dimensional array of boolean values, can be used to efficiently store a binary matrix (every matrix element takes only one bit) and query the values using natural cartesian coordinates.
</description>
<methods>
<method name="create">
@@ -8957,6 +9059,7 @@
<argument index="0" name="size" type="Vector2">
</argument>
<description>
+ Creates a bitmap with the specified size, filled with false.
</description>
</method>
<method name="create_from_image_alpha">
@@ -8965,6 +9068,7 @@
<argument index="0" name="image" type="Image">
</argument>
<description>
+ Creates a bitmap that matches the given image dimensions, every element of the bitmap is set to false if the alpha value of the image at that position is 0, and true in other case.
</description>
</method>
<method name="get_bit" qualifiers="const">
@@ -8973,18 +9077,21 @@
<argument index="0" name="pos" type="Vector2">
</argument>
<description>
+ Returns bitmap's value at the specified position.
</description>
</method>
<method name="get_size" qualifiers="const">
<return type="Vector2">
</return>
<description>
+ Returns bitmap's dimensions.
</description>
</method>
<method name="get_true_bit_count" qualifiers="const">
<return type="int">
</return>
<description>
+ Returns the amount of bitmap elements that are set to true.
</description>
</method>
<method name="set_bit">
@@ -8995,6 +9102,7 @@
<argument index="1" name="bit" type="bool">
</argument>
<description>
+ Sets the bitmap's element at the specified position, to the specified value.
</description>
</method>
<method name="set_bit_rect">
@@ -9005,6 +9113,7 @@
<argument index="1" name="bit" type="bool">
</argument>
<description>
+ Sets a rectangular portion of the bitmap to the specified value.
</description>
</method>
</methods>
@@ -9183,6 +9292,7 @@
<return type="String">
</return>
<description>
+ Returns the name of the bone node attached to.
</description>
</method>
<method name="set_bone_name">
@@ -9191,6 +9301,7 @@
<argument index="0" name="bone_name" type="String">
</argument>
<description>
+ Changes the name of the bone node
</description>
</method>
</methods>
@@ -9292,35 +9403,30 @@
<return type="Texture">
</return>
<description>
- Return the button icon.
</description>
</method>
<method name="get_clip_text" qualifiers="const">
<return type="bool">
</return>
<description>
- Return the state of the [i]clip_text[/i] property (see [method set_clip_text])
</description>
</method>
<method name="get_text" qualifiers="const">
<return type="String">
</return>
<description>
- Return the button text.
</description>
</method>
<method name="get_text_align" qualifiers="const">
<return type="int" enum="Button.TextAlign">
</return>
<description>
- Return the text alignment policy.
</description>
</method>
<method name="is_flat" qualifiers="const">
<return type="bool">
</return>
<description>
- Return the state of the [i]flat[/i] property (see [method set_flat]).
</description>
</method>
<method name="set_button_icon">
@@ -9329,7 +9435,6 @@
<argument index="0" name="texture" type="Texture">
</argument>
<description>
- Set the icon that will be displayed next to the text inside the button area.
</description>
</method>
<method name="set_clip_text">
@@ -9338,7 +9443,6 @@
<argument index="0" name="enabled" type="bool">
</argument>
<description>
- Set the [i]clip_text[/i] property of a Button. When this property is enabled, text that is too large to fit the button is clipped, when disabled (default) the Button will always be wide enough to hold the text.
</description>
</method>
<method name="set_flat">
@@ -9347,7 +9451,6 @@
<argument index="0" name="enabled" type="bool">
</argument>
<description>
- Set the [i]flat[/i] property of a Button. Flat buttons don't display decoration unless hovered or pressed.
</description>
</method>
<method name="set_text">
@@ -9356,7 +9459,6 @@
<argument index="0" name="text" type="String">
</argument>
<description>
- Set the button text, which will be displayed inside the button area.
</description>
</method>
<method name="set_text_align">
@@ -9365,20 +9467,24 @@
<argument index="0" name="align" type="int" enum="Button.TextAlign">
</argument>
<description>
- Set the text alignment policy, using one of the ALIGN_* constants.
</description>
</method>
</methods>
<members>
<member name="align" type="int" setter="set_text_align" getter="get_text_align" brief="" enum="Button.TextAlign">
+ Text alignment policy for the button's text, use one of the ALIGN_* constants.
</member>
<member name="clip_text" type="bool" setter="set_clip_text" getter="get_clip_text" brief="">
+ When this property is enabled, text that is too large to fit the button is clipped, when disabled the Button will always be wide enough to hold the text. This property is disabled by default.
</member>
- <member name="flat" type="bool" setter="set_flat" getter="is_flat" brief="">
+ <member name="flat" type="bool" setter="set_flat" getter="is_flat" brief="button decoration mode">
+ Flat buttons don't display decoration.
</member>
<member name="icon" type="Texture" setter="set_button_icon" getter="get_button_icon" brief="">
+ Button's icon, if text is present the icon will be placed before the text.
</member>
<member name="text" type="String" setter="set_text" getter="get_text" brief="">
+ The button's text that will be displayed inside the button's area.
</member>
</members>
<constants>
@@ -9386,7 +9492,7 @@
Align the text to the left.
</constant>
<constant name="ALIGN_CENTER" value="1">
- Center the text.
+ Align the text to the center.
</constant>
<constant name="ALIGN_RIGHT" value="2">
Align the text to the right.
@@ -10955,8 +11061,10 @@
</class>
<class name="CapsuleMesh" inherits="PrimitiveMesh" category="Core">
<brief_description>
+ Class representing a capsule-shaped [PrimitiveMesh].
</brief_description>
<description>
+ Class representing a capsule-shaped [PrimitiveMesh].
</description>
<methods>
<method name="get_mid_height" qualifiers="const">
@@ -11018,12 +11126,16 @@
</methods>
<members>
<member name="mid_height" type="float" setter="set_mid_height" getter="get_mid_height" brief="">
+ Height of the capsule mesh from the center point. Defaults to 1.0.
</member>
<member name="radial_segments" type="int" setter="set_radial_segments" getter="get_radial_segments" brief="">
+ Number of radial segments on the capsule mesh. Defaults to 64.
</member>
<member name="radius" type="float" setter="set_radius" getter="get_radius" brief="">
+ Radius of the capsule mesh. Defaults to 1.0.
</member>
<member name="rings" type="int" setter="set_rings" getter="get_rings" brief="">
+ Number of rings along the height of the capsule. Defaults to 8.
</member>
</members>
<constants>
@@ -12077,8 +12189,10 @@
</class>
<class name="CollisionShape" inherits="Spatial" category="Core">
<brief_description>
+ Node that represents collision shape data in 3D space.
</brief_description>
<description>
+ Editor facility for creating and editing collision shapes in 3D space. You can use this node to represent all sorts of collision shapes, for example, add this to an [Area] to give it a detection shape, or add it to a [PhysicsBody] to give create solid object. [b]IMPORTANT[/b]: this is an Editor-only helper to create shapes, use [method get_shape] to get the actual shape.
</description>
<methods>
<method name="get_shape" qualifiers="const">
@@ -12097,6 +12211,7 @@
<return type="void">
</return>
<description>
+ Sets the collision shape's shape to the addition of all its convexed [MeshInstance] siblings geometry.
</description>
</method>
<method name="resource_changed">
@@ -12105,6 +12220,7 @@
<argument index="0" name="resource" type="Resource">
</argument>
<description>
+ If this method exists within a script it will be called whenever the shape resource has been modified.
</description>
</method>
<method name="set_disabled">
@@ -12126,8 +12242,10 @@
</methods>
<members>
<member name="disabled" type="bool" setter="set_disabled" getter="is_disabled" brief="">
+ A disabled collision shape has no effect in the world.
</member>
<member name="shape" type="Shape" setter="set_shape" getter="get_shape" brief="">
+ The actual shape owned by this collision shape.
</member>
</members>
<constants>
@@ -12135,17 +12253,16 @@
</class>
<class name="CollisionShape2D" inherits="Node2D" category="Core">
<brief_description>
- Editor-only class for easy editing of shapes.
+ Node that represents collision shape data in 2D space.
</brief_description>
<description>
- Editor-only class. This is not present when running the game. It's used in the editor to properly edit and position collision shapes in [CollisionObject2D]. This is not accessible from regular code.
+ Editor facility for creating and editing collision shapes in 2D space. You can use this node to represent all sorts of collision shapes, for example, add this to an [Area2D] to give it a detection shape, or add it to a [PhysicsBody2D] to give create solid object. [b]IMPORTANT[/b]: this is an Editor-only helper to create shapes, use [method get_shape] to get the actual shape.
</description>
<methods>
<method name="get_shape" qualifiers="const">
<return type="Shape2D">
</return>
<description>
- Return this shape's [Shape2D].
</description>
</method>
<method name="is_disabled" qualifiers="const">
@@ -12182,16 +12299,18 @@
<argument index="0" name="shape" type="Shape2D">
</argument>
<description>
- Set this shape's [Shape2D]. This will not appear as a node, but can be directly edited as a property.
</description>
</method>
</methods>
<members>
<member name="disabled" type="bool" setter="set_disabled" getter="is_disabled" brief="">
+ A disabled collision shape has no effect in the world.
</member>
<member name="one_way_collision" type="bool" setter="set_one_way_collision" getter="is_one_way_collision_enabled" brief="">
+ Sets whether this collision shape should only detect collision on one side (top or bottom).
</member>
<member name="shape" type="Shape2D" setter="set_shape" getter="get_shape" brief="">
+ The actual shape owned by this collision shape.
</member>
</members>
<constants>
@@ -12199,10 +12318,10 @@
</class>
<class name="Color" category="Built-In Types">
<brief_description>
- Color in RGBA format.
+ Color in RGBA format with some support for ARGB format.
</brief_description>
<description>
- A color is represented as red, green and blue (r,g,b) components. Additionally, "a" represents the alpha component, often used for transparency. Values are in floating point and usually range from 0 to 1. Some methods (such as set_modulate() ) may accept values &gt; 1.
+ A color is represented as red, green and blue (r,g,b) components. Additionally, "a" represents the alpha component, often used for transparency. Values are in floating point and usually range from 0 to 1. Some methods (such as set_modulate(color)) may accept values &gt; 1.
</description>
<methods>
<method name="Color">
@@ -12217,7 +12336,10 @@
<argument index="3" name="a" type="float">
</argument>
<description>
- Construct the color from an RGBA profile.
+ Constructs a color from an RGBA profile using values between 0 and 1 (float).
+ [codeblock]
+ var c = Color(0.2, 1.0, .7, .8) # a color of an RGBA(51, 255, 178, 204)
+ [/codeblock]
</description>
</method>
<method name="Color">
@@ -12230,7 +12352,10 @@
<argument index="2" name="b" type="float">
</argument>
<description>
- Construct the color from an RGBA profile.
+ Constructs a color from an RGB profile using values between 0 and 1 (float). Alpha will always be 1.
+ [codeblock]
+ var c = Color(0.2, 1.0, .7) # a color of an RGBA(51, 255, 178, 255)
+ [/codeblock]
</description>
</method>
<method name="Color">
@@ -12239,7 +12364,10 @@
<argument index="0" name="from" type="int">
</argument>
<description>
- Construct the color from an RGBA profile.
+ Constructs a color from a 32-bit integer (each byte represents a component of the RGBA profile).
+ [codeblock]
+ var c = Color(274) # a color of an RGBA(0, 0, 1, 18)
+ [/codeblock]
</description>
</method>
<method name="Color">
@@ -12248,7 +12376,19 @@
<argument index="0" name="from" type="String">
</argument>
<description>
- Construct the color from an RGBA profile.
+ Constructs a color from an HTML hexadecimal color string in ARGB or RGB format.
+ The following string formats are supported:
+ [code]"#ff00ff00"[/code] - ARGB format with '#'
+ [code]"ff00ff00"[/code] - ARGB format
+ [code]"#ff00ff"[/code] - RGB format with '#'
+ [code]"ff00ff"[/code] - RGB format
+ [codeblock]
+ # The following code creates the same color of an RGBA(178, 217, 10, 255)
+ var c1 = Color("#ffb2d90a") # ARGB format with '#'
+ var c2 = Color("ffb2d90a") # ARGB format
+ var c3 = Color("#b2d90a") # RGB format with '#'
+ var c4 = Color("b2d90a") # RGB format
+ [/codeblock]
</description>
</method>
<method name="blend">
@@ -12257,28 +12397,46 @@
<argument index="0" name="over" type="Color">
</argument>
<description>
- Return a new color blended with anothor one.
+ Returns a new color resulting from blending this color over another color. If the color is opaque, the result would also be opaque. The other color could then take a range of values with different alpha values.
+ [codeblock]
+ var bg = Color(0.0, 1.0, 0.0, 0.5) # Green with alpha of 50%
+ var fg = Color(1.0, 0.0, 0.0, .5) # Red with alpha of 50%
+ var blendedColor = bg.blend(fg) # Brown with alpha of 75%
+ [/codeblock]
</description>
</method>
<method name="contrasted">
<return type="Color">
</return>
<description>
- Return the most contrasting color with this one.
+ Returns the most contrasting color.
+ [codeblock]
+ var c = Color(.3, .4, .9)
+ var contrastedColor = c.contrasted() # a color of an RGBA(204, 229, 102, 255)
+ [/codeblock]
</description>
</method>
<method name="gray">
<return type="float">
</return>
<description>
- Convert the color to gray.
+ Returns the color's grayscale.
+ The gray is calculated by (r + g + b) / 3.
+ [codeblock]
+ var c = Color(0.2, 0.45, 0.82)
+ var gray = c.gray() # a value of 0.466667
+ [/codeblock]
</description>
</method>
<method name="inverted">
<return type="Color">
</return>
<description>
- Return the inverted color (1-r, 1-g, 1-b, 1-a).
+ Returns the inverted color (1-r, 1-g, 1-b, 1-a).
+ [codeblock]
+ var c = Color(.3, .4, .9)
+ var invertedColor = c.inverted() # a color of an RGBA(178, 153, 26, 255)
+ [/codeblock]
</description>
</method>
<method name="linear_interpolate">
@@ -12289,21 +12447,36 @@
<argument index="1" name="t" type="float">
</argument>
<description>
- Return the linear interpolation with another color.
+ Returns the color of the linear interpolation with another color. The value t is between 0 and 1 (float).
+ [codeblock]
+ var c1 = Color(1.0, 0.0, 0.0)
+ var c2 = Color(0.0, 1.0, 0.0)
+ var li_c = c1.linear_interpolate(c2, 0.5) # a color of an RGBA(128, 128, 0, 255)
+ [/codeblock]
</description>
</method>
<method name="to_32">
<return type="int">
</return>
<description>
- Convert the color to a 32 its integer (each byte represents a RGBA).
+ Returns the color's 32-bit integer in ARGB format (each byte represents a component of the ARGB profile).
+ [codeblock]
+ var c = Color(1, .5, .2)
+ print(str(c.to_32())) # prints 4294934323
+ [/codeblock]
+
+ [i]This is same as [method to_ARGB32] but may be changed later to support RGBA format instead[/i].
</description>
</method>
<method name="to_ARGB32">
<return type="int">
</return>
<description>
- Convert color to ARGB32, more compatible with DirectX.
+ Returns the color's 32-bit integer in ARGB format (each byte represents a component of the ARGB profile). More compatible with DirectX.
+ [codeblock]
+ var c = Color(1, .5, .2)
+ print(str(c.to_32())) # prints 4294934323
+ [/codeblock]
</description>
</method>
<method name="to_html">
@@ -12312,7 +12485,13 @@
<argument index="0" name="with_alpha" type="bool" default="True">
</argument>
<description>
- Return the HTML hexadecimal color string.
+ Returns the color's HTML hexadecimal color string in ARGB format (ex: [code]ff34f822[/code]).
+ Optionally flag 'false' to not include alpha in hexadecimal string.
+ [codeblock]
+ var c = Color(1, 1, 1, .5)
+ var s1 = c.to_html() # Results "7fffffff"
+ var s2 = c.to_html(false) # Results 'ffffff'
+ [/codeblock]
</description>
</method>
</methods>
@@ -12494,6 +12673,12 @@
<argument index="0" name="color" type="Color">
</argument>
<description>
+ Set new color to ColorRect.
+
+ [codeblock]
+ var cr = get_node("colorrect_node")
+ cr.set_frame_color(Color(1, 0, 0, 1)) # Set color rect node to red
+ [/codeblock]
</description>
</method>
</methods>
@@ -12541,14 +12726,21 @@
</class>
<class name="ColorRect" inherits="Control" category="Core">
<brief_description>
+ Colored rect for canvas.
</brief_description>
<description>
+ An object that is represented on the canvas as a rect with color. [Color] is used to set or get color info for the rect.
</description>
<methods>
<method name="get_frame_color" qualifiers="const">
<return type="Color">
</return>
<description>
+ Return the color in RGBA format.
+ [codeblock]
+ var cr = get_node("colorrect_node")
+ var c = cr.get_frame_color() # Default color is white
+ [/codeblock]
</description>
</method>
<method name="set_frame_color">
@@ -12557,6 +12749,11 @@
<argument index="0" name="color" type="Color">
</argument>
<description>
+ Set new color to ColorRect.
+ [codeblock]
+ var cr = get_node("colorrect_node")
+ cr.set_frame_color(Color(1, 0, 0, 1)) # Set color rect node to red
+ [/codeblock]
</description>
</method>
</methods>
@@ -12856,23 +13053,23 @@
</class>
<class name="Control" inherits="CanvasItem" category="Core">
<brief_description>
- Control is the base node for all the GUI components.
+ Base node for all User Interface components.
</brief_description>
<description>
- Control is the base class Node for all the GUI components. Every GUI component inherits from it, directly or indirectly. In this way, sections of the scene tree made of contiguous control nodes, become user interfaces.
- Controls are relative to the parent position and size by using anchors and margins. This ensures that they can adapt easily in most situation to changing dialog and screen sizes. When more flexibility is desired, [Container] derived nodes can be used.
+ The base class Node for all User Interface components. Every UI node inherits from it. Any scene or portion of a scene tree composed of Control nodes is a User Interface.
+ Controls use anchors and margins to place themselves relative to their parent. They adapt automatically when their parent or the screen size changes. To build flexible UIs, use built-in [Container] nodes or create your own.
Anchors work by defining which margin do they follow, and a value relative to it. Allowed anchoring modes are ANCHOR_BEGIN, where the margin is relative to the top or left margins of the parent (in pixels), ANCHOR_END for the right and bottom margins of the parent and ANCHOR_RATIO, which is a ratio from 0 to 1 in the parent range.
- Input device events are first sent to the root controls via the [method Node._input], which distribute it through the tree, then delivers them to the adequate one (under cursor or keyboard focus based) by calling [method MainLoop._input_event]. There is no need to enable input processing on controls to receive such events. To ensure that no one else will receive the event (not even [method Node._unhandled_input]), the control can accept it by calling [method accept_event].
- Only one control can hold the keyboard focus (receiving keyboard events), for that the control must define the focus mode with [method set_focus_mode]. Focus is lost when another control gains it, or the current focus owner is hidden.
- It is sometimes desired for a control to ignore mouse/pointer events. This is often the case when placing other controls on top of a button, in such cases. Calling [method set_ignore_mouse] enables this function.
- Finally, controls are skinned according to a [Theme]. Setting a [Theme] on a control will propagate all the skinning down the tree. Optionally, skinning can be overridden per each control by calling the add_*_override functions, or from the editor.
+ Godot sends Input events to the root node first, via [method Node._input]. The method distributes it through the node tree and delivers the input events to the node under the mouse cursor or on focus with the keyboard. To do so, it calls [method MainLoop._input_event]. No need to enable [method Node.set_process_input] on Controls to receive input events. Call [method accept_event] to ensure no other node receives the event, not even [method Node._unhandled_input].
+ Only the one Control node in focus receives keyboard events. To do so, the Control must get the focus mode with [method set_focus_mode]. It loses focus when another Control gets it, or if the current Control in focus is hidden.
+ You'll sometimes want Controls to ignore mouse or touch events. For example, if you place an icon on top of a button. Call [method set_ignore_mouse] for that.
+ [Theme] resources change the Control's appearance. If you change the [Theme] on a parent Control node, it will propagate to all of its children. You can override parts of the theme on each Control with the add_*_override methods, like [method add_font_override]. You can also override the theme from the editor.
</description>
<methods>
<method name="_get_minimum_size" qualifiers="virtual">
<return type="Vector2">
</return>
<description>
- Return the minimum size this Control can shrink to. A control will never be displayed or resized smaller than its minimum size.
+ Returns the minimum size this Control can shrink to. A control will never be displayed or resized smaller than its minimum size.
</description>
</method>
<method name="_gui_input" qualifiers="virtual">
@@ -12887,7 +13084,7 @@
<return type="void">
</return>
<description>
- Handles the event, no other control will receive it and it will not be sent to nodes waiting on [method Node._unhandled_input] or [method Node._unhandled_key_input].
+ Marks the input event as handled. No other Control will receive it, and the input event will not propagate. Not even to nodes listening to [method Node._unhandled_input] or [method Node._unhandled_key_input].
</description>
</method>
<method name="add_color_override">
@@ -13742,12 +13939,12 @@
<signals>
<signal name="focus_entered">
<description>
- Emitted when keyboard focus is gained.
+ Emitted when the node gains keyboard focus.
</description>
</signal>
<signal name="focus_exited">
<description>
- Emitted when the keyboard focus is lost.
+ Emitted when the node loses keyboard focus.
</description>
</signal>
<signal name="gui_input">
@@ -13758,7 +13955,7 @@
</signal>
<signal name="minimum_size_changed">
<description>
- Emitted when the minimum size of the control changed.
+ Emitted when the node's minimum size changes.
</description>
</signal>
<signal name="modal_closed">
@@ -13767,22 +13964,22 @@
</signal>
<signal name="mouse_entered">
<description>
- Emitted when the mouse enters the control area.
+ Emitted when the mouse enters the control's area.
</description>
</signal>
<signal name="mouse_exited">
<description>
- Emitted when the mouse left the control area.
+ Emitted when the mouse leaves the control's area.
</description>
</signal>
<signal name="resized">
<description>
- Emitted when the control changed size.
+ Emitted when the control changes size.
</description>
</signal>
<signal name="size_flags_changed">
<description>
- Emitted when the size flags changed.
+ Emitted when the size flags change.
</description>
</signal>
</signals>
@@ -14093,8 +14290,10 @@
</class>
<class name="CubeMesh" inherits="PrimitiveMesh" category="Core">
<brief_description>
+ Generate an axis-aligned cuboid [PrimitiveMesh].
</brief_description>
<description>
+ Generate an axis-aligned cuboid [PrimitiveMesh].
</description>
<methods>
<method name="get_size" qualifiers="const">
@@ -14156,12 +14355,16 @@
</methods>
<members>
<member name="size" type="Vector3" setter="set_size" getter="get_size" brief="">
+ Size of the cuboid mesh. Defaults to (2, 2, 2).
</member>
<member name="subdivide_depth" type="int" setter="set_subdivide_depth" getter="get_subdivide_depth" brief="">
+ Number of extra edge loops inserted along the z-axis. Defaults to 0.
</member>
<member name="subdivide_height" type="int" setter="set_subdivide_height" getter="get_subdivide_height" brief="">
+ Number of extra edge loops inserted along the y-axis. Defaults to 0.
</member>
<member name="subdivide_width" type="int" setter="set_subdivide_width" getter="get_subdivide_width" brief="">
+ Number of extra edge loops inserted along the x-axis. Defaults to 0.
</member>
</members>
<constants>
@@ -14851,8 +15054,10 @@
</class>
<class name="CylinderMesh" inherits="PrimitiveMesh" category="Core">
<brief_description>
+ Class representing a cylindrical [PrimitiveMesh].
</brief_description>
<description>
+ Class representing a cylindrical [PrimitiveMesh].
</description>
<methods>
<method name="get_bottom_radius" qualifiers="const">
@@ -14928,14 +15133,19 @@
</methods>
<members>
<member name="bottom_radius" type="float" setter="set_bottom_radius" getter="get_bottom_radius" brief="">
+ Bottom radius of the cylinder. Defaults to 1.0.
</member>
<member name="height" type="float" setter="set_height" getter="get_height" brief="">
+ Full height of the cylinder. Defaults to 2.0.
</member>
<member name="radial_segments" type="int" setter="set_radial_segments" getter="get_radial_segments" brief="">
+ Number of radial segments on the cylinder. Defaults to 64.
</member>
<member name="rings" type="int" setter="set_rings" getter="get_rings" brief="">
+ Number of edge rings along the height of the cylinder. Defaults to 4.
</member>
<member name="top_radius" type="float" setter="set_top_radius" getter="get_top_radius" brief="">
+ Top radius of the cylinder. Defaults to 1.0.
</member>
</members>
<constants>
@@ -19137,6 +19347,12 @@
<description>
</description>
</method>
+ <method name="is_singleton_gdnative" qualifiers="const">
+ <return type="bool">
+ </return>
+ <description>
+ </description>
+ </method>
<method name="set_library_path">
<return type="void">
</return>
@@ -19147,26 +19363,49 @@
<description>
</description>
</method>
+ <method name="set_singleton_gdnative">
+ <return type="void">
+ </return>
+ <argument index="0" name="singleton" type="bool">
+ </argument>
+ <description>
+ </description>
+ </method>
</methods>
+ <members>
+ <member name="singleton_gdnative" type="bool" setter="set_singleton_gdnative" getter="is_singleton_gdnative" brief="">
+ </member>
+ </members>
<constants>
</constants>
</class>
<class name="GDScript" inherits="Script" category="Core">
<brief_description>
+ A script implemented in the GDScript programming language.
</brief_description>
<description>
+ A script implemented in the GDScript programming language. The script exends the functionality of all objects that instance it.
+ [method new] creates a new instance of the script. [method Object.set_script] extends an existing object, if that object's class matches one of the script's base classes.
</description>
<methods>
<method name="get_as_byte_code" qualifiers="const">
<return type="PoolByteArray">
</return>
<description>
+ Returns byte code for the script source code.
</description>
</method>
<method name="new" qualifiers="vararg">
<return type="Object">
</return>
<description>
+ Returns a new instance of the script.
+ For example:
+ [codeblock]
+ var MyClass = load("myclass.gd")
+ var instance = MyClass.new()
+ assert(instance.get_script() == MyClass)
+ [/codeblock]
</description>
</method>
</methods>
@@ -20365,8 +20604,10 @@
</class>
<class name="GradientTexture" inherits="Texture" category="Core">
<brief_description>
+ Gradient filled texture.
</brief_description>
<description>
+ Uses a [Gradient] to fill the texture data, the gradient will be filled from left to right using colors obtained from the gradient, this means that the texture does not necessarily represent an exact copy of the gradient, but instead an interpolation of samples obtained from the gradient at fixed steps (see [method set_width]).
</description>
<methods>
<method name="get_gradient" qualifiers="const">
@@ -20394,8 +20635,10 @@
</methods>
<members>
<member name="gradient" type="Gradient" setter="set_gradient" getter="get_gradient" brief="">
+ The [Gradient] that will be used to fill the texture.
</member>
<member name="width" type="int" setter="set_width" getter="get_width" brief="">
+ The number of color samples that will be obtained from the [Gradient].
</member>
</members>
<constants>
@@ -20807,7 +21050,7 @@
<description>
</description>
</method>
- <method name="is_resizeable" qualifiers="const">
+ <method name="is_resizable" qualifiers="const">
<return type="bool">
</return>
<description>
@@ -20862,10 +21105,10 @@
<description>
</description>
</method>
- <method name="set_resizeable">
+ <method name="set_resizable">
<return type="void">
</return>
- <argument index="0" name="resizeable" type="bool">
+ <argument index="0" name="resizable" type="bool">
</argument>
<description>
</description>
@@ -20922,7 +21165,7 @@
</method>
</methods>
<members>
- <member name="resizeable" type="bool" setter="set_resizeable" getter="is_resizeable" brief="">
+ <member name="resizable" type="bool" setter="set_resizable" getter="is_resizable" brief="">
</member>
<member name="show_close" type="bool" setter="set_show_close_button" getter="is_close_button_visible" brief="">
</member>
@@ -22009,7 +22252,7 @@
IP Protocol support functions.
</brief_description>
<description>
- IP contains some support functions for the IPv4 protocol. TCP/IP support is in different classes (see [StreamPeerTCP] and [TCP_Server]). IP provides hostname resolution support, both blocking and threaded.
+ IP contains support functions for the IPv4 protocol. TCP/IP support is in different classes (see [StreamPeerTCP] and [TCP_Server]). IP provides hostname resolution support, both blocking and threaded.
</description>
<methods>
<method name="clear_cache">
@@ -22018,6 +22261,7 @@
<argument index="0" name="hostname" type="String" default="&quot;&quot;">
</argument>
<description>
+ Removes all of a "hostname"'s cached references. If no "hostname" is given then all cached IP addresses are removed.
</description>
</method>
<method name="erase_resolve_item">
@@ -22026,13 +22270,14 @@
<argument index="0" name="id" type="int">
</argument>
<description>
- Erase a queue ID, removing it from the queue if needed. This should be used after a queue is completed to free it and enable more queries to happen.
+ Removes a given item "id" from the queue. This should be used to free a queue after it has completed to enable more queries to happen.
</description>
</method>
- <method name="get_local_addresses" qualifiers="const">
+ <method name="get_local_addresses" qualifiers="const">
<return type="Array">
</return>
<description>
+ Returns all of the user's current IPv4 and IPv6 addresses as an array.
</description>
</method>
<method name="get_resolve_item_address" qualifiers="const">
@@ -22041,7 +22286,7 @@
<argument index="0" name="id" type="int">
</argument>
<description>
- Return a resolved item address, or an empty string if an error happened or resolution didn't happen yet (see [method get_resolve_item_status]).
+ Returns a queued hostname's IP address, given its queue "id". Returns an empty string on error or if resolution hasn't happened yet (see [method get_resolve_item_status]).
</description>
</method>
<method name="get_resolve_item_status" qualifiers="const">
@@ -22050,7 +22295,7 @@
<argument index="0" name="id" type="int">
</argument>
<description>
- Return the status of hostname queued for resolving, given its queue ID. Returned status can be any of the RESOLVER_STATUS_* enumeration.
+ Returns a queued hostname's status as a RESOLVER_STATUS_* constant, given its queue "id".
</description>
</method>
<method name="resolve_hostname">
@@ -22061,7 +22306,7 @@
<argument index="1" name="ip_type" type="int" enum="IP.Type" default="3">
</argument>
<description>
- Resolve a given hostname, blocking. Resolved hostname is returned as an IPv4 or IPv6 depending on "ip_type".
+ Returns a given hostname's IPv4 or IPv6 address when resolved (blocking-type method). The address type returned depends on the TYPE_* constant given as "ip_type".
</description>
</method>
<method name="resolve_hostname_queue_item">
@@ -22072,7 +22317,7 @@
<argument index="1" name="ip_type" type="int" enum="IP.Type" default="3">
</argument>
<description>
- Create a queue item for resolving a given hostname to an IPv4 or IPv6 depending on "ip_type". The queue ID is returned, or RESOLVER_INVALID_ID on error.
+ Creates a queue item to resolve a hostname to an IPv4 or IPv6 address depending on the TYPE_* constant given as "ip_type". Returns the queue ID if successful, or RESOLVER_INVALID_ID on error.
</description>
</method>
</methods>
@@ -23153,6 +23398,7 @@
</class>
<class name="InputEvent" inherits="Resource" category="Core">
<brief_description>
+ Generic input event
</brief_description>
<description>
</description>
@@ -23163,24 +23409,28 @@
<argument index="0" name="event" type="InputEvent">
</argument>
<description>
+ Returns true if this input event matches the event passed.
</description>
</method>
<method name="as_text" qualifiers="const">
<return type="String">
</return>
<description>
+ Returns a [String] representation of the event.
</description>
</method>
<method name="get_device" qualifiers="const">
<return type="int">
</return>
<description>
+ Returns the id of the device that generated the event.
</description>
</method>
<method name="get_id" qualifiers="const">
<return type="int">
</return>
<description>
+ Returns the id of the event.
</description>
</method>
<method name="is_action" qualifiers="const">
@@ -23189,7 +23439,7 @@
<argument index="0" name="action" type="String">
</argument>
<description>
- Return if this input event matches a pre-defined action, no matter the type.
+ Returns true if this input event matches a pre-defined action, no matter the type.
</description>
</method>
<method name="is_action_pressed" qualifiers="const">
@@ -23198,7 +23448,7 @@
<argument index="0" name="action" type="String">
</argument>
<description>
- Return whether the given action is being pressed (and is not an echo event for KEY events). Not relevant for the event types MOUSE_MOTION, SCREEN_DRAG and NONE.
+ Returns true if the given action is being pressed (and is not an echo event for KEY events). Not relevant for the event types MOUSE_MOTION, SCREEN_DRAG and NONE.
</description>
</method>
<method name="is_action_released" qualifiers="const">
@@ -23207,7 +23457,7 @@
<argument index="0" name="action" type="String">
</argument>
<description>
- Return whether the given action is released (i.e. not pressed). Not relevant for the event types MOUSE_MOTION, SCREEN_DRAG and NONE.
+ Returns true if the given action is released (i.e. not pressed). Not relevant for the event types MOUSE_MOTION, SCREEN_DRAG and NONE.
</description>
</method>
<method name="is_action_type" qualifiers="const">
@@ -23220,14 +23470,14 @@
<return type="bool">
</return>
<description>
- Return if this input event is an echo event (only for events of type KEY, it will return false for other types).
+ Returns true if this input event is an echo event (only for events of type KEY, it will return false for other types).
</description>
</method>
<method name="is_pressed" qualifiers="const">
<return type="bool">
</return>
<description>
- Return if this input event is pressed. Not relevant for the event types MOUSE_MOTION, SCREEN_DRAG and NONE.
+ Returns true if this input event is pressed. Not relevant for the event types MOUSE_MOTION, SCREEN_DRAG and NONE.
</description>
</method>
<method name="set_device">
@@ -24844,108 +25094,28 @@
Kinematic Characters: KinematicBody also has an api for moving objects (the [method move] method) while performing collision tests. This makes them really useful to implement characters that collide against a world, but that don't require advanced physics.
</description>
<methods>
- <method name="get_collision_collider" qualifiers="const">
- <return type="Object">
- </return>
- <argument index="0" name="collision" type="int">
- </argument>
- <description>
- </description>
- </method>
- <method name="get_collision_collider_id" qualifiers="const">
- <return type="int">
- </return>
- <argument index="0" name="collision" type="int">
- </argument>
- <description>
- </description>
- </method>
- <method name="get_collision_collider_metadata" qualifiers="const">
- <return type="Variant">
- </return>
- <argument index="0" name="collision" type="int">
- </argument>
- <description>
- </description>
- </method>
- <method name="get_collision_collider_shape" qualifiers="const">
- <return type="Object">
- </return>
- <argument index="0" name="collision" type="int">
- </argument>
- <description>
- </description>
- </method>
- <method name="get_collision_collider_shape_index" qualifiers="const">
- <return type="int">
- </return>
- <argument index="0" name="collision" type="int">
- </argument>
- <description>
- </description>
- </method>
- <method name="get_collision_collider_velocity" qualifiers="const">
- <return type="Vector3">
- </return>
- <argument index="0" name="collision" type="int">
- </argument>
- <description>
- </description>
- </method>
- <method name="get_collision_count" qualifiers="const">
- <return type="int">
- </return>
- <description>
- </description>
- </method>
- <method name="get_collision_local_shape" qualifiers="const">
- <return type="Object">
- </return>
- <argument index="0" name="collision" type="int">
- </argument>
- <description>
- </description>
- </method>
- <method name="get_collision_normal" qualifiers="const">
+ <method name="get_floor_velocity" qualifiers="const">
<return type="Vector3">
</return>
- <argument index="0" name="collision" type="int">
- </argument>
<description>
</description>
</method>
- <method name="get_collision_position" qualifiers="const">
- <return type="Vector3">
- </return>
- <argument index="0" name="collision" type="int">
- </argument>
- <description>
- </description>
- </method>
- <method name="get_collision_remainder" qualifiers="const">
- <return type="Vector3">
+ <method name="get_safe_margin" qualifiers="const">
+ <return type="float">
</return>
- <argument index="0" name="collision" type="int">
- </argument>
<description>
</description>
</method>
- <method name="get_collision_travel" qualifiers="const">
- <return type="Vector3">
+ <method name="get_slide_collision">
+ <return type="KinematicCollision">
</return>
- <argument index="0" name="collision" type="int">
+ <argument index="0" name="slide_idx" type="int">
</argument>
<description>
</description>
</method>
- <method name="get_floor_velocity" qualifiers="const">
- <return type="Vector3">
- </return>
- <description>
- </description>
- </method>
- <method name="get_safe_margin" qualifiers="const">
- <return type="float">
+ <method name="get_slide_count" qualifiers="const">
+ <return type="int">
</return>
<description>
</description>
@@ -24968,22 +25138,12 @@
<description>
</description>
</method>
- <method name="move">
- <return type="Dictionary">
+ <method name="move_and_collide">
+ <return type="KinematicCollision">
</return>
<argument index="0" name="rel_vec" type="Vector3">
</argument>
<description>
- Move the body in the given direction, stopping if there is an obstacle. If as a result of a movement there will be any collision then informations about this collision will be in returned dictionary. Dictionary will contains those keys:
- - "position" - collision position
- - "normal" - collision normal
- - "local_shape" - id of this kinematic body shape that took part in a collision
- - "travel" - traveled movement before being stopped
- - "remainder" - remaining movement before being stopped
- - "collider_id" - id of the collider, it can be used when dealing with [PhysicsServer]
- - "collider" - colliding body
- - "collider_shape_index" - index of the colliding shape, inside collider body "collider_metadata"
- If the body did not intersect anything, then an empty dictionary (dir.empty()==true) is returned instead. Please note that this method is less user friendly than [method move_and_slide]. If you don't want to program each edge case manually, then it's recommended to use [method move_and_slide] instead.
</description>
</method>
<method name="move_and_slide">
@@ -24995,7 +25155,7 @@
</argument>
<argument index="2" name="slope_stop_min_velocity" type="float" default="0.05">
</argument>
- <argument index="3" name="max_bounces" type="int" default="4">
+ <argument index="3" name="max_slides" type="int" default="4">
</argument>
<argument index="4" name="floor_max_angle" type="float" default="0.785398">
</argument>
@@ -25224,6 +25384,106 @@
<constants>
</constants>
</class>
+<class name="KinematicCollision" inherits="Reference" category="Core">
+ <brief_description>
+ </brief_description>
+ <description>
+ </description>
+ <methods>
+ <method name="get_collider" qualifiers="const">
+ <return type="Object">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="get_collider_id" qualifiers="const">
+ <return type="int">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="get_collider_metadata" qualifiers="const">
+ <return type="Variant">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="get_collider_shape" qualifiers="const">
+ <return type="Object">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="get_collider_shape_index" qualifiers="const">
+ <return type="int">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="get_collider_velocity" qualifiers="const">
+ <return type="Vector3">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="get_local_shape" qualifiers="const">
+ <return type="Object">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="get_normal" qualifiers="const">
+ <return type="Vector3">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="get_position" qualifiers="const">
+ <return type="Vector3">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="get_remainder" qualifiers="const">
+ <return type="Vector3">
+ </return>
+ <description>
+ </description>
+ </method>
+ <method name="get_travel" qualifiers="const">
+ <return type="Vector3">
+ </return>
+ <description>
+ </description>
+ </method>
+ </methods>
+ <members>
+ <member name="collider" type="Object" setter="" getter="get_collider" brief="">
+ </member>
+ <member name="collider_id" type="int" setter="" getter="get_collider_id" brief="">
+ </member>
+ <member name="collider_metadata" type="Variant" setter="" getter="get_collider_metadata" brief="">
+ </member>
+ <member name="collider_shape" type="Object" setter="" getter="get_collider_shape" brief="">
+ </member>
+ <member name="collider_shape_index" type="int" setter="" getter="get_collider_shape_index" brief="">
+ </member>
+ <member name="collider_velocity" type="Vector3" setter="" getter="get_collider_velocity" brief="">
+ </member>
+ <member name="local_shape" type="Object" setter="" getter="get_local_shape" brief="">
+ </member>
+ <member name="normal" type="Vector3" setter="" getter="get_normal" brief="">
+ </member>
+ <member name="position" type="Vector3" setter="" getter="get_position" brief="">
+ </member>
+ <member name="remainder" type="Vector3" setter="" getter="get_remainder" brief="">
+ </member>
+ <member name="travel" type="Vector3" setter="" getter="get_travel" brief="">
+ </member>
+ </members>
+ <constants>
+ </constants>
+</class>
<class name="Label" inherits="Control" category="Core">
<brief_description>
Control that displays formatted text.
@@ -26154,10 +26414,10 @@
</class>
<class name="LightOccluder2D" inherits="Node2D" category="Core">
<brief_description>
- Occludes light cast by a Light2D, thus casting shadows.
+ Occludes light cast by a Light2D, casting shadows.
</brief_description>
<description>
- Occludes light cast by a Light2D, thus casting shadows. The LightOccluder2D must be provided with a shape (see OccluderPolygon2D) that allows the shadow to be computed. This shape affects the resulting shadow, while the shape of the representating asset shadowed does not actually affect shadows.
+ Occludes light cast by a Light2D, casting shadows. The LightOccluder2D must be provided with an [OccluderPolygon2D] in order for the shadow to be computed.
</description>
<methods>
<method name="get_occluder_light_mask" qualifiers="const">
@@ -26195,8 +26455,10 @@
</methods>
<members>
<member name="light_mask" type="int" setter="set_occluder_light_mask" getter="get_occluder_light_mask" brief="">
+ The LightOccluder2D's light mask. The LightOccluder2D will cast shadows only from Light2D(s) that have the same light mask(s).
</member>
<member name="occluder" type="OccluderPolygon2D" setter="set_occluder_polygon" getter="get_occluder_polygon" brief="">
+ The [OccluderPolygon2D] used to compute the shadow.
</member>
</members>
<constants>
@@ -26204,8 +26466,10 @@
</class>
<class name="Line2D" inherits="Node2D" category="Core">
<brief_description>
+ A 2D line.
</brief_description>
<description>
+ A line through several points in 2D space.
</description>
<methods>
<method name="add_point">
@@ -26214,6 +26478,7 @@
<argument index="0" name="pos" type="Vector2">
</argument>
<description>
+ Add a point at the x/y position in the supplied [Vector2]
</description>
</method>
<method name="get_begin_cap_mode" qualifiers="const">
@@ -26302,6 +26567,7 @@
<argument index="0" name="i" type="int">
</argument>
<description>
+ Remove the point at index 'i' from the line.
</description>
</method>
<method name="set_begin_cap_mode">
@@ -26506,6 +26772,7 @@
<return type="int" enum="LineEdit.Align">
</return>
<description>
+ Return the align mode of the [LineEdit].
</description>
</method>
<method name="get_cursor_pos" qualifiers="const">
@@ -26532,18 +26799,21 @@
<return type="PopupMenu">
</return>
<description>
+ Return the [PopupMenu] of this [LineEdit].
</description>
</method>
<method name="get_placeholder" qualifiers="const">
<return type="String">
</return>
<description>
+ Return the placeholder text.
</description>
</method>
<method name="get_placeholder_alpha" qualifiers="const">
<return type="float">
</return>
<description>
+ Return transparency of the placeholder text.
</description>
</method>
<method name="get_text" qualifiers="const">
@@ -26573,6 +26843,7 @@
<argument index="0" name="option" type="int">
</argument>
<description>
+ Execute a given action as defined in the MENU_* enum.
</description>
</method>
<method name="select">
@@ -26583,6 +26854,12 @@
<argument index="1" name="to" type="int" default="-1">
</argument>
<description>
+ Select the text inside [LineEdit] by the given character positions. [code]from[/code] is default to the beginning. [code]to[/code] is default to the end.
+ [codeblock]
+ select() # select all
+ select(5) # select from the fifth character to the end.
+ select(2, 5) # select from the second to the fifth character.
+ [/codeblock]
</description>
</method>
<method name="select_all">
@@ -26598,6 +26875,7 @@
<argument index="0" name="align" type="int" enum="LineEdit.Align">
</argument>
<description>
+ Set text alignment of the [LineEdit].
</description>
</method>
<method name="set_cursor_pos">
@@ -26641,6 +26919,7 @@
<argument index="0" name="text" type="String">
</argument>
<description>
+ Set the placeholder text.
</description>
</method>
<method name="set_placeholder_alpha">
@@ -26649,6 +26928,7 @@
<argument index="0" name="alpha" type="float">
</argument>
<description>
+ Set transparency of the placeholder text.
</description>
</method>
<method name="set_secret">
@@ -26712,24 +26992,34 @@
</signals>
<constants>
<constant name="ALIGN_LEFT" value="0">
+ Align left.
</constant>
<constant name="ALIGN_CENTER" value="1">
+ Align center.
</constant>
<constant name="ALIGN_RIGHT" value="2">
+ Align right.
</constant>
<constant name="ALIGN_FILL" value="3">
+ Align fill.
</constant>
<constant name="MENU_CUT" value="0">
+ Cut (Copy and clear).
</constant>
<constant name="MENU_COPY" value="1">
+ Copy the selected text.
</constant>
<constant name="MENU_PASTE" value="2">
+ Paste the clipboard text over the selected text.
</constant>
<constant name="MENU_CLEAR" value="3">
+ Clear the text.
</constant>
<constant name="MENU_SELECT_ALL" value="4">
+ Select all text.
</constant>
<constant name="MENU_UNDO" value="5">
+ Undo an action.
</constant>
<constant name="MENU_MAX" value="6">
</constant>
@@ -26932,6 +27222,7 @@
<return type="void">
</return>
<description>
+ Called before the program exits.
</description>
</method>
<method name="_idle" qualifiers="virtual">
@@ -26940,12 +27231,14 @@
<argument index="0" name="delta" type="float">
</argument>
<description>
+ Called each idle frame with time since last call as an only argument.
</description>
</method>
<method name="_initialize" qualifiers="virtual">
<return type="void">
</return>
<description>
+ Called once during initialization.
</description>
</method>
<method name="_input_event" qualifiers="virtual">
@@ -27072,6 +27365,7 @@
<argument index="0" name="base64_str" type="String">
</argument>
<description>
+ Return [PoolByteArray] of a given base64 encoded String.
</description>
</method>
<method name="base64_to_utf8">
@@ -27080,6 +27374,7 @@
<argument index="0" name="base64_str" type="String">
</argument>
<description>
+ Return utf8 String of a given base64 encoded String.
</description>
</method>
<method name="base64_to_variant">
@@ -27088,6 +27383,7 @@
<argument index="0" name="base64_str" type="String">
</argument>
<description>
+ Return [Variant] of a given base64 encoded String.
</description>
</method>
<method name="raw_to_base64">
@@ -27096,6 +27392,7 @@
<argument index="0" name="array" type="PoolByteArray">
</argument>
<description>
+ Return base64 encoded String of a given [PoolByteArray].
</description>
</method>
<method name="utf8_to_base64">
@@ -27104,6 +27401,7 @@
<argument index="0" name="utf8_str" type="String">
</argument>
<description>
+ Return base64 encoded String of a given utf8 String.
</description>
</method>
<method name="variant_to_base64">
@@ -27112,6 +27410,7 @@
<argument index="0" name="variant" type="Variant">
</argument>
<description>
+ Return base64 encoded String of a given [Variant].
</description>
</method>
</methods>
@@ -27191,6 +27490,7 @@
<signals>
<signal name="about_to_show">
<description>
+ Emitted when [PopupMenu] of this MenuButton is about to show.
</description>
</signal>
</signals>
@@ -27727,6 +28027,14 @@
Create a new item in the library, supplied an id.
</description>
</method>
+ <method name="find_item_by_name" qualifiers="const">
+ <return type="int">
+ </return>
+ <argument index="0" name="name" type="String">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="get_item_list" qualifiers="const">
<return type="PoolIntArray">
</return>
@@ -28585,6 +28893,7 @@
<argument index="3" name="out_bandwidth" type="int" default="0">
</argument>
<description>
+ Create client that connects to a server at address [code]ip[/code] using specified [code]port[/code].
</description>
</method>
<method name="create_server">
@@ -28599,6 +28908,7 @@
<argument index="3" name="out_bandwidth" type="int" default="0">
</argument>
<description>
+ Create server that listens to connections via [code]port[/code].
</description>
</method>
<method name="get_compression_mode" qualifiers="const">
@@ -28665,6 +28975,7 @@
<return type="bool">
</return>
<description>
+ Return whether this [NetworkedMultiplayerPeer] is refusing new connections.
</description>
</method>
<method name="poll">
@@ -28679,6 +28990,7 @@
<argument index="0" name="enable" type="bool">
</argument>
<description>
+ If [code]endable[/code] is true, this [NetworkedMultiplayerPeer] will refuse new connections.
</description>
</method>
<method name="set_target_peer">
@@ -28701,26 +29013,31 @@
<signals>
<signal name="connection_failed">
<description>
+ Emitted when failed to connect to server.
</description>
</signal>
<signal name="connection_succeeded">
<description>
+ Emitted when successfully connected to server.
</description>
</signal>
<signal name="peer_connected">
<argument index="0" name="id" type="int">
</argument>
<description>
+ Emitted by the server when a client is connected.
</description>
</signal>
<signal name="peer_disconnected">
<argument index="0" name="id" type="int">
</argument>
<description>
+ Emitted by the server when a client is disconnected.
</description>
</signal>
<signal name="server_disconnected">
<description>
+ Emitted by clients when server is disconnected.
</description>
</signal>
</signals>
@@ -29089,6 +29406,7 @@
<argument index="0" name="event" type="InputEvent">
</argument>
<description>
+ Called when there is a change to input devices. Propagated through the node tree until a Node consumes it.
</description>
</method>
<method name="_process" qualifiers="virtual">
@@ -29116,6 +29434,7 @@
<argument index="0" name="event" type="InputEvent">
</argument>
<description>
+ Propagated to all nodes when the previous InputEvent is not consumed by any nodes.
</description>
</method>
<method name="_unhandled_key_input" qualifiers="virtual">
@@ -29313,12 +29632,14 @@
<return type="int" enum="Node.PauseMode">
</return>
<description>
+ Return the pause mode (PAUSE_MODE_*) of this Node.
</description>
</method>
<method name="get_position_in_parent" qualifiers="const">
<return type="int">
</return>
<description>
+ Return the order in the node tree branch, i.e. if called by the first child Node, return 0.
</description>
</method>
<method name="get_process_delta_time" qualifiers="const">
@@ -29338,6 +29659,7 @@
<return type="SceneTree">
</return>
<description>
+ Return a [SceneTree] that this node is inside.
</description>
</method>
<method name="get_viewport" qualifiers="const">
@@ -29352,6 +29674,7 @@
<argument index="0" name="path" type="NodePath">
</argument>
<description>
+ Return whether the node that a given [NodePath] points too exists.
</description>
</method>
<method name="has_node_and_resource" qualifiers="const">
@@ -29405,12 +29728,14 @@
<argument index="0" name="group" type="String">
</argument>
<description>
+ Return whether this Node is in the specified group.
</description>
</method>
<method name="is_inside_tree" qualifiers="const">
<return type="bool">
</return>
<description>
+ Return whether this Node is inside a [SceneTree].
</description>
</method>
<method name="is_network_master" qualifiers="const">
@@ -29502,6 +29827,7 @@
<return type="void">
</return>
<description>
+ Queues a node for deletion at the end of the current frame. When deleted, all of its children nodes will be deleted as well. This method ensures it's safe to delete the node, contrary to [method Object.free]. Use [method Object.is_queued_for_deletion] to know whether a node will be deleted at the end of the frame.
</description>
</method>
<method name="raise">
@@ -29551,6 +29877,7 @@
<return type="void">
</return>
<description>
+ Request that [code]_ready[/code] be called again.
</description>
</method>
<method name="rpc" qualifiers="vararg">
@@ -29731,6 +30058,7 @@
<argument index="0" name="mode" type="int" enum="Node.PauseMode">
</argument>
<description>
+ Set pause mode (PAUSE_MODE_*) of this Node.
</description>
</method>
<method name="set_process">
@@ -29801,10 +30129,12 @@
</signal>
<signal name="tree_entered">
<description>
+ Emitted when Node enters the tree.
</description>
</signal>
<signal name="tree_exited">
<description>
+ Emitted when Node exits the tree.
</description>
</signal>
</signals>
@@ -29849,18 +30179,25 @@
<constant name="RPC_MODE_DISABLED" value="0">
</constant>
<constant name="RPC_MODE_REMOTE" value="1">
+ Call a method remotely.
</constant>
<constant name="RPC_MODE_SYNC" value="2">
+ Call a method both remotely and locally.
</constant>
<constant name="RPC_MODE_MASTER" value="3">
+ Call a method if the Node is Master.
</constant>
<constant name="RPC_MODE_SLAVE" value="4">
+ Call a method if the Node is Slave.
</constant>
<constant name="PAUSE_MODE_INHERIT" value="0">
+ Inherits pause mode from parent. For root node, it is equivalent to PAUSE_MODE_STOP.
</constant>
<constant name="PAUSE_MODE_STOP" value="1">
+ Stop processing when SceneTree is paused.
</constant>
<constant name="PAUSE_MODE_PROCESS" value="2">
+ Continue to process regardless of SceneTree pause state.
</constant>
<constant name="DUPLICATE_SIGNALS" value="1">
</constant>
@@ -37842,8 +38179,10 @@
</class>
<class name="PlaneMesh" inherits="PrimitiveMesh" category="Core">
<brief_description>
+ Class representing a planar [PrimitiveMesh].
</brief_description>
<description>
+ Class representing a planar [PrimitiveMesh]. This flat mesh does not have a thickness.
</description>
<methods>
<method name="get_size" qualifiers="const">
@@ -37891,10 +38230,13 @@
</methods>
<members>
<member name="size" type="Vector2" setter="set_size" getter="get_size" brief="">
+ Size of the generated plane. Defaults to (2.0, 2.0).
</member>
<member name="subdivide_depth" type="int" setter="set_subdivide_depth" getter="get_subdivide_depth" brief="">
+ Number of subdivision along the z-axis. Defaults to 0.
</member>
<member name="subdivide_width" type="int" setter="set_subdivide_width" getter="get_subdivide_width" brief="">
+ Number of subdivision along the x-axis. Defaults to 0.
</member>
</members>
<constants>
@@ -39552,8 +39894,10 @@
</class>
<class name="PrimitiveMesh" inherits="Mesh" category="Core">
<brief_description>
+ Base class for all primitive meshes. Handles applying a [Material] to a primitive mesh.
</brief_description>
<description>
+ Base class for all primitive meshes. Handles applying a [Material] to a primitive mesh.
</description>
<methods>
<method name="get_material" qualifiers="const">
@@ -39573,6 +39917,7 @@
</methods>
<members>
<member name="material" type="Material" setter="set_material" getter="get_material" brief="">
+ The current [Material] of the primitive mesh.
</member>
</members>
<constants>
@@ -39580,8 +39925,10 @@
</class>
<class name="PrismMesh" inherits="PrimitiveMesh" category="Core">
<brief_description>
+ Class representing a prism-shaped [PrimitiveMesh].
</brief_description>
<description>
+ Class representing a prism-shaped [PrimitiveMesh].
</description>
<methods>
<method name="get_left_to_right" qualifiers="const">
@@ -39657,14 +40004,19 @@
</methods>
<members>
<member name="left_to_right" type="float" setter="set_left_to_right" getter="get_left_to_right" brief="">
+ Displacement of of the upper edge along the x-axis. 0.0 positions edge straight above the bottome left edge. Defaults to 0.5 (positioned on the midpoint).
</member>
<member name="size" type="Vector3" setter="set_size" getter="get_size" brief="">
+ Size of the prism. Defaults to (2.0, 2.0, 2.0).
</member>
<member name="subdivide_depth" type="int" setter="set_subdivide_depth" getter="get_subdivide_depth" brief="">
+ Number of added edge loops along the z-axis. Defaults to 0.
</member>
<member name="subdivide_height" type="int" setter="set_subdivide_height" getter="get_subdivide_height" brief="">
+ Number of added edge loops along the y-axis. Defaults to 0.
</member>
<member name="subdivide_width" type="int" setter="set_subdivide_width" getter="get_subdivide_width" brief="">
+ Number of added edge loops along the x-axis. Defaults to 0.
</member>
</members>
<constants>
@@ -40214,8 +40566,10 @@
</class>
<class name="QuadMesh" inherits="PrimitiveMesh" category="Core">
<brief_description>
+ Class representing a square mesh.
</brief_description>
<description>
+ Class representing a square mesh with size (2,2,0). Consider using a [PlaneMesh] if you require a differently sized plane.
</description>
<methods>
</methods>
@@ -40575,11 +40929,11 @@
Query the closest object intersecting a ray.
</brief_description>
<description>
- A RayCast represents a line from its origin to its destination position [code]cast_to[/code], it is used to query the 3D space in order to find the closest object intersecting with the ray.
+ A RayCast represents a line from its origin to its destination position, [code]cast_to[/code]. It is used to query the 3D space in order to find the closest object along the path of the ray.
- RayCast can ignore some objects by adding them to the exception list via [code]add_exception[/code], setting proper filtering with layers, or by filtering object types with type masks.
+ RayCast can ignore some objects by adding them to the exception list via [code]add_exception[/code], by setting proper filtering with collision layers, or by filtering object types with type masks.
- Only enabled raycasts will be able to query the space and report collisions!
+ Only enabled raycasts will be able to query the space and report collisions.
RayCast calculates intersection every fixed frame (see [Node]), and the result is cached so it can be used later until the next frame. If multiple queries are required between fixed frames (or during the same frame) use [method force_raycast_update] after adjusting the raycast.
</description>
@@ -40590,7 +40944,7 @@
<argument index="0" name="node" type="Object">
</argument>
<description>
- Adds a collision exception so the ray does not report collisions with the specified [code]node[/code].
+ Adds a collision exception so the ray does not report collisions with the specified node.
</description>
</method>
<method name="add_exception_rid">
@@ -40599,20 +40953,22 @@
<argument index="0" name="rid" type="RID">
</argument>
<description>
+ Adds a collision exception so the ray does not report collisions with the specified [RID].
</description>
</method>
<method name="clear_exceptions">
<return type="void">
</return>
<description>
- Removes all collision exception for this ray.
+ Removes all collision exceptions for this ray.
</description>
</method>
<method name="force_raycast_update">
<return type="void">
</return>
<description>
- Updates the collision information in case if this object's properties changed during the current frame (for example position, rotation or the cast_point). Note, [code]set_enabled[/code] is not required for this to work.
+ Updates the collision information for the ray.
+ Use this method to update the collision information immediately instead of waiting for the next [code]_fixed_process[/code] call, for example if the ray or its parent has changed state. Note: [code]enabled == true[/code] is not required for this to work.
</description>
</method>
<method name="get_cast_to" qualifiers="const">
@@ -40626,14 +40982,24 @@
<return type="Object">
</return>
<description>
- Return the closest object the ray is pointing to. Note that this does not consider the length of the vector, so you must also use [method is_colliding] to check if the object returned is actually colliding with the ray.
+ Return the closest object the ray is pointing to. Note that this does not consider the length of the ray, so you must also use [method is_colliding] to check if the object returned is actually colliding with the ray.
+ Example:
+ [codeblock]
+ if RayCast.is_colliding():
+ var collider = RayCast.get_collider()
+ [/codeblock]
</description>
</method>
<method name="get_collider_shape" qualifiers="const">
<return type="int">
</return>
<description>
- Returns the collision shape of the closest object the ray is pointing to.
+ Returns the collision shape of the closest object the ray is pointing to. Note that this does not consider the length of the ray, so you must also use [method is_colliding] to check if the object returned is actually colliding with the ray.
+ Example:
+ [codeblock]
+ if RayCast.is_colliding():
+ var shape = RayCast.get_collider_shape()
+ [/codeblock]
</description>
</method>
<method name="get_collision_layer" qualifiers="const">
@@ -40647,14 +41013,14 @@
<return type="Vector3">
</return>
<description>
- Returns the normal of the intersecting object shape face containing the collision point.
+ Returns the normal of the intersecting object's shape at the collision point.
</description>
</method>
<method name="get_collision_point" qualifiers="const">
<return type="Vector3">
</return>
<description>
- Returns collision point. This point is in [b]global[/b] coordinate system.
+ Returns the collision point at which the ray intersects the closest object. Note: this point is in the [b]global[/b] coordinate system.
</description>
</method>
<method name="get_type_mask" qualifiers="const">
@@ -40675,7 +41041,7 @@
<return type="bool">
</return>
<description>
- Returns whether this raycast is enabled or not.
+ Returns whether the ray is enabled or not.
</description>
</method>
<method name="remove_exception">
@@ -40684,7 +41050,7 @@
<argument index="0" name="node" type="Object">
</argument>
<description>
- Removes a collision exception so the ray does report collisions with the specified [code]node[/code].
+ Removes a collision exception so the ray does report collisions with the specified node.
</description>
</method>
<method name="remove_exception_rid">
@@ -40693,6 +41059,7 @@
<argument index="0" name="rid" type="RID">
</argument>
<description>
+ Removes a collision exception so the ray does report collisions with the specified [RID].
</description>
</method>
<method name="set_cast_to">
@@ -40701,7 +41068,7 @@
<argument index="0" name="local_point" type="Vector3">
</argument>
<description>
- Sets to which point ray should be casted. This point is in [b]local[/b] coordinate system.
+ Sets the ray destination point, so that the ray will test from the ray's origin to [code]local_point[/code].
</description>
</method>
<method name="set_collision_layer">
@@ -40734,12 +41101,20 @@
</methods>
<members>
<member name="cast_to" type="Vector3" setter="set_cast_to" getter="get_cast_to" brief="">
+ The ray's destination point, relative to the RayCast's [code]position[/code].
</member>
<member name="collision_layer" type="int" setter="set_collision_layer" getter="get_collision_layer" brief="">
+ The RayCast's collison layer(s). Only bodies in the same collision layer(s) will be detected.
</member>
<member name="enabled" type="bool" setter="set_enabled" getter="is_enabled" brief="">
+ If [code]true[/code], collisions will be reported. Default value: [code]false[/code].
</member>
<member name="type_mask" type="int" setter="set_type_mask" getter="get_type_mask" brief="">
+ Object types to detect using a logical sum (OR operation) of type constants defined in [Physics2DDirectSpaceState].
+ Example:
+ [codeblock]
+ RayCast.type_mask = Physics2DDirectSpaceState.TYPE_MASK_STATIC_BODY | Physics2DDirectSpaceState.TYPE_MASK_KINEMATIC_BODY
+ [/codeblock]
</member>
</members>
<constants>
@@ -40750,12 +41125,9 @@
Query the closest object intersecting a ray.
</brief_description>
<description>
- A RayCast2D represents a line from its origin to its destination position [code]cast_to[/code], it is used to query the 2D space in order to find the closest object intersecting with the ray.
-
- RayCast2D can ignore some objects by adding them to the exception list via [code]add_exception[/code], setting proper filtering with layers, or by filtering object types with type masks.
-
- Only enabled raycasts will be able to query the space and report collisions!
-
+ A RayCast represents a line from its origin to its destination position, [code]cast_to[/code]. It is used to query the 2D space in order to find the closest object along the path of the ray.
+ RayCast2D can ignore some objects by adding them to the exception list via [code]add_exception[/code], by setting proper filtering with collision layers, or by filtering object types with type masks.
+ Only enabled raycasts will be able to query the space and report collisions.
RayCast2D calculates intersection every fixed frame (see [Node]), and the result is cached so it can be used later until the next frame. If multiple queries are required between fixed frames (or during the same frame) use [method force_raycast_update] after adjusting the raycast.
</description>
<methods>
@@ -40765,7 +41137,7 @@
<argument index="0" name="node" type="Object">
</argument>
<description>
- Adds a collision exception so the ray does not report collisions with the specified [code]node[/code].
+ Adds a collision exception so the ray does not report collisions with the specified node.
</description>
</method>
<method name="add_exception_rid">
@@ -40774,20 +41146,21 @@
<argument index="0" name="rid" type="RID">
</argument>
<description>
+ Adds a collision exception so the ray does not report collisions with the specified [RID].
</description>
</method>
<method name="clear_exceptions">
<return type="void">
</return>
<description>
- Removes all collision exception for this ray.
+ Removes all collision exceptions for this ray.
</description>
</method>
<method name="force_raycast_update">
<return type="void">
</return>
<description>
- Updates the collision information in case if this object's properties changed during the current frame (for example position, rotation or the cast_point). Note, [code]set_enabled[/code] is not required for this to work.
+ Updates the collision information for the ray. Use this method to update the collision information immediately instead of waiting for the next [code]_fixed_process[/code] call, for example if the ray or its parent has changed state. Note: [code]enabled == true[/code] is not required for this to work.
</description>
</method>
<method name="get_cast_to" qualifiers="const">
@@ -40801,14 +41174,24 @@
<return type="Object">
</return>
<description>
- Return the closest object the ray is pointing to. Note that this does not consider the length of the vector, so you must also use [method is_colliding] to check if the object returned is actually colliding with the ray.
+ Returns the closest object the ray is pointing to. Note that this does not consider the length of the ray, so you must also use [method is_colliding] to check if the object returned is actually colliding with the ray.
+ Example:
+ [codeblock]
+ if RayCast2D.is_colliding():
+ var collider = RayCast2D.get_collider()
+ [/codeblock]
</description>
</method>
<method name="get_collider_shape" qualifiers="const">
<return type="int">
</return>
<description>
- Returns the collision shape of the closest object the ray is pointing to.
+ Returns the collision shape of the closest object the ray is pointing to. Note that this does not consider the length of the ray, so you must also use [method is_colliding] to check if the object returned is actually colliding with the ray.
+ Example:
+ [codeblock]
+ if RayCast2D.is_colliding():
+ var shape = RayCast2D.get_collider_shape()
+ [/codeblock]
</description>
</method>
<method name="get_collision_layer" qualifiers="const">
@@ -40822,14 +41205,14 @@
<return type="Vector2">
</return>
<description>
- Returns the normal of the intersecting object shape face containing the collision point.
+ Returns the normal of the intersecting object's shape at the collision point.
</description>
</method>
<method name="get_collision_point" qualifiers="const">
<return type="Vector2">
</return>
<description>
- Returns the collision point in which the ray intersects the closest object. This point is in [b]global[/b] coordinate system.
+ Returns the collision point at which the ray intersects the closest object. Note: this point is in the [b]global[/b] coordinate system.
</description>
</method>
<method name="get_exclude_parent_body" qualifiers="const">
@@ -40866,7 +41249,7 @@
<argument index="0" name="node" type="Object">
</argument>
<description>
- Removes a collision exception so the ray does report collisions with the specified [code]node[/code].
+ Removes a collision exception so the ray does report collisions with the specified node.
</description>
</method>
<method name="remove_exception_rid">
@@ -40875,6 +41258,7 @@
<argument index="0" name="rid" type="RID">
</argument>
<description>
+ Removes a collision exception so the ray does report collisions with the specified [RID].
</description>
</method>
<method name="set_cast_to">
@@ -40925,14 +41309,23 @@
</methods>
<members>
<member name="cast_to" type="Vector2" setter="set_cast_to" getter="get_cast_to" brief="">
+ The ray's destination point, relative to the RayCast's [code]position[/code].
</member>
<member name="collision_layer" type="int" setter="set_collision_layer" getter="get_collision_layer" brief="">
+ The RayCast2D's collison layer(s). Only bodies in the same collision layer(s) will be detected.
</member>
<member name="enabled" type="bool" setter="set_enabled" getter="is_enabled" brief="">
+ If [code]true[/code], collisions will be reported. Default value: [code]false[/code].
</member>
<member name="exclude_parent" type="bool" setter="set_exclude_parent_body" getter="get_exclude_parent_body" brief="">
+ If [code]true[/code], the parent node will be excluded from collision detection. Default value: [code]true[/code].
</member>
<member name="type_mask" type="int" setter="set_type_mask" getter="get_type_mask" brief="">
+ Object types to detect using a logical sum (OR operation) of type constants defined in [Physics2DDirectSpaceState].
+ Example:
+ [codeblock]
+ RayCast.type_mask = Physics2DDirectSpaceState.TYPE_MASK_STATIC_BODY | Physics2DDirectSpaceState.TYPE_MASK_KINEMATIC_BODY
+ [/codeblock]
</member>
</members>
<constants>
@@ -42738,6 +43131,8 @@
</theme_item>
<theme_item name="mono_font" type="Font">
</theme_item>
+ <theme_item name="normal" type="StyleBox">
+ </theme_item>
<theme_item name="normal_font" type="Font">
</theme_item>
<theme_item name="selection_color" type="Color">
@@ -43069,38 +43464,55 @@
</methods>
<members>
<member name="angular_damp" type="float" setter="set_angular_damp" getter="get_angular_damp" brief="">
+ Dampens rotational forces of the Rigid body by the 'angular_damp' rate.
</member>
<member name="angular_velocity" type="Vector3" setter="set_angular_velocity" getter="get_angular_velocity" brief="">
+ The current rotational velocity of the Rigid body
</member>
<member name="axis_lock" type="int" setter="set_axis_lock" getter="get_axis_lock" brief="" enum="RigidBody.AxisLock">
+ Locks the rotational forces to a particular axis, preventing rotations on other axes.
</member>
<member name="bounce" type="float" setter="set_bounce" getter="get_bounce" brief="">
+ Bounciness of the Rigid body.
</member>
<member name="can_sleep" type="bool" setter="set_can_sleep" getter="is_able_to_sleep" brief="">
+ If true, the Rigid body will no longer calculate forces when there is no movement and will act as a static body. It will wake up when other forces are applied through other collisions or when the 'apply_impulse' method is used.
</member>
<member name="contact_monitor" type="bool" setter="set_contact_monitor" getter="is_contact_monitor_enabled" brief="">
+ If true, the Rigid body will emit signals when it collides with another Rigid body.
</member>
<member name="contacts_reported" type="int" setter="set_max_contacts_reported" getter="get_max_contacts_reported" brief="">
+ The maximum contacts to report. Bodies can keep a log of the contacts with other bodies, this is enabled by setting the maximum amount of contacts reported to a number greater than 0.
</member>
<member name="continuous_cd" type="bool" setter="set_use_continuous_collision_detection" getter="is_using_continuous_collision_detection" brief="">
+ Continuous collision detection tries to predict where a moving body will collide, instead of moving it and correcting its movement if it collided. The first is more precise, and misses less impacts by small, fast-moving objects. The second is faster to compute, but can miss small, fast-moving objects.
</member>
<member name="custom_integrator" type="bool" setter="set_use_custom_integrator" getter="is_using_custom_integrator" brief="">
+ If true, internal force integration will be disabled (like gravity or air friction) for this body. Other than collision response, the body will only move as determined by the [method _integrate_forces] function, if defined.
</member>
<member name="friction" type="float" setter="set_friction" getter="get_friction" brief="">
+ The body friction, from 0 (frictionless) to 1 (max friction).
</member>
<member name="gravity_scale" type="float" setter="set_gravity_scale" getter="get_gravity_scale" brief="">
+ The 'gravity_scale' for this Rigid body will be multiplied by the global 3d gravity setting found in "Project > Project Settings > Physics > 3d". A value of 1 will be normal gravity, 2 will apply double gravity, and 0.5 will apply half gravity to this object.
</member>
<member name="linear_damp" type="float" setter="set_linear_damp" getter="get_linear_damp" brief="">
+ The linear damp for this body. Default of -1, cannot be less than -1. If this value is different from -1, any linear damp derived from the world or areas will be overridden.
</member>
<member name="linear_velocity" type="Vector3" setter="set_linear_velocity" getter="get_linear_velocity" brief="">
+ The body linear velocity. Can be used sporadically, but [b]DON'T SET THIS IN EVERY FRAME[/b], because physics may run in another thread and runs at a different granularity. Use [method _integrate_forces] as your process loop for precise control of the body state.
</member>
<member name="mass" type="float" setter="set_mass" getter="get_mass" brief="">
+ The body mass.
</member>
<member name="mode" type="int" setter="set_mode" getter="get_mode" brief="" enum="RigidBody.Mode">
+ The body mode from the MODE_* enum. Modes include: MODE_STATIC, MODE_KINEMATIC, MODE_RIGID, and MODE_CHARACTER.
</member>
<member name="sleeping" type="bool" setter="set_sleeping" getter="is_sleeping" brief="">
+ The current 'sleeping' state of the Rigid body.
</member>
<member name="weight" type="float" setter="set_weight" getter="get_weight" brief="">
+ The body weight given standard earth-weight (gravity 9.8).
</member>
</members>
<signals>
@@ -44256,17 +44668,18 @@
</class>
<class name="Script" inherits="Resource" category="Core">
<brief_description>
- Base class for scripts.
+ A class stored as a resource.
</brief_description>
<description>
- Base class for scripts. Any script that is loaded becomes one of these resources, which can then create instances.
+ A class stored as a resource. The script exends the functionality of all objects that instance it.
+ The 'new' method of a script subclass creates a new instance. [method Object.set_script] extends an existing object, if that object's class matches one of the script's base classes.
</description>
<methods>
<method name="can_instance" qualifiers="const">
<return type="bool">
</return>
<description>
- Return true if this script can be instance (ie not a library).
+ Returns true if the script can be instanced.
</description>
</method>
<method name="get_node_type" qualifiers="const">
@@ -44279,7 +44692,7 @@
<return type="String">
</return>
<description>
- Return the script source code (if available).
+ Returns the script source code, or an empty string if source code is not available.
</description>
</method>
<method name="has_script_signal" qualifiers="const">
@@ -44288,13 +44701,14 @@
<argument index="0" name="signal_name" type="String">
</argument>
<description>
+ Returns true if the script, or a base class, defines a signal with the given name.
</description>
</method>
<method name="has_source_code" qualifiers="const">
<return type="bool">
</return>
<description>
- Return true if the script contains source code.
+ Returns true if the script contains non-empty source code.
</description>
</method>
<method name="instance_has" qualifiers="const">
@@ -44303,21 +44717,24 @@
<argument index="0" name="base_object" type="Object">
</argument>
<description>
- Return true if a given object uses an instance of this script.
+ Returns true if 'base_object' is an instance of this script.
</description>
</method>
<method name="is_tool" qualifiers="const">
<return type="bool">
</return>
<description>
+ Returns true if the script is a tool script. A tool script can run in the editor.
</description>
</method>
<method name="reload">
<return type="int" enum="Error">
</return>
<argument index="0" name="keep_state" type="bool" default="false">
+ If true, preserve existing script instances and subclasses.
</argument>
<description>
+ Reloads the script's class implementation. Returns an error code.
</description>
</method>
<method name="set_source_code">
@@ -44326,7 +44743,7 @@
<argument index="0" name="source" type="String">
</argument>
<description>
- Set the script source code.
+ Sets the script source code. Does not reload the class implementation.
</description>
</method>
</methods>
@@ -45294,16 +45711,17 @@
</class>
<class name="Spatial" inherits="Node" category="Core">
<brief_description>
- Base class for all 3D nodes.
+ Most basic 3D game object, parent of all 3D related nodes.
</brief_description>
<description>
- Spatial is the base for every type of 3D [Node]. It contains a 3D [Transform] which can be set or get as local or global. If a Spatial [Node] has Spatial children, their transforms will be relative to the parent.
+ Most basic 3D game object, with a 3D [Transform] and visibility settings. All 3D physics nodes and sprites inherit from Spatial. Use Spatial as a parent node to move, scale, rotate and show/hide children in a 3D project.
</description>
<methods>
<method name="get_gizmo" qualifiers="const">
<return type="SpatialGizmo">
</return>
<description>
+ Return the SpatialGizmo for this node. Used for example in [EditorSpatialGizmo] as custom visualization and editing handles in Editor.
</description>
</method>
<method name="get_global_transform" qualifiers="const">
@@ -45357,6 +45775,7 @@
<return type="World">
</return>
<description>
+ Return current [World] resource this Spatial node is registered to.
</description>
</method>
<method name="global_rotate">
@@ -45367,6 +45786,7 @@
<argument index="1" name="radians" type="float">
</argument>
<description>
+ Rotate current node along normal [Vector3] by angle in radians in Global space.
</description>
</method>
<method name="global_translate">
@@ -45375,42 +45795,49 @@
<argument index="0" name="offset" type="Vector3">
</argument>
<description>
+ Move current node by [Vector3] offset in Global space.
</description>
</method>
<method name="hide">
<return type="void">
</return>
<description>
+ Disable rendering of this node. Change Spatial Visible property to false.
</description>
</method>
<method name="is_local_transform_notification_enabled" qualifiers="const">
<return type="bool">
</return>
<description>
+ Returns whether node sends notification that its local transformation changed. Spatial will not propagate this by default.
</description>
</method>
<method name="is_set_as_toplevel" qualifiers="const">
<return type="bool">
</return>
<description>
+ Returns whether this node is set as Toplevel, ignoring its parent node transformations.
</description>
</method>
<method name="is_transform_notification_enabled" qualifiers="const">
<return type="bool">
</return>
<description>
+ Returns whether node sends notification that its transformation changed. Spatial will not propagate this by default.
</description>
</method>
<method name="is_visible" qualifiers="const">
<return type="bool">
</return>
<description>
+ Returns whether this node is set to be visible.
</description>
</method>
<method name="is_visible_in_tree" qualifiers="const">
<return type="bool">
</return>
<description>
+ Returns whether this node is visible, taking into consideration that its parents visibility.
</description>
</method>
<method name="look_at">
@@ -45421,6 +45848,7 @@
<argument index="1" name="up" type="Vector3">
</argument>
<description>
+ Rotates itself to point into direction of target position. Operations take place in global space.
</description>
</method>
<method name="look_at_from_pos">
@@ -45433,12 +45861,14 @@
<argument index="2" name="up" type="Vector3">
</argument>
<description>
+ Moves itself to specified position and then rotates itself to point into direction of target position. Operations take place in global space.
</description>
</method>
<method name="orthonormalize">
<return type="void">
</return>
<description>
+ Reset this node transformations (like scale, skew and taper) preserving its rotation and translation. Performs orthonormalization on this node [Transform3D].
</description>
</method>
<method name="rotate">
@@ -45449,6 +45879,7 @@
<argument index="1" name="radians" type="float">
</argument>
<description>
+ Rotates node in local space on given normal [Vector3] by angle in radians.
</description>
</method>
<method name="rotate_x">
@@ -45457,6 +45888,7 @@
<argument index="0" name="radians" type="float">
</argument>
<description>
+ Rotates node in local space on X axis by angle in radians.
</description>
</method>
<method name="rotate_y">
@@ -45465,6 +45897,7 @@
<argument index="0" name="radians" type="float">
</argument>
<description>
+ Rotates node in local space on Y axis by angle in radians.
</description>
</method>
<method name="rotate_z">
@@ -45473,6 +45906,7 @@
<argument index="0" name="radians" type="float">
</argument>
<description>
+ Rotates node in local space on Z axis by angle in radians.
</description>
</method>
<method name="set_as_toplevel">
@@ -45481,6 +45915,7 @@
<argument index="0" name="enable" type="bool">
</argument>
<description>
+ Makes this node ignore its parents tranformations. Node tranformations are only in global space.
</description>
</method>
<method name="set_gizmo">
@@ -45489,6 +45924,7 @@
<argument index="0" name="gizmo" type="SpatialGizmo">
</argument>
<description>
+ Set [SpatialGizmo] for this node. Used for example in [EditorSpatialGizmo] as custom visualization and editing handles in Editor.
</description>
</method>
<method name="set_global_transform">
@@ -45497,13 +45933,14 @@
<argument index="0" name="global" type="Transform">
</argument>
<description>
- Set the transform globally, relative to worldspace.
+ Set the transform globally, relative to world space.
</description>
</method>
<method name="set_identity">
<return type="void">
</return>
<description>
+ Reset all tranformations for this node. Set its [Transform3D] to identity matrix.
</description>
</method>
<method name="set_ignore_transform_notification">
@@ -45512,6 +45949,7 @@
<argument index="0" name="enabled" type="bool">
</argument>
<description>
+ Set whether this node ignores notification that its transformation changed.
</description>
</method>
<method name="set_notify_local_transform">
@@ -45520,6 +45958,7 @@
<argument index="0" name="enable" type="bool">
</argument>
<description>
+ Set whether this node sends notification that its local transformation changed. Spatial will not propagate this by default.
</description>
</method>
<method name="set_notify_transform">
@@ -45528,6 +45967,7 @@
<argument index="0" name="enable" type="bool">
</argument>
<description>
+ Set whether this node sends notification that its transformation changed. Spatial will not propagate this by default.
</description>
</method>
<method name="set_rotation">
@@ -45554,6 +45994,7 @@
<argument index="0" name="scale" type="Vector3">
</argument>
<description>
+ Set the scale.
</description>
</method>
<method name="set_transform">
@@ -45585,6 +46026,7 @@
<return type="void">
</return>
<description>
+ Enable rendering of this node. Change Spatial Visible property to false.
</description>
</method>
<method name="to_global" qualifiers="const">
@@ -45593,6 +46035,7 @@
<argument index="0" name="local_point" type="Vector3">
</argument>
<description>
+ Tranform [Vector3] from this node local space to world space.
</description>
</method>
<method name="to_local" qualifiers="const">
@@ -45601,6 +46044,7 @@
<argument index="0" name="global_point" type="Vector3">
</argument>
<description>
+ Tranform [Vector3] from world space to this node local space.
</description>
</method>
<method name="translate">
@@ -45609,46 +46053,60 @@
<argument index="0" name="offset" type="Vector3">
</argument>
<description>
+ Change node position by given offset [Vector3].
</description>
</method>
<method name="update_gizmo">
<return type="void">
</return>
<description>
+ Update [SpatialGizmo] of this node.
</description>
</method>
</methods>
<members>
<member name="global_transform" type="Transform" setter="set_global_transform" getter="get_global_transform" brief="">
+ World space (global) [Transform] of this node.
</member>
<member name="rotation" type="Vector3" setter="set_rotation" getter="get_rotation" brief="">
+ Local euler rotation in radians of this node.
</member>
<member name="rotation_deg" type="Vector3" setter="set_rotation_deg" getter="get_rotation_deg" brief="">
+ Local euler rotation in degrees of this node.
</member>
<member name="scale" type="Vector3" setter="set_scale" getter="get_scale" brief="">
+ Local scale of this node.
</member>
<member name="transform" type="Transform" setter="set_transform" getter="get_transform" brief="">
+ Local space [Transform] of this node.
</member>
<member name="translation" type="Vector3" setter="set_translation" getter="get_translation" brief="">
+ Local translation of this node.
</member>
<member name="visible" type="bool" setter="set_visible" getter="is_visible" brief="">
+ Visibility of this node. Toggles if this node is rendered.
</member>
</members>
<signals>
<signal name="visibility_changed">
<description>
+ Emitted when node visibility changed.
</description>
</signal>
</signals>
<constants>
<constant name="NOTIFICATION_TRANSFORM_CHANGED" value="29" enum="">
- Spatial nodes receive this notification with their global transform changes. This means that either the current or a parent node changed its transform.
+ Spatial nodes receive this notification when their global transform changes. This means that either the current or a parent node changed its transform.
+ In order for NOTIFICATION_TRANSFORM_CHANGED to work user first needs to ask for it, with set_notify_transform(true).
</constant>
<constant name="NOTIFICATION_ENTER_WORLD" value="41" enum="">
+ Spatial nodes receive this notification when they are registered to new [World] resource.
</constant>
<constant name="NOTIFICATION_EXIT_WORLD" value="42" enum="">
+ Spatial nodes receive this notification when they are unregistered from current [World] resource.
</constant>
<constant name="NOTIFICATION_VISIBILITY_CHANGED" value="43" enum="">
+ Spatial nodes receive this notification when their visibility changes.
</constant>
</constants>
</class>
@@ -45908,6 +46366,12 @@
<description>
</description>
</method>
+ <method name="get_transmission" qualifiers="const">
+ <return type="Color">
+ </return>
+ <description>
+ </description>
+ </method>
<method name="get_uv1_offset" qualifiers="const">
<return type="Vector3">
</return>
@@ -46290,6 +46754,14 @@
<description>
</description>
</method>
+ <method name="set_transmission">
+ <return type="void">
+ </return>
+ <argument index="0" name="transmission" type="Color">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="set_uv1_offset">
<return type="void">
</return>
@@ -46484,6 +46956,12 @@
</member>
<member name="subsurf_scatter_texture" type="Texture" setter="set_texture" getter="get_texture" brief="">
</member>
+ <member name="transmission" type="Color" setter="set_transmission" getter="get_transmission" brief="">
+ </member>
+ <member name="transmission_enabled" type="bool" setter="set_feature" getter="get_feature" brief="">
+ </member>
+ <member name="transmission_texture" type="Texture" setter="set_texture" getter="get_texture" brief="">
+ </member>
<member name="uv1_offset" type="Vector3" setter="set_uv1_offset" getter="get_uv1_offset" brief="">
</member>
<member name="uv1_scale" type="Vector3" setter="set_uv1_scale" getter="get_uv1_scale" brief="">
@@ -46528,15 +47006,17 @@
</constant>
<constant name="TEXTURE_SUBSURFACE_SCATTERING" value="10">
</constant>
- <constant name="TEXTURE_REFRACTION" value="11">
+ <constant name="TEXTURE_TRANSMISSION" value="11">
+ </constant>
+ <constant name="TEXTURE_REFRACTION" value="12">
</constant>
- <constant name="TEXTURE_DETAIL_MASK" value="12">
+ <constant name="TEXTURE_DETAIL_MASK" value="13">
</constant>
- <constant name="TEXTURE_DETAIL_ALBEDO" value="13">
+ <constant name="TEXTURE_DETAIL_ALBEDO" value="14">
</constant>
- <constant name="TEXTURE_DETAIL_NORMAL" value="14">
+ <constant name="TEXTURE_DETAIL_NORMAL" value="15">
</constant>
- <constant name="TEXTURE_MAX" value="15">
+ <constant name="TEXTURE_MAX" value="16">
</constant>
<constant name="DETAIL_UV_1" value="0">
</constant>
@@ -46560,11 +47040,13 @@
</constant>
<constant name="FEATURE_SUBSURACE_SCATTERING" value="8">
</constant>
- <constant name="FEATURE_REFRACTION" value="9">
+ <constant name="FEATURE_TRANSMISSION" value="9">
+ </constant>
+ <constant name="FEATURE_REFRACTION" value="10">
</constant>
- <constant name="FEATURE_DETAIL" value="10">
+ <constant name="FEATURE_DETAIL" value="11">
</constant>
- <constant name="FEATURE_MAX" value="11">
+ <constant name="FEATURE_MAX" value="12">
</constant>
<constant name="BLEND_MODE_MIX" value="0">
</constant>
@@ -46616,7 +47098,7 @@
</constant>
<constant name="DIFFUSE_LAMBERT" value="0">
</constant>
- <constant name="DIFFUSE_HALF_LAMBERT" value="1">
+ <constant name="DIFFUSE_LAMBERT_WRAP" value="1">
</constant>
<constant name="DIFFUSE_OREN_NAYAR" value="2">
</constant>
@@ -46702,8 +47184,10 @@
</class>
<class name="SphereMesh" inherits="PrimitiveMesh" category="Core">
<brief_description>
+ Class representing a spherical [PrimitiveMesh].
</brief_description>
<description>
+ Class representing a spherical [PrimitiveMesh].
</description>
<methods>
<method name="get_height" qualifiers="const">
@@ -46779,14 +47263,19 @@
</methods>
<members>
<member name="height" type="float" setter="set_height" getter="get_height" brief="">
+ Full height of the sphere. Defaults to 2.0.
</member>
<member name="is_hemisphere" type="bool" setter="set_is_hemisphere" getter="get_is_hemisphere" brief="">
+ Determines whether a full sphere or a hemisphere is created. Attention: To get a regular hemisphere the height and radius of the sphere have to equal. Defaults to false.
</member>
<member name="radial_segments" type="int" setter="set_radial_segments" getter="get_radial_segments" brief="">
+ Number of radial segments on the sphere. Defaults to 64.
</member>
<member name="radius" type="float" setter="set_radius" getter="get_radius" brief="">
+ Radius of sphere. Defaults to 1.0.
</member>
<member name="rings" type="int" setter="set_rings" getter="get_rings" brief="">
+ Number of segments along the height of the sphere. Defaults to 32.
</member>
</members>
<constants>
@@ -47786,12 +48275,16 @@
</methods>
<members>
<member name="bounce" type="float" setter="set_bounce" getter="get_bounce" brief="">
+ The body bounciness.
</member>
<member name="constant_angular_velocity" type="Vector3" setter="set_constant_angular_velocity" getter="get_constant_angular_velocity" brief="">
+ The constant angular velocity for the body. This does not rotate the body, but affects other bodies that touch it, as if it was in a state of rotation.
</member>
<member name="constant_linear_velocity" type="Vector3" setter="set_constant_linear_velocity" getter="get_constant_linear_velocity" brief="">
+ The constant linear velocity for the body. This does not move the body, but affects other bodies that touch it, as if it was in a state of movement.
</member>
<member name="friction" type="float" setter="set_friction" getter="get_friction" brief="">
+ The body friction, from 0 (frictionless) to 1 (full friction).
</member>
</members>
<constants>
@@ -49210,10 +49703,26 @@
</class>
<class name="StyleBoxFlat" inherits="StyleBox" category="Core">
<brief_description>
- Stylebox of a single color.
+ Customizable Stylebox with a given set of parameters. (no texture required)
</brief_description>
<description>
- Stylebox of a single color. Displays the stylebox of a single color, alternatively a border with light/dark colors can be assigned.
+ This stylebox can be used to achieve all kinds of looks without the need of a texture. Those properties are customizable:
+ - Color
+ - Border width (individual width for each border)
+ - Rounded corners (individual radius for each corner)
+ - Shadow
+ About corner radius:
+ Setting corner radius to high values is allowed. As soon as corners would overlap the stylebox will switch to a relative system. Example:
+ [codeblock]
+ height = 30
+ corner_radius_top_left = 50
+ corner_raidus_bottom_left = 100
+ [/codeblock]
+ The relative system now would take the 1:2 ratio of the two left corners to calculate the actual corner width. Both corners added will [b]never[/b] be more than the height. Result:
+ [codeblock]
+ corner_radius_top_left: 10
+ corner_raidus_bottom_left: 20
+ [/codeblock]
</description>
<methods>
<method name="get_aa_size" qualifiers="const">
@@ -49457,46 +49966,69 @@
</methods>
<members>
<member name="anti_aliasing" type="bool" setter="set_anti_aliased" getter="is_anti_aliased" brief="">
+ Anti Aliasing draws a small ring around edges. This ring fades to transparent. As a result edges look much smoother. This is only noticable when using rounded corners.
</member>
<member name="anti_aliasing_size" type="int" setter="set_aa_size" getter="get_aa_size" brief="">
+ This changes the size of the faded ring. Higher values can be used to achieve a "blurry" effect.
</member>
<member name="bg_color" type="Color" setter="set_bg_color" getter="get_bg_color" brief="">
+ The background color of the stylebox.
</member>
<member name="border_blend" type="bool" setter="set_border_blend" getter="get_border_blend" brief="">
+ When set to true, the border will fade into the background color.
</member>
<member name="border_color" type="Color" setter="set_border_color" getter="get_border_color" brief="">
+ Sets the color of the border.
</member>
<member name="border_width_bottom" type="int" setter="set_border_width" getter="get_border_width" brief="">
+ Border width for the bottom border.
</member>
<member name="border_width_left" type="int" setter="set_border_width" getter="get_border_width" brief="">
+ Border width for the left border.
</member>
<member name="border_width_right" type="int" setter="set_border_width" getter="get_border_width" brief="">
+ Border width for the right border.
</member>
<member name="border_width_top" type="int" setter="set_border_width" getter="get_border_width" brief="">
+ Border width for the top border.
</member>
<member name="corner_detail" type="int" setter="set_corner_detail" getter="get_corner_detail" brief="">
+ This sets the amount of vertices used for each corner. Higher values result in rounder corners but take more processing power to compute. When choosing a value you should take the corner radius ([method set_corner_radius]) into account.
+ For corner radius smaller than 10: 4-5 should be enough
+ For corner radius smaller than 30: 8-12 should be enough ...
</member>
<member name="corner_radius_bottom_left" type="int" setter="set_corner_radius" getter="get_corner_radius" brief="">
+ The corner radius of the bottom left corner. When set to 0 the corner is not rounded.
</member>
<member name="corner_radius_bottom_right" type="int" setter="set_corner_radius" getter="get_corner_radius" brief="">
+ The corner radius of the bottom right corner. When set to 0 the corner is not rounded.
</member>
<member name="corner_radius_top_left" type="int" setter="set_corner_radius" getter="get_corner_radius" brief="">
+ The corner radius of the top left corner. When set to 0 the corner is not rounded.
</member>
<member name="corner_radius_top_right" type="int" setter="set_corner_radius" getter="get_corner_radius" brief="">
+ The corner radius of the top right corner. When set to 0 the corner is not rounded.
</member>
<member name="draw_center" type="bool" setter="set_draw_center" getter="is_draw_center_enabled" brief="">
+ Toggels drawing of the inner part of the stylebox.
</member>
<member name="expand_margin_bottom" type="float" setter="set_expand_margin" getter="get_expand_margin" brief="">
+ Expands the stylebox outside of the control rect on the bottom edge. Useful in combination with border_width_bottom. To draw a border outside the control rect.
</member>
<member name="expand_margin_left" type="float" setter="set_expand_margin" getter="get_expand_margin" brief="">
+ Expands the stylebox outside of the control rect on the left edge. Useful in combination with border_width_left. To draw a border outside the control rect.
</member>
<member name="expand_margin_right" type="float" setter="set_expand_margin" getter="get_expand_margin" brief="">
+ Expands the stylebox outside of the control rect on the right edge. Useful in combination with border_width_right. To draw a border outside the control rect.
</member>
<member name="expand_margin_top" type="float" setter="set_expand_margin" getter="get_expand_margin" brief="">
+ Expands the stylebox outside of the control rect on the top edge. Useful in combination with border_width_top. To draw a border outside the control rect.
</member>
<member name="shadow_color" type="Color" setter="set_shadow_color" getter="get_shadow_color" brief="">
+ The color of the shadow. (This has no effect when shadow_size &lt; 1)
</member>
<member name="shadow_size" type="int" setter="set_shadow_size" getter="get_shadow_size" brief="">
+ The shadow size in pixels.
</member>
</members>
<constants>
@@ -51494,10 +52026,10 @@
</class>
<class name="TextureRect" inherits="Control" category="Core">
<brief_description>
- Control Frame that draws a texture.
+ Control that draws a texture.
</brief_description>
<description>
- Control frame that simply draws an assigned texture. It can stretch or not. It's a simple way to just show an image in a UI.
+ Control that draws a texture.
</description>
<methods>
<method name="get_stretch_mode" qualifiers="const">
@@ -51545,10 +52077,13 @@
</methods>
<members>
<member name="expand" type="bool" setter="set_expand" getter="has_expand" brief="">
+ If [code]true[/code] texture will expand to fit. Default value: [code]false[/code].
</member>
<member name="stretch_mode" type="int" setter="set_stretch_mode" getter="get_stretch_mode" brief="" enum="TextureRect.StretchMode">
+ Stretch mode of the texture. Use STRETCH_* constants as value.
</member>
<member name="texture" type="Texture" setter="set_texture" getter="get_texture" brief="">
+ The [Texture] resource for the node.
</member>
</members>
<constants>
@@ -51928,11 +52463,10 @@
</class>
<class name="TileMap" inherits="Node2D" category="Core">
<brief_description>
- Node for 2D tile-based games.
+ Node for 2D tile-based maps.
</brief_description>
<description>
- Node for 2D tile-based games. Tilemaps use a [TileSet] which contain a list of tiles (textures, their rect and a collision) and are used to create complex grid-based maps.
- To optimize drawing and culling (sort of like [GridMap]), you can specify a quadrant size, so chunks of the map will be batched together at drawing time.
+ Node for 2D tile-based maps. Tilemaps use a [TileSet] which contain a list of tiles (textures plus optional collision, navigation, and/or occluder shapes) which are used to create grid-based maps.
</description>
<methods>
<method name="clear">
@@ -52375,40 +52909,55 @@
</methods>
<members>
<member name="cell_custom_transform" type="Transform2D" setter="set_custom_transform" getter="get_custom_transform" brief="">
+ The custom [Transform2D] to be applied to the TileMap's cells.
</member>
<member name="cell_half_offset" type="int" setter="set_half_offset" getter="get_half_offset" brief="" enum="TileMap.HalfOffset">
+ Amount to offset alternating tiles. Uses HALF_OFFSET_* constants. Default value: HALF_OFFSET_DISABLED.
</member>
<member name="cell_quadrant_size" type="int" setter="set_quadrant_size" getter="get_quadrant_size" brief="">
+ The TileMap's quadrant size. Optimizes drawing by batching, using chunks of this size. Default value: 16.
</member>
<member name="cell_size" type="Vector2" setter="set_cell_size" getter="get_cell_size" brief="">
+ The TileMap's cell size.
</member>
<member name="cell_tile_origin" type="int" setter="set_tile_origin" getter="get_tile_origin" brief="" enum="TileMap.TileOrigin">
+ Position for tile origin. Uses TILE_ORIGIN_* constants. Default value: TILE_ORIGIN_TOP_LEFT.
</member>
<member name="cell_y_sort" type="bool" setter="set_y_sort_mode" getter="is_y_sort_mode_enabled" brief="">
+ If [code]true[/code] the TileMap's children will be drawn in order of their Y coordinate. Default value: [code]false[/code].
</member>
<member name="collision_bounce" type="float" setter="set_collision_bounce" getter="get_collision_bounce" brief="">
+ Bounce value for static body collisions (see [code]collision_use_kinematic[/code]). Default value: 0.
</member>
<member name="collision_friction" type="float" setter="set_collision_friction" getter="get_collision_friction" brief="">
+ Friction value for static body collisions (see [code]collision_use_kinematic[/code]). Default value: 1.
</member>
<member name="collision_layer" type="int" setter="set_collision_layer" getter="get_collision_layer" brief="">
+ The collision layer(s) for all colliders in the TileMap.
</member>
<member name="collision_mask" type="int" setter="set_collision_mask" getter="get_collision_mask" brief="">
+ The collision mask(s) for all colliders in the TileMap.
</member>
<member name="collision_use_kinematic" type="bool" setter="set_collision_use_kinematic" getter="get_collision_use_kinematic" brief="">
+ If [code]true[/code] TileMap collisions will be handled as a kinematic body. If [code]false[/code] collisions will be handled as static body. Default value: [code]false[/code].
</member>
<member name="mode" type="int" setter="set_mode" getter="get_mode" brief="" enum="TileMap.Mode">
+ The TileMap orientation mode. Uses MODE_* constants. Default value: MODE_SQUARE.
</member>
<member name="occluder_light_mask" type="int" setter="set_occluder_light_mask" getter="get_occluder_light_mask" brief="">
+ The light mask assigned to all light occluders in the TileMap. The TileSet's light occluders will cast shadows only from Light2D(s) that have the same light mask(s).
</member>
<member name="tile_data" type="PoolIntArray" setter="_set_tile_data" getter="_get_tile_data" brief="">
+ A [PoolIntArray] containing
</member>
<member name="tile_set" type="TileSet" setter="set_tileset" getter="get_tileset" brief="">
+ The assigned [TileSet].
</member>
</members>
<signals>
<signal name="settings_changed">
<description>
- Signal indicating that a tilemap setting has changed.
+ Emitted when a tilemap setting has changed.
</description>
</signal>
</signals>
@@ -52813,10 +53362,10 @@
</class>
<class name="Timer" inherits="Node" category="Core">
<brief_description>
- A simple Timer node.
+ A countdown timer.
</brief_description>
<description>
- Timer node. This is a simple node that will emit a timeout callback when the timer runs out. It can optionally be set to loop.
+ Counts down a specified interval and emits a signal on reaching 0. Can be set to repeat or "one shot" mode.
</description>
<methods>
<method name="get_time_left" qualifiers="const">
@@ -52916,47 +53465,58 @@
<return type="void">
</return>
<description>
- Start the timer.
+ Start the Timer.
</description>
</method>
<method name="stop">
<return type="void">
</return>
<description>
- Stop (cancel) the timer.
+ Stop (cancel) the Timer.
</description>
</method>
</methods>
<members>
<member name="autostart" type="bool" setter="set_autostart" getter="has_autostart" brief="">
+ If [code]true[/code], Timer will automatically start when entering the scene tree. Default value: [code]false[/code].
</member>
<member name="one_shot" type="bool" setter="set_one_shot" getter="is_one_shot" brief="">
+ If [code]true[/code], Timer will stop when reaching 0. If [code]false[/code], it will restart. Default value: [code]false[/code].
</member>
<member name="process_mode" type="int" setter="set_timer_process_mode" getter="get_timer_process_mode" brief="" enum="Timer.TimerProcessMode">
+ Processing mode. Uses TIMER_PROCESS_* constants as value.
</member>
<member name="wait_time" type="float" setter="set_wait_time" getter="get_wait_time" brief="">
+ Wait time in seconds.
</member>
</members>
<signals>
<signal name="timeout">
<description>
- Emitted when the time runs out.
+ Emitted when the Timer reaches 0.
</description>
</signal>
</signals>
<constants>
<constant name="TIMER_PROCESS_FIXED" value="0">
- Update the timer at fixed intervals (framerate processing).
+ Update the Timer at fixed intervals (framerate processing).
</constant>
<constant name="TIMER_PROCESS_IDLE" value="1">
- Update the timer during the idle time at each frame.
+ Update the Timer during the idle time at each frame.
</constant>
</constants>
</class>
<class name="ToolButton" inherits="Button" category="Core">
<brief_description>
+ Flat button helper class.
</brief_description>
<description>
+ This is a helper class to generate a flat [Button] (see [method Button.set_flat]), creating a ToolButton is equivalent to:
+
+ [codeblock]
+ var btn = Button.new()
+ btn.set_flat(true)
+ [/codeblock]
</description>
<methods>
</methods>
@@ -53161,10 +53721,10 @@
</class>
<class name="Transform" category="Built-In Types">
<brief_description>
- 3D Transformation.
+ 3D Transformation. 3x4 matrix.
</brief_description>
<description>
- Transform is used to store translation, rotation and scaling transformations. It consists of a Basis "basis" and Vector3 "origin". Transform is used to represent transformations of objects in space, and as such, determine their position, orientation and scale. It is similar to a 3x4 matrix.
+ Represents one or many transformations in 3D space such as translation, rotation, or scaling. It consists of a [Basis] "basis" and an [Vector3] "origin". It is similar to a 3x4 matrix.
</description>
<methods>
<method name="Transform">
@@ -53179,7 +53739,7 @@
<argument index="3" name="origin" type="Vector3">
</argument>
<description>
- Construct the Transform from four Vector3. Each axis corresponds to local basis vectors (some of which may be scaled).
+ Construct the Transform from four [Vector3]. Each axis corresponds to local basis vectors (some of which may be scaled).
</description>
</method>
<method name="Transform">
@@ -53190,7 +53750,7 @@
<argument index="1" name="origin" type="Vector3">
</argument>
<description>
- Construct the Transform from a Basis and Vector3.
+ Construct the Transform from a [Basis] and [Vector3].
</description>
</method>
<method name="Transform">
@@ -53199,7 +53759,7 @@
<argument index="0" name="from" type="Transform2D">
</argument>
<description>
- Construct the Transform from a Transform2D.
+ Construct the Transform from a [Transform2D].
</description>
</method>
<method name="Transform">
@@ -53208,7 +53768,7 @@
<argument index="0" name="from" type="Quat">
</argument>
<description>
- Construct the Transform from a Quat. The origin will be Vector3(0, 0, 0).
+ Construct the Transform from a [Quat]. The origin will be Vector3(0, 0, 0).
</description>
</method>
<method name="Transform">
@@ -53217,7 +53777,7 @@
<argument index="0" name="from" type="Basis">
</argument>
<description>
- Construct the Transform from a Basis. The origin will be Vector3(0, 0, 0).
+ Construct the Transform from a [Basis]. The origin will be Vector3(0, 0, 0).
</description>
</method>
<method name="affine_inverse">
@@ -53235,13 +53795,14 @@
<argument index="1" name="weight" type="float">
</argument>
<description>
+ Interpolate to other Transform by weight amount (0-1).
</description>
</method>
<method name="inverse">
<return type="Transform">
</return>
<description>
- Returns the inverse of the transform, under the assumption that the transformation is composed of rotation and translation (no scaling).
+ Returns the inverse of the transform, under the assumption that the transformation is composed of rotation and translation (no scaling, use affine_inverse for transforms with scaling).
</description>
</method>
<method name="looking_at">
@@ -53288,7 +53849,7 @@
<argument index="0" name="ofs" type="Vector3">
</argument>
<description>
- Translate the transform by the specified displacement.
+ Translate the transform by the specified offset.
</description>
</method>
<method name="xform">
@@ -53312,10 +53873,10 @@
</methods>
<members>
<member name="basis" type="Basis" setter="" getter="" brief="">
- The basis is a matrix containing 3 [Vector3] as its columns: X axis, Y axis, and Z axis. These vectors can be interpreted as the basis vectors of local coordinate system travelling with the object.
+ The basis is a matrix containing 3 [Vector3] as its columns: X axis, Y axis, and Z axis. These vectors can be interpreted as the basis vectors of local coordinate system traveling with the object.
</member>
<member name="origin" type="Vector3" setter="" getter="" brief="">
- The origin of the transform. Which is the translation offset.
+ The translation offset of the transform.
</member>
</members>
<constants>
@@ -53323,10 +53884,10 @@
</class>
<class name="Transform2D" category="Built-In Types">
<brief_description>
- 3x2 Matrix for 2D transforms.
+ 2D Transformation. 3x2 matrix.
</brief_description>
<description>
- 3x2 Matrix for 2D transforms.
+ Represents one or many transformations in 3D space such as translation, rotation, or scaling. It consists of a two [Vector2] x, y and [Vector2] "origin". It is similar to a 3x2 matrix.
</description>
<methods>
<method name="Transform2D">
@@ -53335,6 +53896,7 @@
<argument index="0" name="from" type="Transform">
</argument>
<description>
+ Constructs the [Transform2D] from a 3D [Transform].
</description>
</method>
<method name="Transform2D">
@@ -53347,6 +53909,7 @@
<argument index="2" name="origin" type="Vector2">
</argument>
<description>
+ Constructs the [Transform2D] from 3 [Vector2] consisting of rows x, y and origin.
</description>
</method>
<method name="Transform2D">
@@ -53357,13 +53920,14 @@
<argument index="1" name="pos" type="Vector2">
</argument>
<description>
+ Constructs the [Transform2D] from rotation angle in radians and position [Vector2].
</description>
</method>
<method name="affine_inverse">
<return type="Transform2D">
</return>
<description>
- Return the inverse of the matrix.
+ Returns the inverse of the matrix.
</description>
</method>
<method name="basis_xform">
@@ -53372,6 +53936,7 @@
<argument index="0" name="v" type="var">
</argument>
<description>
+ Transforms the given vector "v" by this transform basis (no translation).
</description>
</method>
<method name="basis_xform_inv">
@@ -53380,12 +53945,14 @@
<argument index="0" name="v" type="var">
</argument>
<description>
+ Inverse-transforms vector "v" by this transform basis (no translation).
</description>
</method>
<method name="get_origin">
<return type="Vector2">
</return>
<description>
+ Return the origin [Vector2] (translation).
</description>
</method>
<method name="get_rotation">
@@ -53399,6 +53966,7 @@
<return type="Vector2">
</return>
<description>
+ Return the scale.
</description>
</method>
<method name="interpolate_with">
@@ -53409,18 +53977,21 @@
<argument index="1" name="weight" type="float">
</argument>
<description>
+ Interpolate to other Transform2D by weight amount (0-1).
</description>
</method>
<method name="inverse">
<return type="Transform2D">
</return>
<description>
+ Returns the inverse of the transform, under the assumption that the transformation is composed of rotation and translation (no scaling, use affine_inverse for transforms with scaling).
</description>
</method>
<method name="orthonormalized">
<return type="Transform2D">
</return>
<description>
+ Returns a transfrom with the basis orthogonal (90 degrees), and normalized axis vectors.
</description>
</method>
<method name="rotated">
@@ -53429,6 +54000,7 @@
<argument index="0" name="phi" type="float">
</argument>
<description>
+ Rotate the transform by phi.
</description>
</method>
<method name="scaled">
@@ -53437,6 +54009,7 @@
<argument index="0" name="scale" type="Vector2">
</argument>
<description>
+ Scale the transform by the specified 2D scaling factors.
</description>
</method>
<method name="translated">
@@ -53445,6 +54018,7 @@
<argument index="0" name="offset" type="Vector2">
</argument>
<description>
+ Translate the transform by the specified offset.
</description>
</method>
<method name="xform">
@@ -53453,6 +54027,7 @@
<argument index="0" name="v" type="var">
</argument>
<description>
+ Transforms the given vector "v" by this transform.
</description>
</method>
<method name="xform_inv">
@@ -53461,15 +54036,19 @@
<argument index="0" name="v" type="var">
</argument>
<description>
+ Inverse-transforms the given vector "v" by this transform.
</description>
</method>
</methods>
<members>
<member name="origin" type="Vector2" setter="" getter="" brief="">
+ The translation offset of the transform.
</member>
<member name="x" type="Vector2" setter="" getter="" brief="">
+ The X axis of 2x2 basis matrix containing 2 [Vector2] as its columns: X axis and Y axis. These vectors can be interpreted as the basis vectors of local coordinate system traveling with the object.
</member>
<member name="y" type="Vector2" setter="" getter="" brief="">
+ The Y axis of 2x2 basis matrix containing 2 [Vector2] as its columns: X axis and Y axis. These vectors can be interpreted as the basis vectors of local coordinate system traveling with the object.
</member>
</members>
<constants>
@@ -55342,8 +55921,10 @@
</class>
<class name="Variant" category="Core">
<brief_description>
+ The most important data type in Godot.
</brief_description>
<description>
+ A Variant takes up only 20 bytes and can store almost any engine datatype inside of it. Variants are rarely used to hold information for long periods of time, instead they are used mainly for communication, editing, serialization and moving data around.
</description>
<methods>
</methods>
diff --git a/drivers/gles3/rasterizer_canvas_gles3.cpp b/drivers/gles3/rasterizer_canvas_gles3.cpp
index ff0741f425..84f29facf4 100644
--- a/drivers/gles3/rasterizer_canvas_gles3.cpp
+++ b/drivers/gles3/rasterizer_canvas_gles3.cpp
@@ -1115,6 +1115,10 @@ void RasterizerCanvasGLES3::canvas_render_items(Item *p_item_list, int p_z, cons
_copy_texscreen(Rect2());
}
+ if (shader_ptr->canvas_item.uses_time) {
+ VisualServerRaster::redraw_request();
+ }
+
state.canvas_shader.set_custom_shader(shader_ptr->custom_code_id);
state.canvas_shader.bind();
diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp
index 6bef039dd1..146a2359b6 100644
--- a/drivers/gles3/rasterizer_scene_gles3.cpp
+++ b/drivers/gles3/rasterizer_scene_gles3.cpp
@@ -32,6 +32,7 @@
#include "os/os.h"
#include "project_settings.h"
#include "rasterizer_canvas_gles3.h"
+#include "servers/visual/visual_server_raster.h"
#ifndef GLES_OVER_GL
#define glClearDepth glClearDepthf
@@ -1939,6 +1940,7 @@ void RasterizerSceneGLES3::_render_list(RenderList::Element **p_elements, int p_
bool prev_use_instancing = false;
storage->info.render.draw_call_count += p_element_count;
+ bool prev_opaque_prepass = false;
for (int i = 0; i < p_element_count; i++) {
@@ -2072,6 +2074,13 @@ void RasterizerSceneGLES3::_render_list(RenderList::Element **p_elements, int p_
}
}
+ bool use_opaque_prepass = e->sort_key & RenderList::SORT_KEY_OPAQUE_PRE_PASS;
+
+ if (use_opaque_prepass != prev_opaque_prepass) {
+ state.scene_shader.set_conditional(SceneShaderGLES3::USE_OPAQUE_PREPASS, use_opaque_prepass);
+ rebind = true;
+ }
+
bool use_instancing = e->instance->base_type == VS::INSTANCE_MULTIMESH || e->instance->base_type == VS::INSTANCE_PARTICLES;
if (use_instancing != prev_use_instancing) {
@@ -2127,6 +2136,7 @@ void RasterizerSceneGLES3::_render_list(RenderList::Element **p_elements, int p_
prev_shading = shading;
prev_skeleton = skeleton;
prev_use_instancing = use_instancing;
+ prev_opaque_prepass = use_opaque_prepass;
first = false;
}
@@ -2148,9 +2158,10 @@ void RasterizerSceneGLES3::_render_list(RenderList::Element **p_elements, int p_
state.scene_shader.set_conditional(SceneShaderGLES3::USE_GI_PROBES, false);
state.scene_shader.set_conditional(SceneShaderGLES3::USE_CONTACT_SHADOWS, false);
state.scene_shader.set_conditional(SceneShaderGLES3::USE_VERTEX_LIGHTING, false);
+ state.scene_shader.set_conditional(SceneShaderGLES3::USE_OPAQUE_PREPASS, false);
}
-void RasterizerSceneGLES3::_add_geometry(RasterizerStorageGLES3::Geometry *p_geometry, InstanceBase *p_instance, RasterizerStorageGLES3::GeometryOwner *p_owner, int p_material, bool p_shadow) {
+void RasterizerSceneGLES3::_add_geometry(RasterizerStorageGLES3::Geometry *p_geometry, InstanceBase *p_instance, RasterizerStorageGLES3::GeometryOwner *p_owner, int p_material, bool p_depth_pass) {
RasterizerStorageGLES3::Material *m = NULL;
RID m_src = p_instance->material_override.is_valid() ? p_instance->material_override : (p_material >= 0 ? p_instance->materials[p_material] : p_geometry->material);
@@ -2182,22 +2193,21 @@ void RasterizerSceneGLES3::_add_geometry(RasterizerStorageGLES3::Geometry *p_geo
ERR_FAIL_COND(!m);
- _add_geometry_with_material(p_geometry, p_instance, p_owner, m, p_shadow);
+ _add_geometry_with_material(p_geometry, p_instance, p_owner, m, p_depth_pass);
while (m->next_pass.is_valid()) {
m = storage->material_owner.getornull(m->next_pass);
if (!m || !m->shader || !m->shader->valid)
break;
- _add_geometry_with_material(p_geometry, p_instance, p_owner, m, p_shadow);
+ _add_geometry_with_material(p_geometry, p_instance, p_owner, m, p_depth_pass);
}
}
-void RasterizerSceneGLES3::_add_geometry_with_material(RasterizerStorageGLES3::Geometry *p_geometry, InstanceBase *p_instance, RasterizerStorageGLES3::GeometryOwner *p_owner, RasterizerStorageGLES3::Material *p_material, bool p_shadow) {
+void RasterizerSceneGLES3::_add_geometry_with_material(RasterizerStorageGLES3::Geometry *p_geometry, InstanceBase *p_instance, RasterizerStorageGLES3::GeometryOwner *p_owner, RasterizerStorageGLES3::Material *p_material, bool p_depth_pass) {
bool has_base_alpha = (p_material->shader->spatial.uses_alpha && !p_material->shader->spatial.uses_alpha_scissor) || p_material->shader->spatial.uses_screen_texture;
bool has_blend_alpha = p_material->shader->spatial.blend_mode != RasterizerStorageGLES3::Shader::Spatial::BLEND_MODE_MIX;
bool has_alpha = has_base_alpha || has_blend_alpha;
- bool shadow = false;
bool mirror = p_instance->mirror;
bool no_cull = false;
@@ -2217,7 +2227,7 @@ void RasterizerSceneGLES3::_add_geometry_with_material(RasterizerStorageGLES3::G
state.used_screen_texture = true;
}
- if (p_shadow) {
+ if (p_depth_pass) {
if (has_blend_alpha || (has_base_alpha && p_material->shader->spatial.depth_draw_mode != RasterizerStorageGLES3::Shader::Spatial::DEPTH_DRAW_ALPHA_PREPASS))
return; //bye
@@ -2252,14 +2262,14 @@ void RasterizerSceneGLES3::_add_geometry_with_material(RasterizerStorageGLES3::G
e->geometry->index = current_geometry_index++;
}
- if (!p_shadow && directional_light && (directional_light->light_ptr->cull_mask & e->instance->layer_mask) == 0) {
+ if (!p_depth_pass && directional_light && (directional_light->light_ptr->cull_mask & e->instance->layer_mask) == 0) {
e->sort_key |= SORT_KEY_NO_DIRECTIONAL_FLAG;
}
e->sort_key |= uint64_t(e->geometry->index) << RenderList::SORT_KEY_GEOMETRY_INDEX_SHIFT;
e->sort_key |= uint64_t(e->instance->base_type) << RenderList::SORT_KEY_GEOMETRY_TYPE_SHIFT;
- if (!p_shadow) {
+ if (!p_depth_pass) {
if (e->material->last_pass != render_pass) {
e->material->last_pass = render_pass;
@@ -2269,17 +2279,6 @@ void RasterizerSceneGLES3::_add_geometry_with_material(RasterizerStorageGLES3::G
e->sort_key |= uint64_t(e->material->index) << RenderList::SORT_KEY_MATERIAL_INDEX_SHIFT;
e->sort_key |= uint64_t(e->instance->depth_layer) << RenderList::SORT_KEY_OPAQUE_DEPTH_LAYER_SHIFT;
- if (!has_blend_alpha && has_alpha && p_material->shader->spatial.depth_draw_mode == RasterizerStorageGLES3::Shader::Spatial::DEPTH_DRAW_ALPHA_PREPASS) {
-
- //if nothing exists, add this element as opaque too
- RenderList::Element *oe = render_list.add_element();
-
- if (!oe)
- return;
-
- copymem(oe, e, sizeof(RenderList::Element));
- }
-
if (e->instance->gi_probe_instances.size()) {
e->sort_key |= SORT_KEY_GI_PROBES_FLAG;
}
@@ -2302,24 +2301,21 @@ void RasterizerSceneGLES3::_add_geometry_with_material(RasterizerStorageGLES3::G
//e->light_type=0xFF; // no lights!
- if (shadow || p_material->shader->spatial.unshaded || state.debug_draw == VS::VIEWPORT_DEBUG_DRAW_UNSHADED) {
-
+ if (p_depth_pass || p_material->shader->spatial.unshaded || state.debug_draw == VS::VIEWPORT_DEBUG_DRAW_UNSHADED) {
e->sort_key |= SORT_KEY_UNSHADED_FLAG;
}
- if (!shadow && (p_material->shader->spatial.uses_vertex_lighting || storage->config.force_vertex_shading)) {
+ if (p_depth_pass && p_material->shader->spatial.depth_draw_mode == RasterizerStorageGLES3::Shader::Spatial::DEPTH_DRAW_ALPHA_PREPASS) {
+ e->sort_key |= RenderList::SORT_KEY_OPAQUE_PRE_PASS;
+ }
+
+ if (!p_depth_pass && (p_material->shader->spatial.uses_vertex_lighting || storage->config.force_vertex_shading)) {
e->sort_key |= SORT_KEY_VERTEX_LIT_FLAG;
}
- if (!shadow && has_alpha && p_material->shader->spatial.depth_draw_mode == RasterizerStorageGLES3::Shader::Spatial::DEPTH_DRAW_ALPHA_PREPASS) {
- //depth prepass for alpha
- RenderList::Element *eo = render_list.add_element();
-
- eo->instance = e->instance;
- eo->geometry = e->geometry;
- eo->material = e->material;
- eo->sort_key = e->sort_key;
+ if (p_material->shader->spatial.uses_time) {
+ VisualServerRaster::redraw_request();
}
}
@@ -2603,7 +2599,7 @@ void RasterizerSceneGLES3::_setup_directional_light(int p_index, const Transform
}
}
- ubo_data.shadow_split_offsets[j] = 1.0 / li->shadow_transform[j].split;
+ ubo_data.shadow_split_offsets[j] = li->shadow_transform[j].split;
Transform modelview = (p_camera_inverse_transform * li->shadow_transform[j].transform).inverse();
@@ -3032,7 +3028,7 @@ void RasterizerSceneGLES3::_copy_texture_to_front_buffer(GLuint p_texture) {
storage->shaders.copy.set_conditional(CopyShaderGLES3::DISABLE_ALPHA, false);
}
-void RasterizerSceneGLES3::_fill_render_list(InstanceBase **p_cull_result, int p_cull_count, bool p_shadow) {
+void RasterizerSceneGLES3::_fill_render_list(InstanceBase **p_cull_result, int p_cull_count, bool p_depth_pass) {
current_geometry_index = 0;
current_material_index = 0;
@@ -3057,7 +3053,7 @@ void RasterizerSceneGLES3::_fill_render_list(InstanceBase **p_cull_result, int p
int mat_idx = inst->materials[i].is_valid() ? i : -1;
RasterizerStorageGLES3::Surface *s = mesh->surfaces[i];
- _add_geometry(s, inst, NULL, mat_idx, p_shadow);
+ _add_geometry(s, inst, NULL, mat_idx, p_depth_pass);
}
//mesh->last_pass=frame;
@@ -3080,7 +3076,7 @@ void RasterizerSceneGLES3::_fill_render_list(InstanceBase **p_cull_result, int p
for (int i = 0; i < ssize; i++) {
RasterizerStorageGLES3::Surface *s = mesh->surfaces[i];
- _add_geometry(s, inst, multi_mesh, -1, p_shadow);
+ _add_geometry(s, inst, multi_mesh, -1, p_depth_pass);
}
} break;
@@ -3089,7 +3085,7 @@ void RasterizerSceneGLES3::_fill_render_list(InstanceBase **p_cull_result, int p
RasterizerStorageGLES3::Immediate *immediate = storage->immediate_owner.getptr(inst->base);
ERR_CONTINUE(!immediate);
- _add_geometry(immediate, inst, NULL, -1, p_shadow);
+ _add_geometry(immediate, inst, NULL, -1, p_depth_pass);
} break;
case VS::INSTANCE_PARTICLES: {
@@ -3111,7 +3107,7 @@ void RasterizerSceneGLES3::_fill_render_list(InstanceBase **p_cull_result, int p
for (int j = 0; j < ssize; j++) {
RasterizerStorageGLES3::Surface *s = mesh->surfaces[j];
- _add_geometry(s, inst, particles, -1, p_shadow);
+ _add_geometry(s, inst, particles, -1, p_depth_pass);
}
}
@@ -3178,6 +3174,7 @@ void RasterizerSceneGLES3::_render_mrts(Environment *env, const CameraMatrix &p_
for (int i = 0; i < storage->frame.current_rt->effects.ssao.depth_mipmap_fbos.size(); i++) {
state.ssao_minify_shader.set_conditional(SsaoMinifyShaderGLES3::MINIFY_START, i == 0);
+ state.ssao_minify_shader.set_conditional(SsaoMinifyShaderGLES3::USE_ORTHOGONAL_PROJECTION, p_cam_projection.is_orthogonal());
state.ssao_minify_shader.bind();
state.ssao_minify_shader.set_uniform(SsaoMinifyShaderGLES3::CAMERA_Z_FAR, p_cam_projection.get_z_far());
state.ssao_minify_shader.set_uniform(SsaoMinifyShaderGLES3::CAMERA_Z_NEAR, p_cam_projection.get_z_near());
@@ -3207,6 +3204,7 @@ void RasterizerSceneGLES3::_render_mrts(Environment *env, const CameraMatrix &p_
glDepthFunc(GL_GREATER);
// do SSAO!
state.ssao_shader.set_conditional(SsaoShaderGLES3::ENABLE_RADIUS2, env->ssao_radius2 > 0.001);
+ state.ssao_shader.set_conditional(SsaoShaderGLES3::USE_ORTHOGONAL_PROJECTION, p_cam_projection.is_orthogonal());
state.ssao_shader.bind();
state.ssao_shader.set_uniform(SsaoShaderGLES3::CAMERA_Z_FAR, p_cam_projection.get_z_far());
state.ssao_shader.set_uniform(SsaoShaderGLES3::CAMERA_Z_NEAR, p_cam_projection.get_z_near());
@@ -3316,6 +3314,7 @@ void RasterizerSceneGLES3::_render_mrts(Environment *env, const CameraMatrix &p_
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, storage->frame.current_rt->effects.ssao.blur_fbo[0]);
glBlitFramebuffer(0, 0, storage->frame.current_rt->width, storage->frame.current_rt->height, 0, 0, storage->frame.current_rt->width, storage->frame.current_rt->height, GL_COLOR_BUFFER_BIT, GL_LINEAR);
+ state.sss_shader.set_conditional(SubsurfScatteringShaderGLES3::USE_ORTHOGONAL_PROJECTION, p_cam_projection.is_orthogonal());
state.sss_shader.set_conditional(SubsurfScatteringShaderGLES3::USE_11_SAMPLES, subsurface_scatter_quality == SSS_QUALITY_LOW);
state.sss_shader.set_conditional(SubsurfScatteringShaderGLES3::USE_17_SAMPLES, subsurface_scatter_quality == SSS_QUALITY_MEDIUM);
state.sss_shader.set_conditional(SubsurfScatteringShaderGLES3::USE_25_SAMPLES, subsurface_scatter_quality == SSS_QUALITY_HIGH);
@@ -3370,6 +3369,7 @@ void RasterizerSceneGLES3::_render_mrts(Environment *env, const CameraMatrix &p_
//perform SSR
state.ssr_shader.set_conditional(ScreenSpaceReflectionShaderGLES3::REFLECT_ROUGHNESS, env->ssr_roughness);
+ state.ssr_shader.set_conditional(ScreenSpaceReflectionShaderGLES3::USE_ORTHOGONAL_PROJECTION, p_cam_projection.is_orthogonal());
state.ssr_shader.bind();
@@ -3523,6 +3523,7 @@ void RasterizerSceneGLES3::_post_process(Environment *env, const CameraMatrix &p
int vp_h = storage->frame.current_rt->height;
int vp_w = storage->frame.current_rt->width;
+ state.effect_blur_shader.set_conditional(EffectBlurShaderGLES3::USE_ORTHOGONAL_PROJECTION, p_cam_projection.is_orthogonal());
state.effect_blur_shader.set_conditional(EffectBlurShaderGLES3::DOF_FAR_BLUR, true);
state.effect_blur_shader.set_conditional(EffectBlurShaderGLES3::DOF_QUALITY_LOW, env->dof_blur_far_quality == VS::ENV_DOF_BLUR_QUALITY_LOW);
state.effect_blur_shader.set_conditional(EffectBlurShaderGLES3::DOF_QUALITY_MEDIUM, env->dof_blur_far_quality == VS::ENV_DOF_BLUR_QUALITY_MEDIUM);
@@ -3565,6 +3566,7 @@ void RasterizerSceneGLES3::_post_process(Environment *env, const CameraMatrix &p
state.effect_blur_shader.set_conditional(EffectBlurShaderGLES3::DOF_QUALITY_LOW, false);
state.effect_blur_shader.set_conditional(EffectBlurShaderGLES3::DOF_QUALITY_MEDIUM, false);
state.effect_blur_shader.set_conditional(EffectBlurShaderGLES3::DOF_QUALITY_HIGH, false);
+ state.effect_blur_shader.set_conditional(EffectBlurShaderGLES3::USE_ORTHOGONAL_PROJECTION, false);
composite_from = storage->frame.current_rt->effects.mip_maps[0].color;
}
@@ -3577,6 +3579,7 @@ void RasterizerSceneGLES3::_post_process(Environment *env, const CameraMatrix &p
int vp_h = storage->frame.current_rt->height;
int vp_w = storage->frame.current_rt->width;
+ state.effect_blur_shader.set_conditional(EffectBlurShaderGLES3::USE_ORTHOGONAL_PROJECTION, p_cam_projection.is_orthogonal());
state.effect_blur_shader.set_conditional(EffectBlurShaderGLES3::DOF_NEAR_BLUR, true);
state.effect_blur_shader.set_conditional(EffectBlurShaderGLES3::DOF_NEAR_FIRST_TAP, true);
@@ -3652,6 +3655,7 @@ void RasterizerSceneGLES3::_post_process(Environment *env, const CameraMatrix &p
state.effect_blur_shader.set_conditional(EffectBlurShaderGLES3::DOF_QUALITY_LOW, false);
state.effect_blur_shader.set_conditional(EffectBlurShaderGLES3::DOF_QUALITY_MEDIUM, false);
state.effect_blur_shader.set_conditional(EffectBlurShaderGLES3::DOF_QUALITY_HIGH, false);
+ state.effect_blur_shader.set_conditional(EffectBlurShaderGLES3::USE_ORTHOGONAL_PROJECTION, false);
composite_from = storage->frame.current_rt->effects.mip_maps[0].color;
}
@@ -3743,6 +3747,8 @@ void RasterizerSceneGLES3::_post_process(Environment *env, const CameraMatrix &p
SWAP(exposure_shrink[exposure_shrink.size() - 1].color, storage->frame.current_rt->exposure.color);
glViewport(0, 0, storage->frame.current_rt->width, storage->frame.current_rt->height);
+
+ VisualServerRaster::redraw_request(); //if using auto exposure, redraw must happen
}
int max_glow_level = -1;
@@ -4159,7 +4165,7 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const
clear_color = env->bg_color.to_linear();
storage->frame.clear_request = false;
- } else if (env->bg_mode == VS::ENV_BG_SKY) {
+ } else if (env->bg_mode == VS::ENV_BG_SKY || env->bg_mode == VS::ENV_BG_COLOR_SKY) {
sky = storage->sky_owner.getornull(env->sky);
@@ -4167,6 +4173,9 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const
env_radiance_tex = sky->radiance;
}
storage->frame.clear_request = false;
+ if (env->bg_mode == VS::ENV_BG_COLOR_SKY) {
+ clear_color = env->bg_color.to_linear();
+ }
} else {
storage->frame.clear_request = false;
diff --git a/drivers/gles3/rasterizer_scene_gles3.h b/drivers/gles3/rasterizer_scene_gles3.h
index 5503dba5c4..b3fd6fa2a0 100644
--- a/drivers/gles3/rasterizer_scene_gles3.h
+++ b/drivers/gles3/rasterizer_scene_gles3.h
@@ -664,6 +664,7 @@ public:
//bits 12-8 geometry type
SORT_KEY_GEOMETRY_TYPE_SHIFT = 8,
//bits 0-7 for flags
+ SORT_KEY_OPAQUE_PRE_PASS = 8,
SORT_KEY_CULL_DISABLED_FLAG = 4,
SORT_KEY_SKELETON_FLAG = 2,
SORT_KEY_MIRROR_FLAG = 1
@@ -805,9 +806,9 @@ public:
void _render_list(RenderList::Element **p_elements, int p_element_count, const Transform &p_view_transform, const CameraMatrix &p_projection, GLuint p_base_env, bool p_reverse_cull, bool p_alpha_pass, bool p_shadow, bool p_directional_add, bool p_directional_shadows);
- _FORCE_INLINE_ void _add_geometry(RasterizerStorageGLES3::Geometry *p_geometry, InstanceBase *p_instance, RasterizerStorageGLES3::GeometryOwner *p_owner, int p_material, bool p_shadow);
+ _FORCE_INLINE_ void _add_geometry(RasterizerStorageGLES3::Geometry *p_geometry, InstanceBase *p_instance, RasterizerStorageGLES3::GeometryOwner *p_owner, int p_material, bool p_depth_passs);
- _FORCE_INLINE_ void _add_geometry_with_material(RasterizerStorageGLES3::Geometry *p_geometry, InstanceBase *p_instance, RasterizerStorageGLES3::GeometryOwner *p_owner, RasterizerStorageGLES3::Material *p_material, bool p_shadow);
+ _FORCE_INLINE_ void _add_geometry_with_material(RasterizerStorageGLES3::Geometry *p_geometry, InstanceBase *p_instance, RasterizerStorageGLES3::GeometryOwner *p_owner, RasterizerStorageGLES3::Material *p_material, bool p_depth_pass);
void _draw_sky(RasterizerStorageGLES3::Sky *p_sky, const CameraMatrix &p_projection, const Transform &p_transform, bool p_vflip, float p_scale, float p_energy);
@@ -820,7 +821,7 @@ public:
void _copy_to_front_buffer(Environment *env);
void _copy_texture_to_front_buffer(GLuint p_texture); //used for debug
- void _fill_render_list(InstanceBase **p_cull_result, int p_cull_count, bool p_shadow);
+ void _fill_render_list(InstanceBase **p_cull_result, int p_cull_count, bool p_depth_pass);
void _blur_effect_buffer();
void _render_mrts(Environment *env, const CameraMatrix &p_cam_projection);
diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp
index 91ba3aa702..ba380bab7b 100644
--- a/drivers/gles3/rasterizer_storage_gles3.cpp
+++ b/drivers/gles3/rasterizer_storage_gles3.cpp
@@ -165,7 +165,7 @@ Ref<Image> RasterizerStorageGLES3::_get_gl_image_and_format(const Ref<Image> &p_
} break;
case Image::FORMAT_RGB8: {
- r_gl_internal_format = (config.srgb_decode_supported || p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) ? GL_SRGB8 : GL_RGB8;
+ r_gl_internal_format = (config.srgb_decode_supported || (p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)) ? GL_SRGB8 : GL_RGB8;
r_gl_format = GL_RGB;
r_gl_type = GL_UNSIGNED_BYTE;
srgb = true;
@@ -174,7 +174,7 @@ Ref<Image> RasterizerStorageGLES3::_get_gl_image_and_format(const Ref<Image> &p_
case Image::FORMAT_RGBA8: {
r_gl_format = GL_RGBA;
- r_gl_internal_format = (config.srgb_decode_supported || p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) ? GL_SRGB8_ALPHA8 : GL_RGBA8;
+ r_gl_internal_format = (config.srgb_decode_supported || (p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)) ? GL_SRGB8_ALPHA8 : GL_RGBA8;
r_gl_type = GL_UNSIGNED_BYTE;
srgb = true;
@@ -254,7 +254,7 @@ Ref<Image> RasterizerStorageGLES3::_get_gl_image_and_format(const Ref<Image> &p_
if (config.s3tc_supported) {
- r_gl_internal_format = (config.srgb_decode_supported || p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) ? _EXT_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_NV : _EXT_COMPRESSED_RGBA_S3TC_DXT1_EXT;
+ r_gl_internal_format = (config.srgb_decode_supported || (p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)) ? _EXT_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_NV : _EXT_COMPRESSED_RGBA_S3TC_DXT1_EXT;
r_gl_format = GL_RGBA;
r_gl_type = GL_UNSIGNED_BYTE;
r_compressed = true;
@@ -270,7 +270,7 @@ Ref<Image> RasterizerStorageGLES3::_get_gl_image_and_format(const Ref<Image> &p_
if (config.s3tc_supported) {
- r_gl_internal_format = (config.srgb_decode_supported || p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) ? _EXT_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_NV : _EXT_COMPRESSED_RGBA_S3TC_DXT3_EXT;
+ r_gl_internal_format = (config.srgb_decode_supported || (p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)) ? _EXT_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_NV : _EXT_COMPRESSED_RGBA_S3TC_DXT3_EXT;
r_gl_format = GL_RGBA;
r_gl_type = GL_UNSIGNED_BYTE;
r_compressed = true;
@@ -286,7 +286,7 @@ Ref<Image> RasterizerStorageGLES3::_get_gl_image_and_format(const Ref<Image> &p_
if (config.s3tc_supported) {
- r_gl_internal_format = (config.srgb_decode_supported || p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) ? _EXT_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_NV : _EXT_COMPRESSED_RGBA_S3TC_DXT5_EXT;
+ r_gl_internal_format = (config.srgb_decode_supported || (p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)) ? _EXT_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_NV : _EXT_COMPRESSED_RGBA_S3TC_DXT5_EXT;
r_gl_format = GL_RGBA;
r_gl_type = GL_UNSIGNED_BYTE;
r_compressed = true;
@@ -331,7 +331,7 @@ Ref<Image> RasterizerStorageGLES3::_get_gl_image_and_format(const Ref<Image> &p_
if (config.bptc_supported) {
- r_gl_internal_format = (config.srgb_decode_supported || p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) ? _EXT_COMPRESSED_SRGB_ALPHA_BPTC_UNORM : _EXT_COMPRESSED_RGBA_BPTC_UNORM;
+ r_gl_internal_format = (config.srgb_decode_supported || (p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)) ? _EXT_COMPRESSED_SRGB_ALPHA_BPTC_UNORM : _EXT_COMPRESSED_RGBA_BPTC_UNORM;
r_gl_format = GL_RGBA;
r_gl_type = GL_UNSIGNED_BYTE;
r_compressed = true;
@@ -371,7 +371,7 @@ Ref<Image> RasterizerStorageGLES3::_get_gl_image_and_format(const Ref<Image> &p_
if (config.pvrtc_supported) {
- r_gl_internal_format = (config.srgb_decode_supported || p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) ? _EXT_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT : _EXT_COMPRESSED_RGB_PVRTC_2BPPV1_IMG;
+ r_gl_internal_format = (config.srgb_decode_supported || (p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)) ? _EXT_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT : _EXT_COMPRESSED_RGB_PVRTC_2BPPV1_IMG;
r_gl_format = GL_RGBA;
r_gl_type = GL_UNSIGNED_BYTE;
r_compressed = true;
@@ -386,7 +386,7 @@ Ref<Image> RasterizerStorageGLES3::_get_gl_image_and_format(const Ref<Image> &p_
if (config.pvrtc_supported) {
- r_gl_internal_format = (config.srgb_decode_supported || p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) ? _EXT_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT : _EXT_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;
+ r_gl_internal_format = (config.srgb_decode_supported || (p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)) ? _EXT_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT : _EXT_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;
r_gl_format = GL_RGBA;
r_gl_type = GL_UNSIGNED_BYTE;
r_compressed = true;
@@ -402,7 +402,7 @@ Ref<Image> RasterizerStorageGLES3::_get_gl_image_and_format(const Ref<Image> &p_
if (config.pvrtc_supported) {
- r_gl_internal_format = (config.srgb_decode_supported || p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) ? _EXT_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT : _EXT_COMPRESSED_RGB_PVRTC_4BPPV1_IMG;
+ r_gl_internal_format = (config.srgb_decode_supported || (p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)) ? _EXT_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT : _EXT_COMPRESSED_RGB_PVRTC_4BPPV1_IMG;
r_gl_format = GL_RGBA;
r_gl_type = GL_UNSIGNED_BYTE;
r_compressed = true;
@@ -418,7 +418,7 @@ Ref<Image> RasterizerStorageGLES3::_get_gl_image_and_format(const Ref<Image> &p_
if (config.pvrtc_supported) {
- r_gl_internal_format = (config.srgb_decode_supported || p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) ? _EXT_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT : _EXT_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;
+ r_gl_internal_format = (config.srgb_decode_supported || (p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)) ? _EXT_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT : _EXT_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;
r_gl_format = GL_RGBA;
r_gl_type = GL_UNSIGNED_BYTE;
r_compressed = true;
@@ -503,7 +503,7 @@ Ref<Image> RasterizerStorageGLES3::_get_gl_image_and_format(const Ref<Image> &p_
if (config.etc2_supported) {
- r_gl_internal_format = (config.srgb_decode_supported || p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) ? _EXT_COMPRESSED_SRGB8_ETC2 : _EXT_COMPRESSED_RGB8_ETC2;
+ r_gl_internal_format = (config.srgb_decode_supported || (p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)) ? _EXT_COMPRESSED_SRGB8_ETC2 : _EXT_COMPRESSED_RGB8_ETC2;
r_gl_format = GL_RGB;
r_gl_type = GL_UNSIGNED_BYTE;
r_compressed = true;
@@ -518,7 +518,7 @@ Ref<Image> RasterizerStorageGLES3::_get_gl_image_and_format(const Ref<Image> &p_
if (config.etc2_supported) {
- r_gl_internal_format = (config.srgb_decode_supported || p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) ? _EXT_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC : _EXT_COMPRESSED_RGBA8_ETC2_EAC;
+ r_gl_internal_format = (config.srgb_decode_supported || (p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)) ? _EXT_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC : _EXT_COMPRESSED_RGBA8_ETC2_EAC;
r_gl_format = GL_RGBA;
r_gl_type = GL_UNSIGNED_BYTE;
r_compressed = true;
@@ -533,7 +533,7 @@ Ref<Image> RasterizerStorageGLES3::_get_gl_image_and_format(const Ref<Image> &p_
if (config.etc2_supported) {
- r_gl_internal_format = (config.srgb_decode_supported || p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) ? _EXT_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 : _EXT_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2;
+ r_gl_internal_format = (config.srgb_decode_supported || (p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)) ? _EXT_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 : _EXT_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2;
r_gl_format = GL_RGBA;
r_gl_type = GL_UNSIGNED_BYTE;
r_compressed = true;
@@ -560,7 +560,7 @@ Ref<Image> RasterizerStorageGLES3::_get_gl_image_and_format(const Ref<Image> &p_
}
r_gl_format = GL_RGBA;
- r_gl_internal_format = (config.srgb_decode_supported || p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) ? GL_SRGB8_ALPHA8 : GL_RGBA8;
+ r_gl_internal_format = (config.srgb_decode_supported || (p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)) ? GL_SRGB8_ALPHA8 : GL_RGBA8;
r_gl_type = GL_UNSIGNED_BYTE;
r_compressed = false;
srgb = true;
@@ -686,7 +686,7 @@ void RasterizerStorageGLES3::texture_set_data(RID p_texture, const Ref<Image> &p
texture->ignore_mipmaps = compressed && !img->has_mipmaps();
- if (texture->flags & VS::TEXTURE_FLAG_MIPMAPS && !texture->ignore_mipmaps)
+ if ((texture->flags & VS::TEXTURE_FLAG_MIPMAPS) && !texture->ignore_mipmaps)
glTexParameteri(texture->target, GL_TEXTURE_MIN_FILTER, config.use_fast_texture_filter ? GL_LINEAR_MIPMAP_NEAREST : GL_LINEAR_MIPMAP_LINEAR);
else {
if (texture->flags & VS::TEXTURE_FLAG_FILTER) {
@@ -717,7 +717,7 @@ void RasterizerStorageGLES3::texture_set_data(RID p_texture, const Ref<Image> &p
glTexParameteri(texture->target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); // raw Filtering
}
- if ((texture->flags & VS::TEXTURE_FLAG_REPEAT || texture->flags & VS::TEXTURE_FLAG_MIRRORED_REPEAT) && texture->target != GL_TEXTURE_CUBE_MAP) {
+ if (((texture->flags & VS::TEXTURE_FLAG_REPEAT) || (texture->flags & VS::TEXTURE_FLAG_MIRRORED_REPEAT)) && texture->target != GL_TEXTURE_CUBE_MAP) {
if (texture->flags & VS::TEXTURE_FLAG_MIRRORED_REPEAT) {
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT);
@@ -770,7 +770,7 @@ void RasterizerStorageGLES3::texture_set_data(RID p_texture, const Ref<Image> &p
}
}
- int mipmaps = (texture->flags & VS::TEXTURE_FLAG_MIPMAPS && img->has_mipmaps()) ? img->get_mipmap_count() + 1 : 1;
+ int mipmaps = ((texture->flags & VS::TEXTURE_FLAG_MIPMAPS) && img->has_mipmaps()) ? img->get_mipmap_count() + 1 : 1;
int w = img->get_width();
int h = img->get_height();
@@ -820,7 +820,7 @@ void RasterizerStorageGLES3::texture_set_data(RID p_texture, const Ref<Image> &p
texture->stored_cube_sides |= (1 << p_cube_side);
- if (texture->flags & VS::TEXTURE_FLAG_MIPMAPS && mipmaps == 1 && !texture->ignore_mipmaps && (!(texture->flags & VS::TEXTURE_FLAG_CUBEMAP) || texture->stored_cube_sides == (1 << 6) - 1)) {
+ if ((texture->flags & VS::TEXTURE_FLAG_MIPMAPS) && mipmaps == 1 && !texture->ignore_mipmaps && (!(texture->flags & VS::TEXTURE_FLAG_CUBEMAP) || texture->stored_cube_sides == (1 << 6) - 1)) {
//generate mipmaps if they were requested and the image does not contain them
glGenerateMipmap(texture->target);
} else if (mipmaps > 1) {
@@ -912,7 +912,7 @@ void RasterizerStorageGLES3::texture_set_flags(RID p_texture, uint32_t p_flags)
uint32_t cube = texture->flags & VS::TEXTURE_FLAG_CUBEMAP;
texture->flags = p_flags | cube; // can't remove a cube from being a cube
- if ((texture->flags & VS::TEXTURE_FLAG_REPEAT || texture->flags & VS::TEXTURE_FLAG_MIRRORED_REPEAT) && texture->target != GL_TEXTURE_CUBE_MAP) {
+ if (((texture->flags & VS::TEXTURE_FLAG_REPEAT) || (texture->flags & VS::TEXTURE_FLAG_MIRRORED_REPEAT)) && texture->target != GL_TEXTURE_CUBE_MAP) {
if (texture->flags & VS::TEXTURE_FLAG_MIRRORED_REPEAT) {
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT);
@@ -937,7 +937,7 @@ void RasterizerStorageGLES3::texture_set_flags(RID p_texture, uint32_t p_flags)
}
}
- if (texture->flags & VS::TEXTURE_FLAG_MIPMAPS && !texture->ignore_mipmaps) {
+ if ((texture->flags & VS::TEXTURE_FLAG_MIPMAPS) && !texture->ignore_mipmaps) {
if (!had_mipmaps && texture->mipmaps == 1) {
glGenerateMipmap(texture->target);
}
@@ -1584,6 +1584,7 @@ void RasterizerStorageGLES3::_update_shader(Shader *p_shader) const {
shaders.actions_canvas.usage_flag_pointers["SCREEN_UV"] = &p_shader->canvas_item.uses_screen_uv;
shaders.actions_canvas.usage_flag_pointers["SCREEN_PIXEL_SIZE"] = &p_shader->canvas_item.uses_screen_uv;
shaders.actions_canvas.usage_flag_pointers["SCREEN_TEXTURE"] = &p_shader->canvas_item.uses_screen_texture;
+ shaders.actions_canvas.usage_flag_pointers["TIME"] = &p_shader->canvas_item.uses_time;
actions = &shaders.actions_canvas;
actions->uniforms = &p_shader->uniforms;
@@ -1632,6 +1633,7 @@ void RasterizerStorageGLES3::_update_shader(Shader *p_shader) const {
shaders.actions_scene.usage_flag_pointers["SSS_STRENGTH"] = &p_shader->spatial.uses_sss;
shaders.actions_scene.usage_flag_pointers["DISCARD"] = &p_shader->spatial.uses_discard;
shaders.actions_scene.usage_flag_pointers["SCREEN_TEXTURE"] = &p_shader->spatial.uses_screen_texture;
+ shaders.actions_scene.usage_flag_pointers["TIME"] = &p_shader->spatial.uses_time;
shaders.actions_scene.write_flag_pointers["MODELVIEW_MATRIX"] = &p_shader->spatial.writes_modelview_or_projection;
shaders.actions_scene.write_flag_pointers["PROJECTION_MATRIX"] = &p_shader->spatial.writes_modelview_or_projection;
@@ -3358,7 +3360,7 @@ Rect3 RasterizerStorageGLES3::mesh_get_aabb(RID p_mesh, RID p_skeleton) const {
for (int i = 0; i < mesh->surfaces.size(); i++) {
Rect3 laabb;
- if (mesh->surfaces[i]->format & VS::ARRAY_FORMAT_BONES && mesh->surfaces[i]->skeleton_bone_aabb.size()) {
+ if ((mesh->surfaces[i]->format & VS::ARRAY_FORMAT_BONES) && mesh->surfaces[i]->skeleton_bone_aabb.size()) {
int bs = mesh->surfaces[i]->skeleton_bone_aabb.size();
const Rect3 *skbones = mesh->surfaces[i]->skeleton_bone_aabb.ptr();
@@ -4471,6 +4473,7 @@ RID RasterizerStorageGLES3::light_create(VS::LightType p_type) {
light->omni_shadow_mode = VS::LIGHT_OMNI_SHADOW_DUAL_PARABOLOID;
light->omni_shadow_detail = VS::LIGHT_OMNI_SHADOW_DETAIL_VERTICAL;
light->directional_blend_splits = false;
+ light->directional_range_mode = VS::LIGHT_DIRECTIONAL_SHADOW_DEPTH_RANGE_STABLE;
light->reverse_cull = false;
light->version = 0;
@@ -4623,6 +4626,22 @@ VS::LightDirectionalShadowMode RasterizerStorageGLES3::light_directional_get_sha
return light->directional_shadow_mode;
}
+void RasterizerStorageGLES3::light_directional_set_shadow_depth_range_mode(RID p_light, VS::LightDirectionalShadowDepthRangeMode p_range_mode) {
+
+ Light *light = light_owner.getornull(p_light);
+ ERR_FAIL_COND(!light);
+
+ light->directional_range_mode = p_range_mode;
+}
+
+VS::LightDirectionalShadowDepthRangeMode RasterizerStorageGLES3::light_directional_get_shadow_depth_range_mode(RID p_light) const {
+
+ const Light *light = light_owner.getornull(p_light);
+ ERR_FAIL_COND_V(!light, VS::LIGHT_DIRECTIONAL_SHADOW_DEPTH_RANGE_STABLE);
+
+ return light->directional_range_mode;
+}
+
VS::LightType RasterizerStorageGLES3::light_get_type(RID p_light) const {
const Light *light = light_owner.getornull(p_light);
@@ -6845,42 +6864,28 @@ int RasterizerStorageGLES3::get_captured_render_info(VS::RenderInfo p_info) {
int RasterizerStorageGLES3::get_render_info(VS::RenderInfo p_info) {
switch (p_info) {
- case VS::INFO_OBJECTS_IN_FRAME: {
-
+ case VS::INFO_OBJECTS_IN_FRAME:
return info.render_final.object_count;
- } break;
- case VS::INFO_VERTICES_IN_FRAME: {
-
+ case VS::INFO_VERTICES_IN_FRAME:
return info.render_final.vertices_count;
- } break;
- case VS::INFO_MATERIAL_CHANGES_IN_FRAME: {
+ case VS::INFO_MATERIAL_CHANGES_IN_FRAME:
return info.render_final.material_switch_count;
- } break;
- case VS::INFO_SHADER_CHANGES_IN_FRAME: {
+ case VS::INFO_SHADER_CHANGES_IN_FRAME:
return info.render_final.shader_rebind_count;
- } break;
- case VS::INFO_SURFACE_CHANGES_IN_FRAME: {
+ case VS::INFO_SURFACE_CHANGES_IN_FRAME:
return info.render_final.surface_switch_count;
- } break;
- case VS::INFO_DRAW_CALLS_IN_FRAME: {
+ case VS::INFO_DRAW_CALLS_IN_FRAME:
return info.render_final.draw_call_count;
- } break;
- case VS::INFO_USAGE_VIDEO_MEM_TOTAL: {
-
+ case VS::INFO_USAGE_VIDEO_MEM_TOTAL:
return 0; //no idea
- } break;
- case VS::INFO_VIDEO_MEM_USED: {
-
+ case VS::INFO_VIDEO_MEM_USED:
return info.vertex_mem + info.texture_mem;
- } break;
- case VS::INFO_TEXTURE_MEM_USED: {
-
+ case VS::INFO_TEXTURE_MEM_USED:
return info.texture_mem;
- } break;
- case VS::INFO_VERTEX_MEM_USED: {
-
+ case VS::INFO_VERTEX_MEM_USED:
return info.vertex_mem;
- } break;
+ default:
+ return 0; //no idea either
}
}
diff --git a/drivers/gles3/rasterizer_storage_gles3.h b/drivers/gles3/rasterizer_storage_gles3.h
index f75b77aabe..6abc22b643 100644
--- a/drivers/gles3/rasterizer_storage_gles3.h
+++ b/drivers/gles3/rasterizer_storage_gles3.h
@@ -410,6 +410,7 @@ public:
int light_mode;
bool uses_screen_texture;
bool uses_screen_uv;
+ bool uses_time;
} canvas_item;
@@ -449,6 +450,7 @@ public:
bool uses_discard;
bool uses_sss;
bool uses_screen_texture;
+ bool uses_time;
bool writes_modelview_or_projection;
bool uses_vertex_lighting;
@@ -877,6 +879,7 @@ public:
VS::LightOmniShadowMode omni_shadow_mode;
VS::LightOmniShadowDetail omni_shadow_detail;
VS::LightDirectionalShadowMode directional_shadow_mode;
+ VS::LightDirectionalShadowDepthRangeMode directional_range_mode;
bool directional_blend_splits;
uint64_t version;
};
@@ -904,6 +907,9 @@ public:
virtual VS::LightDirectionalShadowMode light_directional_get_shadow_mode(RID p_light);
virtual VS::LightOmniShadowMode light_omni_get_shadow_mode(RID p_light);
+ virtual void light_directional_set_shadow_depth_range_mode(RID p_light, VS::LightDirectionalShadowDepthRangeMode p_range_mode);
+ virtual VS::LightDirectionalShadowDepthRangeMode light_directional_get_shadow_depth_range_mode(RID p_light) const;
+
virtual bool light_has_shadow(RID p_light) const;
virtual VS::LightType light_get_type(RID p_light) const;
diff --git a/drivers/gles3/shader_compiler_gles3.cpp b/drivers/gles3/shader_compiler_gles3.cpp
index bdd54543d2..419decce29 100644
--- a/drivers/gles3/shader_compiler_gles3.cpp
+++ b/drivers/gles3/shader_compiler_gles3.cpp
@@ -438,26 +438,44 @@ String ShaderCompilerGLES3::_dump_node_code(SL::Node *p_node, int p_level, Gener
SL::BlockNode *bnode = (SL::BlockNode *)p_node;
//variables
- code += _mktab(p_level - 1) + "{\n";
- for (Map<StringName, SL::BlockNode::Variable>::Element *E = bnode->variables.front(); E; E = E->next()) {
-
- code += _mktab(p_level) + _prestr(E->get().precision) + _typestr(E->get().type) + " " + _mkid(E->key()) + ";\n";
+ if (!bnode->single_statement) {
+ code += _mktab(p_level - 1) + "{\n";
}
-
+
for (int i = 0; i < bnode->statements.size(); i++) {
String scode = _dump_node_code(bnode->statements[i], p_level, r_gen_code, p_actions, p_default_actions);
- if (bnode->statements[i]->type == SL::Node::TYPE_CONTROL_FLOW || bnode->statements[i]->type == SL::Node::TYPE_CONTROL_FLOW) {
- // FIXME: if (A || A) ? I am hesitant to delete one of them, could be copy-paste error.
+ if (bnode->statements[i]->type == SL::Node::TYPE_CONTROL_FLOW || bnode->single_statement ) {
code += scode; //use directly
} else {
code += _mktab(p_level) + scode + ";\n";
}
}
- code += _mktab(p_level - 1) + "}\n";
+ if (!bnode->single_statement) {
+ code += _mktab(p_level - 1) + "}\n";
+ }
} break;
+ case SL::Node::TYPE_VARIABLE_DECLARATION: {
+ SL::VariableDeclarationNode *vdnode = (SL::VariableDeclarationNode *)p_node;
+
+ String declaration = _prestr(vdnode->precision) + _typestr(vdnode->datatype);
+ for(int i=0;i<vdnode->declarations.size();i++) {
+ if (i>0) {
+ declaration+=",";
+ } else {
+ declaration+=" ";
+ }
+ declaration += _mkid(vdnode->declarations[i].name);
+ if (vdnode->declarations[i].initializer) {
+ declaration+="=";
+ declaration+=_dump_node_code(vdnode->declarations[i].initializer, p_level, r_gen_code, p_actions, p_default_actions);
+ }
+ }
+
+ code+=declaration;
+ } break;
case SL::Node::TYPE_VARIABLE: {
SL::VariableNode *vnode = (SL::VariableNode *)p_node;
@@ -600,6 +618,13 @@ String ShaderCompilerGLES3::_dump_node_code(SL::Node *p_node, int p_level, Gener
code += _mktab(p_level) + "while (" + _dump_node_code(cfnode->expressions[0], p_level, r_gen_code, p_actions, p_default_actions) + ")\n";
code += _dump_node_code(cfnode->blocks[0], p_level + 1, r_gen_code, p_actions, p_default_actions);
+ } else if (cfnode->flow_op == SL::FLOW_OP_FOR) {
+
+ String left = _dump_node_code(cfnode->blocks[0], p_level, r_gen_code, p_actions, p_default_actions);
+ String middle = _dump_node_code(cfnode->expressions[0], p_level, r_gen_code, p_actions, p_default_actions);
+ String right = _dump_node_code(cfnode->expressions[1], p_level, r_gen_code, p_actions, p_default_actions);
+ code += _mktab(p_level) + "for (" +left+";"+middle+";"+right+")\n";
+ code += _dump_node_code(cfnode->blocks[1], p_level + 1, r_gen_code, p_actions, p_default_actions);
} else if (cfnode->flow_op == SL::FLOW_OP_RETURN) {
@@ -611,6 +636,12 @@ String ShaderCompilerGLES3::_dump_node_code(SL::Node *p_node, int p_level, Gener
} else if (cfnode->flow_op == SL::FLOW_OP_DISCARD) {
code = "discard;";
+ } else if (cfnode->flow_op == SL::FLOW_OP_CONTINUE) {
+
+ code = "continue;";
+ } else if (cfnode->flow_op == SL::FLOW_OP_BREAK) {
+
+ code = "break;";
}
} break;
diff --git a/drivers/gles3/shaders/canvas.glsl b/drivers/gles3/shaders/canvas.glsl
index 3bcfd24383..bf8eaf601d 100644
--- a/drivers/gles3/shaders/canvas.glsl
+++ b/drivers/gles3/shaders/canvas.glsl
@@ -116,7 +116,7 @@ void main() {
#ifdef USE_TEXTURE_RECT
- if (dst_rect.z < 0) { // Transpose is encoded as negative dst_rect.z
+ if (dst_rect.z < 0.0) { // Transpose is encoded as negative dst_rect.z
uv_interp = src_rect.xy + abs(src_rect.zw) * vertex.yx;
} else {
uv_interp = src_rect.xy + abs(src_rect.zw) * vertex;
@@ -139,7 +139,7 @@ void main() {
float frame_w = 1.0/float(h_frames);
float frame_h = 1.0/float(v_frames);
uv_interp.x = uv_interp.x * frame_w + frame_w * float(frame % h_frames);
- uv_interp.y = uv_interp.y * frame_h + frame_h * float(frame / v_frames);
+ uv_interp.y = uv_interp.y * frame_h + frame_h * float(frame / h_frames);
#endif
diff --git a/drivers/gles3/shaders/effect_blur.glsl b/drivers/gles3/shaders/effect_blur.glsl
index 09e522866c..b5f98a1244 100644
--- a/drivers/gles3/shaders/effect_blur.glsl
+++ b/drivers/gles3/shaders/effect_blur.glsl
@@ -168,7 +168,11 @@ void main() {
float depth = textureLod( dof_source_depth, uv_interp, 0.0).r;
depth = depth * 2.0 - 1.0;
+#ifdef USE_ORTHOGONAL_PROJECTION
+ depth = ((depth + (camera_z_far + camera_z_near)/(camera_z_far - camera_z_near)) * (camera_z_far - camera_z_near))/2.0;
+#else
depth = 2.0 * camera_z_near * camera_z_far / (camera_z_far + camera_z_near - depth * (camera_z_far - camera_z_near));
+#endif
float amount = smoothstep(dof_begin,dof_end,depth);
float k_accum=0.0;
@@ -182,8 +186,11 @@ void main() {
float tap_depth = texture( dof_source_depth, tap_uv, 0.0).r;
tap_depth = tap_depth * 2.0 - 1.0;
+#ifdef USE_ORTHOGONAL_PROJECTION
+ tap_depth = ((tap_depth + (camera_z_far + camera_z_near)/(camera_z_far - camera_z_near)) * (camera_z_far - camera_z_near))/2.0;
+#else
tap_depth = 2.0 * camera_z_near * camera_z_far / (camera_z_far + camera_z_near - tap_depth * (camera_z_far - camera_z_near));
-
+#endif
float tap_amount = mix(smoothstep(dof_begin,dof_end,tap_depth),1.0,int_ofs==0);
tap_amount*=tap_amount*tap_amount; //prevent undesired glow effect
@@ -221,7 +228,11 @@ void main() {
float tap_depth = texture( dof_source_depth, tap_uv, 0.0).r;
tap_depth = tap_depth * 2.0 - 1.0;
+#ifdef USE_ORTHOGONAL_PROJECTION
+ tap_depth = ((tap_depth + (camera_z_far + camera_z_near)/(camera_z_far - camera_z_near)) * (camera_z_far - camera_z_near))/2.0;
+#else
tap_depth = 2.0 * camera_z_near * camera_z_far / (camera_z_far + camera_z_near - tap_depth * (camera_z_far - camera_z_near));
+#endif
float tap_amount = 1.0-smoothstep(dof_end,dof_begin,tap_depth);
tap_amount*=tap_amount*tap_amount; //prevent undesired glow effect
diff --git a/drivers/gles3/shaders/scene.glsl b/drivers/gles3/shaders/scene.glsl
index 7c60a8ee97..73268c1914 100644
--- a/drivers/gles3/shaders/scene.glsl
+++ b/drivers/gles3/shaders/scene.glsl
@@ -484,7 +484,7 @@ VERTEX_SHADER_CODE
vec3 directional_diffuse = vec3(0.0);
vec3 directional_specular = vec3(0.0);
- light_compute(normal_interp,-light_direction_attenuation.xyz,-normalize( vertex_interp ),normal_interp,roughness,directional_diffuse,directional_specular);
+ light_compute(normal_interp,-light_direction_attenuation.xyz,-normalize( vertex_interp ),light_color_energy.rgb,roughness,directional_diffuse,directional_specular);
float diff_avg = dot(diffuse_light_interp.rgb,vec3(0.33333));
float diff_dir_avg = dot(directional_diffuse,vec3(0.33333));
@@ -1590,6 +1590,12 @@ FRAGMENT_SHADER_CODE
}
#endif
+#ifdef USE_OPAQUE_PREPASS
+
+ if (alpha<0.99) {
+ discard;
+ }
+#endif
#if defined(ENABLE_NORMALMAP)
@@ -1691,9 +1697,16 @@ FRAGMENT_SHADER_CODE
vec3 light_attenuation=vec3(1.0);
+ float depth_z = -vertex.z;
#ifdef LIGHT_DIRECTIONAL_SHADOW
- if (gl_FragCoord.w > shadow_split_offsets.w) {
+#ifdef LIGHT_USE_PSSM4
+ if (depth_z < shadow_split_offsets.w) {
+#elif defined(LIGHT_USE_PSSM2)
+ if (depth_z < shadow_split_offsets.y) {
+#else
+ if (depth_z < shadow_split_offsets.x) {
+#endif //LIGHT_USE_PSSM4
vec3 pssm_coord;
float pssm_fade=0.0;
@@ -1702,17 +1715,15 @@ FRAGMENT_SHADER_CODE
float pssm_blend;
vec3 pssm_coord2;
bool use_blend=true;
- vec3 light_pssm_split_inv = 1.0/shadow_split_offsets.xyz;
- float w_inv = 1.0/gl_FragCoord.w;
#endif
#ifdef LIGHT_USE_PSSM4
- if (gl_FragCoord.w > shadow_split_offsets.y) {
+ if (depth_z < shadow_split_offsets.y) {
- if (gl_FragCoord.w > shadow_split_offsets.x) {
+ if (depth_z < shadow_split_offsets.x) {
highp vec4 splane=(shadow_matrix1 * vec4(vertex,1.0));
pssm_coord=splane.xyz/splane.w;
@@ -1722,7 +1733,7 @@ FRAGMENT_SHADER_CODE
splane=(shadow_matrix2 * vec4(vertex,1.0));
pssm_coord2=splane.xyz/splane.w;
- pssm_blend=smoothstep(0.0,light_pssm_split_inv.x,w_inv);
+ pssm_blend=smoothstep(0.0,shadow_split_offsets.x,depth_z);
#endif
} else {
@@ -1733,14 +1744,14 @@ FRAGMENT_SHADER_CODE
#if defined(LIGHT_USE_PSSM_BLEND)
splane=(shadow_matrix3 * vec4(vertex,1.0));
pssm_coord2=splane.xyz/splane.w;
- pssm_blend=smoothstep(light_pssm_split_inv.x,light_pssm_split_inv.y,w_inv);
+ pssm_blend=smoothstep(shadow_split_offsets.x,shadow_split_offsets.y,depth_z);
#endif
}
} else {
- if (gl_FragCoord.w > shadow_split_offsets.z) {
+ if (depth_z < shadow_split_offsets.z) {
highp vec4 splane=(shadow_matrix3 * vec4(vertex,1.0));
pssm_coord=splane.xyz/splane.w;
@@ -1748,13 +1759,14 @@ FRAGMENT_SHADER_CODE
#if defined(LIGHT_USE_PSSM_BLEND)
splane=(shadow_matrix4 * vec4(vertex,1.0));
pssm_coord2=splane.xyz/splane.w;
- pssm_blend=smoothstep(light_pssm_split_inv.y,light_pssm_split_inv.z,w_inv);
+ pssm_blend=smoothstep(shadow_split_offsets.y,shadow_split_offsets.z,depth_z);
#endif
} else {
+
highp vec4 splane=(shadow_matrix4 * vec4(vertex,1.0));
pssm_coord=splane.xyz/splane.w;
- pssm_fade = smoothstep(shadow_split_offsets.z,shadow_split_offsets.w,gl_FragCoord.w);
+ pssm_fade = smoothstep(shadow_split_offsets.z,shadow_split_offsets.w,depth_z);
#if defined(LIGHT_USE_PSSM_BLEND)
use_blend=false;
@@ -1770,7 +1782,7 @@ FRAGMENT_SHADER_CODE
#ifdef LIGHT_USE_PSSM2
- if (gl_FragCoord.w > shadow_split_offsets.x) {
+ if (depth_z < shadow_split_offsets.x) {
highp vec4 splane=(shadow_matrix1 * vec4(vertex,1.0));
pssm_coord=splane.xyz/splane.w;
@@ -1780,13 +1792,13 @@ FRAGMENT_SHADER_CODE
splane=(shadow_matrix2 * vec4(vertex,1.0));
pssm_coord2=splane.xyz/splane.w;
- pssm_blend=smoothstep(0.0,light_pssm_split_inv.x,w_inv);
+ pssm_blend=smoothstep(0.0,shadow_split_offsets.x,depth_z);
#endif
} else {
highp vec4 splane=(shadow_matrix2 * vec4(vertex,1.0));
pssm_coord=splane.xyz/splane.w;
- pssm_fade = smoothstep(shadow_split_offsets.x,shadow_split_offsets.y,gl_FragCoord.w);
+ pssm_fade = smoothstep(shadow_split_offsets.x,shadow_split_offsets.y,depth_z);
#if defined(LIGHT_USE_PSSM_BLEND)
use_blend=false;
@@ -1828,6 +1840,7 @@ FRAGMENT_SHADER_CODE
}
+
#endif //LIGHT_DIRECTIONAL_SHADOW
#ifdef USE_VERTEX_LIGHTING
diff --git a/drivers/gles3/shaders/screen_space_reflection.glsl b/drivers/gles3/shaders/screen_space_reflection.glsl
index cc41d36c37..b2e6f7a736 100644
--- a/drivers/gles3/shaders/screen_space_reflection.glsl
+++ b/drivers/gles3/shaders/screen_space_reflection.glsl
@@ -56,7 +56,6 @@ vec2 view_to_screen(vec3 view_pos,out float w) {
#define M_PI 3.14159265359
-
void main() {
@@ -158,8 +157,13 @@ void main() {
w+=w_advance;
//convert to linear depth
+
depth = texture(source_depth, pos*pixel_size).r * 2.0 - 1.0;
+#ifdef USE_ORTHOGONAL_PROJECTION
+ depth = ((depth + (camera_z_far + camera_z_near)/(camera_z_far - camera_z_near)) * (camera_z_far - camera_z_near))/2.0;
+#else
depth = 2.0 * camera_z_near * camera_z_far / (camera_z_far + camera_z_near - depth * (camera_z_far - camera_z_near));
+#endif
depth=-depth;
z_from = z_to;
diff --git a/drivers/gles3/shaders/ssao.glsl b/drivers/gles3/shaders/ssao.glsl
index 0e8fc89d6c..c668e63745 100644
--- a/drivers/gles3/shaders/ssao.glsl
+++ b/drivers/gles3/shaders/ssao.glsl
@@ -65,7 +65,12 @@ layout(location = 0) out float visibility;
uniform vec4 proj_info;
vec3 reconstructCSPosition(vec2 S, float z) {
- return vec3((S.xy * proj_info.xy + proj_info.zw) * z, z);
+#ifdef USE_ORTHOGONAL_PROJECTION
+ return vec3((S.xy * proj_info.xy + proj_info.zw), z);
+#else
+ return vec3((S.xy * proj_info.xy + proj_info.zw) * z, z);
+
+#endif
}
vec3 getPosition(ivec2 ssP) {
@@ -73,7 +78,11 @@ vec3 getPosition(ivec2 ssP) {
P.z = texelFetch(source_depth, ssP, 0).r;
P.z = P.z * 2.0 - 1.0;
+#ifdef USE_ORTHOGONAL_PROJECTION
+ P.z = ((P.z + (camera_z_far + camera_z_near)/(camera_z_far - camera_z_near)) * (camera_z_far - camera_z_near))/2.0;
+#else
P.z = 2.0 * camera_z_near * camera_z_far / (camera_z_far + camera_z_near - P.z * (camera_z_far - camera_z_near));
+#endif
P.z = -P.z;
// Offset to pixel center
@@ -118,7 +127,12 @@ vec3 getOffsetPosition(ivec2 ssC, vec2 unitOffset, float ssR) {
//read from depth buffer
P.z = texelFetch(source_depth, mipP, 0).r;
P.z = P.z * 2.0 - 1.0;
+#ifdef USE_ORTHOGONAL_PROJECTION
+ P.z = ((P.z + (camera_z_far + camera_z_near)/(camera_z_far - camera_z_near)) * (camera_z_far - camera_z_near))/2.0;
+#else
P.z = 2.0 * camera_z_near * camera_z_far / (camera_z_far + camera_z_near - P.z * (camera_z_far - camera_z_near));
+
+#endif
P.z = -P.z;
} else {
@@ -214,8 +228,11 @@ void main() {
// Choose the screen-space sample radius
// proportional to the projected area of the sphere
+#ifdef USE_ORTHOGONAL_PROJECTION
+ float ssDiskRadius = -proj_scale * radius;
+#else
float ssDiskRadius = -proj_scale * radius / C.z;
-
+#endif
float sum = 0.0;
for (int i = 0; i < NUM_SAMPLES; ++i) {
sum += sampleAO(ssC, C, n_C, ssDiskRadius, radius,i, randomPatternRotationAngle);
diff --git a/drivers/gles3/shaders/ssao_minify.glsl b/drivers/gles3/shaders/ssao_minify.glsl
index 6e46a1842c..647c762438 100644
--- a/drivers/gles3/shaders/ssao_minify.glsl
+++ b/drivers/gles3/shaders/ssao_minify.glsl
@@ -41,7 +41,11 @@ void main() {
#ifdef MINIFY_START
float fdepth = texelFetch(source_depth, clamp(ssP * 2 + ivec2(ssP.y & 1, ssP.x & 1), ivec2(0), from_size - ivec2(1)), source_mipmap).r;
fdepth = fdepth * 2.0 - 1.0;
+#ifdef USE_ORTHOGONAL_PROJECTION
+ fdepth = ((fdepth + (camera_z_far + camera_z_near)/(camera_z_far - camera_z_near)) * (camera_z_far - camera_z_near))/2.0;
+#else
fdepth = 2.0 * camera_z_near * camera_z_far / (camera_z_far + camera_z_near - fdepth * (camera_z_far - camera_z_near));
+#endif
fdepth /= camera_z_far;
depth = uint(clamp(fdepth*65535.0,0.0,65535.0));
diff --git a/drivers/gles3/shaders/subsurf_scattering.glsl b/drivers/gles3/shaders/subsurf_scattering.glsl
index 8873443727..20c3b7473f 100644
--- a/drivers/gles3/shaders/subsurf_scattering.glsl
+++ b/drivers/gles3/shaders/subsurf_scattering.glsl
@@ -17,36 +17,36 @@ void main() {
//#define QUALIFIER uniform // some guy on the interweb says it may be faster with this
#define QUALIFIER const
+
#ifdef USE_25_SAMPLES
const int kernel_size=25;
-
QUALIFIER vec2 kernel[25] = vec2[] (
-vec2(0.099654,0.0),
-vec2(0.001133,-3.0),
-vec2(0.002316,-2.52083),
-vec2(0.00445,-2.08333),
-vec2(0.008033,-1.6875),
-vec2(0.013627,-1.33333),
-vec2(0.021724,-1.02083),
-vec2(0.032542,-0.75),
-vec2(0.04581,-0.520833),
-vec2(0.0606,-0.333333),
-vec2(0.075333,-0.1875),
-vec2(0.088001,-0.0833333),
-vec2(0.096603,-0.0208333),
-vec2(0.096603,0.0208333),
-vec2(0.088001,0.0833333),
-vec2(0.075333,0.1875),
-vec2(0.0606,0.333333),
-vec2(0.04581,0.520833),
-vec2(0.032542,0.75),
-vec2(0.021724,1.02083),
-vec2(0.013627,1.33333),
-vec2(0.008033,1.6875),
-vec2(0.00445,2.08333),
-vec2(0.002316,2.52),
-vec2(0.001133,3.0)
+ vec2(0.530605, 0.0),
+ vec2(0.000973794, -3.0),
+ vec2(0.00333804, -2.52083),
+ vec2(0.00500364, -2.08333),
+ vec2(0.00700976, -1.6875),
+ vec2(0.0094389, -1.33333),
+ vec2(0.0128496, -1.02083),
+ vec2(0.017924, -0.75),
+ vec2(0.0263642, -0.520833),
+ vec2(0.0410172, -0.333333),
+ vec2(0.0493588, -0.1875),
+ vec2(0.0402784, -0.0833333),
+ vec2(0.0211412, -0.0208333),
+ vec2(0.0211412, 0.0208333),
+ vec2(0.0402784, 0.0833333),
+ vec2(0.0493588, 0.1875),
+ vec2(0.0410172, 0.333333),
+ vec2(0.0263642, 0.520833),
+ vec2(0.017924, 0.75),
+ vec2(0.0128496, 1.02083),
+ vec2(0.0094389, 1.33333),
+ vec2(0.00700976, 1.6875),
+ vec2(0.00500364, 2.08333),
+ vec2(0.00333804, 2.52083),
+ vec2(0.000973794, 3.0)
);
#endif //USE_25_SAMPLES
@@ -56,23 +56,23 @@ vec2(0.001133,3.0)
const int kernel_size=17;
QUALIFIER vec2 kernel[17] = vec2[](
-vec2(0.197417,0.0),
-vec2(0.000078,-2.0),
-vec2(0.000489,-1.53125),
-vec2(0.002403,-1.125),
-vec2(0.009245,-0.78125),
-vec2(0.027835,-0.5),
-vec2(0.065592,-0.28125),
-vec2(0.12098,-0.125),
-vec2(0.17467,-0.03125),
-vec2(0.17467,0.03125),
-vec2(0.12098,0.125),
-vec2(0.065592,0.28125),
-vec2(0.027835,0.5),
-vec2(0.009245,0.78125),
-vec2(0.002403,1.125),
-vec2(0.000489,1.53125),
-vec2(0.000078,2.0)
+ vec2(0.536343, 0.0),
+ vec2(0.00317394, -2.0),
+ vec2(0.0100386, -1.53125),
+ vec2(0.0144609, -1.125),
+ vec2(0.0216301, -0.78125),
+ vec2(0.0347317, -0.5),
+ vec2(0.0571056, -0.28125),
+ vec2(0.0582416, -0.125),
+ vec2(0.0324462, -0.03125),
+ vec2(0.0324462, 0.03125),
+ vec2(0.0582416, 0.125),
+ vec2(0.0571056, 0.28125),
+ vec2(0.0347317, 0.5),
+ vec2(0.0216301, 0.78125),
+ vec2(0.0144609, 1.125),
+ vec2(0.0100386, 1.53125),
+ vec2(0.00317394,2.0)
);
#endif //USE_17_SAMPLES
@@ -82,23 +82,24 @@ vec2(0.000078,2.0)
const int kernel_size=11;
-QUALIFIER vec2 kernel[kernel_size] = vec2[](
-vec2(0.198596,0.0),
-vec2(0.0093,-2.0),
-vec2(0.028002,-1.28),
-vec2(0.065984,-0.72),
-vec2(0.121703,-0.32),
-vec2(0.175713,-0.08),
-vec2(0.175713,0.08),
-vec2(0.121703,0.32),
-vec2(0.065984,0.72),
-vec2(0.028002,1.28),
-vec2(0.0093,2.0)
+QUALIFIER vec4 kernel[11] = vec4[](
+ vec4(0.560479, 0.0),
+ vec4(0.00471691, -2.0),
+ vec4(0.0192831, -1.28),
+ vec4(0.03639, -0.72),
+ vec4(0.0821904, -0.32),
+ vec4(0.0771802, -0.08),
+ vec4(0.0771802, 0.08),
+ vec4(0.0821904, 0.32),
+ vec4(0.03639, 0.72),
+ vec4(0.0192831, 1.28),
+ vec4(0.00471691,2.0)
);
#endif //USE_11_SAMPLES
+
uniform float max_radius;
uniform float camera_z_far;
uniform float camera_z_near;
@@ -126,12 +127,16 @@ void main() {
// Fetch linear depth of current pixel:
float depth = texture(source_depth, uv_interp).r * 2.0 - 1.0;
+#ifdef USE_ORTHOGONAL_PROJECTION
+ depth = ((depth + (camera_z_far + camera_z_near)/(camera_z_far - camera_z_near)) * (camera_z_far - camera_z_near))/2.0;
+ float scale = unit_size; //remember depth is negative by default in OpenGL
+#else
depth = 2.0 * camera_z_near * camera_z_far / (camera_z_far + camera_z_near - depth * (camera_z_far - camera_z_near));
+ float scale = unit_size / depth; //remember depth is negative by default in OpenGL
+#endif
- float scale = unit_size / depth; //remember depth is negative by default in OpenGL
-
// Calculate the final step to fetch the surrounding pixels:
vec2 step = max_radius * scale * dir;
step *= strength; // Modulate it using the alpha channel.
@@ -153,9 +158,14 @@ void main() {
#ifdef ENABLE_FOLLOW_SURFACE
// If the difference in depth is huge, we lerp color back to "colorM":
float depth_cmp = texture(source_depth, offset).r *2.0 - 1.0;
+
+#ifdef USE_ORTHOGONAL_PROJECTION
+ depth_cmp = ((depth_cmp + (camera_z_far + camera_z_near)/(camera_z_far - camera_z_near)) * (camera_z_far - camera_z_near))/2.0;
+#else
depth_cmp = 2.0 * camera_z_near * camera_z_far / (camera_z_far + camera_z_near - depth_cmp * (camera_z_far - camera_z_near));
+#endif
- float s = clamp(300.0f * distance *
+ float s = clamp(300.0f * scale *
max_radius * abs(depth - depth_cmp),0.0,1.0);
color = mix(color, base_color.rgb, s);
#endif
diff --git a/drivers/unix/dir_access_unix.cpp b/drivers/unix/dir_access_unix.cpp
index ddc3b2ed33..6b8038c3ef 100644
--- a/drivers/unix/dir_access_unix.cpp
+++ b/drivers/unix/dir_access_unix.cpp
@@ -211,36 +211,35 @@ Error DirAccessUnix::make_dir(String p_dir) {
Error DirAccessUnix::change_dir(String p_dir) {
GLOBAL_LOCK_FUNCTION
+
p_dir = fix_path(p_dir);
+ // prev_dir is the directory we are changing out of
+ String prev_dir;
char real_current_dir_name[2048];
getcwd(real_current_dir_name, 2048);
- String prev_dir;
if (prev_dir.parse_utf8(real_current_dir_name))
prev_dir = real_current_dir_name; //no utf8, maybe latin?
- chdir(current_dir.utf8().get_data()); //ascii since this may be unicode or wathever the host os wants
- bool worked = (chdir(p_dir.utf8().get_data()) == 0); // we can only give this utf8
-
- String base = _get_root_path();
- if (base != "") {
-
- getcwd(real_current_dir_name, 2048);
- String new_dir;
- new_dir.parse_utf8(real_current_dir_name);
- if (!new_dir.begins_with(base))
- worked = false;
+ // try_dir is the directory we are trying to change into
+ String try_dir = "";
+ if (p_dir.is_rel_path()) {
+ String next_dir = current_dir + "/" + p_dir;
+ next_dir = next_dir.simplify_path();
+ try_dir = next_dir;
+ } else {
+ try_dir = p_dir;
}
- if (worked) {
-
- getcwd(real_current_dir_name, 2048);
- if (current_dir.parse_utf8(real_current_dir_name))
- current_dir = real_current_dir_name; //no utf8, maybe latin?
+ bool worked = (chdir(try_dir.utf8().get_data()) == 0); // we can only give this utf8
+ if (!worked) {
+ return ERR_INVALID_PARAMETER;
}
+ // the directory exists, so set current_dir to try_dir
+ current_dir = try_dir;
chdir(prev_dir.utf8().get_data());
- return worked ? OK : ERR_INVALID_PARAMETER;
+ return OK;
}
String DirAccessUnix::get_current_dir() {
@@ -307,11 +306,16 @@ size_t DirAccessUnix::get_space_left() {
DirAccessUnix::DirAccessUnix() {
dir_stream = 0;
- current_dir = ".";
_cisdir = false;
/* determine drive count */
+ // set current directory to an absolute path of the current directory
+ char real_current_dir_name[2048];
+ getcwd(real_current_dir_name, 2048);
+ if (current_dir.parse_utf8(real_current_dir_name))
+ current_dir = real_current_dir_name;
+
change_dir(current_dir);
}
diff --git a/drivers/unix/file_access_unix.cpp b/drivers/unix/file_access_unix.cpp
index d5a66d9a1c..80565c5b02 100644
--- a/drivers/unix/file_access_unix.cpp
+++ b/drivers/unix/file_access_unix.cpp
@@ -36,12 +36,17 @@
#include <sys/stat.h>
#include <sys/types.h>
+#if defined(UNIX_ENABLED)
+#include <unistd.h>
+#endif
+
#ifndef ANDROID_ENABLED
#include <sys/statvfs.h>
#endif
#ifdef MSVC
#define S_ISREG(m) ((m)&_S_IFREG)
+#include <io.h>
#endif
#ifndef S_ISREG
#define S_ISREG(m) ((m)&S_IFREG)
@@ -85,13 +90,18 @@ Error FileAccessUnix::_open(const String &p_path, int p_mode_flags) {
//printf("opening %s as %s\n", p_path.utf8().get_data(), path.utf8().get_data());
struct stat st;
- if (stat(path.utf8().get_data(), &st) == 0) {
-
- if (!S_ISREG(st.st_mode))
- return ERR_FILE_CANT_OPEN;
- };
+ int err = stat(path.utf8().get_data(), &st);
+ if (!err) {
+ switch (st.st_mode & S_IFMT) {
+ case S_IFLNK:
+ case S_IFREG:
+ break;
+ default:
+ return ERR_FILE_CANT_OPEN;
+ }
+ }
- if (is_backup_save_enabled() && p_mode_flags & WRITE && !(p_mode_flags & READ)) {
+ if (is_backup_save_enabled() && (p_mode_flags & WRITE) && !(p_mode_flags & READ)) {
save_path = path;
path = path + ".tmp";
//print_line("saving instead to "+path);
@@ -108,15 +118,19 @@ Error FileAccessUnix::_open(const String &p_path, int p_mode_flags) {
return OK;
}
}
+
void FileAccessUnix::close() {
if (!f)
return;
+
fclose(f);
f = NULL;
+
if (close_notification_func) {
close_notification_func(path, flags);
}
+
if (save_path != "") {
//unlink(save_path.utf8().get_data());
@@ -131,10 +145,12 @@ void FileAccessUnix::close() {
ERR_FAIL_COND(rename_error != 0);
}
}
+
bool FileAccessUnix::is_open() const {
return (f != NULL);
}
+
void FileAccessUnix::seek(size_t p_position) {
ERR_FAIL_COND(!f);
@@ -143,29 +159,37 @@ void FileAccessUnix::seek(size_t p_position) {
if (fseek(f, p_position, SEEK_SET))
check_errors();
}
+
void FileAccessUnix::seek_end(int64_t p_position) {
ERR_FAIL_COND(!f);
+
if (fseek(f, p_position, SEEK_END))
check_errors();
}
+
size_t FileAccessUnix::get_pos() const {
- size_t aux_position = 0;
- if (!(aux_position = ftell(f))) {
+ ERR_FAIL_COND_V(!f, 0);
+
+ int pos = ftell(f);
+ if (pos < 0) {
check_errors();
- };
- return aux_position;
+ ERR_FAIL_V(0);
+ }
+ return pos;
}
+
size_t FileAccessUnix::get_len() const {
ERR_FAIL_COND_V(!f, 0);
- FileAccessUnix *fau = const_cast<FileAccessUnix *>(this);
- int pos = fau->get_pos();
- fau->seek_end();
- int size = fau->get_pos();
- fau->seek(pos);
+ int pos = ftell(f);
+ ERR_FAIL_COND_V(pos < 0, 0);
+ ERR_FAIL_COND_V(fseek(f, 0, SEEK_END), 0);
+ int size = ftell(f);
+ ERR_FAIL_COND_V(size < 0, 0);
+ ERR_FAIL_COND_V(fseek(f, pos, SEEK_SET), 0);
return size;
}
@@ -181,8 +205,8 @@ uint8_t FileAccessUnix::get_8() const {
uint8_t b;
if (fread(&b, 1, 1, f) == 0) {
check_errors();
- };
-
+ b = '\0';
+ }
return b;
}
@@ -202,22 +226,36 @@ Error FileAccessUnix::get_error() const {
void FileAccessUnix::store_8(uint8_t p_dest) {
ERR_FAIL_COND(!f);
- fwrite(&p_dest, 1, 1, f);
+ ERR_FAIL_COND(fwrite(&p_dest, 1, 1, f) != 1);
}
bool FileAccessUnix::file_exists(const String &p_path) {
- FILE *g;
- //printf("opening file %s\n", p_fname.c_str());
+ int err;
+ struct stat st;
String filename = fix_path(p_path);
- g = fopen(filename.utf8().get_data(), "rb");
- if (g == NULL) {
+ // Does the name exist at all?
+ err = stat(filename.utf8().get_data(), &st);
+ if (err)
return false;
- } else {
- fclose(g);
- return true;
+#ifdef UNIX_ENABLED
+ // See if we have access to the file
+ if (access(filename.utf8().get_data(), F_OK))
+ return false;
+#else
+ if (_access(filename.utf8().get_data(), 4) == -1)
+ return false;
+#endif
+
+ // See if this is a regular file
+ switch (st.st_mode & S_IFMT) {
+ case S_IFLNK:
+ case S_IFREG:
+ return true;
+ default:
+ return false;
}
}
@@ -225,9 +263,9 @@ uint64_t FileAccessUnix::_get_modified_time(const String &p_file) {
String file = fix_path(p_file);
struct stat flags;
- bool success = (stat(file.utf8().get_data(), &flags) == 0);
+ int err = stat(file.utf8().get_data(), &flags);
- if (success) {
+ if (!err) {
return flags.st_mtime;
} else {
print_line("ERROR IN: " + p_file);
@@ -249,6 +287,7 @@ FileAccessUnix::FileAccessUnix() {
flags = 0;
last_error = OK;
}
+
FileAccessUnix::~FileAccessUnix() {
close();
diff --git a/drivers/windows/file_access_windows.cpp b/drivers/windows/file_access_windows.cpp
index 30c8332fa3..fe2069089c 100644
--- a/drivers/windows/file_access_windows.cpp
+++ b/drivers/windows/file_access_windows.cpp
@@ -159,7 +159,8 @@ void FileAccessWindows::seek_end(int64_t p_position) {
size_t FileAccessWindows::get_pos() const {
size_t aux_position = 0;
- if (!(aux_position = ftell(f))) {
+ aux_position = ftell(f);
+ if (!aux_position) {
check_errors();
};
return aux_position;
diff --git a/editor/SCsub b/editor/SCsub
index 172447147c..0e690cf465 100644
--- a/editor/SCsub
+++ b/editor/SCsub
@@ -155,31 +155,71 @@ def make_authors_header(target, source, env):
g.write("#define _EDITOR_AUTHORS_H\n")
current_section = ""
- name_count = -1
+ reading = False
def close_section():
g.write("\t0\n")
g.write("};\n")
- g.write("#define " + current_section.upper() + "_COUNT " + str(name_count) + "\n")
for line in f:
- if name_count >= 0:
+ if reading:
if line.startswith(" "):
g.write("\t\"" + line.strip() + "\",\n")
- name_count += 1
continue
if line.startswith("## "):
- if name_count >= 0:
+ if reading:
close_section()
- name_count = -1
+ reading = False
for i in range(len(sections)):
if line.strip().endswith(sections[i]):
current_section = sections_id[i]
- name_count = 0
+ reading = True
g.write("static const char *" + current_section + "[] = {\n")
break
- if name_count >= 0:
+ if reading:
+ close_section()
+
+ g.write("#endif\n")
+
+def make_donors_header(target, source, env):
+
+ sections = ["Platinum sponsors", "Gold sponsors", "Mini sponsors", "Gold donors", "Silver donors", "Bronze donors"]
+ sections_id = ["donor_s_plat", "donor_s_gold", "donor_s_mini", "donor_gold", "donor_silver", "donor_bronze"]
+
+ src = source[0].srcnode().abspath
+ dst = target[0].srcnode().abspath
+ f = open_utf8(src, "r")
+ g = open_utf8(dst, "w")
+
+ g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
+ g.write("#ifndef _EDITOR_DONORS_H\n")
+ g.write("#define _EDITOR_DONORS_H\n")
+
+ current_section = ""
+ reading = False
+
+ def close_section():
+ g.write("\t0\n")
+ g.write("};\n")
+
+ for line in f:
+ if reading >= 0:
+ if line.startswith(" "):
+ g.write("\t\"" + line.strip() + "\",\n")
+ continue
+ if line.startswith("## "):
+ if reading:
+ close_section()
+ reading = False
+ for i in range(len(sections)):
+ if line.strip().endswith(sections[i]):
+ current_section = sections_id[i]
+ reading = True
+ g.write("static const char *" + current_section + "[] = {\n")
+ break
+
+ if reading:
close_section()
g.write("#endif\n")
@@ -393,6 +433,10 @@ if (env["tools"] == "yes"):
env.Depends('#editor/authors.gen.h', "../AUTHORS.md")
env.Command('#editor/authors.gen.h', "../AUTHORS.md", make_authors_header)
+ # Donors
+ env.Depends('#editor/donors.gen.h', "../DONORS.md")
+ env.Command('#editor/donors.gen.h', "../DONORS.md", make_donors_header)
+
# License
env.Depends('#editor/license.gen.h', ["../COPYRIGHT.txt", "../LICENSE.txt"])
env.Command('#editor/license.gen.h', ["../COPYRIGHT.txt", "../LICENSE.txt"], make_license_header)
diff --git a/editor/dependency_editor.cpp b/editor/dependency_editor.cpp
index 890c3d8091..54bf31cd62 100644
--- a/editor/dependency_editor.cpp
+++ b/editor/dependency_editor.cpp
@@ -489,6 +489,7 @@ DependencyErrorDialog::DependencyErrorDialog() {
vb->add_margin_child(TTR("Scene failed to load due to missing dependencies:"), files, true);
files->set_v_size_flags(SIZE_EXPAND_FILL);
get_ok()->set_text(TTR("Open Anyway"));
+ get_cancel()->set_text(TTR("Done"));
text = memnew(Label);
vb->add_child(text);
diff --git a/editor/editor_about.cpp b/editor/editor_about.cpp
index 8bd7bfb4bd..a48e6c9057 100644
--- a/editor/editor_about.cpp
+++ b/editor/editor_about.cpp
@@ -30,6 +30,7 @@
#include "editor_about.h"
#include "authors.gen.h"
+#include "donors.gen.h"
#include "license.gen.h"
#include "version.h"
#include "version_hash.gen.h"
@@ -51,6 +52,47 @@ TextureRect *EditorAbout::get_logo() const {
return _logo;
}
+ScrollContainer *EditorAbout::_populate_list(const String &p_name, const List<String> &p_sections, const char **p_src[]) {
+
+ ScrollContainer *sc = memnew(ScrollContainer);
+ sc->set_name(p_name);
+ sc->set_v_size_flags(Control::SIZE_EXPAND);
+
+ VBoxContainer *vbc = memnew(VBoxContainer);
+ vbc->set_h_size_flags(Control::SIZE_EXPAND_FILL);
+ sc->add_child(vbc);
+
+ for (int i = 0; i < p_sections.size(); i++) {
+
+ const char **names_ptr = p_src[i];
+ if (*names_ptr) {
+
+ Label *lbl = memnew(Label);
+ lbl->set_text(p_sections[i]);
+ vbc->add_child(lbl);
+
+ ItemList *il = memnew(ItemList);
+ il->set_max_columns(16);
+ il->set_h_size_flags(Control::SIZE_EXPAND_FILL);
+ il->set_same_column_width(true);
+ il->set_auto_height(true);
+ while (*names_ptr) {
+ il->add_item(String::utf8(*names_ptr++), NULL, false);
+ }
+ vbc->add_child(il);
+ if (il->get_item_count() == 2) {
+ il->set_fixed_column_width(200 * EDSCALE);
+ }
+
+ HSeparator *hs = memnew(HSeparator);
+ hs->set_modulate(Color(0, 0, 0, 0));
+ vbc->add_child(hs);
+ }
+ }
+
+ return sc;
+}
+
EditorAbout::EditorAbout() {
set_title(TTR("Thanks from the Godot community!"));
@@ -84,43 +126,29 @@ EditorAbout::EditorAbout() {
tc->set_v_size_flags(Control::SIZE_EXPAND_FILL);
vbc->add_child(tc);
- ScrollContainer *dev_base = memnew(ScrollContainer);
- dev_base->set_name(TTR("Authors"));
- dev_base->set_v_size_flags(Control::SIZE_EXPAND);
- tc->add_child(dev_base);
-
- VBoxContainer *dev_vbc = memnew(VBoxContainer);
- dev_vbc->set_h_size_flags(Control::SIZE_EXPAND_FILL);
- dev_base->add_child(dev_vbc);
+ // Authors
List<String> dev_sections;
dev_sections.push_back(TTR("Project Founders"));
dev_sections.push_back(TTR("Lead Developer"));
dev_sections.push_back(TTR("Project Manager"));
dev_sections.push_back(TTR("Developers"));
-
const char **dev_src[] = { dev_founders, dev_lead, dev_manager, dev_names };
+ tc->add_child(_populate_list(TTR("Authors"), dev_sections, dev_src));
- for (int i = 0; i < dev_sections.size(); i++) {
-
- Label *lbl = memnew(Label);
- lbl->set_text(dev_sections[i]);
- dev_vbc->add_child(lbl);
-
- ItemList *il = memnew(ItemList);
- il->set_max_columns(16);
- il->set_h_size_flags(Control::SIZE_EXPAND_FILL);
- il->set_fixed_column_width(230 * EDSCALE);
- il->set_auto_height(true);
- const char **dev_names_ptr = dev_src[i];
- while (*dev_names_ptr)
- il->add_item(String::utf8(*dev_names_ptr++), NULL, false);
- dev_vbc->add_child(il);
-
- HSeparator *hs = memnew(HSeparator);
- hs->set_modulate(Color(0, 0, 0, 0));
- dev_vbc->add_child(hs);
- }
+ // Donors
+
+ List<String> donor_sections;
+ donor_sections.push_back(TTR("Platinum Sponsors"));
+ donor_sections.push_back(TTR("Gold Sponsors"));
+ donor_sections.push_back(TTR("Mini Sponsors"));
+ donor_sections.push_back(TTR("Gold Donors"));
+ donor_sections.push_back(TTR("Silver Donors"));
+ donor_sections.push_back(TTR("Bronze Donors"));
+ const char **donor_src[] = { donor_s_plat, donor_s_gold, donor_s_mini, donor_gold, donor_silver, donor_bronze };
+ tc->add_child(_populate_list(TTR("Donors"), donor_sections, donor_src));
+
+ // License
TextEdit *license = memnew(TextEdit);
license->set_name(TTR("License"));
@@ -131,6 +159,8 @@ EditorAbout::EditorAbout() {
license->set_text(String::utf8(about_license));
tc->add_child(license);
+ // Thirdparty License
+
VBoxContainer *license_thirdparty = memnew(VBoxContainer);
license_thirdparty->set_name(TTR("Thirdparty License"));
license_thirdparty->set_h_size_flags(Control::SIZE_EXPAND_FILL);
diff --git a/editor/editor_about.h b/editor/editor_about.h
index d7047c03a3..d455b1f074 100644
--- a/editor/editor_about.h
+++ b/editor/editor_about.h
@@ -52,6 +52,7 @@ class EditorAbout : public AcceptDialog {
private:
void _license_tree_selected();
+ ScrollContainer *_populate_list(const String &p_name, const List<String> &p_sections, const char **p_src[]);
Tree *_tpl_tree;
TextEdit *_tpl_text;
diff --git a/editor/editor_audio_buses.cpp b/editor/editor_audio_buses.cpp
index 6937f74316..29159c7ad5 100644
--- a/editor/editor_audio_buses.cpp
+++ b/editor/editor_audio_buses.cpp
@@ -414,7 +414,10 @@ void EditorAudioBus::_gui_input(const Ref<InputEvent> &p_event) {
void EditorAudioBus::_bus_popup_pressed(int p_option) {
- if (p_option == 1) {
+ if (p_option == 2) {
+ // Reset volume
+ emit_signal("vol_reset_request");
+ } else if (p_option == 1) {
emit_signal("delete_request");
} else if (p_option == 0) {
//duplicate
@@ -617,6 +620,7 @@ void EditorAudioBus::_bind_methods() {
ADD_SIGNAL(MethodInfo("duplicate_request"));
ADD_SIGNAL(MethodInfo("delete_request"));
+ ADD_SIGNAL(MethodInfo("vol_reset_request"));
ADD_SIGNAL(MethodInfo("drop_end_request"));
ADD_SIGNAL(MethodInfo("dropped"));
}
@@ -742,6 +746,7 @@ EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses) {
bus_popup = bus_options->get_popup();
bus_popup->add_item(TTR("Duplicate"));
bus_popup->add_item(TTR("Delete"));
+ bus_popup->add_item(TTR("Reset Volume"));
bus_popup->connect("index_pressed", this, "_bus_popup_pressed");
delete_effect_popup = memnew(PopupMenu);
@@ -790,6 +795,7 @@ void EditorAudioBuses::_update_buses() {
bus_hb->add_child(audio_bus);
audio_bus->connect("delete_request", this, "_delete_bus", varray(audio_bus), CONNECT_DEFERRED);
audio_bus->connect("duplicate_request", this, "_duplicate_bus", varray(), CONNECT_DEFERRED);
+ audio_bus->connect("vol_reset_request", this, "_reset_bus_volume", varray(audio_bus), CONNECT_DEFERRED);
audio_bus->connect("drop_end_request", this, "_request_drop_end");
audio_bus->connect("dropped", this, "_drop_at_index", varray(), CONNECT_DEFERRED);
}
@@ -919,6 +925,20 @@ void EditorAudioBuses::_duplicate_bus(int p_which) {
ur->commit_action();
}
+void EditorAudioBuses::_reset_bus_volume(Object *p_which) {
+
+ EditorAudioBus *bus = Object::cast_to<EditorAudioBus>(p_which);
+ int index = bus->get_index();
+
+ UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
+ ur->create_action(TTR("Reset Bus Volume"));
+ ur->add_do_method(AudioServer::get_singleton(), "set_bus_volume_db", index, 0.f);
+ ur->add_undo_method(AudioServer::get_singleton(), "set_bus_volume_db", index, AudioServer::get_singleton()->get_bus_volume_db(index));
+ ur->add_do_method(this, "_update_buses");
+ ur->add_undo_method(this, "_update_buses");
+ ur->commit_action();
+}
+
void EditorAudioBuses::_request_drop_end() {
if (!drop_end && bus_hb->get_child_count()) {
@@ -1063,6 +1083,7 @@ void EditorAudioBuses::_bind_methods() {
ClassDB::bind_method("_load_default_layout", &EditorAudioBuses::_load_default_layout);
ClassDB::bind_method("_new_layout", &EditorAudioBuses::_new_layout);
ClassDB::bind_method("_duplicate_bus", &EditorAudioBuses::_duplicate_bus);
+ ClassDB::bind_method("_reset_bus_volume", &EditorAudioBuses::_reset_bus_volume);
ClassDB::bind_method("_file_dialog_callback", &EditorAudioBuses::_file_dialog_callback);
}
diff --git a/editor/editor_audio_buses.h b/editor/editor_audio_buses.h
index e04ba7b89d..2c61228bde 100644
--- a/editor/editor_audio_buses.h
+++ b/editor/editor_audio_buses.h
@@ -158,6 +158,7 @@ class EditorAudioBuses : public VBoxContainer {
void _delete_bus(Object *p_which);
void _duplicate_bus(int p_which);
+ void _reset_bus_volume(Object *p_which);
void _request_drop_end();
void _drop_at_index(int p_bus, int p_index);
diff --git a/editor/editor_fonts.cpp b/editor/editor_fonts.cpp
index 22a9c84d21..3ab3f05906 100644
--- a/editor/editor_fonts.cpp
+++ b/editor/editor_fonts.cpp
@@ -72,11 +72,14 @@ static Ref<BitmapFont> make_font(int p_height, int p_ascent, int p_valign, int p
m_name->add_fallback(FontJapanese); \
m_name->add_fallback(FontFallback);
-#define MAKE_DEFAULT_FONT(m_name, m_size) \
- Ref<DynamicFont> m_name; \
- m_name.instance(); \
- m_name->set_size(m_size); \
- m_name->set_font_data(DefaultFont); \
+// the custom spacings might only work with Noto Sans
+#define MAKE_DEFAULT_FONT(m_name, m_size) \
+ Ref<DynamicFont> m_name; \
+ m_name.instance(); \
+ m_name->set_size(m_size); \
+ m_name->set_font_data(DefaultFont); \
+ m_name->set_spacing(DynamicFont::SPACING_TOP, -1); \
+ m_name->set_spacing(DynamicFont::SPACING_BOTTOM, -1); \
MAKE_FALLBACKS(m_name);
void editor_register_fonts(Ref<Theme> p_theme) {
diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp
index 0e22f0d386..7fa2c53275 100644
--- a/editor/editor_help.cpp
+++ b/editor/editor_help.cpp
@@ -1712,9 +1712,8 @@ void EditorHelp::_notification(int p_what) {
} 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);
+
+ class_desc->add_color_override("selection_color", EDITOR_DEF("text_editor/highlighting/selection_color", Color(0.2, 0.2, 1)));
} break;
default: break;
@@ -1786,14 +1785,12 @@ EditorHelp::EditorHelp() {
{
background_panel = memnew(Panel);
- Ref<StyleBoxFlat> style(memnew(StyleBoxFlat));
- style->set_bg_color(EditorSettings::get_singleton()->get("text_editor/highlighting/background_color"));
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);
background_panel->add_child(class_desc);
- class_desc->set_area_as_parent_rect(8);
+ class_desc->set_area_as_parent_rect();
+ class_desc->add_color_override("selection_color", EDITOR_DEF("text_editor/highlighting/selection_color", Color(0.2, 0.2, 1)));
class_desc->connect("meta_clicked", this, "_class_desc_select");
class_desc->connect("gui_input", this, "_class_desc_input");
}
@@ -1882,8 +1879,13 @@ void EditorHelpBit::_bind_methods() {
void EditorHelpBit::_notification(int p_what) {
- if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
- add_style_override("panel", get_stylebox("ScriptPanel", "EditorStyles"));
+ switch (p_what) {
+ case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
+
+ rich_text->add_color_override("selection_color", EDITOR_DEF("text_editor/highlighting/selection_color", Color(0.2, 0.2, 1)));
+ } break;
+
+ default: break;
}
}
@@ -1897,8 +1899,8 @@ EditorHelpBit::EditorHelpBit() {
rich_text = memnew(RichTextLabel);
add_child(rich_text);
- rich_text->set_area_as_parent_rect(8 * EDSCALE);
+ rich_text->set_area_as_parent_rect();
rich_text->connect("meta_clicked", this, "_meta_clicked");
+ rich_text->add_color_override("selection_color", EDITOR_DEF("text_editor/highlighting/selection_color", Color(0.2, 0.2, 1)));
set_custom_minimum_size(Size2(0, 70 * EDSCALE));
- add_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_stylebox("ScriptPanel", "EditorStyles"));
}
diff --git a/editor/editor_log.cpp b/editor/editor_log.cpp
index a1f416a17c..35291f8f9e 100644
--- a/editor/editor_log.cpp
+++ b/editor/editor_log.cpp
@@ -59,7 +59,6 @@ void EditorLog::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
- log->add_color_override("default_color", get_color("font_color", "Tree"));
//button->set_icon(get_icon("Console","EditorIcons"));
}
if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
@@ -91,7 +90,7 @@ void EditorLog::add_message(const String &p_msg, bool p_error) {
log->add_newline();
if (p_error) {
- log->push_color(get_color("fg_error", "Editor"));
+ log->push_color(get_color("error_color", "Editor"));
Ref<Texture> icon = get_icon("Error", "EditorIcons");
log->add_image(icon);
//button->set_icon(icon);
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 6b5db7572a..91d2ddcd19 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -283,13 +283,22 @@ void EditorNode::_notification(int p_what) {
scene_tabs->set_tab_close_display_policy((bool(EDITOR_DEF("interface/always_show_close_button_in_scene_tabs", false)) ? Tabs::CLOSE_BUTTON_SHOW_ALWAYS : Tabs::CLOSE_BUTTON_SHOW_ACTIVE_ONLY));
property_editor->set_enable_capitalize_paths(bool(EDITOR_DEF("interface/capitalize_properties", true)));
Ref<Theme> theme = create_editor_theme(theme_base->get_theme());
+
theme_base->set_theme(theme);
+
gui_base->add_style_override("panel", gui_base->get_stylebox("Background", "EditorStyles"));
play_button_panel->add_style_override("panel", gui_base->get_stylebox("PlayButtonPanel", "EditorStyles"));
scene_root_parent->add_style_override("panel", gui_base->get_stylebox("Content", "EditorStyles"));
bottom_panel->add_style_override("panel", gui_base->get_stylebox("panel", "TabContainer"));
scene_tabs->add_style_override("tab_fg", gui_base->get_stylebox("SceneTabFG", "EditorStyles"));
scene_tabs->add_style_override("tab_bg", gui_base->get_stylebox("SceneTabBG", "EditorStyles"));
+
+ file_menu->add_style_override("hover", gui_base->get_stylebox("MenuHover", "EditorStyles"));
+ project_menu->add_style_override("hover", gui_base->get_stylebox("MenuHover", "EditorStyles"));
+ debug_menu->add_style_override("hover", gui_base->get_stylebox("MenuHover", "EditorStyles"));
+ settings_menu->add_style_override("hover", gui_base->get_stylebox("MenuHover", "EditorStyles"));
+ help_menu->add_style_override("hover", gui_base->get_stylebox("MenuHover", "EditorStyles"));
+
if (bool(EDITOR_DEF("interface/scene_tabs/resize_if_many_tabs", true))) {
scene_tabs->set_min_width(int(EDITOR_DEF("interface/scene_tabs/minimum_width", 50)) * EDSCALE);
} else {
@@ -1368,6 +1377,16 @@ void EditorNode::_set_editing_top_editors(Object *p_current_object) {
editor_plugins_over->edit(p_current_object);
}
+static bool overrides_external_editor(Object *p_object) {
+
+ Script *script = Object::cast_to<Script>(p_object);
+
+ if (!script)
+ return false;
+
+ return script->get_language()->overrides_external_editor();
+}
+
void EditorNode::_edit_current() {
uint32_t current = editor_history.get_current();
@@ -1434,7 +1453,7 @@ void EditorNode::_edit_current() {
if (main_plugin) {
// special case if use of external editor is true
- if (main_plugin->get_name() == "Script" && bool(EditorSettings::get_singleton()->get("text_editor/external/use_external_editor"))) {
+ if (main_plugin->get_name() == "Script" && (bool(EditorSettings::get_singleton()->get("text_editor/external/use_external_editor")) || overrides_external_editor(current_obj))) {
main_plugin->edit(current_obj);
}
@@ -1442,6 +1461,7 @@ void EditorNode::_edit_current() {
// update screen main_plugin
if (!changing_scene) {
+
if (editor_plugin_screen)
editor_plugin_screen->make_visible(false);
editor_plugin_screen = main_plugin;
@@ -2721,6 +2741,14 @@ Dictionary EditorNode::_get_main_scene_state() {
state["property_edit_offset"] = get_property_editor()->get_scene_tree()->get_vscroll_bar()->get_value();
state["saved_version"] = saved_version;
state["node_filter"] = scene_tree_dock->get_filter();
+ int current = -1;
+ for (int i = 0; i < editor_table.size(); i++) {
+ if (editor_plugin_screen == editor_table[i]) {
+ current = i;
+ break;
+ }
+ }
+ state["editor_index"] = current;
return state;
}
@@ -2731,8 +2759,9 @@ void EditorNode::_set_main_scene_state(Dictionary p_state, Node *p_for_scene) {
changing_scene = false;
- if (get_edited_scene()) {
+ if (p_state.has("editor_index")) {
+ int index = p_state["editor_index"];
int current = -1;
for (int i = 0; i < editor_table.size(); i++) {
if (editor_plugin_screen == editor_table[i]) {
@@ -2741,15 +2770,18 @@ void EditorNode::_set_main_scene_state(Dictionary p_state, Node *p_for_scene) {
}
}
- if (current < 2) {
- //use heuristic instead
-
- int n2d = 0, n3d = 0;
- _find_node_types(get_edited_scene(), n2d, n3d);
- if (n2d > n3d) {
- _editor_select(EDITOR_2D);
- } else if (n3d > n2d) {
- _editor_select(EDITOR_3D);
+ if (current < 2) { //if currently in spatial/2d, only switch to spatial/2d. if curently in script, stay there
+ if (index < 2 || !get_edited_scene()) {
+ _editor_select(index);
+ } else {
+ //use heuristic instead
+ int n2d = 0, n3d = 0;
+ _find_node_types(get_edited_scene(), n2d, n3d);
+ if (n2d > n3d) {
+ _editor_select(EDITOR_2D);
+ } else if (n3d > n2d) {
+ _editor_select(EDITOR_3D);
+ }
}
}
}
@@ -4818,9 +4850,10 @@ EditorNode::EditorNode() {
}
file_menu = memnew(MenuButton);
+ file_menu->set_flat(false);
file_menu->set_text(TTR("Scene"));
- left_menu_hb->add_child(file_menu);
file_menu->add_style_override("hover", gui_base->get_stylebox("MenuHover", "EditorStyles"));
+ left_menu_hb->add_child(file_menu);
prev_scene = memnew(ToolButton);
prev_scene->set_icon(gui_base->get_icon("PrevScene", "EditorIcons"));
@@ -4908,6 +4941,7 @@ EditorNode::EditorNode() {
p->add_item(TTR("Quit"), FILE_QUIT, KEY_MASK_CMD + KEY_Q);
project_menu = memnew(MenuButton);
+ project_menu->set_flat(false);
project_menu->set_tooltip(TTR("Miscellaneous project or scene-wide tools."));
project_menu->set_text(TTR("Project"));
project_menu->add_style_override("hover", gui_base->get_stylebox("MenuHover", "EditorStyles"));
@@ -4941,9 +4975,11 @@ EditorNode::EditorNode() {
menu_hb->add_child(editor_region);
debug_menu = memnew(MenuButton);
+ debug_menu->set_flat(false);
debug_menu->set_text(TTR("Debug"));
debug_menu->add_style_override("hover", gui_base->get_stylebox("MenuHover", "EditorStyles"));
left_menu_hb->add_child(debug_menu);
+
p = debug_menu->get_popup();
p->set_hide_on_item_selection(false);
p->add_check_item(TTR("Deploy with Remote Debug"), RUN_DEPLOY_REMOTE_DEBUG);
@@ -4965,9 +5001,10 @@ EditorNode::EditorNode() {
menu_hb->add_spacer();
settings_menu = memnew(MenuButton);
- left_menu_hb->add_child(settings_menu);
+ settings_menu->set_flat(false);
settings_menu->set_text(TTR("Editor"));
settings_menu->add_style_override("hover", gui_base->get_stylebox("MenuHover", "EditorStyles"));
+ left_menu_hb->add_child(settings_menu);
p = settings_menu->get_popup();
p->add_item(TTR("Editor Settings"), SETTINGS_PREFERENCES);
@@ -4982,10 +5019,12 @@ EditorNode::EditorNode() {
p->add_item(TTR("Manage Export Templates"), SETTINGS_MANAGE_EXPORT_TEMPLATES);
// Help Menu
- MenuButton *help_menu = memnew(MenuButton);
- left_menu_hb->add_child(help_menu);
+ help_menu = memnew(MenuButton);
+ help_menu->set_flat(false);
help_menu->set_text(TTR("Help"));
help_menu->add_style_override("hover", gui_base->get_stylebox("MenuHover", "EditorStyles"));
+ left_menu_hb->add_child(help_menu);
+
p = help_menu->get_popup();
p->connect("id_pressed", this, "_menu_option");
p->add_icon_item(gui_base->get_icon("ClassList", "EditorIcons"), TTR("Classes"), HELP_CLASSES);
diff --git a/editor/editor_node.h b/editor/editor_node.h
index c3ceee350a..ea74bcbd9d 100644
--- a/editor/editor_node.h
+++ b/editor/editor_node.h
@@ -236,11 +236,12 @@ private:
MenuButton *file_menu;
MenuButton *project_menu;
MenuButton *debug_menu;
+ MenuButton *settings_menu;
+ MenuButton *help_menu;
PopupMenu *tool_menu;
ToolButton *export_button;
ToolButton *prev_scene;
MenuButton *object_menu;
- MenuButton *settings_menu;
ToolButton *play_button;
MenuButton *native_play_button;
ToolButton *pause_button;
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index 9c9eef848a..db76a27f5f 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -603,7 +603,6 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
hints["text_editor/theme/color_theme"] = PropertyInfo(Variant::STRING, "text_editor/theme/color_theme", PROPERTY_HINT_ENUM, "Default");
set("text_editor/theme/line_spacing", 4);
- set("text_editor/theme/adapted_code_editor_background_color", true);
_load_default_text_editor_theme();
diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp
index 8943d5f0dc..19356aad3a 100644
--- a/editor/editor_themes.cpp
+++ b/editor/editor_themes.cpp
@@ -198,6 +198,8 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
bool highlight_tabs = EDITOR_DEF("interface/theme/highlight_tabs", false);
int border_size = EDITOR_DEF("interface/theme/border_size", 1);
+ Color script_bg_color = EDITOR_DEF("text_editor/highlighting/background_color", Color(0, 0, 0, 0));
+
switch (preset) {
case 0: { // Default
highlight_color = Color::html("#699ce8");
@@ -235,8 +237,8 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
Color dark_color_2 = base_color.linear_interpolate(Color(0, 0, 0, 1), contrast * 1.5);
Color dark_color_3 = base_color.linear_interpolate(Color(0, 0, 0, 1), contrast * 2);
- Color contrast_color_1 = base_color.linear_interpolate((dark_theme ? Color(1, 1, 1, 1) : Color(0, 0, 0, 1)), 0.3);
- Color contrast_color_2 = base_color.linear_interpolate((dark_theme ? Color(1, 1, 1, 1) : Color(0, 0, 0, 1)), 0.5);
+ Color contrast_color_1 = base_color.linear_interpolate((dark_theme ? Color(1, 1, 1, 1) : Color(0, 0, 0, 1)), MAX(contrast, default_contrast));
+ Color contrast_color_2 = base_color.linear_interpolate((dark_theme ? Color(1, 1, 1, 1) : Color(0, 0, 0, 1)), MAX(contrast * 1.5, default_contrast * 1.5));
Color font_color = dark_theme ? Color(1, 1, 1) : Color(0, 0, 0);
Color font_color_disabled = dark_theme ? Color(0.6, 0.6, 0.6) : Color(0.45, 0.45, 0.45);
@@ -279,8 +281,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
editor_register_fonts(theme);
// Editor background
- Ref<StyleBoxFlat> style_panel = make_flat_stylebox(dark_color_2, 4, 4, 4, 4);
- theme->set_stylebox("Background", "EditorStyles", style_panel);
+ theme->set_stylebox("Background", "EditorStyles", make_flat_stylebox(dark_color_2, 4, 4, 4, 4));
// Focus
Ref<StyleBoxFlat> focus_sbt = make_flat_stylebox(contrast_color_1, 4, 4, 4, 4);
@@ -302,12 +303,11 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
Ref<StyleBoxFlat> style_menu_hover_bg = make_flat_stylebox(dark_color_2, 4, 4, 4, 4);
style_menu_hover_border->set_draw_center(false);
- style_menu_hover_border->set_border_width(MARGIN_BOTTOM, border_width);
+ style_menu_hover_border->set_border_width(MARGIN_BOTTOM, 2 * EDSCALE);
style_menu_hover_border->set_border_color_all(highlight_color);
- style_menu_hover_border->set_expand_margin_size(MARGIN_BOTTOM, border_width);
theme->set_stylebox("normal", "MenuButton", style_menu);
- theme->set_stylebox("hover", "MenuButton", style_menu_hover_border);
+ theme->set_stylebox("hover", "MenuButton", style_menu);
theme->set_stylebox("pressed", "MenuButton", style_menu);
theme->set_stylebox("focus", "MenuButton", style_menu);
theme->set_stylebox("disabled", "MenuButton", style_menu);
@@ -333,10 +333,10 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
theme->set_stylebox("MenuHover", "EditorStyles", style_menu_hover_border);
// Content of each tab
- Ref<StyleBoxFlat> style_content_panel = make_flat_stylebox(base_color, 4, 5, 4, 4);
+ Ref<StyleBoxFlat> style_content_panel = make_flat_stylebox(base_color, 4, 4, 4, 4);
style_content_panel->set_border_color_all(base_color);
style_content_panel->set_border_width_all(border_width);
- Ref<StyleBoxFlat> style_content_panel_vp = make_flat_stylebox(base_color, border_width, 5, border_width, border_width);
+ Ref<StyleBoxFlat> style_content_panel_vp = make_flat_stylebox(base_color, border_width, 4, border_width, border_width);
style_content_panel_vp->set_border_color_all(base_color);
style_content_panel_vp->set_border_width_all(border_width);
theme->set_stylebox("panel", "TabContainer", style_content_panel);
@@ -357,6 +357,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
theme->set_stylebox("pressed", "Button", change_border_color(style_button_type, highlight_color));
theme->set_stylebox("focus", "Button", change_border_color(style_button_type, highlight_color));
theme->set_stylebox("disabled", "Button", style_button_type_disabled);
+
theme->set_color("font_color", "Button", button_font_color);
theme->set_color("font_color_hover", "Button", HIGHLIGHT_COLOR_FONT);
theme->set_color("font_color_pressed", "Button", highlight_color);
@@ -366,13 +367,12 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
theme->set_color("icon_color_pressed", "Button", Color(highlight_color.r * 1.15, highlight_color.g * 1.15, highlight_color.b * 1.15, highlight_color.a));
// OptionButton
- Ref<StyleBoxFlat> style_option_button = make_flat_stylebox(dark_color_1, 4, 4, 4, 4);
- style_option_button->set_border_width_all(border_width);
+ theme->set_stylebox("normal", "OptionButton", style_button_type);
theme->set_stylebox("hover", "OptionButton", change_border_color(style_button_type, contrast_color_1));
theme->set_stylebox("pressed", "OptionButton", change_border_color(style_button_type, HIGHLIGHT_COLOR_FONT));
theme->set_stylebox("focus", "OptionButton", change_border_color(style_button_type, highlight_color));
theme->set_stylebox("disabled", "OptionButton", style_button_type_disabled);
- theme->set_stylebox("normal", "OptionButton", style_button_type);
+
theme->set_color("font_color", "OptionButton", button_font_color);
theme->set_color("font_color_hover", "OptionButton", HIGHLIGHT_COLOR_FONT);
theme->set_color("font_color_pressed", "OptionButton", highlight_color);
@@ -385,6 +385,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
// CheckButton
theme->set_icon("on", "CheckButton", theme->get_icon("GuiToggleOn", "EditorIcons"));
theme->set_icon("off", "CheckButton", theme->get_icon("GuiToggleOff", "EditorIcons"));
+
theme->set_color("font_color", "CheckButton", button_font_color);
theme->set_color("font_color_hover", "CheckButton", HIGHLIGHT_COLOR_FONT);
theme->set_color("font_color_pressed", "CheckButton", highlight_color);
@@ -424,12 +425,6 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
style_tree_bg->set_border_color_all(dark_color_3);
theme->set_stylebox("bg", "Tree", style_tree_bg);
- // Script background
- Ref<StyleBoxFlat> style_script_bg = make_flat_stylebox(dark_color_1, 0, 0, 0, 0);
- style_script_bg->set_border_width_all(border_width);
- style_script_bg->set_border_color_all(dark_color_3);
- theme->set_stylebox("ScriptPanel", "EditorStyles", style_script_bg);
-
// Tree
theme->set_icon("checked", "Tree", theme->get_icon("GuiChecked", "EditorIcons"));
theme->set_icon("unchecked", "Tree", theme->get_icon("GuiUnchecked", "EditorIcons"));
@@ -441,7 +436,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
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_FONT);
- theme->set_color("font_color", "Tree", font_color_disabled);
+ theme->set_color("font_color", "Tree", font_color);
theme->set_color("font_color_selected", "Tree", font_color);
Ref<StyleBox> style_tree_btn = make_flat_stylebox(contrast_color_1, 2, 4, 2, 4);
@@ -471,8 +466,6 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
theme->set_color("prop_category", "Editor", prop_category_color);
theme->set_color("prop_section", "Editor", prop_section_color);
theme->set_color("prop_subsection", "Editor", prop_subsection_color);
- theme->set_color("fg_selected", "Editor", HIGHLIGHT_COLOR_BG);
- theme->set_color("fg_error", "Editor", error_color);
theme->set_color("drop_position_color", "Tree", highlight_color);
// ItemList
@@ -531,6 +524,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
// LineEdit
Ref<StyleBoxFlat> style_line_edit = make_flat_stylebox(dark_color_1, 6, 4, 6, 4);
+ style_line_edit->set_border_width_all(border_width);
style_line_edit = change_border_color(style_line_edit, contrast_color_1);
Ref<StyleBoxFlat> style_line_edit_disabled = change_border_color(style_line_edit, dark_color_1);
style_line_edit_disabled->set_bg_color(Color(0, 0, 0, .1));
@@ -614,11 +608,14 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
theme->set_icon("grabber_highlight", "VSlider", theme->get_icon("GuiSliderGrabberHl", "EditorIcons"));
//RichTextLabel
- theme->set_color("font_color", "RichTextLabel", font_color);
+ Color rtl_combined_bg_color = dark_color_1.linear_interpolate(script_bg_color, script_bg_color.a);
+ Color rtl_font_color = (rtl_combined_bg_color.r + rtl_combined_bg_color.g + rtl_combined_bg_color.b > 0.5 * 3) ? Color(0, 0, 0) : Color(1, 1, 1);
+ theme->set_color("default_color", "RichTextLabel", rtl_font_color);
theme->set_stylebox("focus", "RichTextLabel", make_empty_stylebox());
+ theme->set_stylebox("normal", "RichTextLabel", make_flat_stylebox(script_bg_color, 6, 6, 6, 6));
// Panel
- theme->set_stylebox("panel", "Panel", style_panel);
+ theme->set_stylebox("panel", "Panel", make_flat_stylebox(dark_color_1, 6, 4, 6, 4));
// Label
theme->set_color("font_color", "Label", font_color);
diff --git a/editor/fileserver/editor_file_server.cpp b/editor/fileserver/editor_file_server.cpp
index ba90beee22..fccf7c323c 100644
--- a/editor/fileserver/editor_file_server.cpp
+++ b/editor/fileserver/editor_file_server.cpp
@@ -34,7 +34,7 @@
#include "io/marshalls.h"
//#define DEBUG_PRINT(m_p) print_line(m_p)
-#define DEBUG_TIME(m_what) printf("MS: %s - %lli\n", m_what, OS::get_singleton()->get_ticks_usec());
+#define DEBUG_TIME(m_what) printf("MS: %s - %lu\n", m_what, OS::get_singleton()->get_ticks_usec());
//#define DEBUG_TIME(m_what)
diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp
index 04036f410a..a66d1724a1 100644
--- a/editor/filesystem_dock.cpp
+++ b/editor/filesystem_dock.cpp
@@ -1839,7 +1839,7 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) {
path = "res://";
- add_constant_override("separation", 3);
+ add_constant_override("separation", 4);
}
FileSystemDock::~FileSystemDock() {
diff --git a/editor/icons/icon_class_list.svg b/editor/icons/icon_class_list.svg
index 1f2b37bd25..87a20743c7 100644
--- a/editor/icons/icon_class_list.svg
+++ b/editor/icons/icon_class_list.svg
@@ -1,11 +1,5 @@
<svg width="16" height="16" version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
-<g transform="translate(0 -1036.4)" fill="#e0e0e0">
-<rect x="1" y="1038.4" width="5" height=".99998"/>
-<rect x="6" y="1037.4" width="6" height="3"/>
-<rect x="3" y="1038.4" width="1" height="11"/>
-<rect x="4" y="1043.4" width="5" height="1"/>
-<rect x="9" y="1042.4" width="6" height="3"/>
-<rect x="4" y="1048.4" width="5" height="1"/>
-<rect x="9" y="1047.4" width="6" height="3"/>
+<g transform="translate(0 -1036.4)">
+<path transform="translate(0 1036.4)" d="m6 1v1h-5v1h2v10h1 5v1h6v-3h-6v1h-5v-4h5v1h6v-3h-6v1h-5v-4h2v1h6v-3h-6z" fill="#e0e0e0"/>
</g>
</svg>
diff --git a/editor/icons/icon_file_dead.svg b/editor/icons/icon_file_dead.svg
new file mode 100644
index 0000000000..e0aee6fd90
--- /dev/null
+++ b/editor/icons/icon_file_dead.svg
@@ -0,0 +1,7 @@
+<svg width="16" height="16" version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
+<g transform="translate(0 -1036.4)">
+<g transform="translate(0 -1.6949e-5)">
+<path transform="translate(0 1036.4)" d="m2 1v14h12v-9h-5v-5zm8 0v4h4zm-6.0078 6c0.1353-0.0020779 0.26567 0.050774 0.36133 0.14648l0.64648 0.64648 0.64648-0.64648c0.09183-0.091882 0.21582-0.14442 0.3457-0.14648 0.1353-0.00208 0.26567 0.050774 0.36133 0.14648 0.19521 0.19525 0.19521 0.51178 0 0.70703l-0.64648 0.64648 0.64648 0.64648c0.19521 0.19525 0.19521 0.51178 0 0.70703-0.19525 0.19521-0.51178 0.19521-0.70703 0l-0.64648-0.64648-0.64648 0.64648c-0.19525 0.19521-0.51178 0.19521-0.70703 0-0.19521-0.19525-0.19521-0.51178 0-0.70703l0.64648-0.64648-0.64648-0.64648c-0.19521-0.19525-0.19521-0.51178 0-0.70703 0.09183-0.091882 0.21582-0.14442 0.3457-0.14648zm6 0c0.1353-0.00208 0.26567 0.050774 0.36133 0.14648l0.64648 0.64648 0.64648-0.64648c0.09183-0.091883 0.21582-0.14442 0.3457-0.14648 0.1353-0.00208 0.26567 0.050774 0.36133 0.14648 0.19521 0.19525 0.19521 0.51178 0 0.70703l-0.64648 0.64648 0.64648 0.64648c0.19521 0.19525 0.19521 0.51178 0 0.70703-0.19525 0.19521-0.51178 0.19521-0.70703 0l-0.64648-0.64648-0.64648 0.64648c-0.19525 0.19521-0.51178 0.19521-0.70703 0-0.19521-0.19525-0.19521-0.51178 0-0.70703l0.64648-0.64648-0.64648-0.64648c-0.19521-0.19525-0.19521-0.51178 0-0.70703 0.09183-0.091882 0.21582-0.14442 0.3457-0.14648zm-6.4922 4h9c0.277 0 0.5 0.223 0.5 0.5s-0.223 0.5-0.5 0.5h-4.5c0 1.1046-0.89543 2-2 2s-2-0.8954-2-2h-0.5c-0.277 0-0.5-0.223-0.5-0.5s0.223-0.5 0.5-0.5zm1.5 1c-1.9e-5 0.5523 0.44771 1 1 1s1-0.4477 1-1z" fill="#ff8484"/>
+</g>
+</g>
+</svg>
diff --git a/editor/icons/icon_filesystem.svg b/editor/icons/icon_filesystem.svg
new file mode 100644
index 0000000000..41e0348d68
--- /dev/null
+++ b/editor/icons/icon_filesystem.svg
@@ -0,0 +1,5 @@
+<svg width="16" height="16" version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
+<g transform="translate(0 -1036.4)">
+<path transform="translate(0 1036.4)" d="m1 1v5h2v8h1 5v1h6v-3h-6v1h-5v-4h5v1h6v-3h-6v1h-5v-2h3v-4h-2l-1-1h-3z" fill="#e0e0e0"/>
+</g>
+</svg>
diff --git a/editor/icons/icon_key_call.svg b/editor/icons/icon_key_call.svg
new file mode 100644
index 0000000000..7fcc65801a
--- /dev/null
+++ b/editor/icons/icon_key_call.svg
@@ -0,0 +1,5 @@
+<svg width="8" height="8" version="1.1" viewBox="0 0 8 8" xmlns="http://www.w3.org/2000/svg">
+<g transform="translate(0 -1044.4)">
+<rect transform="rotate(-45)" x="-741.53" y="741.08" width="6.1027" height="6.1027" ry=".76286" fill="#adf18f"/>
+</g>
+</svg>
diff --git a/editor/icons/icon_mini_checkerboard.svg b/editor/icons/icon_mini_checkerboard.svg
new file mode 100644
index 0000000000..e740113b2d
--- /dev/null
+++ b/editor/icons/icon_mini_checkerboard.svg
@@ -0,0 +1,4 @@
+<svg width="16" height="16" version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
+<path d="m0 0v8h8v-8h-8zm8 8v8h8v-8h-8z" fill="#e0e0e0" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.9994"/>
+<path d="m8 0v8h8v-8h-8zm0 8h-8v8h8v-8z" fill="#fff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.9994"/>
+</svg>
diff --git a/editor/icons/icon_shader_material.svg b/editor/icons/icon_shader_material.svg
new file mode 100644
index 0000000000..f77aa837c5
--- /dev/null
+++ b/editor/icons/icon_shader_material.svg
@@ -0,0 +1,11 @@
+<svg width="16" height="16" version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
+<g transform="translate(0 -1036.4)">
+<path transform="translate(0 1036.4)" d="m2 1c-0.55226 1e-4 -0.99994 0.4477-1 1v1h2 6 3l-2-2h-8z" fill="#ff7070"/>
+<path transform="translate(0 1036.4)" d="m1 3v2h2v-2h-2zm8 0v2h5l-2-2h-3z" fill="#ffeb70"/>
+<path transform="translate(0 1036.4)" d="m1 5v2h2v-2h-2zm8 0v1c0 0.554 0.44599 1 1 1h3 2v-1l-1-1h-5z" fill="#9dff70"/>
+<path transform="translate(0 1036.4)" d="m1 7v2h2v-2h-2zm12 0v2h2v-2h-2z" fill="#70ffb9"/>
+<path transform="translate(0 1036.4)" d="m1 9v2h2v-2h-2zm12 0v2h2v-2h-2z" fill="#70deff"/>
+<path transform="translate(0 1036.4)" d="m1 13v1c5.52e-5 0.5523 0.44774 0.9999 1 1h12c0.55226-1e-4 0.99994-0.4477 1-1v-1h-2-10-2z" fill="#ff70ac"/>
+<path transform="translate(0 1036.4)" d="m1 11v2h2v-2h-2zm12 0v2h2v-2h-2z" fill="#9f70ff"/>
+</g>
+</svg>
diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp
index 594728d2e0..0bbe287e2b 100644
--- a/editor/import/resource_importer_scene.cpp
+++ b/editor/import/resource_importer_scene.cpp
@@ -230,8 +230,8 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array
if (isroot)
return p_node;
-
- if (MeshInstance *mi = Object::cast_to<MeshInstance>(p_node)) {
+ MeshInstance *mi = Object::cast_to<MeshInstance>(p_node);
+ if (mi) {
Node *col = mi->create_trimesh_collision_node();
ERR_FAIL_COND_V(!col, NULL);
@@ -1024,7 +1024,7 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p
String root_type = p_options["nodes/root_type"];
if (scene->get_class() != root_type) {
- Node *base_node = base_node = Object::cast_to<Node>(ClassDB::instance(root_type));
+ Node *base_node = Object::cast_to<Node>(ClassDB::instance(root_type));
if (base_node) {
diff --git a/editor/import/resource_importer_texture.cpp b/editor/import/resource_importer_texture.cpp
index ade3550daa..f29bdde634 100644
--- a/editor/import/resource_importer_texture.cpp
+++ b/editor/import/resource_importer_texture.cpp
@@ -33,7 +33,7 @@
#include "io/config_file.h"
#include "io/image_loader.h"
#include "scene/resources/texture.h"
-
+#include "editor/editor_node.h"
void ResourceImporterTexture::_texture_reimport_srgb(const Ref<StreamTexture> &p_tex) {
singleton->mutex->lock();
@@ -411,10 +411,14 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String
if (compress_mode == COMPRESS_VIDEO_RAM) {
//must import in all formats, in order of priority (so platform choses the best supported one. IE, etc2 over etc).
//Android, GLES 2.x
+
+ bool ok_on_pc=false;
+
if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_s3tc")) {
_save_stex(image, p_save_path + ".s3tc.stex", compress_mode, lossy, Image::COMPRESS_S3TC, mipmaps, tex_flags, stream, detect_3d, detect_srgb, force_rgbe, detect_normal, force_normal);
r_platform_variants->push_back("s3tc");
+ ok_on_pc=true;
}
if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_etc2")) {
@@ -434,6 +438,9 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String
r_platform_variants->push_back("pvrtc");
}
+ if (!ok_on_pc) {
+ EditorNode::add_io_error("Warning, no suitable PC VRAM compression enabled in Project Settings. This texture will not display correcly on PC.");
+ }
} else {
//import normally
_save_stex(image, p_save_path + ".stex", compress_mode, lossy, Image::COMPRESS_S3TC /*this is ignored */, mipmaps, tex_flags, stream, detect_3d, detect_srgb, force_rgbe, detect_normal, force_normal);
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index 3b74601e78..2b2358f3d0 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -580,7 +580,8 @@ void CanvasItemEditor::_key_move(const Vector2 &p_dir, bool p_snap, KeyMoveMODE
} else { // p_move_mode==MOVE_LOCAL_BASE || p_move_mode==MOVE_LOCAL_WITH_ROT
- if (Node2D *node_2d = Object::cast_to<Node2D>(canvas_item)) {
+ Node2D *node_2d = Object::cast_to<Node2D>(canvas_item);
+ if (node_2d) {
if (p_move_mode == MOVE_LOCAL_WITH_ROT) {
Transform2D m;
@@ -589,9 +590,10 @@ void CanvasItemEditor::_key_move(const Vector2 &p_dir, bool p_snap, KeyMoveMODE
}
node_2d->set_position(node_2d->get_position() + drag);
- } else if (Control *control = Object::cast_to<Control>(canvas_item)) {
-
- control->set_position(control->get_position() + drag);
+ } else {
+ Control *control = Object::cast_to<Control>(canvas_item);
+ if (control)
+ control->set_position(control->get_position() + drag);
}
}
}
@@ -742,7 +744,8 @@ float CanvasItemEditor::_anchor_snap(float p_anchor, bool *p_snapped, float p_op
float radius = 0.05 / zoom;
float basic_anchors[3] = { 0.0, 0.5, 1.0 };
for (int i = 0; i < 3; i++) {
- if ((dist = fabs(p_anchor - basic_anchors[i])) < radius) {
+ dist = fabs(p_anchor - basic_anchors[i]);
+ if (dist < radius) {
if (!snapped || dist <= dist_min) {
p_anchor = basic_anchors[i];
dist_min = dist;
@@ -750,7 +753,8 @@ float CanvasItemEditor::_anchor_snap(float p_anchor, bool *p_snapped, float p_op
}
}
}
- if (p_opposite_anchor >= 0 && (dist = fabs(p_anchor - p_opposite_anchor)) < radius) {
+ dist = fabs(p_anchor - p_opposite_anchor);
+ if (p_opposite_anchor >= 0 && dist < radius) {
if (!snapped || dist <= dist_min) {
p_anchor = p_opposite_anchor;
dist_min = dist;
@@ -1019,6 +1023,51 @@ void CanvasItemEditor::_list_select(const Ref<InputEventMouseButton> &b) {
}
}
+void CanvasItemEditor::_update_cursor() {
+
+ CursorShape c = CURSOR_ARROW;
+ switch (drag) {
+ case DRAG_NONE:
+ if (Input::get_singleton()->is_mouse_button_pressed(BUTTON_MIDDLE) || Input::get_singleton()->is_key_pressed(KEY_SPACE)) {
+ c = CURSOR_DRAG;
+ } else {
+ switch (tool) {
+ case TOOL_MOVE:
+ c = CURSOR_MOVE;
+ break;
+ case TOOL_EDIT_PIVOT:
+ c = CURSOR_CROSS;
+ break;
+ case TOOL_PAN:
+ c = CURSOR_DRAG;
+ break;
+ }
+ }
+ break;
+ case DRAG_LEFT:
+ case DRAG_RIGHT:
+ c = CURSOR_HSIZE;
+ break;
+ case DRAG_TOP:
+ case DRAG_BOTTOM:
+ c = CURSOR_VSIZE;
+ break;
+ case DRAG_TOP_LEFT:
+ case DRAG_BOTTOM_RIGHT:
+ c = CURSOR_FDIAGSIZE;
+ break;
+ case DRAG_TOP_RIGHT:
+ case DRAG_BOTTOM_LEFT:
+ c = CURSOR_BDIAGSIZE;
+ break;
+ case DRAG_ALL:
+ case DRAG_NODE_2D:
+ c = CURSOR_MOVE;
+ break;
+ }
+ viewport->set_default_cursor_shape(c);
+}
+
void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
{
@@ -1457,6 +1506,7 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
Ref<InputEventMouseMotion> m = p_event;
if (m.is_valid()) {
// Mouse motion event
+ _update_cursor();
if (!viewport->has_focus() && (!get_focus_owner() || !get_focus_owner()->is_text_field()))
viewport->call_deferred("grab_focus");
@@ -1469,7 +1519,7 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) {
}
if (drag == DRAG_NONE) {
- if ((m->get_button_mask() & BUTTON_MASK_LEFT && tool == TOOL_PAN) || m->get_button_mask() & BUTTON_MASK_MIDDLE || (m->get_button_mask() & BUTTON_MASK_LEFT && Input::get_singleton()->is_key_pressed(KEY_SPACE))) {
+ if (((m->get_button_mask() & BUTTON_MASK_LEFT) && tool == TOOL_PAN) || (m->get_button_mask() & BUTTON_MASK_MIDDLE) || ((m->get_button_mask() & BUTTON_MASK_LEFT) && Input::get_singleton()->is_key_pressed(KEY_SPACE))) {
// Pan the viewport
Point2i relative;
if (bool(EditorSettings::get_singleton()->get("editors/2d/warped_mouse_panning"))) {
@@ -2223,6 +2273,8 @@ void CanvasItemEditor::_notification(int p_what) {
if (p_what == NOTIFICATION_FIXED_PROCESS) {
+ EditorNode::get_singleton()->get_scene_root()->set_snap_controls_to_pixels(GLOBAL_GET("gui/common/snap_controls_to_pixels"));
+
List<Node *> &selection = editor_selection->get_selected_node_list();
bool all_control = true;
@@ -3562,29 +3614,31 @@ void CanvasItemEditorViewport::_create_preview(const Vector<String> &files) cons
Sprite *sprite = memnew(Sprite);
sprite->set_texture(texture);
sprite->set_modulate(Color(1, 1, 1, 0.7f));
- preview->add_child(sprite);
+ preview_node->add_child(sprite);
label->show();
label_desc->show();
} else {
if (scene.is_valid()) {
Node *instance = scene->instance();
if (instance) {
- preview->add_child(instance);
+ preview_node->add_child(instance);
}
}
}
- editor->get_scene_root()->add_child(preview);
+ editor->get_scene_root()->add_child(preview_node);
}
}
}
void CanvasItemEditorViewport::_remove_preview() {
- if (preview->get_parent()) {
- editor->get_scene_root()->remove_child(preview);
- for (int i = preview->get_child_count() - 1; i >= 0; i--) {
- Node *node = preview->get_child(i);
- memdelete(node);
+ if (preview_node->get_parent()) {
+ for (int i = preview_node->get_child_count() - 1; i >= 0; i--) {
+ Node *node = preview_node->get_child(i);
+ node->queue_delete();
+ preview_node->remove_child(node);
}
+ editor->get_scene_root()->remove_child(preview_node);
+
label->hide();
label_desc->hide();
}
@@ -3794,11 +3848,11 @@ bool CanvasItemEditorViewport::can_drop_data(const Point2 &p_point, const Varian
break;
}
if (can_instance) {
- if (!preview->get_parent()) { // create preview only once
+ if (!preview_node->get_parent()) { // create preview only once
_create_preview(files);
}
Transform2D trans = canvas->get_canvas_transform();
- preview->set_position((p_point - trans.get_origin()) / trans.get_scale().x);
+ preview_node->set_position((p_point - trans.get_origin()) / trans.get_scale().x);
label->set_text(vformat(TTR("Adding %s..."), default_type));
}
return can_instance;
@@ -3820,11 +3874,16 @@ void CanvasItemEditorViewport::drop_data(const Point2 &p_point, const Variant &p
List<Node *> list = editor->get_editor_selection()->get_selected_node_list();
if (list.size() == 0) {
- accept->get_ok()->set_text(TTR("OK :("));
- accept->set_text(TTR("No parent to instance a child at."));
- accept->popup_centered_minsize();
- _remove_preview();
- return;
+ Node *root_node = editor->get_edited_scene();
+ if (root_node) {
+ list.push_back(root_node);
+ } else {
+ accept->get_ok()->set_text(TTR("OK :("));
+ accept->set_text(TTR("No parent to instance a child at."));
+ accept->popup_centered_minsize();
+ _remove_preview();
+ return;
+ }
}
if (list.size() != 1) {
accept->get_ok()->set_text(TTR("I see.."));
@@ -3891,7 +3950,7 @@ CanvasItemEditorViewport::CanvasItemEditorViewport(EditorNode *p_node, CanvasIte
editor = p_node;
editor_data = editor->get_scene_tree_dock()->get_editor_data();
canvas = p_canvas;
- preview = memnew(Node2D);
+ preview_node = memnew(Node2D);
accept = memnew(AcceptDialog);
editor->get_gui_base()->add_child(accept);
@@ -3945,5 +4004,5 @@ CanvasItemEditorViewport::CanvasItemEditorViewport(EditorNode *p_node, CanvasIte
}
CanvasItemEditorViewport::~CanvasItemEditorViewport() {
- memdelete(preview);
+ memdelete(preview_node);
}
diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h
index da217007ea..2e1a2eac5f 100644
--- a/editor/plugins/canvas_item_editor_plugin.h
+++ b/editor/plugins/canvas_item_editor_plugin.h
@@ -34,7 +34,6 @@
#include "editor/editor_plugin.h"
#include "scene/2d/canvas_item.h"
#include "scene/gui/box_container.h"
-#include "scene/gui/button_group.h"
#include "scene/gui/check_box.h"
#include "scene/gui/label.h"
#include "scene/gui/panel_container.h"
@@ -324,6 +323,7 @@ class CanvasItemEditor : public VBoxContainer {
bool updating_scroll;
void _update_scroll(float);
void _update_scrollbars();
+ void _update_cursor();
void incbeg(float &beg, float &end, float inc, float minsize, bool p_symmetric);
void incend(float &beg, float &end, float inc, float minsize, bool p_symmetric);
@@ -459,7 +459,7 @@ class CanvasItemEditorViewport : public Control {
EditorNode *editor;
EditorData *editor_data;
CanvasItemEditor *canvas;
- Node2D *preview;
+ Node2D *preview_node;
AcceptDialog *accept;
WindowDialog *selector;
Label *selector_label;
diff --git a/editor/plugins/collision_polygon_2d_editor_plugin.h b/editor/plugins/collision_polygon_2d_editor_plugin.h
index bc3c5a1659..4715abd2e6 100644
--- a/editor/plugins/collision_polygon_2d_editor_plugin.h
+++ b/editor/plugins/collision_polygon_2d_editor_plugin.h
@@ -33,7 +33,6 @@
#include "editor/editor_node.h"
#include "editor/editor_plugin.h"
#include "scene/2d/collision_polygon_2d.h"
-#include "scene/gui/button_group.h"
#include "scene/gui/tool_button.h"
/**
diff --git a/editor/plugins/collision_polygon_editor_plugin.h b/editor/plugins/collision_polygon_editor_plugin.h
index 0150d8a9d7..0f63810443 100644
--- a/editor/plugins/collision_polygon_editor_plugin.h
+++ b/editor/plugins/collision_polygon_editor_plugin.h
@@ -35,7 +35,6 @@
#include "scene/3d/collision_polygon.h"
#include "scene/3d/immediate_geometry.h"
#include "scene/3d/mesh_instance.h"
-#include "scene/gui/button_group.h"
#include "scene/gui/tool_button.h"
/**
diff --git a/editor/plugins/cube_grid_theme_editor_plugin.cpp b/editor/plugins/cube_grid_theme_editor_plugin.cpp
index 08b38c2ca2..1c17daf425 100644
--- a/editor/plugins/cube_grid_theme_editor_plugin.cpp
+++ b/editor/plugins/cube_grid_theme_editor_plugin.cpp
@@ -88,7 +88,7 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library,
if (mesh.is_null())
continue;
- int id = p_library->find_item_name(mi->get_name());
+ int id = p_library->find_item_by_name(mi->get_name());
if (id < 0) {
id = p_library->get_last_unused_item_id();
@@ -111,7 +111,8 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library,
sb->get_shape_owners(&shapes);
for (List<uint32_t>::Element *E = shapes.front(); E; E = E->next()) {
- if (sb->is_shape_owner_disabled(E->get())) continue;
+ if (sb->is_shape_owner_disabled(E->get()))
+ continue;
//Transform shape_transform = sb->shape_owner_get_transform(E->get());
@@ -120,7 +121,7 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library,
for (int k = 0; k < sb->shape_owner_get_shape_count(E->get()); k++) {
Ref<Shape> collision = sb->shape_owner_get_shape(E->get(), k);
- if (collision.is_valid())
+ if (!collision.is_valid())
continue;
MeshLibrary::ShapeData shape_data;
shape_data.shape = collision;
diff --git a/editor/plugins/light_occluder_2d_editor_plugin.h b/editor/plugins/light_occluder_2d_editor_plugin.h
index 7a4f18963d..b270dcb6e5 100644
--- a/editor/plugins/light_occluder_2d_editor_plugin.h
+++ b/editor/plugins/light_occluder_2d_editor_plugin.h
@@ -33,7 +33,6 @@
#include "editor/editor_node.h"
#include "editor/editor_plugin.h"
#include "scene/2d/light_occluder_2d.h"
-#include "scene/gui/button_group.h"
#include "scene/gui/tool_button.h"
/**
diff --git a/editor/plugins/line_2d_editor_plugin.h b/editor/plugins/line_2d_editor_plugin.h
index dea77ec248..dea0433084 100644
--- a/editor/plugins/line_2d_editor_plugin.h
+++ b/editor/plugins/line_2d_editor_plugin.h
@@ -34,7 +34,6 @@
#include "editor/editor_plugin.h"
#include "scene/2d/line_2d.h"
#include "scene/2d/path_2d.h"
-#include "scene/gui/button_group.h"
#include "scene/gui/tool_button.h"
class CanvasItemEditor;
diff --git a/editor/plugins/navigation_polygon_editor_plugin.h b/editor/plugins/navigation_polygon_editor_plugin.h
index 33f9d5c785..7dd555e9c9 100644
--- a/editor/plugins/navigation_polygon_editor_plugin.h
+++ b/editor/plugins/navigation_polygon_editor_plugin.h
@@ -33,7 +33,6 @@
#include "editor/editor_node.h"
#include "editor/editor_plugin.h"
#include "scene/2d/navigation_polygon.h"
-#include "scene/gui/button_group.h"
#include "scene/gui/tool_button.h"
/**
diff --git a/editor/plugins/path_2d_editor_plugin.h b/editor/plugins/path_2d_editor_plugin.h
index c195845244..f0f5d4d637 100644
--- a/editor/plugins/path_2d_editor_plugin.h
+++ b/editor/plugins/path_2d_editor_plugin.h
@@ -33,7 +33,6 @@
#include "editor/editor_node.h"
#include "editor/editor_plugin.h"
#include "scene/2d/path_2d.h"
-#include "scene/gui/button_group.h"
#include "scene/gui/tool_button.h"
/**
diff --git a/editor/plugins/polygon_2d_editor_plugin.cpp b/editor/plugins/polygon_2d_editor_plugin.cpp
index f7008298f0..3917c700f0 100644
--- a/editor/plugins/polygon_2d_editor_plugin.cpp
+++ b/editor/plugins/polygon_2d_editor_plugin.cpp
@@ -395,7 +395,7 @@ bool Polygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
if (mm.is_valid()) {
- if (edited_point != -1 && (wip_active || mm->get_button_mask() & BUTTON_MASK_LEFT)) {
+ if (edited_point != -1 && (wip_active || (mm->get_button_mask() & BUTTON_MASK_LEFT))) {
Vector2 gpoint = mm->get_position();
Vector2 cpoint = canvas_item_editor->get_canvas_transform().affine_inverse().xform(gpoint);
@@ -554,7 +554,7 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
if (mm.is_valid()) {
- if (mm->get_button_mask() & BUTTON_MASK_MIDDLE || Input::get_singleton()->is_key_pressed(KEY_SPACE)) {
+ if ((mm->get_button_mask() & BUTTON_MASK_MIDDLE) || Input::get_singleton()->is_key_pressed(KEY_SPACE)) {
Vector2 drag(mm->get_relative().x, mm->get_relative().y);
uv_hscroll->set_value(uv_hscroll->get_value() - drag.x);
diff --git a/editor/plugins/polygon_2d_editor_plugin.h b/editor/plugins/polygon_2d_editor_plugin.h
index 38148ca7e3..f9d6a6b4b6 100644
--- a/editor/plugins/polygon_2d_editor_plugin.h
+++ b/editor/plugins/polygon_2d_editor_plugin.h
@@ -33,7 +33,6 @@
#include "editor/editor_node.h"
#include "editor/editor_plugin.h"
#include "scene/2d/polygon_2d.h"
-#include "scene/gui/button_group.h"
#include "scene/gui/tool_button.h"
/**
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index a529f152dc..04be1ba4ab 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -972,6 +972,14 @@ void ScriptEditor::_menu_option(int p_option) {
EditorNode::get_singleton()->show_warning("Can't obtain the script for running");
break;
}
+
+ current->apply_code();
+ Error err = scr->reload(false); //hard reload script before running always
+
+ if (err != OK) {
+ EditorNode::get_singleton()->show_warning("Script failed reloading, check console for errors.");
+ return;
+ }
if (!scr->is_tool()) {
EditorNode::get_singleton()->show_warning("Script is not in tool mode, will not be able to run");
@@ -1149,8 +1157,6 @@ void ScriptEditor::_notification(int p_what) {
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
- tab_container->add_style_override("panel", editor->get_gui_base()->get_stylebox("ScriptPanel", "EditorStyles"));
-
help_search->set_icon(get_icon("HelpSearch", "EditorIcons"));
site_search->set_icon(get_icon("Instance", "EditorIcons"));
class_search->set_icon(get_icon("ClassList", "EditorIcons"));
@@ -1417,7 +1423,7 @@ void ScriptEditor::_update_script_colors() {
int non_zero_hist_size = (hist_size == 0) ? 1 : hist_size;
float v = Math::ease((edit_pass - pass) / float(non_zero_hist_size), 0.4);
- script_list->set_item_custom_bg_color(i, hot_color.linear_interpolate(cold_color, v));
+ script_list->set_item_custom_fg_color(i, hot_color.linear_interpolate(cold_color, v));
}
}
}
@@ -1539,8 +1545,14 @@ bool ScriptEditor::edit(const Ref<Script> &p_script, int p_line, int p_col, bool
bool open_dominant = EditorSettings::get_singleton()->get("text_editor/files/open_dominant_script_on_scene_change");
+ if (p_script->get_language()->overrides_external_editor()) {
+ Error err = p_script->get_language()->open_in_external_editor(p_script, p_line >= 0 ? p_line : 0, p_col);
+ if (err != OK)
+ ERR_PRINT("Couldn't open script in the overridden external text editor");
+ return false;
+ }
+
if ((debugger->get_dump_stack_script() != p_script || debugger->get_debug_with_external_editor()) &&
- p_script->get_language()->open_in_external_editor(p_script, p_line >= 0 ? p_line : 0, p_col) == OK &&
p_script->get_path().is_resource_file() &&
bool(EditorSettings::get_singleton()->get("text_editor/external/use_external_editor"))) {
@@ -2210,7 +2222,6 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
members_overview->set_v_size_flags(SIZE_EXPAND_FILL);
tab_container = memnew(TabContainer);
- tab_container->add_style_override("panel", p_editor->get_gui_base()->get_stylebox("ScriptPanel", "EditorStyles"));
tab_container->set_tabs_visible(false);
script_split->add_child(tab_container);
@@ -2506,9 +2517,9 @@ ScriptEditorPlugin::ScriptEditorPlugin(EditorNode *p_node) {
EDITOR_DEF("text_editor/open_scripts/script_temperature_enabled", true);
EDITOR_DEF("text_editor/open_scripts/highlight_current_script", true);
EDITOR_DEF("text_editor/open_scripts/script_temperature_history_size", 15);
- EDITOR_DEF("text_editor/open_scripts/script_temperature_hot_color", Color(1, 0, 0, 0.3));
- EDITOR_DEF("text_editor/open_scripts/script_temperature_cold_color", Color(0, 0, 1, 0.3));
- EDITOR_DEF("text_editor/open_scripts/current_script_background_color", Color(0.81, 0.81, 0.14, 0.63));
+ EDITOR_DEF("text_editor/open_scripts/script_temperature_hot_color", Color::html("ed5e5e"));
+ EDITOR_DEF("text_editor/open_scripts/script_temperature_cold_color", Color(1, 1, 1, 0.3));
+ EDITOR_DEF("text_editor/open_scripts/current_script_background_color", Color(1, 1, 1, 0.5));
EDITOR_DEF("text_editor/open_scripts/group_help_pages", true);
EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::INT, "text_editor/open_scripts/sort_scripts_by", PROPERTY_HINT_ENUM, "Name,Path"));
EDITOR_DEF("text_editor/open_scripts/sort_scripts_by", 0);
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp
index 33890d890d..fae57eb5d2 100644
--- a/editor/plugins/script_text_editor.cpp
+++ b/editor/plugins/script_text_editor.cpp
@@ -75,14 +75,9 @@ void ScriptTextEditor::_load_theme_settings() {
text_edit->clear_colors();
- /* color from color_theme or from editor color */
-
- Color background_color = EDITOR_DEF("text_editor/highlighting/background_color", Color(0, 0, 0, 0));
- if (EDITOR_DEF("text_editor/theme/adapted_code_editor_background_color", false))
- background_color = get_color("dark_color_1", "Editor");
-
/* keyword color */
- text_edit->add_color_override("background_color", background_color);
+
+ text_edit->add_color_override("background_color", EDITOR_DEF("text_editor/highlighting/background_color", Color(0, 0, 0, 0)));
text_edit->add_color_override("completion_background_color", EDITOR_DEF("text_editor/highlighting/completion_background_color", Color(0, 0, 0, 0)));
text_edit->add_color_override("completion_selected_color", EDITOR_DEF("text_editor/highlighting/completion_selected_color", Color::html("434244")));
text_edit->add_color_override("completion_existing_color", EDITOR_DEF("text_editor/highlighting/completion_existing_color", Color::html("21dfdfdf")));
diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp
index 13b0391a87..b02016c273 100644
--- a/editor/plugins/shader_editor_plugin.cpp
+++ b/editor/plugins/shader_editor_plugin.cpp
@@ -289,6 +289,8 @@ void ShaderEditor::_editor_settings_changed() {
shader_editor->get_text_edit()->cursor_set_blink_speed(EditorSettings::get_singleton()->get("text_editor/cursor/caret_blink_speed"));
shader_editor->get_text_edit()->add_constant_override("line_spacing", EditorSettings::get_singleton()->get("text_editor/theme/line_spacing"));
shader_editor->get_text_edit()->cursor_set_block_mode(EditorSettings::get_singleton()->get("text_editor/cursor/block_caret"));
+ shader_editor->get_text_edit()->set_smooth_scroll_enabled(EditorSettings::get_singleton()->get("text_editor/open_scripts/smooth_scrolling"));
+ shader_editor->get_text_edit()->set_v_scroll_speed(EditorSettings::get_singleton()->get("text_editor/open_scripts/v_scroll_speed"));
}
void ShaderEditor::_bind_methods() {
diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp
index d9fc2f32f7..4e722be44b 100644
--- a/editor/plugins/spatial_editor_plugin.cpp
+++ b/editor/plugins/spatial_editor_plugin.cpp
@@ -35,12 +35,15 @@
#include "editor/editor_node.h"
#include "editor/editor_settings.h"
#include "editor/plugins/animation_player_editor_plugin.h"
+#include "editor/plugins/script_editor_plugin.h"
+#include "editor/script_editor_debugger.h"
#include "editor/spatial_editor_gizmos.h"
#include "os/keyboard.h"
#include "print_string.h"
#include "project_settings.h"
#include "scene/3d/camera.h"
#include "scene/3d/visual_instance.h"
+#include "scene/resources/packed_scene.h"
#include "scene/resources/surface_tool.h"
#include "sort.h"
@@ -77,7 +80,7 @@ void SpatialEditorViewport::_update_camera(float p_interp_delta) {
Transform old_transform = camera->get_global_transform();
Transform transform;
- bool disable_interp = (Input::get_singleton()->get_mouse_button_mask() & (2 | 4)) || Input::get_singleton()->is_key_pressed(KEY_SHIFT) || Input::get_singleton()->is_key_pressed(KEY_ALT) || Input::get_singleton()->is_key_pressed(KEY_CONTROL);
+ bool disable_interp = orthogonal || (Input::get_singleton()->get_mouse_button_mask() & (2 | 4)) || Input::get_singleton()->is_key_pressed(KEY_SHIFT) || Input::get_singleton()->is_key_pressed(KEY_ALT) || Input::get_singleton()->is_key_pressed(KEY_CONTROL);
if (p_interp_delta && !disable_interp) {
//interpolate
@@ -228,7 +231,7 @@ Vector3 SpatialEditorViewport::_get_camera_normal() const {
return -_get_camera_transform().basis.get_axis(2);
}
-Vector3 SpatialEditorViewport::_get_ray(const Vector2 &p_pos) {
+Vector3 SpatialEditorViewport::_get_ray(const Vector2 &p_pos) const {
return camera->project_ray_normal(p_pos);
}
@@ -700,6 +703,11 @@ void SpatialEditorViewport::_smouseenter() {
surface->grab_focus();
}
+void SpatialEditorViewport::_smouseexit() {
+
+ _remove_preview();
+}
+
void SpatialEditorViewport::_list_select(Ref<InputEventMouseButton> b) {
_find_items_at_pos(b->get_position(), clicked_includes_current, selection_results, b->get_shift());
@@ -1895,6 +1903,7 @@ void SpatialEditorViewport::_notification(int p_what) {
surface->connect("draw", this, "_draw");
surface->connect("gui_input", this, "_sinput");
surface->connect("mouse_entered", this, "_smouseenter");
+ surface->connect("mouse_exited", this, "_smouseexit");
info->add_style_override("panel", get_stylebox("panel", "Panel"));
preview_camera->set_icon(get_icon("Camera", "EditorIcons"));
_init_gizmo_instance(index);
@@ -2425,6 +2434,7 @@ void SpatialEditorViewport::_bind_methods() {
ClassDB::bind_method(D_METHOD("_draw"), &SpatialEditorViewport::_draw);
ClassDB::bind_method(D_METHOD("_smouseenter"), &SpatialEditorViewport::_smouseenter);
+ ClassDB::bind_method(D_METHOD("_smouseexit"), &SpatialEditorViewport::_smouseexit);
ClassDB::bind_method(D_METHOD("_sinput"), &SpatialEditorViewport::_sinput);
ClassDB::bind_method(D_METHOD("_menu_option"), &SpatialEditorViewport::_menu_option);
ClassDB::bind_method(D_METHOD("_toggle_camera_preview"), &SpatialEditorViewport::_toggle_camera_preview);
@@ -2432,6 +2442,8 @@ void SpatialEditorViewport::_bind_methods() {
ClassDB::bind_method(D_METHOD("update_transform_gizmo_view"), &SpatialEditorViewport::update_transform_gizmo_view);
ClassDB::bind_method(D_METHOD("_selection_result_pressed"), &SpatialEditorViewport::_selection_result_pressed);
ClassDB::bind_method(D_METHOD("_selection_menu_hide"), &SpatialEditorViewport::_selection_menu_hide);
+ ClassDB::bind_method(D_METHOD("can_drop_data_fw"), &SpatialEditorViewport::can_drop_data_fw);
+ ClassDB::bind_method(D_METHOD("drop_data_fw"), &SpatialEditorViewport::drop_data_fw);
ADD_SIGNAL(MethodInfo("toggle_maximize_view", PropertyInfo(Variant::OBJECT, "viewport")));
}
@@ -2481,6 +2493,293 @@ void SpatialEditorViewport::focus_selection() {
cursor.pos = center;
}
+void SpatialEditorViewport::assign_pending_data_pointers(Spatial *p_preview_node, Rect3 *p_preview_bounds, AcceptDialog *p_accept) {
+ preview_node = p_preview_node;
+ preview_bounds = p_preview_bounds;
+ accept = p_accept;
+}
+
+Vector3 SpatialEditorViewport::_get_instance_position(const Point2 &p_pos) const {
+ const float MAX_DISTANCE = 10;
+
+ Vector3 world_ray = _get_ray(p_pos);
+ Vector3 world_pos = _get_ray_pos(p_pos);
+
+ Vector<ObjectID> instances = VisualServer::get_singleton()->instances_cull_ray(world_pos, world_ray, get_tree()->get_root()->get_world()->get_scenario());
+ Set<Ref<SpatialEditorGizmo> > found_gizmos;
+
+ float closest_dist = MAX_DISTANCE;
+
+ Vector3 point = world_pos + world_ray * MAX_DISTANCE;
+ Vector3 normal = Vector3(0.0, 0.0, 0.0);
+
+ for (int i = 0; i < instances.size(); i++) {
+
+ MeshInstance *mesh_instance = Object::cast_to<MeshInstance>(ObjectDB::get_instance(instances[i]));
+
+ if (!mesh_instance)
+ continue;
+
+ Ref<SpatialEditorGizmo> seg = mesh_instance->get_gizmo();
+
+ if ((!seg.is_valid()) || found_gizmos.has(seg)) {
+ continue;
+ }
+
+ found_gizmos.insert(seg);
+
+ int handle = -1;
+ Vector3 hit_point;
+ Vector3 hit_normal;
+ bool inters = seg->intersect_ray(camera, p_pos, hit_point, hit_normal, NULL, false);
+
+ if (!inters)
+ continue;
+
+ float dist = world_pos.distance_to(hit_point);
+
+ if (dist < 0)
+ continue;
+
+ if (dist < closest_dist) {
+ closest_dist = dist;
+ point = hit_point;
+ normal = hit_normal;
+ }
+ }
+ Vector3 center = preview_bounds->get_size() * 0.5;
+ return point + (center * normal);
+}
+
+Rect3 SpatialEditorViewport::_calculate_spatial_bounds(const Spatial *p_parent, const Rect3 p_bounds) {
+ Rect3 bounds = p_bounds;
+ for (int i = 0; i < p_parent->get_child_count(); i++) {
+ Spatial *child = Object::cast_to<Spatial>(p_parent->get_child(i));
+ if (child) {
+ MeshInstance *mesh_instance = Object::cast_to<MeshInstance>(child);
+ if (mesh_instance) {
+ Rect3 mesh_instance_bounds = mesh_instance->get_aabb();
+ mesh_instance_bounds.position += mesh_instance->get_global_transform().origin - p_parent->get_global_transform().origin;
+ bounds.merge_with(mesh_instance_bounds);
+ }
+ bounds = _calculate_spatial_bounds(child, bounds);
+ }
+ }
+ return bounds;
+}
+
+void SpatialEditorViewport::_create_preview(const Vector<String> &files) const {
+ for (int i = 0; i < files.size(); i++) {
+ String path = files[i];
+ RES res = ResourceLoader::load(path);
+ Ref<PackedScene> scene = Ref<PackedScene>(Object::cast_to<PackedScene>(*res));
+ if (scene != NULL) {
+ if (scene.is_valid()) {
+ Node *instance = scene->instance();
+ if (instance) {
+ preview_node->add_child(instance);
+ }
+ }
+ editor->get_scene_root()->add_child(preview_node);
+ }
+ }
+ *preview_bounds = _calculate_spatial_bounds(preview_node, Rect3());
+}
+
+void SpatialEditorViewport::_remove_preview() {
+ if (preview_node->get_parent()) {
+ for (int i = preview_node->get_child_count() - 1; i >= 0; i--) {
+ Node *node = preview_node->get_child(i);
+ node->queue_delete();
+ preview_node->remove_child(node);
+ }
+ editor->get_scene_root()->remove_child(preview_node);
+ }
+}
+
+bool SpatialEditorViewport::_cyclical_dependency_exists(const String &p_target_scene_path, Node *p_desired_node) {
+ if (p_desired_node->get_filename() == p_target_scene_path) {
+ return true;
+ }
+
+ int childCount = p_desired_node->get_child_count();
+ for (int i = 0; i < childCount; i++) {
+ Node *child = p_desired_node->get_child(i);
+ if (_cyclical_dependency_exists(p_target_scene_path, child)) {
+ return true;
+ }
+ }
+ return false;
+}
+
+bool SpatialEditorViewport::_create_instance(Node *parent, String &path, const Point2 &p_point) {
+ Ref<PackedScene> sdata = ResourceLoader::load(path);
+ if (!sdata.is_valid()) { // invalid scene
+ return false;
+ }
+
+ Node *instanced_scene = sdata->instance(PackedScene::GEN_EDIT_STATE_INSTANCE);
+ if (!instanced_scene) { // error on instancing
+ return false;
+ }
+
+ if (editor->get_edited_scene()->get_filename() != "") { // cyclical instancing
+ if (_cyclical_dependency_exists(editor->get_edited_scene()->get_filename(), instanced_scene)) {
+ memdelete(instanced_scene);
+ return false;
+ }
+ }
+
+ instanced_scene->set_filename(ProjectSettings::get_singleton()->localize_path(path));
+
+ editor_data->get_undo_redo().add_do_method(parent, "add_child", instanced_scene);
+ editor_data->get_undo_redo().add_do_method(instanced_scene, "set_owner", editor->get_edited_scene());
+ editor_data->get_undo_redo().add_do_reference(instanced_scene);
+ editor_data->get_undo_redo().add_undo_method(parent, "remove_child", instanced_scene);
+
+ String new_name = parent->validate_child_name(instanced_scene);
+ ScriptEditorDebugger *sed = ScriptEditor::get_singleton()->get_debugger();
+ editor_data->get_undo_redo().add_do_method(sed, "live_debug_instance_node", editor->get_edited_scene()->get_path_to(parent), path, new_name);
+ editor_data->get_undo_redo().add_undo_method(sed, "live_debug_remove_node", NodePath(String(editor->get_edited_scene()->get_path_to(parent)) + "/" + new_name));
+
+ Transform global_transform;
+ Spatial *parent_spatial = Object::cast_to<Spatial>(parent);
+ if (parent_spatial)
+ global_transform = parent_spatial->get_global_transform();
+
+ global_transform.origin = _get_instance_position(p_point);
+
+ editor_data->get_undo_redo().add_do_method(instanced_scene, "set_global_transform", global_transform);
+
+ return true;
+}
+
+void SpatialEditorViewport::_perform_drop_data() {
+ _remove_preview();
+
+ Vector<String> error_files;
+
+ editor_data->get_undo_redo().create_action(TTR("Create Node"));
+
+ for (int i = 0; i < selected_files.size(); i++) {
+ String path = selected_files[i];
+ RES res = ResourceLoader::load(path);
+ if (res.is_null()) {
+ continue;
+ }
+ Ref<PackedScene> scene = Ref<PackedScene>(Object::cast_to<PackedScene>(*res));
+ if (scene != NULL) {
+ bool success = _create_instance(target_node, path, drop_pos);
+ if (!success) {
+ error_files.push_back(path);
+ }
+ }
+ }
+
+ editor_data->get_undo_redo().commit_action();
+
+ if (error_files.size() > 0) {
+ String files_str;
+ for (int i = 0; i < error_files.size(); i++) {
+ files_str += error_files[i].get_file().get_basename() + ",";
+ }
+ files_str = files_str.substr(0, files_str.length() - 1);
+ accept->get_ok()->set_text(TTR("Ugh"));
+ accept->set_text(vformat(TTR("Error instancing scene from %s"), files_str.c_str()));
+ accept->popup_centered_minsize();
+ }
+}
+
+bool SpatialEditorViewport::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
+
+ bool can_instance = false;
+
+ if (!preview_node->is_inside_tree()) {
+ Dictionary d = p_data;
+ if (d.has("type") && (String(d["type"]) == "files")) {
+ Vector<String> files = d["files"];
+
+ List<String> scene_extensions;
+ ResourceLoader::get_recognized_extensions_for_type("PackedScene", &scene_extensions);
+
+ for (int i = 0; i < files.size(); i++) {
+ if (scene_extensions.find(files[i].get_extension())) {
+ RES res = ResourceLoader::load(files[i]);
+ if (res.is_null()) {
+ continue;
+ }
+
+ String type = res->get_class();
+ if (type == "PackedScene") {
+ Ref<PackedScene> sdata = ResourceLoader::load(files[i]);
+ Node *instanced_scene = sdata->instance(PackedScene::GEN_EDIT_STATE_INSTANCE);
+ if (!instanced_scene) {
+ continue;
+ }
+ memdelete(instanced_scene);
+ }
+ can_instance = true;
+ break;
+ }
+ }
+ if (can_instance) {
+ _create_preview(files);
+ }
+ }
+ } else {
+ can_instance = true;
+ }
+
+ if (can_instance) {
+ Transform global_transform = Transform(Basis(), _get_instance_position(p_point));
+ preview_node->set_global_transform(global_transform);
+ }
+
+ return can_instance;
+}
+
+void SpatialEditorViewport::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
+ if (!can_drop_data_fw(p_point, p_data, p_from))
+ return;
+
+ bool is_shift = Input::get_singleton()->is_key_pressed(KEY_SHIFT);
+
+ selected_files.clear();
+ Dictionary d = p_data;
+ if (d.has("type") && String(d["type"]) == "files") {
+ selected_files = d["files"];
+ }
+
+ List<Node *> list = editor->get_editor_selection()->get_selected_node_list();
+ if (list.size() == 0) {
+ Node *root_node = editor->get_edited_scene();
+ if (root_node) {
+ list.push_back(root_node);
+ } else {
+ accept->get_ok()->set_text(TTR("OK :("));
+ accept->set_text(TTR("No parent to instance a child at."));
+ accept->popup_centered_minsize();
+ _remove_preview();
+ return;
+ }
+ }
+ if (list.size() != 1) {
+ accept->get_ok()->set_text(TTR("I see.."));
+ accept->set_text(TTR("This operation requires a single selected node."));
+ accept->popup_centered_minsize();
+ _remove_preview();
+ return;
+ }
+
+ target_node = list[0];
+ if (is_shift && target_node != editor->get_edited_scene()) {
+ target_node = target_node->get_parent();
+ }
+ drop_pos = p_point;
+
+ _perform_drop_data();
+}
+
SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, EditorNode *p_editor, int p_index) {
_edit.mode = TRANSFORM_NONE;
@@ -2491,6 +2790,7 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed
index = p_index;
editor = p_editor;
+ editor_data = editor->get_scene_tree_dock()->get_editor_data();
editor_selection = editor->get_editor_selection();
undo_redo = editor->get_undo_redo();
clicked = 0;
@@ -2509,6 +2809,7 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed
c->add_child(viewport);
surface = memnew(Control);
+ surface->set_drag_forwarding(this);
add_child(surface);
surface->set_area_as_parent_rect();
surface->set_clip_contents(true);
@@ -2573,9 +2874,10 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed
preview_camera->hide();
preview_camera->connect("toggled", this, "_toggle_camera_preview");
previewing = NULL;
- preview = NULL;
gizmo_scale = 1.0;
+ preview_node = NULL;
+
info = memnew(PanelContainer);
info->set_self_modulate(Color(1, 1, 1, 0.4));
surface->add_child(info);
@@ -2583,6 +2885,8 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed
info->add_child(info_label);
info->hide();
+ accept = NULL;
+
freelook_active = false;
selection_menu = memnew(PopupMenu);
@@ -4000,6 +4304,10 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
vs = memnew(VSeparator);
hbc_menu->add_child(vs);
+ // Drag and drop support;
+ preview_node = memnew(Spatial);
+ preview_bounds = Rect3();
+
ED_SHORTCUT("spatial_editor/bottom_view", TTR("Bottom View"), KEY_MASK_ALT + KEY_KP_7);
ED_SHORTCUT("spatial_editor/top_view", TTR("Top View"), KEY_KP_7);
ED_SHORTCUT("spatial_editor/rear_view", TTR("Rear View"), KEY_MASK_ALT + KEY_KP_1);
@@ -4044,6 +4352,9 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
p = view_menu->get_popup();
+ accept = memnew(AcceptDialog);
+ editor->get_gui_base()->add_child(accept);
+
p->add_check_shortcut(ED_SHORTCUT("spatial_editor/1_viewport", TTR("1 Viewport"), KEY_MASK_CMD + KEY_1), MENU_VIEW_USE_1_VIEWPORT);
p->add_check_shortcut(ED_SHORTCUT("spatial_editor/2_viewports", TTR("2 Viewports"), KEY_MASK_CMD + KEY_2), MENU_VIEW_USE_2_VIEWPORTS);
p->add_check_shortcut(ED_SHORTCUT("spatial_editor/2_viewports_alt", TTR("2 Viewports (Alt)"), KEY_MASK_ALT + KEY_MASK_CMD + KEY_2), MENU_VIEW_USE_2_VIEWPORTS_ALT);
@@ -4078,6 +4389,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
viewports[i] = memnew(SpatialEditorViewport(this, editor, i));
viewports[i]->connect("toggle_maximize_view", this, "_toggle_maximize_view");
+ viewports[i]->assign_pending_data_pointers(preview_node, &preview_bounds, accept);
viewport_base->add_child(viewports[i]);
}
//vbc->add_child(viewport_base);
@@ -4212,6 +4524,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
}
SpatialEditor::~SpatialEditor() {
+ memdelete(preview_node);
}
void SpatialEditorPlugin::make_visible(bool p_visible) {
diff --git a/editor/plugins/spatial_editor_plugin.h b/editor/plugins/spatial_editor_plugin.h
index 374861b5e7..db5abe2b53 100644
--- a/editor/plugins/spatial_editor_plugin.h
+++ b/editor/plugins/spatial_editor_plugin.h
@@ -106,7 +106,16 @@ private:
void _menu_option(int p_option);
Size2 prev_size;
+ Spatial *preview_node;
+ Rect3 *preview_bounds;
+ Vector<String> selected_files;
+ AcceptDialog *accept;
+
+ Node *target_node;
+ Point2 drop_pos;
+
EditorNode *editor;
+ EditorData *editor_data;
EditorSelection *editor_selection;
UndoRedo *undo_redo;
@@ -143,7 +152,7 @@ private:
ObjectID _select_ray(const Point2 &p_pos, bool p_append, bool &r_includes_current, int *r_gizmo_handle = NULL, bool p_alt_select = false);
void _find_items_at_pos(const Point2 &p_pos, bool &r_includes_current, Vector<_RayResult> &results, bool p_alt_select = false);
Vector3 _get_ray_pos(const Vector2 &p_pos) const;
- Vector3 _get_ray(const Vector2 &p_pos);
+ Vector3 _get_ray(const Vector2 &p_pos) const;
Point2 _point_to_screen(const Vector3 &p_point);
Transform _get_camera_transform() const;
int get_selected_count() const;
@@ -250,6 +259,7 @@ private:
void _draw();
void _smouseenter();
+ void _smouseexit();
void _sinput(const Ref<InputEvent> &p_event);
void _update_freelook(real_t delta);
SpatialEditor *spatial_editor;
@@ -266,6 +276,17 @@ private:
void _list_select(Ref<InputEventMouseButton> b);
Point2i _get_warped_mouse_motion(const Ref<InputEventMouseMotion> &p_ev_mouse_motion) const;
+ Vector3 _get_instance_position(const Point2 &p_pos) const;
+ static Rect3 _calculate_spatial_bounds(const Spatial *p_parent, const Rect3 p_bounds);
+ void _create_preview(const Vector<String> &files) const;
+ void _remove_preview();
+ bool _cyclical_dependency_exists(const String &p_target_scene_path, Node *p_desired_node);
+ bool _create_instance(Node *parent, String &path, const Point2 &p_point);
+ void _perform_drop_data();
+
+ bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;
+ void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);
+
protected:
void _notification(int p_what);
static void _bind_methods();
@@ -281,6 +302,11 @@ public:
void focus_selection();
+ void assign_pending_data_pointers(
+ Spatial *p_preview_node,
+ Rect3 *p_preview_bounds,
+ AcceptDialog *p_accept);
+
Viewport *get_viewport_node() { return viewport; }
SpatialEditorViewport(SpatialEditor *p_spatial_editor, EditorNode *p_editor, int p_index);
@@ -396,6 +422,10 @@ private:
Ref<SpatialMaterial> indicator_mat;
Ref<SpatialMaterial> cursor_material;
+ // Scene drag and drop support
+ Spatial *preview_node;
+ Rect3 preview_bounds;
+
/*
struct Selected {
AABB aabb;
@@ -442,6 +472,8 @@ private:
MenuButton *transform_menu;
MenuButton *view_menu;
+ AcceptDialog *accept;
+
ConfirmationDialog *snap_dialog;
ConfirmationDialog *xform_dialog;
ConfirmationDialog *settings_dialog;
@@ -559,6 +591,7 @@ public:
Camera *get_camera() { return NULL; }
void edit(Spatial *p_spatial);
void clear();
+
SpatialEditor(EditorNode *p_editor);
~SpatialEditor();
};
diff --git a/editor/plugins/sprite_frames_editor_plugin.cpp b/editor/plugins/sprite_frames_editor_plugin.cpp
index c2c26bfe6c..7b40f69082 100644
--- a/editor/plugins/sprite_frames_editor_plugin.cpp
+++ b/editor/plugins/sprite_frames_editor_plugin.cpp
@@ -244,8 +244,22 @@ void SpriteFramesEditor::_down_pressed() {
void SpriteFramesEditor::_delete_pressed() {
+ ERR_FAIL_COND(!frames->has_animation(edited_anim));
+
if (tree->get_current() < 0)
return;
+
+ int to_delete = tree->get_current();
+ if (to_delete < 0 || to_delete >= frames->get_frame_count(edited_anim)) {
+ return;
+ }
+
+ undo_redo->create_action(TTR("Delete Resource"));
+ undo_redo->add_do_method(frames, "remove_frame", edited_anim, to_delete);
+ undo_redo->add_undo_method(frames, "add_frame", edited_anim, frames->get_frame(edited_anim, to_delete), to_delete);
+ undo_redo->add_do_method(this, "_update_library");
+ undo_redo->add_undo_method(this, "_update_library");
+ undo_redo->commit_action();
}
void SpriteFramesEditor::_animation_select() {
diff --git a/editor/plugins/theme_editor_plugin.h b/editor/plugins/theme_editor_plugin.h
index cb6f086de6..16b2da94d1 100644
--- a/editor/plugins/theme_editor_plugin.h
+++ b/editor/plugins/theme_editor_plugin.h
@@ -30,7 +30,6 @@
#ifndef THEME_EDITOR_PLUGIN_H
#define THEME_EDITOR_PLUGIN_H
-#include "scene/gui/button_group.h"
#include "scene/gui/check_box.h"
#include "scene/gui/file_dialog.h"
#include "scene/gui/option_button.h"
diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp
index 323a36154e..b36d4715c4 100644
--- a/editor/project_manager.cpp
+++ b/editor/project_manager.cpp
@@ -449,13 +449,15 @@ struct ProjectItem {
String conf;
uint64_t last_modified;
bool favorite;
+ bool grayed;
ProjectItem() {}
- ProjectItem(const String &p_project, const String &p_path, const String &p_conf, uint64_t p_last_modified, bool p_favorite = false) {
+ ProjectItem(const String &p_project, const String &p_path, const String &p_conf, uint64_t p_last_modified, bool p_favorite = false, bool p_grayed = false) {
project = p_project;
path = p_path;
conf = p_conf;
last_modified = p_last_modified;
favorite = p_favorite;
+ grayed = p_grayed;
}
_FORCE_INLINE_ bool operator<(const ProjectItem &l) const { return last_modified > l.last_modified; }
_FORCE_INLINE_ bool operator==(const ProjectItem &l) const { return project == l.project; }
@@ -465,7 +467,7 @@ void ProjectManager::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
- Engine::get_singleton()->set_editor_hint(true);
+ Engine::get_singleton()->set_editor_hint(false);
} else if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
@@ -737,6 +739,7 @@ void ProjectManager::_load_recent_projects() {
String project = _name.get_slice("/", 1);
String conf = path.plus_file("project.godot");
bool favorite = (_name.begins_with("favorite_projects/")) ? true : false;
+ bool grayed = false;
uint64_t last_modified = 0;
if (FileAccess::exists(conf)) {
@@ -748,16 +751,15 @@ void ProjectManager::_load_recent_projects() {
if (cache_modified > last_modified)
last_modified = cache_modified;
}
-
- ProjectItem item(project, path, conf, last_modified, favorite);
- if (favorite)
- favorite_projects.push_back(item);
- else
- projects.push_back(item);
} else {
- //project doesn't exist on disk but it's in the XML settings file
- EditorSettings::get_singleton()->erase(_name); //remove it
+ grayed = true;
}
+
+ ProjectItem item(project, path, conf, last_modified, favorite, grayed);
+ if (favorite)
+ favorite_projects.push_back(item);
+ else
+ projects.push_back(item);
}
projects.sort();
@@ -782,14 +784,14 @@ void ProjectManager::_load_recent_projects() {
String path = item.path;
String conf = item.conf;
bool is_favorite = item.favorite;
+ bool is_grayed = item.grayed;
Ref<ConfigFile> cf = memnew(ConfigFile);
- Error err = cf->load(conf);
- ERR_CONTINUE(err != OK);
+ Error cf_err = cf->load(conf);
String project_name = TTR("Unnamed Project");
- if (cf->has_section_key("application", "config/name")) {
+ if (cf_err == OK && cf->has_section_key("application", "config/name")) {
project_name = static_cast<String>(cf->get_value("application", "config/name")).xml_unescape();
}
@@ -797,7 +799,7 @@ void ProjectManager::_load_recent_projects() {
continue;
Ref<Texture> icon;
- if (cf->has_section_key("application", "config/icon")) {
+ if (cf_err == OK && cf->has_section_key("application", "config/icon")) {
String appicon = cf->get_value("application", "config/icon");
if (appicon != "") {
Ref<Image> img;
@@ -819,8 +821,10 @@ void ProjectManager::_load_recent_projects() {
}
String main_scene;
- if (cf->has_section_key("application", "run/main_scene")) {
+ if (cf_err == OK && cf->has_section_key("application", "run/main_scene")) {
main_scene = cf->get_value("application", "run/main_scene");
+ } else {
+ main_scene = "";
}
selected_list_copy.erase(project);
@@ -848,6 +852,8 @@ void ProjectManager::_load_recent_projects() {
hb->add_child(tf);
VBoxContainer *vb = memnew(VBoxContainer);
+ if (is_grayed)
+ vb->set_modulate(Color(0.5, 0.5, 0.5));
vb->set_name("project");
vb->set_h_size_flags(SIZE_EXPAND_FILL);
hb->add_child(vb);
@@ -926,6 +932,13 @@ void ProjectManager::_open_project_confirm() {
for (Map<String, String>::Element *E = selected_list.front(); E; E = E->next()) {
const String &selected = E->key();
String path = EditorSettings::get_singleton()->get("projects/" + selected);
+ String conf = path + "/project.godot";
+ if (!FileAccess::exists(conf)) {
+ dialog_error->set_text(TTR("Can't open project"));
+ dialog_error->popup_centered_minsize();
+ return;
+ }
+
print_line("OPENING: " + path + " (" + selected + ")");
List<String> args;
@@ -1397,6 +1410,9 @@ ProjectManager::ProjectManager() {
run_error_diag = memnew(AcceptDialog);
gui_base->add_child(run_error_diag);
run_error_diag->set_title(TTR("Can't run project"));
+
+ dialog_error = memnew(AcceptDialog);
+ gui_base->add_child(dialog_error);
}
ProjectManager::~ProjectManager() {
diff --git a/editor/project_manager.h b/editor/project_manager.h
index ecc01955ba..9fcf10a0d9 100644
--- a/editor/project_manager.h
+++ b/editor/project_manager.h
@@ -58,6 +58,7 @@ class ProjectManager : public Control {
ConfirmationDialog *multi_run_ask;
ConfirmationDialog *multi_scan_ask;
AcceptDialog *run_error_diag;
+ AcceptDialog *dialog_error;
NewProjectDialog *npdialog;
ScrollContainer *scroll;
VBoxContainer *scroll_childs;
diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp
index 9fd31f818e..1f65589643 100644
--- a/editor/project_settings_editor.cpp
+++ b/editor/project_settings_editor.cpp
@@ -182,8 +182,8 @@ void ProjectSettingsEditor::_device_input_add() {
Ref<InputEvent> ie;
String name = add_at;
int idx = edit_idx;
- Variant old_val = ProjectSettings::get_singleton()->get(name);
- Array arr = old_val;
+ Array old_val = ProjectSettings::get_singleton()->get(name);
+ Array arr = old_val.duplicate();
switch (add_type) {
@@ -285,8 +285,8 @@ void ProjectSettingsEditor::_press_a_key_confirm() {
String name = add_at;
int idx = edit_idx;
- Variant old_val = ProjectSettings::get_singleton()->get(name);
- Array arr = old_val;
+ Array old_val = ProjectSettings::get_singleton()->get(name);
+ Array arr = old_val.duplicate();
for (int i = 0; i < arr.size(); i++) {
@@ -700,6 +700,8 @@ void ProjectSettingsEditor::_update_actions() {
action->set_meta("__input", ie);
}
}
+
+ _action_check(action_name->get_text());
}
void ProjectSettingsEditor::popup_project_settings() {
@@ -809,28 +811,41 @@ void ProjectSettingsEditor::_item_del() {
undo_redo->commit_action();
}
-void ProjectSettingsEditor::_action_adds(String) {
+void ProjectSettingsEditor::_action_check(String p_action) {
- _action_add();
-}
+ if (p_action == "") {
-void ProjectSettingsEditor::_action_add() {
+ action_add->set_disabled(true);
+ } else {
- 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) * EDSCALE);
- return;
+ if (p_action.find("/") != -1 || p_action.find(":") != -1) {
+ action_add->set_text(TTR("Can't contain '/' or ':'"));
+ action_add->set_disabled(true);
+ return;
+ }
+ if (ProjectSettings::get_singleton()->has("input/" + p_action)) {
+ action_add->set_text(TTR("Already existing"));
+ action_add->set_disabled(true);
+ return;
+ }
+
+ action_add->set_disabled(false);
}
- if (ProjectSettings::get_singleton()->has("input/" + action)) {
- message->set_text(vformat(TTR("Action '%s' already exists!"), action));
- message->popup_centered(Size2(300, 100) * EDSCALE);
- return;
+ action_add->set_text(TTR("Add"));
+}
+
+void ProjectSettingsEditor::_action_adds(String) {
+
+ if (!action_add->is_disabled()) {
+ _action_add();
}
+}
+
+void ProjectSettingsEditor::_action_add() {
Array va;
- String name = "input/" + action;
+ String name = "input/" + action_name->get_text();
undo_redo->create_action(TTR("Add Input Action Event"));
undo_redo->add_do_method(ProjectSettings::get_singleton(), "set", name, va);
undo_redo->add_undo_method(ProjectSettings::get_singleton(), "clear", name);
@@ -854,6 +869,7 @@ void ProjectSettingsEditor::_action_add() {
return;
r->select(0);
input_editor->ensure_cursor_is_visible();
+ action_add->set_text(TTR("Add"));
}
void ProjectSettingsEditor::_item_checked(const String &p_item, bool p_check) {
@@ -1336,6 +1352,7 @@ void ProjectSettingsEditor::_bind_methods() {
ClassDB::bind_method(D_METHOD("_save"), &ProjectSettingsEditor::_save);
ClassDB::bind_method(D_METHOD("_action_add"), &ProjectSettingsEditor::_action_add);
ClassDB::bind_method(D_METHOD("_action_adds"), &ProjectSettingsEditor::_action_adds);
+ ClassDB::bind_method(D_METHOD("_action_check"), &ProjectSettingsEditor::_action_check);
ClassDB::bind_method(D_METHOD("_action_selected"), &ProjectSettingsEditor::_action_selected);
ClassDB::bind_method(D_METHOD("_action_edited"), &ProjectSettingsEditor::_action_edited);
ClassDB::bind_method(D_METHOD("_action_activated"), &ProjectSettingsEditor::_action_activated);
@@ -1482,9 +1499,8 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
get_ok()->set_text(TTR("Close"));
set_hide_on_ok(true);
- message = memnew(ConfirmationDialog);
+ message = memnew(AcceptDialog);
add_child(message);
- message->set_hide_on_ok(true);
Control *input_base = memnew(Control);
input_base->set_name(TTR("Input Map"));
@@ -1500,7 +1516,6 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
l = memnew(Label);
vbc->add_child(l);
- l->set_position(Point2(6, 5) * EDSCALE);
l->set_text(TTR("Action:"));
hbc = memnew(HBoxContainer);
@@ -1510,12 +1525,15 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
action_name->set_h_size_flags(SIZE_EXPAND_FILL);
hbc->add_child(action_name);
action_name->connect("text_entered", this, "_action_adds");
+ action_name->connect("text_changed", this, "_action_check");
add = memnew(Button);
hbc->add_child(add);
add->set_custom_minimum_size(Size2(150, 0) * EDSCALE);
add->set_text(TTR("Add"));
+ add->set_disabled(true);
add->connect("pressed", this, "_action_add");
+ action_add = add;
input_editor = memnew(Tree);
vbc->add_child(input_editor);
diff --git a/editor/project_settings_editor.h b/editor/project_settings_editor.h
index e58ba9b1c0..7f9b18a968 100644
--- a/editor/project_settings_editor.h
+++ b/editor/project_settings_editor.h
@@ -66,7 +66,7 @@ class ProjectSettingsEditor : public AcceptDialog {
ToolButton *clear_button;
HBoxContainer *add_prop_bar;
- ConfirmationDialog *message;
+ AcceptDialog *message;
LineEdit *category;
LineEdit *property;
OptionButton *type;
@@ -80,6 +80,7 @@ class ProjectSettingsEditor : public AcceptDialog {
MenuButton *popup_copy_to_feature;
LineEdit *action_name;
+ Button *action_add;
Tree *input_editor;
bool setting;
bool updating_translations;
@@ -108,6 +109,7 @@ class ProjectSettingsEditor : public AcceptDialog {
void _add_item(int p_item, Ref<InputEvent> p_exiting_event = NULL);
void _edit_item(Ref<InputEvent> p_exiting_event);
+ void _action_check(String p_action);
void _action_adds(String);
void _action_add();
void _device_input_add();
diff --git a/editor/quick_open.cpp b/editor/quick_open.cpp
index c71cc5af3f..b92ebed167 100644
--- a/editor/quick_open.cpp
+++ b/editor/quick_open.cpp
@@ -171,33 +171,50 @@ void EditorQuickOpen::_parse_fs(EditorFileSystemDirectory *efsd, Vector<Pair<Str
Pair<String, Ref<Texture> > pair;
pair.first = file;
pair.second = get_icon((has_icon(efsd->get_file_type(i), ei) ? efsd->get_file_type(i) : ot), ei);
+ list.push_back(pair);
+ }
+ }
+
+ if (add_directories) {
+ for (int i = 0; i < efsd->get_subdir_count(); i++) {
- if (search_text != String() && list.size() > 0) {
+ _parse_fs(efsd->get_subdir(i), list);
+ }
+ }
+}
- float this_sim = _path_cmp(search_text, file);
- float other_sim = _path_cmp(list[0].first, file);
- int pos = 1;
+Vector<Pair<String, Ref<Texture> > > EditorQuickOpen::_sort_fs(Vector<Pair<String, Ref<Texture> > > &list) {
- while (pos < list.size() && this_sim <= other_sim) {
- other_sim = _path_cmp(list[pos++].first, file);
- }
+ String search_text = search_box->get_text();
+ Vector<Pair<String, Ref<Texture> > > sorted_list;
- pos = this_sim >= other_sim ? pos - 1 : pos;
- list.insert(pos, pair);
+ if (search_text == String() || list.size() == 0)
+ return sorted_list;
- } else {
+ Vector<float> scores;
+ scores.resize(list.size());
+ for (int i = 0; i < list.size(); i++)
+ scores[i] = _path_cmp(search_text, list[i].first);
- list.push_back(pair);
- }
- }
- }
+ while (list.size() > 0) {
- if (add_directories) {
- for (int i = 0; i < efsd->get_subdir_count(); i++) {
+ float best_score = 0.0f;
+ int best_idx = 0;
- _parse_fs(efsd->get_subdir(i), list);
+ for (int i = 0; i < list.size(); i++) {
+ float current_score = scores[i];
+ if (current_score > best_score) {
+ best_score = current_score;
+ best_idx = i;
+ }
}
+
+ sorted_list.push_back(list[best_idx]);
+ list.remove(best_idx);
+ scores.remove(best_idx);
}
+
+ return sorted_list;
}
void EditorQuickOpen::_update_search() {
@@ -208,6 +225,7 @@ void EditorQuickOpen::_update_search() {
Vector<Pair<String, Ref<Texture> > > list;
_parse_fs(efsd, list);
+ list = _sort_fs(list);
for (int i = 0; i < list.size(); i++) {
TreeItem *ti = search_options->create_item(root);
diff --git a/editor/quick_open.h b/editor/quick_open.h
index 3f64dd8cf0..5b91965920 100644
--- a/editor/quick_open.h
+++ b/editor/quick_open.h
@@ -49,6 +49,7 @@ class EditorQuickOpen : public ConfirmationDialog {
void _sbox_input(const Ref<InputEvent> &p_ie);
void _parse_fs(EditorFileSystemDirectory *efsd, Vector<Pair<String, Ref<Texture> > > &list);
+ Vector<Pair<String, Ref<Texture> > > _sort_fs(Vector<Pair<String, Ref<Texture> > > &list);
float _path_cmp(String search, String path) const;
void _confirmed();
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp
index 9420e1909a..5b783493cb 100644
--- a/editor/scene_tree_dock.cpp
+++ b/editor/scene_tree_dock.cpp
@@ -582,13 +582,13 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
new_scene_from_dialog->popup_centered_ratio();
new_scene_from_dialog->set_title(TTR("Save New Scene As.."));
-
} break;
case TOOL_COPY_NODE_PATH: {
List<Node *> selection = editor_selection->get_selected_node_list();
-
- if (List<Node *>::Element *e = selection.front()) {
- if (Node *node = e->get()) {
+ List<Node *>::Element *e = selection.front();
+ if (e) {
+ Node *node = e->get();
+ if (node) {
Node *root = EditorNode::get_singleton()->get_edited_scene();
NodePath path = root->get_path().rel_path_to(node->get_path());
OS::get_singleton()->set_clipboard(path);
@@ -597,8 +597,10 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
} break;
case TOOL_SCENE_EDITABLE_CHILDREN: {
List<Node *> selection = editor_selection->get_selected_node_list();
- if (List<Node *>::Element *e = selection.front()) {
- if (Node *node = e->get()) {
+ List<Node *>::Element *e = selection.front();
+ if (e) {
+ Node *node = e->get();
+ if (node) {
bool editable = EditorNode::get_singleton()->get_edited_scene()->is_editable_instance(node);
int editable_item_idx = menu->get_item_idx_from_text(TTR("Editable Children"));
int placeholder_item_idx = menu->get_item_idx_from_text(TTR("Load As Placeholder"));
@@ -617,8 +619,10 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
} break;
case TOOL_SCENE_USE_PLACEHOLDER: {
List<Node *> selection = editor_selection->get_selected_node_list();
- if (List<Node *>::Element *e = selection.front()) {
- if (Node *node = e->get()) {
+ List<Node *>::Element *e = selection.front();
+ if (e) {
+ Node *node = e->get();
+ if (node) {
bool placeholder = node->get_scene_instance_load_placeholder();
placeholder = !placeholder;
int editable_item_idx = menu->get_item_idx_from_text(TTR("Editable Children"));
@@ -635,15 +639,16 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
} break;
case TOOL_SCENE_CLEAR_INSTANCING: {
List<Node *> selection = editor_selection->get_selected_node_list();
- if (List<Node *>::Element *e = selection.front()) {
- if (Node *node = e->get()) {
+ List<Node *>::Element *e = selection.front();
+ if (e) {
+ Node *node = e->get();
+ if (node) {
Node *root = EditorNode::get_singleton()->get_edited_scene();
UndoRedo *undo_redo = &editor_data->get_undo_redo();
if (!root)
break;
ERR_FAIL_COND(node->get_filename() == String());
-
undo_redo->create_action(TTR("Discard Instancing"));
undo_redo->add_do_method(node, "set_filename", "");
undo_redo->add_undo_method(node, "set_filename", node->get_filename());
@@ -656,8 +661,10 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
} break;
case TOOL_SCENE_OPEN: {
List<Node *> selection = editor_selection->get_selected_node_list();
- if (List<Node *>::Element *e = selection.front()) {
- if (Node *node = e->get()) {
+ List<Node *>::Element *e = selection.front();
+ if (e) {
+ Node *node = e->get();
+ if (node) {
scene_tree->emit_signal("open", node->get_filename());
}
}
@@ -667,8 +674,10 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
} break;
case TOOL_SCENE_CLEAR_INHERITANCE_CONFIRM: {
List<Node *> selection = editor_selection->get_selected_node_list();
- if (List<Node *>::Element *e = selection.front()) {
- if (Node *node = e->get()) {
+ List<Node *>::Element *e = selection.front();
+ if (e) {
+ Node *node = e->get();
+ if (node) {
node->set_scene_inherited_state(Ref<SceneState>());
scene_tree->update_tree();
EditorNode::get_singleton()->get_property_editor()->update_tree();
@@ -677,8 +686,10 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
} break;
case TOOL_SCENE_OPEN_INHERITED: {
List<Node *> selection = editor_selection->get_selected_node_list();
- if (List<Node *>::Element *e = selection.front()) {
- if (Node *node = e->get()) {
+ List<Node *>::Element *e = selection.front();
+ if (e) {
+ Node *node = e->get();
+ if (node) {
if (node && node->get_scene_inherited_state().is_valid()) {
scene_tree->emit_signal("open", node->get_scene_inherited_state()->get_path());
}
@@ -823,7 +834,14 @@ Node *SceneTreeDock::_duplicate(Node *p_node, Map<Node *, Node *> &duplimap) {
if (!(E->get().usage & PROPERTY_USAGE_STORAGE))
continue;
String name = E->get().name;
- node->set(name, p_node->get(name));
+ Variant value = p_node->get(name);
+ // Duplicate dictionaries and arrays, mainly needed for __meta__
+ if (value.get_type() == Variant::DICTIONARY) {
+ value = Dictionary(value).copy();
+ } else if (value.get_type() == Variant::ARRAY) {
+ value = Array(value).duplicate();
+ }
+ node->set(name, value);
}
List<Node::GroupInfo> group_info;
diff --git a/editor/settings_config_dialog.cpp b/editor/settings_config_dialog.cpp
index 623e458aca..05e3feedb5 100644
--- a/editor/settings_config_dialog.cpp
+++ b/editor/settings_config_dialog.cpp
@@ -165,7 +165,7 @@ void EditorSettingsDialog::_update_shortcuts() {
section->set_custom_bg_color(1, get_color("prop_subsection", "Editor"));
}
- if (shortcut_filter.is_subsequence_ofi(sc->get_name())) {
+ if (shortcut_filter.is_subsequence_ofi(sc->get_name()) || shortcut_filter.is_subsequence_ofi(sc->get_as_text())) {
TreeItem *item = shortcuts->create_item(section);
item->set_text(0, sc->get_name());
diff --git a/main/main.cpp b/main/main.cpp
index 7b2a890a8e..51d1d966b0 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -1333,6 +1333,9 @@ bool Main::start() {
Viewport::Usage usage = Viewport::Usage(int(GLOBAL_GET("rendering/quality/intended_usage/framebuffer_allocation")));
sml->get_root()->set_usage(usage);
+ bool snap_controls = GLOBAL_DEF("gui/common/snap_controls_to_pixels", true);
+ sml->get_root()->set_snap_controls_to_pixels(snap_controls);
+
} else {
GLOBAL_DEF("display/window/stretch/mode", "disabled");
ProjectSettings::get_singleton()->set_custom_property_info("display/window/stretch/mode", PropertyInfo(Variant::STRING, "display/window/stretch/mode", PROPERTY_HINT_ENUM, "disabled,2d,viewport"));
@@ -1342,6 +1345,7 @@ bool Main::start() {
ProjectSettings::get_singleton()->set_custom_property_info("display/window/stretch/shrink", PropertyInfo(Variant::STRING, "display/window/stretch/shrink", PROPERTY_HINT_RANGE, "1,8,1"));
sml->set_auto_accept_quit(GLOBAL_DEF("application/config/auto_accept_quit", true));
sml->set_quit_on_go_back(GLOBAL_DEF("application/config/quit_on_go_back", true));
+ GLOBAL_DEF("gui/common/snap_controls_to_pixels", true);
}
String local_game_path;
diff --git a/misc/dist/html/default.html b/misc/dist/html/default.html
new file mode 100644
index 0000000000..9fae34f97e
--- /dev/null
+++ b/misc/dist/html/default.html
@@ -0,0 +1,386 @@
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
+<head>
+ <meta charset="utf-8" />
+ <title></title>
+ <style type="text/css">
+
+ body {
+ margin: 0;
+ border: 0 none;
+ padding: 0;
+ text-align: center;
+ background-color: #222226;
+ font-family: 'Noto Sans', Arial, sans-serif;
+ }
+
+
+ /* Godot Engine default theme style
+ * ================================ */
+
+ .godot {
+ color: #e0e0e0;
+ background-color: #3b3943;
+ background-image: linear-gradient(to bottom, #403e48, #35333c);
+ border: 1px solid #45434e;
+ box-shadow: 0 0 1px 1px #2f2d35;
+ }
+
+ button.godot {
+ font-family: 'Droid Sans', Arial, sans-serif; /* override user agent style */
+ padding: 1px 5px;
+ background-color: #37353f;
+ background-image: linear-gradient(to bottom, #413e49, #3a3842);
+ border: 1px solid #514f5d;
+ border-radius: 1px;
+ box-shadow: 0 0 1px 1px #2a2930;
+ }
+
+ button.godot:hover {
+ color: #f0f0f0;
+ background-color: #44414e;
+ background-image: linear-gradient(to bottom, #494652, #423f4c);
+ border: 1px solid #5a5667;
+ box-shadow: 0 0 1px 1px #26252b;
+ }
+
+ button.godot:active {
+ color: #fff;
+ background-color: #3e3b46;
+ background-image: linear-gradient(to bottom, #36343d, #413e49);
+ border: 1px solid #4f4c59;
+ box-shadow: 0 0 1px 1px #26252b;
+ }
+
+ button.godot:disabled {
+ color: rgba(230, 230, 230, 0.2);
+ background-color: #3d3d3d;
+ background-image: linear-gradient(to bottom, #434343, #393939);
+ border: 1px solid #474747;
+ box-shadow: 0 0 1px 1px #2d2b33;
+ }
+
+
+ /* Canvas / wrapper
+ * ================ */
+
+ #container {
+ display: inline-block; /* scale with canvas */
+ vertical-align: top; /* prevent extra height */
+ position: relative; /* root for absolutely positioned overlay */
+ margin: 0;
+ border: 0 none;
+ padding: 0;
+ background-color: #0c0c0c;
+ }
+
+ #canvas {
+ display: block;
+ margin: 0 auto;
+ color: white;
+ }
+
+ #canvas:focus {
+ outline: none;
+ }
+
+
+ /* Status display
+ * ============== */
+
+ #status {
+ position: absolute;
+ left: 0;
+ top: 0;
+ right: 0;
+ bottom: 0;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ /* don't consume click events - make children visible explicitly */
+ visibility: hidden;
+ }
+
+ #status-progress {
+ width: 244px;
+ height: 7px;
+ background-color: #38363A;
+ border: 1px solid #444246;
+ padding: 1px;
+ box-shadow: 0 0 2px 1px #1B1C22;
+ border-radius: 2px;
+ visibility: visible;
+ }
+
+ #status-progress-inner {
+ height: 100%;
+ width: 0;
+ box-sizing: border-box;
+ transition: width 0.5s linear;
+ background-color: #202020;
+ border: 1px solid #222223;
+ box-shadow: 0 0 1px 1px #27282E;
+ border-radius: 3px;
+ }
+
+ #status-indeterminate {
+ visibility: visible;
+ position: relative;
+ }
+
+ #status-indeterminate > div {
+ width: 3px;
+ height: 0;
+ border-style: solid;
+ border-width: 6px 2px 0 2px;
+ border-color: #2b2b2b transparent transparent transparent;
+ transform-origin: center 14px;
+ position: absolute;
+ }
+
+ #status-indeterminate > div:nth-child(1) { transform: rotate( 22.5deg); }
+ #status-indeterminate > div:nth-child(2) { transform: rotate( 67.5deg); }
+ #status-indeterminate > div:nth-child(3) { transform: rotate(112.5deg); }
+ #status-indeterminate > div:nth-child(4) { transform: rotate(157.5deg); }
+ #status-indeterminate > div:nth-child(5) { transform: rotate(202.5deg); }
+ #status-indeterminate > div:nth-child(6) { transform: rotate(247.5deg); }
+ #status-indeterminate > div:nth-child(7) { transform: rotate(292.5deg); }
+ #status-indeterminate > div:nth-child(8) { transform: rotate(337.5deg); }
+
+ #status-notice {
+ margin: 0 100px;
+ line-height: 1.3;
+ visibility: visible;
+ padding: 4px 6px;
+ visibility: visible;
+ }
+
+
+ /* Debug output
+ * ============ */
+
+ #output-panel {
+ display: none;
+ max-width: 700px;
+ font-size: small;
+ margin: 6px auto 0;
+ padding: 0 4px 4px;
+ text-align: left;
+ line-height: 2.2;
+ }
+
+ #output-header {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ }
+
+ #output-container {
+ padding: 6px;
+ background-color: #2c2a32;
+ box-shadow: inset 0 0 1px 1px #232127;
+ color: #bbb;
+ }
+
+ #output-scroll {
+ line-height: 1;
+ height: 12em;
+ overflow-y: scroll;
+ white-space: pre-wrap;
+ font-size: small;
+ font-family: "Lucida Console", Monaco, monospace;
+ }
+ </style>
+$GODOT_HEAD_INCLUDE
+</head>
+<body>
+ <div id="container">
+ <canvas id="canvas" oncontextmenu="event.preventDefault();" width="640" height="480">
+ HTML5 canvas appears to be unsupported in the current browser.<br />
+ Please try updating or use a different browser.
+ </canvas>
+ <div id="status">
+ <div id='status-progress' style='display: none;' oncontextmenu="event.preventDefault();"><div id ='status-progress-inner'></div></div>
+ <div id='status-indeterminate' style='display: none;' oncontextmenu="event.preventDefault();">
+ <div></div>
+ <div></div>
+ <div></div>
+ <div></div>
+ <div></div>
+ <div></div>
+ <div></div>
+ <div></div>
+ </div>
+ <div id="status-notice" class="godot" style='display: none;'></div>
+ </div>
+ </div>
+ <div id="output-panel" class="godot">
+ <div id="output-header">
+ Output:
+ <button id='output-clear' class='godot' type='button' autocomplete='off'>Clear</button>
+ </div>
+ <div id="output-container"><div id="output-scroll"></div></div>
+ </div>
+
+ <script type="text/javascript" src="$GODOT_BASENAME.js"></script>
+ <script type="text/javascript">//<![CDATA[
+
+ var game = new Engine;
+
+ (function() {
+
+ const BASENAME = '$GODOT_BASENAME';
+ const MEMORY_SIZE = $GODOT_TOTAL_MEMORY;
+ const DEBUG_ENABLED = $GODOT_DEBUG_ENABLED;
+ const INDETERMINATE_STATUS_STEP_MS = 100;
+
+ var container = document.getElementById('container');
+ var canvas = document.getElementById('canvas');
+ var statusProgress = document.getElementById('status-progress');
+ var statusProgressInner = document.getElementById('status-progress-inner');
+ var statusIndeterminate = document.getElementById('status-indeterminate');
+ var statusNotice = document.getElementById('status-notice');
+
+ var initializing = true;
+ var statusMode = 'hidden';
+ var indeterminiateStatusAnimationId = 0;
+
+ setStatusMode('indeterminate');
+ game.setCanvas(canvas);
+ game.setAsmjsMemorySize(MEMORY_SIZE);
+
+ function setStatusMode(mode) {
+
+ if (statusMode === mode || !initializing)
+ return;
+ [statusProgress, statusIndeterminate, statusNotice].forEach(elem => {
+ elem.style.display = 'none';
+ });
+ if (indeterminiateStatusAnimationId !== 0) {
+ cancelAnimationFrame(indeterminiateStatusAnimationId);
+ indeterminiateStatusAnimationId = 0;
+ }
+ switch (mode) {
+ case 'progress':
+ statusProgress.style.display = 'block';
+ break;
+ case 'indeterminate':
+ statusIndeterminate.style.display = 'block';
+ indeterminiateStatusAnimationId = requestAnimationFrame(animateStatusIndeterminate);
+ break;
+ case 'notice':
+ statusNotice.style.display = 'block';
+ break;
+ case 'hidden':
+ break;
+ default:
+ throw new Error("Invalid status mode");
+ }
+ statusMode = mode;
+ }
+
+ function animateStatusIndeterminate(ms) {
+ var i = Math.floor(ms / INDETERMINATE_STATUS_STEP_MS % 8);
+ if (statusIndeterminate.children[i].style.borderTopColor == '') {
+ Array.prototype.slice.call(statusIndeterminate.children).forEach(child => {
+ child.style.borderTopColor = '';
+ });
+ statusIndeterminate.children[i].style.borderTopColor = '#dfdfdf';
+ }
+ requestAnimationFrame(animateStatusIndeterminate);
+ }
+
+ function setStatusNotice(text) {
+
+ while (statusNotice.lastChild) {
+ statusNotice.removeChild(statusNotice.lastChild);
+ }
+ var lines = text.split('\n');
+ lines.forEach((line, index) => {
+ statusNotice.appendChild(document.createTextNode(line));
+ statusNotice.appendChild(document.createElement('br'));
+ });
+ };
+
+ game.setProgressFunc((current, total) => {
+
+ if (total > 0) {
+ statusProgressInner.style.width = current/total * 100 + '%';
+ setStatusMode('progress');
+ if (current === total) {
+ // wait for progress bar animation
+ setTimeout(() => {
+ setStatusMode('indeterminate');
+ }, 500);
+ }
+ } else {
+ setStatusMode('indeterminate');
+ }
+ });
+
+ if (DEBUG_ENABLED) {
+ var outputRoot = document.getElementById("output-panel");
+ var outputScroll = document.getElementById("output-scroll");
+ var OUTPUT_MSG_COUNT_MAX = 400;
+
+ document.getElementById('output-clear').addEventListener('click', () => {
+ while (outputScroll.firstChild) {
+ outputScroll.firstChild.remove();
+ }
+ });
+
+ outputRoot.style.display = 'block';
+
+ function print(text) {
+ if (arguments.length > 1) {
+ text = Array.prototype.slice.call(arguments).join(" ");
+ }
+ if (text.length <= 0) return;
+ while (outputScroll.childElementCount >= OUTPUT_MSG_COUNT_MAX) {
+ outputScroll.firstChild.remove();
+ }
+ var msg = document.createElement("div");
+ if (String.prototype.trim.call(text).startsWith("**ERROR**")) {
+ msg.style.color = "#d44";
+ } else if (String.prototype.trim.call(text).startsWith("**WARNING**")) {
+ msg.style.color = "#ccc000";
+ } else if (String.prototype.trim.call(text).startsWith("**SCRIPT ERROR**")) {
+ msg.style.color = "#c6d";
+ }
+ msg.textContent = text;
+ var scrollToBottom = outputScroll.scrollHeight - (outputScroll.clientHeight + outputScroll.scrollTop) < 10;
+ outputScroll.appendChild(msg);
+ if (scrollToBottom) {
+ outputScroll.scrollTop = outputScroll.scrollHeight;
+ }
+ };
+
+ function printError(text) {
+ print('**ERROR**' + ":", text);
+ }
+
+ game.setStdoutFunc(text => {
+ print(text);
+ console.log(text);
+ });
+
+ game.setStderrFunc(text => {
+ printError(text);
+ console.warn(text);
+ });
+ }
+
+ game.start(BASENAME + '.pck').then(() => {
+ setStatusMode('hidden');
+ initializing = false;
+ }, err => {
+ if (DEBUG_ENABLED)
+ printError(err.message);
+ setStatusNotice(err.message);
+ setStatusMode('notice');
+ initializing = false;
+ });
+ })();
+ //]]></script>
+</body>
+</html>
diff --git a/misc/dist/html_fs/godotfs.js b/misc/dist/html_fs/godotfs.js
deleted file mode 100644
index 676ee689fb..0000000000
--- a/misc/dist/html_fs/godotfs.js
+++ /dev/null
@@ -1,151 +0,0 @@
-
-var Module;
-if (typeof Module === 'undefined') Module = eval('(function() { try { return Module || {} } catch(e) { return {} } })()');
-if (!Module.expectedDataFileDownloads) {
- Module.expectedDataFileDownloads = 0;
- Module.finishedDataFileDownloads = 0;
-}
-Module.expectedDataFileDownloads++;
-(function() {
-
- const PACK_FILE_NAME = '$GODOT_PACK_NAME';
- const PACK_FILE_SIZE = $GODOT_PACK_SIZE;
- function fetchRemotePackage(packageName, callback, errback) {
- var xhr = new XMLHttpRequest();
- xhr.open('GET', packageName, true);
- xhr.responseType = 'arraybuffer';
- xhr.onprogress = function(event) {
- var url = packageName;
- if (event.loaded && event.total) {
- if (!xhr.addedTotal) {
- xhr.addedTotal = true;
- if (!Module.dataFileDownloads) Module.dataFileDownloads = {};
- Module.dataFileDownloads[url] = {
- loaded: event.loaded,
- total: event.total
- };
- } else {
- Module.dataFileDownloads[url].loaded = event.loaded;
- }
- var total = 0;
- var loaded = 0;
- var num = 0;
- for (var download in Module.dataFileDownloads) {
- var data = Module.dataFileDownloads[download];
- total += data.total;
- loaded += data.loaded;
- num++;
- }
- total = Math.ceil(total * Module.expectedDataFileDownloads/num);
- if (Module['setStatus']) Module['setStatus']('Downloading data... (' + loaded + '/' + total + ')');
- } else if (!Module.dataFileDownloads) {
- if (Module['setStatus']) Module['setStatus']('Downloading data...');
- }
- };
- xhr.onload = function(event) {
- var packageData = xhr.response;
- callback(packageData);
- };
- xhr.send(null);
- };
-
- function handleError(error) {
- console.error('package error:', error);
- };
-
- var fetched = null, fetchedCallback = null;
- fetchRemotePackage(PACK_FILE_NAME, function(data) {
- if (fetchedCallback) {
- fetchedCallback(data);
- fetchedCallback = null;
- } else {
- fetched = data;
- }
- }, handleError);
-
- function runWithFS() {
-
-function assert(check, msg) {
- if (!check) throw msg + new Error().stack;
-}
-
- function DataRequest(start, end, crunched, audio) {
- this.start = start;
- this.end = end;
- this.crunched = crunched;
- this.audio = audio;
- }
- DataRequest.prototype = {
- requests: {},
- open: function(mode, name) {
- this.name = name;
- this.requests[name] = this;
- Module['addRunDependency']('fp ' + this.name);
- },
- send: function() {},
- onload: function() {
- var byteArray = this.byteArray.subarray(this.start, this.end);
-
- this.finish(byteArray);
-
- },
- finish: function(byteArray) {
- var that = this;
- Module['FS_createPreloadedFile'](this.name, null, byteArray, true, true, function() {
- Module['removeRunDependency']('fp ' + that.name);
- }, function() {
- if (that.audio) {
- Module['removeRunDependency']('fp ' + that.name); // workaround for chromium bug 124926 (still no audio with this, but at least we don't hang)
- } else {
- Module.printErr('Preloading file ' + that.name + ' failed');
- }
- }, false, true); // canOwn this data in the filesystem, it is a slide into the heap that will never change
- this.requests[this.name] = null;
- },
- };
- new DataRequest(0, PACK_FILE_SIZE, 0, 0).open('GET', '/' + PACK_FILE_NAME);
-
- var PACKAGE_PATH;
- if (typeof window === 'object') {
- PACKAGE_PATH = window['encodeURIComponent'](window.location.pathname.toString().substring(0, window.location.pathname.toString().lastIndexOf('/')) + '/');
- } else {
- // worker
- PACKAGE_PATH = encodeURIComponent(location.pathname.toString().substring(0, location.pathname.toString().lastIndexOf('/')) + '/');
- }
- var PACKAGE_NAME = PACK_FILE_NAME;
- var REMOTE_PACKAGE_NAME = PACK_FILE_NAME;
- var PACKAGE_UUID = 'b39761ce-0348-4959-9b16-302ed8e1592e';
-
- function processPackageData(arrayBuffer) {
- Module.finishedDataFileDownloads++;
- assert(arrayBuffer, 'Loading data file failed.');
- var byteArray = new Uint8Array(arrayBuffer);
- var curr;
-
- // Reuse the bytearray from the XHR as the source for file reads.
- DataRequest.prototype.byteArray = byteArray;
- DataRequest.prototype.requests['/' + PACK_FILE_NAME].onload();
- Module['removeRunDependency']('datafile_datapack');
-
- };
- Module['addRunDependency']('datafile_datapack');
-
- if (!Module.preloadResults) Module.preloadResults = {};
-
- Module.preloadResults[PACKAGE_NAME] = {fromCache: false};
- if (fetched) {
- processPackageData(fetched);
- fetched = null;
- } else {
- fetchedCallback = processPackageData;
- }
-
- }
- if (Module['calledRun']) {
- runWithFS();
- } else {
- if (!Module['preRun']) Module['preRun'] = [];
- Module["preRun"].push(runWithFS); // FS is not initialized yet, wait for it
- }
-
-})();
diff --git a/modules/etc/image_etc.cpp b/modules/etc/image_etc.cpp
index e86fd06d81..dc7d23bbd7 100644
--- a/modules/etc/image_etc.cpp
+++ b/modules/etc/image_etc.cpp
@@ -37,7 +37,6 @@
static Image::Format _get_etc2_mode(Image::DetectChannels format) {
switch (format) {
- case Image::DETECTED_L:
case Image::DETECTED_R:
return Image::FORMAT_ETC2_R11;
@@ -47,7 +46,7 @@ static Image::Format _get_etc2_mode(Image::DetectChannels format) {
case Image::DETECTED_RGB:
return Image::FORMAT_ETC2_RGB8;
- case Image::DETECTED_RGBA:
+ default:
return Image::FORMAT_ETC2_RGBA8;
// TODO: would be nice if we could use FORMAT_ETC2_RGB8A1 for FORMAT_RGBA5551
diff --git a/modules/gdnative/SCsub b/modules/gdnative/SCsub
index 65970d48c1..f386f2b542 100644
--- a/modules/gdnative/SCsub
+++ b/modules/gdnative/SCsub
@@ -2,12 +2,16 @@
Import('env')
-env.add_source_files(env.modules_sources, "*.cpp")
-env.add_source_files(env.modules_sources, "godot/*.cpp")
+gdn_env = env.Clone()
-env.Append(CPPFLAGS=['-DGDAPI_BUILT_IN'])
-env.Append(CPPPATH=['#modules/gdnative/'])
+gdn_env.add_source_files(env.modules_sources, "*.cpp")
+gdn_env.add_source_files(env.modules_sources, "gdnative/*.cpp")
+gdn_env.add_source_files(env.modules_sources, "nativescript/*.cpp")
+
+gdn_env.Append(CPPFLAGS=['-DGDAPI_BUILT_IN'])
+gdn_env.Append(CPPPATH=['#modules/gdnative/include/'])
if "platform" in env and env["platform"] == "x11": # there has to be a better solution?
env.Append(LINKFLAGS=["-rdynamic"])
+
env.use_ptrcall = True
diff --git a/modules/gdnative/gdnative.cpp b/modules/gdnative/gdnative.cpp
index ded987557c..6da538844a 100644
--- a/modules/gdnative/gdnative.cpp
+++ b/modules/gdnative/gdnative.cpp
@@ -100,6 +100,11 @@ GDNativeLibrary::~GDNativeLibrary() {
void GDNativeLibrary::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_library_path", "platform", "path"), &GDNativeLibrary::set_library_path);
ClassDB::bind_method(D_METHOD("get_library_path", "platform"), &GDNativeLibrary::get_library_path);
+
+ ClassDB::bind_method(D_METHOD("is_singleton_gdnative"), &GDNativeLibrary::is_singleton_gdnative);
+ ClassDB::bind_method(D_METHOD("set_singleton_gdnative", "singleton"), &GDNativeLibrary::set_singleton_gdnative);
+
+ ADD_PROPERTYNZ(PropertyInfo(Variant::BOOL, "singleton_gdnative"), "set_singleton_gdnative", "is_singleton_gdnative");
}
bool GDNativeLibrary::_set(const StringName &p_name, const Variant &p_value) {
@@ -175,7 +180,6 @@ GDNative::GDNative() {
}
GDNative::~GDNative() {
- // TODO(karroffel): implement ALL the things!
}
extern "C" void _api_anchor();
diff --git a/modules/gdnative/gdnative.h b/modules/gdnative/gdnative.h
index dc1c3507ec..4753c7efe5 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 "gdnative/gdnative.h"
class GDNativeLibrary : public Resource {
GDCLASS(GDNativeLibrary, Resource)
@@ -77,6 +77,8 @@ class GDNativeLibrary : public Resource {
String library_paths[NUM_PLATFORMS];
+ bool singleton_gdnative = false;
+
protected:
bool _set(const StringName &p_name, const Variant &p_value);
bool _get(const StringName &p_name, Variant &r_ret) const;
@@ -92,6 +94,9 @@ public:
String get_library_path(StringName p_platform) const;
String get_active_library_path() const;
+
+ _FORCE_INLINE_ bool is_singleton_gdnative() const { return singleton_gdnative; }
+ _FORCE_INLINE_ void set_singleton_gdnative(bool p_singleton) { singleton_gdnative = p_singleton; }
};
typedef godot_variant (*native_call_cb)(void *, godot_string *, godot_array *);
diff --git a/modules/gdnative/godot/array.cpp b/modules/gdnative/gdnative/array.cpp
index c3fde0e954..51c023981f 100644
--- a/modules/gdnative/godot/array.cpp
+++ b/modules/gdnative/gdnative/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 <godot/array.h>
+#include "gdnative/array.h"
#include "core/array.h"
#include "core/os/memory.h"
diff --git a/modules/gdnative/godot/basis.cpp b/modules/gdnative/gdnative/basis.cpp
index 1d7aa18a70..b1327cdaef 100644
--- a/modules/gdnative/godot/basis.cpp
+++ b/modules/gdnative/gdnative/basis.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 <godot/basis.h>
+#include "gdnative/basis.h"
#include "core/math/matrix3.h"
#include "core/variant.h"
diff --git a/modules/gdnative/godot/color.cpp b/modules/gdnative/gdnative/color.cpp
index 3677fdc265..3f8912d896 100644
--- a/modules/gdnative/godot/color.cpp
+++ b/modules/gdnative/gdnative/color.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 <godot/color.h>
+#include "gdnative/color.h"
#include "core/color.h"
#include "core/variant.h"
diff --git a/modules/gdnative/godot/dictionary.cpp b/modules/gdnative/gdnative/dictionary.cpp
index 2996cc78a3..ed98cdbb00 100644
--- a/modules/gdnative/godot/dictionary.cpp
+++ b/modules/gdnative/gdnative/dictionary.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 <godot/dictionary.h>
+#include "gdnative/dictionary.h"
#include "core/variant.h"
// core/variant.h before to avoid compile errors with MSVC
diff --git a/modules/gdnative/godot/gdnative.cpp b/modules/gdnative/gdnative/gdnative.cpp
index 7cd52da34d..cf1f6a4f16 100644
--- a/modules/gdnative/godot/gdnative.cpp
+++ b/modules/gdnative/gdnative/gdnative.cpp
@@ -27,11 +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 <godot/gdnative.h>
+#include "gdnative/gdnative.h"
#include "class_db.h"
#include "error_macros.h"
-#include "gdnative.h"
#include "global_constants.h"
#include "os/os.h"
#include "project_settings.h"
diff --git a/modules/gdnative/godot/node_path.cpp b/modules/gdnative/gdnative/node_path.cpp
index 2309588a81..50fade5b94 100644
--- a/modules/gdnative/godot/node_path.cpp
+++ b/modules/gdnative/gdnative/node_path.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 <godot/node_path.h>
+#include "gdnative/node_path.h"
#include "core/node_path.h"
#include "core/variant.h"
diff --git a/modules/gdnative/godot/plane.cpp b/modules/gdnative/gdnative/plane.cpp
index f3d4b6971e..a5e05ffa6b 100644
--- a/modules/gdnative/godot/plane.cpp
+++ b/modules/gdnative/gdnative/plane.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 <godot/plane.h>
+#include "gdnative/plane.h"
#include "core/math/plane.h"
#include "core/variant.h"
diff --git a/modules/gdnative/godot/pool_arrays.cpp b/modules/gdnative/gdnative/pool_arrays.cpp
index 49bf851051..1393374da2 100644
--- a/modules/gdnative/godot/pool_arrays.cpp
+++ b/modules/gdnative/gdnative/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 <godot/pool_arrays.h>
+#include "gdnative/pool_arrays.h"
#include "array.h"
#include "core/variant.h"
diff --git a/modules/gdnative/godot/quat.cpp b/modules/gdnative/gdnative/quat.cpp
index e6bea78b60..7db7847da1 100644
--- a/modules/gdnative/godot/quat.cpp
+++ b/modules/gdnative/gdnative/quat.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 <godot/quat.h>
+#include "gdnative/quat.h"
#include "core/math/quat.h"
#include "core/variant.h"
diff --git a/modules/gdnative/godot/rect2.cpp b/modules/gdnative/gdnative/rect2.cpp
index 98e7855dc9..ecd8cce9ca 100644
--- a/modules/gdnative/godot/rect2.cpp
+++ b/modules/gdnative/gdnative/rect2.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 <godot/rect2.h>
+#include "gdnative/rect2.h"
#include "core/math/math_2d.h"
#include "core/variant.h"
diff --git a/modules/gdnative/godot/rect3.cpp b/modules/gdnative/gdnative/rect3.cpp
index 88952ab49c..d34d964db9 100644
--- a/modules/gdnative/godot/rect3.cpp
+++ b/modules/gdnative/gdnative/rect3.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 <godot/rect3.h>
+#include "gdnative/rect3.h"
#include "core/math/rect3.h"
#include "core/variant.h"
diff --git a/modules/gdnative/godot/rid.cpp b/modules/gdnative/gdnative/rid.cpp
index 51c8aaa1b3..f05c39906c 100644
--- a/modules/gdnative/godot/rid.cpp
+++ b/modules/gdnative/gdnative/rid.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 <godot/rid.h>
+#include "gdnative/rid.h"
#include "core/resource.h"
#include "core/rid.h"
diff --git a/modules/gdnative/godot/string.cpp b/modules/gdnative/gdnative/string.cpp
index 1282cf95e5..9b715ce36a 100644
--- a/modules/gdnative/godot/string.cpp
+++ b/modules/gdnative/gdnative/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 <godot/string.h>
+#include "gdnative/string.h"
#include "core/variant.h"
#include "string_db.h"
diff --git a/modules/gdnative/godot/transform.cpp b/modules/gdnative/gdnative/transform.cpp
index a965067b77..d7a3e78d3f 100644
--- a/modules/gdnative/godot/transform.cpp
+++ b/modules/gdnative/gdnative/transform.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 <godot/transform.h>
+#include "gdnative/transform.h"
#include "core/math/transform.h"
#include "core/variant.h"
diff --git a/modules/gdnative/godot/transform2d.cpp b/modules/gdnative/gdnative/transform2d.cpp
index 9fc44ecdfa..dcb54f7a53 100644
--- a/modules/gdnative/godot/transform2d.cpp
+++ b/modules/gdnative/gdnative/transform2d.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 <godot/transform2d.h>
+#include "gdnative/transform2d.h"
#include "core/math/math_2d.h"
#include "core/variant.h"
diff --git a/modules/gdnative/godot/variant.cpp b/modules/gdnative/gdnative/variant.cpp
index 582544b3a0..b61f80b1f9 100644
--- a/modules/gdnative/godot/variant.cpp
+++ b/modules/gdnative/gdnative/variant.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 <godot/variant.h>
+#include "gdnative/variant.h"
#include "core/variant.h"
diff --git a/modules/gdnative/godot/vector2.cpp b/modules/gdnative/gdnative/vector2.cpp
index 78ed5f06a9..67f858997f 100644
--- a/modules/gdnative/godot/vector2.cpp
+++ b/modules/gdnative/gdnative/vector2.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 <godot/vector2.h>
+#include "gdnative/vector2.h"
#include "core/math/math_2d.h"
#include "core/variant.h"
diff --git a/modules/gdnative/godot/vector3.cpp b/modules/gdnative/gdnative/vector3.cpp
index 5faeac2864..c85a3f1c08 100644
--- a/modules/gdnative/godot/vector3.cpp
+++ b/modules/gdnative/gdnative/vector3.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 <godot/vector3.h>
+#include "gdnative/vector3.h"
#include "core/variant.h"
#include "core/vector.h"
diff --git a/modules/gdnative/godot/icon.png.import b/modules/gdnative/godot/icon.png.import
deleted file mode 100644
index 27920124f9..0000000000
--- a/modules/gdnative/godot/icon.png.import
+++ /dev/null
@@ -1,23 +0,0 @@
-[remap]
-
-importer="texture"
-type="StreamTexture"
-path="res://.import/icon.png-aa47d037a37fb38b3b7e7828e4eec407.stex"
-
-[params]
-
-compress/mode=0
-compress/lossy_quality=0.7
-compress/hdr_mode=0
-compress/normal_map=0
-flags/repeat=0
-flags/filter=true
-flags/mipmaps=false
-flags/anisotropic=false
-flags/srgb=2
-process/fix_alpha_border=true
-process/premult_alpha=false
-process/HDR_as_SRGB=false
-stream=false
-size_limit=0
-detect_3d=true
diff --git a/modules/gdnative/godot/array.h b/modules/gdnative/include/gdnative/array.h
index 08f73c8785..edab028cba 100644
--- a/modules/gdnative/godot/array.h
+++ b/modules/gdnative/include/gdnative/array.h
@@ -46,10 +46,10 @@ typedef struct {
} godot_array;
#endif
-#include <godot/pool_arrays.h>
-#include <godot/variant.h>
+#include <gdnative/pool_arrays.h>
+#include <gdnative/variant.h>
-#include <godot/gdnative.h>
+#include <gdnative/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.h b/modules/gdnative/include/gdnative/basis.h
index f36d2199de..8ff6a6f541 100644
--- a/modules/gdnative/godot/basis.h
+++ b/modules/gdnative/include/gdnative/basis.h
@@ -45,9 +45,9 @@ typedef struct {
} godot_basis;
#endif
-#include <godot/gdnative.h>
-#include <godot/quat.h>
-#include <godot/vector3.h>
+#include <gdnative/gdnative.h>
+#include <gdnative/quat.h>
+#include <gdnative/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.h b/modules/gdnative/include/gdnative/color.h
index 5d550e40b3..90dccf75aa 100644
--- a/modules/gdnative/godot/color.h
+++ b/modules/gdnative/include/gdnative/color.h
@@ -45,8 +45,8 @@ typedef struct {
} godot_color;
#endif
-#include <godot/gdnative.h>
-#include <godot/string.h>
+#include <gdnative/gdnative.h>
+#include <gdnative/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.h b/modules/gdnative/include/gdnative/dictionary.h
index 10d580af08..c85c3f3830 100644
--- a/modules/gdnative/godot/dictionary.h
+++ b/modules/gdnative/include/gdnative/dictionary.h
@@ -45,9 +45,9 @@ typedef struct {
} godot_dictionary;
#endif
-#include <godot/array.h>
-#include <godot/gdnative.h>
-#include <godot/variant.h>
+#include <gdnative/array.h>
+#include <gdnative/gdnative.h>
+#include <gdnative/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.h b/modules/gdnative/include/gdnative/gdnative.h
index c71a7ae1ef..c574c56d5a 100644
--- a/modules/gdnative/godot/gdnative.h
+++ b/modules/gdnative/include/gdnative/gdnative.h
@@ -146,100 +146,74 @@ typedef float godot_real;
/////// Object (forward declared)
typedef void godot_object;
-/////// Brute force forward declarations for the rest
-/*
-typedef struct godot_variant godot_variant;
-typedef struct godot_string godot_string;
-typedef struct godot_vector2 godot_vector2;
-typedef struct godot_rect2 godot_rect2;
-typedef struct godot_vector3 godot_vector3;
-typedef struct godot_transform2d godot_transform2d;
-typedef struct godot_plane godot_plane;
-typedef struct godot_quat godot_quat;
-typedef struct godot_rect3 godot_rect3;
-typedef struct godot_basis godot_basis;
-typedef struct godot_transform godot_transform;
-typedef struct godot_color godot_color;
-typedef struct godot_node_path godot_node_path;
-typedef struct godot_rid godot_rid;
-typedef struct godot_dictionary godot_dictionary;
-typedef struct godot_array godot_array;
-typedef struct godot_pool_byte_array godot_pool_byte_array;
-typedef struct godot_pool_int_array godot_pool_int_array;
-typedef struct godot_pool_real_array godot_pool_real_array;
-typedef struct godot_pool_string_array godot_pool_string_array;
-typedef struct godot_pool_vector2_array godot_pool_vector2_array;
-typedef struct godot_pool_vector3_array godot_pool_vector3_array;
-typedef struct godot_pool_color_array godot_pool_color_array;
-*/
/////// String
-#include <godot/string.h>
+#include <gdnative/string.h>
////// Vector2
-#include <godot/vector2.h>
+#include <gdnative/vector2.h>
////// Rect2
-#include <godot/rect2.h>
+#include <gdnative/rect2.h>
////// Vector3
-#include <godot/vector3.h>
+#include <gdnative/vector3.h>
////// Transform2D
-#include <godot/transform2d.h>
+#include <gdnative/transform2d.h>
/////// Plane
-#include <godot/plane.h>
+#include <gdnative/plane.h>
/////// Quat
-#include <godot/quat.h>
+#include <gdnative/quat.h>
/////// Rect3
-#include <godot/rect3.h>
+#include <gdnative/rect3.h>
/////// Basis
-#include <godot/basis.h>
+#include <gdnative/basis.h>
/////// Transform
-#include <godot/transform.h>
+#include <gdnative/transform.h>
/////// Color
-#include <godot/color.h>
+#include <gdnative/color.h>
/////// NodePath
-#include <godot/node_path.h>
+#include <gdnative/node_path.h>
/////// RID
-#include <godot/rid.h>
+#include <gdnative/rid.h>
/////// Dictionary
-#include <godot/dictionary.h>
+#include <gdnative/dictionary.h>
/////// Array
-#include <godot/array.h>
+#include <gdnative/array.h>
// single API file for Pool*Array
-#include <godot/pool_arrays.h>
+#include <gdnative/pool_arrays.h>
void GDAPI godot_object_destroy(godot_object *p_o);
////// Variant
-#include <godot/variant.h>
+#include <gdnative/variant.h>
////// Singleton API
diff --git a/modules/gdnative/godot/node_path.h b/modules/gdnative/include/gdnative/node_path.h
index 2f71ddd59d..0cfdbc1127 100644
--- a/modules/gdnative/godot/node_path.h
+++ b/modules/gdnative/include/gdnative/node_path.h
@@ -45,8 +45,8 @@ typedef struct {
} godot_node_path;
#endif
-#include <godot/gdnative.h>
-#include <godot/string.h>
+#include <gdnative/gdnative.h>
+#include <gdnative/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.h b/modules/gdnative/include/gdnative/plane.h
index 27548c8b0c..6a8915e08b 100644
--- a/modules/gdnative/godot/plane.h
+++ b/modules/gdnative/include/gdnative/plane.h
@@ -45,8 +45,8 @@ typedef struct {
} godot_plane;
#endif
-#include <godot/gdnative.h>
-#include <godot/vector3.h>
+#include <gdnative/gdnative.h>
+#include <gdnative/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.h b/modules/gdnative/include/gdnative/pool_arrays.h
index 1b51dca38c..cb1095ee8c 100644
--- a/modules/gdnative/godot/pool_arrays.h
+++ b/modules/gdnative/include/gdnative/pool_arrays.h
@@ -113,12 +113,12 @@ typedef struct {
} godot_pool_color_array;
#endif
-#include <godot/array.h>
-#include <godot/color.h>
-#include <godot/vector2.h>
-#include <godot/vector3.h>
+#include <gdnative/array.h>
+#include <gdnative/color.h>
+#include <gdnative/vector2.h>
+#include <gdnative/vector3.h>
-#include <godot/gdnative.h>
+#include <gdnative/gdnative.h>
// byte
diff --git a/modules/gdnative/godot/quat.h b/modules/gdnative/include/gdnative/quat.h
index 9a3238a337..4ffb96eb26 100644
--- a/modules/gdnative/godot/quat.h
+++ b/modules/gdnative/include/gdnative/quat.h
@@ -45,8 +45,8 @@ typedef struct {
} godot_quat;
#endif
-#include <godot/gdnative.h>
-#include <godot/vector3.h>
+#include <gdnative/gdnative.h>
+#include <gdnative/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.h b/modules/gdnative/include/gdnative/rect2.h
index 8ceeddf1b4..9e6cf60342 100644
--- a/modules/gdnative/godot/rect2.h
+++ b/modules/gdnative/include/gdnative/rect2.h
@@ -43,8 +43,8 @@ typedef struct godot_rect2 {
} godot_rect2;
#endif
-#include <godot/gdnative.h>
-#include <godot/vector2.h>
+#include <gdnative/gdnative.h>
+#include <gdnative/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.h b/modules/gdnative/include/gdnative/rect3.h
index ca96aadd5c..f94b6fea25 100644
--- a/modules/gdnative/godot/rect3.h
+++ b/modules/gdnative/include/gdnative/rect3.h
@@ -45,9 +45,9 @@ typedef struct {
} godot_rect3;
#endif
-#include <godot/gdnative.h>
-#include <godot/plane.h>
-#include <godot/vector3.h>
+#include <gdnative/gdnative.h>
+#include <gdnative/plane.h>
+#include <gdnative/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.h b/modules/gdnative/include/gdnative/rid.h
index c56ff38735..d9b5336fc9 100644
--- a/modules/gdnative/godot/rid.h
+++ b/modules/gdnative/include/gdnative/rid.h
@@ -45,7 +45,7 @@ typedef struct {
} godot_rid;
#endif
-#include <godot/gdnative.h>
+#include <gdnative/gdnative.h>
void GDAPI godot_rid_new(godot_rid *r_dest);
diff --git a/modules/gdnative/godot/string.h b/modules/gdnative/include/gdnative/string.h
index 128448e64e..aca23a81d8 100644
--- a/modules/gdnative/godot/string.h
+++ b/modules/gdnative/include/gdnative/string.h
@@ -46,8 +46,8 @@ typedef struct {
} godot_string;
#endif
-#include <godot/gdnative.h>
-#include <godot/variant.h>
+#include <gdnative/gdnative.h>
+#include <gdnative/variant.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.h b/modules/gdnative/include/gdnative/transform.h
index 60788e3d57..656afae129 100644
--- a/modules/gdnative/godot/transform.h
+++ b/modules/gdnative/include/gdnative/transform.h
@@ -45,10 +45,10 @@ typedef struct {
} godot_transform;
#endif
-#include <godot/basis.h>
-#include <godot/gdnative.h>
-#include <godot/variant.h>
-#include <godot/vector3.h>
+#include <gdnative/basis.h>
+#include <gdnative/gdnative.h>
+#include <gdnative/variant.h>
+#include <gdnative/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.h b/modules/gdnative/include/gdnative/transform2d.h
index c0f5725eed..a945868b17 100644
--- a/modules/gdnative/godot/transform2d.h
+++ b/modules/gdnative/include/gdnative/transform2d.h
@@ -45,9 +45,9 @@ typedef struct {
} godot_transform2d;
#endif
-#include <godot/gdnative.h>
-#include <godot/variant.h>
-#include <godot/vector2.h>
+#include <gdnative/gdnative.h>
+#include <gdnative/variant.h>
+#include <gdnative/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.h b/modules/gdnative/include/gdnative/variant.h
index 849ba8bda6..969506585d 100644
--- a/modules/gdnative/godot/variant.h
+++ b/modules/gdnative/include/gdnative/variant.h
@@ -99,25 +99,25 @@ typedef struct godot_variant_call_error {
godot_variant_type expected;
} godot_variant_call_error;
-#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>
+#include <gdnative/array.h>
+#include <gdnative/basis.h>
+#include <gdnative/color.h>
+#include <gdnative/dictionary.h>
+#include <gdnative/node_path.h>
+#include <gdnative/plane.h>
+#include <gdnative/pool_arrays.h>
+#include <gdnative/quat.h>
+#include <gdnative/rect2.h>
+#include <gdnative/rect3.h>
+#include <gdnative/rid.h>
+#include <gdnative/string.h>
+#include <gdnative/transform.h>
+#include <gdnative/transform2d.h>
+#include <gdnative/variant.h>
+#include <gdnative/vector2.h>
+#include <gdnative/vector3.h>
+
+#include <gdnative/gdnative.h>
godot_variant_type GDAPI godot_variant_get_type(const godot_variant *p_v);
diff --git a/modules/gdnative/godot/vector2.h b/modules/gdnative/include/gdnative/vector2.h
index 98e9700e32..0af4abae27 100644
--- a/modules/gdnative/godot/vector2.h
+++ b/modules/gdnative/include/gdnative/vector2.h
@@ -45,7 +45,7 @@ typedef struct {
} godot_vector2;
#endif
-#include <godot/gdnative.h>
+#include <gdnative/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.h b/modules/gdnative/include/gdnative/vector3.h
index b76ca11a9c..a27d516ec5 100644
--- a/modules/gdnative/godot/vector3.h
+++ b/modules/gdnative/include/gdnative/vector3.h
@@ -45,8 +45,8 @@ typedef struct {
} godot_vector3;
#endif
-#include <godot/basis.h>
-#include <godot/gdnative.h>
+#include <gdnative/basis.h>
+#include <gdnative/gdnative.h>
typedef enum {
GODOT_VECTOR3_AXIS_X,
diff --git a/modules/nativescript/godot_nativescript.h b/modules/gdnative/include/nativescript/godot_nativescript.h
index d1cbf221ec..96f213ead7 100644
--- a/modules/nativescript/godot_nativescript.h
+++ b/modules/gdnative/include/nativescript/godot_nativescript.h
@@ -30,7 +30,7 @@
#ifndef GODOT_NATIVESCRIPT_H
#define GODOT_NATIVESCRIPT_H
-#include <godot/gdnative.h>
+#include <gdnative/gdnative.h>
#ifdef __cplusplus
extern "C" {
diff --git a/modules/nativescript/SCsub b/modules/gdnative/nativescript/SCsub
index e980e40e8e..e980e40e8e 100644
--- a/modules/nativescript/SCsub
+++ b/modules/gdnative/nativescript/SCsub
diff --git a/modules/nativescript/api_generator.cpp b/modules/gdnative/nativescript/api_generator.cpp
index fdd5a2ea19..fdd5a2ea19 100644
--- a/modules/nativescript/api_generator.cpp
+++ b/modules/gdnative/nativescript/api_generator.cpp
diff --git a/modules/nativescript/api_generator.h b/modules/gdnative/nativescript/api_generator.h
index 56c2d786e6..56c2d786e6 100644
--- a/modules/nativescript/api_generator.h
+++ b/modules/gdnative/nativescript/api_generator.h
diff --git a/modules/nativescript/godot_nativescript.cpp b/modules/gdnative/nativescript/godot_nativescript.cpp
index 926b3261b2..61ac13b796 100644
--- a/modules/nativescript/godot_nativescript.cpp
+++ b/modules/gdnative/nativescript/godot_nativescript.cpp
@@ -27,17 +27,17 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "godot_nativescript.h"
-
-#include "nativescript.h"
+#include "nativescript/godot_nativescript.h"
#include "class_db.h"
#include "error_macros.h"
-#include "gdnative.h"
+#include "gdnative/gdnative.h"
#include "global_constants.h"
#include "project_settings.h"
#include "variant.h"
+#include "nativescript.h"
+
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/modules/nativescript/nativescript.cpp b/modules/gdnative/nativescript/nativescript.cpp
index e141080687..b9bd65af53 100644
--- a/modules/nativescript/nativescript.cpp
+++ b/modules/gdnative/nativescript/nativescript.cpp
@@ -29,7 +29,7 @@
/*************************************************************************/
#include "nativescript.h"
-#include "modules/gdnative/godot/gdnative.h"
+#include "gdnative/gdnative.h"
#include "global_constants.h"
#include "io/file_access_encrypted.h"
@@ -315,7 +315,7 @@ void NativeScript::get_script_signal_list(List<MethodInfo> *r_signals) const {
bool NativeScript::get_property_default_value(const StringName &p_property, Variant &r_value) const {
NativeScriptDesc *script_data = get_script_desc();
- Map<StringName, NativeScriptDesc::Property>::Element *P = NULL;
+ OrderedHashMap<StringName, NativeScriptDesc::Property>::Element P;
while (!P && script_data) {
P = script_data->properties.find(p_property);
script_data = script_data->base_data;
@@ -323,7 +323,7 @@ bool NativeScript::get_property_default_value(const StringName &p_property, Vari
if (!P)
return false;
- r_value = P->get().default_value;
+ r_value = P.get().default_value;
return true;
}
@@ -355,23 +355,20 @@ void NativeScript::get_script_method_list(List<MethodInfo> *p_list) const {
void NativeScript::get_script_property_list(List<PropertyInfo> *p_list) const {
NativeScriptDesc *script_data = get_script_desc();
- if (!script_data)
- return;
-
- Set<PropertyInfo> properties;
-
+ Set<StringName> existing_properties;
while (script_data) {
-
- for (Map<StringName, NativeScriptDesc::Property>::Element *E = script_data->properties.front(); E; E = E->next()) {
- properties.insert(E->get().info);
+ List<PropertyInfo>::Element *insert_position = p_list->front();
+ bool insert_before = true;
+
+ for (OrderedHashMap<StringName, NativeScriptDesc::Property>::Element E = script_data->properties.front(); E; E = E.next()) {
+ if (!existing_properties.has(E.key())) {
+ insert_position = insert_before ? p_list->insert_before(insert_position, E.get().info) : p_list->insert_after(insert_position, E.get().info);
+ insert_before = false;
+ existing_properties.insert(E.key());
+ }
}
-
script_data = script_data->base_data;
}
-
- for (Set<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) {
- p_list->push_back(E->get());
- }
}
Variant NativeScript::_new(const Variant **p_args, int p_argcount, Variant::CallError &r_error) {
@@ -461,10 +458,10 @@ bool NativeScriptInstance::set(const StringName &p_name, const Variant &p_value)
NativeScriptDesc *script_data = GET_SCRIPT_DESC();
while (script_data) {
- Map<StringName, NativeScriptDesc::Property>::Element *P = script_data->properties.find(p_name);
+ OrderedHashMap<StringName, NativeScriptDesc::Property>::Element P = script_data->properties.find(p_name);
if (P) {
- P->get().setter.set_func((godot_object *)owner,
- P->get().setter.method_data,
+ P.get().setter.set_func((godot_object *)owner,
+ P.get().setter.method_data,
userdata,
(godot_variant *)&p_value);
return true;
@@ -491,11 +488,11 @@ bool NativeScriptInstance::get(const StringName &p_name, Variant &r_ret) const {
NativeScriptDesc *script_data = GET_SCRIPT_DESC();
while (script_data) {
- Map<StringName, NativeScriptDesc::Property>::Element *P = script_data->properties.find(p_name);
+ OrderedHashMap<StringName, NativeScriptDesc::Property>::Element P = script_data->properties.find(p_name);
if (P) {
godot_variant value;
- value = P->get().getter.get_func((godot_object *)owner,
- P->get().getter.method_data,
+ value = P.get().getter.get_func((godot_object *)owner,
+ P.get().getter.method_data,
userdata);
r_ret = *(Variant *)&value;
godot_variant_destroy(&value);
@@ -592,10 +589,10 @@ Variant::Type NativeScriptInstance::get_property_type(const StringName &p_name,
while (script_data) {
- Map<StringName, NativeScriptDesc::Property>::Element *P = script_data->properties.find(p_name);
+ OrderedHashMap<StringName, NativeScriptDesc::Property>::Element P = script_data->properties.find(p_name);
if (P) {
*r_is_valid = true;
- return P->get().info.type;
+ return P.get().info.type;
}
script_data = script_data->base_data;
@@ -706,9 +703,9 @@ NativeScriptInstance::RPCMode NativeScriptInstance::get_rset_mode(const StringNa
while (script_data) {
- Map<StringName, NativeScriptDesc::Property>::Element *E = script_data->properties.find(p_variable);
+ OrderedHashMap<StringName, NativeScriptDesc::Property>::Element E = script_data->properties.find(p_variable);
if (E) {
- switch (E->get().rset_mode) {
+ switch (E.get().rset_mode) {
case GODOT_METHOD_RPC_MODE_DISABLED:
return RPC_MODE_DISABLED;
case GODOT_METHOD_RPC_MODE_REMOTE:
@@ -796,12 +793,12 @@ void NativeScriptLanguage::_unload_stuff() {
for (Map<StringName, NativeScriptDesc>::Element *C = L->get().front(); C; C = C->next()) {
// free property stuff first
- for (Map<StringName, NativeScriptDesc::Property>::Element *P = C->get().properties.front(); P; P = P->next()) {
- if (P->get().getter.free_func)
- P->get().getter.free_func(P->get().getter.method_data);
+ for (OrderedHashMap<StringName, NativeScriptDesc::Property>::Element P = C->get().properties.front(); P; P = P.next()) {
+ if (P.get().getter.free_func)
+ P.get().getter.free_func(P.get().getter.method_data);
- if (P->get().setter.free_func)
- P->get().setter.free_func(P->get().setter.method_data);
+ if (P.get().setter.free_func)
+ P.get().setter.free_func(P.get().setter.method_data);
}
// free method stuff
diff --git a/modules/nativescript/nativescript.h b/modules/gdnative/nativescript/nativescript.h
index 571a3c9cc7..bc7e850d3e 100644
--- a/modules/nativescript/nativescript.h
+++ b/modules/gdnative/nativescript/nativescript.h
@@ -32,14 +32,15 @@
#include "io/resource_loader.h"
#include "io/resource_saver.h"
+#include "ordered_hash_map.h"
#include "os/thread_safe.h"
#include "resource.h"
#include "scene/main/node.h"
#include "script_language.h"
#include "self_list.h"
-#include "godot_nativescript.h"
#include "modules/gdnative/gdnative.h"
+#include <nativescript/godot_nativescript.h>
#ifndef NO_THREADS
#include "os/mutex.h"
@@ -65,7 +66,7 @@ struct NativeScriptDesc {
};
Map<StringName, Method> methods;
- Map<StringName, Property> properties;
+ OrderedHashMap<StringName, Property> properties;
Map<StringName, Signal> signals_; // QtCreator doesn't like the name signals
StringName base;
StringName base_native_type;
diff --git a/modules/nativescript/register_types.cpp b/modules/gdnative/nativescript/register_types.cpp
index b846710ab8..b846710ab8 100644
--- a/modules/nativescript/register_types.cpp
+++ b/modules/gdnative/nativescript/register_types.cpp
diff --git a/modules/nativescript/register_types.h b/modules/gdnative/nativescript/register_types.h
index 7ac558f68f..7ac558f68f 100644
--- a/modules/nativescript/register_types.h
+++ b/modules/gdnative/nativescript/register_types.h
diff --git a/modules/gdnative/register_types.cpp b/modules/gdnative/register_types.cpp
index 9ad05b7194..559e9fa455 100644
--- a/modules/gdnative/register_types.cpp
+++ b/modules/gdnative/register_types.cpp
@@ -28,12 +28,99 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "register_types.h"
+#include "gdnative/gdnative.h"
+
#include "gdnative.h"
#include "io/resource_loader.h"
#include "io/resource_saver.h"
+#include "nativescript/register_types.h"
+
+#include "core/engine.h"
#include "core/os/os.h"
+#include "core/project_settings.h"
+
+#ifdef TOOLS_ENABLED
+#include "editor/editor_node.h"
+
+// Class used to discover singleton gdnative files
+
+void actual_discoverer_handler();
+
+class GDNativeSingletonDiscover : public Object {
+ // GDCLASS(GDNativeSingletonDiscover, Object)
+
+ virtual String get_class() const {
+ // okay, this is a really dirty hack.
+ // We're overriding get_class so we can connect it to a signal
+ // This works because get_class is a virtual method, so we don't
+ // need to register a new class to ClassDB just for this one
+ // little signal.
+
+ actual_discoverer_handler();
+
+ return "Object";
+ }
+};
+
+Set<String> get_gdnative_singletons(EditorFileSystemDirectory *p_dir) {
+
+ Set<String> file_paths;
+
+ // check children
+
+ for (int i = 0; i < p_dir->get_file_count(); i++) {
+ String file_name = p_dir->get_file(i);
+ String file_type = p_dir->get_file_type(i);
+
+ if (file_type != "GDNativeLibrary") {
+ continue;
+ }
+
+ Ref<GDNativeLibrary> lib = ResourceLoader::load(p_dir->get_file_path(i));
+ if (lib.is_valid() && lib->is_singleton_gdnative()) {
+ file_paths.insert(p_dir->get_file_path(i));
+ }
+ }
+
+ // check subdirectories
+ for (int i = 0; i < p_dir->get_subdir_count(); i++) {
+ Set<String> paths = get_gdnative_singletons(p_dir->get_subdir(i));
+
+ for (Set<String>::Element *E = paths.front(); E; E = E->next()) {
+ file_paths.insert(E->get());
+ }
+ }
+
+ return file_paths;
+}
+
+void actual_discoverer_handler() {
+ EditorFileSystemDirectory *dir = EditorFileSystem::get_singleton()->get_filesystem();
+
+ Set<String> file_paths = get_gdnative_singletons(dir);
+
+ Array files;
+ files.resize(file_paths.size());
+ int i = 0;
+ for (Set<String>::Element *E = file_paths.front(); E; i++, E = E->next()) {
+ files.set(i, E->get());
+ }
+
+ ProjectSettings::get_singleton()->set("gdnative/singletons", files);
+
+ ProjectSettings::get_singleton()->save();
+}
+
+GDNativeSingletonDiscover *discoverer = NULL;
+
+void discoverer_callback() {
+ discoverer = memnew(GDNativeSingletonDiscover);
+ EditorFileSystem::get_singleton()->connect("filesystem_changed", discoverer, "get_class");
+}
+
+#endif
godot_variant cb_standard_varcall(void *handle, godot_string *p_procedure, godot_array *p_args) {
if (handle == NULL) {
@@ -62,21 +149,110 @@ godot_variant cb_standard_varcall(void *handle, godot_string *p_procedure, godot
return proc(NULL, p_args);
}
+void cb_singleton_call(
+ void *p_handle,
+ godot_string *p_proc_name,
+ void *p_data,
+ int p_num_args,
+ void **p_args,
+ void *r_return) {
+ if (p_handle == NULL) {
+ ERR_PRINT("No valid library handle, can't call singleton procedure");
+ return;
+ }
+
+ void *singleton_proc;
+ Error err = OS::get_singleton()->get_dynamic_library_symbol_handle(
+ p_handle,
+ *(String *)p_proc_name,
+ singleton_proc);
+
+ if (err != OK) {
+ return;
+ }
+
+ void (*singleton_procedure_ptr)() = (void (*)())singleton_proc;
+ singleton_procedure_ptr();
+}
+
GDNativeCallRegistry *GDNativeCallRegistry::singleton;
+Vector<Ref<GDNative> > singleton_gdnatives;
+
void register_gdnative_types() {
+#ifdef TOOLS_ENABLED
+
+ if (Engine::get_singleton()->is_editor_hint()) {
+ EditorNode::add_init_callback(discoverer_callback);
+ }
+#endif
+
ClassDB::register_class<GDNativeLibrary>();
ClassDB::register_class<GDNative>();
GDNativeCallRegistry::singleton = memnew(GDNativeCallRegistry);
GDNativeCallRegistry::singleton->register_native_call_type("standard_varcall", cb_standard_varcall);
+
+ GDNativeCallRegistry::singleton->register_native_raw_call_type("gdnative_singleton_call", cb_singleton_call);
+
+ register_nativescript_types();
+
+ // run singletons
+
+ Array singletons = ProjectSettings::get_singleton()->get("gdnative/singletons");
+
+ singleton_gdnatives.resize(singletons.size());
+
+ for (int i = 0; i < singletons.size(); i++) {
+ String path = singletons[i];
+
+ Ref<GDNativeLibrary> lib = ResourceLoader::load(path);
+
+ singleton_gdnatives[i].instance();
+ singleton_gdnatives[i]->set_library(lib);
+
+ if (!singleton_gdnatives[i]->initialize()) {
+ // Can't initialize. Don't make a native_call then
+ continue;
+ }
+
+ singleton_gdnatives[i]->call_native_raw(
+ "gdnative_singleton_call",
+ "godot_gdnative_singleton",
+ NULL,
+ 0,
+ NULL,
+ NULL);
+ }
}
void unregister_gdnative_types() {
+
+ for (int i = 0; i < singleton_gdnatives.size(); i++) {
+
+ if (singleton_gdnatives[i].is_null()) {
+ continue;
+ }
+
+ if (!singleton_gdnatives[i]->is_initialized()) {
+ continue;
+ }
+
+ singleton_gdnatives[i]->terminate();
+ }
+
+ unregister_nativescript_types();
+
memdelete(GDNativeCallRegistry::singleton);
+#ifdef TOOLS_ENABLED
+ if (Engine::get_singleton()->is_editor_hint() && discoverer != NULL) {
+ memdelete(discoverer);
+ }
+#endif
+
// This is for printing out the sizes of the core types
/*
diff --git a/modules/gdscript/gd_editor.cpp b/modules/gdscript/gd_editor.cpp
index 70e7da5748..bc51b84047 100644
--- a/modules/gdscript/gd_editor.cpp
+++ b/modules/gdscript/gd_editor.cpp
@@ -866,7 +866,7 @@ static bool _guess_expression_type(GDCompletionContext &context, const GDParser:
MethodBind *mb = ClassDB::get_method(base_type, getter);
if (mb) {
PropertyInfo rt = mb->get_return_info();
- if (rt.usage & PROPERTY_USAGE_CLASS_IS_ENUM && t == Variant::INT) {
+ if ((rt.usage & PROPERTY_USAGE_CLASS_IS_ENUM) && t == Variant::INT) {
r_type.enumeration = rt.class_name;
} else if (t == Variant::OBJECT) {
@@ -1903,11 +1903,11 @@ static void _find_call_arguments(GDCompletionContext &context, const GDParser::N
arghint += ", ";
else
arghint += " ";
- if (i == p_argidx || (mi.flags & METHOD_FLAG_VARARG && i > p_argidx)) {
+ if (i == p_argidx || ((mi.flags & METHOD_FLAG_VARARG) && i > p_argidx)) {
arghint += String::chr(0xFFFF);
}
arghint += _get_visual_datatype(mi.arguments[i]) + " " + mi.arguments[i].name;
- if (i == p_argidx || (mi.flags & METHOD_FLAG_VARARG && i > p_argidx)) {
+ if (i == p_argidx || ((mi.flags & METHOD_FLAG_VARARG) && i > p_argidx)) {
arghint += String::chr(0xFFFF);
}
}
diff --git a/modules/gdscript/gd_functions.cpp b/modules/gdscript/gd_functions.cpp
index f0cfdd6258..04752dc71a 100644
--- a/modules/gdscript/gd_functions.cpp
+++ b/modules/gdscript/gd_functions.cpp
@@ -1177,20 +1177,28 @@ void GDFunctions::call(Function p_func, const Variant **p_args, int p_arg_count,
VALIDATE_ARG_COUNT(1);
switch (p_args[0]->get_type()) {
+ case Variant::STRING: {
+
+ String d = *p_args[0];
+ r_ret = d.length();
+ } break;
case Variant::DICTIONARY: {
+
Dictionary d = *p_args[0];
r_ret = d.size();
} break;
case Variant::ARRAY: {
+
Array d = *p_args[0];
r_ret = d.size();
} break;
case Variant::POOL_BYTE_ARRAY: {
+
PoolVector<uint8_t> d = *p_args[0];
r_ret = d.size();
-
} break;
case Variant::POOL_INT_ARRAY: {
+
PoolVector<int> d = *p_args[0];
r_ret = d.size();
} break;
@@ -1200,14 +1208,14 @@ void GDFunctions::call(Function p_func, const Variant **p_args, int p_arg_count,
r_ret = d.size();
} break;
case Variant::POOL_STRING_ARRAY: {
+
PoolVector<String> d = *p_args[0];
r_ret = d.size();
-
} break;
case Variant::POOL_VECTOR2_ARRAY: {
+
PoolVector<Vector2> d = *p_args[0];
r_ret = d.size();
-
} break;
case Variant::POOL_VECTOR3_ARRAY: {
diff --git a/modules/gdscript/gd_script.h b/modules/gdscript/gd_script.h
index 6f05a4770b..5e1a8b19ac 100644
--- a/modules/gdscript/gd_script.h
+++ b/modules/gdscript/gd_script.h
@@ -389,7 +389,6 @@ public:
virtual bool can_inherit_from_file() { return true; }
virtual int find_function(const String &p_function, const String &p_code) const;
virtual String make_function(const String &p_class, const String &p_name, const PoolStringArray &p_args) const;
- virtual Error open_in_external_editor(const Ref<Script> &p_script, int p_line, int p_col) { return OK; }
virtual Error complete_code(const String &p_code, const String &p_base_path, Object *p_owner, List<String> *r_options, bool &r_forced, String &r_call_hint);
#ifdef TOOLS_ENABLED
virtual Error lookup_code(const String &p_code, const String &p_symbol, const String &p_base_path, Object *p_owner, LookupResult &r_result);
diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cpp
index 1b932f040e..4f7545a11d 100644
--- a/modules/gridmap/grid_map.cpp
+++ b/modules/gridmap/grid_map.cpp
@@ -396,8 +396,6 @@ bool GridMap::_octant_update(const OctantKey &p_key) {
Map<int, List<Pair<Transform, IndexKey> > > multimesh_items;
- print_line("updating octant " + itos(p_key.x) + ", " + itos(p_key.y) + ", " + itos(p_key.z) + " cells: " + itos(g.cells.size()));
-
for (Set<IndexKey>::Element *E = g.cells.front(); E; E = E->next()) {
ERR_CONTINUE(!cell_map.has(E->get()));
@@ -464,7 +462,6 @@ bool GridMap::_octant_update(const OctantKey &p_key) {
//update multimeshes
for (Map<int, List<Pair<Transform, IndexKey> > >::Element *E = multimesh_items.front(); E; E = E->next()) {
- print_line("multimesh item " + itos(E->key()) + " transforms " + itos(E->get().size()));
Octant::MultimeshInstance mmi;
RID mm = VS::get_singleton()->multimesh_create();
@@ -655,6 +652,24 @@ void GridMap::_notification(int p_what) {
//_update_area_instances();
} break;
+ case NOTIFICATION_VISIBILITY_CHANGED: {
+ _update_visibility();
+ } break;
+ }
+}
+
+void GridMap::_update_visibility() {
+ if (!is_inside_tree())
+ return;
+
+ _change_notify("visible");
+
+ for (Map<OctantKey, Octant *>::Element *e = octant_map.front(); e; e = e->next()) {
+ Octant *octant = e->value();
+ for (int i = 0; i < octant->multimesh_instances.size(); i++) {
+ Octant::MultimeshInstance &mi = octant->multimesh_instances[i];
+ VS::get_singleton()->instance_set_visible(mi.instance, is_visible());
+ }
}
}
@@ -720,6 +735,7 @@ void GridMap::_update_octants_callback() {
to_delete.pop_back();
}
+ _update_visibility();
awaiting_update = false;
}
diff --git a/modules/gridmap/grid_map.h b/modules/gridmap/grid_map.h
index 9e1d250680..eb1b215696 100644
--- a/modules/gridmap/grid_map.h
+++ b/modules/gridmap/grid_map.h
@@ -190,6 +190,7 @@ protected:
void _get_property_list(List<PropertyInfo> *p_list) const;
void _notification(int p_what);
+ void _update_visibility();
static void _bind_methods();
public:
diff --git a/modules/nativescript/config.py b/modules/nativescript/config.py
deleted file mode 100644
index 9f57b9bb74..0000000000
--- a/modules/nativescript/config.py
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-def can_build(platform):
- return True
-
-
-def configure(env):
- env.use_ptrcall = True
diff --git a/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp b/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp
index df427907f8..9457fbfaf6 100644
--- a/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp
+++ b/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp
@@ -45,6 +45,12 @@ void AudioStreamPlaybackOGGVorbis::_mix_internal(AudioFrame *p_buffer, int p_fra
while (todo && active) {
int mixed = stb_vorbis_get_samples_float_interleaved(ogg_stream, 2, (float *)p_buffer, todo * 2);
+ if (vorbis_stream->channels == 1 && mixed > 0) {
+ //mix mono to stereo
+ for (int i = 0; i < mixed; i++) {
+ p_buffer[i].r = p_buffer[i].l;
+ }
+ }
todo -= mixed;
frames_mixed += mixed;
diff --git a/modules/theora/video_stream_theora.cpp b/modules/theora/video_stream_theora.cpp
index 2a24f8d4d1..02b994f8db 100644
--- a/modules/theora/video_stream_theora.cpp
+++ b/modules/theora/video_stream_theora.cpp
@@ -414,7 +414,8 @@ void VideoStreamPlaybackTheora::update(float p_delta) {
bool buffer_full = false;
/* if there's pending, decoded audio, grab it */
- if ((ret = vorbis_synthesis_pcmout(&vd, &pcm)) > 0) {
+ ret = vorbis_synthesis_pcmout(&vd, &pcm);
+ if (ret > 0) {
const int AUXBUF_LEN = 4096;
int to_read = ret;
diff --git a/modules/visual_script/visual_script.h b/modules/visual_script/visual_script.h
index b2e7a6aa27..297e9e510f 100644
--- a/modules/visual_script/visual_script.h
+++ b/modules/visual_script/visual_script.h
@@ -571,7 +571,6 @@ public:
virtual bool has_named_classes() const;
virtual int find_function(const String &p_function, const String &p_code) const;
virtual String make_function(const String &p_class, const String &p_name, const PoolStringArray &p_args) const;
- virtual Error open_in_external_editor(const Ref<Script> &p_script, int p_line, int p_col) { return ERR_UNAVAILABLE; }
virtual void auto_indent_code(String &p_code, int p_from_line, int p_to_line) const;
virtual void add_global_constant(const StringName &p_variable, const Variant &p_value);
diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp
index 8386687c9f..37bd730d08 100644
--- a/modules/visual_script/visual_script_editor.cpp
+++ b/modules/visual_script/visual_script_editor.cpp
@@ -523,7 +523,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
if (Object::cast_to<VisualScriptExpression>(*node)) {
Ref<VisualScriptComment> vsc = node;
gnode->set_comment(true);
- gnode->set_resizeable(true);
+ gnode->set_resizable(true);
gnode->set_custom_minimum_size(vsc->get_size() * EDSCALE);
gnode->connect("resize_request", this, "_comment_node_resized", varray(E->get()));
}
diff --git a/platform/javascript/SCsub b/platform/javascript/SCsub
index b804863ee1..e282041745 100644
--- a/platform/javascript/SCsub
+++ b/platform/javascript/SCsub
@@ -20,33 +20,32 @@ for x in javascript_files:
javascript_objects.append(env_javascript.Object(x))
env.Append(LINKFLAGS=["-s", "EXPORTED_FUNCTIONS=\"['_main','_audio_server_mix_function','_main_after_fs_sync','_send_notification']\""])
-env.Append(LINKFLAGS=["--shell-file", '"platform/javascript/godot_shell.html"'])
# output file name without file extension
basename = "godot" + env["PROGSUFFIX"]
target_dir = env.Dir("#bin")
-js_file = target_dir.File(basename + ".js")
-implicit_targets = [js_file]
zip_dir = target_dir.Dir('.javascript_zip')
-zip_files = env.InstallAs([zip_dir.File("godot.js"), zip_dir.File("godotfs.js")], [js_file, "#misc/dist/html_fs/godotfs.js"])
+zip_files = env.InstallAs(zip_dir.File('godot.html'), '#misc/dist/html/default.html')
+implicit_targets = []
if env['wasm'] == 'yes':
- wasm_file = target_dir.File(basename+'.wasm')
- implicit_targets.append(wasm_file)
- zip_files.append(InstallAs(zip_dir.File('godot.wasm'), wasm_file))
+ wasm = target_dir.File(basename + '.wasm')
+ implicit_targets.append(wasm)
+ zip_files.append(InstallAs(zip_dir.File('godot.wasm'), wasm))
+ prejs = env.File('pre_wasm.js')
else:
- asmjs_files = [target_dir.File(basename+'.asm.js'), target_dir.File(basename+'.html.mem')]
- zip_files.append(InstallAs([zip_dir.File('godot.asm.js'), zip_dir.File('godot.mem')], asmjs_files))
+ asmjs_files = [target_dir.File(basename + '.asm.js'), target_dir.File(basename + '.js.mem')]
implicit_targets.extend(asmjs_files)
+ zip_files.append(InstallAs([zip_dir.File('godot.asm.js'), zip_dir.File('godot.mem')], asmjs_files))
+ prejs = env.File('pre_asmjs.js')
-# HTML file must be the first target in the list
-html_file = env.Program(["#bin/godot"] + implicit_targets, javascript_objects, PROGSUFFIX=env["PROGSUFFIX"]+".html")[0]
-Depends(html_file, "godot_shell.html")
+js = env.Program(['#bin/godot'] + implicit_targets, javascript_objects, PROGSUFFIX=env['PROGSUFFIX'] + '.js')[0];
+zip_files.append(InstallAs(zip_dir.File('godot.js'), js))
-# Emscripten hardcodes file names, so replace common base name with
-# placeholder while leaving extension; also change `.html.mem` to just `.mem`
-fixup_html = env.Substfile(html_file, SUBST_DICT=[(basename, '$$GODOT_BASE'), ('.html.mem', '.mem')], SUBSTFILESUFFIX='.fixup.html')
+postjs = env.File('engine.js')
+env.Depends(js, [prejs, postjs])
+env.Append(LINKFLAGS=['--pre-js', prejs.path])
+env.Append(LINKFLAGS=['--post-js', postjs.path])
-zip_files.append(InstallAs(zip_dir.File('godot.html'), fixup_html))
-Zip('#bin/godot', zip_files, ZIPSUFFIX=env['PROGSUFFIX']+env['ZIPSUFFIX'], ZIPROOT=zip_dir, ZIPCOMSTR="Archving $SOURCES as $TARGET")
+Zip('#bin/godot', zip_files, ZIPSUFFIX=env['PROGSUFFIX'] + env['ZIPSUFFIX'], ZIPROOT=zip_dir, ZIPCOMSTR="Archving $SOURCES as $TARGET")
diff --git a/platform/javascript/detect.py b/platform/javascript/detect.py
index 5f066f1b15..bea8f156af 100644
--- a/platform/javascript/detect.py
+++ b/platform/javascript/detect.py
@@ -100,6 +100,7 @@ def configure(env):
## Link flags
+ env.Append(LINKFLAGS=['-s', 'EXTRA_EXPORTED_RUNTIME_METHODS="[\'FS\']"'])
env.Append(LINKFLAGS=['-s', 'USE_WEBGL2=1'])
if (env['wasm'] == 'yes'):
@@ -112,6 +113,7 @@ def configure(env):
else:
env.Append(LINKFLAGS=['-s', 'ASM_JS=1'])
env.Append(LINKFLAGS=['--separate-asm'])
+ env.Append(LINKFLAGS=['--memory-init-file', '1'])
# TODO: Move that to opus module's config
if("module_opus_enabled" in env and env["module_opus_enabled"] != "no"):
diff --git a/platform/javascript/engine.js b/platform/javascript/engine.js
new file mode 100644
index 0000000000..552f5a7e02
--- /dev/null
+++ b/platform/javascript/engine.js
@@ -0,0 +1,366 @@
+ return Module;
+ },
+};
+
+(function() {
+ var engine = Engine;
+
+ var USING_WASM = engine.USING_WASM;
+ var DOWNLOAD_ATTEMPTS_MAX = 4;
+
+ var basePath = null;
+ var engineLoadPromise = null;
+
+ var loadingFiles = {};
+
+ function getBasePath(path) {
+
+ if (path.endsWith('/'))
+ path = path.slice(0, -1);
+ if (path.lastIndexOf('.') > path.lastIndexOf('/'))
+ path = path.slice(0, path.lastIndexOf('.'));
+ return path;
+ }
+
+ function getBaseName(path) {
+
+ path = getBasePath(path);
+ return path.slice(path.lastIndexOf('/') + 1);
+ }
+
+ Engine = function Engine() {
+
+ this.rtenv = null;
+
+ var gameInitPromise = null;
+ var unloadAfterInit = true;
+ var memorySize = 268435456;
+
+ var progressFunc = null;
+ var pckProgressTracker = {};
+ var lastProgress = { loaded: 0, total: 0 };
+
+ var canvas = null;
+ var stdout = null;
+ var stderr = null;
+
+ this.initGame = function(mainPack) {
+
+ if (!gameInitPromise) {
+
+ if (mainPack === undefined) {
+ if (basePath !== null) {
+ mainPack = basePath + '.pck';
+ } else {
+ return Promise.reject(new Error("No main pack to load specified"));
+ }
+ }
+ if (basePath === null)
+ basePath = getBasePath(mainPack);
+
+ gameInitPromise = Engine.initEngine().then(
+ instantiate.bind(this)
+ );
+ var gameLoadPromise = loadPromise(mainPack, pckProgressTracker).then(function(xhr) { return xhr.response; });
+ gameInitPromise = Promise.all([gameLoadPromise, gameInitPromise]).then(function(values) {
+ // resolve with pck
+ return new Uint8Array(values[0]);
+ });
+ if (unloadAfterInit)
+ gameInitPromise.then(Engine.unloadEngine);
+ requestAnimationFrame(animateProgress);
+ }
+ return gameInitPromise;
+ };
+
+ function instantiate(initializer) {
+
+ var rtenvOpts = {
+ noInitialRun: true,
+ thisProgram: getBaseName(basePath),
+ engine: this,
+ };
+ if (typeof stdout === 'function')
+ rtenvOpts.print = stdout;
+ if (typeof stderr === 'function')
+ rtenvOpts.printErr = stderr;
+ if (typeof WebAssembly === 'object' && initializer instanceof WebAssembly.Module) {
+ rtenvOpts.instantiateWasm = function(imports, onSuccess) {
+ WebAssembly.instantiate(initializer, imports).then(function(result) {
+ onSuccess(result);
+ });
+ return {};
+ };
+ } else if (initializer.asm && initializer.mem) {
+ rtenvOpts.asm = initializer.asm;
+ rtenvOpts.memoryInitializerRequest = initializer.mem;
+ rtenvOpts.TOTAL_MEMORY = memorySize;
+ } else {
+ throw new Error("Invalid initializer");
+ }
+
+ return new Promise(function(resolve, reject) {
+ rtenvOpts.onRuntimeInitialized = resolve;
+ rtenvOpts.onAbort = reject;
+ rtenvOpts.engine.rtenv = Engine.RuntimeEnvironment(rtenvOpts);
+ });
+ }
+
+ this.start = function(mainPack) {
+
+ return this.initGame(mainPack).then(synchronousStart.bind(this));
+ };
+
+ function synchronousStart(pckView) {
+ // TODO don't expect canvas when runninng as cli tool
+ if (canvas instanceof HTMLCanvasElement) {
+ this.rtenv.canvas = canvas;
+ } else {
+ var firstCanvas = document.getElementsByTagName('canvas')[0];
+ if (firstCanvas instanceof HTMLCanvasElement) {
+ this.rtenv.canvas = firstCanvas;
+ } else {
+ throw new Error("No canvas found");
+ }
+ }
+
+ var actualCanvas = this.rtenv.canvas;
+ var context = false;
+ try {
+ context = actualCanvas.getContext('webgl2') || actualCanvas.getContext('experimental-webgl2');
+ } catch (e) {}
+ if (!context) {
+ throw new Error("WebGL 2 not available");
+ }
+
+ // canvas can grab focus on click
+ if (actualCanvas.tabIndex < 0) {
+ actualCanvas.tabIndex = 0;
+ }
+ // necessary to calculate cursor coordinates correctly
+ actualCanvas.style.padding = 0;
+ actualCanvas.style.borderWidth = 0;
+ actualCanvas.style.borderStyle = 'none';
+ // until context restoration is implemented
+ actualCanvas.addEventListener('webglcontextlost', function(ev) {
+ alert("WebGL context lost, please reload the page");
+ ev.preventDefault();
+ }, false);
+
+ this.rtenv.FS.createDataFile('/', this.rtenv.thisProgram + '.pck', pckView, true, true, true);
+ gameInitPromise = null;
+ this.rtenv.callMain();
+ }
+
+ this.setProgressFunc = function(func) {
+ progressFunc = func;
+ };
+
+ function animateProgress() {
+
+ var loaded = 0;
+ var total = 0;
+ var totalIsValid = true;
+ var progressIsFinal = true;
+
+ [loadingFiles, pckProgressTracker].forEach(function(tracker) {
+ Object.keys(tracker).forEach(function(file) {
+ if (!tracker[file].final)
+ progressIsFinal = false;
+ if (!totalIsValid || tracker[file].total === 0) {
+ totalIsValid = false;
+ total = 0;
+ } else {
+ total += tracker[file].total;
+ }
+ loaded += tracker[file].loaded;
+ });
+ });
+ if (loaded !== lastProgress.loaded || total !== lastProgress.total) {
+ lastProgress.loaded = loaded;
+ lastProgress.total = total;
+ if (typeof progressFunc === 'function')
+ progressFunc(loaded, total);
+ }
+ if (!progressIsFinal)
+ requestAnimationFrame(animateProgress);
+ }
+
+ this.setCanvas = function(elem) {
+ canvas = elem;
+ };
+
+ this.setAsmjsMemorySize = function(size) {
+ memorySize = size;
+ };
+
+ this.setUnloadAfterInit = function(enabled) {
+
+ if (enabled && !unloadAfterInit && gameInitPromise) {
+ gameInitPromise.then(Engine.unloadEngine);
+ }
+ unloadAfterInit = enabled;
+ };
+
+ this.setStdoutFunc = function(func) {
+
+ var print = function(text) {
+ if (arguments.length > 1) {
+ text = Array.prototype.slice.call(arguments).join(" ");
+ }
+ func(text);
+ };
+ if (this.rtenv)
+ this.rtenv.print = print;
+ stdout = print;
+ };
+
+ this.setStderrFunc = function(func) {
+
+ var printErr = function(text) {
+ if (arguments.length > 1)
+ text = Array.prototype.slice.call(arguments).join(" ");
+ func(text);
+ };
+ if (this.rtenv)
+ this.rtenv.printErr = printErr;
+ stderr = printErr;
+ };
+
+
+ }; // Engine()
+
+ Engine.RuntimeEnvironment = engine.RuntimeEnvironment;
+
+ Engine.initEngine = function(newBasePath) {
+
+ if (newBasePath !== undefined) basePath = getBasePath(newBasePath);
+ if (engineLoadPromise === null) {
+ if (USING_WASM) {
+ if (typeof WebAssembly !== 'object')
+ return Promise.reject(new Error("Browser doesn't support WebAssembly"));
+ // TODO cache/retrieve module to/from idb
+ engineLoadPromise = loadPromise(basePath + '.wasm').then(function(xhr) {
+ return WebAssembly.compile(xhr.response);
+ });
+ } else {
+ var asmjsPromise = loadPromise(basePath + '.asm.js').then(function(xhr) {
+ return asmjsModulePromise(xhr.response);
+ });
+ var memPromise = loadPromise(basePath + '.mem');
+ engineLoadPromise = Promise.all([asmjsPromise, memPromise]).then(function(values) {
+ return { asm: values[0], mem: values[1] };
+ });
+ }
+ engineLoadPromise = engineLoadPromise.catch(function(err) {
+ engineLoadPromise = null;
+ throw err;
+ });
+ }
+ return engineLoadPromise;
+ };
+
+ function asmjsModulePromise(module) {
+ var elem = document.createElement('script');
+ var script = new Blob([
+ 'Engine.asm = (function() { var Module = {};',
+ module,
+ 'return Module.asm; })();'
+ ]);
+ var url = URL.createObjectURL(script);
+ elem.src = url;
+ return new Promise(function(resolve, reject) {
+ elem.addEventListener('load', function() {
+ URL.revokeObjectURL(url);
+ var asm = Engine.asm;
+ Engine.asm = undefined;
+ setTimeout(function() {
+ // delay to reclaim compilation memory
+ resolve(asm);
+ }, 1);
+ });
+ elem.addEventListener('error', function() {
+ URL.revokeObjectURL(url);
+ reject("asm.js faiilure");
+ });
+ document.body.appendChild(elem);
+ });
+ }
+
+ Engine.unloadEngine = function() {
+ engineLoadPromise = null;
+ };
+
+ function loadPromise(file, tracker) {
+ if (tracker === undefined)
+ tracker = loadingFiles;
+ return new Promise(function(resolve, reject) {
+ loadXHR(resolve, reject, file, tracker);
+ });
+ }
+
+ function loadXHR(resolve, reject, file, tracker) {
+
+ var xhr = new XMLHttpRequest;
+ xhr.open('GET', file);
+ if (!file.endsWith('.js')) {
+ xhr.responseType = 'arraybuffer';
+ }
+ ['loadstart', 'progress', 'load', 'error', 'timeout', 'abort'].forEach(function(ev) {
+ xhr.addEventListener(ev, onXHREvent.bind(xhr, resolve, reject, file, tracker));
+ });
+ xhr.send();
+ }
+
+ function onXHREvent(resolve, reject, file, tracker, ev) {
+
+ if (this.status >= 400) {
+
+ if (this.status < 500 || ++tracker[file].attempts >= DOWNLOAD_ATTEMPTS_MAX) {
+ reject(new Error("Failed loading file '" + file + "': " + this.statusText));
+ this.abort();
+ return;
+ } else {
+ loadXHR(resolve, reject, file);
+ }
+ }
+
+ switch (ev.type) {
+ case 'loadstart':
+ if (tracker[file] === undefined) {
+ tracker[file] = {
+ total: ev.total,
+ loaded: ev.loaded,
+ attempts: 0,
+ final: false,
+ };
+ }
+ break;
+
+ case 'progress':
+ tracker[file].loaded = ev.loaded;
+ tracker[file].total = ev.total;
+ break;
+
+ case 'load':
+ tracker[file].final = true;
+ resolve(this);
+ break;
+
+ case 'error':
+ case 'timeout':
+ if (++tracker[file].attempts >= DOWNLOAD_ATTEMPTS_MAX) {
+ tracker[file].final = true;
+ reject(new Error("Failed loading file '" + file + "'"));
+ } else {
+ loadXHR(resolve, reject, file);
+ }
+ break;
+
+ case 'abort':
+ tracker[file].final = true;
+ reject(new Error("Loading file '" + file + "' was aborted."));
+ break;
+ }
+ }
+})();
diff --git a/platform/javascript/export/export.cpp b/platform/javascript/export/export.cpp
index 5a161dd0ab..4a97bf4c32 100644
--- a/platform/javascript/export/export.cpp
+++ b/platform/javascript/export/export.cpp
@@ -100,8 +100,8 @@ void EditorExportPlatformJavaScript::_fix_html(Vector<uint8_t> &p_html, const Re
for (int i = 0; i < lines.size(); i++) {
String current_line = lines[i];
- current_line = current_line.replace("$GODOT_TMEM", itos(memory_mb * 1024 * 1024));
- current_line = current_line.replace("$GODOT_BASE", p_name);
+ current_line = current_line.replace("$GODOT_TOTAL_MEMORY", itos(memory_mb * 1024 * 1024));
+ current_line = current_line.replace("$GODOT_BASENAME", p_name);
current_line = current_line.replace("$GODOT_HEAD_INCLUDE", p_preset->get("html/head_include"));
current_line = current_line.replace("$GODOT_DEBUG_ENABLED", p_debug ? "true" : "false");
str_export += current_line + "\n";
@@ -114,28 +114,6 @@ void EditorExportPlatformJavaScript::_fix_html(Vector<uint8_t> &p_html, const Re
}
}
-void EditorExportPlatformJavaScript::_fix_fsloader_js(Vector<uint8_t> &p_js, const String &p_pack_name, uint64_t p_pack_size) {
-
- String str_template = String::utf8(reinterpret_cast<const char *>(p_js.ptr()), p_js.size());
- String str_export;
- Vector<String> lines = str_template.split("\n");
- for (int i = 0; i < lines.size(); i++) {
- if (lines[i].find("$GODOT_PACK_NAME") != -1) {
- str_export += lines[i].replace("$GODOT_PACK_NAME", p_pack_name);
- } else if (lines[i].find("$GODOT_PACK_SIZE") != -1) {
- str_export += lines[i].replace("$GODOT_PACK_SIZE", itos(p_pack_size));
- } else {
- str_export += lines[i] + "\n";
- }
- }
-
- CharString cs = str_export.utf8();
- p_js.resize(cs.length());
- for (int i = 0; i < cs.length(); i++) {
- p_js[i] = cs[i];
- }
-}
-
void EditorExportPlatformJavaScript::get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) {
if (p_preset->get("texture_format/s3tc")) {
@@ -286,10 +264,6 @@ Error EditorExportPlatformJavaScript::export_project(const Ref<EditorExportPrese
_fix_html(data, p_preset, p_path.get_file().get_basename(), p_debug);
file = p_path.get_file();
- } else if (file == "godotfs.js") {
-
- _fix_fsloader_js(data, pck_path.get_file(), pack_size);
- file = p_path.get_file().get_basename() + "fs.js";
} else if (file == "godot.js") {
file = p_path.get_file().get_basename() + ".js";
diff --git a/platform/javascript/godot_shell.html b/platform/javascript/godot_shell.html
deleted file mode 100644
index ee7399a129..0000000000
--- a/platform/javascript/godot_shell.html
+++ /dev/null
@@ -1,347 +0,0 @@
-<!DOCTYPE html>
-<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
-<head>
- <meta charset="utf-8" />
- <title></title>
- <style type="text/css">
- body {
- margin: 0;
- border: 0 none;
- padding: 0;
- text-align: center;
- background-color: #222226;
- font-family: 'Droid Sans', Arial, sans-serif;
- }
-
-
- /* Godot Engine default theme style
- * ================================ */
-
- .godot {
- color: #e0e0e0;
- background-color: #3b3943;
- background-image: linear-gradient(to bottom, #403e48, #35333c);
- border: 1px solid #45434e;
- box-shadow: 0 0 1px 1px #2f2d35;
- }
-
- button.godot {
- font-family: 'Droid Sans', Arial, sans-serif; /* override user agent style */
- padding: 1px 5px;
- background-color: #37353f;
- background-image: linear-gradient(to bottom, #413e49, #3a3842);
- border: 1px solid #514f5d;
- border-radius: 1px;
- box-shadow: 0 0 1px 1px #2a2930;
- }
-
- button.godot:hover {
- color: #f0f0f0;
- background-color: #44414e;
- background-image: linear-gradient(to bottom, #494652, #423f4c);
- border: 1px solid #5a5667;
- box-shadow: 0 0 1px 1px #26252b;
- }
-
- button.godot:active {
- color: #fff;
- background-color: #3e3b46;
- background-image: linear-gradient(to bottom, #36343d, #413e49);
- border: 1px solid #4f4c59;
- box-shadow: 0 0 1px 1px #26252b;
- }
-
- button.godot:disabled {
- color: rgba(230, 230, 230, 0.2);
- background-color: #3d3d3d;
- background-image: linear-gradient(to bottom, #434343, #393939);
- border: 1px solid #474747;
- box-shadow: 0 0 1px 1px #2d2b33;
- }
-
-
- /* Canvas / wrapper
- * ================ */
-
- #container {
- display: inline-block; /* scale with canvas */
- vertical-align: top; /* prevent extra height */
- position: relative; /* root for absolutely positioned overlay */
- margin: 0;
- border: 0 none;
- padding: 0;
- background-color: #0c0c0c;
- }
-
- #canvas {
- display: block;
- margin: 0 auto;
- /* canvas must have border and padding set to zero to
- * calculate cursor coordinates correctly */
- border: 0 none;
- padding: 0;
- color: white;
- }
-
- #canvas:focus {
- outline: none;
- }
-
-
- /* Status display
- * ============== */
-
- #status-container {
- position: absolute;
- left: 0;
- top: 0;
- right: 0;
- bottom: 0;
- display: flex;
- justify-content: center;
- align-items: center;
- /* don't consume click events - make children visible explicitly */
- visibility: hidden;
- }
-
- #status {
- line-height: 1.3;
- cursor: pointer;
- visibility: visible;
- padding: 4px 6px;
- }
-
-
- /* Debug output
- * ============ */
-
- #output-panel {
- display: none;
- max-width: 700px;
- font-size: small;
- margin: 6px auto 0;
- padding: 0 4px 4px;
- text-align: left;
- line-height: 2.2;
- }
-
- #output-header {
- display: flex;
- justify-content: space-between;
- align-items: center;
- }
-
- #output-container {
- padding: 6px;
- background-color: #2c2a32;
- box-shadow: inset 0 0 1px 1px #232127;
- color: #bbb;
- }
-
- #output-scroll {
- line-height: 1;
- height: 12em;
- overflow-y: scroll;
- white-space: pre-wrap;
- font-size: small;
- font-family: "Lucida Console", Monaco, monospace;
- }
- </style>
-$GODOT_HEAD_INCLUDE
-</head>
-<body>
- <div id="container">
- <canvas id="canvas" width="640" height="480" tabindex="0" oncontextmenu="event.preventDefault();">
- HTML5 canvas appears to be unsupported in the current browser.<br />
- Please try updating or use a different browser.
- </canvas>
- <div id="status-container">
- <span id="status" class="godot" onclick="this.style.visibility='hidden';">Downloading page...</span>
- </div>
- </div>
- <div id="output-panel" class="godot">
- <div id="output-header">
- Output:
- <button class="godot" type="button" autocomplete="off" onclick="Presentation.clearOutput();">Clear</button>
- </div>
- <div id="output-container"><div id="output-scroll"></div></div>
- </div>
-
- <!-- Scripts -->
- <script type="text/javascript">//<![CDATA[
- var Presentation = (function() {
- var statusElement = document.getElementById("status");
- var canvasElement = document.getElementById("canvas");
-
- var presentation = {
- postRun: [],
- setStatusVisible: function setStatusVisible(visible) {
- statusElement.style.visibility = (visible ? "visible" : "hidden");
- },
- setStatus: function setStatus(text) {
- if (text.length === 0) {
- // emscripten sets empty string as status after "Running..."
- // per timeout, but another status may have been set by then
- if (Presentation.setStatus.lastText === "Running...")
- Presentation.setStatusVisible(false);
- return;
- }
- Presentation.setStatus.lastText = text;
- while (statusElement.lastChild) {
- statusElement.removeChild(statusElement.lastChild);
- }
- var lines = text.split("\n");
- lines.forEach(function(line, index) {
- statusElement.appendChild(document.createTextNode(line));
- statusElement.appendChild(document.createElement("br"));
- });
- var closeNote = document.createElement("span");
- closeNote.style.fontSize = "small";
- closeNote.textContent = "click to close";
- statusElement.appendChild(closeNote);
- Presentation.setStatusVisible(true);
- },
- isWebGL2Available: function isWebGL2Available() {
- var context;
- try {
- context = canvasElement.getContext("webgl2") || canvasElement.getContext("experimental-webgl2");
- } catch (e) {}
- return !!context;
- },
- };
-
- window.onerror = function(event) { presentation.setStatus("Failure during start-up\nSee JavaScript console") };
-
- if ($GODOT_DEBUG_ENABLED) { // debugging enabled
- var outputRoot = document.getElementById("output-panel");
- var outputElement = document.getElementById("output-scroll");
- const maxOutputMessages = 400;
-
- presentation.setOutputVisible = function setOutputVisible(visible) {
- outputRoot.style.display = (visible ? "block" : "none");
- };
- presentation.clearOutput = function clearOutput() {
- while (outputElement.firstChild) {
- outputElement.firstChild.remove();
- }
- };
-
- presentation.setOutputVisible(true);
-
- presentation.print = function print(text) {
- if (arguments.length > 1) {
- text = Array.prototype.slice.call(arguments).join(" ");
- }
- if (text.length <= 0) return;
- while (outputElement.childElementCount >= maxOutputMessages) {
- outputElement.firstChild.remove();
- }
- var msg = document.createElement("div");
- if (String.prototype.trim.call(text).startsWith("**ERROR**")
- || String.prototype.trim.call(text).startsWith("**EXCEPTION**")) {
- msg.style.color = "#d44";
- } else if (String.prototype.trim.call(text).startsWith("**WARNING**")) {
- msg.style.color = "#ccc000";
- } else if (String.prototype.trim.call(text).startsWith("**SCRIPT ERROR**")) {
- msg.style.color = "#c6d";
- }
- msg.textContent = text;
- var scrollToBottom = outputElement.scrollHeight - (outputElement.clientHeight + outputElement.scrollTop) < 10;
- outputElement.appendChild(msg);
- if (scrollToBottom) {
- outputElement.scrollTop = outputElement.scrollHeight;
- }
- };
-
- presentation.postRun.push(function() {
- window.onerror = function(event) { presentation.print("**EXCEPTION**:", event) };
- });
-
- } else {
- presentation.postRun.push(function() { window.onerror = null; });
- }
-
- return presentation;
- })();
-
- // Emscripten interface
- var Module = (function() {
- const BASE_NAME = '$GODOT_BASE';
- var module = {
- thisProgram: BASE_NAME,
- wasmBinaryFile: BASE_NAME + '.wasm',
- TOTAL_MEMORY: $GODOT_TMEM,
- print: function print(text) {
- if (arguments.length > 1) {
- text = Array.prototype.slice.call(arguments).join(" ");
- }
- console.log(text);
- if (typeof Presentation !== "undefined" && typeof Presentation.print === "function") {
- Presentation.print(text);
- }
- },
- printErr: function printErr(text) {
- if (arguments.length > 1) {
- text = Array.prototype.slice.call(arguments).join(" ");
- }
- console.error(text);
- if (typeof Presentation !== "undefined" && typeof Presentation.print === "function") {
- Presentation.print("**ERROR**:", text)
- }
- },
- canvas: document.getElementById("canvas"),
- setStatus: function setStatus(text) {
- var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/);
- var now = Date.now();
- if (m) {
- if (now - Date.now() < 30) // if this is a progress update, skip it if too soon
- return;
- text = m[1];
- }
- if (typeof Presentation !== "undefined" && typeof Presentation.setStatus == "function") {
- Presentation.setStatus(text);
- }
- }
- };
-
- // As a default initial behavior, pop up an alert when WebGL context is lost. To make your
- // application robust, you may want to override this behavior before shipping!
- // See http://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15.2
- module.canvas.addEventListener("webglcontextlost", function(e) { alert("WebGL context lost. Plase reload the page."); e.preventDefault(); }, false);
-
- if (typeof Presentation !== "undefined" && Presentation.postRun instanceof Array) {
- module.postRun = Presentation.postRun;
- }
-
- return module;
- })();
-
- if (!Presentation.isWebGL2Available()) {
- Presentation.setStatus("WebGL 2 appears to be unsupported.\nPlease update browser and drivers.");
- Presentation.preventLoading = true;
- } else {
- Presentation.setStatus("Downloading...");
- }
-
- if (Presentation.preventLoading) {
- // prevent *fs.js and Emscripten's SCRIPT placeholder from loading any files
- Presentation._XHR_send = XMLHttpRequest.prototype.send;
- XMLHttpRequest.prototype.send = function() {};
- Presentation._Node_appendChild = Node.prototype.appendChild;
- Node.prototype.appendChild = function(node) {
- if (!(node instanceof HTMLScriptElement)) {
- return Presentation._Node_appendChild.call(this, node);
- }
- }
- }
- //]]></script>
- <script type="text/javascript" src="$GODOT_BASEfs.js"></script>
-{{{ SCRIPT }}}
- <script type="text/javascript">
- if (Presentation.preventLoading) {
- XMLHttpRequest.prototype.send = Presentation._XHR_send;
- Node.prototype.appendChild = Presentation._Node_appendChild;
- }
- </script>
-</body>
-</html>
diff --git a/platform/javascript/pre_asmjs.js b/platform/javascript/pre_asmjs.js
new file mode 100644
index 0000000000..3c497721b6
--- /dev/null
+++ b/platform/javascript/pre_asmjs.js
@@ -0,0 +1,3 @@
+var Engine = {
+ USING_WASM: false,
+ RuntimeEnvironment: function(Module) {
diff --git a/platform/javascript/pre_wasm.js b/platform/javascript/pre_wasm.js
new file mode 100644
index 0000000000..be4383c8c9
--- /dev/null
+++ b/platform/javascript/pre_wasm.js
@@ -0,0 +1,3 @@
+var Engine = {
+ USING_WASM: true,
+ RuntimeEnvironment: function(Module) {
diff --git a/platform/windows/context_gl_win.cpp b/platform/windows/context_gl_win.cpp
index 328b987f1f..8640f27699 100644
--- a/platform/windows/context_gl_win.cpp
+++ b/platform/windows/context_gl_win.cpp
@@ -130,24 +130,28 @@ Error ContextGL_Win::initialize() {
0, 0, 0 // Layer Masks Ignored
};
- if (!(hDC = GetDC(hWnd))) {
+ hDC = GetDC(hWnd);
+ if (!hDC) {
MessageBox(NULL, "Can't Create A GL Device Context.", "ERROR", MB_OK | MB_ICONEXCLAMATION);
return ERR_CANT_CREATE; // Return FALSE
}
- if (!(pixel_format = ChoosePixelFormat(hDC, &pfd))) // Did Windows Find A Matching Pixel Format?
+ pixel_format = ChoosePixelFormat(hDC, &pfd);
+ if (!pixel_format) // Did Windows Find A Matching Pixel Format?
{
MessageBox(NULL, "Can't Find A Suitable pixel_format.", "ERROR", MB_OK | MB_ICONEXCLAMATION);
return ERR_CANT_CREATE; // Return FALSE
}
- if (!SetPixelFormat(hDC, pixel_format, &pfd)) // Are We Able To Set The Pixel Format?
+ BOOL ret = SetPixelFormat(hDC, pixel_format, &pfd);
+ if (!ret) // Are We Able To Set The Pixel Format?
{
MessageBox(NULL, "Can't Set The pixel_format.", "ERROR", MB_OK | MB_ICONEXCLAMATION);
return ERR_CANT_CREATE; // Return FALSE
}
- if (!(hRC = wglCreateContext(hDC))) // Are We Able To Get A Rendering Context?
+ hRC = wglCreateContext(hDC);
+ if (!hRC) // Are We Able To Get A Rendering Context?
{
MessageBox(NULL, "Can't Create A Temporary GL Rendering Context.", "ERROR", MB_OK | MB_ICONEXCLAMATION);
return ERR_CANT_CREATE; // Return FALSE
@@ -175,8 +179,8 @@ Error ContextGL_Win::initialize() {
return ERR_CANT_CREATE;
}
- HGLRC new_hRC;
- if (!(new_hRC = wglCreateContextAttribsARB(hDC, 0, attribs))) {
+ HGLRC new_hRC = wglCreateContextAttribsARB(hDC, 0, attribs);
+ if (!new_hRC) {
wglDeleteContext(hRC);
MessageBox(NULL, "Can't Create An OpenGL 3.3 Rendering Context.", "ERROR", MB_OK | MB_ICONEXCLAMATION);
return ERR_CANT_CREATE; // Return false
diff --git a/platform/windows/joypad.cpp b/platform/windows/joypad.cpp
index 00cfa812de..0c7358f499 100644
--- a/platform/windows/joypad.cpp
+++ b/platform/windows/joypad.cpp
@@ -379,7 +379,9 @@ void JoypadWindows::process_joypads() {
IDirectInputDevice8_Acquire(joy->di_joy);
joy->di_joy->Poll();
}
- if (FAILED(hr = joy->di_joy->GetDeviceState(sizeof(DIJOYSTATE2), &js))) {
+
+ hr = joy->di_joy->GetDeviceState(sizeof(DIJOYSTATE2), &js);
+ if (FAILED(hr)) {
//printf("failed to read joy #%d\n", i);
continue;
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp
index deb9c25576..5814d883cd 100644
--- a/platform/windows/os_windows.cpp
+++ b/platform/windows/os_windows.cpp
@@ -996,7 +996,16 @@ void OS_Windows::initialize(const VideoMode &p_desired, int p_video_driver, int
video_mode.fullscreen = false;
} else {
- if (!(hWnd = CreateWindowExW(dwExStyle, L"Engine", L"", dwStyle | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, (GetSystemMetrics(SM_CXSCREEN) - WindowRect.right) / 2, (GetSystemMetrics(SM_CYSCREEN) - WindowRect.bottom) / 2, WindowRect.right - WindowRect.left, WindowRect.bottom - WindowRect.top, NULL, NULL, hInstance, NULL))) {
+ hWnd = CreateWindowExW(
+ dwExStyle,
+ L"Engine", L"",
+ dwStyle | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
+ (GetSystemMetrics(SM_CXSCREEN) - WindowRect.right) / 2,
+ (GetSystemMetrics(SM_CYSCREEN) - WindowRect.bottom) / 2,
+ WindowRect.right - WindowRect.left,
+ WindowRect.bottom - WindowRect.top,
+ NULL, NULL, hInstance, NULL);
+ if (!hWnd) {
MessageBoxW(NULL, L"Window Creation Error.", L"ERROR", MB_OK | MB_ICONEXCLAMATION);
return; // Return FALSE
}
diff --git a/scene/2d/area_2d.cpp b/scene/2d/area_2d.cpp
index 1124904963..9fc6c8d23a 100644
--- a/scene/2d/area_2d.cpp
+++ b/scene/2d/area_2d.cpp
@@ -596,7 +596,7 @@ void Area2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("_area_enter_tree", "id"), &Area2D::_area_enter_tree);
ClassDB::bind_method(D_METHOD("_area_exit_tree", "id"), &Area2D::_area_exit_tree);
- ClassDB::bind_method(D_METHOD("set_space_override_mode", "enable"), &Area2D::set_space_override_mode);
+ ClassDB::bind_method(D_METHOD("set_space_override_mode", "space_override_mode"), &Area2D::set_space_override_mode);
ClassDB::bind_method(D_METHOD("get_space_override_mode"), &Area2D::get_space_override_mode);
ClassDB::bind_method(D_METHOD("set_gravity_is_point", "enable"), &Area2D::set_gravity_is_point);
@@ -680,6 +680,12 @@ void Area2D::_bind_methods() {
ADD_GROUP("Audio Bus", "audio_bus_");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "audio_bus_override"), "set_audio_bus_override", "is_overriding_audio_bus");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "audio_bus_name", PROPERTY_HINT_ENUM, ""), "set_audio_bus", "get_audio_bus");
+
+ BIND_ENUM_CONSTANT(SPACE_OVERRIDE_DISABLED);
+ BIND_ENUM_CONSTANT(SPACE_OVERRIDE_COMBINE);
+ BIND_ENUM_CONSTANT(SPACE_OVERRIDE_COMBINE_REPLACE);
+ BIND_ENUM_CONSTANT(SPACE_OVERRIDE_REPLACE);
+ BIND_ENUM_CONSTANT(SPACE_OVERRIDE_REPLACE_COMBINE);
}
Area2D::Area2D()
diff --git a/scene/2d/audio_stream_player_2d.cpp b/scene/2d/audio_stream_player_2d.cpp
index 39d3f2d6bf..d2a8e3315a 100644
--- a/scene/2d/audio_stream_player_2d.cpp
+++ b/scene/2d/audio_stream_player_2d.cpp
@@ -217,13 +217,15 @@ void AudioStreamPlayer2D::_notification(int p_what) {
setseek = setplay;
active = true;
setplay = -1;
- _change_notify("playing"); //update property in editor
+ //do not update, this makes it easier to animate (will shut off otherise)
+ //_change_notify("playing"); //update property in editor
}
//stop playing if no longer active
if (!active) {
set_fixed_process_internal(false);
- _change_notify("playing"); //update property in editor
+ //do not update, this makes it easier to animate (will shut off otherise)
+ //_change_notify("playing"); //update property in editor
emit_signal("finished");
}
}
@@ -252,8 +254,6 @@ void AudioStreamPlayer2D::set_stream(Ref<AudioStream> p_stream) {
stream.unref();
ERR_FAIL_COND(stream_playback.is_null());
}
-
-
}
Ref<AudioStream> AudioStreamPlayer2D::get_stream() const {
@@ -439,7 +439,7 @@ void AudioStreamPlayer2D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "stream", PROPERTY_HINT_RESOURCE_TYPE, "AudioStream"), "set_stream", "get_stream");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "volume_db", PROPERTY_HINT_RANGE, "-80,24"), "set_volume_db", "get_volume_db");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "playing", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "_set_playing", "_is_active");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "play", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "_set_playing", "_is_active");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "autoplay"), "set_autoplay", "is_autoplay_enabled");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "max_distance", PROPERTY_HINT_RANGE, "1,65536,1"), "set_max_distance", "get_max_distance");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "attenuation", PROPERTY_HINT_EXP_EASING), "set_attenuation", "get_attenuation");
@@ -447,7 +447,6 @@ void AudioStreamPlayer2D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "area_mask", PROPERTY_HINT_LAYERS_2D_PHYSICS), "set_area_mask", "get_area_mask");
ADD_SIGNAL(MethodInfo("finished"));
-
}
AudioStreamPlayer2D::AudioStreamPlayer2D() {
diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp
index 4f00966e75..a7c5d1adbb 100644
--- a/scene/2d/canvas_item.cpp
+++ b/scene/2d/canvas_item.cpp
@@ -37,6 +37,7 @@
#include "scene/resources/style_box.h"
#include "scene/resources/texture.h"
#include "scene/scene_string_names.h"
+#include "servers/visual/visual_server_raster.h"
#include "servers/visual_server.h"
Mutex *CanvasItemMaterial::material_mutex = NULL;
diff --git a/scene/2d/line_builder.cpp b/scene/2d/line_builder.cpp
index 1235013af4..53db30e3ce 100644
--- a/scene/2d/line_builder.cpp
+++ b/scene/2d/line_builder.cpp
@@ -173,13 +173,15 @@ void LineBuilder::build() {
strip_begin(pos_up0, pos_down0, color0, uvx0);
- // pos_up0 ------------- pos_up1 --------------------
- // | |
- // pos0 - - - - - - - - - pos1 - - - - - - - - - pos2
- // | |
- // pos_down0 ------------ pos_down1 ------------------
- //
- // i-1 i i+1
+ /*
+ * pos_up0 ------------- pos_up1 --------------------
+ * | |
+ * pos0 - - - - - - - - - pos1 - - - - - - - - - pos2
+ * | |
+ * pos_down0 ------------ pos_down1 ------------------
+ *
+ * i-1 i i+1
+ */
// http://labs.hyperandroid.com/tag/opengl-lines
// (not the same implementation but visuals help a lot)
@@ -206,17 +208,19 @@ void LineBuilder::build() {
inner_normal1 = -u1 * hw;
}
- // ---------------------------
- // /
- // 0 / 1
- // / /
- // --------------------x------ /
- // / / (here shown with orientation == DOWN)
- // / /
- // / /
- // / /
- // 2 /
- // /
+ /*
+ * ---------------------------
+ * /
+ * 0 / 1
+ * / /
+ * --------------------x------ /
+ * / / (here shown with orientation == DOWN)
+ * / /
+ * / /
+ * / /
+ * 2 /
+ * /
+ */
// Find inner intersection at the joint
Vector2 corner_pos_in, corner_pos_out;
@@ -315,13 +319,14 @@ void LineBuilder::build() {
// Add joint geometry
if (current_joint_mode != LINE_JOINT_SHARP) {
- // ________________ cbegin
- // / \
- // / \
- // ____________/_ _ _\ cend
- // | |
- // | |
- // | |
+ /* ________________ cbegin
+ * / \
+ * / \
+ * ____________/_ _ _\ cend
+ * | |
+ * | |
+ * | |
+ */
Vector2 cbegin, cend;
if (orientation == UP) {
diff --git a/scene/2d/path_2d.cpp b/scene/2d/path_2d.cpp
index 1d7bd8fc2a..9bd5576d91 100644
--- a/scene/2d/path_2d.cpp
+++ b/scene/2d/path_2d.cpp
@@ -137,7 +137,8 @@ void PathFollow2D::_notification(int p_what) {
case NOTIFICATION_ENTER_TREE: {
- if ((path = Object::cast_to<Path2D>(get_parent()))) {
+ path = Object::cast_to<Path2D>(get_parent());
+ if (path) {
_update_transform();
}
diff --git a/scene/3d/arvr_nodes.cpp b/scene/3d/arvr_nodes.cpp
index caf313190b..966dd88a2c 100644
--- a/scene/3d/arvr_nodes.cpp
+++ b/scene/3d/arvr_nodes.cpp
@@ -31,7 +31,6 @@
#include "arvr_nodes.h"
#include "core/os/input.h"
#include "servers/arvr/arvr_interface.h"
-#include "servers/arvr/arvr_positional_tracker.h"
#include "servers/arvr_server.h"
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -142,6 +141,7 @@ void ARVRController::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_joystick_axis", "axis"), &ARVRController::get_joystick_axis);
ClassDB::bind_method(D_METHOD("get_is_active"), &ARVRController::get_is_active);
+ ClassDB::bind_method(D_METHOD("get_hand"), &ARVRController::get_hand);
ADD_SIGNAL(MethodInfo("button_pressed", PropertyInfo(Variant::INT, "button")));
ADD_SIGNAL(MethodInfo("button_release", PropertyInfo(Variant::INT, "button")));
@@ -204,6 +204,19 @@ bool ARVRController::get_is_active() const {
return is_active;
};
+ARVRPositionalTracker::TrackerHand ARVRController::get_hand() const {
+ // get our ARVRServer
+ ARVRServer *arvr_server = ARVRServer::get_singleton();
+ ERR_FAIL_NULL_V(arvr_server, ARVRPositionalTracker::TRACKER_HAND_UNKNOWN);
+
+ ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, controller_id);
+ if (tracker == NULL) {
+ return ARVRPositionalTracker::TRACKER_HAND_UNKNOWN;
+ };
+
+ return tracker->get_hand();
+};
+
String ARVRController::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 4c14be71b5..5269ec0248 100644
--- a/scene/3d/arvr_nodes.h
+++ b/scene/3d/arvr_nodes.h
@@ -33,6 +33,7 @@
#include "scene/3d/camera.h"
#include "scene/3d/spatial.h"
+#include "servers/arvr/arvr_positional_tracker.h"
/**
@author Bastiaan Olij <mux213@gmail.com>
@@ -84,6 +85,7 @@ public:
float get_joystick_axis(int p_axis) const;
bool get_is_active() const;
+ ARVRPositionalTracker::TrackerHand get_hand() const;
String get_configuration_warning() const;
diff --git a/scene/3d/audio_stream_player_3d.cpp b/scene/3d/audio_stream_player_3d.cpp
index a69bec2fc8..2073ebf94e 100644
--- a/scene/3d/audio_stream_player_3d.cpp
+++ b/scene/3d/audio_stream_player_3d.cpp
@@ -530,13 +530,15 @@ void AudioStreamPlayer3D::_notification(int p_what) {
setseek = setplay;
active = true;
setplay = -1;
- _change_notify("playing"); //update property in editor
+ //do not update, this makes it easier to animate (will shut off otherise)
+ ///_change_notify("playing"); //update property in editor
}
//stop playing if no longer active
if (!active) {
set_fixed_process_internal(false);
- _change_notify("playing"); //update property in editor
+ //do not update, this makes it easier to animate (will shut off otherise)
+ //_change_notify("playing"); //update property in editor
emit_signal("finished");
}
}
@@ -877,7 +879,7 @@ void AudioStreamPlayer3D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::REAL, "unit_db", PROPERTY_HINT_RANGE, "-80,80"), "set_unit_db", "get_unit_db");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "unit_size", PROPERTY_HINT_RANGE, "0.1,100,0.1"), "set_unit_size", "get_unit_size");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "max_db", PROPERTY_HINT_RANGE, "-24,6"), "set_max_db", "get_max_db");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "playing", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "_set_playing", "_is_active");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "play", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "_set_playing", "_is_active");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "autoplay"), "set_autoplay", "is_autoplay_enabled");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "max_distance", PROPERTY_HINT_RANGE, "0,65536,1"), "set_max_distance", "get_max_distance");
ADD_PROPERTY(PropertyInfo(Variant::INT, "out_of_range_mode", PROPERTY_HINT_ENUM, "Mix,Pause"), "set_out_of_range_mode", "get_out_of_range_mode");
diff --git a/scene/3d/bone_attachment.cpp b/scene/3d/bone_attachment.cpp
index e1a5329fb0..2580b645e2 100644
--- a/scene/3d/bone_attachment.cpp
+++ b/scene/3d/bone_attachment.cpp
@@ -71,7 +71,8 @@ void BoneAttachment::_get_property_list(List<PropertyInfo> *p_list) const {
void BoneAttachment::_check_bind() {
- if (Skeleton *sk = Object::cast_to<Skeleton>(get_parent())) {
+ Skeleton *sk = Object::cast_to<Skeleton>(get_parent());
+ if (sk) {
int idx = sk->find_bone(bone_name);
if (idx != -1) {
@@ -86,7 +87,8 @@ void BoneAttachment::_check_unbind() {
if (bound) {
- if (Skeleton *sk = Object::cast_to<Skeleton>(get_parent())) {
+ Skeleton *sk = Object::cast_to<Skeleton>(get_parent());
+ if (sk) {
int idx = sk->find_bone(bone_name);
if (idx != -1) {
diff --git a/scene/3d/collision_shape.cpp b/scene/3d/collision_shape.cpp
index 5f1151f8e9..f49d89122d 100644
--- a/scene/3d/collision_shape.cpp
+++ b/scene/3d/collision_shape.cpp
@@ -50,7 +50,8 @@ void CollisionShape::make_convex_from_brothers() {
for (int i = 0; i < p->get_child_count(); i++) {
Node *n = p->get_child(i);
- if (MeshInstance *mi = Object::cast_to<MeshInstance>(n)) {
+ MeshInstance *mi = Object::cast_to<MeshInstance>(n);
+ if (mi) {
Ref<Mesh> m = mi->get_mesh();
if (m.is_valid()) {
diff --git a/scene/3d/gi_probe.cpp b/scene/3d/gi_probe.cpp
index bb54a43028..c2b5283b9c 100644
--- a/scene/3d/gi_probe.cpp
+++ b/scene/3d/gi_probe.cpp
@@ -1092,7 +1092,7 @@ void GIProbe::_plot_mesh(const Transform &p_xform, Ref<Mesh> &p_mesh, Baker *p_b
void GIProbe::_find_meshes(Node *p_at_node, Baker *p_baker) {
MeshInstance *mi = Object::cast_to<MeshInstance>(p_at_node);
- if (mi && mi->get_flag(GeometryInstance::FLAG_USE_BAKED_LIGHT)) {
+ if (mi && mi->get_flag(GeometryInstance::FLAG_USE_BAKED_LIGHT) && mi->is_visible_in_tree()) {
Ref<Mesh> mesh = mi->get_mesh();
if (mesh.is_valid()) {
@@ -1113,25 +1113,29 @@ void GIProbe::_find_meshes(Node *p_at_node, Baker *p_baker) {
}
}
- if (Spatial *s = Object::cast_to<Spatial>(p_at_node)) {
+ Spatial *s = Object::cast_to<Spatial>(p_at_node);
+ if (s) {
- Array meshes = p_at_node->call("get_meshes");
- for (int i = 0; i < meshes.size(); i += 2) {
+ if (s->is_visible_in_tree()) {
- Transform mxf = meshes[i];
- Ref<Mesh> mesh = meshes[i + 1];
- if (!mesh.is_valid())
- continue;
+ Array meshes = p_at_node->call("get_meshes");
+ for (int i = 0; i < meshes.size(); i += 2) {
- Rect3 aabb = mesh->get_aabb();
+ Transform mxf = meshes[i];
+ Ref<Mesh> mesh = meshes[i + 1];
+ if (!mesh.is_valid())
+ continue;
- Transform xf = get_global_transform().affine_inverse() * (s->get_global_transform() * mxf);
+ Rect3 aabb = mesh->get_aabb();
- if (Rect3(-extents, extents * 2).intersects(xf.xform(aabb))) {
- Baker::PlotMesh pm;
- pm.local_xform = xf;
- pm.mesh = mesh;
- p_baker->mesh_list.push_back(pm);
+ Transform xf = get_global_transform().affine_inverse() * (s->get_global_transform() * mxf);
+
+ if (Rect3(-extents, extents * 2).intersects(xf.xform(aabb))) {
+ Baker::PlotMesh pm;
+ pm.local_xform = xf;
+ pm.mesh = mesh;
+ p_baker->mesh_list.push_back(pm);
+ }
}
}
}
diff --git a/scene/3d/interpolated_camera.cpp b/scene/3d/interpolated_camera.cpp
index 157ae42571..0f281b694d 100644
--- a/scene/3d/interpolated_camera.cpp
+++ b/scene/3d/interpolated_camera.cpp
@@ -55,8 +55,8 @@ void InterpolatedCamera::_notification(int p_what) {
Transform local_transform = get_global_transform();
local_transform = local_transform.interpolate_with(target_xform, delta);
set_global_transform(local_transform);
-
- if (Camera *cam = Object::cast_to<Camera>(node)) {
+ Camera *cam = Object::cast_to<Camera>(node);
+ if (cam) {
if (cam->get_projection() == get_projection()) {
diff --git a/scene/3d/light.cpp b/scene/3d/light.cpp
index 09b253b309..096f787873 100644
--- a/scene/3d/light.cpp
+++ b/scene/3d/light.cpp
@@ -230,7 +230,6 @@ void Light::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "shadow_color", PROPERTY_HINT_COLOR_NO_ALPHA), "set_shadow_color", "get_shadow_color");
ADD_PROPERTYI(PropertyInfo(Variant::REAL, "shadow_bias", PROPERTY_HINT_RANGE, "-16,16,0.01"), "set_param", "get_param", PARAM_SHADOW_BIAS);
ADD_PROPERTYI(PropertyInfo(Variant::REAL, "shadow_contact", PROPERTY_HINT_RANGE, "0,16,0.01"), "set_param", "get_param", PARAM_CONTACT_SHADOW_SIZE);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL, "shadow_max_distance", PROPERTY_HINT_RANGE, "0,65536,0.1"), "set_param", "get_param", PARAM_SHADOW_MAX_DISTANCE);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "shadow_reverse_cull_face"), "set_shadow_reverse_cull_face", "get_shadow_reverse_cull_face");
ADD_GROUP("Editor", "");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "editor_only"), "set_editor_only", "is_editor_only");
@@ -308,6 +307,16 @@ DirectionalLight::ShadowMode DirectionalLight::get_shadow_mode() const {
return shadow_mode;
}
+void DirectionalLight::set_shadow_depth_range(ShadowDepthRange p_range) {
+ shadow_depth_range = p_range;
+ VS::get_singleton()->light_directional_set_shadow_depth_range_mode(light, VS::LightDirectionalShadowDepthRangeMode(p_range));
+}
+
+DirectionalLight::ShadowDepthRange DirectionalLight::get_shadow_depth_range() const {
+
+ return shadow_depth_range;
+}
+
void DirectionalLight::set_blend_splits(bool p_enable) {
blend_splits = p_enable;
@@ -324,6 +333,9 @@ void DirectionalLight::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_shadow_mode", "mode"), &DirectionalLight::set_shadow_mode);
ClassDB::bind_method(D_METHOD("get_shadow_mode"), &DirectionalLight::get_shadow_mode);
+ ClassDB::bind_method(D_METHOD("set_shadow_depth_range", "mode"), &DirectionalLight::set_shadow_depth_range);
+ ClassDB::bind_method(D_METHOD("get_shadow_depth_range"), &DirectionalLight::get_shadow_depth_range);
+
ClassDB::bind_method(D_METHOD("set_blend_splits", "enabled"), &DirectionalLight::set_blend_splits);
ClassDB::bind_method(D_METHOD("is_blend_splits_enabled"), &DirectionalLight::is_blend_splits_enabled);
@@ -335,10 +347,15 @@ void DirectionalLight::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "directional_shadow_blend_splits"), "set_blend_splits", "is_blend_splits_enabled");
ADD_PROPERTYI(PropertyInfo(Variant::REAL, "directional_shadow_normal_bias", PROPERTY_HINT_RANGE, "0,16,0.01"), "set_param", "get_param", PARAM_SHADOW_NORMAL_BIAS);
ADD_PROPERTYI(PropertyInfo(Variant::REAL, "directional_shadow_bias_split_scale", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_param", "get_param", PARAM_SHADOW_BIAS_SPLIT_SCALE);
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "directional_shadow_depth_range", PROPERTY_HINT_ENUM, "Stable,Optimized"), "set_shadow_depth_range", "get_shadow_depth_range");
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "directional_shadow_max_distance", PROPERTY_HINT_RANGE, "0,65536,0.1"), "set_param", "get_param", PARAM_SHADOW_MAX_DISTANCE);
BIND_ENUM_CONSTANT(SHADOW_ORTHOGONAL);
BIND_ENUM_CONSTANT(SHADOW_PARALLEL_2_SPLITS);
BIND_ENUM_CONSTANT(SHADOW_PARALLEL_4_SPLITS);
+
+ BIND_ENUM_CONSTANT(SHADOW_DEPTH_RANGE_STABLE);
+ BIND_ENUM_CONSTANT(SHADOW_DEPTH_RANGE_OPTIMIZED);
}
DirectionalLight::DirectionalLight()
@@ -349,6 +366,7 @@ DirectionalLight::DirectionalLight()
set_param(PARAM_SHADOW_MAX_DISTANCE, 200);
set_param(PARAM_SHADOW_BIAS_SPLIT_SCALE, 0.25);
set_shadow_mode(SHADOW_PARALLEL_4_SPLITS);
+ set_shadow_depth_range(SHADOW_DEPTH_RANGE_STABLE);
blend_splits = false;
}
diff --git a/scene/3d/light.h b/scene/3d/light.h
index 5d589d33e5..6aa0220265 100644
--- a/scene/3d/light.h
+++ b/scene/3d/light.h
@@ -133,9 +133,15 @@ public:
SHADOW_PARALLEL_4_SPLITS
};
+ enum ShadowDepthRange {
+ SHADOW_DEPTH_RANGE_STABLE = VS::LIGHT_DIRECTIONAL_SHADOW_DEPTH_RANGE_STABLE,
+ SHADOW_DEPTH_RANGE_OPTIMIZED = VS::LIGHT_DIRECTIONAL_SHADOW_DEPTH_RANGE_OPTIMIZED,
+ };
+
private:
bool blend_splits;
ShadowMode shadow_mode;
+ ShadowDepthRange shadow_depth_range;
protected:
static void _bind_methods();
@@ -144,6 +150,9 @@ public:
void set_shadow_mode(ShadowMode p_mode);
ShadowMode get_shadow_mode() const;
+ void set_shadow_depth_range(ShadowDepthRange p_mode);
+ ShadowDepthRange get_shadow_depth_range() const;
+
void set_blend_splits(bool p_enable);
bool is_blend_splits_enabled() const;
@@ -151,6 +160,7 @@ public:
};
VARIANT_ENUM_CAST(DirectionalLight::ShadowMode)
+VARIANT_ENUM_CAST(DirectionalLight::ShadowDepthRange)
class OmniLight : public Light {
diff --git a/scene/3d/path.cpp b/scene/3d/path.cpp
index ed4d88417c..60245fe6ce 100644
--- a/scene/3d/path.cpp
+++ b/scene/3d/path.cpp
@@ -155,8 +155,8 @@ void PathFollow::_notification(int p_what) {
Node *parent = get_parent();
if (parent) {
-
- if ((path = Object::cast_to<Path>(parent))) {
+ path = Object::cast_to<Path>(parent);
+ if (path) {
_update_transform();
}
}
diff --git a/scene/3d/physics_body.cpp b/scene/3d/physics_body.cpp
index 9590394211..6a8226c0e1 100644
--- a/scene/3d/physics_body.cpp
+++ b/scene/3d/physics_body.cpp
@@ -912,35 +912,24 @@ RigidBody::~RigidBody() {
//////////////////////////////////////////////////////
//////////////////////////
-Dictionary KinematicBody::_move(const Vector3 &p_motion) {
+Ref<KinematicCollision> KinematicBody::_move(const Vector3 &p_motion) {
Collision col;
- if (move(p_motion, col)) {
- Dictionary d;
- d["position"] = col.collision;
- d["normal"] = col.normal;
- d["local_shape"] = col.local_shape;
- d["travel"] = col.travel;
- d["remainder"] = col.remainder;
- d["collider_id"] = col.collider;
- if (col.collider) {
- d["collider"] = ObjectDB::get_instance(col.collider);
- } else {
- d["collider"] = Variant();
+ if (move_and_collide(p_motion, col)) {
+ if (motion_cache.is_null()) {
+ motion_cache.instance();
+ motion_cache->owner = this;
}
- d["collider_velocity"] = col.collider_vel;
- d["collider_shape_index"] = col.collider_shape;
- d["collider_metadata"] = col.collider_metadata;
-
- return d;
+ motion_cache->collision = col;
- } else {
- return Dictionary();
+ return motion_cache;
}
+
+ return Ref<KinematicCollision>();
}
-bool KinematicBody::move(const Vector3 &p_motion, Collision &r_collision) {
+bool KinematicBody::move_and_collide(const Vector3 &p_motion, Collision &r_collision) {
Transform gt = get_global_transform();
PhysicsServer::MotionResult result;
@@ -964,7 +953,7 @@ bool KinematicBody::move(const Vector3 &p_motion, Collision &r_collision) {
return colliding;
}
-Vector3 KinematicBody::move_and_slide(const Vector3 &p_linear_velocity, const Vector3 &p_floor_direction, float p_slope_stop_min_velocity, int p_max_bounces, float p_floor_max_angle) {
+Vector3 KinematicBody::move_and_slide(const Vector3 &p_linear_velocity, const Vector3 &p_floor_direction, float p_slope_stop_min_velocity, int p_max_slides, float p_floor_max_angle) {
Vector3 motion = (floor_velocity + p_linear_velocity) * get_fixed_process_delta_time();
Vector3 lv = p_linear_velocity;
@@ -975,11 +964,11 @@ Vector3 KinematicBody::move_and_slide(const Vector3 &p_linear_velocity, const Ve
colliders.clear();
floor_velocity = Vector3();
- while (p_max_bounces) {
+ while (p_max_slides) {
Collision collision;
- bool collided = move(motion, collision);
+ bool collided = move_and_collide(motion, collision);
if (collided) {
@@ -1017,7 +1006,7 @@ Vector3 KinematicBody::move_and_slide(const Vector3 &p_linear_velocity, const Ve
break;
}
- p_max_bounces--;
+ p_max_slides--;
if (motion == Vector3())
break;
}
@@ -1059,79 +1048,36 @@ float KinematicBody::get_safe_margin() const {
return margin;
}
-
-int KinematicBody::get_collision_count() const {
+int KinematicBody::get_slide_count() const {
return colliders.size();
}
-Vector3 KinematicBody::get_collision_position(int p_collision) const {
-
- ERR_FAIL_INDEX_V(p_collision, colliders.size(), Vector3());
- return colliders[p_collision].collision;
-}
-Vector3 KinematicBody::get_collision_normal(int p_collision) const {
- ERR_FAIL_INDEX_V(p_collision, colliders.size(), Vector3());
- return colliders[p_collision].normal;
+KinematicBody::Collision KinematicBody::get_slide_collision(int p_bounce) const {
+ ERR_FAIL_INDEX_V(p_bounce, colliders.size(), Collision());
+ return colliders[p_bounce];
}
-Vector3 KinematicBody::get_collision_travel(int p_collision) const {
- ERR_FAIL_INDEX_V(p_collision, colliders.size(), Vector3());
- return colliders[p_collision].travel;
-}
-Vector3 KinematicBody::get_collision_remainder(int p_collision) const {
- ERR_FAIL_INDEX_V(p_collision, colliders.size(), Vector3());
- return colliders[p_collision].remainder;
-}
-Object *KinematicBody::get_collision_local_shape(int p_collision) const {
- ERR_FAIL_INDEX_V(p_collision, colliders.size(), NULL);
- uint32_t owner = shape_find_owner(colliders[p_collision].local_shape);
- return shape_owner_get_owner(owner);
-}
-Object *KinematicBody::get_collision_collider(int p_collision) const {
- ERR_FAIL_INDEX_V(p_collision, colliders.size(), NULL);
+Ref<KinematicCollision> KinematicBody::_get_slide_collision(int p_bounce) {
- if (colliders[p_collision].collider) {
- return ObjectDB::get_instance(colliders[p_collision].collider);
+ ERR_FAIL_INDEX_V(p_bounce, colliders.size(), Ref<KinematicCollision>());
+ if (p_bounce > slide_colliders.size()) {
+ slide_colliders.resize(p_bounce + 1);
}
- return NULL;
-}
-ObjectID KinematicBody::get_collision_collider_id(int p_collision) const {
- ERR_FAIL_INDEX_V(p_collision, colliders.size(), 0);
-
- return colliders[p_collision].collider;
-}
-Object *KinematicBody::get_collision_collider_shape(int p_collision) const {
- ERR_FAIL_INDEX_V(p_collision, colliders.size(), NULL);
- Object *collider = get_collision_collider(p_collision);
- if (collider) {
- CollisionObject *obj2d = Object::cast_to<CollisionObject>(collider);
- if (obj2d) {
- uint32_t owner = shape_find_owner(colliders[p_collision].collider_shape);
- return obj2d->shape_owner_get_owner(owner);
- }
+ if (slide_colliders[p_bounce].is_null()) {
+ slide_colliders[p_bounce].instance();
+ slide_colliders[p_bounce]->owner = this;
}
- return NULL;
-}
-int KinematicBody::get_collision_collider_shape_index(int p_collision) const {
- ERR_FAIL_INDEX_V(p_collision, colliders.size(), -1);
- return colliders[p_collision].collider_shape;
-}
-Vector3 KinematicBody::get_collision_collider_velocity(int p_collision) const {
- ERR_FAIL_INDEX_V(p_collision, colliders.size(), Vector3());
- return colliders[p_collision].collider_vel;
-}
-Variant KinematicBody::get_collision_collider_metadata(int p_collision) const {
- ERR_FAIL_INDEX_V(p_collision, colliders.size(), Variant());
- return colliders[p_collision].collider_metadata;
+ slide_colliders[p_bounce]->collision = colliders[p_bounce];
+ return slide_colliders[p_bounce];
}
void KinematicBody::_bind_methods() {
- ClassDB::bind_method(D_METHOD("move", "rel_vec"), &KinematicBody::_move);
- ClassDB::bind_method(D_METHOD("move_and_slide", "linear_velocity", "floor_normal", "slope_stop_min_velocity", "max_bounces", "floor_max_angle"), &KinematicBody::move_and_slide, DEFVAL(Vector3(0, 0, 0)), DEFVAL(0.05), DEFVAL(4), DEFVAL(Math::deg2rad((float)45)));
+ ClassDB::bind_method(D_METHOD("move_and_collide", "rel_vec"), &KinematicBody::_move);
+ ClassDB::bind_method(D_METHOD("move_and_slide", "linear_velocity", "floor_normal", "slope_stop_min_velocity", "max_slides", "floor_max_angle"), &KinematicBody::move_and_slide, DEFVAL(Vector3(0, 0, 0)), DEFVAL(0.05), DEFVAL(4), DEFVAL(Math::deg2rad((float)45)));
ClassDB::bind_method(D_METHOD("test_move", "from", "rel_vec"), &KinematicBody::test_move);
@@ -1143,18 +1089,8 @@ void KinematicBody::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_safe_margin", "pixels"), &KinematicBody::set_safe_margin);
ClassDB::bind_method(D_METHOD("get_safe_margin"), &KinematicBody::get_safe_margin);
- ClassDB::bind_method(D_METHOD("get_collision_count"), &KinematicBody::get_collision_count);
- ClassDB::bind_method(D_METHOD("get_collision_position", "collision"), &KinematicBody::get_collision_position);
- ClassDB::bind_method(D_METHOD("get_collision_normal", "collision"), &KinematicBody::get_collision_normal);
- ClassDB::bind_method(D_METHOD("get_collision_travel", "collision"), &KinematicBody::get_collision_travel);
- ClassDB::bind_method(D_METHOD("get_collision_remainder", "collision"), &KinematicBody::get_collision_remainder);
- ClassDB::bind_method(D_METHOD("get_collision_local_shape", "collision"), &KinematicBody::get_collision_local_shape);
- ClassDB::bind_method(D_METHOD("get_collision_collider", "collision"), &KinematicBody::get_collision_collider);
- ClassDB::bind_method(D_METHOD("get_collision_collider_id", "collision"), &KinematicBody::get_collision_collider_id);
- ClassDB::bind_method(D_METHOD("get_collision_collider_shape", "collision"), &KinematicBody::get_collision_collider_shape);
- ClassDB::bind_method(D_METHOD("get_collision_collider_shape_index", "collision"), &KinematicBody::get_collision_collider_shape_index);
- ClassDB::bind_method(D_METHOD("get_collision_collider_velocity", "collision"), &KinematicBody::get_collision_collider_velocity);
- ClassDB::bind_method(D_METHOD("get_collision_collider_metadata", "collision"), &KinematicBody::get_collision_collider_metadata);
+ ClassDB::bind_method(D_METHOD("get_slide_count"), &KinematicBody::get_slide_count);
+ ClassDB::bind_method(D_METHOD("get_slide_collision", "slide_idx"), &KinematicBody::_get_slide_collision);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "collision/safe_margin", PROPERTY_HINT_RANGE, "0.001,256,0.001"), "set_safe_margin", "get_safe_margin");
}
@@ -1169,4 +1105,106 @@ KinematicBody::KinematicBody()
on_wall = false;
}
KinematicBody::~KinematicBody() {
+
+ if (motion_cache.is_valid()) {
+ motion_cache->owner = NULL;
+ }
+
+ for (int i = 0; i < slide_colliders.size(); i++) {
+ if (slide_colliders[i].is_valid()) {
+ slide_colliders[i]->owner = NULL;
+ }
+ }
+}
+///////////////////////////////////////
+
+Vector3 KinematicCollision::get_position() const {
+
+ return collision.collision;
+}
+Vector3 KinematicCollision::get_normal() const {
+ return collision.normal;
+}
+Vector3 KinematicCollision::get_travel() const {
+ return collision.travel;
+}
+Vector3 KinematicCollision::get_remainder() const {
+ return collision.remainder;
+}
+Object *KinematicCollision::get_local_shape() const {
+ ERR_FAIL_COND_V(!owner, NULL);
+ uint32_t ownerid = owner->shape_find_owner(collision.local_shape);
+ return owner->shape_owner_get_owner(ownerid);
+}
+
+Object *KinematicCollision::get_collider() const {
+
+ if (collision.collider) {
+ return ObjectDB::get_instance(collision.collider);
+ }
+
+ return NULL;
+}
+ObjectID KinematicCollision::get_collider_id() const {
+
+ return collision.collider;
+}
+Object *KinematicCollision::get_collider_shape() const {
+
+ Object *collider = get_collider();
+ if (collider) {
+ CollisionObject *obj2d = Object::cast_to<CollisionObject>(collider);
+ if (obj2d) {
+ uint32_t ownerid = obj2d->shape_find_owner(collision.collider_shape);
+ return obj2d->shape_owner_get_owner(ownerid);
+ }
+ }
+
+ return NULL;
+}
+int KinematicCollision::get_collider_shape_index() const {
+
+ return collision.collider_shape;
+}
+Vector3 KinematicCollision::get_collider_velocity() const {
+
+ return collision.collider_vel;
+}
+Variant KinematicCollision::get_collider_metadata() const {
+
+ return Variant();
+}
+
+void KinematicCollision::_bind_methods() {
+
+ ClassDB::bind_method(D_METHOD("get_position"), &KinematicCollision::get_position);
+ ClassDB::bind_method(D_METHOD("get_normal"), &KinematicCollision::get_normal);
+ ClassDB::bind_method(D_METHOD("get_travel"), &KinematicCollision::get_travel);
+ ClassDB::bind_method(D_METHOD("get_remainder"), &KinematicCollision::get_remainder);
+ ClassDB::bind_method(D_METHOD("get_local_shape"), &KinematicCollision::get_local_shape);
+ ClassDB::bind_method(D_METHOD("get_collider"), &KinematicCollision::get_collider);
+ ClassDB::bind_method(D_METHOD("get_collider_id"), &KinematicCollision::get_collider_id);
+ ClassDB::bind_method(D_METHOD("get_collider_shape"), &KinematicCollision::get_collider_shape);
+ ClassDB::bind_method(D_METHOD("get_collider_shape_index"), &KinematicCollision::get_collider_shape_index);
+ ClassDB::bind_method(D_METHOD("get_collider_velocity"), &KinematicCollision::get_collider_velocity);
+ ClassDB::bind_method(D_METHOD("get_collider_metadata"), &KinematicCollision::get_collider_metadata);
+
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "position"), "", "get_position");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "normal"), "", "get_normal");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "travel"), "", "get_travel");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "remainder"), "", "get_remainder");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "local_shape"), "", "get_local_shape");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "collider"), "", "get_collider");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "collider_id"), "", "get_collider_id");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "collider_shape"), "", "get_collider_shape");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "collider_shape_index"), "", "get_collider_shape_index");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "collider_velocity"), "", "get_collider_velocity");
+ ADD_PROPERTY(PropertyInfo(Variant::NIL, "collider_metadata", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NIL_IS_VARIANT), "", "get_collider_metadata");
+}
+
+KinematicCollision::KinematicCollision() {
+ collision.collider = 0;
+ collision.collider_shape = 0;
+ collision.local_shape = 0;
+ owner = NULL;
}
diff --git a/scene/3d/physics_body.h b/scene/3d/physics_body.h
index 23d752ad76..f88b3860dc 100644
--- a/scene/3d/physics_body.h
+++ b/scene/3d/physics_body.h
@@ -261,6 +261,8 @@ public:
VARIANT_ENUM_CAST(RigidBody::Mode);
VARIANT_ENUM_CAST(RigidBody::AxisLock);
+class KinematicCollision;
+
class KinematicBody : public PhysicsBody {
GDCLASS(KinematicBody, PhysicsBody);
@@ -286,42 +288,62 @@ private:
bool on_ceiling;
bool on_wall;
Vector<Collision> colliders;
+ Vector<Ref<KinematicCollision> > slide_colliders;
+ Ref<KinematicCollision> motion_cache;
_FORCE_INLINE_ bool _ignores_mode(PhysicsServer::BodyMode) const;
- Dictionary _move(const Vector3 &p_motion);
+ Ref<KinematicCollision> _move(const Vector3 &p_motion);
+ Ref<KinematicCollision> _get_slide_collision(int p_bounce);
protected:
static void _bind_methods();
public:
- bool move(const Vector3 &p_motion, Collision &r_collision);
+ bool move_and_collide(const Vector3 &p_motion, Collision &r_collision);
bool test_move(const Transform &p_from, const Vector3 &p_motion);
void set_safe_margin(float p_margin);
float get_safe_margin() const;
- Vector3 move_and_slide(const Vector3 &p_linear_velocity, const Vector3 &p_floor_direction = Vector3(0, 0, 0), float p_slope_stop_min_velocity = 0.05, int p_max_bounces = 4, float p_floor_max_angle = Math::deg2rad((float)45));
+ Vector3 move_and_slide(const Vector3 &p_linear_velocity, const Vector3 &p_floor_direction = Vector3(0, 0, 0), float p_slope_stop_min_velocity = 0.05, int p_max_slides = 4, float p_floor_max_angle = Math::deg2rad((float)45));
bool is_on_floor() const;
bool is_on_wall() const;
bool is_on_ceiling() const;
Vector3 get_floor_velocity() const;
- int get_collision_count() const;
- Vector3 get_collision_position(int p_collision) const;
- Vector3 get_collision_normal(int p_collision) const;
- Vector3 get_collision_travel(int p_collision) const;
- Vector3 get_collision_remainder(int p_collision) const;
- Object *get_collision_local_shape(int p_collision) const;
- Object *get_collision_collider(int p_collision) const;
- ObjectID get_collision_collider_id(int p_collision) const;
- Object *get_collision_collider_shape(int p_collision) const;
- int get_collision_collider_shape_index(int p_collision) const;
- Vector3 get_collision_collider_velocity(int p_collision) const;
- Variant get_collision_collider_metadata(int p_collision) const;
+ int get_slide_count() const;
+ Collision get_slide_collision(int p_bounce) const;
KinematicBody();
~KinematicBody();
};
+class KinematicCollision : public Reference {
+
+ GDCLASS(KinematicCollision, Reference);
+
+ KinematicBody *owner;
+ friend class KinematicBody;
+ KinematicBody::Collision collision;
+
+protected:
+ static void _bind_methods();
+
+public:
+ Vector3 get_position() const;
+ Vector3 get_normal() const;
+ Vector3 get_travel() const;
+ Vector3 get_remainder() const;
+ Object *get_local_shape() const;
+ Object *get_collider() const;
+ ObjectID get_collider_id() const;
+ Object *get_collider_shape() const;
+ int get_collider_shape_index() const;
+ Vector3 get_collider_velocity() const;
+ Variant get_collider_metadata() const;
+
+ KinematicCollision();
+};
+
#endif // PHYSICS_BODY__H
diff --git a/scene/audio/audio_player.cpp b/scene/audio/audio_player.cpp
index 8bd924e7ce..341ae45ce8 100644
--- a/scene/audio/audio_player.cpp
+++ b/scene/audio/audio_player.cpp
@@ -304,7 +304,7 @@ void AudioStreamPlayer::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "stream", PROPERTY_HINT_RESOURCE_TYPE, "AudioStream"), "set_stream", "get_stream");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "volume_db", PROPERTY_HINT_RANGE, "-80,24"), "set_volume_db", "get_volume_db");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "playing", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "_set_playing", "_is_active");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "play", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "_set_playing", "_is_active");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "autoplay"), "set_autoplay", "is_autoplay_enabled");
ADD_PROPERTY(PropertyInfo(Variant::INT, "mix_target", PROPERTY_HINT_ENUM, "Stereo,Surround,Center"), "set_mix_target", "get_mix_target");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "bus", PROPERTY_HINT_ENUM, ""), "set_bus", "get_bus");
diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp
index 8fd19e8655..5713a35b7a 100644
--- a/scene/gui/base_button.cpp
+++ b/scene/gui/base_button.cpp
@@ -87,14 +87,14 @@ void BaseButton::_gui_input(Ref<InputEvent> p_event) {
status.pressed = !status.pressed;
pressed();
- if (get_script_instance()) {
- Variant::CallError ce;
- get_script_instance()->call(SceneStringNames::get_singleton()->_pressed, NULL, 0, ce);
- }
+
emit_signal("pressed");
_unpress_group();
toggled(status.pressed);
+ if (get_script_instance()) {
+ get_script_instance()->call(SceneStringNames::get_singleton()->_toggled, status.pressed);
+ }
emit_signal("toggled", status.pressed);
}
@@ -143,10 +143,10 @@ void BaseButton::_gui_input(Ref<InputEvent> p_event) {
emit_signal("pressed");
toggled(status.pressed);
- emit_signal("toggled", status.pressed);
if (get_script_instance()) {
get_script_instance()->call(SceneStringNames::get_singleton()->_toggled, status.pressed);
}
+ emit_signal("toggled", status.pressed);
}
_unpress_group();
diff --git a/scene/gui/button_group.cpp b/scene/gui/button_group.cpp
deleted file mode 100644
index 336c88fe9d..0000000000
--- a/scene/gui/button_group.cpp
+++ /dev/null
@@ -1,168 +0,0 @@
-/*************************************************************************/
-/* button_group.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-#include "button_group.h"
-
-#if 0
-#include "base_button.h"
-
-void ButtonGroup::_add_button(BaseButton *p_button) {
-
- buttons.insert(p_button);
- p_button->set_toggle_mode(true);
- p_button->set_click_on_press(true);
- p_button->connect("pressed",this,"_pressed",make_binds(p_button));
-
-}
-
-void ButtonGroup::_remove_button(BaseButton *p_button){
-
- buttons.erase(p_button);
- p_button->disconnect("pressed",this,"_pressed");
-
-}
-
-void ButtonGroup::set_pressed_button(BaseButton *p_button) {
-
- _pressed(p_button);
-}
-
-void ButtonGroup::_pressed(Object *p_button) {
-
- ERR_FAIL_NULL(p_button);
- BaseButton *b=Object::cast_to<BaseButton>(p_button);
- ERR_FAIL_COND(!b);
-
- for(Set<BaseButton*>::Element *E=buttons.front();E;E=E->next()) {
-
- BaseButton *bb=E->get();
- bb->set_pressed( b==bb );
- if (b==bb){
- emit_signal("button_selected", b);
- }
- }
-}
-
-Array ButtonGroup::_get_button_list() const {
-
- List<BaseButton*> b;
- get_button_list(&b);
-
- b.sort_custom<Node::Comparator>();
-
- Array arr;
- arr.resize(b.size());
-
- int idx=0;
-
- for(List<BaseButton*>::Element *E=b.front();E;E=E->next(),idx++) {
-
- arr[idx]=E->get();
- }
-
- return arr;
-}
-
-void ButtonGroup::get_button_list(List<BaseButton*> *p_buttons) const {
-
- for(Set<BaseButton*>::Element *E=buttons.front();E;E=E->next()) {
-
- p_buttons->push_back(E->get());
- }
-}
-
-BaseButton *ButtonGroup::get_pressed_button() const {
-
- for(Set<BaseButton*>::Element *E=buttons.front();E;E=E->next()) {
-
- if (E->get()->is_pressed())
- return E->get();
- }
-
- return NULL;
-}
-
-BaseButton *ButtonGroup::get_focused_button() const{
-
- for(Set<BaseButton*>::Element *E=buttons.front();E;E=E->next()) {
-
- if (E->get()->has_focus())
- return E->get();
- }
-
- return NULL;
-
-}
-
-int ButtonGroup::get_pressed_button_index() const {
- //in tree order, this is bizarre
-
- ERR_FAIL_COND_V(!is_inside_tree(),0);
-
- BaseButton *pressed = get_pressed_button();
- if (!pressed)
- return -1;
-
- List<BaseButton*> blist;
- for(Set<BaseButton*>::Element *E=buttons.front();E;E=E->next()) {
-
- blist.push_back(E->get());
-
- }
-
- blist.sort_custom<Node::Comparator>();
-
- int idx=0;
- for(List<BaseButton*>::Element *E=blist.front();E;E=E->next()) {
-
- if (E->get()==pressed)
- return idx;
-
- idx++;
- }
-
- return -1;
-}
-
-void ButtonGroup::_bind_methods() {
-
- ClassDB::bind_method(D_METHOD("get_pressed_button"),&ButtonGroup::get_pressed_button);
- ClassDB::bind_method(D_METHOD("get_pressed_button_index"),&ButtonGroup::get_pressed_button_index);
- ClassDB::bind_method(D_METHOD("get_focused_button"),&ButtonGroup::get_focused_button);
- ClassDB::bind_method(D_METHOD("get_button_list"),&ButtonGroup::_get_button_list);
- ClassDB::bind_method(D_METHOD("_pressed"),&ButtonGroup::_pressed);
- ClassDB::bind_method(D_METHOD("set_pressed_button","button"),&ButtonGroup::_pressed);
-
- ADD_SIGNAL( MethodInfo("button_selected",PropertyInfo(Variant::OBJECT,"button",PROPERTY_HINT_RESOURCE_TYPE,"BaseButton")));
-}
-
-ButtonGroup::ButtonGroup() : BoxContainer(true)
-{
-}
-#endif
diff --git a/scene/gui/check_box.cpp b/scene/gui/check_box.cpp
index 21e2269141..e2b10a948f 100644
--- a/scene/gui/check_box.cpp
+++ b/scene/gui/check_box.cpp
@@ -29,7 +29,6 @@
/*************************************************************************/
#include "check_box.h"
-#include "button_group.h"
#include "servers/visual_server.h"
void CheckBox::_notification(int p_what) {
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index 961fccc804..87dfd95724 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -1249,6 +1249,10 @@ void Control::_size_changed() {
new_size_cache.height = MAX(minimum_size.height, new_size_cache.height);
}
+ if (get_viewport()->is_snap_controls_to_pixels_enabled()) {
+ new_size_cache = new_size_cache.floor();
+ new_pos_cache = new_pos_cache.floor();
+ }
bool pos_changed = new_pos_cache != data.pos_cache;
bool size_changed = new_size_cache != data.size_cache;
diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp
index 990c0f3d96..87a232e766 100644
--- a/scene/gui/file_dialog.cpp
+++ b/scene/gui/file_dialog.cpp
@@ -183,8 +183,8 @@ void FileDialog::_action_pressed() {
String path = dir_access->get_current_dir();
path = path.replace("\\", "/");
-
- if (TreeItem *item = tree->get_selected()) {
+ TreeItem *item = tree->get_selected();
+ if (item) {
Dictionary d = item->get_metadata(0);
if (d["dir"]) {
path = path.plus_file(d["name"]);
diff --git a/scene/gui/graph_node.cpp b/scene/gui/graph_node.cpp
index 8730be0c06..bef0808fd0 100644
--- a/scene/gui/graph_node.cpp
+++ b/scene/gui/graph_node.cpp
@@ -270,7 +270,7 @@ void GraphNode::_notification(int p_what) {
}
}
- if (resizeable) {
+ if (resizable) {
draw_texture(resizer, get_size() - resizer->get_size());
}
}
@@ -594,7 +594,7 @@ void GraphNode::_gui_input(const Ref<InputEvent> &p_ev) {
Ref<Texture> resizer = get_icon("resizer");
- if (resizeable && mpos.x > get_size().x - resizer->get_width() && mpos.y > get_size().y - resizer->get_height()) {
+ if (resizable && mpos.x > get_size().x - resizer->get_width() && mpos.y > get_size().y - resizer->get_height()) {
resizing = true;
resizing_from = mpos;
@@ -645,15 +645,15 @@ bool GraphNode::is_comment() const {
return comment;
}
-void GraphNode::set_resizeable(bool p_enable) {
+void GraphNode::set_resizable(bool p_enable) {
- resizeable = p_enable;
+ resizable = p_enable;
update();
}
-bool GraphNode::is_resizeable() const {
+bool GraphNode::is_resizable() const {
- return resizeable;
+ return resizable;
}
void GraphNode::_bind_methods() {
@@ -678,8 +678,8 @@ void GraphNode::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_comment", "comment"), &GraphNode::set_comment);
ClassDB::bind_method(D_METHOD("is_comment"), &GraphNode::is_comment);
- ClassDB::bind_method(D_METHOD("set_resizeable", "resizeable"), &GraphNode::set_resizeable);
- ClassDB::bind_method(D_METHOD("is_resizeable"), &GraphNode::is_resizeable);
+ ClassDB::bind_method(D_METHOD("set_resizable", "resizable"), &GraphNode::set_resizable);
+ ClassDB::bind_method(D_METHOD("is_resizable"), &GraphNode::is_resizable);
ClassDB::bind_method(D_METHOD("set_selected", "selected"), &GraphNode::set_selected);
ClassDB::bind_method(D_METHOD("is_selected"), &GraphNode::is_selected);
@@ -702,7 +702,7 @@ void GraphNode::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::STRING, "title"), "set_title", "get_title");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "show_close"), "set_show_close_button", "is_close_button_visible");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "resizeable"), "set_resizeable", "is_resizeable");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "resizable"), "set_resizable", "is_resizable");
ADD_SIGNAL(MethodInfo("offset_changed"));
ADD_SIGNAL(MethodInfo("dragged", PropertyInfo(Variant::VECTOR2, "from"), PropertyInfo(Variant::VECTOR2, "to")));
@@ -722,7 +722,7 @@ GraphNode::GraphNode() {
connpos_dirty = true;
set_mouse_filter(MOUSE_FILTER_STOP);
comment = false;
- resizeable = false;
+ resizable = false;
resizing = false;
selected = false;
}
diff --git a/scene/gui/graph_node.h b/scene/gui/graph_node.h
index 416d711aab..a606e47acd 100644
--- a/scene/gui/graph_node.h
+++ b/scene/gui/graph_node.h
@@ -68,7 +68,7 @@ private:
bool show_close;
Vector2 offset;
bool comment;
- bool resizeable;
+ bool resizable;
bool resizing;
Vector2 resizing_from;
@@ -151,8 +151,8 @@ public:
void set_comment(bool p_enable);
bool is_comment() const;
- void set_resizeable(bool p_enable);
- bool is_resizeable() const;
+ void set_resizable(bool p_enable);
+ bool is_resizable() const;
virtual Size2 get_minimum_size() const;
diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp
index f8d82a339c..9a605c98f3 100644
--- a/scene/gui/item_list.cpp
+++ b/scene/gui/item_list.cpp
@@ -151,6 +151,20 @@ Color ItemList::get_item_custom_bg_color(int p_idx) const {
return items[p_idx].custom_bg;
}
+void ItemList::set_item_custom_fg_color(int p_idx, const Color &p_custom_fg_color) {
+
+ ERR_FAIL_INDEX(p_idx, items.size());
+
+ items[p_idx].custom_fg = p_custom_fg_color;
+}
+
+Color ItemList::get_item_custom_fg_color(int p_idx) const {
+
+ ERR_FAIL_INDEX_V(p_idx, items.size(), Color());
+
+ return items[p_idx].custom_fg;
+}
+
void ItemList::set_item_tag_icon(int p_idx, const Ref<Texture> &p_tag_icon) {
ERR_FAIL_INDEX(p_idx, items.size());
@@ -1021,7 +1035,7 @@ void ItemList::_notification(int p_what) {
else
max_len = size.x;
- Color modulate = items[i].selected ? font_color_selected : font_color;
+ Color modulate = items[i].selected ? font_color_selected : (items[i].custom_fg != Color() ? items[i].custom_fg : font_color);
if (items[i].disabled)
modulate.a *= 0.5;
diff --git a/scene/gui/item_list.h b/scene/gui/item_list.h
index 8166975408..673b7d8956 100644
--- a/scene/gui/item_list.h
+++ b/scene/gui/item_list.h
@@ -61,6 +61,7 @@ private:
bool tooltip_enabled;
Variant metadata;
String tooltip;
+ Color custom_fg;
Color custom_bg;
Rect2 rect_cache;
@@ -150,6 +151,9 @@ public:
void set_item_custom_bg_color(int p_idx, const Color &p_custom_bg_color);
Color get_item_custom_bg_color(int p_idx) const;
+ void set_item_custom_fg_color(int p_idx, const Color &p_custom_fg_color);
+ Color get_item_custom_fg_color(int p_idx) const;
+
void select(int p_idx, bool p_single = true);
void unselect(int p_idx);
bool is_selected(int p_idx) const;
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp
index 66b4e6cec1..6a5f56c78c 100644
--- a/scene/gui/line_edit.cpp
+++ b/scene/gui/line_edit.cpp
@@ -631,7 +631,7 @@ void LineEdit::_notification(int p_what) {
if (has_icon("right_icon")) {
Ref<Texture> r_icon = Control::get_icon("right_icon");
ofs_max -= r_icon->get_width();
- r_icon->draw(ci, Point2(width - r_icon->get_width() - x_ofs, y_ofs), Color(1, 1, 1, disabled_alpha * .9));
+ r_icon->draw(ci, Point2(width - r_icon->get_width() - x_ofs, height / 2 - r_icon->get_height() / 2), Color(1, 1, 1, disabled_alpha * .9));
}
int caret_height = font->get_height() > y_area ? y_area : font->get_height();
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp
index a3f116c883..ab2c2f445f 100644
--- a/scene/gui/rich_text_label.cpp
+++ b/scene/gui/rich_text_label.cpp
@@ -80,6 +80,10 @@ RichTextLabel::Item *RichTextLabel::_get_next_item(Item *p_item, bool p_free) {
return NULL;
}
+Rect2 RichTextLabel::_get_text_rect() {
+ Ref<StyleBox> style = get_stylebox("normal");
+ return Rect2(style->get_offset(), get_size() - style->get_minimum_size());
+}
void RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &y, int p_width, int p_line, ProcessMode p_mode, const Ref<Font> &p_base_font, const Color &p_base_color, const Point2i &p_click_pos, Item **r_click_item, int *r_click_char, bool *r_outside, int p_char_count) {
RID ci;
@@ -583,7 +587,7 @@ void RichTextLabel::_update_scroll() {
int total_height = 0;
if (main->lines.size())
- total_height = main->lines[main->lines.size() - 1].height_accum_cache;
+ total_height = main->lines[main->lines.size() - 1].height_accum_cache + get_stylebox("normal")->get_minimum_size().height;
bool exceeds = total_height > get_size().height && scroll_active;
@@ -641,7 +645,11 @@ void RichTextLabel::_notification(int p_what) {
_update_scroll();
RID ci = get_canvas_item();
+
Size2 size = get_size();
+ Rect2 text_rect = _get_text_rect();
+
+ draw_style_box(get_stylebox("normal"), Rect2(Point2(), size));
if (has_focus()) {
VisualServer::get_singleton()->canvas_item_add_clip_ignore(ci, true);
@@ -657,10 +665,10 @@ void RichTextLabel::_notification(int p_what) {
int total_chars = 0;
while (from_line < main->lines.size()) {
- if (main->lines[from_line].height_accum_cache >= ofs)
+ if (main->lines[from_line].height_accum_cache + _get_text_rect().get_position().y >= ofs)
break;
- from_line++;
total_chars += main->lines[from_line].char_count;
+ from_line++;
}
if (from_line >= main->lines.size())
@@ -672,7 +680,7 @@ void RichTextLabel::_notification(int p_what) {
while (y < size.height && from_line < main->lines.size()) {
- _process_line(main, Point2(), y, size.width - scroll_w, from_line, PROCESS_DRAW, base_font, base_color, Point2i(), NULL, NULL, NULL, total_chars);
+ _process_line(main, text_rect.get_position(), y, text_rect.get_size().width - scroll_w, from_line, PROCESS_DRAW, base_font, base_color, Point2i(), NULL, NULL, NULL, total_chars);
total_chars += main->lines[from_line].char_count;
from_line++;
}
@@ -686,7 +694,7 @@ void RichTextLabel::_find_click(ItemFrame *p_frame, const Point2i &p_click, Item
*r_click_item = NULL;
Size2 size = get_size();
-
+ Rect2 text_rect = _get_text_rect();
int ofs = vscroll->get_value();
//todo, change to binary search
@@ -706,9 +714,9 @@ void RichTextLabel::_find_click(ItemFrame *p_frame, const Point2i &p_click, Item
Ref<Font> base_font = get_font("normal_font");
Color base_color = get_color("default_color");
- while (y < size.height && from_line < p_frame->lines.size()) {
+ while (y < text_rect.get_size().height && from_line < p_frame->lines.size()) {
- _process_line(p_frame, Point2(), y, size.width - scroll_w, from_line, PROCESS_POINTER, base_font, base_color, p_click, r_click_item, r_click_char, r_outside);
+ _process_line(p_frame, text_rect.get_position(), y, text_rect.get_size().width - scroll_w, from_line, PROCESS_POINTER, base_font, base_color, p_click, r_click_item, r_click_char, r_outside);
if (r_click_item && *r_click_item)
return;
from_line++;
@@ -791,7 +799,7 @@ void RichTextLabel::_gui_input(Ref<InputEvent> p_event) {
Ref<InputEventKey> k = p_event;
if (k.is_valid()) {
- if (k->is_pressed() && !k->get_alt() && !k->get_shift() && !k->get_metakey()) {
+ if (k->is_pressed() && !k->get_alt() && !k->get_shift()) {
bool handled = true;
switch (k->get_scancode()) {
case KEY_PAGEUP: {
@@ -1015,13 +1023,14 @@ void RichTextLabel::_validate_line_caches(ItemFrame *p_frame) {
//validate invalid lines!s
Size2 size = get_size();
+ Rect2 text_rect = _get_text_rect();
Ref<Font> base_font = get_font("normal_font");
for (int i = p_frame->first_invalid_line; i < p_frame->lines.size(); i++) {
int y = 0;
- _process_line(p_frame, Point2(), y, size.width - scroll_w, i, PROCESS_CACHE, base_font, Color());
+ _process_line(p_frame, text_rect.get_position(), y, text_rect.get_size().width - scroll_w, i, PROCESS_CACHE, base_font, Color());
p_frame->lines[i].height_cache = y;
p_frame->lines[i].height_accum_cache = y;
@@ -1031,7 +1040,7 @@ void RichTextLabel::_validate_line_caches(ItemFrame *p_frame) {
int total_height = 0;
if (p_frame->lines.size())
- total_height = p_frame->lines[p_frame->lines.size() - 1].height_accum_cache;
+ total_height = p_frame->lines[p_frame->lines.size() - 1].height_accum_cache + get_stylebox("normal")->get_minimum_size().height;
main->first_invalid_line = p_frame->lines.size();
diff --git a/scene/gui/rich_text_label.h b/scene/gui/rich_text_label.h
index 74bf180b5d..4db2c3a8e9 100644
--- a/scene/gui/rich_text_label.h
+++ b/scene/gui/rich_text_label.h
@@ -276,6 +276,8 @@ private:
void _gui_input(Ref<InputEvent> p_event);
Item *_get_next_item(Item *p_item, bool p_free = false);
+ Rect2 _get_text_rect();
+
bool use_bbcode;
String bbcode;
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index ade665b418..1738e303aa 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -2136,15 +2136,25 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
break;
}
}
- if (auto_indent) {
- // indent once again if previous line will end with ':'
- // (i.e. colon precedes current cursor position)
- if (cursor.column > 0 && text[cursor.line][cursor.column - 1] == ':') {
+
+ bool brace_indent = false;
+
+ // no need to indent if we are going upwards.
+ if (auto_indent && !(k->get_command() && k->get_shift())) {
+ // indent once again if previous line will end with ':' or '{'
+ // (i.e. colon/brace precedes current cursor position)
+ if (cursor.column > 0 && (text[cursor.line][cursor.column - 1] == ':' || text[cursor.line][cursor.column - 1] == '{')) {
if (indent_using_spaces) {
ins += space_indent;
} else {
ins += "\t";
}
+
+ // no need to move the brace below if we are not taking the text with us.
+ if (text[cursor.line][cursor.column] == '}' && !k->get_command()) {
+ brace_indent = true;
+ ins += "\n" + ins.substr(1, ins.length() - 2);
+ }
}
}
@@ -2168,6 +2178,9 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
if (first_line) {
cursor_set_line(0);
+ } else if (brace_indent) {
+ cursor_set_line(cursor.line - 1);
+ cursor_set_column(text[cursor.line].length());
}
} break;
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index 5e15bceb7d..d4ebf55f92 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -1116,7 +1116,8 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
cache.selected->draw(ci, r);
}
if (text_editor->is_visible_in_tree()) {
- text_editor->set_position(get_global_position() + r.position);
+ Vector2 ofs(0, (text_editor->get_size().height - r.size.height) / 2);
+ text_editor->set_position(get_global_position() + r.position - ofs);
}
}
@@ -2303,7 +2304,7 @@ void Tree::_gui_input(Ref<InputEvent> p_event) {
int col, h, section;
TreeItem *it = _find_item_at_pos(root, mpos, col, h, section);
- if (drop_mode_flags && it != drop_mode_over || section != drop_mode_section) {
+ if ((drop_mode_flags && it != drop_mode_over) || section != drop_mode_section) {
drop_mode_over = it;
drop_mode_section = section;
update();
@@ -2572,7 +2573,8 @@ bool Tree::edit_selected() {
} else if (c.mode == TreeItem::CELL_MODE_STRING || c.mode == TreeItem::CELL_MODE_RANGE || c.mode == TreeItem::CELL_MODE_RANGE_EXPRESSION) {
- Point2i textedpos = get_global_position() + rect.position;
+ Vector2 ofs(0, (text_editor->get_size().height - rect.size.height) / 2);
+ Point2i textedpos = get_global_position() + rect.position - ofs;
text_editor->set_position(textedpos);
text_editor->set_size(rect.size);
text_editor->clear();
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index 8095949ac6..d3a0857b16 100755
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -2117,7 +2117,15 @@ Node *Node::_duplicate(int p_flags) const {
if (!(p_flags & DUPLICATE_SCRIPTS) && name == "script/script")
continue;
- node->set(name, get(name));
+ Variant value = get(name);
+ // Duplicate dictionaries and arrays, mainly needed for __meta__
+ if (value.get_type() == Variant::DICTIONARY) {
+ value = Dictionary(value).copy();
+ } else if (value.get_type() == Variant::ARRAY) {
+ value = Array(value).duplicate();
+ }
+
+ node->set(name, value);
}
node->set_name(get_name());
@@ -2199,7 +2207,16 @@ void Node::_duplicate_and_reown(Node *p_new_parent, const Map<Node *, Node *> &p
if (!(E->get().usage & PROPERTY_USAGE_STORAGE))
continue;
String name = E->get().name;
- node->set(name, get(name));
+
+ Variant value = get(name);
+ // Duplicate dictionaries and arrays, mainly needed for __meta__
+ if (value.get_type() == Variant::DICTIONARY) {
+ value = Dictionary(value).copy();
+ } else if (value.get_type() == Variant::ARRAY) {
+ value = Array(value).duplicate();
+ }
+
+ node->set(name, value);
}
node->set_name(get_name());
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index c71a280755..567b1dd7a1 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -2578,6 +2578,16 @@ int Viewport::get_render_info(RenderInfo p_info) {
return VS::get_singleton()->viewport_get_render_info(viewport, VS::ViewportRenderInfo(p_info));
}
+void Viewport::set_snap_controls_to_pixels(bool p_enable) {
+
+ snap_controls_to_pixels = p_enable;
+}
+
+bool Viewport::is_snap_controls_to_pixels_enabled() const {
+
+ return snap_controls_to_pixels;
+}
+
void Viewport::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_use_arvr", "use"), &Viewport::set_use_arvr);
@@ -2680,6 +2690,9 @@ void Viewport::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_shadow_atlas_size", "size"), &Viewport::set_shadow_atlas_size);
ClassDB::bind_method(D_METHOD("get_shadow_atlas_size"), &Viewport::get_shadow_atlas_size);
+ ClassDB::bind_method(D_METHOD("set_snap_controls_to_pixels", "enabled"), &Viewport::set_snap_controls_to_pixels);
+ ClassDB::bind_method(D_METHOD("is_snap_controls_to_pixels_enabled"), &Viewport::is_snap_controls_to_pixels_enabled);
+
ClassDB::bind_method(D_METHOD("set_shadow_atlas_quadrant_subdiv", "quadrant", "subdiv"), &Viewport::set_shadow_atlas_quadrant_subdiv);
ClassDB::bind_method(D_METHOD("get_shadow_atlas_quadrant_subdiv", "quadrant"), &Viewport::get_shadow_atlas_quadrant_subdiv);
@@ -2707,6 +2720,7 @@ void Viewport::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "physics_object_picking"), "set_physics_object_picking", "get_physics_object_picking");
ADD_GROUP("GUI", "gui_");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "gui_disable_input"), "set_disable_input", "is_input_disabled");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "gui_snap_controls_to_pixels"), "set_snap_controls_to_pixels", "is_snap_controls_to_pixels_enabled");
ADD_GROUP("Shadow Atlas", "shadow_atlas_");
ADD_PROPERTY(PropertyInfo(Variant::INT, "shadow_atlas_size"), "set_shadow_atlas_size", "get_shadow_atlas_size");
ADD_PROPERTYI(PropertyInfo(Variant::INT, "shadow_atlas_quad_0", PROPERTY_HINT_ENUM, "Disabled,1 Shadow,4 Shadows,16 Shadows,64 Shadows,256 Shadows,1024 Shadows"), "set_shadow_atlas_quadrant_subdiv", "get_shadow_atlas_quadrant_subdiv", 0);
@@ -2822,6 +2836,8 @@ Viewport::Viewport() {
usage = USAGE_3D;
debug_draw = DEBUG_DRAW_DISABLED;
clear_mode = CLEAR_MODE_ALWAYS;
+
+ snap_controls_to_pixels = true;
}
Viewport::~Viewport() {
diff --git a/scene/main/viewport.h b/scene/main/viewport.h
index ce2bc991f5..6bbd4b26b5 100644
--- a/scene/main/viewport.h
+++ b/scene/main/viewport.h
@@ -1,3 +1,4 @@
+
/*************************************************************************/
/* viewport.h */
/*************************************************************************/
@@ -193,6 +194,8 @@ private:
bool filter;
bool gen_mipmaps;
+ bool snap_controls_to_pixels;
+
bool physics_object_picking;
List<Ref<InputEvent> > physics_picking_events;
ObjectID physics_object_capture;
@@ -463,6 +466,9 @@ public:
int get_render_info(RenderInfo p_info);
+ void set_snap_controls_to_pixels(bool p_enable);
+ bool is_snap_controls_to_pixels_enabled() const;
+
Viewport();
~Viewport();
};
diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp
index e01f5e3cdf..9ed3734a36 100644
--- a/scene/register_scene_types.cpp
+++ b/scene/register_scene_types.cpp
@@ -66,7 +66,6 @@
#include "scene/audio/audio_player.h"
#include "scene/gui/box_container.h"
#include "scene/gui/button.h"
-#include "scene/gui/button_group.h"
#include "scene/gui/center_container.h"
#include "scene/gui/check_box.h"
#include "scene/gui/check_button.h"
@@ -378,6 +377,7 @@ void register_scene_types() {
ClassDB::register_virtual_class<CollisionObject>();
ClassDB::register_class<StaticBody>();
ClassDB::register_class<RigidBody>();
+ ClassDB::register_class<KinematicCollision>();
ClassDB::register_class<KinematicBody>();
ClassDB::register_class<VehicleBody>();
diff --git a/scene/resources/curve.cpp b/scene/resources/curve.cpp
index 7fbaa1f73c..e1ad9e4cb0 100644
--- a/scene/resources/curve.cpp
+++ b/scene/resources/curve.cpp
@@ -331,18 +331,19 @@ real_t Curve::interpolate_local_nocheck(int index, real_t local_offset) const {
const Point a = _points[index];
const Point b = _points[index + 1];
- // Cubic bezier
-
- // ac-----bc
- // / \
- // / \ Here with a.right_tangent > 0
- // / \ and b.left_tangent < 0
- // / \
- // a b
- //
- // |-d1--|-d2--|-d3--|
- //
- // d1 == d2 == d3 == d / 3
+ /* Cubic bezier
+ *
+ * ac-----bc
+ * / \
+ * / \ Here with a.right_tangent > 0
+ * / \ and b.left_tangent < 0
+ * / \
+ * a b
+ *
+ * |-d1--|-d2--|-d3--|
+ *
+ * d1 == d2 == d3 == d / 3
+ */
// Control points are chosen at equal distances
real_t d = b.pos.x - a.pos.x;
diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp
index 4ff635edeb..fdea5960e5 100644
--- a/scene/resources/default_theme/default_theme.cpp
+++ b/scene/resources/default_theme/default_theme.cpp
@@ -794,6 +794,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
// RichTextLabel
theme->set_stylebox("focus", "RichTextLabel", focus);
+ theme->set_stylebox("normal", "RichTextLabel", make_stylebox(tree_bg_png, 3, 3, 3, 3));
theme->set_font("normal_font", "RichTextLabel", default_font);
theme->set_font("bold_font", "RichTextLabel", default_font);
diff --git a/scene/resources/environment.cpp b/scene/resources/environment.cpp
index 14225d945d..da3bc6a95b 100644
--- a/scene/resources/environment.cpp
+++ b/scene/resources/environment.cpp
@@ -269,13 +269,13 @@ Ref<Texture> Environment::get_adjustment_color_correction() const {
void Environment::_validate_property(PropertyInfo &property) const {
if (property.name == "background_sky" || property.name == "background_sky_scale" || property.name == "ambient_light/sky_contribution") {
- if (bg_mode != BG_SKY) {
+ if (bg_mode != BG_SKY && bg_mode != BG_COLOR_SKY) {
property.usage = PROPERTY_USAGE_NOEDITOR;
}
}
if (property.name == "background_color") {
- if (bg_mode != BG_COLOR) {
+ if (bg_mode != BG_COLOR && bg_mode != BG_COLOR_SKY) {
property.usage = PROPERTY_USAGE_NOEDITOR;
}
}
@@ -839,7 +839,7 @@ void Environment::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_ambient_light_sky_contribution"), &Environment::get_ambient_light_sky_contribution);
ADD_GROUP("Background", "background_");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "background_mode", PROPERTY_HINT_ENUM, "Clear Color,Custom Color,Sky,Canvas,Keep"), "set_background", "get_background");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "background_mode", PROPERTY_HINT_ENUM, "Clear Color,Custom Color,Sky,Color+Sky,Canvas,Keep"), "set_background", "get_background");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "background_sky", PROPERTY_HINT_RESOURCE_TYPE, "Sky"), "set_sky", "get_sky");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "background_sky_scale", PROPERTY_HINT_RANGE, "0,32,0.01"), "set_sky_scale", "get_sky_scale");
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "background_color"), "set_bg_color", "get_bg_color");
@@ -1118,6 +1118,7 @@ void Environment::_bind_methods() {
BIND_ENUM_CONSTANT(BG_CLEAR_COLOR);
BIND_ENUM_CONSTANT(BG_COLOR);
BIND_ENUM_CONSTANT(BG_SKY);
+ BIND_ENUM_CONSTANT(BG_COLOR_SKY);
BIND_ENUM_CONSTANT(BG_CANVAS);
BIND_ENUM_CONSTANT(BG_MAX);
diff --git a/scene/resources/environment.h b/scene/resources/environment.h
index 6337981b95..9046ec1e49 100644
--- a/scene/resources/environment.h
+++ b/scene/resources/environment.h
@@ -45,6 +45,7 @@ public:
BG_CLEAR_COLOR,
BG_COLOR,
BG_SKY,
+ BG_COLOR_SKY,
BG_CANVAS,
BG_KEEP,
BG_MAX
diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp
index 3d6a10ffc7..abe9a00c3f 100644
--- a/scene/resources/material.cpp
+++ b/scene/resources/material.cpp
@@ -65,6 +65,12 @@ RID Material::get_rid() const {
return material;
}
+void Material::_validate_property(PropertyInfo &property) const {
+
+ if (!_can_do_next_pass() && property.name == "next_pass") {
+ property.usage = 0;
+ }
+}
void Material::_bind_methods() {
@@ -74,7 +80,7 @@ void Material::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_render_priority", "priority"), &Material::set_render_priority);
ClassDB::bind_method(D_METHOD("get_render_priority"), &Material::get_render_priority);
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "render_priority", PROPERTY_HINT_RANGE, itos(RENDER_PRIORITY_MIN) + "," + itos(RENDER_PRIORITY_MAX) + ",1"), "set_render_priority", "get_render_priority");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "render_priority", PROPERTY_HINT_RANGE, itos(RENDER_PRIORITY_MIN) + "," + itos(RENDER_PRIORITY_MAX) + ",1"), "set_render_priority", "get_render_priority");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "next_pass", PROPERTY_HINT_RESOURCE_TYPE, "Material"), "set_next_pass", "get_next_pass");
BIND_CONSTANT(RENDER_PRIORITY_MAX);
@@ -204,6 +210,11 @@ void ShaderMaterial::get_argument_options(const StringName &p_function, int p_id
Resource::get_argument_options(p_function, p_idx, r_options);
}
+bool ShaderMaterial::_can_do_next_pass() const {
+
+ return shader.is_valid() && shader->get_mode() == Shader::MODE_SPATIAL;
+}
+
ShaderMaterial::ShaderMaterial() {
}
diff --git a/scene/resources/material.h b/scene/resources/material.h
index 4e77ab1ed6..fdb11982a8 100644
--- a/scene/resources/material.h
+++ b/scene/resources/material.h
@@ -53,6 +53,9 @@ class Material : public Resource {
protected:
_FORCE_INLINE_ RID _get_material() const { return material; }
static void _bind_methods();
+ virtual bool _can_do_next_pass() const { return false; }
+
+ void _validate_property(PropertyInfo &property) const;
public:
enum {
@@ -84,6 +87,8 @@ protected:
void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const;
+ virtual bool _can_do_next_pass() const;
+
public:
void set_shader(const Ref<Shader> &p_shader);
Ref<Shader> get_shader() const;
@@ -394,6 +399,7 @@ private:
protected:
static void _bind_methods();
void _validate_property(PropertyInfo &property) const;
+ virtual bool _can_do_next_pass() const { return true; }
public:
void set_albedo(const Color &p_albedo);
diff --git a/scene/resources/mesh.cpp b/scene/resources/mesh.cpp
index aa7827a61a..04efe88102 100644
--- a/scene/resources/mesh.cpp
+++ b/scene/resources/mesh.cpp
@@ -761,7 +761,7 @@ Array ArrayMesh::surface_get_arrays(int p_surface) const {
Array ArrayMesh::surface_get_blend_shape_arrays(int p_surface) const {
ERR_FAIL_INDEX_V(p_surface, surfaces.size(), Array());
- return Array();
+ return VisualServer::get_singleton()->mesh_surface_get_blend_shape_arrays(mesh, p_surface);
}
int ArrayMesh::get_surface_count() const {
@@ -1010,6 +1010,8 @@ void ArrayMesh::_bind_methods() {
ClassDB::bind_method(D_METHOD("surface_get_material", "surf_idx"), &ArrayMesh::surface_get_material);
ClassDB::bind_method(D_METHOD("surface_set_name", "surf_idx", "name"), &ArrayMesh::surface_set_name);
ClassDB::bind_method(D_METHOD("surface_get_name", "surf_idx"), &ArrayMesh::surface_get_name);
+ ClassDB::bind_method(D_METHOD("surface_get_arrays", "surf_idx"), &ArrayMesh::surface_get_arrays);
+ ClassDB::bind_method(D_METHOD("surface_get_blend_shape_arrays", "surf_idx"), &ArrayMesh::surface_get_blend_shape_arrays);
ClassDB::bind_method(D_METHOD("create_trimesh_shape"), &ArrayMesh::create_trimesh_shape);
ClassDB::bind_method(D_METHOD("create_convex_shape"), &ArrayMesh::create_convex_shape);
ClassDB::bind_method(D_METHOD("create_outline", "margin"), &ArrayMesh::create_outline);
diff --git a/scene/resources/mesh.h b/scene/resources/mesh.h
index 53c6eb2d89..f4edb258b6 100644
--- a/scene/resources/mesh.h
+++ b/scene/resources/mesh.h
@@ -120,6 +120,7 @@ public:
virtual int surface_get_array_len(int p_idx) const = 0;
virtual int surface_get_array_index_len(int p_idx) const = 0;
virtual Array surface_get_arrays(int p_surface) const = 0;
+ virtual Array surface_get_blend_shape_arrays(int p_surface) const = 0;
virtual uint32_t surface_get_format(int p_idx) const = 0;
virtual PrimitiveType surface_get_primitive_type(int p_idx) const = 0;
virtual Ref<Material> surface_get_material(int p_idx) const = 0;
@@ -174,7 +175,7 @@ public:
void add_surface(uint32_t p_format, PrimitiveType p_primitive, const PoolVector<uint8_t> &p_array, int p_vertex_count, const PoolVector<uint8_t> &p_index_array, int p_index_count, const Rect3 &p_aabb, const Vector<PoolVector<uint8_t> > &p_blend_shapes = Vector<PoolVector<uint8_t> >(), const Vector<Rect3> &p_bone_aabbs = Vector<Rect3>());
Array surface_get_arrays(int p_surface) const;
- virtual Array surface_get_blend_shape_arrays(int p_surface) const;
+ Array surface_get_blend_shape_arrays(int p_surface) const;
void add_blend_shape(const StringName &p_name);
int get_blend_shape_count() const;
diff --git a/scene/resources/mesh_library.cpp b/scene/resources/mesh_library.cpp
index 4e1ffd2ab3..833a4c3d22 100644
--- a/scene/resources/mesh_library.cpp
+++ b/scene/resources/mesh_library.cpp
@@ -214,7 +214,7 @@ Vector<int> MeshLibrary::get_item_list() const {
return ret;
}
-int MeshLibrary::find_item_name(const String &p_name) const {
+int MeshLibrary::find_item_by_name(const String &p_name) const {
for (Map<int, Item>::Element *E = item_map.front(); E; E = E->next()) {
@@ -275,6 +275,8 @@ void MeshLibrary::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_item_shapes", "id"), &MeshLibrary::_get_item_shapes);
ClassDB::bind_method(D_METHOD("get_item_preview", "id"), &MeshLibrary::get_item_preview);
ClassDB::bind_method(D_METHOD("remove_item", "id"), &MeshLibrary::remove_item);
+ ClassDB::bind_method(D_METHOD("find_item_by_name", "name"), &MeshLibrary::find_item_by_name);
+
ClassDB::bind_method(D_METHOD("clear"), &MeshLibrary::clear);
ClassDB::bind_method(D_METHOD("get_item_list"), &MeshLibrary::get_item_list);
ClassDB::bind_method(D_METHOD("get_last_unused_item_id"), &MeshLibrary::get_last_unused_item_id);
diff --git a/scene/resources/mesh_library.h b/scene/resources/mesh_library.h
index 99b6b48d61..c5d23ce50f 100644
--- a/scene/resources/mesh_library.h
+++ b/scene/resources/mesh_library.h
@@ -84,7 +84,7 @@ public:
void clear();
- int find_item_name(const String &p_name) const;
+ int find_item_by_name(const String &p_name) const;
Vector<int> get_item_list() const;
int get_last_unused_item_id() const;
diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp
index c525ca600a..5d6f44dfef 100644
--- a/scene/resources/packed_scene.cpp
+++ b/scene/resources/packed_scene.cpp
@@ -92,7 +92,7 @@ Node *SceneState::instance(GenEditState p_edit_state) const {
NODE_FROM_ID(nparent, n.parent);
#ifdef DEBUG_ENABLED
- if (!nparent && n.parent & FLAG_ID_IS_PATH) {
+ if (!nparent && (n.parent & FLAG_ID_IS_PATH)) {
WARN_PRINT(String("Parent path '" + String(node_paths[n.parent & FLAG_MASK]) + "' for node '" + String(snames[n.name]) + "' has vanished when instancing: '" + get_path() + "'.").ascii().get_data());
}
@@ -489,7 +489,7 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map
// only save what has been changed
// only save changed properties in instance
- if (E->get().usage & PROPERTY_USAGE_NO_INSTANCE_STATE || E->get().name == "__meta__") {
+ if ((E->get().usage & PROPERTY_USAGE_NO_INSTANCE_STATE) || E->get().name == "__meta__") {
//property has requested that no instance state is saved, sorry
//also, meta won't be overridden or saved
continue;
@@ -1288,7 +1288,7 @@ bool SceneState::is_node_instance_placeholder(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx, nodes.size(), false);
- return nodes[p_idx].instance >= 0 && nodes[p_idx].instance & FLAG_INSTANCE_IS_PLACEHOLDER;
+ return nodes[p_idx].instance >= 0 && (nodes[p_idx].instance & FLAG_INSTANCE_IS_PLACEHOLDER);
}
Ref<PackedScene> SceneState::get_node_instance(int p_idx) const {
@@ -1313,7 +1313,7 @@ String SceneState::get_node_instance_placeholder(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx, nodes.size(), String());
- if (nodes[p_idx].instance >= 0 && nodes[p_idx].instance & FLAG_INSTANCE_IS_PLACEHOLDER) {
+ if (nodes[p_idx].instance >= 0 && (nodes[p_idx].instance & FLAG_INSTANCE_IS_PLACEHOLDER)) {
return variants[nodes[p_idx].instance & FLAG_MASK];
}
diff --git a/scene/resources/primitive_meshes.cpp b/scene/resources/primitive_meshes.cpp
index cfc1468533..ba356d89b1 100644
--- a/scene/resources/primitive_meshes.cpp
+++ b/scene/resources/primitive_meshes.cpp
@@ -105,6 +105,15 @@ Array PrimitiveMesh::surface_get_arrays(int p_surface) const {
return VisualServer::get_singleton()->mesh_surface_get_arrays(mesh, 0);
}
+Array PrimitiveMesh::surface_get_blend_shape_arrays(int p_surface) const {
+ ERR_FAIL_INDEX_V(p_surface, 1, Array());
+ if (pending_request) {
+ _update();
+ }
+
+ return Array();
+}
+
uint32_t PrimitiveMesh::surface_get_format(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx, 1, 0);
if (pending_request) {
@@ -119,6 +128,8 @@ Mesh::PrimitiveType PrimitiveMesh::surface_get_primitive_type(int p_idx) const {
}
Ref<Material> PrimitiveMesh::surface_get_material(int p_idx) const {
+ ERR_FAIL_INDEX_V(p_idx, 1, NULL);
+
return material;
}
@@ -151,6 +162,8 @@ void PrimitiveMesh::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_material", "material"), &PrimitiveMesh::set_material);
ClassDB::bind_method(D_METHOD("get_material"), &PrimitiveMesh::get_material);
+ ClassDB::bind_method(D_METHOD("get_mesh_arrays"), &PrimitiveMesh::get_mesh_arrays);
+
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "Material"), "set_material", "get_material");
}
@@ -168,6 +181,10 @@ Ref<Material> PrimitiveMesh::get_material() const {
return material;
}
+Array PrimitiveMesh::get_mesh_arrays() const {
+ return surface_get_arrays(0);
+}
+
PrimitiveMesh::PrimitiveMesh() {
// defaults
mesh = VisualServer::get_singleton()->mesh_create();
@@ -213,7 +230,6 @@ void CapsuleMesh::_create_mesh_array(Array &p_arr) const {
prevrow = 0;
for (j = 0; j <= (rings + 1); j++) {
v = j;
- w;
v /= (rings + 1);
w = sin(0.5 * Math_PI * v);
@@ -292,7 +308,6 @@ void CapsuleMesh::_create_mesh_array(Array &p_arr) const {
prevrow = 0;
for (j = 0; j <= (rings + 1); j++) {
v = j;
- w;
v /= (rings + 1);
v += 1.0;
diff --git a/scene/resources/primitive_meshes.h b/scene/resources/primitive_meshes.h
index 34fb75a196..38a5695883 100644
--- a/scene/resources/primitive_meshes.h
+++ b/scene/resources/primitive_meshes.h
@@ -67,6 +67,7 @@ public:
virtual int surface_get_array_len(int p_idx) const;
virtual int surface_get_array_index_len(int p_idx) const;
virtual Array surface_get_arrays(int p_surface) const;
+ virtual Array surface_get_blend_shape_arrays(int p_surface) const;
virtual uint32_t surface_get_format(int p_idx) const;
virtual Mesh::PrimitiveType surface_get_primitive_type(int p_idx) const;
virtual Ref<Material> surface_get_material(int p_idx) const;
@@ -78,6 +79,8 @@ public:
void set_material(const Ref<Material> &p_material);
Ref<Material> get_material() const;
+ Array get_mesh_arrays() const;
+
PrimitiveMesh();
~PrimitiveMesh();
};
diff --git a/servers/arvr/arvr_positional_tracker.cpp b/servers/arvr/arvr_positional_tracker.cpp
index 539bac6703..4ecd7a3898 100644
--- a/servers/arvr/arvr_positional_tracker.cpp
+++ b/servers/arvr/arvr_positional_tracker.cpp
@@ -31,6 +31,10 @@
#include "core/os/input.h"
void ARVRPositionalTracker::_bind_methods() {
+ BIND_ENUM_CONSTANT(TRACKER_HAND_UNKNOWN);
+ BIND_ENUM_CONSTANT(TRACKER_LEFT_HAND);
+ BIND_ENUM_CONSTANT(TRACKER_RIGHT_HAND);
+
// this class is read only from GDScript, so we only have access to getters..
ClassDB::bind_method(D_METHOD("get_type"), &ARVRPositionalTracker::get_type);
ClassDB::bind_method(D_METHOD("get_name"), &ARVRPositionalTracker::get_name);
@@ -39,6 +43,7 @@ void ARVRPositionalTracker::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_orientation"), &ARVRPositionalTracker::get_orientation);
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_hand"), &ARVRPositionalTracker::get_hand);
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
@@ -141,6 +146,14 @@ Vector3 ARVRPositionalTracker::get_rw_position() const {
return rw_position;
};
+ARVRPositionalTracker::TrackerHand ARVRPositionalTracker::get_hand() const {
+ return hand;
+};
+
+void ARVRPositionalTracker::set_hand(const ARVRPositionalTracker::TrackerHand p_hand) {
+ hand = p_hand;
+};
+
Transform ARVRPositionalTracker::get_transform(bool p_adjust_by_reference_frame) const {
Transform new_transform;
@@ -164,6 +177,7 @@ ARVRPositionalTracker::ARVRPositionalTracker() {
tracker_id = 0;
tracks_orientation = false;
tracks_position = false;
+ hand = TRACKER_HAND_UNKNOWN;
};
ARVRPositionalTracker::~ARVRPositionalTracker(){
diff --git a/servers/arvr/arvr_positional_tracker.h b/servers/arvr/arvr_positional_tracker.h
index f91f862ba3..ff0c150f89 100644
--- a/servers/arvr/arvr_positional_tracker.h
+++ b/servers/arvr/arvr_positional_tracker.h
@@ -48,6 +48,13 @@ class ARVRPositionalTracker : public Object {
GDCLASS(ARVRPositionalTracker, Object);
_THREAD_SAFE_CLASS_
+public:
+ enum TrackerHand {
+ TRACKER_HAND_UNKNOWN, /* unknown or not applicable */
+ TRACKER_LEFT_HAND, /* controller is the left hand controller */
+ TRACKER_RIGHT_HAND /* controller is the right hand controller */
+ };
+
private:
ARVRServer::TrackerType type; // type of tracker
StringName name; // (unique) name of the tracker
@@ -57,6 +64,7 @@ private:
Basis orientation; // our orientation
bool tracks_position; // do we track position?
Vector3 rw_position; // our position "in the real world, so without world_scale applied"
+ TrackerHand hand; // if known, the hand this tracker is held in
protected:
static void _bind_methods();
@@ -77,6 +85,8 @@ public:
Vector3 get_position() const; // get position with world_scale applied
void set_rw_position(const Vector3 &p_rw_position);
Vector3 get_rw_position() const;
+ ARVRPositionalTracker::TrackerHand get_hand() const;
+ void set_hand(const ARVRPositionalTracker::TrackerHand p_hand);
Transform get_transform(bool p_adjust_by_reference_frame) const;
@@ -84,4 +94,6 @@ public:
~ARVRPositionalTracker();
};
+VARIANT_ENUM_CAST(ARVRPositionalTracker::TrackerHand);
+
#endif
diff --git a/servers/arvr_server.cpp b/servers/arvr_server.cpp
index bac24f6438..3308e1cc07 100644
--- a/servers/arvr_server.cpp
+++ b/servers/arvr_server.cpp
@@ -68,8 +68,8 @@ void ARVRServer::_bind_methods() {
ADD_SIGNAL(MethodInfo("interface_added", PropertyInfo(Variant::STRING, "name")));
ADD_SIGNAL(MethodInfo("interface_removed", PropertyInfo(Variant::STRING, "name")));
- ADD_SIGNAL(MethodInfo("tracker_added", PropertyInfo(Variant::STRING, "name"), PropertyInfo(Variant::INT, "type")));
- ADD_SIGNAL(MethodInfo("tracker_removed", PropertyInfo(Variant::STRING, "name")));
+ ADD_SIGNAL(MethodInfo("tracker_added", PropertyInfo(Variant::STRING, "name"), PropertyInfo(Variant::INT, "type"), PropertyInfo(Variant::INT, "id")));
+ ADD_SIGNAL(MethodInfo("tracker_removed", PropertyInfo(Variant::STRING, "name"), PropertyInfo(Variant::INT, "type"), PropertyInfo(Variant::INT, "id")));
};
real_t ARVRServer::get_world_scale() const {
@@ -232,7 +232,7 @@ void ARVRServer::add_tracker(ARVRPositionalTracker *p_tracker) {
ERR_FAIL_NULL(p_tracker);
trackers.push_back(p_tracker);
- emit_signal("tracker_added", p_tracker->get_name(), p_tracker->get_type());
+ emit_signal("tracker_added", p_tracker->get_name(), p_tracker->get_type(), p_tracker->get_tracker_id());
};
void ARVRServer::remove_tracker(ARVRPositionalTracker *p_tracker) {
@@ -250,7 +250,7 @@ void ARVRServer::remove_tracker(ARVRPositionalTracker *p_tracker) {
ERR_FAIL_COND(idx == -1);
- emit_signal("tracker_removed", p_tracker->get_name());
+ emit_signal("tracker_removed", p_tracker->get_name(), p_tracker->get_type(), p_tracker->get_tracker_id());
trackers.remove(idx);
};
diff --git a/servers/audio_server.cpp b/servers/audio_server.cpp
index 3139c6bb7a..29014a7ced 100644
--- a/servers/audio_server.cpp
+++ b/servers/audio_server.cpp
@@ -203,8 +203,9 @@ void AudioServer::_mix_step() {
if (!bus_map.has(bus->send)) {
bus = buses[0]; //send to master
} else {
+ int prev_index_cache = bus->index_cache;
bus = bus_map[bus->send];
- if (bus->index_cache >= bus->index_cache) { //invalid, send to master
+ if (prev_index_cache >= bus->index_cache) { //invalid, send to master
bus = buses[0];
}
}
diff --git a/servers/physics/broad_phase_basic.cpp b/servers/physics/broad_phase_basic.cpp
index 959718a252..c6565ac2e9 100644
--- a/servers/physics/broad_phase_basic.cpp
+++ b/servers/physics/broad_phase_basic.cpp
@@ -30,9 +30,10 @@
#include "broad_phase_basic.h"
#include "list.h"
#include "print_string.h"
+
BroadPhaseSW::ID BroadPhaseBasic::create(CollisionObjectSW *p_object, int p_subindex) {
- ERR_FAIL_COND_V(p_object == NULL, NULL);
+ ERR_FAIL_COND_V(p_object == NULL, 0);
current++;
diff --git a/servers/physics/collision_object_sw.cpp b/servers/physics/collision_object_sw.cpp
index ab716a8f6e..3af8b542fa 100644
--- a/servers/physics/collision_object_sw.cpp
+++ b/servers/physics/collision_object_sw.cpp
@@ -28,6 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "collision_object_sw.h"
+#include "servers/physics/physics_server_sw.h"
#include "space_sw.h"
void CollisionObjectSW::add_shape(ShapeSW *p_shape, const Transform &p_transform) {
@@ -39,8 +40,12 @@ void CollisionObjectSW::add_shape(ShapeSW *p_shape, const Transform &p_transform
s.bpid = 0; //needs update
shapes.push_back(s);
p_shape->add_owner(this);
- _update_shapes();
- _shapes_changed();
+
+ if (!pending_shape_update_list.in_list()) {
+ PhysicsServerSW::singleton->pending_shape_update_list.add(&pending_shape_update_list);
+ }
+ //_update_shapes();
+ //_shapes_changed();
}
void CollisionObjectSW::set_shape(int p_index, ShapeSW *p_shape) {
@@ -50,8 +55,11 @@ void CollisionObjectSW::set_shape(int p_index, ShapeSW *p_shape) {
shapes[p_index].shape = p_shape;
p_shape->add_owner(this);
- _update_shapes();
- _shapes_changed();
+ if (!pending_shape_update_list.in_list()) {
+ PhysicsServerSW::singleton->pending_shape_update_list.add(&pending_shape_update_list);
+ }
+ //_update_shapes();
+ //_shapes_changed();
}
void CollisionObjectSW::set_shape_transform(int p_index, const Transform &p_transform) {
@@ -59,8 +67,11 @@ void CollisionObjectSW::set_shape_transform(int p_index, const Transform &p_tran
shapes[p_index].xform = p_transform;
shapes[p_index].xform_inv = p_transform.affine_inverse();
- _update_shapes();
- _shapes_changed();
+ if (!pending_shape_update_list.in_list()) {
+ PhysicsServerSW::singleton->pending_shape_update_list.add(&pending_shape_update_list);
+ }
+ //_update_shapes();
+ //_shapes_changed();
}
void CollisionObjectSW::remove_shape(ShapeSW *p_shape) {
@@ -90,7 +101,11 @@ void CollisionObjectSW::remove_shape(int p_index) {
shapes[p_index].shape->remove_owner(this);
shapes.remove(p_index);
- _shapes_changed();
+ if (!pending_shape_update_list.in_list()) {
+ PhysicsServerSW::singleton->pending_shape_update_list.add(&pending_shape_update_list);
+ }
+ //_update_shapes();
+ //_shapes_changed();
}
void CollisionObjectSW::_set_static(bool p_static) {
@@ -202,7 +217,8 @@ void CollisionObjectSW::_shape_changed() {
_shapes_changed();
}
-CollisionObjectSW::CollisionObjectSW(Type p_type) {
+CollisionObjectSW::CollisionObjectSW(Type p_type)
+ : pending_shape_update_list(this) {
_static = true;
type = p_type;
diff --git a/servers/physics/collision_object_sw.h b/servers/physics/collision_object_sw.h
index dc988aae86..67a8a44944 100644
--- a/servers/physics/collision_object_sw.h
+++ b/servers/physics/collision_object_sw.h
@@ -75,6 +75,8 @@ private:
Transform inv_transform;
bool _static;
+ SelfList<CollisionObjectSW> pending_shape_update_list;
+
void _update_shapes();
protected:
diff --git a/servers/physics/physics_server_sw.cpp b/servers/physics/physics_server_sw.cpp
index 8d6f7b3fd8..2d46770924 100644
--- a/servers/physics/physics_server_sw.cpp
+++ b/servers/physics/physics_server_sw.cpp
@@ -763,6 +763,8 @@ void PhysicsServerSW::body_apply_impulse(RID p_body, const Vector3 &p_pos, const
BodySW *body = body_owner.get(p_body);
ERR_FAIL_COND(!body);
+ _update_shapes();
+
body->apply_impulse(p_pos, p_impulse);
body->wakeup();
};
@@ -772,6 +774,8 @@ void PhysicsServerSW::body_apply_torque_impulse(RID p_body, const Vector3 &p_imp
BodySW *body = body_owner.get(p_body);
ERR_FAIL_COND(!body);
+ _update_shapes();
+
body->apply_torque_impulse(p_impulse);
body->wakeup();
};
@@ -781,6 +785,8 @@ void PhysicsServerSW::body_set_axis_velocity(RID p_body, const Vector3 &p_axis_v
BodySW *body = body_owner.get(p_body);
ERR_FAIL_COND(!body);
+ _update_shapes();
+
Vector3 v = body->get_linear_velocity();
Vector3 axis = p_axis_velocity.normalized();
v -= axis * axis.dot(v);
@@ -793,6 +799,7 @@ void PhysicsServerSW::body_set_axis_lock(RID p_body, BodyAxisLock p_lock) {
BodySW *body = body_owner.get(p_body);
ERR_FAIL_COND(!body);
+
body->set_axis_lock(p_lock);
body->wakeup();
}
@@ -902,6 +909,8 @@ bool PhysicsServerSW::body_test_motion(RID p_body, const Transform &p_from, cons
ERR_FAIL_COND_V(!body->get_space(), false);
ERR_FAIL_COND_V(body->get_space()->is_locked(), false);
+ _update_shapes();
+
return body->get_space()->test_body_motion(body, p_from, p_motion, p_margin, r_result);
}
@@ -1209,6 +1218,8 @@ bool PhysicsServerSW::generic_6dof_joint_get_flag(RID p_joint, Vector3::Axis p_a
void PhysicsServerSW::free(RID p_rid) {
+ _update_shapes(); //just in case
+
if (shape_owner.owns(p_rid)) {
ShapeSW *shape = shape_owner.get(p_rid);
@@ -1312,6 +1323,8 @@ void PhysicsServerSW::step(real_t p_step) {
if (!active)
return;
+ _update_shapes();
+
doing_sync = false;
last_step = p_step;
@@ -1409,6 +1422,14 @@ int PhysicsServerSW::get_process_info(ProcessInfo p_info) {
return 0;
}
+void PhysicsServerSW::_update_shapes() {
+
+ while (pending_shape_update_list.first()) {
+ pending_shape_update_list.first()->self()->_shape_changed();
+ pending_shape_update_list.remove(pending_shape_update_list.first());
+ }
+}
+
void PhysicsServerSW::_shape_col_cbk(const Vector3 &p_point_A, const Vector3 &p_point_B, void *p_userdata) {
CollCbkData *cbk = (CollCbkData *)p_userdata;
diff --git a/servers/physics/physics_server_sw.h b/servers/physics/physics_server_sw.h
index 2e1fa7065a..99ba302acd 100644
--- a/servers/physics/physics_server_sw.h
+++ b/servers/physics/physics_server_sw.h
@@ -62,6 +62,10 @@ class PhysicsServerSW : public PhysicsServer {
mutable RID_Owner<JointSW> joint_owner;
//void _clear_query(QuerySW *p_query);
+ friend class CollisionObjectSW;
+ SelfList<CollisionObjectSW>::List pending_shape_update_list;
+ void _update_shapes();
+
public:
static PhysicsServerSW *singleton;
diff --git a/servers/visual/rasterizer.h b/servers/visual/rasterizer.h
index 187a0b180b..344c10089a 100644
--- a/servers/visual/rasterizer.h
+++ b/servers/visual/rasterizer.h
@@ -335,6 +335,8 @@ public:
virtual void light_directional_set_shadow_mode(RID p_light, VS::LightDirectionalShadowMode p_mode) = 0;
virtual void light_directional_set_blend_splits(RID p_light, bool p_enable) = 0;
virtual bool light_directional_get_blend_splits(RID p_light) const = 0;
+ virtual void light_directional_set_shadow_depth_range_mode(RID p_light, VS::LightDirectionalShadowDepthRangeMode p_range_mode) = 0;
+ virtual VS::LightDirectionalShadowDepthRangeMode light_directional_get_shadow_depth_range_mode(RID p_light) const = 0;
virtual VS::LightDirectionalShadowMode light_directional_get_shadow_mode(RID p_light) = 0;
virtual VS::LightOmniShadowMode light_omni_get_shadow_mode(RID p_light) = 0;
diff --git a/servers/visual/shader_language.cpp b/servers/visual/shader_language.cpp
index 0684cb1701..c7b02c92f7 100644
--- a/servers/visual/shader_language.cpp
+++ b/servers/visual/shader_language.cpp
@@ -79,7 +79,11 @@ String ShaderLanguage::get_operator_text(Operator p_op) {
"|",
"^",
"~",
- "++"
+ "++",
+ "--",
+ "?",
+ ":",
+ "++",
"--",
"()",
"construct",
@@ -3116,6 +3120,12 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Dat
tk = _get_token();
+ VariableDeclarationNode *vardecl = alloc_node<VariableDeclarationNode>();
+ vardecl->datatype=type;
+ vardecl->precision=precision;
+
+ p_block->statements.push_back(vardecl);
+
while (true) {
if (tk.type != TK_IDENTIFIER) {
@@ -3133,8 +3143,14 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Dat
var.type = type;
var.precision = precision;
var.line = tk_line;
+
p_block->variables[name] = var;
+ VariableDeclarationNode::Declaration decl;
+
+ decl.name=name;
+ decl.initializer=NULL;
+
tk = _get_token();
if (tk.type == TK_OP_ASSIGN) {
@@ -3143,22 +3159,19 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Dat
if (!n)
return ERR_PARSE_ERROR;
- OperatorNode *assign = alloc_node<OperatorNode>();
- VariableNode *vnode = alloc_node<VariableNode>();
- vnode->name = name;
- vnode->datatype_cache = type;
- assign->arguments.push_back(vnode);
- assign->arguments.push_back(n);
- assign->op = OP_ASSIGN;
- p_block->statements.push_back(assign);
- tk = _get_token();
+ decl.initializer = n;
- if (!_validate_operator(assign)) {
- _set_error("Invalid assignment of '" + get_datatype_name(n->get_datatype()) + "' to '" + get_datatype_name(type) + "'");
+ if (var.type!=n->get_datatype()) {
+ _set_error("Invalid assignment of '" + get_datatype_name(n->get_datatype()) + "' to '" + get_datatype_name(var.type) + "'");
return ERR_PARSE_ERROR;
+
}
+ tk = _get_token();
+
}
+ vardecl->declarations.push_back(decl);
+
if (tk.type == TK_COMMA) {
tk = _get_token();
//another variable
@@ -3221,7 +3234,7 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Dat
//if () {}
tk = _get_token();
if (tk.type != TK_PARENTHESIS_OPEN) {
- _set_error("Expected '(' after if");
+ _set_error("Expected '(' after while");
return ERR_PARSE_ERROR;
}
@@ -3243,7 +3256,64 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Dat
cf->blocks.push_back(block);
p_block->statements.push_back(cf);
- Error err = _parse_block(block, p_builtin_types, true, p_can_break, p_can_continue);
+ Error err = _parse_block(block, p_builtin_types, true, true, true);
+ if (err)
+ return err;
+ } else if (tk.type == TK_CF_FOR) {
+ //if () {}
+ tk = _get_token();
+ if (tk.type != TK_PARENTHESIS_OPEN) {
+ _set_error("Expected '(' after for");
+ return ERR_PARSE_ERROR;
+ }
+
+ ControlFlowNode *cf = alloc_node<ControlFlowNode>();
+ cf->flow_op = FLOW_OP_FOR;
+
+ BlockNode *init_block = alloc_node<BlockNode>();
+ init_block->parent_block = p_block;
+ init_block->single_statement=true;
+ cf->blocks.push_back(init_block);
+ if (_parse_block(init_block,p_builtin_types,true,false,false)!=OK) {
+ return ERR_PARSE_ERROR;
+ }
+
+ Node *n = _parse_and_reduce_expression(init_block, p_builtin_types);
+ if (!n)
+ return ERR_PARSE_ERROR;
+
+ if (n->get_datatype()!=TYPE_BOOL) {
+ _set_error("Middle expression is expected to be boolean.");
+ return ERR_PARSE_ERROR;
+
+ }
+
+ tk = _get_token();
+ if (tk.type != TK_SEMICOLON) {
+ _set_error("Expected ';' after middle expression");
+ return ERR_PARSE_ERROR;
+ }
+
+ cf->expressions.push_back(n);
+
+ n = _parse_and_reduce_expression(init_block, p_builtin_types);
+ if (!n)
+ return ERR_PARSE_ERROR;
+
+ cf->expressions.push_back(n);
+
+ tk = _get_token();
+ if (tk.type != TK_PARENTHESIS_CLOSE) {
+ _set_error("Expected ')' after third expression");
+ return ERR_PARSE_ERROR;
+ }
+
+ BlockNode *block = alloc_node<BlockNode>();
+ block->parent_block = p_block;
+ cf->blocks.push_back(block);
+ p_block->statements.push_back(cf);
+
+ Error err = _parse_block(block, p_builtin_types, true, true, true);
if (err)
return err;
@@ -3320,6 +3390,44 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Dat
}
p_block->statements.push_back(flow);
+ } else if (tk.type == TK_CF_BREAK) {
+
+
+ if (!p_can_break) {
+ //all is good
+ _set_error("Breaking is not allowed here");
+ }
+
+ ControlFlowNode *flow = alloc_node<ControlFlowNode>();
+ flow->flow_op = FLOW_OP_BREAK;
+
+ pos = _get_tkpos();
+ tk = _get_token();
+ if (tk.type != TK_SEMICOLON) {
+ //all is good
+ _set_error("Expected ';' after break");
+ }
+
+ p_block->statements.push_back(flow);
+ } else if (tk.type == TK_CF_CONTINUE) {
+
+
+ if (!p_can_break) {
+ //all is good
+ _set_error("Contiuning is not allowed here");
+ }
+
+ ControlFlowNode *flow = alloc_node<ControlFlowNode>();
+ flow->flow_op = FLOW_OP_CONTINUE;
+
+ pos = _get_tkpos();
+ tk = _get_token();
+ if (tk.type != TK_SEMICOLON) {
+ //all is good
+ _set_error("Expected ';' after continue");
+ }
+
+ p_block->statements.push_back(flow);
} else {
diff --git a/servers/visual/shader_language.h b/servers/visual/shader_language.h
index f00b4c5a97..50f5cebeaa 100644
--- a/servers/visual/shader_language.h
+++ b/servers/visual/shader_language.h
@@ -266,6 +266,7 @@ public:
TYPE_FUNCTION,
TYPE_BLOCK,
TYPE_VARIABLE,
+ TYPE_VARIABLE_DECLARATION,
TYPE_CONSTANT,
TYPE_OPERATOR,
TYPE_CONTROL_FLOW,
@@ -315,6 +316,25 @@ public:
}
};
+ struct VariableDeclarationNode : public Node {
+
+ DataPrecision precision;
+ DataType datatype;
+
+ struct Declaration {
+
+ StringName name;
+ Node *initializer;
+ };
+
+ Vector<Declaration> declarations;
+ virtual DataType get_datatype() const { return datatype; }
+
+ VariableDeclarationNode() {
+ type = TYPE_VARIABLE_DECLARATION;
+ }
+ };
+
struct ConstantNode : public Node {
DataType datatype;
@@ -346,10 +366,12 @@ public:
Map<StringName, Variable> variables;
List<Node *> statements;
+ bool single_statement;
BlockNode() {
type = TYPE_BLOCK;
parent_block = NULL;
parent_function = NULL;
+ single_statement=false;
}
};
diff --git a/servers/visual/visual_server_raster.h b/servers/visual/visual_server_raster.h
index 3953bc5f48..7c7ce46268 100644
--- a/servers/visual/visual_server_raster.h
+++ b/servers/visual/visual_server_raster.h
@@ -795,6 +795,7 @@ public:
BIND2(light_directional_set_shadow_mode, RID, LightDirectionalShadowMode)
BIND2(light_directional_set_blend_splits, RID, bool)
+ BIND2(light_directional_set_shadow_depth_range_mode, RID, LightDirectionalShadowDepthRangeMode)
/* PROBE API */
diff --git a/servers/visual/visual_server_scene.cpp b/servers/visual/visual_server_scene.cpp
index 0d70b7fc0e..48ce9e7288 100644
--- a/servers/visual/visual_server_scene.cpp
+++ b/servers/visual/visual_server_scene.cpp
@@ -101,7 +101,7 @@ void *VisualServerScene::_instance_pair(void *p_self, OctreeElementID, Instance
SWAP(A, B); //lesser always first
}
- if (B->base_type == VS::INSTANCE_LIGHT && (1 << A->base_type) & VS::INSTANCE_GEOMETRY_MASK) {
+ if (B->base_type == VS::INSTANCE_LIGHT && ((1 << A->base_type) & VS::INSTANCE_GEOMETRY_MASK)) {
InstanceLightData *light = static_cast<InstanceLightData *>(B->base_data);
InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data);
@@ -119,7 +119,7 @@ void *VisualServerScene::_instance_pair(void *p_self, OctreeElementID, Instance
geom->lighting_dirty = true;
return E; //this element should make freeing faster
- } else if (B->base_type == VS::INSTANCE_REFLECTION_PROBE && (1 << A->base_type) & VS::INSTANCE_GEOMETRY_MASK) {
+ } else if (B->base_type == VS::INSTANCE_REFLECTION_PROBE && ((1 << A->base_type) & VS::INSTANCE_GEOMETRY_MASK)) {
InstanceReflectionProbeData *reflection_probe = static_cast<InstanceReflectionProbeData *>(B->base_data);
InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data);
@@ -133,7 +133,7 @@ void *VisualServerScene::_instance_pair(void *p_self, OctreeElementID, Instance
geom->reflection_dirty = true;
return E; //this element should make freeing faster
- } else if (B->base_type == VS::INSTANCE_GI_PROBE && (1 << A->base_type) & VS::INSTANCE_GEOMETRY_MASK) {
+ } else if (B->base_type == VS::INSTANCE_GI_PROBE && ((1 << A->base_type) & VS::INSTANCE_GEOMETRY_MASK)) {
InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(B->base_data);
InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data);
@@ -169,7 +169,7 @@ void VisualServerScene::_instance_unpair(void *p_self, OctreeElementID, Instance
SWAP(A, B); //lesser always first
}
- if (B->base_type == VS::INSTANCE_LIGHT && (1 << A->base_type) & VS::INSTANCE_GEOMETRY_MASK) {
+ if (B->base_type == VS::INSTANCE_LIGHT && ((1 << A->base_type) & VS::INSTANCE_GEOMETRY_MASK)) {
InstanceLightData *light = static_cast<InstanceLightData *>(B->base_data);
InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data);
@@ -184,7 +184,7 @@ void VisualServerScene::_instance_unpair(void *p_self, OctreeElementID, Instance
}
geom->lighting_dirty = true;
- } else if (B->base_type == VS::INSTANCE_REFLECTION_PROBE && (1 << A->base_type) & VS::INSTANCE_GEOMETRY_MASK) {
+ } else if (B->base_type == VS::INSTANCE_REFLECTION_PROBE && ((1 << A->base_type) & VS::INSTANCE_GEOMETRY_MASK)) {
InstanceReflectionProbeData *reflection_probe = static_cast<InstanceReflectionProbeData *>(B->base_data);
InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data);
@@ -196,7 +196,7 @@ void VisualServerScene::_instance_unpair(void *p_self, OctreeElementID, Instance
geom->reflection_dirty = true;
- } else if (B->base_type == VS::INSTANCE_GI_PROBE && (1 << A->base_type) & VS::INSTANCE_GEOMETRY_MASK) {
+ } else if (B->base_type == VS::INSTANCE_GI_PROBE && ((1 << A->base_type) & VS::INSTANCE_GEOMETRY_MASK)) {
InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(B->base_data);
InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data);
@@ -886,12 +886,53 @@ void VisualServerScene::_light_instance_update_shadow(Instance *p_instance, cons
float max_distance = p_cam_projection.get_z_far();
float shadow_max = VSG::storage->light_get_param(p_instance->base, VS::LIGHT_PARAM_SHADOW_MAX_DISTANCE);
- if (shadow_max > 0) {
+ if (shadow_max > 0 && !p_cam_orthogonal) { //its impractical (and leads to unwanted behaviors) to set max distance in orthogonal camera
max_distance = MIN(shadow_max, max_distance);
}
max_distance = MAX(max_distance, p_cam_projection.get_z_near() + 0.001);
+ float min_distance = MIN(p_cam_projection.get_z_near(), max_distance);
- float range = max_distance - p_cam_projection.get_z_near();
+ VS::LightDirectionalShadowDepthRangeMode depth_range_mode = VSG::storage->light_directional_get_shadow_depth_range_mode(p_instance->base);
+
+ if (depth_range_mode == VS::LIGHT_DIRECTIONAL_SHADOW_DEPTH_RANGE_OPTIMIZED) {
+ //optimize min/max
+ Vector<Plane> planes = p_cam_projection.get_projection_planes(p_cam_transform);
+ int cull_count = p_scenario->octree.cull_convex(planes, instance_shadow_cull_result, MAX_INSTANCE_CULL, VS::INSTANCE_GEOMETRY_MASK);
+ Plane base(p_cam_transform.origin, -p_cam_transform.basis.get_axis(2));
+ //check distance max and min
+
+ bool found_items = false;
+ float z_max = -1e20;
+ float z_min = 1e20;
+
+ for (int i = 0; i < cull_count; i++) {
+
+ Instance *instance = instance_shadow_cull_result[i];
+ if (!instance->visible || !((1 << instance->base_type) & VS::INSTANCE_GEOMETRY_MASK) || !static_cast<InstanceGeometryData *>(instance->base_data)->can_cast_shadows) {
+ continue;
+ }
+
+ float max, min;
+ instance->transformed_aabb.project_range_in_plane(base, min, max);
+
+ if (max > z_max) {
+ z_max = max;
+ }
+
+ if (min < z_min) {
+ z_min = min;
+ }
+
+ found_items = true;
+ }
+
+ if (found_items) {
+ min_distance = MAX(min_distance, z_min);
+ max_distance = MIN(max_distance, z_max);
+ }
+ }
+
+ float range = max_distance - min_distance;
int splits = 0;
switch (VSG::storage->light_directional_get_shadow_mode(p_instance->base)) {
@@ -902,9 +943,9 @@ void VisualServerScene::_light_instance_update_shadow(Instance *p_instance, cons
float distances[5];
- distances[0] = p_cam_projection.get_z_near();
+ distances[0] = min_distance;
for (int i = 0; i < splits; i++) {
- distances[i + 1] = p_cam_projection.get_z_near() + VSG::storage->light_get_param(p_instance->base, VS::LightParam(VS::LIGHT_PARAM_SHADOW_SPLIT_1_OFFSET + i)) * range;
+ distances[i + 1] = min_distance + VSG::storage->light_get_param(p_instance->base, VS::LightParam(VS::LIGHT_PARAM_SHADOW_SPLIT_1_OFFSET + i)) * range;
};
distances[splits] = max_distance;
@@ -984,8 +1025,6 @@ void VisualServerScene::_light_instance_update_shadow(Instance *p_instance, cons
{
//camera viewport stuff
- //this trick here is what stabilizes the shadow (make potential jaggies to not move)
- //at the cost of some wasted resolution. Still the quality increase is very well worth it
Vector3 center;
@@ -1006,7 +1045,7 @@ void VisualServerScene::_light_instance_update_shadow(Instance *p_instance, cons
radius = d;
}
- radius *= texture_size / (texture_size - 2.0); //add a texel by each side, so stepified texture will always fit
+ radius *= texture_size / (texture_size - 2.0); //add a texel by each side
if (i == 0) {
first_radius = radius;
@@ -1021,12 +1060,17 @@ void VisualServerScene::_light_instance_update_shadow(Instance *p_instance, cons
z_max_cam = z_vec.dot(center) + radius;
z_min_cam = z_vec.dot(center) - radius;
- float unit = radius * 2.0 / texture_size;
+ if (depth_range_mode == VS::LIGHT_DIRECTIONAL_SHADOW_DEPTH_RANGE_STABLE) {
+ //this trick here is what stabilizes the shadow (make potential jaggies to not move)
+ //at the cost of some wasted resolution. Still the quality increase is very well worth it
+
+ float unit = radius * 2.0 / texture_size;
- x_max_cam = Math::stepify(x_max_cam, unit);
- x_min_cam = Math::stepify(x_min_cam, unit);
- y_max_cam = Math::stepify(y_max_cam, unit);
- y_min_cam = Math::stepify(y_min_cam, unit);
+ x_max_cam = Math::stepify(x_max_cam, unit);
+ x_min_cam = Math::stepify(x_min_cam, unit);
+ y_max_cam = Math::stepify(y_max_cam, unit);
+ y_min_cam = Math::stepify(y_min_cam, unit);
+ }
}
//now that we now all ranges, we can proceed to make the light frustum planes, for culling octree
@@ -1069,6 +1113,7 @@ void VisualServerScene::_light_instance_update_shadow(Instance *p_instance, cons
}
{
+
CameraMatrix ortho_camera;
real_t half_x = (x_max_cam - x_min_cam) * 0.5;
real_t half_y = (y_max_cam - y_min_cam) * 0.5;
@@ -1375,7 +1420,7 @@ void VisualServerScene::_render_scene(const Transform p_cam_transform, const Cam
gi_probe_update_list.add(&gi_probe->update_element);
}
- } else if ((1 << ins->base_type) & VS::INSTANCE_GEOMETRY_MASK && ins->visible && ins->cast_shadows != VS::SHADOW_CASTING_SETTING_SHADOWS_ONLY) {
+ } else if (((1 << ins->base_type) & VS::INSTANCE_GEOMETRY_MASK) && ins->visible && ins->cast_shadows != VS::SHADOW_CASTING_SETTING_SHADOWS_ONLY) {
keep = true;
diff --git a/servers/visual/visual_server_wrap_mt.h b/servers/visual/visual_server_wrap_mt.h
index f24049be92..5cf941b93d 100644
--- a/servers/visual/visual_server_wrap_mt.h
+++ b/servers/visual/visual_server_wrap_mt.h
@@ -233,6 +233,7 @@ public:
FUNC2(light_directional_set_shadow_mode, RID, LightDirectionalShadowMode)
FUNC2(light_directional_set_blend_splits, RID, bool)
+ FUNC2(light_directional_set_shadow_depth_range_mode, RID, LightDirectionalShadowDepthRangeMode)
/* PROBE API */
diff --git a/servers/visual_server.cpp b/servers/visual_server.cpp
index 67b847d127..47a5f4c7f3 100644
--- a/servers/visual_server.cpp
+++ b/servers/visual_server.cpp
@@ -1420,6 +1420,29 @@ Array VisualServer::mesh_surface_get_arrays(RID p_mesh, int p_surface) const {
return _get_array_from_surface(format, vertex_data, vertex_len, index_data, index_len);
}
+Array VisualServer::mesh_surface_get_blend_shape_arrays(RID p_mesh, int p_surface) const {
+
+ Vector<PoolVector<uint8_t> > blend_shape_data = mesh_surface_get_blend_shapes(p_mesh, p_surface);
+ if (blend_shape_data.size() > 0) {
+ int vertex_len = mesh_surface_get_array_len(p_mesh, p_surface);
+
+ PoolVector<uint8_t> index_data = mesh_surface_get_index_array(p_mesh, p_surface);
+ int index_len = mesh_surface_get_array_index_len(p_mesh, p_surface);
+
+ uint32_t format = mesh_surface_get_format(p_mesh, p_surface);
+
+ Array blend_shape_array;
+ blend_shape_array.resize(blend_shape_data.size());
+ for (int i = 0; i < blend_shape_data.size(); i++) {
+ blend_shape_array.set(i, _get_array_from_surface(format, blend_shape_data[i], vertex_len, index_data, index_len));
+ }
+
+ return blend_shape_array;
+ } else {
+ return Array();
+ }
+}
+
void VisualServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("force_draw"), &VisualServer::draw);
diff --git a/servers/visual_server.h b/servers/visual_server.h
index d516013ee2..72f36f6b65 100644
--- a/servers/visual_server.h
+++ b/servers/visual_server.h
@@ -267,6 +267,7 @@ public:
virtual PoolVector<uint8_t> mesh_surface_get_index_array(RID p_mesh, int p_surface) const = 0;
virtual Array mesh_surface_get_arrays(RID p_mesh, int p_surface) const;
+ virtual Array mesh_surface_get_blend_shape_arrays(RID p_mesh, int p_surface) const;
virtual uint32_t mesh_surface_get_format(RID p_mesh, int p_surface) const = 0;
virtual PrimitiveType mesh_surface_get_primitive_type(RID p_mesh, int p_surface) const = 0;
@@ -406,6 +407,14 @@ public:
virtual void light_directional_set_shadow_mode(RID p_light, LightDirectionalShadowMode p_mode) = 0;
virtual void light_directional_set_blend_splits(RID p_light, bool p_enable) = 0;
+ enum LightDirectionalShadowDepthRangeMode {
+ LIGHT_DIRECTIONAL_SHADOW_DEPTH_RANGE_STABLE,
+ LIGHT_DIRECTIONAL_SHADOW_DEPTH_RANGE_OPTIMIZED,
+
+ };
+
+ virtual void light_directional_set_shadow_depth_range_mode(RID p_light, LightDirectionalShadowDepthRangeMode p_range_mode) = 0;
+
/* PROBE API */
virtual RID reflection_probe_create() = 0;
@@ -620,6 +629,7 @@ public:
ENV_BG_CLEAR_COLOR,
ENV_BG_COLOR,
ENV_BG_SKY,
+ ENV_BG_COLOR_SKY,
ENV_BG_CANVAS,
ENV_BG_KEEP,
ENV_BG_MAX