diff options
85 files changed, 293 insertions, 266 deletions
@@ -71,3 +71,4 @@ for more info. [](https://www.codetriage.com/godotengine/godot) [](https://hosted.weblate.org/engage/godot-engine/?utm_source=widget) [](https://lgtm.com/projects/g/godotengine/godot/alerts) +[](https://www.tickgit.com/browse?repo=github.com/godotengine/godot) diff --git a/SConstruct b/SConstruct index 4ebc33f593..84400e800d 100644 --- a/SConstruct +++ b/SConstruct @@ -1,6 +1,7 @@ #!/usr/bin/env python -EnsureSConsVersion(0, 98, 1) +EnsureSConsVersion(3, 0, 0) +EnsurePythonVersion(3, 5) # System import glob @@ -13,7 +14,7 @@ import methods import gles_builders from platform_methods import run_in_subprocess -# scan possible build platforms +# Scan possible build platforms platform_list = [] # list of platforms platform_opts = {} # options for each platform diff --git a/compat.py b/compat.py deleted file mode 100644 index de99eef9c2..0000000000 --- a/compat.py +++ /dev/null @@ -1,68 +0,0 @@ -import sys - -if sys.version_info < (3,): - def isbasestring(s): - return isinstance(s, basestring) - def open_utf8(filename, mode): - return open(filename, mode) - def byte_to_str(x): - return str(ord(x)) - import cStringIO - def StringIO(): - return cStringIO.StringIO() - def encode_utf8(x): - return x - def decode_utf8(x): - return x - def iteritems(d): - return d.iteritems() - def itervalues(d): - return d.itervalues() - def escape_string(s): - if isinstance(s, unicode): - s = s.encode('ascii') - result = '' - for c in s: - if not (32 <= ord(c) < 127) or c in ('\\', '"'): - result += '\\%03o' % ord(c) - else: - result += c - return result - -else: - def isbasestring(s): - return isinstance(s, (str, bytes)) - def open_utf8(filename, mode): - return open(filename, mode, encoding="utf-8") - def byte_to_str(x): - return str(x) - import io - def StringIO(): - return io.StringIO() - import codecs - def encode_utf8(x): - return codecs.utf_8_encode(x)[0] - def decode_utf8(x): - return codecs.utf_8_decode(x)[0] - def iteritems(d): - return iter(d.items()) - def itervalues(d): - return iter(d.values()) - def charcode_to_c_escapes(c): - rev_result = [] - while c >= 256: - c, low = (c // 256, c % 256) - rev_result.append('\\%03o' % low) - rev_result.append('\\%03o' % c) - return ''.join(reversed(rev_result)) - def escape_string(s): - result = '' - if isinstance(s, str): - s = s.encode('utf-8') - for c in s: - if not(32 <= c < 127) or c in (ord('\\'), ord('"')): - result += charcode_to_c_escapes(c) - else: - result += chr(c) - return result - diff --git a/core/color.h b/core/color.h index a7ab94ab08..16dc721072 100644 --- a/core/color.h +++ b/core/color.h @@ -239,4 +239,4 @@ bool Color::operator<(const Color &p_color) const { return r < p_color.r; } -#endif +#endif // COLOR_H diff --git a/core/command_queue_mt.h b/core/command_queue_mt.h index 90231546ef..cc08ae7004 100644 --- a/core/command_queue_mt.h +++ b/core/command_queue_mt.h @@ -508,4 +508,4 @@ public: #undef CMD_SYNC_TYPE #undef DECL_CMD_SYNC -#endif +#endif // COMMAND_QUEUE_MT_H diff --git a/core/core_builders.py b/core/core_builders.py index 7720183595..a06b61cb9b 100644 --- a/core/core_builders.py +++ b/core/core_builders.py @@ -4,23 +4,41 @@ All such functions are invoked in a subprocess on Windows to prevent build flaki """ from platform_methods import subprocess_main -from compat import iteritems, itervalues, open_utf8, escape_string, byte_to_str -def make_certs_header(target, source, env): +def escape_string(s): + def charcode_to_c_escapes(c): + rev_result = [] + while c >= 256: + c, low = (c // 256, c % 256) + rev_result.append('\\%03o' % low) + rev_result.append('\\%03o' % c) + return ''.join(reversed(rev_result)) + + result = '' + if isinstance(s, str): + s = s.encode('utf-8') + for c in s: + if not(32 <= c < 127) or c in (ord('\\'), ord('"')): + result += charcode_to_c_escapes(c) + else: + result += chr(c) + return result + +def make_certs_header(target, source, env): src = source[0] dst = target[0] f = open(src, "rb") - g = open_utf8(dst, "w") + g = open(dst, "w", encoding="utf-8") buf = f.read() decomp_size = len(buf) import zlib buf = zlib.compress(buf) g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n") - g.write("#ifndef _CERTS_RAW_H\n") - g.write("#define _CERTS_RAW_H\n") + g.write("#ifndef CERTS_COMPRESSED_GEN_H\n") + g.write("#define CERTS_COMPRESSED_GEN_H\n") # System certs path. Editor will use them if defined. (for package maintainers) path = env['system_certs_path'] @@ -32,9 +50,9 @@ def make_certs_header(target, source, env): g.write("static const int _certs_uncompressed_size = " + str(decomp_size) + ";\n") g.write("static const unsigned char _certs_compressed[] = {\n") for i in range(len(buf)): - g.write("\t" + byte_to_str(buf[i]) + ",\n") + g.write("\t" + str(buf[i]) + ",\n") g.write("};\n") - g.write("#endif") + g.write("#endif // CERTS_COMPRESSED_GEN_H") g.close() f.close() @@ -46,12 +64,12 @@ def make_authors_header(target, source, env): src = source[0] dst = target[0] - f = open_utf8(src, "r") - g = open_utf8(dst, "w") + f = open(src, "r", encoding="utf-8") + g = open(dst, "w", encoding="utf-8") g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n") - g.write("#ifndef _EDITOR_AUTHORS_H\n") - g.write("#define _EDITOR_AUTHORS_H\n") + g.write("#ifndef AUTHORS_GEN_H\n") + g.write("#define AUTHORS_GEN_H\n") reading = False @@ -78,7 +96,7 @@ def make_authors_header(target, source, env): if reading: close_section() - g.write("#endif\n") + g.write("#endif // AUTHORS_GEN_H\n") g.close() f.close() @@ -92,12 +110,12 @@ def make_donors_header(target, source, env): src = source[0] dst = target[0] - f = open_utf8(src, "r") - g = open_utf8(dst, "w") + f = open(src, "r", encoding="utf-8") + g = open(dst, "w", encoding="utf-8") g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n") - g.write("#ifndef _EDITOR_DONORS_H\n") - g.write("#define _EDITOR_DONORS_H\n") + g.write("#ifndef DONORS_GEN_H\n") + g.write("#define DONORS_GEN_H\n") reading = False @@ -124,7 +142,7 @@ def make_donors_header(target, source, env): if reading: close_section() - g.write("#endif\n") + g.write("#endif // DONORS_GEN_H\n") g.close() f.close() @@ -163,7 +181,7 @@ def make_license_header(target, source, env): projects = OrderedDict() license_list = [] - with open_utf8(src_copyright, "r") as copyright_file: + with open(src_copyright, "r", encoding="utf-8") as copyright_file: reader = LicenseReader(copyright_file) part = {} while reader.current: @@ -183,21 +201,21 @@ def make_license_header(target, source, env): reader.next_line() data_list = [] - for project in itervalues(projects): + for project in iter(projects.values()): for part in project: part["file_index"] = len(data_list) data_list += part["Files"] part["copyright_index"] = len(data_list) data_list += part["Copyright"] - with open_utf8(dst, "w") as f: + with open(dst, "w", encoding="utf-8") as f: f.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n") - f.write("#ifndef _EDITOR_LICENSE_H\n") - f.write("#define _EDITOR_LICENSE_H\n") + f.write("#ifndef LICENSE_GEN_H\n") + f.write("#define LICENSE_GEN_H\n") f.write("const char *const GODOT_LICENSE_TEXT =") - with open_utf8(src_license, "r") as license_file: + with open(src_license, "r", encoding="utf-8") as license_file: for line in license_file: escaped_string = escape_string(line.strip()) f.write("\n\t\t\"" + escaped_string + "\\n\"") @@ -225,7 +243,7 @@ def make_license_header(target, source, env): f.write("const ComponentCopyrightPart COPYRIGHT_PROJECT_PARTS[] = {\n") part_index = 0 part_indexes = {} - for project_name, project in iteritems(projects): + for project_name, project in iter(projects.items()): part_indexes[project_name] = part_index for part in project: f.write("\t{ \"" + escape_string(part["License"][0]) + "\", " @@ -239,7 +257,7 @@ def make_license_header(target, source, env): f.write("const int COPYRIGHT_INFO_COUNT = " + str(len(projects)) + ";\n") f.write("const ComponentCopyright COPYRIGHT_INFO[] = {\n") - for project_name, project in iteritems(projects): + for project_name, project in iter(projects.items()): f.write("\t{ \"" + escape_string(project_name) + "\", " + "©RIGHT_PROJECT_PARTS[" + str(part_indexes[project_name]) + "], " + str(len(project)) + " },\n") @@ -262,7 +280,7 @@ def make_license_header(target, source, env): f.write("\t\"\",\n\n") f.write("};\n\n") - f.write("#endif\n") + f.write("#endif // LICENSE_GEN_H\n") if __name__ == '__main__': diff --git a/core/core_string_names.h b/core/core_string_names.h index 42416d3f75..dce0244631 100644 --- a/core/core_string_names.h +++ b/core/core_string_names.h @@ -97,4 +97,4 @@ public: StringName notification; }; -#endif // SCENE_STRING_NAMES_H +#endif // CORE_STRING_NAMES_H diff --git a/core/cowdata.h b/core/cowdata.h index fba3f64899..5de78be6d7 100644 --- a/core/cowdata.h +++ b/core/cowdata.h @@ -28,15 +28,15 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef COWDATA_H_ -#define COWDATA_H_ - -#include <string.h> +#ifndef COWDATA_H +#define COWDATA_H #include "core/error_macros.h" #include "core/os/memory.h" #include "core/safe_refcount.h" +#include <string.h> + template <class T> class Vector; class String; @@ -371,4 +371,4 @@ CowData<T>::~CowData() { _unref(_ptr); } -#endif /* COW_H_ */ +#endif // COWDATA_H diff --git a/core/debugger/script_debugger.h b/core/debugger/script_debugger.h index 2273073bf4..a60b57c637 100644 --- a/core/debugger/script_debugger.h +++ b/core/debugger/script_debugger.h @@ -77,4 +77,4 @@ public: ScriptDebugger() {} }; -#endif +#endif // SCRIPT_DEBUGGER_H diff --git a/core/error_list.h b/core/error_list.h index b464a93341..a0218cf045 100644 --- a/core/error_list.h +++ b/core/error_list.h @@ -90,4 +90,4 @@ enum Error { ERR_PRINTER_ON_FIRE, /// the parallel port printer is engulfed in flames }; -#endif +#endif // ERROR_LIST_H diff --git a/core/error_macros.h b/core/error_macros.h index 8818dcbe77..18c46c9e7d 100644 --- a/core/error_macros.h +++ b/core/error_macros.h @@ -623,4 +623,4 @@ void _err_print_index_error(const char *p_function, const char *p_file, int p_li } else \ ((void)0) -#endif +#endif // ERROR_MACROS_H diff --git a/core/hash_map.h b/core/hash_map.h index c9d3a690e7..e40b00a67a 100644 --- a/core/hash_map.h +++ b/core/hash_map.h @@ -599,4 +599,4 @@ public: } }; -#endif +#endif // HASH_MAP_H diff --git a/core/hashfuncs.h b/core/hashfuncs.h index d6cf04e560..219b8b2658 100644 --- a/core/hashfuncs.h +++ b/core/hashfuncs.h @@ -38,6 +38,7 @@ #include "core/string_name.h" #include "core/typedefs.h" #include "core/ustring.h" + /** * Hashing functions */ @@ -171,4 +172,4 @@ struct HashMapComparatorDefault { } }; -#endif +#endif // HASHFUNCS_H diff --git a/core/image.h b/core/image.h index 4dc4bf1328..9453f41334 100644 --- a/core/image.h +++ b/core/image.h @@ -396,4 +396,4 @@ VARIANT_ENUM_CAST(Image::UsedChannels) VARIANT_ENUM_CAST(Image::AlphaMode) VARIANT_ENUM_CAST(Image::RoughnessChannel) -#endif +#endif // IMAGE_H diff --git a/core/int_types.h b/core/int_types.h index e7de053766..71caa2202d 100644 --- a/core/int_types.h +++ b/core/int_types.h @@ -28,6 +28,9 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ +#ifndef INT_TYPES_H +#define INT_TYPES_H + #ifdef _MSC_VER typedef signed __int8 int8_t; @@ -54,4 +57,6 @@ typedef unsigned long long uint64_t; #include <stdint.h> #endif -#endif +#endif // _MSC_VER + +#endif // INT_TYPES_H diff --git a/core/io/image_loader.h b/core/io/image_loader.h index 3ba028b99c..29352e9cd4 100644 --- a/core/io/image_loader.h +++ b/core/io/image_loader.h @@ -79,4 +79,4 @@ public: virtual String get_resource_type(const String &p_path) const; }; -#endif +#endif // IMAGE_LOADER_H diff --git a/core/io/logger.h b/core/io/logger.h index ab2f9d8bc7..7028551185 100644 --- a/core/io/logger.h +++ b/core/io/logger.h @@ -107,4 +107,4 @@ public: virtual ~CompositeLogger(); }; -#endif +#endif // LOGGER_H diff --git a/core/io/marshalls.h b/core/io/marshalls.h index 484f0755de..7d95bc4f86 100644 --- a/core/io/marshalls.h +++ b/core/io/marshalls.h @@ -202,4 +202,4 @@ public: Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int *r_len = NULL, bool p_allow_objects = false); Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bool p_full_objects = false); -#endif +#endif // MARSHALLS_H diff --git a/core/io/multiplayer_api.h b/core/io/multiplayer_api.h index 52f918aefa..4eb4a53e99 100644 --- a/core/io/multiplayer_api.h +++ b/core/io/multiplayer_api.h @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef MULTIPLAYER_PROTOCOL_H -#define MULTIPLAYER_PROTOCOL_H +#ifndef MULTIPLAYER_API_H +#define MULTIPLAYER_API_H #include "core/io/networked_multiplayer_peer.h" #include "core/reference.h" @@ -148,4 +148,4 @@ public: VARIANT_ENUM_CAST(MultiplayerAPI::RPCMode); -#endif // MULTIPLAYER_PROTOCOL_H +#endif // MULTIPLAYER_API_H diff --git a/core/io/networked_multiplayer_peer.h b/core/io/networked_multiplayer_peer.h index bffd544589..c1f1924051 100644 --- a/core/io/networked_multiplayer_peer.h +++ b/core/io/networked_multiplayer_peer.h @@ -80,4 +80,4 @@ public: VARIANT_ENUM_CAST(NetworkedMultiplayerPeer::TransferMode) VARIANT_ENUM_CAST(NetworkedMultiplayerPeer::ConnectionStatus) -#endif // NetworkedMultiplayerPeer_H +#endif // NETWORKED_MULTIPLAYER_PEER_H diff --git a/core/io/resource_loader.h b/core/io/resource_loader.h index 5ba9e26858..a97b72e7df 100644 --- a/core/io/resource_loader.h +++ b/core/io/resource_loader.h @@ -200,4 +200,4 @@ public: static void finalize(); }; -#endif +#endif // RESOURCE_LOADER_H diff --git a/core/io/resource_saver.h b/core/io/resource_saver.h index e749f54cfa..2ddebf0581 100644 --- a/core/io/resource_saver.h +++ b/core/io/resource_saver.h @@ -90,4 +90,4 @@ public: static void remove_custom_savers(); }; -#endif +#endif // RESOURCE_SAVER_H diff --git a/core/io/stream_peer_tcp.h b/core/io/stream_peer_tcp.h index 327aa3cc3b..86df9ab8cf 100644 --- a/core/io/stream_peer_tcp.h +++ b/core/io/stream_peer_tcp.h @@ -93,4 +93,4 @@ public: VARIANT_ENUM_CAST(StreamPeerTCP::Status); -#endif +#endif // STREAM_PEER_TCP_H diff --git a/core/io/xml_parser.h b/core/io/xml_parser.h index 47e276da28..26c3e6802f 100644 --- a/core/io/xml_parser.h +++ b/core/io/xml_parser.h @@ -121,4 +121,4 @@ public: ~XMLParser(); }; -#endif +#endif // XML_PARSER_H diff --git a/core/list.h b/core/list.h index 5a7c9e572c..d441c0230d 100644 --- a/core/list.h +++ b/core/list.h @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef GLOBALS_LIST_H -#define GLOBALS_LIST_H +#ifndef LIST_H +#define LIST_H #include "core/error_macros.h" #include "core/os/memory.h" @@ -708,4 +708,4 @@ public: }; }; -#endif +#endif // LIST_H diff --git a/core/map.h b/core/map.h index b97f735f1b..010c47b0fb 100644 --- a/core/map.h +++ b/core/map.h @@ -682,4 +682,4 @@ public: } }; -#endif +#endif // MAP_H diff --git a/core/math/a_star.h b/core/math/a_star.h index cc6c4619e9..8c10ace33c 100644 --- a/core/math/a_star.h +++ b/core/math/a_star.h @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef ASTAR_H -#define ASTAR_H +#ifndef A_STAR_H +#define A_STAR_H #include "core/oa_hash_map.h" #include "core/reference.h" @@ -210,4 +210,4 @@ public: ~AStar2D(); }; -#endif // ASTAR_H +#endif // A_STAR_H diff --git a/core/math/audio_frame.h b/core/math/audio_frame.h index 6477d029d5..e1dbb385e4 100644 --- a/core/math/audio_frame.h +++ b/core/math/audio_frame.h @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef AUDIOFRAME_H -#define AUDIOFRAME_H +#ifndef AUDIO_FRAME_H +#define AUDIO_FRAME_H #include "core/math/vector2.h" #include "core/typedefs.h" @@ -140,4 +140,4 @@ struct AudioFrame { _ALWAYS_INLINE_ AudioFrame() {} }; -#endif +#endif // AUDIO_FRAME_H diff --git a/core/math/camera_matrix.h b/core/math/camera_matrix.h index 60f7d15974..c10193bc84 100644 --- a/core/math/camera_matrix.h +++ b/core/math/camera_matrix.h @@ -124,4 +124,4 @@ Vector3 CameraMatrix::xform(const Vector3 &p_vec3) const { return ret / w; } -#endif +#endif // CAMERA_MATRIX_H diff --git a/core/math/disjoint_set.h b/core/math/disjoint_set.h index fb89941ce4..32b9875e4c 100644 --- a/core/math/disjoint_set.h +++ b/core/math/disjoint_set.h @@ -152,4 +152,4 @@ void DisjointSet<T, C, AL>::get_members(Vector<T> &out_members, T representative } } -#endif +#endif // DISJOINT_SET_H diff --git a/core/math/geometry.h b/core/math/geometry.h index 6453d16181..becbcdbf0f 100644 --- a/core/math/geometry.h +++ b/core/math/geometry.h @@ -1019,4 +1019,4 @@ private: static Vector<Vector<Point2>> _polypath_offset(const Vector<Point2> &p_polypath, real_t p_delta, PolyJoinType p_join_type, PolyEndType p_end_type); }; -#endif +#endif // GEOMETRY_H diff --git a/core/math/octree.h b/core/math/octree.h index 5478bdaf77..b47c052b68 100644 --- a/core/math/octree.h +++ b/core/math/octree.h @@ -1375,4 +1375,4 @@ Octree<T, use_pairs, AL>::Octree(real_t p_unit_size) { unpair_callback_userdata = NULL; } -#endif +#endif // OCTREE_H diff --git a/core/math/quat.h b/core/math/quat.h index 11ae03dffb..b3135ad1ca 100644 --- a/core/math/quat.h +++ b/core/math/quat.h @@ -231,4 +231,4 @@ bool Quat::operator!=(const Quat &p_quat) const { return x != p_quat.x || y != p_quat.y || z != p_quat.z || w != p_quat.w; } -#endif +#endif // QUAT_H diff --git a/core/math/triangulate.h b/core/math/triangulate.h index f9bcb37141..c453b77ecf 100644 --- a/core/math/triangulate.h +++ b/core/math/triangulate.h @@ -58,4 +58,4 @@ private: static bool snip(const Vector<Vector2> &p_contour, int u, int v, int w, int n, const Vector<int> &V, bool relaxed); }; -#endif +#endif // TRIANGULATE_H diff --git a/core/method_bind.h b/core/method_bind.h index 726ce512f8..a1ab4e58fc 100644 --- a/core/method_bind.h +++ b/core/method_bind.h @@ -405,4 +405,4 @@ class __UnexistingClass; #include "method_bind.gen.inc" -#endif +#endif // METHOD_BIND_H diff --git a/core/node_path.h b/core/node_path.h index 05b6d844ff..76de36cd9f 100644 --- a/core/node_path.h +++ b/core/node_path.h @@ -97,4 +97,4 @@ public: ~NodePath(); }; -#endif +#endif // NODE_PATH_H diff --git a/core/oa_hash_map.h b/core/oa_hash_map.h index 7ceba26be8..447b0db0eb 100644 --- a/core/oa_hash_map.h +++ b/core/oa_hash_map.h @@ -369,4 +369,4 @@ public: } }; -#endif +#endif // OA_HASH_MAP_H diff --git a/core/object.h b/core/object.h index 9bdcf0d3d8..0826686fb3 100644 --- a/core/object.h +++ b/core/object.h @@ -817,4 +817,4 @@ public: //needed by macros #include "core/class_db.h" -#endif +#endif // OBJECT_H diff --git a/core/os/copymem.h b/core/os/copymem.h index 1d6631ddb8..04ea3caeff 100644 --- a/core/os/copymem.h +++ b/core/os/copymem.h @@ -47,4 +47,4 @@ #endif -#endif +#endif // COPYMEM_H diff --git a/core/os/dir_access.h b/core/os/dir_access.h index aac6c67f0a..059f7aad2f 100644 --- a/core/os/dir_access.h +++ b/core/os/dir_access.h @@ -149,4 +149,4 @@ struct DirAccessRef { } }; -#endif +#endif // DIR_ACCESS_H diff --git a/core/os/file_access.h b/core/os/file_access.h index 36a947c691..4a82637ecc 100644 --- a/core/os/file_access.h +++ b/core/os/file_access.h @@ -196,4 +196,4 @@ struct FileAccessRef { } }; -#endif +#endif // FILE_ACCESS_H diff --git a/core/os/input_event.h b/core/os/input_event.h index c105fcd1c1..21549d811f 100644 --- a/core/os/input_event.h +++ b/core/os/input_event.h @@ -622,4 +622,4 @@ public: InputEventMIDI(); }; -#endif +#endif // INPUT_EVENT_H diff --git a/core/os/keyboard.h b/core/os/keyboard.h index bac32e01dd..5d11e6a378 100644 --- a/core/os/keyboard.h +++ b/core/os/keyboard.h @@ -325,4 +325,4 @@ int keycode_get_count(); int keycode_get_value_by_index(int p_index); const char *keycode_get_name_by_index(int p_index); -#endif +#endif // KEYBOARD_H diff --git a/core/os/main_loop.h b/core/os/main_loop.h index b1120aee8a..3fdfb77af2 100644 --- a/core/os/main_loop.h +++ b/core/os/main_loop.h @@ -81,4 +81,4 @@ public: virtual ~MainLoop(); }; -#endif +#endif // MAIN_LOOP_H diff --git a/core/os/memory.h b/core/os/memory.h index 207149b57e..dcaedd92ba 100644 --- a/core/os/memory.h +++ b/core/os/memory.h @@ -206,4 +206,4 @@ struct _GlobalNilClass { static _GlobalNil _nil; }; -#endif +#endif // MEMORY_H diff --git a/core/os/midi_driver.h b/core/os/midi_driver.h index 4f53feb43e..b7377a8a40 100644 --- a/core/os/midi_driver.h +++ b/core/os/midi_driver.h @@ -58,4 +58,4 @@ public: virtual ~MIDIDriver() {} }; -#endif +#endif // MIDI_DRIVER_H diff --git a/core/os/mutex.h b/core/os/mutex.h index b44b1994de..526549dd93 100644 --- a/core/os/mutex.h +++ b/core/os/mutex.h @@ -105,4 +105,4 @@ using BinaryMutex = MutexImpl<FakeMutex>; // Non-recursive, handle with care #endif // !NO_THREADS -#endif +#endif // MUTEX_H diff --git a/core/os/os.h b/core/os/os.h index 1d3619b1e6..3e2ee7affd 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -527,4 +527,4 @@ public: virtual ~OS(); }; -#endif +#endif // OS_H diff --git a/core/os/rw_lock.h b/core/os/rw_lock.h index 21648b6cbc..64dfbef20c 100644 --- a/core/os/rw_lock.h +++ b/core/os/rw_lock.h @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef RWLOCK_H -#define RWLOCK_H +#ifndef RW_LOCK_H +#define RW_LOCK_H #include "core/error_list.h" @@ -79,4 +79,4 @@ public: } }; -#endif // RWLOCK_H +#endif // RW_LOCK_H diff --git a/core/os/semaphore.h b/core/os/semaphore.h index 6f194d4887..3d9d1ab984 100644 --- a/core/os/semaphore.h +++ b/core/os/semaphore.h @@ -80,4 +80,4 @@ public: #endif -#endif +#endif // SEMAPHORE_H diff --git a/core/os/thread.h b/core/os/thread.h index 0803fd1190..76d296bcf7 100644 --- a/core/os/thread.h +++ b/core/os/thread.h @@ -77,4 +77,4 @@ public: virtual ~Thread(); }; -#endif +#endif // THREAD_H diff --git a/core/os/thread_dummy.h b/core/os/thread_dummy.h index da8188f983..066ee498ac 100644 --- a/core/os/thread_dummy.h +++ b/core/os/thread_dummy.h @@ -61,4 +61,4 @@ public: static void make_default(); }; -#endif +#endif // THREAD_DUMMY_H diff --git a/core/os/thread_safe.h b/core/os/thread_safe.h index 0221edf491..670ee8b125 100644 --- a/core/os/thread_safe.h +++ b/core/os/thread_safe.h @@ -38,4 +38,4 @@ #define _THREAD_SAFE_LOCK_ _thread_safe_.lock(); #define _THREAD_SAFE_UNLOCK_ _thread_safe_.unlock(); -#endif +#endif // THREAD_SAFE_H diff --git a/core/pool_allocator.h b/core/pool_allocator.h index e34f5b1104..8c1710ebe0 100644 --- a/core/pool_allocator.h +++ b/core/pool_allocator.h @@ -148,4 +148,4 @@ public: virtual ~PoolAllocator(); }; -#endif +#endif // POOL_ALLOCATOR_H diff --git a/core/print_string.h b/core/print_string.h index c2cf1c293b..d83cc35dd6 100644 --- a/core/print_string.h +++ b/core/print_string.h @@ -60,4 +60,4 @@ extern void print_line(String p_string); extern void print_error(String p_string); extern void print_verbose(String p_string); -#endif +#endif // PRINT_STRING_H diff --git a/core/project_settings.h b/core/project_settings.h index 8695df560e..7b3ca18c62 100644 --- a/core/project_settings.h +++ b/core/project_settings.h @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef GLOBAL_CONFIG_H -#define GLOBAL_CONFIG_H +#ifndef PROJECT_SETTINGS_H +#define PROJECT_SETTINGS_H #include "core/object.h" #include "core/os/thread_safe.h" @@ -166,4 +166,4 @@ Variant _GLOBAL_DEF(const String &p_var, const Variant &p_default, bool p_restar #define GLOBAL_DEF_RST(m_var, m_value) _GLOBAL_DEF(m_var, m_value, true) #define GLOBAL_GET(m_var) ProjectSettings::get_singleton()->get(m_var) -#endif +#endif // PROJECT_SETTINGS_H diff --git a/core/register_core_types.h b/core/register_core_types.h index 22c0025f0c..bdd335f33c 100644 --- a/core/register_core_types.h +++ b/core/register_core_types.h @@ -36,4 +36,4 @@ void register_core_settings(); void register_core_singletons(); void unregister_core_types(); -#endif +#endif // REGISTER_CORE_TYPES_H diff --git a/core/resource.h b/core/resource.h index 4b79a39d9d..9f83848c04 100644 --- a/core/resource.h +++ b/core/resource.h @@ -167,4 +167,4 @@ public: static int get_cached_resource_count(); }; -#endif +#endif // RESOURCE_H diff --git a/core/rid.h b/core/rid.h index 0c4a96efed..3cc0ee3084 100644 --- a/core/rid.h +++ b/core/rid.h @@ -75,4 +75,4 @@ public: } }; -#endif +#endif // RID_H diff --git a/core/ring_buffer.h b/core/ring_buffer.h index f5f43607fe..620a3a3846 100644 --- a/core/ring_buffer.h +++ b/core/ring_buffer.h @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef RINGBUFFER_H -#define RINGBUFFER_H +#ifndef RING_BUFFER_H +#define RING_BUFFER_H #include "core/vector.h" @@ -221,4 +221,4 @@ public: ~RingBuffer<T>(){}; }; -#endif +#endif // RING_BUFFER_H diff --git a/core/safe_refcount.h b/core/safe_refcount.h index 887282f556..953a877397 100644 --- a/core/safe_refcount.h +++ b/core/safe_refcount.h @@ -208,4 +208,4 @@ public: } }; -#endif +#endif // SAFE_REFCOUNT_H diff --git a/core/script_language.h b/core/script_language.h index bb7d74dd83..6219a423d0 100644 --- a/core/script_language.h +++ b/core/script_language.h @@ -459,4 +459,5 @@ public: PlaceHolderScriptInstance(ScriptLanguage *p_language, Ref<Script> p_script, Object *p_owner); ~PlaceHolderScriptInstance(); }; -#endif + +#endif // SCRIPT_LANGUAGE_H diff --git a/core/set.h b/core/set.h index aee3f4bc7a..5ddfb87b74 100644 --- a/core/set.h +++ b/core/set.h @@ -634,4 +634,4 @@ public: } }; -#endif +#endif // SET_H diff --git a/core/simple_type.h b/core/simple_type.h index f637504db8..da031854c6 100644 --- a/core/simple_type.h +++ b/core/simple_type.h @@ -51,4 +51,4 @@ struct GetSimpleTypeT<T const> { typedef T type_t; }; -#endif +#endif // SIMPLE_TYPE_H diff --git a/core/string_buffer.h b/core/string_buffer.h index d80a975c7f..a140f0abf7 100644 --- a/core/string_buffer.h +++ b/core/string_buffer.h @@ -163,4 +163,4 @@ int64_t StringBuffer<SHORT_BUFFER_SIZE>::as_int() { return String::to_int(current_buffer_ptr()); } -#endif +#endif // STRING_BUFFER_H diff --git a/core/type_info.h b/core/type_info.h index 3b08ff3cae..7e4b192b27 100644 --- a/core/type_info.h +++ b/core/type_info.h @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef GET_TYPE_INFO_H -#define GET_TYPE_INFO_H +#ifndef TYPE_INFO_H +#define TYPE_INFO_H #ifdef DEBUG_METHODS_ENABLED @@ -273,4 +273,4 @@ inline StringName __constant_get_enum_name(T param, const String &p_constant) { #endif // DEBUG_METHODS_ENABLED -#endif // GET_TYPE_INFO_H +#endif // TYPE_INFO_H diff --git a/core/ucaps.h b/core/ucaps.h index 013f264d2f..ad71731617 100644 --- a/core/ucaps.h +++ b/core/ucaps.h @@ -1413,4 +1413,5 @@ static int _find_lower(int ch) { return ch; } -#endif + +#endif // UCAPS_H diff --git a/core/variant.h b/core/variant.h index 614d39e84a..d38130e3a3 100644 --- a/core/variant.h +++ b/core/variant.h @@ -516,4 +516,5 @@ const Variant::ObjData &Variant::_get_obj() const { } String vformat(const String &p_text, const Variant &p1 = Variant(), const Variant &p2 = Variant(), const Variant &p3 = Variant(), const Variant &p4 = Variant(), const Variant &p5 = Variant()); -#endif + +#endif // VARIANT_H diff --git a/core/vector.h b/core/vector.h index 51a73e4ae4..7277179621 100644 --- a/core/vector.h +++ b/core/vector.h @@ -181,4 +181,4 @@ bool Vector<T>::push_back(T p_elem) { return false; } -#endif +#endif // VECTOR_H diff --git a/core/version.h b/core/version.h index 42c85c1b13..1198f62db4 100644 --- a/core/version.h +++ b/core/version.h @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef GODOT_VERSION_H -#define GODOT_VERSION_H +#ifndef VERSION_H +#define VERSION_H #include "core/version_generated.gen.h" @@ -68,4 +68,4 @@ // Example: "Godot v3.1.4.stable.official.mono" #define VERSION_FULL_NAME "" VERSION_NAME " v" VERSION_FULL_BUILD -#endif // GODOT_VERSION_H +#endif // VERSION_H diff --git a/doc/Makefile b/doc/Makefile index 7f3f7ea939..9534da9bd5 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -13,13 +13,6 @@ doxygen: mkdir -p $(OUTPUTDIR)/doxygen doxygen Doxyfile -markdown: - rm -rf $(OUTPUTDIR)/markdown - mkdir -p $(OUTPUTDIR)/markdown - pushd $(OUTPUTDIR)/markdown - python2 $(TOOLSDIR)/makemd.py $(CLASSES) - popd - rst: rm -rf $(OUTPUTDIR)/rst mkdir -p $(OUTPUTDIR)/rst diff --git a/editor/SCsub b/editor/SCsub index 6e8679b770..61562d70d3 100644 --- a/editor/SCsub +++ b/editor/SCsub @@ -7,13 +7,12 @@ env.editor_sources = [] import os import os.path from platform_methods import run_in_subprocess -from compat import open_utf8 import editor_builders def _make_doc_data_class_path(to_path): # NOTE: It is safe to generate this file here, since this is still executed serially - g = open_utf8(os.path.join(to_path, "doc_data_class_path.gen.h"), "w") + g = open(os.path.join(to_path, "doc_data_class_path.gen.h"), "w", encoding="utf-8") g.write("static const int _doc_data_class_path_count = " + str(len(env.doc_class_path)) + ";\n") g.write("struct _DocDataClassPath { const char* name; const char* path; };\n") @@ -37,7 +36,7 @@ if env['tools']: reg_exporters += '}\n' # NOTE: It is safe to generate this file here, since this is still executed serially - with open_utf8("register_exporters.gen.cpp", "w") as f: + with open("register_exporters.gen.cpp", "w", encoding="utf-8") as f: f.write(reg_exporters_inc) f.write(reg_exporters) diff --git a/editor/editor_builders.py b/editor/editor_builders.py index e8c23acf9e..44c3e50dfc 100644 --- a/editor/editor_builders.py +++ b/editor/editor_builders.py @@ -6,24 +6,23 @@ All such functions are invoked in a subprocess on Windows to prevent build flaki import os import os.path from platform_methods import subprocess_main -from compat import encode_utf8, byte_to_str, open_utf8 def make_doc_header(target, source, env): dst = target[0] - g = open_utf8(dst, "w") + g = open(dst, "w", encoding="utf-8") buf = "" docbegin = "" docend = "" for src in source: if not src.endswith(".xml"): continue - with open_utf8(src, "r") as f: + with open(src, "r", encoding="utf-8") as f: content = f.read() buf += content - buf = encode_utf8(docbegin + buf + docend) + buf = (docbegin + buf + docend).encode("utf-8") decomp_size = len(buf) import zlib buf = zlib.compress(buf) @@ -35,7 +34,7 @@ def make_doc_header(target, source, env): g.write("static const int _doc_data_uncompressed_size = " + str(decomp_size) + ";\n") g.write("static const unsigned char _doc_data_compressed[] = {\n") for i in range(len(buf)): - g.write("\t" + byte_to_str(buf[i]) + ",\n") + g.write("\t" + str(buf[i]) + ",\n") g.write("};\n") g.write("#endif") @@ -47,7 +46,7 @@ def make_fonts_header(target, source, env): dst = target[0] - g = open_utf8(dst, "w") + g = open(dst, "w", encoding="utf-8") g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n") g.write("#ifndef _EDITOR_FONTS_H\n") @@ -64,7 +63,7 @@ def make_fonts_header(target, source, env): g.write("static const int _font_" + name + "_size = " + str(len(buf)) + ";\n") g.write("static const unsigned char _font_" + name + "[] = {\n") for j in range(len(buf)): - g.write("\t" + byte_to_str(buf[j]) + ",\n") + g.write("\t" + str(buf[j]) + ",\n") g.write("};\n") @@ -77,7 +76,7 @@ def make_translations_header(target, source, env, category): dst = target[0] - g = open_utf8(dst, "w") + g = open(dst, "w", encoding="utf-8") g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n") g.write("#ifndef _{}_TRANSLATIONS_H\n".format(category.upper())) @@ -98,7 +97,7 @@ def make_translations_header(target, source, env, category): g.write("static const unsigned char _{}_translation_{}_compressed[] = {{\n".format(category, name)) for j in range(len(buf)): - g.write("\t" + byte_to_str(buf[j]) + ",\n") + g.write("\t" + str(buf[j]) + ",\n") g.write("};\n") diff --git a/editor/icons/editor_icons_builders.py b/editor/icons/editor_icons_builders.py index ea2c2e57d1..a00f21c265 100644 --- a/editor/icons/editor_icons_builders.py +++ b/editor/icons/editor_icons_builders.py @@ -3,9 +3,10 @@ All such functions are invoked in a subprocess on Windows to prevent build flakiness. """ + import os +from io import StringIO from platform_methods import subprocess_main -from compat import StringIO def make_editor_icons_action(target, source, env): diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp index 9100e28352..a10e1c1d2c 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -2669,6 +2669,38 @@ VisualShaderEditor::VisualShaderEditor() { add_options.push_back(AddOption("Transform", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "transform"), "transform", VisualShaderNode::PORT_TYPE_TRANSFORM, VisualShader::TYPE_VERTEX, Shader::MODE_PARTICLES)); add_options.push_back(AddOption("Velocity", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "velocity"), "velocity", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_VERTEX, Shader::MODE_PARTICLES)); + // SKY INPUTS + + add_options.push_back(AddOption("AtCubeMapPass", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "at_cubemap_pass"), "at_cubemap_pass", VisualShaderNode::PORT_TYPE_BOOLEAN, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY)); + add_options.push_back(AddOption("AtHalfResPass", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "at_half_res_pass"), "at_half_res_pass", VisualShaderNode::PORT_TYPE_BOOLEAN, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY)); + add_options.push_back(AddOption("AtQuarterResPass", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "at_quarter_res_pass"), "at_quarter_res_pass", VisualShaderNode::PORT_TYPE_BOOLEAN, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY)); + add_options.push_back(AddOption("EyeDir", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "eyedir"), "eyedir", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY)); + add_options.push_back(AddOption("HalfResColor", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "half_res_color"), "half_res_color", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY)); + add_options.push_back(AddOption("HalfResAlpha", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "half_res_alpha"), "half_res_alpha", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY)); + add_options.push_back(AddOption("Light0Color", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light0_color"), "light0_color", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY)); + add_options.push_back(AddOption("Light0Direction", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light0_direction"), "light0_direction", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY)); + add_options.push_back(AddOption("Light0Enabled", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light0_enabled"), "light0_enabled", VisualShaderNode::PORT_TYPE_BOOLEAN, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY)); + add_options.push_back(AddOption("Light0Energy", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light0_energy"), "light0_energy", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY)); + add_options.push_back(AddOption("Light1Color", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light1_color"), "light1_color", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY)); + add_options.push_back(AddOption("Light1Direction", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light1_direction"), "light1_direction", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY)); + add_options.push_back(AddOption("Light1Enabled", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light1_enabled"), "light1_enabled", VisualShaderNode::PORT_TYPE_BOOLEAN, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY)); + add_options.push_back(AddOption("Light1Energy", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light1_energy"), "light1_energy", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY)); + add_options.push_back(AddOption("Light2Color", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light2_color"), "light2_color", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY)); + add_options.push_back(AddOption("Light2Direction", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light2_direction"), "light2_direction", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY)); + add_options.push_back(AddOption("Light2Enabled", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light2_enabled"), "light2_enabled", VisualShaderNode::PORT_TYPE_BOOLEAN, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY)); + add_options.push_back(AddOption("Light2Energy", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light2_energy"), "light2_energy", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY)); + add_options.push_back(AddOption("Light3Color", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light3_color"), "light3_color", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY)); + add_options.push_back(AddOption("Light3Direction", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light3_direction"), "light3_direction", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY)); + add_options.push_back(AddOption("Light3Enabled", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light3_enabled"), "light3_enabled", VisualShaderNode::PORT_TYPE_BOOLEAN, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY)); + add_options.push_back(AddOption("Light3Energy", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light3_energy"), "light3_energy", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY)); + add_options.push_back(AddOption("Position", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "position"), "position", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY)); + add_options.push_back(AddOption("QuarterResColor", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "quarter_res_color"), "quarter_res_color", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY)); + add_options.push_back(AddOption("QuarterResAlpha", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "quarter_res_alpha"), "quarter_res_alpha", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY)); + add_options.push_back(AddOption("Radiance", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "radiance"), "radiance", VisualShaderNode::PORT_TYPE_SAMPLER, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY)); + add_options.push_back(AddOption("ScreenUV", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "screen_uv"), "screen_uv", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY)); + add_options.push_back(AddOption("SkyCoords", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "sky_coords"), "sky_coords", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY)); + add_options.push_back(AddOption("Time", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "time"), "time", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY)); + // SCALAR add_options.push_back(AddOption("FloatFunc", "Scalar", "Common", "VisualShaderNodeFloatFunc", TTR("Float function."), -1, VisualShaderNode::PORT_TYPE_SCALAR)); diff --git a/editor/project_settings_editor.h b/editor/project_settings_editor.h index 52e7612acd..2cecb13198 100644 --- a/editor/project_settings_editor.h +++ b/editor/project_settings_editor.h @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef PROJECT_SETTINGS_H -#define PROJECT_SETTINGS_H +#ifndef PROJECT_SETTINGS_EDITOR_H +#define PROJECT_SETTINGS_EDITOR_H #include "core/undo_redo.h" #include "editor/editor_autoload_settings.h" @@ -204,4 +204,4 @@ public: ProjectSettingsEditor(EditorData *p_data); }; -#endif // PROJECT_SETTINGS_H +#endif // PROJECT_SETTINGS_EDITOR_H diff --git a/main/main_builders.py b/main/main_builders.py index c48aaaa572..e24070ccc3 100644 --- a/main/main_builders.py +++ b/main/main_builders.py @@ -4,7 +4,6 @@ All such functions are invoked in a subprocess on Windows to prevent build flaki """ from platform_methods import subprocess_main -from compat import byte_to_str from collections import OrderedDict @@ -22,7 +21,7 @@ def make_splash(target, source, env): g.write('static const Color boot_splash_bg_color = Color(0.14, 0.14, 0.14);\n') g.write("static const unsigned char boot_splash_png[] = {\n") for i in range(len(buf)): - g.write(byte_to_str(buf[i]) + ",\n") + g.write(str(buf[i]) + ",\n") g.write("};\n") g.write("#endif") @@ -41,7 +40,7 @@ def make_splash_editor(target, source, env): g.write('static const Color boot_splash_editor_bg_color = Color(0.14, 0.14, 0.14);\n') g.write("static const unsigned char boot_splash_editor_png[] = {\n") for i in range(len(buf)): - g.write(byte_to_str(buf[i]) + ",\n") + g.write(str(buf[i]) + ",\n") g.write("};\n") g.write("#endif") @@ -59,7 +58,7 @@ def make_app_icon(target, source, env): g.write("#define APP_ICON_H\n") g.write("static const unsigned char app_icon_png[] = {\n") for i in range(len(buf)): - g.write(byte_to_str(buf[i]) + ",\n") + g.write(str(buf[i]) + ",\n") g.write("};\n") g.write("#endif") diff --git a/methods.py b/methods.py index 56c495468d..dc82c97361 100644 --- a/methods.py +++ b/methods.py @@ -2,12 +2,11 @@ import os import re import glob import subprocess -from compat import iteritems, isbasestring, decode_utf8 def add_source_files(self, sources, files, warn_duplicates=True): # Convert string to list of absolute paths (including expanding wildcard) - if isbasestring(files): + if isinstance(files, (str, bytes)): # Keep SCons project-absolute path as they are (no wildcard support) if files.startswith('#'): if '*' in files: @@ -62,6 +61,9 @@ def update_version(module_version_string=""): # NOTE: It is safe to generate this file here, since this is still executed serially f = open("core/version_generated.gen.h", "w") + f.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n") + f.write("#ifndef VERSION_GENERATED_GEN_H\n") + f.write("#define VERSION_GENERATED_GEN_H\n") f.write("#define VERSION_SHORT_NAME \"" + str(version.short_name) + "\"\n") f.write("#define VERSION_NAME \"" + str(version.name) + "\"\n") f.write("#define VERSION_MAJOR " + str(version.major) + "\n") @@ -72,10 +74,14 @@ def update_version(module_version_string=""): f.write("#define VERSION_MODULE_CONFIG \"" + str(version.module_config) + module_version_string + "\"\n") f.write("#define VERSION_YEAR " + str(version.year) + "\n") f.write("#define VERSION_WEBSITE \"" + str(version.website) + "\"\n") + f.write("#endif // VERSION_GENERATED_GEN_H\n") f.close() # NOTE: It is safe to generate this file here, since this is still executed serially fhash = open("core/version_hash.gen.h", "w") + fhash.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n") + fhash.write("#ifndef VERSION_HASH_GEN_H\n") + fhash.write("#define VERSION_HASH_GEN_H\n") githash = "" gitfolder = ".git" @@ -93,7 +99,8 @@ def update_version(module_version_string=""): else: githash = head - fhash.write("#define VERSION_HASH \"" + githash + "\"") + fhash.write("#define VERSION_HASH \"" + githash + "\"\n") + fhash.write("#endif // VERSION_HASH_GEN_H\n") fhash.close() @@ -232,7 +239,7 @@ def use_windows_spawn_fix(self, platform=None): cmdline = cmd + " " + newargs rv = 0 - env = {str(key): str(value) for key, value in iteritems(env)} + env = {str(key): str(value) for key, value in iter(env.items())} if len(cmdline) > 32000 and cmd.endswith("ar"): cmdline = cmd + " " + args[1] + " " + args[2] + " " for i in range(3, len(args)): @@ -522,7 +529,7 @@ def detect_darwin_sdk_path(platform, env): if not env[var_name]: try: - sdk_path = decode_utf8(subprocess.check_output(['xcrun', '--sdk', sdk_name, '--show-sdk-path']).strip()) + sdk_path = subprocess.check_output(['xcrun', '--sdk', sdk_name, '--show-sdk-path']).strip().decode("utf-8") if sdk_path: env[var_name] = sdk_path except (subprocess.CalledProcessError, OSError): @@ -532,7 +539,7 @@ def detect_darwin_sdk_path(platform, env): def is_vanilla_clang(env): if not using_clang(env): return False - version = decode_utf8(subprocess.check_output([env['CXX'], '--version']).strip()) + version = subprocess.check_output([env['CXX'], '--version']).strip().decode("utf-8") return not version.startswith("Apple") @@ -545,7 +552,7 @@ def get_compiler_version(env): # Not using -dumpversion as some GCC distros only return major, and # Clang used to return hardcoded 4.2.1: # https://reviews.llvm.org/D56803 try: - version = decode_utf8(subprocess.check_output([env.subst(env['CXX']), '--version']).strip()) + version = subprocess.check_output([env.subst(env['CXX']), '--version']).strip().decode("utf-8") except (subprocess.CalledProcessError, OSError): print("Couldn't parse CXX environment variable to infer compiler version.") return None diff --git a/modules/freetype/SCsub b/modules/freetype/SCsub index 7b66aa1c76..9e1853c4cd 100644 --- a/modules/freetype/SCsub +++ b/modules/freetype/SCsub @@ -3,8 +3,6 @@ Import('env') Import('env_modules') -from compat import isbasestring - env_freetype = env_modules.Clone() # Thirdparty source files @@ -93,7 +91,7 @@ if env['builtin_freetype']: # and then plain strings for system library. We insert between the two. inserted = False for idx, linklib in enumerate(env["LIBS"]): - if isbasestring(linklib): # first system lib such as "X11", otherwise SCons lib object + if isinstance(linklib, (str, bytes)): # first system lib such as "X11", otherwise SCons lib object env["LIBS"].insert(idx, lib) inserted = True break diff --git a/modules/mono/build_scripts/make_android_mono_config.py b/modules/mono/build_scripts/make_android_mono_config.py index 0afd939c57..4f5a496891 100644 --- a/modules/mono/build_scripts/make_android_mono_config.py +++ b/modules/mono/build_scripts/make_android_mono_config.py @@ -1,7 +1,6 @@ def generate_compressed_config(config_src, output_dir): import os.path - from compat import byte_to_str # Source file with open(os.path.join(output_dir, 'android_mono_config.gen.cpp'), 'w') as cpp: @@ -16,7 +15,7 @@ def generate_compressed_config(config_src, output_dir): for i, buf_idx in enumerate(range(compr_size)): if i > 0: bytes_seq_str += ', ' - bytes_seq_str += byte_to_str(buf[buf_idx]) + bytes_seq_str += str(buf[buf_idx]) cpp.write('''/* THIS FILE IS GENERATED DO NOT EDIT */ #include "android_mono_config.h" diff --git a/modules/mono/build_scripts/mono_reg_utils.py b/modules/mono/build_scripts/mono_reg_utils.py index b2c48f0a61..3bae11b167 100644 --- a/modules/mono/build_scripts/mono_reg_utils.py +++ b/modules/mono/build_scripts/mono_reg_utils.py @@ -1,14 +1,9 @@ import os import platform -from compat import decode_utf8 - if os.name == 'nt': import sys - if sys.version_info < (3,): - import _winreg as winreg - else: - import winreg + import winreg def _reg_open_key(key, subkey): @@ -81,7 +76,7 @@ def find_msbuild_tools_path_reg(): lines = subprocess.check_output([vswhere] + vswhere_args).splitlines() for line in lines: - parts = decode_utf8(line).split(':', 1) + parts = line.decode("utf-8").split(':', 1) if len(parts) < 2 or parts[0] != 'installationPath': continue diff --git a/platform/SCsub b/platform/SCsub index 38bab59d74..40cacce674 100644 --- a/platform/SCsub +++ b/platform/SCsub @@ -1,7 +1,5 @@ #!/usr/bin/env python -from compat import open_utf8 - Import('env') env.platform_sources = [] @@ -21,7 +19,7 @@ reg_apis += '}\n\n' unreg_apis += '}\n' # NOTE: It is safe to generate this file here, since this is still execute serially -with open_utf8('register_platform_apis.gen.cpp', 'w') as f: +with open('register_platform_apis.gen.cpp', 'w', encoding="utf-8") as f: f.write(reg_apis_inc) f.write(reg_apis) f.write(unreg_apis) diff --git a/platform_methods.py b/platform_methods.py index 4300216427..eed76bc8a8 100644 --- a/platform_methods.py +++ b/platform_methods.py @@ -7,10 +7,7 @@ import subprocess # NOTE: The multiprocessing module is not compatible with SCons due to conflict on cPickle -if sys.version_info[0] < 3: - JSON_SERIALIZABLE_TYPES = (bool, int, long, float, basestring) -else: - JSON_SERIALIZABLE_TYPES = (bool, int, float, str) +JSON_SERIALIZABLE_TYPES = (bool, int, float, str) def run_in_subprocess(builder_function): diff --git a/scene/resources/visual_shader.cpp b/scene/resources/visual_shader.cpp index 407325c199..fecef88792 100644 --- a/scene/resources/visual_shader.cpp +++ b/scene/resources/visual_shader.cpp @@ -1034,7 +1034,7 @@ bool VisualShader::_get(const StringName &p_name, Variant &r_ret) const { void VisualShader::_get_property_list(List<PropertyInfo> *p_list) const { //mode - p_list->push_back(PropertyInfo(Variant::INT, "mode", PROPERTY_HINT_ENUM, "Spatial,CanvasItem,Particles")); + p_list->push_back(PropertyInfo(Variant::INT, "mode", PROPERTY_HINT_ENUM, "Spatial,CanvasItem,Particles,Sky")); //render modes Map<String, String> blend_mode_enums; @@ -1299,8 +1299,8 @@ void VisualShader::_update_shader() const { StringBuilder code; Vector<VisualShader::DefaultTextureParam> default_tex_params; Set<StringName> classes; - List<int> insertion_pos; - static const char *shader_mode_str[Shader::MODE_MAX] = { "spatial", "canvas_item", "particles" }; + Map<int, int> insertion_pos; + static const char *shader_mode_str[Shader::MODE_MAX] = { "spatial", "canvas_item", "particles", "sky" }; global_code += String() + "shader_type " + shader_mode_str[shader_mode] + ";\n"; @@ -1357,6 +1357,11 @@ void VisualShader::_update_shader() const { String global_expressions; for (int i = 0, index = 0; i < TYPE_MAX; i++) { + + if (!ShaderTypes::get_singleton()->get_functions(VisualServer::ShaderMode(shader_mode)).has(func_name[i])) { + continue; + } + for (Map<int, Node>::Element *E = graph[i].nodes.front(); E; E = E->next()) { Ref<VisualShaderNodeGlobalExpression> global_expression = Object::cast_to<VisualShaderNodeGlobalExpression>(E->get().node.ptr()); if (global_expression.is_valid()) { @@ -1373,6 +1378,10 @@ void VisualShader::_update_shader() const { for (int i = 0; i < TYPE_MAX; i++) { + if (!ShaderTypes::get_singleton()->get_functions(VisualServer::ShaderMode(shader_mode)).has(func_name[i])) { + continue; + } + //make it faster to go around through shader VMap<ConnectionKey, const List<Connection>::Element *> input_connections; VMap<ConnectionKey, const List<Connection>::Element *> output_connections; @@ -1396,7 +1405,7 @@ void VisualShader::_update_shader() const { Set<int> processed; Error err = _write_node(Type(i), global_code, global_code_per_node, global_code_per_func, code, default_tex_params, input_connections, output_connections, NODE_ID_OUTPUT, processed, false, classes); ERR_FAIL_COND(err != OK); - insertion_pos.push_back(code.get_string_length()); + insertion_pos.insert(i, code.get_string_length()); code += "}\n"; } @@ -1408,6 +1417,9 @@ void VisualShader::_update_shader() const { final_code += global_expressions; String tcode = code; for (int i = 0; i < TYPE_MAX; i++) { + if (!ShaderTypes::get_singleton()->get_functions(VisualServer::ShaderMode(shader_mode)).has(func_name[i])) { + continue; + } tcode = tcode.insert(insertion_pos[i], global_code_per_func[Type(i)]); } final_code += tcode; @@ -1643,6 +1655,38 @@ const VisualShaderNodeInput::Port VisualShaderNodeInput::ports[] = { { Shader::MODE_PARTICLES, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_TRANSFORM, "emission_transform", "EMISSION_TRANSFORM" }, { Shader::MODE_PARTICLES, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_SCALAR, "time", "TIME" }, + + // Sky, Fragment + { Shader::MODE_SKY, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_BOOLEAN, "at_cubemap_pass", "AT_CUBEMAP_PASS" }, + { Shader::MODE_SKY, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_BOOLEAN, "at_half_res_pass", "AT_HALF_RES_PASS" }, + { Shader::MODE_SKY, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_BOOLEAN, "at_quarter_res_pass", "AT_QUARTER_RES_PASS" }, + { Shader::MODE_SKY, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "eyedir", "EYEDIR" }, + { Shader::MODE_SKY, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "half_res_color", "HALF_RES_COLOR.rgb" }, + { Shader::MODE_SKY, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_SCALAR, "half_res_alpha", "HALF_RES_COLOR.a" }, + { Shader::MODE_SKY, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "light0_color", "LIGHT0_COLOR" }, + { Shader::MODE_SKY, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "light0_direction", "LIGHT0_DIRECTION" }, + { Shader::MODE_SKY, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_BOOLEAN, "light0_enabled", "LIGHT0_ENABLED" }, + { Shader::MODE_SKY, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_SCALAR, "light0_energy", "LIGHT0_ENERGY" }, + { Shader::MODE_SKY, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "light1_color", "LIGHT1_COLOR" }, + { Shader::MODE_SKY, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "light1_direction", "LIGHT1_DIRECTION" }, + { Shader::MODE_SKY, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_BOOLEAN, "light1_enabled", "LIGHT1_ENABLED" }, + { Shader::MODE_SKY, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_SCALAR, "light1_energy", "LIGHT1_ENERGY" }, + { Shader::MODE_SKY, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "light2_color", "LIGHT2_COLOR" }, + { Shader::MODE_SKY, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "light2_direction", "LIGHT2_DIRECTION" }, + { Shader::MODE_SKY, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_BOOLEAN, "light2_enabled", "LIGHT2_ENABLED" }, + { Shader::MODE_SKY, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_SCALAR, "light2_energy", "LIGHT2_ENERGY" }, + { Shader::MODE_SKY, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "light3_color", "LIGHT3_COLOR" }, + { Shader::MODE_SKY, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "light3_direction", "LIGHT3_DIRECTION" }, + { Shader::MODE_SKY, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_BOOLEAN, "light3_enabled", "LIGHT3_ENABLED" }, + { Shader::MODE_SKY, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_SCALAR, "light3_energy", "LIGHT3_ENERGY" }, + { Shader::MODE_SKY, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "position", "POSITION" }, + { Shader::MODE_SKY, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "quarter_res_color", "QUARTER_RES_COLOR.rgb" }, + { Shader::MODE_SKY, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_SCALAR, "quarter_res_alpha", "QUARTER_RES_COLOR.a" }, + { Shader::MODE_SKY, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_SAMPLER, "radiance", "RADIANCE" }, + { Shader::MODE_SKY, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "screen_uv", "vec3(SCREEN_UV, 0.0)" }, + { Shader::MODE_SKY, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "sky_coords", "vec3(SKY_COORDS, 0.0)" }, + { Shader::MODE_SKY, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_SCALAR, "time", "TIME" }, + { Shader::MODE_MAX, VisualShader::TYPE_MAX, VisualShaderNode::PORT_TYPE_TRANSFORM, NULL, NULL }, }; @@ -1986,6 +2030,10 @@ const VisualShaderNodeOutput::Port VisualShaderNodeOutput::ports[] = { { Shader::MODE_PARTICLES, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_VECTOR, "custom", "CUSTOM.rgb" }, { Shader::MODE_PARTICLES, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_SCALAR, "custom_alpha", "CUSTOM.a" }, { Shader::MODE_PARTICLES, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_TRANSFORM, "transform", "TRANSFORM" }, + // Sky, Fragment + { Shader::MODE_SKY, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "color", "COLOR" }, + { Shader::MODE_SKY, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_SCALAR, "alpha", "ALPHA" }, + { Shader::MODE_MAX, VisualShader::TYPE_MAX, VisualShaderNode::PORT_TYPE_TRANSFORM, NULL, NULL }, }; diff --git a/servers/visual/rasterizer_rd/shaders/cubemap_filter.glsl b/servers/visual/rasterizer_rd/shaders/cubemap_filter.glsl index e0b0899dfa..193d0a8a3c 100644 --- a/servers/visual/rasterizer_rd/shaders/cubemap_filter.glsl +++ b/servers/visual/rasterizer_rd/shaders/cubemap_filter.glsl @@ -94,35 +94,36 @@ void main() { // determine which texel this is #ifndef USE_TEXTURE_ARRAY - int level = 0; + // NOTE (macOS/MoltenVK): Do not rename, "level" variable name conflicts with the Metal "level(float lod)" mipmap sampling function name. + int mip_level = 0; if (id.x < (128 * 128)) { - level = 0; + mip_level = 0; } else if (id.x < (128 * 128 + 64 * 64)) { - level = 1; + mip_level = 1; id.x -= (128 * 128); } else if (id.x < (128 * 128 + 64 * 64 + 32 * 32)) { - level = 2; + mip_level = 2; id.x -= (128 * 128 + 64 * 64); } else if (id.x < (128 * 128 + 64 * 64 + 32 * 32 + 16 * 16)) { - level = 3; + mip_level = 3; id.x -= (128 * 128 + 64 * 64 + 32 * 32); } else if (id.x < (128 * 128 + 64 * 64 + 32 * 32 + 16 * 16 + 8 * 8)) { - level = 4; + mip_level = 4; id.x -= (128 * 128 + 64 * 64 + 32 * 32 + 16 * 16); } else if (id.x < (128 * 128 + 64 * 64 + 32 * 32 + 16 * 16 + 8 * 8 + 4 * 4)) { - level = 5; + mip_level = 5; id.x -= (128 * 128 + 64 * 64 + 32 * 32 + 16 * 16 + 8 * 8); } else if (id.x < (128 * 128 + 64 * 64 + 32 * 32 + 16 * 16 + 8 * 8 + 4 * 4 + 2 * 2)) { - level = 6; + mip_level = 6; id.x -= (128 * 128 + 64 * 64 + 32 * 32 + 16 * 16 + 8 * 8 + 4 * 4); } else { return; } - int res = BASE_RESOLUTION >> level; + int res = BASE_RESOLUTION >> mip_level; #else // Using Texture Arrays so all levels are the same resolution int res = BASE_RESOLUTION; - int level = int(id.x / (BASE_RESOLUTION * BASE_RESOLUTION)); - id.x -= level * BASE_RESOLUTION * BASE_RESOLUTION; + int mip_level = int(id.x / (BASE_RESOLUTION * BASE_RESOLUTION)); + id.x -= mip_level * BASE_RESOLUTION * BASE_RESOLUTION; #endif // determine dir / pos for the texel @@ -212,29 +213,29 @@ void main() { vec4 coeffsWeight[3]; for (int iCoeff = 0; iCoeff < 3; iCoeff++) { - coeffsDir0[iCoeff] = data.coeffs[level][0][iCoeff][index]; - coeffsDir1[iCoeff] = data.coeffs[level][1][iCoeff][index]; - coeffsDir2[iCoeff] = data.coeffs[level][2][iCoeff][index]; - coeffsLevel[iCoeff] = data.coeffs[level][3][iCoeff][index]; - coeffsWeight[iCoeff] = data.coeffs[level][4][iCoeff][index]; + coeffsDir0[iCoeff] = data.coeffs[mip_level][0][iCoeff][index]; + coeffsDir1[iCoeff] = data.coeffs[mip_level][1][iCoeff][index]; + coeffsDir2[iCoeff] = data.coeffs[mip_level][2][iCoeff][index]; + coeffsLevel[iCoeff] = data.coeffs[mip_level][3][iCoeff][index]; + coeffsWeight[iCoeff] = data.coeffs[mip_level][4][iCoeff][index]; } for (int iSubTap = 0; iSubTap < 4; iSubTap++) { - // determine sample attributes (dir, weight, level) + // determine sample attributes (dir, weight, mip_level) vec3 sample_dir = frameX * (coeffsDir0[0][iSubTap] + coeffsDir0[1][iSubTap] * theta2 + coeffsDir0[2][iSubTap] * phi2) + frameY * (coeffsDir1[0][iSubTap] + coeffsDir1[1][iSubTap] * theta2 + coeffsDir1[2][iSubTap] * phi2) + frameZ * (coeffsDir2[0][iSubTap] + coeffsDir2[1][iSubTap] * theta2 + coeffsDir2[2][iSubTap] * phi2); float sample_level = coeffsLevel[0][iSubTap] + coeffsLevel[1][iSubTap] * theta2 + coeffsLevel[2][iSubTap] * phi2; float sample_weight = coeffsWeight[0][iSubTap] + coeffsWeight[1][iSubTap] * theta2 + coeffsWeight[2][iSubTap] * phi2; #else - vec4 coeffsDir0 = data.coeffs[level][0][index]; - vec4 coeffsDir1 = data.coeffs[level][1][index]; - vec4 coeffsDir2 = data.coeffs[level][2][index]; - vec4 coeffsLevel = data.coeffs[level][3][index]; - vec4 coeffsWeight = data.coeffs[level][4][index]; + vec4 coeffsDir0 = data.coeffs[mip_level][0][index]; + vec4 coeffsDir1 = data.coeffs[mip_level][1][index]; + vec4 coeffsDir2 = data.coeffs[mip_level][2][index]; + vec4 coeffsLevel = data.coeffs[mip_level][3][index]; + vec4 coeffsWeight = data.coeffs[mip_level][4][index]; for (int iSubTap = 0; iSubTap < 4; iSubTap++) { - // determine sample attributes (dir, weight, level) + // determine sample attributes (dir, weight, mip_level) vec3 sample_dir = frameX * coeffsDir0[iSubTap] + frameY * coeffsDir1[iSubTap] + frameZ * coeffsDir2[iSubTap]; float sample_level = coeffsLevel[iSubTap]; @@ -248,7 +249,7 @@ void main() { sample_dir /= max(abs(sample_dir[0]), max(abs(sample_dir[1]), abs(sample_dir[2]))); sample_level += 0.75 * log2(dot(sample_dir, sample_dir)); #ifndef USE_TEXTURE_ARRAY - sample_level += float(level) / 6.0; // Hack to increase the perceived roughness and reduce upscaling artifacts + sample_level += float(mip_level) / 6.0; // Hack to increase the perceived roughness and reduce upscaling artifacts #endif // sample cubemap color.xyz += textureLod(source_cubemap, normalize(sample_dir), sample_level).xyz * sample_weight; @@ -266,7 +267,7 @@ void main() { id.xy *= uvec2(2, 2); #endif - switch (level) { + switch (mip_level) { case 0: imageStore(dest_cubemap0, ivec3(id), color); #ifdef USE_TEXTURE_ARRAY |