diff options
53 files changed, 459 insertions, 315 deletions
diff --git a/ISSUE_TEMPLATE.md b/ISSUE_TEMPLATE.md index dbfb2bdeab..ddddc3a1a9 100644 --- a/ISSUE_TEMPLATE.md +++ b/ISSUE_TEMPLATE.md @@ -1,5 +1,5 @@ **Godot version:** -<!-- If thirdparty of self-compiled, specify the build date or commit hash. --> +<!-- If thirdparty or self-compiled, specify the build date or commit hash. --> **OS/device including version:** @@ -15,3 +15,6 @@ **Minimal reproduction project:** <!-- Optional but greatly speeds up debugging. You can drag and drop a zip archive to upload it. --> + + +- [ ] I searched the existing [GitHub issues](https://github.com/godotengine/godot/issues?utf8=%E2%9C%93&q=is%3Aissue+) for potential duplicates. diff --git a/SConstruct b/SConstruct index 88cd1494f1..88b29695cb 100644 --- a/SConstruct +++ b/SConstruct @@ -168,7 +168,6 @@ opts.Add(BoolVariable('vsproj', "Generate Visual Studio Project.", False)) opts.Add(EnumVariable('warnings', "Set the level of warnings emitted during compilation", 'no', ('extra', 'all', 'moderate', 'no'))) opts.Add(BoolVariable('progress', "Show a progress indicator during build", True)) opts.Add(BoolVariable('dev', "If yes, alias for verbose=yes warnings=all", False)) -opts.Add(BoolVariable('openmp', "If yes, enable OpenMP", True)) opts.Add(EnumVariable('macports_clang', "Build using clang from MacPorts", 'no', ('no', '5.0', 'devel'))) # Thirdparty libraries @@ -411,9 +410,7 @@ if selected_platform in platform_list: methods.update_version(env.module_version_string) - suffix += env.module_version_string - - env["PROGSUFFIX"] = suffix + env["PROGSUFFIX"] + env["PROGSUFFIX"] = suffix + env.module_version_string + env["PROGSUFFIX"] env["OBJSUFFIX"] = suffix + env["OBJSUFFIX"] env["LIBSUFFIX"] = suffix + env["LIBSUFFIX"] env["SHLIBSUFFIX"] = suffix + env["SHLIBSUFFIX"] diff --git a/core/math/math_2d.h b/core/math/math_2d.h index 60351445c0..bbef19de7a 100644 --- a/core/math/math_2d.h +++ b/core/math/math_2d.h @@ -336,9 +336,10 @@ struct Rect2 { g.size.height += p_by * 2; return g; } + inline Rect2 grow_margin(Margin p_margin, real_t p_amount) const { Rect2 g = *this; - g.grow_individual((MARGIN_LEFT == p_margin) ? p_amount : 0, + g = g.grow_individual((MARGIN_LEFT == p_margin) ? p_amount : 0, (MARGIN_TOP == p_margin) ? p_amount : 0, (MARGIN_RIGHT == p_margin) ? p_amount : 0, (MARGIN_BOTTOM == p_margin) ? p_amount : 0); diff --git a/core/os/threaded_array_processor.cpp b/core/os/threaded_array_processor.cpp new file mode 100644 index 0000000000..8e92508ea5 --- /dev/null +++ b/core/os/threaded_array_processor.cpp @@ -0,0 +1,2 @@ +#include "threaded_array_processor.h" + diff --git a/core/os/threaded_array_processor.h b/core/os/threaded_array_processor.h new file mode 100644 index 0000000000..e584fbb193 --- /dev/null +++ b/core/os/threaded_array_processor.h @@ -0,0 +1,80 @@ +#ifndef THREADED_ARRAY_PROCESSOR_H +#define THREADED_ARRAY_PROCESSOR_H + +#include "os/mutex.h" +#include "os/os.h" +#include "os/thread.h" +#include "safe_refcount.h" +#include "thread_safe.h" + +template <class C, class U> +struct ThreadArrayProcessData { + uint32_t elements; + uint32_t index; + C *instance; + U userdata; + void (C::*method)(uint32_t, U); + + void process(uint32_t p_index) { + (instance->*method)(p_index, userdata); + } +}; + +#ifndef NO_THREADS + +template <class T> +void process_array_thread(void *ud) { + + T &data = *(T *)ud; + while (true) { + uint32_t index = atomic_increment(&data.index); + if (index >= data.elements) + break; + data.process(index); + } +} + +template <class C, class M, class U> +void thread_process_array(uint32_t p_elements, C *p_instance, M p_method, U p_userdata) { + + ThreadArrayProcessData<C, U> data; + data.method = p_method; + data.instance = p_instance; + data.userdata = p_userdata; + data.index = 0; + data.elements = p_elements; + data.process(data.index); //process first, let threads increment for next + + Vector<Thread *> threads; + + threads.resize(OS::get_singleton()->get_processor_count()); + + for (int i = 0; i < threads.size(); i++) { + threads[i] = Thread::create(process_array_thread<ThreadArrayProcessData<C, U> >, &data); + } + + for (int i = 0; i < threads.size(); i++) { + Thread::wait_to_finish(threads[i]); + memdelete(threads[i]); + } +} + +#else + +template <class C, class M, class U> +void thread_process_array(uint32_t p_elements, C *p_instance, M p_method, U p_userdata) { + + ThreadArrayProcessData<C, U> data; + data.method = p_method; + data.instance = p_instance; + data.userdata = p_userdata; + data.index = 0; + data.elements = p_elements; + for (uint32_t i = 0; i < p_elements; i++) { + data.process(i); + } +} + +#endif + +#endif // THREADED_ARRAY_PROCESSOR_H diff --git a/doc/classes/ARVRController.xml b/doc/classes/ARVRController.xml index 47a9341643..2adc073ebe 100644 --- a/doc/classes/ARVRController.xml +++ b/doc/classes/ARVRController.xml @@ -62,7 +62,10 @@ </methods> <members> <member name="controller_id" type="int" setter="set_controller_id" getter="get_controller_id"> - The controller's id. The first controller that the [ARVRServer] detects will have id 1, the second id 2, the third id 3, etc. When a controller is turned off, it's slot is freed. This ensures controllers will keep the same id even when controllers with lower ids are turned off. + The controller's id. + A controller id of 0 is unbound and will always result in an inactive node. Controller id 1 is reserved for the first controller that identifies itself as the left hand controller and id 2 is reserved for the first controller that identifies itself as the right hand controller. + For any other controller that the [ARVRServer] detects we continue with controller id 3. + When a controller is turned off, its slot is freed. This ensures controllers will keep the same id even when controllers with lower ids are turned off. </member> <member name="rumble" type="float" setter="set_rumble" getter="get_rumble"> The degree to which the tracker rumbles. Ranges from [code]0.0[/code] to [code]1.0[/code] with precision [code].01[/code]. If changed, updates [member ARVRPositionalTracker.rumble] accordingly. diff --git a/doc/classes/ARVRServer.xml b/doc/classes/ARVRServer.xml index 17202c8c2c..ffe6c35240 100644 --- a/doc/classes/ARVRServer.xml +++ b/doc/classes/ARVRServer.xml @@ -14,7 +14,7 @@ <method name="center_on_hmd"> <return type="void"> </return> - <argument index="0" name="ignore_tilt" type="bool"> + <argument index="0" name="rotation_mode" type="bool"> </argument> <argument index="1" name="keep_height" type="bool"> </argument> @@ -154,5 +154,14 @@ <constant name="TRACKER_ANY" value="255" enum="TrackerType"> Used internally to select all trackers. </constant> + <constant name="RESET_FULL_ROTATION" value="0" enum="RotationMode"> + Fully reset the orientation of the HMD. Regardless of what direction the user is looking to in the real world. The user will look dead ahead in the virtual world. + </constant> + <constant name="RESET_BUT_KEEP_TILT" value="1" enum="RotationMode"> + Resets the orientation but keeps the tilt of the device. So if we're looking down, we keep looking down but heading will be reset. + </constant> + <constant name="DONT_RESET_ROTATION" value="2" enum="RotationMode"> + Does not reset the orientation of the HMD, only the position of the player gets centered. + </constant> </constants> </class> diff --git a/doc/classes/AnimationPlayer.xml b/doc/classes/AnimationPlayer.xml index 570f5e9741..a244788020 100644 --- a/doc/classes/AnimationPlayer.xml +++ b/doc/classes/AnimationPlayer.xml @@ -133,6 +133,7 @@ <return type="float"> </return> <description> + Returns the speed scaling ratio of the current animation channel. For instance, if this value is 1 then the animation plays at normal speed. If it's 0.5 then it plays at half speed. If it's 2 then it plays at double speed. </description> </method> <method name="has_animation" qualifiers="const"> diff --git a/doc/classes/Mutex.xml b/doc/classes/Mutex.xml index 4b845c05ad..74d59b2dd3 100644 --- a/doc/classes/Mutex.xml +++ b/doc/classes/Mutex.xml @@ -4,7 +4,7 @@ A synchronization Mutex. </brief_description> <description> - A synchronization Mutex. Element used in multi-threadding. Basically a binary [Semaphore]. Guarantees that only one thread has this lock, can be used to protect a critical section. + A synchronization Mutex. Element used to synchronize multiple [Thread]s. Basically a binary [Semaphore]. Guarantees that only one thread can ever acquire this lock at a time. Can be used to protect a critical section. Be careful to avoid deadlocks. </description> <tutorials> </tutorials> @@ -22,14 +22,14 @@ <return type="int" enum="Error"> </return> <description> - Try locking this [code]Mutex[/code], does not block. Returns [OK] on success else [ERR_BUSY]. + Try locking this [code]Mutex[/code], does not block. Returns [OK] on success, [ERR_BUSY] otherwise. </description> </method> <method name="unlock"> <return type="void"> </return> <description> - Unlock this [code]Mutex[/code], leaving it to others threads. + Unlock this [code]Mutex[/code], leaving it to other threads. </description> </method> </methods> diff --git a/doc/classes/Semaphore.xml b/doc/classes/Semaphore.xml index d8deb9651a..c8206ff2c2 100644 --- a/doc/classes/Semaphore.xml +++ b/doc/classes/Semaphore.xml @@ -4,7 +4,7 @@ A synchronization Semaphore. </brief_description> <description> - A synchronization Semaphore. Element used in multi-threadding. Initialized to zero on creation. + A synchronization Semaphore. Element used to synchronize multiple [Thread]s. Initialized to zero on creation. Be careful to avoid deadlocks. For a binary version, see [Mutex]. </description> <tutorials> </tutorials> @@ -15,14 +15,14 @@ <return type="int" enum="Error"> </return> <description> - Lowers the [code]Semaphore[/code], allowing one more thread in. + Lowers the [code]Semaphore[/code], allowing one more thread in. Returns [OK] on success, [ERR_BUSY] otherwise. </description> </method> <method name="wait"> <return type="int" enum="Error"> </return> <description> - Tries to wait for the [code]Semaphore[/code], if its value is zero, blocks until non-zero. + Tries to wait for the [code]Semaphore[/code], if its value is zero, blocks until non-zero. Returns [OK] on success, [ERR_BUSY] otherwise. </description> </method> </methods> diff --git a/doc/classes/Transform2D.xml b/doc/classes/Transform2D.xml index 17576f33ed..f4717aa995 100644 --- a/doc/classes/Transform2D.xml +++ b/doc/classes/Transform2D.xml @@ -4,7 +4,7 @@ 2D Transformation. 3x2 matrix. </brief_description> <description> - 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. + Represents one or many transformations in 2D 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> <tutorials> </tutorials> @@ -17,7 +17,7 @@ <argument index="0" name="from" type="Transform"> </argument> <description> - Constructs the [code]Transform2D[/code] from a 3D [Transform]. + Constructs the transform from a 3D [Transform]. </description> </method> <method name="Transform2D"> @@ -30,7 +30,7 @@ <argument index="2" name="origin" type="Vector2"> </argument> <description> - Constructs the [code]Transform2D[/code] from 3 [Vector2] consisting of rows x, y and origin. + Constructs the transform from 3 [Vector2]s representing x, y, and origin. </description> </method> <method name="Transform2D"> @@ -41,7 +41,7 @@ <argument index="1" name="position" type="Vector2"> </argument> <description> - Constructs the [code]Transform2D[/code] from rotation angle in radians and position [Vector2]. + Constructs the transform from a given angle (in radians) and position. </description> </method> <method name="affine_inverse"> @@ -57,7 +57,7 @@ <argument index="0" name="v" type="var"> </argument> <description> - Transforms the given vector "v" by this transform basis (no translation). + Transforms the given vector by this transform's basis (no translation). </description> </method> <method name="basis_xform_inv"> @@ -66,21 +66,21 @@ <argument index="0" name="v" type="var"> </argument> <description> - Inverse-transforms the given vector "v" by this transform basis (no translation). + Inverse-transforms the given vector by this transform's basis (no translation). </description> </method> <method name="get_origin"> <return type="Vector2"> </return> <description> - Returns the origin [Vector2] (translation). + Returns the transform's origin (translation). </description> </method> <method name="get_rotation"> <return type="float"> </return> <description> - Returns the rotation (in radians). + Returns the transform's rotation (in radians). </description> </method> <method name="get_scale"> @@ -98,7 +98,7 @@ <argument index="1" name="weight" type="float"> </argument> <description> - Interpolates the transform to other Transform2D by weight amount (0-1). + Returns a transform interpolated between this transform and another by a given weight (0-1). </description> </method> <method name="inverse"> @@ -121,7 +121,7 @@ <argument index="0" name="phi" type="float"> </argument> <description> - Rotates the transform by phi. + Rotates the transform by the given angle (in radians). </description> </method> <method name="scaled"> @@ -130,7 +130,7 @@ <argument index="0" name="scale" type="Vector2"> </argument> <description> - Scales the transform by the specified 2D scaling factors. + Scales the transform by the given factor. </description> </method> <method name="translated"> @@ -139,7 +139,7 @@ <argument index="0" name="offset" type="Vector2"> </argument> <description> - Translates the transform by the specified offset. + Translates the transform by the given offset. </description> </method> <method name="xform"> @@ -163,13 +163,13 @@ </methods> <members> <member name="origin" type="Vector2" setter="" getter=""> - The translation offset of the transform. + The transform's translation offset. </member> <member name="x" type="Vector2" setter="" getter=""> - 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. + The X axis of 2x2 basis matrix containing 2 [Vector2]s 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=""> - 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. + The Y axis of 2x2 basis matrix containing 2 [Vector2]s 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> diff --git a/drivers/gles3/shaders/scene.glsl b/drivers/gles3/shaders/scene.glsl index 9bc2bc079d..bb9ff29a8e 100644 --- a/drivers/gles3/shaders/scene.glsl +++ b/drivers/gles3/shaders/scene.glsl @@ -296,6 +296,48 @@ void main() { #endif + +#if defined(ENABLE_TANGENT_INTERP) || defined(ENABLE_NORMALMAP) || defined(LIGHT_USE_ANISOTROPY) + + vec3 binormal = normalize( cross(normal,tangent) * binormalf ); +#endif + +#if defined(ENABLE_UV_INTERP) + uv_interp = uv_attrib; +#endif + +#if defined(ENABLE_UV2_INTERP) || defined(USE_LIGHTMAP) + uv2_interp = uv2_attrib; +#endif + +#if defined(USE_INSTANCING) && defined(ENABLE_INSTANCE_CUSTOM) + vec4 instance_custom = instance_custom_data; +#else + vec4 instance_custom = vec4(0.0); +#endif + + highp mat4 local_projection = projection_matrix; + +//using world coordinates +#if !defined(SKIP_TRANSFORM_USED) && defined(VERTEX_WORLD_COORDS_USED) + + vertex = world_matrix * vertex; + normal = normalize((world_matrix * vec4(normal,0.0)).xyz); + +#if defined(ENABLE_TANGENT_INTERP) || defined(ENABLE_NORMALMAP) || defined(LIGHT_USE_ANISOTROPY) + + tangent = normalize((world_matrix * vec4(tangent,0.0)).xyz); + binormal = normalize((world_matrix * vec4(binormal,0.0)).xyz); +#endif +#endif + + float roughness=0.0; + +//defines that make writing custom shaders easier +#define projection_matrix local_projection +#define world_transform world_matrix + + #ifdef USE_SKELETON { //skeleton transform @@ -333,57 +375,13 @@ void main() { texelFetch(skeleton_texture,tex_ofs+ivec2(0,2),0) ) * bone_weights.w; + mat4 bone_matrix = transpose(mat4(m[0],m[1],m[2],vec4(0.0,0.0,0.0,1.0))); - vertex.xyz = vertex * m; - - normal = vec4(normal,0.0) * m; -#if defined(ENABLE_TANGENT_INTERP) || defined(ENABLE_NORMALMAP) || defined(LIGHT_USE_ANISOTROPY) - tangent.xyz = vec4(tangent.xyz,0.0) * m; -#endif + world_matrix = bone_matrix * world_matrix; } #endif - -#if defined(ENABLE_TANGENT_INTERP) || defined(ENABLE_NORMALMAP) || defined(LIGHT_USE_ANISOTROPY) - - vec3 binormal = normalize( cross(normal,tangent) * binormalf ); -#endif - -#if defined(ENABLE_UV_INTERP) - uv_interp = uv_attrib; -#endif - -#if defined(ENABLE_UV2_INTERP) || defined(USE_LIGHTMAP) - uv2_interp = uv2_attrib; -#endif - -#if defined(USE_INSTANCING) && defined(ENABLE_INSTANCE_CUSTOM) - vec4 instance_custom = instance_custom_data; -#else - vec4 instance_custom = vec4(0.0); -#endif - - highp mat4 modelview = camera_inverse_matrix * world_matrix; - highp mat4 local_projection = projection_matrix; - -//using world coordinates -#if !defined(SKIP_TRANSFORM_USED) && defined(VERTEX_WORLD_COORDS_USED) - - vertex = world_matrix * vertex; - normal = normalize((world_matrix * vec4(normal,0.0)).xyz); - -#if defined(ENABLE_TANGENT_INTERP) || defined(ENABLE_NORMALMAP) || defined(LIGHT_USE_ANISOTROPY) - - tangent = normalize((world_matrix * vec4(tangent,0.0)).xyz); - binormal = normalize((world_matrix * vec4(binormal,0.0)).xyz); -#endif -#endif - - float roughness=0.0; - -//defines that make writing custom shaders easier -#define projection_matrix local_projection -#define world_transform world_matrix + mat4 modelview = camera_inverse_matrix * world_matrix; { VERTEX_SHADER_CODE diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp index 2584d26fc4..2189830acb 100644 --- a/editor/create_dialog.cpp +++ b/editor/create_dialog.cpp @@ -267,7 +267,6 @@ void CreateDialog::_update_search() { if (EditorNode::get_editor_data().get_custom_types().has(type) && ClassDB::is_parent_class(type, base_type)) { //there are custom types based on this... cool. - //print_line("there are custom types"); const Vector<EditorData::CustomType> &ct = EditorNode::get_editor_data().get_custom_types()[type]; for (int i = 0; i < ct.size(); i++) { @@ -630,31 +629,44 @@ CreateDialog::CreateDialog() { set_resizable(true); - HSplitContainer *hbc = memnew(HSplitContainer); - - add_child(hbc); - - VBoxContainer *lvbc = memnew(VBoxContainer); - hbc->add_child(lvbc); - lvbc->set_custom_minimum_size(Size2(150, 0) * EDSCALE); - - favorites = memnew(Tree); - lvbc->add_margin_child(TTR("Favorites:"), favorites, true); - favorites->set_hide_root(true); - favorites->set_hide_folding(true); - favorites->connect("cell_selected", this, "_favorite_selected"); - favorites->connect("item_activated", this, "_favorite_activated"); - favorites->set_drag_forwarding(this); + HSplitContainer *hsc = memnew(HSplitContainer); + add_child(hsc); + + VSplitContainer *vsc = memnew(VSplitContainer); + hsc->add_child(vsc); + + { + VBoxContainer *lvbc = memnew(VBoxContainer); + vsc->add_child(lvbc); + lvbc->set_custom_minimum_size(Size2(150, 100) * EDSCALE); + lvbc->set_v_size_flags(SIZE_EXPAND_FILL); + + favorites = memnew(Tree); + lvbc->add_margin_child(TTR("Favorites:"), favorites, true); + favorites->set_hide_root(true); + favorites->set_hide_folding(true); + favorites->connect("cell_selected", this, "_favorite_selected"); + favorites->connect("item_activated", this, "_favorite_activated"); + favorites->set_drag_forwarding(this); + } - recent = memnew(Tree); - lvbc->add_margin_child(TTR("Recent:"), recent, true); - recent->set_hide_root(true); - recent->set_hide_folding(true); - recent->connect("cell_selected", this, "_history_selected"); - recent->connect("item_activated", this, "_history_activated"); + { + VBoxContainer *lvbc = memnew(VBoxContainer); + vsc->add_child(lvbc); + lvbc->set_custom_minimum_size(Size2(150, 100) * EDSCALE); + lvbc->set_v_size_flags(SIZE_EXPAND_FILL); + + recent = memnew(Tree); + lvbc->add_margin_child(TTR("Recent:"), recent, true); + recent->set_hide_root(true); + recent->set_hide_folding(true); + recent->connect("cell_selected", this, "_history_selected"); + recent->connect("item_activated", this, "_history_activated"); + } VBoxContainer *vbc = memnew(VBoxContainer); - hbc->add_child(vbc); + hsc->add_child(vbc); + vbc->set_custom_minimum_size(Size2(300, 0) * EDSCALE); vbc->set_h_size_flags(SIZE_EXPAND_FILL); HBoxContainer *search_hb = memnew(HBoxContainer); search_box = memnew(LineEdit); @@ -676,7 +688,6 @@ CreateDialog::CreateDialog() { set_hide_on_ok(false); search_options->connect("item_activated", this, "_confirmed"); search_options->connect("cell_selected", this, "_item_selected"); - //search_options->set_hide_root(true); base_type = "Object"; preferred_search_result_type = ""; diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index cc0b292cc4..5610baa775 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -972,6 +972,12 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_stylebox("commentfocus", "GraphNode", graphsbcommentselected); theme->set_stylebox("breakpoint", "GraphNode", graphsbbreakpoint); theme->set_stylebox("position", "GraphNode", graphsbposition); + + Color default_node_color = Color(mv2, mv2, mv2); + theme->set_color("title_color", "GraphNode", default_node_color); + default_node_color.a = 0.7; + theme->set_color("close_color", "GraphNode", default_node_color); + theme->set_constant("port_offset", "GraphNode", 14 * EDSCALE); theme->set_constant("title_h_offset", "GraphNode", -16 * EDSCALE); theme->set_constant("close_h_offset", "GraphNode", 20 * EDSCALE); diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index c30f077888..75e4f39e25 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -147,7 +147,7 @@ void FileSystemDock::_notification(int p_what) { if (low_height_mode) { - file_list_vb->hide(); + tree->hide(); tree->set_v_size_flags(SIZE_EXPAND_FILL); button_tree->show(); } else { @@ -158,6 +158,7 @@ void FileSystemDock::_notification(int p_what) { button_favorite->show(); _update_tree(true); } + tree->ensure_cursor_is_visible(); if (!file_list_vb->is_visible()) { file_list_vb->show(); @@ -345,11 +346,7 @@ void FileSystemDock::navigate_to_path(const String &p_path) { _update_tree(true); _update_files(false); } else { - if (file_name.empty()) { - _go_to_tree(); - } else { - _go_to_file_list(); - } + _go_to_file_list(); } if (!file_name.empty()) { diff --git a/editor/plugins/animation_tree_editor_plugin.cpp b/editor/plugins/animation_tree_editor_plugin.cpp index 8fe6538653..0c6c608d3d 100644 --- a/editor/plugins/animation_tree_editor_plugin.cpp +++ b/editor/plugins/animation_tree_editor_plugin.cpp @@ -1435,7 +1435,7 @@ AnimationTreeEditorPlugin::AnimationTreeEditorPlugin(EditorNode *p_node) { anim_tree_editor = memnew(AnimationTreeEditor); anim_tree_editor->set_custom_minimum_size(Size2(0, 300)); - button = editor->add_bottom_panel_item("AnimationTree", anim_tree_editor); + button = editor->add_bottom_panel_item(TTR("AnimationTree"), anim_tree_editor); button->hide(); } diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index f5bfea3395..ceb1ec09fc 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -4100,7 +4100,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { select_button->connect("pressed", this, "_tool_select", make_binds(TOOL_SELECT)); select_button->set_pressed(true); select_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/select_mode", TTR("Select Mode"), KEY_Q)); - select_button->set_tooltip(TTR("Select Mode") + " $sc\n" + keycode_get_string(KEY_MASK_CMD) + TTR("Drag: Rotate") + "\n" + TTR("Alt+Drag: Move") + "\n" + TTR("Press 'v' to Change Pivot, 'Shift+v' to Drag Pivot (while moving).") + "\n" + TTR("Alt+RMB: Depth list selection")); + select_button->set_tooltip(keycode_get_string(KEY_MASK_CMD) + TTR("Drag: Rotate") + "\n" + TTR("Alt+Drag: Move") + "\n" + TTR("Press 'v' to Change Pivot, 'Shift+v' to Drag Pivot (while moving).") + "\n" + TTR("Alt+RMB: Depth list selection")); move_button = memnew(ToolButton); hb->add_child(move_button); diff --git a/editor/plugins/resource_preloader_editor_plugin.cpp b/editor/plugins/resource_preloader_editor_plugin.cpp index 3210af1433..88649ca267 100644 --- a/editor/plugins/resource_preloader_editor_plugin.cpp +++ b/editor/plugins/resource_preloader_editor_plugin.cpp @@ -444,7 +444,7 @@ ResourcePreloaderEditorPlugin::ResourcePreloaderEditorPlugin(EditorNode *p_node) preloader_editor = memnew(ResourcePreloaderEditor); preloader_editor->set_custom_minimum_size(Size2(0, 250)); - button = editor->add_bottom_panel_item("ResourcePreloader", preloader_editor); + button = editor->add_bottom_panel_item(TTR("ResourcePreloader"), preloader_editor); button->hide(); //preloader_editor->set_anchor( MARGIN_TOP, Control::ANCHOR_END); diff --git a/editor/plugins/sprite_frames_editor_plugin.cpp b/editor/plugins/sprite_frames_editor_plugin.cpp index 175655119f..71c81f7111 100644 --- a/editor/plugins/sprite_frames_editor_plugin.cpp +++ b/editor/plugins/sprite_frames_editor_plugin.cpp @@ -840,7 +840,7 @@ SpriteFramesEditorPlugin::SpriteFramesEditorPlugin(EditorNode *p_node) { editor = p_node; frames_editor = memnew(SpriteFramesEditor); frames_editor->set_custom_minimum_size(Size2(0, 300) * EDSCALE); - button = editor->add_bottom_panel_item("SpriteFrames", frames_editor); + button = editor->add_bottom_panel_item(TTR("SpriteFrames"), frames_editor); button->hide(); } diff --git a/editor/plugins/style_box_editor_plugin.cpp b/editor/plugins/style_box_editor_plugin.cpp index 5c965e4a05..9840d9021c 100644 --- a/editor/plugins/style_box_editor_plugin.cpp +++ b/editor/plugins/style_box_editor_plugin.cpp @@ -103,6 +103,6 @@ StyleBoxEditorPlugin::StyleBoxEditorPlugin(EditorNode *p_node) { stylebox_editor->set_custom_minimum_size(Size2(0, 250)); //p_node->get_viewport()->add_child(stylebox_editor); - button = p_node->add_bottom_panel_item("StyleBox", stylebox_editor); + button = p_node->add_bottom_panel_item(TTR("StyleBox"), stylebox_editor); button->hide(); } diff --git a/editor/plugins/theme_editor_plugin.cpp b/editor/plugins/theme_editor_plugin.cpp index 7f956b01ff..38a4bfbfc6 100644 --- a/editor/plugins/theme_editor_plugin.cpp +++ b/editor/plugins/theme_editor_plugin.cpp @@ -934,6 +934,6 @@ ThemeEditorPlugin::ThemeEditorPlugin(EditorNode *p_node) { theme_editor->set_custom_minimum_size(Size2(0, 200)); //p_node->get_viewport()->add_child(theme_editor); - button = editor->add_bottom_panel_item("Theme", theme_editor); + button = editor->add_bottom_panel_item(TTR("Theme"), theme_editor); button->hide(); } diff --git a/editor/plugins/tile_set_editor_plugin.cpp b/editor/plugins/tile_set_editor_plugin.cpp index 5eb3435e24..b56585f62c 100644 --- a/editor/plugins/tile_set_editor_plugin.cpp +++ b/editor/plugins/tile_set_editor_plugin.cpp @@ -314,7 +314,7 @@ TileSetEditorPlugin::TileSetEditorPlugin(EditorNode *p_node) { autotile_editor->side_panel->set_anchors_and_margins_preset(Control::PRESET_WIDE); autotile_editor->side_panel->set_custom_minimum_size(Size2(200, 0)); autotile_editor->side_panel->hide(); - autotile_button = p_node->add_bottom_panel_item("Autotiles", autotile_editor); + autotile_button = p_node->add_bottom_panel_item(TTR("Autotiles"), autotile_editor); autotile_button->hide(); } @@ -387,7 +387,7 @@ AutotileEditor::AutotileEditor(EditorNode *p_editor) { tools[TOOL_SELECT] = memnew(ToolButton); tool_containers[TOOLBAR_DUMMY]->add_child(tools[TOOL_SELECT]); - tools[TOOL_SELECT]->set_tooltip("Select sub-tile to use as icon, this will be also used on invalid autotile bindings."); + tools[TOOL_SELECT]->set_tooltip(TTR("Select sub-tile to use as icon, this will be also used on invalid autotile bindings.")); tools[TOOL_SELECT]->set_toggle_mode(true); tools[TOOL_SELECT]->set_button_group(tg); tools[TOOL_SELECT]->set_pressed(true); @@ -533,7 +533,7 @@ void AutotileEditor::_on_edit_mode_changed(int p_edit_mode) { tool_containers[TOOLBAR_BITMASK]->show(); tool_containers[TOOLBAR_SHAPE]->hide(); tools[TOOL_SELECT]->set_pressed(true); - tools[TOOL_SELECT]->set_tooltip("LMB: set bit on.\nRMB: set bit off."); + tools[TOOL_SELECT]->set_tooltip(TTR("LMB: set bit on.\nRMB: set bit off.")); spin_priority->hide(); } break; case EDITMODE_COLLISION: @@ -542,7 +542,7 @@ void AutotileEditor::_on_edit_mode_changed(int p_edit_mode) { tool_containers[TOOLBAR_DUMMY]->show(); tool_containers[TOOLBAR_BITMASK]->hide(); tool_containers[TOOLBAR_SHAPE]->show(); - tools[TOOL_SELECT]->set_tooltip("Select current edited sub-tile."); + tools[TOOL_SELECT]->set_tooltip(TTR("Select current edited sub-tile.")); spin_priority->hide(); } break; default: { @@ -550,10 +550,10 @@ void AutotileEditor::_on_edit_mode_changed(int p_edit_mode) { tool_containers[TOOLBAR_BITMASK]->hide(); tool_containers[TOOLBAR_SHAPE]->hide(); if (edit_mode == EDITMODE_ICON) { - tools[TOOL_SELECT]->set_tooltip("Select sub-tile to use as icon, this will be also used on invalid autotile bindings."); + tools[TOOL_SELECT]->set_tooltip(TTR("Select sub-tile to use as icon, this will be also used on invalid autotile bindings.")); spin_priority->hide(); } else { - tools[TOOL_SELECT]->set_tooltip("Select sub-tile to change it's priority."); + tools[TOOL_SELECT]->set_tooltip(TTR("Select sub-tile to change it's priority.")); spin_priority->show(); } } break; diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 00488a2a88..04e9f0adc1 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -536,21 +536,21 @@ public: if (mode == MODE_IMPORT) { set_title(TTR("Import Existing Project")); - get_ok()->set_text(TTR("Import")); + get_ok()->set_text(TTR("Import & Edit")); name_container->hide(); project_path->grab_focus(); } else if (mode == MODE_NEW) { set_title(TTR("Create New Project")); - get_ok()->set_text(TTR("Create")); + get_ok()->set_text(TTR("Create & Edit")); name_container->show(); project_name->grab_focus(); } else if (mode == MODE_INSTALL) { set_title(TTR("Install Project:") + " " + zip_title); - get_ok()->set_text(TTR("Install")); + get_ok()->set_text(TTR("Install & Edit")); name_container->hide(); project_path->grab_focus(); } diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp index 6f8573cd70..e69577489e 100644 --- a/editor/project_settings_editor.cpp +++ b/editor/project_settings_editor.cpp @@ -1460,7 +1460,6 @@ void ProjectSettingsEditor::_update_translations() { t2->set_editable(1, true); t2->set_metadata(1, path); int idx = langs.find(locale); - //print_line("find " + locale + " at " + itos(idx)); if (idx < 0) idx = 0; @@ -1709,7 +1708,6 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) { 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"); diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp index 47feac9a12..64351dec4f 100644 --- a/editor/property_editor.cpp +++ b/editor/property_editor.cpp @@ -4591,6 +4591,8 @@ SectionedPropertyEditor::SectionedPropertyEditor() { search_box = NULL; + add_constant_override("autohide", 1); // Fixes the dragger always showing up + VBoxContainer *left_vb = memnew(VBoxContainer); left_vb->set_custom_minimum_size(Size2(170, 0) * EDSCALE); add_child(left_vb); @@ -4602,6 +4604,7 @@ SectionedPropertyEditor::SectionedPropertyEditor() { left_vb->add_child(sections, true); VBoxContainer *right_vb = memnew(VBoxContainer); + right_vb->set_custom_minimum_size(Size2(300, 0) * EDSCALE); right_vb->set_h_size_flags(SIZE_EXPAND_FILL); add_child(right_vb); diff --git a/editor/spatial_editor_gizmos.cpp b/editor/spatial_editor_gizmos.cpp index 5359f9894c..7342dd5b5d 100644 --- a/editor/spatial_editor_gizmos.cpp +++ b/editor/spatial_editor_gizmos.cpp @@ -2829,11 +2829,7 @@ void BakedIndirectLightGizmo::redraw() { Vector<Vector3> lines; Vector3 extents = baker->get_extents(); - static const int subdivs[BakedLightmap::SUBDIV_MAX] = { 64, 128, 256, 512 }; - AABB aabb = AABB(-extents, extents * 2); - int subdiv = subdivs[baker->get_bake_subdiv()]; - float cell_size = aabb.get_longest_axis_size() / subdiv; for (int i = 0; i < 12; i++) { Vector3 a, b; diff --git a/modules/bullet/godot_result_callbacks.cpp b/modules/bullet/godot_result_callbacks.cpp index cbf30c8a2e..37e45cfff8 100644 --- a/modules/bullet/godot_result_callbacks.cpp +++ b/modules/bullet/godot_result_callbacks.cpp @@ -142,6 +142,9 @@ bool GodotAllContactResultCallback::needsCollision(btBroadphaseProxy *proxy0) co btScalar GodotAllContactResultCallback::addSingleResult(btManifoldPoint &cp, const btCollisionObjectWrapper *colObj0Wrap, int partId0, int index0, const btCollisionObjectWrapper *colObj1Wrap, int partId1, int index1) { + if (m_count >= m_resultMax) + return cp.getDistance(); + if (cp.getDistance() <= 0) { PhysicsDirectSpaceState::ShapeResult &result = m_results[m_count]; @@ -165,7 +168,7 @@ btScalar GodotAllContactResultCallback::addSingleResult(btManifoldPoint &cp, con ++m_count; } - return m_count < m_resultMax; + return cp.getDistance(); } bool GodotContactPairContactResultCallback::needsCollision(btBroadphaseProxy *proxy0) const { diff --git a/modules/bullet/rigid_body_bullet.cpp b/modules/bullet/rigid_body_bullet.cpp index 669b2c3f0c..5e736c1856 100644 --- a/modules/bullet/rigid_body_bullet.cpp +++ b/modules/bullet/rigid_body_bullet.cpp @@ -264,6 +264,7 @@ RigidBodyBullet::RigidBodyBullet() : can_sleep(true), force_integration_callback(NULL), isTransformChanged(false), + previousActiveState(true), maxCollisionsDetection(0), collisionsCount(0), maxAreasWhereIam(10), @@ -287,6 +288,7 @@ RigidBodyBullet::RigidBodyBullet() : for (int i = areasWhereIam.size() - 1; 0 <= i; --i) { areasWhereIam[i] = NULL; } + btBody->setSleepingThresholds(0.2, 0.2); } RigidBodyBullet::~RigidBodyBullet() { @@ -337,7 +339,7 @@ void RigidBodyBullet::set_space(SpaceBullet *p_space) { void RigidBodyBullet::dispatch_callbacks() { /// The check isTransformChanged is necessary in order to call integrated forces only when the first transform is sent - if (btBody->isActive() && force_integration_callback && isTransformChanged) { + if ((btBody->isActive() || previousActiveState != btBody->isActive()) && force_integration_callback && isTransformChanged) { BulletPhysicsDirectBodyState *bodyDirect = BulletPhysicsDirectBodyState::get_singleton(this); @@ -364,6 +366,8 @@ void RigidBodyBullet::dispatch_callbacks() { /// Lock axis btBody->setLinearVelocity(btBody->getLinearVelocity() * btBody->getLinearFactor()); btBody->setAngularVelocity(btBody->getAngularVelocity() * btBody->getAngularFactor()); + + previousActiveState = btBody->isActive(); } void RigidBodyBullet::set_force_integration_callback(ObjectID p_id, const StringName &p_method, const Variant &p_udata) { @@ -580,7 +584,8 @@ Variant RigidBodyBullet::get_state(PhysicsServer::BodyState p_state) const { void RigidBodyBullet::apply_central_impulse(const Vector3 &p_impulse) { btVector3 btImpu; G_TO_B(p_impulse, btImpu); - btBody->activate(); + if (Vector3() != p_impulse) + btBody->activate(); btBody->applyCentralImpulse(btImpu); } @@ -589,14 +594,16 @@ void RigidBodyBullet::apply_impulse(const Vector3 &p_pos, const Vector3 &p_impul btVector3 btPos; G_TO_B(p_impulse, btImpu); G_TO_B(p_pos, btPos); - btBody->activate(); + if (Vector3() != p_impulse) + btBody->activate(); btBody->applyImpulse(btImpu, btPos); } void RigidBodyBullet::apply_torque_impulse(const Vector3 &p_impulse) { btVector3 btImp; G_TO_B(p_impulse, btImp); - btBody->activate(); + if (Vector3() != p_impulse) + btBody->activate(); btBody->applyTorqueImpulse(btImp); } @@ -605,28 +612,32 @@ void RigidBodyBullet::apply_force(const Vector3 &p_force, const Vector3 &p_pos) btVector3 btPos; G_TO_B(p_force, btForce); G_TO_B(p_pos, btPos); - btBody->activate(); + if (Vector3() != p_force) + btBody->activate(); btBody->applyForce(btForce, btPos); } void RigidBodyBullet::apply_central_force(const Vector3 &p_force) { btVector3 btForce; G_TO_B(p_force, btForce); - btBody->activate(); + if (Vector3() != p_force) + btBody->activate(); btBody->applyCentralForce(btForce); } void RigidBodyBullet::apply_torque(const Vector3 &p_torque) { btVector3 btTorq; G_TO_B(p_torque, btTorq); - btBody->activate(); + if (Vector3() != p_torque) + btBody->activate(); btBody->applyTorque(btTorq); } void RigidBodyBullet::set_applied_force(const Vector3 &p_force) { btVector3 btVec = btBody->getTotalTorque(); - btBody->activate(); + if (Vector3() != p_force) + btBody->activate(); btBody->clearForces(); btBody->applyTorque(btVec); @@ -644,7 +655,8 @@ Vector3 RigidBodyBullet::get_applied_force() const { void RigidBodyBullet::set_applied_torque(const Vector3 &p_torque) { btVector3 btVec = btBody->getTotalForce(); - btBody->activate(); + if (Vector3() != p_torque) + btBody->activate(); btBody->clearForces(); btBody->applyCentralForce(btVec); @@ -711,7 +723,8 @@ bool RigidBodyBullet::is_continuous_collision_detection_enabled() const { void RigidBodyBullet::set_linear_velocity(const Vector3 &p_velocity) { btVector3 btVec; G_TO_B(p_velocity, btVec); - btBody->activate(); + if (Vector3() != p_velocity) + btBody->activate(); btBody->setLinearVelocity(btVec); } @@ -724,7 +737,8 @@ Vector3 RigidBodyBullet::get_linear_velocity() const { void RigidBodyBullet::set_angular_velocity(const Vector3 &p_velocity) { btVector3 btVec; G_TO_B(p_velocity, btVec); - btBody->activate(); + if (Vector3() != p_velocity) + btBody->activate(); btBody->setAngularVelocity(btVec); } @@ -833,6 +847,9 @@ void RigidBodyBullet::on_exit_area(AreaBullet *p_area) { void RigidBodyBullet::reload_space_override_modificator() { + if (!is_active()) + return; + Vector3 newGravity(space->get_gravity_direction() * space->get_gravity_magnitude()); real_t newLinearDamp(linearDamp); real_t newAngularDamp(angularDamp); diff --git a/modules/bullet/rigid_body_bullet.h b/modules/bullet/rigid_body_bullet.h index c0eb148e24..c3b72172d9 100644 --- a/modules/bullet/rigid_body_bullet.h +++ b/modules/bullet/rigid_body_bullet.h @@ -207,6 +207,7 @@ private: bool isScratchedSpaceOverrideModificator; bool isTransformChanged; + bool previousActiveState; // Last check state ForceIntegrationCallback *force_integration_callback; diff --git a/modules/mono/editor/csharp_project.cpp b/modules/mono/editor/csharp_project.cpp index 9a1efb4423..d5819a4ca3 100644 --- a/modules/mono/editor/csharp_project.cpp +++ b/modules/mono/editor/csharp_project.cpp @@ -54,7 +54,7 @@ String generate_core_api_project(const String &p_dir, const Vector<String> &p_fi ERR_FAIL_V(String()); } - return ret ? GDMonoMarshal::mono_string_to_godot((MonoString *)ret) : ""; + return ret ? GDMonoMarshal::mono_string_to_godot((MonoString *)ret) : String(); } String generate_editor_api_project(const String &p_dir, const String &p_core_dll_path, const Vector<String> &p_files) { @@ -75,7 +75,7 @@ String generate_editor_api_project(const String &p_dir, const String &p_core_dll ERR_FAIL_V(String()); } - return ret ? GDMonoMarshal::mono_string_to_godot((MonoString *)ret) : ""; + return ret ? GDMonoMarshal::mono_string_to_godot((MonoString *)ret) : String(); } String generate_game_project(const String &p_dir, const String &p_name, const Vector<String> &p_files) { @@ -96,7 +96,7 @@ String generate_game_project(const String &p_dir, const String &p_name, const Ve ERR_FAIL_V(String()); } - return ret ? GDMonoMarshal::mono_string_to_godot((MonoString *)ret) : ""; + return ret ? GDMonoMarshal::mono_string_to_godot((MonoString *)ret) : String(); } void add_item(const String &p_project_path, const String &p_item_type, const String &p_include) { diff --git a/modules/mono/editor/godotsharp_editor.cpp b/modules/mono/editor/godotsharp_editor.cpp index 1bc1e8a515..1e61646769 100644 --- a/modules/mono/editor/godotsharp_editor.cpp +++ b/modules/mono/editor/godotsharp_editor.cpp @@ -50,9 +50,9 @@ GodotSharpEditor *GodotSharpEditor::singleton = NULL; bool GodotSharpEditor::_create_project_solution() { - EditorProgress pr("create_csharp_solution", "Generating solution...", 2); + EditorProgress pr("create_csharp_solution", TTR("Generating solution..."), 2); - pr.step("Generating C# project..."); + pr.step(TTR("Generating C# project...")); String path = OS::get_singleton()->get_resource_dir(); String name = ProjectSettings::get_singleton()->get("application/config/name"); @@ -67,7 +67,7 @@ bool GodotSharpEditor::_create_project_solution() { NETSolution solution(name); if (!solution.set_path(path)) { - show_error_dialog("Failed to create solution."); + show_error_dialog(TTR("Failed to create solution.")); return false; } @@ -79,7 +79,7 @@ bool GodotSharpEditor::_create_project_solution() { Error sln_error = solution.save(); if (sln_error != OK) { - show_error_dialog("Failed to save solution."); + show_error_dialog(TTR("Failed to save solution.")); return false; } @@ -89,13 +89,13 @@ bool GodotSharpEditor::_create_project_solution() { if (!GodotSharpBuilds::make_api_sln(GodotSharpBuilds::API_EDITOR)) return false; - pr.step("Done"); + pr.step(TTR("Done")); // Here, after all calls to progress_task_step call_deferred("_remove_create_sln_menu_option"); } else { - show_error_dialog("Failed to create C# project."); + show_error_dialog(TTR("Failed to create C# project.")); } return true; @@ -194,14 +194,14 @@ GodotSharpEditor::GodotSharpEditor(EditorNode *p_editor) { error_dialog = memnew(AcceptDialog); editor->get_gui_base()->add_child(error_dialog); - bottom_panel_btn = editor->add_bottom_panel_item("Mono", memnew(MonoBottomPanel(editor))); + bottom_panel_btn = editor->add_bottom_panel_item(TTR("Mono"), memnew(MonoBottomPanel(editor))); godotsharp_builds = memnew(GodotSharpBuilds); editor->add_child(memnew(MonoReloadNode)); menu_button = memnew(MenuButton); - menu_button->set_text("Mono"); + menu_button->set_text(TTR("Mono")); menu_popup = menu_button->get_popup(); String sln_path = GodotSharpDirs::get_project_sln_path(); @@ -209,7 +209,7 @@ GodotSharpEditor::GodotSharpEditor(EditorNode *p_editor) { if (!FileAccess::exists(sln_path) || !FileAccess::exists(csproj_path)) { bottom_panel_btn->hide(); - menu_popup->add_item("Create C# solution", MENU_CREATE_SLN); + menu_popup->add_item(TTR("Create C# solution"), MENU_CREATE_SLN); } menu_popup->connect("id_pressed", this, "_menu_option_pressed"); diff --git a/modules/mono/editor/mono_bottom_panel.cpp b/modules/mono/editor/mono_bottom_panel.cpp index 31dc09856a..be714026ad 100644 --- a/modules/mono/editor/mono_bottom_panel.cpp +++ b/modules/mono/editor/mono_bottom_panel.cpp @@ -197,7 +197,7 @@ MonoBottomPanel::MonoBottomPanel(EditorNode *p_editor) { panel_builds_tab->add_child(toolbar_hbc); ToolButton *build_project_btn = memnew(ToolButton); - build_project_btn->set_text("Build Project"); + build_project_btn->set_text(TTR("Build Project")); build_project_btn->set_focus_mode(FOCUS_NONE); build_project_btn->connect("pressed", this, "_build_project_pressed"); toolbar_hbc->add_child(build_project_btn); @@ -205,7 +205,7 @@ MonoBottomPanel::MonoBottomPanel(EditorNode *p_editor) { toolbar_hbc->add_spacer(); warnings_btn = memnew(ToolButton); - warnings_btn->set_text("Warnings"); + warnings_btn->set_text(TTR("Warnings")); warnings_btn->set_toggle_mode(true); warnings_btn->set_pressed(true); warnings_btn->set_visible(false); @@ -214,7 +214,7 @@ MonoBottomPanel::MonoBottomPanel(EditorNode *p_editor) { toolbar_hbc->add_child(warnings_btn); errors_btn = memnew(ToolButton); - errors_btn->set_text("Errors"); + errors_btn->set_text(TTR("Errors")); errors_btn->set_toggle_mode(true); errors_btn->set_pressed(true); errors_btn->set_visible(false); diff --git a/modules/mono/mono_gd/gd_mono_field.cpp b/modules/mono/mono_gd/gd_mono_field.cpp index eb34f9dd3f..63b24f3ee6 100644 --- a/modules/mono/mono_gd/gd_mono_field.cpp +++ b/modules/mono/mono_gd/gd_mono_field.cpp @@ -290,7 +290,7 @@ int GDMonoField::get_int_value(MonoObject *p_object) { String GDMonoField::get_string_value(MonoObject *p_object) { MonoObject *val = get_value(p_object); - return val ? GDMonoMarshal::mono_string_to_godot((MonoString *)val) : String(); + return GDMonoMarshal::mono_string_to_godot((MonoString *)val); } bool GDMonoField::has_attribute(GDMonoClass *p_attr_class) { diff --git a/modules/mono/mono_gd/gd_mono_marshal.cpp b/modules/mono/mono_gd/gd_mono_marshal.cpp index 8bc2bb5096..d744d24f24 100644 --- a/modules/mono/mono_gd/gd_mono_marshal.cpp +++ b/modules/mono/mono_gd/gd_mono_marshal.cpp @@ -490,8 +490,9 @@ Variant mono_object_to_variant(MonoObject *p_obj, const ManagedType &p_type) { return unbox<double>(p_obj); case MONO_TYPE_STRING: { - String str = mono_string_to_godot((MonoString *)p_obj); - return str; + if (p_obj == NULL) + return Variant(); // NIL + return mono_string_to_godot_not_null((MonoString *)p_obj); } break; case MONO_TYPE_VALUETYPE: { diff --git a/modules/mono/mono_gd/gd_mono_marshal.h b/modules/mono/mono_gd/gd_mono_marshal.h index 443e947fb5..1be4be1a1c 100644 --- a/modules/mono/mono_gd/gd_mono_marshal.h +++ b/modules/mono/mono_gd/gd_mono_marshal.h @@ -62,13 +62,20 @@ Variant::Type managed_to_variant_type(const ManagedType &p_type); String mono_to_utf8_string(MonoString *p_mono_string); String mono_to_utf16_string(MonoString *p_mono_string); -_FORCE_INLINE_ String mono_string_to_godot(MonoString *p_mono_string) { +_FORCE_INLINE_ String mono_string_to_godot_not_null(MonoString *p_mono_string) { if (sizeof(CharType) == 2) return mono_to_utf16_string(p_mono_string); return mono_to_utf8_string(p_mono_string); } +_FORCE_INLINE_ String mono_string_to_godot(MonoString *p_mono_string) { + if (p_mono_string == NULL) + return String(); + + return mono_string_to_godot_not_null(p_mono_string); +} + _FORCE_INLINE_ MonoString *mono_from_utf8_string(const String &p_string) { return mono_string_new(mono_domain_get(), p_string.utf8().get_data()); } diff --git a/modules/opus/register_types.cpp b/modules/opus/register_types.cpp index a69c8bf9f3..6d7a3575ed 100644 --- a/modules/opus/register_types.cpp +++ b/modules/opus/register_types.cpp @@ -34,13 +34,18 @@ static ResourceFormatLoaderAudioStreamOpus *opus_stream_loader = NULL; void register_opus_types() { - - opus_stream_loader = memnew(ResourceFormatLoaderAudioStreamOpus); - ResourceLoader::add_resource_format_loader(opus_stream_loader); - ClassDB::register_class<AudioStreamOpus>(); + // Sorry guys, do not enable this unless you can figure out a way + // to get Opus to not do any memory allocation or system calls + // in the audio thread. + // Currently the implementation even reads files from the audio thread, + // and this is not how audio programming works. + + //opus_stream_loader = memnew(ResourceFormatLoaderAudioStreamOpus); + //ResourceLoader::add_resource_format_loader(opus_stream_loader); + //ClassDB::register_class<AudioStreamOpus>(); } void unregister_opus_types() { - memdelete(opus_stream_loader); + //memdelete(opus_stream_loader); } diff --git a/platform/osx/detect.py b/platform/osx/detect.py index e8a8319431..2e686fbee4 100644 --- a/platform/osx/detect.py +++ b/platform/osx/detect.py @@ -82,9 +82,6 @@ def configure(env): env['RANLIB'] = mpprefix + "/libexec/llvm-" + mpclangver + "/bin/llvm-ranlib" env['AS'] = mpprefix + "/libexec/llvm-" + mpclangver + "/bin/llvm-as" env.Append(CCFLAGS=['-D__MACPORTS__']) #hack to fix libvpx MM256_BROADCASTSI128_SI256 define - if (env["openmp"]): - env.Append(CPPFLAGS=['-fopenmp']) - env.Append(LINKFLAGS=['-fopenmp']) else: # osxcross build root = os.environ.get("OSXCROSS_ROOT", 0) diff --git a/platform/windows/detect.py b/platform/windows/detect.py index 564359d743..3b8de2caf4 100644 --- a/platform/windows/detect.py +++ b/platform/windows/detect.py @@ -191,8 +191,6 @@ def configure(env): if (env["use_lto"]): env.Append(CCFLAGS=['/GL']) env.Append(LINKFLAGS=['/LTCG']) - if (env["openmp"]): - env.Append(CPPFLAGS=['/openmp']) env.Append(CCFLAGS=["/I" + p for p in os.getenv("INCLUDE").split(";")]) env.Append(LIBPATH=[p for p in os.getenv("LIB").split(";")]) @@ -270,9 +268,6 @@ def configure(env): env.Append(CCFLAGS=['-flto']) env.Append(LINKFLAGS=['-flto=' + str(env.GetOption("num_jobs"))]) - if (env["openmp"]): - env.Append(CPPFLAGS=['-fopenmp']) - env.Append(LINKFLAGS=['-fopenmp']) ## Compile flags diff --git a/platform/x11/detect.py b/platform/x11/detect.py index 09bf57c5f1..cb45fed1be 100644 --- a/platform/x11/detect.py +++ b/platform/x11/detect.py @@ -265,9 +265,5 @@ def configure(env): env.Append(LINKFLAGS=['-m64', '-L/usr/lib/i686-linux-gnu']) - if env["openmp"]: - env.Append(CPPFLAGS=['-fopenmp']) - env.Append(LINKFLAGS=['-fopenmp']) - if env['use_static_cpp']: env.Append(LINKFLAGS=['-static-libstdc++']) diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index 6616e47317..f3f4b1f217 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -1050,6 +1050,10 @@ void OS_X11::set_window_maximized(bool p_enabled) { XSendEvent(x11_display, DefaultRootWindow(x11_display), False, SubstructureRedirectMask | SubstructureNotifyMask, &xev); + while (p_enabled && !is_window_maximized()) { + // Wait for effective resizing (so the GLX context is too). + } + maximized = p_enabled; } diff --git a/scene/3d/arvr_nodes.cpp b/scene/3d/arvr_nodes.cpp index e1e0b9b1ce..2bb41bf49e 100644 --- a/scene/3d/arvr_nodes.cpp +++ b/scene/3d/arvr_nodes.cpp @@ -231,7 +231,7 @@ void ARVRController::_notification(int p_what) { void ARVRController::_bind_methods() { ClassDB::bind_method(D_METHOD("set_controller_id", "controller_id"), &ARVRController::set_controller_id); ClassDB::bind_method(D_METHOD("get_controller_id"), &ARVRController::get_controller_id); - ADD_PROPERTY(PropertyInfo(Variant::INT, "controller_id", PROPERTY_HINT_RANGE, "1,32,1"), "set_controller_id", "get_controller_id"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "controller_id", PROPERTY_HINT_RANGE, "0,32,1"), "set_controller_id", "get_controller_id"); ClassDB::bind_method(D_METHOD("get_controller_name"), &ARVRController::get_controller_name); // passthroughs to information about our related joystick @@ -251,7 +251,8 @@ void ARVRController::_bind_methods() { }; void ARVRController::set_controller_id(int p_controller_id) { - // we don't check any bounds here, this controller may not yet be active and just be a place holder until it is. + // We don't check any bounds here, this controller may not yet be active and just be a place holder until it is. + // Note that setting this to 0 means this node is not bound to a controller yet. controller_id = p_controller_id; }; @@ -420,7 +421,7 @@ void ARVRAnchor::_bind_methods() { ClassDB::bind_method(D_METHOD("set_anchor_id", "anchor_id"), &ARVRAnchor::set_anchor_id); ClassDB::bind_method(D_METHOD("get_anchor_id"), &ARVRAnchor::get_anchor_id); - ADD_PROPERTY(PropertyInfo(Variant::INT, "anchor_id"), "set_anchor_id", "get_anchor_id"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "anchor_id", PROPERTY_HINT_RANGE, "0,32,1"), "set_anchor_id", "get_anchor_id"); ClassDB::bind_method(D_METHOD("get_anchor_name"), &ARVRAnchor::get_anchor_name); ClassDB::bind_method(D_METHOD("get_is_active"), &ARVRAnchor::get_is_active); @@ -430,7 +431,8 @@ void ARVRAnchor::_bind_methods() { }; void ARVRAnchor::set_anchor_id(int p_anchor_id) { - // we don't check any bounds here, this anchor may not yet be active and just be a place holder until it is. + // We don't check any bounds here, this anchor may not yet be active and just be a place holder until it is. + // Note that setting this to 0 means this node is not bound to an anchor yet. anchor_id = p_anchor_id; }; diff --git a/scene/3d/baked_lightmap.cpp b/scene/3d/baked_lightmap.cpp index 754dcd9a6c..8c282a31b8 100644 --- a/scene/3d/baked_lightmap.cpp +++ b/scene/3d/baked_lightmap.cpp @@ -165,20 +165,20 @@ BakedLightmap::BakeBeginFunc BakedLightmap::bake_begin_function = NULL; BakedLightmap::BakeStepFunc BakedLightmap::bake_step_function = NULL; BakedLightmap::BakeEndFunc BakedLightmap::bake_end_function = NULL; -void BakedLightmap::set_bake_subdiv(Subdiv p_subdiv) { - bake_subdiv = p_subdiv; +void BakedLightmap::set_bake_cell_size(float p_cell_size) { + bake_cell_size = p_cell_size; } -BakedLightmap::Subdiv BakedLightmap::get_bake_subdiv() const { - return bake_subdiv; +float BakedLightmap::get_bake_cell_size() const { + return bake_cell_size; } -void BakedLightmap::set_capture_subdiv(Subdiv p_subdiv) { - capture_subdiv = p_subdiv; +void BakedLightmap::set_capture_cell_size(float p_cell_size) { + capture_cell_size = p_cell_size; } -BakedLightmap::Subdiv BakedLightmap::get_capture_subdiv() const { - return capture_subdiv; +float BakedLightmap::get_capture_cell_size() const { + return capture_cell_size; } void BakedLightmap::set_extents(const Vector3 &p_extents) { @@ -327,11 +327,29 @@ BakedLightmap::BakeError BakedLightmap::bake(Node *p_from_node, bool p_create_vi Ref<BakedLightmapData> new_light_data; new_light_data.instance(); - static const int subdiv_value[SUBDIV_MAX] = { 8, 9, 10, 11 }; - VoxelLightBaker baker; - baker.begin_bake(subdiv_value[bake_subdiv], AABB(-extents, extents * 2.0)); + int bake_subdiv; + int capture_subdiv; + AABB bake_bounds; + { + bake_bounds = AABB(-extents, extents * 2.0); + int subdiv = nearest_power_of_2_templated(int(bake_bounds.get_longest_axis_size() / bake_cell_size)); + bake_bounds.size[bake_bounds.get_longest_axis_size()] = subdiv * bake_cell_size; + bake_subdiv = nearest_shift(subdiv) + 1; + + capture_subdiv = bake_subdiv; + float css = bake_cell_size; + while (css < capture_cell_size && capture_subdiv > 2) { + capture_subdiv--; + css *= 2.0; + } + + print_line("bake subdiv: " + itos(bake_subdiv)); + print_line("capture subdiv: " + itos(capture_subdiv)); + } + + baker.begin_bake(bake_subdiv, bake_bounds); List<PlotMesh> mesh_list; List<PlotLight> light_list; @@ -510,19 +528,19 @@ BakedLightmap::BakeError BakedLightmap::bake(Node *p_from_node, bool p_create_vi } } - int csubdiv = subdiv_value[capture_subdiv]; AABB bounds = AABB(-extents, extents * 2); - new_light_data->set_cell_subdiv(csubdiv); + new_light_data->set_cell_subdiv(capture_subdiv); new_light_data->set_bounds(bounds); - new_light_data->set_octree(baker.create_capture_octree(csubdiv)); + new_light_data->set_octree(baker.create_capture_octree(capture_subdiv)); { + float bake_bound_size = bake_bounds.get_longest_axis_size(); Transform to_bounds; - to_bounds.basis.scale(Vector3(bounds.get_longest_axis_size(), bounds.get_longest_axis_size(), bounds.get_longest_axis_size())); + to_bounds.basis.scale(Vector3(bake_bound_size, bake_bound_size, bake_bound_size)); to_bounds.origin = bounds.position; Transform to_grid; - to_grid.basis.scale(Vector3(1 << (csubdiv - 1), 1 << (csubdiv - 1), 1 << (csubdiv - 1))); + to_grid.basis.scale(Vector3(1 << (capture_subdiv - 1), 1 << (capture_subdiv - 1), 1 << (capture_subdiv - 1))); Transform to_cell_space = to_grid * to_bounds.affine_inverse(); new_light_data->set_cell_space_transform(to_cell_space); @@ -693,11 +711,11 @@ void BakedLightmap::_bind_methods() { ClassDB::bind_method(D_METHOD("set_light_data", "data"), &BakedLightmap::set_light_data); ClassDB::bind_method(D_METHOD("get_light_data"), &BakedLightmap::get_light_data); - ClassDB::bind_method(D_METHOD("set_bake_subdiv", "bake_subdiv"), &BakedLightmap::set_bake_subdiv); - ClassDB::bind_method(D_METHOD("get_bake_subdiv"), &BakedLightmap::get_bake_subdiv); + ClassDB::bind_method(D_METHOD("set_bake_cell_size", "bake_cell_size"), &BakedLightmap::set_bake_cell_size); + ClassDB::bind_method(D_METHOD("get_bake_cell_size"), &BakedLightmap::get_bake_cell_size); - ClassDB::bind_method(D_METHOD("set_capture_subdiv", "capture_subdiv"), &BakedLightmap::set_capture_subdiv); - ClassDB::bind_method(D_METHOD("get_capture_subdiv"), &BakedLightmap::get_capture_subdiv); + ClassDB::bind_method(D_METHOD("set_capture_cell_size", "capture_cell_size"), &BakedLightmap::set_capture_cell_size); + ClassDB::bind_method(D_METHOD("get_capture_cell_size"), &BakedLightmap::get_capture_cell_size); ClassDB::bind_method(D_METHOD("set_bake_quality", "bake_quality"), &BakedLightmap::set_bake_quality); ClassDB::bind_method(D_METHOD("get_bake_quality"), &BakedLightmap::get_bake_quality); @@ -724,23 +742,20 @@ void BakedLightmap::_bind_methods() { ClassDB::bind_method(D_METHOD("debug_bake"), &BakedLightmap::_debug_bake); ClassDB::set_method_flags(get_class_static(), _scs_create("debug_bake"), METHOD_FLAGS_DEFAULT | METHOD_FLAG_EDITOR); - ADD_PROPERTY(PropertyInfo(Variant::INT, "bake_subdiv", PROPERTY_HINT_ENUM, "128,256,512,1024"), "set_bake_subdiv", "get_bake_subdiv"); - ADD_PROPERTY(PropertyInfo(Variant::INT, "capture_subdiv", PROPERTY_HINT_ENUM, "128,256,512"), "set_capture_subdiv", "get_capture_subdiv"); + ADD_GROUP("Bake", "bake_"); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "bake_cell_size", PROPERTY_HINT_RANGE, "0.01,64,0.01"), "set_bake_cell_size", "get_bake_cell_size"); ADD_PROPERTY(PropertyInfo(Variant::INT, "bake_quality", PROPERTY_HINT_ENUM, "Low,Medium,High"), "set_bake_quality", "get_bake_quality"); ADD_PROPERTY(PropertyInfo(Variant::INT, "bake_mode", PROPERTY_HINT_ENUM, "ConeTrace,RayTrace"), "set_bake_mode", "get_bake_mode"); - ADD_PROPERTY(PropertyInfo(Variant::REAL, "propagation", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_propagation", "get_propagation"); - ADD_PROPERTY(PropertyInfo(Variant::REAL, "energy", PROPERTY_HINT_RANGE, "0,32,0.01"), "set_energy", "get_energy"); - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "hdr"), "set_hdr", "is_hdr"); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "bake_propagation", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_propagation", "get_propagation"); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "bake_energy", PROPERTY_HINT_RANGE, "0,32,0.01"), "set_energy", "get_energy"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "bake_hdr"), "set_hdr", "is_hdr"); + ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "bake_extents"), "set_extents", "get_extents"); + ADD_GROUP("Capture", "capture_"); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "capture_cell_size", PROPERTY_HINT_RANGE, "0.01,64,0.01"), "set_capture_cell_size", "get_capture_cell_size"); + ADD_GROUP("Data", ""); ADD_PROPERTY(PropertyInfo(Variant::STRING, "image_path", PROPERTY_HINT_DIR), "set_image_path", "get_image_path"); - ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "extents"), "set_extents", "get_extents"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "light_data", PROPERTY_HINT_RESOURCE_TYPE, "BakedIndirectLightData"), "set_light_data", "get_light_data"); - BIND_ENUM_CONSTANT(SUBDIV_128); - BIND_ENUM_CONSTANT(SUBDIV_256); - BIND_ENUM_CONSTANT(SUBDIV_512); - BIND_ENUM_CONSTANT(SUBDIV_1024); - BIND_ENUM_CONSTANT(SUBDIV_MAX); - BIND_ENUM_CONSTANT(BAKE_QUALITY_LOW); BIND_ENUM_CONSTANT(BAKE_QUALITY_MEDIUM); BIND_ENUM_CONSTANT(BAKE_QUALITY_HIGH); @@ -757,8 +772,9 @@ void BakedLightmap::_bind_methods() { BakedLightmap::BakedLightmap() { extents = Vector3(10, 10, 10); - bake_subdiv = SUBDIV_256; - capture_subdiv = SUBDIV_128; + bake_cell_size = 0.25; + capture_cell_size = 0.5; + bake_quality = BAKE_QUALITY_MEDIUM; bake_mode = BAKE_MODE_CONE_TRACE; energy = 1; diff --git a/scene/3d/baked_lightmap.h b/scene/3d/baked_lightmap.h index 9e15f1bb10..9b53e41d73 100644 --- a/scene/3d/baked_lightmap.h +++ b/scene/3d/baked_lightmap.h @@ -61,15 +61,6 @@ class BakedLightmap : public VisualInstance { GDCLASS(BakedLightmap, VisualInstance); public: - enum Subdiv { - SUBDIV_128, - SUBDIV_256, - SUBDIV_512, - SUBDIV_1024, - SUBDIV_MAX - - }; - enum BakeQuality { BAKE_QUALITY_LOW, BAKE_QUALITY_MEDIUM, @@ -95,8 +86,8 @@ public: typedef void (*BakeEndFunc)(); private: - Subdiv bake_subdiv; - Subdiv capture_subdiv; + float bake_cell_size; + float capture_cell_size; Vector3 extents; float propagation; float energy; @@ -148,11 +139,11 @@ public: void set_light_data(const Ref<BakedLightmapData> &p_data); Ref<BakedLightmapData> get_light_data() const; - void set_bake_subdiv(Subdiv p_subdiv); - Subdiv get_bake_subdiv() const; + void set_bake_cell_size(float p_cell_size); + float get_bake_cell_size() const; - void set_capture_subdiv(Subdiv p_subdiv); - Subdiv get_capture_subdiv() const; + void set_capture_cell_size(float p_cell_size); + float get_capture_cell_size() const; void set_extents(const Vector3 &p_extents); Vector3 get_extents() const; @@ -182,7 +173,6 @@ public: BakedLightmap(); }; -VARIANT_ENUM_CAST(BakedLightmap::Subdiv); VARIANT_ENUM_CAST(BakedLightmap::BakeQuality); VARIANT_ENUM_CAST(BakedLightmap::BakeMode); VARIANT_ENUM_CAST(BakedLightmap::BakeError); diff --git a/scene/3d/camera.cpp b/scene/3d/camera.cpp index 72c0b979af..c74abb7e2d 100644 --- a/scene/3d/camera.cpp +++ b/scene/3d/camera.cpp @@ -407,15 +407,6 @@ Camera::KeepAspect Camera::get_keep_aspect_mode() const { return keep_aspect; } -void Camera::set_vaspect(bool p_vaspect) { - set_keep_aspect_mode(p_vaspect ? KEEP_WIDTH : KEEP_HEIGHT); - _update_camera_mode(); -} - -bool Camera::get_vaspect() const { - return keep_aspect == KEEP_HEIGHT; -} - void Camera::set_doppler_tracking(DopplerTracking p_tracking) { if (doppler_tracking == p_tracking) @@ -468,14 +459,11 @@ void Camera::_bind_methods() { ClassDB::bind_method(D_METHOD("get_environment"), &Camera::get_environment); ClassDB::bind_method(D_METHOD("set_keep_aspect_mode", "mode"), &Camera::set_keep_aspect_mode); ClassDB::bind_method(D_METHOD("get_keep_aspect_mode"), &Camera::get_keep_aspect_mode); - ClassDB::bind_method(D_METHOD("set_vaspect"), &Camera::set_vaspect); - ClassDB::bind_method(D_METHOD("get_vaspect"), &Camera::get_vaspect); ClassDB::bind_method(D_METHOD("set_doppler_tracking", "mode"), &Camera::set_doppler_tracking); ClassDB::bind_method(D_METHOD("get_doppler_tracking"), &Camera::get_doppler_tracking); //ClassDB::bind_method(D_METHOD("_camera_make_current"),&Camera::_camera_make_current ); ADD_PROPERTY(PropertyInfo(Variant::INT, "keep_aspect", PROPERTY_HINT_ENUM, "Keep Width,Keep Height"), "set_keep_aspect_mode", "get_keep_aspect_mode"); - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "vaspect"), "set_vaspect", "get_vaspect"); ADD_PROPERTY(PropertyInfo(Variant::INT, "cull_mask", PROPERTY_HINT_LAYERS_3D_RENDER), "set_cull_mask", "get_cull_mask"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "environment", PROPERTY_HINT_RESOURCE_TYPE, "Environment"), "set_environment", "get_environment"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "h_offset"), "set_h_offset", "get_h_offset"); diff --git a/scene/3d/camera.h b/scene/3d/camera.h index 520afb962b..d69a02afeb 100644 --- a/scene/3d/camera.h +++ b/scene/3d/camera.h @@ -148,8 +148,6 @@ public: void set_keep_aspect_mode(KeepAspect p_aspect); KeepAspect get_keep_aspect_mode() const; - void set_vaspect(bool p_vaspect); - bool get_vaspect() const; void set_v_offset(float p_offset); float get_v_offset() const; diff --git a/scene/3d/skeleton.cpp b/scene/3d/skeleton.cpp index d0e0937eca..3d40bb299a 100644 --- a/scene/3d/skeleton.cpp +++ b/scene/3d/skeleton.cpp @@ -180,6 +180,9 @@ void Skeleton::_notification(int p_what) { rest_global_inverse_dirty = false; } + Transform global_transform = get_global_transform(); + Transform global_transform_inverse = global_transform.affine_inverse(); + for (int i = 0; i < len; i++) { Bone &b = bonesptr[i]; @@ -239,7 +242,9 @@ void Skeleton::_notification(int p_what) { } } - vs->skeleton_bone_set_transform(skeleton, i, b.pose_global * b.rest_global_inverse); + Transform transform = b.pose_global * b.rest_global_inverse; + + vs->skeleton_bone_set_transform(skeleton, i, global_transform * (transform * global_transform_inverse)); for (List<uint32_t>::Element *E = b.nodes_bound.front(); E; E = E->next()) { diff --git a/scene/3d/voxel_light_baker.cpp b/scene/3d/voxel_light_baker.cpp index bf0f801e32..17aa649dff 100644 --- a/scene/3d/voxel_light_baker.cpp +++ b/scene/3d/voxel_light_baker.cpp @@ -30,11 +30,9 @@ #include "voxel_light_baker.h" #include "os/os.h" +#include "os/threaded_array_processor.h" #include <stdlib.h> -#ifdef _OPENMP -#include <omp.h> -#endif #define FINDMINMAX(x0, x1, x2, min, max) \ min = max = x0; \ @@ -1689,7 +1687,7 @@ _ALWAYS_INLINE_ uint32_t xorshift32(uint32_t *state) { return x; } -Vector3 VoxelLightBaker::_compute_ray_trace_at_pos(const Vector3 &p_pos, const Vector3 &p_normal, uint32_t *rng_state) { +Vector3 VoxelLightBaker::_compute_ray_trace_at_pos(const Vector3 &p_pos, const Vector3 &p_normal) { int samples_per_quality[3] = { 48, 128, 512 }; @@ -1711,8 +1709,7 @@ Vector3 VoxelLightBaker::_compute_ray_trace_at_pos(const Vector3 &p_pos, const V const Light *light = bake_light.ptr(); const Cell *cells = bake_cells.ptr(); - // Prevent false sharing when running on OpenMP - uint32_t local_rng_state = *rng_state; + uint32_t local_rng_state = rand(); //needs to be fixed again for (int i = 0; i < samples; i++) { @@ -1796,10 +1793,30 @@ Vector3 VoxelLightBaker::_compute_ray_trace_at_pos(const Vector3 &p_pos, const V } // Make sure we don't reset this thread's RNG state - *rng_state = local_rng_state; + return accum / samples; } +void VoxelLightBaker::_lightmap_bake_point(uint32_t p_x, LightMap *p_line) { + + + LightMap *pixel = &p_line[p_x]; + if (pixel->pos == Vector3()) + return; + //print_line("pos: " + pixel->pos + " normal " + pixel->normal); + switch (bake_mode) { + case BAKE_MODE_CONE_TRACE: { + pixel->light = _compute_pixel_light_at_pos(pixel->pos, pixel->normal) * energy; + } break; + case BAKE_MODE_RAY_TRACE: { + pixel->light = _compute_ray_trace_at_pos(pixel->pos, pixel->normal) * energy; + } break; + // pixel->light = Vector3(1, 1, 1); + //} + } + +} + Error VoxelLightBaker::make_lightmap(const Transform &p_xform, Ref<Mesh> &p_mesh, LightMapData &r_lightmap, bool (*p_bake_time_func)(void *, float, float), void *p_bake_time_ud) { //transfer light information to a lightmap @@ -1862,53 +1879,10 @@ Error VoxelLightBaker::make_lightmap(const Transform &p_xform, Ref<Mesh> &p_mesh volatile int lines = 0; // make sure our OS-level rng is seeded - srand(OS::get_singleton()->get_ticks_usec()); - - // setup an RNG state for each OpenMP thread - uint32_t threadcount = 1; - uint32_t threadnum = 0; -#ifdef _OPENMP - threadcount = omp_get_max_threads(); -#endif - Vector<uint32_t> rng_states; - rng_states.resize(threadcount); - for (uint32_t i = 0; i < threadcount; i++) { - do { - rng_states[i] = rand(); - } while (rng_states[i] == 0); - } - uint32_t *rng_states_p = rng_states.ptrw(); for (int i = 0; i < height; i++) { - //print_line("bake line " + itos(i) + " / " + itos(height)); -#ifdef _OPENMP -#pragma omp parallel for schedule(dynamic, 1) private(threadnum) -#endif - for (int j = 0; j < width; j++) { - -#ifdef _OPENMP - threadnum = omp_get_thread_num(); -#endif - - //if (i == 125 && j == 280) { - - LightMap *pixel = &lightmap_ptr[i * width + j]; - if (pixel->pos == Vector3()) - continue; //unused, skipe - - //print_line("pos: " + pixel->pos + " normal " + pixel->normal); - switch (bake_mode) { - case BAKE_MODE_CONE_TRACE: { - pixel->light = _compute_pixel_light_at_pos(pixel->pos, pixel->normal) * energy; - } break; - case BAKE_MODE_RAY_TRACE: { - pixel->light = _compute_ray_trace_at_pos(pixel->pos, pixel->normal, &rng_states_p[threadnum]) * energy; - } break; - // pixel->light = Vector3(1, 1, 1); - //} - } - } + thread_process_array(width,this,&VoxelLightBaker::_lightmap_bake_point,&lightmap_ptr[i*width]); lines = MAX(lines, i); //for multithread if (p_bake_time_func) { diff --git a/scene/3d/voxel_light_baker.h b/scene/3d/voxel_light_baker.h index 7db31f8a67..68e11c356b 100644 --- a/scene/3d/voxel_light_baker.h +++ b/scene/3d/voxel_light_baker.h @@ -148,9 +148,12 @@ private: _FORCE_INLINE_ void _sample_baked_octree_filtered_and_anisotropic(const Vector3 &p_posf, const Vector3 &p_direction, float p_level, Vector3 &r_color, float &r_alpha); _FORCE_INLINE_ Vector3 _voxel_cone_trace(const Vector3 &p_pos, const Vector3 &p_normal, float p_aperture); _FORCE_INLINE_ Vector3 _compute_pixel_light_at_pos(const Vector3 &p_pos, const Vector3 &p_normal); - _FORCE_INLINE_ Vector3 _compute_ray_trace_at_pos(const Vector3 &p_pos, const Vector3 &p_normal, uint32_t *rng_state); + _FORCE_INLINE_ Vector3 _compute_ray_trace_at_pos(const Vector3 &p_pos, const Vector3 &p_normal); + + void _lightmap_bake_point(uint32_t p_x, LightMap *p_line); public: + void begin_bake(int p_subdiv, const AABB &p_bounds); void plot_mesh(const Transform &p_xform, Ref<Mesh> &p_mesh, const Vector<Ref<Material> > &p_materials, const Ref<Material> &p_override_material); void begin_bake_light(BakeQuality p_quality = BAKE_QUALITY_MEDIUM, BakeMode p_bake_mode = BAKE_MODE_CONE_TRACE, float p_propagation = 0.85, float p_energy = 1); diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp index 148277f2dd..a67fe2aeeb 100644 --- a/scene/gui/base_button.cpp +++ b/scene/gui/base_button.cpp @@ -450,11 +450,11 @@ String BaseButton::get_tooltip(const Point2 &p_pos) const { String tooltip = Control::get_tooltip(p_pos); if (shortcut.is_valid() && shortcut->is_valid()) { - if (tooltip.find("$sc") != -1) { - tooltip = tooltip.replace_first("$sc", "(" + shortcut->get_as_text() + ")"); - } else { - tooltip += " (" + shortcut->get_as_text() + ")"; + String text = shortcut->get_name() + " (" + shortcut->get_as_text() + ")"; + if (shortcut->get_name().nocasecmp_to(tooltip) != 0) { + text += "\n" + tooltip; } + tooltip = text; } return tooltip; } diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index c156b0df31..8f431389d8 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -1808,15 +1808,18 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) { pos = gui.focus_inv_xform.xform(pos); mb->set_position(pos); - if (gui.mouse_focus->can_process()) { - _gui_call_input(gui.mouse_focus, mb); - } + Control *mouse_focus = gui.mouse_focus; + //disable mouse focus if needed before calling input, this makes popups on mouse press event work better, as the release will never be received otherwise if (mb->get_button_index() == gui.mouse_focus_button) { gui.mouse_focus = NULL; gui.mouse_focus_button = -1; } + if (mouse_focus->can_process()) { + _gui_call_input(mouse_focus, mb); + } + /*if (gui.drag_data.get_type()!=Variant::NIL && mb->get_button_index()==BUTTON_LEFT) { _propagate_viewport_notification(this,NOTIFICATION_DRAG_END); gui.drag_data=Variant(); //always clear diff --git a/servers/arvr/arvr_positional_tracker.cpp b/servers/arvr/arvr_positional_tracker.cpp index fc0270615c..fb97d5b86b 100644 --- a/servers/arvr/arvr_positional_tracker.cpp +++ b/servers/arvr/arvr_positional_tracker.cpp @@ -62,13 +62,15 @@ void ARVRPositionalTracker::_bind_methods() { void ARVRPositionalTracker::set_type(ARVRServer::TrackerType p_type) { if (type != p_type) { type = p_type; + hand = ARVRPositionalTracker::TRACKER_HAND_UNKNOWN; ARVRServer *arvr_server = ARVRServer::get_singleton(); ERR_FAIL_NULL(arvr_server); // get a tracker id for our type + // note if this is a controller this will be 3 or higher but we may change it later. tracker_id = arvr_server->get_free_tracker_id_for_type(p_type); - } + }; }; ARVRServer::TrackerType ARVRPositionalTracker::get_type() const { @@ -156,7 +158,24 @@ ARVRPositionalTracker::TrackerHand ARVRPositionalTracker::get_hand() const { }; void ARVRPositionalTracker::set_hand(const ARVRPositionalTracker::TrackerHand p_hand) { - hand = p_hand; + ARVRServer *arvr_server = ARVRServer::get_singleton(); + ERR_FAIL_NULL(arvr_server); + + if (hand != p_hand) { + // we can only set this if we've previously set this to be a controller!! + ERR_FAIL_COND((type != ARVRServer::TRACKER_CONTROLLER) && (p_hand != ARVRPositionalTracker::TRACKER_HAND_UNKNOWN)); + + hand = p_hand; + if (hand == ARVRPositionalTracker::TRACKER_LEFT_HAND) { + if (!arvr_server->is_tracker_id_in_use_for_type(type, 1)) { + tracker_id = 1; + }; + } else if (hand == ARVRPositionalTracker::TRACKER_RIGHT_HAND) { + if (!arvr_server->is_tracker_id_in_use_for_type(type, 2)) { + tracker_id = 2; + }; + }; + }; }; Transform ARVRPositionalTracker::get_transform(bool p_adjust_by_reference_frame) const { diff --git a/servers/arvr_server.cpp b/servers/arvr_server.cpp index 1e73d6753c..df73040e1e 100644 --- a/servers/arvr_server.cpp +++ b/servers/arvr_server.cpp @@ -43,7 +43,7 @@ void ARVRServer::_bind_methods() { ClassDB::bind_method(D_METHOD("get_world_scale"), &ARVRServer::get_world_scale); ClassDB::bind_method(D_METHOD("set_world_scale"), &ARVRServer::set_world_scale); ClassDB::bind_method(D_METHOD("get_reference_frame"), &ARVRServer::get_reference_frame); - ClassDB::bind_method(D_METHOD("center_on_hmd", "ignore_tilt", "keep_height"), &ARVRServer::center_on_hmd); + ClassDB::bind_method(D_METHOD("center_on_hmd", "rotation_mode", "keep_height"), &ARVRServer::center_on_hmd); ADD_PROPERTY(PropertyInfo(Variant::REAL, "world_scale"), "set_world_scale", "get_world_scale"); @@ -63,6 +63,10 @@ void ARVRServer::_bind_methods() { BIND_ENUM_CONSTANT(TRACKER_UNKNOWN); BIND_ENUM_CONSTANT(TRACKER_ANY); + BIND_ENUM_CONSTANT(RESET_FULL_ROTATION); + BIND_ENUM_CONSTANT(RESET_BUT_KEEP_TILT); + BIND_ENUM_CONSTANT(DONT_RESET_ROTATION); + ADD_SIGNAL(MethodInfo("interface_added", PropertyInfo(Variant::STRING, "name"))); ADD_SIGNAL(MethodInfo("interface_removed", PropertyInfo(Variant::STRING, "name"))); @@ -96,7 +100,7 @@ Transform ARVRServer::get_reference_frame() const { return reference_frame; }; -void ARVRServer::center_on_hmd(bool p_ignore_tilt, bool p_keep_height) { +void ARVRServer::center_on_hmd(RotationMode p_rotation_mode, bool p_keep_height) { if (primary_interface != NULL) { // clear our current reference frame or we'll end up double adjusting it reference_frame = Transform(); @@ -105,7 +109,7 @@ void ARVRServer::center_on_hmd(bool p_ignore_tilt, bool p_keep_height) { Transform new_reference_frame = primary_interface->get_transform_for_eye(ARVRInterface::EYE_MONO, Transform()); // remove our tilt - if (p_ignore_tilt) { + if (p_rotation_mode == 1) { // take the Y out of our Z new_reference_frame.basis.set_axis(2, Vector3(new_reference_frame.basis.elements[0][2], 0.0, new_reference_frame.basis.elements[2][2]).normalized()); @@ -114,6 +118,9 @@ void ARVRServer::center_on_hmd(bool p_ignore_tilt, bool p_keep_height) { // and X is our cross reference new_reference_frame.basis.set_axis(0, new_reference_frame.basis.get_axis(1).cross(new_reference_frame.basis.get_axis(2)).normalized()); + } else if (p_rotation_mode == 2) { + // remove our rotation, we're only interesting in centering on position + new_reference_frame.basis = Basis(); }; // don't negate our height @@ -229,8 +236,12 @@ bool ARVRServer::is_tracker_id_in_use_for_type(TrackerType p_tracker_type, int p }; int ARVRServer::get_free_tracker_id_for_type(TrackerType p_tracker_type) { - // we start checking at 1, 0 means that it's not a controller.. - int tracker_id = 1; + // We start checking at 1, 0 means that it's not a controller.. + // Note that for controller we reserve: + // - 1 for the left hand controller and + // - 2 for the right hand controller + // so we start at 3 :) + int tracker_id = p_tracker_type == ARVRServer::TRACKER_CONTROLLER ? 3 : 1; while (is_tracker_id_in_use_for_type(p_tracker_type, tracker_id)) { // try the next one diff --git a/servers/arvr_server.h b/servers/arvr_server.h index 9b84ee2e99..0381e6e533 100644 --- a/servers/arvr_server.h +++ b/servers/arvr_server.h @@ -68,6 +68,12 @@ public: TRACKER_ANY = 0xff /* used by get_connected_trackers to return all types */ }; + enum RotationMode { + RESET_FULL_ROTATION = 0, /* we reset the full rotation, regardless of how the HMD is oriented, we're looking dead ahead */ + RESET_BUT_KEEP_TILT = 1, /* reset rotation but keep tilt. */ + DONT_RESET_ROTATION = 2, /* don't reset the rotation, we will only center on position */ + }; + private: Vector<Ref<ARVRInterface> > interfaces; Vector<ARVRPositionalTracker *> trackers; @@ -78,8 +84,6 @@ private: Transform world_origin; /* our world origin point, maps a location in our virtual world to the origin point in our real world tracking volume */ Transform reference_frame; /* our reference frame */ - bool is_tracker_id_in_use_for_type(TrackerType p_tracker_type, int p_tracker_id) const; - protected: static ARVRServer *singleton; @@ -127,7 +131,7 @@ public: and in the virtual world out of sync */ Transform get_reference_frame() const; - void center_on_hmd(bool p_ignore_tilt, bool p_keep_height); + void center_on_hmd(RotationMode p_rotation_mode, bool p_keep_height); /* Interfaces are objects that 'glue' Godot to an AR or VR SDK such as the Oculus SDK, OpenVR, OpenHMD, etc. @@ -150,9 +154,8 @@ public: /* Our trackers are objects that expose the orientation and position of physical devices such as controller, anchor points, etc. They are created and managed by our active AR/VR interfaces. - - Note that for trackers that */ + bool is_tracker_id_in_use_for_type(TrackerType p_tracker_type, int p_tracker_id) const; int get_free_tracker_id_for_type(TrackerType p_tracker_type); void add_tracker(ARVRPositionalTracker *p_tracker); void remove_tracker(ARVRPositionalTracker *p_tracker); @@ -167,5 +170,6 @@ public: #define ARVR ARVRServer VARIANT_ENUM_CAST(ARVRServer::TrackerType); +VARIANT_ENUM_CAST(ARVRServer::RotationMode); #endif |