diff options
26 files changed, 161 insertions, 78 deletions
diff --git a/SConstruct b/SConstruct index 17cf779d4a..ce2566559c 100644 --- a/SConstruct +++ b/SConstruct @@ -125,7 +125,7 @@ opts.Add(BoolVariable('verbose', "Enable verbose output for the compilation", Fa opts.Add(BoolVariable('progress', "Show a progress indicator during compilation", True)) opts.Add(EnumVariable('warnings', "Set the level of warnings emitted during compilation", 'all', ('extra', 'all', 'moderate', 'no'))) opts.Add(BoolVariable('werror', "Treat compiler warnings as errors. Depends on the level of warnings set with 'warnings'", False)) -opts.Add(BoolVariable('dev', "If yes, alias for verbose=yes warnings=all", False)) +opts.Add(BoolVariable('dev', "If yes, alias for verbose=yes warnings=extra werror=yes", False)) opts.Add('extra_suffix', "Custom extra suffix added to the base filename of all generated binary files", '') opts.Add(BoolVariable('vsproj', "Generate a Visual Studio solution", False)) opts.Add(EnumVariable('macports_clang', "Build using Clang from MacPorts", 'no', ('no', '5.0', 'devel'))) @@ -254,8 +254,9 @@ if selected_platform in platform_list: env = env_base.Clone() if env['dev']: - env["warnings"] = "all" env['verbose'] = True + env['warnings'] = "extra" + env['werror'] = True if env['vsproj']: env.vs_incs = [] @@ -337,7 +338,6 @@ if selected_platform in platform_list: if (env["warnings"] == 'extra'): # FIXME: enable -Wclobbered once #26351 is fixed - # FIXME: enable -Wduplicated-branches once #27594 is merged # Note: enable -Wimplicit-fallthrough for Clang (already part of -Wextra for GCC) # once we switch to C++11 or later (necessary for our FALLTHROUGH macro). env.Append(CCFLAGS=['-Wall', '-Wextra', '-Wno-unused-parameter'] @@ -345,7 +345,8 @@ if selected_platform in platform_list: env.Append(CXXFLAGS=['-Wctor-dtor-privacy', '-Wnon-virtual-dtor']) if methods.using_gcc(env): env.Append(CCFLAGS=['-Wno-clobbered', '-Walloc-zero', - '-Wduplicated-cond', '-Wstringop-overflow=4', '-Wlogical-op']) + '-Wduplicated-branches', '-Wduplicated-cond', + '-Wstringop-overflow=4', '-Wlogical-op']) env.Append(CXXFLAGS=['-Wnoexcept', '-Wplacement-new=1']) version = methods.get_compiler_version(env) if version != None and version[0] >= '9': diff --git a/doc/classes/AnimationNode.xml b/doc/classes/AnimationNode.xml index 9854d4c27e..23f7a316d9 100644 --- a/doc/classes/AnimationNode.xml +++ b/doc/classes/AnimationNode.xml @@ -215,6 +215,7 @@ </signal> <signal name="tree_changed"> <description> + Emitted by nodes that inherit from this class and that have an internal tree when one of their nodes changes. The nodes that emit this signal are [AnimationNodeBlendSpace1D], [AnimationNodeBlendSpace2D], [AnimationNodeStateMachine], and [AnimationNodeBlendTree]. </description> </signal> </signals> diff --git a/doc/classes/AnimationNodeAdd2.xml b/doc/classes/AnimationNodeAdd2.xml index ac2a28e396..890d6f8b49 100644 --- a/doc/classes/AnimationNodeAdd2.xml +++ b/doc/classes/AnimationNodeAdd2.xml @@ -1,8 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="AnimationNodeAdd2" inherits="AnimationNode" category="Core" version="3.2"> <brief_description> + Blends two animations additively inside of an [AnimationNodeBlendTree]. </brief_description> <description> + A resource to add to an [AnimationNodeBlendTree]. Blends two animations additively based on an amount value in the [code][0.0, 1.0][/code] range. </description> <tutorials> </tutorials> @@ -10,6 +12,7 @@ </methods> <members> <member name="sync" type="bool" setter="set_use_sync" getter="is_using_sync"> + If [code]true[/code], sets the [code]optimization[/code] to [code]false[/code] when calling [method AnimationNode.blend_input], forcing the blended animations to update every frame. </member> </members> <constants> diff --git a/doc/classes/AnimationNodeAdd3.xml b/doc/classes/AnimationNodeAdd3.xml index 9cfeb47378..4e36f0bae4 100644 --- a/doc/classes/AnimationNodeAdd3.xml +++ b/doc/classes/AnimationNodeAdd3.xml @@ -1,8 +1,14 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="AnimationNodeAdd3" inherits="AnimationNode" category="Core" version="3.2"> <brief_description> + Blends two of three animations additively inside of an [AnimationNodeBlendTree]. </brief_description> <description> + A resource to add to an [AnimationNodeBlendTree]. Blends two animations together additively out of three based on a value in the [-1.0, 1.0] range. + This node has three inputs: + - The base animation to add to + - A -add animation to blend with when the blend amount is in the [-1.0, 0.0] range. + - A +add animation to blend with when the blend amount is in the [code][0.0, 1.0][/code] range </description> <tutorials> </tutorials> @@ -10,6 +16,7 @@ </methods> <members> <member name="sync" type="bool" setter="set_use_sync" getter="is_using_sync"> + If [code]true[/code], sets the [code]optimization[/code] to [code]false[/code] when calling [method AnimationNode.blend_input], forcing the blended animations to update every frame. </member> </members> <constants> diff --git a/doc/classes/AnimationNodeAnimation.xml b/doc/classes/AnimationNodeAnimation.xml index e7d53fc7b3..420a702d38 100644 --- a/doc/classes/AnimationNodeAnimation.xml +++ b/doc/classes/AnimationNodeAnimation.xml @@ -1,8 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="AnimationNodeAnimation" inherits="AnimationRootNode" category="Core" version="3.2"> <brief_description> + Input animation to use in an [AnimationNodeBlendTree]. </brief_description> <description> + A resource to add to an [AnimationNodeBlendTree]. Only features one output set using the [member animation] property. Use it as an input for [AnimationNode] that blend animations together. </description> <tutorials> </tutorials> @@ -10,6 +12,7 @@ </methods> <members> <member name="animation" type="String" setter="set_animation" getter="get_animation"> + Animation to use as an output. It is one of the animations provided by [member AnimationTree.anim_player]. </member> </members> <constants> diff --git a/doc/classes/AnimationNodeBlend2.xml b/doc/classes/AnimationNodeBlend2.xml index f15fa44f39..9358c5eeef 100644 --- a/doc/classes/AnimationNodeBlend2.xml +++ b/doc/classes/AnimationNodeBlend2.xml @@ -1,8 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="AnimationNodeBlend2" inherits="AnimationNode" category="Core" version="3.2"> <brief_description> + Blends two animations linearly inside of an [AnimationNodeBlendTree]. </brief_description> <description> + A resource to add to an [AnimationNodeBlendTree]. Blends two animations linearly based on an amount value in the [code][0.0, 1.0][/code] range. </description> <tutorials> </tutorials> @@ -10,6 +12,7 @@ </methods> <members> <member name="sync" type="bool" setter="set_use_sync" getter="is_using_sync"> + If [code]true[/code], sets the [code]optimization[/code] to [code]false[/code] when calling [method AnimationNode.blend_input], forcing the blended animations to update every frame. </member> </members> <constants> diff --git a/doc/classes/AnimationNodeBlend3.xml b/doc/classes/AnimationNodeBlend3.xml index 2f82eea041..9b9cf80968 100644 --- a/doc/classes/AnimationNodeBlend3.xml +++ b/doc/classes/AnimationNodeBlend3.xml @@ -1,8 +1,14 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="AnimationNodeBlend3" inherits="AnimationNode" category="Core" version="3.2"> <brief_description> + Blends two of three animations linearly inside of an [AnimationNodeBlendTree]. </brief_description> <description> + A resource to add to an [AnimationNodeBlendTree]. Blends two animations together linearly out of three based on a value in the [-1.0, 1.0] range. + This node has three inputs: + - The base animation + - A -blend animation to blend with when the blend amount is in the [-1.0, 0.0] range. + - A +blend animation to blend with when the blend amount is in the [code][0.0, 1.0][/code] range </description> <tutorials> </tutorials> @@ -10,6 +16,7 @@ </methods> <members> <member name="sync" type="bool" setter="set_use_sync" getter="is_using_sync"> + If [code]true[/code], sets the [code]optimization[/code] to [code]false[/code] when calling [method AnimationNode.blend_input], forcing the blended animations to update every frame. </member> </members> <constants> diff --git a/doc/classes/AnimationNodeBlendSpace1D.xml b/doc/classes/AnimationNodeBlendSpace1D.xml index b13aee277e..6fb5c6312b 100644 --- a/doc/classes/AnimationNodeBlendSpace1D.xml +++ b/doc/classes/AnimationNodeBlendSpace1D.xml @@ -1,8 +1,13 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="AnimationNodeBlendSpace1D" inherits="AnimationRootNode" category="Core" version="3.2"> <brief_description> + Blends linearly between two of any number of [AnimationNode] of any type placed on a virtual axis. </brief_description> <description> + A resource to add to an [AnimationNodeBlendTree]. + This is a virtual axis on which you can add any type of [AnimationNode] using [method add_blend_point]. + Outputs the linear blend of the two [code]AnimationNode[/code] closest to the node's current [code]value[/code]. + You can set the extents of the axis using the [member min_space] and [member max_space]. </description> <tutorials> </tutorials> @@ -17,12 +22,14 @@ <argument index="2" name="at_index" type="int" default="-1"> </argument> <description> + Add a new point that represents a [code]node[/code] on the virtual axis at a given position set by [code]pos[/code]. You can insert it at a specific index using the [code]at_index[/code] argument. If you use the default value for [code]at_index[/code] , the point is inserted at the end of the blend points array. </description> </method> <method name="get_blend_point_count" qualifiers="const"> <return type="int"> </return> <description> + Returns the number of points on the blend axis. </description> </method> <method name="get_blend_point_node" qualifiers="const"> @@ -31,6 +38,7 @@ <argument index="0" name="point" type="int"> </argument> <description> + Returns the [code]AnimationNode[/code] referenced by the point at index [code]point[/code]. </description> </method> <method name="get_blend_point_position" qualifiers="const"> @@ -39,6 +47,7 @@ <argument index="0" name="point" type="int"> </argument> <description> + Returns the position of the point at index [code]point[/code]. </description> </method> <method name="remove_blend_point"> @@ -47,6 +56,7 @@ <argument index="0" name="point" type="int"> </argument> <description> + Removes the point at index [code]point[/code] from the blend axis. </description> </method> <method name="set_blend_point_node"> @@ -57,6 +67,7 @@ <argument index="1" name="node" type="AnimationRootNode"> </argument> <description> + Changes the AnimationNode referenced by the point at index [code]point[/code]. </description> </method> <method name="set_blend_point_position"> @@ -67,17 +78,22 @@ <argument index="1" name="pos" type="float"> </argument> <description> + Updates the position of the point at index [code]point[/code] on the blend axis. </description> </method> </methods> <members> <member name="max_space" type="float" setter="set_max_space" getter="get_max_space"> + The blend space's axis's upper limit for the points' position. See [method add_blend_point]. </member> <member name="min_space" type="float" setter="set_min_space" getter="get_min_space"> + The blend space's axis's lower limit for the points' position. See [method add_blend_point]. </member> <member name="snap" type="float" setter="set_snap" getter="get_snap"> + Position increment to snap to when moving a point on the axis. </member> <member name="value_label" type="String" setter="set_value_label" getter="get_value_label"> + Label of the virtual axis of the blend space. </member> </members> <constants> diff --git a/doc/classes/AnimationNodeBlendSpace2D.xml b/doc/classes/AnimationNodeBlendSpace2D.xml index 2ec5977301..74d4f1c60d 100644 --- a/doc/classes/AnimationNodeBlendSpace2D.xml +++ b/doc/classes/AnimationNodeBlendSpace2D.xml @@ -1,8 +1,12 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="AnimationNodeBlendSpace2D" inherits="AnimationRootNode" category="Core" version="3.2"> <brief_description> + Blends linearly between three [AnimationNode] of any type placed in a 2d space. </brief_description> <description> + A resource to add to an [AnimationNodeBlendTree]. + This node allows you to blend linearly between three animations using a [Vector2] weight. + You can add vertices to the blend space with [method add_blend_point] and automatically triangulate it by setting [member auto_triangles] to [code]true[/code]. Otherwise, use [method add_triangle] and [method remove_triangle] to create up the blend space by hand. </description> <tutorials> </tutorials> @@ -17,6 +21,7 @@ <argument index="2" name="at_index" type="int" default="-1"> </argument> <description> + Add a new point that represents a [code]node[/code] at the position set by [code]pos[/code]. You can insert it at a specific index using the [code]at_index[/code] argument. If you use the default value for [code]at_index[/code] , the point is inserted at the end of the blend points array. </description> </method> <method name="add_triangle"> @@ -31,12 +36,14 @@ <argument index="3" name="at_index" type="int" default="-1"> </argument> <description> + Creates a new triangle using three points [code]x[/code], [code]y[/code], and [code]z[/code]. Triangles can overlap. You can insert the triangle at a specific index using the [code]at_index[/code] argument. If you use the default value for [code]at_index[/code] , the point is inserted at the end of the blend points array. </description> </method> <method name="get_blend_point_count" qualifiers="const"> <return type="int"> </return> <description> + Returns the number of points in the blend space. </description> </method> <method name="get_blend_point_node" qualifiers="const"> @@ -45,6 +52,7 @@ <argument index="0" name="point" type="int"> </argument> <description> + Returns the [code]AnimationRootNode[/code] referenced by the point at index [code]point[/code]. </description> </method> <method name="get_blend_point_position" qualifiers="const"> @@ -53,12 +61,14 @@ <argument index="0" name="point" type="int"> </argument> <description> + Returns the position of the point at index [code]point[/code]. </description> </method> <method name="get_triangle_count" qualifiers="const"> <return type="int"> </return> <description> + Returns the number of triangles in the blend space. </description> </method> <method name="get_triangle_point"> @@ -69,6 +79,7 @@ <argument index="1" name="point" type="int"> </argument> <description> + Returns the position of the point at index [code]point[/code] in the triangle of index [code]triangle[/code]. </description> </method> <method name="remove_blend_point"> @@ -77,6 +88,7 @@ <argument index="0" name="point" type="int"> </argument> <description> + Removes the point at index [code]point[/code] from the blend space. </description> </method> <method name="remove_triangle"> @@ -85,6 +97,7 @@ <argument index="0" name="triangle" type="int"> </argument> <description> + Removes the triangle at index [code]triangle[/code] from the blend space. </description> </method> <method name="set_blend_point_node"> @@ -95,6 +108,7 @@ <argument index="1" name="node" type="AnimationRootNode"> </argument> <description> + Changes the AnimationNode referenced by the point at index [code]point[/code]. </description> </method> <method name="set_blend_point_position"> @@ -105,39 +119,49 @@ <argument index="1" name="pos" type="Vector2"> </argument> <description> + Updates the position of the point at index [code]point[/code] on the blend axis. </description> </method> </methods> <members> <member name="auto_triangles" type="bool" setter="set_auto_triangles" getter="get_auto_triangles"> + If true, the blend space is triangulated automatically. The mesh updates every time you add or remove points with [method add_blend_point] and [method remove_blend_point]. </member> <member name="blend_mode" type="int" setter="set_blend_mode" getter="get_blend_mode" enum="AnimationNodeBlendSpace2D.BlendMode"> + Controls the interpolation between animations. See [enum BlendMode] constants. </member> <member name="max_space" type="Vector2" setter="set_max_space" getter="get_max_space"> + The blend space's X and Y axes' upper limit for the points' position. See [method add_blend_point]. </member> <member name="min_space" type="Vector2" setter="set_min_space" getter="get_min_space"> + The blend space's X and Y axes' lower limit for the points' position. See [method add_blend_point]. </member> <member name="snap" type="Vector2" setter="set_snap" getter="get_snap"> + Position increment to snap to when moving a point. </member> <member name="x_label" type="String" setter="set_x_label" getter="get_x_label"> + Name of the blend space's X axis. </member> <member name="y_label" type="String" setter="set_y_label" getter="get_y_label"> + Name of the blend space's Y axis. </member> </members> <signals> <signal name="triangles_updated"> <description> + Emitted every time the blend space's triangles are created, removed, or when one of their vertices changes position. </description> </signal> </signals> <constants> <constant name="BLEND_MODE_INTERPOLATED" value="0" enum="BlendMode"> + The interpolation between animations is linear. </constant> <constant name="BLEND_MODE_DISCRETE" value="1" enum="BlendMode"> - Useful for frame-by-frame 2D animations. + The blend space plays the animation of the node the blending position is closest to. Useful for frame-by-frame 2D animations. </constant> <constant name="BLEND_MODE_DISCRETE_CARRY" value="2" enum="BlendMode"> - Keep the current play position when switching between discrete animations. + Similar to [const BLEND_MODE_DISCRETE], but starts the new animation at the last animation's playback position. </constant> </constants> </class> diff --git a/drivers/unix/net_socket_posix.cpp b/drivers/unix/net_socket_posix.cpp index 37abccbe27..75d51c8503 100644 --- a/drivers/unix/net_socket_posix.cpp +++ b/drivers/unix/net_socket_posix.cpp @@ -306,7 +306,7 @@ Error NetSocketPosix::bind(IP_Address p_addr, uint16_t p_port) { sockaddr_storage addr; size_t addr_size = _set_addr_storage(&addr, p_addr, p_port, _ip_type); - if (::bind(_sock, (struct sockaddr *)&addr, addr_size) == SOCK_EMPTY) { + if (::bind(_sock, (struct sockaddr *)&addr, addr_size) != 0) { close(); ERR_FAIL_V(ERR_UNAVAILABLE); } @@ -317,7 +317,7 @@ Error NetSocketPosix::bind(IP_Address p_addr, uint16_t p_port) { Error NetSocketPosix::listen(int p_max_pending) { ERR_FAIL_COND_V(!is_open(), ERR_UNCONFIGURED); - if (::listen(_sock, p_max_pending) == SOCK_EMPTY) { + if (::listen(_sock, p_max_pending) != 0) { close(); ERR_FAIL_V(FAILED); @@ -334,7 +334,7 @@ Error NetSocketPosix::connect_to_host(IP_Address p_host, uint16_t p_port) { struct sockaddr_storage addr; size_t addr_size = _set_addr_storage(&addr, p_host, p_port, _ip_type); - if (::connect(_sock, (struct sockaddr *)&addr, addr_size) == SOCK_EMPTY) { + if (::connect(_sock, (struct sockaddr *)&addr, addr_size) != 0) { NetError err = _get_socket_error(); diff --git a/drivers/wasapi/audio_driver_wasapi.cpp b/drivers/wasapi/audio_driver_wasapi.cpp index c97849ef07..fea38ee95d 100644 --- a/drivers/wasapi/audio_driver_wasapi.cpp +++ b/drivers/wasapi/audio_driver_wasapi.cpp @@ -167,13 +167,13 @@ Error AudioDriverWASAPI::audio_device_init(AudioDeviceWASAPI *p_device, bool p_c ERR_FAIL_COND_V(hr != S_OK, ERR_CANT_OPEN); for (ULONG i = 0; i < count && !found; i++) { - IMMDevice *device = NULL; + IMMDevice *tmp_device = NULL; - hr = devices->Item(i, &device); + hr = devices->Item(i, &tmp_device); ERR_BREAK(hr != S_OK); IPropertyStore *props = NULL; - hr = device->OpenPropertyStore(STGM_READ, &props); + hr = tmp_device->OpenPropertyStore(STGM_READ, &props); ERR_BREAK(hr != S_OK); PROPVARIANT propvar; @@ -183,7 +183,7 @@ Error AudioDriverWASAPI::audio_device_init(AudioDeviceWASAPI *p_device, bool p_c ERR_BREAK(hr != S_OK); if (p_device->device_name == String(propvar.pwszVal)) { - hr = device->GetId(&strId); + hr = tmp_device->GetId(&strId); ERR_BREAK(hr != S_OK); found = true; @@ -191,7 +191,7 @@ Error AudioDriverWASAPI::audio_device_init(AudioDeviceWASAPI *p_device, bool p_c PropVariantClear(&propvar); props->Release(); - device->Release(); + tmp_device->Release(); } if (found) { @@ -289,7 +289,7 @@ Error AudioDriverWASAPI::audio_device_init(AudioDeviceWASAPI *p_device, bool p_c } DWORD streamflags = 0; - if (mix_rate != pwfex->nSamplesPerSec) { + if ((DWORD)mix_rate != pwfex->nSamplesPerSec) { streamflags |= AUDCLNT_STREAMFLAGS_RATEADJUST; pwfex->nSamplesPerSec = mix_rate; pwfex->nAvgBytesPerSec = pwfex->nSamplesPerSec * pwfex->nChannels * (pwfex->wBitsPerSample / 8); @@ -571,7 +571,7 @@ void AudioDriverWASAPI::thread_func(void *p_udata) { if (ad->audio_output.active) { ad->audio_server_process(ad->buffer_frames, ad->samples_in.ptrw()); } else { - for (unsigned int i = 0; i < ad->samples_in.size(); i++) { + for (int i = 0; i < ad->samples_in.size(); i++) { ad->samples_in.write[i] = 0; } } @@ -699,7 +699,7 @@ void AudioDriverWASAPI::thread_func(void *p_udata) { ERR_BREAK(hr != S_OK); // fixme: Only works for floating point atm - for (int j = 0; j < num_frames_available; j++) { + for (UINT32 j = 0; j < num_frames_available; j++) { int32_t l, r; if (flags & AUDCLNT_BUFFERFLAGS_SILENT) { diff --git a/drivers/windows/file_access_windows.cpp b/drivers/windows/file_access_windows.cpp index 31360d319f..646e744248 100644 --- a/drivers/windows/file_access_windows.cpp +++ b/drivers/windows/file_access_windows.cpp @@ -93,7 +93,7 @@ Error FileAccessWindows::_open(const String &p_path, int p_mode_flags) { // a file using the wrong case (which *works* on Windows, but won't on other // platforms). if (p_mode_flags == READ) { - WIN32_FIND_DATAW d = { 0 }; + WIN32_FIND_DATAW d; HANDLE f = FindFirstFileW(path.c_str(), &d); if (f) { String fname = d.cFileName; @@ -302,7 +302,7 @@ void FileAccessWindows::store_buffer(const uint8_t *p_src, int p_length) { } prev_op = WRITE; } - ERR_FAIL_COND(fwrite(p_src, 1, p_length, f) != p_length); + ERR_FAIL_COND(fwrite(p_src, 1, p_length, f) != (size_t)p_length); } bool FileAccessWindows::file_exists(const String &p_name) { diff --git a/editor/editor_fonts.cpp b/editor/editor_fonts.cpp index cf14cf3e00..40ecffbb3b 100644 --- a/editor/editor_fonts.cpp +++ b/editor/editor_fonts.cpp @@ -204,7 +204,6 @@ void editor_register_fonts(Ref<Theme> p_theme) { dfmono->set_antialiased(font_source_antialiased); dfmono->set_hinting(font_source_hinting); dfmono->set_font_ptr(_font_Hack_Regular, _font_Hack_Regular_size); - //dfd->set_force_autohinter(true); //just looks better..i think? int default_font_size = int(EDITOR_GET("interface/editor/main_font_size")) * EDSCALE; @@ -220,15 +219,14 @@ void editor_register_fonts(Ref<Theme> p_theme) { MAKE_BOLD_FONT(df_title, default_font_size + 2 * EDSCALE); p_theme->set_font("title", "EditorFonts", df_title); - // Doc font - MAKE_BOLD_FONT(df_doc_title, int(EDITOR_GET("text_editor/help/help_title_font_size")) * EDSCALE); - + // Documentation fonts MAKE_DEFAULT_FONT(df_doc, int(EDITOR_GET("text_editor/help/help_font_size")) * EDSCALE); - + MAKE_BOLD_FONT(df_doc_bold, int(EDITOR_GET("text_editor/help/help_font_size")) * EDSCALE); + MAKE_BOLD_FONT(df_doc_title, int(EDITOR_GET("text_editor/help/help_title_font_size")) * EDSCALE); + MAKE_SOURCE_FONT(df_doc_code, int(EDITOR_GET("text_editor/help/help_source_font_size")) * EDSCALE); p_theme->set_font("doc", "EditorFonts", df_doc); + p_theme->set_font("doc_bold", "EditorFonts", df_doc_bold); p_theme->set_font("doc_title", "EditorFonts", df_doc_title); - - MAKE_SOURCE_FONT(df_doc_code, int(EDITOR_GET("text_editor/help/help_source_font_size")) * EDSCALE); p_theme->set_font("doc_source", "EditorFonts", df_doc_code); // Ruler font diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index df25b08b4c..26d793cf65 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -325,6 +325,7 @@ void EditorHelp::_update_doc() { DocData::ClassDoc cd = doc->class_list[edited_class]; //make a copy, so we can sort without worrying Ref<Font> doc_font = get_font("doc", "EditorFonts"); + Ref<Font> doc_bold_font = get_font("doc_bold", "EditorFonts"); Ref<Font> doc_title_font = get_font("doc_title", "EditorFonts"); Ref<Font> doc_code_font = get_font("doc_source", "EditorFonts"); String link_color_text = title_color.to_html(false); @@ -1132,6 +1133,7 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { String base_path; Ref<Font> doc_font = p_rt->get_font("doc", "EditorFonts"); + Ref<Font> doc_bold_font = p_rt->get_font("doc_bold", "EditorFonts"); Ref<Font> doc_code_font = p_rt->get_font("doc_source", "EditorFonts"); Color font_color_hl = p_rt->get_color("headline_color", "EditorHelp"); Color link_color = p_rt->get_color("accent_color", "Editor").linear_interpolate(font_color_hl, 0.8); @@ -1219,7 +1221,7 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { } else if (tag == "b") { //use bold font - p_rt->push_font(doc_code_font); + p_rt->push_font(doc_bold_font); pos = brk_end + 1; tag_stack.push_front(tag); } else if (tag == "i") { @@ -1237,13 +1239,13 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { tag_stack.push_front(tag); } else if (tag == "center") { - //use monospace font + //align to center p_rt->push_align(RichTextLabel::ALIGN_CENTER); pos = brk_end + 1; tag_stack.push_front(tag); } else if (tag == "br") { - //use monospace font + //force a line break p_rt->add_newline(); pos = brk_end + 1; } else if (tag == "u") { @@ -1254,14 +1256,13 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { tag_stack.push_front(tag); } else if (tag == "s") { - //use strikethrough (not supported underline instead) - p_rt->push_underline(); + //use strikethrough + p_rt->push_strikethrough(); pos = brk_end + 1; tag_stack.push_front(tag); } else if (tag == "url") { - //use strikethrough (not supported underline instead) int end = bbcode.find("[", brk_end); if (end == -1) end = bbcode.length(); @@ -1278,7 +1279,6 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { tag_stack.push_front("url"); } else if (tag == "img") { - //use strikethrough (not supported underline instead) int end = bbcode.find("[", brk_end); if (end == -1) end = bbcode.length(); diff --git a/editor/import/editor_scene_importer_gltf.cpp b/editor/import/editor_scene_importer_gltf.cpp index daa423e1d9..c97021433b 100644 --- a/editor/import/editor_scene_importer_gltf.cpp +++ b/editor/import/editor_scene_importer_gltf.cpp @@ -2090,22 +2090,23 @@ void EditorSceneImporterGLTF::_import_animation(GLTFState &state, AnimationPlaye animation->add_track(Animation::TYPE_VALUE); animation->track_set_path(track_idx, node_path); - if (track.weight_tracks[i].interpolation <= GLTFAnimation::INTERP_STEP) { - animation->track_set_interpolation_type(track_idx, track.weight_tracks[i].interpolation == GLTFAnimation::INTERP_STEP ? Animation::INTERPOLATION_NEAREST : Animation::INTERPOLATION_NEAREST); + // Only LINEAR and STEP (NEAREST) can be supported out of the box by Godot's Animation, + // the other modes have to be baked. + GLTFAnimation::Interpolation gltf_interp = track.weight_tracks[i].interpolation; + if (gltf_interp == GLTFAnimation::INTERP_LINEAR || gltf_interp == GLTFAnimation::INTERP_STEP) { + animation->track_set_interpolation_type(track_idx, gltf_interp == GLTFAnimation::INTERP_STEP ? Animation::INTERPOLATION_NEAREST : Animation::INTERPOLATION_LINEAR); for (int j = 0; j < track.weight_tracks[i].times.size(); j++) { float t = track.weight_tracks[i].times[j]; float w = track.weight_tracks[i].values[j]; animation->track_insert_key(track_idx, t, w); } } else { - //must bake, apologies. + // CATMULLROMSPLINE or CUBIC_SPLINE have to be baked, apologies. float increment = 1.0 / float(bake_fps); float time = 0.0; - bool last = false; while (true) { - - _interpolate_track<float>(track.weight_tracks[i].times, track.weight_tracks[i].values, time, track.weight_tracks[i].interpolation); + _interpolate_track<float>(track.weight_tracks[i].times, track.weight_tracks[i].values, time, gltf_interp); if (last) { break; } diff --git a/misc/dist/html/full-size.html b/misc/dist/html/full-size.html index 44b009524c..0e8a41a9fc 100644 --- a/misc/dist/html/full-size.html +++ b/misc/dist/html/full-size.html @@ -162,8 +162,13 @@ $GODOT_HEAD_INCLUDE requestAnimationFrame(animate); function adjustCanvasDimensions() { - canvas.width = innerWidth; - canvas.height = innerHeight; + var scale = window.devicePixelRatio || 1; + var width = window.innerWidth; + var height = window.innerHeight; + canvas.width = width * scale; + canvas.height = height * scale; + canvas.style.width = width + "px"; + canvas.style.height = height + "px"; } animationCallbacks.push(adjustCanvasDimensions); adjustCanvasDimensions(); diff --git a/modules/mono/editor/bindings_generator.cpp b/modules/mono/editor/bindings_generator.cpp index cd7774e7a1..2d618f7891 100644 --- a/modules/mono/editor/bindings_generator.cpp +++ b/modules/mono/editor/bindings_generator.cpp @@ -2536,13 +2536,8 @@ void BindingsGenerator::_default_argument_from_variant(const Variant &p_val, Arg switch (p_val.get_type()) { case Variant::NIL: - if (ClassDB::class_exists(r_iarg.type.cname)) { - // Object type - r_iarg.default_argument = "null"; - } else { - // Variant - r_iarg.default_argument = "null"; - } + // Either Object type or Variant + r_iarg.default_argument = "null"; break; // Atomic types case Variant::BOOL: diff --git a/modules/webrtc/webrtc_data_channel_js.cpp b/modules/webrtc/webrtc_data_channel_js.cpp index ce2fada634..069918cc9c 100644 --- a/modules/webrtc/webrtc_data_channel_js.cpp +++ b/modules/webrtc/webrtc_data_channel_js.cpp @@ -68,7 +68,7 @@ void WebRTCDataChannelJS::_on_error() { } void WebRTCDataChannelJS::_on_message(uint8_t *p_data, uint32_t p_size, bool p_is_string) { - if (in_buffer.space_left() < p_size + 5) { + if (in_buffer.space_left() < (int)(p_size + 5)) { ERR_EXPLAIN("Buffer full! Dropping data"); ERR_FAIL(); } diff --git a/platform/javascript/audio_driver_javascript.cpp b/platform/javascript/audio_driver_javascript.cpp index 11104007e2..163826f828 100644 --- a/platform/javascript/audio_driver_javascript.cpp +++ b/platform/javascript/audio_driver_javascript.cpp @@ -99,7 +99,7 @@ Error AudioDriverJavaScript::init() { return FAILED; } - if (!internal_buffer || memarr_len(internal_buffer) != buffer_length * channel_count) { + if (!internal_buffer || (int)memarr_len(internal_buffer) != buffer_length * channel_count) { if (internal_buffer) memdelete_arr(internal_buffer); internal_buffer = memnew_arr(float, buffer_length *channel_count); diff --git a/platform/javascript/os_javascript.cpp b/platform/javascript/os_javascript.cpp index 8242ed7df7..d96ffc3a55 100644 --- a/platform/javascript/os_javascript.cpp +++ b/platform/javascript/os_javascript.cpp @@ -70,6 +70,20 @@ static bool is_canvas_focused() { /* clang-format on */ } +static Point2 correct_canvas_position(int x, int y) { + int canvas_width; + int canvas_height; + emscripten_get_canvas_element_size(NULL, &canvas_width, &canvas_height); + + double element_width; + double element_height; + emscripten_get_element_css_size(NULL, &element_width, &element_height); + + x = (int)(canvas_width / element_width * x); + y = (int)(canvas_height / element_height * y); + return Point2(x, y); +} + static bool cursor_inside_canvas = true; EM_BOOL OS_JavaScript::fullscreen_change_callback(int p_event_type, const EmscriptenFullscreenChangeEvent *p_event, void *p_user_data) { @@ -285,7 +299,7 @@ EM_BOOL OS_JavaScript::mouse_button_callback(int p_event_type, const EmscriptenM Ref<InputEventMouseButton> ev; ev.instance(); ev->set_pressed(p_event_type == EMSCRIPTEN_EVENT_MOUSEDOWN); - ev->set_position(Point2(p_event->canvasX, p_event->canvasY)); + ev->set_position(correct_canvas_position(p_event->canvasX, p_event->canvasY)); ev->set_global_position(ev->get_position()); dom2godot_mod(p_event, ev); switch (p_event->button) { @@ -349,7 +363,7 @@ EM_BOOL OS_JavaScript::mousemove_callback(int p_event_type, const EmscriptenMous OS_JavaScript *os = get_singleton(); int input_mask = os->input->get_mouse_button_mask(); - Point2 pos = Point2(p_event->canvasX, p_event->canvasY); + Point2 pos = correct_canvas_position(p_event->canvasX, p_event->canvasY); // For motion outside the canvas, only read mouse movement if dragging // started inside the canvas; imitating desktop app behaviour. if (!cursor_inside_canvas && !input_mask) @@ -666,7 +680,7 @@ EM_BOOL OS_JavaScript::touch_press_callback(int p_event_type, const EmscriptenTo if (!touch.isChanged) continue; ev->set_index(touch.identifier); - ev->set_position(Point2(touch.canvasX, touch.canvasY)); + ev->set_position(correct_canvas_position(touch.canvasX, touch.canvasY)); os->touches[i] = ev->get_position(); ev->set_pressed(p_event_type == EMSCRIPTEN_EVENT_TOUCHSTART); @@ -691,7 +705,7 @@ EM_BOOL OS_JavaScript::touchmove_callback(int p_event_type, const EmscriptenTouc if (!touch.isChanged) continue; ev->set_index(touch.identifier); - ev->set_position(Point2(touch.canvasX, touch.canvasY)); + ev->set_position(correct_canvas_position(touch.canvasX, touch.canvasY)); Point2 &prev = os->touches[i]; ev->set_relative(ev->get_position() - prev); prev = ev->get_position(); diff --git a/platform/windows/joypad_windows.cpp b/platform/windows/joypad_windows.cpp index 5a399cdf90..432060f4fe 100644 --- a/platform/windows/joypad_windows.cpp +++ b/platform/windows/joypad_windows.cpp @@ -103,17 +103,17 @@ bool JoypadWindows::is_xinput_device(const GUID *p_guid) { PRAWINPUTDEVICELIST dev_list = NULL; unsigned int dev_list_count = 0; - if (GetRawInputDeviceList(NULL, &dev_list_count, sizeof(RAWINPUTDEVICELIST)) == -1) { + if (GetRawInputDeviceList(NULL, &dev_list_count, sizeof(RAWINPUTDEVICELIST)) == (UINT)-1) { return false; } dev_list = (PRAWINPUTDEVICELIST)malloc(sizeof(RAWINPUTDEVICELIST) * dev_list_count); if (!dev_list) return false; - if (GetRawInputDeviceList(dev_list, &dev_list_count, sizeof(RAWINPUTDEVICELIST)) == -1) { + if (GetRawInputDeviceList(dev_list, &dev_list_count, sizeof(RAWINPUTDEVICELIST)) == (UINT)-1) { free(dev_list); return false; } - for (int i = 0; i < dev_list_count; i++) { + for (unsigned int i = 0; i < dev_list_count; i++) { RID_DEVICE_INFO rdi; char dev_name[128]; @@ -334,9 +334,9 @@ void JoypadWindows::process_joypads() { if (joy.state.dwPacketNumber != joy.last_packet) { int button_mask = XINPUT_GAMEPAD_DPAD_UP; - for (int i = 0; i <= 16; i++) { + for (int j = 0; j <= 16; i++) { - input->joy_button(joy.id, i, joy.state.Gamepad.wButtons & button_mask); + input->joy_button(joy.id, j, joy.state.Gamepad.wButtons & button_mask); button_mask = button_mask * 2; } @@ -406,7 +406,7 @@ void JoypadWindows::process_joypads() { // on mingw, these constants are not constants int count = 6; - int axes[] = { DIJOFS_X, DIJOFS_Y, DIJOFS_Z, DIJOFS_RX, DIJOFS_RY, DIJOFS_RZ }; + unsigned int axes[] = { DIJOFS_X, DIJOFS_Y, DIJOFS_Z, DIJOFS_RX, DIJOFS_RY, DIJOFS_RZ }; int values[] = { js.lX, js.lY, js.lZ, js.lRx, js.lRy, js.lRz }; for (int j = 0; j < joy->joy_axis.size(); j++) { @@ -426,7 +426,11 @@ void JoypadWindows::post_hat(int p_device, DWORD p_dpad) { int dpad_val = 0; - if (p_dpad == -1) { + // Should be -1 when centered, but according to docs: + // "Some drivers report the centered position of the POV indicator as 65,535. Determine whether the indicator is centered as follows: + // BOOL POVCentered = (LOWORD(dwPOV) == 0xFFFF);" + // https://docs.microsoft.com/en-us/previous-versions/windows/desktop/ee416628(v%3Dvs.85)#remarks + if (LOWORD(p_dpad) == 0xFFFF) { dpad_val = InputDefault::HAT_MASK_CENTER; } if (p_dpad == 0) { diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index cd5f0be39c..db56bf5c7e 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -94,6 +94,7 @@ static BOOL CALLBACK _MonitorEnumProcSize(HMONITOR hMonitor, HDC hdcMonitor, LPR return TRUE; } +#ifdef DEBUG_ENABLED static String format_error_message(DWORD id) { LPWSTR messageBuffer = NULL; @@ -106,6 +107,7 @@ static String format_error_message(DWORD id) { return msg; } +#endif // DEBUG_ENABLED extern HINSTANCE godot_hinstance; @@ -555,6 +557,7 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) break; } } + FALLTHROUGH; case WM_MBUTTONDOWN: case WM_MBUTTONUP: case WM_RBUTTONDOWN: @@ -583,7 +586,6 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) case WM_MBUTTONDOWN: { mb->set_pressed(true); mb->set_button_index(3); - } break; case WM_MBUTTONUP: { mb->set_pressed(false); @@ -598,19 +600,16 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) mb->set_button_index(2); } break; case WM_LBUTTONDBLCLK: { - mb->set_pressed(true); mb->set_button_index(1); mb->set_doubleclick(true); } break; case WM_RBUTTONDBLCLK: { - mb->set_pressed(true); mb->set_button_index(2); mb->set_doubleclick(true); } break; case WM_MBUTTONDBLCLK: { - mb->set_pressed(true); mb->set_button_index(3); mb->set_doubleclick(true); @@ -1819,11 +1818,11 @@ void OS_Windows::set_window_size(const Size2 p_size) { // Don't let the mouse leave the window when resizing to a smaller resolution if (mouse_mode == MOUSE_MODE_CONFINED) { - RECT rect; - GetClientRect(hWnd, &rect); - ClientToScreen(hWnd, (POINT *)&rect.left); - ClientToScreen(hWnd, (POINT *)&rect.right); - ClipCursor(&rect); + RECT crect; + GetClientRect(hWnd, &crect); + ClientToScreen(hWnd, (POINT *)&crect.left); + ClientToScreen(hWnd, (POINT *)&crect.right); + ClipCursor(&crect); } } void OS_Windows::set_window_fullscreen(bool p_enabled) { @@ -2196,6 +2195,8 @@ uint64_t OS_Windows::get_unix_time() const { FILETIME fep; SystemTimeToFileTime(&ep, &fep); + // FIXME: dereferencing type-punned pointer will break strict-aliasing rules (GCC warning) + // https://docs.microsoft.com/en-us/windows/desktop/api/minwinbase/ns-minwinbase-filetime#remarks return (*(uint64_t *)&ft - *(uint64_t *)&fep) / 10000000; }; @@ -2381,7 +2382,7 @@ void OS_Windows::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shap } // Finally, create the icon - ICONINFO iconinfo = { 0 }; + ICONINFO iconinfo; iconinfo.fIcon = FALSE; iconinfo.xHotspot = p_hotspot.x; iconinfo.yHotspot = p_hotspot.y; @@ -2534,9 +2535,9 @@ Error OS_Windows::execute(const String &p_path, const List<String> &p_arguments, if (p_blocking) { - DWORD ret = WaitForSingleObject(pi.pi.hProcess, INFINITE); + DWORD ret2 = WaitForSingleObject(pi.pi.hProcess, INFINITE); if (r_exitcode) - *r_exitcode = ret; + *r_exitcode = ret2; CloseHandle(pi.pi.hProcess); CloseHandle(pi.pi.hThread); diff --git a/platform/windows/power_windows.cpp b/platform/windows/power_windows.cpp index b96ae51132..0efd88c216 100644 --- a/platform/windows/power_windows.cpp +++ b/platform/windows/power_windows.cpp @@ -89,7 +89,7 @@ bool PowerWindows::GetPowerInfo_Windows() { if (pct != 255) { /* 255 == unknown */ percent_left = (pct > 100) ? 100 : pct; /* clamp between 0%, 100% */ } - if (secs != 0xFFFFFFFF) { /* ((DWORD)-1) == unknown */ + if (secs != (int)0xFFFFFFFF) { /* ((DWORD)-1) == unknown */ nsecs_left = secs; } } diff --git a/platform/windows/windows_terminal_logger.cpp b/platform/windows/windows_terminal_logger.cpp index 7def419103..adbdafb07e 100644 --- a/platform/windows/windows_terminal_logger.cpp +++ b/platform/windows/windows_terminal_logger.cpp @@ -45,7 +45,7 @@ void WindowsTerminalLogger::logv(const char *p_format, va_list p_list, bool p_er int len = vsnprintf(buf, BUFFER_SIZE, p_format, p_list); if (len <= 0) return; - if (len >= BUFFER_SIZE) + if ((unsigned int)len >= BUFFER_SIZE) len = BUFFER_SIZE; // Output is too big, will be truncated buf[len] = 0; @@ -154,4 +154,4 @@ void WindowsTerminalLogger::log_error(const char *p_function, const char *p_file WindowsTerminalLogger::~WindowsTerminalLogger() {} -#endif
\ No newline at end of file +#endif diff --git a/scene/2d/position_2d.cpp b/scene/2d/position_2d.cpp index 8bccf117fd..f0c46a5fb7 100644 --- a/scene/2d/position_2d.cpp +++ b/scene/2d/position_2d.cpp @@ -33,6 +33,8 @@ #include "core/engine.h" #include "scene/resources/texture.h" +const float DEFAULT_GIZMO_EXTENTS = 10.0; + void Position2D::_draw_cross() { float extents = get_gizmo_extents(); diff --git a/scene/2d/position_2d.h b/scene/2d/position_2d.h index dc9cc2df15..ec73c02d2b 100644 --- a/scene/2d/position_2d.h +++ b/scene/2d/position_2d.h @@ -37,8 +37,6 @@ class Position2D : public Node2D { GDCLASS(Position2D, Node2D) - const float DEFAULT_GIZMO_EXTENTS = 10.0; - void _draw_cross(); protected: |