diff options
282 files changed, 2256 insertions, 2897 deletions
diff --git a/SConstruct b/SConstruct index 065019d591..000c918808 100644 --- a/SConstruct +++ b/SConstruct @@ -120,6 +120,7 @@ opts.Add(BoolVariable("deprecated", "Enable deprecated features", True)) opts.Add(BoolVariable("minizip", "Enable ZIP archive support using minizip", True)) opts.Add(BoolVariable("xaudio2", "Enable the XAudio2 audio driver", False)) opts.Add("custom_modules", "A list of comma-separated directory paths containing custom modules to build.", "") +opts.Add(BoolVariable("custom_modules_recursive", "Detect custom modules recursively for each specified path.", True)) # Advanced options opts.Add(BoolVariable("dev", "If yes, alias for verbose=yes warnings=extra werror=yes", False)) @@ -237,8 +238,14 @@ if env_base["custom_modules"]: Exit(255) for path in module_search_paths: + if path == "modules": + # Built-in modules don't have nested modules, + # so save the time it takes to parse directories. + modules = methods.detect_modules(path, recursive=False) + else: # External. + modules = methods.detect_modules(path, env_base["custom_modules_recursive"]) # Note: custom modules can override built-in ones. - modules_detected.update(methods.detect_modules(path)) + modules_detected.update(modules) include_path = os.path.dirname(path) if include_path: env_base.Prepend(CPPPATH=[include_path]) diff --git a/core/core_constants.cpp b/core/core_constants.cpp index 3df121b9cb..ef5dbf17bb 100644 --- a/core/core_constants.cpp +++ b/core/core_constants.cpp @@ -426,6 +426,12 @@ void register_global_constants() { BIND_CORE_ENUM_CONSTANT(JOY_BUTTON_DPAD_DOWN); BIND_CORE_ENUM_CONSTANT(JOY_BUTTON_DPAD_LEFT); BIND_CORE_ENUM_CONSTANT(JOY_BUTTON_DPAD_RIGHT); + BIND_CORE_ENUM_CONSTANT(JOY_BUTTON_MISC1); + BIND_CORE_ENUM_CONSTANT(JOY_BUTTON_PADDLE1); + BIND_CORE_ENUM_CONSTANT(JOY_BUTTON_PADDLE2); + BIND_CORE_ENUM_CONSTANT(JOY_BUTTON_PADDLE3); + BIND_CORE_ENUM_CONSTANT(JOY_BUTTON_PADDLE4); + BIND_CORE_ENUM_CONSTANT(JOY_BUTTON_TOUCHPAD); BIND_CORE_ENUM_CONSTANT(JOY_BUTTON_SDL_MAX); BIND_CORE_ENUM_CONSTANT(JOY_BUTTON_MAX); diff --git a/core/input/gamecontrollerdb.txt b/core/input/gamecontrollerdb.txt index 65b6534fb5..668a531b1f 100644 --- a/core/input/gamecontrollerdb.txt +++ b/core/input/gamecontrollerdb.txt @@ -789,15 +789,15 @@ xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2, 030000005e0400008e02000073050000,Speedlink TORID Wireless Gamepad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, 030000005e0400008e02000020200000,SpeedLink XEOX Pro Analog Gamepad pad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, 03000000d11800000094000011010000,Stadia Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,platform:Linux, -03000000de2800000112000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Linux, -03000000de2800000211000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Linux, -03000000de2800000211000011010000,Steam Controller,a:b2,b:b3,back:b10,dpdown:b18,dpleft:b19,dpright:b20,dpup:b17,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b5,platform:Linux, +03000000de2800000112000001000000,Steam Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,paddle1:b11,paddle2:b10,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Linux, +03000000de2800000211000001000000,Steam Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,paddle1:b11,paddle2:b10,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Linux, +03000000de2800004211000001000000,Steam Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,paddle1:b11,paddle2:b10,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Linux, 03000000de2800004211000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Linux, 03000000de2800004211000011010000,Steam Controller,a:b2,b:b3,back:b10,dpdown:b18,dpleft:b19,dpright:b20,dpup:b17,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b5,platform:Linux, 03000000de280000fc11000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, -05000000de2800000212000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Linux, -05000000de2800000511000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Linux, -05000000de2800000611000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Linux, +05000000de2800000212000001000000,Steam Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,paddle1:b11,paddle2:b10,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Linux, +05000000de2800000511000001000000,Steam Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,paddle1:b11,paddle2:b10,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Linux, +05000000de2800000611000001000000,Steam Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,paddle1:b11,paddle2:b10,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Linux, 03000000de280000ff11000001000000,Steam Virtual Gamepad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, 03000000381000003014000075010000,SteelSeries Stratus Duo,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, 03000000381000003114000075010000,SteelSeries Stratus Duo,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux, @@ -809,7 +809,7 @@ xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2, 0300000000f00000f100000000010000,Super RetroPort,a:b1,b:b5,back:b2,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b3,x:b0,y:b4,platform:Linux, 03000000457500002211000010010000,SZMY-POWER CO. LTD. GAMEPAD,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux, 030000008f0e00000d31000010010000,SZMY-POWER CO. LTD. GAMEPAD 3 TURBO,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux, -030000008f0e00001431000010010000,SZMY-POWER CO.,LTD. PS3 gamepad,a:b1,b:b2,x:b0,y:b3,back:b8,guide:b12,start:b9,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,platform:Linux, +030000008f0e00001431000010010000,SZMY-POWER CO. LTD. PS3 gamepad,a:b1,b:b2,x:b0,y:b3,back:b8,guide:b12,start:b9,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,platform:Linux, 030000004f04000020b3000010010000,Thrustmaster 2 in 1 DT,a:b0,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b1,y:b3,platform:Linux, 030000004f04000015b3000010010000,Thrustmaster Dual Analog 4,a:b0,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b1,y:b3,platform:Linux, 030000004f04000023b3000000010000,Thrustmaster Dual Trigger 3-in-1,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux, @@ -936,6 +936,7 @@ xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2, 4d466947616d65706164020000000000,MFi Gamepad,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,rightshoulder:b5,start:b6,x:b2,y:b3,platform:iOS, 050000004c050000cc090000df070000,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b2,y:b3,platform:iOS, 050000004c050000cc090000ff070000,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b10,x:b2,y:b3,platform:iOS, +050000004c050000cc090000ff876d01,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,misc1:b11,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b10,x:b2,y:b3,,platform:iOS, 050000004c050000cc090000ff870001,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b10,touchpad:b11,x:b2,y:b3,platform:iOS, 05000000ac0500000300000000006d03,Remote,a:b0,b:b2,leftx:a0,lefty:a1,platform:iOS, 05000000ac0500000300000043006d03,Remote,a:b0,b:b2,leftx:a0,lefty:a1,platform:iOS, diff --git a/core/input/input.cpp b/core/input/input.cpp index 2e3f112ebc..047aeb47fd 100644 --- a/core/input/input.cpp +++ b/core/input/input.cpp @@ -55,6 +55,12 @@ static const char *_joy_buttons[JOY_BUTTON_SDL_MAX] = { "dpdown", "dpleft", "dpright", + "misc1", + "paddle1", + "paddle2", + "paddle3", + "paddle4", + "touchpad", }; static const char *_joy_axes[JOY_AXIS_SDL_MAX] = { diff --git a/core/input/input_event.cpp b/core/input/input_event.cpp index 2771a15b80..c91dc4d067 100644 --- a/core/input/input_event.cpp +++ b/core/input/input_event.cpp @@ -985,6 +985,12 @@ static const char *_joy_button_descriptions[JOY_BUTTON_SDL_MAX] = { TTRC("D-pad Down"), TTRC("D-pad Left"), TTRC("D-pad Right"), + TTRC("Xbox Share, PS5 Microphone, Nintendo Capture"), + TTRC("Xbox Paddle 1"), + TTRC("Xbox Paddle 2"), + TTRC("Xbox Paddle 3"), + TTRC("Xbox Paddle 4"), + TTRC("PS4/5 Touchpad"), }; String InputEventJoypadButton::as_text() const { diff --git a/core/input/input_event.h b/core/input/input_event.h index 1500faa24c..a354119cf9 100644 --- a/core/input/input_event.h +++ b/core/input/input_event.h @@ -76,7 +76,13 @@ enum JoyButtonList { JOY_BUTTON_DPAD_DOWN = 12, JOY_BUTTON_DPAD_LEFT = 13, JOY_BUTTON_DPAD_RIGHT = 14, - JOY_BUTTON_SDL_MAX = 15, + JOY_BUTTON_MISC1 = 15, + JOY_BUTTON_PADDLE1 = 16, + JOY_BUTTON_PADDLE2 = 17, + JOY_BUTTON_PADDLE3 = 18, + JOY_BUTTON_PADDLE4 = 19, + JOY_BUTTON_TOUCHPAD = 20, + JOY_BUTTON_SDL_MAX = 21, JOY_BUTTON_MAX = 36, // Android supports up to 36 buttons. }; diff --git a/core/string/ustring.cpp b/core/string/ustring.cpp index 0b6311dadf..59fda65d43 100644 --- a/core/string/ustring.cpp +++ b/core/string/ustring.cpp @@ -3072,39 +3072,46 @@ int String::rfindn(const String &p_str, int p_from) const { bool String::ends_with(const String &p_string) const { int l = p_string.length(); + if (l > length()) { + return false; + } + if (l == 0) { return true; } - int pos = rfind(p_string); - if (pos == -1) { - return false; + const char32_t *p = &p_string[0]; + const char32_t *s = &operator[](length() - l); + + for (int i = 0; i < l; i++) { + if (p[i] != s[i]) { + return false; + } } - return pos + l == length(); + + return true; } bool String::begins_with(const String &p_string) const { - if (p_string.length() > length()) { + int l = p_string.length(); + if (l > length()) { return false; } - int l = p_string.length(); if (l == 0) { return true; } - const char32_t *src = &p_string[0]; - const char32_t *str = &operator[](0); + const char32_t *p = &p_string[0]; + const char32_t *s = &operator[](0); - int i = 0; - for (; i < l; i++) { - if (src[i] != str[i]) { + for (int i = 0; i < l; i++) { + if (p[i] != s[i]) { return false; } } - // only if i == l the p_string matches the beginning - return i == l; + return true; } bool String::begins_with(const char *p_string) const { diff --git a/doc/classes/@GlobalScope.xml b/doc/classes/@GlobalScope.xml index bf81362e79..e5bcc773fe 100644 --- a/doc/classes/@GlobalScope.xml +++ b/doc/classes/@GlobalScope.xml @@ -2147,7 +2147,25 @@ <constant name="JOY_BUTTON_DPAD_RIGHT" value="14" enum="JoyButtonList"> Game controller D-pad right button. </constant> - <constant name="JOY_BUTTON_SDL_MAX" value="15" enum="JoyButtonList"> + <constant name="JOY_BUTTON_MISC1" value="15" enum="JoyButtonList"> + Game controller SDL miscellaneous button. Corresponds to Xbox share button, PS5 microphone button, Nintendo capture button. + </constant> + <constant name="JOY_BUTTON_PADDLE1" value="16" enum="JoyButtonList"> + Game controller SDL paddle 1 button. + </constant> + <constant name="JOY_BUTTON_PADDLE2" value="17" enum="JoyButtonList"> + Game controller SDL paddle 2 button. + </constant> + <constant name="JOY_BUTTON_PADDLE3" value="18" enum="JoyButtonList"> + Game controller SDL paddle 3 button. + </constant> + <constant name="JOY_BUTTON_PADDLE4" value="19" enum="JoyButtonList"> + Game controller SDL paddle 4 button. + </constant> + <constant name="JOY_BUTTON_TOUCHPAD" value="20" enum="JoyButtonList"> + Game controller SDL touchpad button. + </constant> + <constant name="JOY_BUTTON_SDL_MAX" value="21" enum="JoyButtonList"> The number of SDL game controller buttons. </constant> <constant name="JOY_BUTTON_MAX" value="36" enum="JoyButtonList"> diff --git a/doc/classes/Environment.xml b/doc/classes/Environment.xml index 9dd4ecc37b..a986ec35c6 100644 --- a/doc/classes/Environment.xml +++ b/doc/classes/Environment.xml @@ -265,7 +265,9 @@ </member> <member name="volumetric_fog_light_energy" type="float" setter="set_volumetric_fog_light_energy" getter="get_volumetric_fog_light_energy" default="1.0"> </member> - <member name="volumetric_fog_shadow_filter" type="int" setter="set_volumetric_fog_shadow_filter" getter="get_volumetric_fog_shadow_filter" enum="Environment.VolumetricFogShadowFilter" default="1"> + <member name="volumetric_fog_temporal_reprojection_amount" type="float" setter="set_volumetric_fog_temporal_reprojection_amount" getter="get_volumetric_fog_temporal_reprojection_amount" default="0.9"> + </member> + <member name="volumetric_fog_temporal_reprojection_enabled" type="bool" setter="set_volumetric_fog_temporal_reprojection_enabled" getter="is_volumetric_fog_temporal_reprojection_enabled" default="true"> </member> </members> <constants> diff --git a/doc/classes/Light3D.xml b/doc/classes/Light3D.xml index 6c008e4f7e..111473e098 100644 --- a/doc/classes/Light3D.xml +++ b/doc/classes/Light3D.xml @@ -78,7 +78,7 @@ <member name="shadow_enabled" type="bool" setter="set_shadow" getter="has_shadow" default="false"> If [code]true[/code], the light will cast shadows. </member> - <member name="shadow_fog_fade" type="float" setter="set_param" getter="get_param" default="1.0"> + <member name="shadow_fog_fade" type="float" setter="set_param" getter="get_param" default="0.1"> </member> <member name="shadow_normal_bias" type="float" setter="set_param" getter="get_param" default="2.0"> Offsets the lookup into the shadow map by the object's normal. This can be used to reduce self-shadowing artifacts without using [member shadow_bias]. In practice, this value should be tweaked along with [member shadow_bias] to reduce artifacts as much as possible. diff --git a/doc/classes/Object.xml b/doc/classes/Object.xml index 6ff7e34194..f55b8597dd 100644 --- a/doc/classes/Object.xml +++ b/doc/classes/Object.xml @@ -10,11 +10,20 @@ Some classes that extend Object add memory management. This is the case of [Reference], which counts references and deletes itself automatically when no longer referenced. [Node], another fundamental type, deletes all its children when freed from memory. Objects export properties, which are mainly useful for storage and editing, but not really so much in programming. Properties are exported in [method _get_property_list] and handled in [method _get] and [method _set]. However, scripting languages and C++ have simpler means to export them. Property membership can be tested directly in GDScript using [code]in[/code]: - [codeblock] + [codeblocks] + [gdscript] var n = Node2D.new() print("position" in n) # Prints "True". print("other_property" in n) # Prints "False". - [/codeblock] + [/gdscript] + [csharp] + var node = new Node2D(); + // C# has no direct equivalent to GDScript's `in` operator here, but we + // can achieve the same behavior by performing `Get` with a null check. + GD.Print(node.Get("position") != null); // Prints "True". + GD.Print(node.Get("other_property") != null); // Prints "False". + [/csharp] + [/codeblocks] The [code]in[/code] operator will evaluate to [code]true[/code] as long as the key exists, even if the value is [code]null[/code]. Objects also receive notifications. Notifications are a simple way to notify the object about different events, so they can all be handled together. See [method _notification]. [b]Note:[/b] Unlike references to a [Reference], references to an Object stored in a variable can become invalid without warning. Therefore, it's recommended to use [Reference] for data classes instead of [Object]. @@ -96,9 +105,16 @@ </argument> <description> Calls the [code]method[/code] on the object and returns the result. This method supports a variable number of arguments, so parameters are passed as a comma separated list. Example: - [codeblock] - call("set", "position", Vector2(42.0, 0.0)) - [/codeblock] + [codeblocks] + [gdscript] + var node = Node2D.new() + node.call("set", "position", Vector2(42, 0)) + [/gdscript] + [csharp] + var node = new Node2D(); + node.Call("set", "position", new Vector2(42, 0)); + [/csharp] + [/codeblocks] [b]Note:[/b] In C#, the method name must be specified as snake_case if it is defined by a built-in Godot node. This doesn't apply to user-defined methods where you should use the same convention as in the C# source (typically PascalCase). </description> </method> @@ -109,9 +125,16 @@ </argument> <description> Calls the [code]method[/code] on the object during idle time. This method supports a variable number of arguments, so parameters are passed as a comma separated list. Example: - [codeblock] - call_deferred("set", "position", Vector2(42.0, 0.0)) - [/codeblock] + [codeblocks] + [gdscript] + var node = Node2D.new() + node.call_deferred("set", "position", Vector2(42, 0)) + [/gdscript] + [csharp] + var node = new Node2D(); + node.CallDeferred("set", "position", new Vector2(42, 0)); + [/csharp] + [/codeblocks] [b]Note:[/b] In C#, the method name must be specified as snake_case if it is defined by a built-in Godot node. This doesn't apply to user-defined methods where you should use the same convention as in the C# source (typically PascalCase). </description> </method> @@ -124,9 +147,16 @@ </argument> <description> Calls the [code]method[/code] on the object and returns the result. Contrarily to [method call], this method does not support a variable number of arguments but expects all parameters to be via a single [Array]. - [codeblock] - callv("set", [ "position", Vector2(42.0, 0.0) ]) - [/codeblock] + [codeblocks] + [gdscript] + var node = Node2D.new() + node.callv("set", ["position", Vector2(42, 0)]) + [/gdscript] + [csharp] + var node = new Node2D(); + node.Callv("set", new Godot.Collections.Array { "position", new Vector2(42, 0) }); + [/csharp] + [/codeblocks] </description> </method> <method name="can_translate_messages" qualifiers="const"> @@ -148,23 +178,140 @@ <argument index="3" name="flags" type="int" default="0"> </argument> <description> - [b]FIXME:[/b] The syntax changed with the addition of [Callable], this should be updated. - Connects a [code]signal[/code] to a [code]method[/code] on a [code]target[/code] object. Pass optional [code]binds[/code] to the call as an [Array] of parameters. These parameters will be passed to the method after any parameter used in the call to [method emit_signal]. Use [code]flags[/code] to set deferred or one-shot connections. See [enum ConnectFlags] constants. - A [code]signal[/code] can only be connected once to a [code]method[/code]. It will throw an error if already connected, unless the signal was connected with [constant CONNECT_REFERENCE_COUNTED]. To avoid this, first, use [method is_connected] to check for existing connections. - If the [code]target[/code] is destroyed in the game's lifecycle, the connection will be lost. - Examples: - [codeblock] - connect("pressed", self, "_on_Button_pressed") # BaseButton signal - connect("text_entered", self, "_on_LineEdit_text_entered") # LineEdit signal - connect("hit", self, "_on_Player_hit", [ weapon_type, damage ]) # User-defined signal - [/codeblock] - An example of the relationship between [code]binds[/code] passed to [method connect] and parameters used when calling [method emit_signal]: - [codeblock] - connect("hit", self, "_on_Player_hit", [ weapon_type, damage ]) # weapon_type and damage are passed last - emit_signal("hit", "Dark lord", 5) # "Dark lord" and 5 are passed first - func _on_Player_hit(hit_by, level, weapon_type, damage): - print("Hit by %s (lvl %d) with weapon %s for %d damage" % [hit_by, level, weapon_type, damage]) - [/codeblock] + Connects a [code]signal[/code] to a [code]callable[/code]. Pass optional [code]binds[/code] to the call as an [Array] of parameters. These parameters will be passed to the [Callable]'s method after any parameter used in the call to [method emit_signal]. Use [code]flags[/code] to set deferred or one-shot connections. See [enum ConnectFlags] constants. + [b]Note:[/b] This method is the legacy implementation for connecting signals. The recommend modern approach is to use [method Signal.connect] and to use [method Callable.bind] to add and validate parameter binds. Both syntaxes are shown below. + A signal can only be connected once to a [Callable]. It will throw an error if already connected, unless the signal was connected with [constant CONNECT_REFERENCE_COUNTED]. To avoid this, first, use [method is_connected] to check for existing connections. + If the callable's target is destroyed in the game's lifecycle, the connection will be lost. + [b]Examples with recommended syntax:[/b] + Connecting signals is one of the most common operations in Godot and the API gives many options to do so, which are described further down. The code block below shows the recommended approach for both GDScript and C#. + [codeblocks] + [gdscript] + func _ready(): + var button = Button.new() + # `button_down` here is a Signal object, and we thus call the Signal.connect() method, + # not Object.connect(). See discussion below for a more in-depth overview of the API. + button.button_down.connect(_on_button_down) + + # This assumes that a `Player` class exists which defines a `hit` signal. + var player = Player.new() + # We use Signal.connect() again, and we also use the Callable.bind() method which + # returns a new Callable with the parameter binds. + player.hit.connect(_on_player_hit.bind("sword", 100)) + + func _on_button_down(): + print("Button down!") + + func _on_player_hit(weapon_type, damage): + print("Hit with weapon %s for %d damage." % [weapon_type, damage]) + [/gdscript] + [csharp] + public override void _Ready() + { + var button = new Button(); + // C# supports passing signals as events, so we can use this idiomatic construct: + button.ButtonDown += OnButtonDown; + + // This assumes that a `Player` class exists which defines a `Hit` signal. + var player = new Player(); + // Signals as events (`player.Hit += OnPlayerHit;`) do not support argument binding. You have to use: + player.Hit.Connect(OnPlayerHit, new Godot.Collections.Array {"sword", 100 }); + } + + private void OnButtonDown() + { + GD.Print("Button down!"); + } + + private void OnPlayerHit(string weaponType, int damage) + { + GD.Print(String.Format("Hit with weapon {0} for {1} damage.", weaponType, damage)); + } + [/csharp] + [/codeblocks] + [b][code]Object.connect()[/code] or [code]Signal.connect()[/code]?[/b] + As seen above, the recommended method to connect signals is not [method Object.connect]. The code block below shows the four options for connecting signals, using either this legacy method or the recommended [method Signal.connect], and using either an implicit [Callable] or a manually defined one. + [codeblocks] + [gdscript] + func _ready(): + var button = Button.new() + # Option 1: Object.connect() with an implicit Callable for the defined function. + button.connect("button_down", _on_button_down) + # Option 2: Object.connect() with a constructed Callable using a target object and method name. + button.connect("button_down", Callable(self, "_on_button_down")) + # Option 3: Signal.connect() with an implicit Callable for the defined function. + button.button_down.connect(_on_button_down) + # Option 4: Signal.connect() with a constructed Callable using a target object and method name. + button.button_down.connect(Callable(self, "_on_button_down")) + + func _on_button_down(): + print("Button down!") + [/gdscript] + [csharp] + public override void _Ready() + { + var button = new Button(); + // Option 1: Object.Connect() with an implicit Callable for the defined function. + button.Connect("button_down", OnButtonDown); + // Option 2: Object.connect() with a constructed Callable using a target object and method name. + button.Connect("button_down", new Callable(self, nameof(OnButtonDown))); + // Option 3: Signal.connect() with an implicit Callable for the defined function. + button.ButtonDown.Connect(OnButtonDown); + // Option 3b: In C#, we can use signals as events and connect with this more idiomatic syntax: + button.ButtonDown += OnButtonDown; + // Option 4: Signal.connect() with a constructed Callable using a target object and method name. + button.ButtonDown.Connect(new Callable(self, nameof(OnButtonDown))); + } + + private void OnButtonDown() + { + GD.Print("Button down!"); + } + [/csharp] + [/codeblocks] + While all options have the same outcome ([code]button[/code]'s [signal BaseButton.button_down] signal will be connected to [code]_on_button_down[/code]), option 3 offers the best validation: it will throw a compile-time error if either the [code]button_down[/code] signal or the [code]_on_button_down[/code] callable are undefined. On the other hand, option 2 only relies on string names and will only be able to validate either names at runtime: it will throw a runtime error if [code]"button_down"[/code] doesn't correspond to a signal, or if [code]"_on_button_down"[/code] is not a registered method in the object [code]self[/code]. The main reason for using options 1, 2, or 4 would be if you actually need to use strings (e.g. to connect signals programmatically based on strings read from a configuration file). Otherwise, option 3 is the recommended (and fastest) method. + [b]Parameter bindings and passing:[/b] + For legacy or language-specific reasons, there are also several ways to bind parameters to signals. One can pass a [code]binds[/code] [Array] to [method Object.connect] or [method Signal.connect], or use the recommended [method Callable.bind] method to create a new callable from an existing one, with the given parameter binds. + One can also pass additional parameters when emitting the signal with [method emit_signal]. The examples below show the relationship between those two types of parameters. + [codeblocks] + [gdscript] + func _ready(): + # This assumes that a `Player` class exists which defines a `hit` signal. + var player = Player.new() + # Option 1: Using Callable.bind(). + player.hit.connect(_on_player_hit.bind("sword", 100)) + # Option 2: Using a `binds` Array in Signal.connect() (same syntax for Object.connect()). + player.hit.connect(_on_player_hit, ["sword", 100]) + + # Parameters added when emitting the signal are passed first. + player.emit_signal("hit", "Dark lord", 5) + + # Four arguments, since we pass two when emitting (hit_by, level) + # and two when connecting (weapon_type, damage). + func _on_player_hit(hit_by, level, weapon_type, damage): + print("Hit by %s (level %d) with weapon %s for %d damage." % [hit_by, level, weapon_type, damage]) + [/gdscript] + [csharp] + public override void _Ready() + { + // This assumes that a `Player` class exists which defines a `Hit` signal. + var player = new Player(); + // Option 1: Using Callable.Bind(). This way we can still use signals as events. + player.Hit += OnPlayerHit.Bind("sword", 100); + // Option 2: Using a `binds` Array in Signal.Connect() (same syntax for Object.Connect()). + player.Hit.Connect(OnPlayerHit, new Godot.Collections.Array{ "sword", 100 }); + + // Parameters added when emitting the signal are passed first. + player.EmitSignal("hit", "Dark lord", 5); + } + + // Four arguments, since we pass two when emitting (hitBy, level) + // and two when connecting (weaponType, damage). + private void OnPlayerHit(string hitBy, int level, string weaponType, int damage) + { + GD.Print(String.Format("Hit by {0} (level {1}) with weapon {2} for {3} damage.", hitBy, level, weaponType, damage)); + } + [/csharp] + [/codeblocks] </description> </method> <method name="disconnect"> @@ -175,8 +322,7 @@ <argument index="1" name="callable" type="Callable"> </argument> <description> - [b]FIXME:[/b] The syntax changed with the addition of [Callable], this should be updated. - Disconnects a [code]signal[/code] from a [code]method[/code] on the given [code]target[/code]. + Disconnects a [code]signal[/code] from a given [code]callable[/code]. If you try to disconnect a connection that does not exist, the method will throw an error. Use [method is_connected] to ensure that the connection exists. </description> </method> @@ -187,10 +333,16 @@ </argument> <description> Emits the given [code]signal[/code]. The signal must exist, so it should be a built-in signal of this class or one of its parent classes, or a user-defined signal. This method supports a variable number of arguments, so parameters are passed as a comma separated list. Example: - [codeblock] - emit_signal("hit", weapon_type, damage) + [codeblocks] + [gdscript] + emit_signal("hit", "sword", 100) emit_signal("game_over") - [/codeblock] + [/gdscript] + [csharp] + EmitSignal("hit", "sword", 100); + EmitSignal("game_over"); + [/csharp] + [/codeblocks] </description> </method> <method name="free"> @@ -359,8 +511,7 @@ <argument index="1" name="callable" type="Callable"> </argument> <description> - [b]FIXME:[/b] The syntax changed with the addition of [Callable], this should be updated. - Returns [code]true[/code] if a connection exists for a given [code]signal[/code], [code]target[/code], and [code]method[/code]. + Returns [code]true[/code] if a connection exists for a given [code]signal[/code] and [code]callable[/code]. </description> </method> <method name="is_queued_for_deletion" qualifiers="const"> @@ -440,11 +591,20 @@ </argument> <description> Assigns a new value to the property identified by the [NodePath]. The node path should be relative to the current object and can use the colon character ([code]:[/code]) to access nested properties. Example: - [codeblock] - set_indexed("position", Vector2(42, 0)) - set_indexed("position:y", -10) - print(position) # (42, -10) - [/codeblock] + [codeblocks] + [gdscript] + var node = Node2D.new() + node.set_indexed("position", Vector2(42, 0)) + node.set_indexed("position:y", -10) + print(node.position) # (42, -10) + [/gdscript] + [csharp] + var node = new Node2D(); + node.SetIndexed("position", new Vector2(42, 0)); + node.SetIndexed("position:y", -10); + GD.Print(node.Position); // (42, -10) + [/csharp] + [/codeblocks] </description> </method> <method name="set_message_translation"> diff --git a/doc/classes/ProjectSettings.xml b/doc/classes/ProjectSettings.xml index fc618206ed..be72f83406 100644 --- a/doc/classes/ProjectSettings.xml +++ b/doc/classes/ProjectSettings.xml @@ -1088,9 +1088,6 @@ </member> <member name="rendering/lightmapper/probe_capture_update_speed" type="float" setter="" getter="" default="15"> </member> - <member name="rendering/limits/rendering/max_renderable_elements" type="int" setter="" getter="" default="128000"> - Max amount of elements renderable in a frame. If more than this are visible per frame, they will be dropped. Keep in mind elements refer to mesh surfaces and not meshes themselves. - </member> <member name="rendering/limits/time/time_rollover_secs" type="float" setter="" getter="" default="3600"> </member> <member name="rendering/quality/2d/snap_2d_transforms_to_pixel" type="bool" setter="" getter="" default="false"> @@ -1306,11 +1303,7 @@ <member name="rendering/threads/thread_model" type="int" setter="" getter="" default="1"> Thread model for rendering. Rendering on a thread can vastly improve performance, but synchronizing to the main thread can cause a bit more jitter. </member> - <member name="rendering/volumetric_fog/directional_shadow_shrink" type="int" setter="" getter="" default="512"> - </member> - <member name="rendering/volumetric_fog/positional_shadow_shrink" type="int" setter="" getter="" default="512"> - </member> - <member name="rendering/volumetric_fog/use_filter" type="int" setter="" getter="" default="0"> + <member name="rendering/volumetric_fog/use_filter" type="int" setter="" getter="" default="1"> </member> <member name="rendering/volumetric_fog/volume_depth" type="int" setter="" getter="" default="128"> </member> diff --git a/doc/classes/RenderingDevice.xml b/doc/classes/RenderingDevice.xml index d0fb2b9d47..84e307b852 100644 --- a/doc/classes/RenderingDevice.xml +++ b/doc/classes/RenderingDevice.xml @@ -74,6 +74,8 @@ <method name="compute_list_begin"> <return type="int"> </return> + <argument index="0" name="allow_draw_overlap" type="bool" default="false"> + </argument> <description> </description> </method> @@ -443,6 +445,24 @@ <description> </description> </method> + <method name="get_device_name" qualifiers="const"> + <return type="String"> + </return> + <description> + </description> + </method> + <method name="get_device_pipeline_cache_uuid" qualifiers="const"> + <return type="String"> + </return> + <description> + </description> + </method> + <method name="get_device_vendor_name" qualifiers="const"> + <return type="String"> + </return> + <description> + </description> + </method> <method name="get_frame_delay" qualifiers="const"> <return type="int"> </return> @@ -823,6 +843,8 @@ </constant> <constant name="BARRIER_MASK_ALL" value="7"> </constant> + <constant name="BARRIER_MASK_NO_BARRIER" value="8"> + </constant> <constant name="DATA_FORMAT_R4G4_UNORM_PACK8" value="0" enum="DataFormat"> </constant> <constant name="DATA_FORMAT_R4G4B4A4_UNORM_PACK16" value="1" enum="DataFormat"> @@ -1587,13 +1609,15 @@ </constant> <constant name="INITIAL_ACTION_CLEAR_REGION" value="1" enum="InitialAction"> </constant> - <constant name="INITIAL_ACTION_KEEP" value="2" enum="InitialAction"> + <constant name="INITIAL_ACTION_CLEAR_REGION_CONTINUE" value="2" enum="InitialAction"> + </constant> + <constant name="INITIAL_ACTION_KEEP" value="3" enum="InitialAction"> </constant> - <constant name="INITIAL_ACTION_DROP" value="3" enum="InitialAction"> + <constant name="INITIAL_ACTION_DROP" value="4" enum="InitialAction"> </constant> - <constant name="INITIAL_ACTION_CONTINUE" value="4" enum="InitialAction"> + <constant name="INITIAL_ACTION_CONTINUE" value="5" enum="InitialAction"> </constant> - <constant name="INITIAL_ACTION_MAX" value="5" enum="InitialAction"> + <constant name="INITIAL_ACTION_MAX" value="6" enum="InitialAction"> </constant> <constant name="FINAL_ACTION_READ" value="0" enum="FinalAction"> </constant> diff --git a/doc/classes/SurfaceTool.xml b/doc/classes/SurfaceTool.xml index e10b65e309..331de4284e 100644 --- a/doc/classes/SurfaceTool.xml +++ b/doc/classes/SurfaceTool.xml @@ -155,8 +155,8 @@ <argument index="0" name="flip" type="bool" default="false"> </argument> <description> - Generates normals from vertices so you do not have to do it manually. If [code]flip[/code] is [code]true[/code], the resulting normals will be inverted. - Requires the primitive type to be set to [constant Mesh.PRIMITIVE_TRIANGLES]. + Generates normals from vertices so you do not have to do it manually. If [code]flip[/code] is [code]true[/code], the resulting normals will be inverted. [method generate_normals] should be called [i]after[/i] generating geometry and [i]before[/i] committing the mesh using [method commit] or [method commit_to_arrays]. + [b]Note:[/b] [method generate_normals] only works if the primitive type to be set to [constant Mesh.PRIMITIVE_TRIANGLES]. </description> </method> <method name="generate_tangents"> diff --git a/doc/classes/SyntaxHighlighter.xml b/doc/classes/SyntaxHighlighter.xml index 3f87e4f61d..642d75fa9b 100644 --- a/doc/classes/SyntaxHighlighter.xml +++ b/doc/classes/SyntaxHighlighter.xml @@ -15,7 +15,7 @@ <return type="void"> </return> <description> - Virtual method which can be overridden to clear any local caches. + Virtual method which can be overridden to clear any local caches. </description> </method> <method name="_get_line_syntax_highlighting" qualifiers="virtual"> @@ -32,7 +32,7 @@ <return type="void"> </return> <description> - Virtual method which can be overridden to update any local caches. + Virtual method which can be overridden to update any local caches. </description> </method> <method name="clear_highlighting_cache"> diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index 4d8a4f46b2..111d2666c3 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -1267,16 +1267,20 @@ void EditorPropertyRect2::setup(double p_min, double p_max, double p_step, bool EditorPropertyRect2::EditorPropertyRect2(bool p_force_wide) { bool horizontal = p_force_wide || bool(EDITOR_GET("interface/inspector/horizontal_vector_types_editing")); - + bool grid = false; BoxContainer *bc; if (p_force_wide) { bc = memnew(HBoxContainer); add_child(bc); } else if (horizontal) { - bc = memnew(HBoxContainer); + bc = memnew(VBoxContainer); add_child(bc); set_bottom_editor(bc); + + bc->add_child(memnew(HBoxContainer)); + bc->add_child(memnew(HBoxContainer)); + grid = true; } else { bc = memnew(VBoxContainer); add_child(bc); @@ -1287,7 +1291,13 @@ EditorPropertyRect2::EditorPropertyRect2(bool p_force_wide) { spin[i] = memnew(EditorSpinSlider); spin[i]->set_label(desc[i]); spin[i]->set_flat(true); - bc->add_child(spin[i]); + + if (grid) { + bc->get_child(i / 2)->add_child(spin[i]); + } else { + bc->add_child(spin[i]); + } + add_focusable(spin[i]); spin[i]->connect("value_changed", callable_mp(this, &EditorPropertyRect2::_value_changed), varray(desc[i])); if (horizontal) { @@ -1530,16 +1540,20 @@ void EditorPropertyRect2i::setup(int p_min, int p_max, bool p_no_slider) { EditorPropertyRect2i::EditorPropertyRect2i(bool p_force_wide) { bool horizontal = p_force_wide || bool(EDITOR_GET("interface/inspector/horizontal_vector_types_editing")); - + bool grid = false; BoxContainer *bc; if (p_force_wide) { bc = memnew(HBoxContainer); add_child(bc); } else if (horizontal) { - bc = memnew(HBoxContainer); + bc = memnew(VBoxContainer); add_child(bc); set_bottom_editor(bc); + + bc->add_child(memnew(HBoxContainer)); + bc->add_child(memnew(HBoxContainer)); + grid = true; } else { bc = memnew(VBoxContainer); add_child(bc); @@ -1550,7 +1564,13 @@ EditorPropertyRect2i::EditorPropertyRect2i(bool p_force_wide) { spin[i] = memnew(EditorSpinSlider); spin[i]->set_label(desc[i]); spin[i]->set_flat(true); - bc->add_child(spin[i]); + + if (grid) { + bc->get_child(i / 2)->add_child(spin[i]); + } else { + bc->add_child(spin[i]); + } + add_focusable(spin[i]); spin[i]->connect("value_changed", callable_mp(this, &EditorPropertyRect2i::_value_changed), varray(desc[i])); if (horizontal) { diff --git a/methods.py b/methods.py index 15eb82ae74..f302500b5d 100644 --- a/methods.py +++ b/methods.py @@ -145,34 +145,88 @@ def parse_cg_file(fname, uniforms, sizes, conditionals): fs.close() -def detect_modules(at_path): - module_list = OrderedDict() # name : path +def detect_modules(search_path, recursive=False): + """Detects and collects a list of C++ modules at specified path - modules_glob = os.path.join(at_path, "*") - files = glob.glob(modules_glob) - files.sort() # so register_module_types does not change that often, and also plugins are registered in alphabetic order + `search_path` - a directory path containing modules. The path may point to + a single module, which may have other nested modules. A module must have + "register_types.h", "SCsub", "config.py" files created to be detected. - for x in files: - if not is_module(x): - continue - name = os.path.basename(x) - path = x.replace("\\", "/") # win32 - module_list[name] = path + `recursive` - if `True`, then all subdirectories are searched for modules as + specified by the `search_path`, otherwise collects all modules under the + `search_path` directory. If the `search_path` is a module, it is collected + in all cases. - return module_list + Returns an `OrderedDict` with module names as keys, and directory paths as + values. If a path is relative, then it is a built-in module. If a path is + absolute, then it is a custom module collected outside of the engine source. + """ + modules = OrderedDict() + + def add_module(path): + module_name = os.path.basename(path) + module_path = path.replace("\\", "/") # win32 + modules[module_name] = module_path + + def is_engine(path): + # Prevent recursively detecting modules in self and other + # Godot sources when using `custom_modules` build option. + version_path = os.path.join(path, "version.py") + if os.path.exists(version_path): + with open(version_path) as f: + version = {} + exec(f.read(), version) + if version.get("short_name") == "godot": + return True + return False + + def get_files(path): + files = glob.glob(os.path.join(path, "*")) + # Sort so that `register_module_types` does not change that often, + # and plugins are registered in alphabetic order as well. + files.sort() + return files + + if not recursive: + if is_module(search_path): + add_module(search_path) + for path in get_files(search_path): + if is_engine(path): + continue + if is_module(path): + add_module(path) + else: + to_search = [search_path] + while to_search: + path = to_search.pop() + if is_module(path): + add_module(path) + for child in get_files(path): + if not os.path.isdir(child): + continue + if is_engine(child): + continue + to_search.insert(0, child) + return modules def is_module(path): - return os.path.isdir(path) and os.path.exists(os.path.join(path, "SCsub")) + if not os.path.isdir(path): + return False + must_exist = ["register_types.h", "SCsub", "config.py"] + for f in must_exist: + if not os.path.exists(os.path.join(path, f)): + return False + return True -def write_modules(module_list): +def write_modules(modules): includes_cpp = "" preregister_cpp = "" register_cpp = "" unregister_cpp = "" - for name, path in module_list.items(): + for name, path in modules.items(): try: with open(os.path.join(path, "register_types.h")): includes_cpp += '#include "' + path + '/register_types.h"\n' @@ -230,8 +284,6 @@ def convert_custom_modules_path(path): raise ValueError(err_msg % "point to an existing directory.") if path == os.path.realpath("modules"): raise ValueError(err_msg % "be a directory other than built-in `modules` directory.") - if is_module(path): - raise ValueError(err_msg % "point to a directory with modules, not a single module.") return path diff --git a/modules/basis_universal/texture_basisu.cpp b/modules/basis_universal/texture_basisu.cpp index 66eb81d7f2..92882a1cc8 100644 --- a/modules/basis_universal/texture_basisu.cpp +++ b/modules/basis_universal/texture_basisu.cpp @@ -207,7 +207,6 @@ Vector<uint8_t> TextureBasisU::get_basisu_data() const { }; TextureBasisU::TextureBasisU() { - flags = FLAGS_DEFAULT; texture = RenderingServer::get_singleton()->texture_create(); }; diff --git a/modules/basis_universal/texture_basisu.h b/modules/basis_universal/texture_basisu.h index 0a4783eaff..282a0dfc8a 100644 --- a/modules/basis_universal/texture_basisu.h +++ b/modules/basis_universal/texture_basisu.h @@ -47,7 +47,7 @@ class TextureBasisU : public Texture { RID texture; Size2 tex_size; - uint32_t flags; + uint32_t flags = FLAGS_DEFAULT; Vector<uint8_t> data; diff --git a/modules/bmp/image_loader_bmp.h b/modules/bmp/image_loader_bmp.h index d3f12f0115..379e971458 100644 --- a/modules/bmp/image_loader_bmp.h +++ b/modules/bmp/image_loader_bmp.h @@ -55,24 +55,24 @@ protected: struct bmp_header_s { struct bmp_file_header_s { - uint16_t bmp_signature; - uint32_t bmp_file_size; - uint32_t bmp_file_padding; - uint32_t bmp_file_offset; + uint16_t bmp_signature = 0; + uint32_t bmp_file_size = 0; + uint32_t bmp_file_padding = 0; + uint32_t bmp_file_offset = 0; } bmp_file_header; struct bmp_info_header_s { - uint32_t bmp_header_size; - uint32_t bmp_width; - uint32_t bmp_height; - uint16_t bmp_planes; - uint16_t bmp_bit_count; - uint32_t bmp_compression; - uint32_t bmp_size_image; - uint32_t bmp_pixels_per_meter_x; - uint32_t bmp_pixels_per_meter_y; - uint32_t bmp_colors_used; - uint32_t bmp_important_colors; + uint32_t bmp_header_size = 0; + uint32_t bmp_width = 0; + uint32_t bmp_height = 0; + uint16_t bmp_planes = 0; + uint16_t bmp_bit_count = 0; + uint32_t bmp_compression = 0; + uint32_t bmp_size_image = 0; + uint32_t bmp_pixels_per_meter_x = 0; + uint32_t bmp_pixels_per_meter_y = 0; + uint32_t bmp_colors_used = 0; + uint32_t bmp_important_colors = 0; } bmp_info_header; }; diff --git a/modules/bullet/area_bullet.h b/modules/bullet/area_bullet.h index a5fa678fec..7cf666c119 100644 --- a/modules/bullet/area_bullet.h +++ b/modules/bullet/area_bullet.h @@ -80,18 +80,18 @@ public: private: // These are used by function callEvent. Instead to create this each call I create if one time. Variant call_event_res[5]; - Variant *call_event_res_ptr[5]; + Variant *call_event_res_ptr[5] = {}; - btGhostObject *btGhost; + btGhostObject *btGhost = nullptr; Vector<OverlappingObjectData> overlappingObjects; bool monitorable = true; PhysicsServer3D::AreaSpaceOverrideMode spOv_mode = PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED; bool spOv_gravityPoint = false; - real_t spOv_gravityPointDistanceScale = 0; - real_t spOv_gravityPointAttenuation = 1; + real_t spOv_gravityPointDistanceScale = 0.0; + real_t spOv_gravityPointAttenuation = 1.0; Vector3 spOv_gravityVec = Vector3(0, -1, 0); - real_t spOv_gravityMag = 10; + real_t spOv_gravityMag = 10.0; real_t spOv_linearDump = 0.1; real_t spOv_angularDump = 0.1; int spOv_priority = 0; diff --git a/modules/bullet/btRayShape.cpp b/modules/bullet/btRayShape.cpp index 1568cca63d..109854c9dd 100644 --- a/modules/bullet/btRayShape.cpp +++ b/modules/bullet/btRayShape.cpp @@ -39,11 +39,9 @@ */ btRayShape::btRayShape(btScalar length) : - btConvexInternalShape(), - m_shapeAxis(0, 0, 1) { + btConvexInternalShape() { m_shapeType = CUSTOM_CONVEX_SHAPE_TYPE; setLength(length); - slipsOnSlope = false; } btRayShape::~btRayShape() { diff --git a/modules/bullet/btRayShape.h b/modules/bullet/btRayShape.h index dcc4cc79c7..330755aa31 100644 --- a/modules/bullet/btRayShape.h +++ b/modules/bullet/btRayShape.h @@ -42,10 +42,10 @@ /// Ray shape around z axis ATTRIBUTE_ALIGNED16(class) btRayShape : public btConvexInternalShape { - btScalar m_length; - bool slipsOnSlope; + btScalar m_length = 0; + bool slipsOnSlope = false; /// The default axis is the z - btVector3 m_shapeAxis; + btVector3 m_shapeAxis = btVector3(0, 0, 1); btTransform m_cacheSupportPoint; btScalar m_cacheScaledLength; diff --git a/modules/bullet/collision_object_bullet.h b/modules/bullet/collision_object_bullet.h index bea28f2183..c8081a53f1 100644 --- a/modules/bullet/collision_object_bullet.h +++ b/modules/bullet/collision_object_bullet.h @@ -110,7 +110,7 @@ public: }; protected: - Type type; + Type type = TYPE_AREA; ObjectID instance_id; uint32_t collisionLayer = 0; uint32_t collisionMask = 0; diff --git a/modules/bullet/godot_motion_state.h b/modules/bullet/godot_motion_state.h index 0669d2739a..ca17349130 100644 --- a/modules/bullet/godot_motion_state.h +++ b/modules/bullet/godot_motion_state.h @@ -51,7 +51,7 @@ class GodotMotionState : public btMotionState { /// This data is used to store last world position btTransform bodyCurrentWorldTransform; - RigidBodyBullet *owner; + RigidBodyBullet *owner = nullptr; public: GodotMotionState(RigidBodyBullet *p_owner) : diff --git a/modules/bullet/godot_ray_world_algorithm.h b/modules/bullet/godot_ray_world_algorithm.h index f705edef81..25798aecb4 100644 --- a/modules/bullet/godot_ray_world_algorithm.h +++ b/modules/bullet/godot_ray_world_algorithm.h @@ -45,7 +45,7 @@ class GodotRayWorldAlgorithm : public btActivatingCollisionAlgorithm { const btDiscreteDynamicsWorld *m_world; btPersistentManifold *m_manifoldPtr; bool m_ownManifold = false; - bool m_isSwapped; + bool m_isSwapped = false; public: GodotRayWorldAlgorithm(const btDiscreteDynamicsWorld *world, btPersistentManifold *mf, const btCollisionAlgorithmConstructionInfo &ci, const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap, bool isSwapped); diff --git a/modules/bullet/godot_result_callbacks.h b/modules/bullet/godot_result_callbacks.h index 4f40f7ecfd..f92665f3e4 100644 --- a/modules/bullet/godot_result_callbacks.h +++ b/modules/bullet/godot_result_callbacks.h @@ -59,8 +59,8 @@ struct GodotClosestRayResultCallback : public btCollisionWorld::ClosestRayResult bool m_pickRay = false; int m_shapeId = 0; - bool collide_with_bodies; - bool collide_with_areas; + bool collide_with_bodies = false; + bool collide_with_areas = false; public: GodotClosestRayResultCallback(const btVector3 &rayFromWorld, const btVector3 &rayToWorld, const Set<RID> *p_exclude, bool p_collide_with_bodies, bool p_collide_with_areas) : @@ -84,8 +84,8 @@ public: // store all colliding object struct GodotAllConvexResultCallback : public btCollisionWorld::ConvexResultCallback { public: - PhysicsDirectSpaceState3D::ShapeResult *m_results; - int m_resultMax; + PhysicsDirectSpaceState3D::ShapeResult *m_results = nullptr; + int m_resultMax = 0; const Set<RID> *m_exclude; int count = 0; @@ -117,8 +117,8 @@ public: const Set<RID> *m_exclude; int m_shapeId = 0; - bool collide_with_bodies; - bool collide_with_areas; + bool collide_with_bodies = false; + bool collide_with_areas = false; GodotClosestConvexResultCallback(const btVector3 &convexFromWorld, const btVector3 &convexToWorld, const Set<RID> *p_exclude, bool p_collide_with_bodies, bool p_collide_with_areas) : btCollisionWorld::ClosestConvexResultCallback(convexFromWorld, convexToWorld), @@ -134,13 +134,13 @@ public: struct GodotAllContactResultCallback : public btCollisionWorld::ContactResultCallback { public: const btCollisionObject *m_self_object; - PhysicsDirectSpaceState3D::ShapeResult *m_results; - int m_resultMax; + PhysicsDirectSpaceState3D::ShapeResult *m_results = nullptr; + int m_resultMax = 0; const Set<RID> *m_exclude; int m_count = 0; - bool collide_with_bodies; - bool collide_with_areas; + bool collide_with_bodies = false; + bool collide_with_areas = false; GodotAllContactResultCallback(btCollisionObject *p_self_object, PhysicsDirectSpaceState3D::ShapeResult *p_results, int p_resultMax, const Set<RID> *p_exclude, bool p_collide_with_bodies, bool p_collide_with_areas) : m_self_object(p_self_object), @@ -159,13 +159,13 @@ public: struct GodotContactPairContactResultCallback : public btCollisionWorld::ContactResultCallback { public: const btCollisionObject *m_self_object; - Vector3 *m_results; - int m_resultMax; + Vector3 *m_results = nullptr; + int m_resultMax = 0; const Set<RID> *m_exclude; int m_count = 0; - bool collide_with_bodies; - bool collide_with_areas; + bool collide_with_bodies = false; + bool collide_with_areas = false; GodotContactPairContactResultCallback(btCollisionObject *p_self_object, Vector3 *p_results, int p_resultMax, const Set<RID> *p_exclude, bool p_collide_with_bodies, bool p_collide_with_areas) : m_self_object(p_self_object), @@ -183,14 +183,14 @@ public: struct GodotRestInfoContactResultCallback : public btCollisionWorld::ContactResultCallback { public: const btCollisionObject *m_self_object; - PhysicsDirectSpaceState3D::ShapeRestInfo *m_result; + PhysicsDirectSpaceState3D::ShapeRestInfo *m_result = nullptr; const Set<RID> *m_exclude; bool m_collided = false; - real_t m_min_distance = 0; - const btCollisionObject *m_rest_info_collision_object; + real_t m_min_distance = 0.0; + const btCollisionObject *m_rest_info_collision_object = nullptr; btVector3 m_rest_info_bt_point; - bool collide_with_bodies; - bool collide_with_areas; + bool collide_with_bodies = false; + bool collide_with_areas = false; GodotRestInfoContactResultCallback(btCollisionObject *p_self_object, PhysicsDirectSpaceState3D::ShapeRestInfo *p_result, const Set<RID> *p_exclude, bool p_collide_with_bodies, bool p_collide_with_areas) : m_self_object(p_self_object), diff --git a/modules/bullet/rid_bullet.h b/modules/bullet/rid_bullet.h index 0b74a0cc4d..face6b4861 100644 --- a/modules/bullet/rid_bullet.h +++ b/modules/bullet/rid_bullet.h @@ -41,7 +41,7 @@ class BulletPhysicsServer3D; class RIDBullet { RID self; - BulletPhysicsServer3D *physicsServer; + BulletPhysicsServer3D *physicsServer = nullptr; public: _FORCE_INLINE_ void set_self(const RID &p_self) { self = p_self; } diff --git a/modules/bullet/rigid_body_bullet.h b/modules/bullet/rigid_body_bullet.h index 57b80cf50c..a4be7f9e07 100644 --- a/modules/bullet/rigid_body_bullet.h +++ b/modules/bullet/rigid_body_bullet.h @@ -81,8 +81,8 @@ public: } public: - RigidBodyBullet *body; - real_t deltaTime; + RigidBodyBullet *body = nullptr; + real_t deltaTime = 0.0; private: BulletPhysicsDirectBodyState3D() {} @@ -144,13 +144,13 @@ public: class RigidBodyBullet : public RigidCollisionObjectBullet { public: struct CollisionData { - RigidBodyBullet *otherObject; - int other_object_shape; - int local_shape; + RigidBodyBullet *otherObject = nullptr; + int other_object_shape = 0; + int local_shape = 0; Vector3 hitLocalLocation; Vector3 hitWorldLocation; Vector3 hitNormal; - real_t appliedImpulse; + real_t appliedImpulse = 0.0; }; struct ForceIntegrationCallback { @@ -169,7 +169,7 @@ public: }; struct KinematicUtilities { - RigidBodyBullet *owner; + RigidBodyBullet *owner = nullptr; btScalar safe_margin; Vector<KinematicShape> shapes; @@ -194,10 +194,10 @@ private: GodotMotionState *godotMotionState; btRigidBody *btBody; uint16_t locked_axis = 0; - real_t mass = 1; - real_t gravity_scale = 1; - real_t linearDamp = 0; - real_t angularDamp = 0; + real_t mass = 1.0; + real_t gravity_scale = 1.0; + real_t linearDamp = 0.0; + real_t angularDamp = 0.0; bool can_sleep = true; bool omit_forces_integration = false; bool can_integrate_forces = false; diff --git a/modules/bullet/shape_bullet.h b/modules/bullet/shape_bullet.h index 63475822de..bfd95747eb 100644 --- a/modules/bullet/shape_bullet.h +++ b/modules/bullet/shape_bullet.h @@ -213,10 +213,10 @@ private: class HeightMapShapeBullet : public ShapeBullet { public: Vector<real_t> heights; - int width; - int depth; - real_t min_height; - real_t max_height; + int width = 0; + int depth = 0; + real_t min_height = 0.0; + real_t max_height = 0.0; HeightMapShapeBullet(); @@ -231,7 +231,7 @@ private: class RayShapeBullet : public ShapeBullet { public: - real_t length = 1; + real_t length = 1.0; bool slips_on_slope = false; RayShapeBullet(); diff --git a/modules/bullet/soft_body_bullet.h b/modules/bullet/soft_body_bullet.h index b15b72daf9..564566d8b8 100644 --- a/modules/bullet/soft_body_bullet.h +++ b/modules/bullet/soft_body_bullet.h @@ -59,7 +59,7 @@ class SoftBodyBullet : public CollisionObjectBullet { private: btSoftBody *bt_soft_body = nullptr; Vector<Vector<int>> indices_table; - btSoftBody::Material *mat0; // This is just a copy of pointer managed by btSoftBody + btSoftBody::Material *mat0 = nullptr; // This is just a copy of pointer managed by btSoftBody bool isScratched = false; Ref<Mesh> soft_mesh; diff --git a/modules/bullet/space_bullet.cpp b/modules/bullet/space_bullet.cpp index 79a5fdb3d2..7d337bc4d0 100644 --- a/modules/bullet/space_bullet.cpp +++ b/modules/bullet/space_bullet.cpp @@ -1092,13 +1092,13 @@ private: btDbvtVolume bounds; const btCollisionObject *self_collision_object; - uint32_t collision_layer; - uint32_t collision_mask; + uint32_t collision_layer = 0; + uint32_t collision_mask = 0; struct CompoundLeafCallback : btDbvt::ICollide { private: - RecoverPenetrationBroadPhaseCallback *parent_callback; - btCollisionObject *collision_object; + RecoverPenetrationBroadPhaseCallback *parent_callback = nullptr; + btCollisionObject *collision_object = nullptr; public: CompoundLeafCallback(RecoverPenetrationBroadPhaseCallback *p_parent_callback, btCollisionObject *p_collision_object) : @@ -1116,8 +1116,8 @@ private: public: struct BroadphaseResult { - btCollisionObject *collision_object; - int compound_child_index; + btCollisionObject *collision_object = nullptr; + int compound_child_index = 0; }; Vector<BroadphaseResult> results; diff --git a/modules/bullet/space_bullet.h b/modules/bullet/space_bullet.h index 1caa3c2a0c..87aa2b9e93 100644 --- a/modules/bullet/space_bullet.h +++ b/modules/bullet/space_bullet.h @@ -100,12 +100,12 @@ class SpaceBullet : public RIDBullet { btGhostPairCallback *ghostPairCallback = nullptr; GodotFilterCallback *godotFilterCallback = nullptr; - btGjkEpaPenetrationDepthSolver *gjk_epa_pen_solver; - btVoronoiSimplexSolver *gjk_simplex_solver; + btGjkEpaPenetrationDepthSolver *gjk_epa_pen_solver = nullptr; + btVoronoiSimplexSolver *gjk_simplex_solver = nullptr; BulletPhysicsDirectSpaceState *direct_access; Vector3 gravityDirection = Vector3(0, -1, 0); - real_t gravityMagnitude = 10; + real_t gravityMagnitude = 10.0; real_t linear_damp = 0.0; real_t angular_damp = 0.0; diff --git a/modules/csg/csg.h b/modules/csg/csg.h index 1612c16a32..3fbed66e5c 100644 --- a/modules/csg/csg.h +++ b/modules/csg/csg.h @@ -48,9 +48,9 @@ struct CSGBrush { Vector3 vertices[3]; Vector2 uvs[3]; AABB aabb; - bool smooth; - bool invert; - int material; + bool smooth = false; + bool invert = false; + int material = 0; }; Vector<Face> faces; @@ -74,20 +74,20 @@ struct CSGBrushOperation { struct MeshMerge { struct Face { - bool from_b; - bool inside; - int points[3]; + bool from_b = false; + bool inside = false; + int points[3] = {}; Vector2 uvs[3]; - bool smooth; - bool invert; - int material_idx; + bool smooth = false; + bool invert = false; + int material_idx = 0; }; struct FaceBVH { - int face; - int left; - int right; - int next; + int face = 0; + int left = 0; + int right = 0; + int next = 0; Vector3 center; AABB aabb; }; @@ -142,7 +142,7 @@ struct CSGBrushOperation { Map<Ref<Material>, int> materials; Map<Vector3, int> vertex_map; OAHashMap<VertexKey, int, VertexKeyHash> snap_cache; - float vertex_snap; + float vertex_snap = 0.0; inline void _add_distance(List<real_t> &r_intersectionsA, List<real_t> &r_intersectionsB, bool p_from_B, real_t p_distance) const; inline bool _bvh_inside(FaceBVH *facebvhptr, int p_max_depth, int p_bvh_first, int p_face_idx) const; @@ -159,7 +159,7 @@ struct CSGBrushOperation { }; struct Face2D { - int vertex_idx[3]; + int vertex_idx[3] = {}; }; Vector<Vertex2D> vertices; @@ -167,7 +167,7 @@ struct CSGBrushOperation { Plane plane; Transform to_2D; Transform to_3D; - float vertex_snap2; + float vertex_snap2 = 0.0; inline int _get_point_idx(const Vector2 &p_point); inline int _add_vertex(const Vertex2D &p_vertex); diff --git a/modules/csg/csg_shape.cpp b/modules/csg/csg_shape.cpp index e348f8a568..82d3ac8b1b 100644 --- a/modules/csg/csg_shape.cpp +++ b/modules/csg/csg_shape.cpp @@ -625,15 +625,6 @@ void CSGShape3D::_bind_methods() { } CSGShape3D::CSGShape3D() { - operation = OPERATION_UNION; - parent = nullptr; - brush = nullptr; - dirty = false; - snap = 0.001; - use_collision = false; - collision_layer = 1; - collision_mask = 1; - calculate_tangents = true; set_notify_local_transform(true); } diff --git a/modules/csg/csg_shape.h b/modules/csg/csg_shape.h index 7dff8b6d3b..de7de09f00 100644 --- a/modules/csg/csg_shape.h +++ b/modules/csg/csg_shape.h @@ -50,23 +50,23 @@ public: }; private: - Operation operation; - CSGShape3D *parent; + Operation operation = OPERATION_UNION; + CSGShape3D *parent = nullptr; - CSGBrush *brush; + CSGBrush *brush = nullptr; AABB node_aabb; - bool dirty; - float snap; + bool dirty = false; + float snap = 0.001; - bool use_collision; - uint32_t collision_layer; - uint32_t collision_mask; + bool use_collision = false; + uint32_t collision_layer = 1; + uint32_t collision_mask = 1; Ref<ConcavePolygonShape3D> root_collision_shape; RID root_collision_instance; - bool calculate_tangents; + bool calculate_tangents = true; Ref<ArrayMesh> root_mesh; @@ -85,12 +85,12 @@ private: Vector<Vector2> uvs; Vector<float> tans; Ref<Material> material; - int last_added; + int last_added = 0; - Vector3 *verticesw; - Vector3 *normalsw; - Vector2 *uvsw; - float *tansw; + Vector3 *verticesw = nullptr; + Vector3 *normalsw = nullptr; + Vector2 *uvsw = nullptr; + float *tansw = nullptr; }; //mikktspace callbacks diff --git a/modules/cvtt/image_compress_cvtt.cpp b/modules/cvtt/image_compress_cvtt.cpp index 43faa52218..dbd6d9e9f9 100644 --- a/modules/cvtt/image_compress_cvtt.cpp +++ b/modules/cvtt/image_compress_cvtt.cpp @@ -37,26 +37,26 @@ #include <ConvectionKernels.h> struct CVTTCompressionJobParams { - bool is_hdr; - bool is_signed; - int bytes_per_pixel; + bool is_hdr = false; + bool is_signed = false; + int bytes_per_pixel = 0; cvtt::Options options; }; struct CVTTCompressionRowTask { const uint8_t *in_mm_bytes; - uint8_t *out_mm_bytes; - int y_start; - int width; - int height; + uint8_t *out_mm_bytes = nullptr; + int y_start = 0; + int width = 0; + int height = 0; }; struct CVTTCompressionJobQueue { CVTTCompressionJobParams job_params; const CVTTCompressionRowTask *job_tasks; - uint32_t num_tasks; - uint32_t current_task; + uint32_t num_tasks = 0; + uint32_t current_task = 0; }; static void _digest_row_task(const CVTTCompressionJobParams &p_job_params, const CVTTCompressionRowTask &p_row_task) { diff --git a/modules/dds/texture_loader_dds.cpp b/modules/dds/texture_loader_dds.cpp index 2865b3c9ae..5415fcc92e 100644 --- a/modules/dds/texture_loader_dds.cpp +++ b/modules/dds/texture_loader_dds.cpp @@ -69,11 +69,11 @@ enum DDSFormat { struct DDSFormatInfo { const char *name; - bool compressed; - bool palette; - uint32_t divisor; - uint32_t block_size; - Image::Format format; + bool compressed = false; + bool palette = false; + uint32_t divisor = 0; + uint32_t block_size = 0; + Image::Format format = Image::Format::FORMAT_BPTC_RGBA; }; static const DDSFormatInfo dds_format_info[DDS_MAX] = { diff --git a/modules/enet/networked_multiplayer_enet.cpp b/modules/enet/networked_multiplayer_enet.cpp index 66db9ab84e..91984b8928 100644 --- a/modules/enet/networked_multiplayer_enet.cpp +++ b/modules/enet/networked_multiplayer_enet.cpp @@ -866,28 +866,12 @@ void NetworkedMultiplayerENet::_bind_methods() { } NetworkedMultiplayerENet::NetworkedMultiplayerENet() { - active = false; - server = false; - refuse_connections = false; - server_relay = true; - unique_id = 0; - target_peer = 0; - current_packet.packet = nullptr; - transfer_mode = TRANSFER_MODE_RELIABLE; - channel_count = SYSCH_MAX; - transfer_channel = -1; - always_ordered = false; - connection_status = CONNECTION_DISCONNECTED; - compression_mode = COMPRESS_NONE; enet_compressor.context = this; enet_compressor.compress = enet_compress; enet_compressor.decompress = enet_decompress; enet_compressor.destroy = enet_compressor_destroy; bind_ip = IP_Address("*"); - - dtls_enabled = false; - dtls_verify = true; } NetworkedMultiplayerENet::~NetworkedMultiplayerENet() { diff --git a/modules/enet/networked_multiplayer_enet.h b/modules/enet/networked_multiplayer_enet.h index 4baa48be5e..eb70d71c2c 100644 --- a/modules/enet/networked_multiplayer_enet.h +++ b/modules/enet/networked_multiplayer_enet.h @@ -62,35 +62,35 @@ private: SYSCH_MAX }; - bool active; - bool server; + bool active = false; + bool server = false; - uint32_t unique_id; + uint32_t unique_id = 0; - int target_peer; - TransferMode transfer_mode; - int transfer_channel; - int channel_count; - bool always_ordered; + int target_peer = 0; + TransferMode transfer_mode = TRANSFER_MODE_RELIABLE; + int transfer_channel = -1; + int channel_count = SYSCH_MAX; + bool always_ordered = false; ENetEvent event; - ENetPeer *peer; - ENetHost *host; + ENetPeer *peer = nullptr; + ENetHost *host = nullptr; - bool refuse_connections; - bool server_relay; + bool refuse_connections = false; + bool server_relay = true; - ConnectionStatus connection_status; + ConnectionStatus connection_status = CONNECTION_DISCONNECTED; Map<int, ENetPeer *> peer_map; struct Packet { - ENetPacket *packet; - int from; - int channel; + ENetPacket *packet = nullptr; + int from = 0; + int channel = 0; }; - CompressionMode compression_mode; + CompressionMode compression_mode = COMPRESS_NONE; List<Packet> incoming_packets; @@ -110,10 +110,10 @@ private: IP_Address bind_ip; - bool dtls_enabled; + bool dtls_enabled = false; Ref<CryptoKey> dtls_key; Ref<X509Certificate> dtls_cert; - bool dtls_verify; + bool dtls_verify = true; protected: static void _bind_methods(); diff --git a/modules/etc/texture_loader_pkm.cpp b/modules/etc/texture_loader_pkm.cpp index b0ea109f76..456473672d 100644 --- a/modules/etc/texture_loader_pkm.cpp +++ b/modules/etc/texture_loader_pkm.cpp @@ -35,11 +35,11 @@ struct ETC1Header { char tag[6]; // "PKM 10" - uint16_t format; // Format == number of mips (== zero) - uint16_t texWidth; // Texture dimensions, multiple of 4 (big-endian) - uint16_t texHeight; - uint16_t origWidth; // Original dimensions (big-endian) - uint16_t origHeight; + uint16_t format = 0; // Format == number of mips (== zero) + uint16_t texWidth = 0; // Texture dimensions, multiple of 4 (big-endian) + uint16_t texHeight = 0; + uint16_t origWidth = 0; // Original dimensions (big-endian) + uint16_t origHeight = 0; }; RES ResourceFormatPKM::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, bool p_no_cache) { diff --git a/modules/gdnative/gdnative_library_editor_plugin.h b/modules/gdnative/gdnative_library_editor_plugin.h index 184db3d817..61afb1aaaa 100644 --- a/modules/gdnative/gdnative_library_editor_plugin.h +++ b/modules/gdnative/gdnative_library_editor_plugin.h @@ -95,9 +95,9 @@ public: class GDNativeLibraryEditorPlugin : public EditorPlugin { GDCLASS(GDNativeLibraryEditorPlugin, EditorPlugin); - GDNativeLibraryEditor *library_editor; - EditorNode *editor; - Button *button; + GDNativeLibraryEditor *library_editor = nullptr; + EditorNode *editor = nullptr; + Button *button = nullptr; public: virtual String get_name() const override { return "GDNativeLibrary"; } diff --git a/modules/gdnative/nativescript/nativescript.cpp b/modules/gdnative/nativescript/nativescript.cpp index 19cf1f980b..def020adad 100644 --- a/modules/gdnative/nativescript/nativescript.cpp +++ b/modules/gdnative/nativescript/nativescript.cpp @@ -1196,13 +1196,6 @@ void NativeScriptLanguage::_unload_stuff(bool p_reload) { NativeScriptLanguage::NativeScriptLanguage() { NativeScriptLanguage::singleton = this; -#ifndef NO_THREADS - has_objects_to_register = false; -#endif - -#ifdef DEBUG_ENABLED - profiling = false; -#endif _init_call_type = "nativescript_init"; _init_call_name = "nativescript_init"; diff --git a/modules/gdnative/nativescript/nativescript.h b/modules/gdnative/nativescript/nativescript.h index 9d72bf39d1..ea7ced6511 100644 --- a/modules/gdnative/nativescript/nativescript.h +++ b/modules/gdnative/nativescript/nativescript.h @@ -51,8 +51,8 @@ struct NativeScriptDesc { struct Method { godot_nativescript_instance_method method; MethodInfo info; - int rpc_mode; - uint16_t rpc_method_id; + int rpc_mode = 0; + uint16_t rpc_method_id = 0; String documentation; }; @@ -61,7 +61,7 @@ struct NativeScriptDesc { godot_nativescript_property_get_func getter; PropertyInfo info; Variant default_value; - int rset_mode; + int rset_mode = 0; uint16_t rset_property_id; String documentation; }; @@ -78,7 +78,7 @@ struct NativeScriptDesc { Map<StringName, Signal> signals_; // QtCreator doesn't like the name signals StringName base; StringName base_native_type; - NativeScriptDesc *base_data; + NativeScriptDesc *base_data = nullptr; godot_nativescript_instance_create_func create_func; godot_nativescript_instance_destroy_func destroy_func; @@ -86,7 +86,7 @@ struct NativeScriptDesc { const void *type_tag = nullptr; - bool is_tool; + bool is_tool = false; inline NativeScriptDesc() { zeromem(&create_func, sizeof(godot_nativescript_instance_create_func)); @@ -254,7 +254,7 @@ class NativeScriptLanguage : public ScriptLanguage { private: static NativeScriptLanguage *singleton; - int lang_idx; + int lang_idx = 0; void _unload_stuff(bool p_reload = false); @@ -262,7 +262,7 @@ private: #ifndef NO_THREADS Set<Ref<GDNativeLibrary>> libs_to_init; Set<NativeScript *> scripts_to_register; - volatile bool has_objects_to_register; // so that we don't lock mutex every frame - it's rarely needed + volatile bool has_objects_to_register = false; // so that we don't lock mutex every frame - it's rarely needed void defer_init_library(Ref<GDNativeLibrary> lib, NativeScript *script); #endif @@ -279,19 +279,19 @@ private: struct ProfileData { StringName signature; - uint64_t call_count; - uint64_t self_time; - uint64_t total_time; - uint64_t frame_call_count; - uint64_t frame_self_time; - uint64_t frame_total_time; - uint64_t last_frame_call_count; - uint64_t last_frame_self_time; - uint64_t last_frame_total_time; + uint64_t call_count = 0; + uint64_t self_time = 0; + uint64_t total_time = 0; + uint64_t frame_call_count = 0; + uint64_t frame_self_time = 0; + uint64_t frame_total_time = 0; + uint64_t last_frame_call_count = 0; + uint64_t last_frame_self_time = 0; + uint64_t last_frame_total_time = 0; }; Map<StringName, ProfileData> profile_data; - bool profiling; + bool profiling = false; public: // These two maps must only be touched on the main thread diff --git a/modules/gdnative/pluginscript/pluginscript_instance.h b/modules/gdnative/pluginscript/pluginscript_instance.h index 865080fddf..536eb550e0 100644 --- a/modules/gdnative/pluginscript/pluginscript_instance.h +++ b/modules/gdnative/pluginscript/pluginscript_instance.h @@ -44,10 +44,10 @@ class PluginScriptInstance : public ScriptInstance { private: Ref<PluginScript> _script; - Object *_owner; + Object *_owner = nullptr; Variant _owner_variant; - godot_pluginscript_instance_data *_data; - const godot_pluginscript_instance_desc *_desc; + godot_pluginscript_instance_data *_data = nullptr; + const godot_pluginscript_instance_desc *_desc = nullptr; public: _FORCE_INLINE_ Object *get_owner() { return _owner; } diff --git a/modules/gdnative/videodecoder/video_stream_gdnative.h b/modules/gdnative/videodecoder/video_stream_gdnative.h index e64cda6602..3db5609952 100644 --- a/modules/gdnative/videodecoder/video_stream_gdnative.h +++ b/modules/gdnative/videodecoder/video_stream_gdnative.h @@ -118,7 +118,7 @@ class VideoStreamPlaybackGDNative : public VideoStreamPlayback { AudioMixCallback mix_callback = nullptr; int num_channels = -1; - float time = 0; + float time = 0.0; bool seek_backward = false; int mix_rate = 0; double delay_compensation = 0; diff --git a/modules/gdnavigation/nav_utils.h b/modules/gdnavigation/nav_utils.h index d1d1687a1f..d257a95ef1 100644 --- a/modules/gdnavigation/nav_utils.h +++ b/modules/gdnavigation/nav_utils.h @@ -51,7 +51,7 @@ union PointKey { int64_t z : 21; }; - uint64_t key; + uint64_t key = 0; bool operator<(const PointKey &p_key) const { return key < p_key.key; } }; @@ -86,8 +86,6 @@ struct Edge { /// The other `Polygon` at this edge id has this `Polygon`. int other_edge = -1; - - Edge() {} }; struct Polygon { @@ -111,8 +109,6 @@ struct Connection { int A_edge = -1; Polygon *B = nullptr; int B_edge = -1; - - Connection() {} }; struct NavigationPoly { @@ -141,12 +137,12 @@ struct NavigationPoly { }; struct FreeEdge { - bool is_free; - Polygon *poly; - uint32_t edge_id; + bool is_free = false; + Polygon *poly = nullptr; + uint32_t edge_id = 0; Vector3 edge_center; Vector3 edge_dir; - float edge_len_squared; + float edge_len_squared = 0.0; }; } // namespace gd diff --git a/modules/gdnavigation/rvo_agent.h b/modules/gdnavigation/rvo_agent.h index d9e3345498..369cb1f9a3 100644 --- a/modules/gdnavigation/rvo_agent.h +++ b/modules/gdnavigation/rvo_agent.h @@ -53,7 +53,7 @@ class RvoAgent : public NavRid { NavMap *map = nullptr; RVO::Agent agent; AvoidanceComputedCallback callback; - uint32_t map_update_id; + uint32_t map_update_id = 0; public: RvoAgent(); diff --git a/modules/gdscript/editor/gdscript_translation_parser_plugin.h b/modules/gdscript/editor/gdscript_translation_parser_plugin.h index 5358a77140..fcf438422a 100644 --- a/modules/gdscript/editor/gdscript_translation_parser_plugin.h +++ b/modules/gdscript/editor/gdscript_translation_parser_plugin.h @@ -39,8 +39,8 @@ class GDScriptEditorTranslationParserPlugin : public EditorTranslationParserPlugin { GDCLASS(GDScriptEditorTranslationParserPlugin, EditorTranslationParserPlugin); - Vector<String> *ids; - Vector<Vector<String>> *ids_ctx_plural; + Vector<String> *ids = nullptr; + Vector<Vector<String>> *ids_ctx_plural = nullptr; // List of patterns used for extracting translation strings. StringName tr_func = "tr"; diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index 502e294275..f891145988 100644 --- a/modules/gdscript/gdscript.cpp +++ b/modules/gdscript/gdscript.cpp @@ -219,7 +219,7 @@ StringName GDScript::get_instance_base_type() const { } struct _GDScriptMemberSort { - int index; + int index = 0; StringName name; _FORCE_INLINE_ bool operator<(const _GDScriptMemberSort &p_member) const { return index < p_member.index; } }; @@ -1162,17 +1162,6 @@ String GDScript::_get_gdscript_reference_class_name(const GDScript *p_gdscript) GDScript::GDScript() : script_list(this) { - valid = false; - subclass_count = 0; - initializer = nullptr; - _base = nullptr; - _owner = nullptr; - tool = false; -#ifdef TOOLS_ENABLED - source_changed_cache = false; - placeholder_fallback_enabled = false; -#endif - #ifdef DEBUG_ENABLED { MutexLock lock(GDScriptLanguage::get_singleton()->lock); diff --git a/modules/gdscript/gdscript.h b/modules/gdscript/gdscript.h index 37f01b2571..ee270f6b2f 100644 --- a/modules/gdscript/gdscript.h +++ b/modules/gdscript/gdscript.h @@ -57,11 +57,11 @@ public: class GDScript : public Script { GDCLASS(GDScript, Script); - bool tool; - bool valid; + bool tool = false; + bool valid = false; struct MemberInfo { - int index; + int index = 0; StringName setter; StringName getter; MultiplayerAPI::RPCMode rpc_mode; @@ -77,8 +77,8 @@ class GDScript : public Script { Ref<GDScriptNativeClass> native; Ref<GDScript> base; - GDScript *_base; //fast pointer access - GDScript *_owner; //for subclasses + GDScript *_base = nullptr; //fast pointer access + GDScript *_owner = nullptr; //for subclasses Set<StringName> members; //members are just indices to the instanced script. Map<StringName, Variant> constants; @@ -97,8 +97,8 @@ class GDScript : public Script { Map<StringName, Variant> member_default_values_cache; Ref<GDScript> base_cache; Set<ObjectID> inheriters_cache; - bool source_changed_cache; - bool placeholder_fallback_enabled; + bool source_changed_cache = false; + bool placeholder_fallback_enabled = false; void _update_exports_values(Map<StringName, Variant> &values, List<PropertyInfo> &propnames); DocData::ClassDoc doc; @@ -121,7 +121,7 @@ class GDScript : public Script { GDScriptFunction *implicit_initializer = nullptr; GDScriptFunction *initializer = nullptr; //direct pointer to new , faster to locate - int subclass_count; + int subclass_count = 0; Set<Object *> instances; //exported members String source; diff --git a/modules/gdscript/gdscript_compiler.h b/modules/gdscript/gdscript_compiler.h index 00953ad752..651391f972 100644 --- a/modules/gdscript/gdscript_compiler.h +++ b/modules/gdscript/gdscript_compiler.h @@ -133,8 +133,8 @@ class GDScriptCompiler { Error _parse_class_level(GDScript *p_script, const GDScriptParser::ClassNode *p_class, bool p_keep_state); Error _parse_class_blocks(GDScript *p_script, const GDScriptParser::ClassNode *p_class, bool p_keep_state); void _make_scripts(GDScript *p_script, const GDScriptParser::ClassNode *p_class, bool p_keep_state); - int err_line; - int err_column; + int err_line = 0; + int err_column = 0; StringName source; String error; bool within_await = false; diff --git a/modules/gdscript/gdscript_function.cpp b/modules/gdscript/gdscript_function.cpp index 2171426e6f..c6c9a439df 100644 --- a/modules/gdscript/gdscript_function.cpp +++ b/modules/gdscript/gdscript_function.cpp @@ -77,14 +77,14 @@ int GDScriptFunction::get_max_stack_size() const { } struct _GDFKC { - int order; + int order = 0; List<int> pos; }; struct _GDFKCS { - int order; + int order = 0; StringName id; - int pos; + int pos = 0; bool operator<(const _GDFKCS &p_r) const { return order < p_r.order; @@ -294,7 +294,6 @@ void GDScriptFunctionState::_bind_methods() { GDScriptFunctionState::GDScriptFunctionState() : scripts_list(this), instances_list(this) { - function = nullptr; } GDScriptFunctionState::~GDScriptFunctionState() { diff --git a/modules/gdscript/gdscript_function.h b/modules/gdscript/gdscript_function.h index 6c791836b9..e64630a743 100644 --- a/modules/gdscript/gdscript_function.h +++ b/modules/gdscript/gdscript_function.h @@ -420,19 +420,19 @@ private: public: struct CallState { - GDScript *script; - GDScriptInstance *instance; + GDScript *script = nullptr; + GDScriptInstance *instance = nullptr; #ifdef DEBUG_ENABLED StringName function_name; String script_path; #endif Vector<uint8_t> stack; - int stack_size; + int stack_size = 0; Variant self; - uint32_t alloca_size; - int ip; - int line; - int defarg; + uint32_t alloca_size = 0; + int ip = 0; + int line = 0; + int defarg = 0; Variant result; }; @@ -488,7 +488,7 @@ public: class GDScriptFunctionState : public Reference { GDCLASS(GDScriptFunctionState, Reference); friend class GDScriptFunction; - GDScriptFunction *function; + GDScriptFunction *function = nullptr; GDScriptFunction::CallState state; Variant _signal_callback(const Variant **p_args, int p_argcount, Callable::CallError &r_error); Ref<GDScriptFunctionState> first_state; diff --git a/modules/gdscript/gdscript_parser.h b/modules/gdscript/gdscript_parser.h index f43708b81f..d59b68b602 100644 --- a/modules/gdscript/gdscript_parser.h +++ b/modules/gdscript/gdscript_parser.h @@ -351,7 +351,7 @@ public: OP_COMP_GREATER_EQUAL, }; - OpType operation; + OpType operation = OpType::OP_ADDITION; Variant::Operator variant_op = Variant::OP_MAX; ExpressionNode *left_operand = nullptr; ExpressionNode *right_operand = nullptr; @@ -753,7 +753,7 @@ public: struct MatchBranchNode : public Node { Vector<PatternNode *> patterns; - SuiteNode *block; + SuiteNode *block = nullptr; bool has_wildcard = false; MatchBranchNode() { @@ -1001,7 +1001,7 @@ public: OP_LOGIC_NOT, }; - OpType operation; + OpType operation = OP_POSITIVE; Variant::Operator variant_op = Variant::OP_MAX; ExpressionNode *operand = nullptr; diff --git a/modules/gdscript/gdscript_tokenizer.h b/modules/gdscript/gdscript_tokenizer.h index cdb0072294..bea4b14019 100644 --- a/modules/gdscript/gdscript_tokenizer.h +++ b/modules/gdscript/gdscript_tokenizer.h @@ -178,7 +178,6 @@ public: } Token() { - type = EMPTY; } }; diff --git a/modules/gdscript/language_server/gdscript_language_server.cpp b/modules/gdscript/language_server/gdscript_language_server.cpp index 12ed56a568..98ada9de4d 100644 --- a/modules/gdscript/language_server/gdscript_language_server.cpp +++ b/modules/gdscript/language_server/gdscript_language_server.cpp @@ -36,11 +36,6 @@ #include "editor/editor_node.h" GDScriptLanguageServer::GDScriptLanguageServer() { - thread_running = false; - started = false; - - use_thread = false; - port = 6008; _EDITOR_DEF("network/language_server/remote_port", port); _EDITOR_DEF("network/language_server/enable_smart_resolve", true); _EDITOR_DEF("network/language_server/show_native_symbols_in_editor", false); diff --git a/modules/gdscript/language_server/gdscript_language_server.h b/modules/gdscript/language_server/gdscript_language_server.h index 7b7837a463..29c5ddd70e 100644 --- a/modules/gdscript/language_server/gdscript_language_server.h +++ b/modules/gdscript/language_server/gdscript_language_server.h @@ -41,10 +41,10 @@ class GDScriptLanguageServer : public EditorPlugin { GDScriptLanguageProtocol protocol; Thread thread; - bool thread_running; - bool started; - bool use_thread; - int port; + bool thread_running = false; + bool started = false; + bool use_thread = false; + int port = 6008; static void thread_main(void *p_userdata); private: diff --git a/modules/gdscript/language_server/lsp.hpp b/modules/gdscript/language_server/lsp.hpp index 6a913edbbf..96744a15d7 100644 --- a/modules/gdscript/language_server/lsp.hpp +++ b/modules/gdscript/language_server/lsp.hpp @@ -547,7 +547,7 @@ struct TextDocumentItem { * The version number of this document (it will increase after each * change, including undo/redo). */ - int version; + int version = 0; /** * The content of the opened text document. @@ -584,7 +584,7 @@ struct TextDocumentContentChangeEvent { /** * The length of the range that got replaced. */ - int rangeLength; + int rangeLength = 0; /** * The new text of the range/document. @@ -656,12 +656,12 @@ struct Diagnostic { * The diagnostic's severity. Can be omitted. If omitted it is up to the * client to interpret diagnostics as error, warning, info or hint. */ - int severity; + int severity = 0; /** * The diagnostic's code, which might appear in the user interface. */ - int code; + int code = 0; /** * A human-readable string describing the source of this @@ -833,7 +833,7 @@ struct CompletionItem { * an icon is chosen by the editor. The standardized set * of available values is defined in `CompletionItemKind`. */ - int kind; + int kind = 0; /** * A human-readable string with additional information @@ -891,7 +891,7 @@ struct CompletionItem { * The format of the insert text. The format applies to both the `insertText` property * and the `newText` property of a provided `textEdit`. */ - int insertTextFormat; + int insertTextFormat = 0; /** * An edit which is applied to a document when selecting this completion. When an edit is provided the value of @@ -1003,7 +1003,7 @@ struct CompletionList { * This list it not complete. Further typing should result in recomputing * this list. */ - bool isIncomplete; + bool isIncomplete = false; /** * The completion items. diff --git a/modules/gltf/gltf_camera.h b/modules/gltf/gltf_camera.h index e5c2041793..bf94b80bef 100644 --- a/modules/gltf/gltf_camera.h +++ b/modules/gltf/gltf_camera.h @@ -38,8 +38,8 @@ class GLTFCamera : public Resource { private: bool perspective = true; - float fov_size = 75; - float zfar = 4000; + float fov_size = 75.0; + float zfar = 4000.0; float znear = 0.05; protected: diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp index cce0740121..4868347a74 100644 --- a/modules/gltf/gltf_document.cpp +++ b/modules/gltf/gltf_document.cpp @@ -2391,7 +2391,7 @@ Error GLTFDocument::_serialize_meshes(Ref<GLTFState> state) { e["targetNames"] = target_names; for (int j = 0; j < target_names.size(); j++) { - real_t weight = 0; + real_t weight = 0.0; if (j < state->meshes.write[gltf_mesh_i]->get_blend_weights().size()) { weight = state->meshes.write[gltf_mesh_i]->get_blend_weights()[j]; } @@ -5569,7 +5569,7 @@ void GLTFDocument::_import_animation(Ref<GLTFState> state, AnimationPlayer *ap, animation->set_loop(true); } - float length = 0; + float length = 0.0; for (Map<int, GLTFAnimation::Track>::Element *track_i = anim->get_tracks().front(); track_i; track_i = track_i->next()) { const GLTFAnimation::Track &track = track_i->get(); diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cpp index 5a17541075..323b025774 100644 --- a/modules/gridmap/grid_map.cpp +++ b/modules/gridmap/grid_map.cpp @@ -1046,26 +1046,7 @@ RID GridMap::get_bake_mesh_instance(int p_idx) { } GridMap::GridMap() { - collision_layer = 1; - collision_mask = 1; - - cell_size = Vector3(2, 2, 2); - octant_size = 8; - awaiting_update = false; - _in_tree = false; - center_x = true; - center_y = true; - center_z = true; - - clip = false; - clip_floor = 0; - clip_axis = Vector3::AXIS_Z; - clip_above = true; - cell_scale = 1.0; - - navigation = nullptr; set_notify_transform(true); - recreating_octants = false; } GridMap::~GridMap() { diff --git a/modules/gridmap/grid_map.h b/modules/gridmap/grid_map.h index 48ad95f9ff..e5ec4bb602 100644 --- a/modules/gridmap/grid_map.h +++ b/modules/gridmap/grid_map.h @@ -53,7 +53,7 @@ class GridMap : public Node3D { int16_t y; int16_t z; }; - uint64_t key; + uint64_t key = 0; _FORCE_INLINE_ bool operator<(const IndexKey &p_key) const { return key < p_key.key; @@ -68,7 +68,7 @@ class GridMap : public Node3D { y = (int16_t)p_vector.y; z = (int16_t)p_vector.z; } - IndexKey() { key = 0; } + IndexKey() {} }; /** @@ -80,13 +80,7 @@ class GridMap : public Node3D { unsigned int rot : 5; unsigned int layer : 8; }; - uint32_t cell; - - Cell() { - item = 0; - rot = 0; - layer = 0; - } + uint32_t cell = 0; }; /** @@ -103,7 +97,7 @@ class GridMap : public Node3D { RID instance; RID multimesh; struct Item { - int index; + int index = 0; Transform transform; IndexKey key; }; @@ -116,7 +110,7 @@ class GridMap : public Node3D { RID collision_debug; RID collision_debug_instance; - bool dirty; + bool dirty = false; RID static_body; Map<IndexKey, NavMesh> navmesh_ids; }; @@ -129,35 +123,37 @@ class GridMap : public Node3D { int16_t empty; }; - uint64_t key; + uint64_t key = 0; _FORCE_INLINE_ bool operator<(const OctantKey &p_key) const { return key < p_key.key; } //OctantKey(const IndexKey& p_k, int p_item) { indexkey=p_k.key; item=p_item; } - OctantKey() { key = 0; } + OctantKey() {} }; - uint32_t collision_layer; - uint32_t collision_mask; + uint32_t collision_layer = 1; + uint32_t collision_mask = 1; Transform last_transform; - bool _in_tree; - Vector3 cell_size; - int octant_size; - bool center_x, center_y, center_z; - float cell_scale; - Navigation3D *navigation; + bool _in_tree = false; + Vector3 cell_size = Vector3(2, 2, 2); + int octant_size = 8; + bool center_x = true; + bool center_y = true; + bool center_z = true; + float cell_scale = 1.0; + Navigation3D *navigation = nullptr; - bool clip; - bool clip_above; - int clip_floor; + bool clip = false; + bool clip_above = true; + int clip_floor = 0; - bool recreating_octants; + bool recreating_octants = false; - Vector3::Axis clip_axis; + Vector3::Axis clip_axis = Vector3::AXIS_Z; Ref<MeshLibrary> mesh_library; @@ -167,10 +163,10 @@ class GridMap : public Node3D { void _recreate_octant_data(); struct BakeLight { - RS::LightType type; + RS::LightType type = RS::LightType::LIGHT_DIRECTIONAL; Vector3 pos; Vector3 dir; - float param[RS::LIGHT_PARAM_MAX]; + float param[RS::LIGHT_PARAM_MAX] = {}; }; _FORCE_INLINE_ Vector3 _octant_get_offset(const OctantKey &p_key) const { @@ -183,7 +179,7 @@ class GridMap : public Node3D { bool _octant_update(const OctantKey &p_key); void _octant_clean_up(const OctantKey &p_key); void _octant_transform(const OctantKey &p_key); - bool awaiting_update; + bool awaiting_update = false; void _queue_octants_dirty(); void _update_octants_callback(); diff --git a/modules/gridmap/grid_map_editor_plugin.cpp b/modules/gridmap/grid_map_editor_plugin.cpp index 4732a3f62d..565830c16f 100644 --- a/modules/gridmap/grid_map_editor_plugin.cpp +++ b/modules/gridmap/grid_map_editor_plugin.cpp @@ -769,7 +769,7 @@ bool GridMapEditor::forward_spatial_input_event(Camera3D *p_camera, const Ref<In struct _CGMEItemSort { String name; - int id; + int id = 0; _FORCE_INLINE_ bool operator<(const _CGMEItemSort &r_it) const { return name < r_it.name; } }; @@ -1151,7 +1151,6 @@ void GridMapEditor::_bind_methods() { } GridMapEditor::GridMapEditor(EditorNode *p_editor) { - input_action = INPUT_NONE; editor = p_editor; undo_redo = p_editor->get_undo_redo(); @@ -1234,7 +1233,6 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) { settings_pick_distance->set_value(EDITOR_DEF("editors/grid_map/pick_distance", 5000.0)); settings_vbc->add_margin_child(TTR("Pick Distance:"), settings_pick_distance); - clip_mode = CLIP_DISABLED; options->get_popup()->connect("id_pressed", callable_mp(this, &GridMapEditor::_menu_option)); HBoxContainer *hb = memnew(HBoxContainer); @@ -1275,8 +1273,6 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) { EDITOR_DEF("editors/grid_map/preview_size", 64); - display_mode = DISPLAY_THUMBNAIL; - mesh_library_palette = memnew(ItemList); add_child(mesh_library_palette); mesh_library_palette->set_v_size_flags(SIZE_EXPAND_FILL); @@ -1296,11 +1292,6 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) { edit_floor[1] = -1; edit_floor[2] = -1; - cursor_visible = false; - selected_palette = -1; - lock_view = false; - cursor_rot = 0; - selection_mesh = RenderingServer::get_singleton()->mesh_create(); paste_mesh = RenderingServer::get_singleton()->mesh_create(); @@ -1418,8 +1409,6 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) { } _set_selection(false); - updating = false; - accumulated_floor_delta = 0.0; indicator_mat.instance(); indicator_mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); diff --git a/modules/gridmap/grid_map_editor_plugin.h b/modules/gridmap/grid_map_editor_plugin.h index 0c0ec64680..6c7f0bedf6 100644 --- a/modules/gridmap/grid_map_editor_plugin.h +++ b/modules/gridmap/grid_map_editor_plugin.h @@ -65,11 +65,11 @@ class GridMapEditor : public VBoxContainer { }; UndoRedo *undo_redo; - InputAction input_action; + InputAction input_action = INPUT_NONE; Panel *panel; MenuButton *options; SpinBox *floor; - double accumulated_floor_delta; + double accumulated_floor_delta = 0.0; Button *mode_thumbnail; Button *mode_list; LineEdit *search_box; @@ -82,19 +82,19 @@ class GridMapEditor : public VBoxContainer { struct SetItem { Vector3i position; - int new_value; - int new_orientation; - int old_value; - int old_orientation; + int new_value = 0; + int new_orientation = 0; + int old_value = 0; + int old_orientation = 0; }; List<SetItem> set_items; GridMap *node = nullptr; MeshLibrary *last_mesh_library; - ClipMode clip_mode; + ClipMode clip_mode = CLIP_DISABLED; - bool lock_view; + bool lock_view = false; Transform grid_xform; Transform edit_grid_xform; Vector3::Axis edit_axis; @@ -112,9 +112,9 @@ class GridMapEditor : public VBoxContainer { RID paste_instance; struct ClipboardItem { - int cell_item; + int cell_item = 0; Vector3 grid_offset; - int orientation; + int orientation = 0; RID instance; }; @@ -125,14 +125,14 @@ class GridMapEditor : public VBoxContainer { Ref<StandardMaterial3D> outer_mat; Ref<StandardMaterial3D> selection_floor_mat; - bool updating; + bool updating = false; struct Selection { Vector3 click; Vector3 current; Vector3 begin; Vector3 end; - bool active; + bool active = false; } selection; Selection last_selection; @@ -141,18 +141,18 @@ class GridMapEditor : public VBoxContainer { Vector3 current; Vector3 begin; Vector3 end; - int orientation; + int orientation = 0; }; PasteIndicator paste_indicator; - bool cursor_visible; + bool cursor_visible = false; Transform cursor_transform; Vector3 cursor_origin; - int display_mode; - int selected_palette; - int cursor_rot; + int display_mode = DISPLAY_THUMBNAIL; + int selected_palette = -1; + int cursor_rot = 0; enum Menu { MENU_OPTION_NEXT_LEVEL, diff --git a/modules/lightmapper_rd/lightmapper_rd.cpp b/modules/lightmapper_rd/lightmapper_rd.cpp index f31eb3f066..82aaa492fc 100644 --- a/modules/lightmapper_rd/lightmapper_rd.cpp +++ b/modules/lightmapper_rd/lightmapper_rd.cpp @@ -93,8 +93,8 @@ void LightmapperRD::add_spot_light(bool p_static, const Vector3 &p_position, con l.direction[2] = p_direction.z; l.range = p_range; l.attenuation = p_attenuation; - l.spot_angle = Math::deg2rad(p_spot_angle); - l.spot_attenuation = p_spot_attenuation; + l.cos_spot_angle = Math::cos(Math::deg2rad(p_spot_angle)); + l.inv_spot_attenuation = 1.0f / p_spot_attenuation; l.color[0] = p_color.r; l.color[1] = p_color.g; l.color[2] = p_color.b; diff --git a/modules/lightmapper_rd/lightmapper_rd.h b/modules/lightmapper_rd/lightmapper_rd.h index bb735baf6c..f2a826a447 100644 --- a/modules/lightmapper_rd/lightmapper_rd.h +++ b/modules/lightmapper_rd/lightmapper_rd.h @@ -46,18 +46,18 @@ class LightmapperRD : public Lightmapper { }; struct Light { - float position[3]; + float position[3] = {}; uint32_t type = LIGHT_TYPE_DIRECTIONAL; - float direction[3]; - float energy; - float color[3]; - float size; - float range; - float attenuation; - float spot_angle; - float spot_attenuation; - uint32_t static_bake; - uint32_t pad[3]; + float direction[3] = {}; + float energy = 0.0; + float color[3] = {}; + float size = 0.0; + float range = 0.0; + float attenuation = 0.0; + float cos_spot_angle = 0.0; + float inv_spot_attenuation = 0.0; + uint32_t static_bake = 0; + uint32_t pad[3] = {}; bool operator<(const Light &p_light) const { return type < p_light.type; @@ -65,10 +65,10 @@ class LightmapperRD : public Lightmapper { }; struct Vertex { - float position[3]; - float normal_z; - float uv[2]; - float normal_xy[2]; + float position[3] = {}; + float normal_z = 0.0; + float uv[2] = {}; + float normal_xy[2] = {}; bool operator==(const Vertex &p_vtx) const { return (position[0] == p_vtx.position[0]) && @@ -102,7 +102,7 @@ class LightmapperRD : public Lightmapper { }; struct Probe { - float position[4]; + float position[4] = {}; }; Vector<Probe> probe_positions; @@ -158,15 +158,15 @@ class LightmapperRD : public Lightmapper { }; struct Box { - float min_bounds[3]; - float pad0; - float max_bounds[3]; - float pad1; + float min_bounds[3] = {}; + float pad0 = 0.0; + float max_bounds[3] = {}; + float pad1 = 0.0; }; struct Triangle { - uint32_t indices[3]; - uint32_t slice; + uint32_t indices[3] = {}; + uint32_t slice = 0; bool operator<(const Triangle &p_triangle) const { return slice < p_triangle.slice; } @@ -177,8 +177,8 @@ class LightmapperRD : public Lightmapper { Vector<Light> lights; struct TriangleSort { - uint32_t cell_index; - uint32_t triangle_index; + uint32_t cell_index = 0; + uint32_t triangle_index = 0; bool operator<(const TriangleSort &p_triangle_sort) const { return cell_index < p_triangle_sort.cell_index; //sorting by triangle index in this case makes no sense } @@ -187,44 +187,44 @@ class LightmapperRD : public Lightmapper { void _plot_triangle_into_triangle_index_list(int p_size, const Vector3i &p_ofs, const AABB &p_bounds, const Vector3 p_points[], uint32_t p_triangle_index, LocalVector<TriangleSort> &triangles, uint32_t p_grid_size); struct RasterPushConstant { - float atlas_size[2]; - float uv_offset[2]; - float to_cell_size[3]; - uint32_t base_triangle; - float to_cell_offset[3]; - float bias; - int32_t grid_size[3]; - uint32_t pad2; + float atlas_size[2] = {}; + float uv_offset[2] = {}; + float to_cell_size[3] = {}; + uint32_t base_triangle = 0; + float to_cell_offset[3] = {}; + float bias = 0.0; + int32_t grid_size[3] = {}; + uint32_t pad2 = 0; }; struct RasterSeamsPushConstant { - uint32_t base_index; - uint32_t slice; - float uv_offset[2]; - uint32_t debug; - float blend; - uint32_t pad[2]; + uint32_t base_index = 0; + uint32_t slice = 0; + float uv_offset[2] = {}; + uint32_t debug = 0; + float blend = 0.0; + uint32_t pad[2] = {}; }; struct PushConstant { - int32_t atlas_size[2]; - uint32_t ray_count; - uint32_t ray_to; + int32_t atlas_size[2] = {}; + uint32_t ray_count = 0; + uint32_t ray_to = 0; - float world_size[3]; - float bias; + float world_size[3] = {}; + float bias = 0.0; - float to_cell_offset[3]; - uint32_t ray_from; + float to_cell_offset[3] = {}; + uint32_t ray_from = 0; - float to_cell_size[3]; - uint32_t light_count; + float to_cell_size[3] = {}; + uint32_t light_count = 0; - int32_t grid_size; - int32_t atlas_slice; - int32_t region_ofs[2]; + int32_t grid_size = 0; + int32_t atlas_slice = 0; + int32_t region_ofs[2] = {}; - float environment_xform[12]; + float environment_xform[12] = {}; }; Vector<Ref<Image>> bake_textures; diff --git a/modules/lightmapper_rd/lm_common_inc.glsl b/modules/lightmapper_rd/lm_common_inc.glsl index 0ff455936e..f8a0cd16de 100644 --- a/modules/lightmapper_rd/lm_common_inc.glsl +++ b/modules/lightmapper_rd/lm_common_inc.glsl @@ -56,8 +56,8 @@ struct Light { float range; float attenuation; - float spot_angle; - float spot_attenuation; + float cos_spot_angle; + float inv_spot_attenuation; bool static_bake; uint pad[3]; diff --git a/modules/lightmapper_rd/lm_compute.glsl b/modules/lightmapper_rd/lm_compute.glsl index 8a9adbc5cc..eb9d817f99 100644 --- a/modules/lightmapper_rd/lm_compute.glsl +++ b/modules/lightmapper_rd/lm_compute.glsl @@ -313,13 +313,16 @@ void main() { if (lights.data[i].type == LIGHT_TYPE_SPOT) { vec3 rel = normalize(position - light_pos); - float angle = acos(dot(rel, lights.data[i].direction)); - if (angle > lights.data[i].spot_angle) { + float cos_spot_angle = lights.data[i].cos_spot_angle; + float cos_angle = dot(rel, lights.data[i].direction); + + if (cos_angle < cos_spot_angle) { continue; //invisible, dont try } - float d = clamp(angle / lights.data[i].spot_angle, 0, 1); - attenuation *= pow(1.0 - d, lights.data[i].spot_attenuation); + float scos = max(cos_angle, cos_spot_angle); + float spot_rim = max(0.0001, (1.0 - scos) / (1.0 - cos_spot_angle)); + attenuation *= 1.0 - pow(spot_rim, lights.data[i].inv_spot_attenuation); } } diff --git a/modules/mbedtls/packet_peer_mbed_dtls.cpp b/modules/mbedtls/packet_peer_mbed_dtls.cpp index b2f8d668bf..8a6cdfb131 100644 --- a/modules/mbedtls/packet_peer_mbed_dtls.cpp +++ b/modules/mbedtls/packet_peer_mbed_dtls.cpp @@ -246,7 +246,6 @@ int PacketPeerMbedDTLS::get_max_packet_size() const { PacketPeerMbedDTLS::PacketPeerMbedDTLS() { ssl_ctx.instance(); - status = STATUS_DISCONNECTED; } PacketPeerMbedDTLS::~PacketPeerMbedDTLS() { diff --git a/modules/mbedtls/packet_peer_mbed_dtls.h b/modules/mbedtls/packet_peer_mbed_dtls.h index 0feec04c6e..6554c74a21 100644 --- a/modules/mbedtls/packet_peer_mbed_dtls.h +++ b/modules/mbedtls/packet_peer_mbed_dtls.h @@ -44,7 +44,7 @@ private: uint8_t packet_buffer[PACKET_BUFFER_SIZE]; - Status status; + Status status = STATUS_DISCONNECTED; String hostname; Ref<PacketPeerUDP> base; diff --git a/modules/mbedtls/ssl_context_mbedtls.cpp b/modules/mbedtls/ssl_context_mbedtls.cpp index 046f30588a..cbb532587f 100644 --- a/modules/mbedtls/ssl_context_mbedtls.cpp +++ b/modules/mbedtls/ssl_context_mbedtls.cpp @@ -76,7 +76,6 @@ void CookieContextMbedTLS::clear() { } CookieContextMbedTLS::CookieContextMbedTLS() { - inited = false; } CookieContextMbedTLS::~CookieContextMbedTLS() { @@ -205,7 +204,6 @@ mbedtls_ssl_context *SSLContextMbedTLS::get_context() { } SSLContextMbedTLS::SSLContextMbedTLS() { - inited = false; } SSLContextMbedTLS::~SSLContextMbedTLS() { diff --git a/modules/mbedtls/ssl_context_mbedtls.h b/modules/mbedtls/ssl_context_mbedtls.h index d243185726..30632018a8 100644 --- a/modules/mbedtls/ssl_context_mbedtls.h +++ b/modules/mbedtls/ssl_context_mbedtls.h @@ -50,7 +50,7 @@ class CookieContextMbedTLS : public Reference { friend class SSLContextMbedTLS; protected: - bool inited; + bool inited = false; mbedtls_entropy_context entropy; mbedtls_ctr_drbg_context ctr_drbg; mbedtls_ssl_cookie_ctx cookie_ctx; @@ -65,7 +65,7 @@ public: class SSLContextMbedTLS : public Reference { protected: - bool inited; + bool inited = false; static PackedByteArray _read_file(String p_path); diff --git a/modules/mbedtls/stream_peer_mbedtls.cpp b/modules/mbedtls/stream_peer_mbedtls.cpp index 1332d0923c..d7597aa435 100644 --- a/modules/mbedtls/stream_peer_mbedtls.cpp +++ b/modules/mbedtls/stream_peer_mbedtls.cpp @@ -274,7 +274,6 @@ int StreamPeerMbedTLS::get_available_bytes() const { StreamPeerMbedTLS::StreamPeerMbedTLS() { ssl_ctx.instance(); - status = STATUS_DISCONNECTED; } StreamPeerMbedTLS::~StreamPeerMbedTLS() { diff --git a/modules/mbedtls/stream_peer_mbedtls.h b/modules/mbedtls/stream_peer_mbedtls.h index ccbbebe4f8..b89d7fb238 100644 --- a/modules/mbedtls/stream_peer_mbedtls.h +++ b/modules/mbedtls/stream_peer_mbedtls.h @@ -36,7 +36,7 @@ class StreamPeerMbedTLS : public StreamPeerSSL { private: - Status status; + Status status = STATUS_DISCONNECTED; String hostname; Ref<StreamPeer> base; diff --git a/modules/minimp3/audio_stream_mp3.h b/modules/minimp3/audio_stream_mp3.h index de02ba6003..ce001fc418 100644 --- a/modules/minimp3/audio_stream_mp3.h +++ b/modules/minimp3/audio_stream_mp3.h @@ -78,11 +78,11 @@ class AudioStreamMP3 : public AudioStream { void *data = nullptr; uint32_t data_len = 0; - float sample_rate = 1; + float sample_rate = 1.0; int channels = 1; - float length = 0; + float length = 0.0; bool loop = false; - float loop_offset = 0; + float loop_offset = 0.0; void clear_data(); protected: diff --git a/modules/mobile_vr/mobile_vr_interface.cpp b/modules/mobile_vr/mobile_vr_interface.cpp index a9073ea4a0..25b110dc62 100644 --- a/modules/mobile_vr/mobile_vr_interface.cpp +++ b/modules/mobile_vr/mobile_vr_interface.cpp @@ -448,19 +448,7 @@ void MobileVRInterface::process() { }; }; -MobileVRInterface::MobileVRInterface() { - initialized = false; - - // Just set some defaults for these. At some point we need to look at adding a lookup table for common device + headset combos and/or support reading cardboard QR codes - eye_height = 1.85; - intraocular_dist = 6.0; - display_width = 14.5; - display_to_lens = 4.0; - oversample = 1.5; - k1 = 0.215; - k2 = 0.215; - last_ticks = 0; -}; +MobileVRInterface::MobileVRInterface() {} MobileVRInterface::~MobileVRInterface() { // and make sure we cleanup if we haven't already diff --git a/modules/mobile_vr/mobile_vr_interface.h b/modules/mobile_vr/mobile_vr_interface.h index 1afa6c39b6..d28c2196af 100644 --- a/modules/mobile_vr/mobile_vr_interface.h +++ b/modules/mobile_vr/mobile_vr_interface.h @@ -51,19 +51,21 @@ class MobileVRInterface : public XRInterface { GDCLASS(MobileVRInterface, XRInterface); private: - bool initialized; + bool initialized = false; Basis orientation; - float eye_height; - uint64_t last_ticks; - real_t intraocular_dist; - real_t display_width; - real_t display_to_lens; - real_t oversample; + // Just set some defaults for these. At some point we need to look at adding a lookup table for common device + headset combos and/or support reading cardboard QR codes + float eye_height = 1.85; + uint64_t last_ticks = 0; + + real_t intraocular_dist = 6.0; + real_t display_width = 14.5; + real_t display_to_lens = 4.0; + real_t oversample = 1.5; //@TODO not yet used, these are needed in our distortion shader... - real_t k1; - real_t k2; + real_t k1 = 0.215; + real_t k2 = 0.215; /* logic for processing our sensor data, this was originally in our positional tracker logic but I think @@ -73,9 +75,9 @@ private: Vector3 scale_magneto(const Vector3 &p_magnetometer); Basis combine_acc_mag(const Vector3 &p_grav, const Vector3 &p_magneto); - int mag_count; - bool has_gyro; - bool sensor_first; + int mag_count = 0; + bool has_gyro = false; + bool sensor_first = false; Vector3 last_accerometer_data; Vector3 last_magnetometer_data; Vector3 mag_current_min; diff --git a/modules/mono/mono_gd/gd_mono_log.cpp b/modules/mono/mono_gd/gd_mono_log.cpp index e1d283242c..dafd36c36b 100644 --- a/modules/mono/mono_gd/gd_mono_log.cpp +++ b/modules/mono/mono_gd/gd_mono_log.cpp @@ -189,8 +189,6 @@ void GDMonoLog::initialize() { GDMonoLog::GDMonoLog() { singleton = this; - - log_level_id = -1; } GDMonoLog::~GDMonoLog() { diff --git a/modules/mono/mono_gd/gd_mono_log.h b/modules/mono/mono_gd/gd_mono_log.h index 9a95e3cb0a..f7a53156ab 100644 --- a/modules/mono/mono_gd/gd_mono_log.h +++ b/modules/mono/mono_gd/gd_mono_log.h @@ -46,9 +46,9 @@ class GDMonoLog { #ifdef GD_MONO_LOG_ENABLED - int log_level_id; + int log_level_id = -1; - FileAccess *log_file; + FileAccess *log_file = nullptr; String log_file_path; bool _try_create_logs_dir(const String &p_logs_dir); diff --git a/modules/opensimplex/noise_texture.cpp b/modules/opensimplex/noise_texture.cpp index 30a0ca3464..98381ca144 100644 --- a/modules/opensimplex/noise_texture.cpp +++ b/modules/opensimplex/noise_texture.cpp @@ -33,15 +33,6 @@ #include "core/core_string_names.h" NoiseTexture::NoiseTexture() { - update_queued = false; - regen_queued = false; - first_time = true; - - size = Vector2i(512, 512); - seamless = false; - as_normal_map = false; - bump_strength = 8.0; - noise = Ref<OpenSimplexNoise>(); _queue_update(); diff --git a/modules/opensimplex/noise_texture.h b/modules/opensimplex/noise_texture.h index 170275bd2e..e89479d962 100644 --- a/modules/opensimplex/noise_texture.h +++ b/modules/opensimplex/noise_texture.h @@ -47,18 +47,18 @@ private: Thread noise_thread; - bool first_time; - bool update_queued; - bool regen_queued; + bool first_time = true; + bool update_queued = false; + bool regen_queued = false; mutable RID texture; - uint32_t flags; + uint32_t flags = 0; Ref<OpenSimplexNoise> noise; - Vector2i size; - bool seamless; - bool as_normal_map; - float bump_strength; + Vector2i size = Vector2i(512, 512); + bool seamless = false; + bool as_normal_map = false; + float bump_strength = 8.0; void _thread_done(const Ref<Image> &p_image); static void _thread_function(void *p_ud); diff --git a/modules/opensimplex/open_simplex_noise.cpp b/modules/opensimplex/open_simplex_noise.cpp index a823bcf3b8..3773946112 100644 --- a/modules/opensimplex/open_simplex_noise.cpp +++ b/modules/opensimplex/open_simplex_noise.cpp @@ -33,12 +33,6 @@ #include "core/core_string_names.h" OpenSimplexNoise::OpenSimplexNoise() { - seed = 0; - persistence = 0.5; - octaves = 3; - period = 64; - lacunarity = 2.0; - _init_seeds(); } diff --git a/modules/opensimplex/open_simplex_noise.h b/modules/opensimplex/open_simplex_noise.h index f18dd4d798..847c157409 100644 --- a/modules/opensimplex/open_simplex_noise.h +++ b/modules/opensimplex/open_simplex_noise.h @@ -48,11 +48,11 @@ class OpenSimplexNoise : public Resource { osn_context contexts[MAX_OCTAVES]; - int seed; - float persistence; // Controls details, value in [0,1]. Higher increases grain, lower increases smoothness. - int octaves; // Number of noise layers - float period; // Distance above which we start to see similarities. The higher, the longer "hills" will be on a terrain. - float lacunarity; // Controls period change across octaves. 2 is usually a good value to address all detail levels. + int seed = 0; + float persistence = 0.5; // Controls details, value in [0,1]. Higher increases grain, lower increases smoothness. + int octaves = 3; // Number of noise layers + float period = 64.0; // Distance above which we start to see similarities. The higher, the longer "hills" will be on a terrain. + float lacunarity = 2.0; // Controls period change across octaves. 2 is usually a good value to address all detail levels. public: OpenSimplexNoise(); diff --git a/modules/pvr/texture_loader_pvr.cpp b/modules/pvr/texture_loader_pvr.cpp index 70a3c8b5a9..056a923a2d 100644 --- a/modules/pvr/texture_loader_pvr.cpp +++ b/modules/pvr/texture_loader_pvr.cpp @@ -207,7 +207,7 @@ ResourceFormatPVR::ResourceFormatPVR() { struct PVRTCBlock { //blocks are 64 bits - uint32_t data[2]; + uint32_t data[2] = {}; }; _FORCE_INLINE_ bool is_po2(uint32_t p_input) { diff --git a/modules/regex/regex.cpp b/modules/regex/regex.cpp index fe8136ef35..6bae12e7e6 100644 --- a/modules/regex/regex.cpp +++ b/modules/regex/regex.cpp @@ -365,12 +365,10 @@ Array RegEx::get_names() const { RegEx::RegEx() { general_ctx = pcre2_general_context_create_32(&_regex_malloc, &_regex_free, nullptr); - code = nullptr; } RegEx::RegEx(const String &p_pattern) { general_ctx = pcre2_general_context_create_32(&_regex_malloc, &_regex_free, nullptr); - code = nullptr; compile(p_pattern); } diff --git a/modules/regex/regex.h b/modules/regex/regex.h index 46505855d7..f5773042fb 100644 --- a/modules/regex/regex.h +++ b/modules/regex/regex.h @@ -42,8 +42,8 @@ class RegExMatch : public Reference { GDCLASS(RegExMatch, Reference); struct Range { - int start; - int end; + int start = 0; + int end = 0; }; String subject; @@ -72,7 +72,7 @@ class RegEx : public Reference { GDCLASS(RegEx, Reference); void *general_ctx; - void *code; + void *code = nullptr; String pattern; void _pattern_info(uint32_t what, void *where) const; diff --git a/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp b/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp index 4b2be47e74..f7bf650354 100644 --- a/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp +++ b/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp @@ -263,16 +263,7 @@ void AudioStreamOGGVorbis::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "loop_offset"), "set_loop_offset", "get_loop_offset"); } -AudioStreamOGGVorbis::AudioStreamOGGVorbis() { - data = nullptr; - data_len = 0; - length = 0; - sample_rate = 1; - channels = 1; - loop_offset = 0; - decode_mem_size = 0; - loop = false; -} +AudioStreamOGGVorbis::AudioStreamOGGVorbis() {} AudioStreamOGGVorbis::~AudioStreamOGGVorbis() { clear_data(); diff --git a/modules/stb_vorbis/audio_stream_ogg_vorbis.h b/modules/stb_vorbis/audio_stream_ogg_vorbis.h index efc8fc6c27..2bd70a2722 100644 --- a/modules/stb_vorbis/audio_stream_ogg_vorbis.h +++ b/modules/stb_vorbis/audio_stream_ogg_vorbis.h @@ -41,11 +41,11 @@ class AudioStreamOGGVorbis; class AudioStreamPlaybackOGGVorbis : public AudioStreamPlaybackResampled { GDCLASS(AudioStreamPlaybackOGGVorbis, AudioStreamPlaybackResampled); - stb_vorbis *ogg_stream; + stb_vorbis *ogg_stream = nullptr; stb_vorbis_alloc ogg_alloc; - uint32_t frames_mixed; - bool active; - int loops; + uint32_t frames_mixed = 0; + bool active = false; + int loops = 0; friend class AudioStreamOGGVorbis; @@ -76,15 +76,15 @@ class AudioStreamOGGVorbis : public AudioStream { friend class AudioStreamPlaybackOGGVorbis; - void *data; - uint32_t data_len; + void *data = nullptr; + uint32_t data_len = 0; - int decode_mem_size; - float sample_rate; - int channels; - float length; - bool loop; - float loop_offset; + int decode_mem_size = 0; + float sample_rate = 1.0; + int channels = 1; + float length = 0.0; + bool loop = false; + float loop_offset = 0.0; void clear_data(); protected: diff --git a/modules/text_server_adv/bitmap_font_adv.cpp b/modules/text_server_adv/bitmap_font_adv.cpp index 51cc242348..df771301e6 100644 --- a/modules/text_server_adv/bitmap_font_adv.cpp +++ b/modules/text_server_adv/bitmap_font_adv.cpp @@ -36,7 +36,7 @@ struct hb_bmp_font_t { BitmapFontDataAdvanced *face = nullptr; - float font_size = 0; + float font_size = 0.0; bool unref = false; /* Whether to destroy bm_face when done. */ }; @@ -340,7 +340,7 @@ Error BitmapFontDataAdvanced::load_from_file(const String &p_filename, int p_bas char_map[idx] = c; } else if (type == "kerning") { KerningPairKey kpk; - float k = 0; + float k = 0.0; if (keys.has("first")) { kpk.A = keys["first"].to_int(); } diff --git a/modules/text_server_adv/dynamic_font_adv.h b/modules/text_server_adv/dynamic_font_adv.h index c35dd9390b..cd538cb8e1 100644 --- a/modules/text_server_adv/dynamic_font_adv.h +++ b/modules/text_server_adv/dynamic_font_adv.h @@ -74,14 +74,11 @@ private: uint32_t size : 16; uint32_t outline_size : 16; }; - uint32_t key; + uint32_t key = 0; }; bool operator<(CacheID right) const { return key < right.key; } - CacheID() { - key = 0; - } }; struct DataAtSize { @@ -91,10 +88,10 @@ private: int size = 0; float scale_color_font = 1.f; - float ascent = 0; - float descent = 0; - float underline_position = 0; - float underline_thickness = 0; + float ascent = 0.0; + float descent = 0.0; + float underline_position = 0.0; + float underline_thickness = 0.0; Vector<CharTexture> textures; HashMap<uint32_t, Character> glyph_map; diff --git a/modules/text_server_adv/script_iterator.h b/modules/text_server_adv/script_iterator.h index ad476f7c75..896a0e5c15 100644 --- a/modules/text_server_adv/script_iterator.h +++ b/modules/text_server_adv/script_iterator.h @@ -45,9 +45,9 @@ class ScriptIterator { public: struct ScriptRange { - int start; - int end; - hb_script_t script; + int start = 0; + int end = 0; + hb_script_t script = HB_SCRIPT_COMMON; }; Vector<ScriptRange> script_ranges; diff --git a/modules/text_server_fb/bitmap_font_fb.cpp b/modules/text_server_fb/bitmap_font_fb.cpp index 6bc838bd6a..c9a9cc6eba 100644 --- a/modules/text_server_fb/bitmap_font_fb.cpp +++ b/modules/text_server_fb/bitmap_font_fb.cpp @@ -148,7 +148,7 @@ Error BitmapFontDataFallback::load_from_file(const String &p_filename, int p_bas char_map[idx] = c; } else if (type == "kerning") { KerningPairKey kpk; - float k = 0; + float k = 0.0; if (keys.has("first")) { kpk.A = keys["first"].to_int(); } diff --git a/modules/text_server_fb/dynamic_font_fb.h b/modules/text_server_fb/dynamic_font_fb.h index f1cd758f2c..81b18f6af3 100644 --- a/modules/text_server_fb/dynamic_font_fb.h +++ b/modules/text_server_fb/dynamic_font_fb.h @@ -70,14 +70,11 @@ private: uint32_t size : 16; uint32_t outline_size : 16; }; - uint32_t key; + uint32_t key = 0; }; bool operator<(CacheID right) const { return key < right.key; } - CacheID() { - key = 0; - } }; struct DataAtSize { @@ -86,10 +83,10 @@ private: int size = 0; float scale_color_font = 1.f; - float ascent = 0; - float descent = 0; - float underline_position = 0; - float underline_thickness = 0; + float ascent = 0.0; + float descent = 0.0; + float underline_position = 0.0; + float underline_thickness = 0.0; Vector<CharTexture> textures; HashMap<char32_t, Character> char_map; diff --git a/modules/tga/image_loader_tga.h b/modules/tga/image_loader_tga.h index bbfc3fed32..cb2ce07edd 100644 --- a/modules/tga/image_loader_tga.h +++ b/modules/tga/image_loader_tga.h @@ -57,20 +57,20 @@ class ImageLoaderTGA : public ImageFormatLoader { }; struct tga_header_s { - uint8_t id_length; - uint8_t color_map_type; + uint8_t id_length = 0; + uint8_t color_map_type = 0; tga_type_e image_type; - uint16_t first_color_entry; - uint16_t color_map_length; - uint8_t color_map_depth; + uint16_t first_color_entry = 0; + uint16_t color_map_length = 0; + uint8_t color_map_depth = 0; - uint16_t x_origin; - uint16_t y_origin; - uint16_t image_width; - uint16_t image_height; - uint8_t pixel_depth; - uint8_t image_descriptor; + uint16_t x_origin = 0; + uint16_t y_origin = 0; + uint16_t image_width = 0; + uint16_t image_height = 0; + uint8_t pixel_depth = 0; + uint8_t image_descriptor = 0; }; static Error decode_tga_rle(const uint8_t *p_compressed_buffer, size_t p_pixel_size, uint8_t *p_uncompressed_buffer, size_t p_output_size); static Error convert_to_image(Ref<Image> p_image, const uint8_t *p_buffer, const tga_header_s &p_header, const uint8_t *p_palette, const bool p_is_monochrome, size_t p_output_size); diff --git a/modules/theora/video_stream_theora.cpp b/modules/theora/video_stream_theora.cpp index 1026d58b85..afe26d4a5f 100644 --- a/modules/theora/video_stream_theora.cpp +++ b/modules/theora/video_stream_theora.cpp @@ -645,30 +645,13 @@ void VideoStreamPlaybackTheora::_streaming_thread(void *ud) { #endif VideoStreamPlaybackTheora::VideoStreamPlaybackTheora() { - file = nullptr; - theora_p = 0; - vorbis_p = 0; - videobuf_ready = 0; - playing = false; - frames_pending = 0; - videobuf_time = 0; - paused = false; - - buffering = false; texture = Ref<ImageTexture>(memnew(ImageTexture)); - mix_callback = nullptr; - mix_udata = nullptr; - audio_track = 0; - delay_compensation = 0; - audio_frames_wrote = 0; #ifdef THEORA_USE_THREAD_STREAMING int rb_power = nearest_shift(RB_SIZE_KB * 1024); ring_buffer.resize(rb_power); read_buffer.resize(RB_SIZE_KB * 1024); thread_sem = Semaphore::create(); - thread_exit = false; - thread_eof = false; #endif }; diff --git a/modules/theora/video_stream_theora.h b/modules/theora/video_stream_theora.h index c315d682da..71e56e2ee8 100644 --- a/modules/theora/video_stream_theora.h +++ b/modules/theora/video_stream_theora.h @@ -52,12 +52,12 @@ class VideoStreamPlaybackTheora : public VideoStreamPlayback { }; //Image frames[MAX_FRAMES]; - Image::Format format; + Image::Format format = Image::Format::FORMAT_L8; Vector<uint8_t> frame_data; - int frames_pending; - FileAccess *file; + int frames_pending = 0; + FileAccess *file = nullptr; String file_name; - int audio_frames_wrote; + int audio_frames_wrote = 0; Point2i size; int buffer_data(); @@ -65,8 +65,8 @@ class VideoStreamPlaybackTheora : public VideoStreamPlayback { void video_write(); float get_time() const; - bool theora_eos; - bool vorbis_eos; + bool theora_eos = false; + bool vorbis_eos = false; ogg_sync_state oy; ogg_page og; @@ -74,33 +74,33 @@ class VideoStreamPlaybackTheora : public VideoStreamPlayback { ogg_stream_state to; th_info ti; th_comment tc; - th_dec_ctx *td; + th_dec_ctx *td = nullptr; vorbis_info vi; vorbis_dsp_state vd; vorbis_block vb; vorbis_comment vc; th_pixel_fmt px_fmt; - double videobuf_time; - int pp_inc; + double videobuf_time = 0; + int pp_inc = 0; - int theora_p; - int vorbis_p; - int pp_level_max; - int pp_level; - int videobuf_ready; + int theora_p = 0; + int vorbis_p = 0; + int pp_level_max = 0; + int pp_level = 0; + int videobuf_ready = 0; - bool playing; - bool buffering; + bool playing = false; + bool buffering = false; - double last_update_time; - double time; - double delay_compensation; + double last_update_time = 0; + double time = 0; + double delay_compensation = 0; Ref<ImageTexture> texture; AudioMixCallback mix_callback; - void *mix_udata; - bool paused; + void *mix_udata = nullptr; + bool paused = false; #ifdef THEORA_USE_THREAD_STREAMING @@ -110,16 +110,16 @@ class VideoStreamPlaybackTheora : public VideoStreamPlayback { RingBuffer<uint8_t> ring_buffer; Vector<uint8_t> read_buffer; - bool thread_eof; + bool thread_eof = false; Semaphore *thread_sem; Thread thread; - volatile bool thread_exit; + volatile bool thread_exit = false; static void _streaming_thread(void *ud); #endif - int audio_track; + int audio_track = 0; protected: void clear(); diff --git a/modules/upnp/upnp.cpp b/modules/upnp/upnp.cpp index 8c3be884bd..cff13251ce 100644 --- a/modules/upnp/upnp.cpp +++ b/modules/upnp/upnp.cpp @@ -393,9 +393,6 @@ void UPNP::_bind_methods() { } UPNP::UPNP() { - discover_multicast_if = ""; - discover_local_port = 0; - discover_ipv6 = false; } UPNP::~UPNP() { diff --git a/modules/upnp/upnp.h b/modules/upnp/upnp.h index 9dfa907476..a0cca96bc8 100644 --- a/modules/upnp/upnp.h +++ b/modules/upnp/upnp.h @@ -41,9 +41,9 @@ class UPNP : public Reference { GDCLASS(UPNP, Reference); private: - String discover_multicast_if; - int discover_local_port; - bool discover_ipv6; + String discover_multicast_if = ""; + int discover_local_port = 0; + bool discover_ipv6 = false; Vector<Ref<UPNPDevice>> devices; diff --git a/modules/visual_script/visual_script.cpp b/modules/visual_script/visual_script.cpp index fe92f59179..2517b17168 100644 --- a/modules/visual_script/visual_script.cpp +++ b/modules/visual_script/visual_script.cpp @@ -137,7 +137,6 @@ Ref<VisualScript> VisualScriptNode::get_visual_script() const { } VisualScriptNode::VisualScriptNode() { - breakpoint = false; } //////////////// @@ -145,8 +144,6 @@ VisualScriptNode::VisualScriptNode() { ///////////////////// VisualScriptNodeInstance::VisualScriptNodeInstance() { - sequence_outputs = nullptr; - input_ports = nullptr; } VisualScriptNodeInstance::~VisualScriptNodeInstance() { @@ -2623,14 +2620,8 @@ void VisualScriptLanguage::get_registered_node_names(List<String> *r_names) { } VisualScriptLanguage::VisualScriptLanguage() { - notification = "_notification"; - _step = "_step"; - _subcall = "_subcall"; singleton = this; - _debug_parse_err_node = -1; - _debug_parse_err_file = ""; - _debug_call_stack_pos = 0; int dmcs = GLOBAL_DEF("debug/settings/visual_script/max_call_stack", 1024); ProjectSettings::get_singleton()->set_custom_property_info("debug/settings/visual_script/max_call_stack", PropertyInfo(Variant::INT, "debug/settings/visual_script/max_call_stack", PROPERTY_HINT_RANGE, "1024,4096,1,or_greater")); //minimum is 1024 diff --git a/modules/visual_script/visual_script.h b/modules/visual_script/visual_script.h index bdb3c3a16b..72362e0ef4 100644 --- a/modules/visual_script/visual_script.h +++ b/modules/visual_script/visual_script.h @@ -49,7 +49,7 @@ class VisualScriptNode : public Resource { Ref<VisualScript> script_used; Array default_input_values; - bool breakpoint; + bool breakpoint = false; void _set_default_input_values(Array p_values); Array _get_default_input_values() const; @@ -90,13 +90,9 @@ public: virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) = 0; struct TypeGuess { - Variant::Type type; + Variant::Type type = Variant::NIL; StringName gdclass; Ref<Script> script; - - TypeGuess() { - type = Variant::NIL; - } }; virtual TypeGuess guess_output_type(TypeGuess *p_inputs, int p_output) const; @@ -114,19 +110,19 @@ class VisualScriptNodeInstance { INPUT_DEFAULT_VALUE_BIT = INPUT_SHIFT, // from unassigned input port, using default value (edited by user) }; - int id; - int sequence_index; - VisualScriptNodeInstance **sequence_outputs; - int sequence_output_count; + int id = 0; + int sequence_index = 0; + VisualScriptNodeInstance **sequence_outputs = nullptr; + int sequence_output_count = 0; Vector<VisualScriptNodeInstance *> dependencies; - int *input_ports; - int input_port_count; - int *output_ports; - int output_port_count; - int working_mem_idx; - int pass_idx; + int *input_ports = nullptr; + int input_port_count = 0; + int *output_ports = nullptr; + int output_port_count = 0; + int working_mem_idx = 0; + int pass_idx = 0; - VisualScriptNode *base; + VisualScriptNode *base = nullptr; public: enum StartMode { @@ -178,7 +174,7 @@ public: uint64_t from_output : 16; uint64_t to_node : 24; }; - uint64_t id; + uint64_t id = 0; }; bool operator<(const SequenceConnection &p_connection) const { @@ -194,7 +190,7 @@ public: uint64_t to_node : 24; uint64_t to_port : 8; }; - uint64_t id; + uint64_t id = 0; }; bool operator<(const DataConnection &p_connection) const { @@ -208,7 +204,7 @@ private: StringName base_type; struct Argument { String name; - Variant::Type type; + Variant::Type type = Variant::Type::NIL; }; struct NodeData { @@ -231,7 +227,7 @@ private: struct Variable { PropertyInfo info; Variant default_value; - bool _export; + bool _export = false; // Add getter & setter options here. }; @@ -388,26 +384,27 @@ public: }; class VisualScriptInstance : public ScriptInstance { - Object *owner; + Object *owner = nullptr; Ref<VisualScript> script; Map<StringName, Variant> variables; // Using variable path, not script. Map<int, VisualScriptNodeInstance *> instances; struct Function { - int node; - int max_stack; - int trash_pos; - int flow_stack_size; - int pass_stack_size; - int node_count; - int argument_count; + int node = 0; + int max_stack = 0; + int trash_pos = 0; + int flow_stack_size = 0; + int pass_stack_size = 0; + int node_count = 0; + int argument_count = 0; }; Map<StringName, Function> functions; Vector<Variant> default_values; - int max_input_args, max_output_args; + int max_input_args = 0; + int max_output_args = 0; StringName source; @@ -479,14 +476,14 @@ class VisualScriptFunctionState : public Reference { ObjectID instance_id; ObjectID script_id; - VisualScriptInstance *instance; + VisualScriptInstance *instance = nullptr; StringName function; Vector<uint8_t> stack; - int working_mem_index; - int variant_stack_size; - VisualScriptNodeInstance *node; - int flow_stack_pos; - int pass; + int working_mem_index = 0; + int variant_stack_size = 0; + VisualScriptNodeInstance *node = nullptr; + int flow_stack_pos = 0; + int pass = 0; Variant _signal_callback(const Variant **p_args, int p_argcount, Callable::CallError &r_error); @@ -507,25 +504,25 @@ class VisualScriptLanguage : public ScriptLanguage { Map<String, VisualScriptNodeRegisterFunc> register_funcs; struct CallLevel { - Variant *stack; - Variant **work_mem; - const StringName *function; - VisualScriptInstance *instance; - int *current_id; + Variant *stack = nullptr; + Variant **work_mem = nullptr; + const StringName *function = nullptr; + VisualScriptInstance *instance = nullptr; + int *current_id = nullptr; }; - int _debug_parse_err_node; - String _debug_parse_err_file; + int _debug_parse_err_node = -1; + String _debug_parse_err_file = ""; String _debug_error; - int _debug_call_stack_pos; + int _debug_call_stack_pos = 0; int _debug_max_call_stack; CallLevel *_call_stack; public: - StringName notification; + StringName notification = "_notification"; StringName _get_output_port_unsequenced; - StringName _step; - StringName _subcall; + StringName _step = "_step"; + StringName _subcall = "_subcall"; static VisualScriptLanguage *singleton; diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp index 78e4a7f113..92b83f3db0 100644 --- a/modules/visual_script/visual_script_editor.cpp +++ b/modules/visual_script/visual_script_editor.cpp @@ -3689,16 +3689,23 @@ void VisualScriptEditor::_comment_node_resized(const Vector2 &p_new_size, int p_ return; } + Vector2 new_size = p_new_size; + if (graph->is_using_snap()) { + Vector2 snap = Vector2(graph->get_snap(), graph->get_snap()); + Vector2 min_size = (gn->get_minimum_size() + (snap * 0.5)).snapped(snap); + new_size = new_size.snapped(snap).max(min_size); + } + updating_graph = true; graph->set_block_minimum_size_adjust(true); //faster resize undo_redo->create_action(TTR("Resize Comment"), UndoRedo::MERGE_ENDS); - undo_redo->add_do_method(vsc.ptr(), "set_size", p_new_size / EDSCALE); + undo_redo->add_do_method(vsc.ptr(), "set_size", new_size / EDSCALE); undo_redo->add_undo_method(vsc.ptr(), "set_size", vsc->get_size()); undo_redo->commit_action(); - gn->set_custom_minimum_size(p_new_size); + gn->set_custom_minimum_size(new_size); gn->set_size(Size2(1, 1)); graph->set_block_minimum_size_adjust(false); updating_graph = false; diff --git a/modules/visual_script/visual_script_expression.cpp b/modules/visual_script/visual_script_expression.cpp index 9596fda95c..469367ab59 100644 --- a/modules/visual_script/visual_script_expression.cpp +++ b/modules/visual_script/visual_script_expression.cpp @@ -1507,12 +1507,6 @@ VisualScriptNodeInstance *VisualScriptExpression::instance(VisualScriptInstance } VisualScriptExpression::VisualScriptExpression() { - output_type = Variant::NIL; - expression_dirty = true; - error_set = true; - root = nullptr; - nodes = nullptr; - sequenced = false; } VisualScriptExpression::~VisualScriptExpression() { diff --git a/modules/visual_script/visual_script_expression.h b/modules/visual_script/visual_script_expression.h index 7fe665769d..bbf76cef3b 100644 --- a/modules/visual_script/visual_script_expression.h +++ b/modules/visual_script/visual_script_expression.h @@ -39,20 +39,18 @@ class VisualScriptExpression : public VisualScriptNode { friend class VisualScriptNodeInstanceExpression; struct Input { - Variant::Type type; + Variant::Type type = Variant::NIL; String name; - - Input() { type = Variant::NIL; } }; Vector<Input> inputs; - Variant::Type output_type; + Variant::Type output_type = Variant::NIL; String expression; - bool sequenced; - int str_ofs; - bool expression_dirty; + bool sequenced = false; + int str_ofs = 0; + bool expression_dirty = true; bool _compile_expression(); @@ -114,7 +112,7 @@ class VisualScriptExpression : public VisualScriptNode { Error _get_token(Token &r_token); String error_str; - bool error_set; + bool error_set = true; struct ENode { enum Type { @@ -131,11 +129,10 @@ class VisualScriptExpression : public VisualScriptNode { TYPE_CALL }; - ENode *next; + ENode *next = nullptr; - Type type; + Type type = Type::TYPE_SELF; - ENode() { next = nullptr; } virtual ~ENode() { if (next) { memdelete(next); @@ -144,17 +141,17 @@ class VisualScriptExpression : public VisualScriptNode { }; struct Expression { - bool is_op; + bool is_op = false; union { Variant::Operator op; - ENode *node; + ENode *node = nullptr; }; }; ENode *_parse_expression(); struct InputNode : public ENode { - int index; + int index = 0; InputNode() { type = TYPE_INPUT; } @@ -168,9 +165,9 @@ class VisualScriptExpression : public VisualScriptNode { }; struct OperatorNode : public ENode { - Variant::Operator op; + Variant::Operator op = Variant::Operator::OP_ADD; - ENode *nodes[2]; + ENode *nodes[2] = { nullptr, nullptr }; OperatorNode() { type = TYPE_OPERATOR; @@ -184,8 +181,8 @@ class VisualScriptExpression : public VisualScriptNode { }; struct IndexNode : public ENode { - ENode *base; - ENode *index; + ENode *base = nullptr; + ENode *index = nullptr; IndexNode() { type = TYPE_INDEX; @@ -193,7 +190,7 @@ class VisualScriptExpression : public VisualScriptNode { }; struct NamedIndexNode : public ENode { - ENode *base; + ENode *base = nullptr; StringName name; NamedIndexNode() { @@ -202,7 +199,7 @@ class VisualScriptExpression : public VisualScriptNode { }; struct ConstructorNode : public ENode { - Variant::Type data_type; + Variant::Type data_type = Variant::Type::NIL; Vector<ENode *> arguments; ConstructorNode() { @@ -211,7 +208,7 @@ class VisualScriptExpression : public VisualScriptNode { }; struct CallNode : public ENode { - ENode *base; + ENode *base = nullptr; StringName method; Vector<ENode *> arguments; @@ -235,7 +232,7 @@ class VisualScriptExpression : public VisualScriptNode { }; struct BuiltinFuncNode : public ENode { - VisualScriptBuiltinFunc::BuiltinFunc func; + VisualScriptBuiltinFunc::BuiltinFunc func = VisualScriptBuiltinFunc::BuiltinFunc::BYTES_TO_VAR; Vector<ENode *> arguments; BuiltinFuncNode() { type = TYPE_BUILTIN_FUNC; @@ -250,8 +247,8 @@ class VisualScriptExpression : public VisualScriptNode { return node; } - ENode *root; - ENode *nodes; + ENode *root = nullptr; + ENode *nodes = nullptr; protected: bool _set(const StringName &p_name, const Variant &p_value); diff --git a/modules/webrtc/webrtc_data_channel_js.cpp b/modules/webrtc/webrtc_data_channel_js.cpp index 9f2b084cb1..dfbec80c86 100644 --- a/modules/webrtc/webrtc_data_channel_js.cpp +++ b/modules/webrtc/webrtc_data_channel_js.cpp @@ -182,16 +182,9 @@ bool WebRTCDataChannelJS::is_negotiated() const { } WebRTCDataChannelJS::WebRTCDataChannelJS() { - queue_count = 0; - _was_string = false; - _write_mode = WRITE_MODE_BINARY; - _js_id = 0; } WebRTCDataChannelJS::WebRTCDataChannelJS(int js_id) { - queue_count = 0; - _was_string = false; - _write_mode = WRITE_MODE_BINARY; _js_id = js_id; godot_js_rtc_datachannel_connect(js_id, this, &_on_open, &_on_message, &_on_error, &_on_close); diff --git a/modules/webrtc/webrtc_data_channel_js.h b/modules/webrtc/webrtc_data_channel_js.h index 8c56b62303..db58ebccff 100644 --- a/modules/webrtc/webrtc_data_channel_js.h +++ b/modules/webrtc/webrtc_data_channel_js.h @@ -42,16 +42,16 @@ private: String _label; String _protocol; - bool _was_string; - WriteMode _write_mode; + bool _was_string = false; + WriteMode _write_mode = WRITE_MODE_BINARY; enum { PACKET_BUFFER_SIZE = 65536 - 5 // 4 bytes for the size, 1 for for type }; - int _js_id; + int _js_id = 0; RingBuffer<uint8_t> in_buffer; - int queue_count; + int queue_count = 0; uint8_t packet_buffer[PACKET_BUFFER_SIZE]; static void _on_open(void *p_obj); diff --git a/modules/websocket/emws_client.cpp b/modules/websocket/emws_client.cpp index aec01a1eea..25b6d6ef0e 100644 --- a/modules/websocket/emws_client.cpp +++ b/modules/websocket/emws_client.cpp @@ -140,11 +140,7 @@ Error EMWSClient::set_buffers(int p_in_buffer, int p_in_packets, int p_out_buffe } EMWSClient::EMWSClient() { - _in_buf_size = DEF_BUF_SHIFT; - _in_pkt_size = DEF_PKT_SHIFT; - _is_connecting = false; _peer = Ref<EMWSPeer>(memnew(EMWSPeer)); - _js_id = 0; } EMWSClient::~EMWSClient() { diff --git a/modules/websocket/emws_client.h b/modules/websocket/emws_client.h index fdf7a231d2..2ab7dc83d0 100644 --- a/modules/websocket/emws_client.h +++ b/modules/websocket/emws_client.h @@ -41,10 +41,10 @@ class EMWSClient : public WebSocketClient { GDCIIMPL(EMWSClient, WebSocketClient); private: - int _js_id; - bool _is_connecting; - int _in_buf_size; - int _in_pkt_size; + int _js_id = 0; + bool _is_connecting = false; + int _in_buf_size = DEF_BUF_SHIFT; + int _in_pkt_size = DEF_PKT_SHIFT; static void _esws_on_connect(void *obj, char *proto); static void _esws_on_message(void *obj, const uint8_t *p_data, int p_data_size, int p_is_string); diff --git a/modules/websocket/emws_peer.cpp b/modules/websocket/emws_peer.cpp index 496c1edc04..5e75e10d68 100644 --- a/modules/websocket/emws_peer.cpp +++ b/modules/websocket/emws_peer.cpp @@ -106,8 +106,6 @@ void EMWSPeer::set_no_delay(bool p_enabled) { } EMWSPeer::EMWSPeer() { - peer_sock = -1; - write_mode = WRITE_MODE_BINARY; close(); }; diff --git a/modules/websocket/emws_peer.h b/modules/websocket/emws_peer.h index 07f61b62a0..abe5bf2bdb 100644 --- a/modules/websocket/emws_peer.h +++ b/modules/websocket/emws_peer.h @@ -56,12 +56,12 @@ class EMWSPeer : public WebSocketPeer { GDCIIMPL(EMWSPeer, WebSocketPeer); private: - int peer_sock; - WriteMode write_mode; + int peer_sock = -1; + WriteMode write_mode = WRITE_MODE_BINARY; Vector<uint8_t> _packet_buffer; PacketBuffer<uint8_t> _in_buffer; - uint8_t _is_string; + uint8_t _is_string = 0; public: Error read_msg(const uint8_t *p_data, uint32_t p_size, bool p_is_string); diff --git a/modules/websocket/websocket_client.cpp b/modules/websocket/websocket_client.cpp index eb0252e6d1..425013f811 100644 --- a/modules/websocket/websocket_client.cpp +++ b/modules/websocket/websocket_client.cpp @@ -33,7 +33,6 @@ GDCINULL(WebSocketClient); WebSocketClient::WebSocketClient() { - verify_ssl = true; } WebSocketClient::~WebSocketClient() { diff --git a/modules/websocket/websocket_client.h b/modules/websocket/websocket_client.h index 78b77b89cd..0225c9b3d3 100644 --- a/modules/websocket/websocket_client.h +++ b/modules/websocket/websocket_client.h @@ -42,7 +42,7 @@ class WebSocketClient : public WebSocketMultiplayerPeer { protected: Ref<WebSocketPeer> _peer; - bool verify_ssl; + bool verify_ssl = true; Ref<X509Certificate> ssl_cert; static void _bind_methods(); diff --git a/modules/websocket/websocket_multiplayer_peer.cpp b/modules/websocket/websocket_multiplayer_peer.cpp index f94642475c..011cb86535 100644 --- a/modules/websocket/websocket_multiplayer_peer.cpp +++ b/modules/websocket/websocket_multiplayer_peer.cpp @@ -33,15 +33,6 @@ #include "core/os/os.h" WebSocketMultiplayerPeer::WebSocketMultiplayerPeer() { - _is_multiplayer = false; - _peer_id = 0; - _target_peer = 0; - _refusing = false; - - _current_packet.source = 0; - _current_packet.destination = 0; - _current_packet.size = 0; - _current_packet.data = nullptr; } WebSocketMultiplayerPeer::~WebSocketMultiplayerPeer() { diff --git a/modules/websocket/websocket_multiplayer_peer.h b/modules/websocket/websocket_multiplayer_peer.h index e593163b7c..48a6607d89 100644 --- a/modules/websocket/websocket_multiplayer_peer.h +++ b/modules/websocket/websocket_multiplayer_peer.h @@ -55,20 +55,20 @@ protected: }; struct Packet { - int source; - int destination; - uint8_t *data; - uint32_t size; + int source = 0; + int destination = 0; + uint8_t *data = nullptr; + uint32_t size = 0; }; List<Packet> _incoming_packets; Map<int, Ref<WebSocketPeer>> _peer_map; Packet _current_packet; - bool _is_multiplayer; - int _target_peer; - int _peer_id; - int _refusing; + bool _is_multiplayer = false; + int _target_peer = 0; + int _peer_id = 0; + int _refusing = false; static void _bind_methods(); diff --git a/modules/websocket/wsl_client.cpp b/modules/websocket/wsl_client.cpp index 3e2f48e9b3..a075ae3982 100644 --- a/modules/websocket/wsl_client.cpp +++ b/modules/websocket/wsl_client.cpp @@ -337,11 +337,6 @@ Error WSLClient::set_buffers(int p_in_buffer, int p_in_packets, int p_out_buffer } WSLClient::WSLClient() { - _in_buf_size = DEF_BUF_SHIFT; - _in_pkt_size = DEF_PKT_SHIFT; - _out_buf_size = DEF_BUF_SHIFT; - _out_pkt_size = DEF_PKT_SHIFT; - _peer.instance(); _tcp.instance(); disconnect_from_host(); diff --git a/modules/websocket/wsl_client.h b/modules/websocket/wsl_client.h index 8712b57f2c..e7c91ed333 100644 --- a/modules/websocket/wsl_client.h +++ b/modules/websocket/wsl_client.h @@ -44,27 +44,27 @@ class WSLClient : public WebSocketClient { GDCIIMPL(WSLClient, WebSocketClient); private: - int _in_buf_size; - int _in_pkt_size; - int _out_buf_size; - int _out_pkt_size; + int _in_buf_size = DEF_BUF_SHIFT; + int _in_pkt_size = DEF_PKT_SHIFT; + int _out_buf_size = DEF_BUF_SHIFT; + int _out_pkt_size = DEF_PKT_SHIFT; Ref<WSLPeer> _peer; Ref<StreamPeerTCP> _tcp; Ref<StreamPeer> _connection; CharString _request; - int _requested; + int _requested = 0; uint8_t _resp_buf[WSL_MAX_HEADER_SIZE]; - int _resp_pos; + int _resp_pos = 0; String _response; String _key; String _host; Vector<String> _protocols; - bool _use_ssl; + bool _use_ssl = false; void _do_handshake(); bool _verify_headers(String &r_protocol); diff --git a/modules/websocket/wsl_peer.cpp b/modules/websocket/wsl_peer.cpp index 9d016e1139..dbbf86d0da 100644 --- a/modules/websocket/wsl_peer.cpp +++ b/modules/websocket/wsl_peer.cpp @@ -329,10 +329,6 @@ void WSLPeer::invalidate() { } WSLPeer::WSLPeer() { - _data = nullptr; - _is_string = 0; - close_code = -1; - write_mode = WRITE_MODE_BINARY; } WSLPeer::~WSLPeer() { diff --git a/modules/websocket/wsl_peer.h b/modules/websocket/wsl_peer.h index 01efa4b21e..5e6a7e8554 100644 --- a/modules/websocket/wsl_peer.h +++ b/modules/websocket/wsl_peer.h @@ -48,29 +48,17 @@ class WSLPeer : public WebSocketPeer { public: struct PeerData { - bool polling; - bool destroy; - bool valid; - bool is_server; - bool closing; - void *obj; - void *peer; + bool polling = false; + bool destroy = false; + bool valid = false; + bool is_server = false; + bool closing = false; + void *obj = nullptr; + void *peer = nullptr; Ref<StreamPeer> conn; Ref<StreamPeerTCP> tcp; - int id; - wslay_event_context_ptr ctx; - - PeerData() { - polling = false; - destroy = false; - valid = false; - is_server = false; - id = 1; - ctx = nullptr; - obj = nullptr; - closing = false; - peer = nullptr; - } + int id = 1; + wslay_event_context_ptr ctx = nullptr; }; static String compute_key_response(String p_key); @@ -80,17 +68,17 @@ private: static bool _wsl_poll(struct PeerData *p_data); static void _wsl_destroy(struct PeerData **p_data); - struct PeerData *_data; - uint8_t _is_string; + struct PeerData *_data = nullptr; + uint8_t _is_string = 0; // Our packet info is just a boolean (is_string), using uint8_t for it. PacketBuffer<uint8_t> _in_buffer; Vector<uint8_t> _packet_buffer; - WriteMode write_mode; + WriteMode write_mode = WRITE_MODE_BINARY; public: - int close_code; + int close_code = -1; String close_reason; void poll(); // Used by client and server. diff --git a/modules/websocket/wsl_server.cpp b/modules/websocket/wsl_server.cpp index 9df076bf3f..437eb2061b 100644 --- a/modules/websocket/wsl_server.cpp +++ b/modules/websocket/wsl_server.cpp @@ -34,15 +34,6 @@ #include "core/config/project_settings.h" #include "core/os/os.h" -WSLServer::PendingPeer::PendingPeer() { - use_ssl = false; - time = 0; - has_request = false; - response_sent = 0; - req_pos = 0; - memset(req_buf, 0, sizeof(req_buf)); -} - bool WSLServer::PendingPeer::_parse_request(const Vector<String> p_protocols) { Vector<String> psa = String((char *)req_buf).split("\r\n"); int len = psa.size(); @@ -310,10 +301,6 @@ Error WSLServer::set_buffers(int p_in_buffer, int p_in_packets, int p_out_buffer } WSLServer::WSLServer() { - _in_buf_size = DEF_BUF_SHIFT; - _in_pkt_size = DEF_PKT_SHIFT; - _out_buf_size = DEF_BUF_SHIFT; - _out_pkt_size = DEF_PKT_SHIFT; _server.instance(); } diff --git a/modules/websocket/wsl_server.h b/modules/websocket/wsl_server.h index 8b2d4d3a04..75669e12ee 100644 --- a/modules/websocket/wsl_server.h +++ b/modules/websocket/wsl_server.h @@ -53,26 +53,24 @@ private: public: Ref<StreamPeerTCP> tcp; Ref<StreamPeer> connection; - bool use_ssl; + bool use_ssl = false; - int time; - uint8_t req_buf[WSL_MAX_HEADER_SIZE]; - int req_pos; + int time = 0; + uint8_t req_buf[WSL_MAX_HEADER_SIZE] = {}; + int req_pos = 0; String key; String protocol; - bool has_request; + bool has_request = false; CharString response; - int response_sent; - - PendingPeer(); + int response_sent = 0; Error do_handshake(const Vector<String> p_protocols); }; - int _in_buf_size; - int _in_pkt_size; - int _out_buf_size; - int _out_pkt_size; + int _in_buf_size = DEF_BUF_SHIFT; + int _in_pkt_size = DEF_PKT_SHIFT; + int _out_buf_size = DEF_BUF_SHIFT; + int _out_pkt_size = DEF_PKT_SHIFT; List<Ref<PendingPeer>> _pending; Ref<TCP_Server> _server; diff --git a/modules/xatlas_unwrap/register_types.cpp b/modules/xatlas_unwrap/register_types.cpp index 9f6e7efb27..880fe2df61 100644 --- a/modules/xatlas_unwrap/register_types.cpp +++ b/modules/xatlas_unwrap/register_types.cpp @@ -163,8 +163,8 @@ bool xatlas_mesh_lightmap_unwrap_callback(float p_texel_size, const float *p_ver *r_uvs = (float *)malloc(sizeof(float) * output.vertexCount * 2); *r_indices = (int *)malloc(sizeof(int) * output.indexCount); - float max_x = 0; - float max_y = 0; + float max_x = 0.0; + float max_y = 0.0; for (uint32_t i = 0; i < output.vertexCount; i++) { (*r_vertices)[i] = output.vertexArray[i].xref; (*r_uvs)[i * 2 + 0] = output.vertexArray[i].uv[0] / w; diff --git a/platform/linuxbsd/SCsub b/platform/linuxbsd/SCsub index 6e43ffcedb..ddc698a55b 100644 --- a/platform/linuxbsd/SCsub +++ b/platform/linuxbsd/SCsub @@ -18,5 +18,5 @@ common_x11 = [ prog = env.add_program("#bin/godot", ["godot_linuxbsd.cpp"] + common_x11) -if env["debug_symbols"] == "yes" and env["separate_debug_symbols"]: +if env["debug_symbols"] and env["separate_debug_symbols"]: env.AddPostAction(prog, run_in_subprocess(platform_linuxbsd_builders.make_debug_linuxbsd)) diff --git a/platform/linuxbsd/detect.py b/platform/linuxbsd/detect.py index 2141f68725..13d1fe3237 100644 --- a/platform/linuxbsd/detect.py +++ b/platform/linuxbsd/detect.py @@ -92,7 +92,7 @@ def configure(env): else: # optimize for size env.Prepend(CCFLAGS=["-Os"]) - if env["debug_symbols"] == "yes": + if env["debug_symbols"]: env.Prepend(CCFLAGS=["-g2"]) elif env["target"] == "release_debug": @@ -102,7 +102,7 @@ def configure(env): env.Prepend(CCFLAGS=["-Os"]) env.Prepend(CPPDEFINES=["DEBUG_ENABLED"]) - if env["debug_symbols"] == "yes": + if env["debug_symbols"]: env.Prepend(CCFLAGS=["-g2"]) elif env["target"] == "debug": diff --git a/platform/osx/SCsub b/platform/osx/SCsub index aa95a89444..46c13d8550 100644 --- a/platform/osx/SCsub +++ b/platform/osx/SCsub @@ -18,5 +18,5 @@ files = [ prog = env.add_program("#bin/godot", files) -if env["debug_symbols"] == "yes" and env["separate_debug_symbols"]: +if env["debug_symbols"] and env["separate_debug_symbols"]: env.AddPostAction(prog, run_in_subprocess(platform_osx_builders.make_debug_osx)) diff --git a/platform/osx/detect.py b/platform/osx/detect.py index 47ac609917..acea00c5ac 100644 --- a/platform/osx/detect.py +++ b/platform/osx/detect.py @@ -54,7 +54,7 @@ def configure(env): if env["arch"] != "arm64": env.Prepend(CCFLAGS=["-msse2"]) - if env["debug_symbols"] == "yes": + if env["debug_symbols"]: env.Prepend(CCFLAGS=["-g2"]) elif env["target"] == "release_debug": @@ -63,7 +63,7 @@ def configure(env): else: # optimize for size env.Prepend(CCFLAGS=["-Os"]) env.Prepend(CPPDEFINES=["DEBUG_ENABLED"]) - if env["debug_symbols"] == "yes": + if env["debug_symbols"]: env.Prepend(CCFLAGS=["-g2"]) elif env["target"] == "debug": diff --git a/platform/server/detect.py b/platform/server/detect.py index 06042c8e17..1c3fa990fe 100644 --- a/platform/server/detect.py +++ b/platform/server/detect.py @@ -58,7 +58,7 @@ def configure(env): else: # optimize for size env.Prepend(CCFLAGS=["-Os"]) - if env["debug_symbols"] == "yes": + if env["debug_symbols"]: env.Prepend(CCFLAGS=["-g2"]) elif env["target"] == "release_debug": @@ -68,7 +68,7 @@ def configure(env): env.Prepend(CCFLAGS=["-Os"]) env.Prepend(CPPDEFINES=["DEBUG_ENABLED"]) - if env["debug_symbols"] == "yes": + if env["debug_symbols"]: env.Prepend(CCFLAGS=["-g2"]) elif env["target"] == "debug": diff --git a/platform/windows/SCsub b/platform/windows/SCsub index 0c9aa77803..47d8e14680 100644 --- a/platform/windows/SCsub +++ b/platform/windows/SCsub @@ -32,5 +32,5 @@ if env["vsproj"]: env.vs_srcs += ["platform/windows/" + str(x)] if not os.getenv("VCINSTALLDIR"): - if env["debug_symbols"] == "yes" and env["separate_debug_symbols"]: + if env["debug_symbols"] and env["separate_debug_symbols"]: env.AddPostAction(prog, run_in_subprocess(platform_windows_builders.make_debug_mingw)) diff --git a/platform/windows/detect.py b/platform/windows/detect.py index a675a2302f..f26dea8d35 100644 --- a/platform/windows/detect.py +++ b/platform/windows/detect.py @@ -204,12 +204,12 @@ def configure_msvc(env, manual_msvc_config): env.Append(LINKFLAGS=["/OPT:REF"]) elif env["target"] == "debug": - env.AppendUnique(CCFLAGS=["/Z7", "/Od", "/EHsc"]) + env.AppendUnique(CCFLAGS=["/Zi", "/FS", "/Od", "/EHsc"]) env.AppendUnique(CPPDEFINES=["DEBUG_ENABLED"]) env.Append(LINKFLAGS=["/DEBUG"]) - if env["debug_symbols"] == "yes": - env.AppendUnique(CCFLAGS=["/Z7"]) + if env["debug_symbols"]: + env.AppendUnique(CCFLAGS=["/Zi", "/FS"]) env.AppendUnique(LINKFLAGS=["/DEBUG"]) if env["windows_subsystem"] == "gui": @@ -224,6 +224,7 @@ def configure_msvc(env, manual_msvc_config): env.AppendUnique(CCFLAGS=["/MT"]) else: env.AppendUnique(CCFLAGS=["/MD"]) + env.AppendUnique(CCFLAGS=["/Gd", "/GR", "/nologo"]) # Force to use Unicode encoding env.AppendUnique(CCFLAGS=["/utf-8"]) @@ -339,13 +340,13 @@ def configure_mingw(env): else: # optimize for size env.Prepend(CCFLAGS=["-Os"]) - if env["debug_symbols"] == "yes": + if env["debug_symbols"]: env.Prepend(CCFLAGS=["-g2"]) elif env["target"] == "release_debug": env.Append(CCFLAGS=["-O2"]) env.Append(CPPDEFINES=["DEBUG_ENABLED"]) - if env["debug_symbols"] == "yes": + if env["debug_symbols"]: env.Prepend(CCFLAGS=["-g2"]) if env["optimize"] == "speed": # optimize for speed (default) env.Append(CCFLAGS=["-O2"]) diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp index 14e7d395d3..21dfc4ae2c 100644 --- a/platform/windows/display_server_windows.cpp +++ b/platform/windows/display_server_windows.cpp @@ -1784,7 +1784,10 @@ void DisplayServerWindows::_dispatch_input_event(const Ref<InputEvent> &p_event) Ref<InputEventFromWindow> event_from_window = p_event; if (event_from_window.is_valid() && event_from_window->get_window_id() != INVALID_WINDOW_ID) { //send to a window - ERR_FAIL_COND(!windows.has(event_from_window->get_window_id())); + if (!windows.has(event_from_window->get_window_id())) { + in_dispatch_input_event = false; + ERR_FAIL_MSG("DisplayServerWindows: Invalid window id in input event."); + } Callable callable = windows[event_from_window->get_window_id()].input_event_callback; if (callable.is_null()) { in_dispatch_input_event = false; diff --git a/scene/2d/animated_sprite_2d.cpp b/scene/2d/animated_sprite_2d.cpp index d9d551074d..8a6bd5f6b6 100644 --- a/scene/2d/animated_sprite_2d.cpp +++ b/scene/2d/animated_sprite_2d.cpp @@ -712,15 +712,4 @@ void AnimatedSprite2D::_bind_methods() { } AnimatedSprite2D::AnimatedSprite2D() { - centered = true; - hflip = false; - vflip = false; - - frame = 0; - speed_scale = 1.0f; - playing = false; - backwards = false; - animation = "default"; - timeout = 0; - is_over = false; } diff --git a/scene/2d/animated_sprite_2d.h b/scene/2d/animated_sprite_2d.h index a558a3e657..5e53a401e2 100644 --- a/scene/2d/animated_sprite_2d.h +++ b/scene/2d/animated_sprite_2d.h @@ -38,14 +38,9 @@ class SpriteFrames : public Resource { GDCLASS(SpriteFrames, Resource); struct Anim { - float speed; - bool loop; + float speed = 5.0; + bool loop = true; Vector<Ref<Texture2D>> frames; - - Anim() { - loop = true; - speed = 5; - } }; Map<StringName, Anim> animations; @@ -109,20 +104,20 @@ class AnimatedSprite2D : public Node2D { GDCLASS(AnimatedSprite2D, Node2D); Ref<SpriteFrames> frames; - bool playing; - bool backwards; - StringName animation; - int frame; - float speed_scale; + bool playing = false; + bool backwards = false; + StringName animation = "default"; + int frame = 0; + float speed_scale = 1.0f; - bool centered; + bool centered = true; Point2 offset; - bool is_over; - float timeout; + bool is_over = false; + float timeout = 0.0; - bool hflip; - bool vflip; + bool hflip = false; + bool vflip = false; void _res_changed(); diff --git a/scene/2d/area_2d.cpp b/scene/2d/area_2d.cpp index fae893a76c..68d5b4b540 100644 --- a/scene/2d/area_2d.cpp +++ b/scene/2d/area_2d.cpp @@ -627,20 +627,8 @@ void Area2D::_bind_methods() { Area2D::Area2D() : CollisionObject2D(PhysicsServer2D::get_singleton()->area_create(), true) { - space_override = SPACE_OVERRIDE_DISABLED; set_gravity(98); set_gravity_vector(Vector2(0, 1)); - gravity_is_point = false; - gravity_distance_scale = 0; - linear_damp = 0.1; - angular_damp = 1; - locked = false; - priority = 0; - monitoring = false; - monitorable = false; - collision_mask = 1; - collision_layer = 1; - audio_bus_override = false; set_monitoring(true); set_monitorable(true); } diff --git a/scene/2d/area_2d.h b/scene/2d/area_2d.h index 0b45675555..39b022fd2c 100644 --- a/scene/2d/area_2d.h +++ b/scene/2d/area_2d.h @@ -47,19 +47,19 @@ public: }; private: - SpaceOverride space_override; + SpaceOverride space_override = SPACE_OVERRIDE_DISABLED; Vector2 gravity_vec; real_t gravity; - bool gravity_is_point; - real_t gravity_distance_scale; - real_t linear_damp; - real_t angular_damp; - uint32_t collision_mask; - uint32_t collision_layer; - int priority; - bool monitoring; - bool monitorable; - bool locked; + bool gravity_is_point = false; + real_t gravity_distance_scale = 0.0; + real_t linear_damp = 0.1; + real_t angular_damp = 1.0; + uint32_t collision_mask = 1; + uint32_t collision_layer = 1; + int priority = 0; + bool monitoring = false; + bool monitorable = false; + bool locked = false; void _body_inout(int p_status, const RID &p_body, ObjectID p_instance, int p_body_shape, int p_area_shape); @@ -67,8 +67,8 @@ private: void _body_exit_tree(ObjectID p_id); struct ShapePair { - int body_shape; - int area_shape; + int body_shape = 0; + int area_shape = 0; bool operator<(const ShapePair &p_sp) const { if (body_shape == p_sp.body_shape) { return area_shape < p_sp.area_shape; @@ -85,8 +85,8 @@ private: }; struct BodyState { - int rc; - bool in_tree; + int rc = 0; + bool in_tree = false; VSet<ShapePair> shapes; }; @@ -98,8 +98,8 @@ private: void _area_exit_tree(ObjectID p_id); struct AreaShapePair { - int area_shape; - int self_shape; + int area_shape = 0; + int self_shape = 0; bool operator<(const AreaShapePair &p_sp) const { if (area_shape == p_sp.area_shape) { return self_shape < p_sp.self_shape; @@ -116,15 +116,15 @@ private: }; struct AreaState { - int rc; - bool in_tree; + int rc = 0; + bool in_tree = false; VSet<AreaShapePair> shapes; }; Map<ObjectID, AreaState> area_map; void _clear_monitoring(); - bool audio_bus_override; + bool audio_bus_override = false; StringName audio_bus; protected: diff --git a/scene/2d/audio_stream_player_2d.cpp b/scene/2d/audio_stream_player_2d.cpp index f1eb7d017d..ae1c1e449a 100644 --- a/scene/2d/audio_stream_player_2d.cpp +++ b/scene/2d/audio_stream_player_2d.cpp @@ -503,21 +503,6 @@ void AudioStreamPlayer2D::_bind_methods() { } AudioStreamPlayer2D::AudioStreamPlayer2D() { - volume_db = 0; - pitch_scale = 1.0; - autoplay = false; - setseek = -1; - active = false; - output_count = 0; - prev_output_count = 0; - max_distance = 2000; - attenuation = 1; - setplay = -1; - output_ready = false; - area_mask = 1; - stream_paused = false; - stream_paused_fade_in = false; - stream_paused_fade_out = false; AudioServer::get_singleton()->connect("bus_layout_changed", callable_mp(this, &AudioStreamPlayer2D::_bus_layout_changed)); } diff --git a/scene/2d/audio_stream_player_2d.h b/scene/2d/audio_stream_player_2d.h index 4eb709facb..6fb8cc414c 100644 --- a/scene/2d/audio_stream_player_2d.h +++ b/scene/2d/audio_stream_player_2d.h @@ -47,32 +47,32 @@ private: struct Output { AudioFrame vol; - int bus_index; - Viewport *viewport; //pointer only used for reference to previous mix + int bus_index = 0; + Viewport *viewport = nullptr; //pointer only used for reference to previous mix }; Output outputs[MAX_OUTPUTS]; - volatile int output_count; - volatile bool output_ready; + volatile int output_count = 0; + volatile bool output_ready = false; //these are used by audio thread to have a reference of previous volumes (for ramping volume and avoiding clicks) Output prev_outputs[MAX_OUTPUTS]; - int prev_output_count; + int prev_output_count = 0; Ref<AudioStreamPlayback> stream_playback; Ref<AudioStream> stream; Vector<AudioFrame> mix_buffer; - volatile float setseek; - volatile bool active; - volatile float setplay; + volatile float setseek = -1.0; + volatile bool active = false; + volatile float setplay = -1.0; - float volume_db; - float pitch_scale; - bool autoplay; - bool stream_paused; - bool stream_paused_fade_in; - bool stream_paused_fade_out; + float volume_db = 0.0; + float pitch_scale = 1.0; + bool autoplay = false; + bool stream_paused = false; + bool stream_paused_fade_in = false; + bool stream_paused_fade_out = false; StringName bus; void _mix_audio(); @@ -83,10 +83,10 @@ private: void _bus_layout_changed(); - uint32_t area_mask; + uint32_t area_mask = 1; - float max_distance; - float attenuation; + float max_distance = 2000.0; + float attenuation = 1.0; protected: void _validate_property(PropertyInfo &property) const override; diff --git a/scene/2d/back_buffer_copy.cpp b/scene/2d/back_buffer_copy.cpp index 91c887cb84..539a66b881 100644 --- a/scene/2d/back_buffer_copy.cpp +++ b/scene/2d/back_buffer_copy.cpp @@ -93,8 +93,6 @@ void BackBufferCopy::_bind_methods() { } BackBufferCopy::BackBufferCopy() { - rect = Rect2(-100, -100, 200, 200); - copy_mode = COPY_MODE_RECT; _update_copy_mode(); } diff --git a/scene/2d/back_buffer_copy.h b/scene/2d/back_buffer_copy.h index 0916d344f9..6bdb3aaab2 100644 --- a/scene/2d/back_buffer_copy.h +++ b/scene/2d/back_buffer_copy.h @@ -44,8 +44,8 @@ public: }; private: - Rect2 rect; - CopyMode copy_mode; + Rect2 rect = Rect2(-100, -100, 200, 200); + CopyMode copy_mode = COPY_MODE_RECT; void _update_copy_mode(); diff --git a/scene/2d/camera_2d.cpp b/scene/2d/camera_2d.cpp index 4f45325d3a..853e92780b 100644 --- a/scene/2d/camera_2d.cpp +++ b/scene/2d/camera_2d.cpp @@ -749,9 +749,6 @@ void Camera2D::_bind_methods() { } Camera2D::Camera2D() { - anchor_mode = ANCHOR_MODE_DRAG_CENTER; - rotating = false; - current = false; limit[SIDE_LEFT] = -10000000; limit[SIDE_TOP] = -10000000; limit[SIDE_RIGHT] = 10000000; @@ -761,27 +758,6 @@ Camera2D::Camera2D() { drag_margin[SIDE_TOP] = 0.2; drag_margin[SIDE_RIGHT] = 0.2; drag_margin[SIDE_BOTTOM] = 0.2; - camera_pos = Vector2(); - first = true; - smoothing_enabled = false; - limit_smoothing_enabled = false; - custom_viewport = nullptr; - - process_mode = CAMERA2D_PROCESS_IDLE; - - smoothing = 5.0; - zoom = Vector2(1, 1); - - screen_drawing_enabled = true; - limit_drawing_enabled = false; - margin_drawing_enabled = false; - - drag_horizontal_enabled = false; - drag_vertical_enabled = false; - drag_horizontal_offset = 0; - drag_vertical_offset = 0; - drag_horizontal_offset_changed = false; - drag_vertical_offset_changed = false; set_notify_transform(true); } diff --git a/scene/2d/camera_2d.h b/scene/2d/camera_2d.h index 8977d872f0..3a7d01901d 100644 --- a/scene/2d/camera_2d.h +++ b/scene/2d/camera_2d.h @@ -51,32 +51,32 @@ public: protected: Point2 camera_pos; Point2 smoothed_camera_pos; - bool first; + bool first = true; ObjectID custom_viewport_id; // to check validity - Viewport *custom_viewport; - Viewport *viewport; + Viewport *custom_viewport = nullptr; + Viewport *viewport = nullptr; StringName group_name; StringName canvas_group_name; RID canvas; Vector2 offset; - Vector2 zoom; - AnchorMode anchor_mode; - bool rotating; - bool current; - float smoothing; - bool smoothing_enabled; + Vector2 zoom = Vector2(1, 1); + AnchorMode anchor_mode = ANCHOR_MODE_DRAG_CENTER; + bool rotating = false; + bool current = false; + float smoothing = 5.0; + bool smoothing_enabled = false; int limit[4]; - bool limit_smoothing_enabled; + bool limit_smoothing_enabled = false; float drag_margin[4]; - bool drag_horizontal_enabled; - bool drag_vertical_enabled; - float drag_horizontal_offset; - float drag_vertical_offset; - bool drag_horizontal_offset_changed; - bool drag_vertical_offset_changed; + bool drag_horizontal_enabled = false; + bool drag_vertical_enabled = false; + float drag_horizontal_offset = 0.0; + float drag_vertical_offset = 0.0; + bool drag_horizontal_offset_changed = false; + bool drag_vertical_offset_changed = false; Point2 camera_screen_center; void _update_process_mode(); @@ -87,11 +87,11 @@ protected: void _set_old_smoothing(float p_enable); - bool screen_drawing_enabled; - bool limit_drawing_enabled; - bool margin_drawing_enabled; + bool screen_drawing_enabled = true; + bool limit_drawing_enabled = false; + bool margin_drawing_enabled = false; - Camera2DProcessMode process_mode; + Camera2DProcessMode process_mode = CAMERA2D_PROCESS_IDLE; Size2 _get_camera_screen_size() const; diff --git a/scene/2d/canvas_modulate.cpp b/scene/2d/canvas_modulate.cpp index 6e90afde21..5d5aaae505 100644 --- a/scene/2d/canvas_modulate.cpp +++ b/scene/2d/canvas_modulate.cpp @@ -94,7 +94,6 @@ String CanvasModulate::get_configuration_warning() const { } CanvasModulate::CanvasModulate() { - color = Color(1, 1, 1, 1); } CanvasModulate::~CanvasModulate() { diff --git a/scene/2d/canvas_modulate.h b/scene/2d/canvas_modulate.h index 6efc0cab9b..4d55a5d9cb 100644 --- a/scene/2d/canvas_modulate.h +++ b/scene/2d/canvas_modulate.h @@ -36,7 +36,7 @@ class CanvasModulate : public Node2D { GDCLASS(CanvasModulate, Node2D); - Color color; + Color color = Color(1, 1, 1, 1); protected: void _notification(int p_what); diff --git a/scene/2d/collision_object_2d.h b/scene/2d/collision_object_2d.h index 1cfaeaf649..e82b61d441 100644 --- a/scene/2d/collision_object_2d.h +++ b/scene/2d/collision_object_2d.h @@ -37,35 +37,29 @@ class CollisionObject2D : public Node2D { GDCLASS(CollisionObject2D, Node2D); - bool area; + bool area = false; RID rid; - bool pickable; + bool pickable = false; struct ShapeData { - Object *owner; + Object *owner = nullptr; Transform2D xform; struct Shape { Ref<Shape2D> shape; - int index; + int index = 0; }; Vector<Shape> shapes; - bool disabled; - bool one_way_collision; - real_t one_way_collision_margin; - - ShapeData() { - disabled = false; - one_way_collision = false; - one_way_collision_margin = 0; - owner = nullptr; - } + + bool disabled = false; + bool one_way_collision = false; + real_t one_way_collision_margin = 0.0; }; - int total_subshapes; + int total_subshapes = 0; Map<uint32_t, ShapeData> shapes; - bool only_update_transform_changes; //this is used for sync physics in KinematicBody + bool only_update_transform_changes = false; //this is used for sync physics in KinematicBody protected: CollisionObject2D(RID p_rid, bool p_area); diff --git a/scene/2d/collision_polygon_2d.cpp b/scene/2d/collision_polygon_2d.cpp index 505c0beb45..39d7705226 100644 --- a/scene/2d/collision_polygon_2d.cpp +++ b/scene/2d/collision_polygon_2d.cpp @@ -310,12 +310,5 @@ void CollisionPolygon2D::_bind_methods() { } CollisionPolygon2D::CollisionPolygon2D() { - aabb = Rect2(-10, -10, 20, 20); - build_mode = BUILD_SOLIDS; set_notify_local_transform(true); - parent = nullptr; - owner_id = 0; - disabled = false; - one_way_collision = false; - one_way_collision_margin = 1.0; } diff --git a/scene/2d/collision_polygon_2d.h b/scene/2d/collision_polygon_2d.h index 9c9e6f8f62..9df9802629 100644 --- a/scene/2d/collision_polygon_2d.h +++ b/scene/2d/collision_polygon_2d.h @@ -46,14 +46,14 @@ public: }; protected: - Rect2 aabb; - BuildMode build_mode; + Rect2 aabb = Rect2(-10, -10, 20, 20); + BuildMode build_mode = BUILD_SOLIDS; Vector<Point2> polygon; - uint32_t owner_id; - CollisionObject2D *parent; - bool disabled; - bool one_way_collision; - real_t one_way_collision_margin; + uint32_t owner_id = 0; + CollisionObject2D *parent = nullptr; + bool disabled = false; + bool one_way_collision = false; + real_t one_way_collision_margin = 1.0; Vector<Vector<Vector2>> _decompose_in_convex(); diff --git a/scene/2d/collision_shape_2d.cpp b/scene/2d/collision_shape_2d.cpp index 381c2ad29a..4d1d274542 100644 --- a/scene/2d/collision_shape_2d.cpp +++ b/scene/2d/collision_shape_2d.cpp @@ -243,11 +243,5 @@ void CollisionShape2D::_bind_methods() { } CollisionShape2D::CollisionShape2D() { - rect = Rect2(-Point2(10, 10), Point2(20, 20)); set_notify_local_transform(true); - owner_id = 0; - parent = nullptr; - disabled = false; - one_way_collision = false; - one_way_collision_margin = 1.0; } diff --git a/scene/2d/collision_shape_2d.h b/scene/2d/collision_shape_2d.h index 17cc4187c9..695d0c6657 100644 --- a/scene/2d/collision_shape_2d.h +++ b/scene/2d/collision_shape_2d.h @@ -39,13 +39,13 @@ class CollisionObject2D; class CollisionShape2D : public Node2D { GDCLASS(CollisionShape2D, Node2D); Ref<Shape2D> shape; - Rect2 rect; - uint32_t owner_id; - CollisionObject2D *parent; + Rect2 rect = Rect2(-Point2(10, 10), Point2(20, 20)); + uint32_t owner_id = 0; + CollisionObject2D *parent = nullptr; void _shape_changed(); - bool disabled; - bool one_way_collision; - real_t one_way_collision_margin; + bool disabled = false; + bool one_way_collision = false; + real_t one_way_collision_margin = 1.0; void _update_in_shape_owner(bool p_xform_only = false); diff --git a/scene/2d/cpu_particles_2d.cpp b/scene/2d/cpu_particles_2d.cpp index f839e8c304..b34a9a9ea4 100644 --- a/scene/2d/cpu_particles_2d.cpp +++ b/scene/2d/cpu_particles_2d.cpp @@ -1369,34 +1369,14 @@ void CPUParticles2D::_bind_methods() { } CPUParticles2D::CPUParticles2D() { - time = 0; - inactive_time = 0; - frame_remainder = 0; - cycle = 0; - redraw = false; - emitting = false; - mesh = RenderingServer::get_singleton()->mesh_create(); multimesh = RenderingServer::get_singleton()->multimesh_create(); RenderingServer::get_singleton()->multimesh_set_mesh(multimesh, mesh); set_emitting(true); - set_one_shot(false); set_amount(8); - set_lifetime(1); - set_fixed_fps(0); - set_fractional_delta(true); - set_pre_process_time(0); - set_explosiveness_ratio(0); - set_randomness_ratio(0); - set_lifetime_randomness(0); set_use_local_coordinates(true); - set_draw_order(DRAW_ORDER_INDEX); - set_speed_scale(1); - - set_direction(Vector2(1, 0)); - set_spread(45); set_param(PARAM_INITIAL_LINEAR_VELOCITY, 0); set_param(PARAM_ANGULAR_VELOCITY, 0); set_param(PARAM_ORBIT_VELOCITY, 0); @@ -1409,11 +1389,6 @@ CPUParticles2D::CPUParticles2D() { set_param(PARAM_HUE_VARIATION, 0); set_param(PARAM_ANIM_SPEED, 0); set_param(PARAM_ANIM_OFFSET, 0); - set_emission_shape(EMISSION_SHAPE_POINT); - set_emission_sphere_radius(1); - set_emission_rect_extents(Vector2(1, 1)); - - set_gravity(Vector2(0, 98)); for (int i = 0; i < PARAM_MAX; i++) { set_param_randomness(Parameter(i), 0); diff --git a/scene/2d/cpu_particles_2d.h b/scene/2d/cpu_particles_2d.h index 3793f6a418..7ee165b3e1 100644 --- a/scene/2d/cpu_particles_2d.h +++ b/scene/2d/cpu_particles_2d.h @@ -78,31 +78,31 @@ public: }; private: - bool emitting; + bool emitting = false; struct Particle { Transform2D transform; Color color; - float custom[4]; - float rotation; + float custom[4] = {}; + float rotation = 0.0; Vector2 velocity; - bool active; - float angle_rand; - float scale_rand; - float hue_rot_rand; - float anim_offset_rand; - float time; - float lifetime; + bool active = false; + float angle_rand = 0.0; + float scale_rand = 0.0; + float hue_rot_rand = 0.0; + float anim_offset_rand = 0.0; + float time = 0.0; + float lifetime = 0.0; Color base_color; - uint32_t seed; + uint32_t seed = 0; }; - float time; - float inactive_time; - float frame_remainder; - int cycle; - bool redraw; + float time = 0.0; + float inactive_time = 0.0; + float frame_remainder = 0.0; + int cycle = 0; + bool redraw = false; RID mesh; RID multimesh; @@ -112,7 +112,7 @@ private: Vector<int> particle_order; struct SortLifetime { - const Particle *particles; + const Particle *particles = nullptr; bool operator()(int p_a, int p_b) const { return particles[p_a].time > particles[p_b].time; @@ -120,7 +120,7 @@ private: }; struct SortAxis { - const Particle *particles; + const Particle *particles = nullptr; Vector2 axis; bool operator()(int p_a, int p_b) const { return axis.dot(particles[p_a].transform[2]) < axis.dot(particles[p_b].transform[2]); @@ -129,28 +129,28 @@ private: // - bool one_shot; + bool one_shot = false; - float lifetime; - float pre_process_time; - float explosiveness_ratio; - float randomness_ratio; - float lifetime_randomness; - float speed_scale; + float lifetime = 1.0; + float pre_process_time = 0.0; + float explosiveness_ratio = 0.0; + float randomness_ratio = 0.0; + float lifetime_randomness = 0.0; + float speed_scale = 1.0; bool local_coords; - int fixed_fps; - bool fractional_delta; + int fixed_fps = 0; + bool fractional_delta = true; Transform2D inv_emission_transform; - DrawOrder draw_order; + DrawOrder draw_order = DRAW_ORDER_INDEX; Ref<Texture2D> texture; //////// - Vector2 direction; - float spread; + Vector2 direction = Vector2(1, 0); + float spread = 45.0; float parameters[PARAM_MAX]; float randomness[PARAM_MAX]; @@ -161,15 +161,15 @@ private: bool particle_flags[PARTICLE_FLAG_MAX]; - EmissionShape emission_shape; - float emission_sphere_radius; - Vector2 emission_rect_extents; + EmissionShape emission_shape = EMISSION_SHAPE_POINT; + float emission_sphere_radius = 1.0; + Vector2 emission_rect_extents = Vector2(1, 1); Vector<Vector2> emission_points; Vector<Vector2> emission_normals; Vector<Color> emission_colors; - int emission_point_count; + int emission_point_count = 0; - Vector2 gravity; + Vector2 gravity = Vector2(0, 98); void _update_internal(); void _particles_process(float p_delta); diff --git a/scene/2d/joints_2d.cpp b/scene/2d/joints_2d.cpp index 1a31f72a59..80445e7e5d 100644 --- a/scene/2d/joints_2d.cpp +++ b/scene/2d/joints_2d.cpp @@ -249,8 +249,6 @@ void Joint2D::_bind_methods() { } Joint2D::Joint2D() { - bias = 0; - exclude_from_collision = true; } /////////////////////////////////////////////////////////////////////////////// @@ -300,7 +298,6 @@ void PinJoint2D::_bind_methods() { } PinJoint2D::PinJoint2D() { - softness = 0; } /////////////////////////////////////////////////////////////////////////////// @@ -364,8 +361,6 @@ void GrooveJoint2D::_bind_methods() { } GrooveJoint2D::GrooveJoint2D() { - length = 50; - initial_offset = 25; } /////////////////////////////////////////////////////////////////////////////// @@ -467,8 +462,4 @@ void DampedSpringJoint2D::_bind_methods() { } DampedSpringJoint2D::DampedSpringJoint2D() { - length = 50; - rest_length = 0; - stiffness = 20; - damping = 1; } diff --git a/scene/2d/joints_2d.h b/scene/2d/joints_2d.h index d0fbb9fd3a..887155c6ea 100644 --- a/scene/2d/joints_2d.h +++ b/scene/2d/joints_2d.h @@ -43,9 +43,9 @@ class Joint2D : public Node2D { NodePath a; NodePath b; - real_t bias; + real_t bias = 0.0; - bool exclude_from_collision; + bool exclude_from_collision = true; String warning; protected: @@ -80,7 +80,7 @@ public: class PinJoint2D : public Joint2D { GDCLASS(PinJoint2D, Joint2D); - real_t softness; + real_t softness = 0.0; protected: void _notification(int p_what); @@ -97,8 +97,8 @@ public: class GrooveJoint2D : public Joint2D { GDCLASS(GrooveJoint2D, Joint2D); - real_t length; - real_t initial_offset; + real_t length = 50.0; + real_t initial_offset = 25.0; protected: void _notification(int p_what); @@ -118,10 +118,10 @@ public: class DampedSpringJoint2D : public Joint2D { GDCLASS(DampedSpringJoint2D, Joint2D); - real_t stiffness; - real_t damping; - real_t rest_length; - real_t length; + real_t stiffness = 20.0; + real_t damping = 1.0; + real_t rest_length = 0.0; + real_t length = 50.0; protected: void _notification(int p_what); diff --git a/scene/2d/light_2d.cpp b/scene/2d/light_2d.cpp index ba4372f040..c000c8ea19 100644 --- a/scene/2d/light_2d.cpp +++ b/scene/2d/light_2d.cpp @@ -300,22 +300,6 @@ void Light2D::_bind_methods() { Light2D::Light2D() { canvas_light = RenderingServer::get_singleton()->canvas_light_create(); - enabled = true; - editor_only = false; - shadow = false; - color = Color(1, 1, 1); - height = 0; - z_min = -1024; - z_max = 1024; - layer_min = 0; - layer_max = 0; - item_mask = 1; - item_shadow_mask = 1; - energy = 1.0; - shadow_color = Color(0, 0, 0, 0); - shadow_filter = SHADOW_FILTER_NONE; - shadow_smooth = 0; - blend_mode = BLEND_MODE_ADD; set_notify_transform(true); } diff --git a/scene/2d/light_2d.h b/scene/2d/light_2d.h index 0112ab1648..4279baf15b 100644 --- a/scene/2d/light_2d.h +++ b/scene/2d/light_2d.h @@ -52,24 +52,24 @@ public: private: RID canvas_light; - bool enabled; - bool editor_only; - bool shadow; - Color color; - Color shadow_color; - float height; - float energy; - int z_min; - int z_max; - int layer_min; - int layer_max; - int item_mask; - int item_shadow_mask; - float shadow_smooth; + bool enabled = true; + bool editor_only = false; + bool shadow = false; + Color color = Color(1, 1, 1); + Color shadow_color = Color(0, 0, 0, 0); + float height = 0.0; + float energy = 1.0; + int z_min = -1024; + int z_max = 1024; + int layer_min = 0; + int layer_max = 0; + int item_mask = 1; + int item_shadow_mask = 1; + float shadow_smooth = 0.0; Ref<Texture2D> texture; Vector2 texture_offset; - ShadowFilter shadow_filter; - BlendMode blend_mode; + ShadowFilter shadow_filter = SHADOW_FILTER_NONE; + BlendMode blend_mode = BLEND_MODE_ADD; void _update_light_visibility(); diff --git a/scene/2d/light_occluder_2d.cpp b/scene/2d/light_occluder_2d.cpp index 3146e64c08..9589702e2e 100644 --- a/scene/2d/light_occluder_2d.cpp +++ b/scene/2d/light_occluder_2d.cpp @@ -145,9 +145,6 @@ void OccluderPolygon2D::_bind_methods() { OccluderPolygon2D::OccluderPolygon2D() { occ_polygon = RS::get_singleton()->canvas_occluder_polygon_create(); - closed = true; - cull = CULL_DISABLED; - rect_cache_dirty = true; } OccluderPolygon2D::~OccluderPolygon2D() { diff --git a/scene/2d/light_occluder_2d.h b/scene/2d/light_occluder_2d.h index 7944ccad3a..f567c6d965 100644 --- a/scene/2d/light_occluder_2d.h +++ b/scene/2d/light_occluder_2d.h @@ -46,11 +46,11 @@ public: private: RID occ_polygon; Vector<Vector2> polygon; - bool closed; - CullMode cull; + bool closed = true; + CullMode cull = CULL_DISABLED; mutable Rect2 item_rect; - mutable bool rect_cache_dirty; + mutable bool rect_cache_dirty = true; protected: static void _bind_methods(); diff --git a/scene/2d/line_2d.cpp b/scene/2d/line_2d.cpp index 0a3f5673f8..2959ea1a36 100644 --- a/scene/2d/line_2d.cpp +++ b/scene/2d/line_2d.cpp @@ -40,15 +40,6 @@ VARIANT_ENUM_CAST(Line2D::LineCapMode) VARIANT_ENUM_CAST(Line2D::LineTextureMode) Line2D::Line2D() { - _joint_mode = LINE_JOINT_SHARP; - _begin_cap_mode = LINE_CAP_NONE; - _end_cap_mode = LINE_CAP_NONE; - _width = 10; - _default_color = Color(1, 1, 1); - _texture_mode = LINE_TEXTURE_NONE; - _sharp_limit = 2.f; - _round_precision = 8; - _antialiased = false; } #ifdef TOOLS_ENABLED diff --git a/scene/2d/line_2d.h b/scene/2d/line_2d.h index e0b1cea60a..5e7eb4bac9 100644 --- a/scene/2d/line_2d.h +++ b/scene/2d/line_2d.h @@ -124,18 +124,18 @@ private: private: Vector<Vector2> _points; - LineJointMode _joint_mode; - LineCapMode _begin_cap_mode; - LineCapMode _end_cap_mode; - float _width; + LineJointMode _joint_mode = LINE_JOINT_SHARP; + LineCapMode _begin_cap_mode = LINE_CAP_NONE; + LineCapMode _end_cap_mode = LINE_CAP_NONE; + float _width = 10.0; Ref<Curve> _curve; - Color _default_color; + Color _default_color = Color(1, 1, 1); Ref<Gradient> _gradient; Ref<Texture2D> _texture; - LineTextureMode _texture_mode; - float _sharp_limit; - int _round_precision; - bool _antialiased; + LineTextureMode _texture_mode = LINE_TEXTURE_NONE; + float _sharp_limit = 2.f; + int _round_precision = 8; + bool _antialiased = false; }; #endif // LINE2D_H diff --git a/scene/2d/line_builder.cpp b/scene/2d/line_builder.cpp index 5e48a61ff7..892ccadfda 100644 --- a/scene/2d/line_builder.cpp +++ b/scene/2d/line_builder.cpp @@ -94,20 +94,6 @@ static inline Vector2 interpolate(const Rect2 &r, const Vector2 &v) { //---------------------------------------------------------------------------- LineBuilder::LineBuilder() { - joint_mode = Line2D::LINE_JOINT_SHARP; - width = 10; - curve = nullptr; - default_color = Color(0.4, 0.5, 1); - gradient = nullptr; - sharp_limit = 2.f; - round_precision = 8; - begin_cap_mode = Line2D::LINE_CAP_NONE; - end_cap_mode = Line2D::LINE_CAP_NONE; - tile_aspect = 1.f; - - _interpolate_color = false; - _last_index[0] = 0; - _last_index[1] = 0; } void LineBuilder::clear_output() { diff --git a/scene/2d/line_builder.h b/scene/2d/line_builder.h index bd419d330b..654e61422b 100644 --- a/scene/2d/line_builder.h +++ b/scene/2d/line_builder.h @@ -41,17 +41,17 @@ public: // TODO Move in a struct and reference it // Input Vector<Vector2> points; - Line2D::LineJointMode joint_mode; - Line2D::LineCapMode begin_cap_mode; - Line2D::LineCapMode end_cap_mode; - float width; - Curve *curve; - Color default_color; - Gradient *gradient; - Line2D::LineTextureMode texture_mode; - float sharp_limit; - int round_precision; - float tile_aspect; // w/h + Line2D::LineJointMode joint_mode = Line2D::LINE_JOINT_SHARP; + Line2D::LineCapMode begin_cap_mode = Line2D::LINE_CAP_NONE; + Line2D::LineCapMode end_cap_mode = Line2D::LINE_CAP_NONE; + float width = 10.0; + Curve *curve = nullptr; + Color default_color = Color(0.4, 0.5, 1); + Gradient *gradient = nullptr; + Line2D::LineTextureMode texture_mode = Line2D::LineTextureMode::LINE_TEXTURE_NONE; + float sharp_limit = 2.f; + int round_precision = 8; + float tile_aspect = 1.f; // w/h // TODO offset_joints option (offers alternative implementation of round joints) // TODO Move in a struct and reference it @@ -82,8 +82,8 @@ private: void new_arc(Vector2 center, Vector2 vbegin, float angle_delta, Color color, Rect2 uv_rect); private: - bool _interpolate_color; - int _last_index[2]; // Index of last up and down vertices of the strip + bool _interpolate_color = false; + int _last_index[2] = {}; // Index of last up and down vertices of the strip }; #endif // LINE_BUILDER_H diff --git a/scene/2d/node_2d.h b/scene/2d/node_2d.h index a5ae5dae0e..c27d740b8a 100644 --- a/scene/2d/node_2d.h +++ b/scene/2d/node_2d.h @@ -37,9 +37,9 @@ class Node2D : public CanvasItem { GDCLASS(Node2D, CanvasItem); Point2 pos; - float angle = 0; + float angle = 0.0; Size2 _scale = Vector2(1, 1); - float skew = 0; + float skew = 0.0; int z_index = 0; bool z_relative = true; diff --git a/scene/2d/parallax_background.cpp b/scene/2d/parallax_background.cpp index a35ffaa668..c93915d1bc 100644 --- a/scene/2d/parallax_background.cpp +++ b/scene/2d/parallax_background.cpp @@ -185,9 +185,5 @@ void ParallaxBackground::_bind_methods() { } ParallaxBackground::ParallaxBackground() { - scale = 1.0; set_layer(-100); //behind all by default - - base_scale = Vector2(1, 1); - ignore_camera_zoom = false; } diff --git a/scene/2d/parallax_background.h b/scene/2d/parallax_background.h index 578e615be9..c9991efc9d 100644 --- a/scene/2d/parallax_background.h +++ b/scene/2d/parallax_background.h @@ -39,15 +39,15 @@ class ParallaxBackground : public CanvasLayer { GDCLASS(ParallaxBackground, CanvasLayer); Point2 offset; - float scale; + float scale = 1.0; Point2 base_offset; - Point2 base_scale; + Point2 base_scale = Vector2(1, 1); Point2 screen_offset; String group_name; Point2 limit_begin; Point2 limit_end; Point2 final_offset; - bool ignore_camera_zoom; + bool ignore_camera_zoom = false; void _update_scroll(); diff --git a/scene/2d/parallax_layer.cpp b/scene/2d/parallax_layer.cpp index 129082cb91..a38338e1e3 100644 --- a/scene/2d/parallax_layer.cpp +++ b/scene/2d/parallax_layer.cpp @@ -163,5 +163,4 @@ void ParallaxLayer::_bind_methods() { } ParallaxLayer::ParallaxLayer() { - motion_scale = Size2(1, 1); } diff --git a/scene/2d/parallax_layer.h b/scene/2d/parallax_layer.h index b6895b0aca..86694c7724 100644 --- a/scene/2d/parallax_layer.h +++ b/scene/2d/parallax_layer.h @@ -38,7 +38,7 @@ class ParallaxLayer : public Node2D { Point2 orig_offset; Point2 orig_scale; - Size2 motion_scale; + Size2 motion_scale = Size2(1, 1); Vector2 motion_offset; Vector2 mirroring; void _update_mirroring(); diff --git a/scene/2d/path_2d.cpp b/scene/2d/path_2d.cpp index 41c91115ad..8c103a1239 100644 --- a/scene/2d/path_2d.cpp +++ b/scene/2d/path_2d.cpp @@ -240,7 +240,7 @@ bool PathFollow2D::get_cubic_interpolation() const { void PathFollow2D::_validate_property(PropertyInfo &property) const { if (property.name == "offset") { - float max = 10000; + float max = 10000.0; if (path && path->get_curve().is_valid()) { max = path->get_curve()->get_baked_length(); } diff --git a/scene/2d/path_2d.h b/scene/2d/path_2d.h index 3c5e0e4180..a748817555 100644 --- a/scene/2d/path_2d.h +++ b/scene/2d/path_2d.h @@ -64,10 +64,10 @@ class PathFollow2D : public Node2D { public: private: Path2D *path = nullptr; - real_t offset = 0; - real_t h_offset = 0; - real_t v_offset = 0; - real_t lookahead = 4; + real_t offset = 0.0; + real_t h_offset = 0.0; + real_t v_offset = 0.0; + real_t lookahead = 4.0; bool cubic = true; bool loop = true; bool rotates = true; diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp index ee625fb6f9..96d8fb609b 100644 --- a/scene/2d/physics_body_2d.cpp +++ b/scene/2d/physics_body_2d.cpp @@ -111,8 +111,6 @@ bool PhysicsBody2D::get_collision_layer_bit(int p_bit) const { PhysicsBody2D::PhysicsBody2D(PhysicsServer2D::BodyMode p_mode) : CollisionObject2D(PhysicsServer2D::get_singleton()->body_create(), false) { PhysicsServer2D::get_singleton()->body_set_mode(get_rid(), p_mode); - collision_layer = 1; - collision_mask = 1; set_pickable(false); } @@ -197,7 +195,6 @@ void StaticBody2D::_bind_methods() { StaticBody2D::StaticBody2D() : PhysicsBody2D(PhysicsServer2D::BODY_MODE_STATIC) { - constant_angular_velocity = 0; } StaticBody2D::~StaticBody2D() { @@ -320,8 +317,8 @@ void RigidBody2D::_body_inout(int p_status, ObjectID p_instance, int p_body_shap struct _RigidBody2DInOut { ObjectID id; - int shape; - int local_shape; + int shape = 0; + int local_shape = 0; }; bool RigidBody2D::_test_motion(const Vector2 &p_motion, bool p_infinite_inertia, real_t p_margin, const Ref<PhysicsTestMotionResult2D> &p_result) { @@ -841,25 +838,6 @@ void RigidBody2D::_bind_methods() { RigidBody2D::RigidBody2D() : PhysicsBody2D(PhysicsServer2D::BODY_MODE_RIGID) { - mode = MODE_RIGID; - - mass = 1; - - gravity_scale = 1; - linear_damp = -1; - angular_damp = -1; - - max_contacts_reported = 0; - state = nullptr; - - angular_velocity = 0; - sleeping = false; - ccd_mode = CCD_MODE_DISABLED; - - custom_integrator = false; - contact_monitor = nullptr; - can_sleep = true; - PhysicsServer2D::get_singleton()->body_set_force_integration_callback(get_rid(), this, "_direct_state_changed"); } diff --git a/scene/2d/physics_body_2d.h b/scene/2d/physics_body_2d.h index b2a4aed019..2dc853b23b 100644 --- a/scene/2d/physics_body_2d.h +++ b/scene/2d/physics_body_2d.h @@ -41,8 +41,8 @@ class KinematicCollision2D; class PhysicsBody2D : public CollisionObject2D { GDCLASS(PhysicsBody2D, CollisionObject2D); - uint32_t collision_layer; - uint32_t collision_mask; + uint32_t collision_layer = 1; + uint32_t collision_mask = 1; protected: void _notification(int p_what); @@ -74,7 +74,7 @@ class StaticBody2D : public PhysicsBody2D { GDCLASS(StaticBody2D, PhysicsBody2D); Vector2 constant_linear_velocity; - real_t constant_angular_velocity; + real_t constant_angular_velocity = 0.0; Ref<PhysicsMaterial> physics_material_override; @@ -116,30 +116,30 @@ public: }; private: - bool can_sleep; - PhysicsDirectBodyState2D *state; - Mode mode; + bool can_sleep = true; + PhysicsDirectBodyState2D *state = nullptr; + Mode mode = MODE_RIGID; - real_t mass; + real_t mass = 1.0; Ref<PhysicsMaterial> physics_material_override; - real_t gravity_scale; - real_t linear_damp; - real_t angular_damp; + real_t gravity_scale = 1.0; + real_t linear_damp = -1.0; + real_t angular_damp = -1.0; Vector2 linear_velocity; - real_t angular_velocity; - bool sleeping; + real_t angular_velocity = 0.0; + bool sleeping = false; - int max_contacts_reported; + int max_contacts_reported = 0; - bool custom_integrator; + bool custom_integrator = false; - CCDMode ccd_mode; + CCDMode ccd_mode = CCD_MODE_DISABLED; struct ShapePair { - int body_shape; - int local_shape; - bool tagged; + int body_shape = 0; + int local_shape = 0; + bool tagged = false; bool operator<(const ShapePair &p_sp) const { if (body_shape == p_sp.body_shape) { return local_shape < p_sp.local_shape; @@ -160,16 +160,16 @@ private: }; struct BodyState { //int rc; - bool in_scene; + bool in_scene = false; VSet<ShapePair> shapes; }; struct ContactMonitor { - bool locked; + bool locked = false; Map<ObjectID, BodyState> body_map; }; - ContactMonitor *contact_monitor; + ContactMonitor *contact_monitor = nullptr; void _body_enter_tree(ObjectID p_id); void _body_exit_tree(ObjectID p_id); @@ -268,11 +268,11 @@ public: Vector2 collider_vel; ObjectID collider; RID collider_rid; - int collider_shape; + int collider_shape = 0; Variant collider_metadata; Vector2 remainder; Vector2 travel; - int local_shape; + int local_shape = 0; }; private: diff --git a/scene/2d/polygon_2d.cpp b/scene/2d/polygon_2d.cpp index 82e1b7ac96..ecb354ad15 100644 --- a/scene/2d/polygon_2d.cpp +++ b/scene/2d/polygon_2d.cpp @@ -155,7 +155,7 @@ void Polygon2D::_notification(int p_what) { Rect2 bounds; int highest_idx = -1; float highest_y = -1e20; - float sum = 0; + float sum = 0.0; for (int i = 0; i < len; i++) { if (i == 0) { @@ -273,7 +273,7 @@ void Polygon2D::_notification(int p_what) { //normalize the weights for (int i = 0; i < vc; i++) { - float tw = 0; + float tw = 0.0; for (int j = 0; j < 4; j++) { tw += weightsw[i * 4 + j]; } @@ -649,13 +649,4 @@ void Polygon2D::_bind_methods() { } Polygon2D::Polygon2D() { - invert = false; - invert_border = 100; - antialiased = false; - tex_rot = 0; - tex_tile = true; - tex_scale = Vector2(1, 1); - color = Color(1, 1, 1); - rect_cache_dirty = true; - internal_vertices = 0; } diff --git a/scene/2d/polygon_2d.h b/scene/2d/polygon_2d.h index cdb3052225..ab01a4ffd0 100644 --- a/scene/2d/polygon_2d.h +++ b/scene/2d/polygon_2d.h @@ -40,7 +40,7 @@ class Polygon2D : public Node2D { Vector<Vector2> uv; Vector<Color> vertex_colors; Array polygons; - int internal_vertices; + int internal_vertices = 0; struct Bone { NodePath path; @@ -49,19 +49,19 @@ class Polygon2D : public Node2D { Vector<Bone> bone_weights; - Color color; + Color color = Color(1, 1, 1); Ref<Texture2D> texture; - Size2 tex_scale; + Size2 tex_scale = Vector2(1, 1); Vector2 tex_ofs; - bool tex_tile; - float tex_rot; - bool invert; - float invert_border; - bool antialiased; + bool tex_tile = true; + float tex_rot = 0.0; + bool invert = false; + float invert_border = 100.0; + bool antialiased = false; Vector2 offset; - mutable bool rect_cache_dirty; + mutable bool rect_cache_dirty = true; mutable Rect2 item_rect; NodePath skeleton; diff --git a/scene/2d/ray_cast_2d.cpp b/scene/2d/ray_cast_2d.cpp index 2c4a549acf..2cc3a74270 100644 --- a/scene/2d/ray_cast_2d.cpp +++ b/scene/2d/ray_cast_2d.cpp @@ -173,7 +173,7 @@ void RayCast2D::_notification(int p_what) { } draw_line(Vector2(), target_position, draw_col, 2); Vector<Vector2> pts; - float tsize = 8; + float tsize = 8.0; pts.push_back(xf.xform(Vector2(tsize, 0))); pts.push_back(xf.xform(Vector2(0, Math_SQRT12 * tsize))); pts.push_back(xf.xform(Vector2(0, -Math_SQRT12 * tsize))); @@ -325,12 +325,4 @@ void RayCast2D::_bind_methods() { } RayCast2D::RayCast2D() { - enabled = true; - collided = false; - against_shape = 0; - collision_mask = 1; - target_position = Vector2(0, 50); - exclude_parent_body = true; - collide_with_bodies = true; - collide_with_areas = false; } diff --git a/scene/2d/ray_cast_2d.h b/scene/2d/ray_cast_2d.h index ff7a970ebf..dab3302e25 100644 --- a/scene/2d/ray_cast_2d.h +++ b/scene/2d/ray_cast_2d.h @@ -36,20 +36,20 @@ class RayCast2D : public Node2D { GDCLASS(RayCast2D, Node2D); - bool enabled; - bool collided; + bool enabled = true; + bool collided = false; ObjectID against; - int against_shape; + int against_shape = 0; Vector2 collision_point; Vector2 collision_normal; Set<RID> exclude; - uint32_t collision_mask; - bool exclude_parent_body; + uint32_t collision_mask = 1; + bool exclude_parent_body = true; - Vector2 target_position; + Vector2 target_position = Vector2(0, 50); - bool collide_with_areas; - bool collide_with_bodies; + bool collide_with_areas = false; + bool collide_with_bodies = true; protected: void _notification(int p_what); diff --git a/scene/2d/remote_transform_2d.cpp b/scene/2d/remote_transform_2d.cpp index 4ed4c3a8ff..f10714e28a 100644 --- a/scene/2d/remote_transform_2d.cpp +++ b/scene/2d/remote_transform_2d.cpp @@ -223,10 +223,5 @@ void RemoteTransform2D::_bind_methods() { } RemoteTransform2D::RemoteTransform2D() { - use_global_coordinates = true; - update_remote_position = true; - update_remote_rotation = true; - update_remote_scale = true; - set_notify_transform(true); } diff --git a/scene/2d/remote_transform_2d.h b/scene/2d/remote_transform_2d.h index cb4bd37f1f..4a26d7b339 100644 --- a/scene/2d/remote_transform_2d.h +++ b/scene/2d/remote_transform_2d.h @@ -40,10 +40,10 @@ class RemoteTransform2D : public Node2D { ObjectID cache; - bool use_global_coordinates; - bool update_remote_position; - bool update_remote_rotation; - bool update_remote_scale; + bool use_global_coordinates = true; + bool update_remote_position = true; + bool update_remote_rotation = true; + bool update_remote_scale = true; void _update_remote(); void _update_cache(); diff --git a/scene/2d/skeleton_2d.cpp b/scene/2d/skeleton_2d.cpp index bb5a309f65..48e44e01a1 100644 --- a/scene/2d/skeleton_2d.cpp +++ b/scene/2d/skeleton_2d.cpp @@ -157,10 +157,6 @@ String Bone2D::get_configuration_warning() const { } Bone2D::Bone2D() { - skeleton = nullptr; - parent_bone = nullptr; - skeleton_index = -1; - default_length = 16; set_notify_local_transform(true); //this is a clever hack so the bone knows no rest has been set yet, allowing to show an error. for (int i = 0; i < 3; i++) { @@ -293,9 +289,6 @@ void Skeleton2D::_bind_methods() { } Skeleton2D::Skeleton2D() { - bone_setup_dirty = true; - transform_dirty = true; - skeleton = RS::get_singleton()->skeleton_create(); set_notify_transform(true); } diff --git a/scene/2d/skeleton_2d.h b/scene/2d/skeleton_2d.h index 36b9e1b339..80ca8c80ac 100644 --- a/scene/2d/skeleton_2d.h +++ b/scene/2d/skeleton_2d.h @@ -43,12 +43,12 @@ class Bone2D : public Node2D { friend class AnimatedValuesBackup; #endif - Bone2D *parent_bone; - Skeleton2D *skeleton; + Bone2D *parent_bone = nullptr; + Skeleton2D *skeleton = nullptr; Transform2D rest; - float default_length; + float default_length = 16.0; - int skeleton_index; + int skeleton_index = -1; protected: void _notification(int p_what); @@ -82,19 +82,19 @@ class Skeleton2D : public Node2D { bool operator<(const Bone &p_bone) const { return p_bone.bone->is_greater_than(bone); } - Bone2D *bone; - int parent_index; + Bone2D *bone = nullptr; + int parent_index = 0; Transform2D accum_transform; Transform2D rest_inverse; }; Vector<Bone> bones; - bool bone_setup_dirty; + bool bone_setup_dirty = true; void _make_bone_setup_dirty(); void _update_bone_setup(); - bool transform_dirty; + bool transform_dirty = true; void _make_transform_dirty(); void _update_transform(); diff --git a/scene/2d/sprite_2d.cpp b/scene/2d/sprite_2d.cpp index 773214deeb..d1a3c01266 100644 --- a/scene/2d/sprite_2d.cpp +++ b/scene/2d/sprite_2d.cpp @@ -462,16 +462,6 @@ void Sprite2D::_bind_methods() { } Sprite2D::Sprite2D() { - centered = true; - hflip = false; - vflip = false; - region = false; - region_filter_clip = false; - - frame = 0; - - vframes = 1; - hframes = 1; } Sprite2D::~Sprite2D() { diff --git a/scene/2d/sprite_2d.h b/scene/2d/sprite_2d.h index 716882d485..fa765f457d 100644 --- a/scene/2d/sprite_2d.h +++ b/scene/2d/sprite_2d.h @@ -39,21 +39,21 @@ class Sprite2D : public Node2D { Ref<Texture2D> texture; Color specular_color; - float shininess; + float shininess = 0.0; - bool centered; + bool centered = true; Point2 offset; - bool hflip; - bool vflip; - bool region; + bool hflip = false; + bool vflip = false; + bool region = false; Rect2 region_rect; - bool region_filter_clip; + bool region_filter_clip = false; - int frame; + int frame = 0; - int vframes; - int hframes; + int vframes = 1; + int hframes = 1; void _get_rects(Rect2 &r_src_rect, Rect2 &r_dst_rect, bool &r_filter_clip) const; diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp index 01b7a9c260..33c238d455 100644 --- a/scene/2d/tile_map.cpp +++ b/scene/2d/tile_map.cpp @@ -1872,32 +1872,6 @@ void TileMap::_changed_callback(Object *p_changed, const char *p_prop) { } TileMap::TileMap() { - rect_cache_dirty = true; - used_size_cache_dirty = true; - pending_update = false; - quadrant_order_dirty = false; - quadrant_size = 16; - cell_size = Size2(64, 64); - custom_transform = Transform2D(64, 0, 0, 64, 0, 0); - collision_layer = 1; - collision_mask = 1; - friction = 1; - bounce = 0; - mode = MODE_SQUARE; - half_offset = HALF_OFFSET_DISABLED; - use_parent = false; - collision_parent = nullptr; - use_kinematic = false; - navigation = nullptr; - use_y_sort = false; - compatibility_mode = false; - centered_textures = false; - occluder_light_mask = 1; - clip_uv = false; - format = FORMAT_1; // Assume lowest possible format if none is present - - fp_adjust = 0.00001; - tile_origin = TILE_ORIGIN_TOP_LEFT; set_notify_transform(true); set_notify_local_transform(false); } diff --git a/scene/2d/tile_map.h b/scene/2d/tile_map.h index b1e54aafae..cfed4c0743 100644 --- a/scene/2d/tile_map.h +++ b/scene/2d/tile_map.h @@ -70,22 +70,22 @@ private: }; Ref<TileSet> tile_set; - Size2i cell_size; - int quadrant_size; - Mode mode; - Transform2D custom_transform; - HalfOffset half_offset; - bool use_parent; - CollisionObject2D *collision_parent; - bool use_kinematic; - Navigation2D *navigation; + Size2i cell_size = Size2(64, 64); + int quadrant_size = 16; + Mode mode = MODE_SQUARE; + Transform2D custom_transform = Transform2D(64, 0, 0, 64, 0, 0); + HalfOffset half_offset = HALF_OFFSET_DISABLED; + bool use_parent = false; + CollisionObject2D *collision_parent = nullptr; + bool use_kinematic = false; + Navigation2D *navigation = nullptr; union PosKey { struct { int16_t x; int16_t y; }; - uint32_t key; + uint32_t key = 0; //using a more precise comparison so the regions can be sorted later bool operator<(const PosKey &p_k) const { return (y == p_k.y) ? x < p_k.x : y < p_k.y; } @@ -119,8 +119,7 @@ private: int16_t autotile_coord_y : 16; }; - uint64_t _u64t; - Cell() { _u64t = 0; } + uint64_t _u64t = 0; }; Map<PosKey, Cell> tile_map; @@ -130,7 +129,7 @@ private: Vector2 pos; List<RID> canvas_items; RID body; - uint32_t shape_owner_id; + uint32_t shape_owner_id = 0; SelfList<Quadrant> dirty_list; @@ -176,27 +175,27 @@ private: SelfList<Quadrant>::List dirty_quadrant_list; - bool pending_update; + bool pending_update = false; Rect2 rect_cache; - bool rect_cache_dirty; + bool rect_cache_dirty = true; Rect2 used_size_cache; - bool used_size_cache_dirty; - bool quadrant_order_dirty; - bool use_y_sort; - bool compatibility_mode; - bool centered_textures; - bool clip_uv; - float fp_adjust; - float friction; - float bounce; - uint32_t collision_layer; - uint32_t collision_mask; - mutable DataFormat format; - - TileOrigin tile_origin; - - int occluder_light_mask; + bool used_size_cache_dirty = true; + bool quadrant_order_dirty = false; + bool use_y_sort = false; + bool compatibility_mode = false; + bool centered_textures = false; + bool clip_uv = false; + float fp_adjust = 0.00001; + float friction = 1.0; + float bounce = 0.0; + uint32_t collision_layer = 1; + uint32_t collision_mask = 1; + mutable DataFormat format = FORMAT_1; // Assume lowest possible format if none is present + + TileOrigin tile_origin = TILE_ORIGIN_TOP_LEFT; + + int occluder_light_mask = 1; void _fix_cell_transform(Transform2D &xform, const Cell &p_cell, const Vector2 &p_offset, const Size2 &p_sc); diff --git a/scene/2d/touch_screen_button.cpp b/scene/2d/touch_screen_button.cpp index 04a1aedcd3..fccf126dad 100644 --- a/scene/2d/touch_screen_button.cpp +++ b/scene/2d/touch_screen_button.cpp @@ -399,11 +399,6 @@ void TouchScreenButton::_bind_methods() { } TouchScreenButton::TouchScreenButton() { - finger_pressed = -1; - passby_press = false; - visibility = VISIBILITY_ALWAYS; - shape_centered = true; - shape_visible = true; unit_rect = Ref<RectangleShape2D>(memnew(RectangleShape2D)); unit_rect->set_size(Vector2(1, 1)); } diff --git a/scene/2d/touch_screen_button.h b/scene/2d/touch_screen_button.h index f4ae3ca26c..10820ad059 100644 --- a/scene/2d/touch_screen_button.h +++ b/scene/2d/touch_screen_button.h @@ -50,16 +50,16 @@ private: Ref<Texture2D> texture_pressed; Ref<BitMap> bitmask; Ref<Shape2D> shape; - bool shape_centered; - bool shape_visible; + bool shape_centered = true; + bool shape_visible = true; Ref<RectangleShape2D> unit_rect; StringName action; - bool passby_press; - int finger_pressed; + bool passby_press = false; + int finger_pressed = -1; - VisibilityMode visibility; + VisibilityMode visibility = VISIBILITY_ALWAYS; void _input(const Ref<InputEvent> &p_event); diff --git a/scene/2d/visibility_notifier_2d.cpp b/scene/2d/visibility_notifier_2d.cpp index f3dddd5af8..21a2561dd0 100644 --- a/scene/2d/visibility_notifier_2d.cpp +++ b/scene/2d/visibility_notifier_2d.cpp @@ -363,6 +363,4 @@ VisibilityEnabler2D::VisibilityEnabler2D() { } enabler[ENABLER_PARENT_PROCESS] = false; enabler[ENABLER_PARENT_PHYSICS_PROCESS] = false; - - visible = false; } diff --git a/scene/2d/visibility_notifier_2d.h b/scene/2d/visibility_notifier_2d.h index ea3b5df37b..3d1701a1e5 100644 --- a/scene/2d/visibility_notifier_2d.h +++ b/scene/2d/visibility_notifier_2d.h @@ -85,7 +85,7 @@ protected: virtual void _screen_enter() override; virtual void _screen_exit() override; - bool visible; + bool visible = false; void _find_nodes(Node *p_node); diff --git a/scene/2d/y_sort.cpp b/scene/2d/y_sort.cpp index 987e4581f4..7e7bc27cc2 100644 --- a/scene/2d/y_sort.cpp +++ b/scene/2d/y_sort.cpp @@ -48,6 +48,5 @@ void YSort::_bind_methods() { } YSort::YSort() { - sort_enabled = true; RS::get_singleton()->canvas_item_set_sort_children_by_y(get_canvas_item(), true); } diff --git a/scene/2d/y_sort.h b/scene/2d/y_sort.h index 0882a88e3a..7d36ee3391 100644 --- a/scene/2d/y_sort.h +++ b/scene/2d/y_sort.h @@ -35,7 +35,7 @@ class YSort : public Node2D { GDCLASS(YSort, Node2D); - bool sort_enabled; + bool sort_enabled = true; static void _bind_methods(); public: diff --git a/scene/3d/area_3d.cpp b/scene/3d/area_3d.cpp index 36312482cd..99c5276636 100644 --- a/scene/3d/area_3d.cpp +++ b/scene/3d/area_3d.cpp @@ -681,29 +681,10 @@ void Area3D::_bind_methods() { Area3D::Area3D() : CollisionObject3D(PhysicsServer3D::get_singleton()->area_create(), true) { - space_override = SPACE_OVERRIDE_DISABLED; set_gravity(9.8); - locked = false; set_gravity_vector(Vector3(0, -1, 0)); - gravity_is_point = false; - gravity_distance_scale = 0; - linear_damp = 0.1; - angular_damp = 0.1; - priority = 0; - monitoring = false; - monitorable = false; - collision_mask = 1; - collision_layer = 1; set_monitoring(true); set_monitorable(true); - - audio_bus_override = false; - audio_bus = "Master"; - - use_reverb_bus = false; - reverb_bus = "Master"; - reverb_amount = 0.0; - reverb_uniformity = 0.0; } Area3D::~Area3D() { diff --git a/scene/3d/area_3d.h b/scene/3d/area_3d.h index 5d8e1933ba..6d976115f7 100644 --- a/scene/3d/area_3d.h +++ b/scene/3d/area_3d.h @@ -47,19 +47,19 @@ public: }; private: - SpaceOverride space_override; + SpaceOverride space_override = SPACE_OVERRIDE_DISABLED; Vector3 gravity_vec; real_t gravity; - bool gravity_is_point; - real_t gravity_distance_scale; - real_t angular_damp; - real_t linear_damp; - uint32_t collision_mask; - uint32_t collision_layer; - int priority; - bool monitoring; - bool monitorable; - bool locked; + bool gravity_is_point = false; + real_t gravity_distance_scale = 0.0; + real_t angular_damp = 0.1; + real_t linear_damp = 0.1; + uint32_t collision_mask = 1; + uint32_t collision_layer = 1; + int priority = 0; + bool monitoring = false; + bool monitorable = false; + bool locked = false; void _body_inout(int p_status, const RID &p_body, ObjectID p_instance, int p_body_shape, int p_area_shape); @@ -67,8 +67,8 @@ private: void _body_exit_tree(ObjectID p_id); struct ShapePair { - int body_shape; - int area_shape; + int body_shape = 0; + int area_shape = 0; bool operator<(const ShapePair &p_sp) const { if (body_shape == p_sp.body_shape) { return area_shape < p_sp.area_shape; @@ -85,8 +85,8 @@ private: }; struct BodyState { - int rc; - bool in_tree; + int rc = 0; + bool in_tree = false; VSet<ShapePair> shapes; }; @@ -98,8 +98,8 @@ private: void _area_exit_tree(ObjectID p_id); struct AreaShapePair { - int area_shape; - int self_shape; + int area_shape = 0; + int self_shape = 0; bool operator<(const AreaShapePair &p_sp) const { if (area_shape == p_sp.area_shape) { return self_shape < p_sp.self_shape; @@ -116,21 +116,21 @@ private: }; struct AreaState { - int rc; - bool in_tree; + int rc = 0; + bool in_tree = false; VSet<AreaShapePair> shapes; }; Map<ObjectID, AreaState> area_map; void _clear_monitoring(); - bool audio_bus_override; - StringName audio_bus; + bool audio_bus_override = false; + StringName audio_bus = "Master"; - bool use_reverb_bus; - StringName reverb_bus; - float reverb_amount; - float reverb_uniformity; + bool use_reverb_bus = false; + StringName reverb_bus = "Master"; + float reverb_amount = 0.0; + float reverb_uniformity = 0.0; void _validate_property(PropertyInfo &property) const override; diff --git a/scene/3d/audio_stream_player_3d.cpp b/scene/3d/audio_stream_player_3d.cpp index 2bcf898ced..fa8408ba5b 100644 --- a/scene/3d/audio_stream_player_3d.cpp +++ b/scene/3d/audio_stream_player_3d.cpp @@ -42,8 +42,8 @@ class Spcap { private: struct Speaker { Vector3 direction; - real_t effective_number_of_speakers; // precalculated - mutable real_t squared_gain; // temporary + real_t effective_number_of_speakers = 0; // precalculated + mutable real_t squared_gain = 0; // temporary }; Vector<Speaker> speakers; @@ -1002,31 +1002,6 @@ void AudioStreamPlayer3D::_bind_methods() { } AudioStreamPlayer3D::AudioStreamPlayer3D() { - unit_db = 0; - unit_size = 1; - attenuation_model = ATTENUATION_INVERSE_DISTANCE; - max_db = 3; - pitch_scale = 1.0; - autoplay = false; - setseek = -1; - active = false; - output_count = 0; - prev_output_count = 0; - max_distance = 0; - setplay = -1; - output_ready = false; - area_mask = 1; - emission_angle = 45; - emission_angle_enabled = false; - emission_angle_filter_attenuation_db = -12; - attenuation_filter_cutoff_hz = 5000; - attenuation_filter_db = -24; - out_of_range_mode = OUT_OF_RANGE_MIX; - doppler_tracking = DOPPLER_TRACKING_DISABLED; - stream_paused = false; - stream_paused_fade_in = false; - stream_paused_fade_out = false; - velocity_tracker.instance(); AudioServer::get_singleton()->connect("bus_layout_changed", callable_mp(this, &AudioStreamPlayer3D::_bus_layout_changed)); set_disable_scale(true); diff --git a/scene/3d/audio_stream_player_3d.h b/scene/3d/audio_stream_player_3d.h index bcfe2b2229..33ed758749 100644 --- a/scene/3d/audio_stream_player_3d.h +++ b/scene/3d/audio_stream_player_3d.h @@ -71,46 +71,39 @@ private: AudioFilterSW filter; AudioFilterSW::Processor filter_process[8]; AudioFrame vol[4]; - float filter_gain; - float pitch_scale; - int bus_index; - int reverb_bus_index; + float filter_gain = 0.0; + float pitch_scale = 0.0; + int bus_index = -1; + int reverb_bus_index = -1; AudioFrame reverb_vol[4]; - Viewport *viewport; //pointer only used for reference to previous mix - - Output() { - filter_gain = 0; - viewport = nullptr; - reverb_bus_index = -1; - bus_index = -1; - } + Viewport *viewport = nullptr; //pointer only used for reference to previous mix }; Output outputs[MAX_OUTPUTS]; - volatile int output_count; - volatile bool output_ready; + volatile int output_count = 0; + volatile bool output_ready = false; //these are used by audio thread to have a reference of previous volumes (for ramping volume and avoiding clicks) Output prev_outputs[MAX_OUTPUTS]; - int prev_output_count; + int prev_output_count = 0; Ref<AudioStreamPlayback> stream_playback; Ref<AudioStream> stream; Vector<AudioFrame> mix_buffer; - volatile float setseek; - volatile bool active; - volatile float setplay; - - AttenuationModel attenuation_model; - float unit_db; - float unit_size; - float max_db; - float pitch_scale; - bool autoplay; - bool stream_paused; - bool stream_paused_fade_in; - bool stream_paused_fade_out; + volatile float setseek = -1.0; + volatile bool active = false; + volatile float setplay = -1.0; + + AttenuationModel attenuation_model = ATTENUATION_INVERSE_DISTANCE; + float unit_db = 0.0; + float unit_size = 1.0; + float max_db = 3.0; + float pitch_scale = 1.0; + bool autoplay = false; + bool stream_paused = false; + bool stream_paused_fade_in = false; + bool stream_paused_fade_out = false; StringName bus; static void _calc_output_vol(const Vector3 &source_dir, real_t tightness, Output &output); @@ -122,21 +115,21 @@ private: void _bus_layout_changed(); - uint32_t area_mask; + uint32_t area_mask = 1; - bool emission_angle_enabled; - float emission_angle; - float emission_angle_filter_attenuation_db; - float attenuation_filter_cutoff_hz; - float attenuation_filter_db; + bool emission_angle_enabled = false; + float emission_angle = 45.0; + float emission_angle_filter_attenuation_db = -12.0; + float attenuation_filter_cutoff_hz = 5000.0; + float attenuation_filter_db = -24.0; - float max_distance; + float max_distance = 0.0; Ref<VelocityTracker3D> velocity_tracker; - DopplerTracking doppler_tracking; + DopplerTracking doppler_tracking = DOPPLER_TRACKING_DISABLED; - OutOfRangeMode out_of_range_mode; + OutOfRangeMode out_of_range_mode = OUT_OF_RANGE_MIX; float _get_attenuation_db(float p_distance) const; diff --git a/scene/3d/baked_lightmap.cpp b/scene/3d/baked_lightmap.cpp index 14c8755d99..7c05878710 100644 --- a/scene/3d/baked_lightmap.cpp +++ b/scene/3d/baked_lightmap.cpp @@ -1466,17 +1466,4 @@ void BakedLightmap::_bind_methods() { } BakedLightmap::BakedLightmap() { - environment_mode = ENVIRONMENT_MODE_DISABLED; - environment_custom_color = Color(0.2, 0.7, 1.0); - environment_custom_energy = 1.0; - - bake_quality = BAKE_QUALITY_MEDIUM; - interior = false; - directional = false; - - gen_probes = GENERATE_PROBES_DISABLED; - use_denoiser = true; - bounces = 1; - bias = 0.0005; - max_texture_size = 16384; } diff --git a/scene/3d/baked_lightmap.h b/scene/3d/baked_lightmap.h index 7fd1cf892e..e2d89ab2d0 100644 --- a/scene/3d/baked_lightmap.h +++ b/scene/3d/baked_lightmap.h @@ -53,9 +53,9 @@ class BakedLightmapData : public Resource { struct User { NodePath path; - int32_t sub_instance; + int32_t sub_instance = 0; Rect2 uv_scale; - int slice_index; + int slice_index = 0; }; Vector<User> users; @@ -136,32 +136,32 @@ public: }; private: - BakeQuality bake_quality; - bool use_denoiser; - int bounces; - float bias; - int max_texture_size; - bool interior; - EnvironmentMode environment_mode; + BakeQuality bake_quality = BAKE_QUALITY_MEDIUM; + bool use_denoiser = true; + int bounces = 1; + float bias = 0.0005; + int max_texture_size = 16384; + bool interior = false; + EnvironmentMode environment_mode = ENVIRONMENT_MODE_DISABLED; Ref<Sky> environment_custom_sky; - Color environment_custom_color; - float environment_custom_energy; - bool directional; - GenerateProbes gen_probes; + Color environment_custom_color = Color(0.2, 0.7, 1.0); + float environment_custom_energy = 1.0; + bool directional = false; + GenerateProbes gen_probes = GENERATE_PROBES_DISABLED; Ref<BakedLightmapData> light_data; struct LightsFound { Transform xform; - Light3D *light; + Light3D *light = nullptr; }; struct MeshesFound { Transform xform; NodePath node_path; - int32_t subindex; + int32_t subindex = 0; Ref<Mesh> mesh; - int32_t lightmap_scale; + int32_t lightmap_scale = 0; Vector<Ref<Material>> overrides; }; @@ -172,19 +172,20 @@ private: struct BakeTimeData { String text; - int pass; - uint64_t last_step; + int pass = 0; + uint64_t last_step = 0; }; struct BSPSimplex { - int vertices[4]; - int planes[4]; + int vertices[4] = {}; + int planes[4] = {}; }; struct BSPNode { static const int32_t EMPTY_LEAF = INT32_MIN; Plane plane; - int32_t over = EMPTY_LEAF, under = EMPTY_LEAF; + int32_t over = EMPTY_LEAF; + int32_t under = EMPTY_LEAF; }; int _bsp_get_simplex_side(const Vector<Vector3> &p_points, const LocalVector<BSPSimplex> &p_simplices, const Plane &p_plane, uint32_t p_simplex) const; @@ -192,16 +193,16 @@ private: struct BakeStepUD { Lightmapper::BakeStepFunc func; - void *ud; - float from_percent; - float to_percent; + void *ud = nullptr; + float from_percent = 0.0; + float to_percent = 0.0; }; static bool _lightmap_bake_step_function(float p_completion, const String &p_text, void *ud, bool p_refresh); struct GenProbesOctree { Vector3i offset; - uint32_t size; + uint32_t size = 0; GenProbesOctree *children[8] = { nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr }; ~GenProbesOctree() { for (int i = 0; i < 8; i++) { diff --git a/scene/3d/bone_attachment_3d.cpp b/scene/3d/bone_attachment_3d.cpp index 30fe1ecea8..5315e685a0 100644 --- a/scene/3d/bone_attachment_3d.cpp +++ b/scene/3d/bone_attachment_3d.cpp @@ -105,7 +105,6 @@ void BoneAttachment3D::_notification(int p_what) { } BoneAttachment3D::BoneAttachment3D() { - bound = false; } void BoneAttachment3D::_bind_methods() { diff --git a/scene/3d/bone_attachment_3d.h b/scene/3d/bone_attachment_3d.h index 0dddaa1028..0c6d5f12b1 100644 --- a/scene/3d/bone_attachment_3d.h +++ b/scene/3d/bone_attachment_3d.h @@ -36,7 +36,7 @@ class BoneAttachment3D : public Node3D { GDCLASS(BoneAttachment3D, Node3D); - bool bound; + bool bound = false; String bone_name; void _check_bind(); diff --git a/scene/3d/camera_3d.cpp b/scene/3d/camera_3d.cpp index 53c3204b3e..fa9da6898c 100644 --- a/scene/3d/camera_3d.cpp +++ b/scene/3d/camera_3d.cpp @@ -653,24 +653,10 @@ Vector3 Camera3D::get_doppler_tracked_velocity() const { Camera3D::Camera3D() { camera = RenderingServer::get_singleton()->camera_create(); - size = 1; - fov = 0; - frustum_offset = Vector2(); - near = 0; - far = 0; - current = false; - viewport = nullptr; - force_change = false; - mode = PROJECTION_PERSPECTIVE; set_perspective(75.0, 0.05, 4000.0); - keep_aspect = KEEP_HEIGHT; - layers = 0xfffff; - v_offset = 0; - h_offset = 0; RenderingServer::get_singleton()->camera_set_cull_mask(camera, layers); //active=false; velocity_tracker.instance(); - doppler_tracking = DOPPLER_TRACKING_DISABLED; set_notify_transform(true); set_disable_scale(true); } @@ -882,16 +868,10 @@ void ClippedCamera3D::_bind_methods() { } ClippedCamera3D::ClippedCamera3D() { - margin = 0; - clip_offset = 0; - process_mode = CLIP_PROCESS_PHYSICS; set_physics_process_internal(true); - collision_mask = 1; set_notify_local_transform(Engine::get_singleton()->is_editor_hint()); points.resize(5); pyramid_shape = PhysicsServer3D::get_singleton()->shape_create(PhysicsServer3D::SHAPE_CONVEX_POLYGON); - clip_to_areas = false; - clip_to_bodies = true; } ClippedCamera3D::~ClippedCamera3D() { diff --git a/scene/3d/camera_3d.h b/scene/3d/camera_3d.h index aa36c8800d..06bb55e23c 100644 --- a/scene/3d/camera_3d.h +++ b/scene/3d/camera_3d.h @@ -57,26 +57,27 @@ public: }; private: - bool force_change; - bool current; - Viewport *viewport; + bool force_change = false; + bool current = false; + Viewport *viewport = nullptr; - Projection mode; + Projection mode = PROJECTION_PERSPECTIVE; - float fov; - float size; + float fov = 0.0; + float size = 1.0; Vector2 frustum_offset; - float near, far; - float v_offset; - float h_offset; - KeepAspect keep_aspect; + float near = 0.0; + float far = 0.0; + float v_offset = 0.0; + float h_offset = 0.0; + KeepAspect keep_aspect = KEEP_HEIGHT; RID camera; RID scenario_id; // String camera_group; - uint32_t layers; + uint32_t layers = 0xfffff; Ref<Environment> environment; Ref<CameraEffects> effects; @@ -87,7 +88,7 @@ private: friend class Viewport; void _update_audio_listener_state(); - DopplerTracking doppler_tracking; + DopplerTracking doppler_tracking = DOPPLER_TRACKING_DISABLED; Ref<VelocityTracker3D> velocity_tracker; protected: @@ -191,13 +192,13 @@ public: }; private: - ProcessMode process_mode; + ProcessMode process_mode = CLIP_PROCESS_PHYSICS; RID pyramid_shape; - float margin; - float clip_offset; - uint32_t collision_mask; - bool clip_to_areas; - bool clip_to_bodies; + float margin = 0.0; + float clip_offset = 0.0; + uint32_t collision_mask = 1; + bool clip_to_areas = false; + bool clip_to_bodies = true; Set<RID> exclude; diff --git a/scene/3d/collision_object_3d.cpp b/scene/3d/collision_object_3d.cpp index f1d7ac64b2..b7da4822e2 100644 --- a/scene/3d/collision_object_3d.cpp +++ b/scene/3d/collision_object_3d.cpp @@ -325,10 +325,7 @@ uint32_t CollisionObject3D::shape_find_owner(int p_shape_index) const { CollisionObject3D::CollisionObject3D(RID p_rid, bool p_area) { rid = p_rid; area = p_area; - capture_input_on_drag = false; - ray_pickable = true; set_notify_transform(true); - total_subshapes = 0; if (p_area) { PhysicsServer3D::get_singleton()->area_attach_object_instance_id(rid, get_instance_id()); @@ -360,8 +357,6 @@ String CollisionObject3D::get_configuration_warning() const { } CollisionObject3D::CollisionObject3D() { - capture_input_on_drag = false; - ray_pickable = true; set_notify_transform(true); //owner= diff --git a/scene/3d/collision_object_3d.h b/scene/3d/collision_object_3d.h index da65791b9c..b7473ca12a 100644 --- a/scene/3d/collision_object_3d.h +++ b/scene/3d/collision_object_3d.h @@ -37,33 +37,28 @@ class CollisionObject3D : public Node3D { GDCLASS(CollisionObject3D, Node3D); - bool area; + bool area = false; RID rid; struct ShapeData { - Object *owner; + Object *owner = nullptr; Transform xform; struct ShapeBase { Ref<Shape3D> shape; - int index; + int index = 0; }; Vector<ShapeBase> shapes; - bool disabled; - - ShapeData() { - disabled = false; - owner = nullptr; - } + bool disabled = false; }; - int total_subshapes; + int total_subshapes = 0; Map<uint32_t, ShapeData> shapes; - bool capture_input_on_drag; - bool ray_pickable; + bool capture_input_on_drag = false; + bool ray_pickable = true; void _update_pickable(); diff --git a/scene/3d/collision_polygon_3d.cpp b/scene/3d/collision_polygon_3d.cpp index 742387b32d..4d117f02d3 100644 --- a/scene/3d/collision_polygon_3d.cpp +++ b/scene/3d/collision_polygon_3d.cpp @@ -197,10 +197,5 @@ void CollisionPolygon3D::_bind_methods() { } CollisionPolygon3D::CollisionPolygon3D() { - aabb = AABB(Vector3(-1, -1, -1), Vector3(2, 2, 2)); - depth = 1.0; set_notify_local_transform(true); - parent = nullptr; - owner_id = 0; - disabled = false; } diff --git a/scene/3d/collision_polygon_3d.h b/scene/3d/collision_polygon_3d.h index ba6ad2a3f0..cb0aba67b1 100644 --- a/scene/3d/collision_polygon_3d.h +++ b/scene/3d/collision_polygon_3d.h @@ -39,14 +39,14 @@ class CollisionPolygon3D : public Node3D { GDCLASS(CollisionPolygon3D, Node3D); protected: - real_t depth; - AABB aabb; + real_t depth = 1.0; + AABB aabb = AABB(Vector3(-1, -1, -1), Vector3(2, 2, 2)); Vector<Point2> polygon; - uint32_t owner_id; - CollisionObject3D *parent; + uint32_t owner_id = 0; + CollisionObject3D *parent = nullptr; - bool disabled; + bool disabled = false; void _build_polygon(); diff --git a/scene/3d/collision_shape_3d.cpp b/scene/3d/collision_shape_3d.cpp index 503d1be104..914c8eab7a 100644 --- a/scene/3d/collision_shape_3d.cpp +++ b/scene/3d/collision_shape_3d.cpp @@ -93,6 +93,7 @@ void CollisionShape3D::_notification(int p_what) { if (shape.is_valid()) { parent->shape_owner_add_shape(owner_id, shape); } + _update_in_shape_owner(); } } break; case NOTIFICATION_ENTER_TREE: { @@ -213,10 +214,6 @@ bool CollisionShape3D::is_disabled() const { CollisionShape3D::CollisionShape3D() { //indicator = RenderingServer::get_singleton()->mesh_create(); - disabled = false; - debug_shape = nullptr; - parent = nullptr; - owner_id = 0; set_notify_local_transform(true); } diff --git a/scene/3d/collision_shape_3d.h b/scene/3d/collision_shape_3d.h index 5f556b01a9..f55c09ffaa 100644 --- a/scene/3d/collision_shape_3d.h +++ b/scene/3d/collision_shape_3d.h @@ -40,14 +40,14 @@ class CollisionShape3D : public Node3D { Ref<Shape3D> shape; - uint32_t owner_id; - CollisionObject3D *parent; + uint32_t owner_id = 0; + CollisionObject3D *parent = nullptr; - Node *debug_shape; + Node *debug_shape = nullptr; bool debug_shape_dirty; void resource_changed(RES res); - bool disabled; + bool disabled = false; protected: void _update_debug_shape(); diff --git a/scene/3d/cpu_particles_3d.cpp b/scene/3d/cpu_particles_3d.cpp index 85b502e7a0..48fdeb051d 100644 --- a/scene/3d/cpu_particles_3d.cpp +++ b/scene/3d/cpu_particles_3d.cpp @@ -1445,13 +1445,6 @@ void CPUParticles3D::_bind_methods() { } CPUParticles3D::CPUParticles3D() { - time = 0; - inactive_time = 0; - frame_remainder = 0; - cycle = 0; - redraw = false; - emitting = false; - set_notify_transform(true); multimesh = RenderingServer::get_singleton()->multimesh_create(); @@ -1459,23 +1452,8 @@ CPUParticles3D::CPUParticles3D() { set_base(multimesh); set_emitting(true); - set_one_shot(false); set_amount(8); - set_lifetime(1); - set_fixed_fps(0); - set_fractional_delta(true); - set_pre_process_time(0); - set_explosiveness_ratio(0); - set_randomness_ratio(0); - set_lifetime_randomness(0); - set_use_local_coordinates(true); - - set_draw_order(DRAW_ORDER_INDEX); - set_speed_scale(1); - - set_direction(Vector3(1, 0, 0)); - set_spread(45); - set_flatness(0); + set_param(PARAM_INITIAL_LINEAR_VELOCITY, 0); set_param(PARAM_ANGULAR_VELOCITY, 0); set_param(PARAM_ORBIT_VELOCITY, 0); @@ -1488,23 +1466,6 @@ CPUParticles3D::CPUParticles3D() { set_param(PARAM_HUE_VARIATION, 0); set_param(PARAM_ANIM_SPEED, 0); set_param(PARAM_ANIM_OFFSET, 0); - set_emission_shape(EMISSION_SHAPE_POINT); - set_emission_sphere_radius(1); - set_emission_box_extents(Vector3(1, 1, 1)); - - set_gravity(Vector3(0, -9.8, 0)); - - for (int i = 0; i < PARAM_MAX; i++) { - set_param_randomness(Parameter(i), 0); - } - - for (int i = 0; i < PARTICLE_FLAG_MAX; i++) { - particle_flags[i] = false; - } - - can_update = false; - - set_color(Color(1, 1, 1, 1)); } CPUParticles3D::~CPUParticles3D() { diff --git a/scene/3d/cpu_particles_3d.h b/scene/3d/cpu_particles_3d.h index 3ee03ff3d8..d650bf95ac 100644 --- a/scene/3d/cpu_particles_3d.h +++ b/scene/3d/cpu_particles_3d.h @@ -78,30 +78,30 @@ public: }; private: - bool emitting; + bool emitting = false; struct Particle { Transform transform; Color color; - float custom[4]; + float custom[4] = {}; Vector3 velocity; - bool active; - float angle_rand; - float scale_rand; - float hue_rot_rand; - float anim_offset_rand; - float time; - float lifetime; + bool active = false; + float angle_rand = 0.0; + float scale_rand = 0.0; + float hue_rot_rand = 0.0; + float anim_offset_rand = 0.0; + float time = 0.0; + float lifetime = 0.0; Color base_color; - uint32_t seed; + uint32_t seed = 0; }; - float time; - float inactive_time; - float frame_remainder; - int cycle; - bool redraw; + float time = 0.0; + float inactive_time = 0.0; + float frame_remainder = 0.0; + int cycle = 0; + bool redraw = false; RID multimesh; @@ -110,7 +110,7 @@ private: Vector<int> particle_order; struct SortLifetime { - const Particle *particles; + const Particle *particles = nullptr; bool operator()(int p_a, int p_b) const { return particles[p_a].time > particles[p_b].time; @@ -118,7 +118,7 @@ private: }; struct SortAxis { - const Particle *particles; + const Particle *particles = nullptr; Vector3 axis; bool operator()(int p_a, int p_b) const { return axis.dot(particles[p_a].transform.origin) < axis.dot(particles[p_b].transform.origin); @@ -127,50 +127,50 @@ private: // - bool one_shot; + bool one_shot = false; - float lifetime; - float pre_process_time; - float explosiveness_ratio; - float randomness_ratio; - float lifetime_randomness; - float speed_scale; - bool local_coords; - int fixed_fps; - bool fractional_delta; + float lifetime = 1.0; + float pre_process_time = 0.0; + float explosiveness_ratio = 0.0; + float randomness_ratio = 0.0; + float lifetime_randomness = 0.0; + float speed_scale = 1.0; + bool local_coords = true; + int fixed_fps = 0; + bool fractional_delta = true; Transform inv_emission_transform; - volatile bool can_update; + volatile bool can_update = false; - DrawOrder draw_order; + DrawOrder draw_order = DRAW_ORDER_INDEX; Ref<Mesh> mesh; //////// - Vector3 direction; - float spread; - float flatness; + Vector3 direction = Vector3(1, 0, 0); + float spread = 45.0; + float flatness = 0.0; float parameters[PARAM_MAX]; - float randomness[PARAM_MAX]; + float randomness[PARAM_MAX] = {}; Ref<Curve> curve_parameters[PARAM_MAX]; - Color color; + Color color = Color(1, 1, 1, 1); Ref<Gradient> color_ramp; - bool particle_flags[PARTICLE_FLAG_MAX]; + bool particle_flags[PARTICLE_FLAG_MAX] = {}; - EmissionShape emission_shape; - float emission_sphere_radius; - Vector3 emission_box_extents; + EmissionShape emission_shape = EMISSION_SHAPE_POINT; + float emission_sphere_radius = 1.0; + Vector3 emission_box_extents = Vector3(1, 1, 1); Vector<Vector3> emission_points; Vector<Vector3> emission_normals; Vector<Color> emission_colors; - int emission_point_count; + int emission_point_count = 0; - Vector3 gravity; + Vector3 gravity = Vector3(0, -9.8, 0); void _update_internal(); void _particles_process(float p_delta); diff --git a/scene/3d/decal.cpp b/scene/3d/decal.cpp index e67802cfc4..1cdea37dad 100644 --- a/scene/3d/decal.cpp +++ b/scene/3d/decal.cpp @@ -220,18 +220,6 @@ void Decal::_bind_methods() { } Decal::Decal() { - extents = Vector3(1, 1, 1); - emission_energy = 1.0; - modulate = Color(1, 1, 1, 1); - albedo_mix = 1.0; - cull_mask = (1 << 20) - 1; - upper_fade = 0.3; - lower_fade = 0.3; - normal_fade = 0; - distance_fade_enabled = false; - distance_fade_begin = 10; - distance_fade_length = 1; - decal = RenderingServer::get_singleton()->decal_create(); RS::get_singleton()->instance_set_base(get_instance(), decal); } diff --git a/scene/3d/decal.h b/scene/3d/decal.h index 500a1425f2..095579d775 100644 --- a/scene/3d/decal.h +++ b/scene/3d/decal.h @@ -49,18 +49,18 @@ public: private: RID decal; - Vector3 extents; + Vector3 extents = Vector3(1, 1, 1); Ref<Texture2D> textures[TEXTURE_MAX]; - float emission_energy; - float albedo_mix; - Color modulate; - uint32_t cull_mask; - float normal_fade; - float upper_fade; - float lower_fade; - bool distance_fade_enabled; - float distance_fade_begin; - float distance_fade_length; + float emission_energy = 1.0; + float albedo_mix = 1.0; + Color modulate = Color(1, 1, 1, 1); + uint32_t cull_mask = (1 << 20) - 1; + float normal_fade = 0.0; + float upper_fade = 0.3; + float lower_fade = 0.3; + bool distance_fade_enabled = false; + float distance_fade_begin = 10.0; + float distance_fade_length = 1.0; protected: static void _bind_methods(); diff --git a/scene/3d/gi_probe.cpp b/scene/3d/gi_probe.cpp index 0565193437..1f00eab092 100644 --- a/scene/3d/gi_probe.cpp +++ b/scene/3d/gi_probe.cpp @@ -286,17 +286,6 @@ void GIProbeData::_bind_methods() { } GIProbeData::GIProbeData() { - ao = 0.0; - ao_size = 0.5; - dynamic_range = 4; - energy = 1.0; - bias = 1.5; - normal_bias = 0.0; - propagation = 0.7; - anisotropy_strength = 0.5; - interior = false; - use_two_bounces = false; - probe = RS::get_singleton()->gi_probe_create(); } @@ -553,9 +542,6 @@ void GIProbe::_bind_methods() { } GIProbe::GIProbe() { - subdiv = SUBDIV_128; - extents = Vector3(10, 10, 10); - gi_probe = RS::get_singleton()->gi_probe_create(); set_disable_scale(true); } diff --git a/scene/3d/gi_probe.h b/scene/3d/gi_probe.h index afea94fe12..534b425557 100644 --- a/scene/3d/gi_probe.h +++ b/scene/3d/gi_probe.h @@ -46,16 +46,16 @@ class GIProbeData : public Resource { AABB bounds; Vector3 octree_size; - float dynamic_range; - float energy; - float bias; - float normal_bias; - float propagation; - float anisotropy_strength; - float ao; - float ao_size; - bool interior; - bool use_two_bounces; + float dynamic_range = 4.0; + float energy = 1.0; + float bias = 1.5; + float normal_bias = 0.0; + float propagation = 0.7; + float anisotropy_strength = 0.5; + float ao = 0.0; + float ao_size = 0.5; + bool interior = false; + bool use_two_bounces = false; protected: static void _bind_methods(); @@ -129,8 +129,8 @@ private: RID gi_probe; - Subdiv subdiv; - Vector3 extents; + Subdiv subdiv = SUBDIV_128; + Vector3 extents = Vector3(10, 10, 10); struct PlotMesh { Ref<Material> override_material; diff --git a/scene/3d/gpu_particles_collision_3d.h b/scene/3d/gpu_particles_collision_3d.h index 7d6301ee50..81c33663f3 100644 --- a/scene/3d/gpu_particles_collision_3d.h +++ b/scene/3d/gpu_particles_collision_3d.h @@ -130,16 +130,16 @@ private: LEAF_MASK = LEAF_BIT - 1 }; AABB bounds; - uint32_t children[2]; + uint32_t children[2] = {}; }; struct FacePos { Vector3 center; - uint32_t index; + uint32_t index = 0; }; struct FaceSort { - uint32_t axis; + uint32_t axis = 0; bool operator()(const FacePos &p_left, const FacePos &p_right) const { return p_left.center[axis] < p_right.center[axis]; } @@ -148,13 +148,13 @@ private: uint32_t _create_bvh(LocalVector<BVH> &bvh_tree, FacePos *p_faces, uint32_t p_face_count, const Face3 *p_triangles, float p_thickness); struct ComputeSDFParams { - float *cells; + float *cells = nullptr; Vector3i size; - float cell_size; + float cell_size = 0.0; Vector3 cell_offset; - const BVH *bvh; - const Face3 *triangles; - float thickness; + const BVH *bvh = nullptr; + const Face3 *triangles = nullptr; + float thickness = 0.0; }; void _find_closest_distance(const Vector3 &p_pos, const BVH *bvh, uint32_t p_bvh_cell, const Face3 *triangles, float thickness, float &closest_distance); diff --git a/scene/3d/immediate_geometry_3d.cpp b/scene/3d/immediate_geometry_3d.cpp index 47242cf196..d64babaa9d 100644 --- a/scene/3d/immediate_geometry_3d.cpp +++ b/scene/3d/immediate_geometry_3d.cpp @@ -150,7 +150,6 @@ void ImmediateGeometry3D::_bind_methods() { ImmediateGeometry3D::ImmediateGeometry3D() { im = RenderingServer::get_singleton()->immediate_create(); set_base(im); - empty = true; } ImmediateGeometry3D::~ImmediateGeometry3D() { diff --git a/scene/3d/immediate_geometry_3d.h b/scene/3d/immediate_geometry_3d.h index 8e546e27e7..ee4938d9f7 100644 --- a/scene/3d/immediate_geometry_3d.h +++ b/scene/3d/immediate_geometry_3d.h @@ -41,7 +41,7 @@ class ImmediateGeometry3D : public GeometryInstance3D { //a list of textures drawn need to be kept, to avoid references // in RenderingServer from becoming invalid if the texture is no longer used List<Ref<Texture2D>> cached_textures; - bool empty; + bool empty = true; AABB aabb; protected: diff --git a/scene/3d/light_3d.cpp b/scene/3d/light_3d.cpp index 1571b07aca..e6e23b927a 100644 --- a/scene/3d/light_3d.cpp +++ b/scene/3d/light_3d.cpp @@ -324,10 +324,6 @@ Light3D::Light3D(RenderingServer::LightType p_type) { RS::get_singleton()->instance_set_base(get_instance(), light); - reverse_cull = false; - bake_mode = BAKE_DYNAMIC; - - editor_only = false; set_color(Color(1, 1, 1, 1)); set_shadow(false); set_negative(false); @@ -357,7 +353,6 @@ Light3D::Light3D(RenderingServer::LightType p_type) { } Light3D::Light3D() { - type = RenderingServer::LIGHT_DIRECTIONAL; ERR_PRINT("Light3D should not be instanced directly; use the DirectionalLight3D, OmniLight3D or SpotLight3D subtypes instead."); } diff --git a/scene/3d/light_3d.h b/scene/3d/light_3d.h index 833598c4a1..311db54bce 100644 --- a/scene/3d/light_3d.h +++ b/scene/3d/light_3d.h @@ -71,16 +71,16 @@ public: private: Color color; - float param[PARAM_MAX]; + float param[PARAM_MAX] = {}; Color shadow_color; - bool shadow; - bool negative; - bool reverse_cull; - uint32_t cull_mask; - RS::LightType type; - bool editor_only; + bool shadow = false; + bool negative = false; + bool reverse_cull = false; + uint32_t cull_mask = 0; + RS::LightType type = RenderingServer::LIGHT_DIRECTIONAL; + bool editor_only = false; void _update_visibility(); - BakeMode bake_mode; + BakeMode bake_mode = BAKE_DYNAMIC; Ref<Texture2D> projector; // bind helpers diff --git a/scene/3d/listener_3d.cpp b/scene/3d/listener_3d.cpp index 23adb0aa19..9842f152d7 100644 --- a/scene/3d/listener_3d.cpp +++ b/scene/3d/listener_3d.cpp @@ -159,8 +159,6 @@ void Listener3D::_bind_methods() { } Listener3D::Listener3D() { - current = false; - force_change = false; set_notify_transform(true); //active=false; } diff --git a/scene/3d/listener_3d.h b/scene/3d/listener_3d.h index 2a78efb2c7..85657a8e53 100644 --- a/scene/3d/listener_3d.h +++ b/scene/3d/listener_3d.h @@ -38,8 +38,8 @@ class Listener3D : public Node3D { GDCLASS(Listener3D, Node3D); private: - bool force_change; - bool current; + bool force_change = false; + bool current = false; RID scenario_id; diff --git a/scene/3d/mesh_instance_3d.cpp b/scene/3d/mesh_instance_3d.cpp index 44dd6e0e5f..9029b5b028 100644 --- a/scene/3d/mesh_instance_3d.cpp +++ b/scene/3d/mesh_instance_3d.cpp @@ -428,7 +428,6 @@ void MeshInstance3D::_bind_methods() { } MeshInstance3D::MeshInstance3D() { - skeleton_path = NodePath(".."); } MeshInstance3D::~MeshInstance3D() { diff --git a/scene/3d/mesh_instance_3d.h b/scene/3d/mesh_instance_3d.h index 822e04e656..eb300784b1 100644 --- a/scene/3d/mesh_instance_3d.h +++ b/scene/3d/mesh_instance_3d.h @@ -44,15 +44,11 @@ protected: Ref<Skin> skin; Ref<Skin> skin_internal; Ref<SkinReference> skin_ref; - NodePath skeleton_path; + NodePath skeleton_path = NodePath(".."); struct BlendShapeTrack { - int idx; - float value; - BlendShapeTrack() { - idx = 0; - value = 0; - } + int idx = 0; + float value = 0.0; }; Map<StringName, BlendShapeTrack> blend_shape_tracks; diff --git a/scene/3d/navigation_3d.cpp b/scene/3d/navigation_3d.cpp index 2a7195be1a..eaddec7601 100644 --- a/scene/3d/navigation_3d.cpp +++ b/scene/3d/navigation_3d.cpp @@ -110,8 +110,6 @@ Navigation3D::Navigation3D() { set_cell_size(0.3); set_edge_connection_margin(5.0); // Five meters, depends a lot on the agent's radius - - up = Vector3(0, 1, 0); } Navigation3D::~Navigation3D() { diff --git a/scene/3d/navigation_3d.h b/scene/3d/navigation_3d.h index 3e8adaf5ff..b89725a3f5 100644 --- a/scene/3d/navigation_3d.h +++ b/scene/3d/navigation_3d.h @@ -39,7 +39,7 @@ class Navigation3D : public Node3D { RID map; - Vector3 up; + Vector3 up = Vector3(0, 1, 0); real_t cell_size; real_t edge_connection_margin; diff --git a/scene/3d/navigation_region_3d.cpp b/scene/3d/navigation_region_3d.cpp index e8cfa05a4b..a9acaefc65 100644 --- a/scene/3d/navigation_region_3d.cpp +++ b/scene/3d/navigation_region_3d.cpp @@ -150,7 +150,7 @@ Ref<NavigationMesh> NavigationRegion3D::get_navigation_mesh() const { } struct BakeThreadsArgs { - NavigationRegion3D *nav_region; + NavigationRegion3D *nav_region = nullptr; }; void _bake_navigation_mesh(void *p_user_data) { diff --git a/scene/3d/path_3d.h b/scene/3d/path_3d.h index 15e38c95e7..17ee47593e 100644 --- a/scene/3d/path_3d.h +++ b/scene/3d/path_3d.h @@ -66,10 +66,10 @@ public: private: Path3D *path = nullptr; - real_t delta_offset = 0; // Change in offset since last _update_transform. - real_t offset = 0; - real_t h_offset = 0; - real_t v_offset = 0; + real_t delta_offset = 0.0; // Change in offset since last _update_transform. + real_t offset = 0.0; + real_t h_offset = 0.0; + real_t v_offset = 0.0; bool cubic = true; bool loop = true; RotationMode rotation_mode = ROTATION_XYZ; diff --git a/scene/3d/physics_body_3d.cpp b/scene/3d/physics_body_3d.cpp index 71be943232..367dd7ec91 100644 --- a/scene/3d/physics_body_3d.cpp +++ b/scene/3d/physics_body_3d.cpp @@ -330,8 +330,8 @@ void RigidBody3D::_body_inout(int p_status, ObjectID p_instance, int p_body_shap struct _RigidBodyInOut { ObjectID id; - int shape; - int local_shape; + int shape = 0; + int local_shape = 0; }; void RigidBody3D::_direct_state_changed(Object *p_state) { @@ -825,24 +825,6 @@ void RigidBody3D::_bind_methods() { RigidBody3D::RigidBody3D() : PhysicsBody3D(PhysicsServer3D::BODY_MODE_RIGID) { - mode = MODE_RIGID; - - mass = 1; - max_contacts_reported = 0; - state = nullptr; - - gravity_scale = 1; - linear_damp = -1; - angular_damp = -1; - - //angular_velocity=0; - sleeping = false; - ccd = false; - - custom_integrator = false; - contact_monitor = nullptr; - can_sleep = true; - PhysicsServer3D::get_singleton()->body_set_force_integration_callback(get_rid(), this, "_direct_state_changed"); } @@ -1221,11 +1203,6 @@ void KinematicBody3D::_direct_state_changed(Object *p_state) { KinematicBody3D::KinematicBody3D() : PhysicsBody3D(PhysicsServer3D::BODY_MODE_KINEMATIC) { - locked_axis = 0; - on_floor = false; - on_ceiling = false; - on_wall = false; - set_safe_margin(0.001); PhysicsServer3D::get_singleton()->body_set_force_integration_callback(get_rid(), this, "_direct_state_changed"); } diff --git a/scene/3d/physics_body_3d.h b/scene/3d/physics_body_3d.h index 469c6b222c..1450fce6a6 100644 --- a/scene/3d/physics_body_3d.h +++ b/scene/3d/physics_body_3d.h @@ -111,31 +111,31 @@ public: }; protected: - bool can_sleep; - PhysicsDirectBodyState3D *state; - Mode mode; + bool can_sleep = true; + PhysicsDirectBodyState3D *state = nullptr; + Mode mode = MODE_RIGID; - real_t mass; + real_t mass = 1.0; Ref<PhysicsMaterial> physics_material_override; Vector3 linear_velocity; Vector3 angular_velocity; Basis inverse_inertia_tensor; - real_t gravity_scale; - real_t linear_damp; - real_t angular_damp; + real_t gravity_scale = 1.0; + real_t linear_damp = -1.0; + real_t angular_damp = -1.0; - bool sleeping; - bool ccd; + bool sleeping = false; + bool ccd = false; - int max_contacts_reported; + int max_contacts_reported = 0; - bool custom_integrator; + bool custom_integrator = false; struct ShapePair { - int body_shape; - int local_shape; - bool tagged; + int body_shape = 0; + int local_shape = 0; + bool tagged = false; bool operator<(const ShapePair &p_sp) const { if (body_shape == p_sp.body_shape) { return local_shape < p_sp.local_shape; @@ -157,16 +157,16 @@ protected: }; struct BodyState { //int rc; - bool in_tree; + bool in_tree = false; VSet<ShapePair> shapes; }; struct ContactMonitor { - bool locked; + bool locked = false; Map<ObjectID, BodyState> body_map; }; - ContactMonitor *contact_monitor; + ContactMonitor *contact_monitor = nullptr; void _body_enter_tree(ObjectID p_id); void _body_exit_tree(ObjectID p_id); @@ -261,27 +261,27 @@ public: Vector3 collider_vel; ObjectID collider; RID collider_rid; - int collider_shape; + int collider_shape = 0; Variant collider_metadata; Vector3 remainder; Vector3 travel; - int local_shape; + int local_shape = 0; }; private: Vector3 linear_velocity; Vector3 angular_velocity; - uint16_t locked_axis; + uint16_t locked_axis = 0; real_t margin; Vector3 floor_normal; Vector3 floor_velocity; RID on_floor_body; - bool on_floor; - bool on_ceiling; - bool on_wall; + bool on_floor = false; + bool on_ceiling = false; + bool on_wall = false; Vector<Collision> colliders; Vector<Ref<KinematicCollision3D>> slide_colliders; Ref<KinematicCollision3D> motion_cache; @@ -385,10 +385,8 @@ public: virtual void _get_property_list(List<PropertyInfo> *p_list) const; real_t bias = 0.3; - real_t damping = 1.; - real_t impulse_clamp = 0; - - PinJointData() {} + real_t damping = 1.0; + real_t impulse_clamp = 0.0; }; struct ConeJointData : public JointData { @@ -398,14 +396,11 @@ public: virtual bool _get(const StringName &p_name, Variant &r_ret) const; virtual void _get_property_list(List<PropertyInfo> *p_list) const; - real_t swing_span; + real_t swing_span = Math_PI * 0.25; real_t twist_span = Math_PI; real_t bias = 0.3; real_t softness = 0.8; real_t relaxation = 1.; - - ConeJointData() : - swing_span(Math_PI * 0.25) {} }; struct HingeJointData : public JointData { @@ -416,16 +411,11 @@ public: virtual void _get_property_list(List<PropertyInfo> *p_list) const; bool angular_limit_enabled = false; - real_t angular_limit_upper; - real_t angular_limit_lower; + real_t angular_limit_upper = Math_PI * 0.5; + real_t angular_limit_lower = -Math_PI * 0.5; real_t angular_limit_bias = 0.3; real_t angular_limit_softness = 0.9; real_t angular_limit_relaxation = 1.; - - HingeJointData() : - - angular_limit_upper(Math_PI * 0.5), - angular_limit_lower(-Math_PI * 0.5) {} }; struct SliderJointData : public JointData { @@ -435,45 +425,41 @@ public: virtual bool _get(const StringName &p_name, Variant &r_ret) const; virtual void _get_property_list(List<PropertyInfo> *p_list) const; - real_t linear_limit_upper = 1.; - real_t linear_limit_lower = -1.; - real_t linear_limit_softness = 1.; + real_t linear_limit_upper = 1.0; + real_t linear_limit_lower = -1.0; + real_t linear_limit_softness = 1.0; real_t linear_limit_restitution = 0.7; - real_t linear_limit_damping = 1.; - real_t angular_limit_upper = 0; - real_t angular_limit_lower = 0; - real_t angular_limit_softness = 1.; + real_t linear_limit_damping = 1.0; + real_t angular_limit_upper = 0.0; + real_t angular_limit_lower = 0.0; + real_t angular_limit_softness = 1.0; real_t angular_limit_restitution = 0.7; - real_t angular_limit_damping = 1.; - - SliderJointData() {} + real_t angular_limit_damping = 1.0; }; struct SixDOFJointData : public JointData { struct SixDOFAxisData { bool linear_limit_enabled = true; - real_t linear_limit_upper = 0; - real_t linear_limit_lower = 0; + real_t linear_limit_upper = 0.0; + real_t linear_limit_lower = 0.0; real_t linear_limit_softness = 0.7; real_t linear_restitution = 0.5; - real_t linear_damping = 1.; + real_t linear_damping = 1.0; bool linear_spring_enabled = false; - real_t linear_spring_stiffness = 0; - real_t linear_spring_damping = 0; - real_t linear_equilibrium_point = 0; + real_t linear_spring_stiffness = 0.0; + real_t linear_spring_damping = 0.0; + real_t linear_equilibrium_point = 0.0; bool angular_limit_enabled = true; - real_t angular_limit_upper = 0; - real_t angular_limit_lower = 0; + real_t angular_limit_upper = 0.0; + real_t angular_limit_lower = 0.0; real_t angular_limit_softness = 0.5; - real_t angular_restitution = 0; - real_t angular_damping = 1.; + real_t angular_restitution = 0.0; + real_t angular_damping = 1.0; real_t erp = 0.5; bool angular_spring_enabled = false; - real_t angular_spring_stiffness = 0; - real_t angular_spring_damping = 0.; - real_t angular_equilibrium_point = 0; - - SixDOFAxisData() {} + real_t angular_spring_stiffness = 0.0; + real_t angular_spring_damping = 0.0; + real_t angular_equilibrium_point = 0.0; }; virtual JointType get_joint_type() { return JOINT_TYPE_6DOF; } @@ -505,12 +491,12 @@ private: int bone_id = -1; String bone_name; - real_t bounce = 0; - real_t mass = 1; - real_t friction = 1; - real_t gravity_scale = 1; - real_t linear_damp = -1; - real_t angular_damp = -1; + real_t bounce = 0.0; + real_t mass = 1.0; + real_t friction = 1.0; + real_t gravity_scale = 1.0; + real_t linear_damp = -1.0; + real_t angular_damp = -1.0; bool can_sleep = true; protected: diff --git a/scene/3d/physics_joint_3d.cpp b/scene/3d/physics_joint_3d.cpp index b8d8af2385..624587cce4 100644 --- a/scene/3d/physics_joint_3d.cpp +++ b/scene/3d/physics_joint_3d.cpp @@ -245,8 +245,6 @@ void Joint3D::_bind_methods() { } Joint3D::Joint3D() { - exclude_from_collision = true; - solver_priority = 1; set_notify_transform(true); } diff --git a/scene/3d/physics_joint_3d.h b/scene/3d/physics_joint_3d.h index e5fd6e6c87..914ac3c392 100644 --- a/scene/3d/physics_joint_3d.h +++ b/scene/3d/physics_joint_3d.h @@ -44,8 +44,8 @@ class Joint3D : public Node3D { NodePath a; NodePath b; - int solver_priority; - bool exclude_from_collision; + int solver_priority = 1; + bool exclude_from_collision = true; String warning; protected: diff --git a/scene/3d/ray_cast_3d.cpp b/scene/3d/ray_cast_3d.cpp index 0b7c15a023..bfe79f15f5 100644 --- a/scene/3d/ray_cast_3d.cpp +++ b/scene/3d/ray_cast_3d.cpp @@ -392,13 +392,4 @@ void RayCast3D::_clear_debug_shape() { } RayCast3D::RayCast3D() { - enabled = true; - collided = false; - against_shape = 0; - collision_mask = 1; - target_position = Vector3(0, -1, 0); - debug_shape = nullptr; - exclude_parent_body = true; - collide_with_areas = false; - collide_with_bodies = true; } diff --git a/scene/3d/ray_cast_3d.h b/scene/3d/ray_cast_3d.h index 4109853280..ae92189527 100644 --- a/scene/3d/ray_cast_3d.h +++ b/scene/3d/ray_cast_3d.h @@ -36,28 +36,28 @@ class RayCast3D : public Node3D { GDCLASS(RayCast3D, Node3D); - bool enabled; - bool collided; + bool enabled = true; + bool collided = false; ObjectID against; - int against_shape; + int against_shape = 0; Vector3 collision_point; Vector3 collision_normal; - Vector3 target_position; + Vector3 target_position = Vector3(0, -1, 0); Set<RID> exclude; - uint32_t collision_mask; - bool exclude_parent_body; + uint32_t collision_mask = 1; + bool exclude_parent_body = true; - Node *debug_shape; + Node *debug_shape = nullptr; Ref<Material> debug_material; void _create_debug_shape(); void _update_debug_shape(); void _clear_debug_shape(); - bool collide_with_areas; - bool collide_with_bodies; + bool collide_with_areas = false; + bool collide_with_bodies = true; protected: void _notification(int p_what); diff --git a/scene/3d/reflection_probe.cpp b/scene/3d/reflection_probe.cpp index 63fa0c06c3..74f7fe2b52 100644 --- a/scene/3d/reflection_probe.cpp +++ b/scene/3d/reflection_probe.cpp @@ -257,20 +257,6 @@ void ReflectionProbe::_bind_methods() { } ReflectionProbe::ReflectionProbe() { - intensity = 1.0; - ambient_mode = AMBIENT_ENVIRONMENT; - ambient_color = Color(0, 0, 0); - ambient_color_energy = 1.0; - max_distance = 0; - extents = Vector3(1, 1, 1); - origin_offset = Vector3(0, 0, 0); - box_projection = false; - interior = false; - enable_shadows = false; - cull_mask = (1 << 20) - 1; - update_mode = UPDATE_ONCE; - lod_threshold = 1.0; - probe = RenderingServer::get_singleton()->reflection_probe_create(); RS::get_singleton()->instance_set_base(get_instance(), probe); set_disable_scale(true); diff --git a/scene/3d/reflection_probe.h b/scene/3d/reflection_probe.h index a43d4e2422..15c2da3ae0 100644 --- a/scene/3d/reflection_probe.h +++ b/scene/3d/reflection_probe.h @@ -53,20 +53,20 @@ public: private: RID probe; - float intensity; - float max_distance; - Vector3 extents; - Vector3 origin_offset; - bool box_projection; - bool enable_shadows; - bool interior; - AmbientMode ambient_mode; - Color ambient_color; - float ambient_color_energy; - float lod_threshold; - - uint32_t cull_mask; - UpdateMode update_mode; + float intensity = 1.0; + float max_distance = 0.0; + Vector3 extents = Vector3(1, 1, 1); + Vector3 origin_offset = Vector3(0, 0, 0); + bool box_projection = false; + bool enable_shadows = false; + bool interior = false; + AmbientMode ambient_mode = AMBIENT_ENVIRONMENT; + Color ambient_color = Color(0, 0, 0); + float ambient_color_energy = 1.0; + float lod_threshold = 1.0; + + uint32_t cull_mask = (1 << 20) - 1; + UpdateMode update_mode = UPDATE_ONCE; protected: static void _bind_methods(); diff --git a/scene/3d/remote_transform_3d.cpp b/scene/3d/remote_transform_3d.cpp index 4afbb80779..83ac813c53 100644 --- a/scene/3d/remote_transform_3d.cpp +++ b/scene/3d/remote_transform_3d.cpp @@ -217,10 +217,5 @@ void RemoteTransform3D::_bind_methods() { } RemoteTransform3D::RemoteTransform3D() { - use_global_coordinates = true; - update_remote_position = true; - update_remote_rotation = true; - update_remote_scale = true; - set_notify_transform(true); } diff --git a/scene/3d/remote_transform_3d.h b/scene/3d/remote_transform_3d.h index 3b30c835be..21005d92d1 100644 --- a/scene/3d/remote_transform_3d.h +++ b/scene/3d/remote_transform_3d.h @@ -40,10 +40,10 @@ class RemoteTransform3D : public Node3D { ObjectID cache; - bool use_global_coordinates; - bool update_remote_position; - bool update_remote_rotation; - bool update_remote_scale; + bool use_global_coordinates = true; + bool update_remote_position = true; + bool update_remote_rotation = true; + bool update_remote_scale = true; void _update_remote(); void _update_cache(); diff --git a/scene/3d/skeleton_3d.cpp b/scene/3d/skeleton_3d.cpp index 5e09a15b80..ac2e9bf871 100644 --- a/scene/3d/skeleton_3d.cpp +++ b/scene/3d/skeleton_3d.cpp @@ -927,10 +927,6 @@ void Skeleton3D::_bind_methods() { } Skeleton3D::Skeleton3D() { - animate_physical_bones = true; - dirty = false; - version = 1; - process_order_dirty = true; } Skeleton3D::~Skeleton3D() { diff --git a/scene/3d/skeleton_3d.h b/scene/3d/skeleton_3d.h index 73417dce21..9772bfcc95 100644 --- a/scene/3d/skeleton_3d.h +++ b/scene/3d/skeleton_3d.h @@ -74,57 +74,44 @@ private: struct Bone { String name; - bool enabled; - int parent; - int sort_index; //used for re-sorting process order + bool enabled = true; + int parent = -1; + int sort_index = 0; //used for re-sorting process order - bool disable_rest; + bool disable_rest = false; Transform rest; Transform pose; Transform pose_global; - bool custom_pose_enable; + bool custom_pose_enable = false; Transform custom_pose; - float global_pose_override_amount; - bool global_pose_override_reset; + float global_pose_override_amount = 0.0; + bool global_pose_override_reset = false; Transform global_pose_override; #ifndef _3D_DISABLED - PhysicalBone3D *physical_bone; - PhysicalBone3D *cache_parent_physical_bone; + PhysicalBone3D *physical_bone = nullptr; + PhysicalBone3D *cache_parent_physical_bone = nullptr; #endif // _3D_DISABLED List<ObjectID> nodes_bound; - - Bone() { - parent = -1; - enabled = true; - disable_rest = false; - custom_pose_enable = false; - global_pose_override_amount = 0; - global_pose_override_reset = false; -#ifndef _3D_DISABLED - physical_bone = nullptr; - cache_parent_physical_bone = nullptr; -#endif // _3D_DISABLED - } }; Set<SkinReference *> skin_bindings; void _skin_changed(); - bool animate_physical_bones; + bool animate_physical_bones = true; Vector<Bone> bones; Vector<int> process_order; - bool process_order_dirty; + bool process_order_dirty = true; void _make_dirty(); - bool dirty; + bool dirty = false; - uint64_t version; + uint64_t version = 1; // bind helpers Array _get_bound_child_nodes_to_bone(int p_bone) const { diff --git a/scene/3d/skeleton_ik_3d.h b/scene/3d/skeleton_ik_3d.h index 557647aa62..eefecf68bb 100644 --- a/scene/3d/skeleton_ik_3d.h +++ b/scene/3d/skeleton_ik_3d.h @@ -54,15 +54,13 @@ class FabrikInverseKinematic { BoneId bone = -1; PhysicalBone3D *pb = nullptr; - real_t length = 0; + real_t length = 0.0; /// Positions relative to root bone Transform initial_transform; Vector3 current_pos; // Direction from this bone to child Vector3 current_ori; - ChainItem() {} - ChainItem *find_child(const BoneId p_bone_id); ChainItem *add_child(const BoneId p_bone_id); }; @@ -80,7 +78,7 @@ class FabrikInverseKinematic { struct Chain { ChainItem chain_root; - ChainItem *middle_chain_item; + ChainItem *middle_chain_item = nullptr; Vector<ChainTip> tips; Vector3 magnet_position; }; @@ -130,7 +128,7 @@ class SkeletonIK3D : public Node { StringName root_bone; StringName tip_bone; - real_t interpolation = 1; + real_t interpolation = 1.0; Transform target; NodePath target_node_path_override; bool override_tip_basis = true; diff --git a/scene/3d/soft_body_3d.h b/scene/3d/soft_body_3d.h index d3c5dc022f..288deb0673 100644 --- a/scene/3d/soft_body_3d.h +++ b/scene/3d/soft_body_3d.h @@ -39,13 +39,13 @@ class SoftBodyRenderingServerHandler { friend class SoftBody3D; RID mesh; - int surface; + int surface = 0; Vector<uint8_t> buffer; - uint32_t stride; - uint32_t offset_vertices; - uint32_t offset_normal; + uint32_t stride = 0; + uint32_t offset_vertices = 0; + uint32_t offset_normal = 0; - uint8_t *write_buffer; + uint8_t *write_buffer = nullptr; private: SoftBodyRenderingServerHandler(); @@ -91,9 +91,9 @@ private: bool pinned_points_cache_dirty = true; Ref<ArrayMesh> debug_mesh_cache; - class MeshInstance3D *debug_mesh; + class MeshInstance3D *debug_mesh = nullptr; - bool capture_input_on_drag; + bool capture_input_on_drag = false; bool ray_pickable = true; void _update_pickable(); diff --git a/scene/3d/spring_arm_3d.h b/scene/3d/spring_arm_3d.h index 864919c631..63505ab9d3 100644 --- a/scene/3d/spring_arm_3d.h +++ b/scene/3d/spring_arm_3d.h @@ -38,8 +38,8 @@ class SpringArm3D : public Node3D { Ref<Shape3D> shape; Set<RID> excluded_objects; - real_t spring_length = 1; - real_t current_spring_length = 0; + real_t spring_length = 1.0; + real_t current_spring_length = 0.0; bool keep_child_basis = false; uint32_t mask = 1; real_t margin = 0.01; diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp index 3e49750366..f178daad42 100644 --- a/scene/3d/sprite_3d.cpp +++ b/scene/3d/sprite_3d.cpp @@ -339,24 +339,10 @@ void SpriteBase3D::_bind_methods() { } SpriteBase3D::SpriteBase3D() { - color_dirty = true; - centered = true; - hflip = false; - vflip = false; - parent_sprite = nullptr; - pI = nullptr; - for (int i = 0; i < FLAG_MAX; i++) { flags[i] = i == FLAG_TRANSPARENT || i == FLAG_DOUBLE_SIDED; } - alpha_cut = ALPHA_CUT_DISABLED; - billboard_mode = StandardMaterial3D::BILLBOARD_DISABLED; - axis = Vector3::AXIS_Z; - pixel_size = 0.01; - modulate = Color(1, 1, 1, 1); - pending_update = false; - opacity = 1.0; immediate = RenderingServer::get_singleton()->immediate_create(); set_base(immediate); } @@ -1109,8 +1095,4 @@ void AnimatedSprite3D::_bind_methods() { } AnimatedSprite3D::AnimatedSprite3D() { - frame = 0; - playing = false; - animation = "default"; - timeout = 0; } diff --git a/scene/3d/sprite_3d.h b/scene/3d/sprite_3d.h index 3e38d4581e..a9ce2d8eee 100644 --- a/scene/3d/sprite_3d.h +++ b/scene/3d/sprite_3d.h @@ -55,32 +55,32 @@ public: }; private: - bool color_dirty; + bool color_dirty = true; Color color_accum; - SpriteBase3D *parent_sprite; + SpriteBase3D *parent_sprite = nullptr; List<SpriteBase3D *> children; - List<SpriteBase3D *>::Element *pI; + List<SpriteBase3D *>::Element *pI = nullptr; - bool centered; + bool centered = true; Point2 offset; - bool hflip; - bool vflip; + bool hflip = false; + bool vflip = false; - Color modulate; - float opacity; + Color modulate = Color(1, 1, 1, 1); + float opacity = 1.0; - Vector3::Axis axis; - float pixel_size; + Vector3::Axis axis = Vector3::AXIS_Z; + float pixel_size = 0.01; AABB aabb; RID immediate; bool flags[FLAG_MAX]; - AlphaCutMode alpha_cut; - StandardMaterial3D::BillboardMode billboard_mode; - bool pending_update; + AlphaCutMode alpha_cut = ALPHA_CUT_DISABLED; + StandardMaterial3D::BillboardMode billboard_mode = StandardMaterial3D::BILLBOARD_DISABLED; + bool pending_update = false; void _im_update(); void _propagate_color_changed(); @@ -195,16 +195,16 @@ class AnimatedSprite3D : public SpriteBase3D { GDCLASS(AnimatedSprite3D, SpriteBase3D); Ref<SpriteFrames> frames; - bool playing; - StringName animation; - int frame; + bool playing = false; + StringName animation = "default"; + int frame = 0; - bool centered; + bool centered = true; - float timeout; + float timeout = 0.0; - bool hflip; - bool vflip; + bool hflip = 1; + bool vflip = 1; Color modulate; diff --git a/scene/3d/vehicle_body_3d.cpp b/scene/3d/vehicle_body_3d.cpp index ec8a300653..0d25e2f21f 100644 --- a/scene/3d/vehicle_body_3d.cpp +++ b/scene/3d/vehicle_body_3d.cpp @@ -344,30 +344,6 @@ real_t VehicleWheel3D::get_rpm() const { } VehicleWheel3D::VehicleWheel3D() { - steers = false; - engine_traction = false; - m_steering = real_t(0.); - m_engineForce = real_t(0.); - m_rotation = real_t(0.); - m_deltaRotation = real_t(0.); - m_brake = real_t(0.); - m_rollInfluence = real_t(0.1); - - m_suspensionRestLength = 0.15; - m_wheelRadius = 0.5; //0.28; - m_suspensionStiffness = 5.88; - m_wheelsDampingCompression = 0.83; - m_wheelsDampingRelaxation = 0.88; - m_frictionSlip = 10.5; - m_bIsFrontWheel = false; - m_maxSuspensionTravelCm = 500; - m_maxSuspensionForce = 6000; - - m_suspensionRelativeVelocity = 0; - m_clippedInvContactDotSuspension = 1.0; - m_raycastInfo.m_isInContact = false; - - body = nullptr; } void VehicleBody3D::_update_wheel_transform(VehicleWheel3D &wheel, PhysicsDirectBodyState3D *s) { @@ -948,16 +924,6 @@ void VehicleBody3D::_bind_methods() { } VehicleBody3D::VehicleBody3D() { - m_pitchControl = 0; - m_currentVehicleSpeedKmHour = real_t(0.); - m_steeringValue = real_t(0.); - - engine_force = 0; - brake = 0; - - state = nullptr; - ccd = false; - exclude.insert(get_rid()); //PhysicsServer3D::get_singleton()->body_set_force_integration_callback(get_rid(), this, "_direct_state_changed"); diff --git a/scene/3d/vehicle_body_3d.h b/scene/3d/vehicle_body_3d.h index 790179a8f0..3c35c0ce97 100644 --- a/scene/3d/vehicle_body_3d.h +++ b/scene/3d/vehicle_body_3d.h @@ -42,51 +42,51 @@ class VehicleWheel3D : public Node3D { Transform m_worldTransform; Transform local_xform; - bool engine_traction; - bool steers; + bool engine_traction = false; + bool steers = false; Vector3 m_chassisConnectionPointCS; //const Vector3 m_wheelDirectionCS; //const Vector3 m_wheelAxleCS; // const or modified by steering - real_t m_suspensionRestLength; - real_t m_maxSuspensionTravelCm; - real_t m_wheelRadius; + real_t m_suspensionRestLength = 0.15; + real_t m_maxSuspensionTravelCm = 500.0; + real_t m_wheelRadius = 0.5; - real_t m_suspensionStiffness; - real_t m_wheelsDampingCompression; - real_t m_wheelsDampingRelaxation; - real_t m_frictionSlip; - real_t m_maxSuspensionForce; - bool m_bIsFrontWheel; + real_t m_suspensionStiffness = 5.88; + real_t m_wheelsDampingCompression = 0.83; + real_t m_wheelsDampingRelaxation = 0.88; + real_t m_frictionSlip = 10.5; + real_t m_maxSuspensionForce = 6000.0; + bool m_bIsFrontWheel = false; - VehicleBody3D *body; + VehicleBody3D *body = nullptr; //btVector3 m_wheelAxleCS; // const or modified by steering ? - real_t m_steering; - real_t m_rotation; - real_t m_deltaRotation; - real_t m_rpm; - real_t m_rollInfluence; - real_t m_engineForce; - real_t m_brake; + real_t m_steering = 0.0; + real_t m_rotation = 0.0; + real_t m_deltaRotation = 0.0; + real_t m_rpm = 0.0; + real_t m_rollInfluence = 0.1; + real_t m_engineForce = 0.0; + real_t m_brake = 0.0; - real_t m_clippedInvContactDotSuspension; - real_t m_suspensionRelativeVelocity; + real_t m_clippedInvContactDotSuspension = 1.0; + real_t m_suspensionRelativeVelocity = 0.0; //calculated by suspension - real_t m_wheelsSuspensionForce; - real_t m_skidInfo; + real_t m_wheelsSuspensionForce = 0.0; + real_t m_skidInfo = 0.0; struct RaycastInfo { //set by raycaster Vector3 m_contactNormalWS; //contactnormal Vector3 m_contactPointWS; //raycast hitpoint - real_t m_suspensionLength; + real_t m_suspensionLength = 0.0; Vector3 m_hardPointWS; //raycast starting point Vector3 m_wheelDirectionWS; //direction in worldspace Vector3 m_wheelAxleWS; // axle in worldspace - bool m_isInContact; + bool m_isInContact = false; PhysicsBody3D *m_groundObject; //could be general void* ptr } m_raycastInfo; @@ -153,12 +153,12 @@ public: class VehicleBody3D : public RigidBody3D { GDCLASS(VehicleBody3D, RigidBody3D); - real_t engine_force; - real_t brake; + real_t engine_force = 0.0; + real_t brake = 0.0; - real_t m_pitchControl; - real_t m_steeringValue; - real_t m_currentVehicleSpeedKmHour; + real_t m_pitchControl = 0.0; + real_t m_steeringValue = 0.0; + real_t m_currentVehicleSpeedKmHour = 0.0; Set<RID> exclude; @@ -168,12 +168,12 @@ class VehicleBody3D : public RigidBody3D { Vector<real_t> m_sideImpulse; struct btVehicleWheelContactPoint { - PhysicsDirectBodyState3D *m_s; - PhysicsBody3D *m_body1; + PhysicsDirectBodyState3D *m_s = nullptr; + PhysicsBody3D *m_body1 = nullptr; Vector3 m_frictionPositionWorld; Vector3 m_frictionDirectionWorld; - real_t m_jacDiagABInv; - real_t m_maxImpulse; + real_t m_jacDiagABInv = 0.0; + real_t m_maxImpulse = 0.0; btVehicleWheelContactPoint(PhysicsDirectBodyState3D *s, PhysicsBody3D *body1, const Vector3 &frictionPosWorld, const Vector3 &frictionDirectionWorld, real_t maxImpulse); }; diff --git a/scene/3d/velocity_tracker_3d.cpp b/scene/3d/velocity_tracker_3d.cpp index 35d00f3639..5b5cc06456 100644 --- a/scene/3d/velocity_tracker_3d.cpp +++ b/scene/3d/velocity_tracker_3d.cpp @@ -128,6 +128,4 @@ void VelocityTracker3D::_bind_methods() { VelocityTracker3D::VelocityTracker3D() { position_history.resize(4); // should be configurable - position_history_len = 0; - physics_step = false; } diff --git a/scene/3d/velocity_tracker_3d.h b/scene/3d/velocity_tracker_3d.h index 3fc89cc7fb..e971f4755a 100644 --- a/scene/3d/velocity_tracker_3d.h +++ b/scene/3d/velocity_tracker_3d.h @@ -37,13 +37,13 @@ class VelocityTracker3D : public Reference { GDCLASS(VelocityTracker3D, Reference); struct PositionHistory { - uint64_t frame; + uint64_t frame = 0; Vector3 position; }; - bool physics_step; + bool physics_step = false; Vector<PositionHistory> position_history; - int position_history_len; + int position_history_len = 0; protected: static void _bind_methods(); diff --git a/scene/3d/visibility_notifier_3d.cpp b/scene/3d/visibility_notifier_3d.cpp index 14c7659de4..68a275684b 100644 --- a/scene/3d/visibility_notifier_3d.cpp +++ b/scene/3d/visibility_notifier_3d.cpp @@ -112,7 +112,6 @@ void VisibilityNotifier3D::_bind_methods() { } VisibilityNotifier3D::VisibilityNotifier3D() { - aabb = AABB(Vector3(-1, -1, -1), Vector3(2, 2, 2)); set_notify_transform(true); } @@ -252,6 +251,4 @@ VisibilityEnabler3D::VisibilityEnabler3D() { for (int i = 0; i < ENABLER_MAX; i++) { enabler[i] = true; } - - visible = false; } diff --git a/scene/3d/visibility_notifier_3d.h b/scene/3d/visibility_notifier_3d.h index d566b7e40b..9f7705067f 100644 --- a/scene/3d/visibility_notifier_3d.h +++ b/scene/3d/visibility_notifier_3d.h @@ -41,7 +41,7 @@ class VisibilityNotifier3D : public Node3D { Ref<World3D> world; Set<Camera3D *> cameras; - AABB aabb; + AABB aabb = AABB(Vector3(-1, -1, -1), Vector3(2, 2, 2)); protected: virtual void _screen_enter() {} @@ -76,7 +76,7 @@ protected: virtual void _screen_enter() override; virtual void _screen_exit() override; - bool visible; + bool visible = false; void _find_nodes(Node *p_node); diff --git a/scene/3d/visual_instance_3d.cpp b/scene/3d/visual_instance_3d.cpp index dd731d13bd..61591cfd10 100644 --- a/scene/3d/visual_instance_3d.cpp +++ b/scene/3d/visual_instance_3d.cpp @@ -135,7 +135,6 @@ RID VisualInstance3D::get_base() const { VisualInstance3D::VisualInstance3D() { instance = RenderingServer::get_singleton()->instance_create(); RenderingServer::get_singleton()->instance_attach_object_instance_id(instance, get_instance_id()); - layers = 1; set_notify_transform(true); } @@ -412,17 +411,5 @@ void GeometryInstance3D::_bind_methods() { } GeometryInstance3D::GeometryInstance3D() { - lod_min_distance = 0; - lod_max_distance = 0; - lod_min_hysteresis = 0; - lod_max_hysteresis = 0; - - lod_bias = 1.0; - - gi_mode = GI_MODE_DISABLED; - lightmap_scale = LIGHTMAP_SCALE_1X; - - shadow_casting_setting = SHADOW_CASTING_SETTING_ON; - extra_cull_margin = 0; //RS::get_singleton()->instance_geometry_set_baked_light_texture_index(get_instance(),0); } diff --git a/scene/3d/visual_instance_3d.h b/scene/3d/visual_instance_3d.h index f370f29cb0..7fed8095ef 100644 --- a/scene/3d/visual_instance_3d.h +++ b/scene/3d/visual_instance_3d.h @@ -42,7 +42,7 @@ class VisualInstance3D : public Node3D { RID base; RID instance; - uint32_t layers; + uint32_t layers = 1; RID _get_visual_instance_rid() const; @@ -105,21 +105,21 @@ public: }; private: - ShadowCastingSetting shadow_casting_setting; + ShadowCastingSetting shadow_casting_setting = SHADOW_CASTING_SETTING_ON; Ref<Material> material_override; - float lod_min_distance; - float lod_max_distance; - float lod_min_hysteresis; - float lod_max_hysteresis; + float lod_min_distance = 0.0; + float lod_max_distance = 0.0; + float lod_min_hysteresis = 0.0; + float lod_max_hysteresis = 0.0; - float lod_bias; + float lod_bias = 1.0; mutable HashMap<StringName, Variant> instance_uniforms; mutable HashMap<StringName, StringName> instance_uniform_property_remap; - float extra_cull_margin; - LightmapScale lightmap_scale; - GIMode gi_mode; + float extra_cull_margin = 0.0; + LightmapScale lightmap_scale = LIGHTMAP_SCALE_1X; + GIMode gi_mode = GI_MODE_DISABLED; const StringName *_instance_uniform_get_remap(const StringName p_name) const; diff --git a/scene/3d/voxelizer.cpp b/scene/3d/voxelizer.cpp index b99d753dde..17c8596e8f 100644 --- a/scene/3d/voxelizer.cpp +++ b/scene/3d/voxelizer.cpp @@ -1007,7 +1007,4 @@ Transform Voxelizer::get_to_cell_space_xform() const { } Voxelizer::Voxelizer() { - sorted = false; - color_scan_cell_width = 4; - bake_texture_size = 128; } diff --git a/scene/3d/voxelizer.h b/scene/3d/voxelizer.h index a0b581d625..87f949e7db 100644 --- a/scene/3d/voxelizer.h +++ b/scene/3d/voxelizer.h @@ -44,35 +44,25 @@ private: struct Cell { uint32_t children[8]; - float albedo[3]; //albedo in RGB24 - float emission[3]; //accumulated light in 16:16 fixed point (needs to be integer for moving lights fast) - float normal[3]; - uint32_t used_sides; - float alpha; //used for upsampling - uint16_t x; - uint16_t y; - uint16_t z; - uint16_t level; + float albedo[3] = {}; //albedo in RGB24 + float emission[3] = {}; //accumulated light in 16:16 fixed point (needs to be integer for moving lights fast) + float normal[3] = {}; + uint32_t used_sides = 0; + float alpha = 0.0; //used for upsampling + uint16_t x = 0; + uint16_t y = 0; + uint16_t z = 0; + uint16_t level = 0; Cell() { for (int i = 0; i < 8; i++) { children[i] = CHILD_EMPTY; } - - for (int i = 0; i < 3; i++) { - emission[i] = 0; - albedo[i] = 0; - normal[i] = 0; - } - alpha = 0; - used_sides = 0; - x = y = z = 0; - level = 0; } }; Vector<Cell> bake_cells; - int cell_subdiv; + int cell_subdiv = 0; struct CellSort { union { @@ -82,10 +72,10 @@ private: uint64_t x : 16; uint64_t level : 16; }; - uint64_t key; + uint64_t key = 0; }; - int32_t index; + int32_t index = 0; _FORCE_INLINE_ bool operator<(const CellSort &p_cell_sort) const { return key < p_cell_sort.key; @@ -101,16 +91,16 @@ private: Map<Ref<Material>, MaterialCache> material_cache; AABB original_bounds; AABB po2_bounds; - int axis_cell_size[3]; + int axis_cell_size[3] = {}; Transform to_cell_space; - int color_scan_cell_width; - int bake_texture_size; - float cell_size; + int color_scan_cell_width = 4; + int bake_texture_size = 128; + float cell_size = 0.0; - int max_original_cells; - int leaf_voxel_count; + int max_original_cells = 0; + int leaf_voxel_count = 0; Vector<Color> _get_bake_texture(Ref<Image> p_image, const Color &p_color_mul, const Color &p_color_add); MaterialCache _get_material_cache(Ref<Material> p_material); @@ -119,7 +109,7 @@ private: void _fixup_plot(int p_idx, int p_level); void _debug_mesh(int p_idx, int p_level, const AABB &p_aabb, Ref<MultiMesh> &p_multimesh, int &idx); - bool sorted; + bool sorted = false; void _sort(); public: diff --git a/scene/animation/animation_blend_space_1d.cpp b/scene/animation/animation_blend_space_1d.cpp index 41e1318b1f..15f562242f 100644 --- a/scene/animation/animation_blend_space_1d.cpp +++ b/scene/animation/animation_blend_space_1d.cpp @@ -311,14 +311,6 @@ AnimationNodeBlendSpace1D::AnimationNodeBlendSpace1D() { for (int i = 0; i < MAX_BLEND_POINTS; i++) { blend_points[i].name = itos(i); } - blend_points_used = 0; - max_space = 1; - min_space = -1; - - snap = 0.1; - value_label = "value"; - - blend_position = "blend_position"; } AnimationNodeBlendSpace1D::~AnimationNodeBlendSpace1D() { diff --git a/scene/animation/animation_blend_space_1d.h b/scene/animation/animation_blend_space_1d.h index 6edbc4e319..8886e6c679 100644 --- a/scene/animation/animation_blend_space_1d.h +++ b/scene/animation/animation_blend_space_1d.h @@ -43,24 +43,24 @@ class AnimationNodeBlendSpace1D : public AnimationRootNode { struct BlendPoint { StringName name; Ref<AnimationRootNode> node; - float position; + float position = 0.0; }; BlendPoint blend_points[MAX_BLEND_POINTS]; - int blend_points_used; + int blend_points_used = 0; - float max_space; - float min_space; + float max_space = 1.0; + float min_space = -1.0; - float snap; + float snap = 0.1; - String value_label; + String value_label = "value"; void _add_blend_point(int p_index, const Ref<AnimationRootNode> &p_node); void _tree_changed(); - StringName blend_position; + StringName blend_position = "blend_position"; protected: virtual void _validate_property(PropertyInfo &property) const override; diff --git a/scene/animation/animation_blend_space_2d.cpp b/scene/animation/animation_blend_space_2d.cpp index c32cc82bd8..b80ae30f1a 100644 --- a/scene/animation/animation_blend_space_2d.cpp +++ b/scene/animation/animation_blend_space_2d.cpp @@ -665,18 +665,6 @@ AnimationNodeBlendSpace2D::AnimationNodeBlendSpace2D() { for (int i = 0; i < MAX_BLEND_POINTS; i++) { blend_points[i].name = itos(i); } - auto_triangles = true; - blend_points_used = 0; - max_space = Vector2(1, 1); - min_space = Vector2(-1, -1); - snap = Vector2(0.1, 0.1); - x_label = "x"; - y_label = "y"; - trianges_dirty = false; - blend_position = "blend_position"; - closest = "closest"; - length_internal = "length_internal"; - blend_mode = BLEND_MODE_INTERPOLATED; } AnimationNodeBlendSpace2D::~AnimationNodeBlendSpace2D() { diff --git a/scene/animation/animation_blend_space_2d.h b/scene/animation/animation_blend_space_2d.h index c74afcb8ce..65d09a550d 100644 --- a/scene/animation/animation_blend_space_2d.h +++ b/scene/animation/animation_blend_space_2d.h @@ -55,23 +55,23 @@ protected: }; BlendPoint blend_points[MAX_BLEND_POINTS]; - int blend_points_used; + int blend_points_used = 0; struct BlendTriangle { - int points[3]; + int points[3] = {}; }; Vector<BlendTriangle> triangles; - StringName blend_position; - StringName closest; - StringName length_internal; - Vector2 max_space; - Vector2 min_space; - Vector2 snap; - String x_label; - String y_label; - BlendMode blend_mode; + StringName blend_position = "blend_position"; + StringName closest = "closest"; + StringName length_internal = "length_internal"; + Vector2 max_space = Vector2(1, 1); + Vector2 min_space = Vector2(-1, -1); + Vector2 snap = Vector2(0.1, 0.1); + String x_label = "x"; + String y_label = "y"; + BlendMode blend_mode = BLEND_MODE_INTERPOLATED; void _add_blend_point(int p_index, const Ref<AnimationRootNode> &p_node); void _set_triangles(const Vector<int> &p_triangles); @@ -79,8 +79,8 @@ protected: void _blend_triangle(const Vector2 &p_pos, const Vector2 *p_points, float *r_weights); - bool auto_triangles; - bool trianges_dirty; + bool auto_triangles = true; + bool trianges_dirty = false; void _update_triangles(); void _queue_auto_triangles(); diff --git a/scene/animation/animation_blend_tree.cpp b/scene/animation/animation_blend_tree.cpp index 24ae01e9d8..4a0e9e99be 100644 --- a/scene/animation/animation_blend_tree.cpp +++ b/scene/animation/animation_blend_tree.cpp @@ -125,9 +125,6 @@ void AnimationNodeAnimation::_bind_methods() { } AnimationNodeAnimation::AnimationNodeAnimation() { - last_version = 0; - skip = false; - time = "time"; } //////////////////////////////////////////////////////// @@ -346,21 +343,6 @@ void AnimationNodeOneShot::_bind_methods() { AnimationNodeOneShot::AnimationNodeOneShot() { add_input("in"); add_input("shot"); - - fade_in = 0.1; - fade_out = 0.1; - autorestart = false; - autorestart_delay = 1; - autorestart_random_delay = 0; - - mix = MIX_MODE_BLEND; - sync = false; - - active = "active"; - prev_active = "prev_active"; - time = "time"; - remaining = "remaining"; - time_to_restart = "time_to_restart"; } //////////////////////////////////////////////// @@ -405,10 +387,8 @@ void AnimationNodeAdd2::_bind_methods() { } AnimationNodeAdd2::AnimationNodeAdd2() { - add_amount = "add_amount"; add_input("in"); add_input("add"); - sync = false; } //////////////////////////////////////////////// @@ -454,11 +434,9 @@ void AnimationNodeAdd3::_bind_methods() { } AnimationNodeAdd3::AnimationNodeAdd3() { - add_amount = "add_amount"; add_input("-add"); add_input("in"); add_input("+add"); - sync = false; } ///////////////////////////////////////////// @@ -504,10 +482,8 @@ void AnimationNodeBlend2::_bind_methods() { } AnimationNodeBlend2::AnimationNodeBlend2() { - blend_amount = "blend_amount"; add_input("in"); add_input("blend"); - sync = false; } ////////////////////////////////////// @@ -583,7 +559,6 @@ void AnimationNodeTimeScale::_bind_methods() { } AnimationNodeTimeScale::AnimationNodeTimeScale() { - scale = "scale"; add_input("in"); } @@ -620,7 +595,6 @@ void AnimationNodeTimeSeek::_bind_methods() { AnimationNodeTimeSeek::AnimationNodeTimeSeek() { add_input("in"); - seek_pos = "seek_position"; } ///////////////////////////////////////////////// @@ -811,16 +785,7 @@ void AnimationNodeTransition::_bind_methods() { } AnimationNodeTransition::AnimationNodeTransition() { - prev_xfading = "prev_xfading"; - prev = "prev"; - time = "time"; - current = "current"; - prev_current = "prev_current"; - xfade = 0.0; - - enabled_inputs = 0; for (int i = 0; i < MAX_INPUTS; i++) { - inputs[i].auto_advance = false; inputs[i].name = "state " + itos(i); } } diff --git a/scene/animation/animation_blend_tree.h b/scene/animation/animation_blend_tree.h index 45a9f2e7e1..4732f43af2 100644 --- a/scene/animation/animation_blend_tree.h +++ b/scene/animation/animation_blend_tree.h @@ -37,10 +37,10 @@ class AnimationNodeAnimation : public AnimationRootNode { GDCLASS(AnimationNodeAnimation, AnimationRootNode); StringName animation; - StringName time; + StringName time = "time"; - uint64_t last_version; - bool skip; + uint64_t last_version = 0; + bool skip = false; protected: void _validate_property(PropertyInfo &property) const override; @@ -71,26 +71,26 @@ public: }; private: - float fade_in; - float fade_out; + float fade_in = 0.1; + float fade_out = 0.1; - bool autorestart; - float autorestart_delay; - float autorestart_random_delay; - MixMode mix; + bool autorestart = false; + float autorestart_delay = 1.0; + float autorestart_random_delay = 0.0; + MixMode mix = MIX_MODE_BLEND; - bool sync; + bool sync = false; /* bool active; bool do_start; float time; float remaining;*/ - StringName active; - StringName prev_active; - StringName time; - StringName remaining; - StringName time_to_restart; + StringName active = "active"; + StringName prev_active = "prev_active"; + StringName time = "time"; + StringName remaining = "remaining"; + StringName time_to_restart = "time_to_restart"; protected: static void _bind_methods(); @@ -132,8 +132,8 @@ VARIANT_ENUM_CAST(AnimationNodeOneShot::MixMode) class AnimationNodeAdd2 : public AnimationNode { GDCLASS(AnimationNodeAdd2, AnimationNode); - StringName add_amount; - bool sync; + StringName add_amount = "add_amount"; + bool sync = false; protected: static void _bind_methods(); @@ -156,8 +156,8 @@ public: class AnimationNodeAdd3 : public AnimationNode { GDCLASS(AnimationNodeAdd3, AnimationNode); - StringName add_amount; - bool sync; + StringName add_amount = "add_amount"; + bool sync = false; protected: static void _bind_methods(); @@ -180,8 +180,8 @@ public: class AnimationNodeBlend2 : public AnimationNode { GDCLASS(AnimationNodeBlend2, AnimationNode); - StringName blend_amount; - bool sync; + StringName blend_amount = "blend_amount"; + bool sync = false; protected: static void _bind_methods(); @@ -225,7 +225,7 @@ public: class AnimationNodeTimeScale : public AnimationNode { GDCLASS(AnimationNodeTimeScale, AnimationNode); - StringName scale; + StringName scale = "scale"; protected: static void _bind_methods(); @@ -244,7 +244,7 @@ public: class AnimationNodeTimeSeek : public AnimationNode { GDCLASS(AnimationNodeTimeSeek, AnimationNode); - StringName seek_pos; + StringName seek_pos = "seek_position"; protected: static void _bind_methods(); @@ -268,12 +268,11 @@ class AnimationNodeTransition : public AnimationNode { }; struct InputData { String name; - bool auto_advance; - InputData() { auto_advance = false; } + bool auto_advance = false; }; InputData inputs[MAX_INPUTS]; - int enabled_inputs; + int enabled_inputs = 0; /* float prev_xfading; @@ -282,13 +281,13 @@ class AnimationNodeTransition : public AnimationNode { int current; int prev_current; */ - StringName prev_xfading; - StringName prev; - StringName time; - StringName current; - StringName prev_current; + StringName prev_xfading = "prev_xfading"; + StringName prev = "prev"; + StringName time = "time"; + StringName current = "current"; + StringName prev_current = "prev_current"; - float xfade; + float xfade = 0.0; void _update_inputs(); @@ -381,7 +380,7 @@ public: struct NodeConnection { StringName input_node; - int input_index; + int input_index = 0; StringName output_node; }; diff --git a/scene/animation/animation_cache.cpp b/scene/animation/animation_cache.cpp index 6ef2da6977..689acdd57b 100644 --- a/scene/animation/animation_cache.cpp +++ b/scene/animation/animation_cache.cpp @@ -308,7 +308,4 @@ void AnimationCache::set_root(Node *p_root) { } AnimationCache::AnimationCache() { - root = nullptr; - cache_dirty = true; - cache_valid = false; } diff --git a/scene/animation/animation_cache.h b/scene/animation/animation_cache.h index 484b710b06..07c9d09ae0 100644 --- a/scene/animation/animation_cache.h +++ b/scene/animation/animation_cache.h @@ -39,31 +39,23 @@ class AnimationCache : public Object { struct Path { RES resource; - Object *object; - Skeleton3D *skeleton; // haxor - Node *node; - Node3D *spatial; + Object *object = nullptr; + Skeleton3D *skeleton = nullptr; // haxor + Node *node = nullptr; + Node3D *spatial = nullptr; - int bone_idx; + int bone_idx = -1; Vector<StringName> subpath; - bool valid; - Path() { - object = nullptr; - skeleton = nullptr; - node = nullptr; - bone_idx = -1; - valid = false; - spatial = nullptr; - } + bool valid = false; }; Set<Node *> connected_nodes; Vector<Path> path_cache; - Node *root; + Node *root = nullptr; Ref<Animation> animation; - bool cache_dirty; - bool cache_valid; + bool cache_dirty = true; + bool cache_valid = false; void _node_exit_tree(Node *p_node); diff --git a/scene/animation/animation_node_state_machine.cpp b/scene/animation/animation_node_state_machine.cpp index ef9f531f04..552e6b6f5d 100644 --- a/scene/animation/animation_node_state_machine.cpp +++ b/scene/animation/animation_node_state_machine.cpp @@ -130,11 +130,6 @@ void AnimationNodeStateMachineTransition::_bind_methods() { } AnimationNodeStateMachineTransition::AnimationNodeStateMachineTransition() { - switch_mode = SWITCH_MODE_IMMEDIATE; - auto_advance = false; - xfade = 0; - disabled = false; - priority = 1; } //////////////////////////////////////////////////////// @@ -502,16 +497,6 @@ void AnimationNodeStateMachinePlayback::_bind_methods() { AnimationNodeStateMachinePlayback::AnimationNodeStateMachinePlayback() { set_local_to_scene(true); //only one per instanced scene - - playing = false; - len_current = 0; - fading_time = 0; - stop_request = false; - len_total = 0.0; - pos_current = 0.0; - loops_current = 0; - fading_pos = 0.0; - start_request_travel = false; } /////////////////////////////////////////////////////// @@ -975,5 +960,4 @@ void AnimationNodeStateMachine::_bind_methods() { } AnimationNodeStateMachine::AnimationNodeStateMachine() { - playback = "playback"; } diff --git a/scene/animation/animation_node_state_machine.h b/scene/animation/animation_node_state_machine.h index daeb2fabaa..7abc6388a1 100644 --- a/scene/animation/animation_node_state_machine.h +++ b/scene/animation/animation_node_state_machine.h @@ -44,13 +44,13 @@ public: }; private: - SwitchMode switch_mode; - bool auto_advance; + SwitchMode switch_mode = SWITCH_MODE_IMMEDIATE; + bool auto_advance = false; StringName advance_condition; StringName advance_condition_name; - float xfade; - bool disabled; - int priority; + float xfade = 0.0; + bool disabled = false; + int priority = 1; protected: static void _bind_methods(); @@ -89,28 +89,28 @@ class AnimationNodeStateMachinePlayback : public Resource { friend class AnimationNodeStateMachine; struct AStarCost { - float distance; + float distance = 0.0; StringName prev; }; - float len_total; + float len_total = 0.0; - float len_current; - float pos_current; - int loops_current; + float len_current = 0.0; + float pos_current = 0.0; + int loops_current = 0; StringName current; StringName fading_from; - float fading_time; - float fading_pos; + float fading_time = 0.0; + float fading_pos = 0.0; Vector<StringName> path; - bool playing; + bool playing = false; StringName start_request; - bool start_request_travel; - bool stop_request; + bool start_request_travel = false; + bool stop_request = false; bool _travel(AnimationNodeStateMachine *p_state_machine, const StringName &p_travel); @@ -154,7 +154,7 @@ private: Vector<Transition> transitions; - StringName playback; + StringName playback = "playback"; StringName start_node; StringName end_node; diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp index 8e50c733ae..c6554462f7 100644 --- a/scene/animation/animation_player.cpp +++ b/scene/animation/animation_player.cpp @@ -1677,23 +1677,7 @@ void AnimationPlayer::_bind_methods() { } AnimationPlayer::AnimationPlayer() { - accum_pass = 1; - cache_update_size = 0; - cache_update_prop_size = 0; - cache_update_bezier_size = 0; - speed_scale = 1; - end_reached = false; - end_notify = false; - reset_on_save = true; - animation_process_mode = ANIMATION_PROCESS_IDLE; - method_call_mode = ANIMATION_METHOD_CALL_DEFERRED; - processing = false; - default_blend_time = 0; root = SceneStringNames::get_singleton()->path_pp; - playing = false; - active = true; - playback.seeked = false; - playback.started = false; } AnimationPlayer::~AnimationPlayer() { diff --git a/scene/animation/animation_player.h b/scene/animation/animation_player.h index 4532825f5a..c04eeeca68 100644 --- a/scene/animation/animation_player.h +++ b/scene/animation/animation_player.h @@ -41,9 +41,9 @@ class AnimatedValuesBackup : public Reference { GDCLASS(AnimatedValuesBackup, Reference); struct Entry { - Object *object; + Object *object = nullptr; Vector<StringName> subpath; // Unused if bone - int bone_idx; // -1 if not a bone + int bone_idx = -1; // -1 if not a bone Variant value; }; Vector<Entry> entries; @@ -118,8 +118,6 @@ private: Variant value_accum; uint64_t accum_pass = 0; Variant capture; - - PropertyAnim() {} }; Map<StringName, PropertyAnim> property_anim; @@ -130,8 +128,6 @@ private: float bezier_accum = 0.0; Object *object = nullptr; uint64_t accum_pass = 0; - - BezierAnim() {} }; Map<StringName, BezierAnim> bezier_anim; @@ -141,7 +137,7 @@ private: struct TrackNodeCacheKey { ObjectID id; - int bone_idx; + int bone_idx = -1; inline bool operator<(const TrackNodeCacheKey &p_right) const { if (id == p_right.id) { @@ -155,16 +151,16 @@ private: Map<TrackNodeCacheKey, TrackNodeCache> node_cache_map; TrackNodeCache *cache_update[NODE_CACHE_UPDATE_MAX]; - int cache_update_size; + int cache_update_size = 0; TrackNodeCache::PropertyAnim *cache_update_prop[NODE_CACHE_UPDATE_MAX]; - int cache_update_prop_size; + int cache_update_prop_size = 0; TrackNodeCache::BezierAnim *cache_update_bezier[NODE_CACHE_UPDATE_MAX]; - int cache_update_bezier_size; + int cache_update_bezier_size = 0; Set<TrackNodeCache *> playing_caches; - uint64_t accum_pass; - float speed_scale; - float default_blend_time; + uint64_t accum_pass = 1; + float speed_scale = 1.0; + float default_blend_time = 0.0; struct AnimationData { String name; @@ -183,48 +179,37 @@ private: Map<BlendKey, float> blend_times; struct PlaybackData { - AnimationData *from; - float pos; - float speed_scale; - - PlaybackData() { - pos = 0; - speed_scale = 1.0; - from = nullptr; - } + AnimationData *from = nullptr; + float pos = 0.0; + float speed_scale = 1.0; }; struct Blend { PlaybackData data; - float blend_time; - float blend_left; - - Blend() { - blend_left = 0; - blend_time = 0; - } + float blend_time = 0.0; + float blend_left = 0.0; }; struct Playback { List<Blend> blend; PlaybackData current; StringName assigned; - bool seeked; - bool started; + bool seeked = false; + bool started = false; } playback; List<StringName> queued; - bool end_reached; - bool end_notify; + bool end_reached = false; + bool end_notify = false; String autoplay; - bool reset_on_save; - AnimationProcessMode animation_process_mode; - AnimationMethodCallMode method_call_mode; - bool processing; - bool active; + bool reset_on_save = true; + AnimationProcessMode animation_process_mode = ANIMATION_PROCESS_IDLE; + AnimationMethodCallMode method_call_mode = ANIMATION_METHOD_CALL_DEFERRED; + bool processing = false; + bool active = true; NodePath root; @@ -257,7 +242,7 @@ private: void _set_process(bool p_process, bool p_force = false); - bool playing; + bool playing = false; protected: bool _set(const StringName &p_name, const Variant &p_value); diff --git a/scene/animation/animation_tree.cpp b/scene/animation/animation_tree.cpp index 54523cc390..0f0cdc67f4 100644 --- a/scene/animation/animation_tree.cpp +++ b/scene/animation/animation_tree.cpp @@ -441,9 +441,6 @@ void AnimationNode::_bind_methods() { } AnimationNode::AnimationNode() { - state = nullptr; - parent = nullptr; - filter_enabled = false; } //////////////////// @@ -1507,13 +1504,6 @@ void AnimationTree::_bind_methods() { } AnimationTree::AnimationTree() { - process_mode = ANIMATION_PROCESS_IDLE; - active = false; - cache_valid = false; - setup_pass = 1; - process_pass = 1; - started = true; - properties_dirty = true; } AnimationTree::~AnimationTree() { diff --git a/scene/animation/animation_tree.h b/scene/animation/animation_tree.h index a0171e617b..0f78b1f0e2 100644 --- a/scene/animation/animation_tree.h +++ b/scene/animation/animation_tree.h @@ -63,26 +63,26 @@ public: struct AnimationState { Ref<Animation> animation; - float time; - float delta; - const Vector<float> *track_blends; - float blend; - bool seeked; + float time = 0.0; + float delta = 0.0; + const Vector<float> *track_blends = nullptr; + float blend = 0.0; + bool seeked = false; }; struct State { - int track_count; + int track_count = 0; HashMap<NodePath, int> track_map; List<AnimationState> animation_states; - bool valid; - AnimationPlayer *player; - AnimationTree *tree; + bool valid = false; + AnimationPlayer *player = nullptr; + AnimationTree *tree = nullptr; String invalid_reasons; - uint64_t last_pass; + uint64_t last_pass = 0; }; Vector<float> blends; - State *state; + State *state = nullptr; float _pre_process(const StringName &p_base_path, AnimationNode *p_parent, State *p_state, float p_time, bool p_seek, const Vector<StringName> &p_connections); void _pre_update_animations(HashMap<NodePath, int> *track_map); @@ -90,10 +90,10 @@ public: //all this is temporary StringName base_path; Vector<StringName> connections; - AnimationNode *parent; + AnimationNode *parent = nullptr; HashMap<NodePath, bool> filter; - bool filter_enabled; + bool filter_enabled = false; Array _get_filters() const; void _set_filters(const Array &p_filters); @@ -171,36 +171,29 @@ public: private: struct TrackCache { - bool root_motion; - uint64_t setup_pass; - uint64_t process_pass; - Animation::TrackType type; - Object *object; + bool root_motion = false; + uint64_t setup_pass = 0; + uint64_t process_pass = 0; + Animation::TrackType type = Animation::TrackType::TYPE_ANIMATION; + Object *object = nullptr; ObjectID object_id; TrackCache() { - root_motion = false; - setup_pass = 0; - process_pass = 0; - object = nullptr; } virtual ~TrackCache() {} }; struct TrackCacheTransform : public TrackCache { - Node3D *spatial; - Skeleton3D *skeleton; - int bone_idx; + Node3D *spatial = nullptr; + Skeleton3D *skeleton = nullptr; + int bone_idx = -1; Vector3 loc; Quat rot; - float rot_blend_accum; + float rot_blend_accum = 0.0; Vector3 scale; TrackCacheTransform() { type = Animation::TYPE_TRANSFORM; - spatial = nullptr; - bone_idx = -1; - skeleton = nullptr; } }; @@ -215,33 +208,28 @@ private: }; struct TrackCacheBezier : public TrackCache { - float value; + float value = 0.0; Vector<StringName> subpath; TrackCacheBezier() { type = Animation::TYPE_BEZIER; - value = 0; } }; struct TrackCacheAudio : public TrackCache { - bool playing; - float start; - float len; + bool playing = false; + float start = 0.0; + float len = 0.0; TrackCacheAudio() { type = Animation::TYPE_AUDIO; - playing = false; - start = 0; - len = 0; } }; struct TrackCacheAnimation : public TrackCache { - bool playing; + bool playing = false; TrackCacheAnimation() { type = Animation::TYPE_ANIMATION; - playing = false; } }; @@ -250,12 +238,12 @@ private: Ref<AnimationNode> root; - AnimationProcessMode process_mode; - bool active; + AnimationProcessMode process_mode = ANIMATION_PROCESS_IDLE; + bool active = false; NodePath animation_player; AnimationNode::State state; - bool cache_valid; + bool cache_valid = false; void _node_removed(Node *p_node); void _caches_cleared(); @@ -263,16 +251,16 @@ private: bool _update_caches(AnimationPlayer *player); void _process_graph(float p_delta); - uint64_t setup_pass; - uint64_t process_pass; + uint64_t setup_pass = 1; + uint64_t process_pass = 1; - bool started; + bool started = true; NodePath root_motion_track; Transform root_motion_transform; friend class AnimationNode; - bool properties_dirty; + bool properties_dirty = true; void _tree_changed(); void _update_properties(); List<PropertyInfo> properties; @@ -280,8 +268,8 @@ private: HashMap<StringName, Variant> property_map; struct Activity { - uint64_t last_pass; - float activity; + uint64_t last_pass = 0; + float activity = 0.0; }; HashMap<StringName, Vector<Activity>> input_activity_map; diff --git a/scene/animation/root_motion_view.cpp b/scene/animation/root_motion_view.cpp index 5fd936df8e..a4a1b02a4c 100644 --- a/scene/animation/root_motion_view.cpp +++ b/scene/animation/root_motion_view.cpp @@ -188,13 +188,9 @@ void RootMotionView::_bind_methods() { } RootMotionView::RootMotionView() { - zero_y = true; - radius = 10; - cell_size = 1; set_process_internal(true); immediate = RenderingServer::get_singleton()->immediate_create(); set_base(immediate); - color = Color(0.5, 0.5, 1.0); } RootMotionView::~RootMotionView() { diff --git a/scene/animation/root_motion_view.h b/scene/animation/root_motion_view.h index 063fb8feda..afcff6137f 100644 --- a/scene/animation/root_motion_view.h +++ b/scene/animation/root_motion_view.h @@ -39,12 +39,12 @@ class RootMotionView : public VisualInstance3D { public: RID immediate; NodePath path; - float cell_size; - float radius; - bool use_in_game; - Color color; - bool first; - bool zero_y; + float cell_size = 1.0; + float radius = 10.0; + bool use_in_game = false; + Color color = Color(0.5, 0.5, 1.0); + bool first = true; + bool zero_y = true; Transform accumulated; diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp index 8bdb5c7447..354f7e5aae 100644 --- a/scene/animation/tween.cpp +++ b/scene/animation/tween.cpp @@ -1789,12 +1789,6 @@ void Tween::targeting_method(Object *p_object, StringName p_method, Object *p_in } Tween::Tween() { - // Initialize tween attributes - tween_process_mode = TWEEN_PROCESS_IDLE; - repeat = false; - speed_scale = 1; - pending_update = 0; - uid = 0; } Tween::~Tween() { diff --git a/scene/animation/tween.h b/scene/animation/tween.h index c65a6f850f..88c02be0bc 100644 --- a/scene/animation/tween.h +++ b/scene/animation/tween.h @@ -79,11 +79,11 @@ private: }; struct InterpolateData { - bool active; - InterpolateType type; - bool finish; - bool call_deferred; - real_t elapsed; + bool active = false; + InterpolateType type = INTER_CALLBACK; + bool finish = false; + bool call_deferred = false; + real_t elapsed = 0.0; ObjectID id; Vector<StringName> key; StringName concatenated_key; @@ -92,33 +92,27 @@ private: Variant final_val; ObjectID target_id; Vector<StringName> target_key; - real_t duration; - TransitionType trans_type; - EaseType ease_type; - real_t delay; - int args; + real_t duration = 0.0; + TransitionType trans_type = TransitionType::TRANS_BACK; + EaseType ease_type = EaseType::EASE_COUNT; + real_t delay = 0.0; + int args = 0; Variant arg[5]; - int uid; - InterpolateData() { - active = false; - finish = false; - call_deferred = false; - uid = 0; - } + int uid = 0; }; String autoplay; - TweenProcessMode tween_process_mode; - bool repeat; - float speed_scale; - mutable int pending_update; - int uid; + TweenProcessMode tween_process_mode = TWEEN_PROCESS_IDLE; + bool repeat = false; + float speed_scale = 1.0; + mutable int pending_update = 0; + int uid = 0; List<InterpolateData> interpolates; struct PendingCommand { StringName key; - int args; + int args = 0; Variant arg[10]; }; List<PendingCommand> pending_commands; diff --git a/scene/audio/audio_stream_player.cpp b/scene/audio/audio_stream_player.cpp index 4a9e146696..70d00734f4 100644 --- a/scene/audio/audio_stream_player.cpp +++ b/scene/audio/audio_stream_player.cpp @@ -402,18 +402,7 @@ void AudioStreamPlayer::_bind_methods() { } AudioStreamPlayer::AudioStreamPlayer() { - mix_volume_db = 0; - pitch_scale = 1.0; - volume_db = 0; - autoplay = false; - setseek = -1; - active = false; - stream_paused = false; - stream_paused_fade = false; - mix_target = MIX_TARGET_STEREO; fadeout_buffer.resize(512); - setstop = false; - use_fadeout = false; AudioServer::get_singleton()->connect("bus_layout_changed", callable_mp(this, &AudioStreamPlayer::_bus_layout_changed)); } diff --git a/scene/audio/audio_stream_player.h b/scene/audio/audio_stream_player.h index fa45a39682..ab98d41302 100644 --- a/scene/audio/audio_stream_player.h +++ b/scene/audio/audio_stream_player.h @@ -49,22 +49,22 @@ private: Ref<AudioStream> stream; Vector<AudioFrame> mix_buffer; Vector<AudioFrame> fadeout_buffer; - bool use_fadeout; - - volatile float setseek; - volatile bool active; - volatile bool setstop; - volatile bool stop_has_priority; - - float mix_volume_db; - float pitch_scale; - float volume_db; - bool autoplay; - bool stream_paused; - bool stream_paused_fade; + bool use_fadeout = false; + + volatile float setseek = -1.0; + volatile bool active = false; + volatile bool setstop = false; + volatile bool stop_has_priority = false; + + float mix_volume_db = 0.0; + float pitch_scale = 1.0; + float volume_db = 0.0; + bool autoplay = false; + bool stream_paused = false; + bool stream_paused_fade = false; StringName bus; - MixTarget mix_target; + MixTarget mix_target = MIX_TARGET_STEREO; void _mix_internal(bool p_fadeout); void _mix_audio(); diff --git a/scene/debugger/scene_debugger.h b/scene/debugger/scene_debugger.h index 51632446f8..9d54556187 100644 --- a/scene/debugger/scene_debugger.h +++ b/scene/debugger/scene_debugger.h @@ -77,7 +77,7 @@ public: class SceneDebuggerTree { public: struct RemoteNode { - int child_count; + int child_count = 0; String name; String type_name; ObjectID id; diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp index 6c81ef0998..6c36db0c92 100644 --- a/scene/gui/color_picker.cpp +++ b/scene/gui/color_picker.cpp @@ -52,6 +52,7 @@ void ColorPicker::_notification(int p_what) { btn_pick->set_icon(get_theme_icon("screen_picker", "ColorPicker")); bt_add_preset->set_icon(get_theme_icon("add_preset")); + _update_controls(); _update_color(); #ifdef TOOLS_ENABLED diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 81c53708ab..9285314abe 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -2296,7 +2296,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { int prev_col = cursor.column; int prev_line = cursor.line; - cursor_set_line(row, true, false); + cursor_set_line(row, false, false); cursor_set_column(col); if (mb->get_shift() && (cursor.column != prev_col || cursor.line != prev_line)) { diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 3d0756337b..c21497a995 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -3322,6 +3322,14 @@ void Tree::item_selected(int p_column, TreeItem *p_item) { } void Tree::item_deselected(int p_column, TreeItem *p_item) { + if (selected_item == p_item) { + selected_item = nullptr; + } + + if (selected_col == p_column) { + selected_col = -1; + } + if (select_mode == SELECT_MULTI || select_mode == SELECT_SINGLE) { p_item->cells.write[p_column].selected = false; } diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp index 1c9d81e87c..4f1143b201 100644 --- a/scene/main/scene_tree.cpp +++ b/scene/main/scene_tree.cpp @@ -409,6 +409,7 @@ bool SceneTree::physics_process(float p_time) { emit_signal("physics_frame"); _notify_group_pause("physics_process_internal", Node::NOTIFICATION_INTERNAL_PHYSICS_PROCESS); + call_group_flags(GROUP_CALL_REALTIME, "_viewports", "_process_picking"); _notify_group_pause("physics_process", Node::NOTIFICATION_PHYSICS_PROCESS); _flush_ugc(); MessageQueue::get_singleton()->flush(); //small little hack diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 82053e1557..0ba8264f2a 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -568,279 +568,290 @@ void Viewport::_notification(int p_what) { RS::get_singleton()->multimesh_set_visible_instances(contact_3d_debug_multimesh, point_count); } + } break; + case NOTIFICATION_WM_MOUSE_EXIT: { + _drop_physics_mouseover(); + + // Unlike on loss of focus (NOTIFICATION_WM_WINDOW_FOCUS_OUT), do not + // drop the gui mouseover here, as a scrollbar may be dragged while the + // mouse is outside the window (without the window having lost focus). + // See bug #39634 + } break; + case NOTIFICATION_WM_WINDOW_FOCUS_OUT: { + _drop_physics_mouseover(); + + if (gui.mouse_focus && !gui.forced_mouse_focus) { + _drop_mouse_focus(); + } + } break; + } +} + +void Viewport::_process_picking() { + if (!is_inside_tree()) { + return; + } + if (!physics_object_picking) { + return; + } + if (to_screen_rect != Rect2i() && Input::get_singleton()->get_mouse_mode() == Input::MOUSE_MODE_CAPTURED) { + return; + } + + _drop_physics_mouseover(true); - if (physics_object_picking && (to_screen_rect == Rect2i() || Input::get_singleton()->get_mouse_mode() != Input::MOUSE_MODE_CAPTURED)) { #ifndef _3D_DISABLED - Vector2 last_pos(1e20, 1e20); - CollisionObject3D *last_object = nullptr; - ObjectID last_id; + Vector2 last_pos(1e20, 1e20); + CollisionObject3D *last_object = nullptr; + ObjectID last_id; #endif - PhysicsDirectSpaceState3D::RayResult result; - PhysicsDirectSpaceState2D *ss2d = PhysicsServer2D::get_singleton()->space_get_direct_state(find_world_2d()->get_space()); - - if (physics_has_last_mousepos) { - // if no mouse event exists, create a motion one. This is necessary because objects or camera may have moved. - // while this extra event is sent, it is checked if both camera and last object and last ID did not move. If nothing changed, the event is discarded to avoid flooding with unnecessary motion events every frame - bool has_mouse_event = false; - for (List<Ref<InputEvent>>::Element *E = physics_picking_events.front(); E; E = E->next()) { - Ref<InputEventMouse> m = E->get(); - if (m.is_valid()) { - has_mouse_event = true; - break; - } - } + PhysicsDirectSpaceState3D::RayResult result; + PhysicsDirectSpaceState2D *ss2d = PhysicsServer2D::get_singleton()->space_get_direct_state(find_world_2d()->get_space()); + + if (physics_has_last_mousepos) { + // if no mouse event exists, create a motion one. This is necessary because objects or camera may have moved. + // while this extra event is sent, it is checked if both camera and last object and last ID did not move. If nothing changed, the event is discarded to avoid flooding with unnecessary motion events every frame + bool has_mouse_event = false; + for (List<Ref<InputEvent>>::Element *E = physics_picking_events.front(); E; E = E->next()) { + Ref<InputEventMouse> m = E->get(); + if (m.is_valid()) { + has_mouse_event = true; + break; + } + } - if (!has_mouse_event) { - Ref<InputEventMouseMotion> mm; - mm.instance(); - - mm->set_device(InputEvent::DEVICE_ID_INTERNAL); - mm->set_global_position(physics_last_mousepos); - mm->set_position(physics_last_mousepos); - mm->set_alt(physics_last_mouse_state.alt); - mm->set_shift(physics_last_mouse_state.shift); - mm->set_control(physics_last_mouse_state.control); - mm->set_metakey(physics_last_mouse_state.meta); - mm->set_button_mask(physics_last_mouse_state.mouse_mask); - physics_picking_events.push_back(mm); - } - } + if (!has_mouse_event) { + Ref<InputEventMouseMotion> mm; + mm.instance(); - while (physics_picking_events.size()) { - Ref<InputEvent> ev = physics_picking_events.front()->get(); - physics_picking_events.pop_front(); + mm->set_device(InputEvent::DEVICE_ID_INTERNAL); + mm->set_global_position(physics_last_mousepos); + mm->set_position(physics_last_mousepos); + mm->set_alt(physics_last_mouse_state.alt); + mm->set_shift(physics_last_mouse_state.shift); + mm->set_control(physics_last_mouse_state.control); + mm->set_metakey(physics_last_mouse_state.meta); + mm->set_button_mask(physics_last_mouse_state.mouse_mask); + physics_picking_events.push_back(mm); + } + } - Vector2 pos; - bool is_mouse = false; + while (physics_picking_events.size()) { + Ref<InputEvent> ev = physics_picking_events.front()->get(); + physics_picking_events.pop_front(); - Ref<InputEventMouseMotion> mm = ev; + Vector2 pos; + bool is_mouse = false; - if (mm.is_valid()) { - pos = mm->get_position(); - is_mouse = true; + Ref<InputEventMouseMotion> mm = ev; - physics_has_last_mousepos = true; - physics_last_mousepos = pos; - physics_last_mouse_state.alt = mm->get_alt(); - physics_last_mouse_state.shift = mm->get_shift(); - physics_last_mouse_state.control = mm->get_control(); - physics_last_mouse_state.meta = mm->get_metakey(); - physics_last_mouse_state.mouse_mask = mm->get_button_mask(); - } + if (mm.is_valid()) { + pos = mm->get_position(); + is_mouse = true; - Ref<InputEventMouseButton> mb = ev; + physics_has_last_mousepos = true; + physics_last_mousepos = pos; + physics_last_mouse_state.alt = mm->get_alt(); + physics_last_mouse_state.shift = mm->get_shift(); + physics_last_mouse_state.control = mm->get_control(); + physics_last_mouse_state.meta = mm->get_metakey(); + physics_last_mouse_state.mouse_mask = mm->get_button_mask(); + } - if (mb.is_valid()) { - pos = mb->get_position(); - is_mouse = true; + Ref<InputEventMouseButton> mb = ev; - physics_has_last_mousepos = true; - physics_last_mousepos = pos; - physics_last_mouse_state.alt = mb->get_alt(); - physics_last_mouse_state.shift = mb->get_shift(); - physics_last_mouse_state.control = mb->get_control(); - physics_last_mouse_state.meta = mb->get_metakey(); + if (mb.is_valid()) { + pos = mb->get_position(); + is_mouse = true; - if (mb->is_pressed()) { - physics_last_mouse_state.mouse_mask |= (1 << (mb->get_button_index() - 1)); - } else { - physics_last_mouse_state.mouse_mask &= ~(1 << (mb->get_button_index() - 1)); + physics_has_last_mousepos = true; + physics_last_mousepos = pos; + physics_last_mouse_state.alt = mb->get_alt(); + physics_last_mouse_state.shift = mb->get_shift(); + physics_last_mouse_state.control = mb->get_control(); + physics_last_mouse_state.meta = mb->get_metakey(); - // If touch mouse raised, assume we don't know last mouse pos until new events come - if (mb->get_device() == InputEvent::DEVICE_ID_TOUCH_MOUSE) { - physics_has_last_mousepos = false; - } - } - } + if (mb->is_pressed()) { + physics_last_mouse_state.mouse_mask |= (1 << (mb->get_button_index() - 1)); + } else { + physics_last_mouse_state.mouse_mask &= ~(1 << (mb->get_button_index() - 1)); - Ref<InputEventKey> k = ev; - if (k.is_valid()) { - //only for mask - physics_last_mouse_state.alt = k->get_alt(); - physics_last_mouse_state.shift = k->get_shift(); - physics_last_mouse_state.control = k->get_control(); - physics_last_mouse_state.meta = k->get_metakey(); - continue; - } + // If touch mouse raised, assume we don't know last mouse pos until new events come + if (mb->get_device() == InputEvent::DEVICE_ID_TOUCH_MOUSE) { + physics_has_last_mousepos = false; + } + } + } - Ref<InputEventScreenDrag> sd = ev; + Ref<InputEventKey> k = ev; + if (k.is_valid()) { + //only for mask + physics_last_mouse_state.alt = k->get_alt(); + physics_last_mouse_state.shift = k->get_shift(); + physics_last_mouse_state.control = k->get_control(); + physics_last_mouse_state.meta = k->get_metakey(); + continue; + } - if (sd.is_valid()) { - pos = sd->get_position(); - } + Ref<InputEventScreenDrag> sd = ev; - Ref<InputEventScreenTouch> st = ev; + if (sd.is_valid()) { + pos = sd->get_position(); + } - if (st.is_valid()) { - pos = st->get_position(); - } + Ref<InputEventScreenTouch> st = ev; - if (ss2d) { - //send to 2D + if (st.is_valid()) { + pos = st->get_position(); + } - uint64_t frame = get_tree()->get_frame(); + if (ss2d) { + //send to 2D - PhysicsDirectSpaceState2D::ShapeResult res[64]; - for (Set<CanvasLayer *>::Element *E = canvas_layers.front(); E; E = E->next()) { - Transform2D canvas_transform; - ObjectID canvas_layer_id; - if (E->get()) { - // A descendant CanvasLayer - canvas_transform = E->get()->get_transform(); - canvas_layer_id = E->get()->get_instance_id(); - } else { - // This Viewport's builtin canvas - canvas_transform = get_canvas_transform(); - canvas_layer_id = ObjectID(); - } + uint64_t frame = get_tree()->get_frame(); - Vector2 point = canvas_transform.affine_inverse().xform(pos); - - int rc = ss2d->intersect_point_on_canvas(point, canvas_layer_id, res, 64, Set<RID>(), 0xFFFFFFFF, true, true, true); - for (int i = 0; i < rc; i++) { - if (res[i].collider_id.is_valid() && res[i].collider) { - CollisionObject2D *co = Object::cast_to<CollisionObject2D>(res[i].collider); - if (co) { - bool send_event = true; - if (is_mouse) { - Map<ObjectID, uint64_t>::Element *F = physics_2d_mouseover.find(res[i].collider_id); - - if (!F) { - physics_2d_mouseover.insert(res[i].collider_id, frame); - co->_mouse_enter(); - } else { - F->get() = frame; - // It was already hovered, so don't send the event if it's faked - if (mm.is_valid() && mm->get_device() == InputEvent::DEVICE_ID_INTERNAL) { - send_event = false; - } - } - } - - if (send_event) { - co->_input_event(this, ev, res[i].shape); - } + PhysicsDirectSpaceState2D::ShapeResult res[64]; + for (Set<CanvasLayer *>::Element *E = canvas_layers.front(); E; E = E->next()) { + Transform2D canvas_transform; + ObjectID canvas_layer_id; + if (E->get()) { + // A descendant CanvasLayer + canvas_transform = E->get()->get_transform(); + canvas_layer_id = E->get()->get_instance_id(); + } else { + // This Viewport's builtin canvas + canvas_transform = get_canvas_transform(); + canvas_layer_id = ObjectID(); + } + + Vector2 point = canvas_transform.affine_inverse().xform(pos); + + int rc = ss2d->intersect_point_on_canvas(point, canvas_layer_id, res, 64, Set<RID>(), 0xFFFFFFFF, true, true, true); + for (int i = 0; i < rc; i++) { + if (res[i].collider_id.is_valid() && res[i].collider) { + CollisionObject2D *co = Object::cast_to<CollisionObject2D>(res[i].collider); + if (co && co->can_process()) { + bool send_event = true; + if (is_mouse) { + Map<ObjectID, uint64_t>::Element *F = physics_2d_mouseover.find(res[i].collider_id); + + if (!F) { + physics_2d_mouseover.insert(res[i].collider_id, frame); + co->_mouse_enter(); + } else { + F->get() = frame; + // It was already hovered, so don't send the event if it's faked + if (mm.is_valid() && mm->get_device() == InputEvent::DEVICE_ID_INTERNAL) { + send_event = false; } } } - } - if (is_mouse) { - List<Map<ObjectID, uint64_t>::Element *> to_erase; - - for (Map<ObjectID, uint64_t>::Element *E = physics_2d_mouseover.front(); E; E = E->next()) { - if (E->get() != frame) { - Object *o = ObjectDB::get_instance(E->key()); - if (o) { - CollisionObject2D *co = Object::cast_to<CollisionObject2D>(o); - if (co) { - co->_mouse_exit(); - } - } - to_erase.push_back(E); - } + if (send_event) { + co->_input_event(this, ev, res[i].shape); } + } + } + } + } - while (to_erase.size()) { - physics_2d_mouseover.erase(to_erase.front()->get()); - to_erase.pop_front(); + if (is_mouse) { + List<Map<ObjectID, uint64_t>::Element *> to_erase; + + for (Map<ObjectID, uint64_t>::Element *E = physics_2d_mouseover.front(); E; E = E->next()) { + if (E->get() != frame) { + Object *o = ObjectDB::get_instance(E->key()); + if (o) { + CollisionObject2D *co = Object::cast_to<CollisionObject2D>(o); + if (co) { + co->_mouse_exit(); } } + to_erase.push_back(E); } + } + + while (to_erase.size()) { + physics_2d_mouseover.erase(to_erase.front()->get()); + to_erase.pop_front(); + } + } + } #ifndef _3D_DISABLED - bool captured = false; - - if (physics_object_capture.is_valid()) { - CollisionObject3D *co = Object::cast_to<CollisionObject3D>(ObjectDB::get_instance(physics_object_capture)); - if (co && camera) { - _collision_object_input_event(co, camera, ev, Vector3(), Vector3(), 0); - captured = true; - if (mb.is_valid() && mb->get_button_index() == 1 && !mb->is_pressed()) { - physics_object_capture = ObjectID(); - } + bool captured = false; + + if (physics_object_capture.is_valid()) { + CollisionObject3D *co = Object::cast_to<CollisionObject3D>(ObjectDB::get_instance(physics_object_capture)); + if (co && camera) { + _collision_object_input_event(co, camera, ev, Vector3(), Vector3(), 0); + captured = true; + if (mb.is_valid() && mb->get_button_index() == 1 && !mb->is_pressed()) { + physics_object_capture = ObjectID(); + } - } else { - physics_object_capture = ObjectID(); + } else { + physics_object_capture = ObjectID(); + } + } + + if (captured) { + //none + } else if (pos == last_pos) { + if (last_id.is_valid()) { + if (ObjectDB::get_instance(last_id) && last_object) { + //good, exists + _collision_object_input_event(last_object, camera, ev, result.position, result.normal, result.shape); + if (last_object->get_capture_input_on_drag() && mb.is_valid() && mb->get_button_index() == 1 && mb->is_pressed()) { + physics_object_capture = last_id; + } + } + } + } else { + if (camera) { + Vector3 from = camera->project_ray_origin(pos); + Vector3 dir = camera->project_ray_normal(pos); + + PhysicsDirectSpaceState3D *space = PhysicsServer3D::get_singleton()->space_get_direct_state(find_world_3d()->get_space()); + if (space) { + bool col = space->intersect_ray(from, from + dir * 10000, result, Set<RID>(), 0xFFFFFFFF, true, true, true); + ObjectID new_collider; + if (col) { + CollisionObject3D *co = Object::cast_to<CollisionObject3D>(result.collider); + if (co && co->can_process()) { + _collision_object_input_event(co, camera, ev, result.position, result.normal, result.shape); + last_object = co; + last_id = result.collider_id; + new_collider = last_id; + if (co->get_capture_input_on_drag() && mb.is_valid() && mb->get_button_index() == 1 && mb->is_pressed()) { + physics_object_capture = last_id; + } } } - if (captured) { - //none - } else if (pos == last_pos) { - if (last_id.is_valid()) { - if (ObjectDB::get_instance(last_id) && last_object) { - //good, exists - _collision_object_input_event(last_object, camera, ev, result.position, result.normal, result.shape); - if (last_object->get_capture_input_on_drag() && mb.is_valid() && mb->get_button_index() == 1 && mb->is_pressed()) { - physics_object_capture = last_id; - } + if (is_mouse && new_collider != physics_object_over) { + if (physics_object_over.is_valid()) { + CollisionObject3D *co = Object::cast_to<CollisionObject3D>(ObjectDB::get_instance(physics_object_over)); + if (co) { + co->_mouse_exit(); } } - } else { - if (camera) { - Vector3 from = camera->project_ray_origin(pos); - Vector3 dir = camera->project_ray_normal(pos); - - PhysicsDirectSpaceState3D *space = PhysicsServer3D::get_singleton()->space_get_direct_state(find_world_3d()->get_space()); - if (space) { - bool col = space->intersect_ray(from, from + dir * 10000, result, Set<RID>(), 0xFFFFFFFF, true, true, true); - ObjectID new_collider; - if (col) { - CollisionObject3D *co = Object::cast_to<CollisionObject3D>(result.collider); - if (co) { - _collision_object_input_event(co, camera, ev, result.position, result.normal, result.shape); - last_object = co; - last_id = result.collider_id; - new_collider = last_id; - if (co->get_capture_input_on_drag() && mb.is_valid() && mb->get_button_index() == 1 && mb->is_pressed()) { - physics_object_capture = last_id; - } - } - } - - if (is_mouse && new_collider != physics_object_over) { - if (physics_object_over.is_valid()) { - CollisionObject3D *co = Object::cast_to<CollisionObject3D>(ObjectDB::get_instance(physics_object_over)); - if (co) { - co->_mouse_exit(); - } - } - - if (new_collider.is_valid()) { - CollisionObject3D *co = Object::cast_to<CollisionObject3D>(ObjectDB::get_instance(new_collider)); - if (co) { - co->_mouse_enter(); - } - } - physics_object_over = new_collider; - } + if (new_collider.is_valid()) { + CollisionObject3D *co = Object::cast_to<CollisionObject3D>(ObjectDB::get_instance(new_collider)); + if (co) { + co->_mouse_enter(); } - - last_pos = pos; } + + physics_object_over = new_collider; } -#endif } - } - - } break; - case NOTIFICATION_WM_MOUSE_EXIT: { - _drop_physics_mouseover(); - // Unlike on loss of focus (NOTIFICATION_WM_WINDOW_FOCUS_OUT), do not - // drop the gui mouseover here, as a scrollbar may be dragged while the - // mouse is outside the window (without the window having lost focus). - // See bug #39634 - } break; - case NOTIFICATION_WM_WINDOW_FOCUS_OUT: { - _drop_physics_mouseover(); - - if (gui.mouse_focus && !gui.forced_mouse_focus) { - _drop_mouse_focus(); + last_pos = pos; } - } break; + } +#endif } } @@ -2582,28 +2593,41 @@ void Viewport::_drop_mouse_focus() { } } -void Viewport::_drop_physics_mouseover() { +void Viewport::_drop_physics_mouseover(bool p_paused_only) { physics_has_last_mousepos = false; - while (physics_2d_mouseover.size()) { - Object *o = ObjectDB::get_instance(physics_2d_mouseover.front()->key()); + List<Map<ObjectID, uint64_t>::Element *> to_erase; + + for (Map<ObjectID, uint64_t>::Element *E = physics_2d_mouseover.front(); E; E = E->next()) { + Object *o = ObjectDB::get_instance(E->key()); if (o) { CollisionObject2D *co = Object::cast_to<CollisionObject2D>(o); - co->_mouse_exit(); + if (co) { + if (p_paused_only && co->can_process()) { + continue; + } + co->_mouse_exit(); + to_erase.push_back(E); + } } - physics_2d_mouseover.erase(physics_2d_mouseover.front()); + } + + while (to_erase.size()) { + physics_2d_mouseover.erase(to_erase.front()->get()); + to_erase.pop_front(); } #ifndef _3D_DISABLED if (physics_object_over.is_valid()) { CollisionObject3D *co = Object::cast_to<CollisionObject3D>(ObjectDB::get_instance(physics_object_over)); if (co) { - co->_mouse_exit(); + if (!(p_paused_only && co->can_process())) { + co->_mouse_exit(); + physics_object_over = ObjectID(); + physics_object_capture = ObjectID(); + } } } - - physics_object_over = ObjectID(); - physics_object_capture = ObjectID(); #endif } @@ -3529,6 +3553,8 @@ void Viewport::_bind_methods() { ClassDB::bind_method(D_METHOD("set_lod_threshold", "pixels"), &Viewport::set_lod_threshold); ClassDB::bind_method(D_METHOD("get_lod_threshold"), &Viewport::get_lod_threshold); + ClassDB::bind_method(D_METHOD("_process_picking"), &Viewport::_process_picking); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "own_world_3d"), "set_use_own_world_3d", "is_using_own_world_3d"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "world_3d", PROPERTY_HINT_RESOURCE_TYPE, "World3D"), "set_world_3d", "get_world_3d"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "world_2d", PROPERTY_HINT_RESOURCE_TYPE, "World2D", 0), "set_world_2d", "get_world_2d"); diff --git a/scene/main/viewport.h b/scene/main/viewport.h index 17d4835c63..bddc45206d 100644 --- a/scene/main/viewport.h +++ b/scene/main/viewport.h @@ -450,7 +450,7 @@ private: void _canvas_layer_remove(CanvasLayer *p_canvas_layer); void _drop_mouse_focus(); - void _drop_physics_mouseover(); + void _drop_physics_mouseover(bool p_paused_only = false); void _update_canvas_items(Node *p_node); @@ -479,6 +479,7 @@ protected: bool _is_size_allocated() const; void _notification(int p_what); + void _process_picking(); static void _bind_methods(); virtual void _validate_property(PropertyInfo &property) const override; diff --git a/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp b/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp index 14bcfc85c8..09d2c032a8 100644 --- a/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp @@ -1611,8 +1611,8 @@ void RendererSceneRenderRD::_pre_process_gi(RID p_render_buffers, const Transfor lights[idx].has_shadow = storage->light_has_shadow(li->light); lights[idx].attenuation = storage->light_get_param(li->light, RS::LIGHT_PARAM_ATTENUATION); lights[idx].radius = storage->light_get_param(li->light, RS::LIGHT_PARAM_RANGE); - lights[idx].spot_angle = Math::deg2rad(storage->light_get_param(li->light, RS::LIGHT_PARAM_SPOT_ANGLE)); - lights[idx].spot_attenuation = storage->light_get_param(li->light, RS::LIGHT_PARAM_SPOT_ATTENUATION); + lights[idx].cos_spot_angle = Math::cos(Math::deg2rad(storage->light_get_param(li->light, RS::LIGHT_PARAM_SPOT_ANGLE))); + lights[idx].inv_spot_attenuation = 1.0f / storage->light_get_param(li->light, RS::LIGHT_PARAM_SPOT_ATTENUATION); idx++; } @@ -4539,8 +4539,8 @@ void RendererSceneRenderRD::gi_probe_update(RID p_probe, bool p_update_light_ins l.color[1] = color.g; l.color[2] = color.b; - l.spot_angle_radians = Math::deg2rad(storage->light_get_param(light, RS::LIGHT_PARAM_SPOT_ANGLE)); - l.spot_attenuation = storage->light_get_param(light, RS::LIGHT_PARAM_SPOT_ATTENUATION); + l.cos_spot_angle = Math::cos(Math::deg2rad(storage->light_get_param(light, RS::LIGHT_PARAM_SPOT_ANGLE))); + l.inv_spot_attenuation = 1.0f / storage->light_get_param(light, RS::LIGHT_PARAM_SPOT_ATTENUATION); Transform xform = light_instance_get_base_transform(light_instance); @@ -6491,9 +6491,9 @@ void RendererSceneRenderRD::_setup_lights(const PagedArray<RID> &p_lights, const light_data.size = size; - light_data.cone_attenuation = storage->light_get_param(base, RS::LIGHT_PARAM_SPOT_ATTENUATION); + light_data.inv_spot_attenuation = 1.0f / storage->light_get_param(base, RS::LIGHT_PARAM_SPOT_ATTENUATION); float spot_angle = storage->light_get_param(base, RS::LIGHT_PARAM_SPOT_ANGLE); - light_data.cone_angle = Math::cos(Math::deg2rad(spot_angle)); + light_data.cos_spot_angle = Math::cos(Math::deg2rad(spot_angle)); light_data.mask = storage->light_get_cull_mask(base); @@ -8094,8 +8094,8 @@ void RendererSceneRenderRD::_render_sdfgi_static_lights(RID p_render_buffers, ui lights[idx].has_shadow = storage->light_has_shadow(li->light); lights[idx].attenuation = storage->light_get_param(li->light, RS::LIGHT_PARAM_ATTENUATION); lights[idx].radius = storage->light_get_param(li->light, RS::LIGHT_PARAM_RANGE); - lights[idx].spot_angle = Math::deg2rad(storage->light_get_param(li->light, RS::LIGHT_PARAM_SPOT_ANGLE)); - lights[idx].spot_attenuation = storage->light_get_param(li->light, RS::LIGHT_PARAM_SPOT_ATTENUATION); + lights[idx].cos_spot_angle = Math::cos(Math::deg2rad(storage->light_get_param(li->light, RS::LIGHT_PARAM_SPOT_ANGLE))); + lights[idx].inv_spot_attenuation = 1.0f / storage->light_get_param(li->light, RS::LIGHT_PARAM_SPOT_ATTENUATION); idx++; } diff --git a/servers/rendering/renderer_rd/renderer_scene_render_rd.h b/servers/rendering/renderer_rd/renderer_scene_render_rd.h index 8b4f41b6f7..cdcdb73132 100644 --- a/servers/rendering/renderer_rd/renderer_scene_render_rd.h +++ b/servers/rendering/renderer_rd/renderer_scene_render_rd.h @@ -406,10 +406,10 @@ private: float attenuation; float color[3]; - float spot_angle_radians; + float cos_spot_angle; float position[3]; - float spot_attenuation; + float inv_spot_attenuation; float direction[3]; uint32_t has_shadow; @@ -1146,8 +1146,8 @@ private: float attenuation; uint32_t type; - float spot_angle; - float spot_attenuation; + float cos_spot_angle; + float inv_spot_attenuation; float radius; float shadow_color[4]; @@ -1362,8 +1362,8 @@ private: float color[3]; float attenuation; - float cone_attenuation; - float cone_angle; + float inv_spot_attenuation; + float cos_spot_angle; float specular_amount; uint32_t shadow_enabled; diff --git a/servers/rendering/renderer_rd/shaders/gi.glsl b/servers/rendering/renderer_rd/shaders/gi.glsl index 35522103df..92a5682572 100644 --- a/servers/rendering/renderer_rd/shaders/gi.glsl +++ b/servers/rendering/renderer_rd/shaders/gi.glsl @@ -363,57 +363,62 @@ void sdfgi_process(vec3 vertex, vec3 normal, vec3 reflection, float roughness, o ray_pos += (ray_dir * 1.0 / max(abs_ray_dir.x, max(abs_ray_dir.y, abs_ray_dir.z)) + cam_normal * 1.4) * bias / sdfgi.cascades[cascade].to_cell; } float softness = 0.2 + min(1.0, roughness * 5.0) * 4.0; //approximation to roughness so it does not seem like a hard fade - while (length(ray_pos) < max_distance) { - for (uint i = 0; i < sdfgi.max_cascades; i++) { - if (i >= cascade && length(ray_pos) < radius_sizes[i]) { - cascade = max(i, cascade); //never go down - - vec3 pos = ray_pos - sdfgi.cascades[i].position; - pos *= sdfgi.cascades[i].to_cell * pos_to_uvw; - - float distance = texture(sampler3D(sdf_cascades[i], linear_sampler), pos).r * 255.0 - 1.1; - - vec4 hit_light = vec4(0.0); - if (distance < softness) { - hit_light.rgb = texture(sampler3D(light_cascades[i], linear_sampler), pos).rgb; - hit_light.rgb *= 0.5; //approximation given value read is actually meant for anisotropy - hit_light.a = clamp(1.0 - (distance / softness), 0.0, 1.0); - hit_light.rgb *= hit_light.a; - } + uint i = 0; + bool found = false; + while (true) { + if (length(ray_pos) >= max_distance || light_accum.a > 0.99) { + break; + } + if (!found && i >= cascade && length(ray_pos) < radius_sizes[i]) { + uint next_i = min(i + 1, sdfgi.max_cascades - 1); + cascade = max(i, cascade); //never go down - distance /= sdfgi.cascades[i].to_cell; + vec3 pos = ray_pos - sdfgi.cascades[i].position; + pos *= sdfgi.cascades[i].to_cell * pos_to_uvw; - if (i < (sdfgi.max_cascades - 1)) { - pos = ray_pos - sdfgi.cascades[i + 1].position; - pos *= sdfgi.cascades[i + 1].to_cell * pos_to_uvw; + float fdistance = textureLod(sampler3D(sdf_cascades[i], linear_sampler), pos, 0.0).r * 255.0 - 1.1; - float distance2 = texture(sampler3D(sdf_cascades[i + 1], linear_sampler), pos).r * 255.0 - 1.1; + vec4 hit_light = vec4(0.0); + if (fdistance < softness) { + hit_light.rgb = textureLod(sampler3D(light_cascades[i], linear_sampler), pos, 0.0).rgb; + hit_light.rgb *= 0.5; //approximation given value read is actually meant for anisotropy + hit_light.a = clamp(1.0 - (fdistance / softness), 0.0, 1.0); + hit_light.rgb *= hit_light.a; + } - vec4 hit_light2 = vec4(0.0); - if (distance2 < softness) { - hit_light2.rgb = texture(sampler3D(light_cascades[i + 1], linear_sampler), pos).rgb; - hit_light2.rgb *= 0.5; //approximation given value read is actually meant for anisotropy - hit_light2.a = clamp(1.0 - (distance2 / softness), 0.0, 1.0); - hit_light2.rgb *= hit_light2.a; - } + fdistance /= sdfgi.cascades[i].to_cell; - float prev_radius = i == 0 ? 0.0 : radius_sizes[i - 1]; - float blend = clamp((length(ray_pos) - prev_radius) / (radius_sizes[i] - prev_radius), 0.0, 1.0); + if (i < (sdfgi.max_cascades - 1)) { + pos = ray_pos - sdfgi.cascades[next_i].position; + pos *= sdfgi.cascades[next_i].to_cell * pos_to_uvw; - distance2 /= sdfgi.cascades[i + 1].to_cell; + float fdistance2 = textureLod(sampler3D(sdf_cascades[next_i], linear_sampler), pos, 0.0).r * 255.0 - 1.1; - hit_light = mix(hit_light, hit_light2, blend); - distance = mix(distance, distance2, blend); + vec4 hit_light2 = vec4(0.0); + if (fdistance2 < softness) { + hit_light2.rgb = textureLod(sampler3D(light_cascades[next_i], linear_sampler), pos, 0.0).rgb; + hit_light2.rgb *= 0.5; //approximation given value read is actually meant for anisotropy + hit_light2.a = clamp(1.0 - (fdistance2 / softness), 0.0, 1.0); + hit_light2.rgb *= hit_light2.a; } - light_accum += hit_light; - ray_pos += ray_dir * distance; - break; + float prev_radius = i == 0 ? 0.0 : radius_sizes[max(0, i - 1)]; + float blend = clamp((length(ray_pos) - prev_radius) / (radius_sizes[i] - prev_radius), 0.0, 1.0); + + fdistance2 /= sdfgi.cascades[next_i].to_cell; + + hit_light = mix(hit_light, hit_light2, blend); + fdistance = mix(fdistance, fdistance2, blend); } - } - if (light_accum.a > 0.99) { - break; + light_accum += hit_light; + ray_pos += ray_dir * fdistance; + found = true; + } + i++; + if (i == sdfgi.max_cascades) { + i = 0; + found = false; } } diff --git a/servers/rendering/renderer_rd/shaders/giprobe.glsl b/servers/rendering/renderer_rd/shaders/giprobe.glsl index 4f4753d147..b931461b31 100644 --- a/servers/rendering/renderer_rd/shaders/giprobe.glsl +++ b/servers/rendering/renderer_rd/shaders/giprobe.glsl @@ -51,10 +51,10 @@ struct Light { float attenuation; vec3 color; - float spot_angle_radians; + float cos_spot_angle; vec3 position; - float spot_attenuation; + float inv_spot_attenuation; vec3 direction; bool has_shadow; @@ -233,13 +233,15 @@ bool compute_light_vector(uint light, vec3 pos, out float attenuation, out vec3 if (lights.data[light].type == LIGHT_TYPE_SPOT) { vec3 rel = normalize(pos - light_pos); - float angle = acos(dot(rel, lights.data[light].direction)); - if (angle > lights.data[light].spot_angle_radians) { + float cos_spot_angle = lights.data[light].cos_spot_angle; + float cos_angle = dot(rel, lights.data[light].direction); + if (cos_angle < cos_spot_angle) { return false; } - float d = clamp(angle / lights.data[light].spot_angle_radians, 0, 1); - attenuation *= pow(1.0 - d, lights.data[light].spot_attenuation); + float scos = max(cos_angle, cos_spot_angle); + float spot_rim = max(0.0001, (1.0 - scos) / (1.0 - cos_spot_angle)); + attenuation *= 1.0 - pow(spot_rim, lights.data[light].inv_spot_attenuation); } } diff --git a/servers/rendering/renderer_rd/shaders/giprobe_write.glsl b/servers/rendering/renderer_rd/shaders/giprobe_write.glsl index 9c794f1bcc..56b3b7ccb4 100644 --- a/servers/rendering/renderer_rd/shaders/giprobe_write.glsl +++ b/servers/rendering/renderer_rd/shaders/giprobe_write.glsl @@ -43,10 +43,10 @@ struct Light { float attenuation; vec3 color; - float spot_angle_radians; + float cos_spot_angle; vec3 position; - float spot_attenuation; + float inv_spot_attenuation; vec3 direction; bool has_shadow; @@ -146,13 +146,15 @@ bool compute_light_vector(uint light, uint cell, vec3 pos, out float attenuation if (lights.data[light].type == LIGHT_TYPE_SPOT) { vec3 rel = normalize(pos - light_pos); - float angle = acos(dot(rel, lights.data[light].direction)); - if (angle > lights.data[light].spot_angle_radians) { + float cos_spot_angle = lights.data[light].cos_spot_angle; + float cos_angle = dot(rel, lights.data[light].direction); + if (cos_angle < cos_spot_angle) { return false; } - float d = clamp(angle / lights.data[light].spot_angle_radians, 0, 1); - attenuation *= pow(1.0 - d, lights.data[light].spot_attenuation); + float scos = max(cos_angle, cos_spot_angle); + float spot_rim = max(0.0001, (1.0 - scos) / (1.0 - cos_spot_angle)); + attenuation *= 1.0 - pow(spot_rim, lights.data[light].inv_spot_attenuation); } } diff --git a/servers/rendering/renderer_rd/shaders/sdfgi_direct_light.glsl b/servers/rendering/renderer_rd/shaders/sdfgi_direct_light.glsl index bcdfe8cc85..5e8934adb4 100644 --- a/servers/rendering/renderer_rd/shaders/sdfgi_direct_light.glsl +++ b/servers/rendering/renderer_rd/shaders/sdfgi_direct_light.glsl @@ -67,8 +67,8 @@ struct Light { float attenuation; uint type; - float spot_angle; - float spot_attenuation; + float cos_spot_angle; + float inv_spot_attenuation; float radius; vec4 shadow_color; @@ -266,13 +266,16 @@ void main() { rel_vec.y /= params.y_mult; attenuation = get_omni_attenuation(light_distance, 1.0 / lights.data[i].radius, lights.data[i].attenuation); - float angle = acos(dot(normalize(rel_vec), -lights.data[i].direction)); - if (angle > lights.data[i].spot_angle) { - attenuation = 0.0; - } else { - float d = clamp(angle / lights.data[i].spot_angle, 0, 1); - attenuation *= pow(1.0 - d, lights.data[i].spot_attenuation); + float cos_spot_angle = lights.data[i].cos_spot_angle; + float cos_angle = dot(-direction, lights.data[i].direction); + + if (cos_angle < cos_spot_angle) { + continue; } + + float scos = max(cos_angle, cos_spot_angle); + float spot_rim = max(0.0001, (1.0 - scos) / (1.0 - cos_spot_angle)); + attenuation *= 1.0 - pow(spot_rim, lights.data[i].inv_spot_attenuation); } break; } diff --git a/servers/rendering/renderer_rd/shaders/sdfgi_integrate.glsl b/servers/rendering/renderer_rd/shaders/sdfgi_integrate.glsl index e4f6f4b7ea..007e4c113a 100644 --- a/servers/rendering/renderer_rd/shaders/sdfgi_integrate.glsl +++ b/servers/rendering/renderer_rd/shaders/sdfgi_integrate.glsl @@ -244,20 +244,26 @@ void main() { vec4 light; if (hit) { - const float EPSILON = 0.001; - vec3 hit_normal = normalize(vec3( - texture(sampler3D(sdf_cascades[hit_cascade], linear_sampler), uvw + vec3(EPSILON, 0.0, 0.0)).r - texture(sampler3D(sdf_cascades[hit_cascade], linear_sampler), uvw - vec3(EPSILON, 0.0, 0.0)).r, - texture(sampler3D(sdf_cascades[hit_cascade], linear_sampler), uvw + vec3(0.0, EPSILON, 0.0)).r - texture(sampler3D(sdf_cascades[hit_cascade], linear_sampler), uvw - vec3(0.0, EPSILON, 0.0)).r, - texture(sampler3D(sdf_cascades[hit_cascade], linear_sampler), uvw + vec3(0.0, 0.0, EPSILON)).r - texture(sampler3D(sdf_cascades[hit_cascade], linear_sampler), uvw - vec3(0.0, 0.0, EPSILON)).r)); - - vec3 hit_light = texture(sampler3D(light_cascades[hit_cascade], linear_sampler), uvw).rgb; - vec4 aniso0 = texture(sampler3D(aniso0_cascades[hit_cascade], linear_sampler), uvw); - vec3 hit_aniso0 = aniso0.rgb; - vec3 hit_aniso1 = vec3(aniso0.a, texture(sampler3D(aniso1_cascades[hit_cascade], linear_sampler), uvw).rg); - - //one liner magic - light.rgb = hit_light * (dot(max(vec3(0.0), (hit_normal * hit_aniso0)), vec3(1.0)) + dot(max(vec3(0.0), (-hit_normal * hit_aniso1)), vec3(1.0))); - light.a = 1.0; + //avoid reading different texture from different threads + for (uint j = params.cascade; j < params.max_cascades; j++) { + if (j == hit_cascade) { + const float EPSILON = 0.001; + vec3 hit_normal = normalize(vec3( + texture(sampler3D(sdf_cascades[hit_cascade], linear_sampler), uvw + vec3(EPSILON, 0.0, 0.0)).r - texture(sampler3D(sdf_cascades[hit_cascade], linear_sampler), uvw - vec3(EPSILON, 0.0, 0.0)).r, + texture(sampler3D(sdf_cascades[hit_cascade], linear_sampler), uvw + vec3(0.0, EPSILON, 0.0)).r - texture(sampler3D(sdf_cascades[hit_cascade], linear_sampler), uvw - vec3(0.0, EPSILON, 0.0)).r, + texture(sampler3D(sdf_cascades[hit_cascade], linear_sampler), uvw + vec3(0.0, 0.0, EPSILON)).r - texture(sampler3D(sdf_cascades[hit_cascade], linear_sampler), uvw - vec3(0.0, 0.0, EPSILON)).r)); + + vec3 hit_light = texture(sampler3D(light_cascades[hit_cascade], linear_sampler), uvw).rgb; + vec4 aniso0 = texture(sampler3D(aniso0_cascades[hit_cascade], linear_sampler), uvw); + vec3 hit_aniso0 = aniso0.rgb; + vec3 hit_aniso1 = vec3(aniso0.a, texture(sampler3D(aniso1_cascades[hit_cascade], linear_sampler), uvw).rg); + + //one liner magic + light.rgb = hit_light * (dot(max(vec3(0.0), (hit_normal * hit_aniso0)), vec3(1.0)) + dot(max(vec3(0.0), (-hit_normal * hit_aniso1)), vec3(1.0))); + light.a = 1.0; + } + } + } else if (params.sky_mode == SKY_MODE_SKY) { #ifdef USE_CUBEMAP_ARRAY light.rgb = textureLod(samplerCubeArray(sky_irradiance, linear_sampler_mipmaps), vec4(ray_dir, 0.0), 2.0).rgb; //use second mipmap because we dont usually throw a lot of rays, so this compensates diff --git a/servers/rendering/renderer_rd/shaders/volumetric_fog.glsl b/servers/rendering/renderer_rd/shaders/volumetric_fog.glsl index 4cbea055fa..e7ba8feb80 100644 --- a/servers/rendering/renderer_rd/shaders/volumetric_fog.glsl +++ b/servers/rendering/renderer_rd/shaders/volumetric_fog.glsl @@ -497,31 +497,31 @@ void main() { uint light_index = 32 * i + bit; - vec3 light_pos = omni_lights.data[light_index].position; - vec3 light_rel_vec = omni_lights.data[light_index].position - view_pos; + vec3 light_pos = spot_lights.data[light_index].position; + vec3 light_rel_vec = spot_lights.data[light_index].position - view_pos; float d = length(light_rel_vec); float shadow_attenuation = 1.0; - if (d * omni_lights.data[light_index].inv_radius < 1.0) { - float attenuation = get_omni_attenuation(d, omni_lights.data[light_index].inv_radius, omni_lights.data[light_index].attenuation); + if (d * spot_lights.data[light_index].inv_radius < 1.0) { + float attenuation = get_omni_attenuation(d, spot_lights.data[light_index].inv_radius, spot_lights.data[light_index].attenuation); - vec3 spot_dir = omni_lights.data[light_index].direction; - float scos = max(dot(-normalize(light_rel_vec), spot_dir), omni_lights.data[light_index].cone_angle); - float spot_rim = max(0.0001, (1.0 - scos) / (1.0 - omni_lights.data[light_index].cone_angle)); - attenuation *= 1.0 - pow(spot_rim, omni_lights.data[light_index].cone_attenuation); + vec3 spot_dir = spot_lights.data[light_index].direction; + float scos = max(dot(-normalize(light_rel_vec), spot_dir), spot_lights.data[light_index].cone_angle); + float spot_rim = max(0.0001, (1.0 - scos) / (1.0 - spot_lights.data[light_index].cone_angle)); + attenuation *= 1.0 - pow(spot_rim, spot_lights.data[light_index].cone_attenuation); - vec3 light = omni_lights.data[light_index].color / M_PI; + vec3 light = spot_lights.data[light_index].color / M_PI; - if (omni_lights.data[light_index].shadow_enabled) { + if (spot_lights.data[light_index].shadow_enabled) { //has shadow vec4 v = vec4(view_pos, 1.0); - vec4 splane = (omni_lights.data[light_index].shadow_matrix * v); + vec4 splane = (spot_lights.data[light_index].shadow_matrix * v); splane /= splane.w; float depth = texture(sampler2D(shadow_atlas, linear_sampler), splane.xy).r; - shadow_attenuation = exp(min(0.0, (depth - splane.z)) / omni_lights.data[light_index].inv_radius * omni_lights.data[light_index].shadow_volumetric_fog_fade); + shadow_attenuation = exp(min(0.0, (depth - splane.z)) / spot_lights.data[light_index].inv_radius * spot_lights.data[light_index].shadow_volumetric_fog_fade); } total_light += light * attenuation * shadow_attenuation; |