diff options
62 files changed, 486 insertions, 228 deletions
diff --git a/SConstruct b/SConstruct index a056a0c3ae..f1587e0280 100644 --- a/SConstruct +++ b/SConstruct @@ -234,7 +234,8 @@ env_base.platform_exporters = platform_exporters env_base.platform_apis = platform_apis if (env_base['target'] == 'debug'): - env_base.Append(CPPDEFINES=['DEBUG_MEMORY_ALLOC']) + env_base.Append(CPPDEFINES=['DEBUG_MEMORY_ALLOC','DISABLE_FORCED_INLINE']) + if (env_base['no_editor_splash']): env_base.Append(CPPDEFINES=['NO_EDITOR_SPLASH']) @@ -321,13 +322,13 @@ if selected_platform in platform_list: print("WARNING: warnings=yes is deprecated; assuming warnings=all") if env.msvc: - disable_nonessential_warnings = ['/wd4267', '/wd4244', '/wd4305', '/wd4800'] # Truncations, narrowing conversions... + # Truncations, narrowing conversions, signed/unsigned comparisons... + disable_nonessential_warnings = ['/wd4267', '/wd4244', '/wd4305', '/wd4018', '/wd4800'] if (env["warnings"] == 'extra'): env.Append(CCFLAGS=['/Wall']) # Implies /W4 elif (env["warnings"] == 'all' or env["warnings"] == 'yes'): env.Append(CCFLAGS=['/W3'] + disable_nonessential_warnings) elif (env["warnings"] == 'moderate'): - # C4244 shouldn't be needed here being a level-3 warning, but it is env.Append(CCFLAGS=['/W2'] + disable_nonessential_warnings) else: # 'no' env.Append(CCFLAGS=['/w']) diff --git a/core/class_db.cpp b/core/class_db.cpp index dcc07f8f41..71809d5454 100644 --- a/core/class_db.cpp +++ b/core/class_db.cpp @@ -809,10 +809,10 @@ void ClassDB::add_signal(StringName p_class, const MethodInfo &p_signal) { ClassInfo *type = classes.getptr(p_class); ERR_FAIL_COND(!type); - ClassInfo *check = type; StringName sname = p_signal.name; -#ifdef DEBUG_METHODS_ENABLED +#ifdef DEBUG_METHODS_ENABLED + ClassInfo *check = type; while (check) { if (check->signal_map.has(sname)) { ERR_EXPLAIN("Type " + String(p_class) + " already has signal: " + String(sname)); diff --git a/core/image.cpp b/core/image.cpp index c0002e0cd6..e90ed96499 100644 --- a/core/image.cpp +++ b/core/image.cpp @@ -307,6 +307,7 @@ void Image::_get_mipmap_offset_and_size(int p_mipmap, int &r_offset, int &r_widt r_width = w; r_height = h; } + int Image::get_mipmap_offset(int p_mipmap) const { ERR_FAIL_INDEX_V(p_mipmap, get_mipmap_count() + 1, -1); @@ -499,8 +500,6 @@ void Image::convert(Format p_new_format) { bool gen_mipmaps = mipmaps; - //mipmaps=false; - _copy_internals_from(new_img); if (gen_mipmaps) @@ -799,6 +798,7 @@ void Image::resize(int p_width, int p_height, Interpolation p_interpolation) { if (interpolate_mipmaps) { dst2.create(p_width, p_height, 0, format); } + bool had_mipmaps = mipmaps; if (interpolate_mipmaps && !had_mipmaps) { generate_mipmaps(); @@ -951,6 +951,7 @@ void Image::resize(int p_width, int p_height, Interpolation p_interpolation) { } void Image::crop_from_point(int p_x, int p_y, int p_width, int p_height) { + if (!_can_modify(format)) { ERR_EXPLAIN("Cannot crop in indexed, compressed or custom image formats."); ERR_FAIL(); @@ -996,7 +997,7 @@ void Image::crop_from_point(int p_x, int p_y, int p_width, int p_height) { } } - if (mipmaps > 0) + if (has_mipmaps()) dst.generate_mipmaps(); _copy_internals_from(dst); } @@ -1013,10 +1014,10 @@ void Image::flip_y() { ERR_FAIL(); } - bool gm = mipmaps; - - if (gm) + bool used_mipmaps = has_mipmaps(); + if (used_mipmaps) { clear_mipmaps(); + } { PoolVector<uint8_t>::Write w = data.write(); @@ -1037,8 +1038,9 @@ void Image::flip_y() { } } - if (gm) + if (used_mipmaps) { generate_mipmaps(); + } } void Image::flip_x() { @@ -1048,9 +1050,10 @@ void Image::flip_x() { ERR_FAIL(); } - bool gm = mipmaps; - if (gm) + bool used_mipmaps = has_mipmaps(); + if (used_mipmaps) { clear_mipmaps(); + } { PoolVector<uint8_t>::Write w = data.write(); @@ -1071,8 +1074,9 @@ void Image::flip_x() { } } - if (gm) + if (used_mipmaps) { generate_mipmaps(); + } } int Image::_get_dst_image_size(int p_width, int p_height, Format p_format, int &r_mipmaps, int p_mipmaps) { @@ -1167,12 +1171,13 @@ void Image::expand_x2_hq2x() { ERR_FAIL_COND(!_can_modify(format)); - Format current = format; - bool mm = has_mipmaps(); - if (mm) { + bool used_mipmaps = has_mipmaps(); + if (used_mipmaps) { clear_mipmaps(); } + Format current = format; + if (current != FORMAT_RGBA8) convert(FORMAT_RGBA8); @@ -1193,7 +1198,7 @@ void Image::expand_x2_hq2x() { if (current != FORMAT_RGBA8) convert(current); - if (mipmaps) { + if (used_mipmaps) { generate_mipmaps(); } } diff --git a/core/io/compression.cpp b/core/io/compression.cpp index e456a85c65..3c0b6541bd 100644 --- a/core/io/compression.cpp +++ b/core/io/compression.cpp @@ -175,7 +175,7 @@ int Compression::decompress(uint8_t *p_dst, int p_dst_max_size, const uint8_t *p } break; case MODE_ZSTD: { ZSTD_DCtx *dctx = ZSTD_createDCtx(); - if (zstd_long_distance_matching) ZSTD_DCtx_setMaxWindowSize(dctx, 1 << zstd_window_log_size); + if (zstd_long_distance_matching) ZSTD_DCtx_setMaxWindowSize(dctx, (size_t)1 << zstd_window_log_size); int ret = ZSTD_decompressDCtx(dctx, p_dst, p_dst_max_size, p_src, p_src_size); ZSTD_freeDCtx(dctx); return ret; diff --git a/core/io/file_access_pack.cpp b/core/io/file_access_pack.cpp index e3c8fb9eb8..40f756ba9a 100644 --- a/core/io/file_access_pack.cpp +++ b/core/io/file_access_pack.cpp @@ -169,11 +169,11 @@ bool PackedSourcePCK::try_open_pack(const String &p_path) { uint32_t version = f->get_32(); uint32_t ver_major = f->get_32(); uint32_t ver_minor = f->get_32(); - uint32_t ver_rev = f->get_32(); + f->get_32(); // ver_rev ERR_EXPLAIN("Pack version unsupported: " + itos(version)); ERR_FAIL_COND_V(version != PACK_VERSION, false); - ERR_EXPLAIN("Pack created with a newer version of the engine: " + itos(ver_major) + "." + itos(ver_minor) + "." + itos(ver_rev)); + ERR_EXPLAIN("Pack created with a newer version of the engine: " + itos(ver_major) + "." + itos(ver_minor)); ERR_FAIL_COND_V(ver_major > VERSION_MAJOR || (ver_major == VERSION_MAJOR && ver_minor > VERSION_MINOR), false); for (int i = 0; i < 16; i++) { diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp index 628019ef7f..ec430d41a9 100644 --- a/core/io/marshalls.cpp +++ b/core/io/marshalls.cpp @@ -868,8 +868,6 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo } break; case Variant::REAL: { - double d = p_variant; - float f = d; if (flags & ENCODE_FLAG_64) { if (buf) { encode_double(p_variant.operator double(), buf); diff --git a/core/math/bsp_tree.cpp b/core/math/bsp_tree.cpp index 6e51c56357..6ffc963783 100644 --- a/core/math/bsp_tree.cpp +++ b/core/math/bsp_tree.cpp @@ -165,7 +165,6 @@ int BSP_Tree::get_points_inside(const Vector3 *p_points, int p_point_count) cons int pass_count = 0; const Node *nodesptr = &nodes[0]; const Plane *planesptr = &planes[0]; - int plane_count = planes.size(); int node_count = nodes.size(); if (node_count == 0) // no nodes! @@ -192,9 +191,9 @@ int BSP_Tree::get_points_inside(const Vector3 *p_points, int p_point_count) cons break; } - uint16_t plane = nodesptr[idx].plane; #ifdef DEBUG_ENABLED - + int plane_count = planes.size(); + uint16_t plane = nodesptr[idx].plane; ERR_FAIL_INDEX_V(plane, plane_count, false); #endif diff --git a/core/typedefs.h b/core/typedefs.h index 2b26bf08f7..5c15da9c2d 100644 --- a/core/typedefs.h +++ b/core/typedefs.h @@ -44,6 +44,7 @@ #define _MKSTR(m_x) _STR(m_x) #endif +//should always inline no matter what #ifndef _ALWAYS_INLINE_ #if defined(__GNUC__) && (__GNUC__ >= 4) @@ -58,10 +59,17 @@ #endif +//should always inline, except in some cases because it makes debugging harder #ifndef _FORCE_INLINE_ + +#ifdef DISABLE_FORCED_INLINE +#define _FORCE_INLINE_ inline +#else #define _FORCE_INLINE_ _ALWAYS_INLINE_ #endif +#endif + //custom, gcc-safe offsetof, because gcc complains a lot. template <class T> T *_nullptr() { diff --git a/core/ustring.cpp b/core/ustring.cpp index e46896ca85..3f073b181f 100644 --- a/core/ustring.cpp +++ b/core/ustring.cpp @@ -1828,8 +1828,8 @@ static double built_in_strtod(const C *string, /* A decimal ASCII floating-point int sign, expSign = false; double fraction, dblExp; const double *d; - register const C *p; - register int c; + const C *p; + int c; int exp = 0; /* Exponent read from "EX" field. */ int fracExp = 0; /* Exponent that derives from the fractional * part. Under normal circumstances, it is diff --git a/doc/classes/Color.xml b/doc/classes/Color.xml index 2e3cc2e5d1..82a10fbaa4 100644 --- a/doc/classes/Color.xml +++ b/doc/classes/Color.xml @@ -4,8 +4,8 @@ Color in RGBA format with some support for ARGB format. </brief_description> <description> - A color is represented as red, green and blue (r,g,b) components. Additionally, "a" represents the alpha component, often used for transparency. Values are in floating point and usually range from 0 to 1. Some methods (such as set_modulate(color)) may accept values > 1. - You can also create a color from standardised color names with Color.ColorN (e.g. Color.green) or [method @GDScript.ColorN]. + A color is represented by red, green, and blue [code](r, g, b)[/code] components. Additionally, [code]a[/code] represents the alpha component, often used for transparency. Values are in floating point and usually range from 0 to 1. Some properties (such as [member CanvasItem.modulate]) may accept values > 1. + You can also create a color from standardized color names by using [method @GDScript.ColorN]. </description> <tutorials> </tutorials> @@ -25,7 +25,7 @@ [code]"#ff00ff"[/code] - RGB format with '#' [code]"ff00ff"[/code] - RGB format [codeblock] - # The following code creates the same color of an RGBA(178, 217, 10, 255) + # Each of the following creates the same color RGBA(178, 217, 10, 255) var c1 = Color("#ffb2d90a") # ARGB format with '#' var c2 = Color("ffb2d90a") # ARGB format var c3 = Color("#b2d90a") # RGB format with '#' @@ -41,7 +41,7 @@ <description> Constructs a color from a 32-bit integer (each byte represents a component of the RGBA profile). [codeblock] - var c = Color(274) # a color of an RGBA(0, 0, 1, 18) + var c = Color(274) # Equivalent to RGBA(0, 0, 1, 18) [/codeblock] </description> </method> @@ -55,9 +55,9 @@ <argument index="2" name="b" type="float"> </argument> <description> - Constructs a color from an RGB profile using values between 0 and 1 (float). Alpha will always be 1. + Constructs a color from an RGB profile using values between 0 and 1. Alpha will always be 1. [codeblock] - var c = Color(0.2, 1.0, .7) # a color of an RGBA(51, 255, 178, 255) + var c = Color(0.2, 1.0, .7) # Equivalent to RGBA(51, 255, 178, 255) [/codeblock] </description> </method> @@ -73,9 +73,9 @@ <argument index="3" name="a" type="float"> </argument> <description> - Constructs a color from an RGBA profile using values between 0 and 1 (float). + Constructs a color from an RGBA profile using values between 0 and 1. [codeblock] - var c = Color(0.2, 1.0, .7, .8) # a color of an RGBA(51, 255, 178, 204) + var c = Color(0.2, 1.0, .7, .8) # Equivalent to RGBA(51, 255, 178, 204) [/codeblock] </description> </method> @@ -85,7 +85,7 @@ <argument index="0" name="over" type="Color"> </argument> <description> - Returns a new color resulting from blending this color over another color. If the color is opaque, the result would also be opaque. The other color could then take a range of values with different alpha values. + Returns a new color resulting from blending this color over another. If the color is opaque, the result is also opaque. The second color may have a range of alpha values. [codeblock] var bg = Color(0.0, 1.0, 0.0, 0.5) # Green with alpha of 50% var fg = Color(1.0, 0.0, 0.0, .5) # Red with alpha of 50% @@ -100,7 +100,7 @@ Returns the most contrasting color. [codeblock] var c = Color(.3, .4, .9) - var contrastedColor = c.contrasted() # a color of an RGBA(204, 229, 102, 255) + var contrastedColor = c.contrasted() # Equivalent to RGBA(204, 229, 102, 255) [/codeblock] </description> </method> @@ -131,7 +131,7 @@ <description> Constructs a color from an HSV profile. [code]h[/code], [code]s[/code], and [code]v[/code] are values between 0 and 1. [codeblock] - var c = Color.from_hsv(0.58, 0.5, 0.79, 0.8) # equivalent to HSV(210, 50, 79, 0.8) or Color8(100, 151, 201, 0.8) + var c = Color.from_hsv(0.58, 0.5, 0.79, 0.8) # Equivalent to HSV(210, 50, 79, 0.8) or Color8(100, 151, 201, 0.8) [/codeblock] </description> </method> @@ -139,8 +139,8 @@ <return type="float"> </return> <description> - Returns the color's grayscale. - The gray is calculated by (r + g + b) / 3. + Returns the color's grayscale representation. + The gray is calculated by [code](r + g + b) / 3[/code]. [codeblock] var c = Color(0.2, 0.45, 0.82) var gray = c.gray() # a value of 0.466667 @@ -151,7 +151,7 @@ <return type="Color"> </return> <description> - Returns the inverted color (1-r, 1-g, 1-b, 1-a). + Returns the inverted color [code](1 - r, 1 - g, 1 - b, 1 - a)[/code]. [codeblock] var c = Color(.3, .4, .9) var invertedColor = c.inverted() # a color of an RGBA(178, 153, 26, 255) @@ -179,7 +179,7 @@ <argument index="1" name="t" type="float"> </argument> <description> - Returns the color of the linear interpolation with another color. The value t is between 0 and 1 (float). + Returns the linear interpolation with another color. The value t is between 0 and 1. [codeblock] var c1 = Color(1.0, 0.0, 0.0) var c2 = Color(0.0, 1.0, 0.0) @@ -238,7 +238,7 @@ </argument> <description> Returns the color's HTML hexadecimal color string in ARGB format (ex: [code]ff34f822[/code]). - Optionally flag 'false' to not include alpha in hexadecimal string. + Setting [code]with_alpha[/code] to [code]false[/code] excludes alpha from the hexadecimal string. [codeblock] var c = Color(1, 1, 1, .5) var s1 = c.to_html() # Results "7fffffff" @@ -250,7 +250,7 @@ <return type="int"> </return> <description> - Returns the color's 32-bit integer in RGBA format (each byte represents a component of the RGBA profile). RGBA is the format that Godot uses by default. + Returns the color's 32-bit integer in RGBA format (each byte represents a component of the RGBA profile). RGBA is Godot's default format. [codeblock] var c = Color(1, .5, .2) print(c.to_rgba32()) # Prints 4286526463 @@ -261,7 +261,7 @@ <return type="int"> </return> <description> - Returns the color's 64-bit integer in RGBA format (each word represents a component of the RGBA profile). RGBA is the format that Godot uses by default. + Returns the color's 64-bit integer in RGBA format (each word represents a component of the RGBA profile). RGBA is Godot's default format. [codeblock] var c = Color(1, .5, .2) print(c.to_rgba64()) # Prints -140736629309441 @@ -271,37 +271,37 @@ </methods> <members> <member name="a" type="float" setter="" getter=""> - Alpha (0 to 1) + Alpha value (range 0 to 1). </member> <member name="a8" type="int" setter="" getter=""> - Alpha (0 to 255) + Alpha value (range 0 to 255). </member> <member name="b" type="float" setter="" getter=""> - Blue (0 to 1) + Blue value (range 0 to 1). </member> <member name="b8" type="int" setter="" getter=""> - Blue (0 to 255) + Blue value (range 0 to 255). </member> <member name="g" type="float" setter="" getter=""> - Green (0 to 1) + Green value (range 0 to 1). </member> <member name="g8" type="int" setter="" getter=""> - Green (0 to 255) + Green value (range 0 to 255). </member> <member name="h" type="float" setter="" getter=""> - Hue (0 to 1) + HSV hue value (range 0 to 1). </member> <member name="r" type="float" setter="" getter=""> - Red (0 to 1) + Red value (range 0 to 1). </member> <member name="r8" type="int" setter="" getter=""> - Red (0 to 255) + Red value (range 0 to 255). </member> <member name="s" type="float" setter="" getter=""> - Saturation (0 to 1) + HSV saturation value (range 0 to 1). </member> <member name="v" type="float" setter="" getter=""> - Value (0 to 1) + HSV value (range 0 to 1). </member> </members> <constants> diff --git a/doc/classes/ItemList.xml b/doc/classes/ItemList.xml index 38d32fe7c8..4e4947de6c 100644 --- a/doc/classes/ItemList.xml +++ b/doc/classes/ItemList.xml @@ -412,6 +412,7 @@ Fired when specified list item has been selected via right mouse clicking. The click position is also provided to allow appropriate popup of context menus at the correct location. + [member allow_rmb_select] must be enabled. </description> </signal> <signal name="item_selected"> @@ -419,6 +420,7 @@ </argument> <description> Fired when specified item has been selected. + [member allow_reselect] must be enabled to reselect an item. </description> </signal> <signal name="multi_selected"> diff --git a/doc/classes/Node.xml b/doc/classes/Node.xml index 90e9436307..dc754b4628 100644 --- a/doc/classes/Node.xml +++ b/doc/classes/Node.xml @@ -176,6 +176,7 @@ </argument> <description> Finds a descendant of this node whose name matches [code]mask[/code] as in [method String.match] (i.e. case sensitive, but '*' matches zero or more characters and '?' matches any single character except '.'). Note that it does not match against the full path, just against individual node names. + If [code]owned[/code] is [code]true[/code], this method only finds nodes whose owner is this node. This is especially important for scenes instantiated through script, because those scenes don't have an owner. </description> </method> <method name="get_child" qualifiers="const"> diff --git a/doc/classes/OS.xml b/doc/classes/OS.xml index dad4ce898d..26684836ea 100644 --- a/doc/classes/OS.xml +++ b/doc/classes/OS.xml @@ -583,6 +583,7 @@ </argument> <description> Plays native video from the specified path, at the given volume and with audio and subtitle tracks. + Note: This method is only implemented on Android and iOS, and the current Android implementation does not support the [code]volume[/code], [code]audio_track[/code] and [code]subtitle_track[/code] options. </description> </method> <method name="native_video_stop"> diff --git a/doc/classes/ParallaxLayer.xml b/doc/classes/ParallaxLayer.xml index 662a15e043..e6ea166282 100644 --- a/doc/classes/ParallaxLayer.xml +++ b/doc/classes/ParallaxLayer.xml @@ -6,6 +6,7 @@ <description> A ParallaxLayer must be the child of a [ParallaxBackground] node. Each ParallaxLayer can be set to move at different speeds relative to the camera movement or the [member ParallaxBackground.scroll_offset] value. This node's children will be affected by its scroll offset. + Note that any changes to this node's position and scale made after it enters the scene will be ignored. </description> <tutorials> </tutorials> diff --git a/doc/classes/RigidBody.xml b/doc/classes/RigidBody.xml index f9e0f821a9..0977b7ea01 100644 --- a/doc/classes/RigidBody.xml +++ b/doc/classes/RigidBody.xml @@ -60,8 +60,8 @@ <argument index="0" name="impulse" type="Vector3"> </argument> <description> - Applies a single directional impulse without affecting rotation. - This is equivalent to ``apply_impulse(Vector3(0,0,0), impulse)``. + Applies a directional impulse without affecting rotation. + This is equivalent to [code]apply_impulse(Vector3(0,0,0), impulse)[/code]. </description> </method> <method name="apply_impulse"> @@ -72,7 +72,7 @@ <argument index="1" name="impulse" type="Vector3"> </argument> <description> - Apply a positioned impulse (which will be affected by the body mass and shape). This is the equivalent of hitting a billiard ball with a cue: a force that is applied once, and only once. Both the impulse and the position are in global coordinates, and the position is relative to the object's origin. + Applies a positioned impulse which will be affected by the body mass and shape. This is the equivalent of hitting a billiard ball with a cue: a force that is applied once, and only once. Both the impulse and the position are in global coordinates, and the position is relative to the object's origin. </description> </method> <method name="apply_torque_impulse"> @@ -81,14 +81,14 @@ <argument index="0" name="impulse" type="Vector3"> </argument> <description> - Apply a torque impulse (which will be affected by the body mass and shape). This will rotate the body around the passed in vector. + Applies a torque impulse which will be affected by the body mass and shape. This will rotate the body around the passed in vector. </description> </method> <method name="get_colliding_bodies" qualifiers="const"> <return type="Array"> </return> <description> - Return a list of the bodies colliding with this one. By default, number of max contacts reported is at 0 , see [method set_max_contacts_reported] to increase it. Note that the result of this test is not immediate after moving objects. For performance, list of collisions is updated once per frame and before the physics step. Consider using signals instead. + Return a list of the bodies colliding with this one. By default, number of max contacts reported is at 0 , see [method set_max_contacts_reported] to increase it. Note that the result of this test is not immediate after moving objects. For performance, list of collisions is updated once per frame and before the physics step. Consider using signals instead. </description> </method> <method name="set_axis_velocity"> @@ -97,7 +97,7 @@ <argument index="0" name="axis_velocity" type="Vector3"> </argument> <description> - Set an axis velocity. The velocity in the given vector axis will be set as the given vector length. This is useful for jumping behavior. + Sets an axis velocity. The velocity in the given vector axis will be set as the given vector length. This is useful for jumping behavior. </description> </method> </methods> @@ -109,16 +109,22 @@ RigidBody's rotational velocity. </member> <member name="axis_lock_angular_x" type="bool" setter="set_axis_lock" getter="get_axis_lock"> + Lock the body's rotation in the x-axis. </member> <member name="axis_lock_angular_y" type="bool" setter="set_axis_lock" getter="get_axis_lock"> + Lock the body's rotation in the y-axis. </member> <member name="axis_lock_angular_z" type="bool" setter="set_axis_lock" getter="get_axis_lock"> + Lock the body's rotation in the z-axis. </member> <member name="axis_lock_linear_x" type="bool" setter="set_axis_lock" getter="get_axis_lock"> + Lock the body's movement in the x-axis. </member> <member name="axis_lock_linear_y" type="bool" setter="set_axis_lock" getter="get_axis_lock"> + Lock the body's movement in the x-axis. </member> <member name="axis_lock_linear_z" type="bool" setter="set_axis_lock" getter="get_axis_lock"> + Lock the body's movement in the x-axis. </member> <member name="bounce" type="float" setter="set_bounce" getter="get_bounce"> RigidBody's bounciness. @@ -127,7 +133,7 @@ If [code]true[/code] the RigidBody will not calculate forces and will act as a static body while there is no movement. It will wake up when forces are applied through other collisions or when the [code]apply_impulse[/code] method is used. </member> <member name="contact_monitor" type="bool" setter="set_contact_monitor" getter="is_contact_monitor_enabled"> - If true, the RigidBody will emit signals when it collides with another RigidBody. + If [code]true[/code] the RigidBody will emit signals when it collides with another RigidBody. </member> <member name="contacts_reported" type="int" setter="set_max_contacts_reported" getter="get_max_contacts_reported"> The maximum contacts to report. Bodies can keep a log of the contacts with other bodies, this is enabled by setting the maximum amount of contacts reported to a number greater than 0. @@ -140,19 +146,19 @@ If [code]true[/code] internal force integration will be disabled (like gravity or air friction) for this body. Other than collision response, the body will only move as determined by the [method _integrate_forces] function, if defined. </member> <member name="friction" type="float" setter="set_friction" getter="get_friction"> - The body friction, from 0 (frictionless) to 1 (max friction). + The body's friction, from 0 (frictionless) to 1 (max friction). </member> <member name="gravity_scale" type="float" setter="set_gravity_scale" getter="get_gravity_scale"> This is multiplied by the global 3D gravity setting found in "Project > Project Settings > Physics > 3d" to produce RigidBody's gravity. E.g. a value of 1 will be normal gravity, 2 will apply double gravity, and 0.5 will apply half gravity to this object. </member> <member name="linear_damp" type="float" setter="set_linear_damp" getter="get_linear_damp"> - RigidBody's linear damp. Default value: -1, cannot be less than -1. If this value is different from -1, any linear damp derived from the world or areas will be overridden. + The body's linear damp. Default value: -1, cannot be less than -1. If this value is different from -1, any linear damp derived from the world or areas will be overridden. </member> <member name="linear_velocity" type="Vector3" setter="set_linear_velocity" getter="get_linear_velocity"> - RigidBody's linear velocity. Can be used sporadically, but [b]DON'T SET THIS IN EVERY FRAME[/b], because physics may run in another thread and runs at a different granularity. Use [method _integrate_forces] as your process loop for precise control of the body state. + The body's linear velocity. Can be used sporadically, but [b]DON'T SET THIS IN EVERY FRAME[/b], because physics may run in another thread and runs at a different granularity. Use [method _integrate_forces] as your process loop for precise control of the body state. </member> <member name="mass" type="float" setter="set_mass" getter="get_mass"> - RigidBody's mass. + The body's mass. </member> <member name="mode" type="int" setter="set_mode" getter="get_mode" enum="RigidBody.Mode"> The body mode from the MODE_* enum. Modes include: MODE_STATIC, MODE_KINEMATIC, MODE_RIGID, and MODE_CHARACTER. @@ -160,10 +166,10 @@ <member name="physics_material_override" type="PhysicsMaterial" setter="set_physics_material_override" getter="get_physics_material_override"> </member> <member name="sleeping" type="bool" setter="set_sleeping" getter="is_sleeping"> - If [code]true[/code] RigidBody is sleeping and will not calculate forces until woken up by a collision or the [code]apply_impulse[/code] method. + If [code]true[/code] the body is sleeping and will not calculate forces until woken up by a collision or the [code]apply_impulse[/code] method. </member> <member name="weight" type="float" setter="set_weight" getter="get_weight"> - RigidBody's weight based on its mass and the global 3D gravity. Global values are set in "Project > Project Settings > Physics > 3d". + The body's weight based on its mass and the global 3D gravity. Global values are set in "Project > Project Settings > Physics > 3d". </member> </members> <signals> @@ -217,16 +223,16 @@ </signals> <constants> <constant name="MODE_RIGID" value="0" enum="Mode"> - Rigid body. This is the "natural" state of a rigid body. It is affected by forces, and can move, rotate, and be affected by user code. + Rigid body mode. This is the "natural" state of a rigid body. It is affected by forces, and can move, rotate, and be affected by user code. </constant> <constant name="MODE_STATIC" value="1" enum="Mode"> Static mode. The body behaves like a [StaticBody], and can only move by user code. </constant> <constant name="MODE_CHARACTER" value="2" enum="Mode"> - Character body. This behaves like a rigid body, but can not rotate. + Character body mode. This behaves like a rigid body, but can not rotate. </constant> <constant name="MODE_KINEMATIC" value="3" enum="Mode"> - Kinematic body. The body behaves like a [KinematicBody], and can only move by user code. + Kinematic body mode. The body behaves like a [KinematicBody], and can only move by user code. </constant> </constants> </class> diff --git a/doc/classes/RigidBody2D.xml b/doc/classes/RigidBody2D.xml index 1f6b3934c2..079440ab8b 100644 --- a/doc/classes/RigidBody2D.xml +++ b/doc/classes/RigidBody2D.xml @@ -29,6 +29,7 @@ <argument index="0" name="force" type="Vector2"> </argument> <description> + Adds a constant directional force without affecting rotation. </description> </method> <method name="add_force"> @@ -48,6 +49,7 @@ <argument index="0" name="torque" type="float"> </argument> <description> + Adds a constant rotational force. </description> </method> <method name="apply_central_impulse"> @@ -56,6 +58,7 @@ <argument index="0" name="impulse" type="Vector2"> </argument> <description> + Applies a directional impulse without affecting rotation. </description> </method> <method name="apply_impulse"> @@ -75,6 +78,7 @@ <argument index="0" name="torque" type="float"> </argument> <description> + Applies a rotational impulse to the body. </description> </method> <method name="get_colliding_bodies" qualifiers="const"> diff --git a/doc/classes/TreeItem.xml b/doc/classes/TreeItem.xml index 57e0f2825a..c5a63b1acb 100644 --- a/doc/classes/TreeItem.xml +++ b/doc/classes/TreeItem.xml @@ -400,6 +400,7 @@ </argument> <description> Sets the given column's custom draw callback to [code]callback[/code] method on [code]object[/code]. + The [code]callback[/code] should accept two arguments: the [TreeItem] that is drawn and its position and size as a [Rect2]. </description> </method> <method name="set_editable"> diff --git a/doc/tools/makerst.py b/doc/tools/makerst.py index 63a5c8cbbf..b3d6d32c26 100755 --- a/doc/tools/makerst.py +++ b/doc/tools/makerst.py @@ -610,8 +610,7 @@ def make_rst_class(node): s += ' = **' + c.attrib['value'] + '**' if c.text.strip() != '': s += ' --- ' + rstize_text(c.text.strip(), name) - f.write(s + '\n') - f.write('\n') + f.write(s + '\n\n') # Constants if len(consts) > 0: @@ -623,8 +622,7 @@ def make_rst_class(node): s += ' = **' + c.attrib['value'] + '**' if c.text.strip() != '': s += ' --- ' + rstize_text(c.text.strip(), name) - f.write(s + '\n') - f.write('\n') + f.write(s + '\n\n') # Class description descr = node.find('description') diff --git a/drivers/gles2/rasterizer_canvas_gles2.cpp b/drivers/gles2/rasterizer_canvas_gles2.cpp index 30776091a4..18b5dd3483 100644 --- a/drivers/gles2/rasterizer_canvas_gles2.cpp +++ b/drivers/gles2/rasterizer_canvas_gles2.cpp @@ -1185,7 +1185,6 @@ void RasterizerCanvasGLES2::initialize() { _EIDX(1, 1), _EIDX(1, 2), _EIDX(2, 2), _EIDX(2, 2), _EIDX(2, 1), _EIDX(1, 1) }; - ; #undef _EIDX glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(elems), elems, GL_STATIC_DRAW); @@ -1200,6 +1199,8 @@ void RasterizerCanvasGLES2::initialize() { state.canvas_shader.bind(); state.lens_shader.init(); + + state.canvas_shader.set_conditional(CanvasShaderGLES2::USE_PIXEL_SNAP, GLOBAL_DEF("rendering/quality/2d/use_pixel_snap", false)); } void RasterizerCanvasGLES2::finalize() { diff --git a/drivers/gles2/rasterizer_scene_gles2.cpp b/drivers/gles2/rasterizer_scene_gles2.cpp index 15f1aa44be..fbcbebc88c 100644 --- a/drivers/gles2/rasterizer_scene_gles2.cpp +++ b/drivers/gles2/rasterizer_scene_gles2.cpp @@ -742,20 +742,38 @@ void RasterizerSceneGLES2::environment_set_adjustment(RID p_env, bool p_enable, } void RasterizerSceneGLES2::environment_set_fog(RID p_env, bool p_enable, const Color &p_color, const Color &p_sun_color, float p_sun_amount) { + Environment *env = environment_owner.getornull(p_env); ERR_FAIL_COND(!env); + + env->fog_enabled = p_enable; + env->fog_color = p_color; + env->fog_sun_color = p_sun_color; + env->fog_sun_amount = p_sun_amount; } void RasterizerSceneGLES2::environment_set_fog_depth(RID p_env, bool p_enable, float p_depth_begin, float p_depth_curve, bool p_transmit, float p_transmit_curve) { + Environment *env = environment_owner.getornull(p_env); ERR_FAIL_COND(!env); + + env->fog_depth_enabled = p_enable; + env->fog_depth_begin = p_depth_begin; + env->fog_depth_curve = p_depth_curve; + env->fog_transmit_enabled = p_transmit; + env->fog_transmit_curve = p_transmit_curve; } void RasterizerSceneGLES2::environment_set_fog_height(RID p_env, bool p_enable, float p_min_height, float p_max_height, float p_height_curve) { + Environment *env = environment_owner.getornull(p_env); ERR_FAIL_COND(!env); -} + env->fog_height_enabled = p_enable; + env->fog_height_min = p_min_height; + env->fog_height_max = p_max_height; + env->fog_height_curve = p_height_curve; +} bool RasterizerSceneGLES2::is_environment(RID p_env) { return environment_owner.owns(p_env); } @@ -2031,6 +2049,15 @@ void RasterizerSceneGLES2::_render_render_list(RenderList::Element **p_elements, glDisable(GL_BLEND); } + float fog_max_distance = 0; + bool using_fog = false; + if (p_env && !p_shadow && p_env->fog_enabled && (p_env->fog_depth_enabled || p_env->fog_height_enabled)) { + state.scene_shader.set_conditional(SceneShaderGLES2::FOG_DEPTH_ENABLED, p_env->fog_depth_enabled); + state.scene_shader.set_conditional(SceneShaderGLES2::FOG_HEIGHT_ENABLED, p_env->fog_height_enabled); + fog_max_distance = p_projection.get_z_far(); + using_fog = true; + } + RasterizerStorageGLES2::Texture *prev_lightmap = NULL; float lightmap_energy = 1.0; bool prev_use_lightmap_capture = false; @@ -2142,7 +2169,7 @@ void RasterizerSceneGLES2::_render_render_list(RenderList::Element **p_elements, } //condition to enable vertex lighting on this object - bool vertex_lit = light && (material->shader->spatial.uses_vertex_lighting || storage->config.force_vertex_shading) && !unshaded; + bool vertex_lit = (material->shader->spatial.uses_vertex_lighting || storage->config.force_vertex_shading) && ((!unshaded && light) || using_fog); //fog forces vertex lighting because it still applies even if unshaded or no fog if (vertex_lit != prev_vertex_lit) { state.scene_shader.set_conditional(SceneShaderGLES2::USE_VERTEX_LIGHTING, vertex_lit); @@ -2268,10 +2295,34 @@ void RasterizerSceneGLES2::_render_render_list(RenderList::Element **p_elements, rebind_light = true; rebind_reflection = true; rebind_lightmap = true; + + if (using_fog) { + + state.scene_shader.set_uniform(SceneShaderGLES2::FOG_COLOR_BASE, p_env->fog_color); + Color sun_color_amount = p_env->fog_sun_color; + sun_color_amount.a = p_env->fog_sun_amount; + + state.scene_shader.set_uniform(SceneShaderGLES2::FOG_SUN_COLOR_AMOUNT, sun_color_amount); + state.scene_shader.set_uniform(SceneShaderGLES2::FOG_TRANSMIT_ENABLED, p_env->fog_transmit_enabled); + state.scene_shader.set_uniform(SceneShaderGLES2::FOG_TRANSMIT_CURVE, p_env->fog_transmit_curve); + + if (p_env->fog_depth_enabled) { + state.scene_shader.set_uniform(SceneShaderGLES2::FOG_DEPTH_BEGIN, p_env->fog_depth_begin); + state.scene_shader.set_uniform(SceneShaderGLES2::FOG_DEPTH_CURVE, p_env->fog_depth_curve); + state.scene_shader.set_uniform(SceneShaderGLES2::FOG_MAX_DISTANCE, fog_max_distance); + } + + if (p_env->fog_height_enabled) { + state.scene_shader.set_uniform(SceneShaderGLES2::FOG_HEIGHT_MIN, p_env->fog_height_min); + state.scene_shader.set_uniform(SceneShaderGLES2::FOG_HEIGHT_MAX, p_env->fog_height_max); + state.scene_shader.set_uniform(SceneShaderGLES2::FOG_HEIGHT_MAX, p_env->fog_height_max); + state.scene_shader.set_uniform(SceneShaderGLES2::FOG_HEIGHT_CURVE, p_env->fog_height_curve); + } + } } - state.scene_shader.set_uniform(SceneShaderGLES2::CAMERA_MATRIX, view_transform_inverse); - state.scene_shader.set_uniform(SceneShaderGLES2::CAMERA_INVERSE_MATRIX, p_view_transform); + state.scene_shader.set_uniform(SceneShaderGLES2::CAMERA_MATRIX, p_view_transform); + state.scene_shader.set_uniform(SceneShaderGLES2::CAMERA_INVERSE_MATRIX, view_transform_inverse); state.scene_shader.set_uniform(SceneShaderGLES2::PROJECTION_MATRIX, p_projection); state.scene_shader.set_uniform(SceneShaderGLES2::PROJECTION_INVERSE_MATRIX, projection_inverse); @@ -2328,6 +2379,8 @@ void RasterizerSceneGLES2::_render_render_list(RenderList::Element **p_elements, state.scene_shader.set_conditional(SceneShaderGLES2::USE_REFLECTION_PROBE2, false); state.scene_shader.set_conditional(SceneShaderGLES2::USE_LIGHTMAP, false); state.scene_shader.set_conditional(SceneShaderGLES2::USE_LIGHTMAP_CAPTURE, false); + state.scene_shader.set_conditional(SceneShaderGLES2::FOG_DEPTH_ENABLED, false); + state.scene_shader.set_conditional(SceneShaderGLES2::FOG_HEIGHT_ENABLED, false); } void RasterizerSceneGLES2::_draw_sky(RasterizerStorageGLES2::Sky *p_sky, const CameraMatrix &p_projection, const Transform &p_transform, bool p_vflip, float p_custom_fov, float p_energy) { diff --git a/drivers/gles2/rasterizer_scene_gles2.h b/drivers/gles2/rasterizer_scene_gles2.h index 14b9116952..33ac99366d 100644 --- a/drivers/gles2/rasterizer_scene_gles2.h +++ b/drivers/gles2/rasterizer_scene_gles2.h @@ -353,6 +353,21 @@ public: int canvas_max_layer; + bool fog_enabled; + Color fog_color; + Color fog_sun_color; + float fog_sun_amount; + + bool fog_depth_enabled; + float fog_depth_begin; + float fog_depth_curve; + bool fog_transmit_enabled; + float fog_transmit_curve; + bool fog_height_enabled; + float fog_height_min; + float fog_height_max; + float fog_height_curve; + Environment() { bg_mode = VS::ENV_BG_CLEAR_COLOR; sky_custom_fov = 0.0; @@ -361,6 +376,24 @@ public: ambient_energy = 1.0; ambient_sky_contribution = 0.0; canvas_max_layer = 0; + + fog_enabled = false; + fog_color = Color(0.5, 0.5, 0.5); + fog_sun_color = Color(0.8, 0.8, 0.0); + fog_sun_amount = 0; + + fog_depth_enabled = true; + + fog_depth_begin = 10; + fog_depth_curve = 1; + + fog_transmit_enabled = true; + fog_transmit_curve = 1; + + fog_height_enabled = false; + fog_height_min = 0; + fog_height_max = 100; + fog_height_curve = 1; } }; diff --git a/drivers/gles2/shaders/canvas.glsl b/drivers/gles2/shaders/canvas.glsl index 3db60f7caa..b990384949 100644 --- a/drivers/gles2/shaders/canvas.glsl +++ b/drivers/gles2/shaders/canvas.glsl @@ -96,6 +96,10 @@ VERTEX_SHADER_CODE color_interp = color; +#ifdef USE_PIXEL_SNAP + outvec.xy = floor(outvec + 0.5).xy; +#endif + gl_Position = projection_matrix * outvec; } diff --git a/drivers/gles2/shaders/scene.glsl b/drivers/gles2/shaders/scene.glsl index 42b50790b2..fae010b003 100644 --- a/drivers/gles2/shaders/scene.glsl +++ b/drivers/gles2/shaders/scene.glsl @@ -286,6 +286,33 @@ varying mediump vec3 refprobe2_ambient_normal; #endif //vertex lighting for refprobes +#if defined(FOG_DEPTH_ENABLED) || defined(FOG_HEIGHT_ENABLED) + +varying vec4 fog_interp; + +uniform mediump vec4 fog_color_base; +#ifdef LIGHT_MODE_DIRECTIONAL +uniform mediump vec4 fog_sun_color_amount; +#endif + +uniform bool fog_transmit_enabled; +uniform mediump float fog_transmit_curve; + +#ifdef FOG_DEPTH_ENABLED +uniform highp float fog_depth_begin; +uniform mediump float fog_depth_curve; +uniform mediump float fog_max_distance; +#endif + +#ifdef FOG_HEIGHT_ENABLED +uniform highp float fog_height_min; +uniform highp float fog_height_max; +uniform mediump float fog_height_curve; +#endif + + +#endif //fog + void main() { highp vec4 vertex = vertex_attrib; @@ -379,7 +406,7 @@ void main() { #endif - mat4 modelview = camera_matrix * world_matrix; + mat4 modelview = camera_inverse_matrix * world_matrix; float roughness = 1.0; #define world_transform world_matrix @@ -406,11 +433,11 @@ VERTEX_SHADER_CODE #endif #if !defined(SKIP_TRANSFORM_USED) && defined(VERTEX_WORLD_COORDS_USED) - vertex = camera_matrix * vertex; - normal = normalize((camera_matrix * vec4(normal, 0.0)).xyz); + vertex = camera_inverse_matrix * vertex; + normal = normalize((camera_inverse_matrix * vec4(normal, 0.0)).xyz); #if defined(ENABLE_TANGENT_INTERP) || defined(ENABLE_NORMALMAP) - tangent = normalize((camera_matrix * vec4(tangent, 0.0)).xyz); - binormal = normalize((camera_matrix * vec4(binormal, 0.0)).xyz); + tangent = normalize((camera_inverse_matrix * vec4(tangent, 0.0)).xyz); + binormal = normalize((camera_inverse_matrix * vec4(binormal, 0.0)).xyz); #endif #endif @@ -583,6 +610,37 @@ VERTEX_SHADER_CODE #endif //USE_REFLECTION_PROBE2 +#if defined(FOG_DEPTH_ENABLED) || defined(FOG_HEIGHT_ENABLED) + + float fog_amount = 0.0; + +#ifdef LIGHT_MODE_DIRECTIONAL + + vec3 fog_color = mix(fog_color_base.rgb, fog_sun_color_amount.rgb, fog_sun_color_amount.a * pow(max(dot(normalize(vertex_interp), light_direction), 0.0), 8.0)); +#else + vec3 fog_color = fog_color_base.rgb; +#endif + +#ifdef FOG_DEPTH_ENABLED + + { + + float fog_z = smoothstep(fog_depth_begin, fog_max_distance, length(vertex)); + + fog_amount = pow(fog_z, fog_depth_curve); + } +#endif + +#ifdef FOG_HEIGHT_ENABLED + { + float y = (camera_matrix * vec4(vertex_interp, 1.0)).y; + fog_amount = max(fog_amount, pow(smoothstep(fog_height_min, fog_height_max, y), fog_height_curve)); + } +#endif + fog_interp = vec4(fog_color,fog_amount); + +#endif //fog + #endif //use vertex lighting gl_Position = projection_matrix * vec4(vertex_interp, 1.0); } @@ -816,6 +874,8 @@ uniform float ambient_energy; varying highp vec3 diffuse_interp; varying highp vec3 specular_interp; +uniform vec3 light_direction; //may be used by fog, so leave here + #else //done in fragment // general for all lights @@ -1191,8 +1251,8 @@ LIGHT_SHADER_CODE float aspect = sqrt(1.0 - anisotropy * 0.9); float ax = alpha / aspect; float ay = alpha * aspect; - //float XdotH = dot(T, H); - //float YdotH = dot(B, H); + float XdotH = dot(T, H); + float YdotH = dot(B, H); float D = D_GGX_anisotropic(cNdotH, ax, ay, XdotH, YdotH, cNdotH); //float G = G_GGX_anisotropic_2cos(cNdotL, ax, ay, XdotH, YdotH) * G_GGX_anisotropic_2cos(cNdotV, ax, ay, XdotH, YdotH); float G = V_GGX_anisotropic(ax, ay, dot(T, V), dot(T, L), dot(B, V), dot(B, L), cNdotV, cNdotL)) @@ -1296,6 +1356,36 @@ float sample_shadow( #endif +#if defined(FOG_DEPTH_ENABLED) || defined(FOG_HEIGHT_ENABLED) + +#if defined(USE_VERTEX_LIGHTING) + +varying vec4 fog_interp; + +#else +uniform mediump vec4 fog_color_base; +#ifdef LIGHT_MODE_DIRECTIONAL +uniform mediump vec4 fog_sun_color_amount; +#endif + +uniform bool fog_transmit_enabled; +uniform mediump float fog_transmit_curve; + +#ifdef FOG_DEPTH_ENABLED +uniform highp float fog_depth_begin; +uniform mediump float fog_depth_curve; +uniform mediump float fog_max_distance; +#endif + +#ifdef FOG_HEIGHT_ENABLED +uniform highp float fog_height_min; +uniform highp float fog_height_max; +uniform mediump float fog_height_curve; +#endif + +#endif //vertex lit +#endif //fog + void main() { #ifdef RENDER_DEPTH_DUAL_PARABOLOID @@ -1540,7 +1630,7 @@ FRAGMENT_SHADER_CODE highp vec4 splane = shadow_coord; float shadow_len = length(splane.xyz); - splane = normalize(splane.xyz); + splane.xyz = normalize(splane.xyz); vec4 clamp_rect = light_clamp; @@ -1926,5 +2016,50 @@ FRAGMENT_SHADER_CODE #endif //unshaded +//apply fog +#if defined(FOG_DEPTH_ENABLED) || defined(FOG_HEIGHT_ENABLED) + +#if defined(USE_VERTEX_LIGHTING) + + gl_FragColor.rgb = mix(gl_FragColor.rgb,fog_interp.rgb,fog_interp.a); +#else //pixel based fog + float fog_amount = 0.0; + +#ifdef LIGHT_MODE_DIRECTIONAL + + vec3 fog_color = mix(fog_color_base.rgb, fog_sun_color_amount.rgb, fog_sun_color_amount.a * pow(max(dot(eye_position, light_direction), 0.0), 8.0)); +#else + vec3 fog_color = fog_color_base.rgb; +#endif + +#ifdef FOG_DEPTH_ENABLED + + { + + float fog_z = smoothstep(fog_depth_begin, fog_max_distance, length(vertex)); + + fog_amount = pow(fog_z, fog_depth_curve); + + if (fog_transmit_enabled) { + vec3 total_light = gl_FragColor.rgb; + float transmit = pow(fog_z, fog_transmit_curve); + fog_color = mix(max(total_light, fog_color), fog_color, transmit); + } + } +#endif + +#ifdef FOG_HEIGHT_ENABLED + { + float y = (camera_matrix * vec4(vertex, 1.0)).y; + fog_amount = max(fog_amount, pow(smoothstep(fog_height_min, fog_height_max, y), fog_height_curve)); + } +#endif + + gl_FragColor.rgb = mix(gl_FragColor.rgb,fog_color,fog_amount); + +#endif //use vertex lit + +#endif // defined(FOG_DEPTH_ENABLED) || defined(FOG_HEIGHT_ENABLED) + #endif // not RENDER_DEPTH } diff --git a/drivers/gles3/rasterizer_gles3.cpp b/drivers/gles3/rasterizer_gles3.cpp index a97cd32faa..2b3be9d0bd 100644 --- a/drivers/gles3/rasterizer_gles3.cpp +++ b/drivers/gles3/rasterizer_gles3.cpp @@ -73,6 +73,8 @@ RasterizerScene *RasterizerGLES3::get_scene() { #define _EXT_DEBUG_SEVERITY_LOW_ARB 0x9148 #define _EXT_DEBUG_OUTPUT 0x92E0 +#ifdef GLAD_ENABLED +// Restricting to GLAD as only used in initialize() with GLAD_GL_ARB_debug_output #if (defined WINDOWS_ENABLED) && !(defined UWP_ENABLED) #define GLAPIENTRY APIENTRY #else @@ -123,6 +125,7 @@ static void GLAPIENTRY _gl_debug_print(GLenum source, GLenum type, GLuint id, GL ERR_PRINTS(output); } +#endif // GLAD_ENABLED typedef void (*DEBUGPROCARB)(GLenum source, GLenum type, diff --git a/drivers/gles3/shaders/canvas.glsl b/drivers/gles3/shaders/canvas.glsl index 5203f53fa2..8e8b693eb2 100644 --- a/drivers/gles3/shaders/canvas.glsl +++ b/drivers/gles3/shaders/canvas.glsl @@ -182,7 +182,6 @@ VERTEX_SHADER_CODE color_interp = color; #ifdef USE_PIXEL_SNAP - outvec.xy = floor(outvec + 0.5).xy; #endif diff --git a/drivers/png/image_loader_png.cpp b/drivers/png/image_loader_png.cpp index 04acb9387e..a4ea889d3b 100644 --- a/drivers/png/image_loader_png.cpp +++ b/drivers/png/image_loader_png.cpp @@ -227,10 +227,7 @@ static void user_read_data(png_structp png_ptr, png_bytep data, png_size_t p_len PNGReadStatus *rstatus; rstatus = (PNGReadStatus *)png_get_io_ptr(png_ptr); - png_size_t to_read = p_length; - if (rstatus->size >= 0) { - to_read = MIN(p_length, rstatus->size - rstatus->offset); - } + png_size_t to_read = MIN(p_length, rstatus->size - rstatus->offset); memcpy(data, &rstatus->image[rstatus->offset], to_read); rstatus->offset += to_read; diff --git a/drivers/unix/dir_access_unix.cpp b/drivers/unix/dir_access_unix.cpp index a5a9258c4a..48b4369b7e 100644 --- a/drivers/unix/dir_access_unix.cpp +++ b/drivers/unix/dir_access_unix.cpp @@ -391,7 +391,7 @@ size_t DirAccessUnix::get_space_left() { return vfs.f_bfree * vfs.f_bsize; #else -#warning THIS IS BROKEN + // FIXME: Implement this. return 0; #endif }; diff --git a/editor/doc/doc_dump.cpp b/editor/doc/doc_dump.cpp index 86fd9b436b..f1c337605e 100644 --- a/editor/doc/doc_dump.cpp +++ b/editor/doc/doc_dump.cpp @@ -223,7 +223,7 @@ void DocDump::dump(const String &p_file) { hint = "Values: "; for (int j = 0; j < arginfo.hint_string.get_slice_count(","); j++) { if (j > 0) hint += ", "; - hint += arginfo.hint_string.get_slice(",", j) + "=" + itos(1 << j); + hint += arginfo.hint_string.get_slice(",", j) + "=" + itos((uint64_t)1 << j); } break; case PROPERTY_HINT_FILE: hint = "A file:"; break; diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp index 455c889224..1a6188862f 100644 --- a/editor/editor_export.cpp +++ b/editor/editor_export.cpp @@ -1097,6 +1097,7 @@ Ref<EditorExportPreset> EditorExport::get_export_preset(int p_idx) { void EditorExport::remove_export_preset(int p_idx) { export_presets.remove(p_idx); + save_presets(); } void EditorExport::add_export_plugin(const Ref<EditorExportPlugin> &p_plugin) { diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index 2c4168f1a0..c6258c8493 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -484,6 +484,17 @@ void EditorProperty::update_reload_status() { } bool EditorProperty::use_keying_next() const { + List<PropertyInfo> plist; + object->get_property_list(&plist, true); + + for (List<PropertyInfo>::Element *I = plist.front(); I; I = I->next()) { + PropertyInfo &p = I->get(); + + if (p.name == property) { + return p.hint == PROPERTY_HINT_SPRITE_FRAME; + } + } + return false; } void EditorProperty::set_checkable(bool p_checkable) { @@ -618,6 +629,11 @@ void EditorProperty::_gui_input(const Ref<InputEvent> &p_event) { if (keying_rect.has_point(mb->get_position())) { emit_signal("property_keyed", property); + + if (use_keying_next()) { + call_deferred("emit_signal", "property_changed", property, object->get(property).operator int64_t() + 1); + call_deferred("update_property"); + } } if (revert_rect.has_point(mb->get_position())) { diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 2dec21fffb..1e97920f7e 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -531,7 +531,6 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { _initial_set("docks/property_editor/texture_preview_width", 48); _initial_set("docks/property_editor/auto_refresh_interval", 0.3); - _initial_set("text_editor/help/doc_path", ""); _initial_set("text_editor/help/show_help_index", true); _initial_set("filesystem/import/ask_save_before_reimport", false); diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 9e81051dc2..3cdbc4f188 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -376,7 +376,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { //Register icons + font // the resolution and the icon color (dark_theme bool) has not changed, so we do not regenerate the icons - if (p_theme != NULL && fabs(p_theme->get_constant("scale", "Editor") - EDSCALE) < 0.00001 && p_theme->get_constant("dark_theme", "Editor") == dark_theme) { + if (p_theme != NULL && fabs(p_theme->get_constant("scale", "Editor") - EDSCALE) < 0.00001 && (bool)p_theme->get_constant("dark_theme", "Editor") == dark_theme) { // register already generated icons for (int i = 0; i < editor_icons_count; i++) { theme->set_icon(editor_icons_names[i], "EditorIcons", p_theme->get_icon(editor_icons_names[i], "EditorIcons")); diff --git a/editor/plugin_config_dialog.cpp b/editor/plugin_config_dialog.cpp index 93bed035a5..a334f79f5a 100644 --- a/editor/plugin_config_dialog.cpp +++ b/editor/plugin_config_dialog.cpp @@ -76,7 +76,10 @@ void PluginConfigDialog::_on_confirmed() { "extends EditorPlugin\n" "\n" "func _enter_tree():\n" - "\tpass"); + "\tpass\n" + "\n" + "func _exit_tree():\n" + "\tpass\n"); String script_path = path.plus_file(script_edit->get_text()); gdscript->set_path(script_path); ResourceSaver::save(script_path, gdscript); @@ -84,7 +87,7 @@ void PluginConfigDialog::_on_confirmed() { } //TODO: other languages - emit_signal("plugin_ready", script.operator->(), active_edit->is_pressed() ? name_edit->get_text() : ""); + emit_signal("plugin_ready", script.operator->(), active_edit->is_pressed() ? subfolder_edit->get_text() : ""); } else { EditorNode::get_singleton()->get_project_settings()->update_plugins(); } diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index 11a0a42b9e..f2c04d7326 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -689,6 +689,13 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { } } } break; + case TOOL_OPEN_DOCUMENTATION: { + List<Node *> selection = editor_selection->get_selected_node_list(); + for (int i = 0; i < selection.size(); i++) { + ScriptEditor::get_singleton()->goto_help("class_name:" + selection[i]->get_class()); + } + EditorNode::get_singleton()->set_visible_editor(EditorNode::EDITOR_SCRIPT); + } break; case TOOL_SCENE_EDITABLE_CHILDREN: { List<Node *> selection = editor_selection->get_selected_node_list(); List<Node *>::Element *e = selection.front(); @@ -2027,6 +2034,7 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { menu->clear(); + Ref<Script> existing_script; if (selection.size() == 1) { Node *selected = selection[0]; @@ -2041,16 +2049,20 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { menu->add_icon_shortcut(get_icon("Add", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/add_child_node"), TOOL_NEW); menu->add_icon_shortcut(get_icon("Instance", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/instance_scene"), TOOL_INSTANCE); menu->add_separator(); + existing_script = selected->get_script(); + } - menu->add_icon_shortcut(get_icon("ScriptCreate", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/attach_script"), TOOL_ATTACH_SCRIPT); - Ref<Script> existing = selected->get_script(); - if (existing.is_valid()) { - menu->add_icon_shortcut(get_icon("ScriptRemove", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/clear_script"), TOOL_CLEAR_SCRIPT); - } - menu->add_separator(); + menu->add_icon_shortcut(get_icon("ScriptCreate", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/attach_script"), TOOL_ATTACH_SCRIPT); + if (selection.size() > 1 || existing_script.is_valid()) { + menu->add_icon_shortcut(get_icon("ScriptRemove", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/clear_script"), TOOL_CLEAR_SCRIPT); + } + + menu->add_separator(); + if (selection.size() == 1) { menu->add_icon_shortcut(get_icon("Rename", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/rename"), TOOL_RENAME); } menu->add_icon_shortcut(get_icon("Reload", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/change_node_type"), TOOL_REPLACE); + if (scene_tree->get_selected() != edited_scene) { menu->add_separator(); menu->add_icon_shortcut(get_icon("MoveUp", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/move_up"), TOOL_MOVE_UP); @@ -2086,10 +2098,6 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { menu->set_item_checked(menu->get_item_idx_from_text(TTR("Load As Placeholder")), placeholder); } } - } else { - menu->add_separator(); - menu->add_icon_shortcut(get_icon("ScriptCreate", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/attach_script"), TOOL_ATTACH_SCRIPT); - menu->add_icon_shortcut(get_icon("ScriptRemove", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/clear_script"), TOOL_CLEAR_SCRIPT); } if (selection.size() > 1) { @@ -2098,6 +2106,9 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { menu->add_icon_shortcut(get_icon("Rename", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/batch_rename"), TOOL_BATCH_RENAME); } menu->add_separator(); + menu->add_icon_item(get_icon("Help", "EditorIcons"), TTR("Open documentation"), TOOL_OPEN_DOCUMENTATION); + + menu->add_separator(); menu->add_icon_shortcut(get_icon("Remove", "EditorIcons"), ED_SHORTCUT("scene_tree/delete", TTR("Delete Node(s)"), KEY_DELETE), TOOL_ERASE); menu->set_size(Size2(1, 1)); menu->set_position(p_menu_pos); diff --git a/editor/scene_tree_dock.h b/editor/scene_tree_dock.h index 269b0b69db..eea34a3ec5 100644 --- a/editor/scene_tree_dock.h +++ b/editor/scene_tree_dock.h @@ -75,6 +75,7 @@ class SceneTreeDock : public VBoxContainer { TOOL_ERASE, TOOL_COPY_NODE_PATH, TOOL_BUTTON_MAX, + TOOL_OPEN_DOCUMENTATION, TOOL_SCENE_EDITABLE_CHILDREN, TOOL_SCENE_USE_PLACEHOLDER, TOOL_SCENE_MAKE_LOCAL, diff --git a/main/main.cpp b/main/main.cpp index 3eb0b7f354..41ae368087 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -115,9 +115,11 @@ static bool editor = false; static bool project_manager = false; static String locale; static bool show_help = false; -static bool auto_build_solutions = false; static bool auto_quit = false; static OS::ProcessID allow_focus_steal_pid = 0; +#ifdef TOOLS_ENABLED +static bool auto_build_solutions = false; +#endif // Display @@ -871,13 +873,17 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/driver/driver_fallback", PropertyInfo(Variant::STRING, "rendering/quality/driver/driver_fallback", PROPERTY_HINT_ENUM, "Best,Never")); GLOBAL_DEF("display/window/size/width", 1024); + ProjectSettings::get_singleton()->set_custom_property_info("display/window/size/width", PropertyInfo(Variant::INT, "display/window/size/width", PROPERTY_HINT_RANGE, "0,7680,or_greater")); // 8K resolution GLOBAL_DEF("display/window/size/height", 600); + ProjectSettings::get_singleton()->set_custom_property_info("display/window/size/height", PropertyInfo(Variant::INT, "display/window/size/height", PROPERTY_HINT_RANGE, "0,4320,or_greater")); // 8K resolution GLOBAL_DEF("display/window/size/resizable", true); GLOBAL_DEF("display/window/size/borderless", false); GLOBAL_DEF("display/window/size/fullscreen", false); GLOBAL_DEF("display/window/size/always_on_top", false); GLOBAL_DEF("display/window/size/test_width", 0); + ProjectSettings::get_singleton()->set_custom_property_info("display/window/size/test_width", PropertyInfo(Variant::INT, "display/window/size/test_width", PROPERTY_HINT_RANGE, "0,7680,or_greater")); // 8K resolution GLOBAL_DEF("display/window/size/test_height", 0); + ProjectSettings::get_singleton()->set_custom_property_info("display/window/size/test_height", PropertyInfo(Variant::INT, "display/window/size/test_height", PROPERTY_HINT_RANGE, "0,4320,or_greater")); // 8K resolution if (use_custom_res) { diff --git a/misc/travis/android-tools-linux.sh b/misc/travis/android-tools-linux.sh index 04fb2eee21..830820b10b 100755 --- a/misc/travis/android-tools-linux.sh +++ b/misc/travis/android-tools-linux.sh @@ -17,19 +17,19 @@ cd $GODOT_BUILD_TOOLS_PATH ANDROID_BASE_URL=http://dl.google.com/android/repository -ANDROID_SDK_RELEASE=3859397 +ANDROID_SDK_RELEASE=4333796 ANDROID_SDK_DIR=android-sdk ANDROID_SDK_FILENAME=sdk-tools-linux-$ANDROID_SDK_RELEASE.zip ANDROID_SDK_URL=$ANDROID_BASE_URL/$ANDROID_SDK_FILENAME ANDROID_SDK_PATH=$GODOT_BUILD_TOOLS_PATH/$ANDROID_SDK_DIR -ANDROID_SDK_SHA256=444e22ce8ca0f67353bda4b85175ed3731cae3ffa695ca18119cbacef1c1bea0 +ANDROID_SDK_SHA256=92ffee5a1d98d856634e8b71132e8a95d96c83a63fde1099be3d86df3106def9 -ANDROID_NDK_RELEASE=r15c +ANDROID_NDK_RELEASE=r18 ANDROID_NDK_DIR=android-ndk ANDROID_NDK_FILENAME=android-ndk-$ANDROID_NDK_RELEASE-linux-x86_64.zip ANDROID_NDK_URL=$ANDROID_BASE_URL/$ANDROID_NDK_FILENAME ANDROID_NDK_PATH=$GODOT_BUILD_TOOLS_PATH/$ANDROID_NDK_DIR -ANDROID_NDK_SHA1=0bf02d4e8b85fd770fd7b9b2cdec57f9441f27a2 +ANDROID_NDK_SHA1=2ac2e8e1ef73ed551cac3a1479bb28bd49369212 echo echo "Download and install Android development tools ..." @@ -75,7 +75,7 @@ echo "Installing: Android Tools ..." yes | $ANDROID_SDK_DIR/tools/bin/sdkmanager --licenses > /dev/null $ANDROID_SDK_DIR/tools/bin/sdkmanager 'tools' > /dev/null $ANDROID_SDK_DIR/tools/bin/sdkmanager 'platform-tools' > /dev/null -$ANDROID_SDK_DIR/tools/bin/sdkmanager 'build-tools;26.0.2' > /dev/null +$ANDROID_SDK_DIR/tools/bin/sdkmanager 'build-tools;28.0.1' > /dev/null echo EXPORT_VAL="export ANDROID_HOME=$ANDROID_SDK_PATH" diff --git a/modules/bmp/image_loader_bmp.cpp b/modules/bmp/image_loader_bmp.cpp index 919731b52b..063508a25f 100644 --- a/modules/bmp/image_loader_bmp.cpp +++ b/modules/bmp/image_loader_bmp.cpp @@ -42,12 +42,9 @@ Error ImageLoaderBMP::convert_to_image(Ref<Image> p_image, if (err == OK) { size_t index = 0; - size_t width = - static_cast<size_t>(p_header.bmp_info_header.bmp_width < 0 ? -p_header.bmp_info_header.bmp_width : p_header.bmp_info_header.bmp_width); - size_t height = - static_cast<size_t>(p_header.bmp_info_header.bmp_height < 0 ? -p_header.bmp_info_header.bmp_height : p_header.bmp_info_header.bmp_height); - size_t bits_per_pixel = - static_cast<size_t>(p_header.bmp_info_header.bmp_bit_count); + size_t width = (size_t)p_header.bmp_info_header.bmp_width; + size_t height = (size_t)p_header.bmp_info_header.bmp_height; + size_t bits_per_pixel = (size_t)p_header.bmp_info_header.bmp_bit_count; if (p_header.bmp_info_header.bmp_compression != 0) { err = FAILED; diff --git a/modules/csg/csg_gizmos.cpp b/modules/csg/csg_gizmos.cpp index 07c33ed670..5864d02615 100644 --- a/modules/csg/csg_gizmos.cpp +++ b/modules/csg/csg_gizmos.cpp @@ -215,7 +215,7 @@ void CSGShapeSpatialGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo(); ur->create_action(TTR("Change Box Shape Extents")); static const char *method[3] = { "set_width", "set_height", "set_depth" }; - float current; + float current = 0; switch (p_idx) { case 0: current = s->get_width(); break; case 1: current = s->get_height(); break; diff --git a/modules/dds/texture_loader_dds.cpp b/modules/dds/texture_loader_dds.cpp index ff15aaa735..53e9773791 100644 --- a/modules/dds/texture_loader_dds.cpp +++ b/modules/dds/texture_loader_dds.cpp @@ -108,8 +108,8 @@ RES ResourceFormatDDS::load(const String &p_path, const String &p_original_path, uint32_t magic = f->get_32(); uint32_t hsize = f->get_32(); uint32_t flags = f->get_32(); - uint32_t width = f->get_32(); uint32_t height = f->get_32(); + uint32_t width = f->get_32(); uint32_t pitch = f->get_32(); /* uint32_t depth = */ f->get_32(); uint32_t mipmaps = f->get_32(); diff --git a/modules/gdnative/include/gdnative/gdnative.h b/modules/gdnative/include/gdnative/gdnative.h index 616c305f25..796ced84f4 100644 --- a/modules/gdnative/include/gdnative/gdnative.h +++ b/modules/gdnative/include/gdnative/gdnative.h @@ -35,7 +35,7 @@ extern "C" { #endif -#ifdef _WIN32 +#if defined(_WIN32) || defined(__ANDROID__) #define GDCALLINGCONV #define GDAPI GDCALLINGCONV #elif defined(__APPLE__) @@ -47,7 +47,7 @@ extern "C" { #define GDCALLINGCONV __attribute__((sysv_abi)) #define GDAPI GDCALLINGCONV #endif -#else +#else // !_WIN32 && !__APPLE__ #define GDCALLINGCONV __attribute__((sysv_abi)) #define GDAPI GDCALLINGCONV #endif diff --git a/modules/gdscript/gdscript_function.cpp b/modules/gdscript/gdscript_function.cpp index b935861652..8088dcf17d 100644 --- a/modules/gdscript/gdscript_function.cpp +++ b/modules/gdscript/gdscript_function.cpp @@ -155,6 +155,7 @@ String GDScriptFunction::_get_call_error(const Variant::CallError &p_err, const return err_text; } +#ifdef DEBUG_ENABLED static String _get_var_type(const Variant *p_type) { String basestr; @@ -164,7 +165,6 @@ static String _get_var_type(const Variant *p_type) { if (!bobj) { basestr = "null instance"; } else { -#ifdef DEBUG_ENABLED if (ObjectDB::instance_validate(bobj)) { if (bobj->get_script_instance()) basestr = bobj->get_class() + " (" + bobj->get_script_instance()->get_script()->get_path().get_file() + ")"; @@ -173,10 +173,6 @@ static String _get_var_type(const Variant *p_type) { } else { basestr = "previously freed instance"; } - -#else - basestr = "Object"; -#endif } } else { @@ -185,6 +181,7 @@ static String _get_var_type(const Variant *p_type) { return basestr; } +#endif #if defined(__GNUC__) #define OPCODES_TABLE \ @@ -676,6 +673,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a OPCODE(OPCODE_SET_MEMBER) { CHECK_SPACE(3); +#ifdef DEBUG_ENABLED int indexname = _code_ptr[ip + 1]; GD_ERR_BREAK(indexname < 0 || indexname >= _global_names_count); const StringName *index = &_global_names_ptr[indexname]; @@ -683,7 +681,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a bool valid; bool ok = ClassDB::set_property(p_instance->owner, *index, *src, &valid); -#ifdef DEBUG_ENABLED if (!ok) { err_text = "Internal error setting property: " + String(*index); OPCODE_BREAK; @@ -699,13 +696,13 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a OPCODE(OPCODE_GET_MEMBER) { CHECK_SPACE(3); +#ifdef DEBUG_ENABLED int indexname = _code_ptr[ip + 1]; GD_ERR_BREAK(indexname < 0 || indexname >= _global_names_count); const StringName *index = &_global_names_ptr[indexname]; GET_VARIANT_PTR(dst, 2); - bool ok = ClassDB::get_property(p_instance->owner, *index, *dst); -#ifdef DEBUG_ENABLED + bool ok = ClassDB::get_property(p_instance->owner, *index, *dst); if (!ok) { err_text = "Internal error getting property: " + String(*index); OPCODE_BREAK; @@ -752,13 +749,13 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a OPCODE(OPCODE_ASSIGN_TYPED_BUILTIN) { CHECK_SPACE(4); - Variant::Type var_type = (Variant::Type)_code_ptr[ip + 1]; GET_VARIANT_PTR(dst, 2); GET_VARIANT_PTR(src, 3); +#ifdef DEBUG_ENABLED + Variant::Type var_type = (Variant::Type)_code_ptr[ip + 1]; GD_ERR_BREAK(var_type < 0 || var_type >= Variant::VARIANT_MAX); -#ifdef DEBUG_ENABLED if (src->get_type() != var_type) { if (Variant::can_convert_strict(src->get_type(), var_type)) { Variant::CallError ce; @@ -1282,10 +1279,11 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a OPCODE_BREAK; } #endif + Object *obj = argobj->operator Object *(); String signal = argname->operator String(); -#ifdef DEBUG_ENABLED +#ifdef DEBUG_ENABLED if (!obj) { err_text = "First argument of yield() is null."; OPCODE_BREAK; @@ -1302,13 +1300,13 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a OPCODE_BREAK; } -#endif Error err = obj->connect(signal, gdfs.ptr(), "_signal_callback", varray(gdfs), Object::CONNECT_ONESHOT); -#ifdef DEBUG_ENABLED if (err != OK) { err_text = "Error connecting to signal: " + signal + " during yield()."; OPCODE_BREAK; } +#else + obj->connect(signal, gdfs.ptr(), "_signal_callback", varray(gdfs), Object::CONNECT_ONESHOT); #endif } diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp index 2fa5084d84..a79fcccaeb 100644 --- a/modules/gdscript/gdscript_parser.cpp +++ b/modules/gdscript/gdscript_parser.cpp @@ -56,7 +56,9 @@ T *GDScriptParser::alloc_node() { return t; } +#ifdef DEBUG_ENABLED static String _find_function_name(const GDScriptParser::OperatorNode *p_call); +#endif // DEBUG_ENABLED bool GDScriptParser::_end_statement() { @@ -747,7 +749,6 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s while (!bfn && b) { if (b->variables.has(identifier)) { IdentifierNode *id = alloc_node<IdentifierNode>(); - LocalVarNode *lv = b->variables[identifier]; id->name = identifier; id->declared_block = b; id->line = id_line; @@ -755,6 +756,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s bfn = true; #ifdef DEBUG_ENABLED + LocalVarNode *lv = b->variables[identifier]; switch (tokenizer->get_token()) { case GDScriptTokenizer::TK_OP_ASSIGN_ADD: case GDScriptTokenizer::TK_OP_ASSIGN_BIT_AND: diff --git a/modules/mobile_vr/mobile_vr_interface.cpp b/modules/mobile_vr/mobile_vr_interface.cpp index b9a404709e..87e4ddd900 100644 --- a/modules/mobile_vr/mobile_vr_interface.cpp +++ b/modules/mobile_vr/mobile_vr_interface.cpp @@ -398,7 +398,6 @@ void MobileVRInterface::commit_for_eye(ARVRInterface::Eyes p_eye, RID p_render_t ERR_FAIL_COND(p_screen_rect == Rect2()); Rect2 dest = p_screen_rect; - float aspect_ratio = 0.5 * p_screen_rect.size.x / p_screen_rect.size.y; Vector2 eye_center; // we output half a screen diff --git a/modules/mono/editor/bindings_generator.cpp b/modules/mono/editor/bindings_generator.cpp index 308c54ecb3..2c3435fc1c 100644 --- a/modules/mono/editor/bindings_generator.cpp +++ b/modules/mono/editor/bindings_generator.cpp @@ -2244,8 +2244,8 @@ void BindingsGenerator::_populate_global_constants() { String constant_name = GlobalConstants::get_global_constant_name(i); const DocData::ConstantDoc *const_doc = NULL; - for (int i = 0; i < global_scope_doc.constants.size(); i++) { - const DocData::ConstantDoc &curr_const_doc = global_scope_doc.constants[i]; + for (int j = 0; j < global_scope_doc.constants.size(); j++) { + const DocData::ConstantDoc &curr_const_doc = global_scope_doc.constants[j]; if (curr_const_doc.name == constant_name) { const_doc = &curr_const_doc; diff --git a/modules/mono/editor/mono_bottom_panel.cpp b/modules/mono/editor/mono_bottom_panel.cpp index ecc3e4c59e..8d9b345a92 100644 --- a/modules/mono/editor/mono_bottom_panel.cpp +++ b/modules/mono/editor/mono_bottom_panel.cpp @@ -475,14 +475,14 @@ void MonoBuildTab::_bind_methods() { } MonoBuildTab::MonoBuildTab(const MonoBuildInfo &p_build_info, const String &p_logs_dir) : - build_info(p_build_info), - logs_dir(p_logs_dir), build_exited(false), issues_list(memnew(ItemList)), error_count(0), warning_count(0), errors_visible(true), - warnings_visible(true) { + warnings_visible(true), + logs_dir(p_logs_dir), + build_info(p_build_info) { issues_list->set_v_size_flags(SIZE_EXPAND_FILL); issues_list->connect("item_activated", this, "_issue_activated"); add_child(issues_list); diff --git a/modules/mono/utils/mono_reg_utils.cpp b/modules/mono/utils/mono_reg_utils.cpp index 8116df5f51..6bb6efa92a 100644 --- a/modules/mono/utils/mono_reg_utils.cpp +++ b/modules/mono/utils/mono_reg_utils.cpp @@ -228,4 +228,4 @@ cleanup: } } // namespace MonoRegUtils -#endif WINDOWS_ENABLED +#endif // WINDOWS_ENABLED diff --git a/modules/mono/utils/thread_local.h b/modules/mono/utils/thread_local.h index 84dae1d86b..d7d98c47e2 100644 --- a/modules/mono/utils/thread_local.h +++ b/modules/mono/utils/thread_local.h @@ -108,17 +108,23 @@ class ThreadLocal { return data; } + void _initialize(const T &p_init_val) { + init_val = p_init_val; + storage.alloc(&destr_callback); + } + public: - ThreadLocal() : - ThreadLocal(T()) {} + ThreadLocal() { + _initialize(T()); + } - ThreadLocal(const T &p_init_val) : - init_val(p_init_val) { - storage.alloc(&destr_callback); + ThreadLocal(const T &p_init_val) { + _initialize(p_init_val); } - ThreadLocal(const ThreadLocal &other) : - ThreadLocal(*other._tls_get_value()) {} + ThreadLocal(const ThreadLocal &other) { + _initialize(*other._tls_get_value()); + } ~ThreadLocal() { storage.free(); diff --git a/modules/opensimplex/config.py b/modules/opensimplex/config.py index c91c9e5c80..c1010ad433 100644 --- a/modules/opensimplex/config.py +++ b/modules/opensimplex/config.py @@ -7,7 +7,7 @@ def configure(env): def get_doc_classes(): return [ "NoiseTexture", - "SimplexNoise" + "OpenSimplexNoise" ] def get_doc_path(): diff --git a/modules/opensimplex/doc_classes/NoiseTexture.xml b/modules/opensimplex/doc_classes/NoiseTexture.xml index 6af58e7a6b..9642865c43 100644 --- a/modules/opensimplex/doc_classes/NoiseTexture.xml +++ b/modules/opensimplex/doc_classes/NoiseTexture.xml @@ -41,8 +41,11 @@ <member name="seamless" type="bool" setter="set_seamless" getter="get_seamless"> Whether the texture can be tiled without visible seams or not. Seamless textures take longer to generate. </member> - <member name="size" type="Vector2" setter="set_size" getter="get_size"> - Size of the generated texture. + <member name="width" type="int" setter="set_width" getter="get_width"> + Width of the generated texture. + </member> + <member name="height" type="int" setter="set_height" getter="get_height"> + Height of the generated texture. </member> </members> <constants> diff --git a/modules/opensimplex/noise_texture.cpp b/modules/opensimplex/noise_texture.cpp index 6f2723e43b..be522a9ab1 100644 --- a/modules/opensimplex/noise_texture.cpp +++ b/modules/opensimplex/noise_texture.cpp @@ -58,7 +58,6 @@ void NoiseTexture::_bind_methods() { ClassDB::bind_method(D_METHOD("set_width", "width"), &NoiseTexture::set_width); ClassDB::bind_method(D_METHOD("set_height", "height"), &NoiseTexture::set_height); - ClassDB::bind_method(D_METHOD("set_size", "size"), &NoiseTexture::set_size); ClassDB::bind_method(D_METHOD("set_noise", "noise"), &NoiseTexture::set_noise); ClassDB::bind_method(D_METHOD("get_noise"), &NoiseTexture::get_noise); @@ -73,7 +72,8 @@ void NoiseTexture::_bind_methods() { ClassDB::bind_method(D_METHOD("_generate_texture"), &NoiseTexture::_generate_texture); ClassDB::bind_method(D_METHOD("_thread_done", "image"), &NoiseTexture::_thread_done); - ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "size"), "set_size", "get_size"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "width", PROPERTY_HINT_RANGE, "1,2048,1,or_greater"), "set_width", "get_width"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "height", PROPERTY_HINT_RANGE, "1,2048,1,or_greater"), "set_height", "get_height"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "seamless"), "set_seamless", "get_seamless"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "as_normalmap"), "set_as_normalmap", "is_normalmap"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "noise", PROPERTY_HINT_RESOURCE_TYPE, "OpenSimplexNoise"), "set_noise", "get_noise"); @@ -208,17 +208,6 @@ bool NoiseTexture::is_normalmap() { return as_normalmap; } -void NoiseTexture::set_size(Vector2 p_size) { - if (p_size == size) return; - size = p_size; - _queue_update(); -} - -Vector2 NoiseTexture::get_size() { - - return size; -} - int NoiseTexture::get_width() const { return size.x; diff --git a/modules/opensimplex/noise_texture.h b/modules/opensimplex/noise_texture.h index 78a02cda9f..2a4c32d633 100644 --- a/modules/opensimplex/noise_texture.h +++ b/modules/opensimplex/noise_texture.h @@ -83,9 +83,6 @@ public: void set_as_normalmap(bool p_seamless); bool is_normalmap(); - void set_size(Vector2 p_size); - Vector2 get_size(); - int get_width() const; int get_height() const; diff --git a/platform/android/SCsub b/platform/android/SCsub index 807506000f..da2219b9e4 100644 --- a/platform/android/SCsub +++ b/platform/android/SCsub @@ -18,14 +18,17 @@ android_files = [ 'dir_access_jandroid.cpp', 'thread_jandroid.cpp', 'audio_driver_jandroid.cpp', - 'ifaddrs_android.cpp', - 'android_native_app_glue.c', 'java_glue.cpp', - 'cpu-features.c', 'java_class_wrapper.cpp', # 'power_android.cpp' ] +thirdparty_files = [ + 'ifaddrs_android.cpp', + 'android_native_app_glue.c', + 'cpu-features.c', +] + env_android = env.Clone() if env['target'] == "profile": env_android.Append(CPPFLAGS=['-DPROFILER_ENABLED']) @@ -34,6 +37,11 @@ android_objects = [] for x in android_files: android_objects.append(env_android.SharedObject(x)) +env_thirdparty = env_android.Clone() +env_thirdparty.disable_warnings() +for x in thirdparty_files: + android_objects.append(env_thirdparty.SharedObject(x)) + prog = None abspath = env.Dir(".").abspath diff --git a/platform/android/audio_driver_opensl.cpp b/platform/android/audio_driver_opensl.cpp index 28e3ea962f..21c61f6ca0 100644 --- a/platform/android/audio_driver_opensl.cpp +++ b/platform/android/audio_driver_opensl.cpp @@ -38,12 +38,7 @@ /* Structure for passing information to callback function */ void AudioDriverOpenSL::_buffer_callback( - SLAndroidSimpleBufferQueueItf queueItf - /* SLuint32 eventFlags, - const void * pBuffer, - SLuint32 bufferSize, - SLuint32 dataUsed*/ -) { + SLAndroidSimpleBufferQueueItf queueItf) { bool mix = true; @@ -85,7 +80,6 @@ void AudioDriverOpenSL::_buffer_callbacks( AudioDriverOpenSL *ad = (AudioDriverOpenSL *)pContext; - //ad->_buffer_callback(queueItf,eventFlags,pBuffer,bufferSize,dataUsed); ad->_buffer_callback(queueItf); } @@ -98,12 +92,9 @@ const char *AudioDriverOpenSL::get_name() const { Error AudioDriverOpenSL::init() { - SLresult - res; + SLresult res; SLEngineOption EngineOption[] = { - (SLuint32)SL_ENGINEOPTION_THREADSAFE, - (SLuint32)SL_BOOLEAN_TRUE - + { (SLuint32)SL_ENGINEOPTION_THREADSAFE, (SLuint32)SL_BOOLEAN_TRUE } }; res = slCreateEngine(&sl, 1, EngineOption, 0, NULL, NULL); if (res != SL_RESULT_SUCCESS) { @@ -126,8 +117,6 @@ void AudioDriverOpenSL::start() { mutex = Mutex::create(); active = false; - SLint32 numOutputs = 0; - SLuint32 deviceID = 0; SLresult res; buffer_size = 1024; diff --git a/platform/android/audio_driver_opensl.h b/platform/android/audio_driver_opensl.h index 8e879b27c5..39e1315a02 100644 --- a/platform/android/audio_driver_opensl.h +++ b/platform/android/audio_driver_opensl.h @@ -70,19 +70,10 @@ class AudioDriverOpenSL : public AudioDriver { static AudioDriverOpenSL *s_ad; void _buffer_callback( - SLAndroidSimpleBufferQueueItf queueItf - /* SLuint32 eventFlags, - const void * pBuffer, - SLuint32 bufferSize, - SLuint32 dataUsed*/ - ); + SLAndroidSimpleBufferQueueItf queueItf); static void _buffer_callbacks( SLAndroidSimpleBufferQueueItf queueItf, - /*SLuint32 eventFlags, - const void * pBuffer, - SLuint32 bufferSize, - SLuint32 dataUsed,*/ void *pContext); public: diff --git a/platform/android/java_glue.cpp b/platform/android/java_glue.cpp index 6cf49758bc..c3be3a3f11 100644 --- a/platform/android/java_glue.cpp +++ b/platform/android/java_glue.cpp @@ -589,8 +589,6 @@ TST tst; static bool initialized = false; static int step = 0; -static bool resized = false; -static bool resized_reload = false; static Size2 new_size; static Vector3 accelerometer; static Vector3 gravity; @@ -792,7 +790,6 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_initialize(JNIEnv *en _getClipboard = env->GetMethodID(cls, "getClipboard", "()Ljava/lang/String;"); _setClipboard = env->GetMethodID(cls, "setClipboard", "(Ljava/lang/String;)V"); - jclass clsio = env->FindClass("org/godotengine/godot/Godot"); if (cls) { jclass c = env->GetObjectClass(gob); _openURI = env->GetMethodID(c, "openURI", "(Ljava/lang/String;)I"); @@ -886,8 +883,6 @@ static void _initialize_java_modules() { ERR_EXPLAIN("Couldn't find proper initialize function 'public static Godot.SingletonBase Class::initialize(Activity p_activity)' initializer for singleton class: " + m); ERR_CONTINUE(!initialize); } - jobject obj = env->CallStaticObjectMethod(singletonClass, initialize, _godot_instance); - jobject gob = env->NewGlobalRef(obj); } } } @@ -931,13 +926,6 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_resize(JNIEnv *env, j if (os_android) os_android->set_display_size(Size2(width, height)); - - /*input_mutex->lock(); - resized=true; - if (reload) - resized_reload=true; - new_size=Size2(width,height); - input_mutex->unlock();*/ } JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_newcontext(JNIEnv *env, jobject obj, bool p_32_bits) { diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp index 484ca4fff8..30bc413459 100644 --- a/platform/android/os_android.cpp +++ b/platform/android/os_android.cpp @@ -677,13 +677,14 @@ String OS_Android::get_unique_id() const { return OS::get_unique_id(); } -Error OS_Android::native_video_play(String p_path, float p_volume) { +Error OS_Android::native_video_play(String p_path, float p_volume, String p_audio_track, String p_subtitle_track) { + // FIXME: Add support for volume, audio and subtitle tracks if (video_play_func) video_play_func(p_path); return OK; } -bool OS_Android::native_video_is_playing() { +bool OS_Android::native_video_is_playing() const { if (video_is_playing_func) return video_is_playing_func(); return false; diff --git a/platform/android/os_android.h b/platform/android/os_android.h index 9594c6fdf4..e89a380e4c 100644 --- a/platform/android/os_android.h +++ b/platform/android/os_android.h @@ -237,8 +237,8 @@ public: void process_event(Ref<InputEvent> p_event); void init_video_mode(int p_video_width, int p_video_height); - virtual Error native_video_play(String p_path, float p_volume); - virtual bool native_video_is_playing(); + virtual Error native_video_play(String p_path, float p_volume, String p_audio_track, String p_subtitle_track); + virtual bool native_video_is_playing() const; virtual void native_video_pause(); virtual void native_video_stop(); diff --git a/scene/3d/baked_lightmap.cpp b/scene/3d/baked_lightmap.cpp index c58e318651..8f3fe8577e 100644 --- a/scene/3d/baked_lightmap.cpp +++ b/scene/3d/baked_lightmap.cpp @@ -365,7 +365,7 @@ BakedLightmap::BakeError BakedLightmap::bake(Node *p_from_node, bool p_create_vi { bake_bounds = AABB(-extents, extents * 2.0); int subdiv = nearest_power_of_2_templated(int(bake_bounds.get_longest_axis_size() / bake_cell_size)); - bake_bounds.size[bake_bounds.get_longest_axis_size()] = subdiv * bake_cell_size; + bake_bounds.size[bake_bounds.get_longest_axis_index()] = subdiv * bake_cell_size; bake_subdiv = nearest_shift(subdiv) + 1; capture_subdiv = bake_subdiv; diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp index 0ffaac20f6..b4fd7484e9 100644 --- a/scene/gui/graph_edit.cpp +++ b/scene/gui/graph_edit.cpp @@ -1042,7 +1042,7 @@ void GraphEdit::set_connection_activity(const StringName &p_from, int p_from_por if (E->get().from == p_from && E->get().from_port == p_from_port && E->get().to == p_to && E->get().to_port == p_to_port) { - if (ABS(E->get().activity != p_activity)) { + if (ABS(E->get().activity - p_activity) < CMP_EPSILON) { //update only if changed top_layer->update(); connections_layer->update(); diff --git a/scene/main/node.cpp b/scene/main/node.cpp index d3282c6ada..8fd7dc1d7b 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -2182,13 +2182,15 @@ void Node::_duplicate_signals(const Node *p_original, Node *p_copy) const { continue; } NodePath ptarget = p_original->get_path_to(target); - Node *copytarget = p_copy->get_node(ptarget); - // Cannot find a path to the duplicate target, so it seems it's not part - // of the duplicated and not yet parented hierarchy, so at least try to connect + Node *copytarget = target; + + // Atempt to find a path to the duplicate target, if it seems it's not part + // of the duplicated and not yet parented hierarchy then at least try to connect // to the same target as the original - if (!copytarget) - copytarget = target; + + if (p_copy->has_node(ptarget)) + copytarget = p_copy->get_node(ptarget); if (copy && copytarget) { copy->connect(E->get().signal, copytarget, E->get().method, E->get().binds, E->get().flags); @@ -2486,6 +2488,7 @@ void Node::_set_tree(SceneTree *p_tree) { tree_changed_b->tree_changed(); } +#ifdef DEBUG_ENABLED static void _Node_debug_sn(Object *p_obj) { Node *n = Object::cast_to<Node>(p_obj); @@ -2507,6 +2510,7 @@ static void _Node_debug_sn(Object *p_obj) { path = String(p->get_name()) + "/" + p->get_path_to(n); print_line(itos(p_obj->get_instance_id()) + " - Stray Node: " + path + " (Type: " + n->get_class() + ")"); } +#endif // DEBUG_ENABLED void Node::_print_stray_nodes() { @@ -2516,7 +2520,6 @@ void Node::_print_stray_nodes() { void Node::print_stray_nodes() { #ifdef DEBUG_ENABLED - ObjectDB::debug_objects(_Node_debug_sn); #endif } diff --git a/scene/resources/material.h b/scene/resources/material.h index 0154874ae4..cf4d19b5a7 100644 --- a/scene/resources/material.h +++ b/scene/resources/material.h @@ -286,7 +286,7 @@ private: mk.key = 0; for (int i = 0; i < FEATURE_MAX; i++) { if (features[i]) { - mk.feature_mask |= (1 << i); + mk.feature_mask |= ((uint64_t)1 << i); } } mk.detail_uv = detail_uv; @@ -295,7 +295,7 @@ private: mk.cull_mode = cull_mode; for (int i = 0; i < FLAG_MAX; i++) { if (flags[i]) { - mk.flags |= (1 << i); + mk.flags |= ((uint64_t)1 << i); } } mk.detail_blend_mode = detail_blend_mode; |